messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "In the year of 30XX participants of some world programming championship live in a single large hotel. The hotel has n floors. Each floor has m sections with a single corridor connecting all of them. The sections are enumerated from 1 to m along the corridor, and all sections with equal numbers on ... | [{"input": "10 10 1 8 4\n10\n2 3 4 5 6 7 8 9\n10\n1 1 3 1\n2 1 7 1\n1 1 9 1\n7 1 4 1\n10 1 7 1\n2 1 7 1\n3 1 2 1\n5 1 2 1\n10 1 5 1\n6 1 9 1\n", "output": "3\n4\n4\n3\n3\n4\n3\n3\n4\n3\n"}, {"input": "10 18 1 8 4\n10\n2 3 4 5 6 7 8 9\n10\n1 1 3 1\n2 1 7 1\n1 1 9 1\n7 1 4 1\n10 1 7 1\n2 1 7 1\n3 1 2 1\n5 1 2 1\n10 1 5 1... | code_stdio |
[
{
"content": "problem\n\nChairman K is a regular customer of the JOI pizza shop in the center of JOI city. For some reason, he decided to start a life-saving life this month. So he wanted to order the pizza with the highest calories per dollar among the pizzas he could order at the JOI pizza store. Let's call s... | [{"input": "3\n16 2\n358\n87\n1601\n010", "output": "108\n"}, {"input": "3\n16 2\n696\n77\n1150\n010", "output": "102\n"}, {"input": "3\n12 2\n200\n87\n1514\n010", "output": "122\n"}, {"input": "3\n12 2\n491\n77\n1150\n010", "output": "117\n"}, {"input": "3\n12 2\n200\n87\n1149\n010", "output": "96\n"}, {"input": "3\n2... | code_stdio |
[
{
"content": "Polycarp had an array $a$ of $3$ positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array $b$ of $7$ integers.\n\nFor example, if $a = \\{1, 4, 3\\}$, then Polycarp wrote out $1$, $4$, $3$, $1 + 4 = 5$, $1 + 3 = 4$,... | [{"input": "5\n1 3 4 4 5 7 8\n1 2 3 4 5 6 7\n300000000 300000000 300000000 600000000 600000000 600000000 900000000\n1 1 2 999999998 999999999 999999999 1000000000\n1 2 2 3 3 4 5\n", "output": "1 3 4\n1 2 4\n300000000 300000000 300000000\n1 1 999999998\n1 2 2\n"}, {"input": "5\n1 3 4 4 5 7 8\n1 2 3 4 5 6 7\n300000000 30... | code_stdio |
[
{
"content": "You have an array $a_1, a_2, \\dots, a_n$ consisting of $n$ distinct integers. You are allowed to perform the following operation on it:\n\nChoose two elements from the array $a_i$ and $a_j$ ($i \\ne j$) such that $\\gcd(a_i, a_j)$ is not present in the array, and add $\\gcd(a_i, a_j)$ to the end ... | [{"input": "57\n241 444 553 126 612 550 441 420 742 879 520 664 590 198 910 731 308 740 791 680 904 629 324 606 621 75 350 253 57 164 440 970 876 648 581 258 989 851 186 117 700 537 837 284 654 130 728 955 859 988 820 345 901 294 244 125 512\n", "output": "48"}, {"input": "10\n239529 302993 398153 204081 370085 184103 ... | code_stdio |
[
{
"content": "A: Isono, let's do that! --Sendame -\n\nstory\n\nNakajima \"Isono ~, let's do that!\"\n\nIsono \"What is that, Nakajima\"\n\nNakajima \"Look, that's that. It's hard to explain because I have to express it in letters for some reason.\"\n\nIsono \"No, it seems that you can put in figures and photos,... | [{"input": "3\ntameru\ntameru\nuremat\ntameru\nkougekida\ntameru", "output": "Nakajima-kun\n"}, {"input": "3\ntameru\ntameru\nuremat\ntameru\nadikeguok\ntameru", "output": "Hikiwake-kun\n"}, {"input": "3\ntameru\ntameru\nuremat\ntameru\nadikeguok\ntamdru", "output": "Hikiwake-kun\n"}, {"input": "3\ntameru\nuremat\nurem... | code_stdio |
[
{
"content": "Polycarp is going to participate in the contest. It starts at $h_1:m_1$ and ends at $h_2:m_2$. It is guaranteed that the contest lasts an even number of minutes (i.e. $m_1 \\% 2 = m_2 \\% 2$, where $x \\% y$ is $x$ modulo $y$). It is also guaranteed that the entire contest is held during a single ... | [{"input": "10:00\n11:00\n", "output": "10:30\n"}, {"input": "11:10\n11:12\n", "output": "11:11\n"}, {"input": "01:02\n03:02\n", "output": "02:02\n"}, {"input": "00:00\n23:58\n", "output": "11:59\n"}, {"input": "00:01\n23:59\n", "output": "12:00\n"}, {"input": "00:00\n00:02\n", "output": "00:01\n"}, {"input": "23:57\n2... | code_stdio |
[
{
"content": "There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x_1, the second friend lives at the point x_2, and the third friend lives at the point x_3. They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum to... | [{"input": "131 21 80\n", "output": "110\n"}, {"input": "138 23 56\n", "output": "115\n"}, {"input": "149 93 35\n", "output": "114\n"}, {"input": "29 97 147\n", "output": "118\n"}, {"input": "149 93 25\n", "output": "124\n"}, {"input": "235 31 80\n", "output": "204\n"}, {"input": "131 31 80\n", "output": "100\n"}, {"in... | code_stdio |
[
{
"content": "There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you ... | [{"input": "1000 1000\n", "output": "YES\n0 0\n280 960\n-960 280"}, {"input": "545 175\n", "output": "YES\n0 0\n327 436\n-140 105\n"}, {"input": "385 850\n", "output": "YES\n0 0\n231 308\n-680 510\n"}, {"input": "280 210\n", "output": "YES\n0 0\n168 224\n-168 126"}, {"input": "408 765\n", "output": "YES\n0 0\n360 192\n... | code_stdio |
[
{
"content": "There are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficulty. Moreover, there are m pairs of similar problems. Authors want to split problems between two division according to the following rules... | [{"input": "100000 10\n99562 484\n1099 99684\n593 99867\n99529 175\n99738 616\n99523 766\n99503 121\n99784 158\n199 99199\n15 99849\n", "output": "98100\n"}, {"input": "100000 10\n99562 484\n1099 99684\n593 99867\n99529 175\n99738 616\n99523 766\n42925 121\n99784 158\n199 99199\n15 99849\n", "output": "41826\n"}, {"inp... | code_stdio |
[
{
"content": "Recently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit and punish him. For that, he set up an organizational meeting, the issue is: who's bugged the code? Each of the n coders on the meeting said: 'I know for sure that either x or y did it!'\n\nT... | [{"input": "10 3\n6 3\n6 10\n2 5\n5 7\n6 2\n9 2\n8 1\n10 5\n5 10\n7 6\n", "output": "34\n"}, {"input": "10 2\n10 2\n9 3\n9 4\n7 2\n4 6\n10 1\n9 2\n3 10\n7 1\n5 1\n", "output": "43\n"}, {"input": "10 3\n6 3\n6 10\n2 5\n5 7\n6 2\n9 2\n8 1\n10 5\n5 10\n7 3\n", "output": "37\n"}, {"input": "10 3\n6 3\n6 10\n2 5\n2 7\n6 2\n... | code_stdio |
[
{
"content": "Takahashi has N days of summer vacation.\nHis teacher gave him M summer assignments. It will take A_i days for him to do the i-th assignment.\nHe cannot do multiple assignments on the same day, or hang out on a day he does an assignment.\nWhat is the maximum number of days Takahashi can hang out d... | [{"input": "1000000 10000\n10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000... | code_stdio |
[
{
"content": "There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.\n\nIn the grid, N Squares (r_1, c_1), (r_2, c_2), \\ldots, (r_N, c_N) are wall squares, and the others are all empty squares. It is guaranteed... | [{"input": "100000 100000 1\n50000 23836", "output": "920202332\n"}, {"input": "100000 100000 1\n50000 25003", "output": "717307015\n"}, {"input": "100000 100000 1\n50000 29731", "output": "587968146\n"}, {"input": "100000 100000 1\n84868 25003", "output": "677865158\n"}, {"input": "100000 100000 0\n50000 29731", "outp... | code_stdio |
[
{
"content": "— This is not playing but duty as allies of justice, Nii-chan!\n\n— Not allies but justice itself, Onii-chan!\n\nWith hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for somewhere they've never reached — water-surrounded... | [{"input": "5000 5000 5000\n", "output": "986778560\n"}, {"input": "1171 2989 2853\n", "output": "234725427\n"}, {"input": "3238 2923 4661\n", "output": "636587126\n"}, {"input": "4539 2805 2702\n", "output": "356944655\n"}, {"input": "4998 4998 4998\n", "output": "259368717\n"}, {"input": "2048 4096 1024\n", "output":... | code_stdio |
[
{
"content": "Stepan likes to repeat vowel letters when he writes words. For example, instead of the word \"pobeda\" he can write \"pobeeeedaaaaa\".\n\nSergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels... | [{"input": "200\nmmffggzvuuzzlkafduueqocuybiiaaeeoiioouaaurccuqoouuooooooyjjtyyxxiipnoeufyuuoyxxhhkaaeoooxapauuoppzabuuoiiuuggcciissuugejjiirruummsiifaauyypauwoofiemzaeeeeeeiioozzttyyidaaaiggizzerkooooeeepueeauupathhb\n", "output": "mmffggzvuzzlkafdueqocuybiaeeoioouaurccuqoouoyjjtyxxipnoeufyuoyxxhhkaeoxapauoppzabuoiugg... | code_stdio |
[
{
"content": "500-yen Saving\n\n\"500-yen Saving\" is one of Japanese famous methods to save money. The method is quite simple; whenever you receive a 500-yen coin in your change of shopping, put the coin to your 500-yen saving box. Typically, you will find more than one million yen in your saving box in ten ye... | [{"input": "4\n800\n700\n1600\n600\n4\n300\n1205\n1600\n30\n4\n300\n700\n1600\n650\n3\n1001\n2000\n638\n3\n250\n250\n1000\n4\n1251\n1466\n698\n299\n0", "output": "2 2900\n4 3135\n3 3250\n2 1639\n3 1500\n4 3714\n"}, {"input": "4\n800\n700\n1600\n600\n4\n300\n1205\n1600\n30\n4\n300\n700\n1600\n650\n3\n1001\n2000\n638\n3\... | code_stdio |
[
{
"content": "Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of university studies. Consequently Noora had to leave Vičkopol... | [{"input": "12 1000000000\n", "output": "479001600\n"}, {"input": "1000000000 12\n", "output": "479001600\n"}, {"input": "1000000000 12\n", "output": "479001600\n"}, {"input": "12 1000000000\n", "output": "479001600\n"}, {"input": "1000000100 12\n", "output": "479001600\n"}, {"input": "12 1000100000\n", "output": "4790... | code_stdio |
[
{
"content": "There is an infinite board of square tiles. Initially all tiles are white.\n\nVova has a red marker and a blue marker. Red marker can color $a$ tiles. Blue marker can color $b$ tiles. If some tile isn't white then you can't use marker of any color on it. Each marker must be drained completely, so ... | [{"input": "99999999999973 99999999999971\n", "output": "199999999999948\n"}, {"input": "99999999999962 99999999999973\n", "output": "133333333333296\n"}, {"input": "99999999999973 99999999999930\n", "output": "399999999999808\n"}, {"input": "49999819999926 50000000000155\n", "output": "199999640000164\n"}, {"input": "... | code_stdio |
[
{
"content": "CQXYM is counting permutations length of $2n$.\n\nA permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the array) and $[1,3,4]$ is also not a permutati... | [{"input": "20\n597\n2791\n71\n1\n6\n14\n196\n1\n4335\n14\n5133\n6\n17\n3620\n5111\n1\n119\n992\n76848\n127\n", "output": "924058387\n309126958\n25034588\n1\n239500800\n517878947\n323758520\n1\n41675960\n517878947\n479930293\n239500800\n971636156\n715097853\n974503605\n1\n796779807\n613317322\n14480144\n386977425\n"}, ... | code_stdio |
[
{
"content": "You are a mayor of Berlyatov. There are $n$ districts and $m$ two-way roads between them. The $i$-th road connects districts $x_i$ and $y_i$. The cost of travelling along this road is $w_i$. There is some path between each pair of districts, so the city is connected.\n\nThere are $k$ delivery rout... | [{"input": "5 5 4\n1 2 5\n4 3 4\n1 4 3\n4 3 10\n3 5 2\n1 5\n1 3\n3 3\n1 5\n", "output": "13\n"}, {"input": "5 5 4\n1 2 5\n4 3 4\n1 4 3\n4 3 10\n3 5 2\n1 2\n1 3\n3 3\n1 5\n", "output": "13\n"}, {"input": "5 5 4\n1 2 5\n2 3 4\n1 4 3\n4 3 7\n3 5 2\n1 5\n1 3\n3 3\n1 5\n", "output": "13\n"}, {"input": "5 5 4\n1 2 5\n2 3 4\n... | code_stdio |
[
{
"content": "Suppose $a_1, a_2, \\dots, a_n$ is a sorted integer sequence of length $n$ such that $a_1 \\leq a_2 \\leq \\dots \\leq a_n$.\n\nFor every $1 \\leq i \\leq n$, the prefix sum $s_i$ of the first $i$ terms $a_1, a_2, \\dots, a_i$ is defined by $$ s_i = \\sum_{k=1}^i a_k = a_1 + a_2 + \\dots + a_i. $$... | [{"input": "10\n2 1\n1000000000\n3 2\n-100000000 -150000003\n3 2\n-100000000 -150000004\n3 2\n-100000000 -150000001\n3 2\n-100000000 -150000002\n3 2\n-100000000 -150000000\n3 2\n-100000000 -149999999\n3 2\n-100000000 -149999999\n3 2\n-100000000 -149999998\n3 2\n-100000000 -149999997\n", "output": "Yes\nNo\nNo\nNo\nNo\n... | code_stdio |
[
{
"content": "A number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and n, inclusive.\n\nInput\n\nInput contains one integer number n (1 ≤ n ≤ 3000).\n... | [{"input": "2998\n", "output": "1375\n"}, {"input": "2999\n", "output": "1375\n"}, {"input": "2997\n", "output": "1374\n"}, {"input": "3000\n", "output": "1375\n"}, {"input": "2990\n", "output": "1370\n"}, {"input": "2608\n", "output": "1216\n"}, {"input": "2103\n", "output": "1001\n"}, {"input": "1429\n", "output": "7... | code_stdio |
[
{
"content": "Takahashi made N problems for competitive programming.\nThe problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).\nHe is dividing the problems into two categories by choosing an integer K, as follows:\n - A problem with difficulty ... | [{"input": "29108\n82 21 41 24 13 39 53 14 10 42 19 46 48 18 81 69 6 62 80 32 58 97 9 7 19 16 84 91 25 47 83 25 75 19 16 16 70 10 29 45 89 89 68 59 75 30 51 78 86 4 63 73 31 64 24 82 44 16 40 11 15 75 95 27 41 33 2 2 37 57 83 2 33 2 24 93 29 78 49 3 51 76 54 73 48 28 50 67 26 4 78 32 19 4 83 29 36 92 93 71 5 22 72 66 1... | code_stdio |
[
{
"content": "Vasya had a strictly increasing sequence of positive integers a_1, ..., a_{n}. Vasya used it to build a new sequence b_1, ..., b_{n}, where b_{i} is the sum of digits of a_{i}'s decimal representation. Then sequence a_{i} got lost and all that remained is sequence b_{i}.\n\nVasya wonders what the ... | [{"input": "100\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n6\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n18\n... | code_stdio |
[
{
"content": "Takahashi and Aoki will play a game on a tree. The tree has N vertices numbered 1 to N, and the i-th of the N-1 edges connects Vertex a_i and Vertex b_i.\n\nAt the beginning of the game, each vertex contains a coin. Starting from Takahashi, he and Aoki will alternately perform the following operat... | [{"input": "7\n1 7\n3 1\n3 4\n2 5\n6 3\n2 1", "output": "Second\n"}, {"input": "7\n1 7\n7 1\n3 7\n2 5\n6 3\n4 1", "output": "Second\n"}, {"input": "7\n1 7\n4 1\n6 4\n7 5\n6 4\n2 1", "output": "Second\n"}, {"input": "7\n1 7\n5 1\n3 6\n3 5\n6 3\n2 1", "output": "Second\n"}, {"input": "7\n1 7\n3 1\n3 4\n4 5\n6 3\n2 1", "o... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nJohn's barn has a fence consisting of N consecutive parts numbered from left to right starting from 1 to N. Each part is initially painted in one of two colors: red or green, whose information is provided you by a string C. The ... | [{"input": "1\n7 -1\nRGGRGRG", "output": "6\n"}, {"input": "1\n7 -1\nRGGSGRG", "output": "4\n"}, {"input": "1\n7 -1\nGGGRRRG", "output": "2\n"}, {"input": "1\n7 -2\nGGGRRRG", "output": "2\n"}, {"input": "1\n7 -1\nGRGRGGR", "output": "5\n"}, {"input": "1\n7 -1\nGRGQGGR", "output": "3\n"}, {"input": "1\n7 -1\nQGGRGRG", "... | code_stdio |
[
{
"content": "The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a equal rows, each row has b pebbles (a > 1). Note that the Beaver must use all t... | [{"input": "1000000000\n", "output": "1998535156\n"}, {"input": "1000001000\n", "output": "1906011808\n"}, {"input": "1549355491\n", "output": "1559780582\n"}, {"input": "1292236879\n", "output": "1292236880\n"}, {"input": "999996270\n", "output": "1705144136\n"}, {"input": "999999999\n", "output": "1494160827\n"}, {"i... | code_stdio |
[
{
"content": "Let's assume that we are given a matrix b of size x × y, let's determine the operation of mirroring matrix b. The mirroring of matrix b is a 2x × y matrix c which has the following properties:\n\n the upper half of matrix c (rows with numbers from 1 to x) exactly matches b; the lower half of mat... | [{"input": "8 20\n0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 0\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 1 1\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 1 1\n0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 0\n0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 1 1 0\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 1 1\n1 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 1 1 1\n0 0 1 1 1 1 0 0... | code_stdio |
[
{
"content": "You are given undirected weighted graph. Find the length of the shortest cycle which starts from the vertex 1 and passes throught all the edges at least once. Graph may contain multiply edges between a pair of vertices and loops (edges from the vertex to itself).\n\nInput\n\nThe first line of the ... | [{"input": "15 32\n15 9 8860\n12 4 9045\n12 12 8221\n9 6 8306\n11 14 9052\n13 14 8176\n14 5 8857\n6 8 8835\n3 9 8382\n10 14 8212\n13 13 9061\n2 14 8765\n4 13 9143\n13 13 8276\n13 11 8723\n7 10 8775\n8 15 8965\n15 5 8800\n4 5 9317\n5 13 9178\n1 7 9031\n4 10 9114\n10 4 8628\n9 1 8584\n5 7 8701\n6 15 8177\n3 3 9325\n4 5 9... | code_stdio |
[
{
"content": "In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams.\n\nAfter practice competition, participant number i g... | [{"input": "1000 1000 1000 1000 1000 1000\n", "output": "YES\n"}, {"input": "1000 1000 1000 1000 1000 1000\n", "output": "YES\n"}, {"input": "1000 1001 1000 1000 1000 1000\n", "output": "NO\n"}, {"input": "1000 1001 1000 0000 1000 1000\n", "output": "NO\n"}, {"input": "1000 1000 999 1000 1000 1000\n", "output": "NO\n"}... | code_stdio |
[
{
"content": "Ivan plays an old action game called Heretic. He's stuck on one of the final levels of this game, so he needs some help with killing the monsters.\n\nThe main part of the level is a large corridor (so large and narrow that it can be represented as an infinite coordinate line). The corridor is divi... | [{"input": "2\n3 2\n1 3 5\n4 1\n5 2 3 5\n", "output": "2\n2\n"}, {"input": "2\n3 2\n1 3 5\n4 1\n5 4 3 5\n", "output": "2\n3\n"}, {"input": "2\n3 2\n1 1 5\n4 1\n5 4 3 5\n", "output": "1\n3\n"}, {"input": "2\n3 2\n0 1 5\n4 1\n5 2 3 5\n", "output": "1\n2\n"}, {"input": "2\n3 2\n0 1 5\n4 1\n5 4 3 5\n", "output": "1\n3\n"},... | code_stdio |
[
{
"content": "There is an integer sequence A of length N whose values are unknown.\nGiven is an integer sequence B of length N-1 which is known to satisfy the following:\n B_i \\geq \\max(A_i, A_{i+1}) \nFind the maximum possible sum of the elements of A.\n\n-----Constraints-----\n - All values in input are int... | [{"input": "100\n100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 10... | code_stdio |
[
{
"content": "You are given an integer a that consists of n digits. You are also given a sequence of digits s of length m. The digit in position j (1 ≤ j ≤ m) of sequence s means that you can choose an arbitrary position i (1 ≤ i ≤ n) in a and replace the digit in the chosen position i with sj. Each element in ... | [{"input": "123456789012345678905764345\n00001\n", "output": "123456789112345678905764345\n"}, {"input": "123456789012345678905764345\n01001\n", "output": "123456789112345678915764345"}, {"input": "123456789012345678905764345\n11001\n", "output": "123456789112345678915764345"}, {"input": "123456789012345678905764345\n1... | code_stdio |
[
{
"content": "At the big break Nastya came to the school dining room. There are $n$ pupils in the school, numbered from $1$ to $n$. Unfortunately, Nastya came pretty late, so that all pupils had already stood in the queue, i.e. Nastya took the last place in the queue. Of course, it's a little bit sad for Nastya... | [{"input": "20 47\n4 6 11 15 9 17 3 1 19 14 12 8 2 5 7 20 16 18 13 10\n18 10\n6 3\n15 17\n18 7\n4 5\n19 10\n6 7\n11 3\n1 10\n17 3\n6 14\n7 10\n19 5\n12 10\n1 8\n6 11\n18 5\n6 8\n12 12\n1 5\n20 11\n16 8\n3 10\n20 19\n17 8\n19 10\n2 5\n19 8\n6 9\n16 3\n16 10\n19 7\n17 16\n10 13\n8 9\n12 5\n17 10\n2 15\n6 15\n4 9\n10 1\n1... | code_stdio |
[
{
"content": "Takahashi participated in a contest on AtCoder.\nThe contest had N problems.\nTakahashi made M submissions during the contest.\nThe i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA).\nThe number of Takahashi's correct answers is the number of problems on which... | [{"input": "100000 3\n7777 AC\n7777 AC\n7777 AC\n", "output": "1 0\n"}, {"input": "100000 3\n12676 AC\n7777 AC\n7777 CA", "output": "2 0\n"}, {"input": "100000 3\n7777 AC\n7777 AC\n7777 CA", "output": "1 0\n"}, {"input": "100000 3\n6234 AC\n7777 AC\n7777 AC", "output": "2 0\n"}, {"input": "100000 3\n7777 AC\n7777 AC\n7... | code_stdio |
[
{
"content": "Let S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(101) = 1 + 0 + 1 = 2.\nGiven an integer N, determine if S(N) divides N.\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^9\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n-----O... | [{"input": "1000000000\n", "output": "Yes\n"}, {"input": "999999999\n", "output": "Yes\n"}, {"input": "873041724\n", "output": "Yes\n"}, {"input": "689670774\n", "output": "Yes\n"}, {"input": "506479109\n", "output": "Yes\n"}, {"input": "693828976\n", "output": "No\n"}, {"input": "972655544\n", "output": "No\n"}, {"inp... | code_stdio |
[
{
"content": "There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.\n\nEach kangaroo can hold at most one kangaroo, ... | [{"input": "100\n154\n60\n97\n638\n139\n150\n570\n579\n601\n647\n804\n237\n245\n549\n288\n347\n778\n282\n916\n441\n974\n145\n957\n886\n655\n702\n930\n618\n132\n520\n972\n48\n94\n54\n682\n433\n896\n134\n845\n636\n242\n842\n125\n141\n240\n130\n409\n666\n948\n938\n604\n110\n474\n484\n364\n40\n807\n271\n438\n288\n201\n814\... | code_stdio |
[
{
"content": "Grandma Laura came to the market to sell some apples. During the day she sold all the apples she had. But grandma is old, so she forgot how many apples she had brought to the market.\n\nShe precisely remembers she had n buyers and each of them bought exactly half of the apples she had at the momen... | [{"input": "40 562\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalf\nhalf\nhalf\nhalfplus\nhalf\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalf\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalfplus\nhalf\nhalf\nhalfplus\nhalf\nhalfplus\nhalfplus\nhalf\nhalf\nhalfpl... | code_stdio |
[
{
"content": "Let's say you are standing on the $XY$-plane at point $(0, 0)$ and you want to reach point $(n, n)$.\n\nYou can move only in two directions:\n\nto the right, i. e. horizontally and in the direction that increase your $x$ coordinate,\n\nor up, i. e. vertically and in the direction that increase you... | [{"input": "3\n2\n13 100\n3\n4 3 1\n5\n13 4 1 1 5\n", "output": "226\n15\n25\n"}, {"input": "3\n2\n13 100\n3\n2 3 0\n5\n4 3 2 1 5\n", "output": "226\n11\n19\n"}, {"input": "3\n2\n13 100\n3\n2 3 0\n5\n4 3 1 1 5\n", "output": "226\n11\n15\n"}, {"input": "3\n2\n13 100\n3\n2 3 0\n5\n4 3 0 1 5\n", "output": "226\n11\n11\n"}... | code_stdio |
[
{
"content": "There are N balls in a row. Initially, the i-th ball from the left has the integer A_i written on it.\n\nWhen Snuke cast a spell, the following happens:\n\n* Let the current number of balls be k. All the balls with k written on them disappear at the same time.\n\n\n\nSnuke's objective is to vanish... | [{"input": "10 10\n8 7 2 9 10 6 6 5 5 4\n8 1\n6 3\n6 2\n7 10\n9 7\n9 9\n2 4\n10 1\n1 8\n7 7", "output": "1\n0\n1\n2\n2\n3\n3\n4\n4\n3\n"}, {"input": "10 10\n8 7 2 9 10 6 6 5 5 4\n8 1\n6 3\n6 2\n7 10\n9 7\n9 4\n2 4\n10 1\n1 8\n7 7", "output": "1\n0\n1\n2\n2\n2\n3\n3\n3\n2\n"}, {"input": "10 10\n8 7 2 9 10 6 6 5 5 4\n8 1... | code_stdio |
[
{
"content": "You are given a string s, consisting of small Latin letters. Let's denote the length of the string as |s|. The characters in the string are numbered starting from 1. \n\nYour task is to find out if it is possible to rearrange characters in string s so that for any prime number p ≤ |s| and for any ... | [{"input": "xxxxxxxxxxfxxxxxxxxxxxxxxxxxxxxxxxxxxxrxtxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxexxxxmxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoxxxxxxxxxxexxxxxxxxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxoxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxtxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxuxxxxxxxxxxxxxxxxxxxxxxxxxxxx... | code_stdio |
[
{
"content": "You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.\n\nInput\n\nThe first and the single line contains three space-separated integers — th... | [{"input": "10000 10000 10000\n", "output": "1200"}, {"input": "10000 1 10000\n", "output": "40008"}, {"input": "9801 9801 9801\n", "output": "1188"}, {"input": "1 10000 10000\n", "output": "40008"}, {"input": "9801 9702 9702\n", "output": "1184"}, {"input": "1656 6900 1350\n", "output": "740"}, {"input": "3623 3623 1\... | code_stdio |
[
{
"content": "Alice and Bob are playing a game on a line with n cells. There are n cells labeled from 1 through n. For each i from 1 to n-1, cells i and i+1 are adjacent.\n\nAlice initially has a token on some cell on the line, and Bob tries to guess where it is. \n\nBob guesses a sequence of line cell numbers ... | [{"input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50\n", "output": "0\n"}, {"input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36... | code_stdio |
[
{
"content": "You are given two positive integer numbers x and y. An array F is called an y-factorization of x iff the following conditions are met: There are y elements in F, and all of them are integer numbers; $\\prod_{i = 1}^{y} F_{i} = x$. \n\nYou have to count the number of pairwise distinct arrays that... | [{"input": "1\n524288 1000000\n", "output": "645043186\n"}, {"input": "1\n524288 1000000\n", "output": "645043186\n"}, {"input": "1\n983675 1000000\n", "output": "661876874\n"}, {"input": "1\n65536 1000000\n", "output": "928522471\n"}, {"input": "1\n65536 1000000\n", "output": "928522471\n"}, {"input": "1\n36157 100000... | code_stdio |
[
{
"content": "She loves e-mail so much! She sends e-mails by her cellular phone to her friends when she has breakfast, she talks with other friends, and even when she works in the library! Her cellular phone has somewhat simple layout (Figure 1). Pushing button 1 once displays a character (’), pushing\n\n<image... | [{"input": "666660666\n134424306396481246895756\n12784174432754272468162", "output": "No\n'dhagdmdwmgt'agmtwjpjm\n'aptg'phdapjgapagmt'ma\n"}, {"input": "666660666\n113124756735251440964347\n33891614279093528467517", "output": "No\n,d'agpjmpdjaj'hwmgdgp\netw'm'gapwwdjatgmpj'p\n"}, {"input": "666660666\n11850618639893972... | code_stdio |
[
{
"content": "Polycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn from cell (x, y) to (x - 1, y) or (x, y - 1). Vasiliy can move his pawn from (x... | [{"input": "100000 100000 100000 123228\n", "output": "Polycarp\n"}, {"input": "100000 99999 100000 100000\n", "output": "Polycarp\n"}, {"input": "100000 99999 100010 100000\n", "output": "Polycarp\n"}, {"input": "100000 100000 100000 99999\n", "output": "Vasiliy\n"}, {"input": "53208 42123 134209 85846\n", "output": "... | code_stdio |
[
{
"content": "Alice and Bob begin their day with a quick game. They first choose a starting number X_0 ≥ 3 and try to reach one million by the process described below. \n\nAlice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the... | [{"input": "1000000\n", "output": "998677\n"}, {"input": "959806\n", "output": "239958\n"}, {"input": "166320\n", "output": "110879\n"}, {"input": "221760\n", "output": "110880\n"}, {"input": "277200\n", "output": "138600\n"}, {"input": "332640\n", "output": "166320\n"}, {"input": "498960\n", "output": "332639\n"}, {"i... | code_stdio |
[
{
"content": "Little Petya has a birthday soon. Due this wonderful event, Petya's friends decided to give him sweets. The total number of Petya's friends equals to n.\n\nLet us remind you the definition of the greatest common divisor: GCD(a1, ..., ak) = d, where d represents such a maximal positive number that ... | [{"input": "50\n", "output": "9539133444790097506800945910496378878609919834178506027953758452154850007466954507364870095\n6359422296526731671200630606997585919073279889452337351969172301436566671644636338243246730\n3815653377916039002720378364198551551443967933671402411181503380861940002986781802945948038\n27254666985... | code_stdio |
[
{
"content": "Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nPetya loves long lucky numbers very much. He is interested in the minimum ... | [{"input": "86451 754 85 84\n", "output": "4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444... | code_stdio |
[
{
"content": "What joy! Petya's parents went on a business trip for the whole year and the playful kid is left all by himself. Petya got absolutely happy. He jumped on the bed and threw pillows all day long, until... \n\nToday Petya opened the cupboard and found a scary note there. His parents had left him with... | [{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100\n", "output": "1\n"}, {"input": "100\n100 100 100 100 110 100 100 100 100 100 100 100\n", "output": "1\n"}, {"input": "100\n100 100 100 100 110 100 100 100 100 100 101 100\n", "output": "1\n"}, {"input": "100\n100 100 100 100 110 100 100 100 100 100 101 1... | code_stdio |
[
{
"content": "Valerian was captured by Shapur. The victory was such a great one that Shapur decided to carve a scene of Valerian's defeat on a mountain. So he had to find the best place to make his victory eternal!\n\nHe decided to visit all n cities of Persia to find the best available mountain, but after the ... | [{"input": "15\n12 1 52\n6 2 10\n4 1 55\n11 7 20\n10 3 54\n13 9 44\n15 2 6\n14 5 55\n9 3 32\n2 1 32\n8 4 14\n6 5 24\n5 3 74\n7 6 157\n", "output": "1039\n"}, {"input": "15\n12 1 52\n3 2 10\n4 1 45\n11 7 20\n10 3 54\n13 9 44\n15 2 6\n14 5 55\n9 3 32\n2 1 32\n8 4 14\n6 5 24\n5 3 74\n7 6 157\n", "output": "921\n"}, {"inpu... | code_stdio |
[
{
"content": "A cricket team consists of 11 players and some are good at batting, others are good at bowling and some of them are good at both batting and bowling. The batting coach wants to select exactly K players having maximum possible sum of scores. Given the batting score of each of the 11 players, find t... | [{"input": "2\n1 2 3 4 5 11 14 11 11 6 11\n3\n0 5 1 2 4 1 4 5 1 2 1\n11", "output": "6\n1\n"}, {"input": "2\n2 1 3 4 5 11 14 11 12 6 12\n3\n0 5 1 2 4 1 4 5 1 2 1\n11", "output": "1\n1\n"}, {"input": "2\n2 1 3 4 5 11 14 11 9 6 11\n3\n-1 5 1 2 4 1 4 5 1 2 1\n11", "output": "3\n1\n"}, {"input": "2\n2 1 3 4 5 11 14 11 9 6 ... | code_stdio |
[
{
"content": "Alice and Bob are playing a game on a line with $n$ cells. There are $n$ cells labeled from $1$ through $n$. For each $i$ from $1$ to $n-1$, cells $i$ and $i+1$ are adjacent.\n\nAlice initially has a token on some cell on the line, and Bob tries to guess where it is. \n\nBob guesses a sequence of ... | [{"input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50\n", "output": "0\n"}, {"input": "50 75\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36... | code_stdio |
[
{
"content": "Given are a prime number p and a sequence of p integers a_0, \\ldots, a_{p-1} consisting of zeros and ones.\nFind a polynomial of degree at most p-1, f(x) = b_{p-1} x^{p-1} + b_{p-2} x^{p-2} + \\ldots + b_0, satisfying the following conditions:\n - For each i (0 \\leq i \\leq p-1), b_i is an integ... | [{"input": "2999\n0 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 1 1 1 1 0 1 0 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 1 0 1 0 1 0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 1 0 0 1 0 1 1 1 1 0 1 0 1 1 1 0 0 ... | code_stdio |
[
{
"content": "Вася купил стол, у которого n ножек. Каждая ножка состоит из двух частей, которые соединяются друг с другом. Каждая часть может быть произвольной положительной длины, но гарантируется, что из всех 2n частей возможно составить n ножек одинаковой длины. При составлении ножки любые две части могут бы... | [{"input": "100\n8 7 7 5 2 7 7 5 1 8 6 3 6 7 2 4 4 2 6 8 5 6 5 2 6 1 3 9 5 8 7 6 5 4 8 6 5 5 3 2 6 5 4 9 7 1 5 7 9 5 7 4 1 6 5 8 2 6 6 1 4 2 3 2 3 9 3 8 7 1 2 4 5 7 3 5 5 6 3 8 3 6 1 5 5 3 3 3 8 8 1 4 3 6 7 1 1 2 4 4 7 3 7 7 8 9 5 8 6 6 4 7 4 9 3 4 7 5 2 8 4 1 9 7 9 7 9 6 7 7 9 6 1 1 1 9 9 4 4 1 5 6 6 3 9 3 3 7 4 2 4 9... | code_stdio |
[
{
"content": "Soroush and Keshi each have a labeled and rooted tree on n vertices. Both of their trees are rooted from vertex 1.\n\nSoroush and Keshi used to be at war. After endless decades of fighting, they finally became allies to prepare a Codeforces round. To celebrate this fortunate event, they decided to... | [{"input": "4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 1 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n", "output": "\n1\n4\n1\n3\n"}, {"input": "4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 1 1 1\n6\n1 2 1 1 2\n1 2 1 2 2\n7\n1 1 3 4 4 5\n1 2 1 4 2 5\n", "output": "1\n4\n1\n3\n"}, {"input": "4\n4\n1 2 3\n1 2 3\n5\n1 2 3 4\n1 ... | code_stdio |
[
{
"content": "Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $1$ to $n$. For every edge $e$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the ed... | [{"input": "15\n10 15\n12 15\n6 15\n8 15\n2 15\n3 15\n10 15\n13 15\n5 15\n7 15\n11 15\n4 14\n1 15\n14 15\n", "output": "NO\n"}, {"input": "15\n10 15\n12 15\n6 15\n8 15\n2 15\n3 15\n10 15\n13 15\n5 15\n7 15\n11 15\n4 14\n1 15\n14 15\n", "output": "NO\n"}, {"input": "15\n9 15\n6 15\n12 15\n3 14\n14 15\n11 15\n6 15\n7 15\... | code_stdio |
[
{
"content": "Takahashi's house has only one socket.\nTakahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets.\nOne power strip with A sockets can extend one empty socket into A empty sockets.\nFind the minimum number of power strips required.\n\n-----Con... | [{"input": "13 17\n", "output": "2\n"}, {"input": "10 19\n", "output": "2\n"}, {"input": "20 19\n", "output": "1\n"}, {"input": "2 20\n", "output": "19\n"}, {"input": "4 10\n", "output": "3\n"}, {"input": "4 12\n", "output": "4\n"}, {"input": "9 12\n", "output": "2\n"}, {"input": "3 17\n", "output": "8\n"}, {"input": "... | code_stdio |
[
{
"content": "Takayuki and Kazuyuki are good twins, but their behavior is exactly the opposite. For example, if Takayuki goes west, Kazuyuki goes east, and if Kazuyuki goes north, Takayuki goes south. Currently the two are in a department store and are in different locations. How can two people who move in the ... | [{"input": "6 6\n2 4\n6 2\n0 0 0 0 1 0\n0 1 1 0 0 0\n0 1 0 0 0 0\n0 0 0 1 0 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n3 3\n1 1\n3 3\n0 0 0\n0 1 0\n0 0 0\n0 0", "output": "3\nNA\n"}, {"input": "6 6\n2 4\n6 2\n0 0 0 0 1 0\n0 1 0 0 1 0\n0 1 0 0 0 0\n0 1 0 1 1 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n3 3\n1 1\n3 3\n0 0 0\n0 1 0\n0 0 0\n0 0", "outp... | code_stdio |
[
{
"content": "Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a... | [{"input": "1707 1117\n", "output": "237674323"}, {"input": "1766 1038\n", "output": "435768250"}, {"input": "1229 1315\n", "output": "100240813"}, {"input": "1903 1612\n", "output": "620810276"}, {"input": "1887 1729\n", "output": "730033374"}, {"input": "1153 1823\n", "output": "791493066"}, {"input": "1544 1794\n", ... | code_stdio |
[
{
"content": "And again a misfortune fell on Poor Student. He is being late for an exam.\n\nHaving rushed to a bus stop that is in point (0, 0), he got on a minibus and they drove along a straight line, parallel to axis OX, in the direction of increasing x.\n\nPoor Student knows the following: \n\n * during on... | [{"input": "94 2 1\n0 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 506... | code_stdio |
[
{
"content": "Uh oh! Ray lost his array yet again! However, Omkar might be able to help because he thinks he has found the OmkArray of Ray's array. The OmkArray of an array a with elements a_1, a_2, …, a_{2k-1}, is the array b with elements b_1, b_2, …, b_{k} such that b_i is equal to the median of a_1, a_2, …,... | [{"input": "5\n8\n-8 2 -6 -5 -4 3 2 2\n7\n1 1 3 1 0 -2 -1\n7\n6 12 8 6 2 6 10\n6\n5 1 2 2 12 7\n5\n1 3 4 3 -1\n", "output": "NO\nYES\nNO\nNO\nNO\n"}, {"input": "5\n8\n-8 3 -6 -5 -4 3 3 2\n7\n1 1 4 1 0 -2 -1\n7\n6 12 8 6 2 6 10\n6\n5 1 2 2 12 7\n5\n1 3 4 3 0\n", "output": "YES\nYES\nNO\nNO\nNO\n"}, {"input": "5\n8\n-8 3... | code_stdio |
[
{
"content": "You are given a sequence a_1, a_2, ..., a_{n} of one-dimensional segments numbered 1 through n. Your task is to find two distinct indices i and j such that segment a_{i} lies within segment a_{j}.\n\nSegment [l_1, r_1] lies within segment [l_2, r_2] iff l_1 ≥ l_2 and r_1 ≤ r_2.\n\nPrint indices i ... | [{"input": "11\n22226 28285\n9095 23314\n19162 25530\n255 13298\n4904 25801\n17914 23501\n13874 28117\n11880 29994\n11123 19874\n21505 27971\n7658 14109\n", "output": "11 5\n"}, {"input": "11\n22226 28285\n9095 23314\n19162 25530\n255 13298\n4904 25801\n17914 23501\n8441 28117\n11880 29994\n11123 19874\n21505 27971\n76... | code_stdio |
[
{
"content": "Zeke loves to spend time with Penny and likes her. Penny is having an issue to solve a mathematics problem and is confused. She seeks Zeke's help as she feels he could help her with the problem. He finds this problem very simple. The problem is to count the number of unique triplets of different n... | [{"input": "1000\n1804289384 846930887 1681692778\n1714636916 1957747794 424238336\n719885387 1649760493 596516650\n1189641422 1025202363 1350490028\n783368691 1102520060 2044897764\n1967513927 1365180541 1540383427\n304089173 1303455737 35005212\n521595369 294702568 1726956430\n336465783 861021531 278722863\n233665124... | code_stdio |
[
{
"content": "Happy PMP is freshman and he is learning about algorithmic problems. He enjoys playing algorithmic games a lot.\n\nOne of the seniors gave Happy PMP a nice game. He is given two permutations of numbers 1 through n and is asked to convert the first one to the second. In one move he can remove the l... | [{"input": "20\n1 12 9 6 11 13 2 8 20 7 16 19 4 18 3 15 10 17 14 5\n5 14 17 10 15 3 18 4 19 16 7 20 8 2 13 11 6 9 12 1\n", "output": "19"}, {"input": "10\n1 6 10 3 4 9 2 5 8 7\n7 5 2 6 10 3 4 8 9 1\n", "output": "9\n"}, {"input": "10\n5 8 1 10 3 6 2 9 7 4\n4 2 6 3 1 9 10 5 8 7\n", "output": "8"}, {"input": "10\n1 6 10 ... | code_stdio |
[
{
"content": "Taro and Hanako decided to play hit-and-blow. The hit-and-blow rules are as follows.\n\n* Separated into questioners and respondents.\n* The questioner decides a 4-digit number (correct answer) that does not include duplicate numbers.\n* Respondents guess the 4-digit number (answer).\n* For the an... | [{"input": "1234 10660\n1234 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "output": "1 0\n2 1\n4 0\n1 3\n0 3\n"}, {"input": "1234 10660\n1964 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "output": "1 0\n2 0\n4 0\n1 3\n0 3\n"}, {"input": "1234 10660\n2242 1354\n1234 1234\n1230 1023\n0123 1234\n0 0", "output": "1 0\n0 1\... | code_stdio |
[
{
"content": "Anton likes to play chess, and so does his friend Danik.\n\nOnce they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.\n\nNow Anton wonders, who won more games, he or Danik? Help him determine this.\n\n\n-----Input-----... | [{"input": "379\nAADAAAAAADDAAAAAADAADADADDAAAAADADDAADAAAADDDADAAAAAAADAADAAAAAAADAAAAAAAAADAAAAAAADAAAAAAAAAAADDDADAAAAAAAADAADADAAAADAAAAAAAAAAAAAAAAADAAAADDDAADAAAAAAADAAADAAADAADDDADDAAADAAAAAADDDADDDAAADAAAADAAAAAAAAADAAADAAAAAAAAADAAAAAAAAAAAAAAAAAADADAAAAAAAAAAADAAAAADAAAADAAAAAAAAAAAAADADAADAAAAAAAADAADAAAAAAA... | code_stdio |
[
{
"content": "A string is called beautiful if no two consecutive characters are equal. For example, \"ababcb\", \"a\" and \"abab\" are beautiful strings, while \"aaaaaa\", \"abaa\" and \"bb\" are not.\n\nAhcl wants to construct a beautiful string. He has a string $s$, consisting of only characters 'a', 'b', 'c'... | [{"input": "23\n?\n??\n???\n????\n????\n?a\n?b\n?c\na?\nb?\nc?\n?a?\n?b?\n?c?\na?a\na?b\na?c\nb?a\nb?b\nb?c\nc?a\nc?b\nc?c\n", "output": "a\nab\naba\nabab\nabab\nba\nab\nac\nab\nba\nca\nbab\naba\naca\naba\nacb\nabc\nbca\nbab\nbac\ncba\ncab\ncac\n"}, {"input": "23\n?\n??\n???\n????\n????\n?a\n?b\n?c\na?\nb?\nc?\n?a?\n?b... | code_stdio |
[
{
"content": "Let us consider a grid of squares with 10^9 rows and N columns. Let (i, j) be the square at the i-th column (1 \\leq i \\leq N) from the left and j-th row (1 \\leq j \\leq 10^9) from the bottom.\n\nSnuke has cut out some part of the grid so that, for each i = 1, 2, ..., N, the bottom-most h_i squa... | [{"input": "9\n17 18 51 18 28 45 112 45 23", "output": "917046249"}, {"input": "9\n17 18 51 18 34 45 112 45 23", "output": "938229436"}, {"input": "9\n17 18 51 18 34 45 190 45 23", "output": "353713429"}, {"input": "9\n17 18 51 18 34 45 190 56 23", "output": "814466445"}, {"input": "9\n17 18 81 18 34 45 190 56 23", "ou... | code_stdio |
[
{
"content": "You are given a digital clock with $n$ digits. Each digit shows an integer from $0$ to $9$, so the whole clock shows an integer from $0$ to $10^n-1$. The clock will show leading zeroes if the number is smaller than $10^{n-1}$.\n\nYou want the clock to show $0$ with as few operations as possible. I... | [{"input": "7\n3\n007\n4\n1000\n5\n00000\n3\n153\n4\n1247\n9\n123456789\n30\n001678294039710047203946100020\n", "output": "7\n2\n0\n11\n17\n53\n115\n"}, {"input": "7\n3\n007\n4\n1000\n5\n00000\n3\n153\n4\n1293\n9\n123456789\n30\n001678294039710047203946100020\n", "output": "7\n2\n0\n11\n18\n53\n115\n"}, {"input": "7\n3... | code_stdio |
[
{
"content": "Valera had two bags of potatoes, the first of these bags contains x (x ≥ 1) potatoes, and the second — y (y ≥ 1) potatoes. Valera — very scattered boy, so the first bag of potatoes (it contains x potatoes) Valera lost. Valera remembers that the total amount of potatoes (x + y) in the two bags, fir... | [{"input": "1 2 27764\n", "output": "1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 101 103 105 107 109 111 113 115 117 119 121 123 125 127 129 131 133 135 137 139 141 143 145 147 149 151 153 155 157 159 161 163 165 167 16... | code_stdio |
[
{
"content": "We have a string X, which has an even number of characters. Half the characters are `S`, and the other half are `T`.\n\nTakahashi, who hates the string `ST`, will perform the following operation 10^{10000} times:\n\n* Among the occurrences of `ST` in X as (contiguous) substrings, remove the leftmo... | [{"input": "SSTTTSST", "output": "2\n"}, {"input": "TTTTSSSS", "output": "8\n"}, {"input": "TSSTTSST", "output": "2\n"}, {"input": "TTSTSSST", "output": "4\n"}, {"input": "SSTTSTST", "output": "0\n"}, {"input": "TSSSTSTT", "output": "2\n"}, {"input": "TSTSTTSS", "output": "4\n"}, {"input": "SSSTTTST", "output": "0\n"},... | code_stdio |
[
{
"content": "Crazy Town is a plane on which there are n infinite line roads. Each road is defined by the equation a_{i}x + b_{i}y + c_{i} = 0, where a_{i} and b_{i} are not both equal to the zero. The roads divide the plane into connected regions, possibly of infinite space. Let's call each such region a block... | [{"input": "841746 527518\n595261 331297\n10\n-946901 129987 670374\n-140388 -684770 309555\n-302589 415564 -387435\n-565799 -72069 -395358\n-523453 -511446 854898\n-846967 -749453 -341866\n-622388 434663 264157\n-638453 625357 344195\n-255265 -676356 -772398\n-824723 -319141 33585\n", "output": "0\n"}, {"input": "8417... | code_stdio |
[
{
"content": "You are given an array of n integers a1... an. The cost of a subsegment is the number of unordered pairs of distinct indices within the subsegment that contain equal elements. Split the given array into k non-intersecting non-empty subsegments so that the sum of their costs is minimum possible. Ea... | [{"input": "128 5\n116 8 116 116 119 39 116 116 119 116 8 119 119 119 39 116 39 119 39 119 119 39 8 39 14 119 8 116 116 116 119 119 8 39 39 8 116 119 119 119 119 8 11 8 119 39 119 116 119 119 39 39 119 8 116 116 116 116 116 119 116 116 119 116 39 39 119 8 8 119 39 116 39 39 119 119 116 116 119 119 119 119 8 8 116 116 1... | code_stdio |
[
{
"content": "There is a building with n rooms, numbered 1 to n.\nWe can move from any room to any other room in the building.\nLet us call the following event a move: a person in some room i goes to another room j~ (i \\neq j).\nInitially, there was one person in each room in the building.\nAfter that, we know... | [{"input": "200000 1000000000\n", "output": "607923868\n"}, {"input": "200000 0000001000", "output": "525127456\n"}, {"input": "200000 0000001001", "output": "578341203\n"}, {"input": "200000 0001001001", "output": "607923868\n"}, {"input": "140753 0011001000", "output": "810481869\n"}, {"input": "135689 0011001000", "... | code_stdio |
[
{
"content": "We have N cards. A number a_i is written on the i-th card.\n\nAlice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.\n\nThe game ends when all the cards are taken by the two players, and the score of each player is the sum of the ... | [{"input": "4\n20 18 2 18\n", "output": "18\n"}, {"input": "4\n20 18 2 12", "output": "12\n"}, {"input": "4\n139 4 2 5", "output": "136\n"}, {"input": "4\n139 1 2 5", "output": "135\n"}, {"input": "4\n139 0 2 4", "output": "137\n"}, {"input": "4\n20 1 4 12", "output": "11\n"}, {"input": "4\n20 2 0 12", "output": "10\n"... | code_stdio |
[
{
"content": "Among other things, Bob is keen on photography. Especially he likes to take pictures of sportsmen. That was the reason why he placed himself in position x0 of a long straight racetrack and got ready to take pictures. But the problem was that not all the runners passed him. The total amount of spor... | [{"input": "50 77\n24 119\n43 119\n102 22\n117 30\n127 54\n93 19\n120 9\n118 27\n98 16\n17 105\n22 127\n109 52\n115 40\n11 121\n12 120\n113 30\n13 108\n33 124\n31 116\n112 39\n37 108\n127 28\n127 39\n120 29\n19 114\n103 18\n106 16\n24 121\n93 10\n36 112\n104 40\n39 100\n36 97\n83 9\n14 114\n126 12\n85 47\n25 84\n105 29... | code_stdio |
[
{
"content": "After bracket sequences Arthur took up number theory. He has got a new favorite sequence of length n (a1, a2, ..., an), consisting of integers and integer k, not exceeding n.\n\nThis sequence had the following property: if you write out the sums of all its segments consisting of k consecutive elem... | [{"input": "39 3\n-5 1 -13 ? 2 -12 ? 3 -11 -2 4 -10 ? 5 -9 0 6 -8 ? 7 -7 ? 8 -6 5 9 -5 ? 10 -4 ? 11 -3 ? 12 -2 10 13 -1\n", "output": "-5 1 -13 -4 2 -12 -3 3 -11 -2 4 -10 -1 5 -9 0 6 -8 1 7 -7 2 8 -6 5 9 -5 6 10 -4 7 11 -3 8 12 -2 10 13 -1\n"}, {"input": "39 3\n-5 1 -13 ? 2 -12 ? 3 -11 -3 4 -10 ? 5 -9 0 6 -8 ? 7 -7 ? 8... | code_stdio |
[
{
"content": "Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount systems.\n\nThere are m types of discounts. We assume that the discounts are indexed from 1 to m. To use the discount number i, the customer takes a special basket, where he puts exactly qi items... | [{"input": "48\n14 2 5 3 10 10 5 6 14 8 19 13 4 4 3 13 18 19 9 16 3 1 14 9 13 10 13 4 12 11 8 2 18 20 14 11 3 11 18 11 4 2 7 2 18 19 2 8\n70\n9497 5103 1001 2399 5701 4053 3557 8481 1736 4139 5829 1107 6461 4089 5936 7961 6017 1416 1191 4635 4288 5605 8857 1822 71 1435 2837 5523 6993 2404 2840 8251 765 5678 7834 8595 3... | code_stdio |
[
{
"content": "You have a string A = A_1 A_2 ... A_n consisting of lowercase English letters.\n\nYou can choose any two indices i and j such that 1 \\leq i \\leq j \\leq n and reverse substring A_i A_{i+1} ... A_j.\n\nYou can perform this operation at most once.\n\nHow many different strings can you obtain?\n\nC... | [{"input": "abracbdabra", "output": "46\n"}, {"input": "aaracbdaarb", "output": "44\n"}, {"input": "aarqabdaacb", "output": "45\n"}, {"input": "abrqabdaacb", "output": "47\n"}, {"input": "arbadbcbrca", "output": "48\n"}, {"input": "arbadbcbsca", "output": "49\n"}, {"input": "aqbadacaraa", "output": "41\n"}, {"input": "... | code_stdio |
[
{
"content": "Each employee of the \"Blake Techologies\" company uses a special messaging app \"Blake Messenger\". All the stuff likes this app and uses it constantly. However, some important futures are missing. For example, many users want to be able to search through the message history. It was already annou... | [{"input": "28 7\n1-a 1-b 1-c 1-d 1-e 1-f 1-t 1-a 1-b 1-c 1-d 1-e 1-f 1-j 1-a 1-b 1-c 1-d 1-e 1-f 1-g 1-a 1-b 1-c 1-d 1-e 1-f 2-g\n1-a 1-b 1-c 1-d 1-e 1-f 1-g\n", "output": "2\n"}, {"input": "28 7\n1-a 1-b 1-c 1-d 1-e 1-f 1-t 1-a 1-b 1-c 1-d 1-e 1-f 1-j 1-a 1-b 1-c 1-d 1-e 1-f 1-g 1-a 1-b 1-c 1-d 1-e 1-f 2-g\n1-a 1-b 1... | code_stdio |
[
{
"content": "Alice and Bob play a game. The game consists of several sets, and each set consists of several rounds. Each round is won either by Alice or by Bob, and the set ends when one of the players has won $x$ rounds in a row. For example, if Bob won five rounds in a row and $x = 2$, then two sets ends.\n\... | [{"input": "12\n???1??????1?\n", "output": "12 6 4 3 2 2 1 1 1 1 1 1 \n"}, {"input": "12\n?1?1????????\n", "output": "12 6 4 3 2 2 1 1 1 1 1 1\n"}, {"input": "12\n?1??????1???\n", "output": "12 6 4 3 2 2 1 1 1 1 1 1\n"}, {"input": "12\n????????1?1?\n", "output": "12 6 4 3 2 2 1 1 1 1 1 1\n"}, {"input": "12\n???1??????1... | code_stdio |
[
{
"content": "Sergey attends lessons of the N-ish language. Each lesson he receives a hometask. This time the task is to translate some sentence to the N-ish language. Sentences of the N-ish language can be represented as strings consisting of lowercase Latin letters without spaces or punctuation marks.\n\nSerg... | [{"input": "ttspivgoupgupvgpusvppogsseueusuglpiugssviuutlvgvugtpovuvspvpipggooplgvgugpogvesppulovugsvuougveiivgvslllviogpvtolepglguuellotpvgevspvoiiggiiplppgosuguvtstttpielteuglspgeoeeuivtptggltoltpgliviotsospvitupiopisoetupvvspooilsopslpoloptigstspoiuutiuvvuvlpplvioitsuvlpvtleveslslovolloogsgpvpepgueesslgtosttuupiepps... | code_stdio |
[
{
"content": "There is a string s of length 3 or greater. No two neighboring characters in s are equal.\n\nTakahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first:\n\n* Remove one of the characters in s, excluding both ends. How... | [{"input": "bceab", "output": "Second\n"}, {"input": "bacba", "output": "First\n"}, {"input": "badba", "output": "First\n"}, {"input": "cadba", "output": "First\n"}, {"input": "dadba", "output": "First\n"}, {"input": "ddaba", "output": "First\n"}, {"input": "dd`ba", "output": "First\n"}, {"input": "dd`b`", "output": "F... | code_stdio |
[
{
"content": "Petya and Vasya are competing with each other in a new interesting game as they always do.\n\nAt the beginning of the game Petya has to come up with an array of N positive integers. Sum of all elements in his array should be equal to S. Then Petya has to select an integer K such that 0 ≤ K ≤ S.\n\... | [{"input": "10 20\n", "output": "YES\n2 2 2 2 2 2 2 2 2 2\n1\n"}, {"input": "10 24\n", "output": "YES\n2 2 2 2 2 2 2 2 2 6\n1\n"}, {"input": "8 36\n", "output": "YES\n2 2 2 2 2 2 2 22\n1\n"}, {"input": "8 17\n", "output": "YES\n2 2 2 2 2 2 2 3\n1\n"}, {"input": "8 18\n", "output": "YES\n2 2 2 2 2 2 2 4\n1\n"}, {"input"... | code_stdio |
[
{
"content": "Snuke received a positive integer N from Takahashi. A positive integer m is called a favorite number when the following condition is satisfied:\n\n* The quotient and remainder of N divided by m are equal, that is, \\lfloor \\frac{N}{m} \\rfloor = N \\bmod m holds.\n\n\n\nFind all favorite numbers ... | [{"input": "1000010000000", "output": "2716922731275\n"}, {"input": "1000011000000", "output": "3307289212967\n"}, {"input": "1100011000000", "output": "2999416055122\n"}, {"input": "1110011000000", "output": "3146654438234\n"}, {"input": "1110011100000", "output": "4080876601631\n"}, {"input": "1110011100100", "output... | code_stdio |
[
{
"content": "A shop sells N kinds of fruits, Fruit 1, \\ldots, N, at prices of p_1, \\ldots, p_N yen per item, respectively. (Yen is the currency of Japan.)\nHere, we will choose K kinds of fruits and buy one of each chosen kind. Find the minimum possible total price of those fruits.\n\n-----Constraints-----\n... | [{"input": "1000 1000\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 10... | code_stdio |
[
{
"content": "Chef likes cooking. But more than that, he likes to give gifts. And now he wants to give his girlfriend an unforgettable gift. But unfortunately he forgot the password to the safe where the money he saved for the gift is kept.\n\nBut he knows how to hack the safe. To do this, you need to correctly... | [{"input": "2\n3\n3 -2 3\n-1\n10", "output": "-18\n10\n"}, {"input": "2\n3\n3 -4 3\n-2\n10", "output": "-36\n10\n"}, {"input": "2\n3\n3 -4 0\n-2\n10", "output": "-12\n10\n"}, {"input": "2\n3\n3 -5 0\n-2\n10", "output": "-15\n10\n"}, {"input": "2\n3\n3 -5 1\n-2\n10", "output": "-16\n10\n"}, {"input": "2\n3\n5 -4 5\n1\n3... | code_stdio |
[
{
"content": "Each year in the castle of Dwarven King there is a competition in growing mushrooms among the dwarves. The competition is one of the most prestigious ones, and the winner gets a wooden salad bowl. This year's event brought together the best mushroom growers from around the world, so we had to slig... | [{"input": "10 6 1 48\n239 632\n976 315\n797 112\n1 835\n938 862\n531 884\n422 607\n152 331\n413 677\n622 978\n", "output": "5 3788.56\n10 3673.36\n2 3360.12\n6 3289.08\n4 2606.20\n3 2598.64\n9 2525.24\n7 2315.84\n1 2210.84\n8 1184.72\n"}, {"input": "10 6 1 41\n239 632\n976 315\n797 112\n1 835\n938 862\n531 884\n422 60... | code_stdio |
[
{
"content": "Imagine that you have a twin brother or sister. Having another person that looks exactly like you seems very unusual. It's hard to say if having something of an alter ego is good or bad. And if you do have a twin, then you very well know what it's like.\n\nNow let's imagine a typical morning in yo... | [{"input": "100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n", "output... | code_stdio |
[
{
"content": "One quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera loved math, he didn't find this particular topic interesting. Even more, it seemed so boring t... | [{"input": "1000000000 2000000000 2\n", "output": "500000001\n"}, {"input": "200000000 2000000000 1800000011\n", "output": "1\n"}, {"input": "1500000000 2000000000 11\n", "output": "10389612\n"}, {"input": "1100000000 2000000000 2\n", "output": "450000001\n"}, {"input": "316274526 2000000000 1800000011\n", "output": "1... | code_stdio |
[
{
"content": "Serval is fighting with a monster.\nThe health of the monster is H.\nIn one attack, Serval can decrease the monster's health by A.\nThere is no other way to decrease the monster's health.\nServal wins when the monster's health becomes 0 or below.\nFind the number of attacks Serval needs to make be... | [{"input": "10000 1\n", "output": "10000\n"}, {"input": "10000 10000\n", "output": "1\n"}, {"input": "11000 1", "output": "11000\n"}, {"input": "10010 1", "output": "10010\n"}, {"input": "10001 1", "output": "10001\n"}, {"input": "11010 1", "output": "11010\n"}, {"input": "10101 1", "output": "10101\n"}, {"input": "100... | code_stdio |
[
{
"content": "Monocarp has arranged $n$ colored marbles in a row. The color of the $i$-th marble is $a_i$. Monocarp likes ordered things, so he wants to rearrange marbles in such a way that all marbles of the same color form a contiguos segment (and there is only one such segment for each color). \n\nIn other w... | [{"input": "100\n11 16 16 11 16 11 16 16 11 16 16 16 16 16 16 16 16 16 11 16 16 16 16 16 16 11 16 11 16 11 16 16 16 11 5 16 16 11 16 16 16 16 16 11 16 11 5 16 16 16 16 5 16 16 11 11 16 16 5 16 11 11 16 16 16 11 11 16 11 16 16 16 16 16 16 11 11 16 16 5 16 5 20 5 16 16 16 11 16 16 16 16 16 16 11 16 20 11 16 5\n", "output... | code_stdio |
[
{
"content": "You are given an array of n integer numbers a_0, a_1, ..., a_{n} - 1. Find the distance between two closest (nearest) minimums in it. It is guaranteed that in the array a minimum occurs at least two times.\n\n\n-----Input-----\n\nThe first line contains positive integer n (2 ≤ n ≤ 10^5) — size of ... | [{"input": "85\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 72 67 68 69 70 71 72 73 74 119 76 77 78 79 80 81 82 83 84 1\n", "output": "84\n"}, {"input": "85\n1 2 3 4 5 6 7 8 9 10... | code_stdio |
[
{
"content": "Alice and Bob play ping-pong with simplified rules.\n\nDuring the game, the player serving the ball commences a play. The server strikes the ball then the receiver makes a return by hitting the ball back. Thereafter, the server and receiver must alternately make a return until one of them doesn't ... | [{"input": "12\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n", "output": "0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n"}, {"input": "12\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n1 1\n2 1\n1 7\n", "output": "0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n0 1\n1 1\n0 7\n"}, {"input": "2\... | code_stdio |
[
{
"content": "Anton likes to play chess. Also, he likes to do programming. That is why he decided to write the program that plays chess. However, he finds the game on 8 to 8 board to too simple, he uses an infinite one instead.\n\nThe first task he faced is to check whether the king is in check. Anton doesn't k... | [{"input": "20\n-321 454\nQ 1369 -89\nR -811 454\nQ -404 454\nR -734 454\nQ -804 454\nQ -316 77\nQ -802 468\nB -499 602\nQ 401 -663\nQ -601 454\nQ -974 454\nB 710 298\nB -917 454\nB -555 -924\nQ -337 950\nR 501 40\nR 355 310\nB 1163 -374\nR -860 454\nR 839 -10\n", "output": "YES\n"}, {"input": "20\n-321 454\nQ 1369 -89... | code_stdio |
[
{
"content": "There are N stores called Store 1, Store 2, \\cdots, Store N. Takahashi, who is at his house at time 0, is planning to visit some of these stores.\n\nIt takes Takahashi one unit of time to travel from his house to one of the stores, or between any two stores.\n\nIf Takahashi reaches Store i at tim... | [{"input": "7 149\n0 25\n3 10\n2 4\n2 20\n3 22\n2 23\n1 2", "output": "4\n"}, {"input": "7 85\n0 25\n3 10\n2 4\n5 20\n3 22\n2 23\n1 18", "output": "3\n"}, {"input": "7 99\n0 25\n3 10\n2 4\n5 20\n3 22\n2 23\n1 18", "output": "3\n"}, {"input": "7 99\n0 25\n3 10\n2 4\n2 20\n3 22\n2 23\n1 18", "output": "3\n"}, {"input": "... | code_stdio |
[
{
"content": "Programmer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are unapplicable to it. To fully understand the statement, please read the langua... | [{"input": "10\ntypedef &void**** youdyfpinzk\ntypeof &youdyfpinzk***\ntypedef &&&&youdyfpinzk****** nfbsgpjzhxzskmxc\ntypeof nfbsgpjzhxzskmxc***\ntypedef &&&void*** puerqioirikxej\ntypeof &puerqioirikxej********\ntypedef &puerqioirikxej******** xzgzsamjdufuyxz\ntypeof &xzgzsamjdufuyxz******\ntypedef &&&&xzgzsamjdufuyx... | code_stdio |
[
{
"content": "There are N cats. We number them from 1 through N.\n\nEach of the cats wears a hat. Cat i says: \"there are exactly a_i different colors among the N - 1 hats worn by the cats except me.\"\n\nDetermine whether there exists a sequence of colors of the hats that is consistent with the remarks of the ... | [{"input": "5\n3 4 3 4 3", "output": "Yes\n"}, {"input": "5\n3 4 3 3 3", "output": "No\n"}, {"input": "4\n1 0 -1 2", "output": "No\n"}, {"input": "4\n1 0 -1 3", "output": "No\n"}, {"input": "4\n1 1 -1 3", "output": "No\n"}, {"input": "4\n1 2 -1 3", "output": "No\n"}, {"input": "4\n2 2 -1 3", "output": "No\n"}, {"input"... | code_stdio |
[
{
"content": "This is the easy version of the problem. The difference between the versions is in the constraints on the array elements. You can make hacks only if all versions of the problem are solved.\n\nYou are given an array [a_1, a_2, ..., a_n]. \n\nYour goal is to find the length of the longest subarray o... | [{"input": "100\n92 42 58 62 24 59 62 100 92 62 54 100 62 82 91 62 100 100 62 100 100 62 92 92 92 62 92 92 62 92 62 92 88 100 100 36 62 92 16 92 62 100 62 92 35 62 100 92 92 62 93 100 100 62 76 100 62 62 92 62 92 50 100 8 7 62 100 18 92 62 92 92 100 62 32 92 92 62 37 76 100 39 62 92 62 41 62 62 19 57 100 37 92 99 100 4... | code_stdio |
[
{
"content": "You are given a string s consisting of lowercase English letters and a number k. Let's call a string consisting of lowercase English letters beautiful if the number of occurrences of each letter in that string is divisible by k. You are asked to find the lexicographically smallest beautiful string... | [{"input": "12\n12 3\nzazasqzqsasq\n1 2\ny\n1 1\na\n15 5\nabccbaabccbazaa\n16 8\ncadjfdsljfdkljds\n6 2\nbaazaa\n6 3\nbosszb\n6 1\nqwerty\n7 7\ndaaaaaa\n14 2\nacabcbdeffewzc\n18 6\nzzzzzzzzzzzzyyyyyz\n9 4\naabaabbbc\n", "output": "zazasqzqsasq\n-1\na\nabccbaabccbbaac\ncbbbbbbbbccccccc\nbaazbz\nbpbbpp\nqwerty\nddddddd\na... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.