messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "This problem is a complicated version of D1, but it has significant differences, so read the whole statement.\n\nPolycarp has an array of $n$ ($n$ is even) integers $a_1, a_2, \\dots, a_n$. Polycarp conceived of a positive integer $k$. After that, Polycarp began performing the following operations... | [{"input": "10\n10\n-30 45 -37 -11 25 61 97 7 7 35\n10\n48 -2 13 88 97 -27 40 88 41 -67\n10\n-13 -31 94 -43 19 95 -35 5 41 10\n10\n-28 -88 17 17 2 -43 -73 -73 -13 2\n10\n46 -73 47 54 -13 67 7 -33 1 -33\n10\n60 92 -100 -76 -12 -52 4 84 -38 36\n10\n50 62 56 -58 -10 87 29 52 14 -22\n10\n-78 50 -52 -28 -6 -28 17 51 40 -30\... | code_stdio |
[
{
"content": "Ho ho! So you think you know integers, do you? Well then, young wizard, tell us what the Nth digit of the [Champernowne constant](https://en.wikipedia.org/wiki/Champernowne_constant) is!\n\nThe constant proceeds like this: `0.12345678910111213141516...`\n\nI hope you see the pattern!\n\nConjure a ... | [{"input": "501337501337101", "output": "[3]", "fn_name": "champernowneDigit"}, {"input": "77199254740991", "output": "[7]", "fn_name": "champernowneDigit"}, {"input": "101800813569", "output": "[6]", "fn_name": "champernowneDigit"}, {"input": "1000599563", "output": "[1]", "fn_name": "champernowneDigit"}, {"input": "1... | code_functional |
[
{
"content": "The phantom thief \"Lupin IV\" is told by the beautiful \"Fujiko Mine\", a descendant of the Aizu clan, that the military funds left by the Aizu clan are sleeping in Aizuwakamatsu city. According to a report by Lupine's longtime companion, \"Ishikawa Koshiemon,\" military funds are stored in sever... | [{"input": "5\n13 199 1\n93 1000 1\n37 350 10\n27 300 2\n123 200 1100", "output": "93 37 27 13 123\n"}, {"input": "5\n11 199 0\n93 1000 1\n37 350 10\n27 300 2\n123 200 1100", "output": "93 37 27 11 123\n"}, {"input": "5\n11 91 0\n124 1000 1\n37 350 3\n12 300 2\n123 200 1111", "output": "124 37 12 11 123\n"}, {"input": ... | code_stdio |
[
{
"content": "Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] \n\nwhere: <protocol> can equal either \"http\" (without the quotes) o... | [{"input": "ftpprutpfrutrutptpfrutpfrutfrutrfrutpfrutprutruruu\n", "output": "ftp://p.ru/tpfrutrutptpfrutpfrutfrutrfrutpfrutprutruruu\n"}, {"input": "ftpprutufrutrutptpfrutpfrutfrutrfrutpfrptprutruruu\n", "output": "ftp://p.ru/tufrutrutptpfrutpfrutfrutrfrutpfrptprutruruu"}, {"input": "ftpprutufrutrutptpfrutpfrutfrutrfr... | code_stdio |
[
{
"content": "Consider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5.... The sequence is built in the following way: at first the number 1 is written out, then the numbers from 1 to 2, then the numbers from 1 to 3, then the numbers from 1 to 4 and so on. Note that the sequence c... | [{"input": "100000000000000\n", "output": "1749820\n"}, {"input": "99999998250180\n", "output": "14142135\n"}, {"input": "99999998250180\n", "output": "14142135\n"}, {"input": "100000000000000\n", "output": "1749820\n"}, {"input": "1001000000000\n", "output": "1404260\n"}, {"input": "1001000001000\n", "output": "140526... | code_stdio |
[
{
"content": "Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $a$ and screen height not greater than $b$. Monocarp is also used to TV sets with a certain aspect ratio: formally, if the wi... | [{"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000 1000000000000000000 999999... | code_stdio |
[
{
"content": "Guy-Manuel and Thomas are going to build a polygon spaceship.\n\nYou're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon obtained by translating P by vector \\overrightarrow {(x,y)}. The picture belo... | [{"input": "8\n-440365664 -897818514\n107345267 -994221803\n248590739 -968608613\n473576011 -880752952\n105203574 994450706\n-164464580 1061907476\n-522092561 852888831\n-874210729 485546704\n", "output": "NO\n"}, {"input": "8\n-845415846 -897818514\n107345267 -994221803\n248590739 -968608613\n473576011 -880752952\n105... | code_stdio |
[
{
"content": "Find the union of two sets $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ and $B = \\\\{b_0, b_1, ..., b_{m-1}\\\\}$.\n\nConstraints\n\n* $1 \\leq n, m \\leq 200,000$\n* $0 \\leq a_0 < a_1 < ... < a_{n-1} \\leq 10^9$\n* $0 \\leq b_0 < b_1 < ... < b_{m-1} \\leq 10^9$\n\nInput\n\nThe input is given in the f... | [{"input": "3\n2 4 15\n2\n11 64", "output": "2\n4\n11\n15\n64\n"}, {"input": "3\n-1 5 10\n2\n3 16", "output": "-1\n3\n5\n10\n16\n"}, {"input": "3\n-1 4 10\n2\n3 16", "output": "-1\n3\n4\n10\n16\n"}, {"input": "3\n-1 4 10\n2\n5 16", "output": "-1\n4\n5\n10\n16\n"}, {"input": "3\n2 9 15\n2\n7 11", "output": "2\n7\n9\n11\... | code_stdio |
[
{
"content": "Lunar New Year is approaching, and you bought a matrix with lots of \"crosses\".\n\nThis matrix $M$ of size $n \\times n$ contains only 'X' and '.' (without quotes). The element in the $i$-th row and the $j$-th column $(i, j)$ is defined as $M(i, j)$, where $1 \\leq i, j \\leq n$. We define a cros... | [{"input": "14\nXXX.XXXXX..X.X\nX..XX..X...X..\n.....X.XX..XXX\n.X..X..XXX.XX.\n...XXXX.XX..XX\n.X..XX...XXX..\nXX.XX.XX..XXX.\n.X..X.....X.XX\n...XXX...XX.XX\nXXX.XX.XX.X.XX\nX.XXXX..XX.XX.\n.X.XX....X....\nX..XX..X.XX.X.\n..X...XX....XX\n", "output": "2\n"}, {"input": "14\nXXX.XXXXX..X.X\nX..XX..X...X..\n.....X.XX..X... | code_stdio |
[
{
"content": "Petya has an array of integers a_1, a_2, …, a_n. He only likes sorted arrays. Unfortunately, the given array could be arbitrary, so Petya wants to sort it.\n\nPetya likes to challenge himself, so he wants to sort array using only 3-cycles. More formally, in one operation he can pick 3 pairwise dis... | [{"input": "7\n1\n1\n2\n2 2\n2\n2 2\n3\n1 2 3\n3\n1 1 1\n3\n3 1 2\n4\n2 1 4 3\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "7\n1\n1\n2\n1 2\n2\n1 1\n3\n1 2 3\n3\n2 1 1\n3\n3 1 1\n4\n4 1 4 3\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "7\n1\n1\n2\n1 2\n2\n1 1\n3\n1 3 3\n3\n2 1 1\n3... | code_stdio |
[
{
"content": "You are given a picture consisting of $n$ rows and $m$ columns. Rows are numbered from $1$ to $n$ from the top to the bottom, columns are numbered from $1$ to $m$ from the left to the right. Each cell is painted either black or white. \n\nYou think that this picture is not interesting enough. You ... | [{"input": "9\n5 5\n..*..\n..*..\n*****\n..*..\n..*..\n3 4\n****\n.*..\n.*..\n4 3\n***\n*..\n*..\n*..\n5 5\n*****\n*.*.*\n*****\n..*.*\n..***\n1 4\n****\n5 5\n.....\n..*..\n.***.\n..*..\n.....\n5 3\n...\n.*.\n.*.\n***\n.*.\n3 3\n.*.\n*.*\n.*.\n4 4\n*.**\n....\n*.**\n*.**\n", "output": "0\n0\n0\n0\n0\n4\n1\n1\n2\n"}, {"... | code_stdio |
[
{
"content": "For two permutations p and q of the integers from 1 through N, let f(p,q) be the permutation that satisfies the following:\n\n* The p_i-th element (1 \\leq i \\leq N) in f(p,q) is q_i. Here, p_i and q_i respectively denote the i-th element in p and q.\n\n\n\nYou are given two permutations p and q ... | [{"input": "10 1000001000\n7 10 6 5 4 2 9 1 3 8\n4 1 9 2 3 7 8 10 6 5", "output": "8 4 6 5 2 7 9 10 1 3"}, {"input": "10 1001000001\n7 10 6 5 4 2 9 1 3 8\n4 1 9 2 3 7 8 10 6 5", "output": "4 8 10 6 9 2 1 3 5 7"}, {"input": "10 1000000001\n7 10 6 5 4 2 9 1 3 8\n4 1 9 2 3 7 8 10 6 5", "output": "10 3 7 6 4 8 2 1 5 9"}, {... | code_stdio |
[
{
"content": "Problem\n\nThere are coins with front and back sides and dice with rolls from $ 1 $ to $ N $. Gacho decided to play the following games using these.\n\nThe game starts with a score of $ 0 $ and proceeds as follows.\n\n\n1. Roll the dice $ 1 $ and add the number of rolls to the score.\n2. If the cu... | [{"input": "12 110 467", "output": "469611202\n"}, {"input": "12 100 467", "output": "732809678\n"}, {"input": "12 13 187", "output": "455459798\n"}, {"input": "12 60 467", "output": "654858060\n"}, {"input": "13 31 187", "output": "681077066\n"}, {"input": "10 31 187", "output": "611384855\n"}, {"input": "6 13 187", "... | code_stdio |
[
{
"content": "# Task\n\nThe game starts with `n` people standing in a circle. The presenter counts `m` people starting with the first one, and gives `1` coin to each of them. The rest of the players receive `2` coins each. After that, the last person who received `1` coin leaves the circle, giving everything he... | [{"input": "75\n34", "output": "[[35, 4238]]", "fn_name": "find_last"}, {"input": "82\n49", "output": "[[48, 5091]]", "fn_name": "find_last"}, {"input": "73\n38", "output": "[[61, 3996]]", "fn_name": "find_last"}, {"input": "86\n71", "output": "[[10, 6275]]", "fn_name": "find_last"}, {"input": "61\n17", "output": "[[26... | code_functional |
[
{
"content": "Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a \"plus\") and negative (a \"minus\"). If two magnets are put together at a close distance, then the like poles will rep... | [{"input": "115\n10\n10\n10\n10\n01\n01\n10\n10\n10\n01\n01\n10\n01\n01\n10\n10\n10\n01\n10\n01\n10\n10\n01\n01\n10\n10\n10\n10\n01\n10\n01\n01\n10\n10\n10\n10\n01\n10\n10\n10\n01\n10\n01\n10\n10\n10\n10\n01\n01\n01\n10\n10\n01\n01\n01\n10\n10\n01\n10\n01\n01\n01\n01\n10\n10\n01\n10\n01\n01\n01\n01\n01\n10\n01\n10\n10\... | code_stdio |
[
{
"content": "Let's introduce some definitions that will be needed later.\n\nLet $prime(x)$ be the set of prime divisors of $x$. For example, $prime(140) = \\{ 2, 5, 7 \\}$, $prime(169) = \\{ 13 \\}$.\n\nLet $g(x, p)$ be the maximum possible integer $p^k$ where $k$ is an integer such that $x$ is divisible by $p... | [{"input": "1000000000 1000000000000000000\n", "output": "997440007\n"}, {"input": "1000000000 1000000000000000000\n", "output": "997440007\n"}, {"input": "1000000000 1000000000010000000\n", "output": "778038345\n"}, {"input": "1000001001 1000000000010000000\n", "output": "141474221\n"}, {"input": "732253291 1106035102... | code_stdio |
[
{
"content": "Alice has just learned addition. However, she hasn't learned the concept of \"carrying\" fully — instead of carrying to the next column, she carries to the column two columns to the left.\n\nFor example, the regular way to evaluate the sum $2039 + 2976$ would be as shown:\n\nHowever, Alice evaluat... | [{"input": "2\n352942581\n1100110000\n", "output": "192407906\n102030199\n"}, {"input": "2\n178886702\n1100110000\n", "output": "148360651\n102030199\n"}, {"input": "2\n139544809\n1100110000\n", "output": "69014088\n102030199\n"}, {"input": "2\n217736582\n1100110000\n", "output": "48387455\n102030199\n"}, {"input": "2\... | code_stdio |
[
{
"content": "A: Union Ball\n\nProblem Statement\n\nThere are N balls in a box. The i-th ball is labeled with a positive integer A_i.\n\nYou can interact with balls in the box by taking actions under the following rules:\n\n* If integers on balls in the box are all odd or all even, you cannot take actions anymo... | [{"input": "3\n17 1 12", "output": "1\n"}, {"input": "3\n17 0 12", "output": "2\n"}, {"input": "3\n12 2 2", "output": "0\n"}, {"input": "3\n12 1 2", "output": "2\n"}, {"input": "3\n10 2 2", "output": "0\n"}, {"input": "3\n19 2 2", "output": "2\n"}, {"input": "3\n17 1 4", "output": "1\n"}, {"input": "3\n17 0 4", "output... | code_stdio |
[
{
"content": "You are standing at the point $0$ on a coordinate line. Your goal is to reach the point $n$. In one minute, you can move by $2$ or by $3$ to the left or to the right (i. e., if your current coordinate is $x$, it can become $x-3$, $x-2$, $x+2$ or $x+3$). Note that the new coordinate can become nega... | [{"input": "10\n999999999\n999999990\n999999995\n999999951\n999999999\n999999990\n999999999\n999999992\n999999997\n999999999\n", "output": "333333333\n333333330\n333333332\n333333317\n333333333\n333333330\n333333333\n333333331\n333333333\n333333333\n"}, {"input": "1\n84123456\n", "output": "28041152\n"}, {"input": "1\n... | code_stdio |
[
{
"content": "You 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 number that is a non-trivial divisor of the last written number. Then he should ru... | [{"input": "7938986881993\n", "output": "1\n378028993"}, {"input": "1477562914357\n", "output": "1\n41161181\n"}, {"input": "472670214391\n", "output": "1\n23020027"}, {"input": "1468526771489\n", "output": "1\n613783"}, {"input": "1245373417369\n", "output": "1\n908209"}, {"input": "365292057641\n", "output": "1\n1260... | code_stdio |
[
{
"content": "On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he places his grasshopper to one of the empty cells and a small insect in anothe... | [{"input": "100 20\n.....G.#.#..................#.........##....#...................#.#..........#...#.#.T..#.......#...\n", "output": "YES\n"}, {"input": "100 33\nG..................................................................................................T\n", "output": "YES\n"}, {"input": "100 33\nG.............. | code_stdio |
[
{
"content": "You are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will consist of n problems. You can either solve problem i in exactly t_{i} milliseconds or ignore it and spend no time. You don't need time to rest after solving a problem, either.\n\nUnfortunate... | [{"input": "10 481\n6 25\n0 85\n8 96\n6 7\n1 16\n4 32\n2 5\n3 42\n9 126\n7 70\n", "output": "5\n5\n4 1 10 3 9"}, {"input": "10 481\n6 25\n0 85\n8 96\n6 7\n1 16\n4 32\n2 9\n3 42\n9 126\n7 70\n", "output": "5\n5\n4 1 10 3 9"}, {"input": "10 481\n6 25\n0 85\n8 96\n6 7\n1 16\n4 32\n2 0\n3 42\n9 126\n7 70\n", "output": "5\n... | code_stdio |
[
{
"content": "Given time in 24-hour format, convert it to words. \n\n```\nFor example:\n13:00 = one o'clock \n13:09 = nine minutes past one \n13:15 = quarter past one \n13:29 = twenty nine minutes past one\n13:30 = half past one \n13:31 = twenty nine minutes to two\n13:45 = quarter to two \n00:48 = twelve minut... | [{"input": "\"23:31\"", "output": "[\"twenty nine minutes to midnight\"]", "fn_name": "solve"}, {"input": "\"11:31\"", "output": "[\"twenty nine minutes to twelve\"]", "fn_name": "solve"}, {"input": "\"13:29\"", "output": "[\"twenty nine minutes past one\"]", "fn_name": "solve"}, {"input": "\"00:08\"", "output": "[\"ei... | code_functional |
[
{
"content": "You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y.\n\nYour favorite rational number in the [0;1] range is p / q. Now y... | [{"input": "5\n99999997 999999998 999999998 999999999\n99999996 999999997 999999997 999999999\n99999997 999999998 999999998 999999999\n99999996 999999997 999999997 999999999\n99999997 999999998 999999998 999999999\n", "output": "899999999100000001\n449999999550000002\n899999999100000001\n449999999550000002\n89999999910... | code_stdio |
[
{
"content": "Student A and student B are giving each other test answers during a test. \nThey don't want to be caught so they are sending each other coded messages.\n\nStudent A is sending student B the message: `Answer to Number 5 Part b`. \nHe starts of with a square grid (in this example the grid = 5x5). ... | [{"input": "\"8 d9dx0962x8067d x 760x272690 d852757d59 d552820d52dx767d 0dxxxd995x0676x59d6x7760x0d7 02dd7558770x2d0760x85d8x709d0x590\"", "output": "[\"88x256960x8 027275x22xd6758dx7dd797272 07d00dd6d0066779x 95dd7056d0x095x6x5009 2xx08xx67d dx5d785268dxd97759x05579d 0d0\"]", "fn_name": "decipher_message"}, {"input... | code_functional |
[
{
"content": "You are given a forest with N vertices and M edges. The vertices are numbered 0 through N-1. The edges are given in the format (x_i,y_i), which means that Vertex x_i and y_i are connected by an edge.\n\nEach vertex i has a value a_i. You want to add edges in the given forest so that the forest bec... | [{"input": "7 -1\n1 2 3 4 5 6 0\n3 0\n4 0\n1 2\n1 3\n5 6", "output": "Impossible\n"}, {"input": "7 -1\n1 2 3 4 5 6 0\n3 0\n4 0\n1 2\n2 3\n5 6", "output": "Impossible\n"}, {"input": "7 -1\n1 2 3 4 5 6 0\n0 0\n4 0\n1 2\n2 3\n5 6", "output": "Impossible\n"}, {"input": "7 -1\n1 4 3 4 5 6 0\n0 0\n4 0\n1 2\n2 3\n5 6", "outpu... | code_stdio |
[
{
"content": "Vasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses (\"+\") in the line between certain digits in the line so that the result was a correct arithmetic e... | [{"input": "200 100\n56988719755815575893282254081467698462485803782142631369385180999746639622554559884281193367342283559238834106917388166048020056852911293394377949964185368886333934084399980368238188117302968424219707\n", "output": "295455656\n"}, {"input": "200 100\n655255749193583406396355747768874383520958452063... | code_stdio |
[
{
"content": "An eviternity number is a number which:\n* contains only digits 8, 5 and 3, and \n* the count of the digit `8` >= count of digit `5` >= count of digit `3`. \n\nThe first few eviternity numbers are as follows. \n```Haskell\n[8, 58, 85, 88, 358, 385, 538, 583, 588, 835, 853, 858, 885, 888]\n```\nYou... | [{"input": "0\n100000", "output": "[103]", "fn_name": "solve"}, {"input": "0\n500000", "output": "[148]", "fn_name": "solve"}, {"input": "90\n139701", "output": "[99]", "fn_name": "solve"}, {"input": "61\n56976", "output": "[53]", "fn_name": "solve"}, {"input": "0\n10000", "output": "[37]", "fn_name": "solve"}, {"input... | code_functional |
[
{
"content": "Connect the countless points with lines, till we reach the faraway yonder.\n\nThere are n points on a coordinate plane, the i-th of which being (i, y_{i}).\n\nDetermine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of the... | [{"input": "20\n-975467170 758268840 -975467171 758268839 -975467172 758268838 -975467173 758268837 -975467174 1015089897 -975467175 758268835 -975467176 758268834 -975467177 967684266 -975467178 758268832 -975467179 1082851919\n", "output": "No\n"}, {"input": "20\n-975467170 758268840 -975467171 758268839 -975467172 7... | code_stdio |
[
{
"content": "You are given a permutation $a$ consisting of $n$ numbers $1$, $2$, ..., $n$ (a permutation is an array in which each element from $1$ to $n$ occurs exactly once).\n\nYou can perform the following operation: choose some subarray (contiguous subsegment) of $a$ and rearrange the elements in it in an... | [{"input": "3\n4\n1 3 2 10\n3\n1 2 3\n5\n3 1 4 0 0\n", "output": "1\n0\n2\n"}, {"input": "3\n4\n1 3 2 7\n3\n1 2 3\n5\n2 1 4 5 -1\n", "output": "1\n0\n2\n"}, {"input": "3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3\n", "output": "\n1\n0\n2\n"}, {"input": "3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3\n", "output": "1\n0\n2\n"}, {"input... | code_stdio |
[
{
"content": "After a successful field test, Heidi is considering deploying a trap along some Corridor, possibly not the first one. She wants to avoid meeting the Daleks inside the Time Vortex, so for abundance of caution she considers placing the traps only along those Corridors that are not going to be used a... | [{"input": "10 26\n9 5 277429172\n10 8 789225932\n5 2 992601916\n9 8 277294258\n8 6 245446241\n6 2 439001127\n7 1 447891377\n10 6 699661758\n1 9 865851152\n2 8 299785854\n7 10 756200111\n8 3 431547893\n5 6 465205287\n7 4 957301499\n3 4 308491540\n3 7 252157788\n10 5 282875145\n1 8 262659451\n5 4 981921705\n2 4 16048245... | code_stdio |
[
{
"content": "Основой любой социальной сети является отношение дружбы между двумя пользователями в том или ином смысле. В одной известной социальной сети дружба симметрична, то есть если a является другом b, то b также является другом a. \n\nВ этой же сети есть функция, которая демонстрирует множество людей, им... | [{"input": "10 50\n946010975 207263044\n923545573 749203275\n862015642 426425906\n749203275 839134958\n910721783 289091881\n827003531 333726912\n49704846 538788252\n382891592 207263044\n333726912 438209022\n974360048 49704846\n", "output": "49704846: 0\n207263044: 0\n289091881: 0\n333726912: 0\n382891592: 1 946010975\n... | code_stdio |
[
{
"content": "Polycarp has come up with a new game to play with you. He calls it \"A missing bigram\".\n\nA bigram of a word is a sequence of two adjacent letters in it.\n\nFor example, word \"abbaaba\" contains bigrams \"ab\", \"bb\", \"ba\", \"aa\", \"ab\" and \"ba\".\n\nThe game goes as follows. First, Polyc... | [{"input": "4\n7\nab bb ba aa ba\n7\nab ba aa ab ba\n3\naa\n5\nbb ab bb\n", "output": "abbaaba\nabaabaa\naaa\nbbabb\n"}, {"input": "4\n7\nab bb ba aa ba\n7\nab ba aa ab ba\n3\naa\n5\nbb ab bb\n", "output": "abbaaba\nabaabaa\naaa\nbbabb\n"}, {"input": "4\n7\nab bb ba aa ba\n7\nab ba aa ab ab\n3\naa\n5\nbb ab bb\n", "out... | code_stdio |
[
{
"content": "Challenge:\nGiven two null-terminated strings in the arguments \"string\" and \"prefix\", determine if \"string\" starts with the \"prefix\" string. Return 1 (or any other \"truthy\" value) if true, 0 if false.\n\nExample:\n```\nstartsWith(\"hello world!\", \"hello\"); // should return 1.\nstartsW... | [{"input": "\"hello world!\"\n\"HELLO\"", "output": "[false]", "fn_name": "starts_with"}, {"input": "\"hello world!\"\n\"hello\"", "output": "[true]", "fn_name": "starts_with"}, {"input": "\"nowai\"\n\"nowaisir\"", "output": "[false]", "fn_name": "starts_with"}, {"input": "\"\"\n\"abc\"", "output": "[false]", "fn_name"... | code_functional |
[
{
"content": "Absent-minded Masha got set of n cubes for her birthday.\n\nAt each of 6 faces of each cube, there is exactly one digit from 0 to 9. Masha became interested what is the largest natural x such she can make using her new cubes all integers from 1 to x.\n\nTo make a number Masha can rotate her cubes ... | [{"input": "3\n5 1 2 9 6 4\n9 0 6 4 2 8\n4 6 2 8 3 7\n", "output": "10\n"}, {"input": "3\n1 1 1 0 2 3\n4 5 6 7 8 9\n0 0 0 0 0 0\n", "output": "10\n"}, {"input": "3\n1 1 1 1 1 1\n0 2 3 4 5 6\n7 8 9 2 3 4\n", "output": "10\n"}, {"input": "3\n0 1 1 2 2 3\n4 5 6 7 8 9\n3 4 5 6 7 1\n", "output": "19\n"}, {"input": "3\n3 4 5... | code_stdio |
[
{
"content": "Meikyokan University is very famous for its research and education in the area of computer science. This university has a computer center that has advanced and secure computing facilities including supercomputers and many personal computers connected to the Internet.\n\nOne of the policies of the ... | [{"input": "8\n2\nomura\ntoshio\nraku\ntanaka\ninura\nyoshoi\nhayashi\nmiura\n3\n1\ntasaka\nnakata\ntanaka\n1\n1\nfoo\n5\n2\npsqt\nabcdef\nabzdefa\npqrst\nabdxcef\n0", "output": "inura,miura\ninura,omura\nmiura,omura\ntoshio,yoshoi\n4\ntanaka,tasaka\n1\n0\nabcdef,abdxcef\nabcdef,abzdefa\npqrst,psqt\n3\n"}, {"input": "8... | code_stdio |
[
{
"content": "There are $n$ cities and $m$ roads in Berland. Each road connects a pair of cities. The roads in Berland are one-way.\n\nWhat is the minimum number of new roads that need to be built to make all the cities reachable from the capital?\n\nNew roads will also be one-way.\n\n\n-----Input-----\n\nThe f... | [{"input": "39 40 38\n4 8\n24 28\n16 17\n7 25\n4 29\n34 35\n16 24\n21 10\n23 36\n36 14\n28 16\n34 19\n15 21\n22 38\n22 37\n37 27\n28 33\n3 29\n32 22\n12 30\n9 15\n5 19\n23 27\n19 17\n25 17\n24 11\n39 10\n6 20\n16 6\n3 18\n34 21\n15 38\n11 19\n11 3\n32 4\n15 13\n16 11\n11 7\n33 7\n3 33\n", "output": "12\n"}, {"input": "... | code_stdio |
[
{
"content": "In 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important role to protect Kyoto at the end of the Edo period when security has deteriorated. You have to patrol the city by sharing it with the shogunate and other clan. However, when it came time to ... | [{"input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 6\n5 6\n6 3\n5 8\n1 16\n1 8\n2 14\n7 0\n11 9\n9 2\n0 0\n1 3\n3 4\n5 5\n4 2\n0 0", "output": "NG\nOK\n"}, {"input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 6\n5 6\n6 3\n5 8\n1 16\n3 8\n6 14\n7 0\n8 9\n9 2\n0 0\n1 3\n3 4\n5 5\n4 2\n0 0", "output": "NG\nOK\n"}, {"input": "1 3\n3 4\n3 5... | code_stdio |
[
{
"content": "You are given two strings $s$ and $t$, each of length $n$ and consisting of lowercase Latin alphabets. You want to make $s$ equal to $t$. \n\nYou can perform the following operation on $s$ any number of times to achieve it — Choose any substring of $s$ and rotate it clockwise once, that is, if t... | [{"input": "16\n3\naaa\naaa\n3\nabb\naab\n3\naab\nbaa\n3\naab\naba\n3\naca\naba\n3\naba\nbaa\n3\naba\naab\n3\nabb\nabb\n3\nabb\nbab\n3\nabb\nbba\n3\nabc\nabc\n3\ncba\nbad\n3\nabc\ndab\n3\nabc\nacb\n3\ncba\ncba\n3\nabc\nbca\n", "output": "0\n-1\n1\n1\n-1\n1\n1\n0\n1\n2\n0\n-1\n-1\n1\n0\n2\n"}, {"input": "16\n3\naaa\naaa... | code_stdio |
[
{
"content": "In this kata, you should calculate type of triangle with three given sides ``a``, ``b`` and ``c`` (given in any order).\n\nIf all angles are less than ``90°``, this triangle is ``acute`` and function should return ``1``.\n\nIf one angle is strictly ``90°``, this triangle is ``right`` and function ... | [{"input": "100000\n100005\n111111", "output": "[1]", "fn_name": "triangle_type"}, {"input": "68000\n285000\n293000", "output": "[2]", "fn_name": "triangle_type"}, {"input": "122.14\n222.11\n250", "output": "[1]", "fn_name": "triangle_type"}, {"input": "8.625\n33.625\n32.5", "output": "[2]", "fn_name": "triangle_type"}... | code_functional |
[
{
"content": "In Math, an improper fraction is a fraction where the numerator (the top number) is greater than or equal to the denominator (the bottom number) For example: ```5/3``` (five third).\n\nA mixed numeral is a whole number and a fraction combined into one \"mixed\" number. For example: ```1 1/2``` (on... | [{"input": "\"-21511/21\"", "output": "[\"-1024 7/21\"]", "fn_name": "convert_to_mixed_numeral"}, {"input": "\"9999/24\"", "output": "[\"416 15/24\"]", "fn_name": "convert_to_mixed_numeral"}, {"input": "\"-504/26\"", "output": "[\"-19 10/26\"]", "fn_name": "convert_to_mixed_numeral"}, {"input": "\"74/30\"", "output": "... | code_functional |
[
{
"content": "Little Petya loves playing with squares. Mum bought him a square 2n × 2n in size. Petya marked a cell inside the square and now he is solving the following task.\n\nThe task is to draw a broken line that would go along the grid lines and that would cut the square into two equal parts. The cutting ... | [{"input": "100 100 100\n", "output": "YES\n"}, {"input": "100 110 100\n", "output": "YES\n"}, {"input": "110 110 100\n", "output": "YES\n"}, {"input": "110 110 110\n", "output": "YES\n"}, {"input": "110 110 101\n", "output": "YES\n"}, {"input": "110 111 101\n", "output": "YES\n"}, {"input": "010 111 101\n", "output": ... | code_stdio |
[
{
"content": "A simple recommendation system would recommend a user things liked by a certain number of their friends. In this problem you will implement part of such a system.\n\nYou are given user's friends' opinions about a list of items. You are also given a threshold T — the minimal number of \"likes\" nec... | [{"input": "10 10 10\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\n", "output": "10\n"}, {"input": "10 10 10\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\n", "output": "1... | code_stdio |
[
{
"content": "Dolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-hour clock is used. For example, 9:00 p.m. is referred to as \"21 o'clock\".\n\nThe current time is A o'clock, and a contest will begin in exactly B hours.\nWhen will the contest begin? Ans... | [{"input": "23 23\n", "output": "22\n"}, {"input": "405 14", "output": "11\n"}, {"input": "9 12\n", "output": "21\n"}, {"input": "19 0\n", "output": "19\n"}, {"input": "22 1\n", "output": "23\n"}, {"input": "3 12\n", "output": "15\n"}, {"input": "0 15\n", "output": "15\n"}, {"input": "17 -1", "output": "16\n"}, {"input... | code_stdio |
[
{
"content": "Input\n\nThe input contains two integers N, M (1 ≤ N ≤ 1024, 2 ≤ M ≤ 16), separated by a single space.\n\nOutput\n\nOutput \"YES\" or \"NO\".\n\nExamples\n\nInput\n\n\n2 3\n\n\nOutput\n\n\nYES\n\n\nInput\n\n\n3 2\n\n\nOutput\n\n\nNO\n\n\nInput\n\n\n33 16\n\n\nOutput\n\n\nYES\n\n\nInput\n\n\n26 5\n... | [{"input": "33 16\n", "output": "\nYES\n"}, {"input": "11 11\n", "output": "YES\n"}, {"input": "12 16\n", "output": "YES\n"}, {"input": "11 20\n", "output": "YES\n"}, {"input": "15 11\n", "output": "YES\n"}, {"input": "26 11\n", "output": "YES\n"}, {"input": "12 26\n", "output": "YES\n"}, {"input": "13 11\n", "output":... | code_stdio |
[
{
"content": "Did you ever hear about 'crossing the bridge noodle' ? Let me tell you that it's not some kind of bridge made of noodles. It's a dish, a kind of rice noodle soup. Mr.Ping makes the best noodle soup and his son Po is eagerly waiting for the user reviews in his father's blog. Users can vote with a (... | [{"input": "2\nQ 0\nP 14\n\n2\nO -1\nM -16\n\n0", "output": "13\n15\n"}, {"input": "2\nQ -1\nP 14\n\n2\nN -1\nM -3\n\n0", "output": "13\n2\n"}, {"input": "2\nQ -1\nP 8\n\n2\nM -1\nM -14\n\n0", "output": "7\n13\n"}, {"input": "2\nQ -1\nP 8\n\n2\nM -1\nM -13\n\n0", "output": "7\n12\n"}, {"input": "2\nQ 1\nP 7\n\n2\nO 0\n... | code_stdio |
[
{
"content": "In computing, there are two primary byte order formats: big-endian and little-endian. Big-endian is used primarily for networking (e.g., IP addresses are transmitted in big-endian) whereas little-endian is used mainly by computers with microprocessors.\n\nHere is an example (using 32-bit integers ... | [{"input": "859983475894789589772983457982345896389458937589738945435\n1024", "output": "[10935879118170253467575045997837531765542549198363770264806105328514144954155675005294370560789173602325403413189569286370255297035043193807918631267898110032789194315444561922202783069416581989858234400991054570729329260875447493... | code_functional |
[
{
"content": "Takahashi has two integers X and Y.\nHe computed X + Y and X - Y, and the results were A and B, respectively.\nNow he cannot remember what X and Y were. Find X and Y for him.\n\n-----Constraints-----\n - -100 \\leq A, B \\leq 100\n - For the given integers A and B, there uniquely exist integers X ... | [{"input": "-100 -100\n", "output": "-100 0\n"}, {"input": "-100 100\n", "output": "0 -100\n"}, {"input": "-39 -69\n", "output": "-54 15\n"}, {"input": "100 -100\n", "output": "0 100\n"}, {"input": "-98 4\n", "output": "-47 -51\n"}, {"input": "-23 71\n", "output": "24 -47\n"}, {"input": "17 -95\n", "output": "-39 56\n"... | code_stdio |
[
{
"content": "# The die is cast!\n\nYour task in this kata is to write a \"dice roller\" that interprets a subset of [dice notation](http://en.wikipedia.org/wiki/Dice_notation).\n\n# Description\n\nIn most role-playing games, die rolls required by the system are given in the form `AdX`. `A` and `X` are variable... | [{"input": "\"2d6+3 abc\"", "output": "[false]", "fn_name": "roll"}, {"input": "\"abc 2d6+3\"", "output": "[false]", "fn_name": "roll"}, {"input": "\"2d6++4\"", "output": "[false]", "fn_name": "roll"}, {"input": "\"abc\"", "output": "[false]", "fn_name": "roll"}, {"input": "\"\"", "output": "[false]", "fn_name": "roll"... | code_functional |
[
{
"content": "You are given an integer N. Find the number of strings of length N that satisfy the following conditions, modulo 10^9+7:\n - The string does not contain characters other than A, C, G and T.\n - The string does not contain AGC as a substring.\n - The condition above cannot be violated by swapping t... | [{"input": "100\n", "output": "388130742\n"}, {"input": "18\n", "output": "261943303\n"}, {"input": "26\n", "output": "858533109\n"}, {"input": "50\n", "output": "113468411\n"}, {"input": "90\n", "output": "252858375\n"}, {"input": "97\n", "output": "329869205\n"}, {"input": "98\n", "output": "616680192\n"}, {"input": ... | code_stdio |
[
{
"content": "Harry is a bright student. To prepare thoroughly for exams, he completes all the exercises in his book! Now that the exams are approaching fast, he is doing book exercises day and night. He writes down and keeps updating the remaining number of exercises on the back cover of each book.\nHarry has ... | [{"input": "6\n14 hrilgne\n6 mathematics\n-1 geography\n-1\n3 grcphias\n-1", "output": "0 mathematics\n0 hrilgne\n0 grcphias\n"}, {"input": "6\n9 english\n7 nathematics\n-1 geography\n-1\n3 gchpsias\n-1", "output": "0 nathematics\n0 english\n0 gchpsias\n"}, {"input": "6\n1 hsilgne\n-1 lathematics\n14 georgaphy\n-1\n2 s... | code_stdio |
[
{
"content": "Arkady invited Anna for a dinner to a sushi restaurant. The restaurant is a bit unusual: it offers $n$ pieces of sushi aligned in a row, and a customer has to choose a continuous subsegment of these sushi to buy.\n\nThe pieces of sushi are of two types: either with tuna or with eel. Let's denote t... | [{"input": "100\n2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "54\n"}, {"input": "100\n1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 1 ... | code_stdio |
[
{
"content": "You are given three integers $a \\le b \\le c$.\n\nIn one move, you can add $+1$ or $-1$ to any of these integers (i.e. increase or decrease any number by one). You can perform such operation any (possibly, zero) number of times, you can even perform this operation several times with one number. N... | [{"input": "10\n3351 6383 6479\n7051 9793 9929\n1 1061 9572\n5401 5401 5865\n9777 9987 9987\n3393 7229 9665\n8014 8533 8665\n9549 9917 9998\n3336 6686 9962\n5351 8201 9241\n", "output": "208\n3239 6478 6478\n2223\n4964 9928 9928\n7\n1 1063 9567\n464\n5401 5401 5401\n210\n9987 9987 9987\n2608\n3221 9663 9663\n651\n8533 ... | code_stdio |
[
{
"content": "Find the minimum area of a square land on which you can place two identical rectangular $a \\times b$ houses. The sides of the houses should be parallel to the sides of the desired square land.\n\nFormally, You are given two identical rectangles with side lengths $a$ and $b$ ($1 \\le a, b \\le 1... | [{"input": "8\n3 2\n4 2\n1 1\n3 1\n4 13\n1 3\n12 4\n100 100\n", "output": "16\n16\n4\n9\n169\n9\n144\n40000\n"}, {"input": "8\n3 2\n2 2\n1 1\n4 2\n2 11\n1 4\n7 4\n100 101\n", "output": "16\n16\n4\n16\n121\n16\n64\n40000\n"}, {"input": "8\n3 2\n4 2\n1 1\n3 1\n12 7\n1 3\n12 4\n100 001\n", "output": "16\n16\n4\n9\n196\n9\... | code_stdio |
[
{
"content": "Define a \"prime prime\" number to be a rational number written as one prime number over another prime number: `primeA / primeB` (e.g. `7/31`)\n\nGiven a whole number `N`, generate the number of \"prime prime\" rational numbers less than 1, using only prime numbers between `0` and `N` (non inclusi... | [{"input": "1000", "output": "[[14028, 6266]]", "fn_name": "prime_primes"}, {"input": "666", "output": "[[7260, 3213]]", "fn_name": "prime_primes"}, {"input": "65", "output": "[[153, 63]]", "fn_name": "prime_primes"}, {"input": "10", "output": "[[6, 3]]", "fn_name": "prime_primes"}, {"input": "6", "output": "[[3, 1]]",... | code_functional |
[
{
"content": "There are N integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi will repeatedly perform the following operation on these numbers:\n\n* Select a pair of integers, A_i and A_j, that have the same parity (that is, both are even or both are odd) and erase them.\n* Then, write a new... | [{"input": "5\n1 18 1 14 0", "output": "YES\n"}, {"input": "5\n2 18 0 14 0", "output": "YES\n"}, {"input": "5\n4 3 -1 16 4", "output": "YES\n"}, {"input": "5\n2 3 -1 16 4", "output": "YES\n"}, {"input": "5\n2 3 -1 16 2", "output": "YES\n"}, {"input": "5\n4 3 -1 16 2", "output": "YES\n"}, {"input": "5\n6 3 -1 16 2", "ou... | code_stdio |
[
{
"content": "problem\n\nAt IOI Confectionery, rice crackers are baked using the traditional method since the company was founded. This traditional method is to bake the front side for a certain period of time with charcoal, turn it over when the front side is baked, and bake the back side for a certain period ... | [{"input": "2 5\n0 1 1 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0", "output": "10\n15\n"}, {"input": "2 5\n1 1 1 1 0\n0 0 0 0 1\n3 6\n1 0 0 0 0 1\n0 1 1 0 1 0\n1 0 1 1 0 1\n0 0", "output": "10\n16\n"}, {"input": "2 5\n1 1 1 1 0\n0 0 0 0 1\n3 6\n1 0 0 0 1 0\n0 1 1 0 1 1\n1 0 1 1 0 1\n0 0", "output":... | code_stdio |
[
{
"content": "Alice is visiting New York City. To make the trip fun, Alice will take photos of the city skyline and give the set of photos as a present to Bob. However, she wants to find the set of photos with maximum beauty and she needs your help.\n\nThere are $n$ buildings in the city, the $i$-th of them has... | [{"input": "50\n5 42 16 13 20 2 39 49 33 1 11 4 46 3 48 44 12 7 27 41 35 38 26 6 31 37 10 50 24 9 32 15 47 30 17 28 22 29 23 34 8 18 40 21 19 36 25 43 45 14\n427 -3 -165 -161 302 -337 285 -418 227 -78 -453 -122 -162 -249 -194 119 -127 322 -238 467 -236 254 263 -57 225 391 270 -96 -173 329 -45 133 -36 449 -3 168 -490 15... | code_stdio |
[
{
"content": "# Summary:\nGiven a number, `num`, return the shortest amount of `steps` it would take from 1, to land exactly on that number.\n\n# Description:\nA `step` is defined as either:\n- Adding 1 to the number: `num += 1`\n- Doubling the number: `num *= 2`\n\nYou will always start from the number `1` and... | [{"input": "10000", "output": "[17]", "fn_name": "shortest_steps_to_num"}, {"input": "1500", "output": "[16]", "fn_name": "shortest_steps_to_num"}, {"input": "1534", "output": "[18]", "fn_name": "shortest_steps_to_num"}, {"input": "1978", "output": "[17]", "fn_name": "shortest_steps_to_num"}, {"input": "2763", "output"... | code_functional |
[
{
"content": "Given is an integer S.\nFind how many sequences there are whose terms are all integers greater than or equal to 3, and whose sum is equal to S.\nThe answer can be very large, so output it modulo 10^9 + 7.\n\n-----Constraints-----\n - 1 \\leq S \\leq 2000\n - All values in input are integers.\n\n--... | [{"input": "1729\n", "output": "294867501\n"}, {"input": "2000\n", "output": "883312678\n"}, {"input": "1445\n", "output": "157799856\n"}, {"input": "1447\n", "output": "185357934\n"}, {"input": "1497\n", "output": "661810862\n"}, {"input": "1202\n", "output": "751905815\n"}, {"input": "522\n", "output": "272885863\n"}... | code_stdio |
[
{
"content": "A variation of determining leap years, assuming only integers are used and years can be negative and positive.\n\nWrite a function which will return the days in the year and the year entered in a string. For example 2000, entered as an integer, will return as a string 2000 has 366 days\n\nThere a... | [{"input": "2016", "output": "[\"2016 has 366 days\"]", "fn_name": "year_days"}, {"input": "1974", "output": "[\"1974 has 365 days\"]", "fn_name": "year_days"}, {"input": "1857", "output": "[\"1857 has 365 days\"]", "fn_name": "year_days"}, {"input": "2000", "output": "[\"2000 has 366 days\"]", "fn_name": "year_days"},... | code_functional |
[
{
"content": "There is a building with 2N floors, numbered 1, 2, \\ldots, 2N from bottom to top.\nThe elevator in this building moved from Floor 1 to Floor 2N just once.\nOn the way, N persons got on and off the elevator. Each person i (1 \\leq i \\leq N) got on at Floor A_i and off at Floor B_i. Here, 1 \\leq ... | [{"input": "100\n65 165\n6 106\n41 141\n1 101\n4 104\n33 133\n5 105\n57 157\n98 198\n15 115\n52 152\n53 153\n46 146\n29 129\n42 142\n8 108\n12 112\n69 169\n47 147\n87 187\n79 179\n88 188\n67 167\n26 126\n55 155\n73 173\n72 172\n74 174\n95 195\n36 136\n61 161\n10 110\n17 117\n7 107\n23 123\n30 130\n14 114\n90 190\n66 16... | code_stdio |
[
{
"content": "Mr. Square is going on a holiday. He wants to bring 2 of his favorite squares with him, so he put them in his rectangle suitcase.\n\nWrite a function that, given the size of the squares and the suitcase, return whether the squares can fit inside the suitcase.\n```Python\nfit_in(a,b,m,n)\na,b are t... | [{"input": "10\n10\n11\n11", "output": "[false]", "fn_name": "fit_in"}, {"input": "1\n2\n2\n1", "output": "[false]", "fn_name": "fit_in"}, {"input": "3\n2\n3\n2", "output": "[false]", "fn_name": "fit_in"}, {"input": "1\n2\n1\n2", "output": "[false]", "fn_name": "fit_in"}, {"input": "6\n5\n8\n7", "output": "[false]", "f... | code_functional |
[
{
"content": "There are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \\dots, x_N) and (y_1, y_2, \\dots, y_N) are both permuations of (1, 2, \\dots, N).\n\nFor each k = 1,2,\\dots,N, find the answer to the following question:\n\nRng is in City k. Rng can perform the fol... | [{"input": "7\n6 4\n4 2\n3 5\n7 1\n2 7\n5 3\n1 6", "output": "3\n3\n1\n1\n2\n3\n2\n"}, {"input": "7\n6 4\n4 3\n3 5\n7 1\n2 6\n5 2\n1 7", "output": "3\n3\n1\n1\n1\n3\n1\n"}, {"input": "7\n6 4\n4 3\n3 5\n7 1\n2 7\n5 2\n1 6", "output": "3\n3\n1\n1\n2\n3\n2"}, {"input": "4\n2 4\n1 3\n3 1\n4 2", "output": "2\n2\n2\n2\n"}, {... | code_stdio |
[
{
"content": "Contest T-shirts\n\nSegtree has $ M $ contest T-shirts.\n\nHe decided to spend $ N $ days on the contest T-shirt alone, and told $ i = 1, 2, 3, \\ dots, N $ \"$ A_i $ T-shirt on the $ i $ day.\" I made a plan for $ N $ to wear.\n\nHowever, if you keep the current plan, you may not be able to do th... | [{"input": "11 0\n2 2 -1", "output": "0\n"}, {"input": "-1 0\n3 0 -1", "output": "0\n"}, {"input": "0 1\n2 -1 -2", "output": "0\n"}, {"input": "0 0\n-1 3 -2", "output": "0\n"}, {"input": "-1 0\n2 3 -1", "output": "0\n"}, {"input": "11 0\n2 0 -2", "output": "0\n"}, {"input": "-1 0\n-1 0 0", "output": "0\n"}, {"input": "... | code_stdio |
[
{
"content": "Vasya has recently got a job as a cashier at a local store. His day at work is $L$ minutes long. Vasya has already memorized $n$ regular customers, the $i$-th of which comes after $t_{i}$ minutes after the beginning of the day, and his service consumes $l_{i}$ minutes. It is guaranteed that no cus... | [{"input": "1 1000000000 1\n0 1000000000\n", "output": "0\n"}, {"input": "1 1000000000 1\n0 1000000000\n", "output": "0"}, {"input": "0 1000000000 1\n", "output": "1000000000\n"}, {"input": "0 1000000000 1000000000\n", "output": "1\n"}, {"input": "0 1000000000 1000000010\n", "output": "0\n"}, {"input": "0 1000010000 10... | code_stdio |
[
{
"content": "There is a directed graph with N vertices and M edges.\nThe i-th edge (1≤i≤M) points from vertex a_i to vertex b_i, and has a weight c_i.\nWe will play the following single-player game using this graph and a piece.\nInitially, the piece is placed at vertex 1, and the score of the player is set to ... | [{"input": "6 5\n1 2 -1000000000\n2 3 -1000000000\n3 4 -1000000000\n4 5 -1000000000\n5 6 -1000000000\n", "output": "-5000000000\n"}, {"input": "6 5\n1 2 -1000000000\n2 3 -1000000000\n3 5 -1000000000\n4 5 -1000000000\n5 6 -1000000000", "output": "-4000000000\n"}, {"input": "6 5\n1 2 -1000000000\n2 3 -1000000000\n3 5 -12... | code_stdio |
[
{
"content": "Bridge Removal\n\nICPC islands once had been a popular tourist destination. For nature preservation, however, the government decided to prohibit entrance to the islands, and to remove all the man-made structures there. The hardest part of the project is to remove all the bridges connecting the isl... | [{"input": "4\n1 2 3\n10 37 30\n10\n1 2 2 1 1 5 1 10 8\n10 2 1 20 2 1 30 1 1\n3\n1 1\n1 1\n0", "output": "114\n139\n2\n"}, {"input": "4\n1 2 3\n10 37 52\n10\n1 2 2 1 1 5 1 10 8\n10 2 1 20 2 1 30 1 1\n3\n1 1\n1 1\n0", "output": "136\n139\n2\n"}, {"input": "4\n1 2 3\n10 30 30\n10\n1 2 2 1 1 5 1 8 8\n10 1 1 20 2 1 30 1 1\... | code_stdio |
[
{
"content": "Polycarpus has a sequence, consisting of n non-negative integers: a1, a2, ..., an.\n\nLet's define function f(l, r) (l, r are integer, 1 ≤ l ≤ r ≤ n) for sequence a as an operation of bitwise OR of all the sequence elements with indexes from l to r. Formally: f(l, r) = al | al + 1 | ... | ar. \n\n... | [{"input": "10\n375813 659427 484038 348181 432640 368050 271089 721588 345312 630771\n", "output": "29\n"}, {"input": "10\n1 1 3 4 5 12 1 2 9 10\n", "output": "12\n"}, {"input": "10\n6 8 11 5 1 9 10 2 4 7\n", "output": "13\n"}, {"input": "10\n1 1 3 1 5 12 1 2 9 10\n", "output": "11\n"}, {"input": "10\n1 1 3 1 5 12 1 2... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nChef likes problems involving arrays. Unfortunately, the last one he tried to solve didn't quite get solved.\n\nChef has an array A of N positive numbers. He wants to find the number of subarrays for which the sum an... | [{"input": "3\n3\n3 0 0\n4\n3 2 0 1\n6\n1 0 -1 0 1 0", "output": "4\n4\n12\n"}, {"input": "3\n3\n1 0 0\n4\n3 2 0 1\n6\n0 0 -1 0 1 0", "output": "4\n4\n13\n"}, {"input": "3\n3\n1 3 2\n4\n4 2 6 -1\n6\n2 1 2 -1 2 1", "output": "4\n4\n6\n"}, {"input": "3\n3\n1 0 2\n4\n4 1 2 1\n6\n1 3 2 2 2 2", "output": "3\n5\n10\n"}, {"in... | code_stdio |
[
{
"content": "We have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\nYou can perform the following operation at most once: choose integers i and j (1 \\leq i < j \\leq N), and swap p_i and p_j. Note that you can also choose not to perform it.\nPrint YES if you can sor... | [{"input": "50\n43 20 27 29 33 34 2 15 50 18 23 3 13 19 12 1 11 7 32 48 35 36 41 44 22 24 6 30 45 46 5 25 37 16 26 4 47 39 28 8 42 9 31 21 10 49 40 17 14 38\n", "output": "NO\n"}, {"input": "44\n1 2 3 4 5 6 7 8 9 10 22 12 13 14 15 16 17 18 19 20 21 11 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44\n"... | code_stdio |
[
{
"content": "You get a \"text\" and have to shift the vowels by \"n\" positions to the right.\n(Negative value for n should shift to the left.)\n\"Position\" means the vowel's position if taken as one item in a list of all vowels within the string.\nA shift by 1 would mean, that every vowel shifts to the place... | [{"input": "\"This is a test!\"\n-1", "output": "[\"This as e tist!\"]", "fn_name": "vowel_shift"}, {"input": "\"This is a test!\"\n-5", "output": "[\"This as e tist!\"]", "fn_name": "vowel_shift"}, {"input": "\"This is a test!\"\n0", "output": "[\"This is a test!\"]", "fn_name": "vowel_shift"}, {"input": "\"This is a ... | code_functional |
[
{
"content": "Mahmoud and Ehab play a game called the even-odd game. Ehab chooses his favorite integer n and then they take turns, starting from Mahmoud. In each player's turn, he has to choose an integer a and subtract it from n such that: 1 ≤ a ≤ n. If it's Mahmoud's turn, a has to be even, but if it's Ehab... | [{"input": "1001000000\n", "output": "Mahmoud\n"}, {"input": "1011000000\n", "output": "Mahmoud\n"}, {"input": "1165278070\n", "output": "Mahmoud\n"}, {"input": "1425124860\n", "output": "Mahmoud\n"}, {"input": "1000000000\n", "output": "Mahmoud"}, {"input": "1000000000\n", "output": "Mahmoud"}, {"input": "691838234\n"... | code_stdio |
[
{
"content": "Ari the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that consists of n cities, connected by n - 1 bidirectional roads. Every road connects exactly two distinct cities, and the whole road system is designed in a way t... | [{"input": "63 20\n35 26\n54 5\n32 56\n56 53\n59 46\n37 31\n46 8\n4 1\n2 47\n59 42\n55 11\n62 6\n30 7\n60 24\n41 36\n34 22\n24 34\n21 2\n12 52\n8 44\n60 21\n24 30\n48 35\n48 25\n32 57\n20 37\n11 54\n11 62\n42 58\n31 43\n12 23\n55 48\n51 55\n41 27\n25 33\n21 18\n42 12\n4 15\n51 60\n62 39\n46 41\n57 9\n30 61\n31 4\n58 13... | code_stdio |
[
{
"content": "Takahashi recorded his daily life for the last few days as a integer sequence of length 2N, as follows:\n\n* a_1, b_1, a_2, b_2, ... , a_N, b_N\n\n\n\nThis means that, starting from a certain time T, he was:\n\n* sleeping for exactly a_1 seconds\n* then awake for exactly b_1 seconds\n* then sleepi... | [{"input": "10\n43196 57600\n4800 9600\n6000 1200\n600 600\n300 600\n5400 600\n6000 5760\n6760 2880\n6000 12000\n9000 600", "output": "5\n"}, {"input": "10\n43196 57600\n4800 9600\n6000 1200\n600 600\n300 600\n5400 600\n6000 5760\n6760 2880\n6000 12000\n9000 794", "output": "5\n"}, {"input": "10\n43196 21072\n8364 1124... | code_stdio |
[
{
"content": "You are given a string s of length n consisting of lowercase English letters.\n\nFor two given strings s and t, say S is the set of distinct characters of s and T is the set of distinct characters of t. The strings s and t are isomorphic if their lengths are equal and there is a one-to-one mapping... | [{"input": "10 30\naccbaaccac\n6 8 3\n2 9 1\n6 8 3\n10 5 1\n6 2 2\n1 4 7\n3 10 1\n6 9 1\n7 7 3\n7 3 2\n8 4 1\n4 9 1\n7 6 4\n6 8 2\n10 2 1\n1 3 5\n5 10 1\n7 10 1\n4 1 2\n8 5 3\n9 8 1\n8 6 2\n6 9 2\n10 3 1\n3 9 1\n5 5 5\n1 5 6\n4 2 6\n10 7 1\n9 8 2\n", "output": "NO\nYES\nNO\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nYES\nNO\... | code_stdio |
[
{
"content": "You are given an array $a$ of length $n$ that has a special condition: every element in this array has at most 7 divisors. Find the length of the shortest non-empty subsequence of this array product of whose elements is a perfect square.\n\nA sequence $a$ is a subsequence of an array $b$ if $a$ ca... | [{"input": "8\n6 15 35 129 143 221 34 26\n", "output": "3\n"}, {"input": "8\n6 15 35 129 143 221 3 26\n", "output": "-1\n"}, {"input": "8\n6 15 35 129 143 221 3 51\n", "output": "-1\n"}, {"input": "8\n6 11 35 129 143 221 3 51\n", "output": "5\n"}, {"input": "8\n6 15 35 77 143 221 34 26\n", "output": "3"}, {"input": "8\... | code_stdio |
[
{
"content": "Taro and Jiro will play the following game against each other.\n\nInitially, they are given a sequence a = (a_1, a_2, \\ldots, a_N). Until a becomes empty, the two players perform the following operation alternately, starting from Taro:\n\n* Remove the element at the beginning or the end of a. The... | [{"input": "10\n1000000000 0 1000000000 1 1000000000 1 1000000000 1 1000000000 1", "output": "4999999996\n"}, {"input": "10\n1000000000 1 1000000000 1 1000000000 2 1000000000 1 1000000000 1", "output": "4999999994\n"}, {"input": "10\n1000000000 0 1000000000 1 1000000000 1 1010000000 1 1000000000 1", "output": "50099999... | code_stdio |
[
{
"content": "Four-digit palindromes start with `[1001,1111,1221,1331,1441,1551,1551,...]` and the number at position `2` is `1111`. \n\nYou will be given two numbers `a` and `b`. Your task is to return the `a-digit` palindrome at position `b` if the palindromes were arranged in increasing order. \n\nTherefore... | [{"input": "6\n20", "output": "[119911]", "fn_name": "palin"}, {"input": "7\n3", "output": "[1002001]", "fn_name": "palin"}, {"input": "5\n19", "output": "[11811]", "fn_name": "palin"}, {"input": "6\n3", "output": "[102201]", "fn_name": "palin"}, {"input": "3\n10", "output": "[191]", "fn_name": "palin"}, {"input": "4\n... | code_functional |
[
{
"content": "Given are three positive integers A, B, and C. Compute the following value modulo 998244353:\n\\sum_{a=1}^{A} \\sum_{b=1}^{B} \\sum_{c=1}^{C} abc\n\n-----Constraints-----\n - 1 \\leq A, B, C \\leq 10^9\n\n-----Input-----\nInput is given from standard input in the following format:\nA B C\n\n-----O... | [{"input": "1000000000 987654321 123456789\n", "output": "951633476\n"}, {"input": "192279221 156648747 154396385\n", "output": "152138957\n"}, {"input": "264704198 120999147 136987925\n", "output": "24444247\n"}, {"input": "682152024 451794315 2028038\n", "output": "579633067\n"}, {"input": "693 299 737\n", "output": ... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is the constraints.\n\nVova likes pictures with kittens. The news feed in the social network he uses can be represented as an array of $n$ consecutive pictures (with kittens, of course). Vova likes all these pictures, but some are more beautiful t... | [{"input": "25 4 15\n172043124 384297369 650214870 426077944 587045971 576701397 865475689 261462255 763837593 285228401 629011531 611623799 456424430 820020943 166915939 903479811 357808031 561107351 177427070 14589838 994169358 1227795556 193684940 439658261 237500762\n", "output": "10512644504\n"}, {"input": "25 4 1... | code_stdio |
[
{
"content": "Problem statement\n\nAOR Ika got a cabbage with $ N $ leaves. The leaves of this cabbage are numbered $ 1, \\ ldots, N $ in order from the outside, and the dirtiness of the $ i $ th leaf is $ D_i $. The larger this value is, the worse the degree of dirt is. AOR Ika-chan decided to use the cabbage ... | [{"input": "16 6 10 -1\n24 1 4 -1 0", "output": "1\n"}, {"input": "16 6 10 -1\n24 1 5 -1 0", "output": "1\n"}, {"input": "21 10 0 4\n5 2 13 -1 0", "output": "3\n"}, {"input": "16 6 10 -1\n24 1 4 0 1", "output": "1\n"}, {"input": "16 6 10 -1\n24 1 4 0 0", "output": "1\n"}, {"input": "16 6 10 0\n24 1 5 -1 0", "output": "... | code_stdio |
[
{
"content": "Most languages have a `split` function that lets you turn a string like `“hello world”` into an array like`[“hello”, “world”]`. But what if we don't want to lose the separator? Something like `[“hello”, “ world”]`.\n\n#### Task:\n\nYour job is to implement a function, (`split_without_loss` in Ruby... | [{"input": "\"hello world! hello world!\"\n\"hello wo|rld!\"", "output": "[[\"hello wo\", \"rld! hello wo\", \"rld!\"]]", "fn_name": "split_without_loss"}, {"input": "\"hello world! hello world!\"\n\" |\"", "output": "[[\"hello \", \"world! \", \"hello \", \"world!\"]]", "fn_name": "split_without_loss"}, {"input": "\"h... | code_functional |
[
{
"content": "The HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. \"Do I give such a hard task?\" — the HR manager thought. \"Just raise number 5 to the power of n and get last two digits of the number. Yes, of course, n can be rather big, and one can... | [{"input": "2000000000000000000\n", "output": "25\n"}, {"input": "1000000000000000000\n", "output": "25\n"}, {"input": "1000001000000000000\n", "output": "25\n"}, {"input": "1440563777463828705\n", "output": "25\n"}, {"input": "1000001000000010000\n", "output": "25\n"}, {"input": "1000001000000000100\n", "output": "25\... | code_stdio |
[
{
"content": "Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meeting said: 'I know for sure that either x or y did it!'\n\nT... | [{"input": "10 2\n10 2\n9 3\n9 4\n7 2\n4 6\n10 1\n9 2\n3 10\n7 1\n5 1\n", "output": "43\n"}, {"input": "10 3\n6 3\n6 10\n2 5\n5 7\n6 2\n9 2\n8 1\n10 5\n5 10\n7 6\n", "output": "34\n"}, {"input": "10 2\n10 2\n9 3\n9 4\n7 2\n4 6\n10 1\n9 2\n3 10\n7 1\n5 1\n", "output": "43\n"}, {"input": "10 3\n6 3\n6 10\n2 5\n5 7\n6 2\n... | code_stdio |
[
{
"content": "A `Nice array` is defined to be an array where for every value `n` in the array, there is also an element `n-1` or `n+1` in the array.\n\nexample:\n\n```\n[2,10,9,3] is Nice array because\n\n2=3-1\n10=9+1\n3=2+1\n9=10-1\n```\nWrite a function named `isNice`/`IsNice` that returns `true` if its arra... | [{"input": "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "output": "[true]", "fn_name": "is_nice"}, {"input": "[1, -1, 2, -2, 3, -3, 6]", "output": "[false]", "fn_name": "is_nice"}, {"input": "[3, 2, 10, 4, 1, 6]", "output": "[false]", "fn_name": "is_nice"}, {"input": "[0, 1, 3, -2, 5, 4]", "output": "[false]", "fn_name": "is_nice... | code_functional |
[
{
"content": "The only difference between the easy and the hard versions is constraints.\n\nA subsequence is a string that can be derived from another string by deleting some or no symbols without changing the order of the remaining symbols. Characters to be deleted are not required to go successively, there ca... | [{"input": "100 1000000000000\ndjgykfqaywhkhpocyxcpvbiiouyielmighclnuopadzuvrirbecucwnzwahahagvfstbxxaednajfauscxwttiglbbxtomnnalcl\n", "output": "8854753825335\n"}, {"input": "100 1000000000000\ndjgykfqaywhkhpocyxcpvbiiouyielmighclnuopadzuvrirbecucwnzwahahagvfstbxxaednajfauscxwttiglbbxtomnnalcl\n", "output": "88547538... | code_stdio |
[
{
"content": "C: Only one subsequence --Unique Subsequence-\n\nproblem\n\nOne day Ebi-chan noticed that a text string T of length n and a pattern string P (m \\ leq n) of length m were placed on the desk. Ebi-chan loves the \"only one subsequence\" that appears in strings, so she immediately began investigating... | [{"input": "aziucamp\nazu", "output": "yes\n"}, {"input": "azjucamp\nazu", "output": "yes\n"}, {"input": "aizucamp\nuza", "output": "no\n"}, {"input": "azjucamp\nazt", "output": "no\n"}, {"input": "azjucamp\nzat", "output": "no\n"}, {"input": "pmacujza\nzat", "output": "no\n"}, {"input": "pmacuiza\nzat", "output": "no\... | code_stdio |
[
{
"content": "Suppose you are given a string $s$ of length $n$ consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.\n\nTo compress the string, you have to represent $s$ as a concatenation of several non-empty strings: $s = t_{1} t_{2} \\ldots t_{k}$. The ... | [{"input": "255 3880 4590\nwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwkwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwawgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwkwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgw\n", "output": "62460\n"}, {"input": "... | code_stdio |
[
{
"content": "Petya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, find the next number. Now Petya can solve only problems with arithmetic or geometric progressions.\n\nArithmetic progression is a sequence a_1, a_1 + d, a_1 + 2d, ..., a_1 + (n - 1)d, where a... | [{"input": "64 160 400 1000\n", "output": "2500\n"}, {"input": "992 994 1419 1000\n", "output": "42\n"}, {"input": "1000 980 1495 906\n", "output": "42\n"}, {"input": "992 429 1419 1000\n", "output": "42\n"}, {"input": "836 624 412 200\n", "output": "-12\n"}, {"input": "1 334 667 1000\n", "output": "1333\n"}, {"input":... | code_stdio |
[
{
"content": "Happy traveller [Part 1]\n\nThere is a play grid NxN; Always square! \n\n 0 1 2 3\n0 [o, o, o, X]\n1 [o, o, o, o]\n2 [o, o, o, o]\n3 [o, o, o, o]\n\n\nYou start from a random point. I mean, you are given the coordinates of your start position in format (row, col). \n\nAnd your TASK is to defi... | [{"input": "6\n[5, 0]", "output": "[252]", "fn_name": "count_paths"}, {"input": "7\n[6, 0]", "output": "[924]", "fn_name": "count_paths"}, {"input": "5\n[4, 0]", "output": "[70]", "fn_name": "count_paths"}, {"input": "1\n[0, 0]", "output": "[0]", "fn_name": "count_paths"}, {"input": "2\n[1, 0]", "output": "[2]", "fn_na... | code_functional |
[
{
"content": "You are given an array a consisting of n integers.\n\nLet min(l, r) be the minimum value among a_l, a_{l + 1}, …, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, …, a_r.\n\nYour task is to choose three positive (greater than 0) integers x, y and z such that:\n\n * x + y + z = n; \n ... | [{"input": "8\n3\n1000000000 1000000000 1000000000\n3\n1 1000000000 1000000000\n3\n1000000000 1 1000000000\n3\n1 1 1000000000\n3\n1000000000 1000000000 1\n3\n1 1000000000 1\n3\n1000000000 1 1\n3\n1 1 1\n", "output": "YES\n1 1 1\nNO\nNO\nNO\nNO\nNO\nNO\nYES\n1 1 1\n"}, {"input": "8\n3\n1000000000 1000000000 1000000000\n... | code_stdio |
[
{
"content": "Bear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention the sponsor name in the statement. Limak takes it seriously and he is going to change some words. To make it still possible to read, he will try to modify each word as little as possible.\n... | [{"input": "75\nVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\n", "output": "1406\n"}, {"input": "75\nVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\n", "output": "1406\n"}, {"input": "75\nVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVK... | code_stdio |
[
{
"content": "It can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, where k and r are integers, k ≥ 0, 0 < r ≤ 2k. Let's call that representation prairie partition of x.\n\nFor example, the prairie partitions of 12, 17, 7 and 1 are: \n\n12 = 1 + 2 + 4 + 5,\... | [{"input": "100\n1 1 1 1 1 1 1 2 2 2 2 2 2 2 4 4 4 4 4 4 4 6 8 8 8 8 8 8 8 10 16 16 16 16 16 16 16 17 22 24 24 30 32 32 32 46 32 32 48 62 64 108 65 65 67 70 74 88 89 98 99 101 101 109 121 127 128 128 137 143 152 153 155 156 160 161 114 183 186 196 196 214 220 226 228 230 238 240 241 245 249 249 250 253 254 256 256 512 ... | code_stdio |
[
{
"content": "The central dogma of molecular biology is that DNA is transcribed into RNA, which is then tranlsated into protein. RNA, like DNA, is a long strand of nucleic acids held together by a sugar backbone (ribose in this case). Each segment of three bases is called a codon. Molecular machines called ribo... | [{"input": "\"AUGUAUCCUUCCAUCAAGGAAACCAUGCGCGUUCAGCUUUCUAUGGAGGGUAGUGUUAACUACCACGCCUUCAAGUGCACUGGAAAAGGAGAGGGAAAACCAUACGAAGGCACCCAAAGCCUGAAUAUUACAAUAACUGAAGGAGGUCCUCUGCCAUUUGCUUUUGACAUUCUGUCACACGCCUUUCAGUAUGGCAUCAAGGUCUUCGCCAAGUACCCCAAAGAAAUUCCUGACUUCUUUAAGCAGUCUCUACCUGGUGGUUUUUCUUGGGAAAGAGUAAGCACCUAUGAAGAUGGAGGAGUGCUU... | code_functional |
[
{
"content": "For any positive integer, we define a digit rotation as either moving the first digit\nto the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).\nFor example, the number 12345 could be left digit rotated to 23451, or right digit rotated to... | [{"input": "6\n12345\n43634\n21427\n211011\n7\n166", "output": "51234\n63443\n72142\n211011\n7\n661\n"}, {"input": "6\n23325\n43634\n21427\n211011\n7\n166", "output": "52332\n63443\n72142\n211011\n7\n661\n"}, {"input": "6\n23325\n43634\n21427\n211011\n1\n166", "output": "52332\n63443\n72142\n211011\n1\n661\n"}, {"input... | code_stdio |
[
{
"content": "We have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left. We will choose K of the squares and put a piece on each of them.\nIf we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K, y_K), the cost ... | [{"input": "155776 1 112696\n", "output": "837491985\n"}, {"input": "200000 1 134405\n", "output": "945631888\n"}, {"input": "491 405 148903\n", "output": "206234613\n"}, {"input": "435 448 126173\n", "output": "779238467\n"}, {"input": "454 424 168618\n", "output": "804548732\n"}, {"input": "488 405 176503\n", "output... | code_stdio |
[
{
"content": "Given two integers `a` and `b`, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return `a` or `b`.\n\n**Note:** `a` and `b` are not ordered!\n\n## Examples\n\n```python\nget_sum(1, 0) == 1 // 1 + 0 = 1\nget... | [{"input": "-321\n123", "output": "[-44055]", "fn_name": "get_sum"}, {"input": "-505\n4", "output": "[-127755]", "fn_name": "get_sum"}, {"input": "321\n123", "output": "[44178]", "fn_name": "get_sum"}, {"input": "505\n4", "output": "[127759]", "fn_name": "get_sum"}, {"input": "-50\n0", "output": "[-1275]", "fn_name": "... | code_functional |
[
{
"content": "Being a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisting of n distinct integers.\n\nUnfortunately, the size of a is too small. You want a bigger array! Your friends agree to give you a bigger array, but only if you are able to answer the follo... | [{"input": "40\n22993199 75843013 76710455 99749069 105296587 122559115 125881005 153961749 163646706 175409222 185819807 214465092 264449243 278246513 295514446 322935239 370349154 375773209 390474983 775646826 767329655 740310077 718820037 708508595 693119912 680958422 669537382 629123011 607511013 546574974 54657213... | code_stdio |
[
{
"content": "Given a number, write a function to output its reverse digits. (e.g. given 123 the answer is 321)\n\n\nNumbers should preserve their sign; i.e. a negative number should still be negative when reversed.\n\n### Examples\n```\n 123 -> 321\n-456 -> -654\n1000 -> 1\n```\n\nWrite Python code to sol... | [{"input": "98989898", "output": "[89898989]", "fn_name": "reverse_number"}, {"input": "4321234", "output": "[4321234]", "fn_name": "reverse_number"}, {"input": "-123", "output": "[-321]", "fn_name": "reverse_number"}, {"input": "123", "output": "[321]", "fn_name": "reverse_number"}, {"input": "1000", "output": "[1]", ... | code_functional |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.