messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
1 value
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ consisting of $n$ integers.\n\nIn one move, you can choose two indices $1 \\le i, j \\le n$ such that $i \\ne j$ and set $a_i := a_j$. You can perform such moves any number of times (possibly, z...
[{"type": "stdin_stdout", "input": "5\n2\n0 3\n4\n2 0 13 1\n3\n3 3 3\n4\n5 10 5 4\n4\n2 1 1 2\n", "output": "YES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "5\n2\n0 3\n4\n2 0 25 1\n3\n3 3 3\n4\n5 10 5 4\n4\n2 1 1 2\n", "output": "YES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "5\n2\n0 3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNiwango-kun, an employee of Dwango Co., Ltd., likes Niconico TV-chan, so he collected a lot of soft toys of her and spread them on the floor.\n\nNiwango-kun has N black rare soft toys of Niconico TV-chan and they are spre...
[{"type": "stdin_stdout", "input": "17 2\n0 5\n2 3\n1 0\n1 2\n3 1\n3 1\n3 5\n5 1\n5 4\n7 4\n8 4\n6 1\n1 2\n6 1\n8 1\n11 0\n11 0\n11 -1\n7 0", "output": "5\n"}, {"type": "stdin_stdout", "input": "17 3\n0 5\n2 3\n1 0\n1 2\n3 1\n3 1\n3 5\n5 1\n5 4\n7 4\n8 4\n6 1\n1 2\n6 1\n8 1\n11 1\n11 0\n11 -1\n7 1", "output": "6\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's introduce the designation <image>, where x is a string, n is a positive integer and operation \" + \" is the string concatenation operation. For example, [abc, 2] = abcabc.\n\nWe'll say that string s can be obtained...
[{"type": "stdin_stdout", "input": "10000000 1\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "10000000\n"}, {"type": "stdin_stdout", "input": "10000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet a and b be some non-negative integers. Let's define strange addition of a and b as following:\n\n 1. write down the numbers one under another and align them by their least significant digit; \n 2. add them up digit ...
[{"type": "stdin_stdout", "input": "2 3\n14\n2 4\n2 1\n1 1\n", "output": "15\n12\n12\n"}, {"type": "stdin_stdout", "input": "2 3\n14\n2 4\n2 1\n2 0\n", "output": "15\n12\n11\n"}, {"type": "stdin_stdout", "input": "2 3\n11\n2 8\n2 2\n2 0\n", "output": "19\n13\n11\n"}, {"type": "stdin_stdout", "input": "2 3\n11\n2 8\n2 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are three integers A_1, A_2, and A_3.\nIf A_1+A_2+A_3 is greater than or equal to 22, print bust; otherwise, print win.\n\n-----Constraints-----\n - 1 \\leq A_i \\leq 13 \\ \\ (i=1,2,3)\n - All values in input are i...
[{"type": "stdin_stdout", "input": "13 13 13\n", "output": "bust\n"}, {"type": "stdin_stdout", "input": "1 10 11\n", "output": "bust\n"}, {"type": "stdin_stdout", "input": "6 13 10\n", "output": "bust\n"}, {"type": "stdin_stdout", "input": "115 -5 1", "output": "bust\n"}, {"type": "stdin_stdout", "input": "-2 -10 -1", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given N points in the xy-plane. You have a circle of radius one and move it on the xy-plane, so as to enclose as many of the points as possible. Find how many points can be simultaneously enclosed at the maximum. ...
[{"type": "stdin_stdout", "input": "3\n6.834942604239939 7.69628\n6.04723928846506 4.859878448884584\n7.439438773048666 6.914350092484497\n6\n7.260024632937995 4.220572316804344\n7.2301779956102665 2.69466\n5.977411451010016 4.7893139817742\n5.771323891387089 5.033018424848772\n7.097650770216692 5.940611762552271\n8.51...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe process of mammoth's genome decoding in Berland comes to its end!\n\nOne of the few remaining tasks is to restore unrecognized nucleotides in a found chain s. Each nucleotide is coded with a capital letter of English ...
[{"type": "stdin_stdout", "input": "252\n???????GCG??T??TT?????T?C???C?CCG???GA???????AC??A???AAC?C?CC??CCC??A??TA?CCC??T???C??CA???CA??G????C?C?C????C??C??A???C?T????C??ACGC??CC?A?????A??CC?C??C?CCG?C??C??A??CG?A?????A?CT???CC????CCC?CATC?G??????????A???????????????TCCCC?C?CA??AC??GC????????\n", "output": "AAAAAAAGCGA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe consider a positive integer perfect, if and only if the sum of its digits is exactly $10$. Given a positive integer $k$, your task is to find the $k$-th smallest perfect positive integer.\n\n\n-----Input-----\n\nA sing...
[{"type": "stdin_stdout", "input": "10000\n", "output": "10800100\n"}, {"type": "stdin_stdout", "input": "9999\n", "output": "10800010\n"}, {"type": "stdin_stdout", "input": "9139\n", "output": "10134010\n"}, {"type": "stdin_stdout", "input": "9859\n", "output": "10422001\n"}, {"type": "stdin_stdout", "input": "8888\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPasha decided to invite his friends to a tea party. For that occasion, he has a large teapot with the capacity of w milliliters and 2n tea cups, each cup is for one of Pasha's friends. The i-th cup can hold at most a_{i} ...
[{"type": "stdin_stdout", "input": "4 1000000000\n1 1 1 1 2 2 2 2\n", "output": "12.0000000000\n"}, {"type": "stdin_stdout", "input": "4 1000000000\n1 1 1 1 1 1 1 1\n", "output": "6.0000000000\n"}, {"type": "stdin_stdout", "input": "5 15\n2 3 4 1 2 4 5 3 5 10\n", "output": "15.0000000000\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConvenience store Deven Eleven is planning to open its first store in Aizuwakamatsu City to expand its business. There are already many other convenience stores in Aizuwakamatsu, so the place to open a new store is likely...
[{"type": "stdin_stdout", "input": "10 12\n6\n2 1\n6 1\n6 2\n1 5\n0 6\n5 6\n2\n1 3\n5 3\n11 6\n6\n3 3\n3 4\n6 1\n1 1\n1 6\n5 6\n2\n0 3\n6 4\n0 0", "output": "6\n18\n"}, {"type": "stdin_stdout", "input": "10 12\n6\n1 1\n6 1\n6 2\n1 5\n0 6\n5 6\n2\n1 3\n5 3\n11 6\n6\n3 3\n3 4\n6 2\n1 1\n1 5\n1 6\n2\n0 3\n6 4\n0 0", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou play a computer game. In this game, you lead a party of $m$ heroes, and you have to clear a dungeon with $n$ monsters. Each monster is characterized by its power $a_i$. Each hero is characterized by his power $p_i$ an...
[{"type": "stdin_stdout", "input": "2\n6\n2 3 11 14 1 8\n2\n3 2\n000 1\n5\n3 5 100 2 3\n2\n30 5\n90 1\n", "output": "-1\n-1\n"}, {"type": "stdin_stdout", "input": "2\n6\n1 3 11 14 1 10\n2\n3 2\n100 1\n5\n3 5 100 2 3\n2\n30 5\n11 1\n", "output": "5\n-1\n"}, {"type": "stdin_stdout", "input": "2\n6\n1 3 11 16 1 10\n2\n3 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this problem MEX of a certain array is the smallest positive integer not contained in this array.\n\nEveryone knows this definition, including Lesha. But Lesha loves MEX, so he comes up with a new problem involving MEX...
[{"type": "stdin_stdout", "input": "100\n1 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 29 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 57 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 85 86 87 88 89 90 91 92 93 94 95 96 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs a New Year's gift, Dolphin received a string s of length 19.\nThe string s has the following format: `[five lowercase English letters],[seven lowercase English letters],[five lowercase English letters]`.\nDolphin wants...
[{"type": "stdin_stdout", "input": "gaiku,atcoder,tasks", "output": "gaiku atcoder tasks\n"}, {"type": "stdin_stdout", "input": "abgde,fchihgf,edcba", "output": "abgde fchihgf edcba\n"}, {"type": "stdin_stdout", "input": "ha,pypnewyear,enjoy", "output": "ha pypnewyear enjoy\n"}, {"type": "stdin_stdout", "input": "gaiku...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSeiji Maki doesn't only like to observe relationships being unfolded, he also likes to observe sequences of numbers, especially permutations. Today, he has his eyes on almost sorted permutations.\n\nA permutation $a_1, a_...
[{"type": "stdin_stdout", "input": "1\n264 695448956957126051\n", "output": "1 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 29 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 57 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 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.\n\nVanya will enter passw...
[{"type": "stdin_stdout", "input": "20 5\nvSyC787KlIL8kZ2Uv5sw\nWKWOP\n7i8J3E8EByIq\nNW2VyGweL\nmyR2sRNu\nmXusPP0\nf4jgGxra\n4wHRzRhOCpEt\npPz9kybGb\nOtSpePCRoG5nkjZ2VxRy\nwHYsSttWbJkg\nKBOP9\nQfiOiFyHPPsw3GHo8J8\nxB8\nqCpehZEeEhdq\niOLjICK6\nQ91\nHmCsfMGTFKoFFnv238c\nJKjhg\ngkEUh\nKBOP9\n", "output": "3 11\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Berland a bus travels along the main street of the capital. The street begins from the main square and looks like a very long segment. There are n bus stops located along the street, the i-th of them is located at the ...
[{"type": "stdin_stdout", "input": "6\n2 3 5 7 9 11\n11\n1 2 2 3 3 4 4 5 5 5 6\n", "output": " 18\n"}, {"type": "stdin_stdout", "input": "6\n2 3 5 7 11 13\n9\n1 2 2 3 3 4 5 5 6\n", "output": " 16\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis week Arkady wanted to cook some pancakes (to follow ancient traditions) and make a problem about that. But then he remembered that one can't make a problem about stacking pancakes without working at a specific IT com...
[{"type": "stdin_stdout", "input": "3\n6\n0 3 0 0 1 3\n10\n0 0 0 1 0 5 0 0 0 2\n3\n0 0 0\n", "output": "\n1 1 0 1 1 1 \n0 1 1 1 1 1 0 0 1 1 \n0 0 0 \n"}, {"type": "stdin_stdout", "input": "3\n6\n0 3 0 0 1 3\n10\n0 0 0 1 0 5 0 0 0 2\n3\n0 0 0\n", "output": "1 1 0 1 1 1 \n0 1 1 1 1 1 0 0 1 1 \n0 0 0 \n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMs. Iyo Kiffa-Australis has a balance and only two kinds of weights to measure a dose of medicine.\n\nFor example, to measure 200mg of aspirin using 300mg weights and 700mg weights, she can put one 700mg weight on the sid...
[{"type": "stdin_stdout", "input": "700 300 200\n993 200 300\n244 200 500\n275 111 330\n275 010 385\n694 375 1747\n3 1 10010\n0 0 0", "output": "1 3\n100 495\n25 28\n21 55\n1 11\n163 297\n3336 2\n"}, {"type": "stdin_stdout", "input": "700 300 200\n500 283 300\n349 200 500\n275 110 330\n275 010 385\n1067 344 4002\n3 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n TV shows you want to watch. Suppose the whole time is split into equal parts called \"minutes\". The i-th of the shows is going from l_i-th to r_i-th minute, both ends inclusive.\n\nYou need a TV to watch a TV...
[{"type": "stdin_stdout", "input": "10 798547896 459313948\n40312491 40315265\n40299842 40315264\n40296035 40315263\n40282844 40315262\n40304824 40315261\n40280414 40315260\n40299203 40315259\n40301967 40315258\n40276169 40315257\n40286575 40315256\n", "output": "236433977\n"}, {"type": "stdin_stdout", "input": "4 2882...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPrint the K-th element of the following sequence of length 32:\n\n\n1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51\n\nConstraints\n\n* 1 \\leq K \\leq 32\n* All values in...
[{"type": "stdin_stdout", "input": "16", "output": "14\n"}, {"type": "stdin_stdout", "input": "24", "output": "15\n"}, {"type": "stdin_stdout", "input": "32", "output": "51\n"}, {"type": "stdin_stdout", "input": "-22", "output": "2\n"}, {"type": "stdin_stdout", "input": "-27", "output": "1\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the spring of 2014, a student successfully passed the university and started living alone. The problem here is what to do with the supper. He decided to plan a supper for the next N days.\n\nHe wants to maximize the to...
[{"type": "stdin_stdout", "input": "3 1 -10\n-19\n-10\n-10", "output": "-27\n"}, {"type": "stdin_stdout", "input": "2 1 -10\n-19\n-10\n-10", "output": "-19\n"}, {"type": "stdin_stdout", "input": "3 1 -19\n-19\n-10\n-10", "output": "-39\n"}, {"type": "stdin_stdout", "input": "3 1 -19\n-19\n-10\n-18", "output": "-47\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebrandingΒ β€” an active marketing strategy, that includes a set of measures to change either the brand...
[{"type": "stdin_stdout", "input": "10 10\nlellelleel\ne l\ne l\ne l\ne l\ne l\ne e\nl l\nl e\nl l\ne e\n", "output": "lellelleel\n"}, {"type": "stdin_stdout", "input": "10 10\nlellelleel\ne l\ne l\ne l\ne l\ne l\ne e\nl l\nl e\nl l\ne e\n", "output": "lellelleel\n"}, {"type": "stdin_stdout", "input": "10 10\nlellellee...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVictor and Peter are playing hide-and-seek. Peter has hidden, and Victor is to find him. In the room where they are playing, there is only one non-transparent wall and one double-sided mirror. Victor and Peter are points ...
[{"type": "stdin_stdout", "input": "-7366 1446\n-7727 -1428\n-2680 -3822 -5191 -5553\n-7304 -6313 -9229 1377\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "-4752 -3262\n-4582 6436\n-8997 -6490 -4630 1426\n-9865 -6697 -2371 -5622\n", "output": "YES"}, {"type": "stdin_stdout", "input": "-4752 -3262\n-4582 643...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLimak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of hi identical blocks. For clarification see picture for the first sample.\n\nL...
[{"type": "stdin_stdout", "input": "170\n1 2 1 2 1 1 1 1 2 3 2 1 1 2 2 1 2 1 2 1 1 2 3 3 2 1 1 1 1 1 1 1 1 2 1 2 3 3 2 1 2 2 1 2 3 2 1 1 2 3 2 1 2 1 1 1 2 3 3 2 1 2 1 2 1 1 1 2 1 2 1 1 2 2 1 1 2 1 2 2 1 2 1 2 2 1 2 1 2 3 2 1 1 2 3 4 4 3 2 1 2 1 2 1 2 3 3 2 1 2 1 1 1 1 1 1 1 2 2 1 1 2 1 1 1 1 2 1 1 2 3 2 1 2 2 1 2 1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a string $s$ of length $n$ and integer $k$ ($1 \\le k \\le n$). The string $s$ has a level $x$, if $x$ is largest non-negative integer, such that it's possible to find in $s$: $x$ non-intersecting (non-overlapping)...
[{"type": "stdin_stdout", "input": "92 5\nwwwwwwwwwwwwwwwwwgggggggggggggggbbbbyyyyyyyyyyyyyyjjjjjjjjjjjuuuuuuuuaaaaaaaaaaaafooooooooig\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "92 5\nwwwwwwwwwwwwwwwwwgggggggggggggggbbbbyyyyyyyyyyyyyyjjjjjjjjjjjuuuuuuuuaaaaaaaaaaaafooooooooig\n", "output": "3\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are the planning manager of an animation production company. What animation production companies produce these days is not limited to animation itself. Related products, such as figures of characters and character son...
[{"type": "stdin_stdout", "input": "4\nakzakr 2 1 8\nfnmyi 5 2 3 4 6 9\ntsnukk 5 2 3 4 7 9\nyskwcnt 6 3 4 7 8 9 10\n4\nakzakr 1 2\nfnmyi 3 10 11 12\ntsnukk 2 1 8\nyskwcnt 2 1 8\n5\nknmmdk 2 13 19\nakmhmr 4 13 15 19 22\nmksyk 6 3 7 12 13 15 19\nskrkyk 3 1 4 8\ntmemm 3 1 17 24\n5\nknmmdk 5 5 6 16 18 26\nakmhmr 9 3 4 7 11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRyouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hea...
[{"type": "stdin_stdout", "input": "100 100\n28 28 28 34 28 28 28 40 28 28 28 28 28 28 28 28 28 28 28 28 28 28 47 28 28 28 28 28 28 28 28 28 28 28 28 28 19 28 28 28 28 28 28 28 28 28 28 28 28 28 46 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 49 28 28 28 28 28 28 28 31 28 28 28 28 28 28 28 28 28 28 28 28 28...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya the programmer lives in the middle of the Programming subway branch. He has two girlfriends: Dasha and Masha, who live at the different ends of the branch, each one is unaware of the other one's existence.\n\nWhen V...
[{"type": "stdin_stdout", "input": "999999 1000000\n", "output": "Equal\n"}, {"type": "stdin_stdout", "input": "1000000 999993\n", "output": "Masha\n"}, {"type": "stdin_stdout", "input": "999997 1000000\n", "output": "Dasha\n"}, {"type": "stdin_stdout", "input": "459973 1000000\n", "output": "Dasha\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe flag of Berland is such rectangular field n Γ— m that satisfies following conditions:\n\n Flag consists of three colors which correspond to letters 'R', 'G' and 'B'. Flag consists of three equal in width and height s...
[{"type": "stdin_stdout", "input": "15 28\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's consider equation:x^2 + s(x)Β·x - n = 0, \n\nwhere x, n are positive integers, s(x) is the function, equal to the sum of digits of number x in the decimal number system.\n\nYou are given an integer n, find the small...
[{"type": "stdin_stdout", "input": "160000001600000000\n", "output": "400000000\n"}, {"type": "stdin_stdout", "input": "250000002500000000\n", "output": "500000000\n"}, {"type": "stdin_stdout", "input": "360000003600000000\n", "output": "600000000\n"}, {"type": "stdin_stdout", "input": "490000004900000000\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N boxes arranged in a circle. The i-th box contains A_i stones.\n\nDetermine whether it is possible to remove all the stones from the boxes by repeatedly performing the following operation:\n\n* Select one box. ...
[{"type": "stdin_stdout", "input": "5\n12 26 12 10 8", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n6 11 12 10 8", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n6 16 12 10 8", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n6 26 12 10 8", "output": "NO\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe $\\text{$gcdSum$}$ of a positive integer is the $gcd$ of that integer with its sum of digits. Formally, $\\text{$gcdSum$}(x) = gcd(x, \\text{ sum of digits of } x)$ for a positive integer $x$. $gcd(a, b)$ denotes the ...
[{"type": "stdin_stdout", "input": "3\n17\n110\n182\n", "output": "18\n110\n183\n"}, {"type": "stdin_stdout", "input": "3\n17\n110\n359\n", "output": "18\n110\n360\n"}, {"type": "stdin_stdout", "input": "3\n17\n100\n359\n", "output": "18\n102\n360\n"}, {"type": "stdin_stdout", "input": "3\n33\n100\n359\n", "output": "3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system.\n\nWe are going to put drops of ink on the paper. A drop comes in three different...
[{"type": "stdin_stdout", "input": "2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n1,4,1", "output": "75\n5\n"}, {"type": "stdin_stdout", "input": "2,5,3\n1,6,3\n3,4,2\n4,5,2\n3,6,3\n2,4,1", "output": "73\n5\n"}, {"type": "stdin_stdout", "input": "2,5,3\n3,6,1\n2,4,2\n4,5,2\n3,6,3\n1,4,1", "output": "76\n5\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. A wants to get to the destination on the Yamanote line.\n\nAfter getting on the train, Mr. A gets up for a minute and sleeps for b minutes repeatedly. It is c minutes after boarding to the destination, and you can get...
[{"type": "stdin_stdout", "input": "196 2 133", "output": "133\n"}, {"type": "stdin_stdout", "input": "128 12 16", "output": "16\n"}, {"type": "stdin_stdout", "input": "134 22 13", "output": "13\n"}, {"type": "stdin_stdout", "input": "134 22 21", "output": "21\n"}, {"type": "stdin_stdout", "input": "50 40 68", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDreamoon likes to play with sets, integers and <image>. <image> is defined as the largest positive integer that divides both a and b.\n\nLet S be a set of exactly four distinct integers greater than 0. Define S to be of r...
[{"type": "stdin_stdout", "input": "3081 11\n", "output": "203335\n11 22 33 55\n77 88 99 121\n143 154 165 187\n209 220 231 253\n275 286 297 319\n341 352 363 385\n407 418 429 451\n473 484 495 517\n539 550 561 583\n605 616 627 649\n671 682 693 715\n737 748 759 781\n803 814 825 847\n869 880 891 913\n935 946 957 979\n1001 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, y...
[{"type": "stdin_stdout", "input": "100 20 100 10202\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwhwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwww\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 20 100 19121\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwhwhhwhwwhhwhwhwwwhwwwwhwhwwww...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a weighted undirected graph. The vertices are enumerated from 1 to n. Your task is to find the shortest path between the vertex 1 and the vertex n.\n\nInput\n\nThe first line contains two integers n and m (2...
[{"type": "stdin_stdout", "input": "10 10\n1 5 12\n2 4 140\n2 10 149\n3 6 154\n3 7 17\n3 8 226\n3 10 132\n4 10 55\n5 8 33\n7 8 173\n", "output": "1 5 8 7 3 10\n"}, {"type": "stdin_stdout", "input": "10 10\n1 5 12\n2 4 140\n2 10 149\n3 6 154\n2 7 17\n3 8 226\n3 10 136\n4 10 55\n5 8 33\n7 8 173\n", "output": "1 5 8 7 2 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA set of four prime numbers arranged like (a, a + 2, a + 6, a + 8) is called a quadruplet prime number. Of the four prime numbers that make up a quadruplet prime, the largest number is called the size of the quadruplet pr...
[{"type": "stdin_stdout", "input": "13\n14\n15\n16\n17\n18\n19\n20\n10010\n0", "output": "13\n13\n13\n13\n13\n13\n19\n19\n9439\n"}, {"type": "stdin_stdout", "input": "13\n14\n15\n16\n17\n36\n19\n20\n10000\n0", "output": "13\n13\n13\n13\n13\n19\n19\n19\n9439\n"}, {"type": "stdin_stdout", "input": "13\n14\n15\n16\n27\n36...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet $n$ be a positive integer. Let $a, b, c$ be nonnegative integers such that $a + b + c = n$.\n\nAlice and Bob are gonna play rock-paper-scissors $n$ times. Alice knows the sequences of hands that Bob will play. However...
[{"type": "stdin_stdout", "input": "7\n2\n1 1 0\nRR\n2\n2 0 0\nSS\n2\n2 0 0\nRR\n3\n1 2 0\nRRR\n3\n2 1 0\nRRR\n1\n1 0 0\nP\n1\n1 0 0\nS\n", "output": "YES\nPR\nYES\nRR\nNO\nYES\nPPR\nNO\nNO\nYES\nR\n"}, {"type": "stdin_stdout", "input": "7\n2\n1 1 0\nRR\n2\n2 0 0\nSS\n2\n2 0 0\nRR\n3\n1 2 0\nRRR\n3\n2 1 0\nRRR\n1\n1 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke loves \"paper cutting\": he cuts out characters from a newspaper headline and rearranges them to form another string.\nHe will receive a headline which contains one of the strings S_1,...,S_n tomorrow.\nHe is excite...
[{"type": "stdin_stdout", "input": "3\ncbaa\ndaacc\nacacac\n", "output": "aac\n"}, {"type": "stdin_stdout", "input": "3\ncacb\nccabe\n`cacbc", "output": "abcc\n"}, {"type": "stdin_stdout", "input": "3\ncaaa\ndaacc\nacacac", "output": "aac\n"}, {"type": "stdin_stdout", "input": "3\ncaca\ncca`d\nacacac", "output": "acc\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are the gym teacher in the school.\n\nThere are $n$ students in the row. And there are two rivalling students among them. The first one is in position $a$, the second in position $b$. Positions are numbered from $1$ t...
[{"type": "stdin_stdout", "input": "22\n100 100 100 1\n100 100 1 100\n100 0 100 1\n100 0 1 100\n2 0 1 2\n2 100 1 2\n2 0 2 1\n2 100 2 1\n100 0 1 2\n100 98 1 2\n100 97 1 2\n100 0 2 1\n100 98 2 1\n100 97 2 1\n100 0 99 100\n100 98 99 100\n100 97 99 100\n100 0 100 99\n100 98 100 99\n100 97 100 99\n100 0 13 37\n100 0 66 11\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProfessor Abacus has just built a new computing engine for making numerical tables. It was designed to calculate the values of a polynomial function in one variable at several points at a time. With the polynomial functio...
[{"type": "stdin_stdout", "input": "2\n1.0\n4.0\n14.21446074361601\n16.0\n25.0\n1\n-30.5893962764\n6.055835197262627\n39.3853798058\n74.3727663177\n0\n42.56611822314588\n79.5420238202\n28.0282396675\n-30.3627807522\n-49.34987576252381\n-25.34819013612247\n7.58575761381\n0\n-21.42163030108298\n-47.94509062430888\n-23.35...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nXenia is a girl being born a noble. Due to the inflexibility and harshness of her family, Xenia has to find some ways to amuse herself.\n\n<image>\n\nRecently Xenia has bought n_r red gems, n_g green gems and n_b blue gem...
[{"type": "stdin_stdout", "input": "5\n2 2 3\n7 8\n6 3\n3 1 4\n1 1 1\n1\n1\n1000000000\n2 2 2\n0 2\n5 4\n6 7\n2 2 2\n1 2\n3 4\n6 7\n3 4 1\n3 2 1\n7 3 3 4\n12\n", "output": "14\n1999999996000000002\n24\n24\n122\n"}, {"type": "stdin_stdout", "input": "5\n2 2 3\n7 8\n6 3\n3 0 4\n1 1 1\n1\n1\n1000000000\n2 2 2\n0 2\n5 4\n6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i.\n\nMr. Takahashi, the shop owner, has decided on the followi...
[{"type": "stdin_stdout", "input": "15\n4\n1\n4\n1\n3\n18\n4\n12\n5\n3\n6\n8\n15\n12\n9", "output": "43\n"}, {"type": "stdin_stdout", "input": "15\n4\n1\n4\n1\n3\n18\n4\n12\n5\n3\n3\n8\n15\n12\n9", "output": "42\n"}, {"type": "stdin_stdout", "input": "15\n4\n1\n4\n1\n3\n31\n4\n8\n5\n3\n6\n8\n15\n7\n9", "output": "46\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\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": "100 100\n82 51 81 14 37 17 78 123 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 3 76 80 60 100 49 70 59 72 8 38 75 45 97 71 14 76 54 81 4 59 46 39 29 92 3 49 22 53 99 59 52 74 31 92 43 42 23 44 9 82 47 7 40 12 16 3 55 37 85 46 22 159 52 98 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmugae has a sentence consisting of $n$ words. He want to compress this sentence into one word. Amugae doesn't like repetitions, so when he merges two words into one word, he removes the longest prefix of the second word ...
[{"type": "stdin_stdout", "input": "9\nL M5 M5D M5DAYBl0r6gmttCTR M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAc M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVgg0xe M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe09re\n", "output": "LM5D...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n incoming messages for Vasya. The i-th message is going to be received after t_{i} minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each ...
[{"type": "stdin_stdout", "input": "108 576 610 844 573\n242 134 45 515 430 354 405 179 174 366 155 4 300 176 96 36 508 70 75 316 118 563 55 340 128 214 138 511 507 437 454 478 341 443 421 573 270 362 208 107 256 471 436 378 336 507 383 352 450 411 297 34 179 551 119 524 141 288 387 9 283 241 304 214 503 559 416 447 49...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a plan view consisting of 12 vertical and 12 horizontal squares showing the terrain. Each square is painted white or black. White represents the sea and black represents the land. When two black squares touch eac...
[{"type": "stdin_stdout", "input": "111100001111\n111000001111\n110000001110\n100000001111\n000100010000\n010000111010\n000001111100\n100011111110\n010101111100\n111000111000\n111100010000\n000000100000\n\n110001111100\n110010001010\n010010000001\n010000000001\n010000000110\n010000111000\n010000000000\n010000010010\n01...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFlatland is inhabited by pixels of three colors: red, green and blue. We know that if two pixels of different colors meet in a violent fight, only one of them survives the fight (that is, the total number of pixels decrea...
[{"type": "stdin_stdout", "input": "2147483630 2147483642 2147483610\n", "output": " 2147483630\n"}, {"type": "stdin_stdout", "input": "1944219055 454183506 1369298327\n", "output": " 1944219055\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMasa Kita, who entered the University of Tokyo, joined a circle called TSG (University of Tokyo Super Gamers).\n\nThis circle exhibits games at the Komaba Festival every year, and Masa Kita decided to create and display t...
[{"type": "stdin_stdout", "input": "3\n......\n......\n......\n......\n......\n......\n......\n......\n.RGB..\nRGOP..\nRGBPB.\nRGBPP.\nGBRGYP\nGBRRYP\nBGGRBB\nBPRGYY\nGGPRRY\nBYPPRB\nYGGGPB\nGYYYPR\nYRBRBR\nYBRBRB\nBRBRBR\nBRBRBR\n......\n......\n......\n......\n......\n......\n......\n......\n.....-\n......\n..OO..\n....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider the following game:\n\n* The game is played using a row of N squares and many stones.\n* First, a_i stones are put in Square i\\ (1 \\leq i \\leq N).\n* A player can perform the following operation as many time a...
[{"type": "stdin_stdout", "input": "36 17", "output": "644469316\n"}, {"type": "stdin_stdout", "input": "36 18", "output": "653755501\n"}, {"type": "stdin_stdout", "input": "36 22", "output": "667405665\n"}, {"type": "stdin_stdout", "input": "59 22", "output": "723249007\n"}, {"type": "stdin_stdout", "input": "49 17", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment.\n\nAmr has n different types of chemicals. Each chemical i has an initial volume of a_{i} liters. For this experiment...
[{"type": "stdin_stdout", "input": "20\n1 2 3 4 6 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 100000\n", "output": "113\n"}, {"type": "stdin_stdout", "input": "20\n1 2 3 4 6 8 16 32 64 128 256 512 1024 2048 3647 8192 16384 32768 65536 100000\n", "output": "124\n"}, {"type": "stdin_stdout", "input": "20...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer N.\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\nFind the probability that a is odd.\n\n-----Constraints-----\n - 1 \\leq N \\leq 100\n\n-----In...
[{"type": "stdin_stdout", "input": "-1297", "output": "0.499614494988\n"}, {"type": "stdin_stdout", "input": "-1739", "output": "0.499712478436\n"}, {"type": "stdin_stdout", "input": "-2609", "output": "0.499808355692\n"}, {"type": "stdin_stdout", "input": "-4637", "output": "0.499892171663\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N integers. The i-th number is A_i.\n\\{A_i\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\\leq i < j \\leq N.\n\\{A_i\\} is said to be setwise coprime when \\{A_i\\}...
[{"type": "stdin_stdout", "input": "3\n6 10 15\n", "output": "setwise coprime\n"}, {"type": "stdin_stdout", "input": "3\n17 10 15", "output": "setwise coprime\n"}, {"type": "stdin_stdout", "input": "3\n26 10 15", "output": "setwise coprime\n"}, {"type": "stdin_stdout", "input": "3\n7 10 31", "output": "pairwise coprime...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's define the sum of two permutations p and q of numbers 0, 1, ..., (n - 1) as permutation [Image], where Perm(x) is the x-th lexicographically permutation of numbers 0, 1, ..., (n - 1) (counting from zero), and Ord(p)...
[{"type": "stdin_stdout", "input": "84\n83 4 68 34 24 2 48 38 22 51 5 62 31 67 66 53 49 70 9 71 46 41 30 8 50 17 28 79 15 80 32 43 14 74 29 42 81 60 56 65 23 0 77 76 58 78 1 11 37 27 75 35 18 73 54 20 57 33 36 6 61 69 64 55 39 10 3 45 13 26 59 82 21 25 63 52 16 44 47 72 19 12 7 40\n63 41 80 52 36 45 17 69 22 66 37 21 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.\n\nHe wants ...
[{"type": "stdin_stdout", "input": "18 10\n10000000 100000000 1000000000 -10000000 -100000000 -1000000000 -10000000 -100000000 -1000000000 -10000000 -100000000 -1000000000 10000000 100000000 1000000000 10000000 100000000 1000000000\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "18 10\n10000000 100000000 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob are fighting over who is a superior debater. However they wish to decide this in a dignified manner. \nSo they decide to fight in the Battle of Words. \n\nIn each game both get to speak a sentence. Because t...
[{"type": "stdin_stdout", "input": "10\nkdeuqunsa vylhazxgf filexjohs dxretqfqh ohbcgirwp cwayrtksq wqnfyvohb ymnjjkowo aqhlwnahs vlyjekfjs bbrqrvfmc ymlsmjoyl vjwpaipqo uzohwcqqb bgjkfkbkj esqcfdgkr crweugucm tfncjlbpo rnoadvokf xpzksknrl hqmxnzuof hlggnuusu lzvdzzalu jjsnrslhf tkhfpahcl gmgshdaia eczdyngqz ftumhnais ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn the great island of Baltia, there live N people, numbered from 1 to N. There are exactly M pairs of people that are friends with each other. The people of Baltia want to organize a successful party, but they have very ...
[{"type": "stdin_stdout", "input": "20 57\n13 14\n12 20\n18 3\n17 20\n15 9\n18 13\n12 19\n2 4\n9 2\n12 11\n14 1\n16 11\n11 14\n16 4\n16 15\n11 19\n15 4\n10 15\n12 5\n9 3\n10 2\n10 4\n20 19\n14 7\n19 2\n5 8\n6 14\n4 17\n2 17\n17 9\n13 9\n19 9\n18 8\n12 16\n18 5\n7 1\n8 3\n11 20\n6 13\n20 5\n13 8\n17 19\n7 6\n9 11\n18 9\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou might have heard about the next game in Lara Croft series coming out this year. You also might have watched its trailer. Though you definitely missed the main idea about its plot, so let me lift the veil of secrecy.\n...
[{"type": "stdin_stdout", "input": "636553724 546535019 115079316355948443\n", "output": "425992073 546535018\n"}, {"type": "stdin_stdout", "input": "548492800 434105920 179638683192075937\n", "output": "134679777 434105920\n"}, {"type": "stdin_stdout", "input": "595261150 794915864 332353903994901365\n", "output": "17...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTyndex is again well ahead of the rivals! The reaction to the release of Zoozle Chrome browser was the release of a new browser Tyndex.Brome!\n\nThe popularity of the new browser is growing daily. And the secret is not ev...
[{"type": "stdin_stdout", "input": "20 10\niwbiucrjoj\nqvjewvdrgwgc\newwqyhtdzakryafqaacimthycyasyb\ncuoscayekvbsqokyfdmjnojkjennf\nhkuv\njtdgbespjdtbc\ngeulitsrlqihoujvwuobnfospq\nzphnlqxacchxhyeehnpfwdjnwvj\nxicsaoyfgtdbwqfrdgaiyn\natgshewfkuxaipizcdev\nvp\nyblkfmqsj\nyevxolvycyrrooosberqzrabefdckg\nrytykrlgttc\nafph...
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\nPetya was late for the lesson too. The teacher gave him an additional task. For some array a Petya should find the number of different ways to select non-empty subset of elements from it in such a way that their product i...
[{"type": "stdin_stdout", "input": "20\n20 34 51 40 70 64 14 30 24 20 6 1 70 28 38 43 9 60 31 69\n", "output": "2047\n"}, {"type": "stdin_stdout", "input": "20\n20 34 51 40 70 64 14 30 24 20 6 1 70 28 38 43 9 60 31 69\n", "output": "2047\n"}, {"type": "stdin_stdout", "input": "18\n22 41 40 8 36 48 23 5 58 12 26 44 53 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call a number k-good if it contains all digits not exceeding k (0, ..., k). You've got a number k and an array a containing n numbers. Find out how many k-good numbers are in a (count each number every time it occur...
[{"type": "stdin_stdout", "input": "10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "10 6\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n1234560\n", "output": "10\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nZhinΓΌ was a child of the Emperor, but he was weaving the machine even if he opened it at the request of his father.\n\nIt was a pleasure of the Emperor to wear clothes made of a splendid cloth called Unnishiki woven by Zh...
[{"type": "stdin_stdout", "input": "5\n0 4 0 2 9 3 4 8 2 -1\n3 8 -1 0 0 3 1 2 17 54\n1 2 1 2 41 2 17 21 11 0\n-2 2 14 24 0 21 1 14 20 4\n7 6 30 0 10 1 22 -2 8 -1", "output": "NG\nNG\nNG\nOK\nNG\n"}, {"type": "stdin_stdout", "input": "5\n0 4 -1 2 7 3 4 8 2 -1\n3 5 -1 0 0 3 0 6 8 62\n1 4 1 0 76 4 17 2 11 0\n-2 2 14 24 -1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAtaru Oafoot of Aizu Gakuen University High School decided to play with a slot machine.\n\nWhen you insert a medal on this machine, three reels will start spinning and each reel will stop automatically. In a normal game (...
[{"type": "stdin_stdout", "input": "3 2 30 3 41 226\n9 0 18 4 20 118\n5 5 12 0 15 203\n13 4 19 2 22 197\n7 4 24 4 17 209\n0 0 0 0 0 0", "output": "172\n795\n410\n1199\n617\n"}, {"type": "stdin_stdout", "input": "3 2 30 3 41 226\n9 0 36 4 20 118\n5 5 12 0 18 203\n13 4 19 2 22 197\n1 4 42 4 17 209\n0 0 0 0 0 0", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSanta Claus has n candies, he dreams to give them as gifts to children.\n\nWhat is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of c...
[{"type": "stdin_stdout", "input": "1000\n", "output": "44\n1 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 54 \n"}, {"type": "stdin_stdout", "input": "990\n", "output": "44\n1 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 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has $6$ strings and an infinite number of frets numbered from $1$. Fretting the fret number $j$ on the ...
[{"type": "stdin_stdout", "input": "58260522 32004256 2436426 24979445 61648772 23690081\n10\n582107247 906728404 411434947 673536177 411497300 488012525 1035611341 800305059 992325267 138720156\n", "output": "837678839\n"}, {"type": "stdin_stdout", "input": "58260522 32004256 2436426 24979445 12477970 11891566\n10\n58...
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$ and two integers $m$ and $k$.\n\nYou can choose some subarray $a_l, a_{l+1}, \\dots, a_{r-1}, a_r$. \n\nThe cost of subarray $a_l, a_{l+1}, \\dots, a_{r-1}, a_r$ is equal to...
[{"type": "stdin_stdout", "input": "44 2 531595322\n926215961 -385821837 -278841122 -422772006 -509196878 -81824369 -101501043 -33095577 -520514931 402836017 48602657 881104200 -110528684 52550046 -208588735 -814534121 -548420443 410430115 -636402169 -848516069 -70639158 775203498 -679440929 -427359667 33598904 6568726...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got an n Γ— m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased ...
[{"type": "stdin_stdout", "input": "10 10\n20 53 6 97 74 12 92 48 13 97\n157 47 32 75 21 69 75 95 54 1\n97 36 1 41 87 1 23 39 44 27\n97 73 1 1 26 6 3 48 69 5\n70 93 42 35 5 12 22 33 29 13\n96 8 13 69 40 91 5 19 16 33\n61 92 54 82 60 24 63 64 59 65\n76 44 60 37 29 16 50 74 59 59\n77 58 95 30 52 25 34 2 49 92\n37 65 12 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya is developing his own programming language VPL (Vasya Programming Language). Right now he is busy making the system of exceptions. He thinks that the system of exceptions must function like that.\n\nThe exceptions a...
[{"type": "stdin_stdout", "input": "21\n try \n try \n try \n try \n try \n try \n try \n try \n try \n try \n throw( qtSMze) \ncatch(LY,\"x3 j\")\ncatch(hgSAFgbMGx,\"moByu\")\ncatch(LmydVQgv,\"hbZl\")\ncatch(oK,\"B6OZx qy\")\ncatch(rrtnRQB,\"7VFkQMv\")\ncatch(CASqQXaz,\"d9oci1Kx\")\ncatch(CTCzs...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nThere are $ M $ type characters. Use them to create a string of length $ N $. How many strings are used that have $ K $ or more? Find too much divided by $ 998244353 $.\n\nHere, the difference between two strin...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 1001", "output": "824796085\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 0001", "output": "276774580\n"}, {"type": "stdin_stdout", "input": "1000000000000000001 1000000000000000000 0001", "output": "314695265\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Rebel fleet is on the run. It consists of m ships currently gathered around a single planet. Just a few seconds ago, the vastly more powerful Empire fleet has appeared in the same solar system, and the Rebels will nee...
[{"type": "stdin_stdout", "input": "30\n(89+76)/87\n(81+78)/18\n(60+97)/32\n(41+14)/48\n(55+65)/27\n(29+15)/95\n(64+13)/96\n(78+30)/75\n(43+6)/60\n(69+34)/48\n(62+2)/97\n(85+42)/3\n(4+97)/42\n(1+18)/39\n(46+55)/76\n(22+59)/24\n(62+81)/98\n(64+8)/51\n(9+59)/48\n(47+2)/80\n(33+74)/76\n(61+83)/44\n(86+4)/51\n(65+41)/49\n(...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro is an elementary school student who has just learned multiplication. Somehow, he likes multiplication, so when he sees numbers, he wants to multiply. He seems to like to do the following for integers greater than or ...
[{"type": "stdin_stdout", "input": "2\n999999\n1000100", "output": "12\n2\n"}, {"type": "stdin_stdout", "input": "2\n999999\n1010100", "output": "12\n3\n"}, {"type": "stdin_stdout", "input": "2\n999999\n1010110", "output": "12\n5\n"}, {"type": "stdin_stdout", "input": "2\n999999\n1101100", "output": "12\n4\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:\n...
[{"type": "stdin_stdout", "input": "resaremaerd", "output": "NO\n"}, {"type": "stdin_stdout", "input": "ersaremaerd", "output": "NO\n"}, {"type": "stdin_stdout", "input": "ersaremadrd", "output": "NO\n"}, {"type": "stdin_stdout", "input": "ersarfmadrd", "output": "NO\n"}, {"type": "stdin_stdout", "input": "errarfmadrd"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTenten runs a weapon shop for ninjas. Today she is willing to sell n shurikens which cost 1, 2, ..., n ryo (local currency). During a day, Tenten will place the shurikens onto the showcase, which is empty at the beginning...
[{"type": "stdin_stdout", "input": "10\n+\n- 3\n+\n+\n+\n+\n- 1\n- 7\n- 9\n- 10\n+\n+\n+\n- 4\n- 5\n- 8\n+\n- 6\n+\n- 2\n", "output": "YES\n3 10 9 7 1 8 5 4 6 2 "}, {"type": "stdin_stdout", "input": "10\n+\n- 1\n+\n+\n+\n+\n- 1\n- 7\n- 9\n- 10\n+\n+\n+\n- 7\n- 10\n- 8\n+\n+\n- 6\n- 2\n", "output": "NO\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of positive integers. While there are at least two equal elements, we will perform the following operation. We choose the smallest value $x$ that occurs in the array $2$ or more times. Take the firs...
[{"type": "stdin_stdout", "input": "34\n967614464 967614464 1000000000 1000000000 1000000000 1000000000 1000000000 1010000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N students and M checkpoints on the xy-plane.\n\nThe coordinates of the i-th student (1 \\leq i \\leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \\leq j \\leq M) is (c_j,d_j).\n\nWhen t...
[{"type": "stdin_stdout", "input": "50 50\n-87868672 9773500\n38180447 36636308\n-93470873 38029088\n49678522 -87311634\n62792334 -82584220\n50941177 2445768\n-21746015 -16856077\n-69539173 -40150977\n-82915111 -60619217\n-42155179 93071641\n-3205477 16657057\n26789545 -1410866\n-32360553 -38239433\n-69707837 59109468\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAtCoDeer the deer has found two positive integers, a and b.\nDetermine whether the concatenation of a and b in this order is a square number.\n\n-----Constraints-----\n - 1 ≀ a,b ≀ 100\n - a and b are integers.\n\n-----In...
[{"type": "stdin_stdout", "input": "100 100\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "000 001", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "010 000", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "000 000", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "000 100", "output": "Ye...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn a strategic computer game \"Settlers II\" one has to build defense structures to expand and protect the territory. Let's take one of these buildings. At the moment the defense structure accommodates exactly n soldiers....
[{"type": "stdin_stdout", "input": "100 100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, Duff has been practicing weight lifting. As a hard practice, Malek gave her a task. He gave her a sequence of weights. Weight of i-th of them is 2wi pounds. In each step, Duff can lift some of the remaining weig...
[{"type": "stdin_stdout", "input": "100\n196 1681 196 0 61 93 196 196 196 196 196 0 0 96 18 1576 0 93 666463 18 93 1 1278 8939 93 196 196 1278 3 0 67416 869956 10 56489 196 745 39 783 196 8939 196 81 69634 4552 39 3 14 20 25 8 10 4 7302 0 19579 20 1140 15990 7302 0 19579 4142 11 1354 75252 93 311 1278 0 79475 10 75252 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere was an electronic store heist last night.\n\nAll keyboards which were in the store yesterday were numbered in ascending order from some integer number $x$. For example, if $x = 4$ and there were $3$ keyboards in the...
[{"type": "stdin_stdout", "input": "40\n194 121 110 134 172 142 195 135 186 187 128 161 185 132 117 175 178 131 143 151 170 181 188 140 133 145 119 129 179 149 109 123 124 106 100 199 197 155 141 183\n", "output": "60\n"}, {"type": "stdin_stdout", "input": "40\n194 121 110 134 172 142 195 135 186 187 128 161 185 132 11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into three pie...
[{"type": "stdin_stdout", "input": "100\n3 0 -5 2 -3 -1 -1 0 -2 -5 -4 2 1 2 -2 -1 -1 -4 3 -1 -3 -1 5 0 -4 -4 -1 0 -2 -2 0 1 -1 -2 -1 -5 -4 -2 3 1 -3 0 -1 1 0 -1 2 0 -2 -1 -3 1 -2 2 3 2 -3 -5 2 2 -2 -2 1 2 -2 -1 3 0 -4 7 -2 2 1 4 -9 -1 -2 -1 0 -1 0 -2 -2 -1 1 1 -4 2 -3 -3 7 1 1 -3 -7 0 -2 0 5 -2\n", "output": "5\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet x be an array of integers x = [x_1, x_2, ..., x_n]. Let's define B(x) as a minimal size of a partition of x into subsegments such that all elements in each subsegment are equal. For example, B([3, 3, 6, 1, 6, 6, 6]) =...
[{"type": "stdin_stdout", "input": "5\n1 1 1 1 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "530612279\n"}, {"type": "stdin_stdout", "input": "10\n10 1 9 3 9 4 10 3 8 5\n10 1 10 14 12 4 10 4 10 7\n", "output": "875000103\n"}, {"type": "stdin_stdout", "input": "10\n10 1 9 3 9 4 10 3 8 5\n10 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are going out for a walk, when you suddenly encounter N monsters. Each monster has a parameter called health, and the health of the i-th monster is h_i at the moment of encounter. A monster will vanish immediately whe...
[{"type": "stdin_stdout", "input": "5 2 1\n900000000\n900000000\n1000000000\n1000000000\n1000000000\n", "output": "800000000\n"}, {"type": "stdin_stdout", "input": "5 2 1\n105611412\n1737860309\n1010000000\n1000000101\n1100000000", "output": "969572082\n"}, {"type": "stdin_stdout", "input": "5 3 1\n105611412\n115148729...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIlya is an experienced player in tic-tac-toe on the 4 Γ— 4 field. He always starts and plays with Xs. He played a lot of games today with his friend Arseny. The friends became tired and didn't finish the last game. It was ...
[{"type": "stdin_stdout", "input": "xx..\n.oo.\nx...\noox.\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "x..x\n..oo\no...\nx.xo\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": ".xox\no.x.\nx.o.\n..o.\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "o.oo\n.x.o\nx.x.\n.x..\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam.\n\nThey love equilateral triangles and want to create $n$ equilateral triangles on the grid by adding some straig...
[{"type": "stdin_stdout", "input": "10\n45996\n1494\n17871\n87082\n59317\n76537\n37514\n56796\n60195\n80410\n", "output": "263\n48\n164\n362\n299\n339\n238\n292\n301\n348\n"}, {"type": "stdin_stdout", "input": "5\n66\n6666\n666666\n66666666\n666666666\n", "output": "10\n100\n1000\n10000\n31623\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven N integers A_1, ..., A_N, compute A_1 \\times ... \\times A_N.\nHowever, if the result exceeds 10^{18}, print -1 instead.\n\n-----Constraints-----\n - 2 \\leq N \\leq 10^5\n - 0 \\leq A_i \\leq 10^{18}\n - All value...
[{"type": "stdin_stdout", "input": "31\n4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "31\n4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 0 2 7 9 5 0", "output": "0\n"}, {"type": "stdin_stdout", "input": "31\n4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n workers in a company, each of them has a unique id from 1 to n. Exaclty one of them is a chief, his id is s. Each worker except the chief has exactly one immediate superior.\n\nThere was a request to each of t...
[{"type": "stdin_stdout", "input": "10 10\n3 0 0 0 0 0 1 1 1 0\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10 10\n3 0 0 0 0 0 1 0 1 0\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "10 10\n3 0 0 0 0 1 1 0 1 0\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "10 10\n3 0 0 0 1 1 1 0 1 0\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce upon a time, Oolimry saw a suffix array. He wondered how many strings can produce this suffix array.\n\nMore formally, given a suffix array of length $n$ and having an alphabet size $k$, count the number of strings t...
[{"type": "stdin_stdout", "input": "73 95\n4 53 37 9 45 54 16 34 12 10 13 24 2 36 33 48 50 43 15 11 47 42 46 30 27 52 67 72 66 19 56 61 69 21 68 1 70 49 64 62 3 51 44 65 29 25 38 28 8 5 39 59 17 6 26 20 63 7 41 23 22 32 40 14 57 60 55 31 35 58 18 0 71\n", "output": "423380456"}, {"type": "stdin_stdout", "input": "73 95...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N squares assigned the numbers 1,2,3,\\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i.\n\nHow many squares i satisfy both of the following conditions?\n\n* The assign...
[{"type": "stdin_stdout", "input": "15\n1 10 145 15 87 138 51 194 1 18 77 20 9 17 93", "output": "8\n"}, {"type": "stdin_stdout", "input": "15\n15 11 46 15 50 98 93 129 31 43 44 11 6 24 14", "output": "3\n"}, {"type": "stdin_stdout", "input": "15\n15 11 46 15 50 98 93 129 41 43 44 11 6 24 14", "output": "3\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFirecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement.\n\nLittle Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on...
[{"type": "stdin_stdout", "input": "3\n-10 4 10\n10 4 10\n0 -7 10\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "3\n-10 4 10\n10 4 10\n0 -7 10\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "3\n-3 -2 3\n-4 -12 3\n-6 -4 9\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "3\n1 -7 10\n-7 9 10\n-2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima the hamster enjoys nibbling different things: cages, sticks, bad problemsetters and even trees!\n\nRecently he found a binary search tree and instinctively nibbled all of its edges, hence messing up the vertices. Dim...
[{"type": "stdin_stdout", "input": "36\n3 41 82 123 174 216 432 864 1080 1228 2149 4298 8596 11052 22104 33156 35919 71838 179595 359190 431028 862056 994680 1315440 1753920 3507840 7015680 10523520 21047040 26500200 53000400 106000800 132501000 176668000 353336000 530004000\n", "output": "Yes\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n-----Problem Statement-----\nWrite a program that accepts a number, n, and outputs the same.\n\n-----Input-----\nThe only line contains a single integer. \n\n-----Output-----\nOutput the answer in a single line.\n\n-----C...
[{"type": "stdin_stdout", "input": "1047", "output": "1047\n"}, {"type": "stdin_stdout", "input": "1652", "output": "1652\n"}, {"type": "stdin_stdout", "input": "3133", "output": "3133\n"}, {"type": "stdin_stdout", "input": "1313", "output": "1313\n"}, {"type": "stdin_stdout", "input": "1107", "output": "1107\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs the students are back in hostel after a long time, the gamers have decided to have a LAN gaming competition to find out who has utilized his time in gaming during vacations. They play \"Counter ATOD\". However, the sco...
[{"type": "stdin_stdout", "input": "2 2200\nvinay 1\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000000\nvinay -1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDrazil likes heap very much. So he created a problem with heap:\n\nThere is a max heap with a height h implemented on the array. The details of this heap are the following:\n\nThis heap contains exactly 2^h - 1 distinct p...
[{"type": "stdin_stdout", "input": "2\n3 1\n14 6 3 5 4 2 1\n3 2\n7 4 5 1 3 2 1\n", "output": "1\n1 1 1 1 1 1\n4\n1 1 1 1\n"}, {"type": "stdin_stdout", "input": "2\n3 1\n14 6 3 5 4 2 1\n3 2\n7 6 5 1 3 2 1\n", "output": "1\n1 1 1 1 1 1\n4\n1 1 1 1\n"}, {"type": "stdin_stdout", "input": "2\n3 1\n14 6 3 5 4 2 1\n3 2\n9 6 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have $n$ sticks of the given lengths.\n\nYour task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single ...
[{"type": "stdin_stdout", "input": "10\n20\n10 14 10 14 10 7 10 10 14 10 7 9 10 8 14 10 10 8 14 15\n12\n7 2 2 2 2 16 16 7 18 17 17 18\n5\n7 13 17 13 7\n6\n10 10 9 9 10 10\n6\n17 19 17 19 14 14\n10\n10 13 5 18 13 13 13 10 18 5\n11\n3 4 16 4 4 3 4 13 4 16 13\n7\n17 19 1 17 17 1 19\n5\n17 17 19 17 19\n9\n13 15 13 18 13 18...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInitially Ildar has an empty array. He performs $n$ steps. On each step he takes a subset of integers already added to the array and appends the mex of this subset to the array. \n\nThe mex of an multiset of integers is t...
[{"type": "stdin_stdout", "input": "3\n0 1 1000000000\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n1 1 1000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n1 0 1000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n1 0 0000000000\n", "output": "1\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are a positive integer N and a string S of length N consisting of lowercase English letters.\nDetermine whether the string is a concatenation of two copies of some string.\nThat is, determine whether there is a stri...
[{"type": "stdin_stdout", "input": "100\ntttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "100\nyyxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this task you need to process a set of stock exchange orders and use them to create order book.\n\nAn order is an instruction of some participant to buy or sell stocks on stock exchange. The order number i has price p_...
[{"type": "stdin_stdout", "input": "3 3\nB 16671 5044\nS 23924 4895\nS 76276 1905\n", "output": "S 76276 1905\nS 23924 4895\nB 16671 5044\n"}, {"type": "stdin_stdout", "input": "3 3\nB 16671 5006\nS 23924 4895\nS 76276 1905\n", "output": "S 76276 1905\nS 23924 4895\nB 16671 5006\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem C Medical Checkup\n\nStudents of the university have to go for a medical checkup, consisting of lots of checkup items, numbered 1, 2, 3, and so on.\n\nStudents are now forming a long queue, waiting for the checkup...
[{"type": "stdin_stdout", "input": "3 102\n1\n3\n0", "output": "103\n34\n34\n"}, {"type": "stdin_stdout", "input": "3 35\n1\n3\n3", "output": "36\n12\n11\n"}, {"type": "stdin_stdout", "input": "3 55\n1\n3\n4", "output": "56\n19\n13\n"}, {"type": "stdin_stdout", "input": "3 55\n1\n3\n0", "output": "56\n19\n19\n"}, {"typ...
code_stdio