messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
1 value
[ { "content": "Problem statement\n\nThere are rectangles with vertical and horizontal lengths of h and w, and square squares with a side length of 1 are spread inside. If the upper left cell is (0,0) and the cell to the right of j below (0,0) is represented as (i, j), (i, j) is i + j. If is even, it is painted r...
[{"input": "3\n1 11\n5 11\n4 5", "output": "6 5\n28 27\n1 1\n"}, {"input": "3\n1 11\n5 11\n3 5", "output": "6 5\n28 27\n8 7\n"}, {"input": "3\n2 11\n5 11\n3 5", "output": "1 1\n28 27\n8 7\n"}, {"input": "3\n3 12\n13 7\n1 4", "output": "1 1\n46 45\n1 1\n"}, {"input": "3\n1 8\n3 11\n4 3", "output": "1 1\n17 16\n1 1\n"}, ...
code_stdio
[ { "content": "Let's solve the geometric problem\n\nMr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems.\n\nFloating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal nu...
[{"input": "128 205", "output": "205\n"}, {"input": "110 161", "output": "161\n"}, {"input": "13 204", "output": "102\n"}, {"input": "11 251", "output": "251\n"}, {"input": "10 103", "output": "103\n"}, {"input": "23 217", "output": "217\n"}, {"input": "23 193", "output": "193\n"}, {"input": "21 440", "output": "110\n"...
code_stdio
[ { "content": "You have a long fence which consists of $n$ sections. Unfortunately, it is not painted, so you decided to hire $q$ painters to paint it. $i$-th painter will paint all sections $x$ such that $l_i \\le x \\le r_i$.\n\nUnfortunately, you are on a tight budget, so you may hire only $q - 2$ painters. O...
[{"input": "48 47\n34 44\n24 45\n21 36\n29 38\n17 29\n20 29\n30 32\n23 40\n47 48\n36 43\n2 37\n27 42\n11 17\n26 47\n4 16\n24 35\n32 47\n8 22\n28 46\n17 26\n36 43\n1 26\n26 40\n26 47\n5 38\n20 33\n6 27\n9 33\n2 7\n17 35\n12 18\n20 36\n20 43\n22 45\n13 44\n3 7\n1 33\n7 45\n20 36\n33 41\n10 11\n29 35\n17 21\n10 24\n39 41\...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \nAfter a long time, Chef has finally decided to renovate his house. Chef's house has N rooms in it numbered from 1 to N. Each room is currently painted in one of the red, blue or green colors. Your are given configurati...
[{"input": "3\n3\nRGR\n3\nRRR\n3\nGRB", "output": "1\n0\n2\n"}, {"input": "3\n3\nGRR\n3\nRRR\n3\nGRB", "output": "1\n0\n2\n"}, {"input": "3\n3\nRGR\n3\nRRR\n3\nRBG", "output": "1\n0\n2\n"}, {"input": "3\n3\nGRR\n3\nRRR\n3\nBRG", "output": "1\n0\n2\n"}, {"input": "3\n3\nRRG\n3\nRRR\n3\nRGB", "output": "1\n0\n2\n"}, {"in...
code_stdio
[ { "content": "There are league games and tournament games in sports competitions. In soccer league games, points are given to each of the wins, losses, and draws, and the rankings are competed based on the points. The points are win (3 points), negative (0 points), and draw (1 point), respectively.\n\nEnter the...
[{"input": "4\nJapan 1 0 2\nEgypt 1 3 -1\nCanada 0 2 1\nSpain 1 0 1\n3\nJndia -1 2 0\nPoland 1 1 1\nItalx 1 -1 1\n0", "output": "Japan,5\nSpain,4\nEgypt,2\nCanada,1\n\nPoland,4\nItalx,4\nJndia,-3\n"}, {"input": "4\nnapaJ 1 0 0\nEgzpt 0 2 -1\naDaadn 0 2 3\nnibpS 2 0 0\n3\nioIda 0 0 -6\nPoland 1 0 3\nItaly 2 0 1\n0", "ou...
code_stdio
[ { "content": "problem\n\nAOR Ika and you came to the tournament-style table tennis tournament singles section for reconnaissance. For AOR Ika-chan, who wants to record all the games, you decide to ask for the number of games that will be played in this tournament.\n\nThere are $ N $ players in the tournament, e...
[{"input": "66 -51", "output": "116\n"}, {"input": "66 -87", "output": "152\n"}, {"input": "66 -49", "output": "114\n"}, {"input": "96 -49", "output": "144\n"}, {"input": "96 -45", "output": "140\n"}, {"input": "96 -10", "output": "105\n"}, {"input": "96 -13", "output": "108\n"}, {"input": "96 -11", "output": "106\n"},...
code_stdio
[ { "content": "Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ryouko's Memory Note. She writes what she sees and what she hears on the notebook, and the notebook became her memory.\n\nThough Ryouko is f...
[{"input": "100 100\n28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28...
code_stdio
[ { "content": "There are N apple trees in a row. People say that one of them will bear golden apples.\nWe want to deploy some number of inspectors so that each of these trees will be inspected.\nEach inspector will be deployed under one of the trees. For convenience, we will assign numbers from 1 through N to th...
[{"input": "14 3\n", "output": "2\n"}, {"input": "20 4\n", "output": "3\n"}, {"input": "15 2\n", "output": "3\n"}, {"input": "20 2\n", "output": "4\n"}, {"input": "17 8\n", "output": "1\n"}, {"input": "15 3\n", "output": "3\n"}, {"input": "17 4\n", "output": "2\n"}, {"input": "20 1\n", "output": "7\n"}, {"input": "1 20...
code_stdio
[ { "content": "The Romans have attacked again. This time they are much more than the Persians but Shapur is ready to defeat them. He says: \"A lion is never afraid of a hundred sheep\". \n\nNevertheless Shapur has to find weaknesses in the Roman army to defeat them. So he gives the army a weakness number.\n\nIn ...
[{"input": "97\n800 771 66 126 231 306 981 96 196 229 253 35 903 739 461 962 979 347 152 424 934 586 225 838 103 178 524 400 156 149 560 629 697 417 717 738 181 430 611 513 754 595 847 464 356 640 24 854 138 481 98 371 142 460 194 288 220 41 999 581 441 407 301 651 271 226 457 393 980 166 272 250 900 337 358 359 80 904...
code_stdio
[ { "content": "There are n students who have taken part in an olympiad. Now it's time to award the students.\n\nSome of them will receive diplomas, some wiil get certificates, and others won't receive anything. Students with diplomas and certificates are called winners. But there are some rules of counting the n...
[{"input": "2106623580587 109123020071\n", "output": "9 982107180639 1124516399939 "}, {"input": "1000000000000 499999999999\n", "output": "1 499999999999 500000000000\n"}, {"input": "1000000000000 1000\n", "output": "499500499 499500499000 500000000501\n"}, {"input": "1000000000000 32416187567\n", "output": "15 486242...
code_stdio
[ { "content": "Write a program which reads a list of student test scores and evaluates the performance for each student.\n\nThe test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not...
[{"input": "92 101 -1\n16 30 -1\n0 2 -1\n-1 -1 -1", "output": "A\nD\nF\n"}, {"input": "150 64 -2\n16 30 -1\n1 0 -1\n-1 -1 -1", "output": "A\nD\nF\n"}, {"input": "116 100 -1\n16 50 -1\n1 1 0\n-1 -1 -1", "output": "A\nB\nF\n"}, {"input": "92 111 -1\n16 30 -1\n0 2 -1\n-1 -1 -1", "output": "A\nD\nF\n"}, {"input": "150 64 -...
code_stdio
[ { "content": "PolandBall has such a convex polygon with n veritces that no three of its diagonals intersect at the same point. PolandBall decided to improve it and draw some red segments. \n\nHe chose a number k such that gcd(n, k) = 1. Vertices of the polygon are numbered from 1 to n in a clockwise way. Poland...
[{"input": "2633 717\n", "output": "2 3 4 6 9 12 15 19 24 29 34 40 47 54 62 71 80 89 99 110 121 132 144 157 170 184 199 214 229 245 262 279 296 314 333 352 372 393 414 435 457 480 503 526 550 575 600 626 653 680 707 735 764 793 822 852 883 914 946 979 1012 1045 1079 1114 1149 1184 1220 1257 1294 1332 1371 1410 1449 148...
code_stdio
[ { "content": "Chef loves games! But he likes to invent his own. Now he plays game \"Digit Jump\". Chef has a sequence of digits $S_{1}, S_{2}, \\ldots , S_{N}$. He is staying in the first digit $S_{1}$ and wants to reach the last digit $S_{N}$ in the minimal number of jumps. \nWhile staying in some index $i$ Ch...
[{"input": "012134444444443", "output": "4\n"}, {"input": "20776892991725", "output": "2\n"}, {"input": "10353326888495", "output": "4\n"}, {"input": "14708953637626", "output": "5\n"}, {"input": "6858574858270", "output": "5\n"}, {"input": "2595212919780", "output": "6\n"}, {"input": "1149262658611", "output": "1\n"},...
code_stdio
[ { "content": "A sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n - For each i = 1,2,..., n-2, a_i = a_{i+2}.\n - Exactly two different numbers appear in the sequence.\nYou are given a sequence v_1,v_2,...,v_n whose length is even.\nWe would like to make this sequ...
[{"input": "34\n84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822 84822\n", "output": "17\n"}, {"input": "6\n105 119 105 119 105 119\n", "output": "0\n"}, {"input": "4\n3 1...
code_stdio
[ { "content": "Polycarp has n different binary words. A word called binary if it contains only characters '0' and '1'. For example, these words are binary: \"0001\", \"11\", \"0\" and \"0011100\".\n\nPolycarp wants to offer his set of n binary words to play a game \"words\". In this game, players name words and ...
[{"input": "4\n4\n0001\n1000\n0011\n0111\n3\n010\n111\n0\n2\n00000\n00001\n4\n01\n001\n0001\n00001\n", "output": "1\n3\n-1\n0\n\n2\n1 2\n"}, {"input": "4\n4\n0001\n0000\n0011\n0111\n3\n010\n111\n1\n2\n00000\n00001\n4\n01\n001\n0001\n00001\n", "output": "1\n1\n-1\n0\n\n2\n1 2\n"}, {"input": "4\n4\n0001\n0000\n0011\n0111...
code_stdio
[ { "content": "Nam is playing with a string on his computer. The string consists of n lowercase English letters. It is meaningless, so Nam decided to make the string more beautiful, that is to make it be a palindrome by using 4 arrow keys: left, right, up, down.\n\nThere is a cursor pointing at some symbol of th...
[{"input": "198 10\ntuxqalctjyegbvouezfiqoeoazizhmjhpcmvyvjkyrgxkeupwcmvzcosdrrfgtdmxwfttxjxsbaspjwftgpnvsfyfqsrmyjmypdwonbzwsftepwtjlgbilhcsqyfzfzrfvrvfqiwoemthwvqpvqnflqqspvqrnmvucnspexpijnivqpavqxjyucufculletaedlvut\n", "output": "695\n"}, {"input": "198 14\ntuxqalctjyegbvouezfiqoeoazizhmjhpcmvyvjkyrgxkeupwcmvzcosdr...
code_stdio
[ { "content": "You are both a shop keeper and a shop assistant at a small nearby shop. You have $n$ goods, the $i$-th good costs $a_i$ coins.\n\nYou got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. More precisely you decided to set the same pri...
[{"input": "3\n5\n1 2 6 4 5\n3\n1 2 3\n2\n777 2131\n", "output": "4\n2\n1454\n"}, {"input": "3\n5\n1 2 3 4 5\n3\n1 2 3\n2\n777 1089\n", "output": "3\n2\n933\n"}, {"input": "3\n5\n1 2 6 4 5\n3\n1 2 3\n2\n777 1089\n", "output": "4\n2\n933\n"}, {"input": "3\n5\n0 3 3 16 5\n3\n2 2 3\n2\n777 778\n", "output": "6\n3\n778\n"}...
code_stdio
[ { "content": "One day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend.\n\nFind the following:\n\n<image>\n\nConstraints\n\n* 1 ≦ N ≦ 200,000\n* (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput\n\nThe input is given from Standard Input in the following format:\n\n...
[{"input": "8\n5 3 8 1 2 6 7 4", "output": "84\n"}, {"input": "8\n4 5 8 1 2 6 7 3", "output": "86\n"}, {"input": "8\n5 4 8 1 2 6 7 3", "output": "85"}, {"input": "4\n2 3 1 4", "output": "17\n"}, {"input": "4\n1 3 4 2", "output": "20\n"}, {"input": "4\n3 2 4 1", "output": "19\n"}, {"input": "4\n2 3 4 1", "output": "20\n...
code_stdio
[ { "content": "You are given an integer N. Among the divisors of N! (= 1 \\times 2 \\times ... \\times N), how many Shichi-Go numbers (literally \"Seven-Five numbers\") are there?\nHere, a Shichi-Go number is a positive integer that has exactly 75 divisors.\n\n-----Note-----\nWhen a positive integer A divides a ...
[{"input": "100\n", "output": "543\n"}, {"input": "52\n", "output": "123\n"}, {"input": "54\n", "output": "131\n"}, {"input": "77\n", "output": "323\n"}, {"input": "78\n", "output": "324\n"}, {"input": "90\n", "output": "384\n"}, {"input": "91\n", "output": "391\n"}, {"input": "92\n", "output": "491\n"}, {"input": "94\...
code_stdio
[ { "content": "A team of students from the city S is sent to the All-Berland Olympiad in Informatics. Traditionally, they go on the train. All students have bought tickets in one carriage, consisting of n compartments (each compartment has exactly four people). We know that if one compartment contain one or two ...
[{"input": "200\n2 1 1 2 2 2 2 1 1 2 2 2 1 1 2 2 2 2 1 1 1 2 2 2 2 2 2 1 2 2 1 1 1 1 2 1 2 2 1 2 2 2 2 1 2 2 1 1 1 1 2 2 1 1 1 1 1 2 2 2 2 1 2 1 2 2 2 2 1 1 1 2 1 2 2 2 2 1 1 1 1 1 1 2 2 2 1 2 2 2 1 2 2 2 1 1 1 2 2 1 1 1 1 2 2 1 2 1 1 1 2 2 1 1 2 2 2 1 2 2 0 1 2 1 1 2 2 2 1 2 2 1 1 1 2 2 2 1 2 1 2 1 2 1 1 2 2 1 1 1 1 1...
code_stdio
[ { "content": "You are given two lists of non-zero digits.\n\nLet's call an integer pretty if its (base 10) representation has at least one digit from the first list and at least one digit from the second list. What is the smallest positive pretty integer?\n\n\n-----Input-----\n\nThe first line contains two inte...
[{"input": "9 9\n5 4 3 2 1 6 7 8 9\n3 2 1 5 4 7 8 9 6\n", "output": "1\n"}, {"input": "9 9\n1 2 3 4 5 6 7 8 9\n1 2 3 4 5 6 7 8 9\n", "output": "1\n"}, {"input": "9 9\n1 2 3 4 5 6 7 8 9\n9 8 7 6 5 4 3 2 1\n", "output": "1\n"}, {"input": "9 9\n9 8 7 6 5 4 3 2 1\n1 2 3 4 5 6 7 8 9\n", "output": "1\n"}, {"input": "9 9\n9 8...
code_stdio
[ { "content": "Polycarp is a frequent user of the very popular messenger. He's chatting with his friends all the time. He has $n$ friends, numbered from $1$ to $n$.\n\nRecall that 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.\n\nSo his...
[{"input": "100 100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 1 76 80 60 100 49 70 59 72 8 38 71 15 97 71 14 76 90 81 4 59 46 39 28 92 3 28 22 53 99 59 52 74 43 92 43 42 23 44 9 82 47 7 48 12 12 3 55 37 71 46 22 84 52 98 41 21 77 63 17 62 91\n", "o...
code_stdio
[ { "content": "Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i.\n\nHe wrote an integer X on the blackboard, then performed the following operation N times:\n\n* Choose one element from S and remove it.\n* Let x be the number written on the blackboard now, and y be the in...
[{"input": "10 100000\n13715 50001 13306 50003 50004 59986 50006 110740 62164 36071", "output": "491699060\n"}, {"input": "10 100000\n13715 50001 13306 50003 50004 59986 50006 110740 62439 36071", "output": "380819060\n"}, {"input": "10 100000\n13715 50001 13306 50003 50004 59986 50006 110740 49261 36071", "output": "6...
code_stdio
[ { "content": "An architect, Devunky, who lives in Water Deven, has been asked to renovate an old large hospital.\n\nIn some countries, people don't want to use numbers that are disliked as numerophobia (4 and 9 are famous in Japan). However, the room numbers in this hospital were numbered from 1 regardless of t...
[{"input": "15\n100\n1000000000\n1\n0", "output": "19\n155\n9358757000\n1\n"}, {"input": "15\n110\n1000000000\n1\n0", "output": "19\n178\n9358757000\n1\n"}, {"input": "15\n101\n1000000000\n3\n0", "output": "19\n157\n9358757000\n3\n"}, {"input": "15\n101\n1001000000\n3\n0", "output": "19\n157\n9372508100\n3\n"}, {"input...
code_stdio
[ { "content": "Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:\n\n * each cut should be straight (horizontal or vertical); \n * each cut should go along edges of unit squares (it is prohibite...
[{"input": "1000000000 1000000000 999999999\n", "output": "1000000000\n"}, {"input": "1000000000 1000000000 220000000\n", "output": "4000000000\n"}, {"input": "1000000000 1000000000 123456\n", "output": "8099000000000\n"}, {"input": "1000000000 1000000000 1\n", "output": "500000000000000000\n"}, {"input": "1000000000 1...
code_stdio
[ { "content": "Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $a$ of $n$ non-negative integers.\n\nDark created that array $1000$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two...
[{"input": "7\n5\n-1 3 -1 24 -1\n5\n-1 40 14 -1 35\n6\n-1 -1 6 -1 0 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n1 -1 7 10 0 0 10\n", "output": "11 13\n26 27\n3 3\n0 0\n0 0\n1 2\n10 4\n"}, {"input": "7\n5\n-1 10 -1 20 -1\n5\n-1 22 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3 -1\n7\n0 -1 12 5 2 -1 0\n", "output...
code_stdio
[ { "content": "Chef has a binary tree. The binary tree consists of 1 or more nodes. Each node has a unique integer id. Each node has up to 2 children, which are identified by their ids, and each node is the child of at most 1 other node. A node X is considered to be an ancestor of node Y if node Y is a child of ...
[{"input": "2\n1\n10 0\n6\n1 5\n2 0\n3 0\n4 0\n5 5\n10 5", "output": "10\n10\n"}, {"input": "2\n1\n4 0\n6\n1 11\n2 0\n4 0\n8 -1\n5 5\n-1 5", "output": "4\n-1\n"}, {"input": "2\n1\n4 0\n6\n1 11\n2 0\n4 0\n8 -1\n5 5\n-2 5", "output": "4\n-2\n"}, {"input": "2\n1\n16 0\n6\n-1 8\n1 1\n3 0\n7 0\n0 3\n6 5", "output": "16\n-1\...
code_stdio
[ { "content": "AtCoDeer the deer is going on a trip in a two-dimensional plane.\nIn his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.\nIf AtCoDeer is at point (x, y) at time t, he can be at one of the following points at ...
[{"input": "2\n-3 4 1\n111 4 -1", "output": "No\n"}, {"input": "2\n5 1 1\n100 1 1\n", "output": "No\n"}, {"input": "2\n5 2 3\n100 0 0", "output": "Yes\n"}, {"input": "2\n5 2 2\n100 1 -1", "output": "No\n"}, {"input": "2\n5 2 1\n111 1 0", "output": "Yes\n"}, {"input": "2\n2 1 1\n100 1 1", "output": "Yes\n"}, {"input": "...
code_stdio
[ { "content": "Each of you probably has your personal experience of riding public transportation and buying tickets. After a person buys a ticket (which traditionally has an even number of digits), he usually checks whether the ticket is lucky. Let us remind you that a ticket is lucky if the sum of digits in its...
[{"input": "100\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111112222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222\n", "output": "YES\n"}, {"input": "100\n77183123282838517843664381789267288922656323541699343586762218...
code_stdio
[ { "content": "Mr. Chanek is currently participating in a science fair that is popular in town. He finds an exciting puzzle in the fair and wants to solve it.\n\nThere are $N$ atoms numbered from $1$ to $N$. These atoms are especially quirky. Initially, each atom is in normal state. Each atom can be in an excite...
[{"input": "6 1\n1 10 10 5 20 100\n1000000 1 10 10 100 1000000\n", "output": "144\n"}, {"input": "6 1\n1 10 10 20 5 100\n1000000 1 10 100 10 1000000\n", "output": "144\n"}, {"input": "6 1\n1 10 10 5 20 100\n1000000 1 10 10 100 1000000\n", "output": "144\n"}, {"input": "6 1\n1 10 10 20 5 100\n1000000 1 10 100 10 1000000...
code_stdio
[ { "content": "George is a cat, so he really likes to play. Most of all he likes to play with his array of positive integers b. During the game, George modifies the array by using special changes. Let's mark George's current array as b_1, b_2, ..., b_{|}b| (record |b| denotes the current length of the array). Th...
[{"input": "69756649467079322827497669450385938193725265564551073376856848456377282337192553343102536673046067874193973249293390979688852602950724884726382282903675659200865787042684264196306648305545290076062924087939978017987667847105325657080274323400258982046115892228300171243907466293917094607884335945541120514423...
code_stdio
[ { "content": "There is \"7 rows\" in the game using playing cards. Here we consider a game that simplifies it. Arrange 7 using 13 cards with numbers 1 to 13 written on each. In the match, the game progresses as follows with only two players.\n\n1. Place 7 cards in the \"field\".\n2. Six remaining cards will be ...
[{"input": "5\n1 2 3 4 5 6\n1 3 5 6 8 4\n1 2 3 4 6 8\n1 2 3 5 10 11\n1 3 3 6 9 11", "output": "yes\nyes\nyes\nyes\nno\n"}, {"input": "5\n1 2 3 4 5 10\n1 3 5 6 12 3\n1 2 3 4 6 8\n1 2 4 5 10 11\n1 4 2 6 9 5", "output": "no\nno\nyes\nyes\nyes\n"}, {"input": "5\n1 2 3 4 5 6\n1 3 5 6 8 4\n1 2 3 4 6 8\n1 2 3 5 10 11\n1 3 3 2...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nVadim and Roman like discussing challenging problems with each other. One day Vadim told his friend following problem:\nGiven N points on a plane. Each point p is defined by it's two integer coordinates — p_{x} and p_{y}. The di...
[{"input": "2\n2\n2 -1\n2 0\n3\n-1 1\n-1 0\n-2 1", "output": "3\n0\n"}, {"input": "2\n2\n2 -1\n0 0\n3\n-1 1\n-1 0\n-2 1", "output": "3\n0\n"}, {"input": "2\n2\n0 2\n-1 -1\n3\n3 3\n0 -1\n1 3", "output": "3\n0\n"}, {"input": "2\n2\n0 2\n-1 -1\n3\n5 3\n0 -1\n1 3", "output": "3\n0\n"}, {"input": "2\n2\n2 3\n0 0\n2\n3 -1\n-...
code_stdio
[ { "content": "Example\n\nInput\n\n2 2\n1 2 0\n3 4 1\n\n\nOutput\n\n2\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.", "role": "user" } ]
[{"input": "8 0\n-2 0 1\n12 2 12", "output": "680445551\n"}, {"input": "4 0\n-2 0 -1\n12 2 5", "output": "15400\n"}, {"input": "4 0\n-2 0 1\n12 2 10", "output": "15400\n"}, {"input": "4 0\n1 0 1\n9 -1 -1", "output": "15400\n"}, {"input": "4 0\n1 0 0\n9 -1 -1", "output": "15400\n"}, {"input": "4 0\n-2 0 0\n12 2 5", "out...
code_stdio
[ { "content": "This problem differs from the previous one only in the absence of the constraint on the equal length of all numbers $a_1, a_2, \\dots, a_n$.\n\nA team of SIS students is going to make a trip on a submarine. Their target is an ancient treasure in a sunken ship lying on the bottom of the Great Rybin...
[{"input": "100\n463 6421 2912 1546 3999 5175 4357 2259 7380 6081 1148 7857 3532 4168 5643 8819 2568 6681 975 9216 4590 5217 6215 7422 6631 1651 39 4268 8290 2022 3175 8281 1552 980 9314 234 934 5133 6712 1880 2766 5042 5004 5455 6038 6010 6022 1553 4015 4544 3985 4033 223 7682 6302 2121 4832 3956 9872 8340 5327 6763 2...
code_stdio
[ { "content": "Chanek Jones is back, helping his long-lost relative Indiana Jones, to find a secret treasure in a maze buried below a desert full of illusions.\n\nThe map of the labyrinth forms a tree with n rooms numbered from 1 to n and n - 1 tunnels connecting them such that it is possible to travel between e...
[{"input": "4 4\n2 -1000 100 3\n2 1\n3 2\n4 1\n2 1 3\n2 2 2\n1 1 -1000000000\n2 1 4\n", "output": "2102\n0\n1000000003\n"}, {"input": "4 4\n2 -1000 100 3\n2 1\n3 2\n4 2\n2 1 3\n2 2 2\n1 1 -1000000000\n2 1 4\n", "output": "2102\n0\n1000002003\n"}, {"input": "4 4\n2 -1000 100 3\n2 1\n3 2\n4 2\n2 2 3\n2 2 2\n1 1 -10000000...
code_stdio
[ { "content": "Dr. Evil kidnapped Mahmoud and Ehab in the evil land because of their performance in the Evil Olympiad in Informatics (EOI). He decided to give them some problems to let them go.\n\nDr. Evil is interested in sets, He has a set of n integers. Dr. Evil calls a set of integers evil if the MEX of it i...
[{"input": "100 100\n58 88 12 71 22 1 40 19 73 20 67 48 57 17 69 36 100 35 33 37 72 55 52 8 89 85 47 42 78 70 81 86 11 9 68 99 6 16 21 61 53 98 23 62 32 59 51 0 87 24 50 30 65 10 80 95 7 92 25 74 60 79 91 5 13 31 75 38 90 94 46 66 93 34 14 41 28 2 76 84 43 96 3 56 49 82 27 77 64 63 4 45 18 29 54 39 15 26 83 44\n", "out...
code_stdio
[ { "content": "Let's call an undirected graph of n vertices p-interesting, if the following conditions fulfill: the graph contains exactly 2n + p edges; the graph doesn't contain self-loops and multiple edges; for any integer k (1 ≤ k ≤ n), any subgraph consisting of k vertices contains at most 2k + p edges....
[{"input": "5\n24 228\n24 228\n24 228\n24 228\n24 228\n", "output": "1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n2 10\n2 11\n2 12\n2 13\n2 14\n2 15\n2 16\n2 17\n2 18\n2 19\n2 20\n2 21\n2 22\n2 23\n2 ...
code_stdio
[ { "content": "E869120 defined a sequence $a$ like this:\n\n\n* $a_1=a_2=1$, $a_{k+2}=a_{k+1}+a_k \\ (k \\ge 1)$\n\n\nHe also defined sequences $d_1, d_2, d_3, \\dots , d_n$, as the following recurrence relation :\n\n\n* $d_{1, j} = a_j$\n* $d_{i, j} = \\sum_{k = 1}^j d_{i - 1, k} \\ (i \\ge 2)$\n\n\nYou are giv...
[{"input": "42 102", "output": "184174004\n"}, {"input": "42 123", "output": "268300608\n"}, {"input": "46 123", "output": "960087486\n"}, {"input": "70 123", "output": "396400358\n"}, {"input": "42 140", "output": "918023453\n"}, {"input": "46 178", "output": "108507677\n"}, {"input": "118 12", "output": "677962323\n"...
code_stdio
[ { "content": "Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere else.\n\nFor example, the numbers 1727374, 17, 1 are 7-magic but 77, 7, 123, 34, 71 are not 7-magic. On the other hand the number 7 is...
[{"input": "1286 4\n1886373541983002858974907276497223649072414883083336663541044958378875954171855070620868427474284001\n4050983123791059817478363830631049287126338893626273758612677264947268375965600848751800494833017145\n", "output": "820371303\n"}, {"input": "516 4\n1886373541983002858974907276497223649072414883083...
code_stdio
[ { "content": "Cowboy Beblop is a funny little boy who likes sitting at his computer. He somehow obtained two elastic hoops in the shape of 2D polygons, which are not necessarily convex. Since there's no gravity on his spaceship, the hoops are standing still in the air. Since the hoops are very elastic, Cowboy B...
[{"input": "16\n0 1000 0\n436 1013 0\n509 517 0\n1000 500 0\n1000 1000 0\n1401 1028 0\n1434 461 0\n2086 442 0\n2079 1044 0\n2506 1032 0\n2549 450 0\n3077 446 0\n3063 1067 0\n3715 1062 0\n3756 -125 0\n0 0 0\n16\n-243 700 394\n109 700 365\n129 700 -366\n763 700 -366\n725 700 397\n1131 700 409\n1173 700 -339\n2294 700 -43...
code_stdio
[ { "content": "Vika has an infinite sheet of squared paper. Initially all squares are white. She introduced a two-dimensional coordinate system on this sheet and drew n black horizontal and vertical segments parallel to the coordinate axes. All segments have width equal to 1 square, that means every segment occu...
[{"input": "10\n-357884841 -999999905 -357884841 999999943\n-130177221 999999983 -130177221 -999999974\n627454332 999999936 627454332 -999999900\n999999986 366591992 -999999919 366591992\n488824292 999999952 488824292 -999999979\n-261575319 999999910 -261575319 -999999995\n837827059 -999999983 837827059 999999984\n-999...
code_stdio
[ { "content": "We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions:\n\n* Question 1: Are you subscribing to Newspaper X?\n* Question 2: Are you subscribing to Newspaper Y?\n\n\n\nAs the result, A respondents answered \"yes\" to Quest...
[{"input": "101 110 100", "output": "100 109\n"}, {"input": "100 110 100", "output": "100 110\n"}, {"input": "000 110 100", "output": "100 210\n"}, {"input": "000 100 100", "output": "100 200\n"}, {"input": "000 101 100", "output": "100 201\n"}, {"input": "100 101 100", "output": "100 101\n"}, {"input": "101 101 100", ...
code_stdio
[ { "content": "Tunnel formula\n\nOne day while exploring an abandoned mine, you found a long formula S written in the mine. If you like large numbers, you decide to take out the choke and add `(` or `)` so that the result of the formula calculation is as large as possible. If it has to be a mathematical formula ...
[{"input": "2-(2-3+4+5)", "output": "12\n"}, {"input": "3+(2-4-4+5)", "output": "10\n"}, {"input": "2-(2-3+4+6)", "output": "13\n"}, {"input": "3+(2-4-4+6)", "output": "11\n"}, {"input": "4-(2+5-0+2)", "output": "-1\n"}, {"input": "2-(2-3+4+7)", "output": "14\n"}, {"input": "0-(4+5-1+6)", "output": "-2\n"}, {"input": "...
code_stdio
[ { "content": "Chef Ciel wants to put a fancy neon signboard over the entrance of her restaurant. She has not enough money to buy the new one so she bought some old neon signboard through the internet. Ciel was quite disappointed when she received her order - some of its letters were broken. But she realized tha...
[{"input": "5\n????CIELIS???E?\n????CIELISOUR???F\nT?KEITE?SY\n????????\n@??C???", "output": "CHEFCIELISACHEF\nCHEFCIELISOURCHEF\nTAKEITEASY\nCHEFCHEF\n@AACHEF\n"}, {"input": "5\n????CIELIS???E?\n????CIELISOUR???F\nYS?ETIEK?T\n????????\n@??C???", "output": "CHEFCIELISACHEF\nCHEFCIELISOURCHEF\nYSAETIEKAT\nCHEFCHEF\n@AAC...
code_stdio
[ { "content": "You are given a rectangular grid with $n$ rows and $m$ columns. The cell located on the $i$-th row from the top and the $j$-th column from the left has a value $a_{ij}$ written in it.\n\nYou can perform the following operation any number of times (possibly zero):\n\nChoose any two adjacent cells a...
[{"input": "2\n2 2\n-1 1\n1 1\n3 4\n-1 -1 -2 -10\n0 -2 -5 -6\n-1 -3 -4 -5\n", "output": "2\n40\n"}, {"input": "2\n2 2\n-1 1\n1 1\n3 4\n-1 -1 -2 -3\n-1 -2 -3 -4\n-2 -1 -8 -5\n", "output": "2\n33\n"}, {"input": "2\n2 2\n-1 1\n1 1\n3 4\n-1 -1 -2 -3\n-1 -2 -2 -4\n-2 -1 -8 -5\n", "output": "2\n32\n"}, {"input": "2\n2 2\n-1 ...
code_stdio
[ { "content": "Problem\n\nDen, the phone number of Ukunikia Co., Ltd., enters a very long phone number into the phone every day.\nOne day, too tired, Den came up with a surprising idea.\n\"Isn't it even a little easier if you rearrange the arrangement of the buttons on the phone ?!\"\n\nThe phone has squares eve...
[{"input": "11\n129483884450", "output": "125\n694\n738\n"}, {"input": "11\n128935478480", "output": "123\n689\n745\n"}, {"input": "11\n18396312558", "output": "124\n857\n369\n"}, {"input": "11\n24764186449", "output": "318\n246\n597\n"}, {"input": "11\n31342613688", "output": "134\n562\n789\n"}, {"input": "11\n1173265...
code_stdio
[ { "content": "Petya has a rectangular Board of size $n \\times m$. Initially, $k$ chips are placed on the board, $i$-th chip is located in the cell at the intersection of $sx_i$-th row and $sy_i$-th column.\n\nIn one action, Petya can move all the chips to the left, right, down or up by $1$ cell.\n\nIf the chip...
[{"input": "10 10 20\n7 5\n4 5\n5 4\n7 4\n1 5\n6 7\n9 10\n8 4\n1 4\n2 10\n3 10\n4 10\n0 6\n5 7\n6 2\n1 1\n10 9\n7 6\n1 4\n11 4\n8 2\n10 3\n5 1\n10 8\n4 2\n1 9\n1 10\n9 5\n2 2\n6 7\n8 6\n8 9\n2 2\n7 1\n3 3\n1 2\n6 20\n9 4\n10 2\n7 7\n", "output": "117\nUUUUUUUUULLLLLLLLLRRRRRRRRRDLLLLLLLLLDRRRRRRRRRDLLLLLLLLLDRRRRRRRRRD...
code_stdio
[ { "content": "You may know that Euclid was a mathematician. Well, as it turns out, Morpheus knew it too. So when he wanted to play a mean trick on Euclid, he sent him an appropriate nightmare. \n\nIn his bad dream Euclid has a set S of n m-dimensional vectors over the Z_2 field and can perform vector addition o...
[{"input": "50 500000\n2 57 94\n2 1 10\n2 97 98\n2 15 86\n2 66 84\n2 40 100\n2 8 27\n2 14 43\n2 55 75\n2 25 90\n2 22 69\n2 9 12\n2 32 34\n2 24 48\n2 54 88\n2 13 50\n2 30 56\n2 38 77\n2 4 70\n2 39 92\n2 23 72\n2 17 36\n2 20 29\n2 6 51\n2 11 87\n2 21 68\n2 59 80\n2 52 61\n2 26 42\n2 2 37\n2 45 62\n2 28 83\n2 41 73\n2 46 ...
code_stdio
[ { "content": "Recently Vasya found a golden ticket — a sequence which consists of $n$ digits $a_1a_2\\dots a_n$. Vasya considers a ticket to be lucky if it can be divided into two or more non-intersecting segments with equal sums. For example, ticket $350178$ is lucky since it can be divided into three segments...
[{"input": "100\n0809740931424957283280264749151125408689778966769781910603952566405858112111930579193115510555198933\n", "output": "YES\n"}, {"input": "100\n4360837235306857829226262079948050131795231482102447137288804547991971660484969090651046154392003840\n", "output": "YES\n"}, {"input": "100\n481885884397341317392...
code_stdio
[ { "content": "Vasya is a school PE teacher. Unlike other PE teachers, Vasya doesn't like it when the students stand in line according to their height. Instead, he demands that the children stand in the following order: a1, a2, ..., an, where ai is the height of the i-th student in the line and n is the number o...
[{"input": "6\n590202194 293471749 259345095 293471749 18056518 293471749\n293471749 293471749 293471749 18056518 259345095 590202194\n", "output": "9\n5 6\n4 5\n3 4\n2 3\n1 2\n5 6\n4 5\n3 4\n5 6\n"}, {"input": "5\n470138369 747764103 729004864 491957578 874531368\n874531368 729004864 491957578 747764103 470138369\n", ...
code_stdio
[ { "content": "Vasya writes his own library for building graphical user interface. Vasya called his creation VTK (VasyaToolKit). One of the interesting aspects of this library is that widgets are packed in each other. \n\nA widget is some element of graphical interface. Each widget has width and height, and occu...
[{"input": "20\nVBox hykl\nVBox enwv\nenwv.pack(hykl)\nVBox dlepf\ndlepf.pack(hykl)\nenwv.set_border(30)\nWidget mjrrik(54,21)\nhykl.set_border(2)\ndlepf.set_border(22)\nenwv.set_border(3)\nenwv.pack(dlepf)\ndlepf.pack(mjrrik)\nhykl.set_spacing(96)\nenwv.set_border(32)\ndlepf.set_border(72)\nWidget j(54,86)\nhykl.pack(...
code_stdio
[ { "content": "A star map in Berland is a checked field n × m squares. In each square there is or there is not a star. The favourite constellation of all Berland's astronomers is the constellation of the Cross. This constellation can be formed by any 5 stars so, that for some integer x (radius of the constellati...
[{"input": "10 10 40\n**********\n**********\n**********\n**********\n**********\n**********\n**********\n**********\n**********\n**********\n", "output": "6 9\n5 9\n7 9\n6 8\n6 10\n"}, {"input": "10 10 59\n**.*******\n********.*\n***.******\n**.*******\n*******.**\n**********\n**.**.****\n.*********\n*****.****\n*****...
code_stdio
[ { "content": "You know that Japan is the country with almost the largest 'electronic devices per person' ratio. So you might be quite surprised to find out that the primary school in Japan teaches to count using a Soroban — an abacus developed in Japan. This phenomenon has its reasons, of course, but we are not...
[{"input": "1116434957\n", "output": "-O|OO-OO\n-O|-OOOO\n-O|OOOO-\nO-|OOOO-\nO-|OOO-O\nO-|OOOO-\n-O|O-OOO\nO-|O-OOO\nO-|O-OOO\nO-|O-OOO\n"}, {"input": "1603481361\n", "output": "O-|O-OOO\n-O|O-OOO\nO-|OOO-O\nO-|O-OOO\n-O|OOO-O\nO-|OOOO-\nO-|OOO-O\nO-|-OOOO\n-O|O-OOO\nO-|O-OOO\n"}, {"input": "1231106676\n", "output": "...
code_stdio
[ { "content": "The Kingdom of Takahashi has N towns, numbered 1 through N.\nThere is one teleporter in each town. The teleporter in Town i (1 \\leq i \\leq N) sends you to Town A_i.\nTakahashi, the king, loves the positive integer K. The selfish king wonders what town he will be in if he starts at Town 1 and use...
[{"input": "6 727202214173249351\n6 5 2 5 3 2\n", "output": "2\n"}, {"input": "6 1007784494318310970\n6 5 2 5 3 2", "output": "3\n"}, {"input": "6 1122048832909353099\n6 4 1 1 3 2", "output": "4\n"}, {"input": "6 2190427306125562200\n6 4 1 1 3 2", "output": "1\n"}, {"input": "6 2190427306125562200\n6 4 2 1 3 2", "outpu...
code_stdio
[ { "content": "Nazar, a student of the scientific lyceum of the Kingdom of Kremland, is known for his outstanding mathematical abilities. Today a math teacher gave him a very difficult task.\n\nConsider two infinite sets of numbers. The first set consists of odd positive numbers ($1, 3, 5, 7, \\ldots$), and the ...
[{"input": "1000000000000000000 1000000000000000000\n", "output": "975735772\n"}, {"input": "1000000000000000000 1000000000010000000\n", "output": "636734266\n"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "975735772"}, {"input": "100879890062904086 919413561635743169\n", "output": "824441806\n"},...
code_stdio
[ { "content": "The employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble.\n\nThe point is to trick the spectator's attention. Initially, the spectator stands in front of a line of n plastic cups. Then the magici...
[{"input": "100 50\n11 28\n11 1\n98 58\n38 27\n24 27\n67 37\n90 48\n91 14\n43 29\n3 64\n24 6\n53 19\n97 65\n13 27\n75 53\n37 82\n69 75\n94 99\n1 26\n95 60\n45 27\n100 82\n71 49\n86 99\n74 58\n88 68\n39 63\n38 23\n22 39\n29 58\n62 83\n62 1\n61 58\n2 30\n41 48\n83 90\n1 17\n73 81\n23 53\n71 16\n43 29\n27 78\n54 48\n6 89\...
code_stdio
[ { "content": "A factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-day period to do maintenance and construction; it cannot produce any thimbles ...
[{"input": "5 2 2 1 8\n1 1 2\n1 5 3\n1 2 1\n2 2\n1 4 2\n1 3 0\n2 1\n2 3\n", "output": "3\n4\n4\n"}, {"input": "5 2 2 2 8\n1 1 2\n1 5 3\n1 2 1\n2 2\n1 4 2\n1 3 2\n2 1\n2 3\n", "output": "4\n6\n5\n"}, {"input": "5 2 2 1 8\n1 1 2\n1 5 3\n1 2 1\n2 2\n1 5 2\n1 3 0\n2 1\n2 3\n", "output": "3\n2\n4\n"}, {"input": "5 2 2 2 8\n...
code_stdio
[ { "content": "A programming competition site AtCode provides algorithmic problems.\nEach problem is allocated a score based on its difficulty.\nCurrently, for each integer i between 1 and D (inclusive), there are p_i problems with a score of 100i points.\nThese p_1 + … + p_D problems are all of the problems ava...
[{"input": "10 10550000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n", "output": "1000\n"}, {"input": "10 100\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1000000\n100 1...
code_stdio
[ { "content": "The Quarkgo Empire Expeditionary Force is an evil organization that plans to invade the Earth. In keeping with the tradition of the invaders, they continued to send monsters at a pace of one every week, targeting the area around Tokyo in Japan. However, each time, five warriors calling themselves ...
[{"input": "1204648530", "output": "20\n"}, {"input": "3727082973", "output": "21\n"}, {"input": "1369610954", "output": "20\n"}, {"input": "2281056559", "output": "20\n"}, {"input": "104442668", "output": "17\n"}, {"input": "518772949", "output": "19\n"}, {"input": "169668482", "output": "18\n"}, {"input": "2000000000...
code_stdio
[ { "content": "Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on eac...
[{"input": "420196140727489673 679891637638612258\n", "output": "1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B1A1B"}, {"input": "498454011879264 806515533049393\n", "output": "1B1A1B1A1B1A1B1A1B1A1B1...
code_stdio
[ { "content": "Vasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.\n\nThere are n solutions, the i-th of them should be tested on a_i tests, testing one solution on one test takes 1 second. The solutions are judged in the order from 1 to ...
[{"input": "100 10\n3 114 77 78 105 87 6 122 141 100 75 118 64 18 88 37 109 72 31 101 36 10 62 18 52 17 149 115 22 150 138 48 46 42 104 8 63 21 117 58 87 80 7 131 125 118 67 13 144 43 59 67 74 13 124 77 86 148 107 11 51 9 87 52 147 22 7 22 143 12 121 123 17 35 33 87 91 140 92 38 106 10 66 26 40 100 121 42 134 127 116 1...
code_stdio
[ { "content": "The year 2015 is almost over.\n\nLimak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system — 2015_10 = 11111011111_2. Note that he doesn't care about the number of zeros in the deci...
[{"input": "1000000000000000000 1000000000000000000\n", "output": "0\n"}, {"input": "500000000000000000 1000000000000000000\n", "output": "58\n"}, {"input": "500000000000000000 1000000000000000000\n", "output": "58\n"}, {"input": "1000000000000000000 1000000000000000000\n", "output": "0\n"}, {"input": "5000000000000000...
code_stdio
[ { "content": "Once upon a time in the Kingdom of Far Far Away lived Sir Lancelot, the chief Royal General. He was very proud of his men and he liked to invite the King to come and watch drill exercises which demonstrated the fighting techniques and tactics of the squad he was in charge of. But time went by and ...
[{"input": "1000 1000\n", "output": "500000\n"}, {"input": "999 1000\n", "output": "499500\n"}, {"input": "1000 997\n", "output": "498500\n"}, {"input": "997 1000\n", "output": "498500\n"}, {"input": "998 1000\n", "output": "499000\n"}, {"input": "1000 999\n", "output": "499500\n"}, {"input": "1000 998\n", "output": "4...
code_stdio
[ { "content": "Serval soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.\n\nIn his favorite math class, the teacher taught him the following interesting definitions.\n\nA parenthesis sequence is a string, containing only characters \"(\" and \")\".\n\nA correct parenthesis seq...
[{"input": "300\n??????(??????(???)??(???????)??????)((??????(???(??)())?(???????)???????????((??(??(??(?)???)(????)??(??(?(??(????????()?????(????(?(??(?(?????)??(????(????(??(??(????((??)(??(??????????????????(????????(????(?(???????(??(????(???)?(???????)?)??(?????((??(??(??????????()?????(??????)??(((??(????????\n"...
code_stdio
[ { "content": "Miyako came to the flea kingdom with a ukulele. She became good friends with local flea residents and played beautiful music for them every day.\n\nIn return, the fleas made a bigger ukulele for her: it has $n$ strings, and each string has $(10^{18} + 1)$ frets numerated from $0$ to $10^{18}$. The...
[{"input": "10\n13 18 10 3 9 19 20 4 10 5\n20\n0 9\n5 11\n1 5\n1 16\n3 3\n0 7\n10 19\n14 20\n6 15\n11 12\n13 16\n11 13\n3 9\n7 10\n2 2\n10 11\n17 20\n17 18\n0 15\n0 6\n", "output": "27 24 22 33 9 25 27 24 27 13 20 17 24 20 9 13 20 13 33 24\n"}, {"input": "10\n13 18 10 3 9 19 20 4 10 5\n20\n0 9\n5 11\n1 5\n1 16\n3 3\n0 ...
code_stdio
[ { "content": "The range search problem consists of a set of attributed records S to determine which records from S intersect with a given range.\n\nFor n points on a plane, report a set of points which are within in a given range. Note that you do not need to consider insert and delete operations for the set.\n...
[{"input": "6\n0 1\n4 0\n5 0\n6 4\n3 2\n11 6\n2\n-1 4 -1 2\n0 8 0 5", "output": "0\n1\n4\n\n0\n1\n2\n3\n4\n\n"}, {"input": "6\n2 1\n2 2\n4 2\n4 2\n3 3\n5 4\n2\n2 4 0 4\n4 10 2 5", "output": "0\n1\n2\n3\n4\n\n2\n3\n5\n\n"}, {"input": "6\n0 1\n4 2\n5 0\n6 4\n3 2\n11 4\n2\n-1 4 -1 2\n3 8 0 5", "output": "0\n1\n4\n\n1\n2\n...
code_stdio
[ { "content": "We have N points numbered 1 to N arranged in a line in this order.\n\nTakahashi decides to make an undirected graph, using these points as the vertices. In the beginning, the graph has no edge. Takahashi will do M operations to add edges in this graph. The i-th operation is as follows:\n\n* The op...
[{"input": "14 7\n2 4 18\n1 4 10\n2 3 1\n4 10 10\n3 9 -1\n6 14 5\n5 10 0", "output": "14\n"}, {"input": "10 7\n1 5 18\n3 4 14\n1 3 5\n4 7 10\n1 9 8\n6 10 5\n5 10 10", "output": "13\n"}, {"input": "10 7\n1 5 18\n3 4 10\n1 2 5\n4 7 10\n3 9 1\n6 10 6\n5 10 10", "output": "25\n"}, {"input": "10 7\n1 5 18\n3 4 13\n1 3 10\n3...
code_stdio
[ { "content": "Vova has won $n$ trophies in different competitions. Each trophy is either golden or silver. The trophies are arranged in a row.\n\nThe beauty of the arrangement is the length of the longest subsegment consisting of golden trophies. Vova wants to swap two trophies (not necessarily adjacent ones) t...
[{"input": "300\nSSGSGSSSGSGSSSSGGSGSSGGSGSGGSSSGSSGSGGSSGGSGSSGGSGGSSGSSSGSGSGSSGSGGSSSGSSGSSGGGGSSGSSGSSGSGGSSSSGGGGSSGSSSSSSSSGSSSSGSGSSSSSSSSGSGSSSSGSSGGSSGSGSSSSSSGSGSSSGGSSGSGSSGSSSSSSGGGSSSGSGSGSGGSGGGSSGSGSSSGSSGGSSGSSGGGGSGSSGSSSSGGSSSSGGSGSSSSSSGSSSGGGSGSGGSSGSSSSSSGGSSSGSSSSGGGSSGSSSGSGGGSSSSGSSSGSGSGGGGS\n"...
code_stdio
[ { "content": "In distant future on Earth day lasts for n hours and that's why there are n timezones. Local times in adjacent timezones differ by one hour. For describing local time, hours numbers from 1 to n are used, i.e. there is no time \"0 hours\", instead of it \"n hours\" is used. When local time in the 1...
[{"input": "100\n6072 8210 6405 1191 2533 8552 7594 8793 2207 8855 7415 6252 3433 2339 5532 3118 3054 5750 3690 9843 3881 1390 936 8611 7099 988 7730 3835 7065 5030 6932 6936 5531 5173 1331 8975 5454 1592 8516 328 1091 4368 8275 6462 8638 4002 5534 113 6295 5960 1688 3668 6604 9632 4214 8687 7950 3483 6149 4301 6607 11...
code_stdio
[ { "content": "On a history lesson the teacher asked Vasya to name the dates when n famous events took place. He doesn't remembers the exact dates but he remembers a segment of days [li, ri] (inclusive) on which the event could have taken place. However Vasya also remembers that there was at most one event in on...
[{"input": "10\n10 10\n13 15\n6 14\n10 15\n4 15\n11 12\n11 15\n8 15\n1 11\n1 9\n", "output": "10 14 6 12 4 11 13 8 2 1\n"}, {"input": "10\n10 10\n13 15\n6 14\n10 15\n4 15\n11 12\n11 15\n5 15\n1 11\n1 9\n", "output": "10 14 6 12 4 11 13 5 2 1\n"}, {"input": "10\n10 10\n13 15\n6 14\n10 15\n4 15\n11 12\n11 15\n8 15\n1 20\...
code_stdio
[ { "content": "Mr. Bill is shopping at the store. There are some coins in his wallet (10-yen coins, 50-yen coins, 100-yen coins, 500-yen coins), but he is now trying to consume as much of this coin as possible. In other words, by paying for the goods with an appropriate number of coins, we are trying to minimize...
[{"input": "160\n1 1 2 0\n160\n1 1 2 10\n0", "output": "10 1\n50 1\n100 1\n\n10 1\n50 1\n100 1\n"}, {"input": "160\n1 1 2 0\n160\n1 -1 1 10\n0", "output": "10 1\n50 1\n100 1\n\n10 1\n500 1\n"}, {"input": "160\n1 1 4 0\n125\n-1 1 2 10\n0", "output": "10 1\n50 1\n100 1\n\n50 1\n100 1\n"}, {"input": "160\n1 1 8 0\n125\n-1...
code_stdio
[ { "content": "The government of Berland decided to improve network coverage in his country. Berland has a unique structure: the capital in the center and $n$ cities in a circle around the capital. The capital already has a good network coverage (so the government ignores it), but the $i$-th city contains $a_i$ ...
[{"input": "3\n10\n3 3 2 3 2 5 1 2 11 3\n6 5 2 5 3 2 4 2 1 2\n20\n9 1 10 1 17 7 5 5 8 1 1 2 7 1 4 2 3 7 6 3\n2 6 3 2 37 1 5 5 4 5 1 3 21 15 1 7 7 5 0 1\n20\n9 1 9 1 5 1 3 2 0 3 6 1 2 8 11 7 3 5 14 2\n11 14 6 4 6 8 8 2 9 9 6 5 3 2 5 7 1 9 14 1\n", "output": "NO\nNO\nNO\n"}, {"input": "3\n10\n3 3 2 3 2 5 1 2 11 3\n6 5 2 ...
code_stdio
[ { "content": "Ridhiman challenged Ashish to find the maximum valued subsequence of an array $a$ of size $n$ consisting of positive integers. \n\nThe value of a non-empty subsequence of $k$ elements of $a$ is defined as $\\sum 2^i$ over all integers $i \\ge 0$ such that at least $\\max(1, k - 2)$ elements of the...
[{"input": "20\n541032394951352952 204302388514120798 548305186805250399 743987576790520671 332874928746186630 60150973547887825 600093435051546090 862815570651991829 798946884837606574 383607230476788640 748981752333005915 317959714195378963 824508576221039025 547099154391774856 411018774272655732 824285680939035203 1...
code_stdio
[ { "content": "We have a string s consisting of lowercase English letters. Snuke is partitioning s into some number of non-empty substrings. Let the subtrings obtained be s_1, s_2, ..., s_N from left to right. (Here, s = s_1 + s_2 + ... + s_N holds.) Snuke wants to satisfy the following condition:\n\n* For each ...
[{"input": "zyxwvutsrqponmlkjihgfedcba", "output": "26\n"}, {"input": "zyxwvutsrqponmlkjihgfedbba", "output": "24\n"}, {"input": "ayxwvutsrqponmlkiihgfedbbz", "output": "22\n"}, {"input": "ayxwwutsrqponmlkiihgfedbbz", "output": "20\n"}, {"input": "ayxwwutsrpponmlkiihgfedbbz", "output": "18\n"}, {"input": "ayxwwutsrppon...
code_stdio
[ { "content": "Vasya has a grid with $2$ rows and $n$ columns. He colours each cell red, green, or blue.\n\nVasya is colourblind and can't distinguish green from blue. Determine if Vasya will consider the two rows of the grid to be coloured the same.\n\n\n-----Input-----\n\nThe input consists of multiple test ca...
[{"input": "1\n55\nBBBBBBBBBBBBBBBBBBBGGGGGGGGGGGGGGGGGGGGGGGGGGGGBBBBGBGB\nBBBBBBBBBBBBBBBBBBBGGGGGGGGGGGGGGGGGGGGGGGGGGGGBBBBGBGB\n", "output": "YES\n"}, {"input": "6\n2\nRG\nRB\n4\nGRBG\nGBGB\n5\nGGGGG\nBBBBB\n7\nBBBBBBB\nRRRRRRR\n8\nRGBRRGBR\nRGGRRBGR\n1\nG\nG\n", "output": "YES\nNO\nYES\nNO\nYES\nYES\n"}, {"input"...
code_stdio
[ { "content": "There are N squares lining up in a row, numbered 1 through N from left to right. Initially, all squares are white. We also have N-1 painting machines, numbered 1 through N-1. When operated, Machine i paints Square i and i+1 black.\n\nSnuke will operate these machines one by one. The order in which...
[{"input": "100010", "output": "795416653\n"}, {"input": "110010", "output": "993165555\n"}, {"input": "110011", "output": "471359203\n"}, {"input": "110001", "output": "428910207\n"}, {"input": "111001", "output": "293611143\n"}, {"input": "101001", "output": "186012357\n"}, {"input": "101101", "output": "187749075\n"...
code_stdio
[ { "content": "You are given an array of $n$ integers: $a_1, a_2, \\ldots, a_n$. Your task is to find some non-zero integer $d$ ($-10^3 \\leq d \\leq 10^3$) such that, after each number in the array is divided by $d$, the number of positive numbers that are presented in the array is greater than or equal to half...
[{"input": "100\n-246 -98 -29 -208 -305 -231 -309 -632 -255 -293 -810 -283 -962 -593 -203 -40 -910 -934 -640 -520 -481 -988 -774 -696 -700 -875 -418 -750 -193 -863 -163 -498 -77 -627 -786 -820 -469 -799 -50 -162 -938 -133 -842 -144 -383 -245 -983 -975 -279 -86 -725 -304 -313 -785 -509 -192 -110 -726 -789 -36 -151 -792 ...
code_stdio
[ { "content": "Monocarp plays a computer game (yet again!). This game has a unique trading mechanics.\n\nTo trade with a character, Monocarp has to choose one of the items he possesses and trade it for some item the other character possesses. Each item has an integer price. If Monocarp's chosen item has price $x...
[{"input": "3 4 5\n10 60 30\n12 57 17 6\n0 2 2 1 1\n", "output": "100\n102\n102\n100\n100\n"}, {"input": "3 4 5\n10 60 30\n12 57 17 6\n0 2 1 1 1\n", "output": "100\n102\n100\n100\n100\n"}, {"input": "3 4 5\n10 36 60\n19 57 23 0\n0 2 2 1 1\n", "output": "106\n106\n106\n106\n106\n"}, {"input": "3 4 5\n10 60 30\n12 57 28 ...
code_stdio
[ { "content": "Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is true and the value of the second argument is false. \n\nImplication is written by using character '$\\rightarrow$', and the arguments and the result of the implication are writt...
[{"input": "200\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
code_stdio
[ { "content": "Problem\n\nIt seems that a magician with a smoky smell will show off his magic.\n\n\"Now, think of one favorite integer.\"\nYou decide to think of your counting years in your head.\n\nThe magician has thrown the query $ N $ times.\nEach query is one of the following:\n\n\n1. \"Multiply the number ...
[{"input": "10\n1 10\n2 10\n1 10\n1 10\n1 10\n1 10\n1 10\n1 10\n1 10\n1 10", "output": "-1000000000 1000000000\n"}, {"input": "10\n1 10\n1 10\n1 10\n1 10\n2 10\n1 10\n1 10\n1 10\n1 10\n1 10", "output": "-1000000 1000000000\n"}, {"input": "10\n1 10\n1 10\n1 10\n1 10\n2 10\n1 10\n1 10\n1 10\n1 10\n1 17", "output": "-1700...
code_stdio
[ { "content": "Kevin Sun wants to move his precious collection of n cowbells from Naperthrill to Exeter, where there is actually grass instead of corn. Before moving, he must pack his cowbells into k boxes of a fixed size. In order to keep his collection safe during transportation, he won't place more than two c...
[{"input": "100 49990\n221 257 543 613 818 855 884 1195 1233 1293 1327 1474 1567 1568 1728 1789 1809 1957 1994 2198 2217 2289 2298 2360 2441 2454 2517 2519 2597 2652 2909 2958 2970 3271 3310 3409 3450 3646 3950 3965 4016 4116 4134 4159 4462 4624 4631 4783 4804 5031 5276 5538 5729 5845 5880 5894 5959 5961 6028 6105 6184...
code_stdio
[ { "content": "It is so boring in the summer holiday, isn't it? So Alice and Bob have invented a new game to play. The rules are as follows. First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the curr...
[{"input": "10\n100000000 200000000 300000000 400000000 500000000 600000000 700000000 800000000 900000000 1000000000\n", "output": "Bob\n"}, {"input": "10\n100000000 200000000 300000000 400000000 500000000 600000000 700000000 800000000 900000000 1000000000\n", "output": "Bob\n"}, {"input": "10\n101000000 200000000 3000...
code_stdio
[ { "content": "Problem Statement\n\nYou are given a connected undirected graph which has even numbers of nodes. A connected graph is a graph in which all nodes are connected directly or indirectly by edges.\n\nYour task is to find a spanning tree whose median value of edges' costs is minimum. A spanning tree of ...
[{"input": "2 1\n1 2 10\n4 6\n2 2 1\n1 3 2\n1 4 3\n3 3 6\n2 4 1\n3 1 6\n8 17\n1 4 767\n3 1 609\n8 3 426\n6 5 1132\n8 1 607\n6 4 51\n5 1 683\n3 2 451\n3 8 630\n8 7 912\n3 7 20\n5 7 421\n3 5 204\n8 4 538\n5 7 1262\n1 6 604\n8 2 608\n0 0", "output": "10\n2\n426\n"}, {"input": "2 1\n1 2 10\n4 6\n2 2 1\n1 3 0\n1 4 3\n3 3 6\...
code_stdio
[ { "content": "You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute of the movie. By pressing this button, you watch the current minute of the movie and the player automatically proceeds to the next minute of the movie. Skip exactly x minutes...
[{"input": "18 111\n1449 2156\n3497 4784\n7775 14575\n23857 24593\n29211 30739\n31932 33447\n35902 36426\n36991 38506\n39679 47202\n48772 60016\n60522 61868\n63340 63982\n68417 78537\n79445 86568\n86918 87940\n90081 90310\n90629 94325\n95728 96263\n", "output": "58967\n"}, {"input": "18 111\n1449 2156\n3497 4784\n7775 ...
code_stdio
[ { "content": "To quickly hire highly skilled specialists one of the new IT City companies made an unprecedented move. Every employee was granted a car, and an employee can choose one of four different car makes.\n\nThe parking lot before the office consists of one line of (2n - 2) parking spaces. Unfortunately ...
[{"input": "30\n", "output": "4809844402031689728\n"}, {"input": "29\n", "output": "1161928703861587968\n"}, {"input": "29\n", "output": "1161928703861587968"}, {"input": "30\n", "output": "4809844402031689728"}, {"input": "28\n", "output": "280349076803813376\n"}, {"input": "28\n", "output": "280349076803813376"}, {"i...
code_stdio
[ { "content": "In this problem you will have to help Berland army with organizing their command delivery system.\n\nThere are $n$ officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer has exactly one direct superior. If officer $a$ is th...
[{"input": "13 12\n1 1 1 1 1 1 1 1 1 1 1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"input": "13 12\n1 1 1 1 1 1 1 1 1 1 1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"inp...
code_stdio
[ { "content": "Write a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\n\n\nInput\n\n...
[{"input": "10\n10\n126", "output": "4\n4\n30\n"}, {"input": "10\n117\n4", "output": "4\n30\n2\n"}, {"input": "10\n147\n9", "output": "4\n34\n4\n"}, {"input": "10\n54\n18", "output": "4\n16\n7\n"}, {"input": "10\n10\n41", "output": "4\n4\n13\n"}, {"input": "10\n36\n18", "output": "4\n11\n7\n"}, {"input": "10\n19\n43", ...
code_stdio
[ { "content": "Given is an integer r.\nHow many times is the area of a circle of radius r larger than the area of a circle of radius 1?\nIt can be proved that the answer is always an integer under the constraints given.\n\n-----Constraints-----\n - 1 \\leq r \\leq 100\n - All values in input are integers.\n\n---...
[{"input": "100\n", "output": "10000\n"}, {"input": "87\n", "output": "7569\n"}, {"input": "76\n", "output": "5776\n"}, {"input": "91\n", "output": "8281\n"}, {"input": "88\n", "output": "7744\n"}, {"input": "79\n", "output": "6241\n"}, {"input": "83\n", "output": "6889\n"}, {"input": "52\n", "output": "2704\n"}, {"inp...
code_stdio
[ { "content": "Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively. Now, they will exchange those cookies by repeating the action below:\n\n* Each person simultaneously divides his cookies in half and gives one half to each of the other two persons.\n\n\n\nThis action will be repea...
[{"input": "1390 180 1200", "output": "1\n"}, {"input": "1390 180 2246", "output": "1\n"}, {"input": "1390 180 2625", "output": "0\n"}, {"input": "1390 213 2625", "output": "0\n"}, {"input": "1390 213 4202", "output": "0\n"}, {"input": "1592 128 6815", "output": "0\n"}, {"input": "1592 128 6089", "output": "0\n"}, {"in...
code_stdio
[ { "content": "D: Shiritori Compression\n\nproblem\n\nEbi-chan and Kana-chan did a shiritori. Ebi-chan is looking at the memo of the word that came out in Shiritori.\n\nEbi-chan wants to remove redundant continuous subsequences from this word sequence w_1, w_2, ..., w_N until they no longer exist. The redundant ...
[{"input": "7\nbanana\nta\ntomb\nbus\nsound\ndoes\nsome", "output": "2\n"}, {"input": "7\nananab\nta\nsomb\nbus\nsound\ndoes\nsemo", "output": "3\n"}, {"input": "7\nbanaoa\nta\ntomb\nbus\nsound\ndoes\nsome", "output": "2\n"}, {"input": "7\nbanaoa\nta\nuomb\nbus\nsound\ndoes\nsome", "output": "2\n"}, {"input": "7\nbanao...
code_stdio
[ { "content": "Eric is the teacher of graph theory class. Today, Eric teaches independent set and edge-induced subgraph.\n\nGiven a graph $G=(V,E)$, an independent set is a subset of vertices $V' \\subset V$ such that for every pair $u,v \\in V'$, $(u,v) \\not \\in E$ (i.e. no edge in $E$ connects two vertices f...
[{"input": "50\n21 10\n30 22\n3 37\n37 32\n4 27\n18 7\n2 30\n29 19\n6 37\n12 39\n47 25\n41 49\n45 9\n25 48\n16 14\n9 7\n33 28\n3 31\n34 16\n35 37\n27 40\n45 16\n29 44\n16 15\n26 15\n1 12\n2 13\n15 21\n43 14\n9 33\n44 15\n46 1\n38 5\n15 5\n1 32\n42 35\n20 27\n23 8\n1 16\n15 17\n36 50\n13 8\n49 45\n11 2\n24 4\n36 15\n15 ...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese here \n\n------ Problem Statement ------ \n\nLira is a little girl form Bytenicut, a small and cozy village located in the country of Byteland.\n As the village is located on a somewhat hidden and isolated area, little Lira is a bit lonely and she needs...
[{"input": "2\n-1 -1 0 100 100 0\n1 2 0 11 14 1", "output": "2 1\n"}, {"input": "2\n-1 1 -1 010 000 0\n1 6 0 10 14 1", "output": "1 2\n"}, {"input": "2\n-1 1 -1 000 000 0\n1 6 0 10 14 1", "output": "1 2\n"}, {"input": "2\n-2 1 -1 010 000 0\n1 6 0 10 14 1", "output": "1 2\n"}, {"input": "2\n-1 0 -1 010 000 0\n1 3 0 7 14...
code_stdio
[ { "content": "Let f(A, B) be the exclusive OR of A, A+1, ..., B. Find f(A, B).\nWhat is exclusive OR?\nThe bitwise exclusive OR of integers c_1, c_2, ..., c_n (let us call it y) is defined as follows:\n - When y is written in base two, the digit in the 2^k's place (k \\geq 0) is 1 if, the number of integers amo...
[{"input": "1000000000000 1000000000000\n", "output": "1000000000000\n"}, {"input": "123456789012 123456789012\n", "output": "123456789012\n"}, {"input": "250874886258 260155437540\n", "output": "260155437541\n"}, {"input": "449425032568 599872999674\n", "output": "599872999675\n"}, {"input": "339795662481 341697428425...
code_stdio
[ { "content": "You have $n$ coins, each of the same value of $1$.\n\nDistribute them into packets such that any amount $x$ ($1 \\leq x \\leq n$) can be formed using some (possibly one or all) number of these packets.\n\nEach packet may only be used entirely or not used at all. No packet may be used more than onc...
[{"input": "1000000000\n", "output": "30\n"}, {"input": "1000000000\n", "output": "30"}, {"input": "723061816\n", "output": "30\n"}, {"input": "517188853\n", "output": "29\n"}, {"input": "237913214\n", "output": "28\n"}, {"input": "536870911\n", "output": "29\n"}, {"input": "781222222\n", "output": "30\n"}, {"input": "...
code_stdio
[ { "content": "The smallest unit of data handled by a computer is called a bit, and the amount of information that represents multiple bits together is called a word. Currently, many computers process one word as 32 bits.\n\nFor a computer that represents one word in 32 bits, create a program that outputs the am...
[{"input": "-322", "output": "-10304\n"}, {"input": "-542", "output": "-17344\n"}, {"input": "-130", "output": "-4160\n"}, {"input": "-133", "output": "-4256\n"}, {"input": "-199", "output": "-6368\n"}, {"input": "-177", "output": "-5664\n"}, {"input": "-35", "output": "-1120\n"}, {"input": "-32", "output": "-1024\n"},...
code_stdio
[ { "content": "The Chef commutes to work every day using the city's underground metro. The schedule for the trains has recently been changed and he wants to know how long it will take to travel from the station nearest to his house and the station nearest to his restaurant.\n\nThe Chef doesn't want to change the...
[{"input": "3\n2\n0 3 6\n0 6 8\n2\n0 -1 3\n12 4 1\n2\n0 1 8\n0 0 12", "output": "14\n16\n12\n"}, {"input": "3\n2\n0 4 12\n-1 8 5\n2\n-1 1 2\n6 8 10\n2\n1 1 5\n0 2 3", "output": "12\n14\n5\n"}, {"input": "3\n2\n0 3 7\n0 6 5\n2\n0 -1 3\n12 4 1\n2\n1 1 8\n1 0 12", "output": "11\n16\n13\n"}, {"input": "3\n2\n0 3 7\n0 6 6\n...
code_stdio
[ { "content": "A tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n.\n\nLimak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh stolen it. Bear is very sad now because he doesn't remember much about the tree —...
[{"input": "11005 209 166\n", "output": "1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n11 12\n12 13\n13 14\n14 15\n15 16\n16 17\n17 18\n18 19\n19 20\n20 21\n21 22\n22 23\n23 24\n24 25\n25 26\n26 27\n27 28\n28 29\n29 30\n30 31\n31 32\n32 33\n33 34\n34 35\n35 36\n36 37\n37 38\n38 39\n39 40\n40 41\n41 42\n42 43\n43...
code_stdio
[ { "content": "Set\n\nGiven the sequence a_1, a_2, .., a_N.\n\nHow many values ​​are there in this sequence?\n\ninput\n\n\nN\na_1 a_2 ... a_N\n\n\noutput\n\nOutput the number of types of values ​​in the sequence.\n\nConstraint\n\n* 1 \\ leq N \\ leq 10 ^ 5\n* 1 \\ leq a_i \\ leq 10 ^ 9\n\n\n\nInput example\n\n\n...
[{"input": "6\n-4 -3 1 -1 27 -1", "output": "5\n"}, {"input": "6\n-1 0 63 -1 3 -1", "output": "4\n"}, {"input": "6\n-2 -1 25 -2 4 0", "output": "5\n"}, {"input": "6\n-1 -1 25 -2 4 0", "output": "5\n"}, {"input": "6\n-1 -1 25 -2 4 1", "output": "5\n"}, {"input": "6\n-1 -1 35 -2 4 1", "output": "5\n"}, {"input": "6\n-1 2...
code_stdio
[ { "content": "You are given an integer sequence $a_1, a_2, \\dots, a_n$.\n\nFind the number of pairs of indices $(l, r)$ ($1 \\le l \\le r \\le n$) such that the value of median of $a_l, a_{l+1}, \\dots, a_r$ is exactly the given number $m$.\n\nThe median of a sequence is the value of an element which is in the...
[{"input": "15 2\n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3\n", "output": "97\n"}, {"input": "15 1\n1 2 3 1 2 3 1 2 3 1 2 3 1 2 3\n", "output": "18\n"}, {"input": "15 1\n1 2 3 0 2 3 1 2 3 1 2 3 1 2 3\n", "output": "15\n"}, {"input": "15 1\n1 2 3 0 2 3 1 2 3 1 2 3 2 2 3\n", "output": "11\n"}, {"input": "15 2\n1 2 3 1 2 3 1 2 3 1 2 ...
code_stdio