messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "AquaMoon has $n$ friends. They stand in a row from left to right, and the $i$-th friend from the left wears a T-shirt with a number $a_i$ written on it. Each friend has a direction (left or right). In the beginning, the direction of each friend is right.\n\nAquaMoon can make some operations on fri...
[{"input": "10\n10\n6 2 1 1 1 10 10 2 10 5\n8\n1 3 1 1 4 5 4 4\n9\n14 6 9 9 2 8 7 2 2\n10\n9 4 3 3 5 4 3 10 4 5\n9\n7 5 1 7 5 5 5 5 6\n8\n8 8 4 4 7 6 2 8\n10\n6 8 1 6 8 8 5 6 8 4\n10\n5 5 5 8 3 4 3 3 10 10\n8\n1 1 3 6 6 7 1 2\n8\n4 1 3 5 3 1 3 3\n", "output": "NO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nNO\n"}, {"input...
code_stdio
[ { "content": "The Two-dimensional kingdom is going through hard times... This morning the Three-Dimensional kingdom declared war on the Two-dimensional one. This (possibly armed) conflict will determine the ultimate owner of the straight line.\n\nThe Two-dimensional kingdom has a regular army of n people. Each ...
[{"input": "33 23 17 2\n1 1 2 2 2 3 3 3 3 3 3 4 4 4 4 4 5 5 5 6 6 7 7 7 8 8 8 8 8 9 9 10 10\n1 1 3 3 4 4 4 5 5 6 6 6 7 8 8 8 8 8 8 9 9 10 10\n", "output": "23\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n12 10\n13 11\n14 12\n17 13\n20 14\n21 15\n22 16\n23 17\n24 18\n25 19\n26 20\n27 21\n28 22\n29 23\n"}, {"input": "20...
code_stdio
[ { "content": "In some other world, today is the day before Christmas Eve.\nMr. Takaha is buying N items at a department store. The regular price of the i-th item (1 \\leq i \\leq N) is p_i yen (the currency of Japan).\nHe has a discount coupon, and can buy one item with the highest price for half the regular pr...
[{"input": "10\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n10000\n", "output": "95000\n"}, {"input": "10\n8830\n106\n9248\n6388\n3562\n7160\n8452\n3486\n5802\n9228\n", "output": "57638\n"}, {"input": "9\n6126\n5482\n9198\n9274\n2166\n2424\n1954\n2018\n1226\n", "output": "35231\n"}, {"input": "8\n346...
code_stdio
[ { "content": "There are $n$ students standing in a row. Two coaches are forming two teams β€” the first coach chooses the first team and the second coach chooses the second team.\n\nThe $i$-th student has integer programming skill $a_i$. All programming skills are distinct and between $1$ and $n$, inclusive.\n\nF...
[{"input": "100 10\n19 55 91 50 31 23 60 84 38 1 22 51 27 76 28 98 11 44 61 63 15 93 52 3 66 16 53 36 18 62 35 85 78 37 73 64 87 74 46 26 82 69 49 33 83 89 56 67 71 25 39 94 96 17 21 6 47 68 34 42 57 81 13 10 54 2 48 80 20 77 4 5 59 30 90 95 45 75 8 88 24 41 40 14 97 32 7 9 65 70 100 99 72 58 92 29 79 12 86 43\n", "out...
code_stdio
[ { "content": "Find the largest integer that can be formed with exactly N matchsticks, under the following conditions:\n - Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \\leq A_i \\leq 9).\n - The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, ...
[{"input": "10000 9\n1 2 3 4 5 6 7 8 9\n", "output": "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
code_stdio
[ { "content": "Snuke has a string x of length N. Initially, every character in x is `0`.\n\nSnuke can do the following two operations any number of times in any order:\n\n* Choose A consecutive characters in x and replace each of them with `0`.\n* Choose B consecutive characters in x and replace each of them wit...
[{"input": "1000 101 10", "output": "631009281\n"}, {"input": "1100 101 10", "output": "915151017\n"}, {"input": "1100 111 10", "output": "890861662\n"}, {"input": "1100 100 10", "output": "725819821\n"}, {"input": "1100 101 19", "output": "724720670\n"}, {"input": "1000 100 17", "output": "719982564\n"}, {"input": "11...
code_stdio
[ { "content": "Problem\n\nTaro decided to watch one movie every day at a nearby movie theater during the summer vacation. (Taro has 31 days of summer vacation from August 1st to August 31st.)\n\nThe theater is set to show n movies during the summer vacation. Each movie is assigned a number from 1 to n, and the i...
[{"input": "5\n1 18\n10 20\n20 21\n22 31\n10 15", "output": "1800\n"}, {"input": "5\n1 18\n10 20\n20 21\n22 31\n11 15", "output": "1800\n"}, {"input": "5\n1 18\n10 20\n20 21\n22 31\n10 25", "output": "1800\n"}, {"input": "5\n1 18\n16 20\n20 21\n22 31\n11 15", "output": "1800\n"}, {"input": "5\n1 10\n10 20\n20 21\n22 31...
code_stdio
[ { "content": "Mahmoud has an array a consisting of n integers. He asked Ehab to find another array b of the same length such that:\n\n b is lexicographically greater than or equal to a. b_{i} β‰₯ 2. b is pairwise coprime: for every 1 ≀ i < j ≀ n, b_{i} and b_{j} are coprime, i.Β e. GCD(b_{i}, b_{j}) = 1, where ...
[{"input": "10\n5 3 2 2 3 3 3 4 2 5\n", "output": "5 3 2 7 11 13 17 19 23 29 "}, {"input": "10\n5 3 2 2 3 3 3 4 2 5\n", "output": "5 3 2 7 11 13 17 19 23 29 "}, {"input": "10\n5 3 4 2 3 3 3 4 2 5\n", "output": "5 3 4 7 11 13 17 19 23 29\n"}, {"input": "7\n23 11 6 14 7 17 20\n", "output": "23 11 6 17 5 7 13\n"}, {"input...
code_stdio
[ { "content": "Dreamoon likes sequences very much. So he created a problem about the sequence that you can't find in OEIS: \n\nYou are given two integers d, m, find the number of arrays a, satisfying the following constraints:\n\n * The length of a is n, n β‰₯ 1 \n * 1 ≀ a_1 < a_2 < ... < a_n ≀ d \n * Define an...
[{"input": "10\n1 1100000000\n2 1587398050\n4 99999998\n4 9999997\n5 999996\n10 99995\n9 9994\n8 1104\n12 92\n19 1\n", "output": "1\n3\n11\n11\n17\n119\n89\n59\n87\n0\n"}, {"input": "10\n1 1100000000\n2 1587398050\n3 99999998\n4 9999997\n5 999996\n18 99995\n9 9994\n8 1104\n12 92\n36 1\n", "output": "1\n3\n5\n11\n17\n10...
code_stdio
[ { "content": "Welcome to PC Koshien, players. Physical condition management is important to participate in the event. It is said that at the turn of the season when the temperature fluctuates greatly, it puts a strain on the body and it is easy to catch a cold. The day you should be careful about is the day whe...
[{"input": "30 20\n55 0\n32 18\n2 23\n43 21\n34 10\n20 -13", "output": "10\n55\n14\n-21\n22\n24\n33\n"}, {"input": "30 19\n39 20\n19 18\n4 20\n22 21\n23 10\n10 -10", "output": "11\n19\n1\n-16\n1\n13\n20\n"}, {"input": "30 19\n39 20\n19 18\n4 20\n22 21\n23 10\n15 -10", "output": "11\n19\n1\n-16\n1\n13\n25\n"}, {"input":...
code_stdio
[ { "content": "Little Chris is a huge fan of linear algebra. This time he has been given a homework about the unusual square of a square matrix.\n\nThe dot product of two integer number vectors x and y of size n is the sum of the products of the corresponding components of the vectors. The unusual square of an n...
[{"input": "5\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n7\n3\n2 4\n1 3\n3\n2 5\n1 2\n3\n", "output": "111\n"}, {"input": "5\n1 0 1 1 1\n0 1 0 1 0\n1 0 1 1 1\n0 1 0 1 0\n1 0 1 0 0\n7\n3\n2 4\n1 3\n3\n2 5\n1 1\n3\n", "output": "000\n"}, {"input": "5\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n0 1 0 1 0\n1 0 1 0 1\n7\...
code_stdio
[ { "content": "A calculator scholar has discovered a strange life form called an electronic fly that lives in electronic space. While observing the behavior of the electronic flies, the electronic flies at the (x, y, z) point in this space then move to (x', y', z') indicated by the following rules. I found out.\...
[{"input": "2 5 6 7 6 13\n517 1389 746 11867 4303 3125\n0 0 0 0 0 0", "output": "12\n3426307500\n"}, {"input": "2 5 6 7 6 25\n517 1389 746 11867 4303 3125\n0 0 0 0 0 0", "output": "20\n3426307500\n"}, {"input": "2 5 3 7 6 13\n913 1354 746 12979 4303 1361\n0 0 0 0 0 0", "output": "12\n1491431760\n"}, {"input": "2 5 5 7 ...
code_stdio
[ { "content": "King Mercer is the king of ACM kingdom. There are one capital and some cities in his kingdom. Amazingly, there are no roads in the kingdom now. Recently, he planned to construct roads between the capital and the cities, but it turned out that the construction cost of his plan is much higher than e...
[{"input": "3 3\n1 2 1 4\n2 3 2 1\n3 1 3 2\n5 5\n1 3 2 2\n2 3 1 1\n1 4 1 1\n4 5 1 1\n5 3 2 1\n5 10\n1 2 32 10\n1 3 43 43\n1 4 12 77\n1 5 84 23\n2 3 58 42\n2 4 86 163\n2 3 57 133\n3 4 11 32\n3 5 75 41\n4 5 17 43\n5 10\n1 2 1 53\n1 5 0 65\n2 4 1 24\n1 5 1 76\n2 3 2 19\n2 4 1 46\n2 5 1 25\n3 4 1 13\n3 5 1 65\n4 5 1 34\n0 ...
code_stdio
[ { "content": "Let's call a non-empty sequence of positive integers a_1, a_2... a_{k} coprime if the greatest common divisor of all elements of this sequence is equal to 1.\n\nGiven an array a consisting of n positive integers, find the number of its coprime subsequences. Since the answer may be very large, prin...
[{"input": "100\n881 479 355 759 257 497 690 598 275 446 439 787 257 326 584 713 322 5 253 781 434 307 164 154 241 381 38 942 680 906 240 11 431 478 628 959 346 74 493 964 455 746 950 41 585 549 892 687 264 41 487 676 63 453 861 980 477 901 80 907 285 506 619 748 773 743 56 925 651 685 845 313 419 504 770 324 2 559 405...
code_stdio
[ { "content": "The only difference between easy and hard versions is the number of elements in the array.\n\nYou are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \\lfloor\\frac{a_i}{2}\\rflo...
[{"input": "50 25\n199970 199997 199998 199988 199999 199981 200000 199990 199974 199985 199932 200000 199966 199999 199999 199951 199983 199975 199974 199996 199974 199992 199979 199995 199955 199989 199960 199975 199983 199990 199950 199952 199999 199999 199962 199939 199979 199977 199962 199996 199910 199997 199976 ...
code_stdio
[ { "content": "Squirrel Liss is interested in sequences. She also has preferences of integers. She thinks n integers a_1, a_2, ..., a_{n} are good.\n\nNow she is interested in good sequences. A sequence x_1, x_2, ..., x_{k} is called good if it satisfies the following three conditions: The sequence is strictly ...
[{"input": "49\n10 34 58 72 126 166 176 180 198 200 208 228 238 248 302 332 340 344 350 354 380 406 418 428 438 442 482 532 536 544 546 554 596 626 642 682 684 704 714 792 804 820 862 880 906 946 954 966 970\n", "output": "49\n"}, {"input": "49\n10 34 58 72 126 166 176 180 198 200 208 228 238 248 302 332 340 344 350 35...
code_stdio
[ { "content": "You are given an array $a_1, a_2, \\dots , a_n$, which is sorted in non-decreasing order ($a_i \\le a_{i + 1})$. \n\nFind three indices $i$, $j$, $k$ such that $1 \\le i < j < k \\le n$ and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to...
[{"input": "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "output": "1 2 7\n-1\n1 2 3\n"}, {"input": "3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n", "output": "1 2 7\n-1\n1 2 3\n"}, {"input": "3\n7\n4 6 11 11 15 18 34\n4\n10 10 10 11\n3\n1 1 1000000000\n", "output": "1 2 7\n-1\n1 2 3\...
code_stdio
[ { "content": "This is the harder version of the problem. In this version, $1 \\le n, m \\le 2\\cdot10^5$. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems.\n\nYou are given a sequence of integers $a=[a_1,a_2,\\dots,a_n]$ of length $n$. Its subseq...
[{"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 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...
code_stdio
[ { "content": "The Bitlandians are quite weird people. They do everything differently. They have a different alphabet so they have a different definition for a string.\n\nA Bitlandish string is a string made only of characters \"0\" and \"1\".\n\nBitHaval (the mayor of Bitland) loves to play with Bitlandish stri...
[{"input": "1000000000000000000000000000000000000011111111000000000000\n0111111111100000000000111111111000000000000000111111110001\n", "output": "YES\n"}, {"input": "1000000000000000000000000000000000000011111111000000000000\n0111111111100000000000111111111000000000000000111111110001\n", "output": "YES\n"}, {"input": "...
code_stdio
[ { "content": "There is a sequence of length N: A_1, A_2, ..., A_N. Initially, this sequence is a permutation of 1, 2, ..., N.\nOn this sequence, Snuke can perform the following operation:\n - Choose K consecutive elements in the sequence. Then, replace the value of each chosen element with the minimum value amo...
[{"input": "7635 1737\n1 4336 5028 2246 3376 4632 3484 5018 6851 5712 6421 1045 4582 6443 5762 2211 5622 2385 1213 6493 6742 4499 7581 6655 2974 2212 2861 4283 5757 1316 4008 2602 5971 4098 5433 1398 4622 7224 93 4338 1998 1188 853 2588 2210 7123 3903 1360 1308 3213 3437 2333 6285 2126 3228 2323 7477 34 3187 3914 1128 ...
code_stdio
[ { "content": "The customer telephone support center of the computer sales company called JAG is now in- credibly confused. There are too many customers who request the support, and they call the support center all the time. So, the company wants to figure out how many operators needed to handle this situation.\...
[{"input": "3 300\n100 46 150\n100 50 150\n101 50 148\n3 300\n110 50 150\n100 50 150\n200 50 150\n9 18\n5 1 1\n3 1 1\n3 1 1\n4 100 1\n5 100 1\n5 100 1\n10 5 5\n10 5 5\n2 7 1000\n10 18\n1 2 6\n2 3 1\n3 4 5\n4 5 6\n5 6 7\n6 7 8\n7 8 9\n12 9 10\n9 10 11\n18 11 12\n0 0", "output": "2\n3\n5\n10\n"}, {"input": "3 300\n100 46...
code_stdio
[ { "content": "You are given two integers $n$ and $m$. You have to construct the array $a$ of length $n$ consisting of non-negative integers (i.e. integers greater than or equal to zero) such that the sum of elements of this array is exactly $m$ and the value $\\sum\\limits_{i=1}^{n-1} |a_i - a_{i+1}|$ is the ma...
[{"input": "5\n1 100\n2 -1\n5 5\n2 1000000000\n1000100000 1000000000\n", "output": "0\n-1\n10\n1000000000\n2000000000\n"}, {"input": "5\n1 100\n2 2\n5 5\n2 1000000000\n1000000000 1000000000\n", "output": "0\n2\n10\n1000000000\n2000000000\n"}, {"input": "5\n1 100\n2 0\n5 5\n2 1000000000\n1000000000 1000000000\n", "outpu...
code_stdio
[ { "content": "The preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the full name. Typically there are multiple possible logins for each person.\n\nYou ...
[{"input": "asdfghjkli ware\n", "output": "asdfghjkliw\n"}, {"input": "asdfghjkli ware\n", "output": "asdfghjkliw\n"}, {"input": "asdfghkkli ware\n", "output": "asdfghkkliw\n"}, {"input": "ilkkhgfdsa ware\n", "output": "ilkkhgfdsaw\n"}, {"input": "aaaaaaaaaz york\n", "output": "aaaaaaaaay\n"}, {"input": "aaaaaaaaaz yor...
code_stdio
[ { "content": "There are N cells arranged in a row, numbered 1, 2, \\ldots, N from left to right.\nTak lives in these cells and is currently on Cell 1. He is trying to reach Cell N by using the procedure described below.\nYou are given an integer K that is less than or equal to 10, and K non-intersecting segment...
[{"input": "200000 10\n195313 197047\n198503 199144\n199910 200000\n193793 195312\n186922 193792\n199860 199909\n199145 199570\n197048 198502\n1 186921\n199571 199859\n", "output": "946746535\n"}, {"input": "199993 10\n23896 23905\n92651 92660\n184931 184940\n101332 101341\n126813 126822\n52635 52644\n9715 9724\n58620 ...
code_stdio
[ { "content": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive).\nIn how many pairs of a subsequence of S and a subsequence of T do the two subsequences are the same in content?\nHere the subsequence of A is a sequence obtaine...
[{"input": "1989 1986\n84234 80908 59749 63761 63761 49034 63761 64697 84234 84234 64697 64697 49034 80908 80908 63761 66200 59749 59749 80908 84234 63761 80908 80908 66200 92283 84234 63761 80908 63761 92283 59749 49034 78052 53613 49034 92283 80908 53613 59749 49034 49034 59749 80908 66200 80908 63761 64697 92283 490...
code_stdio
[ { "content": "There are N+1 towns. The i-th town is being attacked by A_i monsters.\nWe have N heroes. The i-th hero can defeat monsters attacking the i-th or (i+1)-th town, for a total of at most B_i monsters.\nWhat is the maximum total number of monsters the heroes can cooperate to defeat?\n\n-----Constraints...
[{"input": "1611\n999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 999999999 99...
code_stdio
[ { "content": "An integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9.\nDetermine whether N is a multiple of 9.\n\n-----Constraints-----\n - 0 \\leq N < 10^{200000}\n - N is an integer.\n\n-----Input-----\nInput is given from Standard Input in t...
[{"input": "33813819154164361588118768953262516554574111032083043031384286303065210509562262038973079975476396016546146039303789823110933080134565927492314604458575884820133400398416950126075966048913496870281342656762187821939147033106717650124502612019109078419691362651717290499399798948652832533487239630898917216407...
code_stdio
[ { "content": "There are N non-negative integers written on a blackboard. The i-th integer is A_i.\nTakahashi can perform the following two kinds of operations any number of times in any order:\n - Select one integer written on the board (let this integer be X). Write 2X on the board, without erasing the selecte...
[{"input": "6 111011100000010010101101010101101010001000000101011101000101001110110110011101000000000000011110011100110111011101100111111011000100110111111010000100100110110100110000001000011110010001001110011100001101101010010000010111001001111111101000101111011111011111011101001001011000101011110101010111101101010100...
code_stdio
[ { "content": "Genos recently installed the game Zuma on his phone. In Zuma there exists a line of n gemstones, the i-th of which has color c_{i}. The goal of the game is to destroy all the gemstones in the line as quickly as possible.\n\nIn one second, Genos is able to choose exactly one continuous substring of...
[{"input": "50\n22 19 14 22 20 11 16 28 23 15 3 23 6 16 30 15 15 10 24 28 19 19 22 30 28 1 27 12 12 14 17 30 17 26 21 26 27 1 11 23 9 30 18 19 17 29 11 20 29 24\n", "output": "25\n"}, {"input": "50\n22 19 14 22 20 11 16 28 23 15 3 23 6 16 30 15 15 10 24 28 19 19 22 30 28 1 27 12 12 14 17 30 17 26 21 26 27 1 11 23 9 30 ...
code_stdio
[ { "content": "The spring is coming and it means that a lot of fruits appear on the counters. One sunny day little boy Valera decided to go shopping. He made a list of m fruits he wanted to buy. If Valera want to buy more than one fruit of some kind, he includes it into the list several times. \n\nWhen he came t...
[{"input": "24 24\n25 69 103 18 40 8 78 14 14 10 27 61 75 140 10 69 80 71 102 8 91 14 15 10\nswtcofrcpeys{ydwkrg\nszyd\ndyzsyep\nrcpeyszydwkrgfj\nfgrkwdyzsyfp\ndwyz\nsmzginydyrtua\nj\nk\ntzwsw\ngfj\nmsplnqossy\ninydyrtuatzw\ninxdy\nlpsmzginydyrtuatzwswtcofrcpeyszy\nyssoqnlpsm\npeyszyd\nysosqnlpsm\ninydy\ndyztyep\ninywy...
code_stdio
[ { "content": "Think of New York as a rectangular grid consisting of N vertical avenues numerated from 1 to N and M horizontal streets numerated 1 to M. C friends are staying at C hotels located at some street-avenue crossings. They are going to celebrate birthday of one of them in the one of H restaurants also ...
[{"input": "100 100\n10\n53 20\n97 6\n12 74\n48 92\n97 13\n47 96\n123 32\n69 21\n95 75\n1 54\n10\n36 97\n41 1\n1 87\n39 23\n27 44\n73 97\n1 1\n6 26\n48 3\n5 69\n", "output": "108\n4\n"}, {"input": "100 100\n10\n53 20\n97 6\n12 74\n48 92\n97 13\n47 96\n123 32\n69 21\n95 75\n1 54\n10\n36 97\n18 1\n1 87\n39 23\n27 44\n73 ...
code_stdio
[ { "content": "On some square in the lowest row of a chessboard a stands a pawn. It has only two variants of moving: upwards and leftwards or upwards and rightwards. The pawn can choose from which square of the lowest row it can start its journey. On each square lay from 0 to 9 peas. The pawn wants to reach the ...
[{"input": "100 3 4\n644\n861\n478\n250\n560\n998\n141\n162\n386\n778\n123\n811\n602\n533\n391\n515\n898\n215\n965\n556\n446\n883\n256\n195\n573\n889\n515\n240\n179\n339\n258\n593\n930\n730\n735\n949\n522\n067\n549\n366\n452\n405\n473\n188\n488\n994\n000\n046\n930\n217\n897\n580\n509\n032\n343\n722\n176\n925\n728\n717\...
code_stdio
[ { "content": "There are N rabbits, numbered 1 through N.\n\nThe i-th (1≀i≀N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_iβ‰ i.\n\nFor a pair of rabbits i and j (i<j), we call the pair (i,j) a friendly pair if the following condition is met.\n\n* Rabbit i likes rabbit j and rabbit j l...
[{"input": "5\n5 5 5 -1 2", "output": "1\n"}, {"input": "5\n5 5 5 -2 2", "output": "1\n"}, {"input": "5\n3 5 5 -1 1", "output": "0\n"}, {"input": "5\n5 5 5 -1 1", "output": "1\n"}, {"input": "5\n3 3 5 -1 1", "output": "0\n"}, {"input": "5\n0 5 1 -1 2", "output": "1\n"}, {"input": "5\n5 3 5 -1 0", "output": "0\n"}, {"in...
code_stdio
[ { "content": "A sequence of non-negative integers a1, a2, ..., an of length n is called a wool sequence if and only if there exists two integers l and r (1 ≀ l ≀ r ≀ n) such that <image>. In other words each wool sequence contains a subsequence of consecutive elements with xor equal to 0.\n\nThe expression <ima...
[{"input": "100000 100000\n", "output": "738698541\n"}, {"input": "50000 100000\n", "output": "821709120\n"}, {"input": "21857 94145\n", "output": "689996210\n"}, {"input": "50664 46559\n", "output": "425318276\n"}, {"input": "25063 54317\n", "output": "735545216\n"}, {"input": "62600 39199\n", "output": "366778414\n"}...
code_stdio
[ { "content": "Vova's family is building the Great Vova Wall (named by Vova himself). Vova's parents, grandparents, grand-grandparents contributed to it. Now it's totally up to Vova to put the finishing touches.\n\nThe current state of the wall can be respresented by a sequence $a$ of $n$ integers, with $a_i$ be...
[{"input": "20\n10 5 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"input": "20\n10 5 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"input": "20\n10 1 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"}, {"input": "20\n16 1 2 3 5 7 7 9 4 9 9 4 9 7 7 5 3 2 5 10\n", "output": "NO\n"},...
code_stdio
[ { "content": "There are $n$ programmers that you want to split into several non-empty teams. The skill of the $i$-th programmer is $a_i$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among ...
[{"input": "3\n5 10\n13 11 2 14 1\n4 8\n2 4 2 1\n4 8\n1 3 3 7\n", "output": "3\n0\n1\n"}, {"input": "3\n5 10\n14 11 4 5 1\n4 11\n2 7 2 1\n4 8\n1 4 3 2\n", "output": "2\n0\n0\n"}, {"input": "3\n5 17\n7 11 2 9 5\n4 8\n2 1 2 3\n4 11\n1 3 3 11\n", "output": "1\n0\n1\n"}, {"input": "3\n5 10\n11 11 4 9 2\n4 15\n2 4 2 1\n4 9\...
code_stdio
[ { "content": "There are n railway stations in Berland. They are connected to each other by n-1 railway sections. The railway network is connected, i.e. can be represented as an undirected tree.\n\nYou have a map of that network, so for each railway section you know which stations it connects.\n\nEach of the n-1...
[{"input": "10\n9 4\n5 7\n2 1\n3 4\n2 10\n6 3\n2 5\n1 3\n4 8\n8\n6 8 3\n10 5 3\n2 10 3\n3 5 2\n8 4 3\n1 9 3\n9 5 2\n3 10 2\n", "output": "3 1 2 3 3 3 3 3 3 \n"}, {"input": "10\n3 6\n3 2\n4 1\n1 10\n3 8\n5 2\n6 7\n2 1\n6 9\n7\n9 10 3\n5 7 1\n9 10 3\n7 4 1\n3 10 4\n3 6 4\n5 1 4\n", "output": "4 4 1 4 1 4 1 4 3 \n"}, {"in...
code_stdio
[ { "content": "Find the edit distance between given two words s1 and s2.\n\nThe disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations:\n\n* insertion: Insert a character at a particular position.\n* deletion: Delete a cha...
[{"input": "icpc\nipcc", "output": "2\n"}, {"input": "icpb\ncbio", "output": "4\n"}, {"input": "cpci\nipcc", "output": "2\n"}, {"input": "cpci\nccpi", "output": "2\n"}, {"input": "icpc\nccpi", "output": "2\n"}, {"input": "ibpc\nccpi", "output": "3\n"}, {"input": "icpb\nccpi", "output": "2\n"}, {"input": "icpb\nccip", "...
code_stdio
[ { "content": "Problem\n\nThere are $ 2 $ teams, Team UKU and Team Ushi. Initially, Team UKU has $ N $ people and Team Uku has $ M $ people. Team UKU and Team Ushi decided to play a game called \"U & U\". \"U & U\" has a common score for $ 2 $ teams, and the goal is to work together to minimize the common score....
[{"input": "1000000000000000000 1000000000010000000", "output": "4\n"}, {"input": "1000000001000000000 1000000000010000000", "output": "2\n"}, {"input": "1000001001000000000 1000000000010000000", "output": "2\n"}, {"input": "1000001001001000000 1000000000010000000", "output": "2\n"}, {"input": "1000001001001000010 1000...
code_stdio
[ { "content": "AtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≀i≀N) is a_i.\nBecause he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.\nThen, for each card i, he judges wh...
[{"input": "6 20\n10 4 3 10 25 2\n", "output": "3\n"}, {"input": "6 20\n10 4 5 10 25 2", "output": "0\n"}, {"input": "6 20\n10 4 5 10 25 3", "output": "0\n"}, {"input": "6 20\n10 4 3 10 25 2", "output": "3"}, {"input": "1 586\n-1 2 1 -2 5", "output": "1\n"}, {"input": "1 988\n-1 2 1 -2 5", "output": "1\n"}, {"input": "...
code_stdio
[ { "content": "You have two strings A = A_1 A_2 ... A_n and B = B_1 B_2 ... B_n of the same length consisting of 0 and 1.\n\nYou can transform A using the following operations in any order and as many times as you want:\n\n* Shift A by one character to the left (i.e., if A = A_1 A_2 ... A_n, replace A with A_2 A...
[{"input": "0100100\n1111101", "output": "4\n"}, {"input": "0100100\n1100000", "output": "5\n"}, {"input": "0100100\n0000001", "output": "6\n"}, {"input": "0100100\n0111111", "output": "4\n"}, {"input": "0100100\n0101111", "output": "3\n"}, {"input": "0100100\n0101110", "output": "2\n"}, {"input": "0100100\n0101100", "...
code_stdio
[ { "content": "Problem\n\nIn 1333, the greatest scientist in human history, Dr. Ushishi, developed an artificial intelligence with an ID of ai1333 in order to pass on his wisdom to posterity. For the next 100 years, ai1333 brought great benefits to humankind, but on the 100th anniversary of its birth, it created...
[{"input": "200", "output": "ai133333\n"}, {"input": "300", "output": "ai1333333"}, {"input": "100", "output": "ai13333\n"}, {"input": "-12", "output": "ai1333\n"}, {"input": "-22", "output": "ai1333\n"}, {"input": "-21", "output": "ai1333\n"}, {"input": "-32", "output": "ai1333\n"}, {"input": "-10", "output": "ai1333\...
code_stdio
[ { "content": "You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal.\n\nOperation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perf...
[{"input": "5\n-1 -1 -1 18 1\n1 1 1 0 0", "output": "No\n"}, {"input": "5\n-1 -1 -1 18 1\n1 2 1 0 0", "output": "No\n"}, {"input": "5\n-1 -1 -1 12 1\n1 2 1 0 0", "output": "No\n"}, {"input": "5\n7 2 8 2 14\n1 7 2 -1 10", "output": "No\n"}, {"input": "5\n7 2 8 2 11\n1 7 2 -1 10", "output": "No\n"}, {"input": "5\n7 2 8 2...
code_stdio
[ { "content": "It is the hard version of the problem. The only difference is that in this version $1 \\le n \\le 300$.\n\nIn the cinema seats can be represented as the table with $n$ rows and $m$ columns. The rows are numbered with integers from $1$ to $n$. The seats in each row are numbered with consecutive int...
[{"input": "7\n1 2\n1 1\n3 2\n1 1 2 2 4 6\n3 3\n3 4 4 1 1 1 1 1 5\n2 2\n2 1 2 1\n4 2\n50 50 50 50 3 50 56 50\n4 2\n6 6 6 10 2 2 9 6\n2 9\n1 3 2 3 3 6 1 1 3 2 3 1 1 6 3 1 1 3\n", "output": "0\n1\n2\n0\n0\n0\n12\n"}, {"input": "7\n1 2\n1 1\n3 2\n1 1 2 4 4 6\n3 3\n3 4 4 1 1 1 1 1 5\n2 2\n2 1 2 1\n4 2\n50 50 50 50 3 50 56 ...
code_stdio
[ { "content": "On a planet far, far away, M languages are spoken. They are conveniently numbered 1 through M.\n\nFor CODE FESTIVAL 20XX held on this planet, N participants gathered from all over the planet.\n\nThe i-th (1≦i≦N) participant can speak K_i languages numbered L_{i,1}, L_{i,2}, ..., L_{i,{}K_i}.\n\nTw...
[{"input": "4 6\n3 2 3 3\n2 4 2\n2 4 6\n1 6", "output": "YES\n"}, {"input": "4 6\n3 2 3 4\n2 4 2\n2 4 6\n1 6", "output": "YES\n"}, {"input": "4 6\n3 2 3 4\n2 4 4\n2 4 6\n1 6", "output": "YES\n"}, {"input": "4 6\n3 0 3 4\n2 4 4\n2 4 6\n1 6", "output": "YES\n"}, {"input": "4 6\n3 0 2 3\n2 4 2\n2 4 6\n1 6", "output": "YES...
code_stdio
[ { "content": "In programming languages like C/C++, a goto statement provides an unconditional jump from the \"goto\" to a labeled statement. For example, a statement \"goto CHECK_NUM;\" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops.\n\nNote...
[{"input": "430", "output": " 3 6 9 12 13 15 18 21 23 24 27 30 31 32 33 34 35 36 37 38 39 42 43 45 48 51 53 54 57 60 63 66 69 72 73 75 78 81 83 84 87 90 93 96 99 102 103 105 108 111 113 114 117 120 123 126 129 130 131 132 133 134 135 136 137 138 139 141 143 144 147 150 153 156 159 162 163 165 168 171 173 174 177 180 18...
code_stdio
[ { "content": "A little boy Gerald entered a clothes shop and found out something very unpleasant: not all clothes turns out to match. For example, Gerald noticed that he looks rather ridiculous in a smoking suit and a baseball cap.\n\nOverall the shop sells n clothing items, and exactly m pairs of clothing item...
[{"input": "6 11\n95 81 74 94 60 69\n3 2\n1 4\n4 2\n3 4\n1 5\n5 2\n5 3\n1 6\n2 6\n3 6\n4 6\n", "output": "215"}, {"input": "6 10\n29 5 55 24 55 74\n1 4\n2 3\n3 4\n5 1\n5 2\n5 3\n4 5\n6 2\n6 3\n6 5\n", "output": "108\n"}, {"input": "6 10\n17 5 55 24 55 74\n1 3\n2 3\n3 4\n5 1\n5 2\n5 3\n4 5\n6 2\n6 3\n6 5\n", "output": "...
code_stdio
[ { "content": "Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options:\n\n on this day ...
[{"input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "100\n"}, {"input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
code_stdio
[ { "content": "The reciprocal of all non-zero real numbers is real, but the reciprocal of an integer is not necessarily an integer. This is the reason why 3/2 * 2 = 2 even though 3.0 / 2.0 * 2.0 = 3.0 in C language. However, if you consider integers with the same remainder after dividing by a prime number as the...
[{"input": "5: 2 - 3\n17: 1 + 3 * (2 + 3 / 5 * 2) + 7\n11: 1 / 8 - 5 - 8 * 2\n19: 8 / (2 - 1 * 7)\n1153: 10 * 3 / 7 + ( 50 + 151 / 22 ) + 11\n0:", "output": "2-3 = 4 (mod 5)\n1+3*(2+3/5*2)+7 = 4 (mod 17)\n1/8-5-8*2 = 8 (mod 11)\n8/(2-1*7) = 6 (mod 19)\n10*3/7+(50+151/22)+11 = 1023 (mod 1153)\n"}, {"input": "5: 3 - 3\n1...
code_stdio
[ { "content": "There are N turkeys. We number them from 1 through N.\n\nM men will visit here one by one. The i-th man to visit will take the following action:\n\n* If both turkeys x_i and y_i are alive: selects one of them with equal probability, then eats it.\n* If either turkey x_i or y_i is alive (but not bo...
[{"input": "14 1\n5 9\n2 13\n7 6\n4 9\n4 8\n2 13\n0 12\n3 3\n3 1\n3 10", "output": "90\n"}, {"input": "16 1\n8 9\n2 8\n4 6\n4 9\n7 8\n2 11\n1 8\n3 4\n6 4\n3 7", "output": "119\n"}, {"input": "24 1\n8 9\n2 8\n5 6\n4 9\n7 3\n2 11\n1 8\n3 4\n1 4\n3 7", "output": "275\n"}, {"input": "24 2\n8 9\n2 8\n5 5\n4 9\n7 3\n2 11\n1 ...
code_stdio
[ { "content": "An IPv6-address is a 128-bit number. For convenience, this number is recorded in blocks of 16 bits in hexadecimal record, the blocks are separated by colons β€” 8 blocks in total, each block has four hexadecimal digits. Here is an example of the correct record of a IPv6 address: \"0124:5678:90ab:cde...
[{"input": "20\n0:0:9e39:9:b21:c9b:c:0\n0:0:0:0:0:a27:6b:cb0a\n2:7:4d:b:0:3:2:f401\n17:2dc6::0:89e3:0:dc:0\nca:4:0:0:d6:b999:e:0\n4af:553:b29:dd7:2:5b:0:7\n0:c981:8f:a4d:0:d4:0:f61\n0:0:1:0:dc33:0:1964:0\n84:da:0:6d6:0ecc:1:f:0\n4:fb:4d37:0:8c:4:4a52:24\nc:e:a:0:0:0:e:0\n0:3761:72ed:b7:3b0:ff7:fc:102\n5ae:8ca7:10::0:9b...
code_stdio
[ { "content": "Vasya often uses public transport. The transport in the city is of two types: trolleys and buses. The city has n buses and m trolleys, the buses are numbered by integers from 1 to n, the trolleys are numbered by integers from 1 to m.\n\nPublic transport is not free. There are 4 types of tickets: ...
[{"input": "680 871 347 800\n10 100\n872 156 571 136 703 201 832 213 15 333\n465 435 870 173 660 237 694 594 423 405 27 866 325 490 255 989 128 345 278 125 708 210 771 848 961 448 871 190 745 343 532 174 103 999 874 221 252 500 886 129 185 208 137 425 758 34 696 15 198 981 91 50 545 885 194 583 475 415 162 712 116 911 ...
code_stdio
[ { "content": "You have got a shelf and want to put some books on it.\n\nYou are given $q$ queries of three types: L $id$ β€” put a book having index $id$ on the shelf to the left from the leftmost existing book; R $id$ β€” put a book having index $id$ on the shelf to the right from the rightmost existing book; ?...
[{"input": "10\nL 100\nR 100000\nR 123\nL 101\n? 123\nL 10\nR 115\n? 100\nR 110\n? 115\n", "output": "0\n2\n1\n"}, {"input": "10\nL 100\nR 101000\nR 123\nL 101\n? 123\nL 10\nR 115\n? 100\nR 110\n? 115\n", "output": "0\n2\n1\n"}, {"input": "10\nL 100\nR 100000\nR 123\nL 101\n? 123\nL 17\nR 115\n? 100\nR 110\n? 115\n", "...
code_stdio
[ { "content": "Two players, Red and Blue, are at it again, and this time they're playing with crayons! The mischievous duo is now vandalizing a rooted tree, by coloring the nodes while playing their favorite game.\n\nThe game works as follows: there is a tree of size n, rooted at node 1, where each node is initi...
[{"input": "21 2\n1 2\n2 3\n2 4\n4 5\n10 6\n6 7\n13 8\n8 9\n1 10\n3 11\n11 12\n12 13\n3 15\n14 15\n20 16\n14 17\n14 18\n14 19\n14 20\n17 21\n", "output": "-70\n"}, {"input": "21 1\n1 2\n2 3\n2 4\n4 5\n10 6\n6 7\n14 8\n8 9\n9 10\n3 11\n11 12\n12 13\n5 14\n14 15\n14 16\n14 17\n14 18\n14 19\n14 20\n14 21\n", "output": "-9...
code_stdio
[ { "content": "A card pyramid of height $1$ is constructed by resting two cards against each other. For $h>1$, a card pyramid of height $h$ is constructed by placing a card pyramid of height $h-1$ onto a base. A base consists of $h$ pyramids of height $1$, and $h-1$ cards on top. For example, card pyramids of he...
[{"input": "50\n11833308\n5211498\n64660\n9077929\n2699416\n2432035\n234901\n1337830\n8457191\n10523566\n5722429\n5452712\n5511654\n8587879\n348160\n3141182\n2661936\n395300\n6950223\n2119926\n4407089\n3559060\n10228325\n5752720\n1607500\n647047\n8904557\n1954681\n698061\n9852830\n1972893\n13760200\n5944868\n9527673\n2...
code_stdio
[ { "content": "William arrived at a conference dedicated to cryptocurrencies. Networking, meeting new people, and using friends' connections are essential to stay up to date with the latest news from the world of cryptocurrencies.\n\nThe conference has $n$ participants, who are initially unfamiliar with each oth...
[{"input": "10 8\n1 2\n2 3\n3 4\n1 4\n6 7\n8 9\n8 10\n1 4\n", "output": "1\n2\n3\n4\n5\n5\n6\n8\n"}, {"input": "7 6\n1 2\n3 4\n2 4\n7 6\n6 5\n1 7\n", "output": "1\n1\n3\n3\n3\n6\n"}, {"input": "4 3\n2 1\n4 1\n1 2\n", "output": "1\n2\n3\n"}, {"input": "3 2\n1 3\n3 1\n", "output": "1\n2\n"}, {"input": "4 2\n2 4\n3 4\n", ...
code_stdio
[ { "content": "One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.\n\nBut there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a probl...
[{"input": "____________________________________________________________________________________________________\n", "output": "NO\n"}, {"input": "__________________________________________________________________________________________________`_\n", "output": "NO\n"}, {"input": "_`____________________________________...
code_stdio
[ { "content": "You are given array $a_1, a_2, \\dots, a_n$. Find the subsegment $a_l, a_{l+1}, \\dots, a_r$ ($1 \\le l \\le r \\le n$) with maximum arithmetic mean $\\frac{1}{r - l + 1}\\sum\\limits_{i=l}^{r}{a_i}$ (in floating-point numbers, i.e. without any rounding).\n\nIf there are many such subsegments find...
[{"input": "101\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 2 2 2 2 2\n", "output": "101\n"}, {"input": "101\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...
code_stdio
[ { "content": "Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has a_{i} coins. \n\nPolycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive ...
[{"input": "99\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000...
code_stdio
[ { "content": "After lessons Nastya decided to read a book. The book contains $n$ chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.\n\nYesterday evening Nastya did not manage to finish reading the book, so she marked the pa...
[{"input": "49\n1 17\n18 115\n116 211\n212 269\n270 345\n346 404\n405 441\n442 467\n468 526\n527 583\n584 664\n665 757\n758 794\n795 802\n803 882\n883 920\n921 960\n961 962\n963 1006\n1007 1081\n1082 1112\n1113 1149\n1150 1217\n1218 1282\n1283 1287\n1288 1365\n1366 1374\n1375 1379\n1380 1478\n1479 1524\n1525 1549\n1550...
code_stdio
[ { "content": "As you have noticed, there are lovely girls in Arpa’s land.\n\nPeople in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crushi.\n\n<image>\n\nSomeday Arpa shouted Owf loudly from the top of the palace and a funny game started in ...
[{"input": "100\n84 94 72 32 61 90 61 2 76 42 35 82 90 29 51 27 65 99 38 41 44 73 100 58 56 64 54 31 14 58 57 64 90 49 73 80 74 19 31 86 73 44 39 43 28 95 23 5 85 5 74 81 34 44 86 30 50 57 94 56 53 42 53 87 92 78 53 49 78 60 37 63 41 19 15 68 25 77 87 48 23 100 54 27 68 84 43 92 76 55 2 94 100 20 92 18 76 83 100 99\n",...
code_stdio
[ { "content": "The electrical resistance is the opposition to the passage of electric current. If two resistors with resistance R1 and R2 are connected to each other, the resultant resistance R depends on how their ends are connected. If they are connected in Series, they simply add up to give R = R1 + R2. If th...
[{"input": "3\n1 36\n2 16\n100 11111", "output": "1/1\n2/3\n10456/4100\n"}, {"input": "3\n1 20\n4 17\n100 10010", "output": "1/1\n13/4\n5501/5775\n"}, {"input": "3\n1 20\n4 17\n101 10010", "output": "1/1\n13/4\n1266/7041\n"}, {"input": "3\n1 10\n1 12\n100 10000", "output": "1/1\n1/1\n4301/9525\n"}, {"input": "3\n1 20\n...
code_stdio
[ { "content": "At the school where the twins Ami and Mami attend, the summer vacation has already begun, and a huge amount of homework has been given this year as well. However, the two of them were still trying to go out without doing any homework today. It is obvious that you will see crying on the last day of...
[{"input": "4\n1 2\n3 1\n4 1\n2 1\n3\n10 4\n1 2\n1 2\n1\n1000 1000\n10\n5 62\n10 68\n15 132\n20 73\n25 75\n30 77\n35 79\n40 82\n45 100\n815 283\n6\n106 21\n53 55\n118 77\n19 13\n83 42\n2 1\n0", "output": "15\n24\n3000\n2072\n590\n"}, {"input": "4\n1 2\n3 1\n4 1\n2 2\n3\n10 4\n1 2\n1 2\n1\n1000 1000\n10\n5 62\n10 68\n15...
code_stdio
[ { "content": "Sasha and Dima want to buy two $n$-tier cakes. Each cake should consist of $n$ different tiers: from the size of $1$ to the size of $n$. Tiers should go in order from the smallest to the biggest (from top to bottom).\n\nThey live on the same street, there are $2 \\cdot n$ houses in a row from left...
[{"input": "10\n8 8 3 9 7 1 9 6 10 6 4 2 7 3 4 10 5 5 1 2\n", "output": "123\n"}, {"input": "10\n8 8 3 9 7 1 9 6 10 6 4 2 7 3 4 10 5 5 1 2\n", "output": "123\n"}, {"input": "9\n1 3 6 1 4 9 2 8 3 4 8 7 5 7 2 5 9 6\n", "output": "89\n"}, {"input": "9\n1 3 6 1 4 9 2 8 3 4 8 7 5 7 2 5 9 6\n", "output": "89\n"}, {"input": "...
code_stdio
[ { "content": "Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to right.\n\nIlya is really keep on helping his city. So, he wants to fix at least k holes (perharps he can f...
[{"input": "3 3 3\n1 2 1000000000\n2 3 1000000000\n1 1 1000000000\n", "output": "2000000000\n"}, {"input": "10 7 1\n3 5 15\n8 9 8\n5 6 8\n9 10 6\n1 4 2\n1 4 10\n8 10 13\n", "output": "2\n"}, {"input": "10 7 1\n3 5 15\n8 9 8\n4 6 8\n9 10 6\n1 4 2\n1 4 10\n8 10 13\n", "output": "2\n"}, {"input": "10 7 1\n3 5 15\n8 9 8\n4...
code_stdio
[ { "content": "Example\n\nInput\n\n2 2 2 0 0 0 5\n\n\nOutput\n\n1 3 3 1 0\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": "2 2 4 1 0 1 35", "output": "1 4 6 4 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"input": "1 1 4 0 0 0 24", "output": "1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"input": "1 1 4 0 0 1 24", "output": "1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"input": "1 2 4 0 0 ...
code_stdio
[ { "content": "Fafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.\n\nFafa finds doing this every time is very tiring for him. So, he decided to ...
[{"input": "100000\n", "output": "35\n"}, {"input": "83160\n", "output": "127\n"}, {"input": "127925\n", "output": "23\n"}, {"input": "99999\n", "output": "11\n"}, {"input": "65536\n", "output": "16\n"}, {"input": "40320\n", "output": "95\n"}, {"input": "30030\n", "output": "63\n"}, {"input": "10000\n", "output": "24\n...
code_stdio
[ { "content": "We have N integers A_1, A_2, ..., A_N.\nThere are \\frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?\n\n-----Constraints-----\n - All values in input are ...
[{"input": "30 413\n-170202098 -268409015 537203564 983211703 11883920 -443999067 -286607651 -159124657 -358352725 526800997 -1907718835 648738515 -1273635706 -1268616353 37909651 -1 1196187672 -20098238 0 -948955241 1 -214720580 287839163 -18897162 694477644 0 -425610555 158912296 842295515 0", "output": "546429541592...
code_stdio
[ { "content": "This is the easy version of the problem. The only difference is that in this version k = 0.\n\nThere is an array a_1, a_2, …, a_n of n positive integers. You should divide it into a minimal number of continuous segments, such that in each segment there are no two numbers (on different positions), ...
[{"input": "2\n14 0\n1 16 1 81 1 36 1 1024 1 1000000 1 1048576 1 4194304\n14 0\n1 16 1 112 1 36 1 1024 1 1000000 1 1048576 1 4194304\n", "output": "14\n13\n"}, {"input": "2\n14 0\n2 16 1 81 1 36 1 1024 1 1000000 1 1048576 1 4194304\n14 0\n1 16 1 112 1 36 1 1024 1 1000000 1 1048576 1 4194304\n", "output": "13\n13\n"}, {...
code_stdio
[ { "content": "After a long journey, the super-space-time immigrant ship carrying you finally discovered a planet that seems to be habitable. The planet, named JOI, is a harsh planet with three types of terrain, \"Jungle,\" \"Ocean,\" and \"Ice,\" as the name implies. A simple survey created a map of the area ar...
[{"input": "4 7\n4\nJIOJOIJ\nIJIOJOO\nJOIJOOI\nOOJJIJO\n5 7 0 7\n2 2 3 0\n2 3 2 2\n1 1 0 7", "output": "-1 -2 -1\n-1 0 -1\n0 0 0\n0 0 0\n"}, {"input": "4 7\n4\nJIOJOIJ\nIJIOJOO\nJOIJOOI\nOOJJIJO\n5 2 0 7\n2 2 2 0\n2 3 2 2\n1 1 0 7", "output": "-8 -10 -6\n0 0 -1\n0 0 0\n0 0 0\n"}, {"input": "4 7\n4\nJIOJOIJ\nOJIOJOI\nJO...
code_stdio
[ { "content": "Given an integer x, find 2 integers a and b such that: \n\n * 1 ≀ a,b ≀ x \n * b divides a (a is divisible by b). \n * a β‹… b>x. \n * a/b<x. \n\nInput\n\nThe only line contains the integer x (1 ≀ x ≀ 100).\n\nOutput\n\nYou should output two integers a and b, satisfying the given conditions, sep...
[{"input": "100\n", "output": "11 11\n"}, {"input": "82\n", "output": "10 10\n"}, {"input": "92\n", "output": "10 10\n"}, {"input": "90\n", "output": "10 10\n"}, {"input": "86\n", "output": "10 10\n"}, {"input": "98\n", "output": "10 10\n"}, {"input": "87\n", "output": "10 10\n"}, {"input": "85\n", "output": "10 10\n"}...
code_stdio
[ { "content": "You have three tasks, all of which need to be completed.\nFirst, you can complete any one task at cost 0.\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\nHere, |x| denotes the absolute value of x.\nFind the minimum total cost required to complete al...
[{"input": "100 100 000", "output": "100\n"}, {"input": "100 111 000", "output": "111\n"}, {"input": "100 111 001", "output": "110\n"}, {"input": "100 111 010", "output": "101\n"}, {"input": "110 001 010", "output": "109\n"}, {"input": "100 000 000", "output": "100\n"}, {"input": "100 100 100\n", "output": "0\n"}, {"in...
code_stdio
[ { "content": "Joisino is working as a receptionist at a theater.\nThe theater has 100000 seats, numbered from 1 to 100000.\nAccording to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).\nHow many people are sitting at the ...
[{"input": "2\n151 -2\n0 4", "output": "-147\n"}, {"input": "2\n276 -2\n0 4", "output": "-272\n"}, {"input": "2\n276 -1\n0 4", "output": "-271\n"}, {"input": "2\n276 -1\n0 7", "output": "-268\n"}, {"input": "2\n276 -2\n0 7", "output": "-269\n"}, {"input": "2\n331 -1\n0 7", "output": "-323\n"}, {"input": "2\n331 -1\n0 3...
code_stdio
[ { "content": "There is a beautiful garden of stones in Innopolis.\n\nIts most beautiful place is the $n$ piles with stones numbered from $1$ to $n$.\n\nEJOI participants have visited this place twice. \n\nWhen they first visited it, the number of stones in piles was $x_1, x_2, \\ldots, x_n$, correspondingly. On...
[{"input": "50\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100...
code_stdio
[ { "content": "There are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\n* Choose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\n\n\nFind ...
[{"input": "7\n1\n2\n10\n2\n1\n6\n2", "output": "5\n"}, {"input": "7\n1\n2\n1\n2\n3\n3\n2", "output": "6\n"}, {"input": "7\n1\n3\n1\n2\n1\n3\n2", "output": "7\n"}, {"input": "7\n1\n3\n1\n2\n4\n3\n2", "output": "5\n"}, {"input": "7\n1\n3\n1\n2\n2\n3\n2", "output": "5\n"}, {"input": "7\n1\n2\n2\n2\n3\n3\n2", "output": "2...
code_stdio
[ { "content": "Eugeny has array a = a_1, a_2, ..., a_{n}, consisting of n integers. Each integer a_{i} equals to -1, or to 1. Also, he has m queries: Query number i is given as a pair of integers l_{i}, r_{i} (1 ≀ l_{i} ≀ r_{i} ≀ n). The response to the query will be integer 1, if the elements of array a can b...
[{"input": "10 10\n-1 1 -1 1 -1 -1 -1 -1 -1 -1\n6 10\n4 5\n3 6\n2 3\n3 5\n4 5\n3 4\n1 7\n1 1\n1 1\n", "output": "0\n1\n1\n1\n0\n1\n1\n0\n0\n0\n"}, {"input": "10 10\n-1 1 -1 1 -1 -1 -1 -1 -1 -1\n6 13\n4 5\n3 6\n2 3\n0 5\n4 5\n3 4\n1 4\n1 1\n1 1\n", "output": "0\n1\n1\n1\n0\n1\n1\n1\n0\n0\n"}, {"input": "10 10\n-1 1 -1 1...
code_stdio
[ { "content": "After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of n horizontal and m vertical sticks.\n\nAn intersection point is any point on the grid which is formed by the intersection of one horizontal stick and one vertical stic...
[{"input": "100 100\n", "output": "Malvika\n"}, {"input": "100 100\n", "output": "Malvika\n"}, {"input": "98 100\n", "output": "Malvika\n"}, {"input": "100 98\n", "output": "Malvika\n"}, {"input": "98 100\n", "output": "Malvika\n"}, {"input": "100 98\n", "output": "Malvika\n"}, {"input": "28 100\n", "output": "Malvika\...
code_stdio
[ { "content": "Read problems statements in Russian also. \nChef plays with the sequence of N numbers. During a single move Chef is able to choose a non-decreasing subsequence of the sequence and to remove it from the sequence. Help him to remove all the numbers in the minimal number of moves. \n\n------ Input --...
[{"input": "4\n20 -1 -2 -4", "output": "4\n"}, {"input": "4\n0 -2 6 10", "output": "2\n"}, {"input": "4\n1 -2 6 10", "output": "2\n"}, {"input": "4\n2 -2 6 10", "output": "2\n"}, {"input": "4\n4 -2 6 10", "output": "2\n"}, {"input": "4\n2 -1 6 10", "output": "2\n"}, {"input": "4\n0 -1 6 10", "output": "2\n"}, {"input":...
code_stdio
[ { "content": "Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.\n\nYou are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place ...
[{"input": "128982\n", "output": "17 16 15 14 13 11 10 9 8 7 5 3 2\n"}, {"input": "97205\n", "output": "17 15 14 13 12 10 9 8 6 5 3 1 \n"}, {"input": "97205\n", "output": "17 15 14 13 12 10 9 8 6 5 3 1\n"}, {"input": "32698\n", "output": "15 14 13 12 11 10 9 8 6 5 4 2\n"}, {"input": "97260\n", "output": "17 15 14 13 12...
code_stdio
[ { "content": "The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called \"Testing Pants for Sadness\".\n\nThe test consists of n questions; the questions are to be answered strictly in the order in which they are ...
[{"input": "50\n515844718 503470143 928669067 209884122 322869098 241621928 844696197 105586164 552680307 968792756 135928721 842094825 298782438 829020472 791637138 285482545 811025527 428952878 887796419 11883658 546401594 6272027 100292274 308219869 372132044 955814846 644008184 521195760 919389466 215065725 6877641...
code_stdio
[ { "content": "You are given $n$ strings $s_1, s_2, \\ldots, s_n$ consisting of lowercase Latin letters.\n\nIn one operation you can remove a character from a string $s_i$ and insert it to an arbitrary position in a string $s_j$ ($j$ may be equal to $i$). You may perform this operation any number of times. Is it...
[{"input": "4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc\n", "output": "YES\nNO\nYES\nNO\n"}, {"input": "4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc\n", "output": "YES\nNO\nYES\nNO\n"}, {"input": "1\n26\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\n...
code_stdio
[ { "content": "Naman has two binary strings $s$ and $t$ of length $n$ (a binary string is a string which only consists of the characters \"0\" and \"1\"). He wants to convert $s$ into $t$ using the following operation as few times as possible.\n\nIn one operation, he can choose any subsequence of $s$ and rotate ...
[{"input": "12\n011001010101\n111001010101\n", "output": "-1\n"}, {"input": "12\n011101010101\n101001010101\n", "output": "-1\n"}, {"input": "12\n011001010101\n111001010101\n", "output": "-1"}, {"input": "12\n011101010101\n111001010101\n", "output": "1\n"}, {"input": "10\n1010011110\n1011101101\n", "output": "-1\n"}, {...
code_stdio
[ { "content": "Leha is planning his journey from Moscow to Saratov. He hates trains, so he has decided to get from one city to another by car.\n\nThe path from Moscow to Saratov can be represented as a straight line (well, it's not that straight in reality, but in this problem we will consider it to be straight)...
[{"input": "100\n3 3 3 4 7 8 8 8 9 9 10 12 12 13 14 14 15 15 16 17 17 20 21 21 22 22 23 25 29 31 36 37 37 38 39 40 41 41 41 42 43 44 45 46 46 47 47 49 49 49 51 52 52 53 54 55 59 59 59 60 62 63 63 64 66 69 70 71 71 72 74 76 76 77 77 78 78 79 80 81 81 82 82 84 85 86 87 87 87 89 91 92 92 92 92 97 98 99 100 100\n", "output...
code_stdio
[ { "content": "Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x_1 = a, another one is in the point x_2 = b. \n\nEach of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend ...
[{"input": "864\n179\n", "output": "117649\n"}, {"input": "967\n102\n", "output": "187489\n"}, {"input": "967\n142\n", "output": "170569\n"}, {"input": "967\n282\n", "output": "117649\n"}, {"input": "944\n193\n", "output": "141376\n"}, {"input": "1\n1000\n", "output": "250000\n"}, {"input": "1000\n1\n", "output": "2500...
code_stdio
[ { "content": "Given are integer sequence of length N, A = (A_1, A_2, \\cdots, A_N), and an integer K.\nFor each X such that 1 \\le X \\le K, find the following value:\n\\left(\\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} (A_L+A_R)^X\\right) \\bmod 998244353\n\n-----Constraints-----\n - All values in input ...
[{"input": "192 275\n426 445 272 81 447 129 497 202 275 325 482 284 417 156 432 402 228 37 357 239 418 211 179 6 340 68 368 16 440 263 93 449 491 310 355 68 431 80 257 218 434 328 176 355 221 80 422 45 11 67 467 174 191 4 335 34 465 480 221 395 1 152 325 231 302 153 396 22 489 399 107 466 432 2 468 333 475 292 84 10 19...
code_stdio
[ { "content": "The problem statement looms below, filling you with determination.\n\nConsider a grid in which some cells are empty and some cells are filled. Call a cell in this grid exitable if, starting at that cell, you can exit the grid by moving up and left through only empty cells. This includes the cell i...
[{"input": "3 3\nXX.\n...\n.XX\n10\n1 3\n1 3\n1 2\n1 2\n3 3\n1 3\n2 3\n3 3\n2 3\n2 2\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "3 3\n..X\nX.X\n..X\n10\n2 3\n2 2\n3 3\n1 3\n1 1\n3 3\n3 3\n1 1\n1 2\n1 1\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "3 ...
code_stdio
[ { "content": "There are $n$ beautiful skyscrapers in New York, the height of the $i$-th one is $h_i$. Today some villains have set on fire first $n - 1$ of them, and now the only safety building is $n$-th skyscraper.\n\nLet's call a jump from $i$-th skyscraper to $j$-th ($i < j$) discrete, if all skyscrapers be...
[{"input": "8\n7 2 5 5 1 2 5 2\n", "output": "4\n"}, {"input": "8\n7 2 5 5 1 2 2 2\n", "output": "5\n"}, {"input": "8\n7 2 5 5 2 2 5 2\n", "output": "4\n"}, {"input": "8\n4 3 5 5 1 2 5 2\n", "output": "4\n"}, {"input": "5\n110 1 100 1 100\n", "output": "2\n"}, {"input": "8\n7 2 5 5 3 2 5 2\n", "output": "3\n"}, {"input...
code_stdio
[ { "content": "Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game.\n\nRules of the game are very simple: at first number o...
[{"input": "100\n4 3\n3 4\n5 1\n2 5\n5 3\n1 5\n6 3\n2 4\n5 2\n2 6\n5 2\n1 5\n6 3\n1 5\n6 3\n3 4\n5 2\n1 5\n6 1\n1 5\n4 2\n3 5\n6 3\n2 6\n6 3\n1 4\n6 2\n3 4\n4 1\n3 6\n5 1\n2 4\n5 1\n3 4\n6 2\n3 5\n4 1\n2 6\n4 3\n2 6\n5 2\n3 6\n6 2\n3 5\n4 3\n1 5\n5 3\n3 6\n4 2\n3 4\n6 1\n3 4\n5 2\n2 6\n5 2\n2 4\n6 2\n3 6\n4 3\n2 4\n4 3...
code_stdio
[ { "content": "Kuro has just learned about permutations and he is really excited to create a new permutation type. He has chosen $n$ distinct positive integers and put all of them in a set $S$. Now he defines a magical permutation to be: A permutation of integers from $0$ to $2^x - 1$, where $x$ is a non-negativ...
[{"input": "69\n1034 414 632 614 62 855 915 385 1098 8 462 1750 1227 960 450 25 1307 578 37 262 482 1143 844 696 1004 1008 70 1137 509 1217 561 557 192 513 792 794 1335 1201 1290 543 698 55 119 536 1088 162 1074 676 246 457 662 595 1054 1252 778 165 703 1222 326 158 145 272 729 381 1087 1261 717 113 73\n", "output": "1...
code_stdio
[ { "content": "The Kingdom of Kremland is a tree (a connected undirected graph without cycles) consisting of $n$ vertices. Each vertex $i$ has its own value $a_i$. All vertices are connected in series by edges. Formally, for every $1 \\leq i < n$ there is an edge between the vertices of $i$ and $i+1$.\n\nDenote ...
[{"input": "44\n42 44 4 24 29 17 32 30 30 9 28 9 22 16 20 41 17 19 41 23 28 19 38 44 1 34 41 34 19 36 32 37 22 31 4 3 27 23 21 21 26 39 20 8\n", "output": "6926\n"}, {"input": "44\n42 44 4 24 29 17 32 30 30 9 28 9 22 16 20 41 17 19 41 23 28 19 38 44 1 34 41 34 19 36 32 37 22 31 4 3 27 23 21 21 26 39 20 8\n", "output": ...
code_stdio
[ { "content": "In 40XX, the Earth was invaded by aliens! Already most of the Earth has been dominated by aliens, leaving Tsuruga Castle Fortress as the only remaining defense base. Suppression units are approaching the Tsuruga Castle Fortress one after another.\n\n<image>\n\n\nBut hope remains. The ultimate defe...
[{"input": "110 5\n111 101 5 5\n110 110 2 3\n-112 -100 5 11\n-208 160 109 90\n-110 159 10 3\n26 11\n15 -1 5 2\n25 0 5 1\n35 0 5 1\n118 0 5 1\n55 0 5 1\n65 0 5 1\n149 -1 5 1\n169 0 1 1\n90 0 5 1\n-19 -1 5 20\n-30 0 500 5\n0 0", "output": "1\n4\n"}, {"input": "100 5\n111 101 5 5\n110 110 2 3\n-112 -100 5 11\n-208 160 109...
code_stdio
[ { "content": "There are n points on a straight line, and the i-th point among them is located at x_{i}. All these coordinates are distinct.\n\nDetermine the number m β€” the smallest number of points you should add on the line to make the distances between all neighboring points equal. \n\n\n-----Input-----\n\nTh...
[{"input": "10\n711183437 845779129 -106125616 -481773790 66231250 -183390793 -711197523 -196001897 -440633306 -873649505\n", "output": "156311685\n"}, {"input": "10\n711183437 845779129 -106125616 -481773790 66231250 -183390793 -711197523 -196001897 -440633306 -873649505\n", "output": "156311685\n"}, {"input": "7\n996...
code_stdio
[ { "content": "There are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel ...
[{"input": "5 4 0\n1 2 2\n3 5 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n3 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5", "output": "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n"}, {"input": "5 4 1\n1 2 2\n3 2 2\n3 4 1\n4 5 3\n20\n2 1\n3 1\n3 1\n5 1\n1 2...
code_stdio
[ { "content": "There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. \n\nHan Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0...
[{"input": "10 -4 -4\n2 -4\n2 0\n-4 2\n5 -4\n-3 -5\n1 4\n-4 2\n-3 5\n0 -3\n2 4\n", "output": "8\n"}, {"input": "10 -4 -4\n2 -4\n2 0\n-4 2\n5 -4\n-3 -5\n1 4\n-4 2\n-3 5\n0 -3\n2 4\n", "output": "8\n"}, {"input": "10 -4 -4\n1 -4\n2 0\n-4 2\n5 -4\n-3 -5\n1 4\n-4 2\n-3 5\n0 -3\n2 4\n", "output": "8\n"}, {"input": "10 -4 -4...
code_stdio
[ { "content": "Hanh lives in a shared apartment. There are $n$ people (including Hanh) living there, each has a private fridge. \n\n$n$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all cha...
[{"input": "10\n10 10\n8 9 2 10 3 8 10 9 1 10\n10 10\n3 10 3 13 12 14 3 3 4 4\n10 5\n7 13 10 14 5 12 5 5 7 11\n10 10\n12 13 3 6 12 9 6 6 5 7\n10 10\n4 10 15 13 13 15 9 8 8 14\n10 10\n2 3 8 5 9 7 11 12 7 9\n10 10\n12 15 11 10 1 8 10 3 4 2\n10 5\n8 11 7 14 7 9 5 2 8 9\n10 10\n4 9 9 9 10 4 1 12 13 15\n10 10\n12 2 7 5 15 8...
code_stdio
[ { "content": "While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 2016 Robot Rap Battle Tournament, she notices th...
[{"input": "13 78\n10 2\n6 5\n5 7\n10 3\n6 13\n4 7\n4 13\n1 12\n13 2\n1 7\n10 5\n10 13\n12 2\n10 6\n5 3\n10 8\n9 11\n6 1\n4 5\n12 3\n6 7\n8 2\n1 9\n4 11\n5 8\n6 3\n9 5\n5 2\n13 11\n10 4\n12 7\n5 13\n12 8\n10 12\n6 12\n5 11\n1 8\n7 8\n12 4\n10 7\n1 5\n1 2\n10 11\n2 11\n12 13\n9 7\n8 3\n12 9\n9 2\n6 9\n10 9\n7 11\n12 5\n...
code_stdio
[ { "content": "It is September 9 in Japan now.\nYou are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?\n\n-----Constraints-----\n - 10≀N≀99\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n-----Output-----\nIf 9 is contained in ...
[{"input": "29\n", "output": "Yes\n"}, {"input": "91\n", "output": "Yes\n"}, {"input": "929", "output": "Yes\n"}, {"input": "109", "output": "Yes\n"}, {"input": "189", "output": "Yes\n"}, {"input": "1223", "output": "No\n"}, {"input": "72\n", "output": "No\n"}, {"input": "69", "output": "Yes\n"}, {"input": "115", "outp...
code_stdio
[ { "content": "You are given two binary strings $a$ and $b$ of the same length. You can perform the following two operations on the string $a$:\n\n Swap any two bits at indices $i$ and $j$ respectively ($1 \\le i, j \\le n$), the cost of this operation is $|i - j|$, that is, the absolute difference between $i$ ...
[{"input": "91\n0010010000110001001011011011111001000110001000100111110010010001100110010111100111011111100\n1101110110000100110000100011010110111101100000011011100111111000110000001101101111100100101\n", "output": "43\n"}, {"input": "91\n001001000011000100101101101111100100011000100010011111001001000110011001011110011...
code_stdio
[ { "content": "Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the track of everything.\n\nDuring an audit, you were surpri...
[{"input": "111\n15 45 14 65 49 25 102 86 14 80 54 73 43 78 42 32 47 60 55 66 84 69 49 22 26 72 89 52 26 80 71 35 56 2 88 23 23 53 65 92 46 73 29 65 88 99 19 99 87 10 47 96 109 20 60 89 63 105 29 92 109 20 95 65 31 89 107 3 3 50 58 9 28 39 104 42 41 36 70 49 59 96 16 9 3 108 38 42 2 67 32 86 20 6 101 70 101 91 38 10 74...
code_stdio
[ { "content": "Santosh has a farm at Byteland. He has a very big family to look after. His life takes a sudden turn and he runs into a financial crisis. After giving all the money he has in his hand, he decides to sell his plots. The speciality of his land is that it is rectangular in nature. Santosh comes to k...
[{"input": "2\n15 28\n13 1", "output": "420\n13\n"}, {"input": "2\n11 28\n13 1", "output": "308\n13\n"}, {"input": "2\n11 28\n12 1", "output": "308\n12\n"}, {"input": "2\n11 51\n12 1", "output": "561\n12\n"}, {"input": "2\n18 51\n12 1", "output": "102\n12\n"}, {"input": "2\n18 55\n12 1", "output": "990\n12\n"}, {"input...
code_stdio