messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 1000. \nIf the quantity and price per item are input, write a program to calculate the total expenses.\n\n------ Input Format ------ \n\nThe first line contains an integer T, total number of test ca... | [{"input": "3 \n100 120\n10 20\n1200 20\n", "output": "12000.000000\n200.000000\n21600.000000\n"}, {"input": "3 \n100 120\n10 20\n1200 40", "output": "12000.000000\n200.000000\n43200.000000\n"}, {"input": "3 \n100 215\n10 20\n1200 40", "output": "21500.000000\n200.000000\n43200.000000\n"}, {"input": "3 \n100 215\n10 20... | code_stdio |
[
{
"content": "One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the memory of his not less mean sister Hexadecimal. He loaded there a huge amount of n different natural numbers from 1 to n to obtain total control over her energy.\n\nBut his plan faile... | [{"input": "1000000000\n", "output": "512\n"}, {"input": "999999999\n", "output": "511\n"}, {"input": "121212121\n", "output": "511\n"}, {"input": "101010101\n", "output": "341\n"}, {"input": "901556123\n", "output": "511\n"}, {"input": "312410141\n", "output": "511\n"}, {"input": "111111111\n", "output": "511\n"}, {"i... | code_stdio |
[
{
"content": "You are given $n$ lengths of segments that need to be placed on an infinite axis with coordinates.\n\nThe first segment is placed on the axis so that one of its endpoints lies at the point with coordinate $0$. Let's call this endpoint the \"start\" of the first segment and let's call its \"end\" a... | [{"input": "6\n2\n1 3\n3\n1 2 3\n4\n1 2 3 14\n4\n6 12 4 14\n7\n1 2 4 9 7 10 3\n8\n8 6 0 3 3 4 3 6\n", "output": "3\n3\n14\n16\n12\n8\n"}, {"input": "6\n2\n1 3\n3\n1 2 3\n4\n1 2 3 14\n4\n6 8 4 14\n7\n1 2 4 9 13 10 3\n8\n8 6 0 3 3 4 3 6\n", "output": "3\n3\n14\n14\n13\n8\n"}, {"input": "6\n2\n1 3\n3\n1 2 3\n4\n1 2 3 14\n... | code_stdio |
[
{
"content": "Here is a very simple variation of the game backgammon, named “Minimal Backgammon”. The game is played by only one player, using only one of the dice and only one checker (the token used by the player).\n\nThe game board is a line of (N + 1) squares labeled as 0 (the start) to N (the goal). At the... | [{"input": "10 1 0 0\n7 1 0 0\n13 0 0 0\n6 11 1 1\n2\n5\n7 1 0 6\n1\n1\n3\n4\n5\n6\n0 0 0 0", "output": "0.000000\n0.000000\n0.000000\n0.829031\n0.000000\n"}, {"input": "6 1 0 0\n7 1 0 0\n7 2 0 0\n12 3 1 1\n2\n5\n8 10 0 6\n1\n3\n4\n4\n5\n6\n0 0 0 0", "output": "0.166667\n0.000000\n0.166667\n0.106481\n0.229136\n"}, {"in... | code_stdio |
[
{
"content": "There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time... | [{"input": "12814", "output": "160\n"}, {"input": "19710", "output": "199\n"}, {"input": "36877", "output": "272\n"}, {"input": "49568", "output": "315\n"}, {"input": "44971", "output": "300\n"}, {"input": "34941", "output": "264\n"}, {"input": "27935", "output": "236\n"}, {"input": "43035", "output": "293\n"}, {"input... | code_stdio |
[
{
"content": "The only difference between the easy and the hard versions is constraints.\n\nA subsequence is a string that can be derived from another string by deleting some or no symbols without changing the order of the remaining symbols. Characters to be deleted are not required to go successively, there ca... | [{"input": "100 1000000000100\ndjgykfqaywhkhpocyxcpvbiiouyielmighclnuopadzuvrirbecucwnzwahahagvfstbxxaednajfauscxwttiglbbxtomnnalcl\n", "output": "8854753826235\n"}, {"input": "100 1000000000000\ndjgykfqaywhkhpocyxcpvbiiouyielmighclnuopadzuvrirbecucwnzwahahagvfstbxxaednajfauscxwttiglbbxtomnnalcl\n", "output": "88547538... | code_stdio |
[
{
"content": "Input\n\nThe input is given from standard input in the following format.\n\n\n> $H \\ W$ $a_{1, 1} \\ a_{1, 2} \\ \\cdots \\ a_{1, W}$ $a_{2, 1} \\ a_{2, 2} \\ \\cdots \\ a_{2, W}$ $\\vdots \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\vdots \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\vdots$ $a_{H, 1} \\ a_{H, 2} \\ \\cdot... | [{"input": "4 6\n2 3 3 8 2 3\n11 8 9 0 2 0\n0 1 0 1 8 5\n3 10 3 5 9 27\n0 1 1 -1 2 4\n2 19 1 12 1 15", "output": "107\n"}, {"input": "4 6\n2 3 3 7 1 3\n11 8 9 0 2 0\n0 1 4 1 8 5\n3 10 3 5 9 14\n0 1 1 0 2 2\n2 19 1 12 1 10", "output": "96\n"}, {"input": "6 6\n2 2 3 4 3 3\n8 8 9 -1 4 0\n0 1 14 1 5 9\n2 6 2 2 5 9\n2 15 1 ... | code_stdio |
[
{
"content": "Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can c... | [{"input": "53 3\n1 3 4 4 5 7 10 14 19 25 32 40 23 59 70 82 148 109 124 140 157 175 194 214 235 257 280 304 329 355 382 410 439 469 500 532 565 599 634 670 388 745 784 824 865 907 950 994 1039 1085 1132 1180 1229\n1 2 40\n", "output": "0\n"}, {"input": "53 3\n1 3 4 4 5 7 10 14 19 10 32 40 23 59 70 82 148 109 124 140 15... | code_stdio |
[
{
"content": "A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.\n\nThe fare is constructed in the following manner. There are three types ... | [{"input": "10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n", "output": "20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n"}, {"input": "10\n11\n45\n46\n60\n103\n115\n126\n150\n256\n516\n", "output": "20\n20\n10\n0\n20\n0\n0\n20\n20\n10\n"}, {"input": "10\n13\n45\n46\n60\n103\n115\n126\n150\n256\n516\n", "output": "20\n20\n10\n... | code_stdio |
[
{
"content": "During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals.\n\nGrisha needs to obtain some yellow, green and blue balls. It's known that to produce a yellow ba... | [{"input": "1000000000 1000000000\n1000000000 1000000000 1000000000\n", "output": "5000000000\n"}, {"input": "1000000000 1000000000\n1000000000 1000000000 1000000000\n", "output": "5000000000\n"}, {"input": "1000000000 1000000000\n1000100000 1000000000 1000000000\n", "output": "5000200000\n"}, {"input": "1000000000 101... | code_stdio |
[
{
"content": "We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contain some amount of sand.\nWhen we put the sandglass, either bulb A or B lies on top of the other and becomes the upper bulb. The other bulb becomes the lower bulb.\nThe sand drops from the upper bulb to the lower bulb ... | [{"input": "100\n5\n48 141 231 554 425\n7\n0 19\n50 98\n143 30\n231 55\n342 0\n365 100\n600 10", "output": "19\n52\n91\n10\n100\n100\n100\n"}, {"input": "100\n5\n48 179 142 554 425\n7\n0 19\n50 98\n143 30\n231 55\n342 0\n365 100\n600 9", "output": "19\n52\n95\n100\n100\n100\n100\n"}, {"input": "100\n5\n48 179 142 554 4... | code_stdio |
[
{
"content": "Encryption System\n\nA programmer developed a new encryption system. However, his system has an issue that two or more distinct strings are `encrypted' to the same string.\n\nWe have a string encrypted by his system. To decode the original string, we want to enumerate all the candidates of the str... | [{"input": "enw\nabc\nabcdefghijklmnopqrst\ny\n#", "output": "1\nfox\n5\nacc\nacd\nbbd\nbcc\nbcd\n17711\nacceeggiikkmmooqqssu\nacceeggiikkmmooqqstt\nacceeggiikkmmooqqstu\nacceeggiikkmmooqrrtt\nacceeggiikkmmooqrrtu\nbcdefghijklmnopqrrtt\nbcdefghijklmnopqrrtu\nbcdefghijklmnopqrssu\nbcdefghijklmnopqrstt\nbcdefghijklmnopqr... | code_stdio |
[
{
"content": "Astronaut Natasha arrived on Mars. She knows that the Martians are very poor aliens. To ensure a better life for the Mars citizens, their emperor decided to take tax from every tourist who visited the planet. Natasha is the inhabitant of Earth, therefore she had to pay the tax to enter the territo... | [{"input": "2 420\n412 363\n", "output": "420\n0 1 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 9... | code_stdio |
[
{
"content": "We have N bags numbered 1 through N and N dishes numbered 1 through N.\nBag i contains a_i coins, and each dish has nothing on it initially.\nTaro the first and Jiro the second will play a game against each other.\nThey will alternately take turns, with Taro the first going first.\nIn each player'... | [{"input": "3\n1\n10\n2\n1 2\n21\n476523737 103976339 266993 706803678 802362985 892644371 953855359 196462821 817301757 409460796 773943961 488763959 405483423 616934516 710762957 239829390 55474813 818352359 312280585 185800870 255245162\n", "output": "Second\nFirst\nSecond\n"}] | code_stdio |
[
{
"content": "You are given two integers A and B as the input. Output the value of A + B.\nHowever, if A + B is 10 or greater, output error instead.\n\n-----Constraints-----\n - A and B are integers.\n - 1 ≤ A, B ≤ 9\n\n-----Input-----\nInput is given from Standard Input in the following format:\nA B\n\n-----Ou... | [{"input": "-169 -1", "output": "-170\n"}, {"input": "-169 -2", "output": "-171\n"}, {"input": "-279 -2", "output": "-281\n"}, {"input": "-279 -1", "output": "-280\n"}, {"input": "-433 -1", "output": "-434\n"}, {"input": "-408 -1", "output": "-409\n"}, {"input": "-347 -1", "output": "-348\n"}, {"input": "-1 -139", "out... | code_stdio |
[
{
"content": "You have an array a[1], a[2], ..., a[n], containing distinct integers from 1 to n. Your task is to sort this array in increasing order with the following operation (you may need to apply it multiple times):\n\n choose two indexes, i and j (1 ≤ i < j ≤ n; (j - i + 1) is a prime number); swap the ... | [{"input": "100\n100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\n", "output... | code_stdio |
[
{
"content": "You are given a chessboard of size 1 × n. It is guaranteed that n is even. The chessboard is painted like this: \"BWBW...BW\".\n\nSome cells of the board are occupied by the chess pieces. Each cell contains no more than one chess piece. It is known that the total number of pieces equals to $\\frac... | [{"input": "100\n93 54 57 61 68 66 70 96 64 82 80 75 69 77 76 94 67 86 90 73 74 58 100 83 92 89 56 99 88 59 95 72 81 51 85 71 97 60 91 63 65 98 79 84 53 62 87 55 52 78\n", "output": "1225\n"}, {"input": "100\n93 54 57 61 68 66 70 96 64 82 80 75 69 77 76 94 67 86 90 73 74 58 100 83 92 89 56 99 88 59 95 72 81 51 85 71 97... | code_stdio |
[
{
"content": "Two players are playing a game. The game is played on a sequence of positive integer pairs. The players make their moves alternatively. During his move the player chooses a pair and decreases the larger integer in the pair by a positive multiple of the smaller integer in the pair in such a way tha... | [{"input": "3\n1\n2 5\n2\n4 10\n5 10\n2\n2 3\n1 5", "output": "YES\nYES\nYES\n"}, {"input": "3\n1\n1 5\n2\n4 10\n5 10\n2\n2 3\n1 5", "output": "YES\nYES\nYES\n"}, {"input": "3\n1\n1 3\n2\n4 10\n5 10\n2\n4 3\n3 5", "output": "YES\nYES\nYES\n"}, {"input": "3\n1\n2 4\n2\n10 5\n5 6\n1\n2 6\n5 0", "output": "YES\nYES\nYES\n... | code_stdio |
[
{
"content": "Assume that a, b, and n are all positive integers. Let f (i) be the i-th fraction of the fraction a / b (0 ≤ f (i) ≤ 9). At this time, let s be the sum of f (i) from i = 1 to n.\n\ns = f (1) + f (2) + ... + f (n)\n\n\nCreate a program that reads a, b, n, outputs s, and exits.\n\n\n\nInput\n\nThe i... | [{"input": "2 3 2\n2 7 3\n13 3 5\n4 6 2", "output": "12\n15\n15\n12\n"}, {"input": "1 3 2\n2 7 3\n13 3 5\n4 6 2", "output": "6\n15\n15\n12\n"}, {"input": "2 3 2\n2 7 3\n13 3 5\n4 4 2", "output": "12\n15\n15\n0\n"}, {"input": "2 3 2\n2 7 2\n13 3 5\n4 4 2", "output": "12\n10\n15\n0\n"}, {"input": "0 4 1\n2 3 2\n10 4 3\n5... | code_stdio |
[
{
"content": "A tree is a connected graph that doesn't contain any cycles.\n\nThe distance between two vertices of a tree is the length (in edges) of the shortest path between these vertices.\n\nYou are given a tree with n vertices and a positive number k. Find the number of distinct pairs of the vertices which... | [{"input": "50 3\n2 1\n3 2\n4 3\n5 4\n6 5\n7 6\n8 7\n9 8\n10 9\n11 10\n12 11\n13 12\n14 13\n15 14\n16 15\n17 16\n18 17\n19 18\n20 19\n21 20\n22 21\n23 22\n24 23\n25 24\n26 25\n27 26\n28 27\n29 28\n30 29\n31 30\n32 31\n33 32\n34 33\n35 34\n36 35\n37 36\n38 37\n39 38\n40 39\n41 40\n42 41\n43 42\n44 43\n45 44\n46 45\n47 4... | code_stdio |
[
{
"content": "At regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for same reason gave 3 candies to Valera in next turn.\n\nMore formally, the guys t... | [{"input": "1000000000 1000000000\n", "output": "Vladik\n"}, {"input": "1000000000 1000000000\n", "output": "Vladik\n"}, {"input": "1000000000 1387445955\n", "output": "Vladik\n"}, {"input": "1000000000 1000000001\n", "output": "Vladik\n"}, {"input": "1000000000 1214716107\n", "output": "Vladik\n"}, {"input": "10000000... | code_stdio |
[
{
"content": "Johnny has just found the new, great tutorial: \"How to become a grandmaster?\". The tutorial tells many strange and unexpected for Johnny things, such as you have to be patient or that very important is solving many harder and harder problems. \n\nThe boy has found an online judge with tasks divi... | [{"input": "1\n71 2\n100 99 98 97 96 95 94 93 92 91 90 87 86 82 79 78 76 71 70 69 68 66 64 63 62 56 55 53 52 51 50 46 43 42 39 38 37 35 33 31 30 29 22 20 19 18 11 7 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": "999999985\n"}, {"input": "1\n71 2\n100 99 98 97 96 95 94 93 92 91 90 87 86 82 79 78 36 71 70 6... | code_stdio |
[
{
"content": "You will turn on the air conditioner if, and only if, the temperature of the room is 30 degrees Celsius or above.\nThe current temperature of the room is X degrees Celsius. Will you turn on the air conditioner?\n\n-----Constraints-----\n - -40 \\leq X \\leq 40\n - X is an integer.\n\n-----Input---... | [{"input": "30\n", "output": "Yes\n"}, {"input": "40\n", "output": "Yes\n"}, {"input": "-40\n", "output": "No\n"}, {"input": "-29\n", "output": "No\n"}, {"input": "-30\n", "output": "No\n"}, {"input": "31\n", "output": "Yes\n"}, {"input": "-36\n", "output": "No\n"}, {"input": "32\n", "output": "Yes\n"}, {"input": "32\n... | code_stdio |
[
{
"content": "Two beavers, Timur and Marsel, play the following game.\n\nThere are n logs, each of exactly m meters in length. The beavers move in turns. For each move a beaver chooses a log and gnaws it into some number (more than one) of equal parts, the length of each one is expressed by an integer and is no... | [{"input": "1000000000 1000000000 1000000000\n", "output": "Marsel\n"}, {"input": "1000000000 1000000000 1100000000\n", "output": "Marsel\n"}, {"input": "999999999 1000000000 1000000000\n", "output": "Marsel\n"}, {"input": "999999999 1000000000 1000000100\n", "output": "Marsel\n"}, {"input": "1262564090 1000000000 5000... | code_stdio |
[
{
"content": "At the first holiday in spring, the town Shortriver traditionally conducts a flower festival. Townsfolk wear traditional wreaths during these festivals. Each wreath contains exactly k flowers.\n\nThe work material for the wreaths for all n citizens of Shortriver is cut from the longest flowered li... | [{"input": "100 15 6 10\n12 9 1 7 6 4 1 9 3 2 4 6 2 5 3 8 9 2 9 1 6 5 6 2 3 10 7 10 7 4 5 4 4 4 4 7 1 10 8 4 8 3 10 10 7 4 4 10 6 1 8 5 4 6 2 4 10 3 2 5 7 5 6 10 10 3 4 5 4 3 3 1 7 8 10 10 10 10 8 3 7 4 2 1 8 6 5 6 5 8 7 9 2 1 9 2 4 6 10 8\n6 9 7 8 7 1 4 5 5 8\n", "output": "9\n18 19 23 24 25 26 28 32 33 "}, {"input": ... | code_stdio |
[
{
"content": "Bakry faced a problem, but since he's lazy to solve it, he asks for your help.\n\nYou are given a tree of $n$ nodes, the $i$-th node has value $a_i$ assigned to it for each $i$ from $1$ to $n$. As a reminder, a tree on $n$ nodes is a connected graph with $n-1$ edges.\n\nYou want to delete at least... | [{"input": "5\n2 2\n1 3\n1 2\n5 5\n3 3 3 3 3\n1 2\n2 3\n1 4\n4 5\n5 2\n1 7 2 3 5\n1 2\n2 3\n1 4\n4 5\n5 3\n1 6 4 1 2\n1 2\n2 3\n1 4\n4 5\n3 3\n1 7 4\n1 2\n2 3\n", "output": "NO\nYES\nNO\nYES\nNO\n"}, {"input": "1\n9 3\n2 2 1 1 3 2 1 1 2\n1 2\n2 3\n2 4\n1 5\n1 6\n6 7\n6 8\n6 9\n", "output": "NO\n"}, {"input": "1\n8 3\n1... | code_stdio |
[
{
"content": "On a chessboard with a width of $10^9$ and a height of $10^9$, the rows are numbered from bottom to top from $1$ to $10^9$, and the columns are numbered from left to right from $1$ to $10^9$. Therefore, for each cell of the chessboard you can assign the coordinates $(x,y)$, where $x$ is the column... | [{"input": "0 5\n1 192023486 84774294\n243235878 312125306 50510976\n326016273 338641867 50510976\n570999440 445224816 125759940\n456157384 569789185 50510976\n", "output": "0\n"}, {"input": "0 5\n1 192023486 50510976\n243235878 312125306 50510976\n326016273 338641867 50510976\n570999440 445224816 50510976\n456157384 5... | code_stdio |
[
{
"content": "Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.\n\nConstraints\n\n* The number of characters in the sentence < 1200\n\nInput\n\nA sentence in English is given in several lines.\n\nOutput\n\nPrints the number of alphabetical letters in... | [{"input": "This is ` pen.", "output": "a : 0\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n"}, {"input": "This si a pen.", "output": "a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\... | code_stdio |
[
{
"content": "The string $s$ is given, the string length is odd number. The string consists of lowercase letters of the Latin alphabet.\n\nAs long as the string length is greater than $1$, the following operation can be performed on it: select any two adjacent letters in the string $s$ and delete them from the ... | [{"input": "5\nabcde\nc\nabcde\nb\nx\ny\naaaaaaaaaaaaaaa\na\ncontest\nt\n", "output": "YES\nNO\nNO\nYES\nYES\n"}, {"input": "5\nabcde\nc\nabcde\nb\nx\ny\nabobobussss\ns\ncontest\nt\n", "output": "YES\nNO\nNO\nYES\nYES\n"}, {"input": "1\nqwertyuioppoiuytrewqplkmnjiuhbs\nz\n", "output": "NO\n"}, {"input": "1\nadsfdxvxvsd... | code_stdio |
[
{
"content": "Andi and Budi were given an assignment to tidy up their bookshelf of $n$ books. Each book is represented by the book title — a string $s_i$ numbered from $1$ to $n$, each with length $m$. Andi really wants to sort the book lexicographically ascending, while Budi wants to sort it lexicographically ... | [{"input": "5 2\nAA\nAB\nBB\nBA\nAZ\n", "output": "5 2 1 3 4 \n"}, {"input": "5 2\nAA\nAB\nBB\nBA\nAZ\n", "output": "5 2 1 3 4\n"}, {"input": "5 2\nAA\nAB\nBB\nBA\nZA\n", "output": "2 1 3 4 5\n"}, {"input": "5 2\nAA\nAB\nCB\nBA\nAZ\n", "output": "5 2 1 4 3\n"}, {"input": "5 2\nAA\nAB\nBC\nBA\nAZ\n", "output": "5 2 1 3 ... | code_stdio |
[
{
"content": "We have a grid with H rows and W columns, where all the squares are initially white.\n\nYou will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions:\n\n* Choose one row, then paint all the squares in that row black.\n* Choose one c... | [{"input": "14\n0\n15028", "output": "1074\n"}, {"input": "14\n0\n19420", "output": "1388\n"}, {"input": "14\n0\n25749", "output": "1840\n"}, {"input": "14\n0\n16704", "output": "1194\n"}, {"input": "14\n1\n20917", "output": "1495\n"}, {"input": "14\n2\n28787", "output": "2057\n"}, {"input": "14\n4\n25994", "output": "... | code_stdio |
[
{
"content": "Three companies decided to order a billboard with pictures of their logos. A billboard is a big square board. A logo of each company is a rectangle of a non-zero area. \n\nAdvertisers will put up the ad only if it is possible to place all three logos on the billboard so that they do not overlap an... | [{"input": "17 100 100 22 61 100\n", "output": "100\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA... | code_stdio |
[
{
"content": "Hr0d1y has $q$ queries on a binary string $s$ of length $n$. A binary string is a string containing only characters '0' and '1'.\n\nA query is described by a pair of integers $l_i$, $r_i$ $(1 \\leq l_i \\lt r_i \\leq n)$.\n\nFor each query, he has to determine whether there exists a good subsequen... | [{"input": "2\n6 3\n001000\n2 4\n1 3\n3 5\n4 2\n1111\n1 4\n2 3\n", "output": "\nYES\nNO\nYES\nNO\nYES\n"}, {"input": "2\n6 3\n001000\n2 4\n1 3\n3 5\n4 2\n1111\n1 4\n2 3\n", "output": "YES\nNO\nYES\nNO\nYES\n"}, {"input": "2\n6 3\n001000\n2 4\n1 3\n3 5\n4 2\n1111\n1 4\n1 3\n", "output": "YES\nNO\nYES\nNO\nYES\n"}, {"inp... | code_stdio |
[
{
"content": "To write a research paper, you should definitely follow the structured format. This format, in many cases, is strictly defined, and students who try to write their papers have a hard time with it.\n\nOne of such formats is related to citations. If you refer several pages of a material, you should ... | [{"input": "5\n1 2 1 4 11\n3\n12 28 16\n0", "output": "1-2 1 4 11\n12 28 16\n"}, {"input": "5\n1 2 1 4 9\n3\n12 28 16\n0", "output": "1-2 1 4 9\n12 28 16\n"}, {"input": "5\n1 2 1 4 0\n3\n12 28 16\n0", "output": "1-2 1 4 0\n12 28 16\n"}, {"input": "5\n1 2 4 4 9\n3\n13 14 14\n0", "output": "1-2 4 4 9\n13-14 14\n"}, {"inp... | code_stdio |
[
{
"content": "Takahashi has a maze, which is a grid of H \\times W squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column is a \"wall\" square if S_{ij} is #, and a \"road\" square if S_{ij} is ..\nFrom a road square, you can move to a horizontally or... | [{"input": "20 20\n....................\n###################.\n....................\n.###################\n....................\n###################.\n....................\n.###################\n....................\n###################.\n....................\n.###################\n....................\n###############... | code_stdio |
[
{
"content": "For given an integer $n$, print all permutations of $\\\\{1, 2, ..., n\\\\}$ in lexicographic order.\n\nConstraints\n\n* $1 \\leq n \\leq 9$\n\nInput\n\nAn integer $n$ is given in a line.\n\nOutput\n\nPrint each permutation in a line in order. Separate adjacency elements by a space character.\n\nE... | [{"input": "5", "output": "1 2 3 4 5\n1 2 3 5 4\n1 2 4 3 5\n1 2 4 5 3\n1 2 5 3 4\n1 2 5 4 3\n1 3 2 4 5\n1 3 2 5 4\n1 3 4 2 5\n1 3 4 5 2\n1 3 5 2 4\n1 3 5 4 2\n1 4 2 3 5\n1 4 2 5 3\n1 4 3 2 5\n1 4 3 5 2\n1 4 5 2 3\n1 4 5 3 2\n1 5 2 3 4\n1 5 2 4 3\n1 5 3 2 4\n1 5 3 4 2\n1 5 4 2 3\n1 5 4 3 2\n2 1 3 4 5\n2 1 3 5 4\n2 1 4 3... | code_stdio |
[
{
"content": "Today an outstanding event is going to happen in the forest — hedgehog Filya will come to his old fried Sonya!\n\nSonya is an owl and she sleeps during the day and stay awake from minute l_1 to minute r_1 inclusive. Also, during the minute k she prinks and is unavailable for Filya.\n\nFilya works ... | [{"input": "519325240668210886 776112702001665034 360568516809443669 1272711703453279586 994594983925273138\n", "output": "256787461333454149\n"}, {"input": "519325240668210886 776112702001665034 360568516809443669 875594219634943179 994594983925273138\n", "output": "256787461333454149\n"}, {"input": "51932524066821088... | code_stdio |
[
{
"content": "Given are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N. Determine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N, A_i \\leq B_i holds:\n\n* Choose two distinct integers x and y between 1 and N (inc... | [{"input": "6\n0 0 1 2 3 12\n0 2 14 6 2 3", "output": "Yes\n"}, {"input": "6\n1 0 1 2 3 12\n0 2 14 6 2 3", "output": "Yes\n"}, {"input": "6\n1 0 1 2 3 12\n0 4 14 6 2 3", "output": "Yes\n"}, {"input": "6\n1 0 1 2 3 12\n1 4 14 6 2 3", "output": "Yes\n"}, {"input": "6\n0 0 1 2 3 6\n1 2 14 6 2 3", "output": "Yes\n"}, {"inp... | code_stdio |
[
{
"content": "The Little Elephant has got a problem — somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.\n\nThe Little Elephant doesn't want to call the police until he understands if he could have accidentally changed the array himself. ... | [{"input": "128\n1 2 4 6 8 17 20 20 23 33 43 49 49 49 52 73 74 75 82 84 85 87 90 91 102 103 104 105 111 111 401 142 142 152 155 160 175 176 178 181 183 184 101 188 191 193 326 202 202 214 224 225 236 239 240 243 246 247 249 249 257 257 261 264 265 271 277 281 284 284 286 289 290 296 297 303 305 307 307 317 318 320 322 ... | code_stdio |
[
{
"content": "Monocarp is the coach of the Berland State University programming teams. He decided to compose a problemset for a training session for his teams.\n\nMonocarp has $n$ problems that none of his students have seen yet. The $i$-th problem has a topic $a_i$ (an integer from $1$ to $n$) and a difficulty... | [{"input": "2\n4\n2 4\n3 4\n2 1\n1 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "output": "3\n10\n"}, {"input": "2\n4\n2 4\n3 4\n2 1\n2 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "output": "2\n10\n"}, {"input": "2\n4\n2 4\n3 3\n2 2\n1 3\n5\n1 5\n2 4\n3 3\n4 2\n5 1\n", "output": "4\n10\n"}, {"input": "2\n4\n4 4\n3 3\n2 2\n2 3\n5\n1 5\n2 4\... | code_stdio |
[
{
"content": "Shortest Common Non-Subsequence\n\nA subsequence of a sequence $P$ is a sequence that can be derived from the original sequence $P$ by picking up some or no elements of $P$ preserving the order. For example, \"ICPC\" is a subsequence of \"MICROPROCESSOR\".\n\nA common subsequence of two sequences ... | [{"input": "0101\n1101001", "output": "0000\n"}, {"input": "0101\n1101000", "output": "0001\n"}, {"input": "0101\n0011001", "output": "1000\n"}, {"input": "0101\n0110001", "output": "0010\n"}, {"input": "0101\n1001001", "output": "0110\n"}, {"input": "0101\n0101001", "output": "1110\n"}, {"input": "0101\n0100101", "out... | code_stdio |
[
{
"content": "Vasya has become interested in wrestling. In wrestling wrestlers use techniques for which they are awarded points by judges. The wrestler who gets the most points wins.\n\nWhen the numbers of points of both wrestlers are equal, the wrestler whose sequence of points is lexicographically greater, wi... | [{"input": "131\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n0\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\n-1\n1\... | code_stdio |
[
{
"content": "Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?\n\nYou are given a system of equations: \n\n<image>\n\nYou should c... | [{"input": "1000 1010\n", "output": "0\n"}, {"input": "1000 1000\n", "output": "0"}, {"input": "1190 225\n", "output": "0\n"}, {"input": "1190 315\n", "output": "0\n"}, {"input": "1491 512\n", "output": "0\n"}, {"input": "247 438\n", "output": "0\n"}, {"input": "529 780\n", "output": "0\n"}, {"input": "120 433\n", "out... | code_stdio |
[
{
"content": "You are a given a list of integers $a_1, a_2, \\ldots, a_n$ and $s$ of its segments $[l_j; r_j]$ (where $1 \\le l_j \\le r_j \\le n$).\n\nYou need to select exactly $m$ segments in such a way that the $k$-th order statistic of the multiset of $a_i$, where $i$ is contained in at least one segment, ... | [{"input": "5 10 1 1\n1000000000 1000000000 1000000000 1 1000000000\n1 1\n1 3\n5 5\n1 1\n2 3\n3 3\n3 4\n1 2\n2 2\n3 3\n", "output": "1\n"}, {"input": "5 10 1 1\n1000000000 1000000000 1000000000 1 1000000000\n1 1\n1 3\n5 5\n1 1\n2 3\n3 3\n3 4\n1 2\n2 2\n3 3\n", "output": "1\n"}, {"input": "5 10 1 1\n1000000000 100000000... | code_stdio |
[
{
"content": "Seiji Hayashi had been a professor of the Nisshinkan Samurai School in the domain of Aizu for a long time in the 18th century. In order to reward him for his meritorious career in education, Katanobu Matsudaira, the lord of the domain of Aizu, had decided to grant him a rectangular estate within a... | [{"input": "16\n10 8\n2 2\n2 6\n2 7\n6 6\n4 8\n4 2\n5 5\n4 8\n10 2\n6 7\n7 7\n7 8\n8 1\n5 4\n9 1\n10 3\n4 3\n8\n6 4\n2 2\n2 1\n2 4\n3 4\n4 2\n5 3\n1 1\n3 2\n3 3\n0", "output": "5\n5\n"}, {"input": "16\n10 9\n2 4\n2 6\n2 7\n6 6\n4 8\n4 2\n5 5\n4 8\n6 4\n6 7\n7 6\n7 8\n8 0\n8 4\n9 1\n10 3\n1 3\n8\n6 13\n1 2\n2 1\n2 4\n3 ... | code_stdio |
[
{
"content": "problem\n\nThere are many $ N $ colored balls of different weights in the queue. The queue is in ascending order from the beginning: $ 1,2,3, \\ dots, N-1, N, 1,2,3, \\ dots, N-1, N, 1,2,3, \\ dots $ The balls are lined up, followed by the balls of color $ N $, followed by the balls of color $ 1 $... | [{"input": "8 4\n46 70 57 10 174 41 130 43", "output": "193\n"}, {"input": "8 4\n46 70 57 10 174 33 130 43", "output": "201\n"}, {"input": "8 7\n46 70 57 3 174 25 130 43", "output": "1302\n"}, {"input": "8 4\n46 70 57 10 174 38 130 43", "output": "196\n"}, {"input": "8 4\n46 105 57 3 174 25 130 60", "output": "251\n"},... | code_stdio |
[
{
"content": "One not particularly beautiful evening Valera got very bored. To amuse himself a little bit, he found the following game.\n\nHe took a checkered white square piece of paper, consisting of n × n cells. After that, he started to paint the white cells black one after the other. In total he painted m ... | [{"input": "10 60\n6 7\n2 4\n3 6\n1 4\n8 7\n2 8\n5 7\n6 4\n5 10\n1 7\n3 9\n3 4\n9 2\n7 1\n3 8\n10 7\n9 7\n9 1\n5 5\n4 7\n5 8\n4 2\n2 2\n9 4\n3 3\n7 5\n7 4\n7 7\n8 2\n8 1\n4 5\n1 10\n9 6\n3 1\n1 3\n3 2\n10 10\n4 6\n5 4\n7 3\n10 1\n3 7\n5 1\n10 9\n4 10\n6 10\n7 10\n5 9\n5 6\n1 2\n7 8\n3 5\n9 8\n9 5\n8 10\n4 3\n10 6\n9 10... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is constraints.\n\nNauuo is a girl who loves random picture websites.\n\nOne day she made a random picture website by herself which includes $n$ pictures.\n\nWhen Nauuo visits the website, she sees exactly one picture. The website does not display... | [{"input": "100 3000\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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0\n10 8 1 9 7 5 12 9 15 7 16 5 17 5 17 21 11 3 4 4 30 17 3 84 12 30 2 8 2 2 22 24 15 11 15 13 7 17 1... | code_stdio |
[
{
"content": "This is a simplified version of the task Toy Train. These two versions differ only in the constraints. Hacks for this version are disabled.\n\nAlice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ stations, enumerated from $1$ through $n$. The... | [{"input": "5000 1\n4008 1126\n", "output": "6125 6124 6123 6122 6121 6120 6119 6118 6117 6116 6115 6114 6113 6112 6111 6110 6109 6108 6107 6106 6105 6104 6103 6102 6101 6100 6099 6098 6097 6096 6095 6094 6093 6092 6091 6090 6089 6088 6087 6086 6085 6084 6083 6082 6081 6080 6079 6078 6077 6076 6075 6074 6073 6072 6071 ... | code_stdio |
[
{
"content": "You are given a string S. Each character of S is uppercase or lowercase English letter.\nDetermine if S satisfies all of the following conditions:\n - The initial character of S is an uppercase A.\n - There is exactly one occurrence of C between the third character from the beginning and the secon... | [{"input": "AccccCcccc\n", "output": "AC\n"}, {"input": "AmvlkweClF\n", "output": "WA\n"}, {"input": "AcCCCCCCCc\n", "output": "WA\n"}, {"input": "zzzzzzzzzz\n", "output": "WA\n"}, {"input": "abcarCagc\n", "output": "WA\n"}, {"input": "ApproaCh\n", "output": "AC\n"}, {"input": "AcCepted\n", "output": "AC\n"}, {"input":... | code_stdio |
[
{
"content": "Those days, many boys use beautiful girls' photos as avatars in forums. So it is pretty hard to tell the gender of a user at the first glance. Last year, our hero went to a forum and had a nice chat with a beauty (he thought so). After that they talked very often and eventually they became a coupl... | [{"input": "yufkkfwyhhvcjntsgsvpzbhqtmtgyxifqoewmuplphykmptfdebjxuaxigomjtwgtljwdjhjernkitifbomifbhysnmadtnyn\n", "output": "CHAT WITH HER!\n"}, {"input": "yufkkfwyhhvcjntsgsvpzbhqtmtgyxifqoewmuplphykmptfdebjxuaxigomjtwgtljwdjhjernkitifbomifbhysnmadtnyn\n", "output": "CHAT WITH HER!\n"}, {"input": "yufkkfwyhhvcjntsgsvp... | code_stdio |
[
{
"content": "There are $n$ children numbered from $1$ to $n$ in a kindergarten. Kindergarten teacher gave $a_i$ ($1 \\leq a_i \\leq n$) candies to the $i$-th child. Children were seated in a row in order from $1$ to $n$ from left to right and started eating candies. \n\nWhile the $i$-th child was eating candie... | [{"input": "50\n0 0 2 3 2 4 4 4 0 5 5 10 4 6 6 13 13 13 3 14 14 7 15 7 7 7 5 8 8 8 22 22 3 23 6 24 10 25 25 10 10 3 28 28 0 29 8 4 14 32\n0 0 7 29 2 10 10 10 0 9 9 22 5 8 8 19 19 19 1 18 18 7 17 7 7 7 4 6 6 6 10 10 1 9 3 8 4 7 7 4 4 1 4 4 0 3 1 0 0 0\n", "output": "YES\n50 50 41 18 46 36 36 36 50 36 36 18 41 36 36 18 1... | code_stdio |
[
{
"content": "Chefs from all over the globe gather each year for an international convention. Each chef represents some country. Please, note that more than one chef can represent a country.\nEach of them presents their best dish to the audience. The audience then sends emails to a secret and secure mail server... | [{"input": "2 2\nNewton Englaod\nEuclid Greece\nNewton\nEuclid", "output": "Englaod\nEuclid\n"}, {"input": "2 1\nNewton Englaod\nEuclid Greece\nNewton\nEuclid", "output": "Englaod\nNewton\n"}, {"input": "2 1\nNewton England\nEuclid Greece\nNewton\nEuclid", "output": "England\nNewton\n"}, {"input": "2 1\nNewton dnalgnE\... | code_stdio |
[
{
"content": "Maksim walks on a Cartesian plane. Initially, he stands at the point $(0, 0)$ and in one move he can go to any of four adjacent points (left, right, up, down). For example, if Maksim is currently at the point $(0, 0)$, he can go to any of the following points in one move: $(1, 0)$; $(0, 1)$; $... | [{"input": "39\n27 47\n30 9\n18 28\n49 16\n10 12\n25 13\n44 11\n13 9\n3 8\n30 2\n8 30\n38 32\n7 29\n38 43\n27 37\n6 13\n21 25\n31 18\n17 26\n51 52\n27 40\n10 43\n50 27\n41 41\n2 11\n38 45\n37 43\n20 52\n36 11\n43 46\n4 39\n22 32\n42 11\n8 37\n9 17\n38 8\n41 1\n24 50\n47 7\n", "output": "861\n"}, {"input": "39\n27 47\n3... | code_stdio |
[
{
"content": "Ayush, Ashish and Vivek are busy preparing a new problem for the next Codeforces round and need help checking if their test cases are valid.\n\nEach test case consists of an integer $n$ and two arrays $a$ and $b$, of size $n$. If after some (possibly zero) operations described below, array $a$ can... | [{"input": "24\n4\n1 2 3 4\n1 2 3 4\n4\n1 2 3 4\n1 2 4 3\n4\n1 2 3 4\n1 3 2 4\n4\n1 2 3 4\n1 3 4 2\n4\n1 2 3 4\n1 4 2 3\n4\n1 2 3 4\n1 4 3 2\n4\n1 2 3 4\n2 1 3 4\n4\n1 2 3 4\n2 1 4 3\n4\n1 2 3 4\n2 3 1 4\n4\n1 2 3 4\n2 3 4 1\n4\n1 2 3 4\n2 4 1 3\n4\n1 2 3 4\n2 4 3 1\n4\n1 2 3 4\n3 1 2 4\n4\n1 2 3 4\n3 1 4 2\n4\n1 2 3 4... | code_stdio |
[
{
"content": "You are given a tree consisting of n nodes. You generate an array from the tree by marking nodes one by one.\n\nInitially, when no nodes are marked, a node is equiprobably chosen and marked from the entire tree. \n\nAfter that, until all nodes are marked, a node is equiprobably chosen and marked f... | [{"input": "6\n2 1\n2 3\n6 1\n2 4\n2 5\n", "output": "583333343\n"}, {"input": "6\n2 1\n2 3\n6 1\n2 4\n1 5\n", "output": "500000009\n"}, {"input": "6\n3 1\n2 3\n6 1\n2 4\n1 5\n", "output": "875000012\n"}, {"input": "6\n2 1\n1 3\n6 1\n1 4\n2 5\n", "output": "416666675\n"}, {"input": "6\n2 1\n1 3\n6 1\n1 4\n4 5\n", "outp... | code_stdio |
[
{
"content": "Snuke is having a barbeque party.\nAt the party, he will make N servings of Skewer Meal.\nExample of a serving of Skewer Meal\nHe has a stock of 2N skewers, all of which will be used in Skewer Meal. The length of the i-th skewer is L_i.\nAlso, he has an infinite supply of ingredients.\nTo make a s... | [{"input": "100\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100... | code_stdio |
[
{
"content": "Little Vasya went to the supermarket to get some groceries. He walked about the supermarket for a long time and got a basket full of products. Now he needs to choose the cashier to pay for the products.\n\nThere are n cashiers at the exit from the supermarket. At the moment the queue for the i-th ... | [{"input": "1\n90\n90 90 90 90 51 90 88 90 112 67 90 90 90 13 90 48 164 172 98 102 73 90 90 90 90 124 90 90 46 139 90 84 85 90 90 18 52 30 90 90 90 87 47 90 146 30 90 97 153 90 90 227 248 90 90 28 174 139 90 90 62 90 23 124 90 36 81 90 90 82 90 54 90 163 105 147 90 14 90 90 151 90 90 82 90 90 90 56 90 90\n", "output": ... | code_stdio |
[
{
"content": "Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that a ≤ x ≤ b and x is divisible by k.\n\n\n-----Input-----\n\nThe only line contains three space-separated integers k, a and b (1 ≤ k ≤ 10^18; - 10^18 ≤ a ≤ b ≤ 10^18... | [{"input": "1 -1000000000000000000 1000000000000000000\n", "output": "2000000000000000001\n"}, {"input": "2 -1000000000000000000 1000000000000000000\n", "output": "1000000000000000001\n"}, {"input": "1000000000000000000 -1000000000000000000 1000000000000000000\n", "output": "3\n"}, {"input": "100000000000000321 -100000... | code_stdio |
[
{
"content": "The Fair Nut likes kvass very much. On his birthday parents presented him $n$ kegs of kvass. There are $v_i$ liters of kvass in the $i$-th keg. Each keg has a lever. You can pour your glass by exactly $1$ liter pulling this lever. The Fair Nut likes this drink very much, so he wants to pour his gl... | [{"input": "4 4\n1000000000 1000000000 1000000000 1000000000\n", "output": "999999999\n"}, {"input": "4 4\n1000000000 1000000000 1000000000 1000000000\n", "output": "999999999\n"}, {"input": "4 4\n1000000000 1000000100 1000000000 1000000000\n", "output": "1000000000"}, {"input": "4 4\n1000000000 1000000100 1000000000 1... | code_stdio |
[
{
"content": "n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out a_{i} people in clockwise order, starting from the n... | [{"input": "101 30\n1122517 913885 829106 127375 848316 278798 520469 1178427 61045 916519 767861 370006 75224 321506 124981 1042689 131175 689748 422800 181309 1322 2845106 1285852 60402 766045 1676905 513021 206603 979480 962688\n", "output": "4 90 71 46 100 15 77 24 63 81 85 3 26 72 31 58 84 13 11 21 52 37 97 38 101... | code_stdio |
[
{
"content": "Linear Kingdom has exactly one tram line. It has n stops, numbered from 1 to n in the order of tram's movement. At the i-th stop ai passengers exit the tram, while bi passengers enter it. The tram is empty before it arrives at the first stop. Also, when the tram arrives at the last stop, all passe... | [{"input": "100\n0 1\n0 0\n0 0\n1 0\n0 0\n0 1\n0 1\n1 1\n0 0\n0 0\n1 1\n0 0\n1 1\n0 1\n1 1\n0 1\n1 1\n1 0\n1 0\n0 0\n1 0\n0 0\n1 0\n0 0\n0 1\n1 1\n1 1\n0 1\n0 0\n1 0\n1 1\n0 1\n1 0\n1 1\n0 1\n1 1\n1 0\n0 0\n0 0\n0 1\n0 0\n-1 1\n1 1\n0 0\n1 1\n1 1\n0 0\n0 1\n1 0\n0 1\n0 0\n0 1\n0 1\n1 1\n1 1\n1 1\n0 0\n0 0\n1 1\n0 1\n0 ... | code_stdio |
[
{
"content": "The Fair Nut is going to travel to the Tree Country, in which there are $n$ cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a tree (connected graph without cycles). Nut wants to rent a car in the city $u$ and go by a simple path to city $v$. ... | [{"input": "10\n81 34 31 38 69 62 54 18 72 29\n4 8 12\n2 9 25\n4 5 17\n5 7 35\n10 1 13\n9 3 53\n7 6 22\n1 6 82\n3 10 42\n", "output": " 187\n"}, {"input": "10\n11 43 11 96 18 53 25 89 31 41\n2 4 41\n7 1 88\n3 2 19\n10 3 38\n8 4 97\n7 5 21\n7 2 71\n3 6 69\n9 5 ... | code_stdio |
[
{
"content": "For two sequences S and T of length N consisting of 0 and 1, let us define f(S, T) as follows:\n - Consider repeating the following operation on S so that S will be equal to T. f(S, T) is the minimum possible total cost of those operations.\n - Change S_i (from 0 to 1 or vice versa). The cost of t... | [{"input": "5\n52 67 72 25 79\n", "output": "269312\n"}, {"input": "5\n52 103 72 25 79", "output": "292096\n"}, {"input": "5\n63 103 72 25 79", "output": "306176\n"}, {"input": "1\n1000000000\n", "output": "999999993\n"}, {"input": "5\n20 67 72 25 79", "output": "227072\n"}, {"input": "5\n2 124 30 25 55", "output": "17... | code_stdio |
[
{
"content": "You have $n \\times n$ square grid and an integer $k$. Put an integer in each cell while satisfying the conditions below. All numbers in the grid should be between $1$ and $k$ inclusive. Minimum number of the $i$-th row is $1$ ($1 \\le i \\le n$). Minimum number of the $j$-th column is $1$ ($1 ... | [{"input": "250 1000000000\n", "output": "770503193\n"}, {"input": "250 1000000000\n", "output": "770503193\n"}, {"input": "216 1142401243\n", "output": "820247611\n"}, {"input": "246 1140071398\n", "output": "783102336\n"}, {"input": "218 1771958988\n", "output": "699159875\n"}, {"input": "244 315404017\n", "output": ... | code_stdio |
[
{
"content": "Petya and Gena love playing table tennis. A single match is played according to the following rules: a match consists of multiple sets, each set consists of multiple serves. Each serve is won by one of the players, this player scores one point. As soon as one of the players scores t points, he win... | [{"input": "186\n2 1 2 1 1 1 1 1 2 1 1 2 2 2 1 1 2 2 1 1 1 2 1 1 2 2 1 1 1 2 2 1 1 1 1 1 2 1 1 1 2 1 2 1 1 2 1 1 1 2 2 2 2 2 2 2 1 2 1 2 1 1 2 1 2 2 1 1 1 1 1 2 2 1 2 2 1 2 2 1 1 1 2 2 1 1 2 2 1 2 2 1 2 2 2 2 2 1 1 1 1 2 1 1 2 2 2 2 2 2 1 1 1 1 1 2 1 1 2 2 1 2 2 1 1 1 1 1 2 2 1 1 2 2 1 2 2 2 1 2 1 2 1 1 2 1 2 2 2 2 1 2... | code_stdio |
[
{
"content": "Due to the coronavirus pandemic, city authorities obligated citizens to keep a social distance. The mayor of the city Semyon wants to light up Gluharniki park so that people could see each other even at night to keep the social distance.\n\nThe park is a rectangular table with $n$ rows and $m$ col... | [{"input": "5\n2 1\n1 3\n2 2\n1 3\n5 4\n", "output": "1\n2\n2\n2\n10\n"}, {"input": "2\n461 5299\n118 177\n", "output": "1221420\n10443\n"}, {"input": "2\n461 5299\n176 177\n", "output": "1221420\n15576\n"}, {"input": "5\n5 1\n1 3\n2 4\n1 3\n7 3\n", "output": "3\n2\n4\n2\n11\n"}, {"input": "2\n461 5299\n176 213\n", "ou... | code_stdio |
[
{
"content": "Mike and !Mike are old childhood rivals, they are opposite in everything they do, except programming. Today they have a problem they cannot solve on their own, but together (with you) — who knows? \n\nEvery one of them has an integer sequences a and b of length n. Being given a query of the form o... | [{"input": "17\n714413739 -959271262 714413739 -745891378 926207665 -404845105 -404845105 -959271262 -189641729 -670860364 714413739 -189641729 192457837 -745891378 -670860364 536388097 -959271262\n-417715348 -959271262 -959271262 714413739 -189641729 571055593 571055593 571055593 -417715348 -417715348 192457837 -74589... | code_stdio |
[
{
"content": "Little town Nsk consists of n junctions connected by m bidirectional roads. Each road connects two distinct junctions and no two roads connect the same pair of junctions. It is possible to get from any junction to any other junction by these roads. The distance between two junctions is equal to th... | [{"input": "5 6 1 5\n1 2\n1 3\n1 4\n4 5\n3 5\n2 5\n", "output": "3\n"}, {"input": "5 6 1 5\n1 2\n1 3\n1 4\n4 5\n3 5\n1 5\n", "output": "4\n"}, {"input": "5 6 1 5\n1 2\n1 3\n2 4\n4 5\n3 5\n2 5\n", "output": "3\n"}, {"input": "5 6 1 5\n1 2\n1 3\n1 4\n1 5\n3 5\n2 5\n", "output": "4\n"}, {"input": "5 6 1 5\n1 2\n1 5\n1 4\n... | code_stdio |
[
{
"content": "Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm.\n\nSereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first ele... | [{"input": "7\n1 53989\n1 47249\n1 71935\n2 1 3\n1 84520\n1 84185\n2 6 1\n14\n1 2 3 4 5 6 7 8 9 10 11 12 13 14\n", "output": "53989 47249 71935 53989 53989 53989 84520 84185 53989 47249 71935 53989 53989 53989\n"}, {"input": "7\n1 53989\n1 47249\n1 71935\n2 1 3\n1 84520\n1 84185\n2 6 1\n14\n1 2 3 4 5 6 7 8 9 10 11 12 1... | code_stdio |
[
{
"content": "Ancient Egyptians are known to have used a large set of symbols $\\sum$ to write on the walls of the temples. Fafa and Fifa went to one of the temples and found two non-empty words S_1 and S_2 of equal lengths on the wall of temple written one below the other. Since this temple is very ancient, so... | [{"input": "107 100000\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 0 0 0 0 0 0 0\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... | code_stdio |
[
{
"content": "-----Problem Statement-----\nSereja has a sequence of n integers a[1], a[2], ..., a[n]. Sereja can do following transformation of the array:\n\n- create a new sequence of n integers b[1], b[2], ..., b[n]in this way: (1 ≤ i ≤ n)\n\n- Replace the sequence a by b, i.e., a[i] = b[i] for all i in [1... | [{"input": "3\n0 1 -1 0\n5 0 -1 1\n7 2 -1 1", "output": "0\n999999977\n999999629\n"}, {"input": "3\n-24 12 0 -1\n-1 -6 1 -2\n102 1 -1 1", "output": "0\n0\n810970227\n"}, {"input": "3\n-24 12 0 -1\n-1 -6 1 -2\n198 1 -1 1", "output": "0\n0\n249722532\n"}, {"input": "3\n-24 12 0 -1\n-1 -2 1 -2\n198 0 -1 1", "output": "0\n... | code_stdio |
[
{
"content": "Alice is playing with some stones.\n\nNow there are three numbered heaps of stones. The first of them contains $a$ stones, the second of them contains $b$ stones and the third of them contains $c$ stones.\n\nEach time she can do one of two operations: take one stone from the first heap and two st... | [{"input": "64\n0 0 0\n0 0 1\n0 0 2\n0 0 3\n0 1 0\n0 1 1\n0 1 2\n0 1 3\n0 2 0\n0 2 1\n0 2 2\n0 2 3\n0 3 0\n0 3 1\n0 3 2\n0 3 3\n1 0 0\n1 0 1\n1 0 2\n1 0 3\n1 1 0\n1 1 1\n1 1 2\n1 1 3\n1 2 0\n1 2 1\n1 2 2\n1 2 3\n1 3 0\n1 3 1\n1 3 2\n1 3 3\n2 0 0\n2 0 1\n2 0 2\n2 0 3\n2 1 0\n2 1 1\n2 1 2\n2 1 3\n2 2 0\n2 2 1\n2 2 2\n2 2... | code_stdio |
[
{
"content": "You are given an integer $n$. In $1$ move, you can do one of the following actions:\n\nerase any digit of the number (it's acceptable that the number before the operation has exactly one digit and after the operation, it is \"empty\");\n\nadd one digit to the right.\n\nThe actions may be performed... | [{"input": "12\n825\n8888\n4\n157\n146\n1\n301\n19634\n1504\n10521\n1000000000\n687194767\n", "output": "2\n3\n0\n2\n1\n0\n2\n3\n3\n3\n9\n2\n"}, {"input": "12\n825\n4320\n12\n75\n113\n1\n186\n10133\n2180\n12699\n1000000000\n687194767\n", "output": "2\n2\n1\n3\n2\n0\n1\n4\n3\n3\n9\n2\n"}, {"input": "12\n825\n8888\n4\n15... | code_stdio |
[
{
"content": "Recently Luba learned about a special kind of numbers that she calls beautiful numbers. The number is called beautiful iff its binary representation consists of k + 1 consecutive ones, and then k consecutive zeroes.\n\nSome examples of beautiful numbers: 1_2 (1_10); 110_2 (6_10); 1111000_2 (12... | [{"input": "32640\n", "output": "32640\n"}, {"input": "97920\n", "output": "32640\n"}, {"input": "32640\n", "output": "32640\n"}, {"input": "97920\n", "output": "32640\n"}, {"input": "12096\n", "output": "2016\n"}, {"input": "38304\n", "output": "2016\n"}, {"input": "89408\n", "output": "8128\n"}, {"input": "10080\n", ... | code_stdio |
[
{
"content": "Given are positive integers N and K.\n\nDetermine if the 3N integers K, K+1, ..., K+3N-1 can be partitioned into N triples (a_1,b_1,c_1), ..., (a_N,b_N,c_N) so that the condition below is satisfied. Any of the integers K, K+1, ..., K+3N-1 must appear in exactly one of those triples.\n\n* For every... | [{"input": "1 -12", "output": "-12 -11 -10\n"}, {"input": "1 -20", "output": "-20 -19 -18\n"}, {"input": "1 -33", "output": "-33 -32 -31\n"}, {"input": "1 -36", "output": "-36 -35 -34\n"}, {"input": "1 -26", "output": "-26 -25 -24\n"}, {"input": "1 -16", "output": "-16 -15 -14\n"}, {"input": "1 -10", "output": "-10 -9 ... | code_stdio |
[
{
"content": "Ridbit starts with an integer $n$.\n\nIn one move, he can perform one of the following operations:\n\ndivide $n$ by one of its proper divisors, or\n\nsubtract $1$ from $n$ if $n$ is greater than $1$.\n\nA proper divisor is a divisor of a number, excluding itself. For example, $1$, $2$, $4$, $5$, a... | [{"input": "6\n1\n2\n3\n10\n10\n18\n", "output": "0\n1\n2\n2\n2\n2\n"}, {"input": "6\n1\n2\n3\n14\n6\n45\n", "output": "0\n1\n2\n2\n2\n3\n"}, {"input": "6\n2\n2\n3\n11\n4\n45\n", "output": "1\n1\n2\n3\n2\n3\n"}, {"input": "6\n2\n1\n3\n11\n4\n45\n", "output": "1\n0\n2\n3\n2\n3\n"}, {"input": "6\n1\n2\n1\n10\n1\n16\n", "... | code_stdio |
[
{
"content": "Arkady coordinates rounds on some not really famous competitive programming platform. Each round features $n$ problems of distinct difficulty, the difficulties are numbered from $1$ to $n$.\n\nTo hold a round Arkady needs $n$ new (not used previously) problems, one for each difficulty. As for now,... | [{"input": "11000 10\n10000 9999 9998 1967 4502 9995 9994 10823 9992 9991\n", "output": "0000000000\n"}, {"input": "11000 10\n10000 9999 9998 1967 4502 9995 3707 10823 9992 9991\n", "output": "0000000000\n"}, {"input": "11010 10\n10000 9999 9998 1967 4502 9995 3707 10823 9992 9991\n", "output": "0000000000\n"}, {"input... | code_stdio |
[
{
"content": "You're given a list of n strings a_1, a_2, ..., a_{n}. You'd like to concatenate them together in some order such that the resulting string would be lexicographically smallest.\n\nGiven the list of strings, output the lexicographically smallest concatenation.\n\n\n-----Input-----\n\nThe first line... | [{"input": "13\nclgknjjojyuvdtv\nclgknjjojyuvdtvzxz\nclgknjjojyuvdtvzxzxradqhm\ngvzpnckalbaubfviyhijosiixvxaydxagvymq\nclgknjjojyuvdtvjgcwarwvgilcctdiytmvmvfxxkezymt\nbvwzpuut\nclgknjjojyuvdtvjgcwarwvgilcctdiytmvmvfxxkezymth\nclgknjjojyuvdtvjgcwarwvgilcctdiytmvmvfxxkezymtlkdl\nrbwvaayhhunlvmwexvkmqbquypsnjbdkkeytthektt... | code_stdio |
[
{
"content": "The Smart Beaver from ABBYY invented a new message encryption method and now wants to check its performance. Checking it manually is long and tiresome, so he decided to ask the ABBYY Cup contestants for help.\n\nA message is a sequence of n integers a1, a2, ..., an. Encryption uses a key which is ... | [{"input": "20 15 17\n4 9 14 11 15 16 15 4 0 10 7 12 10 1 8 6 7 14 1 13\n6 3 14 8 8 11 16 4 5 9 2 13 6 14 15\n", "output": "10 1 3 8 3 15 7 14 1 12 3 10 15 16 16 5 4 15 13 11 "}, {"input": "20 15 17\n4 9 14 11 15 16 15 4 0 10 7 12 10 1 8 6 7 14 1 13\n6 3 14 8 8 11 16 4 6 9 2 13 6 14 15\n", "output": "10 1 3 8 3 15 7 14... | code_stdio |
[
{
"content": "In this problem, your task is to use ASCII graphics to paint a cardiogram. \n\nA cardiogram is a polyline with the following corners:$(0 ; 0),(a_{1} ; a_{1}),(a_{1} + a_{2} ; a_{1} - a_{2}),(a_{1} + a_{2} + a_{3} ; a_{1} - a_{2} + a_{3}), \\ldots,(\\sum_{i = 1}^{n} a_{i} ; \\sum_{i = 1}^{n}(- 1)^{... | [{"input": "23\n33 42 55 36 73 42 36 39 35 38 38 65 31 33 26 40 20 32 45 32 31 35 36\n", "output": " ... | code_stdio |
[
{
"content": "A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.\n\nCatacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself... | [{"input": "100\n0 0 0 0 0 0 1 4 4 0 2 2 4 1 7 1 11 0 8 4 12 12 3 0 3 2 2 4 3 9 1 5 4 6 9 14 6 2 4 18 7 7 19 11 20 13 17 16 0 34 2 6 12 27 9 4 29 22 4 20 20 17 17 20 37 53 17 3 3 15 1 46 11 24 31 6 12 6 11 18 13 1 5 0 19 10 24 41 16 41 18 52 46 39 16 30 18 23 53 13\n", "output": "66\n"}, {"input": "100\n0 0 0 0 0 0 1 4... | code_stdio |
[
{
"content": "One of the oddest traditions of the town of Gameston may be that even the town mayor of the next term is chosen according to the result of a game. When the expiration of the term of the mayor approaches, at least three candidates, including the mayor of the time, play a game of pebbles, and the wi... | [{"input": "3 3\n1 2\n3 50\n10 29\n146 32\n39 2\n50 50\n0 0", "output": "0\n0\n1\n5\n31\n1\n13\n"}, {"input": "3 2\n1 2\n3 10\n10 29\n142 48\n39 2\n50 50\n0 0", "output": "1\n0\n2\n5\n63\n1\n13\n"}, {"input": "4 3\n3 3\n3 105\n10 29\n31 32\n27 5\n50 50\n0 0", "output": "3\n0\n1\n5\n30\n7\n13\n"}, {"input": "4 3\n3 3\n3... | code_stdio |
[
{
"content": "You are given a matrix, consisting of n rows and m columns. The rows are numbered top to bottom, the columns are numbered left to right.\n\nEach cell of the matrix can be either free or locked.\n\nLet's call a path in the matrix a staircase if it: \n\n * starts and ends in the free cell; \n * vi... | [{"input": "9 10 30\n5 3\n5 5\n5 10\n1 3\n5 7\n1 8\n4 9\n2 10\n4 10\n3 1\n2 5\n3 8\n1 7\n2 2\n1 5\n2 3\n3 2\n3 10\n3 2\n2 7\n2 4\n1 4\n4 8\n2 8\n4 1\n5 3\n4 6\n5 8\n1 5\n1 1\n", "output": "1027\n857\n829\n783\n664\n648\n619\n611\n606\n595\n548\n527\n521\n486\n480\n469\n462\n458\n465\n458\n451\n450\n420\n417\n404\n470\n... | code_stdio |
[
{
"content": "Compute A \\times B, truncate its fractional part, and print the result as an integer.\n\n-----Constraints-----\n - 0 \\leq A \\leq 10^{15}\n - 0 \\leq B < 10\n - A is an integer.\n - B is a number with two digits after the decimal point.\n\n-----Input-----\nInput is given from Standard Input in t... | [{"input": "1000000000000000 9.99\n", "output": "9990000000000000\n"}, {"input": "1010000000000101 9.99", "output": "10089900000001008\n"}, {"input": "1010000000100101 9.99", "output": "10089900001000008\n"}, {"input": "1010000100000101 9.99", "output": "10089900999001008\n"}, {"input": "1010010100000101 9.99", "output... | code_stdio |
[
{
"content": "Ivan wants to have a good dinner. A good dinner should consist of a first course, a second course, a drink, and a dessert.\n\nThere are $n_1$ different types of first courses Ivan can buy (the $i$-th of them costs $a_i$ coins), $n_2$ different types of second courses (the $i$-th of them costs $b_i... | [{"input": "5 5 5 5\n836 776 809 618 397\n121 629 373 169 333\n589 439 410 388 446\n936 472 433 647 791\n25\n1 2\n4 5\n5 4\n4 1\n3 5\n5 2\n2 4\n3 4\n3 3\n3 2\n4 4\n4 3\n1 1\n1 4\n5 1\n2 3\n1 5\n5 5\n2 5\n3 1\n2 1\n2 2\n1 3\n5 3\n4 2\n25\n1 1\n5 4\n4 1\n1 2\n1 4\n2 3\n3 3\n4 3\n2 2\n5 3\n2 1\n1 3\n5 5\n3 5\n2 4\n3 1\n5 ... | code_stdio |
[
{
"content": "There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i.\n\nSnuke can perform the following operation zero or more times:\n\n* Choose two distinct cities that are not directly connected by a road, and build a new road between t... | [{"input": "103 1\n6 8", "output": "101\n"}, {"input": "164 1\n6 8", "output": "162\n"}, {"input": "109 1\n5 9", "output": "107\n"}, {"input": "56 1\n12 11", "output": "54\n"}, {"input": "129 1\n4 6", "output": "127\n"}, {"input": "129 1\n6 6", "output": "128\n"}, {"input": "110 1\n3 1", "output": "108\n"}, {"input": "... | code_stdio |
[
{
"content": "Dima's got a staircase that consists of n stairs. The first stair is at height a_1, the second one is at a_2, the last one is at a_{n} (1 ≤ a_1 ≤ a_2 ≤ ... ≤ a_{n}). \n\nDima decided to play with the staircase, so he is throwing rectangular boxes at the staircase from above. The i-th box has width... | [{"input": "5\n1 2 3 6 6\n25\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 1000000000\n1 10000000... | code_stdio |
[
{
"content": "You are given a line of $n$ colored squares in a row, numbered from $1$ to $n$ from left to right. The $i$-th square initially has the color $c_i$.\n\nLet's say, that two squares $i$ and $j$ belong to the same connected component if $c_i = c_j$, and $c_i = c_k$ for all $k$ satisfying $i < k < j$. ... | [{"input": "93\n2805 3621 1888 921 2394 2426 3424 739 4404 1923 2043 1106 305 788 546 1396 2252 4915 1857 1833 2601 3148 1768 1079 893 4669 1939 1231 1019 4578 3202 3645 352 4730 2074 1251 736 168 1377 4630 1542 3083 222 2864 1 4838 1319 1037 4297 552 304 2638 3278 518 4563 513 4313 4620 4907 4990 4785 2808 4135 4171 1... | code_stdio |
[
{
"content": "You are given an integer $x$ of $n$ digits $a_1, a_2, \\ldots, a_n$, which make up its decimal notation in order from left to right.\n\nAlso, you are given a positive integer $k < n$.\n\nLet's call integer $b_1, b_2, \\ldots, b_m$ beautiful if $b_i = b_{i+k}$ for each $i$, such that $1 \\leq i \\l... | [{"input": "20 10\n21474836472147483648\n", "output": "20\n21474836482147483648\n"}, {"input": "20 19\n19999999999999999999\n", "output": "20\n20000000000000000002\n"}, {"input": "20 19\n19999999999999999999\n", "output": "20\n20000000000000000002\n"}, {"input": "20 10\n21474836472147483648\n", "output": "20\n214748364... | code_stdio |
[
{
"content": "In Chef's house there are N apples lying in a row on the floor. These apples are numbered from 1 (left most one) to N (right most one). The types of apples are also numbered by positive integers, and the type of apple i is Ti.\nChef has recently brought two trained dogs. Both of the dogs are too i... | [{"input": "5 12\n1 4 4 2 -1", "output": "-1\n"}, {"input": "5 24\n1 4 4 2 -1", "output": "-1\n"}, {"input": "5 24\n1 7 4 2 -1", "output": "-1\n"}, {"input": "5 24\n1 6 4 2 -1", "output": "-1\n"}, {"input": "5 24\n1 6 2 2 -1", "output": "-1\n"}, {"input": "5 16\n1 4 4 2 1", "output": "-1\n"}, {"input": "5 16\n1 4 4 2 0... | code_stdio |
[
{
"content": "You are given a string $s$ consisting of lowercase Latin letters. Let the length of $s$ be $|s|$. You may perform several operations on this string.\n\nIn one operation, you can choose some index $i$ and remove the $i$-th character of $s$ ($s_i$) if at least one of its adjacent characters is the p... | [{"input": "100\nyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\n", "output": "99\n"}, {"input": "100\naaaaaabbcccccccddffffhhhhhhhhiiiiiikkkkkkkkmmmmmmooooooopppprrrrrrrrrttttttvvvvvvvvvvvvxxxxxxxzzzzzz\n", "output": "21\n"}, {"input": "100\nbabaababbaabbabababbabb... | code_stdio |
[
{
"content": "The numbers 1 to n x n are contained in the n x n square squares one by one, and the sum of the squares in any vertical column and the sum of the squares in any horizontal column are diagonal squares. Those with the same sum of eyes are called magic squares.\n\nThere are the following methods to c... | [{"input": "3\n29\n0", "output": " 4 9 2\n 3 5 7\n 8 1 6\n 407 828 379 800 351 772 323 744 295 716 267 688 239 660 211 632 183 604 155 576 127 548 99 520 71 492 43 464 15\n 16 408 829 380 801 352 773 324 745 296 717 268 689 240 661 212 633 184 605 156 577 128 549 100 521 72 493 44 436\n 437 17... | code_stdio |
[
{
"content": "Write a program which manipulates a sequence A = {a0, a1, . . . , an-1} with the following operations:\n\n* find(s, t): report the minimum element in as, as+1, . . . ,at.\n* update(i, x): change ai to x.\n\n\n\nNote that the initial values of ai (i = 0, 1, . . . , n−1) are 231-1.\n\nConstraints\n\... | [{"input": "5 5\n0 0 0\n1 2 4\n1 0 0\n1 1 9\n1 1 2", "output": "2147483647\n0\n2147483647\n2147483647\n"}, {"input": "6 5\n1 0 0\n0 1 2\n1 2 3\n1 0 2\n1 2 2", "output": "2147483647\n2147483647\n2\n2147483647\n"}, {"input": "3 5\n0 0 1\n1 1 2\n1 2 2\n1 0 3\n1 0 8", "output": "2147483647\n2147483647\n1\n1\n"}, {"input": ... | code_stdio |
[
{
"content": "The last stage of Football World Cup is played using the play-off system.\n\nThere are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, t... | [{"input": "256 128 256\n", "output": "Final!\n"}, {"input": "256 128 129\n", "output": "Final!\n"}, {"input": "256 255 128\n", "output": "Final!\n"}, {"input": "256 107 129\n", "output": "Final!\n"}, {"input": "256 107 240\n", "output": "Final!\n"}, {"input": "256 128 129\n", "output": "Final!"}, {"input": "256 128 25... | code_stdio |
[
{
"content": "Dr .: Peter, I've finally done it.\n\nPeter: See you again? What kind of silly invention is this time?\n\nDr .: I finally came up with a revolutionary way to process mathematical formulas on a computer. Look at this table.\n\nOrdinary notation | Dr.'s \"breakthrough\" notation\n--- | ---\n1 + 2 | ... | [{"input": "10 0 82 - /\n4 5 - 31 1 5 * * *\n0 -2 1 + +", "output": "-0.121951\n-155.000000\n-1.000000\n"}, {"input": "10 0 82 - /\n4 5 - 60 1 5 * * *\n0 -2 1 + +", "output": "-0.121951\n-300.000000\n-1.000000\n"}, {"input": "10 0 82 - /\n4 0 - 60 1 5 * * *\n0 -2 1 + +", "output": "-0.121951\n1200.000000\n-1.000000\n"}... | code_stdio |
[
{
"content": "n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.\n\nYour task is to write a program that will find the minimum and the maximum number of pairs ... | [{"input": "1011000000 0001000\n", "output": "511059994500000 511059489505999500\n"}, {"input": "1011100000 0001000\n", "output": "511161099450000 511160594406049500\n"}, {"input": "1011110000 0001000\n", "output": "511171210495000 511170705446054500\n"}, {"input": "1011110000 0001100\n", "output": "464701054490500 511... | code_stdio |
[
{
"content": "Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.\n\nOne day in 230 AD Shapur was trying to find out if... | [{"input": "1010000011010110011101001101110001110010000111011101110010110110111111001001110100101100010101010001\n0111101000111100101100000101111010100100001000011101010100110011100011010011010101000100101011100011\n", "output": "110110101110101011000100100000101101011000111100000010011000010101110001101010000110100011... | code_stdio |
[
{
"content": "problem\n\nAt the JOI pasta shop, the recommended pasta for lunch and the set menu of freshly squeezed juice are popular. When ordering this set menu, choose one from each of the three pasta and two juices of the day. The price is the total price of pasta and juice minus 50 yen.\n\nGiven the price... | [{"input": "800\n1126\n900\n198\n330", "output": "948\n"}, {"input": "800\n1126\n900\n132\n330", "output": "882\n"}, {"input": "800\n1126\n206\n132\n330", "output": "288\n"}, {"input": "800\n1126\n180\n132\n330", "output": "262\n"}, {"input": "800\n1126\n180\n29\n330", "output": "159\n"}, {"input": "800\n1126\n280\n29\... | code_stdio |
[
{
"content": "Jeff has become friends with Furik. Now these two are going to play one quite amusing game.\n\nAt the beginning of the game Jeff takes a piece of paper and writes down a permutation consisting of n numbers: p1, p2, ..., pn. Then the guys take turns to make moves, Jeff moves first. During his move,... | [{"input": "95\n68 56 24 89 79 20 74 69 49 59 85 67 95 66 15 34 2 13 92 25 84 77 70 71 17 93 62 81 1 87 76 38 75 31 63 51 35 33 37 11 36 52 23 10 27 90 12 6 45 32 86 26 60 47 91 65 58 80 78 88 50 9 44 4 28 29 22 8 48 7 19 57 14 54 55 83 5 30 72 18 82 94 43 46 41 3 61 53 73 39 40 16 64 42 21\n", "output": "5076"}, {"inp... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.