messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "After reaching your destination, you want to build a new colony on the new planet. Since this planet has many mountains and the colony must be built on a flat surface you decided to flatten the mountains using boulders (you are still dreaming so this makes sense to you).\n\nYou are given an array ...
[{"input": "20\n5 166\n11 21 31 41 51\n5 37\n11 21 31 41 51\n5 231\n11 21 31 41 51\n5 58\n11 21 31 41 51\n5 157\n11 21 31 41 51\n5 179\n11 21 31 41 51\n5 150\n11 21 31 41 51\n5 122\n11 20 27 37 47\n5 204\n11 21 31 41 51\n5 62\n3 13 23 8 43\n5 136\n43 58 51 86 34\n5 42\n31 25 62 45 100\n5 36\n20 26 37 5 69\n5 169\n41 99...
code_stdio
[ { "content": "For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and an integer $S$, find the smallest sub-array size (smallest window length) where the sum of the sub-array is greater than or equal to $S$. If there is not such sub-array, report 0.\n\nConstraints\n\n* $1 \\leq N \\leq 10^5$\n* $1 \\le...
[{"input": "12 5\n0 2 0 3 10 7", "output": "1\n"}, {"input": "12 5\n1 2 0 3 10 7", "output": "1\n"}, {"input": "13 5\n1 2 0 3 10 7", "output": "1\n"}, {"input": "24 5\n1 2 0 3 10 7", "output": "1\n"}, {"input": "24 5\n1 2 1 3 10 7", "output": "1\n"}, {"input": "41 5\n1 2 1 3 10 7", "output": "1\n"}, {"input": "53 5\n1 ...
code_stdio
[ { "content": "Jenny is 9 years old. She is the youngest detective in North America. Jenny is a 3rd grader student, so when a new mission comes up, she gets a code to decipher in a form of a sticker (with numbers) in her math notebook and a comment (a sentence) in her writing notebook. All she needs to do is to ...
[{"input": "[1, 16, 21]\n\"A purple pig and a green donkey flew a kite in the middle of the night\"", "output": "[\"pen\"]", "fn_name": "missing"}, {"input": "[18, 25, 45]\n\"are you going to have a funnel birthday cake for your next birthday\"", "output": "[\"fix\"]", "fn_name": "missing"}, {"input": "[35, 8, 20]\n\"A...
code_functional
[ { "content": "B: Periodic Sequence-\n\nproblem\n\nDr. Period, a professor at H University, is studying a property called the cycle that is supposed to be hidden in all things. As a generally known basic cycle, a cycle hidden in a sequence may be considered. That is, if the sequence S = S_1, S_2, ..., S_N of len...
[{"input": "6\n-1 -14 10 -3 2 -1", "output": "1\n"}, {"input": "6\n-1 -14 18 -3 2 -1", "output": "1\n"}, {"input": "6\n-1 -14 18 -1 2 -1", "output": "1\n"}, {"input": "6\n-1 -10 18 -1 2 -1", "output": "1\n"}, {"input": "6\n0 -10 18 -2 -1 -2", "output": "1\n"}, {"input": "6\n-1 -10 8 -3 2 -1", "output": "1\n"}, {"input"...
code_stdio
[ { "content": "Generous sponsors of the olympiad in which Chloe and Vladik took part allowed all the participants to choose a prize for them on their own. Christmas is coming, so sponsors decided to decorate the Christmas tree with their prizes. \n\nThey took n prizes for the contestants and wrote on each of the...
[{"input": "10\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000\n7 8\n5 10\n8 6\n1 5\n7 9\n3 9\n2 10\n2 6\n4 3\n", "output": "Impossible"}, {"input": "10\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -10000000...
code_stdio
[ { "content": "Beroffice text editor has a wide range of features that help working with text. One of the features is an automatic search for typos and suggestions of how to fix them.\n\nBeroffice works only with small English letters (i.e. with 26 letters from a to z). Beroffice thinks that a word is typed with...
[{"input": "bababcdfabbcabcdfacbbabcdfacacabcdfacbcabcdfaccbabcdfacaaabcdfabacabcdfabcbabcdfacbaabcdfabaaabcdfabbaabcdfacababcdfabbbabcdfabcaabcdfaaababcdfabccabcdfacccabcdfaacbabcdfaabaabcdfaabcabcdfaaacabcdfaccaabcdfaabbabcdfaaaaabcdfaacaabcdfaacc\n", "output": "bababc dfabb cabc dfacb babc dfacacabc dfacb cabc dfacc...
code_stdio
[ { "content": "Create a function which accepts one arbitrary string as an argument, and return a string of length 26.\n\nThe objective is to set each of the 26 characters of the output string to either `'1'` or `'0'` based on the fact whether the Nth letter of the alphabet is present in the input (independent of...
[{"input": "\"&%&%/$%$%$%$%GYtf67fg34678hgfdyd\"", "output": "[\"00010111000000000001000010\"]", "fn_name": "change"}, {"input": "\"abcdefghijklmnopqrstuvwxyz\"", "output": "[\"11111111111111111111111111\"]", "fn_name": "change"}, {"input": "\"Abc e $$ z\"", "output": "[\"11101000000000000000000001\"]", "fn_name": "c...
code_functional
[ { "content": "The translation from the Berland language into the Birland language is not an easy task. Those languages are very similar: a berlandish word differs from a birlandish word with the same meaning a little: it is spelled (and pronounced) reversely. For example, a Berlandish word code corresponds to a...
[{"input": "vxpqullmcbegsdskddortcvxyqlbvxmmkhevovnezubvpvnrcajpxraeaxizgaowtfkzywvhnbgzsxbhkaipcmoumtikkiyyaivg\ngviayyikkitmuomcpiakhbxszgbnhvwyzkftwoagzixaearxpjacrnvpvbuzenvovehkmmxvblqyxvctroddksdsgebcmlluqpxv\n", "output": "YES\n"}, {"input": "dgxmzbqofstzcdgthbaewbwocowvhqpinehpjatnnbrijcolvsatbblsrxabzrpszoiecp...
code_stdio
[ { "content": "If you finish this kata, you can try [Insane Coloured Triangles](http://www.codewars.com/kata/insane-coloured-triangles) by Bubbler, which is a ***much*** harder version of this one.\n\nA coloured triangle is created from a row of colours, each of which is red, green or blue. Successive rows, each...
[{"input": "\"RBRGBRBGGRRRBGBBBGG\"", "output": "[\"G\"]", "fn_name": "triangle"}, {"input": "\"RBRGBRB\"", "output": "[\"G\"]", "fn_name": "triangle"}, {"input": "\"RGBG\"", "output": "[\"B\"]", "fn_name": "triangle"}, {"input": "\"RRR\"", "output": "[\"R\"]", "fn_name": "triangle"}, {"input": "\"GB\"", "output": "[\"...
code_functional
[ { "content": "Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on eac...
[{"input": "420196140727489673 679891637638612258\n", "output": "1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B\n"}, {"input": "420196140727489673 679891637638612258\n", "output": "1B1A1B1A1B1A1B1...
code_stdio
[ { "content": "In a Berland's zoo there is an enclosure with camels. It is known that camels like to spit. Bob watched these interesting animals for the whole day and registered in his notepad where each animal spitted. Now he wants to know if in the zoo there are two camels, which spitted at each other. Help hi...
[{"input": "30\n-398 -1774\n313 -6974\n2346 -4657\n8552 -9647\n-5265 1538\n8195 4864\n-5641 -5219\n-1394 8563\n-1190 1992\n-4669 -1156\n7574 256\n9206 -2414\n4140 -549\n-294 2169\n7029 -2871\n3808 -9799\n3141 5690\n4648 -2680\n-5990 9800\n-2299 1697\n6077 -7177\n-400 -9724\n-4644 -2392\n-2198 -9531\n-2105 9386\n-8165 -...
code_stdio
[ { "content": "Remember the movie with David Bowie: 'The Labyrinth'?\n\nYou can remember your childhood here: https://www.youtube.com/watch?v=2dgmgub8mHw\n\nIn this scene the girl is faced with two 'Knights\" and two doors. One door leads the castle where the Goblin King and her kid brother is, the other leads t...
[{"input": "\"not True and False or False or False\"", "output": "[\"Knave! Do not trust.\"]", "fn_name": "knight_or_knave"}, {"input": "\"3 is 3 is 3 is 9\"", "output": "[\"Knave! Do not trust.\"]", "fn_name": "knight_or_knave"}, {"input": "\"4 is \\\"blue\\\"\"", "output": "[\"Knave! Do not trust.\"]", "fn_name": "kn...
code_functional
[ { "content": "Mrs. Smith is trying to contact her husband, John Smith, but she forgot the secret phone number!\n\nThe only thing Mrs. Smith remembered was that any permutation of $n$ can be a secret phone number. Only those permutations that minimize secret value might be the phone of her husband.\n\nThe sequen...
[{"input": "11110\n", "output": "11006 11007 11008 11009 11010 11011 11012 11013 11014 11015 11016 11017 11018 11019 11020 11021 11022 11023 11024 11025 11026 11027 11028 11029 11030 11031 11032 11033 11034 11035 11036 11037 11038 11039 11040 11041 11042 11043 11044 11045 11046 11047 11048 11049 11050 11051 11052 11053...
code_stdio
[ { "content": "You are given two lists of segments $[al_1, ar_1], [al_2, ar_2], \\dots, [al_n, ar_n]$ and $[bl_1, br_1], [bl_2, br_2], \\dots, [bl_n, br_n]$.\n\nInitially, all segments $[al_i, ar_i]$ are equal to $[l_1, r_1]$ and all segments $[bl_i, br_i]$ are equal to $[l_2, r_2]$.\n\nIn one step, you can choo...
[{"input": "3\n3 5\n1 2\n3 4\n2 1000000000\n1 1\n999999999 999999999\n10 3\n5 10\n7 8\n", "output": "7\n2000000000\n0\n"}, {"input": "3\n3 5\n1 2\n3 4\n1 1000000000\n1 1\n999999999 999999999\n10 3\n5 10\n7 8\n", "output": "7\n2000000000\n0\n"}, {"input": "3\n3 2\n1 2\n3 4\n1 1000000000\n1 1\n999999999 999999999\n10 3\n...
code_stdio
[ { "content": "Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the cell with coordinates (xi, yi). Vanya moves towards vector (dx, dy). That means that if Vanya is now at the cell (x, y), then in a second he will be at cell <image>. The followin...
[{"input": "2 15 1 1\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 -1\n0 0\n0 0\n0 0\n", "output": "0 0\n"}, {"input": "2 15 1 1\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 -1\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n", "output": "0 0\n"}, {"input": "2 15 1 1\n0 0\n0 1\n0 0\n0 1\n0 0\n0 1\n0 0\n0 1\n0 0\n0 1\n0 0\n0 1...
code_stdio
[ { "content": "Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month).\n\nUnfortunately, right after the doubling the wardrobe eats one of th...
[{"input": "314647997243943415 107188213956410843\n", "output": "109575135\n"}, {"input": "314647997243943415 107188213956410843\n", "output": "109575135\n"}, {"input": "316313018463929883 108989792589951708\n", "output": "398397727\n"}, {"input": "1497482167524343307 29585639347346605\n", "output": "228961297\n"}, {"i...
code_stdio
[ { "content": "You are given a connected undirected graph consisting of $n$ vertices and $m$ edges. There are no self-loops or multiple edges in the given graph.\n\nYou have to direct its edges in such a way that the obtained directed graph does not contain any paths of length two or greater (where the length of...
[{"input": "10 10\n9 2\n6 4\n2 10\n7 8\n8 6\n9 3\n2 6\n7 1\n7 4\n5 4\n", "output": "YES\n0010101000\n"}, {"input": "10 10\n1 3\n9 6\n4 5\n1 9\n8 6\n1 7\n3 2\n5 7\n5 3\n10 5\n", "output": "YES\n1001010110\n"}, {"input": "10 10\n4 3\n6 8\n5 3\n8 1\n2 9\n9 8\n3 6\n10 2\n9 3\n6 3\n", "output": "YES\n1110010111\n"}, {"input...
code_stdio
[ { "content": "It is a balmy spring afternoon, and Farmer John's n cows are ruminating about link-cut cacti in their stalls. The cows, labeled 1 through n, are arranged so that the i-th cow occupies the i-th stall from the left. However, Elsie, after realizing that she will forever live in the shadows beyond Bes...
[{"input": "100000 100000\n", "output": "4999950000\n"}, {"input": "100000 100000\n", "output": "4999950000\n"}, {"input": "100000 40000\n", "output": "4799960000\n"}, {"input": "100000 50000\n", "output": "4999950000\n"}, {"input": "100000 50001\n", "output": "4999950000\n"}, {"input": "100000 50002\n", "output": "499...
code_stdio
[ { "content": "In this Kata, you will be given a number and your task will be to rearrange the number so that it is divisible by `25`, but without leading zeros. Return the minimum number of digit moves that are needed to make this possible. If impossible, return `-1` ( `Nothing` in Haskell ).\n\nFor example:\n\...
[{"input": "5000033333337", "output": "[16]", "fn_name": "solve"}, {"input": "7000033333335", "output": "[8]", "fn_name": "solve"}, {"input": "50011111112", "output": "[12]", "fn_name": "solve"}, {"input": "50001111312", "output": "[13]", "fn_name": "solve"}, {"input": "72046951686", "output": "[12]", "fn_name": "solve...
code_functional
[ { "content": "Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.\n\nA little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the p...
[{"input": "btbdpnzdenxueteteytvkwnegodyhmdwhmrmbftrifytzudumzlacwytsuzefqfpjesdblxhpcsidgksisjdmhyxmmugrjmtfcgxmcgpmvbxbyszdugvmoyjeeqsywcvuqskcjotyhvdijyslgfvyujxthngnonasgnbzzygyikheelirdfsvuicbiazfdeqecbtbdpnzdenxueteteytvkwnegodyhmdwhmrmbftrifytzudumzlacwytsuzefqfpjesdblxhpcsidgksisjdmhyxmmugrjmtfcgxmcgpccdtdteoht...
code_stdio
[ { "content": "Your task is to write an update for a lottery machine. Its current version produces a sequence of random letters and integers (passed as a string to the function). Your code must filter out all letters and return **unique** integers as a string, in their order of first appearance. If there are no ...
[{"input": "\"ffaQtaRFKeGIIBIcSJtg\"", "output": "[\"One more run!\"]", "fn_name": "lottery"}, {"input": "\"wQ8Hy0y5m5oshQPeRCkG\"", "output": "[\"805\"]", "fn_name": "lottery"}, {"input": "\"20191224isXmas\"", "output": "[\"20194\"]", "fn_name": "lottery"}, {"input": "\"HappyNewYear2020\"", "output": "[\"20\"]", "fn_n...
code_functional
[ { "content": "ZS the Coder loves to read the dictionary. He thinks that a word is nice if there exists a substring (contiguous segment of letters) of it of length 26 where each letter of English alphabet appears exactly once. In particular, if the string has length strictly less than 26, no such substring exist...
[{"input": "LLVYUOXHBHUZSAPUMQEKWSQAFRKSMEENXDQYOPQFXNNFXSRBGXFUIRBFJDSDKQIDMCPPTWRJOZCRHZYZPBVUJPQXHNALAOCJDTTBDZWYDBVPMNSQNVMLHHUJAOIWFSEJEJSRBYREOZKHEXTBAXPTISPGIPOYBFFEJNAKKXAEPNGKWYGEJTNEZIXAWRSCEIRTKNEWSKSGKNIKDEOVXGYVEVFRGTNDFNWIFDRZQEJQZYIWNZXCONVZAKKKETPTPPXZMIVDWPGXOFODRNJZBATKGXAPXYHTUUFFASCHOLSMVSWBIJBAENEG...
code_stdio
[ { "content": "A permutation is a sequence of integers from 1 to n of length n containing each number exactly once. For example, (1), (4, 3, 5, 1, 2), (3, 2, 1) are permutations, and (1, 1), (4, 3, 1), (2, 3, 4) are not. \n\nThere are many tasks on permutations. Today you are going to solve one of them. Let’s im...
[{"input": "100\n9 6 3 28 10 2 2 11 2 1 25 3 13 5 14 13 4 14 2 16 12 27 8 1 7 9 8 19 33 23 4 1 15 6 7 12 2 8 30 4 1 31 6 1 15 5 18 3 2 24 7 3 1 20 10 8 26 22 3 3 9 6 1 10 1 5 1 3 7 6 11 10 1 16 19 5 9 4 4 4 2 18 12 21 11 5 2 32 17 29 2 4 8 1 7 5 3 2 17 1\n", "output": "12\n1 1 1 1 1 1 2 1 3 1 1 2 1 1 1 2 1 2 4 1 1 1 1 ...
code_stdio
[ { "content": "You are given a sequence with N integers: A = \\{ A_1, A_2, \\cdots, A_N \\}.\nFor each of these N integers, we will choose a color and paint the integer with that color. Here the following condition must be satisfied:\n - If A_i and A_j (i < j) are painted with the same color, A_i < A_j.\nFind th...
[{"input": "5\n10\n-1\n1\n13\n3", "output": "2\n"}, {"input": "5\n10\n-1\n6\n13\n3", "output": "3\n"}, {"input": "5\n10\n-1\n1\n13\n2", "output": "2\n"}, {"input": "5\n10\n-1\n6\n13\n5", "output": "3\n"}, {"input": "5\n10\n-1\n1\n13\n5", "output": "2\n"}, {"input": "5\n10\n-1\n6\n13\n6", "output": "3\n"}, {"input": "5\...
code_stdio
[ { "content": "Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortes...
[{"input": "10\n2 37526406560905229 37526426361107171\n2 37526424114740747 18763396439955441\n2 300485276957081578 301492476099962199\n1 75035386466351570 441803674395985082 642312512\n2 300197522144700185 220954108245114486\n1 150105696341181576 559187296 100113944\n1 300197522135707767 150242638470761995 170574370\n2...
code_stdio
[ { "content": "Vasya got really tired of these credits (from problem F) and now wants to earn the money himself! He decided to make a contest to gain a profit.\n\nVasya has $n$ problems to choose from. They are numbered from $1$ to $n$. The difficulty of the $i$-th problem is $d_i$. Moreover, the problems are gi...
[{"input": "22 936\n20 743\n55 46\n83 282\n157 3\n168 979\n241 338\n293 113\n312 292\n333 509\n339 632\n345 149\n347 109\n384 846\n420 151\n619 923\n647 336\n706 935\n726 600\n760 45\n804 126\n810 739\n906 341\n", "output": " 3371\n"}, {"input": "22 936\n20 743...
code_stdio
[ { "content": "You are given a permutation p consisting of n integers 1, 2, ..., n (a permutation is an array where each element from 1 to n occurs exactly once).\n\nLet's call an array a bipartite if the following undirected graph is bipartite:\n\n * the graph consists of n vertices; \n * two vertices i and j...
[{"input": "4\n3\n1 2 1\n6\n1 3 2 6 2 4\n4\n4 1 3 2\n8\n3 2 1 6 7 8 2 4\n", "output": "YES\n-1 -2 1\nYES\n-1 -3 2 6 2 4\nYES\n-4 -1 -3 2\nYES\n-3 -2 1 6 7 -8 2 4\n"}, {"input": "4\n3\n1 2 3\n6\n1 0 2 6 5 4\n4\n4 1 3 2\n8\n3 2 1 6 7 8 5 4\n", "output": "YES\n1 2 3\nYES\n-1 0 2 -6 -5 4\nYES\n-4 -1 -3 2\nYES\n-3 -2 1 6 7 ...
code_stdio
[ { "content": "We have N cards numbered 1, 2, ..., N. Card i (1 \\leq i \\leq N) has an integer A_i written in red ink on one side and an integer B_i written in blue ink on the other side. Initially, these cards are arranged from left to right in the order from Card 1 to Card N, with the red numbers facing up.\n...
[{"input": "5\n28 15 22 43 30\n20 22 43 33 32", "output": "-1"}, {"input": "5\n28 15 22 43 31\n20 22 43 33 32", "output": "-1"}, {"input": "5\n11 15 22 43 30\n20 22 43 33 32", "output": "1"}, {"input": "5\n4 46 6 31 43\n33 15 18 27 37", "output": "3"}, {"input": "5\n4 26 6 31 43\n33 15 18 27 37", "output": "3"}, {"inpu...
code_stdio
[ { "content": "Given is a sequence of integers A_1, A_2, ..., A_N.\nIf its elements are pairwise distinct, print YES; otherwise, print NO.\n\n-----Constraints-----\n - 2 ≤ N ≤ 200000\n - 1 ≤ A_i ≤ 10^9\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following f...
[{"input": "2\n10000000 10000000\n", "output": "NO\n"}, {"input": "2\n10000100 10000000", "output": "YES\n"}, {"input": "2\n10000100 10001000", "output": "YES\n"}, {"input": "2\n10000100 10101000", "output": "YES\n"}, {"input": "2\n10010100 10101000", "output": "YES\n"}, {"input": "2\n10010100 10101001", "output": "YES...
code_stdio
[ { "content": "Iahub got bored, so he invented a game to be played on paper.\n He writes n integers a1, a2, ..., an. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j (1 ≤ i ≤ j ≤ n) and flips all values ak for which their positions are in range [i, ...
[{"input": "[0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1]", "output": "[18]", "fn_name": "flipping_game"}, {"input": "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]", "output": "[22]", "fn_name": "flipping_game"}, {"input": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
code_functional
[ { "content": "Tokitsukaze has two colorful tapes. There are $n$ distinct colors, numbered $1$ through $n$, and each color appears exactly once on each of the two tapes. Denote the color of the $i$-th position of the first tape as $ca_i$, and the color of the $i$-th position of the second tape as $cb_i$.\n\nNow ...
[{"input": "1\n50\n4 50 11 27 15 29 2 9 12 39 31 1 6 17 32 28 7 24 36 3 18 49 37 35 33 21 48 19 26 5 20 45 14 13 34 40 42 16 44 43 41 25 38 23 30 10 22 8 47 46\n10 43 29 5 47 12 39 26 31 15 33 18 13 21 11 22 44 4 38 30 41 25 1 24 14 8 27 36 20 45 23 48 2 42 46 19 32 17 7 50 40 49 37 9 3 35 28 6 16 34\n", "output": "125...
code_stdio
[ { "content": "Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store — \"PriceFixed\". Here are some rules of that store:\n\nThe store has an infinite number of items of every product.\n\nAll products have the same price: $2$...
[{"input": "15\n1 18646259228611\n1 76062756486449\n1 5817259716888\n1 22110867828535\n1 100627485465221\n1 40799537235509\n1 56529154503793\n1 56148198559428\n1 77940886559829\n1 74079407528201\n1 6574734766207\n1 79264199999788\n1 19171266033881\n1 38437872037474\n1 34320923862986\n", "output": "30\n"}, {"input": "15...
code_stdio
[ { "content": "In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi.\n\nTakahashi checked and found that the time gap (defined below) between the local times in his city and the i-th person's city was D_i hours. The time gap between two cities is defined as follows. For ...
[{"input": "3\n7 12 11", "output": "1\n"}, {"input": "3\n8 12 11", "output": "1\n"}, {"input": "3\n10 12 8", "output": "2\n"}, {"input": "3\n9 12 8", "output": "3\n"}, {"input": "3\n8 12 0", "output": "0\n"}, {"input": "3\n4 12 8", "output": "4\n"}, {"input": "2\n12 12", "output": "0\n"}, {"input": "3\n7 12 8", "output...
code_stdio
[ { "content": "Snuke got positive integers s_1,...,s_N from his mother, as a birthday present. There may be duplicate elements.\n\nHe will circle some of these N integers. Since he dislikes cubic numbers, he wants to ensure that if both s_i and s_j (i ≠ j) are circled, the product s_is_j is not cubic. For exampl...
[{"input": "10\n1\n11\n100\n1000000007\n10000000100\n1000000009\n999999999\n1416\n999\n999", "output": "10"}, {"input": "10\n1\n11\n100\n1000000007\n10000000100\n1000000009\n999999999\n1416\n922\n999", "output": "10"}, {"input": "10\n1\n11\n100\n1000000007\n10000000100\n1000000009\n999999999\n1416\n922\n613", "output":...
code_stdio
[ { "content": "You are given a positive integer X.\nFind the largest perfect power that is at most X.\nHere, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.\n\n-----Constraints-----\n - 1 ≤ X ≤ 1000\n - X is an integer.\n\n-...
[{"input": "1074", "output": "1024\n"}, {"input": "1023", "output": "1000\n"}, {"input": "1298", "output": "1296\n"}, {"input": "1357", "output": "1331\n"}, {"input": "1746", "output": "1728\n"}, {"input": "999\n", "output": "961\n"}, {"input": "610", "output": "576\n"}, {"input": "159", "output": "144\n"}, {"input": "...
code_stdio
[ { "content": "Having read half of the book called \"Storm and Calm\" on the IT lesson, Innocentius was absolutely determined to finish the book on the maths lessons. All was fine until the math teacher Ms. Watkins saw Innocentius reading fiction books instead of solving equations of the fifth degree. As during ...
[{"input": "DaABYAOivguEueXufuoUeoiLiuEuEIeZAdoPgaUIIrUtoodAALPESiUaEbqitAphOIIEAogrjUBZLnIALGbazIermGEiAAdDAOFaaizopuUuuEugOHsXTAelFxAyZXWQXiEEKkGiIVdUmwiThDOiEyiuOEaiIAAjEQyaEuOiUGOuuzvaIEUEAhXEuOliOeEkJuJaUaszUKePiQuwXSuoQYEeUOgOeuyvOwhUuitEEKDVOaUaoiaIyiAEkyXeuiEkUorUYCaOXEAiUYPnUMaURebouLUOiOojcOeODaaIeEeuukDvpiIk...
code_stdio
[ { "content": "Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, for Alice days $[l_a; r_a]$ are lucky, then there are som...
[{"input": "372839920 992839201 1000000000\n100293021 1262614379 999999993\n", "output": "619999282\n"}, {"input": "372839920 992839201 1000000000\n100293021 773829394 999999993\n", "output": "619999282\n"}, {"input": "372839920 992839201 1000000000\n100293021 773829394 999999993\n", "output": "619999282\n"}, {"input":...
code_stdio
[ { "content": "Dice Stamp\n\nDice stamp\n\nAt a local fair, you found a game store you've never seen before. This is a game in which N 6-sided dice are dropped and rolled on the board. More precisely, N buttons are tied to N dice on a one-to-one basis, and pressing the button causes the corresponding dice to fal...
[{"input": "1\n0 0\n1 2 3 4 5 6\nRRRRBBBBLLLLFFFF\n2\n0 0\n1 1 1 1 1 1\nRRR\n2 2\n100 100 100 100 100 101\nFFF\n1\n1010 -1000\n1 2 3 4 5 6\nLFRB\n4\n-3 -4\n1 2 3 4 5 6\nBBBBBBBB\n4 -3\n11 12 13 14 15 16\nLLLLLLLL\n3 4\n21 22 23 24 25 26\nFFFFFFFF\n-4 3\n31 32 33 34 35 36\nRRRRRRRR\n3\n-2 -2\n9 3 1 1 1 1\nRRRRBLLLBRRBLB...
code_stdio
[ { "content": "For a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequnece (LIS) in A.\n\nAn increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 ≤ i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.\n\nConstraints\n\n* 1 ≤ n ≤ 100000\n* 0 ≤...
[{"input": "5\n5\n1\n2\n-1\n10", "output": "3\n"}, {"input": "5\n5\n1\n0\n-1\n10", "output": "2\n"}, {"input": "5\n5\n1\n0\n-1\n11", "output": "2\n"}, {"input": "5\n8\n1\n0\n-1\n11", "output": "2\n"}, {"input": "5\n8\n2\n0\n-1\n11", "output": "2\n"}, {"input": "5\n11\n1\n1\n0\n11", "output": "2\n"}, {"input": "5\n14\n1...
code_stdio
[ { "content": "problem\n\nHanako is playing with n (4 ≤ n ≤ 10) cards side by side. Each card has one integer between 1 and 99. Hanako chose k cards (2 ≤ k ≤ 4) from these cards and arranged them in a horizontal row to make an integer. How many kinds of integers can Hanako make in total?\n\nFor example, consider...
[{"input": "4\n2\n-1\n3\n10\n1\n6\n2\n133\n1\n15\n6\n0\n-1\n0\n0", "output": "12\n30\n"}, {"input": "4\n2\n1\n3\n22\n2\n6\n4\n11\n3\n12\n10\n2\n1\n0\n0", "output": "11\n308\n"}, {"input": "4\n4\n1\n7\n42\n0\n6\n3\n126\n3\n43\n7\n1\n2\n0\n0", "output": "24\n120\n"}, {"input": "4\n2\n-1\n10\n12\n2\n6\n3\n72\n2\n12\n7\n2\...
code_stdio
[ { "content": "Petya is a beginner programmer. He has already mastered the basics of the C++ language and moved on to learning algorithms. The first algorithm he encountered was insertion sort. Petya has already written the code that implements this algorithm and sorts the given integer zero-indexed array a of s...
[{"input": "150\n48 115 13 9 105 117 41 136 123 32 84 95 62 50 140 106 145 91 57 141 139 35 45 27 129 63 137 10 37 60 44 30 101 119 138 78 22 103 39 134 49 36 25 12 28 67 69 99 148 26 16 87 146 65 8 74 14 38 47 89 81 19 40 11 64 43 110 66 102 3 122 124 100 2 125 42 97 73 121 7 52 23 29 109 1 70 34 108 59 55 127 90 88 1...
code_stdio
[ { "content": "On a certain meeting of a ruling party \"A\" minister Pavel suggested to improve the sewer system and to create a new pipe in the city.\n\nThe city is an n × m rectangular squared field. Each square of the field is either empty (then the pipe can go in it), or occupied (the pipe cannot go in such ...
[{"input": "9 37\n.......#................#.##...#.....\n..#......................##..........\n..#......#.........#.................\n..........#..#..#..#...........#.....\n...#............#..##.#.....##.......\n......................#..............\n......#........##....#......#........\n........#.......................
code_stdio
[ { "content": "Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess.\n\nThe queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is located on the same vertical, horizontal or diagonal line with ...
[{"input": "1000000000\n", "output": "white\n1 2\n"}, {"input": "1000000000\n", "output": "white\n1 2\n"}, {"input": "1000000010\n", "output": "white\n1 2\n"}, {"input": "1823733270\n", "output": "white\n1 2\n"}, {"input": "1381061568\n", "output": "white\n1 2\n"}, {"input": "1091549244\n", "output": "white\n1 2\n"}, {...
code_stdio
[ { "content": "You are given an array $a[0 \\ldots n - 1] = [a_0, a_1, \\ldots, a_{n - 1}]$ of zeroes and ones only. Note that in this problem, unlike the others, the array indexes are numbered from zero, not from one.\n\nIn one step, the array $a$ is replaced by another array of length $n$ according to the foll...
[{"input": "5\n2 2\n0 1\n3 2\n1 1 1\n5 2\n1 1 0 0 0\n4 1\n0 0 0 0\n1 1\n1\n", "output": "-1\n-1\n1\n0\n-1\n"}, {"input": "5\n2 1\n1 1\n3 1\n0 1 0\n5 3\n1 1 0 0 0\n4 4\n1 1 0 0\n1 1\n1\n", "output": "-1\n1\n1\n-1\n-1\n"}, {"input": "5\n2 1\n0 1\n3 3\n0 1 0\n5 3\n1 1 1 1 0\n4 4\n0 1 0 0\n1 1\n1\n", "output": "1\n-1\n4\n-...
code_stdio
[ { "content": "Polycarpus is sure that his life fits the description: \"first there is a white stripe, then a black one, then a white one again\". So, Polycarpus is sure that this rule is going to fulfill during the next n days. Polycarpus knows that he is in for w good events and b not-so-good events. At least ...
[{"input": "4000 2000 2219\n", "output": " 865711019"}, {"input": "4000 1244 4000\n", "output": " 344837886"}, {"input": "4000 1244 2881\n", "output": " 8905...
code_stdio
[ { "content": "A and B are preparing themselves for programming contests.\n\nAfter several years of doing sports programming and solving many problems that require calculating all sorts of abstract objects, A and B also developed rather peculiar tastes.\n\nA likes lowercase letters of the Latin alphabet. He has ...
[{"input": "-2 -2 2 1 4 0 -2 4 5 4 -5 -5 2 1 1 -1 0 -5 -2 3 -2 4 5 2 3 -5\nqgzhbkitmqwttdyoyvcbxincwjryzknubpacsngorexaldfurondbednowemnnlphhboycfavsovisrmfaefusoobingjhsmrukx\n", "output": "7\n"}, {"input": "-2 -2 2 1 4 0 -2 4 5 4 -5 -5 2 1 1 -1 0 -5 -2 3 -2 4 5 2 3 -5\nqgzhbkitmqwttdyoyvcbxincwjryzknubpacsngorexaldfu...
code_stdio
[ { "content": "Arkady wants to water his only flower. Unfortunately, he has a very poor watering system that was designed for $n$ flowers and so it looks like a pipe with $n$ holes. Arkady can only use the water that flows from the first hole.\n\nArkady can block some of the holes, and then pour $A$ liters of wa...
[{"input": "10 300 100\n35 25 110 40 60 7 44 145 23 96\n", "output": "6\n"}, {"input": "10 300 100\n35 42 110 40 60 7 44 145 23 96\n", "output": "6\n"}, {"input": "10 300 100\n35 42 110 40 60 7 26 145 23 96\n", "output": "6\n"}, {"input": "10 300 100\n35 42 110 40 60 7 26 158 23 96\n", "output": "6\n"}, {"input": "10 2...
code_stdio
[ { "content": "Berland year consists of $m$ months with $d$ days each. Months are numbered from $1$ to $m$. Berland week consists of $w$ days. The first day of the year is also the first day of the week. Note that the last week of the year might be shorter than $w$ days.\n\nA pair $(x, y)$ such that $x < y$ is a...
[{"input": "5\n6 7 1\n10 12 11\n12 30 6\n1 1 1\n3247834 10298779 625324\n", "output": "15\n45\n6\n0\n116461800\n"}, {"input": "5\n6 7 4\n10 9 16\n12 17 4\n0 1 1\n7341628 25065973 296620\n", "output": "6\n16\n66\n0\n359753922\n"}, {"input": "5\n6 10 1\n10 7 12\n12 30 6\n1 1 1\n3247834 3741802 625324\n", "output": "15\n9...
code_stdio
[ { "content": "Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.\n\nDuring his ride, Ark...
[{"input": "2\n64 23 81 66 95 91 56 12 48 24 78 36 67 57 75 88 82 98 83 46 100 58 62 80 8 4 28 74 70 50 42 11 68 18 19 6 94 59 13 72 37 31 90 41 60 34 86 55 76 69 32 21 73 84 3 52 92 79 61 63 38 87 17 14 29\n65 89 14 93 58 60 80 64 28 91 70 48 19 55 75 21 100 98 88 69 7 42 41 81 8 76 54 87 16 56 53 29 71 9 37 62 61 73 ...
code_stdio
[ { "content": "We have a two-dimensional grid with H \\times W squares. There are M targets to destroy in this grid - the position of the i-th target is \\left(h_i, w_i \\right).\nTakahashi will choose one square in this grid, place a bomb there, and ignite it. The bomb will destroy all targets that are in the r...
[{"input": "5 5 10\n2 5\n4 3\n2 3\n5 5\n2 2\n5 4\n5 3\n5 1\n3 5\n1 4\n", "output": "6\n"}, {"input": "5 10 10\n2 5\n4 5\n2 3\n5 5\n2 4\n5 4\n5 1\n1 1\n4 5\n1 4", "output": "6\n"}, {"input": "5 10 10\n2 5\n4 5\n2 3\n5 5\n2 4\n5 4\n5 1\n1 1\n4 1\n1 4", "output": "6\n"}, {"input": "5 10 10\n2 5\n4 5\n2 1\n3 5\n2 2\n5 4\n5...
code_stdio
[ { "content": "There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one large integer. For example, if he chooses digit 1 from the first block and d...
[{"input": "100 1000000000 42 97\n2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2\n", "output": "590949100\n"}, {"input": "100 1000000000 42 97\n2 5 1 8 8 1 5 2 1 2 5 1...
code_stdio
[ { "content": "Transformation\n\n\n\n\nWrite a program which performs a sequence of commands to a given string $str$. The command is one of:\n\n* print a b: print from the a-th character to the b-th character of $str$\n* reverse a b: reverse from the a-th character to the b-th character of $str$\n* replace a b p...
[{"input": "abcde\n3\nreplace 1 0 xy{\nreverse 0 2\nprint 1 6", "output": "xa{bcd\n"}, {"input": "abcde\n3\nreplace 1 0 xy{\nreverse 0 1\nprint 1 6", "output": "ay{bcd\n"}, {"input": "abcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 0 4", "output": "yxaze\n"}, {"input": "xy{\n3\nprint 0 2\nreplace 2 2 abb\nprint 0 4", "ou...
code_stdio
[ { "content": "Consider a sequence made up of the consecutive prime numbers. This infinite sequence would start with: \n```python\n\"2357111317192329313741434753596167717379...\"\n```\n\nYou will be given two numbers: `a` and `b`, and your task will be to return `b` elements starting from index `a` in this seque...
[{"input": "30\n12", "output": "[\"616771737983\"]", "fn_name": "solve"}, {"input": "20\n9", "output": "[\"414347535\"]", "fn_name": "solve"}, {"input": "40\n8", "output": "[\"83899710\"]", "fn_name": "solve"}, {"input": "10000\n5", "output": "[\"02192\"]", "fn_name": "solve"}, {"input": "20000\n5", "output": "[\"09334...
code_functional
[ { "content": "You have a description of a lever as string s. We'll represent the string length as record |s|, then the lever looks as a horizontal bar with weights of length |s| - 1 with exactly one pivot. We will assume that the bar is a segment on the Ox axis between points 0 and |s| - 1.\n\nThe decoding of t...
[{"input": "==88=^95==83=45===8====73===7==7====1=29====29=8=85=\n", "output": "right\n"}, {"input": "==88=^95==83=45===8====73===7==7====1=39====29=8=85=\n", "output": "right\n"}, {"input": "==88=^=5==83=45===8====73==97==7====1=39====29=8=85=\n", "output": "right\n"}, {"input": "==88=^95==83=45===8====73===7==7====1=...
code_stdio
[ { "content": "D: Sunburn-Suntan-\n\nstory\n\nAizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. Cute like an angel. Aizu Nyan is planning to participate in this summer festival, so I made a schedule for the band to go to l...
[{"input": "20\n1\n-1 12", "output": "13\n"}, {"input": "20\n1\n-1 19", "output": "20\n"}, {"input": "20\n1\n0 19", "output": "19\n"}, {"input": "20\n1\n0 12", "output": "12\n"}, {"input": "20\n1\n0 28", "output": "20\n"}, {"input": "20\n1\n1 15", "output": "14\n"}, {"input": "20\n1\n1 19", "output": "18\n"}, {"input":...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \nSome chefs go for a tour lasting N days. They take packages of bread for food. Each package has K pieces of breads. On the i^{th} day, they eat A_{i} pieces of bread.\nUnfortunately, chefs are very lazy people, and they always forget to ...
[{"input": "3\n3 4\n12 1 2\n1 1\n2\n2 1\n23 1", "output": "4\n2\n24\n"}, {"input": "3\n3 4\n10 2 -1\n1 1\n1\n2 4\n12 2", "output": "4\n1\n4\n"}, {"input": "3\n3 4\n12 1 2\n1 1\n2\n2 1\n26 1", "output": "4\n2\n27\n"}, {"input": "3\n3 9\n6 -1 4\n1 1\n1\n2 1\n27 0", "output": "2\n1\n27\n"}, {"input": "3\n3 9\n6 -1 4\n1 1\...
code_stdio
[ { "content": "Polycarp remembered the $2020$-th year, and he is happy with the arrival of the new $2021$-th year. To remember such a wonderful moment, Polycarp wants to represent the number $n$ as the sum of a certain number of $2020$ and a certain number of $2021$.\n\nFor example, if:\n\n$n=4041$, then the num...
[{"input": "5\n1\n4041\n4042\n8081\n8079\n", "output": "\nNO\nYES\nYES\nYES\nNO\n"}, {"input": "5\n1\n4041\n4042\n8081\n8079\n", "output": "NO\nYES\nYES\nYES\nNO\n"}, {"input": "5\n1\n4041\n4042\n12391\n8079\n", "output": "NO\nYES\nYES\nNO\nNO\n"}, {"input": "5\n1\n4041\n4042\n8081\n4273\n", "output": "NO\nYES\nYES\nYE...
code_stdio
[ { "content": "Example\n\nInput\n\n1+2*3+4\n11\n\n\nOutput\n\nM\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "4+1*3+0\n104", "output": "I\n"}, {"input": "4+1*3+0\n102", "output": "I\n"}, {"input": "0+3*1+4\n104", "output": "I\n"}, {"input": "0+3*1+4\n129", "output": "I\n"}, {"input": "3*1+0*4\n12", "output": "L\n"}, {"input": "1+2+3+4\n11", "output": "I\n"}, {"input": "1+2*3+4\n14", "output": "I\n"}, {"input": "4+3...
code_stdio
[ { "content": "There is a country with $n$ citizens. The $i$-th of them initially has $a_{i}$ money. The government strictly controls the wealth of its citizens. Whenever a citizen makes a purchase or earns some money, they must send a receipt to the social services mentioning the amount of money they currently ...
[{"input": "10\n7 9 4 4 7 6 3 7 9 8\n10\n1 3 2\n1 10 5\n1 5 3\n1 5 2\n1 2 9\n1 2 9\n1 2 10\n1 5 7\n1 6 10\n1 10 9\n", "output": "7 10 2 4 7 10 3 7 9 9 \n"}, {"input": "10\n7 9 4 4 7 6 3 7 9 10\n10\n1 4 2\n1 10 5\n1 5 3\n1 5 2\n1 2 9\n1 2 9\n1 2 10\n1 5 7\n1 6 10\n1 10 9\n", "output": "7 10 4 2 7 10 3 7 9 9\n"}, {"input...
code_stdio
[ { "content": "Hongcow is learning to spell! One day, his teacher gives him a word that he needs to learn to spell. Being a dutiful student, he immediately learns how to spell the word.\n\nHongcow has decided to try to make new words from this one. He starts by taking the word he just learned how to spell, and m...
[{"input": "abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxy\n", "output": "25\n"}, {"input": "zyzzzyyzyyyzyyzyzyzyzyzzzyyyzzyzyyzzzzzyyyzzzzyzyy\n", "output": "50\n"}, {"input": "aaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaab\n", "output": "25\n"}, {"input": "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx\n"...
code_stdio
[ { "content": "Vasya studies music. \n\nHe has learned lots of interesting stuff. For example, he knows that there are 12 notes: C, C#, D, D#, E, F, F#, G, G#, A, B, H. He also knows that the notes are repeated cyclically: after H goes C again, and before C stands H. We will consider the C note in the row's begi...
[{"input": "F# F# F#\n", "output": "strange\n"}, {"input": "D# D# F#\n", "output": "strange\n"}, {"input": "G# G# A\n", "output": "strange\n"}, {"input": "G# C# D\n", "output": "strange\n"}, {"input": "F D# G#\n", "output": "strange\n"}, {"input": "B C# C#\n", "output": "strange\n"}, {"input": "F# H F#\n", "output": "s...
code_stdio
[ { "content": "Meka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal $a$ instant damage to him, and then heal that enemy $b$ health points at the end of every second, for exactly $c$ seconds, starting one second after the ability is used. That means that if the abi...
[{"input": "6\n1411352 712902 579689 383030\n997653 839911 351405 69197\n31160 1580030 281506 245835\n234837 489356 452352 448472\n382561 916024 805514 657373\n287796 831046 710305 568719\n", "output": "1411352\n997653\n31160\n234837\n382561\n287796\n"}, {"input": "6\n1411352 712902 579689 383030\n997653 839911 351405 ...
code_stdio
[ { "content": "You are given an undirected unweighted graph consisting of $n$ vertices and $m$ edges (which represents the map of Bertown) and the array of prices $p$ of length $m$. It is guaranteed that there is a path between each pair of vertices (districts).\n\nMike has planned a trip from the vertex (distri...
[{"input": "2\n4 3 2 3 4\n2 4 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 4\n6 7\n", "output": "11\n12\n"}, {"input": "2\n4 3 2 3 4\n1 5 3\n1 2\n1 3\n1 4\n7 9 2 5 7\n3 10 4 8 5 8 7 3 3\n2 2\n2 3\n1 4\n3 2\n3 5\n4 3\n5 6\n1 4\n6 7\n", "output": "10\n13\n"}, {"input": "2\n4 3 2 3...
code_stdio
[ { "content": "You are playing a game where your character should overcome different obstacles. The current problem is to come down from a cliff. The cliff has height $h$, and there is a moving platform on each height $x$ from $1$ to $h$.\n\nEach platform is either hidden inside the cliff or moved out. At first,...
[{"input": "28\n8 4\n8 7 6 3\n8 5\n8 7 6 3 1\n8 5\n8 7 6 3 2\n8 6\n8 7 6 3 2 1\n8 4\n8 7 6 4\n8 5\n8 7 6 4 1\n8 5\n8 7 6 4 2\n8 6\n8 7 6 4 2 1\n8 5\n8 7 6 4 3\n8 6\n8 7 6 4 3 1\n8 6\n8 7 6 4 3 2\n8 7\n8 7 6 4 3 2 1\n8 4\n8 7 6 5\n8 5\n8 7 6 5 1\n8 5\n8 7 6 5 2\n8 6\n8 7 6 5 2 1\n8 5\n8 7 6 5 3\n8 6\n8 7 6 5 3 1\n8 6\n8...
code_stdio
[ { "content": "You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one.\n\nAt least how many operations are necessary to satisfy the following conditions?\n\n* For every i (1≤i≤n), the sum of the term...
[{"input": "5\n113 -2 -1 0 -1", "output": "120\n"}, {"input": "5\n113 -2 -1 1 -1", "output": "121\n"}, {"input": "5\n113 -1 -1 1 -2", "output": "119\n"}, {"input": "5\n106 -1 -1 1 -5", "output": "112\n"}, {"input": "6\n9 0 -11 1 -2 -1", "output": "25\n"}, {"input": "6\n-1 2 -40 1 -2 4", "output": "39\n"}, {"input": "6\...
code_stdio
[ { "content": "Little Petya has recently started attending a programming club. Naturally he is facing the problem of choosing a programming language. After long considerations he realized that Java is the best choice. The main argument in favor of choosing Java was that it has a very large integer data type, cal...
[{"input": "14391752689956519300788497161416904648305096969559656916798920426154191397931561980203179360129309381\n", "output": "BigInteger\n"}, {"input": "11271203439111662452647816080492937379011458047735472400976277474953429583477559167812276320735634783\n", "output": "BigInteger\n"}, {"input": "13710824100893639035...
code_stdio
[ { "content": "Count the number of divisors of a positive integer `n`.\n\nRandom tests go up to `n = 500000`.\n\n## Examples\n```python\ndivisors(4) == 3 # 1, 2, 4\ndivisors(5) == 2 # 1, 5\ndivisors(12) == 6 # 1, 2, 3, 4, 6, 12\ndivisors(30) == 8 # 1, 2, 3, 5, 6, 10, 15, 30\n```\n\nWrite Python code to sol...
[{"input": "4096", "output": "[13]", "fn_name": "divisors"}, {"input": "12", "output": "[6]", "fn_name": "divisors"}, {"input": "25", "output": "[3]", "fn_name": "divisors"}, {"input": "30", "output": "[8]", "fn_name": "divisors"}, {"input": "1", "output": "[1]", "fn_name": "divisors"}, {"input": "4", "output": "[3]", ...
code_functional
[ { "content": "Little Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw $n$ squares in the snow with a side length of $1$. For simplicity, we assume that Sofia lives on a plane and can draw only segments of length $1$, parallel to ...
[{"input": "1000000000\n", "output": "63246\n"}, {"input": "1000000000\n", "output": "63246\n"}, {"input": "1010000000\n", "output": "63561\n"}, {"input": "1550090838\n", "output": "78743\n"}, {"input": "1237445143\n", "output": "70355\n"}, {"input": "1010100000\n", "output": "63565\n"}, {"input": "1214137855\n", "outp...
code_stdio
[ { "content": "A programming contest is held every year at White Tiger University. When the total number of teams is N, each team is assigned a team ID from 1 to N. The contest starts with all teams scoring 0 and runs continuously for L seconds.\n\nThis year's contest will be broadcast on TV. Only the team with ...
[{"input": "3 4 600\n3 100 5\n1 200 14\n2 400 20\n3 500 20", "output": "1\n"}, {"input": "3 4 600\n3 100 5\n1 200 14\n2 400 20\n3 500 8", "output": "1\n"}, {"input": "3 4 600\n3 100 5\n1 200 11\n2 400 20\n3 500 8", "output": "1\n"}, {"input": "3 4 600\n3 100 5\n1 80 10\n2 400 20\n3 500 20", "output": "1\n"}, {"input": ...
code_stdio
[ { "content": "Many cats live on the campus of a school. Natsume's daily routine is to pet those cats. However, the cats may be capricious and go for a walk off campus.\n\nThe campus site is a rectangle with each side parallel to the x-axis or y-axis and is surrounded by a fence except for the gate, but cats can...
[{"input": "2\n1 3 20 10\n4\n21 13\n1 15\n10 10\n41 10\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10", "output": "2\n2\n"}, {"input": "2\n1 3 20 10\n4\n21 13\n1 15\n10 10\n55 10\n1 3 20 10\n4\n21 13\n1 15\n10 10\n25 10", "output": "2\n2\n"}, {"input": "2\n1 3 20 10\n4\n15 13\n1 15\n10 10\n25 10\n1 3 20 10\n4\n21 13\n1 15\n1...
code_stdio
[ { "content": "## The Story\nGreen Lantern's long hours of study and practice with his ring have really paid off -- his skills, focus, and control have improved so much that now he can even use his ring to update and redesign his web site. Earlier today he was focusing his will and a beam from his ring upon the ...
[{"input": "\"pAlEgOlDeNrOd\"", "output": "[\"LightGreen\"]", "fn_name": "yellow_be_gone"}, {"input": "\"lemonchiffon\"", "output": "[\"PaleGreen\"]", "fn_name": "yellow_be_gone"}, {"input": "\"BlueViolet\"", "output": "[\"BlueViolet\"]", "fn_name": "yellow_be_gone"}, {"input": "\"GOLD\"", "output": "[\"ForestGreen\"]"...
code_functional
[ { "content": "You have a sequence A composed of N positive integers: A_{1}, A_{2}, \\cdots, A_{N}.\nYou will now successively do the following Q operations:\n - In the i-th operation, you replace every element whose value is B_{i} with C_{i}.\nFor each i (1 \\leq i \\leq Q), find S_{i}: the sum of all elements ...
[{"input": "2\n1 2\n3\n1 100\n2 100\n100 1000\n", "output": "102\n200\n2000\n"}, {"input": "2\n1 2\n3\n1 100\n2 000\n100 1000", "output": "102\n100\n1000\n"}, {"input": "2\n1 2\n3\n1 100\n2 001\n100 1000", "output": "102\n101\n1001\n"}, {"input": "2\n1 2\n3\n1 100\n1 001\n100 1000", "output": "102\n102\n1002\n"}, {"inp...
code_stdio
[ { "content": "There are $ n $ acitivities with start times $ \\\\ {s_i \\\\} $ and finish times $ \\\\ {t_i \\\\} $. Assuming that a person can only work on a single activity at a time, find the maximum number of activities that can be performed by a single person.\n\nConstraints\n\n* $ 1 \\ le n \\ le 10 ^ 5 $...
[{"input": "5\n1 2\n10 2\n-1 4\n1 2\n3 12", "output": "3\n"}, {"input": "5\n1 2\n10 2\n-2 4\n1 2\n3 12", "output": "3\n"}, {"input": "5\n1 2\n12 2\n-2 4\n1 2\n3 12", "output": "3\n"}, {"input": "5\n1 2\n10 2\n0 4\n1 2\n3 12", "output": "3\n"}, {"input": "5\n3 2\n5 2\n0 4\n1 7\n6 12", "output": "3\n"}, {"input": "5\n1 2...
code_stdio
[ { "content": "Let's call an array $t$ dominated by value $v$ in the next situation.\n\nAt first, array $t$ should have at least $2$ elements. Now, let's calculate number of occurrences of each number $num$ in $t$ and define it as $occ(num)$. Then $t$ is dominated (by $v$) if (and only if) $occ(v) > occ(v')$ for...
[{"input": "4\n1\n1\n6\n1 2 3 4 5 1\n9\n4 1 2 4 5 4 3 2 1\n4\n3 3 3 3\n", "output": "-1\n6\n3\n2\n"}, {"input": "4\n1\n1\n6\n1 2 3 4 5 2\n9\n4 1 2 4 5 4 3 2 1\n4\n3 3 3 3\n", "output": "-1\n5\n3\n2\n"}, {"input": "4\n1\n1\n6\n1 2 3 4 5 2\n9\n4 1 4 4 5 4 3 2 1\n4\n3 3 3 3\n", "output": "-1\n5\n2\n2\n"}, {"input": "4\n1\...
code_stdio
[ { "content": "ZS the Coder and Chris the Baboon are travelling to Udayland! To get there, they have to get on the special IOI bus. The IOI bus has n rows of seats. There are 4 seats in each row, and the seats are separated into pairs by a walkway. When ZS and Chris came, some places in the bus was already occup...
[{"input": "61\nOX|XX\nOX|XX\nOX|XX\nXO|XO\nXX|XO\nXX|XX\nXX|XX\nOX|XX\nXO|XO\nOX|XO\nXO|OX\nXX|XX\nXX|XX\nOX|OX\nXX|OX\nOX|XO\nOX|XO\nXO|OX\nXO|XX\nOX|XX\nOX|XX\nXO|OX\nXO|XX\nXO|XX\nOX|XX\nXX|XX\nXX|XO\nXO|XX\nXX|XX\nXO|OX\nXX|XO\nXO|XX\nXO|XO\nXO|OX\nXX|OX\nXO|OX\nOX|XX\nXX|OX\nXX|XX\nOX|XO\nOX|XX\nXO|OX\nOX|XX\nOX|...
code_stdio
[ { "content": "For a given weighted graph G(V, E) and a source r, find the source shortest path to each vertex from the source (SSSP: Single Source Shortest Path).\n\nConstraints\n\n* 1 ≤ |V| ≤ 100000\n* 0 ≤ di ≤ 10000\n* 0 ≤ |E| ≤ 500000\n* There are no parallel edges\n* There are no self-loops\n\nInput\n\nAn e...
[{"input": "8 6 1\n0 1 1\n0 2 4\n2 0 1\n0 2 2\n3 1 1\n3 2 5", "output": "INF\n0\nINF\nINF\nINF\nINF\nINF\nINF\n"}, {"input": "8 6 1\n0 1 1\n0 2 4\n0 0 1\n1 2 2\n3 0 2\n3 2 5", "output": "INF\n0\n2\nINF\nINF\nINF\nINF\nINF\n"}, {"input": "8 6 2\n0 2 1\n0 2 2\n2 0 1\n1 0 0\n3 1 1\n3 2 5", "output": "1\nINF\n0\nINF\nINF\n...
code_stdio
[ { "content": "Toad Pimple has an array of integers $a_1, a_2, \\ldots, a_n$.\n\nWe say that $y$ is reachable from $x$ if $x<y$ and there exists an integer array $p$ such that $x = p_1 < p_2 < \\ldots < p_k=y$, and $a_{p_i}\\, \\&\\, a_{p_{i+1}} > 0$ for all integers $i$ such that $1 \\leq i < k$.\n\nHere $\\&$ ...
[{"input": "5 3\n1 3 -1 2 -1\n1 2\n2 5\n1 4\n", "output": "Shi\nShi\nShi\n"}, {"input": "5 3\n1 3 -1 2 -1\n1 2\n2 5\n1 5\n", "output": "Shi\nShi\nShi\n"}, {"input": "5 3\n1 3 -1 2 1\n1 3\n2 4\n1 4\n", "output": "Shi\nShi\nShi\n"}, {"input": "5 3\n1 3 -1 2 0\n1 3\n2 5\n1 4\n", "output": "Shi\nFou\nShi\n"}, {"input": "5 ...
code_stdio
[ { "content": "A sequence $a_1, a_2, \\dots, a_k$ is called an arithmetic progression if for each $i$ from $1$ to $k$ elements satisfy the condition $a_i = a_1 + c \\cdot (i - 1)$ for some fixed $c$.\n\nFor example, these five sequences are arithmetic progressions: $[5, 7, 9, 11]$, $[101]$, $[101, 100, 99]$, $[1...
[{"input": "6\n-658647496 -999999999 -1000000000 -999999996 -999999997 -1117017479\n", "output": "-1\n"}, {"input": "6\n-999999998 -999999999 -1000000000 -999999995 -999999997 -999999995\n", "output": "-1\n"}, {"input": "6\n-999999998 -999999999 -1000000000 -999999996 -999999997 -1117017479\n", "output": "6\n"}, {"inpu...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers. For each $i$ ($1 \\le i \\le n$) the following inequality is true: $-2 \\le a_i \\le 2$.\n\nYou can remove any number (possibly $0$) of elements from the beginning of the array and any number (possibly $0$) of elements from the end of the arra...
[{"input": "1\n100\n2 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 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 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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 0 2 2 2\n", "output": "0 4\n"}, {"input": "5\n4\n1 2 -1 2\n3\n1 1 -2\n5\n2 0 -2 2 -1\n3\n-2 -1 -1\n3\n-1 -2 ...
code_stdio
[ { "content": "Takahashi is playing a board game called Sugoroku.\nOn the board, there are N + 1 squares numbered 0 to N. Takahashi starts at Square 0, and he has to stop exactly at Square N to win the game.\nThe game uses a roulette with the M numbers from 1 to M. In each turn, Takahashi spins the roulette. If ...
[{"input": "99810 49281\n0000001101101010010101110010010001111110101100000010000011100010010010010011110111000000011101110000000100010000100110110001010100101001000101110010111101110111100011100011110010101000011011100100010101010011010110011011111111100101011000100100110000001110011000010100110011001001111100100101100...
code_stdio
[ { "content": "In the 2050 Conference, some people from the competitive programming community meet together and are going to take a photo. The n people form a line. They are numbered from 1 to n from left to right. Each of them either holds a cardboard with the letter 'C' or a cardboard with the letter 'P'.\n\nL...
[{"input": "3\n5\n1 2 3 1 2\n4\n11 2 28 5\n1\n998244353\n", "output": "11\n8\n1\n"}, {"input": "3\n5\n1 2 3 0 1\n4\n11 3 28 5\n1\n998244353\n", "output": "10\n8\n1\n"}, {"input": "3\n5\n1 2 3 1 2\n4\n11 2 15 5\n1\n998244353\n", "output": "11\n7\n1\n"}, {"input": "3\n5\n2 1 2 1 1\n4\n11 2 2 2\n1\n1749992475\n", "output"...
code_stdio
[ { "content": "problem\n\nTaro bought 10 books. Later, I tried to find out the price based on the receipt, but the receipt was dirty and I could not read the price of a book. We decided to calculate the price of the book from the total price of 10 books and the prices of the other 9 books.\n\nWrite a program tha...
[{"input": "9850\n1050\n800\n420\n380\n600\n1164\n2400\n3134\n980\n0", "output": "-1078\n"}, {"input": "9850\n1050\n800\n420\n380\n600\n1164\n2400\n3265\n980\n0", "output": "-1209\n"}, {"input": "9850\n1050\n800\n481\n380\n600\n1164\n2400\n3265\n980\n0", "output": "-1270\n"}, {"input": "9850\n1050\n800\n481\n380\n600\n...
code_stdio
[ { "content": "Mr. Yamada Springfield Tanaka was appointed as Deputy Deputy Director of the National Land Readjustment Business Bureau. Currently, his country is in the midst of a major land readjustment, and if this land readjustment can be completed smoothly, his promotion is certain.\n\nHowever, there are man...
[{"input": "2\n-100 -20 100 20\n-20 -100 18 100\n2\n-100 -20 -20 -100\n20 100 100 20\n0", "output": "4\n3\n"}, {"input": "2\n-100 -20 100 20\n-20 -100 20 100\n2\n-100 -34 -20 -100\n20 100 100 20\n0", "output": "4\n3\n"}, {"input": "2\n-100 -20 100 20\n-20 -100 18 100\n2\n-100 -20 -20 -100\n20 100 100 33\n0", "output": ...
code_stdio
[ { "content": "As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:\n\n$f(a, l, r) = \\sum_{i = l}^{r} a [ i ] ; m(a) = \\operatorname{max}_{1 \\leq l \\leq r \\leq n} f(a, l, r)$\n\nA swap operation is the following sequence of actions:\n\n choose two indexe...
[{"input": "116 10\n477 -765 -756 376 -48 -75 768 -658 263 -207 362 -535 96 -960 630 -686 609 -830 889 57 -239 346 -298 -18 -107 853 -607 -443 -517 371 657 105 479 498 -47 432 503 -917 -656 610 -466 216 -747 -587 -163 -174 493 -882 853 -582 -774 -477 -386 610 -58 557 968 196 69 610 -38 366 -79 574 170 317 332 189 158 -...
code_stdio
[ { "content": "While playing yet another strategy game, Mans has recruited $n$ Swedish heroes, whose powers which can be represented as an array $a$.\n\nUnfortunately, not all of those mighty heroes were created as capable as he wanted, so that he decided to do something about it. In order to accomplish his goal...
[{"input": "11\n559227829 -118401759 491756598 -50857099 491152214 -500410377 141179566 -414122877 144131087 -460846619 791017750\n", "output": "3779030445\n"}, {"input": "11\n559227829 -118401759 491756598 -50857099 491152214 -500410377 141179566 -723654625 144131087 -460846619 791017750\n", "output": "4088562193\n"},...
code_stdio
[ { "content": "Snuke got an integer sequence of length N from his mother, as a birthday present. The i-th (1 ≦ i ≦ N) element of the sequence is a_i. The elements are pairwise distinct. He is sorting this sequence in increasing order. With supernatural power, he can perform the following two operations on the se...
[{"input": "5\n10\n8\n10\n6\n2", "output": "1\n"}, {"input": "5\n10\n8\n10\n9\n2", "output": "1\n"}, {"input": "5\n10\n8\n10\n7\n2", "output": "1\n"}, {"input": "5\n10\n8\n10\n9\n1", "output": "1\n"}, {"input": "5\n10\n8\n10\n7\n1", "output": "1\n"}, {"input": "5\n20\n8\n10\n6\n2", "output": "1\n"}, {"input": "5\n10\n1...
code_stdio
[ { "content": "- Input: Integer `n`\n- Output: String\n\nExample:\n\n`a(4)` prints as\n```\n A \n A A \n A A A \nA A\n```\n\n`a(8)` prints as\n```\n A \n A A \n A A \n A A \n A A A A A \n A A \n A A \nA A\n```\n\n`a(12)` prin...
[{"input": "30", "output": "[\" A \\n A A \\n A A \\n A A \\n A A ...
code_functional
[ { "content": "Write a function which takes one parameter representing the dimensions of a checkered board. The board will always be square, so 5 means you will need a 5x5 board.\n\nThe dark squares will be represented by a unicode white square, while the light squares will be represented by a unicode black squa...
[{"input": "100", "output": "[\"\\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 \\u25a1 \\u25a0 ...
code_functional
[ { "content": "There are N integers, A_1, A_2, ..., A_N, written on a blackboard.\n\nWe will repeat the following operation N-1 times so that we have only one integer on the blackboard.\n\n* Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y.\n\n\n\nFind the...
[{"input": "3\n8 -4 10", "output": "22\n-4 8\n10 -12\n"}, {"input": "3\n1 -2 10", "output": "13\n-2 1\n10 -3\n"}, {"input": "3\n2 -2 10", "output": "14\n-2 2\n10 -4\n"}, {"input": "3\n2 -4 10", "output": "16\n-4 2\n10 -6\n"}, {"input": "3\n4 -4 10", "output": "18\n-4 4\n10 -8\n"}, {"input": "3\n4 -4 18", "output": "26\...
code_stdio
[ { "content": "A new Berland businessman Vitaly is going to open a household appliances' store. All he's got to do now is to hire the staff.\n\nThe store will work seven days a week, but not around the clock. Every day at least k people must work in the store.\n\nBerland has a law that determines the order of wo...
[{"input": "1000 2 1363\n", "output": "2726\n1 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 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 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 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...
code_stdio
[ { "content": "Ivan wants to play a game with you. He picked some string $s$ of length $n$ consisting only of lowercase Latin letters. \n\nYou don't know this string. Ivan has informed you about all its improper prefixes and suffixes (i.e. prefixes and suffixes of lengths from $1$ to $n-1$), but he didn't tell y...
[{"input": "18\nd\nh\ndj\nxh\ndjs\njxh\ndjsh\nzjxh\ndjshf\nkzjxh\ndjshfk\nhkzjxh\ndjshfkj\nkhkzjxh\ndjshfkje\nskhkzjxh\ndjshfkjeh\ndskhkzjxh\ndjshfkjehd\nhdskhkzjxh\ndjshfkjehds\nehdskhkzjxh\ndjshfkjehdsk\njehdskhkzjxh\ndjshfkjehdskh\nkjehdskhkzjxh\ndjshfkjehdskhk\nfkjehdskhkzjxh\ndjshfkjehdskhkz\nhfkjehdskhkzjxh\ndjsh...
code_stdio
[ { "content": "Create a function that takes a Number as its argument and returns a Chinese numeral string. You don't need to validate the input argument, it will always be a Number in the range `[-99999.999, 99999.999]`, rounded to 8 decimal places.\n\nSimplified Chinese numerals have characters representing eac...
[{"input": "-99999.999", "output": "[\"\\u8d1f\\u4e5d\\u4e07\\u4e5d\\u5343\\u4e5d\\u767e\\u4e5d\\u5341\\u4e5d\\u70b9\\u4e5d\\u4e5d\\u4e5d\"]", "fn_name": "to_chinese_numeral"}, {"input": "99999.999", "output": "[\"\\u4e5d\\u4e07\\u4e5d\\u5343\\u4e5d\\u767e\\u4e5d\\u5341\\u4e5d\\u70b9\\u4e5d\\u4e5d\\u4e5d\"]", "fn_name"...
code_functional
[ { "content": "You are given two strings a and b. You have to remove the minimum possible number of consecutive (standing one after another) characters from string b in such a way that it becomes a subsequence of string a. It can happen that you will not need to remove any characters at all, or maybe you will ha...
[{"input": "bbbbaabbababbaaaaababbaaabbbbaaabbbababbbbabaabababaabaaabbbabababbbabababaababaaaaa\nbbabaaaabaaaabbaaabbbabaaabaabbbababbbbbbbbbbabbababbaababbbaaabababababbbbaaababaaaaab\n", "output": "bbbbbbbabbababbaababbbaaabababababbbbaaababaaaaab\n"}, {"input": "bbbbaabbababbaaaaababbaaabbbbaaabbbababbbbabaabababaa...
code_stdio
[ { "content": "AtCoder's head office consists of N rooms numbered 1 to N. For any two rooms, there is a direct passage connecting these rooms.\n\nFor security reasons, Takahashi the president asked you to set a level for every passage, which is a positive integer and must satisfy the following condition:\n\n* Fo...
[{"input": "315", "output": "1\n2\n1\n3\n1\n2\n1\n4\n1\n2\n1\n3\n1\n2\n1\n5\n1\n2\n1\n3\n1\n2\n1\n4\n1\n2\n1\n3\n1\n2\n1\n6\n1\n2\n1\n3\n1\n2\n1\n4\n1\n2\n1\n3\n1\n2\n1\n5\n1\n2\n1\n3\n1\n2\n1\n4\n1\n2\n1\n3\n1\n2\n1\n7\n1\n2\n1\n3\n1\n2\n1\n4\n1\n2\n1\n3\n1\n2\n1\n5\n1\n2\n1\n3\n1\n2\n1\n4\n1\n2\n1\n3\n1\n2\n1\n6\n1\n...
code_stdio
[ { "content": "The Aizu Wakamatsu city office decided to lay a hot water pipeline covering the whole area of the city to heat houses. The pipeline starts from some hot springs and connects every district in the city. The pipeline can fork at a hot spring or a district, but no cycle is allowed. The city office wa...
[{"input": "3 5\n12 15 70 19 44\n16 13 16 0 17\n20 14 16 10 22\n17 27 18 16\n9 7 0\n19 5\n21\n0 0", "output": "43\n"}, {"input": "3 5\n12 15 70 19 44\n30 13 16 0 17\n20 14 16 10 22\n17 27 18 16\n9 7 0\n19 5\n21\n0 0", "output": "43\n"}, {"input": "3 5\n12 15 70 19 44\n9 13 16 0 17\n20 14 16 10 22\n17 27 18 16\n9 7 0\n1...
code_stdio
[ { "content": "Indian summer is such a beautiful time of the year! A girl named Alyona is walking in the forest and picking a bouquet from fallen leaves. Alyona is very choosy — she doesn't take a leaf if it matches the color and the species of the tree of one of the leaves she already has. Find out how many lea...
[{"input": "17\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbltscqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw\njtbctslqq tosqzw...
code_stdio
[ { "content": "DZY has a sequence a, consisting of n integers.\n\nWe'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.\n\nYour task is to find the longest subsegment of a, such that it is possible to change at most o...
[{"input": "50\n804289384 846930887 681692778 714636916 957747794 424238336 719885387 649760493 596516650 189641422 25202363 350490028 783368691 102520060 44897764 967513927 365180541 540383427 304089173 303455737 35005212 521595369 294702568 726956430 336465783 861021531 59961394 89018457 101513930 125898168 131176230...
code_stdio
[ { "content": "Recently a top secret mission to Mars has taken place. As a result, scientists managed to obtain some information about the Martian DNA. Now we know that any Martian DNA contains at most m different nucleotides, numbered from 1 to m. Special characteristics of the Martian DNA prevent some nucleoti...
[{"input": "853332331434235 35 77\nBy\nhs\nzB\njs\nIr\nEa\nHG\nxb\nxG\nFp\nAC\nDt\nwo\nFB\nzh\nim\ntx\nyi\ngC\nkp\njz\ndc\nwE\naa\nsG\nng\ncr\npB\nCg\ncv\nxs\nDn\ndg\nyj\nCd\naC\nIi\ngH\nml\nww\nAD\nir\nti\nEr\nCj\nHt\nAe\nsn\naH\nHv\nan\nDf\nGn\nfC\nay\ngB\nlh\nup\nda\nzs\nbh\nHB\nHd\nmg\nzy\nGi\nzm\nHq\nac\nCB\niE\nc...
code_stdio
[ { "content": "Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice.\nGiven is a string S. Find the minimum number of hugs needed to make S palindromic.\n\n-----Constraints-----\n - S is a stri...
[{"input": "cgayikejwockvntzlvpsfjtzlqfhoqoiahcodvinogbpuxhvohhcvhzmidloliztdhrntxqurzqjztjmwpylaknjncowkeuikhgc\n", "output": "30\n"}, {"input": "pgfqwbxjygkpqanpkicpaxfgeembvdgtllvtiyamxfpwtknorxxvonpntkwcffyjtvwlqgvvbzmmgfgkwezkemmxpagyihbkqidk\n", "output": "32\n"}, {"input": "ytmltbhwcqlwaliqyxgowpinxvugmgpzzahkhl...
code_stdio
[ { "content": "Given a rational number n\n\n``` n >= 0, with denominator strictly positive``` \n\n- as a string (example: \"2/3\" in Ruby, Python, Clojure, JS, CS, Go) \n- or as two strings (example: \"2\" \"3\" in Haskell, Java, CSharp, C++, Swift) \n- or as a rational or decimal number (example: 3/4, 0.67 in ...
[{"input": "\"0.66\"", "output": "[[\"1/2\", \"1/7\", \"1/59\", \"1/5163\", \"1/53307975\"]]", "fn_name": "decompose"}, {"input": "\"16/17\"", "output": "[[\"1/2\", \"1/3\", \"1/10\", \"1/128\", \"1/32640\"]]", "fn_name": "decompose"}, {"input": "\"1001/3456\"", "output": "[[\"1/4\", \"1/26\", \"1/848\", \"1/2381184\"]...
code_functional