messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a \"Double Cola\" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue...
[{"input": "0000011000\n", "output": "Sheldon\n"}, {"input": "381237714\n", "output": "Sheldon\n"}, {"input": "872651351\n", "output": "Leonard\n"}, {"input": "347025213\n", "output": "Sheldon\n"}, {"input": "425568842\n", "output": "Leonard\n"}, {"input": "758393876\n", "output": "Sheldon\n"}, {"input": "215431553\n",...
code_stdio
[ { "content": "Alperen has two strings, $s$ and $t$ which are both initially equal to \"a\".\n\nHe will perform $q$ operations of two types on the given strings:\n\n$1 \\;\\; k \\;\\; x$ β€” Append the string $x$ exactly $k$ times at the end of string $s$. In other words, $s := s + \\underbrace{x + \\dots + x}_{k ...
[{"input": "3\n5\n2 1 aa\n1 2 a\n2 3 a\n1 2 b\n2 3 abca\n2\n1 5 mihai\n2 2 buiucani\n3\n1 5 b\n2 3 a\n2 4 paiu\n", "output": "YES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nYES\n"}, {"input": "1\n8\n2 7 z\n1 2 xpt\n2 5 aosu\n2 3 veel\n1 3 dnx\n1 8 tgly\n2 5 rqlmvchcir\n1 10 qklu\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYE...
code_stdio
[ { "content": "You are given two arrays A and B consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose k numbers in array A and choose m numbers in array B so that any number chosen in the first array is strictly less than any number chosen in the second array.\n\n\n-----I...
[{"input": "20 30\n19 29\n2 1 2 2 3 3 4 4 7 7 7 9 8 8 8 8 1 0 9 10\n6 9 9 7 9 9 9 9 5 9 9 9 9 18 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10\n", "output": "NO\n"}, {"input": "20 30\n19 29\n2 1 2 2 2 3 4 4 7 10 7 8 8 8 8 8 9 9 9 9\n6 9 9 9 9 9 9 9 9 9 9 9 9 18 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10\n", "output"...
code_stdio
[ { "content": "There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\nYou can rearrange these children just one time in any order you like.\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position fro...
[{"input": "2000\n919697266 557620328 306200382 938985256 815342630 163392675 302065984 171634774 595091891 878051152 45556321 599365418 836259090 519017787 53355189 239963918 892242532 41911517 32213197 241306129 182967761 735538395 277915827 947333936 397686688 951038946 390763995 565454633 980862050 263983172 856918...
code_stdio
[ { "content": "A binary search tree can be unbalanced depending on features of data. For example, if we insert $n$ elements into a binary search tree in ascending order, the tree become a list, leading to long search times. One of strategies is to randomly shuffle the elements to be inserted. However, we should ...
[{"input": "16\ninsert 21 99\ninsert 3 80\ninsert 1 12\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 141 47\ninsert 26 6\ninsert 12 10\ninsert 6 139\nprint\nfind 21\nfind 22\ndelete 35\ndelete 99\nprint", "output": " 1 3 6 12 14 21 26 42 80 141\n 6 3 1 21 14 12 80 26 42 141\nyes\nno\n 1 3 6 12 14 21 26 42 80 141\n 6...
code_stdio
[ { "content": "One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of n non-negative integers.\n\nIf there are exactly K distinct values in the array, the...
[{"input": "50 20\n592183311 362557946 154127088 616872926 395353745 675069471 509655682 79915471 356656666 937992998 304422065 724106263 472338455 792258113 796069631 1325917135 201799298 566151622 722278085 827802227 703159587 690854023 925377265 11010958 69791159 990158269 535460930 167415727 999216963 237203826 693...
code_stdio
[ { "content": "There are N squares aligned in a row. The i-th square from the left contains an integer a_i.\n\nInitially, all the squares are white. Snuke will perform the following operation some number of times:\n\n* Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here,...
[{"input": "10 5\n5 -4 -5 -16 -4 0 2 -4 -1 3", "output": "10\n"}, {"input": "10 5\n6 -4 -5 -16 -4 0 2 -4 -1 3", "output": "11\n"}, {"input": "10 5\n6 -4 -5 -16 -4 0 2 -4 -2 3", "output": "11\n"}, {"input": "10 5\n5 -4 -5 -8 -4 7 2 -4 0 14", "output": "24\n"}, {"input": "10 5\n5 -4 -5 -16 -4 0 1 -4 -1 3", "output": "9\n...
code_stdio
[ { "content": "One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers.\n\nIf there are exactly $K$ distinct values in the array,...
[{"input": "50 20\n592183311 362557946 154127088 616872926 395353745 675069471 509655682 79915471 356656666 937992998 304422065 724106263 472338455 792258113 796069631 663370025 201799298 566151622 722278085 508905399 703159587 690854023 925377265 11010958 69791159 990158269 535460930 167415727 999216963 237203826 6939...
code_stdio
[ { "content": "There is a graph of $n$ rows and $10^6 + 2$ columns, where rows are numbered from $1$ to $n$ and columns from $0$ to $10^6 + 1$:\n\nLet's denote the node in the row $i$ and column $j$ by $(i, j)$.\n\nInitially for each $i$ the $i$-th row has exactly one obstacle β€” at node $(i, a_i)$. You want to m...
[{"input": "4\n2 3 1\n999999 1000000\n2 3 2\n999999 1000000\n2 3 1\n1000000 1584412\n2 3 1\n100 1000000\n", "output": "1\n2\n0\n0\n"}, {"input": "4\n2 3 1\n285716 1000000\n2 3 2\n999999 1000000\n2 3 1\n1000000 1584412\n2 3 1\n100 1000000\n", "output": "0\n2\n0\n0\n"}, {"input": "4\n2 3 1\n999999 1000000\n2 3 2\n999999 ...
code_stdio
[ { "content": "Some large corporation where Polycarpus works has its own short message service center (SMSC). The center's task is to send all sorts of crucial information. Polycarpus decided to check the efficiency of the SMSC. \n\nFor that, he asked to give him the statistics of the performance of the SMSC for...
[{"input": "40\n313 97063\n372 23668\n377 56079\n428 88458\n435 57330\n454 88869\n456 75553\n466 87607\n468 4542\n469 30243\n471 8958\n472 59745\n473 90985\n474 32247\n475 71576\n476 14016\n477 91574\n478 38345\n479 93280\n480 89902\n481 41828\n482 3233\n483 66725\n484 23523\n485 46772\n486 95688\n487 19864\n488 10295\...
code_stdio
[ { "content": "Let's denote a function \n\n$d(x, y) = \\left\\{\\begin{array}{ll}{y - x,} & {\\text{if}|x - y|> 1} \\\\{0,} & {\\text{if}|x - y|\\leq 1} \\end{array} \\right.$\n\nYou are given an array a consisting of n integers. You have to calculate the sum of d(a_{i}, a_{j}) over all pairs (i, j) such that 1 ...
[{"input": "100\n591 417 888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983 526 103 500 963 400 23 276 704 570 757 410 658 507 620 984 244 486 ...
code_stdio
[ { "content": "The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus n ice sculptures were erected. The sculptures are arranged in a circle at equal distances from...
[{"input": "97\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 -1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -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\n", "output": "-1\n"}, {"input": "97\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 -1 -...
code_stdio
[ { "content": "Iahub got bored, so he invented a game to be played on paper. \n\nHe writes n integers a_1, a_2, ..., a_{n}. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j (1 ≀ i ≀ j ≀ n) and flips all values a_{k} for which their positions are in ...
[{"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 1 0 1 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0 1 1 1 0 1...
code_stdio
[ { "content": "Takahashi is drawing a segment on grid paper.\n\nFrom a certain square, a square that is x squares to the right and y squares above, is denoted as square (x, y).\n\nWhen Takahashi draws a segment connecting the lower left corner of square (A, B) and the lower left corner of square (C, D), find the...
[{"input": "124 -2 -1 -1", "output": "125\n"}, {"input": "241 -2 -1 -1", "output": "242\n"}, {"input": "121 -1 -1 0", "output": "122\n"}, {"input": "116 1 -2 -1", "output": "118\n"}, {"input": "209 -1 -1 0", "output": "210\n"}, {"input": "116 1 -2 -2", "output": "120\n"}, {"input": "124 1 1 -2", "output": "123\n"}, {"i...
code_stdio
[ { "content": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nOne day Petya was delivered a string s, containing only digits. He needs to ...
[{"input": "00000000000000000000000000000000000000000000000000\n", "output": "-1\n"}, {"input": "110996812575168252737244204200508745829735318381381\n", "output": "7\n"}, {"input": "122094830270541438292052920866473330280784608392695\n", "output": "4\n"}, {"input": "00000000000000000000000000000100000000000000000000\n"...
code_stdio
[ { "content": "There are $n$ students in a university. The number of students is even. The $i$-th student has programming skill equal to $a_i$. \n\nThe coach wants to form $\\frac{n}{2}$ teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can ...
[{"input": "100\n1 1 100 100 1 100 1 1 1 1 1 1 100 1 100 100 100 1 1 100 100 100 100 100 1 100 1 100 1 1 1 100 1 1 100 1 100 1 1 1 100 100 1 1 1 100 100 100 100 100 1 100 100 1 1 1 1 100 1 1 100 1 1 1 1 100 100 100 1 100 1 100 100 100 1 1 100 100 100 100 1 100 1 100 100 1 100 1 100 100 100 100 100 100 1 1 1 100 100 1\n...
code_stdio
[ { "content": "Inaka has a disc, the circumference of which is $n$ units. The circumference is equally divided by $n$ points numbered clockwise from $1$ to $n$, such that points $i$ and $i + 1$ ($1 \\leq i < n$) are adjacent, and so are points $n$ and $1$.\n\nThere are $m$ straight segments on the disc, the endp...
[{"input": "30000 28\n10601 1119\n11119 20601\n9493 25771\n14351 4869\n13101 3619\n23101 13619\n29869 9351\n6119 15601\n3101 23619\n1851 22369\n11851 2369\n8619 18101\n19579 20882\n18619 28101\n16851 7369\n8101 28619\n24869 4351\n24351 14869\n27369 6851\n9869 19351\n5601 26119\n3976 21301\n21851 12369\n25601 16119\n244...
code_stdio
[ { "content": "You got a box with a combination lock. The lock has a display showing n digits. There are two buttons on the box, each button changes digits on the display. You have quickly discovered that the first button adds 1 to all the digits (all digits 9 become digits 0), and the second button shifts all t...
[{"input": "200\n79025531557298703099245700860027432585447902553155729870309924570086002743258544790255315572987030992457008600274325854479025531557298703099245700860027432585447902553155729870309924570086002743258544\n", "output": "002743258544790255315572987030992457008600274325854479025531557298703099245700860027432...
code_stdio
[ { "content": "A histogram is made of a number of contiguous bars, which have same width.\n\nFor a given histogram with $N$ bars which have a width of 1 and a height of $h_i$ = $h_1, h_2, ... , h_N$ respectively, find the area of the largest rectangular area.\n\nConstraints\n\n* $1 \\leq N \\leq 10^5$\n* $0 \\le...
[{"input": "8\n1 20 9 13 4 10 1 26", "output": "27\n"}, {"input": "8\n1 36 9 13 4 10 1 26", "output": "36\n"}, {"input": "8\n1 36 9 13 4 10 1 38", "output": "38\n"}, {"input": "8\n1 20 3 13 4 7 1 26", "output": "26\n"}, {"input": "8\n5 13 10 10 1 2 0 2", "output": "30\n"}, {"input": "8\n5 13 15 19 0 2 0 2", "output": "...
code_stdio
[ { "content": "Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.\n\nEach apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Tou...
[{"input": "100\n200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200...
code_stdio
[ { "content": "There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.\n\nThe presenter ha...
[{"input": "32 10540\n", "output": "12\n"}, {"input": "84 10000\n", "output": "10\n"}, {"input": "37 25195\n", "output": "29\n"}, {"input": "123 1008\n", "output": "18\n"}, {"input": "75 10000\n", "output": "19\n"}, {"input": "26 10010\n", "output": "11\n"}, {"input": "50 10000\n", "output": "40"}, {"input": "57 6218\n...
code_stdio
[ { "content": "Problem statement\n\nCards with ranks of $ 2 $ and $ 8 $ are powerful in card game millionaires. Therefore, we call an integer consisting of only the numbers $ 2 $ and $ 8 $ in $ 10 $ decimal notation a good integer. The best integers are listed from the smallest to $ 2, 8, 22, 28, 82, 88, \\ cdot...
[{"input": "-104", "output": "-1\n"}, {"input": "-102", "output": "-1\n"}, {"input": "-118", "output": "-1\n"}, {"input": "-114", "output": "-1\n"}, {"input": "-206", "output": "-1\n"}, {"input": "-168", "output": "-1\n"}, {"input": "-101", "output": "-1\n"}, {"input": "-109", "output": "-1\n"}, {"input": "-106", "outp...
code_stdio
[ { "content": "Given an array $A_1, A_2, ..., A_N$, count the number of subarrays of array $A$ which are non-decreasing.\n\nA subarray $A[i, j]$, where $1 ≀ i ≀ j ≀ N$ is a sequence of integers $A_i, A_i+1, ..., A_j$.\nA subarray $A[i, j]$ is non-decreasing if $A_i ≀ A_i+1 ≀ A_i+2 ≀ ... ≀ A_j$. You have to count...
[{"input": "2\n4\n-1 1 2 2\n1\n4", "output": "10\n1\n"}, {"input": "2\n4\n1 2 2 3\n1\n5", "output": "10\n1\n"}, {"input": "2\n4\n1 2 2 3\n1\n2", "output": "10\n1\n"}, {"input": "2\n4\n2 13 0 2\n1\n4", "output": "6\n1\n"}, {"input": "2\n4\n2 2 2 3\n1\n2", "output": "10\n1\n"}, {"input": "2\n4\n0 1 2 2\n1\n4", "output": ...
code_stdio
[ { "content": "Monocarp is playing a game \"Assimilation IV\". In this game he manages a great empire: builds cities and conquers new lands.\n\nMonocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur,...
[{"input": "3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3\n", "output": "\n166374062\n"}, {"input": "3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3\n", "output": "166374062\n"}, {"input": "3 5\n1 4 4 3 4\n1 4 2 4 2\n1 4 4 4 3\n", "output": "831870297\n"}, {"input": "3 5\n1 4 4 3 4\n1 4 2 4 2\n1 3 4 4 3\n", "output": "166374062\n"}, {"inp...
code_stdio
[ { "content": "You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0.\n\nWrite the program which finds the number of points in the intersection of two given sets.\n\nInput\n\nThe first line of the input...
[{"input": "100 100 100\n-100 100 -100\n", "output": "1"}, {"input": "12 -32 89\n0 67 -23\n", "output": "1"}, {"input": "-1 1 -1\n-1 1 -1\n", "output": "-1\n"}, {"input": "0 -1 -1\n-1 -1 -1\n", "output": "1\n"}, {"input": "-1 -1 0\n-1 -1 -1\n", "output": "0\n"}, {"input": "0 -1 -1\n-2 -1 -1\n", "output": "1\n"}, {"inpu...
code_stdio
[ { "content": "The legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are hungry, so he instructs his cow Bessie to bring out the snacks! Moo!\n\nThere are $n$ snacks flavors, numbered with integers $1, 2, \\ldots, n$. Bessie has $n$ snack...
[{"input": "100000 12\n8 11\n1 9\n5 4\n11 12\n7 11\n3 4\n6 5\n12 15\n15 13\n13 14\n7 11\n11 14\n", "output": "2\n"}, {"input": "100000 12\n8 10\n1 9\n5 4\n11 12\n7 11\n3 4\n3 5\n12 15\n15 13\n13 14\n7 8\n11 14\n", "output": "2\n"}, {"input": "100000 12\n8 11\n1 9\n5 4\n11 12\n7 11\n3 4\n3 5\n12 15\n15 13\n13 14\n7 8\n1...
code_stdio
[ { "content": "problem\n\nAOR Ika is at the $ S $ th bus stop at time $ 0 $ and wants to go from there to the $ G $ th bus stop. The number of bus stops $ N $ and $ M $ routes (*) connecting different bus stops are given. The bus stops are numbered $ 1, \\ dots, and N $, respectively. Each route consists of $ 4 ...
[{"input": "2 2 1 2\n1 2 16 110\n2 2 7 1526", "output": "16\n"}, {"input": "2 1 1 2\n1 2 12 100\n1 -1 5 500", "output": "12\n"}, {"input": "2 2 1 2\n1 2 19 110\n2 2 7 1526", "output": "19\n"}, {"input": "2 2 1 2\n1 2 19 010\n2 2 7 1526", "output": "19\n"}, {"input": "2 2 1 2\n1 2 19 110\n2 2 3 1526", "output": "19\n"},...
code_stdio
[ { "content": "A fraction whose numerator is 1 and whose denominator is a positive integer is called a unit fraction. A representation of a positive rational number p/q as the sum of finitely many unit fractions is called a partition of p/q into unit fractions. For example, 1/2 + 1/6 is a partition of 2/3 into u...
[{"input": "2 3 120 3\n2 3 300 3\n2 3 299 3\n2 3 12 3\n2 3 12000 7\n54 1343 12000 7\n2 3 300 1\n2 1 200 5\n2 4 54 2\n0 0 0 0", "output": "4\n7\n6\n2\n42\n0\n0\n9\n3\n"}, {"input": "2 3 120 3\n2 3 300 3\n2 3 299 3\n2 3 12 3\n2 3 12000 7\n54 795 12000 7\n2 4 300 1\n2 1 200 5\n2 4 54 2\n0 0 0 0", "output": "4\n7\n6\n2\n42...
code_stdio
[ { "content": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. HW characters from A_{11} to A_{HW} represent the colors of the squares. A_{ij} is `#` if the square at the i-th row from the top and the j-th column from the left is black, ...
[{"input": "6 6\n..#..#\n......\n..#..\n......\n.#....\n-...#.", "output": "3\n"}, {"input": "2 6\n#.#...\n......\n..#0.\n......\n.#.-..\n--..#-", "output": "4\n"}, {"input": "6 6\n..#..#\n......\n..#..\n......\n.#....\n../.#.", "output": "3\n"}, {"input": "6 6\n..#..#\n......\n..#..\n......\n.#....\n-..-#.", "output":...
code_stdio
[ { "content": "There are $n$ candies in a row, they are numbered from left to right from $1$ to $n$. The size of the $i$-th candy is $a_i$.\n\nAlice and Bob play an interesting and tasty game: they eat candy. Alice will eat candy from left to right, and Bob β€” from right to left. The game ends if all the candies ...
[{"input": "7\n11\n3 1 4 1 5 9 1 4 10 3 5\n1\n1000\n3\n1 2 1\n13\n1 2 3 4 5 6 7 8 9 10 11 12 13\n2\n2 1\n6\n1 1 1 1 1 2\n7\n1 2 1 1 1 1 1\n", "output": "6 23 23\n1 1000 0\n2 1 3\n6 45 46\n2 2 1\n4 4 3\n4 4 4\n"}, {"input": "7\n11\n3 1 4 2 5 9 1 4 10 3 5\n1\n1000\n3\n1 2 1\n13\n1 2 3 4 5 6 7 8 9 10 11 12 13\n2\n2 1\n6\n...
code_stdio
[ { "content": "One day Alice visited Byteland to purchase jewels for her upcoming wedding anniversary.\nIn Byteland, every Jewelry shop has their own discount methods to attract the customers. One discount method called Buy1-Get1 caught Alice's attention. That is, Alice buys one jewel, then she can get one addit...
[{"input": "4\nssss\nrsas\nsa\ns", "output": "2\n3\n2\n1\n"}, {"input": "4\ntsss\nsasr\nas\nt", "output": "3\n3\n2\n1\n"}, {"input": "4\nssss\natrs\nat\nt", "output": "2\n4\n2\n1\n"}, {"input": "4\nrsss\natsr\nbt\nt", "output": "3\n4\n2\n1\n"}, {"input": "4\nrstq\narsr\nra\nt", "output": "4\n3\n2\n1\n"}, {"input": "4\n...
code_stdio
[ { "content": "Ivan has got an array of n non-negative integers a_1, a_2, ..., a_{n}. Ivan knows that the array is sorted in the non-decreasing order. \n\nIvan wrote out integers 2^{a}_1, 2^{a}_2, ..., 2^{a}_{n} on a piece of paper. Now he wonders, what minimum number of integers of form 2^{b} (b β‰₯ 0) need to be...
[{"input": "26\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "5\n"}, {"input": "26\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "5\n"}, {"input": "1\n2000000000\n", "output": "2000000000\n"}, {"input": "1\n2000000000\n", "output": "2000000000\n"}, {"input": "1\n1646661570\n", ...
code_stdio
[ { "content": "You are given two integers K and S.\nThree variable X, Y and Z takes integer values satisfying 0≀X,Y,Z≀K.\nHow many different assignments of values to X, Y and Z are there such that X + Y + Z = S?\n\nConstraints\n\n* 2≀K≀2500\n* 0≀S≀3K\n* K and S are integers.\n\nInput\n\nThe input is given from S...
[{"input": "100 58", "output": "1770\n"}, {"input": "100 50", "output": "1326\n"}, {"input": "101 60", "output": "1891\n"}, {"input": "111 72", "output": "2701\n"}, {"input": "111 79", "output": "3240\n"}, {"input": "278 24", "output": "325\n"}, {"input": "278 20", "output": "231\n"}, {"input": "100 22", "output": "276...
code_stdio
[ { "content": "You have two integers $l$ and $r$. Find an integer $x$ which satisfies the conditions below:\n\n $l \\le x \\le r$. All digits of $x$ are different. \n\nIf there are multiple answers, print any of them.\n\n\n-----Input-----\n\nThe first line contains two integers $l$ and $r$ ($1 \\le l \\le r \\...
[{"input": "98766 110000\n", "output": "102345\n"}, {"input": "98766 110010\n", "output": "102345\n"}, {"input": "72073 145777\n", "output": "72081\n"}, {"input": "11097 145777\n", "output": "12034\n"}, {"input": "38912 145777\n", "output": "38912\n"}, {"input": "11097 157931\n", "output": "12034\n"}, {"input": "25610 ...
code_stdio
[ { "content": "Hierarchical Democracy\n\nThe presidential election in Republic of Democratia is carried out through multiple stages as follows.\n\n1. There are exactly two presidential candidates.\n2. At the first stage, eligible voters go to the polls of his/her electoral district. The winner of the district is...
[{"input": "6\n[[123][4567][89]]\n[[5][3][6][3][9]]\n[[[99][59][63][85][51]][[1539][7995][466]][[51][57][79][99][3][91][59]]]\n[[[37][95][31][77][25]][[43][5][5][5][85]][[71][3][51][89][29]][[57][94][5][69][31]][[99][59][65][73][31]]]\n[[[[9][7][3]][[3][5][7]][[7][9][5]]][[[9][9][3]][[5][9][9]][[7][7][3]]][[[5][9][7]][...
code_stdio
[ { "content": "One important contest will take place on the most famous programming platform (Topforces) very soon!\n\nThe authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty cont...
[{"input": "1\n37\n166320 83160 41580 33264 27720 23760 20790 18480 16632 15120 13860 11880 11088 10395 9240 10676 7920 7560 6930 6160 5940 9910 5040 4752 4620 4158 3960 3780 3696 3465 3080 3024 2970 2772 2640 29 23\n", "output": "186906\n"}, {"input": "1\n37\n166320 83160 41580 33264 27720 23760 20790 18480 16632 1512...
code_stdio
[ { "content": "Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to $120^{\\circ}$. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Ge...
[{"input": "1000 1000 1000 1000 1000 1000\n", "output": "6000000\n"}, {"input": "1000 1000 1000 1000 1000 1000\n", "output": "6000000\n"}, {"input": "718 466 729 470 714 481\n", "output": "2102808\n"}, {"input": "677 303 685 288 692 296\n", "output": "1365807\n"}, {"input": "1000 1000 1 1000 1000 1\n", "output": "20040...
code_stdio
[ { "content": "problem\n\nThere are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.\n\nYou work at a ticket center that handles ship tickets. There are many people in JOI who want to travel between islands by boat, as che...
[{"input": "3 8\n1 3 1 10\n0 2 3\n1 2 3 20\n1 1 2 5\n0 3 2\n1 1 3 7\n1 2 1 9\n0 2 3\n5 16\n1 1 3 343750\n1 1 3 3343\n1 1 4 347392\n1 2 5 5497\n1 2 3 123394\n1 2 4 545492\n1 2 5 458\n1 3 4 343983\n1 3 5 843468\n1 4 5 2780\n0 2 1\n0 4 1\n0 3 2\n0 4 2\n0 4 3\n0 5 3\n0 0", "output": "-1\n15\n12\n126737\n129975\n123394\n323...
code_stdio
[ { "content": "There are N stones, numbered 1, 2, \\ldots, N. For each i (1 \\leq i \\leq N), the height of Stone i is h_i.\n\nThere is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N:\n\n* If the frog is currently on Stone i, jump to Stone i + 1 or S...
[{"input": "6\n30 10 60 10 60 57", "output": "33\n"}, {"input": "6\n30 12 60 33 60 18", "output": "54\n"}, {"input": "6\n30 12 21 33 60 18", "output": "36\n"}, {"input": "6\n30 0 26 33 122 14", "output": "30\n"}, {"input": "6\n30 10 99 10 60 50", "output": "60\n"}, {"input": "6\n30 10 35 18 154 1", "output": "39\n"}, {...
code_stdio
[ { "content": "Luckily, Serval got onto the right bus, and he came to the kindergarten on time. After coming to kindergarten, he found the toy bricks very funny.\n\nHe has a special interest to create difficult problems for others to solve. This time, with many $1 \\times 1 \\times 1$ toy bricks, he builds up a ...
[{"input": "2 58 77\n0 0 0 0 6 0 0 0 40 0 0 0 0 22 0 0 41 74 0 0 0 0 0 0 0 15 0 0 60 5 69 0 0 30 0 0 23 60 0 35 0 0 0 0 0 0 69 0 0 0 0 0 0 0 0 0 0 0\n0 74\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\n0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0...
code_stdio
[ { "content": "Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. During his turn a player can take one card: either the leftmost card in a row, or t...
[{"input": "95\n122 29 188 265 292 287 183 225 222 187 155 256 64 148 173 278 218 136 290 17 31 130 2 87 57 283 255 280 68 166 174 142 102 39 116 206 288 154 26 78 296 172 184 232 77 91 277 8 249 186 94 93 207 251 257 195 101 299 193 124 293 65 58 35 24 302 220 189 252 125 27 284 247 182 141 103 198 97 234 83 281 216 8...
code_stdio
[ { "content": "This is an easier version of the problem with smaller constraints.\n\nKorney Korneevich dag up an array $a$ of length $n$. Korney Korneevich has recently read about the operation bitwise XOR , so he wished to experiment with it. For this purpose, he decided to find all integers $x \\ge 0$ such tha...
[{"input": "100\n227 40 465 412 346 400 165 362 247 431 171 215 164 437 34 169 62 223 21 202 372 423 9 336 2 155 92 291 141 187 306 310 340 314 405 387 299 216 9 173 117 478 165 112 311 277 304 454 137 57 337 28 366 374 418 189 2 416 65 309 193 471 406 213 180 85 327 71 341 128 191 239 125 317 21 236 217 292 40 450 173...
code_stdio
[ { "content": "Alice became interested in periods of integer numbers. We say positive $X$ integer number is periodic with length $L$ if there exists positive integer number $P$ with $L$ digits such that $X$ can be written as $PPPP…P$. For example:\n\n$X = 123123123$ is periodic number with length $L = 3$ and $L ...
[{"input": "98779\n163329605173223304180189399899081111990037\n", "output": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
code_stdio
[ { "content": "\"Contestant who earns a score equal to or greater than the k-th place finisher's score will advance to the next round, as long as the contestant earns a positive score...\" β€” an excerpt from contest rules.\n\nA total of n participants took part in the contest (n β‰₯ k), and you already know their s...
[{"input": "50 44\n100 100 99 97 95 91 91 84 83 83 79 71 70 69 69 62 61 60 59 59 58 102 58 55 55 54 52 48 47 45 44 44 38 36 38 31 28 28 25 25 24 24 24 22 17 15 14 13 12 4\n", "output": "44\n"}, {"input": "50 44\n100 100 99 97 95 91 91 84 83 83 79 71 70 69 69 62 61 60 59 59 58 58 58 55 55 54 52 48 47 45 44 44 38 36 32 3...
code_stdio
[ { "content": "Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.\n\nTwo young parents abac and bbad think what name to give to their first-born child. They decided that the name will be the permutation of lett...
[{"input": "abbabaaabaaabbbbabbbbbababababaaaabbabbbbabbbbbabbbbababbaaaaabbbabbbbabbbbbbabaabababaabbbabababbaz\nabaaabaabbbbaabbbbaabababbaabaabababbbaabbbaaabbabbabbbbbbbbaabbbbbabababbbbaaabaaaabbbbbbbbabababba\n", "output": "abaaabaabbbbaabbbbaabababbaabaabababbbaabbbaaabbabbabbbbbbbbaabbbbbabababbbbaaabaaaabbbbbb...
code_stdio
[ { "content": "Increasing E869120 (Ninja E869120)\n\nE869120 You are good at alter ego.\n\nHere are $ N $ members of the PA Lab. But some of them may be E869120.\n\nSo you asked all the $ N $ members of the PA Lab for their names. As a result, the $ N $ members named themselves $ S_1, S_2, S_3, \\ dots, S_N $, r...
[{"input": "5\nE869120\nTMJN\nE869120\nASIAT\nYNYMXIAOLONGBAO", "output": "2\n"}, {"input": "5\nE869120\nTMJN\nE809126\nATIAT\nYNYMXIAOGONLBAO", "output": "1\n"}, {"input": "5\nE86912/\nTMJN\n621908E\nIATSA\nYNYMXIBOGONLBAO", "output": "0\n"}, {"input": "5\nE869120\nTMJN\nE869120\nASIAT\nYNYMXIAOGONLBAO", "output": "2\...
code_stdio
[ { "content": "You are given a tree (an undirected connected graph without cycles) and an integer s.\n\nVanya wants to put weights on all edges of the tree so that all weights are non-negative real numbers and their sum is s. At the same time, he wants to make the diameter of the tree as small as possible.\n\nLe...
[{"input": "3 1000000000\n3 2\n2 1\n", "output": "1000000000.0000000000\n"}, {"input": "2 1000000000\n2 1\n", "output": "1000000000.0000000000\n"}, {"input": "6 1\n2 1\n4 3\n2 5\n5 4\n5 6\n", "output": "0.6666666667\n"}, {"input": "6 1\n2 1\n2 3\n2 5\n2 4\n5 6\n", "output": "0.5000000000\n"}, {"input": "6 2\n2 1\n4 3\n...
code_stdio
[ { "content": "problem\n\nJOI City will hold a large-scale exposition.\n\nThere are two themes for this exposition, and each of the N exhibition facilities in JOI City will exhibit on one of the two themes.\n\nThe location of the facility is represented by plane coordinates (x, y). To move from the facility at p...
[{"input": "5\n-9 -11\n1 0\n2 -1\n-22 -1\n-37 -2", "output": "21\n"}, {"input": "5\n-1 -1\n23 2\n4 -11\n-25 -1\n-1 -1", "output": "32\n"}, {"input": "5\n-1 -1\n23 2\n7 -11\n-25 0\n-1 -1", "output": "29\n"}, {"input": "5\n-1 -1\n39 2\n7 -11\n-25 0\n-1 -1", "output": "43\n"}, {"input": "5\n-2 -1\n39 2\n19 -22\n-7 0\n-3 -...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nToday is Chef's birthday. His mom gifted him a truly lovable gift, a permutation of first N positive integers.\n\nShe placed the permutation on a very long table in front of Chef and left it for him to play with it. But as there was a ...
[{"input": "2\n0 2\n1 3\n11 -1\n2", "output": "Chef\nChef\n"}, {"input": "2\n0 2\n0 3\n11 -1\n2", "output": "Chef\nChef\n"}, {"input": "2\n0 2\n0 3\n11 -2\n2", "output": "Chef\nChef\n"}, {"input": "2\n3 2\n1 4\n13 1\n1", "output": "Chef\nChef\n"}, {"input": "2\n3 2\n1 4\n25 1\n1", "output": "Chef\nChef\n"}, {"input": "...
code_stdio
[ { "content": "Find the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^9\n - N is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n----...
[{"input": "1205711547", "output": "1205686729\n"}, {"input": "1258489257", "output": "1258475625\n"}, {"input": "1044195797", "output": "1044194596\n"}, {"input": "271828182\n", "output": "271821169\n"}, {"input": "115087508", "output": "115068529\n"}, {"input": "167542739", "output": "167521249\n"}, {"input": "317532...
code_stdio
[ { "content": "You are given a string $s$ of length $n$ consisting of characters a and/or b.\n\nLet $\\operatorname{AB}(s)$ be the number of occurrences of string ab in $s$ as a substring. Analogically, $\\operatorname{BA}(s)$ is the number of occurrences of ba in $s$ as a substring.\n\nIn one step, you can choo...
[{"input": "1\naaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbab\n", "output": "baaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbab\n"}, {"input": "1\nabbabababbabababbababbbabbbbabbbabaabaabba\n", "output": "abbabababbabababbababbbabbbbabbbabaabaabba\n"}, {"input": "1\nabbabababbabababbababbbabbbbabbbabaabaabba\n", "output": "abbabab...
code_stdio
[ { "content": "Patrick likes to play baseball, but sometimes he will spend so many hours hitting home runs that his mind starts to get foggy! Patrick is sure that his scores across $n$ sessions follow the identity permutation (ie. in the first game he scores $1$ point, in the second game he scores $2$ points and...
[{"input": "5\n5\n1 3 4 2 5\n4\n2 1 3 4\n5\n2 1 3 5 4\n7\n3 2 4 1 5 7 6\n6\n3 2 1 6 5 4\n", "output": "1\n1\n2\n2\n2\n"}, {"input": "5\n5\n1 3 4 2 5\n4\n2 1 3 4\n5\n2 1 3 5 4\n7\n3 2 4 1 5 7 6\n6\n3 2 1 6 5 1\n", "output": "1\n1\n2\n2\n2\n"}, {"input": "5\n5\n1 3 4 2 5\n4\n2 1 3 4\n5\n2 1 3 5 4\n7\n3 1 4 1 5 7 6\n6\n3 ...
code_stdio
[ { "content": "One day Sasha visited the farmer 2D and his famous magnetic farm. On this farm, the crop grows due to the influence of a special magnetic field. Maintaining of the magnetic field is provided by $n$ machines, and the power of the $i$-th machine is $a_i$. \n\nThis year 2D decided to cultivate a new ...
[{"input": "166\n61 19 19 67 11 11 73 89 73 11 47 2 59 43 61 31 19 83 71 19 29 97 89 97 2 11 5 73 19 2 19 7 41 53 5 23 11 89 2 23 47 47 83 71 17 71 67 67 43 3 29 97 17 83 11 19 67 17 97 7 19 29 29 41 13 71 29 19 19 43 47 17 71 3 13 71 41 19 47 7 29 43 29 97 31 11 43 17 23 83 37 61 79 31 17 5 59 13 67 29 29 11 43 67 89 ...
code_stdio
[ { "content": "It is raining heavily. But this is the first day for Serval, who just became 3 years old, to go to the kindergarten. Unfortunately, he lives far from kindergarten, and his father is too busy to drive him there. The only choice for this poor little boy is to wait for a bus on this rainy day. Under ...
[{"input": "37 99816\n19935 98486\n13473 97526\n12932 94864\n12400 98868\n13485 96232\n10902 93340\n10315 93206\n14926 98755\n13524 99060\n10391 94409\n14740 94040\n16968 94901\n18543 98563\n16376 96008\n16802 95903\n19742 97400\n10380 97416\n13674 91688\n16347 99505\n17541 91909\n19573 93640\n11353 96027\n10659 99302\...
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\n"}, {"input": "10\n8 2 10 3 4 6 1 7 9 5\n8 2 10 3 4 6 1 7 9 5\n", "output": "0\n"}, {"input": "10\n2 1 10 3 7 8 5 6 9 4\n6 9 2 4 1 10 3 7 8 5\n", "output": "3\n"}, {"input": "10\n1 6...
code_stdio
[ { "content": "It’s still hot every day, but September has already come. It’s autumn according to the calendar. Looking around, I see two red dragonflies at rest on the wall in front of me. It’s autumn indeed.\n\nWhen two red dragonflies’ positional information as measured from the end of the wall is given, make...
[{"input": "-7 1028", "output": "1035\n"}, {"input": "-2 1028", "output": "1030\n"}, {"input": "-2 1094", "output": "1096\n"}, {"input": "-2 1349", "output": "1351\n"}, {"input": "-3 1349", "output": "1352\n"}, {"input": "-3 1765", "output": "1768\n"}, {"input": "-3 1569", "output": "1572\n"}, {"input": "-125 1", "outp...
code_stdio
[ { "content": "Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an assistant.\n\nShop, where Noora is working, has a plan on the following n days. Fo...
[{"input": "50 2\n74 90\n68 33\n49 88\n52 13\n73 21\n77 63\n27 62\n8 52\n60 57\n42 83\n98 15\n79 11\n77 46\n55 91\n72 100\n70 86\n50 51\n57 39\n20 54\n64 95\n66 22\n79 64\n31 28\n11 89\n1 36\n13 4\n75 62\n16 62\n100 35\n43 96\n97 54\n86 33\n62 63\n94 24\n19 6\n20 58\n38 38\n11 76\n70 40\n44 24\n32 96\n28 100\n62 45\n41...
code_stdio
[ { "content": "Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit...
[{"input": "100\n1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 1 1 0 0 1 0 0 1 1 0 1 1 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 0 0 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 0\n", "output": "1446\n"}, {"input": "100\n1 1 0 0 1 1 1 1 0 1 1 1 0 1 1 1 0 0 0 0 0 0 1 1 0 1 0 0 0 0 1 ...
code_stdio
[ { "content": "Shichi-Go-San (literally \"Seven-Five-Three\") is a traditional event in a certain country to celebrate the growth of seven-, five- and three-year-old children.\nTakahashi is now X years old. Will his growth be celebrated in Shichi-Go-San this time?\n\n-----Constraints-----\n - 1 ≀ X ≀ 9\n - X is ...
[{"input": "-132", "output": "NO\n"}, {"input": "-154", "output": "NO\n"}, {"input": "-133", "output": "NO\n"}, {"input": "-108", "output": "NO\n"}, {"input": "1271", "output": "NO\n"}, {"input": "5\n", "output": "YES\n"}, {"input": "3\n", "output": "YES\n"}, {"input": "7\n", "output": "YES\n"}, {"input": "-12", "outpu...
code_stdio
[ { "content": "Two students of AtCoder Kindergarten are fighting over candy packs.\nThere are three candy packs, each of which contains a, b, and c candies, respectively.\nTeacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whethe...
[{"input": "10 30 20\n", "output": "Yes\n"}, {"input": "30 30 100\n", "output": "No\n"}, {"input": "56 25 31\n", "output": "Yes\n"}, {"input": "30 30 000", "output": "Yes\n"}, {"input": "106 25 31", "output": "No\n"}, {"input": "30 47 100", "output": "No\n"}, {"input": "30 26 100", "output": "No\n"}, {"input": "30 16 1...
code_stdio
[ { "content": "ΠšΠ°Ρ€Ρ‚Π° Π·Π²Ρ‘Π·Π΄Π½ΠΎΠ³ΠΎ Π½Π΅Π±Π° прСдставляСт собой ΠΏΡ€ΡΠΌΠΎΡƒΠ³ΠΎΠ»ΡŒΠ½ΠΎΠ΅ ΠΏΠΎΠ»Π΅, состоящСС ΠΈΠ· n строк ΠΏΠΎ m символов Π² ΠΊΠ°ΠΆΠ΄ΠΎΠΉ строкС. ΠšΠ°ΠΆΠ΄Ρ‹ΠΉ символ — это Π»ΠΈΠ±ΠΎ Β«.Β» (ΠΎΠ·Π½Π°Ρ‡Π°Π΅Ρ‚ пустой участок Π½Π΅Π±Π°), Π»ΠΈΠ±ΠΎ Β«*Β» (ΠΎΠ·Π½Π°Ρ‡Π°Π΅Ρ‚ Ρ‚ΠΎ, Ρ‡Ρ‚ΠΎ Π² этом мСстС Π½Π° Π½Π΅Π±Π΅ Π΅ΡΡ‚ΡŒ Π·Π²Π΅Π·Π΄Π°). \n\nНовоС ΠΈΠ·Π΄Π°Π½ΠΈΠ΅ ΠΊΠ°Ρ€Ρ‚Ρ‹ Π·Π²Ρ‘Π·Π΄Π½ΠΎΠ³ΠΎ Π½Π΅Π±Π° Π±ΡƒΠ΄Π΅Ρ‚ Π½Π°ΠΏΠ΅Ρ‡Π°Ρ‚Π°Π½ΠΎ Π½Π° ΠΊΠ²Π°Π΄...
[{"input": "7 10\n..........\n......*...\n....**..*.\n...**.....\n...*......\n..........\n..**.*....\n", "output": "7\n"}, {"input": "3 9\n.........\n......*..\n.........\n", "output": "1\n"}, {"input": "5 5\n....*\n....*\n....*\n..*..\n..*.*\n", "output": "5\n"}, {"input": "5 5\n.....\n..*..\n*....\n.....\n.....\n", "...
code_stdio
[ { "content": "You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task.\n\nThe space station is made up with a number of units, called cells. All cells are sphere-shaped, but thei...
[{"input": "3\n10.428063836405636 10.000 50.41258054211165 10.000\n40.000 10.67607738240928 53.01420883969367 10.791354692497457\n40.998260752412115 40.51646067399203 50.343828752057796 10.89540561727416\n2\n30.571866538226903 30.21421585553614 30.992025805702255 20.557461946050214\n40.000 40.897526923182255 40.8505801...
code_stdio
[ { "content": "Obesity is cited as the cause of many adult diseases. In the past, with a few exceptions, it was unrelated to high school students. However, it is no longer unrealistic to suffer from lack of exercise due to excessive studying for entrance exams, or to become bulimia nervosa due to stress. It may ...
[{"input": "1011,50.0,1.60\n1002,60.1,0.70\n1003,60.0,0.80\n1004,80.0,1.71\n1005,90.0,1.60", "output": "1002\n1003\n1004\n1005\n"}, {"input": "1011,50.0,1.60\n1102,60.1,0.70\n1003,60.0,0.80\n1004,80.0,1.71\n1005,80.0,1.60", "output": "1102\n1003\n1004\n1005\n"}, {"input": "1011,50.0,1.61\n1072,60.0,1.00\n1003,70.8,1.00...
code_stdio
[ { "content": "On her way to programming school tiger Dasha faced her first test β€” a huge staircase! [Image] \n\nThe steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she ca...
[{"input": "100 100\n", "output": "YES\n"}, {"input": "100 100\n", "output": "YES\n"}, {"input": "100 101\n", "output": "YES\n"}, {"input": "110 111\n", "output": "YES\n"}, {"input": "111 111\n", "output": "YES\n"}, {"input": "100 99\n", "output": "YES\n"}, {"input": "99 100\n", "output": "YES\n"}, {"input": "100 99\n"...
code_stdio
[ { "content": "Takahashi is going to set a 3-character password.\nHow many possible passwords are there if each of its characters must be a digit between 1 and N (inclusive)?\n\n-----Constraints-----\n - 1 \\leq N \\leq 9\n - N is an integer.\n\n-----Input-----\nInput is given from Standard Input in the followin...
[{"input": "-109", "output": "-1295029\n"}, {"input": "-61", "output": "-226981\n"}, {"input": "-57", "output": "-185193\n"}, {"input": "-68", "output": "-314432\n"}, {"input": "-95", "output": "-857375\n"}, {"input": "-52", "output": "-140608\n"}, {"input": "-59", "output": "-205379\n"}, {"input": "148", "output": "32...
code_stdio
[ { "content": "Well, here is another math class task. In mathematics, GCD is the greatest common divisor, and it's an easy task to calculate the GCD between two positive integers.\n\nA common divisor for two positive numbers is a number which both numbers are divisible by.\n\nBut your teacher wants to give you a...
[{"input": "31607 999002449\n18\n31607 31607\n31606 31608\n31607 31608\n31606 31607\n31606 31606\n31608 31608\n1 31607\n1 31606\n1 31608\n1 1000000000\n31607 1000000000\n31606 1000000000\n31608 1000000000\n1000000000 1000000000\n1 1\n2 31606\n2 31607\n2 31608\n", "output": "31607\n31607\n31607\n31607\n-1\n-1\n31607\n1\...
code_stdio
[ { "content": "Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a contiquous subsequence.\n\n\n\nInput\n\nThe input consists of multiple datasets. Each data set consists of:\n\n\nn\na1\na2\n.\n.\nan...
[{"input": "7\n-4\n-4\n6\n14\n15\n-8\n-14\n13\n1\n0\n3\n2\n-3\n-1\n1\n1\n5\n3\n0\n-6\n2\n3\n1100\n-200\n145\n0", "output": "35\n12\n1100\n"}, {"input": "7\n-5\n-4\n6\n8\n15\n-6\n-12\n13\n1\n2\n3\n2\n-2\n-1\n1\n1\n3\n2\n0\n-4\n2\n3\n1100\n-200\n145\n0", "output": "29\n12\n1100\n"}, {"input": "7\n-5\n-4\n6\n8\n15\n-6\n-1...
code_stdio
[ { "content": "This problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points.\n\nManao decided to pursue a fighter's career. He decided to begin with an ongoing tourname...
[{"input": "40 3\n1 62395\n5 40319\n4 165445\n10 137479\n10 47829\n8 9741\n5 148106\n10 25494\n10 162856\n2 106581\n0 194523\n9 148086\n1 100862\n6 147600\n6 107486\n6 166873\n7 16721\n4 22192\n0 8827\n1 197146\n10 8949\n0 150443\n9 148348\n3 143935\n1 139371\n7 128821\n10 107760\n4 141821\n1 35852\n9 107522\n10 54717\...
code_stdio
[ { "content": "Bankopolis is an incredible city in which all the n crossroads are located on a straight line and numbered from 1 to n along it. On each crossroad there is a bank office.\n\nThe crossroads are connected with m oriented bicycle lanes (the i-th lane goes from crossroad ui to crossroad vi), the diffi...
[{"input": "10 7\n50\n4 7 655\n7 3 220\n3 5 15\n5 10 811\n10 1 490\n1 2 800\n7 10 200\n1 5 377\n1 4 656\n6 4 432\n3 7 563\n1 8 122\n2 9 777\n3 2 157\n5 8 912\n9 8 496\n9 2 740\n3 2 201\n6 7 653\n1 7 554\n6 9 660\n3 2 622\n6 10 227\n9 1 42\n2 6 346\n2 7 944\n3 10 654\n5 2 501\n1 6 786\n3 8 306\n6 1 998\n6 2 581\n10 1 84...
code_stdio
[ { "content": "Petya has an array $a$ consisting of $n$ integers. He wants to remove duplicate (equal) elements.\n\nPetya wants to leave only the rightmost entry (occurrence) for each element of the array. The relative order of the remaining unique elements should not be changed.\n\n\n-----Input-----\n\nThe firs...
[{"input": "48\n992 995 992 991 994 992 995 999 996 993 999 995 993 992 1000 992 568 996 991 993 992 998 998 998 999 995 992 992 993 992 992 995 996 995 997 991 997 991 999 994 994 997 1000 32 1000 992 1000 999\n", "output": "12\n568 998 993 996 995 991 994 997 32 992 1000 999\n"}, {"input": "49\n991 997 995 991 995 99...
code_stdio
[ { "content": "We have A balls with the string S written on each of them and B balls with the string T written on each of them.\n\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\n\nFind the number of balls with the string S and balls with the string T that we have now...
[{"input": "abcdeabcde opqrsopqrs\n7 2\nabcdeabcde\n", "output": "6 2\n"}, {"input": "airport door\n5 5\nairport\n", "output": "4 5\n"}, {"input": "length depth\n3 1\nlength\n", "output": "2 1\n"}, {"input": "tea coffee\n4 4\ncoffee\n", "output": "4 3\n"}, {"input": "rice bread\n3 6\nbread\n", "output": "3 5\n"}, {"inp...
code_stdio
[ { "content": "Let \\mathrm{popcount}(n) be the number of `1`s in the binary representation of n. For example, \\mathrm{popcount}(3) = 2, \\mathrm{popcount}(7) = 3, and \\mathrm{popcount}(0) = 0.\n\nLet f(n) be the number of times the following operation will be done when we repeat it until n becomes 0: \"replac...
[{"input": "23\n00110111001011011001111", "output": "3\n3\n2\n2\n3\n3\n2\n3\n3\n3\n2\n2\n3\n2\n2\n2\n2\n3\n2\n3\n3\n3\n2\n"}, {"input": "23\n00110111001011011101111", "output": "4\n4\n3\n3\n4\n3\n3\n3\n4\n4\n3\n4\n3\n3\n4\n3\n3\n3\n4\n3\n3\n3\n2\n"}, {"input": "23\n00110111001011011101101", "output": "3\n3\n2\n2\n3\n3\...
code_stdio
[ { "content": "The developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them. \n\nIn this problem an image is a rectangular table that consists of lowercase Latin letters. A f...
[{"input": "9 46\nuuexbaacesjclggslacermcbkxlcxhdgqtacdwfryxzuxc\naclrsaefakndbnzlkefenuphgcgoedhkaxefjtnkgfeaca\nefuqunpmfxdyyffyhvracozzrxlpekhtsrfhlilfmyhefg\numyacfzffvicqtdpiulefnwcojuwtfbvlxkfsiapdnzpqo\nactefvuxqptremlqjhdbdwacjxdxitxjktecvefacamjcz\neflarseklqrkayhosverpfefzirqigzlxezabhzeferkwm\nztpypwxyohtacs...
code_stdio
[ { "content": "Read problems statements in Russian also. \nChef likes playing with strings. The most interesting game are named \"CHEF in string\". The move of the game consists of the following: Chef takes a subsequence of string's letters that form the word \"CHEF\" and then he removes that symbols. The goal o...
[{"input": "CHEFCHEFFFF\n", "output": "2"}, {"input": "CIEFCHEFFFF", "output": "1\n"}, {"input": "BHHHEEFFFCC", "output": "0\n"}, {"input": "CHEFCHEFGFF", "output": "2\n"}, {"input": "CHHHEEFFFCC", "output": "1\n"}, {"input": "FIEFCHECFFF", "output": "1\n"}, {"input": "FJEFCHECFFF", "output": "1\n"}, {"input": "BHIHEEF...
code_stdio
[ { "content": "F: Grid number\n\nproblem\n\nEbi-chan is trying to write exactly one integer from 1 to 2 \\ times n in a grid with n columns horizontally and 2 rows vertically.\n\nOnly one integer can be written to each cell in the grid.\n\nIt's not fun just to write normally, so I set the following rules.\n\n* T...
[{"input": "8 10 37", "output": "24\n"}, {"input": "5 4 11", "output": "10\n"}, {"input": "5 3 17", "output": "16\n"}, {"input": "5 4 18", "output": "14\n"}, {"input": "8 6 37", "output": "21\n"}, {"input": "8 6 42", "output": "34\n"}, {"input": "8 6 39", "output": "37\n"}, {"input": "8 6 77", "output": "13\n"}, {"inpu...
code_stdio
[ { "content": "There are two main kinds of events in the life of top-model: fashion shows and photo shoots. Participating in any of these events affects the rating of appropriate top-model. After each photo shoot model's rating increases by a and after each fashion show decreases by b (designers do too many expe...
[{"input": "10 1 1 1 2 0 10\n1 1\n2 1\n3 0\n4 0\n5 1\n6 1\n14 1\n8 1\n9 1\n10 1\n", "output": "5\n"}, {"input": "10 1 1 1 2 0 10\n1 1\n2 1\n3 0\n4 0\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n", "output": "5\n"}, {"input": "10 1 1 1 2 0 10\n1 1\n2 1\n3 0\n4 0\n5 1\n6 1\n7 1\n8 1\n5 1\n10 1\n", "output": "5\n"}, {"input": "5 1 1 -...
code_stdio
[ { "content": "The goddess of programming is reviewing a thick logbook, which is a yearly record of visitors to her holy altar of programming. The logbook also records her visits at the altar.\n\nThe altar attracts programmers from all over the world because one visitor is chosen every year and endowed with a gi...
[{"input": "14\n04/21 09:00 I 000\n04/21 09:00 I 001\n04/21 09:15 I 002\n04/21 90:30 O 001\n04/21 09:45 O 000\n12/40 10:00 O 002\n04/28 09:00 I 003\n04/28 09:15 I 000\n04/28 09:30 I 004\n04/28 09:45 P 004\n04/28 10:00 O 000\n04/28 10:15 O 003\n04/29 20:00 I 002\n04/29 21:30 O 002\n20\n06/01 09:00 I 001\n06/01 09:15 I 0...
code_stdio
[ { "content": "Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from left to right.\n\nOnce Vasya chose one of the boxes, let's assume that its number is i, took all balls out from it (it is guaranteed that this box originally had at least one b...
[{"input": "48 19\n227460648 746912227 51958075 682685526 1080381698 666833118 492590399 167395932 678377837 125106811 638633256 713194370 386921921 34175133 704550052 220688092 499436761 495071386 57379330 137372655 0 720974146 209203457 946682102 237312198 943872065 957150897 357568282 367006748 0 730509325 68523190 ...
code_stdio
[ { "content": "Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers $1$, $5$, $10$ and $50$ respectively. The use of other roman digits is not allowed.\n\nNumbers in this system are written as a sequence of one or more digits. We define the...
[{"input": "1000000000\n", "output": "48999999753\n"}, {"input": "1000000001\n", "output": "48999999802\n"}, {"input": "1897400395\n", "output": "92972619108\n"}, {"input": "1100000001\n", "output": "53899999802\n"}, {"input": "1533257378\n", "output": "75129611275\n"}, {"input": "1100000011\n", "output": "53900000292\...
code_stdio
[ { "content": "There is a puzzle to complete by combining 14 numbers from 1 to 9. Complete by adding another number to the given 13 numbers.\n\nThe conditions for completing the puzzle are\n\n* You must have one combination of the same numbers.\n* The remaining 12 numbers are 4 combinations of 3 numbers.\nThe co...
[{"input": "3649596966777\n4672433573317\n9118992346175\n9643871425498\n7755542764533\n1133557799246", "output": "2 3 5 8\n1 2 4 5 7\n1 2 3 4 5 6 7 8 9\n7 8 9\n1 2 3 4 6 7 8\n0\n"}, {"input": "3649596966777\n4672433573317\n9118992346175\n9643871425498\n7755542764533\n1079549632139", "output": "2 3 5 8\n1 2 4 5 7\n1 2 3...
code_stdio
[ { "content": "You are given a positive integer $m$ and two integer sequence: $a=[a_1, a_2, \\ldots, a_n]$ and $b=[b_1, b_2, \\ldots, b_n]$. Both of these sequence have a length $n$.\n\nPermutation is a sequence of $n$ different positive integers from $1$ to $n$. For example, these sequences are permutations: $[...
[{"input": "20 1000000000\n667066860 170421783 139902912 635488786 31946329 289281524 541340760 264115900 680775010 102068388 128171043 636359373 477042326 879154458 716982402 654668379 256334407 874949294 737194458 663371809\n688973261 813186249 677241392 581016678 216137209 424019643 428224807 184559135 203738728 185...
code_stdio
[ { "content": "Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if:\n\n * the Euclidean distance between A and B is one unit and neither A nor B is blocked; \n...
[{"input": "18855321\n", "output": "106661800\n"}, {"input": "34609610\n", "output": "195781516\n"}, {"input": "40000000\n", "output": "226274168\n"}, {"input": "38450759\n", "output": "217510336\n"}, {"input": "39099999\n", "output": "221182992\n"}, {"input": "30426905\n", "output": "172120564\n"}, {"input": "39999996...
code_stdio
[ { "content": "Polycarpus participates in a competition for hacking into a new secure messenger. He's almost won.\n\nHaving carefully studied the interaction protocol, Polycarpus came to the conclusion that the secret key can be obtained if he properly cuts the public key of the application into two parts. The p...
[{"input": "284254589153928171911281811000\n1009 1000\n", "output": "YES\n2842545891539\n28171911281811000\n"}, {"input": "284254589153928171911281811000\n1009 1100\n", "output": "YES\n2842545891539\n28171911281811000\n"}, {"input": "284254589153928171911281811000\n1009 1000\n", "output": "YES\n2842545891539\n281719112...
code_stdio
[ { "content": "AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code.\n\nThe company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code.\n\nHow many different PIN co...
[{"input": "19\n5546189040285140044", "output": "273\n"}, {"input": "19\n4753841743850076999", "output": "311\n"}, {"input": "19\n9039528710159876563", "output": "412\n"}, {"input": "19\n3616863455241776042", "output": "322\n"}, {"input": "19\n2785343766571511696", "output": "239\n"}, {"input": "19\n2922045480066417189...
code_stdio
[ { "content": "Bob is about to take a hot bath. \n\nThere are two taps to fill the bath: a hot water tap and a cold water tap. The cold water's temperature is t1, and the hot water's temperature is t2. The cold water tap can transmit any integer number of water units per second from 0 to x1, inclusive. Similarly...
[{"input": "1000000 1000000 1000000 1000000 1000000\n", "output": "1000000 1000000\n"}, {"input": "1000000 1000000 999999 999998 1000000\n", "output": "999999 999998\n"}, {"input": "176902 1481077 847541 412251 587604\n", "output": "616526 283398\n"}, {"input": "1000000 1001000 1000000 1000000 1000000\n", "output": "10...
code_stdio
[ { "content": "Arkady and his friends love playing checkers on an $n \\times n$ field. The rows and the columns of the field are enumerated from $1$ to $n$.\n\nThe friends have recently won a championship, so Arkady wants to please them with some candies. Remembering an old parable (but not its moral), Arkady wa...
[{"input": "1000000000 1\n", "output": "1000000000000000000\n"}, {"input": "1000000000 1000\n", "output": "3400000000000000\n"}, {"input": "1100000000 1000\n", "output": "4114000000000000\n"}, {"input": "1000010000 1\n", "output": "1000020000100000000\n"}, {"input": "1100010000 1000\n", "output": "4114074800340000\n"},...
code_stdio
[ { "content": "You are given a rectangular matrix of size $n \\times m$ consisting of integers from $1$ to $2 \\cdot 10^5$.\n\nIn one move, you can: choose any element of the matrix and change its value to any integer between $1$ and $n \\cdot m$, inclusive; take any column and shift it one cell up cyclically ...
[{"input": "7 8\n110137 66175 74657 124739 63011 153464 30956 8\n9 62369 169892 183765 84737 20941 35760 132079\n20802 67434 149925 53269 150062 35286 50218 112696\n153864 26 7405 121648 170439 115181 195278 127323\n136381 197880 57522 109132 104537 38 39 47930\n51739 77547 43 169711 18955 134957 7223 37489\n53153 1084...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian. \n\nAditi recently discovered a new magic trick. First, she gives you an integer N and asks you to think an integer between 1 and N. Then she gives you a bundle of cards each having a sorted list (in ascending order) of some distinct integ...
[{"input": "2\n12\n191", "output": "5\n11\n"}, {"input": "2\n14\n108", "output": "6\n10\n"}, {"input": "2\n21\n114", "output": "7\n10\n"}, {"input": "2\n25\n193", "output": "7\n11\n"}, {"input": "2\n38\n107", "output": "8\n10\n"}, {"input": "2\n14\n204", "output": "6\n11\n"}, {"input": "2\n25\n333", "output": "7\n12\n"...
code_stdio
[ { "content": "You are given an undirected connected weighted graph consisting of $n$ vertices and $m$ edges. Let's denote the length of the shortest path from vertex $1$ to vertex $i$ as $d_i$. \n\nYou have to erase some edges of the graph so that at most $k$ edges remain. Let's call a vertex $i$ good if there ...
[{"input": "9 9 7\n1 2 1000000000\n7 9 1000000000\n9 4 1000000000\n2 6 1000000000\n2 3 1000000000\n3 7 1000000000\n6 8 1000000000\n8 4 1000000000\n4 5 1000000000\n", "output": "7\n1 5 4 6 7 8 2 \n"}, {"input": "9 9 7\n1 2 1000000000\n7 9 1000000000\n9 4 1000000000\n2 6 1000000000\n2 3 1000000000\n3 7 1000000000\n6 8 10...
code_stdio
[ { "content": "Peter likes to travel by train. He likes it so much that on the train he falls asleep. \n\nOnce in summer Peter was going by train from city A to city B, and as usual, was sleeping. Then he woke up, started to look through the window and noticed that every railway station has a flag of a particula...
[{"input": "aababaaababaabbaabababaaababaabababbaabbabaabababaabbabbbababbababababababaabababaababaaaabababaabab\nabaabababaa\nabaabbaa\n", "output": "backward\n"}, {"input": "aababaaababaabbaabababaaababaabababbaabbabaabababaabbabbbababbababababababaabababaababaaaabababaabab\nabaabababaa\naabbaaba\n", "output": "backw...
code_stdio
[ { "content": "A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is a pair of indices (i, j) such that i > j and a_{i} < a_{j}. For example, a permutation [4, 1, 3, 2] contains 4 inversions: (2, 1), (3, 1), (4, 1), ...
[{"input": "1\n1\n10\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "even\neven\neven\neven\neven\neven\neven\neven\neven\neven\n"}, {"input": "1\n1\n10\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "even\neven\neven\neven\neven\neven\neven\neven\neven\neven\n"}, {"input": "7\n2 6 1 7...
code_stdio
[ { "content": "Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come up with the following extravagant algorithm.\...
[{"input": "12 12\n10\n11\n5\n3\n11\n2\n8\n6\n4\n4\n12\n1\n", "output": "9\n6\n3\n2\n6\n7\n12\n8\n10\n10\n11\n1\n"}, {"input": "12 12\n9\n11\n5\n3\n11\n2\n8\n4\n4\n4\n12\n1\n", "output": "5\n6\n3\n2\n6\n7\n12\n10\n10\n10\n11\n1\n"}, {"input": "12 12\n9\n11\n5\n3\n11\n2\n8\n6\n4\n4\n12\n1\n", "output": "5\n6\n3\n2\n6\n7...
code_stdio
[ { "content": "A and B are preparing themselves for programming contests.\n\nThe University where A and B study is a set of rooms connected by corridors. Overall, the University has n rooms connected by n - 1 corridors so that you can get from any room to any other one by moving along the corridors. The rooms ar...
[{"input": "15\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n5 8\n6 9\n9 14\n14 15\n7 10\n4 13\n3 11\n3 12\n6\n10 15\n13 12\n2 15\n8 4\n15 12\n6 13\n", "output": "1\n10\n1\n7\n0\n4\n"}, {"input": "15\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n5 8\n6 9\n9 14\n14 15\n7 10\n4 13\n4 11\n3 12\n6\n10 15\n13 12\n2 15\n8 4\n15 12\n6 13\n", "output": "1\...
code_stdio
[ { "content": "This is an easy version of the problem. The only difference between an easy and a hard version is in the number of queries.\n\nPolycarp grew a tree from $n$ vertices. We remind you that a tree of $n$ vertices is an undirected connected graph of $n$ vertices and $n-1$ edges that does not contain cy...
[{"input": "19\n15 19\n19 1\n12 19\n18 9\n13 19\n4 18\n19 11\n19 17\n5 9\n14 19\n8 19\n19 6\n16 9\n19 7\n3 19\n19 9\n19 10\n9 2\n5\n19\n11 12 18 14 2 3 16 15 4 17 8 9 19 1 10 13 7 6 5\n12\n1 2 4 5 7 8 9 12 13 14 15 16\n19\n5 17 2 19 1 18 7 12 15 14 4 9 16 10 11 3 13 8 6\n12\n2 3 4 5 6 7 9 10 12 14 16 18\n19\n8 10 18 1 ...
code_stdio
[ { "content": "Limak is a little polar bear. He loves connecting with other bears via social networks. He has n friends and his relation with the i-th of them is described by a unique integer t_{i}. The bigger this value is, the better the friendship is. No two friends have the same value t_{i}.\n\nSpring is sta...
[{"input": "20 2 15\n1744261 55128070 116962690 156763505 188535242 194018601 134662359 428710623 442819431 483000923 516768937 552903993 633087286 373594646 415184994 714291344 717660646 846508634 879748146 937368929\n2 20\n1 2\n2 2\n1 19\n1 12\n2 2\n2 18\n2 11\n1 16\n2 1\n2 3\n2 19\n1 17\n2 9\n2 6\n", "output": "NO\n...
code_stdio
[ { "content": "For a given sequence $A = \\\\{a_0, a_1, ... a_{n-1}\\\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\n\nbubbleSort(A)\ncnt = 0 // the n...
[{"input": "5\n3 -13 7 -1 -4", "output": "6\n"}, {"input": "5\n3 -13 10 0 -4", "output": "6\n"}, {"input": "5\n3 -13 10 0 -5", "output": "6\n"}, {"input": "5\n2 -13 10 0 -5", "output": "6\n"}, {"input": "5\n2 -13 10 0 -1", "output": "6\n"}, {"input": "5\n0 -13 10 0 -1", "output": "5\n"}, {"input": "5\n0 -13 17 0 -1", "...
code_stdio
[ { "content": "There are $n$ detachments on the surface, numbered from $1$ to $n$, the $i$-th detachment is placed in a point with coordinates $(x_i, y_i)$. All detachments are placed in different points.\n\nBrimstone should visit each detachment at least once. You can choose the detachment where Brimstone start...
[{"input": "23\n-1000000000 -964752353\n-967012509 -1000000000\n34021744 1000000000\n-931956512 -34021744\n-1034253 967204159\n-1034253 -34021744\n-1034253 -1000000000\n-931956512 -1000000000\n-967012509 1000000000\n964944003 1225903\n1000000000 1225903\n-967012509 1225903\n-1034253 -964752353\n-931956512 1000000000\n3...
code_stdio
[ { "content": "You are given an array $a$ consisting of $n$ integers $a_1, a_2, \\dots, a_n$. You want to split it into exactly $k$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is imposs...
[{"input": "3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 1\n6 3\n3 1 1 4 10 0\n", "output": "YES\n1 3 5\nNO\nYES\n1 2 6\n"}, {"input": "3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n3 1 8 4 10 2\n", "output": "YES\n1 3 5\nNO\nYES\n1 6\n"}, {"input": "3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 1\n6 2\n3 1 8 4 10 2\n", "output": "YES\n1 3 5\nNO...
code_stdio
[ { "content": "You've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:\n\n 1. First we build by the array a an array s of partial sums, consisting of n elements. Element number i (1 ≀ i ≀ n) of array s equals <image>. The opera...
[{"input": "42 42\n42 42 42 42 74 42 42 42 3 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 59 42 42 42 42 42\n", "output": "42 1806 39732 595980 6853802 64426782 515432400 608248315 553670947 820980301 784579711 753219887 714714707 805611691 208784644 262712997 126286707 369857538 724...
code_stdio
[ { "content": "A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R.\nTakahashi placed a mass of weight A and a mass of weight B on the left pan of a...
[{"input": "3 4 5 2\n", "output": "Balanced\n"}, {"input": "0 8 7 1", "output": "Balanced\n"}, {"input": "4 3 5 2", "output": "Balanced\n"}, {"input": "8 3 8 3", "output": "Balanced\n"}, {"input": "12 6 33 2", "output": "Right\n"}, {"input": "19 6 33 2", "output": "Right\n"}, {"input": "19 6 59 2", "output": "Right\n"}...
code_stdio