messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Let's call left cyclic shift of some string $t_1 t_2 t_3 \\dots t_{n - 1} t_n$ as string $t_2 t_3 \\dots t_{n - 1} t_n t_1$.\n\nAnalogically, let's call right cyclic shift of string $t$ as string $t_n t_1 t_2 t_3 \\dots t_{n - 1}$.\n\nLet's say string $t$ is good if its left cyclic shift is equal ... | [{"input": "3\n142345\n100120013\n253858690946\n", "output": "4\n5\n8\n"}, {"input": "3\n175995\n155501496\n289014129764\n", "output": "4\n6\n8\n"}, {"input": "3\n142345\n100120013\n339309424207\n", "output": "4\n5\n8\n"}, {"input": "3\n142345\n186796866\n339309424207\n", "output": "4\n5\n8\n"}, {"input": "3\n180899\n1... | code_stdio |
[
{
"content": "Write a function with the signature shown below:\n```python\ndef is_int_array(arr):\n return True\n```\n* returns `true / True` if every element in an array is an integer or a float with no decimals.\n* returns `true / True` if array is empty.\n* returns `false / False` for every other inpu... | [{"input": "[-11, -12, -13, -14]", "output": "[true]", "fn_name": "is_int_array"}, {"input": "[1.0, 2.0, 3.0001]", "output": "[false]", "fn_name": "is_int_array"}, {"input": "[1.0, 2.0, 3.0]", "output": "[true]", "fn_name": "is_int_array"}, {"input": "[1, 2, null]", "output": "[false]", "fn_name": "is_int_array"}, {"in... | code_functional |
[
{
"content": "N people are arranged in a row from left to right.\nYou are given a string S of length N consisting of 0 and 1, and a positive integer K.\nThe i-th person from the left is standing on feet if the i-th character of S is 0, and standing on hands if that character is 1.\nYou will give the following d... | [{"input": "98351 25613\n1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101... | code_stdio |
[
{
"content": "Kolya got string s for his birthday, the string consists of small English letters. He immediately added k more characters to the right of the string.\n\nThen Borya came and said that the new string contained a tandem repeat of length l as a substring. How large could l be?\n\nSee notes for definit... | [{"input": "jhfwjyyzwrjiyrrgveiqkoltivghgkontrqragikttxxuwszjwqhwxindyrdqhucnbwgwrppgqmsasrzohezjlfmkzsqptwpratprcrxyxecnlsaiqrvimihmhjfgzwdtvmfhgbuonpsblphyoxzclkrwbwrkasahiirzqlfjdoomlosltldbpomyyhmdwfchzxnmwlh\n200\n", "output": "400\n"}, {"input": "nemtbujbscvkgxnbqboeohzfozihjvhcllfseiouggzojhqcoqrvtdsgkubiophnhah... | code_stdio |
[
{
"content": "You are given an array of integers $a_1,a_2,\\ldots,a_n$. Find the maximum possible value of $a_ia_ja_ka_la_t$ among all five indices $(i, j, k, l, t)$ ($i<j<k<l<t$).\n\n\n-----Input-----\n\nThe input consists of multiple test cases. The first line contains an integer $t$ ($1\\le t\\le 2 \\cdot 10... | [{"input": "4\n5\n-1 -1 -4 -1 -5\n6\n-4 -4 -3 1 2 -1\n6\n0 -1 -1 -1 -1 -1\n6\n-12 -7 -10 -3 -2 1\n", "output": "-20\n96\n0\n2520\n"}, {"input": "4\n5\n-1 -1 -4 -1 -5\n6\n-4 -4 -3 1 2 -1\n6\n0 -1 -1 -1 -1 -1\n6\n-9 -7 -10 -3 -2 1\n", "output": "-20\n96\n0\n1890\n"}, {"input": "4\n5\n-1 -1 -3 -4 -5\n6\n-1 -2 -3 1 2 -1\n6... | code_stdio |
[
{
"content": "Taro, a boy who hates any inefficiencies, pays coins so that the number of coins to be returned as change is minimized in order to do smoothly when he buys something.\n\nOne day, however, he doubt if this way is really efficient. When he pays more number of coins, a clerk consumes longer time to f... | [{"input": "123 3 0 2 0 2 0\n1263 14 10 9 3 18 1\n0 0 0 0 0 0 0", "output": "6\n13\n"}, {"input": "167 3 1 2 1 2 1\n1826 9 9 9 1 15 10\n0 0 0 0 0 0 0", "output": "6\n10\n"}, {"input": "123 6 1 2 1 1 2\n999 17 15 9 2 16 10\n0 0 0 0 0 0 0", "output": "6\n3\n"}, {"input": "123 6 1 2 1 1 2\n999 17 15 9 2 14 10\n0 0 0 0 0 0... | code_stdio |
[
{
"content": "You have k pieces of laundry, each of which you want to wash, dry and fold. You are at a laundromat that has n_1 washing machines, n_2 drying machines and n_3 folding machines. Each machine can process only one piece of laundry at a time. You can't dry a piece of laundry before it is washed, and y... | [{"input": "10000 1000 1000 1000 1000 1000 1000\n", "output": "12000\n"}, {"input": "10000 1000 1000 1000 1010 1000 1000\n", "output": "12100\n"}, {"input": "10000 1000 1000 1000 1010 1001 1000\n", "output": "12101\n"}, {"input": "10000 1000 1000 1000 1000 1000 1000\n", "output": "12000"}, {"input": "10000 1 1 1 1000 1... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nFor positive integer x let define function F(x) = 1 * (1! + x) + 2 * (2! + x) + .. + x * (x! + x). \n\"k!\" means factorial: k! = 1 * 2 * .. * k \n\nChef wants to calculate F(p_{1}) + F(p_{2}) + ... + F(p_{n}). \nAs answer could be lar... | [{"input": "1 20\n1 17 2 0 6", "output": "18\n"}, {"input": "1 19\n1 12 0 6 5", "output": "15\n"}, {"input": "5 22\n0 27 0 4 2", "output": "13\n"}, {"input": "8 34\n1 3 3 4 10", "output": "28\n"}, {"input": "15 23\n2 3 3 4 3", "output": "17\n"}, {"input": "0 27\n2 26 2 0 1", "output": "23\n"}, {"input": "15 23\n2 3 0 4... | code_stdio |
[
{
"content": "Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round.\n\nYou are a new applicant for his company. Boboniu will test you with the following chess question:\n\nConsider a $n\\times m$ grid (rows are number... | [{"input": "95 147 67 82\n", "output": "67 82\n1 82\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n... | code_stdio |
[
{
"content": "Multiplication of Big Integers\n\nGiven two integers $A$ and $B$, compute the product, $A \\times B$.\n\nInput\n\nTwo integers $A$ and $B$ separated by a space character are given in a line.\n\nOutput\n\nPrint the product in a line.\n\nConstraints\n\n* $-1 \\times 10^{1000} \\leq A, B \\leq 10^{10... | [{"input": "2 -134", "output": "-268\n"}, {"input": "3 -134", "output": "-402\n"}, {"input": "6 -134", "output": "-804\n"}, {"input": "-124 4", "output": "-496\n"}, {"input": "-103 -1", "output": "103\n"}, {"input": "2 -67", "output": "-134\n"}, {"input": "6 -51", "output": "-306\n"}, {"input": "7 -51", "output": "-357... | code_stdio |
[
{
"content": "You have managed to intercept an important message and you are trying to read it.\n\nYou realise that the message has been encoded and can be decoded by switching each letter with a corresponding letter.\n\nYou also notice that each letter is paired with the letter that it coincides with when the ... | [{"input": "\"qzezxirkg rh z srts ovevo wbmznrx fmgbkvw zmw rmgvikivgvw kiltiznnrmt ozmtfztv rg szh yvvm hgzmwziwravw rm gsv vxnzxirkg ozmtfztv hkvxrurxzgrlm zolmthrwv sgno zmw xhh rg rh lmv lu gsv gsivv vhhvmgrzo gvxsmloltrvh lu dliow drwv dvy xlmgvmg kilwfxgrlm gsv nzqlirgb lu dvyhrgvh vnkolb rg zmw rg rh hfkkligvw y... | code_functional |
[
{
"content": "Railroad Trip\n\nThere are N cities in the JOI country, numbered 1, 2, ..., and N, respectively. In addition, there are N − 1 railroads, which are numbered 1, 2, ..., and N − 1, respectively. The railroad i (1 ≤ i ≤ N − 1) connects the city i and the city i + 1 in both directions.\n\nThere are two... | [{"input": "4 4\n1 3 2 4\n147 131 100\n100 50 80\n250 70 130", "output": "577\n"}, {"input": "4 4\n1 3 3 4\n147 131 100\n100 50 80\n250 70 130", "output": "447\n"}, {"input": "4 4\n1 3 2 4\n120 90 100\n110 50 96\n250 138 130", "output": "616\n"}, {"input": "4 4\n1 3 2 4\n120 90 100\n110 50 111\n115 75 130", "output": "... | code_stdio |
[
{
"content": "In this Kata, you will be given a string of numbers in sequence and your task will be to return the missing number. If there is no number\nmissing or there is an error in the sequence, return `-1`.\n\nFor example:\n```Haskell\nmissing(\"123567\") = 4 \nmissing(\"899091939495\") = 92\nmissing(\"989... | [{"input": "\"900001900002900004900005900006\"", "output": "[900003]", "fn_name": "missing"}, {"input": "\"998999100010011003\"", "output": "[1002]", "fn_name": "missing"}, {"input": "\"99991000110002\"", "output": "[10000]", "fn_name": "missing"}, {"input": "\"979899100101102\"", "output": "[-1]", "fn_name": "missing"... | code_functional |
[
{
"content": "Sasha and Kolya decided to get drunk with Coke, again. This time they have k types of Coke. i-th type is characterised by its carbon dioxide concentration $\\frac{a_{i}}{1000}$. Today, on the party in honour of Sergiy of Vancouver they decided to prepare a glass of Coke with carbon dioxide concent... | [{"input": "971 108\n706 706 991 706 988 997 996 997 991 996 706 706 996 706 996 984 1000 991 996 1000 724 724 997 991 997 984 997 1000 984 996 996 997 724 997 997 1000 997 724 984 997 996 988 997 706 706 997 1000 991 706 988 997 724 988 706 996 706 724 997 988 996 991 1000 1000 724 988 996 1000 988 984 996 991 724 706... | code_stdio |
[
{
"content": "Genos needs your help. He was asked to solve the following programming problem by Saitama:\n\nThe length of some string s is denoted |s|. The Hamming distance between two strings s and t of equal length is defined as $\\sum_{i = 1}^{|s|}|s_{i} - t_{i}|$, where s_{i} is the i-th character of s and ... | [{"input": "1001101001101110101101000\n01111000010011111111110010001101000100011110101111\n", "output": "321\n"}, {"input": "1110010001000101001011111\n00011011000000100001010000010100110011010001111010\n", "output": "316\n"}, {"input": "1001101001101110101101000\n01111000010011111111110010001101000100011110101111\n", ... | code_stdio |
[
{
"content": "After a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known \"Heroes of Might & Magic\". A part of the game is turn-based fights of big squadrons of enemies on infinit... | [{"input": "1000000000\n", "output": "3000000003000000001\n"}, {"input": "1147564610\n", "output": "3950713605816050131\n"}, {"input": "1000010000\n", "output": "3000060003300030001\n"}, {"input": "1065935402\n", "output": "3408654846908511019\n"}, {"input": "1000010010\n", "output": "3000060063300630331\n"}, {"input":... | code_stdio |
[
{
"content": "<image>\n\n\nArrange integers (0 or more and 99 or less) in a rhombus as illustrated in Fig. 1. Create a program that reads the data representing the rhombus and outputs the maximum value of the sum of the integers that pass when starting from the top and proceeding to the bottom according to the ... | [{"input": "7\n3,8\n8,1,0\n2,9,5,4\n4,5,2,6,5\n2,7,4,4\n8,1,1\n8,3\n10", "output": "65\n"}, {"input": "7\n8,3\n8,1,0\n4,4,7,1\n5,6,2,5,4\n2,7,4,4\n8,1,0\n8,3\n15", "output": "71\n"}, {"input": "7\n8,3\n8,1,0\n4,4,7,1\n5,6,2,5,4\n2,7,4,4\n8,1,0\n8,3\n24", "output": "80\n"}, {"input": "7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n... | code_stdio |
[
{
"content": "A bracket sequence is a string, containing only characters \"(\", \")\", \"[\" and \"]\".\n\nA correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"1\" and \"+\" between the original characters of the sequence. For ex... | [{"input": "[()][([[]])][[[]()]][()[]]()()([[][]][[]][](()))[[[(())]]][]()(([([])(([[[]]()])(()))]((())))([()]([()[[[]([][[[[][(())([[]()])]]][[(())]([])]()][[](())]()[])]()[][]]([[]])[]])[(()[()((()[][()]))][])[]()()([]())](()[][][])()()[]()))[]()[]\n", "output": "61\n[()][([[]])][[[]()]][()[]]()()([[][]][[]][](()))[[... | code_stdio |
[
{
"content": "problem\n\nThere are the following games.\n\nN characters are lined up in a vertical row. The color of these characters is red, blue, or yellow, and in the initial state, four or more characters of the same color are not lined up in a row. The player can select a character at a certain position an... | [{"input": "12\n3\n2\n1\n1\n1\n3\n2\n1\n2\n1\n1\n5\n2\n3\n2\n1\n2\n2\n5\n0\n0\n3\n2\n-1\n0\n0", "output": "8\n2\n1\n2\n"}, {"input": "12\n3\n2\n1\n1\n1\n3\n2\n2\n2\n2\n1\n5\n2\n3\n2\n1\n2\n2\n5\n1\n0\n3\n2\n-1\n0\n0", "output": "3\n2\n1\n2\n"}, {"input": "12\n3\n1\n0\n1\n0\n3\n2\n2\n3\n1\n1\n3\n12\n4\n4\n2\n1\n2\n5\n2\... | code_stdio |
[
{
"content": "There are n sheets of square paper of the same size. Align the bottom of these papers horizontally and arrange them in several rows. However, adjacent rows must be arranged so that the left side is not lower than the right side. For example, n When = 5, the following 7 ways of arranging are possib... | [{"input": "5\n29\n0", "output": "5\n4 1\n3 2\n3 1 1\n2 2 1\n2 1 1 1\n1 1 1 1 1\n29\n28 1\n27 2\n27 1 1\n26 3\n26 2 1\n26 1 1 1\n25 4\n25 3 1\n25 2 2\n25 2 1 1\n25 1 1 1 1\n24 5\n24 4 1\n24 3 2\n24 3 1 1\n24 2 2 1\n24 2 1 1 1\n24 1 1 1 1 1\n23 6\n23 5 1\n23 4 2\n23 4 1 1\n23 3 3\n23 3 2 1\n23 3 1 1 1\n23 2 2 2\n23 2 2 ... | code_stdio |
[
{
"content": "Once upon a time a little frog whose name was Vasya decided to travel around his home swamp. Overall there are n mounds on the swamp, located on one line. The distance between the neighboring mounds is one meter. Vasya wants to visit all the mounds in one day; besides, he wants to visit each one e... | [{"input": "10000\n", "output": "1 10000 2 9999 3 9998 4 9997 5 9996 6 9995 7 9994 8 9993 9 9992 10 9991 11 9990 12 9989 13 9988 14 9987 15 9986 16 9985 17 9984 18 9983 19 9982 20 9981 21 9980 22 9979 23 9978 24 9977 25 9976 26 9975 27 9974 28 9973 29 9972 30 9971 31 9970 32 9969 33 9968 34 9967 35 9966 36 9965 37 9964... | code_stdio |
[
{
"content": "You have $a$ coins of value $n$ and $b$ coins of value $1$. You always pay in exact change, so you want to know if there exist such $x$ and $y$ that if you take $x$ ($0 \\le x \\le a$) coins of value $n$ and $y$ ($0 \\le y \\le b$) coins of value $1$, then the total value of taken coins will be $S... | [{"input": "6\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "6\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n1 1000000000 1 1000000000\n... | code_stdio |
[
{
"content": "# Definition\n\nAn **_element is leader_** *if it is greater than The Sum all the elements to its right side*.\n____\n\n# Task\n\n**_Given_** an *array/list [] of integers* , **_Find_** *all the **_LEADERS_** in the array*.\n___\n\n# Notes \n\n* **_Array/list_** size is *at least 3* .\n\n* **_Arra... | [{"input": "[0, -1, -29, 3, 2]", "output": "[[0, -1, 3, 2]]", "fn_name": "array_leaders"}, {"input": "[16, 17, 4, 3, 5, 2]", "output": "[[17, 5, 2]]", "fn_name": "array_leaders"}, {"input": "[-36, -12, -27]", "output": "[[-36, -12]]", "fn_name": "array_leaders"}, {"input": "[-1, -29, -26, -2]", "output": "[[-1]]", "fn_... | code_functional |
[
{
"content": "For given two circles $c1$ and $c2$, print\n\n\n4\n\n\nif they do not cross (there are 4 common tangent lines),\n\n\n3\n\n\nif they are circumscribed (there are 3 common tangent lines),\n\n\n2\n\n\nif they intersect (there are 2 common tangent lines),\n\n\n1\n\n\nif a circle is inscribed in anothe... | [{"input": "-26 -2 -2\n15 2 -1", "output": "4\n"}, {"input": "-26 -2 -2\n15 2 -2", "output": "4\n"}, {"input": "-26 -2 -1\n15 2 -2", "output": "4\n"}, {"input": "-26 -2 -1\n21 2 -2", "output": "4\n"}, {"input": "-35 -1 -1\n46 3 0", "output": "4\n"}, {"input": "-35 -1 -2\n46 3 0", "output": "4\n"}, {"input": "-35 -1 -2\... | code_stdio |
[
{
"content": "Iahub recently has learned Bubble Sort, an algorithm that is used to sort a permutation with n elements a_1, a_2, ..., a_{n} in ascending order. He is bored of this so simple algorithm, so he invents his own graph. The graph (let's call it G) initially has n vertices and 0 edges. During Bubble Sor... | [{"input": "100\n36 48 92 87 28 85 42 10 44 41 39 3 79 9 14 56 1 16 46 35 93 8 82 26 100 59 60 2 96 52 13 98 70 81 71 94 54 91 17 88 33 30 19 50 18 73 65 29 78 21 61 7 99 97 45 89 57 27 76 11 49 72 84 69 43 62 4 22 75 6 66 83 38 34 86 15 40 51 37 74 67 31 20 63 77 80 12 53 5 25 58 90 68 24 64 23 95 32 55 47\n", "output... | code_stdio |
[
{
"content": "You are an immigration officer in the Kingdom of AtCoder. The document carried by an immigrant has some number of integers written on it, and you need to check whether they meet certain criteria.\n\nAccording to the regulation, the immigrant should be allowed entry to the kingdom if and only if th... | [{"input": "5\n-1 -1 1 1 321", "output": "APPROVED\n"}, {"input": "5\n-1 -1 1 1 337", "output": "APPROVED\n"}, {"input": "5\n-1 -1 1 1 200", "output": "APPROVED\n"}, {"input": "5\n-1 -1 1 1 385", "output": "APPROVED\n"}, {"input": "5\n0 -1 5 1 252", "output": "APPROVED\n"}, {"input": "5\n6 7 3 10 31", "output": "APPROV... | code_stdio |
[
{
"content": "In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:\n\n In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the s... | [{"input": "10000\n", "output": "12471\n"}, {"input": "9999\n", "output": "12467\n"}, {"input": "10000\n", "output": "12471"}, {"input": "9999\n", "output": "12467"}, {"input": "1000\n", "output": "881\n"}, {"input": "1201\n", "output": "1096"}, {"input": "1590\n", "output": "1520"}, {"input": "1195\n", "output": "1091... | code_stdio |
[
{
"content": "Takahashi the Jumbo will practice golf.\nHis objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).\nIf he can achieve the objective, print OK; if he cannot, print NG.\n\n-----Constraints-----\n - All values in input ar... | [{"input": "1000\n2 1000\n", "output": "OK\n"}, {"input": "279\n691 872\n", "output": "OK\n"}, {"input": "379\n400 757\n", "output": "NG\n"}, {"input": "1000\n1 999\n", "output": "NG\n"}, {"input": "17\n629 629\n", "output": "OK\n"}, {"input": "48\n888 912\n", "output": "OK\n"}, {"input": "23\n391 404\n", "output": "OK... | code_stdio |
[
{
"content": "As you probably know, Anton goes to school. One of the school subjects that Anton studies is Bracketology. On the Bracketology lessons students usually learn different sequences that consist of round brackets (characters \"(\" and \")\" (without quotes)).\n\nOn the last lesson Anton learned about ... | [{"input": "((((()())))())((((((()(()())(()())()((()()))(((())()()()(())))))()())())))(()()(()))))()(((()(((())()))())())))))(()()()((((((())(()())())()())(()))))()(()))(((()()()))())()(((()(()(((()))(()))()(()))((((((((())))))()))())(())))))()(()(()(((()((()()()())(((())())((()())(((((()()(())()()(()())()()))((()()())... | code_stdio |
[
{
"content": "You are given $n$ integers $a_1, a_2, \\ldots, a_n$. Find the maximum value of $max(a_l, a_{l + 1}, \\ldots, a_r) \\cdot min(a_l, a_{l + 1}, \\ldots, a_r)$ over all pairs $(l, r)$ of integers for which $1 \\le l < r \\le n$.\n\n\n-----Input-----\n\nThe first line contains a single integer $t$ ($1 ... | [{"input": "4\n3\n2 3 3\n4\n3 0 10 1\n2\n359 139\n6\n229275 372495 402638 1125346 388084 422281\n", "output": "9\n10\n49901\n453107062748\n"}, {"input": "4\n3\n2 5 3\n4\n3 0 12 1\n2\n359 80\n6\n229275 718820 272407 1125346 388084 775159\n", "output": "15\n12\n28720\n436728777064\n"}, {"input": "4\n3\n2 3 3\n4\n3 0 6 1\... | code_stdio |
[
{
"content": "Consider 2n rows of the seats in a bus. n rows of the seats on the left and n rows of the seats on the right. Each row can be filled by two people. So the total capacity of the bus is 4n.\n\nConsider that m (m ≤ 4n) people occupy the seats in the bus. The passengers entering the bus are numbered f... | [{"input": "100 400\n", "output": "201 1 202 2 203 3 204 4 205 5 206 6 207 7 208 8 209 9 210 10 211 11 212 12 213 13 214 14 215 15 216 16 217 17 218 18 219 19 220 20 221 21 222 22 223 23 224 24 225 25 226 26 227 27 228 28 229 29 230 30 231 31 232 32 233 33 234 34 235 35 236 36 237 37 238 38 239 39 240 40 241 41 242 42 ... | code_stdio |
[
{
"content": "Dolphin is planning to generate a small amount of a certain chemical substance C.\n\nIn order to generate the substance C, he must prepare a solution which is a mixture of two substances A and B in the ratio of M_a:M_b.\n\nHe does not have any stock of chemicals, however, so he will purchase some ... | [{"input": "40 3 8\n9 1 80\n7 8 13\n1 4 64\n5 2 60\n10 10 84\n5 6 64\n2 10 43\n9 2 73\n8 3 43\n8 2 53\n10 10 26\n4 4 20\n4 10 82\n9 7 96\n4 6 15\n1 3 45\n6 7 53\n3 3 92\n7 7 74\n4 2 62\n8 4 68\n3 7 7\n5 4 73\n5 10 22\n3 5 37\n2 10 88\n3 9 74\n1 7 80\n3 6 20\n7 9 5\n6 2 79\n9 9 20\n1 10 100\n9 7 39\n1 3 33\n8 8 39\n5 1 ... | code_stdio |
[
{
"content": "One day Vasya was going home when he saw a box lying on the road. The box can be represented as a rectangular parallelepiped. Vasya needed no time to realize that the box is special, as all its edges are parallel to the coordinate axes, one of its vertices is at point (0, 0, 0), and the opposite o... | [{"input": "-827584 -680412 -103147\n897186 313672 388429\n892050 717946 505625 200144 311983 606037\n", "output": "1709658\n"}, {"input": "-827584 -680412 -103147\n897186 313672 388429\n892050 717946 505625 278931 311983 606037\n", "output": "1709658\n"}, {"input": "-827584 -680412 -103147\n897186 313672 388429\n89205... | code_stdio |
[
{
"content": "Polycarpus has n markers and m marker caps. Each marker is described by two numbers: xi is the color and yi is the diameter. Correspondingly, each cap is described by two numbers: aj is the color and bj is the diameter. Cap (aj, bj) can close marker (xi, yi) only if their diameters match, that is,... | [{"input": "6 7\n2 1\n1 1\n2 2\n1 2\n1 1\n1 2\n2 1\n1 1\n1 1\n1 1\n1 2\n2 2\n1 1\n", "output": "5 5\n"}, {"input": "6 7\n1 1\n1 1\n1 2\n1 2\n2 2\n1 2\n2 1\n2 1\n2 1\n2 1\n1 1\n1 1\n1 2\n", "output": "3 3\n"}, {"input": "6 7\n2 1\n2 2\n2 1\n1 1\n2 1\n1 2\n2 2\n2 2\n2 2\n1 2\n2 2\n1 1\n1 2\n", "output": "3 3\n"}, {"input... | code_stdio |
[
{
"content": "This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.\n\nYou are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by removing zero or more elements from the sequence a ... | [{"input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"input": "5\n3 1 4 2 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n2\n4\n1\n3\n2\n2\n4\n3\n2\n4\n3... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian as well. \nYour friend Сhef has prepared a rectangular cake for you. Both of you want to divide the cake among yourselves. Your friend is generous enough to let you choose your share first. You have decided to take two pieces.\n\nFor the fir... | [{"input": "2\n1 1 10 32\n11 11 20 20\n1 1 20 20\n11 11 30 76", "output": "360\n1515\n"}, {"input": "2\n1 1 10 10\n11 7 20 20\n1 1 20 20\n11 11 30 55", "output": "198\n1116\n"}, {"input": "2\n1 1 10 20\n11 7 20 20\n1 1 20 20\n11 11 30 55", "output": "288\n1116\n"}, {"input": "2\n1 1 10 4\n11 11 20 20\n1 1 20 20\n11 11 ... | code_stdio |
[
{
"content": "A country called Berland consists of n cities, numbered with integer numbers from 1 to n. Some of them are connected by bidirectional roads. Each road has some length. There is a path from each city to any other one by these roads. According to some Super Duper Documents, Berland is protected by t... | [{"input": "10 45 9\n2 1 428\n3 1 610\n3 2 357\n4 1 855\n4 2 528\n4 3 508\n5 1 425\n5 2 185\n5 3 349\n5 4 845\n6 1 206\n6 2 969\n6 3 153\n6 4 854\n6 5 640\n7 1 87\n7 2 250\n7 3 953\n7 4 456\n7 5 742\n7 6 588\n8 1 641\n8 2 898\n8 3 396\n8 4 960\n8 5 654\n8 6 410\n8 7 640\n9 1 707\n9 2 707\n9 3 707\n9 4 707\n9 5 707\n9 6... | code_stdio |
[
{
"content": "You are given $n$ elements numbered from $1$ to $n$, the element $i$ has value $a_i$ and color $c_i$, initially, $c_i = 0$ for all $i$.\n\nThe following operation can be applied:\n\nSelect three elements $i$, $j$ and $k$ ($1 \\leq i < j < k \\leq n$), such that $c_i$, $c_j$ and $c_k$ are all equal... | [{"input": "13\n1 2 3 2 1 3 3 4 5 5 5 4 7\n", "output": "7\n"}, {"input": "7\n1 2 1 2 7 4 7\n", "output": "2\n"}, {"input": "3\n1 1 2\n", "output": "0\n"}, {"input": "3\n1 1 1\n", "output": "1\n"}, {"input": "3\n1 2 1\n", "output": "1\n"}, {"input": "3\n1 2 2\n", "output": "0\n"}, {"input": "3\n1 2 3\n", "output": "0\n... | code_stdio |
[
{
"content": "You are given n points on the plane. The polygon formed from all the n points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from 1 to n, in clockwise order.\n\nWe define the distance betwe... | [{"input": "20\n-2967010 48581504\n-2967318 48581765\n-2967443 48581988\n-2967541 48582265\n-2967443 48582542\n-2967318 48582765\n-2967010 48583026\n-2966691 48583154\n-2966252 48583234\n-2965813 48583154\n-2965494 48583026\n-2965186 48582765\n-2965061 48582542\n-2964963 48582265\n-2965061 48581988\n-2965186 48581765\n... | code_stdio |
[
{
"content": "We have N bricks arranged in a row from left to right.\nThe i-th brick from the left (1 \\leq i \\leq N) has an integer a_i written on it.\nAmong them, you can break at most N-1 bricks of your choice.\nLet us say there are K bricks remaining. Snuke will be satisfied if, for each integer i (1 \\leq... | [{"input": "10\n3 1 4 1 10 17 1 11 0 3", "output": "9\n"}, {"input": "10\n4 1 4 1 10 17 1 11 0 3", "output": "9\n"}, {"input": "10\n4 1 4 1 10 31 1 11 0 3", "output": "9\n"}, {"input": "10\n4 1 5 1 10 31 1 11 0 3", "output": "9\n"}, {"input": "10\n4 1 5 1 10 31 2 11 0 3", "output": "7\n"}, {"input": "10\n4 1 5 1 11 31 ... | code_stdio |
[
{
"content": "Little Petya loves inequations. Help him find n positive integers a1, a2, ..., an, such that the following two conditions are satisfied:\n\n * a12 + a22 + ... + an2 ≥ x\n * a1 + a2 + ... + an ≤ y\n\nInput\n\nThe first line contains three space-separated integers n, x and y (1 ≤ n ≤ 105, 1 ≤ x ≤ ... | [{"input": "45678 1409926355077 1564465\n", "output": "1518788\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1... | code_stdio |
[
{
"content": "It is the hard version of the problem. The difference is that in this version, there are nodes with already chosen colors.\n\nTheofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you help him with this problem?\n\nYou have a per... | [{"input": "5\n9\n31 yellow\n30 green\n26 yellow\n13 red\n2 red\n22 white\n12 red\n6 orange\n29 blue\n", "output": "0\n"}, {"input": "5\n9\n31 yellow\n30 green\n26 yellow\n13 red\n2 red\n22 white\n12 red\n6 orange\n29 blue\n", "output": "0\n"}, {"input": "5\n9\n31 yellow\n30 green\n26 yellow\n25 red\n2 red\n22 white\n1... | code_stdio |
[
{
"content": "There is an easy way to obtain a new task from an old one called \"Inverse the problem\": we give an output of the original task, and ask to generate an input, such that solution to the original problem will produce the output we provided. The hard task of Topcoder Open 2014 Round 2C, InverseRMQ, ... | [{"input": "5\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n", "output": "NO\n"}, {"input": "4\n0 3 7 6\n3 -1 4 9\n7 4 0 2\n11 9 2 0\n", "output": "NO\n"}, {"input": "4\n0 3 7 6\n3 -1 4 9\n7 4 0 2\n16 9 2 0\n", "output": "NO\n"}, {"input": "4\n0 3 3 6\n3 -1 4 9\n7 4 0 2\n16 9 2 0\n", "output": "NO\n"}, {"inpu... | code_stdio |
[
{
"content": "Snuke has N dogs and M monkeys. He wants them to line up in a row.\n\nAs a Japanese saying goes, these dogs and monkeys are on bad terms. (\"ken'en no naka\", literally \"the relationship of dogs and monkeys\", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging... | [{"input": "001010 001011", "output": "931093537\n"}, {"input": "000101 000101", "output": "414723868\n"}, {"input": "000110 000111", "output": "399920258\n"}, {"input": "001111 001110", "output": "292820538\n"}, {"input": "010010 010011", "output": "475486457\n"}, {"input": "010100 010100", "output": "449134091\n"}, {... | code_stdio |
[
{
"content": "# Introduction\n\nThere is a war and nobody knows - the alphabet war! \nThere are two groups of hostile letters. The tension between left side letters and right side letters was too high and the war began. The letters called airstrike to help them in war - dashes and dots are spreaded everywhere ... | [{"input": "\"z*dq*mw*pb*s\"", "output": "[\"Let's fight again!\"]", "fn_name": "alphabet_war"}, {"input": "\"zdqmwpbs\"", "output": "[\"Let's fight again!\"]", "fn_name": "alphabet_war"}, {"input": "\"*wwwwww*z*\"", "output": "[\"Left side wins!\"]", "fn_name": "alphabet_war"}, {"input": "\"sz**z**zs\"", "output": "[\... | code_functional |
[
{
"content": "On a chessboard with a width of 10^9 and a height of 10^9, the rows are numbered from bottom to top from 1 to 10^9, and the columns are numbered from left to right from 1 to 10^9. Therefore, for each cell of the chessboard you can assign the coordinates (x,y), where x is the column number and y is... | [{"input": "0 5\n-1 96762320 34608098\n243235878 312125306 50510976\n326016273 498514053 50510976\n614560077 445224816 25950222\n1077021507 901150398 37242747\n", "output": "0\n"}, {"input": "0 5\n-1 96762320 34608098\n243235878 312125306 50510976\n326016273 498514053 90733839\n614560077 445224816 25950222\n1077021507 ... | code_stdio |
[
{
"content": "Polycarp, Arkady's friend, prepares to the programming competition and decides to write a contest. The contest consists of $n$ problems and lasts for $T$ minutes. Each of the problems is defined by two positive integers $a_i$ and $p_i$ — its difficulty and the score awarded by its solution.\n\nPol... | [{"input": "2\n4\n1.9585346052548882 31.000\n12 0\n11 6\n30 1\n5 1\n3\n1.360280845492949 30.337801087585063\n0 10\n10 8\n20 8\n", "output": "7\n18\n"}, {"input": "2\n4\n1.557488533293537 31.000\n12 0\n11 6\n30 1\n5 1\n3\n1.360280845492949 30.337801087585063\n0 10\n10 8\n20 8\n", "output": "7\n18\n"}, {"input": "2\n4\n1... | code_stdio |
[
{
"content": "Professor Ibrahim has prepared the final homework for his algorithm’s class. He asked his students to implement the Posterization Image Filter.\n\nTheir algorithm will be tested on an array of integers, where the $i$-th integer represents the color of the $i$-th pixel in the image. The image is in... | [{"input": "100 10\n39 242 238 155 95 30 129 132 72 59 22 91 203 113 99 81 253 204 160 109 92 187 11 227 145 211 100 42 78 14 113 91 140 197 123 182 4 185 208 27 182 207 63 146 102 39 159 195 26 100 72 127 157 159 152 53 0 117 101 125 19 188 179 145 240 50 205 207 113 246 42 56 161 13 188 244 159 222 119 204 26 182 212... | code_stdio |
[
{
"content": "In the city of Ultima Thule job applicants are often offered an IQ test. \n\nThe test is as follows: the person gets a piece of squared paper with a 4 × 4 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the o... | [{"input": "####\n.#..\n####\n....\n", "output": "YES\n"}, {"input": "....\n....\n....\n....\n", "output": "YES\n"}, {"input": "#..#\n.##.\n####\n####\n", "output": "YES\n"}, {"input": "#.#.\n.###\n#.#.\n.###\n", "output": "YES\n"}, {"input": "#..#\n.##.\n.##.\n#..#\n", "output": "YES\n"}, {"input": ".##.\n.#..\n##.#\n... | code_stdio |
[
{
"content": "Nobody knows, but $N$ frogs live in Chef's garden.\nNow they are siting on the X-axis and want to speak to each other. One frog can send a message to another one if the distance between them is less or equal to $K$.\nChef knows all $P$ pairs of frogs, which want to send messages. Help him to defin... | [{"input": "5 6 3\n0 3 8 8 12\n1 2\n1 3\n2 5", "output": "Yes\nYes\nYes\n"}, {"input": "5 3 3\n0 3 15 8 12\n1 2\n1 3\n3 5", "output": "Yes\nNo\nYes\n"}, {"input": "5 4 3\n0 3 2 4 23\n1 2\n1 3\n2 1", "output": "Yes\nYes\nYes\n"}, {"input": "5 4 3\n0 3 3 4 23\n1 2\n1 3\n2 1", "output": "Yes\nYes\nYes\n"}, {"input": "5 6 ... | code_stdio |
[
{
"content": "[0, 0]\n[0, 1] [1, 1]\n[0, 2] [1, 2] [2, 2]\n[0, 3] [1, 3] [2, 3] [3, 3]\n[0, 4] [1, 4] [2, 4] [3, 4] [4, 4]\n[0, 5] [1, 5] [2, 5] [3, 5] [4, 5] [5, 5]\n[0, 6] [1, 6] [2, 6] [3, 6] [4, 6] [5, 6] [6, 6]\n\n\nConsider the standard set of 28 western dominoes as shown in the above... | [{"input": "6\n16 23 16 16 15 25\n10\n00 01 11 02 12 22 03 13 13 33", "output": "Yes\nYes\n"}, {"input": "6\n13 23 14 16 15 25\n10\n00 01 11 02 12 30 03 13 36 33", "output": "Yes\nYes\n"}, {"input": "6\n11 23 16 16 15 25\n10\n00 01 11 02 12 22 03 13 13 33", "output": "Yes\nYes\n"}, {"input": "6\n13 23 14 16 15 25\n10\n... | code_stdio |
[
{
"content": "Jack loved his house very much, because his lovely cats take a nap on the wall of his house almost every day. Jack loved cats very much.\n\nJack decided to keep an observation diary of the cats as a free study during the summer vacation. After observing for a while, he noticed an interesting featu... | [{"input": "4 6\ns 0 1\ns 2 3\ns 2 1\nw 0\ns 5 2\ns 5 2\n2 3\ns 0 2\ns 1 1\ns 0 1\n0 0", "output": "0\n1\nimpossible\nimpossible\nimpossible\nEND\n0\nimpossible\nimpossible\nEND\n"}, {"input": "4 6\ns 0 2\ns 1 2\ns 2 2\nw 0\ns 3 4\ns 8 4\n2 3\ns 1 1\ns 1 2\ns 2 2\n0 0", "output": "0\n2\nimpossible\nimpossible\nimpossib... | code_stdio |
[
{
"content": "The squirrel Chokudai has N acorns. One day, he decides to do some trades in multiple precious metal exchanges to make more acorns.\n\nHis plan is as follows:\n\n1. Get out of the nest with N acorns in his hands.\n2. Go to Exchange A and do some trades.\n3. Go to Exchange B and do some trades.\n4.... | [{"input": "23\n1 2 1\n20 1 10", "output": "920\n"}, {"input": "23\n1 2 4\n10 1 4", "output": "460\n"}, {"input": "23\n1 12 1\n1 1 1", "output": "276\n"}, {"input": "23\n2 11 1\n2 1 2", "output": "506\n"}, {"input": "23\n2 2 4\n10 1 4", "output": "222\n"}, {"input": "23\n2 2 1\n20 1 2", "output": "444\n"}, {"input": "2... | code_stdio |
[
{
"content": "Petya has a simple graph (that is, a graph without loops or multiple edges) consisting of $n$ vertices and $m$ edges.\n\nThe weight of the $i$-th vertex is $a_i$.\n\nThe weight of the $i$-th edge is $w_i$.\n\nA subgraph of a graph is some set of the graph vertices and some set of the graph edges. ... | [{"input": "20 10\n487490574 766859182 860731945 956220596 584871933 815478522 698429627 781975977 485357256 396825095 566947997 680691964 834523631 323163346 665972495 5503804 738797202 410201497 91359028 708811641\n16 15 598574211\n8 7 332007499\n11 1 942159718\n3 1 24779817\n20 4 192862192\n16 6 965177283\n20 5 2673... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nTuzik is a little dog. But despite the fact he is still a puppy he already knows about the pretty things that coins are. He knows that for every coin he can get very tasty bone from his master. He believes that some day he will find a ... | [{"input": "2\n10 16\n14 18", "output": "10\n14\n"}, {"input": "2\n130 45\n4 17", "output": "42\n4\n"}, {"input": "2\n10 4\n21 19", "output": "2\n10\n"}, {"input": "2\n44 45\n2 17", "output": "44\n2\n"}, {"input": "2\n10 22\n4 16", "output": "10\n4\n"}, {"input": "2\n12 22\n4 16", "output": "12\n4\n"}, {"input": "2\n10... | code_stdio |
[
{
"content": "Paul hates palindromes. He assumes that string s is tolerable if each its character is one of the first p letters of the English alphabet and s doesn't contain any palindrome contiguous substring of length 2 or more.\n\nPaul has found a tolerable string s of length n. Help him find the lexicograph... | [{"input": "333 9\nedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedcedce... | code_stdio |
[
{
"content": "In some other world, today is Christmas.\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n - A level-0 burger is a patty.\n - A level-L burger (L \\geq 1) is a bun, a level-(L-1) burger, a pa... | [{"input": "50 4321098765432109\n", "output": "2160549382716056\n"}, {"input": "50 2251799813685246\n", "output": "1125899906842623\n"}, {"input": "50 2251799813685247\n", "output": "1125899906842624\n"}, {"input": "50 2251799813685297\n", "output": "1125899906842625\n"}, {"input": "50 4503599627370442\n", "output": "2... | code_stdio |
[
{
"content": "You are given a table consisting of n rows and m columns. Each cell of the table contains a number, 0 or 1. In one move we can choose some row of the table and cyclically shift its values either one cell to the left, or one cell to the right.\n\nTo cyclically shift a table row one cell to the righ... | [{"input": "10 10\n0000000000\n0000001000\n0000000100\n0101000100\n0000000000\n0000000000\n1000110000\n1011010010\n0000110000\n0000001001\n", "output": "-1\n"}, {"input": "10 10\n0000000000\n0000001000\n0000000100\n0101000100\n0000000000\n0000000000\n1000110000\n1011010010\n0000100000\n0000001001\n", "output": "-1"}, {... | code_stdio |
[
{
"content": "Learn, learn and learn again — Valera has to do this every day. He is studying at mathematical school, where math is the main discipline. The mathematics teacher loves her discipline very much and tries to cultivate this love in children. That's why she always gives her students large and difficul... | [{"input": "100\n-88 -5 -96 -45 -11 -81 -68 -58 -73 -91 -27 -23 -89 -34 -51 -46 -70 -95 -9 -77 -99 -61 -74 -98 -88 -44 -61 -88 -35 -71 -43 -23 -25 -98 -23 0 -1 -80 -52 -47 -26 -92 -82 -73 -45 -37 -15 -49 -9 -7 -47 0 -6 -76 -91 -20 -58 -46 -74 -57 -54 -39 -61 -18 -65 -61 -19 -64 -93 -29 -82 -25 -100 -89 -90 -68 -36 -91 ... | code_stdio |
[
{
"content": "In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury. \n\nTotally in Berland there are n citizens, the welfare of each of them is estimated as the integer in a_{i} burles (burle is... | [{"input": "70\n644488 5444 150441 714420 602059 335330 510670 196555 546346 740011 509449 850947 692874 524857 750434 952985 223744 533151 896124 609694 367352 679050 560202 172728 569291 778616 332116 286927 843598 372698 244906 498046 900681 709791 420904 724593 864493 813094 791377 39998 296710 1033347 403891 57923... | code_stdio |
[
{
"content": "Polycarp has prepared $n$ competitive programming problems. The topic of the $i$-th problem is $a_i$, and some problems' topics may coincide.\n\nPolycarp has to host several thematic contests. All problems in each contest should have the same topic, and all contests should have pairwise distinct t... | [{"input": "55\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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3\n", "output": "49\n"}, {"input": "55\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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3\n", "output": "49"}, {"input": "18\n2 1 2 10 2... | code_stdio |
[
{
"content": "Hongcow likes solving puzzles.\n\nOne day, Hongcow finds two identical puzzle pieces, with the instructions \"make a rectangle\" next to them. The pieces can be described by an n by m grid of characters, where the character 'X' denotes a part of the puzzle and '.' denotes an empty part of the grid... | [{"input": "1 500\n.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX... | code_stdio |
[
{
"content": "Monocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocarp has poor Internet connection — it takes ex... | [{"input": "6 1000000000\n999999995 999999996 999999997 999999998 999999999 1000000000\n", "output": "5999999991\n"}, {"input": "5 1000000000\n500000000 500000000 500000000 500000000 500000000\n", "output": "2500000001\n"}, {"input": "5 999999999\n500000000 500000000 500000000 500000000 500000000\n", "output": "2500000... | code_stdio |
[
{
"content": "Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is \"Squares\". Today we are visiting his studio to see how his masterpieces are given birth.\n\nAt the center of his studio, there is a huuuuuge table and beside it are many, many squares of the same size. Pablo Sq... | [{"input": "1\n5\n0 0\n0 -1\n0 2\n0 3\n12\n0 0\n0 0\n2 0\n3 0\n4 1\n5 1\n6 2\n3 2\n8 2\n9 3\n10 3\n10\n0 2\n1 3\n2 2\n3 2\n2 1\n5 1\n6 1\n7 1\n3 0\n0", "output": "1 1\n3 2\n4 5\n4 5\n"}, {"input": "1\n5\n0 -1\n0 1\n0 2\n0 3\n12\n0 0\n1 0\n2 0\n3 1\n4 1\n5 1\n6 2\n7 1\n8 2\n9 3\n10 3\n10\n0 2\n1 3\n2 2\n3 2\n2 1\n5 1\n6... | code_stdio |
[
{
"content": "You are appointed director of a famous concert hall, to save it from bankruptcy. The hall is very popular, and receives many requests to use its two fine rooms, but unfortunately the previous director was not very efficient, and it has been losing money for many years. The two rooms are of the sam... | [{"input": "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n1 20 1000\n5 25 10000\n2 30 8781\n22 300 5500\n10 117 9000\n7 7 2175\n8\n32 251 2396\n132 281 1659\n222 235 5641\n162 217 1883\n22 158 7195\n194 198 9190\n119 274 1469\n122 334 13708\n0", "output": "30\n21175\n35734\n"}, {"input": "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n... | code_stdio |
[
{
"content": "We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i.\n\nEach bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. In... | [{"input": "5 0\n-8 -10 1 -1 2", "output": "-8 -10 1 -1 2\n"}, {"input": "5 0\n-11 -10 1 0 2", "output": "-11 -10 1 0 2\n"}, {"input": "5 0\n-8 -5 2 -1 2", "output": "-8 -5 2 -1 2\n"}, {"input": "5 0\n-8 -5 1 -1 2", "output": "-8 -5 1 -1 2\n"}, {"input": "5 0\n-8 -10 1 0 2", "output": "-8 -10 1 0 2\n"}, {"input": "5 0\... | code_stdio |
[
{
"content": "There is a train going from Station A to Station B that costs X yen (the currency of Japan).\nAlso, there is a bus going from Station B to Station C that costs Y yen.\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B ... | [{"input": "100 100\n", "output": "150\n"}, {"input": "81 58\n", "output": "110\n"}, {"input": "100 2\n", "output": "101\n"}, {"input": "76 48\n", "output": "100\n"}, {"input": "-1 -17", "output": "-10\n"}, {"input": "-1 -31", "output": "-17\n"}, {"input": "-11 -1", "output": "-12\n"}, {"input": "0 1003", "output": "50... | code_stdio |
[
{
"content": "You are given a string S of length N consisting of ( and ). Your task is to insert some number of ( and ) into S to obtain a correct bracket sequence.\n\nHere, a correct bracket sequence is defined as follows: \n - () is a correct bracket sequence.\n - If X is a correct bracket sequence, the conc... | [{"input": "8\n))))((((\n", "output": "(((())))(((())))\n"}, {"input": "8\n)))(((((", "output": "((()))((((()))))\n"}, {"input": "8\n)))))(((", "output": "((((()))))((()))\n"}, {"input": "8\n))))))))", "output": "(((((((())))))))\n"}, {"input": "8\n))))((((", "output": "(((())))(((())))"}, {"input": "8\n))))(()(", "out... | code_stdio |
[
{
"content": "Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\nTo begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is l... | [{"input": "5000\n01000001011101000100001101101111011001000110010101110010000\n", "output": "500886057\n"}, {"input": "5000\n01000001011101010100001101101111011001000110010101110010000", "output": "500886057\n"}, {"input": "5000\n01000001011001010100001101101111011001000110010101110010000", "output": "500886057\n"}, {"... | code_stdio |
[
{
"content": "Little C loves number «3» very much. He loves all things about it.\n\nNow he is playing a game on a chessboard of size $n \\times m$. The cell in the $x$-th row and in the $y$-th column is called $(x,y)$. Initially, The chessboard is empty. Each time, he places two chessmen on two different empty ... | [{"input": "1000000000 1000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000 1000010000\n", "output": "1000010000000000000\n"}, {"input": "1000000000 1000000000\n", "output": "1000000000000000000"}, {"input": "1226545551 143389547\n", "output": "175873810932755396\n"}, {"input": "1109972776 380634006... | code_stdio |
[
{
"content": "Iahub accidentally discovered a secret lab. He found there n devices ordered in a line, numbered from 1 to n from left to right. Each device i (1 ≤ i ≤ n) can create either ai units of matter or ai units of antimatter. \n\nIahub wants to choose some contiguous subarray of devices in the lab, speci... | [{"input": "250\n6 1 4 3 3 7 4 5 3 2 4 4 2 6 4 2 1 7 6 2 4 5 3 3 4 5 3 4 5 4 6 4 6 5 3 3 1 5 4 5 3 4 2 4 2 5 1 4 3 3 3 2 6 6 4 7 2 6 5 3 3 6 5 2 1 3 3 5 2 2 3 7 3 5 6 4 7 3 5 3 4 5 5 4 11 5 1 5 3 3 3 1 4 6 4 4 5 5 5 5 2 5 9 3 2 2 5 6 10 5 4 2 5 4 2 5 5 3 4 2 5 4 3 2 4 4 2 5 4 1 5 3 9 6 4 6 3 5 4 5 3 6 7 4 5 10 3 6 2 6 ... | code_stdio |
[
{
"content": "Drazil is playing a math game with Varda.\n\nLet's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.\n\nFirst, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start wi... | [{"input": "15\n989898989898989\n", "output": "777777777777777333333333333333322222222222222222222222222222\n"}, {"input": "15\n999999999999990\n", "output": "77777777777777333333333333333333333333333322222222222222\n"}, {"input": "15\n997953296764414\n", "output": "7777775553333333333333322222222222\n"}, {"input": "15... | code_stdio |
[
{
"content": "One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are su... | [{"input": "50\n0 0 0\n0 1 1\n1 1 1\n0 1 0\n1 0 1\n1 1 1\n0 0 1\n1 0 0\n1 1 0\n1 0 1\n0 1 0\n0 0 1\n1 1 0\n0 1 0\n1 1 0\n0 0 0\n1 1 1\n1 0 1\n0 0 1\n1 1 0\n1 1 1\n0 1 1\n1 1 0\n0 0 0\n0 0 0\n1 1 1\n0 0 0\n1 1 1\n0 1 1\n0 0 1\n0 0 0\n0 0 0\n1 1 0\n1 1 0\n1 0 1\n1 0 0\n1 0 1\n1 0 1\n0 1 1\n1 1 0\n1 1 0\n0 1 0\n1 0 1\n0 0... | code_stdio |
[
{
"content": "You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.\n\nSome keys on the keypad have fingerprints. You believe the correct code is the longest not nece... | [{"input": "10 10\n1 2 3 4 5 6 7 8 9 0\n4 5 6 7 1 2 3 0 9 8\n", "output": "1 2 3 4 5 6 7 8 9 0\n"}, {"input": "10 10\n1 2 3 4 5 6 7 8 9 0\n4 5 6 7 1 2 3 0 9 8\n", "output": "1 2 3 4 5 6 7 8 9 0\n"}, {"input": "10 6\n7 1 2 3 8 0 6 4 5 9\n1 5 8 2 3 6\n", "output": "1 2 3 8 6 5\n"}, {"input": "10 6\n7 1 2 3 8 0 6 4 5 9\n1... | code_stdio |
[
{
"content": "The \"BerCorp\" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may k... | [{"input": "100 100\n1 33\n0\n2 35 4\n2 40 78\n1 69\n0\n1 2\n0\n0\n2 81 34\n1 45\n0\n1 87\n1 50\n1 97\n0\n2 100 59\n0\n0\n0\n1 45\n0\n0\n0\n1 6\n1 54\n0\n0\n0\n4 79 96 52 84\n1 86\n0\n0\n0\n0\n0\n0\n0\n0\n3 90 2 80\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n1 2\n0\n1 64\n0\n1 78\n1 82\n0\n0\n0\n0\n0\n1 6\n0\n0\n2 47 57\n1 95\n0\n2... | code_stdio |
[
{
"content": "Theofanis decided to visit his uncle's farm. There are $s$ animals and $n$ animal pens on the farm. For utility purpose, animal pens are constructed in one row.\n\nUncle told Theofanis that a farm is lucky if you can distribute all animals in all pens in such a way that there are no empty pens and... | [{"input": "4\n1 1 1\n1 1 1\n100 50 200\n56220 47258 14497\n", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\n1 1 1\n1 -1 2\n110 50 200\n56220 47258 14497\n", "output": "YES\nNO\nNO\nYES\n"}, {"input": "4\n1 1 1\n1 -1 2\n110 53 200\n56220 47258 14497\n", "output": "YES\nNO\nNO\nYES\n"}, {"input": "4\n1 1 1\n-1 -1 2\n0... | code_stdio |
[
{
"content": "There are two infinite sources of water: hot water of temperature $h$; cold water of temperature $c$ ($c < h$). \n\nYou perform the following procedure of alternating moves: take one cup of the hot water and pour it into an infinitely deep barrel; take one cup of the cold water and pour it int... | [{"input": "3\n30 10 20\n41 15 30\n18 13 18\n", "output": "2\n7\n1\n"}, {"input": "3\n30 10 20\n41 15 26\n18 13 18\n", "output": "2\n2\n1\n"}, {"input": "3\n30 10 20\n41 15 30\n18 13 18\n", "output": "2\n7\n1\n"}, {"input": "1\n114515 114514 114514\n", "output": "2\n"}, {"input": "1\n999855 999262 999557\n", "output": ... | code_stdio |
[
{
"content": "This is an interactive problem. Refer to the Interaction section below for better understanding.\n\nIthea and Chtholly want to play a game in order to determine who can use the kitchen tonight.\n\n<image>\n\nInitially, Ithea puts n clear sheets of paper in a line. They are numbered from 1 to n fro... | [{"input": "10 120 15\n6\n11\n9\n11\n3\n12\n11\n12\n2\n8\n3\n11\n13\n5\n12\n18\n9\n3\n10\n9\n9\n13\n13\n5\n6\n11\n3\n15\n8\n8\n10\n13\n7\n6\n4\n14\n9\n10\n5\n13\n4\n1\n8\n6\n13\n1\n3\n4\n9\n12\n2\n7\n3\n3\n7\n2\n2\n9\n2\n4\n2\n2\n11\n12\n15\n13\n6\n2\n11\n1\n8\n3\n13\n6\n15\n6\n4\n3\n4\n15\n15\n9\n5\n8\n3\n6\n14\n14\n5... | code_stdio |
[
{
"content": "### Background\n\nI was reading a [book](http://www.amazon.co.uk/Things-Make-Do-Fourth-Dimension/dp/1846147646/) recently, \"Things to Make and Do in the Fourth Dimension\" by comedian and mathematician Matt Parker, and in the first chapter of the book Matt talks about problems he likes to solve i... | [{"input": "\"123220\"\n10", "output": "[false]", "fn_name": "is_polydivisible"}, {"input": "\"30043052\"\n6", "output": "[true]", "fn_name": "is_polydivisible"}, {"input": "\"12345\"\n10", "output": "[false]", "fn_name": "is_polydivisible"}, {"input": "\"1234\"\n10", "output": "[false]", "fn_name": "is_polydivisible"}... | code_functional |
[
{
"content": "In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.\n\nThe pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). \nAoki, an explorer, conducted a sur... | [{"input": "100\n10 12 512917373\n6 9 512917366\n66 44 512917421\n49 18 512917412\n57 96 512917426\n65 72 512917442\n62 59 512917440\n27 77 512917437\n31 13 512917395\n38 39 512917428\n15 72 512917430\n0 69 512917418\n22 22 512917395\n9 69 512917427\n37 96 512917428\n12 23 512917386\n100 90 512917389\n4 60 512917415\n9... | code_stdio |
[
{
"content": "One of the most important products of the R1 company is a popular @r1.com mail service. The R1 mailboxes receive and send millions of emails every day.\n\nToday, the online news thundered with terrible information. The R1 database crashed and almost no data could be saved except for one big string... | [{"input": "gerald.agapov1991@gmail.com\n", "output": " 18"}, {"input": "x@x.x@x.x_e_@r1.com\n", "output": " 8"}, {"input": "0000000a@000a111.r\n", "output": " ... | code_stdio |
[
{
"content": "Vanya has a scales for weighing loads and weights of masses w^0, w^1, w^2, ..., w^100 grams where w is some integer not less than 2 (exactly one weight of each nominal value). Vanya wonders whether he can weight an item with mass m using the given weights, if the weights can be put on both pans of... | [{"input": "1000000000 1000000000\n", "output": "YES\n"}, {"input": "1000000000 1000000000\n", "output": "YES\n"}, {"input": "1100000000 1000000000\n", "output": "NO\n"}, {"input": "441890232 441890232\n", "output": "YES\n"}, {"input": "401739553 401739553\n", "output": "YES\n"}, {"input": "285681920 285681919\n", "out... | code_stdio |
[
{
"content": "Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a_1, a_2, ..., a_{n}.\n\nWhile Vasya was walking, his little brother Stepan playe... | [{"input": "10 1 10\n6 7 6 1 10 10 9 5 3 9\n7 10 9 6 1 5 9 3 10 6\n", "output": "TRUTH\n"}, {"input": "10 1 10\n6 7 6 1 10 10 9 5 3 9\n7 10 9 6 1 5 9 3 10 6\n", "output": "TRUTH\n"}, {"input": "8 3 6\n5 3 1 1 1 1 1 10\n3 3 1 1 1 1 5 5\n", "output": "LIE\n"}, {"input": "8 4 6\n5 3 1 1 2 1 3 5\n3 3 1 1 1 2 8 10\n", "outp... | code_stdio |
[
{
"content": "Bob is an avid fan of the video game \"League of Leesins\", and today he celebrates as the League of Leesins World Championship comes to an end! \n\nThe tournament consisted of $n$ ($n \\ge 5$) teams around the world. Before the tournament starts, Bob has made a prediction of the rankings of each ... | [{"input": "9\n7 5 3\n8 9 4\n8 1 7\n8 9 1\n1 5 7\n2 3 5\n6 3 2\n", "output": "4 9 8 1 7 5 3 2 6 \n"}, {"input": "9\n1 8 9\n9 6 4\n2 1 3\n1 2 8\n3 5 2\n6 7 4\n8 9 4\n", "output": "5 3 2 1 8 9 4 6 7 \n"}, {"input": "9\n6 9 8\n2 3 4\n2 3 1\n5 6 8\n4 6 5\n7 8 9\n3 5 4\n", "output": "1 2 3 4 5 6 8 9 7 \n"}, {"input": "9\n7 ... | code_stdio |
[
{
"content": "Polycarp wants to cook a soup. To do it, he needs to buy exactly $n$ liters of water.\n\nThere are only two types of water bottles in the nearby shop — $1$-liter bottles and $2$-liter bottles. There are infinitely many bottles of these two types in the shop.\n\nThe bottle of the first type costs $... | [{"input": "4\n10 1 3\n7 5 2\n1 1000 1\n1000000000000 42 88\n", "output": "10\n11\n1000\n42000000000000\n"}, {"input": "4\n10 1 3\n7 3 2\n1 1000 1\n1000000000000 42 88\n", "output": "10\n9\n1000\n42000000000000\n"}, {"input": "4\n10 1 3\n7 3 2\n1 1000 1\n1000000000000 42 88\n", "output": "10\n9\n1000\n42000000000000\n"... | code_stdio |
[
{
"content": "Takahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows: \n - Let the current rating of the user be a.\n - Suppose that the performance of ... | [{"input": "2002\n2017\n", "output": "2032\n"}, {"input": "4500\n-140", "output": "-4780\n"}, {"input": "4500\n-148", "output": "-4796\n"}, {"input": "4500\n-237", "output": "-4974\n"}, {"input": "2002\n416", "output": "-1170\n"}, {"input": "2002\n468", "output": "-1066\n"}, {"input": "4500\n-15", "output": "-4530\n"},... | code_stdio |
[
{
"content": "A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it can either jump to position $k+a$ or $k-b$.\n\nLet $f(x)$ be the number of distinct integers the frog can reach if it never jumps on an integer outside the interval $[0, ... | [{"input": "997674659 11231 35496\n", "output": "497677363010575988\n"}, {"input": "881706694 5710 46369\n", "output": "388703347089502553\n"}, {"input": "952549276 31416 33000\n", "output": "1718466614644254\n"}, {"input": "952549276 31416 33000\n", "output": "1718466614644254\n"}, {"input": "952549276 31416 6292\n", ... | code_stdio |
[
{
"content": "The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) has exactly two adjacent buildings with indices i-1 and i+1. The first and the... | [{"input": "3\n3\n011\n5\n10001\n7\n0000000", "output": "0\n1\n7\n"}, {"input": "3\n3\n010\n5\n10001\n7\n0010000", "output": "0\n1\n4\n"}, {"input": "3\n3\n010\n5\n10001\n7\n1010000", "output": "0\n1\n3\n"}, {"input": "3\n3\n010\n5\n10000\n7\n1010000", "output": "0\n3\n3\n"}, {"input": "3\n3\n010\n5\n10011\n7\n0000000"... | code_stdio |
[
{
"content": "Don Drumphet lives in a nice neighborhood, but one of his neighbors has started to let his house go. Don Drumphet wants to build a wall between his house and his neighbor’s, and is trying to get the neighborhood association to pay for it. He begins to solicit his neighbors to petition to get the... | [{"input": "\"Melania\"", "output": "[[\"Melania\", \"Me\"]]", "fn_name": "who_is_paying"}, {"input": "\"Melissa\"", "output": "[[\"Melissa\", \"Me\"]]", "fn_name": "who_is_paying"}, {"input": "\"Mexico\"", "output": "[[\"Mexico\", \"Me\"]]", "fn_name": "who_is_paying"}, {"input": "\"Me\"", "output": "[[\"Me\"]]", "fn_... | code_functional |
[
{
"content": "You are given a sequence of $n$ pairs of integers: $(a_1, b_1), (a_2, b_2), \\dots , (a_n, b_n)$. This sequence is called bad if it is sorted in non-descending order by first elements or if it is sorted in non-descending order by second elements. Otherwise the sequence is good. There are examples ... | [{"input": "4\n2 3\n1 2\n2 1\n2 4\n", "output": "17\n"}, {"input": "4\n2 3\n1 2\n2 1\n0 4\n", "output": "21\n"}, {"input": "4\n3 3\n2 3\n2 1\n2 4\n", "output": "16\n"}, {"input": "4\n2 3\n4 2\n2 1\n4 4\n", "output": "19\n"}, {"input": "4\n1 2\n4 2\n2 1\n2 4\n", "output": "20\n"}, {"input": "4\n2 3\n4 2\n2 1\n2 4\n", "o... | code_stdio |
[
{
"content": "You are given three positive integers x, y, n. Your task is to find the nearest fraction to fraction [Image] whose denominator is no more than n. \n\nFormally, you should find such pair of integers a, b (1 ≤ b ≤ n; 0 ≤ a) that the value $|\\frac{x}{y} - \\frac{a}{b}|$ is as minimal as possible.\n\... | [{"input": "43003 70913 108889\n", "output": "43003/70913\n"}, {"input": "76730 157792 71438\n", "output": "33069/68005\n"}, {"input": "43003 75615 108889\n", "output": "43003/75615\n"}, {"input": "76730 157792 50090\n", "output": "22477/46223\n"}, {"input": "113725 82924 57380\n", "output": "69226/50477\n"}, {"input":... | code_stdio |
[
{
"content": "Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\n\nfor i = 1 to A.length-1\nkey = A[i]\n/* insert A[i] into the sorted sequence A[0,...,j-1] */\nj = i - 1\nwhile j >= 0 and A[j] > key\nA[j+1] ... | [{"input": "6\n16 4 2 2 1 -1", "output": "16 4 2 2 1 -1\n4 16 2 2 1 -1\n2 4 16 2 1 -1\n2 2 4 16 1 -1\n1 2 2 4 16 -1\n-1 1 2 2 4 16\n"}, {"input": "6\n2 2 2 -1 2 -2", "output": "2 2 2 -1 2 -2\n2 2 2 -1 2 -2\n2 2 2 -1 2 -2\n-1 2 2 2 2 -2\n-1 2 2 2 2 -2\n-2 -1 2 2 2 2\n"}, {"input": "6\n2 0 2 -1 2 -2", "output": "2 0 2 -1... | code_stdio |
[
{
"content": "Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word \"... | [{"input": "hyyhddqhxhekehkwfhlnlsihzefwchzerevcjtokefplholrbvxlltdlafjxrfhleglrvlolojoqaolagtbeyogxlbgfolllslli\n", "output": "YES\n"}, {"input": "jhfbndhyzdvhbvhmhmefqllujdflwdpjbehedlsqfdsqlyelwjtyloxwsvasrbqosblzbowlqjmyeilcvotdlaouxhdpoeloaovb\n", "output": "YES\n"}, {"input": "hellllllllllllllllllllllllllllllllll... | code_stdio |
[
{
"content": "Polycarp has decided to decorate his room because the New Year is soon. One of the main decorations that Polycarp will install is the garland he is going to solder himself.\n\nSimple garlands consisting of several lamps connected by one wire are too boring for Polycarp. He is going to solder a gar... | [{"input": "100\n25 100 32 34 25 99 19 99 84 52 20 83 34 12 59 89 51 86 5 63 57 2 61 23 48 27 90 28 29 65 31 73 40 79 89 29 18 86 49 14 48 84 100 17 65 79 37 71 52 47 98 100 40 20 71 94 90 53 41 54 47 2 40 36 35 63 14 66 35 11 2 97 23 90 26 88 17 79 2 59 12 22 14 61 78 15 7 62 7 38 43 94 43 12 77 80 60 9 2\n", "output"... | code_stdio |
[
{
"content": "One evening Rainbow Dash and Fluttershy have come up with a game. Since the ponies are friends, they have decided not to compete in the game but to pursue a common goal. \n\nThe game starts on a square flat grid, which initially has the outline borders built up. Rainbow Dash and Fluttershy have fl... | [{"input": "1\n10000001\n", "output": "5000001\n"}, {"input": "1\n10000001\n", "output": "5000001\n"}, {"input": "1\n10001001\n", "output": "5000501\n"}, {"input": "1\n11001001\n", "output": "5500501\n"}, {"input": "1\n11011001\n", "output": "5505501\n"}, {"input": "1\n11001100\n", "output": "5500551\n"}, {"input": "1\... | code_stdio |
[
{
"content": "The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\nWe will close the window so as to minimize the total horizontal length of the uncovered p... | [{"input": "2 -777", "output": "1556\n"}, {"input": "2 -839", "output": "1680\n"}, {"input": "1 -839", "output": "1679\n"}, {"input": "100 100\n", "output": "0\n"}, {"input": "181 21", "output": "139\n"}, {"input": "194 13", "output": "168\n"}, {"input": "125 12", "output": "101\n"}, {"input": "122 -1", "output": "124\... | code_stdio |
[
{
"content": "We have two bottles for holding water.\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\nBottle 2 contains C milliliters of water.\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\nHow much amount of water will remain in Bottle 2?\n... | [{"input": "20 20 20\n", "output": "20\n"}, {"input": "6 113 -1", "output": "106\n"}, {"input": "6 228 -1", "output": "221\n"}, {"input": "2 228 -1", "output": "225\n"}, {"input": "2 396 -1", "output": "393\n"}, {"input": "2 666 -1", "output": "663\n"}, {"input": "2 481 -1", "output": "478\n"}, {"input": "2 931 -1", "o... | code_stdio |
[
{
"content": "Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [p_1, p_2, ..., p_{n}], where p_{i} denotes the number of page that should be read i-th in tu... | [{"input": "20 20\n18 17 2 3 16 15 1 9 12 8 20 11 13 14 4 5 19 7 10 6\n13 15 15\n1 1 1\n2 2 2\n11 14 11\n10 11 10\n2 8 6\n12 18 16\n4 8 8\n2 2 2\n5 11 11\n4 18 9\n5 6 6\n3 20 12\n8 8 8\n6 16 11\n9 18 18\n8 18 17\n1 1 1\n2 6 5\n1 4 3\n", "output": "No\nYes\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nYes\nNo\nNo\nY... | code_stdio |
[
{
"content": "## Objective\n\nGiven a number `n` we will define it's sXORe to be `0 XOR 1 XOR 2 ... XOR n` where `XOR` is the [bitwise XOR operator](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).\n\nWrite a function that takes `n` and returns it's sXORe.\n\n## Examples\n| n | sXORe n\n|---------|--... | [{"input": "9999999999999999999999999", "output": "[0]", "fn_name": "sxore"}, {"input": "1000000", "output": "[1000000]", "fn_name": "sxore"}, {"input": "1000001", "output": "[1]", "fn_name": "sxore"}, {"input": "50", "output": "[51]", "fn_name": "sxore"}, {"input": "0", "output": "[0]", "fn_name": "sxore"}, {"input": ... | code_functional |
[
{
"content": "Consider a table of size $n \\times m$, initially fully white. Rows are numbered $1$ through $n$ from top to bottom, columns $1$ through $m$ from left to right. Some square inside the table with odd side length was painted black. Find the center of this square.\n\n\n-----Input-----\n\nThe first li... | [{"input": "96 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nW\nW\nW\nW\nW\nW\nW\n", "output": "... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.