messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "Monocarp wants to watch $n$ videos. Each video is only one minute long, but its size may be arbitrary. The $i$-th video has the size $a_i$ megabytes. All videos are published on the Internet. A video should be downloaded before it can be watched. Monocarp has poor Internet connection — it takes ex... | [{"input": "6 1000000000\n999999995 999999996 999999997 999999998 999999999 1000000000\n", "output": "5999999991\n"}, {"input": "5 1000000000\n500000000 500000000 500000000 500000000 500000000\n", "output": "2500000001\n"}, {"input": "5 999999999\n500000000 500000000 500000000 500000000 500000000\n", "output": "2500000... | code_stdio |
[
{
"content": "Pablo Squarson is a well-known cubism artist. This year's theme for Pablo Squarson is \"Squares\". Today we are visiting his studio to see how his masterpieces are given birth.\n\nAt the center of his studio, there is a huuuuuge table and beside it are many, many squares of the same size. Pablo Sq... | [{"input": "1\n5\n0 0\n0 -1\n0 2\n0 3\n12\n0 0\n0 0\n2 0\n3 0\n4 1\n5 1\n6 2\n3 2\n8 2\n9 3\n10 3\n10\n0 2\n1 3\n2 2\n3 2\n2 1\n5 1\n6 1\n7 1\n3 0\n0", "output": "1 1\n3 2\n4 5\n4 5\n"}, {"input": "1\n5\n0 -1\n0 1\n0 2\n0 3\n12\n0 0\n1 0\n2 0\n3 1\n4 1\n5 1\n6 2\n7 1\n8 2\n9 3\n10 3\n10\n0 2\n1 3\n2 2\n3 2\n2 1\n5 1\n6... | code_stdio |
[
{
"content": "You are appointed director of a famous concert hall, to save it from bankruptcy. The hall is very popular, and receives many requests to use its two fine rooms, but unfortunately the previous director was not very efficient, and it has been losing money for many years. The two rooms are of the sam... | [{"input": "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n1 20 1000\n5 25 10000\n2 30 8781\n22 300 5500\n10 117 9000\n7 7 2175\n8\n32 251 2396\n132 281 1659\n222 235 5641\n162 217 1883\n22 158 7195\n194 198 9190\n119 274 1469\n122 334 13708\n0", "output": "30\n21175\n35734\n"}, {"input": "4\n1 2 10\n2 3 10\n3 3 10\n1 3 10\n6\n... | code_stdio |
[
{
"content": "We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i.\n\nEach bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. In... | [{"input": "5 0\n-8 -10 1 -1 2", "output": "-8 -10 1 -1 2\n"}, {"input": "5 0\n-11 -10 1 0 2", "output": "-11 -10 1 0 2\n"}, {"input": "5 0\n-8 -5 2 -1 2", "output": "-8 -5 2 -1 2\n"}, {"input": "5 0\n-8 -5 1 -1 2", "output": "-8 -5 1 -1 2\n"}, {"input": "5 0\n-8 -10 1 0 2", "output": "-8 -10 1 0 2\n"}, {"input": "5 0\... | code_stdio |
[
{
"content": "There is a train going from Station A to Station B that costs X yen (the currency of Japan).\nAlso, there is a bus going from Station B to Station C that costs Y yen.\nJoisino got a special ticket. With this ticket, she can take the bus for half the fare if she travels from Station A to Station B ... | [{"input": "100 100\n", "output": "150\n"}, {"input": "81 58\n", "output": "110\n"}, {"input": "100 2\n", "output": "101\n"}, {"input": "76 48\n", "output": "100\n"}, {"input": "-1 -17", "output": "-10\n"}, {"input": "-1 -31", "output": "-17\n"}, {"input": "-11 -1", "output": "-12\n"}, {"input": "0 1003", "output": "50... | code_stdio |
[
{
"content": "You are given a string S of length N consisting of ( and ). Your task is to insert some number of ( and ) into S to obtain a correct bracket sequence.\n\nHere, a correct bracket sequence is defined as follows: \n - () is a correct bracket sequence.\n - If X is a correct bracket sequence, the conc... | [{"input": "8\n))))((((\n", "output": "(((())))(((())))\n"}, {"input": "8\n)))(((((", "output": "((()))((((()))))\n"}, {"input": "8\n)))))(((", "output": "((((()))))((()))\n"}, {"input": "8\n))))))))", "output": "(((((((())))))))\n"}, {"input": "8\n))))((((", "output": "(((())))(((())))"}, {"input": "8\n))))(()(", "out... | code_stdio |
[
{
"content": "Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.\nTo begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is l... | [{"input": "5000\n01000001011101000100001101101111011001000110010101110010000\n", "output": "500886057\n"}, {"input": "5000\n01000001011101010100001101101111011001000110010101110010000", "output": "500886057\n"}, {"input": "5000\n01000001011001010100001101101111011001000110010101110010000", "output": "500886057\n"}, {"... | code_stdio |
[
{
"content": "Little C loves number «3» very much. He loves all things about it.\n\nNow he is playing a game on a chessboard of size $n \\times m$. The cell in the $x$-th row and in the $y$-th column is called $(x,y)$. Initially, The chessboard is empty. Each time, he places two chessmen on two different empty ... | [{"input": "1000000000 1000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000 1000010000\n", "output": "1000010000000000000\n"}, {"input": "1000000000 1000000000\n", "output": "1000000000000000000"}, {"input": "1226545551 143389547\n", "output": "175873810932755396\n"}, {"input": "1109972776 380634006... | code_stdio |
[
{
"content": "Iahub accidentally discovered a secret lab. He found there n devices ordered in a line, numbered from 1 to n from left to right. Each device i (1 ≤ i ≤ n) can create either ai units of matter or ai units of antimatter. \n\nIahub wants to choose some contiguous subarray of devices in the lab, speci... | [{"input": "250\n6 1 4 3 3 7 4 5 3 2 4 4 2 6 4 2 1 7 6 2 4 5 3 3 4 5 3 4 5 4 6 4 6 5 3 3 1 5 4 5 3 4 2 4 2 5 1 4 3 3 3 2 6 6 4 7 2 6 5 3 3 6 5 2 1 3 3 5 2 2 3 7 3 5 6 4 7 3 5 3 4 5 5 4 11 5 1 5 3 3 3 1 4 6 4 4 5 5 5 5 2 5 9 3 2 2 5 6 10 5 4 2 5 4 2 5 5 3 4 2 5 4 3 2 4 4 2 5 4 1 5 3 9 6 4 6 3 5 4 5 3 6 7 4 5 10 3 6 2 6 ... | code_stdio |
[
{
"content": "Drazil is playing a math game with Varda.\n\nLet's define <image> for positive integer x as a product of factorials of its digits. For example, <image>.\n\nFirst, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start wi... | [{"input": "15\n989898989898989\n", "output": "777777777777777333333333333333322222222222222222222222222222\n"}, {"input": "15\n999999999999990\n", "output": "77777777777777333333333333333333333333333322222222222222\n"}, {"input": "15\n997953296764414\n", "output": "7777775553333333333333322222222222\n"}, {"input": "15... | code_stdio |
[
{
"content": "One day three best friends Petya, Vasya and Tonya decided to form a team and take part in programming contests. Participants are usually offered several problems during programming contests. Long before the start the friends decided that they will implement a problem if at least two of them are su... | [{"input": "50\n0 0 0\n0 1 1\n1 1 1\n0 1 0\n1 0 1\n1 1 1\n0 0 1\n1 0 0\n1 1 0\n1 0 1\n0 1 0\n0 0 1\n1 1 0\n0 1 0\n1 1 0\n0 0 0\n1 1 1\n1 0 1\n0 0 1\n1 1 0\n1 1 1\n0 1 1\n1 1 0\n0 0 0\n0 0 0\n1 1 1\n0 0 0\n1 1 1\n0 1 1\n0 0 1\n0 0 0\n0 0 0\n1 1 0\n1 1 0\n1 0 1\n1 0 0\n1 0 1\n1 0 1\n0 1 1\n1 1 0\n1 1 0\n0 1 0\n1 0 1\n0 0... | code_stdio |
[
{
"content": "You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.\n\nSome keys on the keypad have fingerprints. You believe the correct code is the longest not nece... | [{"input": "10 10\n1 2 3 4 5 6 7 8 9 0\n4 5 6 7 1 2 3 0 9 8\n", "output": "1 2 3 4 5 6 7 8 9 0\n"}, {"input": "10 10\n1 2 3 4 5 6 7 8 9 0\n4 5 6 7 1 2 3 0 9 8\n", "output": "1 2 3 4 5 6 7 8 9 0\n"}, {"input": "10 6\n7 1 2 3 8 0 6 4 5 9\n1 5 8 2 3 6\n", "output": "1 2 3 8 6 5\n"}, {"input": "10 6\n7 1 2 3 8 0 6 4 5 9\n1... | code_stdio |
[
{
"content": "The \"BerCorp\" company has got n employees. These employees can use m approved official languages for the formal correspondence. The languages are numbered with integers from 1 to m. For each employee we have the list of languages, which he knows. This list could be empty, i. e. an employee may k... | [{"input": "100 100\n1 33\n0\n2 35 4\n2 40 78\n1 69\n0\n1 2\n0\n0\n2 81 34\n1 45\n0\n1 87\n1 50\n1 97\n0\n2 100 59\n0\n0\n0\n1 45\n0\n0\n0\n1 6\n1 54\n0\n0\n0\n4 79 96 52 84\n1 86\n0\n0\n0\n0\n0\n0\n0\n0\n3 90 2 80\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n1 2\n0\n1 64\n0\n1 78\n1 82\n0\n0\n0\n0\n0\n1 6\n0\n0\n2 47 57\n1 95\n0\n2... | code_stdio |
[
{
"content": "Theofanis decided to visit his uncle's farm. There are $s$ animals and $n$ animal pens on the farm. For utility purpose, animal pens are constructed in one row.\n\nUncle told Theofanis that a farm is lucky if you can distribute all animals in all pens in such a way that there are no empty pens and... | [{"input": "4\n1 1 1\n1 1 1\n100 50 200\n56220 47258 14497\n", "output": "YES\nYES\nNO\nYES\n"}, {"input": "4\n1 1 1\n1 -1 2\n110 50 200\n56220 47258 14497\n", "output": "YES\nNO\nNO\nYES\n"}, {"input": "4\n1 1 1\n1 -1 2\n110 53 200\n56220 47258 14497\n", "output": "YES\nNO\nNO\nYES\n"}, {"input": "4\n1 1 1\n-1 -1 2\n0... | code_stdio |
[
{
"content": "There are two infinite sources of water: hot water of temperature $h$; cold water of temperature $c$ ($c < h$). \n\nYou perform the following procedure of alternating moves: take one cup of the hot water and pour it into an infinitely deep barrel; take one cup of the cold water and pour it int... | [{"input": "3\n30 10 20\n41 15 30\n18 13 18\n", "output": "2\n7\n1\n"}, {"input": "3\n30 10 20\n41 15 26\n18 13 18\n", "output": "2\n2\n1\n"}, {"input": "3\n30 10 20\n41 15 30\n18 13 18\n", "output": "2\n7\n1\n"}, {"input": "1\n114515 114514 114514\n", "output": "2\n"}, {"input": "1\n999855 999262 999557\n", "output": ... | code_stdio |
[
{
"content": "This is an interactive problem. Refer to the Interaction section below for better understanding.\n\nIthea and Chtholly want to play a game in order to determine who can use the kitchen tonight.\n\n<image>\n\nInitially, Ithea puts n clear sheets of paper in a line. They are numbered from 1 to n fro... | [{"input": "10 120 15\n6\n11\n9\n11\n3\n12\n11\n12\n2\n8\n3\n11\n13\n5\n12\n18\n9\n3\n10\n9\n9\n13\n13\n5\n6\n11\n3\n15\n8\n8\n10\n13\n7\n6\n4\n14\n9\n10\n5\n13\n4\n1\n8\n6\n13\n1\n3\n4\n9\n12\n2\n7\n3\n3\n7\n2\n2\n9\n2\n4\n2\n2\n11\n12\n15\n13\n6\n2\n11\n1\n8\n3\n13\n6\n15\n6\n4\n3\n4\n15\n15\n9\n5\n8\n3\n6\n14\n14\n5... | code_stdio |
[
{
"content": "In the Ancient Kingdom of Snuke, there was a pyramid to strengthen the authority of Takahashi, the president of AtCoder Inc.\n\nThe pyramid had center coordinates (C_X, C_Y) and height H. The altitude of coordinates (X, Y) is max(H - |X - C_X| - |Y - C_Y|, 0). \nAoki, an explorer, conducted a sur... | [{"input": "100\n10 12 512917373\n6 9 512917366\n66 44 512917421\n49 18 512917412\n57 96 512917426\n65 72 512917442\n62 59 512917440\n27 77 512917437\n31 13 512917395\n38 39 512917428\n15 72 512917430\n0 69 512917418\n22 22 512917395\n9 69 512917427\n37 96 512917428\n12 23 512917386\n100 90 512917389\n4 60 512917415\n9... | code_stdio |
[
{
"content": "One of the most important products of the R1 company is a popular @r1.com mail service. The R1 mailboxes receive and send millions of emails every day.\n\nToday, the online news thundered with terrible information. The R1 database crashed and almost no data could be saved except for one big string... | [{"input": "gerald.agapov1991@gmail.com\n", "output": " 18"}, {"input": "x@x.x@x.x_e_@r1.com\n", "output": " 8"}, {"input": "0000000a@000a111.r\n", "output": " ... | code_stdio |
[
{
"content": "Vanya has a scales for weighing loads and weights of masses w^0, w^1, w^2, ..., w^100 grams where w is some integer not less than 2 (exactly one weight of each nominal value). Vanya wonders whether he can weight an item with mass m using the given weights, if the weights can be put on both pans of... | [{"input": "1000000000 1000000000\n", "output": "YES\n"}, {"input": "1000000000 1000000000\n", "output": "YES\n"}, {"input": "1100000000 1000000000\n", "output": "NO\n"}, {"input": "441890232 441890232\n", "output": "YES\n"}, {"input": "401739553 401739553\n", "output": "YES\n"}, {"input": "285681920 285681919\n", "out... | code_stdio |
[
{
"content": "Vasya has a sequence of cubes and exactly one integer is written on each cube. Vasya exhibited all his cubes in a row. So the sequence of numbers written on the cubes in the order from the left to the right equals to a_1, a_2, ..., a_{n}.\n\nWhile Vasya was walking, his little brother Stepan playe... | [{"input": "10 1 10\n6 7 6 1 10 10 9 5 3 9\n7 10 9 6 1 5 9 3 10 6\n", "output": "TRUTH\n"}, {"input": "10 1 10\n6 7 6 1 10 10 9 5 3 9\n7 10 9 6 1 5 9 3 10 6\n", "output": "TRUTH\n"}, {"input": "8 3 6\n5 3 1 1 1 1 1 10\n3 3 1 1 1 1 5 5\n", "output": "LIE\n"}, {"input": "8 4 6\n5 3 1 1 2 1 3 5\n3 3 1 1 1 2 8 10\n", "outp... | code_stdio |
[
{
"content": "Bob is an avid fan of the video game \"League of Leesins\", and today he celebrates as the League of Leesins World Championship comes to an end! \n\nThe tournament consisted of $n$ ($n \\ge 5$) teams around the world. Before the tournament starts, Bob has made a prediction of the rankings of each ... | [{"input": "9\n7 5 3\n8 9 4\n8 1 7\n8 9 1\n1 5 7\n2 3 5\n6 3 2\n", "output": "4 9 8 1 7 5 3 2 6 \n"}, {"input": "9\n1 8 9\n9 6 4\n2 1 3\n1 2 8\n3 5 2\n6 7 4\n8 9 4\n", "output": "5 3 2 1 8 9 4 6 7 \n"}, {"input": "9\n6 9 8\n2 3 4\n2 3 1\n5 6 8\n4 6 5\n7 8 9\n3 5 4\n", "output": "1 2 3 4 5 6 8 9 7 \n"}, {"input": "9\n7 ... | code_stdio |
[
{
"content": "Polycarp wants to cook a soup. To do it, he needs to buy exactly $n$ liters of water.\n\nThere are only two types of water bottles in the nearby shop — $1$-liter bottles and $2$-liter bottles. There are infinitely many bottles of these two types in the shop.\n\nThe bottle of the first type costs $... | [{"input": "4\n10 1 3\n7 5 2\n1 1000 1\n1000000000000 42 88\n", "output": "10\n11\n1000\n42000000000000\n"}, {"input": "4\n10 1 3\n7 3 2\n1 1000 1\n1000000000000 42 88\n", "output": "10\n9\n1000\n42000000000000\n"}, {"input": "4\n10 1 3\n7 3 2\n1 1000 1\n1000000000000 42 88\n", "output": "10\n9\n1000\n42000000000000\n"... | code_stdio |
[
{
"content": "Takahashi is a user of a site that hosts programming contests.\n\nWhen a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows: \n - Let the current rating of the user be a.\n - Suppose that the performance of ... | [{"input": "2002\n2017\n", "output": "2032\n"}, {"input": "4500\n-140", "output": "-4780\n"}, {"input": "4500\n-148", "output": "-4796\n"}, {"input": "4500\n-237", "output": "-4974\n"}, {"input": "2002\n416", "output": "-1170\n"}, {"input": "2002\n468", "output": "-1066\n"}, {"input": "4500\n-15", "output": "-4530\n"},... | code_stdio |
[
{
"content": "A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it can either jump to position $k+a$ or $k-b$.\n\nLet $f(x)$ be the number of distinct integers the frog can reach if it never jumps on an integer outside the interval $[0, ... | [{"input": "997674659 11231 35496\n", "output": "497677363010575988\n"}, {"input": "881706694 5710 46369\n", "output": "388703347089502553\n"}, {"input": "952549276 31416 33000\n", "output": "1718466614644254\n"}, {"input": "952549276 31416 33000\n", "output": "1718466614644254\n"}, {"input": "952549276 31416 6292\n", ... | code_stdio |
[
{
"content": "The Little Elephant from the Zoo of Lviv currently is on the military mission. There are N enemy buildings placed in a row and numbered from left to right strating from 0. Each building i (except the first and the last) has exactly two adjacent buildings with indices i-1 and i+1. The first and the... | [{"input": "3\n3\n011\n5\n10001\n7\n0000000", "output": "0\n1\n7\n"}, {"input": "3\n3\n010\n5\n10001\n7\n0010000", "output": "0\n1\n4\n"}, {"input": "3\n3\n010\n5\n10001\n7\n1010000", "output": "0\n1\n3\n"}, {"input": "3\n3\n010\n5\n10000\n7\n1010000", "output": "0\n3\n3\n"}, {"input": "3\n3\n010\n5\n10011\n7\n0000000"... | code_stdio |
[
{
"content": "You are given a sequence of $n$ pairs of integers: $(a_1, b_1), (a_2, b_2), \\dots , (a_n, b_n)$. This sequence is called bad if it is sorted in non-descending order by first elements or if it is sorted in non-descending order by second elements. Otherwise the sequence is good. There are examples ... | [{"input": "4\n2 3\n1 2\n2 1\n2 4\n", "output": "17\n"}, {"input": "4\n2 3\n1 2\n2 1\n0 4\n", "output": "21\n"}, {"input": "4\n3 3\n2 3\n2 1\n2 4\n", "output": "16\n"}, {"input": "4\n2 3\n4 2\n2 1\n4 4\n", "output": "19\n"}, {"input": "4\n1 2\n4 2\n2 1\n2 4\n", "output": "20\n"}, {"input": "4\n2 3\n4 2\n2 1\n2 4\n", "o... | code_stdio |
[
{
"content": "You are given three positive integers x, y, n. Your task is to find the nearest fraction to fraction [Image] whose denominator is no more than n. \n\nFormally, you should find such pair of integers a, b (1 ≤ b ≤ n; 0 ≤ a) that the value $|\\frac{x}{y} - \\frac{a}{b}|$ is as minimal as possible.\n\... | [{"input": "43003 70913 108889\n", "output": "43003/70913\n"}, {"input": "76730 157792 71438\n", "output": "33069/68005\n"}, {"input": "43003 75615 108889\n", "output": "43003/75615\n"}, {"input": "76730 157792 50090\n", "output": "22477/46223\n"}, {"input": "113725 82924 57380\n", "output": "69226/50477\n"}, {"input":... | code_stdio |
[
{
"content": "Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\n\nfor i = 1 to A.length-1\nkey = A[i]\n/* insert A[i] into the sorted sequence A[0,...,j-1] */\nj = i - 1\nwhile j >= 0 and A[j] > key\nA[j+1] ... | [{"input": "6\n16 4 2 2 1 -1", "output": "16 4 2 2 1 -1\n4 16 2 2 1 -1\n2 4 16 2 1 -1\n2 2 4 16 1 -1\n1 2 2 4 16 -1\n-1 1 2 2 4 16\n"}, {"input": "6\n2 2 2 -1 2 -2", "output": "2 2 2 -1 2 -2\n2 2 2 -1 2 -2\n2 2 2 -1 2 -2\n-1 2 2 2 2 -2\n-1 2 2 2 2 -2\n-2 -1 2 2 2 2\n"}, {"input": "6\n2 0 2 -1 2 -2", "output": "2 0 2 -1... | code_stdio |
[
{
"content": "Vasya has recently learned to type and log on to the Internet. He immediately entered a chat room and decided to say hello to everybody. Vasya typed the word s. It is considered that Vasya managed to say hello if several letters can be deleted from the typed word so that it resulted in the word \"... | [{"input": "hyyhddqhxhekehkwfhlnlsihzefwchzerevcjtokefplholrbvxlltdlafjxrfhleglrvlolojoqaolagtbeyogxlbgfolllslli\n", "output": "YES\n"}, {"input": "jhfbndhyzdvhbvhmhmefqllujdflwdpjbehedlsqfdsqlyelwjtyloxwsvasrbqosblzbowlqjmyeilcvotdlaouxhdpoeloaovb\n", "output": "YES\n"}, {"input": "hellllllllllllllllllllllllllllllllll... | code_stdio |
[
{
"content": "Polycarp has decided to decorate his room because the New Year is soon. One of the main decorations that Polycarp will install is the garland he is going to solder himself.\n\nSimple garlands consisting of several lamps connected by one wire are too boring for Polycarp. He is going to solder a gar... | [{"input": "100\n25 100 32 34 25 99 19 99 84 52 20 83 34 12 59 89 51 86 5 63 57 2 61 23 48 27 90 28 29 65 31 73 40 79 89 29 18 86 49 14 48 84 100 17 65 79 37 71 52 47 98 100 40 20 71 94 90 53 41 54 47 2 40 36 35 63 14 66 35 11 2 97 23 90 26 88 17 79 2 59 12 22 14 61 78 15 7 62 7 38 43 94 43 12 77 80 60 9 2\n", "output"... | code_stdio |
[
{
"content": "One evening Rainbow Dash and Fluttershy have come up with a game. Since the ponies are friends, they have decided not to compete in the game but to pursue a common goal. \n\nThe game starts on a square flat grid, which initially has the outline borders built up. Rainbow Dash and Fluttershy have fl... | [{"input": "1\n10000001\n", "output": "5000001\n"}, {"input": "1\n10000001\n", "output": "5000001\n"}, {"input": "1\n10001001\n", "output": "5000501\n"}, {"input": "1\n11001001\n", "output": "5500501\n"}, {"input": "1\n11011001\n", "output": "5505501\n"}, {"input": "1\n11001100\n", "output": "5500551\n"}, {"input": "1\... | code_stdio |
[
{
"content": "The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.)\nWe will close the window so as to minimize the total horizontal length of the uncovered p... | [{"input": "2 -777", "output": "1556\n"}, {"input": "2 -839", "output": "1680\n"}, {"input": "1 -839", "output": "1679\n"}, {"input": "100 100\n", "output": "0\n"}, {"input": "181 21", "output": "139\n"}, {"input": "194 13", "output": "168\n"}, {"input": "125 12", "output": "101\n"}, {"input": "122 -1", "output": "124\... | code_stdio |
[
{
"content": "We have two bottles for holding water.\nBottle 1 can hold up to A milliliters of water, and now it contains B milliliters of water.\nBottle 2 contains C milliliters of water.\nWe will transfer water from Bottle 2 to Bottle 1 as much as possible.\nHow much amount of water will remain in Bottle 2?\n... | [{"input": "20 20 20\n", "output": "20\n"}, {"input": "6 113 -1", "output": "106\n"}, {"input": "6 228 -1", "output": "221\n"}, {"input": "2 228 -1", "output": "225\n"}, {"input": "2 396 -1", "output": "393\n"}, {"input": "2 666 -1", "output": "663\n"}, {"input": "2 481 -1", "output": "478\n"}, {"input": "2 931 -1", "o... | code_stdio |
[
{
"content": "Vladik had started reading a complicated book about algorithms containing n pages. To improve understanding of what is written, his friends advised him to read pages in some order given by permutation P = [p_1, p_2, ..., p_{n}], where p_{i} denotes the number of page that should be read i-th in tu... | [{"input": "20 20\n18 17 2 3 16 15 1 9 12 8 20 11 13 14 4 5 19 7 10 6\n13 15 15\n1 1 1\n2 2 2\n11 14 11\n10 11 10\n2 8 6\n12 18 16\n4 8 8\n2 2 2\n5 11 11\n4 18 9\n5 6 6\n3 20 12\n8 8 8\n6 16 11\n9 18 18\n8 18 17\n1 1 1\n2 6 5\n1 4 3\n", "output": "No\nYes\nYes\nNo\nYes\nYes\nNo\nNo\nYes\nYes\nNo\nNo\nNo\nYes\nNo\nNo\nY... | code_stdio |
[
{
"content": "Consider a table of size $n \\times m$, initially fully white. Rows are numbered $1$ through $n$ from top to bottom, columns $1$ through $m$ from left to right. Some square inside the table with odd side length was painted black. Find the center of this square.\n\n\n-----Input-----\n\nThe first li... | [{"input": "96 1\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nW\nB\nW\nW\nW\nW\nW\nW\nW\n", "output": "... | code_stdio |
[
{
"content": "Ivan is a student at Berland State University (BSU). There are n days in Berland week, and each of these days Ivan might have some classes at the university.\n\nThere are m working hours during each Berland day, and each lesson at the university lasts exactly one hour. If at some day Ivan's first ... | [{"input": "4 113 370\n01110100100010110100110000000011001111110000100111111001011001110111110111001011010110000110110010101010110001000\n01101001111110001010001100101100111100111001001001001101110101100110110110001110100010111011101011101110011110100\n0110011000100111101000001010110011110001111101000010101001101111111... | code_stdio |
[
{
"content": "After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.\n\nThe three friends are very smart so they passed all the challenges very quickly and finally... | [{"input": "727\nbaabbabbbababbbbaaaabaabbaabababaaababaaababbbbababbbbbbbbbbaaabaabbbbbbbbaaaabaabbaaabaabbabaa\nddcdcccccccdccdcdccdddcddcddcddddcdddcdcdccddcdddddccddcccdcdddcdcccdccccccdcdcdccccccdccccccdc\nfffeefeffeefeeeeffefffeeefffeefffefeefefeeeffefefefefefefffffffeeeeeffffeefeeeeffffeeeeeefeffef\n", "output":... | code_stdio |
[
{
"content": "Vasya is an administrator of a public page of organization \"Mouse and keyboard\" and his everyday duty is to publish news from the world of competitive programming. For each news he also creates a list of hashtags to make searching for a particular topic more comfortable. For the purpose of this ... | [{"input": "2\n#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\n#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "#aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "Petya once wrote a sad love song and shared it to Vasya. The song is a string consisting of lowercase English letters. Vasya made up $q$ questions about this song. Each question is about a subsegment of the song starting from the $l$-th letter to the $r$-th letter. Vasya considers a substring made... | [{"input": "13 7\nsonokhisumiwo\n1 5\n2 10\n7 10\n1 13\n1 8\n1 9\n3 6\n", "output": "74\n125\n62\n191\n110\n131\n48\n"}, {"input": "13 7\nowimusihkooos\n1 7\n2 10\n7 8\n2 13\n2 8\n2 4\n6 9\n", "output": "109\n128\n17\n177\n102\n45\n47\n"}, {"input": "13 7\nowimusihkooos\n1 7\n2 10\n7 7\n2 13\n2 8\n2 9\n6 9\n", "output"... | code_stdio |
[
{
"content": "You are given an integer sequence of length N, a_1,a_2,...,a_N.\n\nFor each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing.\n\nAfter these operations, you select an integer X and count the number of i such that a_i=X.\n\nMaximize this count by making optimal choices... | [{"input": "10\n-1 1 2 3 2 8 6 7 14 4", "output": "4\n"}, {"input": "10\n-1 2 1 5 8 2 8 4 20 0", "output": "4\n"}, {"input": "10\n-1 2 1 5 8 4 8 4 20 0", "output": "3\n"}, {"input": "10\n-1 2 1 5 8 4 8 4 17 0", "output": "3\n"}, {"input": "10\n-1 2 1 5 4 4 8 4 17 0", "output": "4\n"}, {"input": "10\n-1 2 1 1 4 4 8 4 17... | code_stdio |
[
{
"content": "The Berland capital is shaken with three bold crimes committed by the Pihsters, a notorious criminal gang.\n\nThe Berland capital's map is represented by an n × m rectangular table. Each cell of the table on the map represents some districts of the capital. \n\nThe capital's main detective Polycar... | [{"input": "99 3\n**.\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n...\n..... | code_stdio |
[
{
"content": "Vasya takes part in the orienteering competition. There are n checkpoints located along the line at coordinates x_1, x_2, ..., x_{n}. Vasya starts at the point with coordinate a. His goal is to visit at least n - 1 checkpoint in order to finish the competition. Participant are allowed to visit che... | [{"input": "97 -13\n-17 -11 -20 -16 -11 -18 -17 -14 -19 -13 -11 -19 -15 -17 -11 -20 -10 -19 -10 -18 -11 -14 -11 -15 -13 -13 -11 -18 -18 -18 -11 -14 -20 -19 -10 -17 -18 -19 -17 -11 -11 -11 -20 -19 -16 -15 -18 -15 -15 -20 -19 -20 -16 -13 -17 -11 -13 -18 -10 -13 -10 -14 -12 -17 -20 -10 -11 -19 -19 -15 -19 -10 -18 -14 -15 ... | code_stdio |
[
{
"content": "Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.\nGiven two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.\n\n-----Constraints-----\n - x and y are integers.\n - 1 ≤ x < y ≤ 12\n\n-----Input--... | [{"input": "12 12", "output": "Yes\n"}, {"input": "1 3\n", "output": "Yes\n"}, {"input": "1 10", "output": "Yes\n"}, {"input": "7 10", "output": "Yes\n"}, {"input": "7 12", "output": "Yes\n"}, {"input": "5 10", "output": "Yes\n"}, {"input": "5 12", "output": "Yes\n"}, {"input": "1 12", "output": "Yes\n"}, {"input": "12... | code_stdio |
[
{
"content": "N Snukes called Snuke 1, Snuke 2, ..., Snuke N live in a town.\nThere are K kinds of snacks sold in this town, called Snack 1, Snack 2, ..., Snack K. The following d_i Snukes have Snack i: Snuke A_{i, 1}, A_{i, 2}, \\cdots, A_{i, {d_i}}.\nTakahashi will walk around this town and make mischief on t... | [{"input": "100 100\n100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n1... | code_stdio |
[
{
"content": "Kuro is living in a country called Uberland, consisting of $n$ towns, numbered from $1$ to $n$, and $n - 1$ bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects two towns $a$ and $b$. Kuro loves walking and he is planning to take a walkin... | [{"input": "70 42 32\n25 50\n51 7\n39 61\n1 33\n20 5\n1 70\n1 63\n42 35\n64 16\n1 11\n39 42\n20 54\n11 14\n57 44\n1 59\n55 40\n25 3\n31 18\n38 68\n57 23\n39 57\n28 10\n39 20\n42 26\n58 6\n20 56\n57 2\n13 21\n15 69\n39 64\n1 39\n62 53\n39 13\n1 41\n22 12\n13 30\n68 67\n20 31\n51 15\n57 32\n59 34\n39 4\n31 65\n58 24\n20 ... | code_stdio |
[
{
"content": "Paul is at the orchestra. The string section is arranged in an r × c rectangular grid and is filled with violinists with the exception of n violists. Paul really likes violas, so he would like to take a picture including at least k of them. Paul can take a picture of any axis-parallel rectangle in... | [{"input": "10 10 10 1\n8 10\n2 9\n1 10\n3 1\n8 5\n10 1\n4 10\n10 2\n5 3\n9 3\n", "output": "1787\n"}, {"input": "10 10 10 1\n8 10\n2 9\n1 10\n3 1\n8 5\n10 1\n4 10\n10 2\n5 3\n9 3\n", "output": "1787\n"}, {"input": "10 10 10 1\n1 10\n10 8\n7 4\n7 2\n1 3\n6 6\n10 1\n2 7\n9 3\n3 10\n", "output": "1991\n"}, {"input": "10 ... | code_stdio |
[
{
"content": "You will receive 3 points for solving this problem.\n\nManao is designing the genetic code for a new type of algae to efficiently produce fuel. Specifically, Manao is focusing on a stretch of DNA that encodes one protein. The stretch of DNA is represented by a string containing only the characters... | [{"input": "CCCTTCACCCGGATCCAAATCCCTTAGAAATAATCCCCGACGGCGTTGTATCACCTCTGCACTTGTTAGTAAGGTCAGGCGTCCATTACGGAAGAACGTA\n", "output": "19\n"}, {"input": "GCATTACATGGGGGGGTCCTACGAGCCCGGCATCCCGGAAACTAGCCGGTTAATTTGGTTTAAACCCTCCCACCCCGGATTGTAACCCCCCTCATTGGTT\n", "output": "17\n"}, {"input": "TTCCCAGAGAAAAAAAGGGGCCCAAATGCCCTAAAAAC... | code_stdio |
[
{
"content": "You are a programmer on the development team for new recording media. This recording medium can be randomly accessed for reading and erasing data. On the other hand, when writing data, access is always performed in order from the beginning, and only the first free space found can be written.\n\nYo... | [{"input": "6\nW 0 2\nW 0 2\nD 0\nW 2 1\nR 3\nR 2\n1\nR 1000000000\n0", "output": "-1\n-1\n\n-1\n\n"}, {"input": "6\nW 0 3\nW 0 2\nD 0\nW 2 1\nR 4\nR 1\n1\nR 1000000000\n0", "output": "-1\n-1\n\n-1\n\n"}, {"input": "6\nW 0 2\nW 0 2\nD 0\nW 3 1\nR 3\nR 2\n1\nR 1000000000\n0", "output": "-1\n-1\n\n-1\n\n"}, {"input": "6\... | code_stdio |
[
{
"content": "Pasha has two hamsters: Arthur and Alexander. Pasha put n apples in front of them. Pasha knows which apples Arthur likes. Similarly, Pasha knows which apples Alexander likes. Pasha doesn't want any conflict between the hamsters (as they may like the same apple), so he decided to distribute the app... | [{"input": "100 1 100\n84\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100\n... | code_stdio |
[
{
"content": "The number \"zero\" is called \"love\" (or \"l'oeuf\" to be precise, literally means \"egg\" in French), for example when denoting the zero score in a game of tennis. \n\nAki is fond of numbers, especially those with trailing zeros. For example, the number $9200$ has two trailing zeros. Aki thinks... | [{"input": "1000000000000000000 1000000000000\n", "output": "20833333333333332\n"}, {"input": "1000000000000000000 1000000000000\n", "output": "20833333333333332\n"}, {"input": "1000000000000000000 470184984576\n", "output": "33333333333333332\n"}, {"input": "1000000000000000000 743008370688\n", "output": "454545454545... | code_stdio |
[
{
"content": "Go around the Labyrinth\n\nExplorer Taro got a floor plan of a labyrinth. The floor of this labyrinth is in the form of a two-dimensional grid. Each of the cells on the floor plan corresponds to a room and is indicated whether it can be entered or not. The labyrinth has only one entrance located a... | [{"input": "3 3\n...\n.#.\n...\n5 5\n..#..\n.....\n#....\n.....\n.....\n3 8\n..#.....\n........\n.....#..\n3 5\n..#..\n-....\n..#..\n4 4\n....\n....\n..##\n..#.\n0 0", "output": "YES\nNO\nYES\nNO\nNO\n"}, {"input": "3 3\n...\n.#.\n...\n5 5\n..#..\n.....\n...#.\n.....\n.....\n3 8\n.....#..\n........\n.....#..\n3 5\n..#.... | code_stdio |
[
{
"content": "Some number of chocolate pieces were prepared for a training camp.\nThe camp had N participants and lasted for D days.\nThe i-th participant (1 \\leq i \\leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on.\... | [{"input": "5\n30 44\n26\n18\n81\n18\n6\n", "output": "56\n"}, {"input": "5\n30 44\n26\n18\n81\n18\n10", "output": "54\n"}, {"input": "5\n30 29\n26\n18\n81\n18\n10", "output": "39\n"}, {"input": "5\n30 29\n26\n18\n81\n18\n19", "output": "38\n"}, {"input": "5\n1 113\n25\n21\n13\n16\n7", "output": "118\n"}, {"input": "5\... | code_stdio |
[
{
"content": "This problem is a version of problem D from the same contest with some additional constraints and tasks.\n\nThere are $n$ candies in a candy box. The type of the $i$-th candy is $a_i$ ($1 \\le a_i \\le n$). \n\nYou have to prepare a gift using some of these candies with the following restriction: ... | [{"input": "3\n8\n1 0\n4 1\n2 0\n4 1\n5 1\n6 1\n3 0\n2 0\n4\n1 1\n1 1\n2 1\n2 1\n9\n2 0\n2 0\n4 1\n4 1\n4 1\n7 0\n7 1\n7 0\n7 1\n", "output": "3 3\n3 3\n9 5\n"}, {"input": "3\n8\n1 0\n4 1\n2 0\n4 1\n5 1\n6 1\n3 0\n2 0\n4\n1 1\n1 1\n2 1\n2 1\n9\n2 0\n2 0\n4 1\n4 1\n4 1\n7 0\n9 1\n7 0\n7 1\n", "output": "3 3\n3 3\n6 5\n"... | code_stdio |
[
{
"content": "A: Information Search\n\nproblem\n\nThe posting list is a list in which there is a correspondence between the search term and the appearing document ID. For example\n\n* Hokkaido: 1, 2, 4, 9\n* Sightseeing: 1, 3, 4, 7\n\n\n\nAnd so on.\n\nFrom the above posting list, if you search for and, the doc... | [{"input": "4 4\n0 2 10 11\n1 2 4 14", "output": "1 7\n2\n0\n1\n2\n4\n10\n11\n14\n"}, {"input": "4 4\n1 2 5 12\n2 3 4 13", "output": "1 7\n2\n1\n2\n3\n4\n5\n12\n13\n"}, {"input": "4 4\n1 2 4 12\n2 3 4 13", "output": "2 6\n2\n4\n1\n2\n3\n4\n12\n13\n"}, {"input": "4 4\n0 2 4 10\n0 3 4 13", "output": "2 6\n0\n4\n0\n2\n3\n... | code_stdio |
[
{
"content": "Tavas is a strange creature. Usually \"zzz\" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead.\n\n<image>\n\nToday Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p.... | [{"input": "173700 6\nbcabcbcbcbaaacaccaacaccaabacabaacbcacbbccaccbcacbabcaccccccaacacabbbbbacabbaaacbcbbaccaccabbbbaabbacacbabccaabcabbbcacaaccbabbcaaaaaabccbbcabcacbcbcabcbcbbaabacaaccccabacaaaccacaaabbacacabbcccacbaabcacacbbaaaccaccbaccccccbccaabcacaacabaccababacabcccbcbbacbabacbcbabacbbaccaabcabcbbbaaabbacbbbcacccb... | code_stdio |
[
{
"content": "There are $n$ monsters standing in a row numbered from $1$ to $n$. The $i$-th monster has $h_i$ health points (hp). You have your attack power equal to $a$ hp and your opponent has his attack power equal to $b$ hp.\n\nYou and your opponent are fighting these monsters. Firstly, you and your opponen... | [{"input": "6 2 3 3\n7 10 50 12 1 8\n", "output": "5\n"}, {"input": "6 2 3 2\n7 10 50 12 1 8\n", "output": "4\n"}, {"input": "6 2 3 2\n5 10 50 12 1 8\n", "output": "3\n"}, {"input": "6 2 2 2\n5 10 50 12 1 8\n", "output": "6\n"}, {"input": "6 2 0 3\n1 9 50 12 1 15\n", "output": "6\n"}, {"input": "6 2 3 3\n7 10 51 12 1 8... | code_stdio |
[
{
"content": "Digits Are Not Just Characters\n\nMr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII cod... | [{"input": "2\nfile10\nfi2el0\nfile3", "output": "-\n-\n"}, {"input": "2\nfjle10\nfi2el0\niele3", "output": "-\n+\n"}, {"input": "2\n01eljf\nfi2el0\niele3", "output": "+\n+\n"}, {"input": "2\nflje10\nif3el0\n2elei", "output": "+\n-\n"}, {"input": "2\nfile10\nfi2el0\neile3", "output": "-\n-\n"}, {"input": "2\nfjle10\nfi... | code_stdio |
[
{
"content": "This is a harder version of the problem with bigger constraints.\n\nKorney Korneevich dag up an array a of length n. Korney Korneevich has recently read about the operation [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR), so he wished to experiment with it. For this purpose, he ... | [{"input": "100\n4845 2410 1317 394 2977 1455 2708 1271 2918 1866 4125 534 4055 1726 1819 790 2526 836 4853 4057 1995 3178 2972 3487 3259 4324 3807 895 2308 1513 3213 3480 1131 2807 1343 3231 1277 2683 1559 825 3667 102 1491 2066 4607 1645 3421 1475 3073 2945 3933 1157 378 3238 4123 2901 2840 483 4274 3463 3676 4011 31... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ ($n \\ge 3$) positive integers. It is known that in this array, all the numbers except one are the same (for example, in the array $[4, 11, 4, 4]$ all numbers except one are equal to $4$).\n\nPrint the index of the element that does not equal others. Th... | [{"input": "4\n4\n11 13 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10\n", "output": "\n2\n1\n5\n3\n"}, {"input": "4\n4\n11 13 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10\n", "output": "2\n1\n5\n3\n"}, {"input": "4\n4\n11 20 11 11\n5\n1 4 4 4 4\n10\n3 3 3 3 10 3 3 3 3 3\n3\n20 20 10\n", "outp... | code_stdio |
[
{
"content": "Fennec is fighting with N monsters.\nThe health of the i-th monster is H_i.\nFennec can do the following two actions:\n - Attack: Fennec chooses one monster. That monster's health will decrease by 1.\n - Special Move: Fennec chooses one monster. That monster's health will become 0.\nThere is no wa... | [{"input": "3 0\n1000000000 1000000000 1000000000\n", "output": "3000000000\n"}, {"input": "3 0\n1000000000 1000000000 1010000000", "output": "3010000000\n"}, {"input": "3 0\n1000000000 1000000000 1110000000", "output": "3110000000\n"}, {"input": "3 0\n1100000000 1000000000 1110000000", "output": "3210000000\n"}, {"inp... | code_stdio |
[
{
"content": "One day, Twilight Sparkle is interested in how to sort a sequence of integers a_1, a_2, ..., a_{n} in non-decreasing order. Being a young unicorn, the only operation she can perform is a unit shift. That is, she can move the last element of the sequence to its beginning:a_1, a_2, ..., a_{n} → a_{n... | [{"input": "9\n4 5 6 7 1 2 3 4 10\n", "output": "-1\n"}, {"input": "9\n4 5 6 7 1 2 3 4 10\n", "output": "-1\n"}, {"input": "9\n4 5 6 7 1 0 3 4 10\n", "output": "-1\n"}, {"input": "9\n4 5 6 7 1 0 3 4 2\n", "output": "-1\n"}, {"input": "9\n4 5 0 7 1 0 3 4 2\n", "output": "-1\n"}, {"input": "9\n4 5 0 7 1 0 0 4 2\n", "outp... | code_stdio |
[
{
"content": "Vasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n numbers on a single line. After that, Vasya began to write out different ways to put pluses (\"+\") in the line between certain digits in the line so that the result was a correct arithmetic e... | [{"input": "200 100\n56988719755815575893282254081467698462485803782142631369385180999746639622554559884281193367342283559238834106917388166048020056852911293394377949964185368886333934084399980368238188117302968424219707\n", "output": "295455656\n"}, {"input": "200 99\n9999999999999999999999999999999999999999999999999... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \nChef has N simple polygons (non self intersecting polygons) in which no two of them intersect with each other. For any two polygons P_{1}, P_{2}, either P_{1} lies inside P_{2} or vice versa. \nChef wants you to count number of polygons ... | [{"input": "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -2 -2\n3\n-1 -1 1 -1 1 1\n4\n3 3 -3 1 -3 -3 3 -3", "output": "1 0 2\n"}, {"input": "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -3 -2\n3\n-1 -1 1 -1 1 1\n4\n3 3 -3 1 -3 -3 3 -3", "output": "1 0 2\n"}, {"input": "1\n3\n6\n-2 2 -1 1 2 2 2 -1 1 -2 -3 -2\n3\n-1 -1 1 -1 1 0\n4\n3 3 -3 1 -3 ... | code_stdio |
[
{
"content": "The Free Meteor Association (FMA) has got a problem: as meteors are moving, the Universal Cosmic Descriptive Humorous Program (UCDHP) needs to add a special module that would analyze this movement. \n\nUCDHP stores some secret information about meteors as an n × m table with integers in its cells.... | [{"input": "6 5 30\n536048 34640 572197 62457 304174\n194764 325606 270468 784237 551632\n10580 294606 63164 543647 531895\n430397 576813 678878 323394 603231\n534567 804015 403517 886087 981939\n518845 962097 609792 877955 88610\nc 1 5\nc 2 5\nc 2 5\nr 5 3\nc 5 2\nc 4 5\nr 6 5\nc 2 1\nr 3 4\nr 4 3\nc 4 5\nc 2 1\nr 1 5... | code_stdio |
[
{
"content": "You are a lover of bacteria. You want to raise some bacteria in a box. \n\nInitially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly x bacteria in the box at some mome... | [{"input": "1000000000\n", "output": "13\n"}, {"input": "1000000000\n", "output": "13\n"}, {"input": "1000100000\n", "output": "13\n"}, {"input": "1034416188\n", "output": "18\n"}, {"input": "1000100100\n", "output": "13\n"}, {"input": "536870911\n", "output": "29\n"}, {"input": "343000816\n", "output": "14\n"}, {"inpu... | code_stdio |
[
{
"content": "<image>\n\n\nThere is a container that is bifurcated as shown in the figure. Drop 10 balls numbered from 1 to 10 through the opening A of the container and place the balls in the left cylinder B or the right cylinder C. Since plate D can rotate left and right around the fulcrum E, you can move pla... | [{"input": "2\n1 3 4 0 0 1 17 2 -1 4\n114 21 15 1 1 1 -1 89 2 13", "output": "NO\nNO\n"}, {"input": "2\n1 3 4 1 0 1 17 2 -1 4\n114 21 15 1 1 1 -1 89 2 13", "output": "NO\nNO\n"}, {"input": "2\n1 3 4 1 0 1 17 2 -1 4\n114 21 15 1 1 1 -1 89 2 20", "output": "NO\nNO\n"}, {"input": "2\n1 3 4 1 0 1 17 2 -1 6\n114 21 15 1 1 1... | code_stdio |
[
{
"content": "Let s be some string consisting of symbols \"0\" or \"1\". Let's call a string t a substring of string s, if there exists such number 1 ≤ l ≤ |s| - |t| + 1 that t = s_l s_{l+1} … s_{l + |t| - 1}. Let's call a substring t of string s unique, if there exist only one such l. \n\nFor example, let s = ... | [{"input": "99985 45273\n", "output": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "\"QAQ\" is a word to denote an expression of crying. Imagine \"Q\" as eyes with tears and \"A\" as a mouth.\n\nNow Diamond has given Bort a string consisting of only uppercase English letters of length n. There is a great number of \"QAQ\" in the string (Diamond is so cute!). $8$ illustration by 猫... | [{"input": "QCQAQAGAWAQQQAQAVQAQQQQAQAQQQAQAAATQAAVAAAQQQQAAAUUQAQQNQQWQQWAQAAQQKQYAQAAQQQAAQRAQQQWBQQQQAPBAQGQA\n", "output": "13174\n"}, {"input": "QQAQQAKQFAQLQAAWAMQAZQAJQAAQQOACQQAAAYANAQAQQAQAAQQAOBQQJQAQAQAQQQAAAAABQQQAVNZAQQQQAMQQAFAAEAQAQHQT\n", "output": "10420\n"}, {"input": "AQEGQHQQKQAQQPQKAQQQAAAAQQQAQEQA... | code_stdio |
[
{
"content": "PolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: \"There exists such a positive integer n that for each positive integer m number n·m + 1 is a prime number\".\n\nUnfortunately, PolandBall is not experienced yet and doesn't know that his h... | [{"input": "1447\n", "output": "1\n"}, {"input": "1127\n", "output": "1\n"}, {"input": "1722\n", "output": "2\n"}, {"input": "1332\n", "output": "1\n"}, {"input": "1261\n", "output": "1\n"}, {"input": "1010\n", "output": "1\n"}, {"input": "1901\n", "output": "1\n"}, {"input": "1865\n", "output": "1\n"}, {"input": "1024... | code_stdio |
[
{
"content": "The nth triangular number is defined as the sum of the first n positive integers. The nth tetrahedral number is defined as the sum of the first n triangular numbers. It is easy to show that the nth tetrahedral number is equal to n(n+1)(n+2) ⁄ 6. For example, the 5th tetrahedral number is 1+(1+2)+(... | [{"input": "40\n14\n10\n55\n120\n199\n61\n150\n0", "output": "2 6\n2 14\n1 10\n2 21\n1 18\n4 29\n3 27\n3 14\n"}, {"input": "40\n14\n10\n55\n120\n269\n61\n150\n0", "output": "2 6\n2 14\n1 10\n2 21\n1 18\n3 31\n3 27\n3 14\n"}, {"input": "40\n14\n10\n55\n120\n269\n61\n291\n0", "output": "2 6\n2 14\n1 10\n2 21\n1 18\n3 31\... | code_stdio |
[
{
"content": "Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.\n\nAfter two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has h_2 health points and an attack power of a... | [{"input": "1 1 100\n100 99\n", "output": "9901\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nH... | code_stdio |
[
{
"content": "$n$ fishermen have just returned from a fishing vacation. The $i$-th fisherman has caught a fish of weight $a_i$.\n\nFishermen are going to show off the fish they caught to each other. To do so, they firstly choose an order in which they show their fish (each fisherman shows his fish exactly once,... | [{"input": "10\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\n", "output": "0\n"}, {"input": "10\n319645572 758298525 812547177 459359946 355467212 304450522 807957797 916787906 239781206 242840396\n", "output": "0\n"}, {"input": "10\n319645572 758298525 812547177 ... | code_stdio |
[
{
"content": "You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.\n\nThe level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (whe... | [{"input": "53 1 27 3\n44 28 48 60 29 42 59 32 9 58 3 11 7 53 4 19 37 41 36 52 29 9 24 8 31 39 52 41 37 44 26 37 37 48 6 21 20 42 25 3 33 2 35 39 33 23 10 60 48 4 1 28 21\n1 1 11\n1 1 21\n1 1 3\n1 1 42\n1 1 16\n1 1 32\n1 1 52\n1 1 17\n1 1 39\n1 1 22\n1 1 31\n1 1 50\n1 1 23\n1 1 14\n1 1 41\n1 1 53\n1 1 60\n1 1 49\n1 1 7... | code_stdio |
[
{
"content": "There are $n$ dormitories in Berland State University, they are numbered with integers from $1$ to $n$. Each dormitory consists of rooms, there are $a_i$ rooms in $i$-th dormitory. The rooms in $i$-th dormitory are numbered from $1$ to $a_i$.\n\nA postman delivers letters. Sometimes there is no sp... | [{"input": "3 10\n1010000000 1000000000 1000000000\n330201655 567869543 1000000000 1000000001 1500000000 1999999999 2000000000 2000000001 2754432345 3000000000\n", "output": "1 330201655\n1 567869543\n1 1000000000\n1 1000000001\n2 490000000\n2 989999999\n2 990000000\n2 990000001\n3 744432345\n3 990000000\n"}, {"input":... | code_stdio |
[
{
"content": "This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any slee... | [{"input": "987654320023456789\n", "output": "29340299842560\n"}, {"input": "987654321123456789\n", "output": "33007837322880\n"}, {"input": "987654321123456780\n", "output": "55657759288320\n"}, {"input": "234906817379759421\n", "output": "22773236965920\n"}, {"input": "978691308972024154\n", "output": "33638772575520... | code_stdio |
[
{
"content": "Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains.\n\nTwo currencies are used in the... | [{"input": "8 12 5 5\n2 8 685087149 1569714306\n6 1 298270585 209942236\n2 4 346080035 234079976\n1 5 131857300 40131411\n1 8 30723332 173476334\n2 6 447829832 706415811\n1 4 181424400 548830121\n4 4 30593148 195056405\n7 8 211146752 588024753\n1 6 127300821 203530153\n3 1 336869679 115858230\n4 4 389775999 199123879",... | code_stdio |
[
{
"content": "Ghosts live in harmony and peace, they travel the space without any purpose other than scare whoever stands in their way.\n\nThere are $n$ ghosts in the universe, they move in the $OXY$ plane, each one of them has its own velocity that does not change in time: $\\overrightarrow{V} = V_{x}\\overrig... | [{"input": "10 7 -626288749\n795312099 49439844 266151109\n-1357052512 23740808 624973405\n-513221420 -44452680 -391096559\n-350963348 -5068756 -160670209\n690883790 11897718 3356227\n-509035268 -76541374 -210137445\n-121282138 -32581578 230716703\n491731655 9500548 -13423963\n-665038289 48170248 446577586\n495114076 -... | code_stdio |
[
{
"content": "\"Balloons should be captured efficiently\", the game designer says. He is designing an oldfashioned game with two dimensional graphics. In the game, balloons fall onto the ground one after another, and the player manipulates a robot vehicle on the ground to capture the balloons. The player can co... | [{"input": "2\n10 100\n100 270\n2\n12 100\n100 280\n3\n100 150\n10 360\n40 450\n3\n100 150\n17 360\n40 440\n2\n100 10\n50 200\n2\n100 100\n50 110\n1\n15 10\n4\n1 10\n2 20\n3 100\n90 200\n0", "output": "OK 220\nOK 200\nOK 260\nOK 246\nNG 1\nNG 2\nNG 1\nOK 188\n"}, {"input": "2\n10 100\n100 270\n2\n12 100\n100 280\n3\n10... | code_stdio |
[
{
"content": "You have given tree consist of n vertices. Select a vertex as root vertex that satisfies the condition below.\n\n * For all vertices v_{1} and v_{2}, if distance(root, v_{1}) = distance(root, v_{2}) then degree(v_{1}) = degree(v_{2}), where degree means the number of vertices connected to that ve... | [{"input": "14\n10 12\n8 14\n6 8\n4 10\n2 4\n1 2\n2 3\n3 5\n5 13\n7 9\n9 11\n10 14\n9 13\n", "output": "-1\n"}, {"input": "14\n10 12\n8 14\n6 8\n4 6\n2 4\n1 2\n2 3\n3 5\n5 13\n7 9\n9 11\n10 14\n9 13\n", "output": "-1\n"}, {"input": "14\n10 12\n8 10\n6 8\n7 6\n3 4\n1 2\n1 3\n3 5\n5 11\n7 9\n7 11\n10 14\n9 13\n", "output... | code_stdio |
[
{
"content": "Alica and Bob are playing a game.\n\nInitially they have a binary string $s$ consisting of only characters 0 and 1.\n\nAlice and Bob make alternating moves: Alice makes the first move, Bob makes the second move, Alice makes the third one, and so on. During each move, the current player must choose... | [{"input": "1\n111111111111111110000000000000000\n", "output": "NET\n"}, {"input": "1\n111111111111111110000000000000000\n", "output": "NET\n"}, {"input": "1\n111111111111101110000000000000000\n", "output": "NET\n"}, {"input": "1\n111111111111101100100000000000000\n", "output": "NET\n"}, {"input": "1\n11111111111100100... | code_stdio |
[
{
"content": "problem\n\nTo the west of the Australian continent is the wide Indian Ocean. Marine researcher JOI is studying the properties of N species of fish in the Indian Ocean.\n\nFor each type of fish, a rectangular parallelepiped habitat range is determined in the sea. Fish can move anywhere in their hab... | [{"input": "3 2\n26 58 0 50 135 000\n10 24 20 127 126 60\n40 60 20 90 90 131", "output": "60000\n"}, {"input": "1 1\n20 50 -2 50 70 000\n10 102 11 39 90 40\n75 100 36 102 159 8", "output": "1200\n"}, {"input": "1 1\n20 50 -3 50 70 000\n10 102 11 39 90 40\n72 100 36 167 159 8", "output": "1800\n"}, {"input": "3 1\n20 50... | code_stdio |
[
{
"content": "There are N candles placed on a number line.\nThe i-th candle from the left is placed on coordinate x_i.\nHere, x_1 < x_2 < ... < x_N holds.\nInitially, no candles are burning.\nSnuke decides to light K of the N candles.\nNow, he is at coordinate 0.\nHe can move left and right along the line with ... | [{"input": "8 5\n-9 -7 -4 -3 1 2 3 4\n", "output": "10\n"}, {"input": "8 4\n-14 -7 -4 -11 1 2 3 4", "output": "4\n"}, {"input": "8 4\n-14 -7 -4 -11 1 2 3 8", "output": "8\n"}, {"input": "8 5\n-14 -7 -1 -11 1 2 3 4", "output": "5\n"}, {"input": "8 4\n-14 -7 -1 -11 1 1 3 8", "output": "3\n"}, {"input": "8 4\n-14 -7 -6 -1... | code_stdio |
[
{
"content": "Toad Ivan has $m$ pairs of integers, each integer is between $1$ and $n$, inclusive. The pairs are $(a_1, b_1), (a_2, b_2), \\ldots, (a_m, b_m)$. \n\nHe asks you to check if there exist two integers $x$ and $y$ ($1 \\leq x < y \\leq n$) such that in each given pair at least one integer is equal to... | [{"input": "10 10\n1 3\n1 3\n1 3\n1 3\n1 3\n2 3\n1 5\n2 6\n2 7\n2 9\n", "output": "YES\n"}, {"input": "10 10\n1 3\n1 3\n1 3\n1 3\n1 3\n2 3\n1 5\n2 7\n2 7\n2 9\n", "output": "YES\n"}, {"input": "10 10\n1 3\n1 3\n1 3\n1 3\n1 3\n2 3\n1 5\n2 3\n2 7\n2 9\n", "output": "YES\n"}, {"input": "10 10\n1 3\n1 3\n1 3\n1 4\n1 3\n2 3... | code_stdio |
[
{
"content": "You are given $n$ strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings.\n\nString $a$ is a substring of string $b$ if it is possible to choose several consecut... | [{"input": "5\na\naba\nabacaba\nba\naba\n", "output": "YES\na\nba\naba\naba\nabacaba\n"}, {"input": "3\nqwerty\nqwerty\nqwerty\n", "output": "YES\nqwerty\nqwerty\nqwerty\n"}, {"input": "3\nqwerty\nqwerty\nqwerty\n", "output": "YES\nqwerty\nqwerty\nqwerty\n"}, {"input": "5\na\naba\nabacaba\nba\naba\n", "output": "YES\na... | code_stdio |
[
{
"content": "It is Professor R's last class of his teaching career. Every time Professor R taught a class, he gave a special problem for the students to solve. You being his favourite student, put your heart into solving it one last time.\n\nYou are given two polynomials $f(x) = a_0 + a_1x + \\dots + a_{n-1}x^... | [{"input": "70 11 17929\n10313 427 268935 211 197219 148 357 179290 97 358580 475 343 175 221 286864 429 304793 179290 189 363 221 340651 376509 453 251006 141 304793 358580 235 107574 141 358580 167 181 101469 335 286864 171 107574 105 449 358580 286864 161 286864 349 89645 197219 395 358580 233077 376509 185 199 3944... | code_stdio |
[
{
"content": "Mishka wants to buy some food in the nearby shop. Initially, he has $s$ burles on his card. \n\nMishka can perform the following operation any number of times (possibly, zero): choose some positive integer number $1 \\le x \\le s$, buy food that costs exactly $x$ burles and obtain $\\lfloor\\frac{... | [{"input": "6\n1\n10\n19\n9876\n12345\n1000000000\n", "output": "1\n11\n21\n10973\n13716\n1111111111\n"}, {"input": "6\n1\n10\n33\n9876\n12345\n1000000000\n", "output": "1\n11\n36\n10973\n13716\n1111111111\n"}, {"input": "6\n1\n10\n24\n9876\n12345\n1000000000\n", "output": "1\n11\n26\n10973\n13716\n1111111111\n"}, {"in... | code_stdio |
[
{
"content": "You are given an array $A$, consisting of $n$ positive integers $a_1, a_2, \\dots, a_n$, and an array $B$, consisting of $m$ positive integers $b_1, b_2, \\dots, b_m$. \n\nChoose some element $a$ of $A$ and some element $b$ of $B$ such that $a+b$ doesn't belong to $A$ and doesn't belong to $B$. \n... | [{"input": "52\n197 90 23 11 63 198 24 132 68 58 195 100 101 120 96 77 132 155 62 197 170 117 189 160 194 106 172 124 180 75 124 51 51 93 186 93 79 111 161 67 84 183 150 125 25 46 106 29 170 175 4 122\n18\n95 28 20 190 75 89 193 152 53 79 100 3 154 42 67 5 137 60\n", "output": "198 193\n"}, {"input": "52\n197 90 23 11 ... | code_stdio |
[
{
"content": "The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring new recruits in groups.\n\nMeanwhile, crimes keeps occurring within the city. One member of the police force can investigate only one crime during his/her lifetime.\n\n... | [{"input": "146\n4 -1 -1 -1 -1 -1 -1 -1 -1 -1 4 -1 3 -1 3 -1 -1 1 4 -1 2 -1 -1 3 -1 -1 -1 4 1 -1 -1 -1 4 -1 -1 -1 -1 -1 -1 3 2 -1 3 2 4 5 2 4 1 5 -1 -1 2 -1 -1 1 -1 5 3 -1 1 2 2 3 5 3 -1 -1 3 -1 -1 3 5 5 -1 -1 5 -1 4 4 1 -1 -1 -1 2 1 -1 -1 -1 2 5 3 -1 -1 -1 3 -1 5 4 -1 1 -1 -1 3 -1 -1 3 1 1 2 -1 -1 -1 1 3 1 -1 2 -1 -1 ... | code_stdio |
[
{
"content": "Vasya has a pile, that consists of some number of stones. $n$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.\n\nYou are given $n$ operations which Vasya has made. Find the minimal possible... | [{"input": "100\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", "output": "100\n"}, {"input": "100\n++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", "output": "100"}, {"input": "100\n---+-----------+-++---+... | code_stdio |
[
{
"content": "It is known that each weight of 1 gram, 3 gram, 9 gram, and 27 gram can be weighed from 1 gram to 40 gram in 1 gram increments using a balance. For example, if you put a weight of 3 grams and a weight you want to weigh on one plate of the balance and a weight of 27 grams and 1 gram on the other pl... | [{"input": "1204", "output": "+--00--+\n"}, {"input": "1942", "output": "+0-000-+\n"}, {"input": "384", "output": "+---+-0\n"}, {"input": "567", "output": "+-+0000\n"}, {"input": "397", "output": "+--0-0+\n"}, {"input": "373", "output": "+----++\n"}, {"input": "520", "output": "+-0++-+\n"}, {"input": "438", "output": "... | code_stdio |
[
{
"content": "Note that this is the first problem of the two similar problems. You can hack this problem only if you solve both problems.\n\nYou are given a tree with n nodes. In the beginning, 0 is written on all edges. In one operation, you can choose any 2 distinct leaves u, v and any real number x and add x... | [{"input": "60\n26 6\n59 30\n31 12\n31 3\n38 23\n59 29\n53 9\n38 56\n53 54\n29 21\n17 55\n59 38\n26 16\n24 59\n24 25\n17 35\n24 41\n30 15\n31 27\n8 44\n26 5\n26 48\n8 32\n53 17\n3 34\n3 51\n30 28\n47 10\n53 60\n36 42\n24 53\n59 22\n53 40\n26 52\n36 4\n59 8\n29 37\n36 20\n17 47\n53 18\n3 50\n30 2\n17 7\n8 58\n59 1\n31 1... | code_stdio |
[
{
"content": "Mishka started participating in a programming contest. There are $n$ problems in the contest. Mishka's problem-solving skill is equal to $k$.\n\nMishka arranges all problems from the contest into a list. Because of his weird principles, Mishka only solves problems from one of the ends of the list.... | [{"input": "100 90\n90 90 90 90 90 90 55 21 90 90 90 90 90 90 90 90 90 90 69 83 90 90 90 90 90 90 90 90 93 95 92 98 92 97 91 92 92 91 91 95 94 95 100 100 96 97 94 93 90 90 95 95 97 99 90 95 98 91 94 96 99 99 94 95 95 97 99 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 12 90 3 90 90 90 90 90 90 90... | code_stdio |
[
{
"content": "You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings \"AB\" and \"BA\" (the substrings can go in any order).\n\n\n-----Input-----\n\nThe only line of input contains a string s of length between 1 and 10^5 consisting of uppercase Latin lett... | [{"input": "AABBBACBBBBBBAACBCCACBBAABBBBBCAACABAACABCACCBCBCCCBCBCABCBBCCBCBBAACBACAABACBBCACCBCCACCABBCBABBAAC\n", "output": "YES\n"}, {"input": "AABBBACBBBBBBAACBCCACBBAABBBBBCAACABAACABCACCBCBCCCBCBCABCBBCCBCBBAACBACAABACBBCACCBCCACCABBCBABBAAC\n", "output": "YES\n"}, {"input": "CAABBABCBBACCACCBCCACBBCABAACABCAABB... | code_stdio |
[
{
"content": "The King of Flatland will organize a knights' tournament! The winner will get half the kingdom and the favor of the princess of legendary beauty and wisdom. The final test of the applicants' courage and strength will be a fencing tournament. The tournament is held by the following rules: the parti... | [{"input": "847094637 -152905363 -1000000000 -1000000000\n", "output": "FIRST\n-152905363\n"}, {"input": "-1000000000 1000000000 1230987 17135570\n", "output": "FIRST\n-983588156\n"}, {"input": "547686188 61562151 -496372503 -115242932\n", "output": "FIRST\n61562151\n"}, {"input": "-1000000000 1000000000 1230987 987123... | code_stdio |
[
{
"content": "You are given n numbers a_1, a_2, ..., a_{n}. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make [Image] as large as possible, where $1$ denotes the bitwise OR. \n\nFind the maximum possible value of [Image] after performing at most k... | [{"input": "5 10 8\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1073741825000000000\n"}, {"input": "5 10 8\n1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1073741825000000000\n"}, {"input": "5 10 8\n1000000000 1010000000 1000000000 1000000000 1000000000\n", "output": "10... | code_stdio |
[
{
"content": "Space Coconut Crab\n\nSpace coconut crab\n\nEnglish text is not available in this practice contest.\n\nKen Marine Blue is a space hunter who travels through the entire galaxy in search of space coconut crabs. The space coconut crab is the largest crustacean in the universe, and it is said that the... | [{"input": "1\n2\n4\n48\n266\n1236\n0", "output": "1\n2\n2\n12\n14\n36\n"}, {"input": "1\n2\n4\n48\n266\n1300\n0", "output": "1\n2\n2\n12\n14\n38\n"}, {"input": "1\n2\n4\n27\n557\n1250\n0", "output": "1\n2\n2\n3\n23\n44\n"}, {"input": "1\n2\n4\n27\n266\n1250\n0", "output": "1\n2\n2\n3\n14\n44\n"}, {"input": "1\n2\n4\n2... | code_stdio |
[
{
"content": "You are given a tree (connected graph without cycles) consisting of $n$ vertices. The tree is unrooted — it is just a connected undirected graph without cycles.\n\nIn one move, you can choose exactly $k$ leaves (leaf is such a vertex that is connected to only one another vertex) connected to the s... | [{"input": "4\n8 10\n1 2\n1 5\n7 6\n6 8\n3 1\n8 4\n7 1\n10 1\n1 2\n1 10\n2 3\n1 5\n1 6\n2 4\n7 10\n10 9\n8 10\n7 2\n3 1\n1 5\n4 6\n7 4\n1 2\n1 4\n5 1\n1 4\n2 1\n4 3\n5 3\n", "output": "0\n9\n3\n4\n"}, {"input": "4\n8 10\n1 2\n1 5\n7 6\n6 8\n3 1\n8 4\n4 1\n10 3\n1 2\n1 10\n2 3\n1 5\n1 6\n2 4\n7 10\n10 9\n8 10\n7 2\n3 1\... | code_stdio |
[
{
"content": "Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.\n\nGiven a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence ... | [{"input": "100\n4 8 10 1 8 8 8 1 10 3 1 8 6 8 6 1 10 3 3 3 3 7 2 1 1 6 10 1 7 9 8 10 3 8 6 2 1 6 5 6 10 8 9 7 4 3 10 5 3 9 10 5 10 8 8 5 7 8 9 5 3 18 9 2 7 8 2 10 4 9 2 8 10 10 5 8 5 1 7 3 4 5 2 2 9 3 2 5 6 2 3 10 1 5 9 6 10 4 10 8\n", "output": "392\n"}, {"input": "100\n4 8 10 1 8 8 8 1 10 3 1 8 6 8 6 1 10 3 3 3 3 7 ... | code_stdio |
[
{
"content": "Many computer strategy games require building cities, recruiting army, conquering tribes, collecting resources. Sometimes it leads to interesting problems. \n\nLet's suppose that your task is to build a square city. The world map uses the Cartesian coordinates. The sides of the city should be para... | [{"input": "10\n-260530833 169589238\n-681955770 -35391010\n223450511 24504262\n479795061 -26191863\n-291344265 21153856\n714700263 -328447419\n-858655942 161086142\n-270884153 462537328\n-501424901 977460517\n115284904 -151626824\n", "output": "2475449747812002025\n"}, {"input": "10\n-260530833 169589238\n-681955770 -... | code_stdio |
[
{
"content": "You have an array $a$ of length $n$. For every positive integer $x$ you are going to perform the following operation during the $x$-th second:\n\n Select some distinct indices $i_{1}, i_{2}, \\ldots, i_{k}$ which are between $1$ and $n$ inclusive, and add $2^{x-1}$ to each corresponding position ... | [{"input": "6\n3\n1000000000 -1 -1000000000\n1\n6\n2\n-1000000000 1000000000\n2\n1000000000 -1000000000\n2\n1000000000 1000000000\n2\n-1000000000 -1000000000\n", "output": "31\n0\n0\n31\n0\n0\n"}, {"input": "6\n3\n1000000000 0 -1000000000\n1\n6\n2\n-1000000000 1000000000\n2\n1000000000 -1000000000\n2\n1000000000 100000... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.