messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "E-training\n\nNene is writing a program to look up $ N $ integers $ V_1, V_2, V_3, \\ cdots, V_N $ for programming training.\n\nAs told by his instructor, Umiko, Nene wrote a program to look up multiples of 2, 3, and 6.\n\nMultiples of 2 were $ A $, multiples of 3 were $ B $, and multiples of 6 we... | [{"input": "150 1 -12 -2", "output": "159\n"}, {"input": "150 1 -11 -2", "output": "158\n"}, {"input": "150 2 -11 -2", "output": "157\n"}, {"input": "150 2 -21 -2", "output": "167\n"}, {"input": "150 2 -19 -2", "output": "165\n"}, {"input": "150 2 -28 -2", "output": "174\n"}, {"input": "150 2 -39 -2", "output": "185\n"... | code_stdio |
[
{
"content": "You are given two arrays $a$ and $b$, each contains $n$ integers.\n\nYou want to create a new array $c$ as follows: choose some real (i.e. not necessarily integer) number $d$, and then for every $i \\in [1, n]$ let $c_i := d \\cdot a_i + b_i$.\n\nYour goal is to maximize the number of zeroes in ar... | [{"input": "5\n-999999999 999999999 1252085585 999999998 -414067761\n-1011239935 -1000000000 -1000000000 -1397885361 1010000000\n", "output": "1\n"}, {"input": "5\n-999999999 999999999 1252085585 999999998 -421666581\n-1011239935 -1000000000 -1000000000 -1397885361 1010000000\n", "output": "1\n"}, {"input": "5\n-999999... | code_stdio |
[
{
"content": "You are given $n$ dominoes. Each domino has a left and a right cell. Each cell can be colored either black or white. Some cells are already colored, while some aren't yet.\n\nThe coloring is said to be valid if and only if it is possible to rearrange the dominoes in some order such that for each $... | [{"input": "100\n??\n??\n??\nB?\n??\nB?\n??\n?W\n?B\n??\n??\n??\n??\nWB\n??\nBW\n?B\nB?\nW?\nW?\nB?\n??\n??\n??\n??\n??\n??\nBB\n??\nWB\n?W\nBB\n??\n??\nW?\nB?\n?W\n?B\nW?\n??\n?W\n??\n??\nB?\nB?\n??\n??\n??\n?W\n??\n??\n?W\n?W\nW?\n??\n??\n??\n?W\nW?\nW?\n?W\nB?\n??\n??\n??\nB?\n??\n??\n??\n??\n??\nBB\n?B\nBW\n??\n??\... | code_stdio |
[
{
"content": "A daily train consists of N cars. Let's consider one particular car. It has 54 places numbered consecutively from 1 to 54, some of which are already booked and some are still free. The places are numbered in the following fashion:\nThe car is separated into 9 compartments of 6 places each, as show... | [{"input": "1 3\n100101110000001011000001111110010011110010010111000101\n001010000000101111100000000000000111101010101111111010\n011110011110000001010000101110001011111010001001111010", "output": "86\n"}, {"input": "1 3\n100101110000001111000001111110010011110010010111000101\n0010100000001011111000000000000001111010101... | code_stdio |
[
{
"content": "Serge came to the school dining room and discovered that there is a big queue here. There are $m$ pupils in the queue. He's not sure now if he wants to wait until the queue will clear, so he wants to know which dish he will receive if he does. As Serge is very tired, he asks you to compute it inst... | [{"input": "5 1\n8 4 8 7 3\n9\n5\n2 1 3\n1 5 1\n2 1 13\n2 1 7\n2 1 3\n", "output": "8\n8\n8\n8\n8\n"}, {"input": "5 1\n8 4 8 7 3\n13\n5\n2 1 3\n1 1 1\n2 1 8\n2 1 7\n2 1 3\n", "output": "8\n8\n7\n8\n8\n"}, {"input": "5 1\n8 1 8 7 3\n9\n5\n2 1 3\n1 5 1\n2 1 13\n2 1 7\n2 1 3\n", "output": "8\n8\n8\n8\n8\n"}, {"input": "5 ... | code_stdio |
[
{
"content": "There is a square in the xy-plane. The coordinates of its four vertices are (x_1,y_1),(x_2,y_2),(x_3,y_3) and (x_4,y_4) in counter-clockwise order.\n(Assume that the positive x-axis points right, and the positive y-axis points up.)\nTakahashi remembers (x_1,y_1) and (x_2,y_2), but he has forgot (x... | [{"input": "67 -89 -90 -11\n", "output": "-168 -168 -11 -246\n"}, {"input": "-100 100 100 -100\n", "output": "300 100 100 300\n"}, {"input": "0 -100 -100 100\n", "output": "-300 0 -200 -200\n"}, {"input": "31 -41 -59 26\n", "output": "-126 -64 -36 -131\n"}, {"input": "1 -46 -103 12", "output": "-161 -92 -57 -150\n"}, {... | code_stdio |
[
{
"content": "A sequence a_1,a_2,... ,a_n is said to be /\\/\\/\\/ when the following conditions are satisfied:\n\n* For each i = 1,2,..., n-2, a_i = a_{i+2}.\n* Exactly two different numbers appear in the sequence.\n\n\n\nYou are given a sequence v_1,v_2,...,v_n whose length is even. We would like to make this... | [{"input": "6\n105 119 204 119 105 119", "output": "1\n"}, {"input": "6\n105 119 204 119 105 78", "output": "2\n"}, {"input": "6\n105 119 105 81 105 119", "output": "1\n"}, {"input": "6\n105 119 204 119 105 81", "output": "2\n"}, {"input": "6\n105 119 105 119 105 119", "output": "0"}, {"input": "6\n105 120 54 119 105 7... | code_stdio |
[
{
"content": "The Patisserie AtCoder sells cakes with number-shaped candles.\nThere are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively.\nEach cake has an integer value called deliciousness, as follows:\n - The deliciousness of the cakes with 1-shaped candles are A_1, A_2, .... | [{"input": "1000 1000 1000 3000\n8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8864823801 8... | code_stdio |
[
{
"content": "Your favorite shop sells n Kinder Surprise chocolate eggs. You know that exactly s stickers and exactly t toys are placed in n eggs in total.\n\nEach Kinder Surprise can be one of three types:\n\n * it can contain a single sticker and no toy; \n * it can contain a single toy and no sticker; \n ... | [{"input": "4\n1 1 1\n1000000000 1000000000 1000000000\n1000000000 999999999 1\n1247516660 666666667 666666666\n", "output": "1\n1\n1000000000\n580849995\n"}, {"input": "4\n1 1 1\n1000000000 1000000000 1000000000\n1000000000 999999999 1\n999999999 666666667 666666666\n", "output": "1\n1\n1000000000\n333333334\n"}, {"in... | code_stdio |
[
{
"content": "The Squareland national forest is divided into equal 1 × 1 square plots aligned with north-south and east-west directions. Each plot can be uniquely described by integer Cartesian coordinates (x, y) of its south-west corner.\n\nThree friends, Alice, Bob, and Charlie are going to buy three distinct... | [{"input": "0 1000\n1000 0\n1000 1000\n", "output": "2001\n0 1000\n1 1000\n2 1000\n3 1000\n4 1000\n5 1000\n6 1000\n7 1000\n8 1000\n9 1000\n10 1000\n11 1000\n12 1000\n13 1000\n14 1000\n15 1000\n16 1000\n17 1000\n18 1000\n19 1000\n20 1000\n21 1000\n22 1000\n23 1000\n24 1000\n25 1000\n26 1000\n27 1000\n28 1000\n29 1000\n3... | code_stdio |
[
{
"content": "Recall that the sequence $b$ is a a subsequence of the sequence $a$ if $b$ can be derived from $a$ by removing zero or more elements without changing the order of the remaining elements. For example, if $a=[1, 2, 1, 3, 1, 2, 1]$, then possible subsequences are: $[1, 1, 1, 1]$, $[3]$ and $[1, 2, 1,... | [{"input": "10\n10\n-1 5 10 2 -8 -7 -6 5 -3 -1\n10\n2 2 1 4 5 6 12 3 9 10\n1\n6\n1\n-7\n11\n5 -4 1 2 3 -5 -7 -10 -2 1 12\n4\n-4 -5 -6 1\n7\n1 2 6 1 2 -6 -2\n5\n-1 -5 4 -2 -9\n1\n9\n3\n1 -1 1\n", "output": "7\n12\n6\n-7\n14\n-3\n4\n1\n9\n1\n"}, {"input": "10\n10\n-1 5 17 3 -8 -7 -6 5 -3 -1\n10\n2 2 1 4 5 6 7 8 9 10\n1\n... | code_stdio |
[
{
"content": "You are given a set of $n$ segments on the axis $Ox$, each segment has integer endpoints between $1$ and $m$ inclusive. Segments may intersect, overlap or even coincide with each other. Each segment is characterized by two integers $l_i$ and $r_i$ ($1 \\le l_i \\le r_i \\le m$) — coordinates of th... | [{"input": "100 100\n1 2\n1 3\n1 3\n2 3\n1 1\n1 2\n1 1\n1 2\n1 3\n1 2\n1 2\n1 5\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 2\n1 1\n1 1\n1 2\n2 2\n1 1\n1 5\n1 4\n1 1\n2 2\n2 9\n1 1\n1 5\n2 3\n2 3\n1 5\n1 2\n2 2\n2 2\n1 2\n1 2\n3 4\n1 5\n1 1\n1 1\n1 1\n1 1\n2 2\n1 3\n1 2\n1 2\n1 2\n1 1\n2 2\n1 4\n1 3\n1 1\n1 2\n1 1\n2 3\n1 2\n2 2\... | code_stdio |
[
{
"content": "There are N cubes stacked vertically on a desk.\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is 0, and blue if that character is 1.\nYou can perform the following operation any number of times: choose a red cube and a blue cube... | [{"input": "01010111100110000101010100010010110001111001111111010001100000111101101001110001001011101100101100001011001110011101011111101010001011110010011000010001001001110100100111000010011010101100110000001011110110110010001001111001011001010110010001100101011001000010101010101100001011101101011101000010101100011000... | code_stdio |
[
{
"content": "Little boy Petya loves stairs very much. But he is bored from simple going up and down them — he loves jumping over several stairs at a time. As he stands on some stair, he can either jump to the next one or jump over one or two stairs at a time. But some stairs are too dirty and Petya doesn't wan... | [{"input": "500 50\n72 474 467 241 442 437 336 234 410 120 438 164 405 177 142 114 27 20 445 235 46 176 88 488 242 391 28 414 145 92 206 334 152 343 367 254 100 243 155 348 148 450 461 483 97 34 471 69 416 362\n", "output": "NO\n"}, {"input": "500 50\n72 474 467 241 442 437 336 234 410 120 438 164 405 177 142 114 27 20... | code_stdio |
[
{
"content": "Hiking club \"Up the hill\" just returned from a walk. Now they are trying to remember which hills they've just walked through.\n\nIt is known that there were N stops, all on different integer heights between 1 and N kilometers (inclusive) above the sea level. On the first day they've traveled fro... | [{"input": "700\n399\n", "output": "400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 ... | code_stdio |
[
{
"content": "You've got a string $S$ consisting of $n$ lowercase English letters from your friend. It turned out that this is a number written in poman numerals. The poman numeral system is long forgotten. All that's left is the algorithm to transform number from poman numerals to the numeral system familiar t... | [{"input": "49 3\nabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\n", "output": "Yes\n"}, {"input": "49 3\nbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\n", "output": "Yes\n"}, {"input": "7 -475391\nqohshra\n", "output": "Yes\n"}, {"input": "5 -50593786\nzsbyd\n", "output": "Yes\n"}, {"input": "5 -34021632\ntinzq... | code_stdio |
[
{
"content": "Given three distinct integers $a$, $b$, and $c$, find the medium number between all of them.\n\nThe medium number is the number that is neither the minimum nor the maximum of the given three numbers.\n\nFor example, the median of $5,2,6$ is $5$, since the minimum is $2$ and the maximum is $6$.\n\n... | [{"input": "69\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2... | code_stdio |
[
{
"content": "In the good old days, the Internet was free from fears and terrorism. People did not have to worry about any cyber criminals or mad computer scientists. Today, however, you are facing atrocious crackers wherever you are, unless being disconnected. You have to protect yourselves against their attac... | [{"input": "2 5\npermit 192168?? ?12??34?\ndeny 19216899 012243?5\n19216711 11233340 HiIamACracker\n19216891 01234345 Hello\n19216899 01234345 HiIamAlsoACracker\n19216809 11200340 World\n00000000 99999999 TheEndOfTheWorld\n1 2\npermit 12345678 23456789\n19216891 01234345 Hello\n12345678 23456789 Hello\n0 0", "output": ... | code_stdio |
[
{
"content": "As technologies develop, manufacturers are making the process of unlocking a phone as user-friendly as possible. To unlock its new phone, Arkady's pet dog Mu-mu has to bark the password once. The phone represents a password as a string of two lowercase English letters.\n\nMu-mu's enemy Kashtanka w... | [{"input": "bn\n100\ndf\nyb\nze\nml\nyr\nof\nnw\nfm\ndw\nlv\nzr\nhu\nzt\nlw\nld\nmo\nxz\ntp\nmr\nou\nme\npx\nvp\nes\nxi\nnr\nbx\nqc\ngm\njs\nkn\ntw\nrq\nkz\nuc\nvc\nqr\nab\nna\nro\nya\nqy\ngu\nvk\nqk\ngs\nyq\nop\nhw\nrj\neo\nlz\nbh\nkr\nkb\nma\nrd\nza\nuf\nhq\nmc\nmn\nti\nwn\nsh\nax\nsi\nnd\ntz\ndu\nfj\nkl\nws\now\nnf\... | code_stdio |
[
{
"content": "Polycarp plays \"Game 23\". Initially he has a number $n$ and his goal is to transform it to $m$. In one move, he can multiply $n$ by $2$ or multiply $n$ by $3$. He can perform any number of moves.\n\nPrint the number of moves needed to transform $n$ to $m$. Print -1 if it is impossible to do so.\... | [{"input": "289777775 341477104\n", "output": "-1\n"}, {"input": "100000000 100000001\n", "output": "-1\n"}, {"input": "289777775 341477104\n", "output": "-1\n"}, {"input": "100000000 100000001\n", "output": "-1\n"}, {"input": "139999978 419999934\n", "output": "1\n"}, {"input": "300000007 300000007\n", "output": "0\n"... | code_stdio |
[
{
"content": "The year of 2012 is coming...\n\nAccording to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the human world. But seven brave heroes have already gathered on the top of a mount... | [{"input": "22\nCleo likes Snowy\nCleo likes Troll\nChapay likes Dracul\nSnowy likes Troll\nDracul likes Chapay\nDracul likes Snowy\nChapay likes Cleo\nSnowy likes Chapay\nDracul likes Troll\nAnka likes Hexadecimal\nSnowy likes Anka\nHexadecimal likes Cleo\nHexadecimal likes Troll\nDracul likes Anka\nCleo likes Hexadec... | code_stdio |
[
{
"content": "Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there. \n\nThe content special agent has got an i... | [{"input": "1023456789??????????????????????????????????????ABCDIFGHIJ\n", "output": "362880000000000000000000000000000000000000000"}, {"input": "?GJ??\n", "output": "81000\n"}, {"input": "BA?C?\n", "output": "64800\n"}, {"input": "HG?JI\n", "output": "45360\n"}, {"input": "GH???\n", "output": "81000\n"}, {"input": "?C... | code_stdio |
[
{
"content": "Takahashi throws N dice, each having K sides with all integers from 1 to K. The dice are NOT pairwise distinguishable.\nFor each i=2,3,...,2K, find the following value modulo 998244353:\n - The number of combinations of N sides shown by the dice such that the sum of no two different sides is i.\nN... | [{"input": "2000 3\n", "output": "337087647\n337087647\n337085647\n337085647\n337083647\n337083647\n337081647\n337081647\n337079647\n337079647\n337077647\n337077647\n337075647\n337075647\n337073647\n337073647\n337071647\n337071647\n337069647\n337069647\n337067647\n337067647\n337065647\n337065647\n337063647\n337063647\n... | code_stdio |
[
{
"content": "Are you fond of collecting some kind of stuff? Mike is crazy about collecting stamps. He is an active member of Stamp Collecting Сommunity(SCC). \n\nSCC consists of N members which are fond of philately. A few days ago Mike argued with the others from SCC. Mike told them that all stamps of the mem... | [{"input": "5\n13 1 1 1 -1", "output": "YES\n"}, {"input": "5\n13 0 1 1 -1", "output": "NO\n"}, {"input": "5\n0 3 -1 0 -1", "output": "NO\n"}, {"input": "5\n0 4 -1 0 -1", "output": "NO\n"}, {"input": "5\n-2 0 3 -1 1", "output": "NO\n"}, {"input": "5\n-3 0 3 -1 1", "output": "NO\n"}, {"input": "5\n13 0 1 1 0", "output":... | code_stdio |
[
{
"content": "Gleb ordered pizza home. When the courier delivered the pizza, he was very upset, because several pieces of sausage lay on the crust, and he does not really like the crust.\n\nThe pizza is a circle of radius r and center at the origin. Pizza consists of the main part — circle of radius r - d with ... | [{"input": "10 2\n11\n1 1 0\n2 2 3\n3 3 0\n6 4 0\n5 5 0\n6 6 0\n7 7 4\n8 8 7\n9 18 3\n10 10 100\n9 0 1\n", "output": "2\n"}, {"input": "10 2\n11\n1 1 0\n2 2 3\n3 3 0\n6 4 0\n5 5 0\n6 6 0\n7 7 8\n8 8 7\n9 18 3\n10 10 100\n9 0 1\n", "output": "2\n"}, {"input": "10 2\n11\n1 1 0\n2 2 3\n3 4 0\n6 4 0\n5 5 0\n6 12 0\n7 7 4\n... | code_stdio |
[
{
"content": "Example\n\nInput\n\nanagram\ngrandmother\n\n\nOutput\n\n4\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": "anagram\ngrandmosher", "output": "4\n"}, {"input": "anbgram\ngrandmosher", "output": "3\n"}, {"input": "anbfram\ngrandmosher", "output": "2\n"}, {"input": "narfamb\nreoahmodsrg", "output": "1\n"}, {"input": "nbgaqnb\ntohtheodscl", "output": "0\n"}, {"input": "anagram\ngrandlother", "output": "4\n"}, {"input... | code_stdio |
[
{
"content": "Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to be sad, so he would ensure to give at lea... | [{"input": "40\n37 15\n48 10\n16 5\n30 23\n32 20\n24 4\n46 19\n16 13\n1 1\n37 22\n44 29\n24 6\n27 10\n39 16\n28 13\n5 4\n31 22\n9 2\n30 26\n23 16\n16 12\n43 5\n29 1\n20 5\n40 12\n18 14\n22 15\n29 2\n3 2\n6 3\n45 28\n42 34\n43 32\n10 10\n12 8\n10 8\n4 1\n17 17\n16 7\n8 7\n", "output": "796297179\n361826943\n1330\n156078... | code_stdio |
[
{
"content": "INTERCAL is the oldest of esoteric programming languages. One of its many weird features is the method of character-based output, known as Turing Tape method. It converts an array of unsigned 8-bit integers into a sequence of characters to print, using the following method.\n\nThe integers of the ... | [{"input": "aMCT]:0hDJ*Up5g_l:O&>>%gjQkZkb(mi&;\\7dL\"nWOGz/;,6h*@Q0R53MS2<}F~+Ms\\\"cF-lgF0>C&y7)72\\.T\"8*#VO=|^OtYs\n", "output": "122\n212\n240\n152\n112\n94\n80\n246\n244\n208\n254\n170\n156\n98\n198\n236\n196\n218\n106\n142\n232\n0\n216\n190\n144\n204\n180\n124\n132\n144\n50\n94\n32\n50\n136\n162\n78\n198\n244\n2... | code_stdio |
[
{
"content": "Vasya lives in a strange world. The year has n months and the i-th month has ai days. Vasya got a New Year present — the clock that shows not only the time, but also the date.\n\nThe clock's face can display any number from 1 to d. It is guaranteed that ai ≤ d for all i from 1 to n. The clock does... | [{"input": "103\n100\n68 38 41 54 37 11 35 26 43 97 70 3 13 11 64 83 3 95 17 16 4 13 22 27 64 20 95 38 40 87 6 17 95 67 31 24 85 33 98 24 89 101 66 38 42 5 95 18 95 13 103 85 72 73 68 93 22 59 48 59 72 46 5 41 54 32 48 69 3 76 2 26 102 44 39 58 55 85 40 16 81 78 92 63 25 97 83 2 54 16 20 63 19 8 84 34 1 22 43 93\n", "o... | code_stdio |
[
{
"content": "Write a program which manipulates a disjoint set S = {S1, S2, . . . , Sk}.\n\nFirst of all, the program should read an integer n, then make a disjoint set where each element consists of 0, 1, ... n−1 respectively.\n\nNext, the program should read an integer q and manipulate the set for q queries. ... | [{"input": "5 12\n1 1 4\n1 2 3\n1 1 1\n1 3 4\n1 2 4\n1 2 2\n1 1 3\n1 1 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0", "output": "0\n0\n1\n0\n0\n1\n0\n0\n0\n0\n0\n"}, {"input": "5 12\n1 1 4\n1 2 3\n1 1 1\n1 3 4\n1 2 4\n1 3 2\n1 1 3\n1 1 4\n1 3 0\n0 0 4\n1 0 3\n1 3 0", "output": "0\n0\n1\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"input": "5 12\n0 ... | code_stdio |
[
{
"content": "Greg is a beginner bodybuilder. Today the gym coach gave him the training plan. All it had was n integers a_1, a_2, ..., a_{n}. These numbers mean that Greg needs to do exactly n exercises today. Besides, Greg should repeat the i-th in order exercise a_{i} times.\n\nGreg now only does three types ... | [{"input": "20\n25 50 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 24\n", "output": "biceps\n"}, {"input": "20\n25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 24\n", "output": "chest\n"}, {"input": "20\n25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 25 24\n", "output": "chest\n"}, {"input": "20\n... | code_stdio |
[
{
"content": "You are given two positive integer numbers a and b. Permute (change order) of the digits of a to construct maximal number not exceeding b. No number in input and/or output can start with the digit 0.\n\nIt is allowed to leave a as it is.\n\n\n-----Input-----\n\nThe first line contains integer a (1... | [{"input": "1000000000000000000\n1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000\n1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000\n1000000000100000000\n", "output": "1000000000000000000\n"}, {"input": "999999999999999999\n100000000000... | code_stdio |
[
{
"content": "Little Elephant was fond of inventing new games. After a lot of research, Little Elephant came to know that most of the animals in the forest were showing less interest to play the multi-player games. Little Elephant had started to invent single player games, and succeeded in inventing the new sin... | [{"input": "1\n2\n1 2 2\n2 -2 1", "output": "1\n-1\n"}, {"input": "1\n2\n1 0 2\n1 -2 2", "output": "0\n-1\n"}, {"input": "1\n1\n1 -4 2\n-1 7 -1", "output": "-2\n"}, {"input": "1\n2\n2 -1 2\n2 8 1", "output": "-1\n4\n"}, {"input": "1\n2\n1 -1 1\n2 7 2", "output": "-1\n3\n"}, {"input": "1\n2\n2 0 1\n1 12 2", "output": "0... | code_stdio |
[
{
"content": "Vova plays a computer game known as Mages and Monsters. Vova's character is a mage. Though as he has just started, his character knows no spells.\n\nVova's character can learn new spells during the game. Every spell is characterized by two values x_{i} and y_{i} — damage per second and mana cost p... | [{"input": "15 100\n1 8 8\n2 200 101\n2 10 99\n1 9 9\n2 10 99\n2 200 101\n1 14 4\n2 194 195\n2 194 194\n2 990 290\n1 2 999992\n2 6 256\n2 7 256\n2 2 999988\n2 2 252\n", "output": "NO\nNO\nYES\nNO\nNO\nYES\nNO\nNO\nYES\nYES\nYES\n"}, {"input": "15 100\n1 8 8\n2 200 101\n2 10 99\n1 9 9\n2 10 99\n2 200 101\n1 14 4\n2 194 ... | code_stdio |
[
{
"content": "A certain type of steel is graded according to the following conditions.\n\n1. Hardness of the steel must be greater than 50\n2. Carbon content of the steel must be less than 0.7\n3. Tensile strength must be greater than 5600\n\nThe grades awarded are as follows:\nGrade is 10 if all three conditio... | [{"input": "3 \n127 1.5460478864469624 13440\n71 -1 8462\n1 -1 0", "output": "7\n10\n6\n"}, {"input": "3 \n127 1.5460478864469624 13440\n16 -1 14390\n1 -2 0", "output": "7\n8\n6\n"}, {"input": "3 \n127 2.9825462611697358 13440\n16 -2 14390\n1 -2 0", "output": "7\n8\n6\n"}, {"input": "3 \n127 3.3228384832989373 13440\n1... | code_stdio |
[
{
"content": "Ashish has an array $a$ of size $n$.\n\nA subsequence of $a$ is defined as a sequence that can be obtained from $a$ by deleting some elements (possibly none), without changing the order of the remaining elements.\n\nConsider a subsequence $s$ of $a$. He defines the cost of $s$ as the minimum betwe... | [{"input": "10 4\n91239 51189 50977 96098 56330 55725 6448 7351 60071 93359\n", "output": "50977\n"}, {"input": "10 4\n91239 51189 50977 96098 56330 55725 6448 7351 82063 93359\n", "output": "50977\n"}, {"input": "10 4\n30551 51189 50977 96098 56330 55725 6448 7351 82063 93359\n", "output": "30551\n"}, {"input": "10 4\... | code_stdio |
[
{
"content": "In the school computer room there are n servers which are responsible for processing several computing tasks. You know the number of scheduled tasks for each server: there are m_{i} tasks assigned to the i-th server.\n\nIn order to balance the load for each server, you want to reassign some tasks ... | [{"input": "10\n19999 19999 20000 20000 29860 20000 12103 20000 19999 17191\n", "output": "10536\n"}, {"input": "10\n19999 19999 20000 39539 29860 20000 12103 20000 19999 17191\n", "output": "25661\n"}, {"input": "10\n11328 19999 20000 39539 29860 20000 12103 20000 19999 17191\n", "output": "27395\n"}, {"input": "10\n1... | code_stdio |
[
{
"content": "A permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For example, sequence [0, 2, 1] is a permutation of length 3 while both [0, 2, 2] and [1, 2, 3] are not.\n\nA fixed point of a function is a point that is mapped to itself by the f... | [{"input": "100\n99 5 40 32 4 31 38 57 94 47 26 16 89 72 9 80 55 86 78 90 42 41 46 74 56 97 21 48 66 27 93 85 88 59 64 95 10 45 12 22 84 60 8 98 62 51 14 65 39 30 11 71 92 19 76 43 87 54 15 53 37 6 25 18 96 35 13 91 2 3 0 23 1 7 49 75 81 33 50 52 63 44 69 36 17 61 24 20 68 34 73 29 70 83 58 79 82 28 77 67\n", "output":... | code_stdio |
[
{
"content": "You have N items that you want to put them into a knapsack. Item i has value vi and weight wi.\n\nYou want to find a subset of items to put such that:\n\n* The total value of the items is as large as possible.\n* The items have combined weight at most W, that is capacity of the knapsack.\n\n\n\nFi... | [{"input": "4 3\n4 0\n5 2\n2 1\n13 1", "output": "22\n"}, {"input": "4 6\n4 0\n5 2\n2 1\n13 1", "output": "24\n"}, {"input": "4 5\n0 2\n5 2\n2 1\n8 3", "output": "13\n"}, {"input": "4 5\n4 2\n5 2\n2 0\n8 3", "output": "15\n"}, {"input": "4 7\n4 2\n5 2\n2 0\n8 3", "output": "19\n"}, {"input": "4 1\n4 4\n5 3\n1 0\n15 3",... | code_stdio |
[
{
"content": "You are running through a rectangular field. This field can be represented as a matrix with 3 rows and m columns. (i, j) denotes a cell belonging to i-th row and j-th column.\n\nYou start in (2, 1) and have to end your path in (2, m). From the cell (i, j) you may advance to:\n\n * (i - 1, j + 1) ... | [{"input": "50 100\n3 24 49\n2 10 12\n1 87 92\n2 19 60\n2 53 79\n3 65 82\n3 10 46\n1 46 86\n2 55 84\n1 50 53\n3 80 81\n3 66 70\n2 35 52\n1 63 69\n2 65 87\n3 68 75\n1 33 42\n1 56 90\n3 73 93\n2 20 26\n2 42 80\n2 83 87\n3 99 99\n1 14 79\n2 94 97\n1 66 85\n1 7 73\n1 50 50\n2 16 40\n2 76 94\n1 71 98\n1 99 99\n1 61 87\n3 98... | code_stdio |
[
{
"content": "Eugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of t_{i} minutes. Eugeny listens to each song, perhaps more than once. He listens to song number i c_{i} times. Eugeny's play list is organized as follows: first song number 1 plays c_1 ti... | [{"input": "10 10\n3 1\n2 7\n5 1\n7 2\n9 10\n9 5\n2 5\n4 8\n9 9\n1 9\n26 34 37 141 146 201 239 245 296 299\n", "output": "4\n4\n5\n6\n6\n8\n9\n9\n10\n10\n"}, {"input": "10 10\n3 1\n2 7\n5 1\n7 2\n9 10\n9 5\n2 5\n4 10\n9 15\n1 9\n26 34 37 141 146 201 239 245 296 299\n", "output": "4\n4\n5\n6\n6\n8\n9\n9\n9\n9\n"}, {"inp... | code_stdio |
[
{
"content": "Snuke built an online judge to hold a programming contest.\n\nWhen a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.)\n\nDetermine whether... | [{"input": "ACABA", "output": "Yes\n"}, {"input": "ACBAA", "output": "Yes\n"}, {"input": "ACAAA", "output": "Yes\n"}, {"input": "AAACA", "output": "Yes\n"}, {"input": "AAAC@", "output": "Yes\n"}, {"input": "BAAC@", "output": "Yes\n"}, {"input": "B@AC@", "output": "Yes\n"}, {"input": "A@AC@", "output": "Yes\n"}, {"input... | code_stdio |
[
{
"content": "Today Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly k months. He looked at the calendar and learned that at the moment is the month number s. Vasya immediately got interested in what month Codecraft III will appear.... | [{"input": "September\n0\n", "output": "September\n"}, {"input": "November\n46\n", "output": "September\n"}, {"input": "December\n240\n", "output": "December\n"}, {"input": "December\n81\n", "output": "September\n"}, {"input": "February\n22\n", "output": "December\n"}, {"input": "September\n3\n", "output": "December\n"... | code_stdio |
[
{
"content": "For a set $S$ of integers, perform a sequence of the following operations. Note that multiple elements can have equivalent values in $S$.\n\n* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after the operation.\n* find($x$): Report the number of $x$ in $S$.\n* delete($x$):... | [{"input": "10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n0 2\n1 3\n0 4\n3 1 4", "output": "1\n2\n3\n4\n2\n4\n1\n5\n1\n1\n2\n3\n4\n"}, {"input": "10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n1 1\n1 3\n0 4\n3 1 4", "output": "1\n2\n3\n4\n2\n2\n1\n4\n1\n1\n3\n4\n"}, {"input": "10\n0 1\n0 1\n0 2\n0 -1\n2 2\n1 0\n1 2\n1 3\n0 4\n3 1 4", "output":... | code_stdio |
[
{
"content": "Given is a string S of length N consisting of lowercase English letters.\nSnuke can do this operation any number of times: remove fox occurring as a substring from s and concatenate the remaining parts of s.\nWhat is the minimum possible length of s after some number of operations by Snuke?\n\n---... | [{"input": "90585\nfohfoxuvgjxpybcfoxmefomtzopbsprupidgsybejhphoymfoxxaobhdxbmfoxqioqjzehbmufpownifoxhwlrybqsqijgkdmbpfoxzlobcfoxfpdznrbcqqjqglhqgnuooojywfoxfsqesfoxagdfmfoxlzlhjxrfkwmrktsintfocipouajpsqucpoydkfogknyjffoxddeqsrdeupfownwreitzyflusfoxrhmoffoxqfoxsmyurkfotmlxhekuksfotxukcdfopfoxrcryuanwuxzxtayrlhmhfpmrqof... | code_stdio |
[
{
"content": "She does her utmost to flawlessly carry out a person's last rites and preserve the world's balance of yin and yang.\n\nHu Tao, being the little prankster she is, has tried to scare you with this graph problem! You are given a connected undirected graph of n nodes with m edges. You also have q quer... | [{"input": "6 7\n2 1\n2 3\n3 5\n1 2\n6 1\n5 6\n4 5\n3\n1 4\n5 1\n4 5\n", "output": "YES\n5\n1 2 3 5 4\n4\n5 3 2 1\n2\n4 5\n"}, {"input": "6 7\n2 1\n2 3\n3 5\n1 4\n6 1\n5 6\n4 5\n3\n1 4\n5 1\n4 5\n", "output": "YES\n2\n1 4\n4\n5 3 2 1\n5\n4 1 2 3 5\n"}, {"input": "6 7\n2 1\n2 3\n2 5\n1 4\n6 1\n5 6\n4 5\n3\n1 4\n5 1\n4 5... | code_stdio |
[
{
"content": "Madoka decided to entrust the organization of a major computer game tournament \"OSU\"!\n\nIn this tournament, matches are held according to the \"Olympic system\". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in tot... | [{"input": "100000 1000000000\n", "output": "607723520\n"}, {"input": "100000 53228\n", "output": "871774727\n"}, {"input": "11994 11995\n", "output": "685385528\n"}, {"input": "87532 32150\n", "output": "165162987\n"}, {"input": "99999 3123\n", "output": "575224395\n"}, {"input": "30 99999999\n", "output": "73741817\n... | code_stdio |
[
{
"content": "There are N gems. The value of the i-th gem is V_i.\nYou will choose some of these gems, possibly all or none, and get them.\nHowever, you need to pay a cost of C_i to get the i-th gem.\nLet X be the sum of the values of the gems obtained, and Y be the sum of the costs paid.\nFind the maximum poss... | [{"input": "20\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\n50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50\n", "output": "0\n"}, {"input": "20\n14 45 40 37 6 20 19 18 5 16 4 11 47 27 24 13 41 9 38 44\n43 50 46 40 29 47 45 46 45 33 12 35 48 44 31 20 42 40 47 48\n", "output": "0\n"}, {"input... | code_stdio |
[
{
"content": "Do you know a story about the three musketeers? Anyway, you will learn about its origins now.\n\nRichelimakieu is a cardinal in the city of Bearis. He is tired of dealing with crime by himself. He needs three brave warriors to help him to fight against bad guys.\n\nThere are n warriors. Richelimak... | [{"input": "987 50\n221 959\n221 553\n959 695\n553 959\n819 437\n371 295\n695 553\n959 347\n595 699\n652 628\n553 347\n868 589\n695 221\n282 714\n351 703\n104 665\n755 436\n556 511\n695 347\n221 347\n243 874\n695 847\n863 501\n583 145\n786 221\n38 286\n72 397\n808 658\n724 437\n911 548\n405 759\n681 316\n648 328\n327 1... | code_stdio |
[
{
"content": "There are $n$ models in the shop numbered from $1$ to $n$, with sizes $s_1, s_2, \\ldots, s_n$.\n\nOrac will buy some of the models and will arrange them in the order of increasing numbers (i.e. indices, but not sizes).\n\nOrac thinks that the obtained arrangement is beatiful, if for any two adjac... | [{"input": "4\n23\n3198 4895 1585 3916 2650 5552 876 2731 1971 126 2152 6910 1096 4103 1074 2594 2897 3983 3830 3460 729 576 3281\n1\n0000000010\n2\n1 1\n100\n1 2 3 4 5 2 7 10 9 14 11 12 13 14 24 16 17 33 19 20 21 22 23 24 25 26 27 28 29 41 31 32 56 34 35 36 37 38 39 40 41 42 43 44 45 46 54 48 25 60 25 52 53 54 49 56 5... | code_stdio |
[
{
"content": "Petya and Vasya are playing a game. Petya's got n non-transparent glasses, standing in a row. The glasses' positions are indexed with integers from 1 to n from left to right. Note that the positions are indexed but the glasses are not.\n\nFirst Petya puts a marble under the glass in position s. Th... | [{"input": "100 27 56\n58 18 50 41 33 37 14 87 77 73 61 53 15 8 70 68 45 96 54 78 39 120 51 60 80 12 93 99 20 92 17 79 4 13 62 91 69 29 49 36 98 34 90 35 84 64 38 83 28 89 165 94 9 16 26 48 10 57 23 75 27 88 44 21 72 76 30 43 32 2 71 24 100 1 31 99 42 40 47 55 86 85 66 5 52 43 95 74 11 19 7 82 6 25 56 63 65 59 46 3\n",... | code_stdio |
[
{
"content": "A permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≤ pi ≤ n).\n\nA lucky permutation is such permutation p, that any integer i (1 ≤ i ≤ n) meets this condition ppi = n - i + 1.\n\nYou have integer n. Find some lucky permutat... | [{"input": "17877\n", "output": "2 17877 4 17875 6 17873 8 17871 10 17869 12 17867 14 17865 16 17863 18 17861 20 17859 22 17857 24 17855 26 17853 28 17851 30 17849 32 17847 34 17845 36 17843 38 17841 40 17839 42 17837 44 17835 46 17833 48 17831 50 17829 52 17827 54 17825 56 17823 58 17821 60 17819 62 17817 64 17815 66 ... | code_stdio |
[
{
"content": "You have $n$ students under your control and you have to compose exactly two teams consisting of some subset of your students. Each student had his own skill, the $i$-th student skill is denoted by an integer $a_i$ (different students can have the same skills).\n\nSo, about the teams. Firstly, the... | [{"input": "4\n7\n4 2 4 1 4 3 4\n5\n2 1 5 4 3\n1\n1\n4\n1 1 1 3\n", "output": "3\n1\n0\n2\n"}, {"input": "4\n7\n4 2 4 1 4 3 4\n5\n2 1 5 1 3\n1\n1\n4\n1 1 1 3\n", "output": "3\n2\n0\n2\n"}, {"input": "4\n7\n4 2 4 1 4 3 4\n5\n2 1 2 1 3\n1\n1\n4\n1 1 1 1\n", "output": "3\n2\n0\n1\n"}, {"input": "4\n7\n4 2 4 1 4 3 4\n5\n2 ... | code_stdio |
[
{
"content": "Natsuki and her friends were taken to the space by an alien and made friends with a lot of aliens. During the space travel, she discovered that aliens’ hands were often very different from humans’. Generally speaking, in a kind of aliens, there are N fingers and M bend rules on a hand. Each bend r... | [{"input": "23 4\n2 3\n3 1\n6 4\n5 2", "output": "1966080\n"}, {"input": "23 4\n2 3\n3 1\n6 6\n5 2", "output": "2621440\n"}, {"input": "24 4\n2 3\n3 2\n4 4\n5 2", "output": "6291456\n"}, {"input": "19 4\n2 2\n3 4\n4 3\n9 5", "output": "196608\n"}, {"input": "9 5\n1 2\n2 2\n3 5\n4 5\n5 1", "output": "112\n"}, {"input": ... | code_stdio |
[
{
"content": "You are given an array of $n$ integers $a_1$, $a_2$, ..., $a_n$, and a set $b$ of $k$ distinct integers from $1$ to $n$.\n\nIn one operation, you may choose two integers $i$ and $x$ ($1 \\le i \\le n$, $x$ can be any integer) and assign $a_i := x$. This operation can be done only if $i$ does not b... | [{"input": "100 2\n96 58 6 51 50 14 42 14 8 23 50 87 18 38 66 12 60 34 67 79 73 79 100 94 89 73 4 13 30 3 34 26 41 65 18 71 29 3 40 65 77 83 51 20 38 45 43 64 7 12 97 42 88 32 62 61 92 17 83 14 3 23 5 58 3 64 17 35 23 86 65 22 44 81 30 95 62 63 17 85 3 3 17 56 26 94 59 84 3 88 70 53 52 74 12 47 79 96 72 30\n4 21\n", "o... | code_stdio |
[
{
"content": "Pavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed originally and in the reversed direction.\n\nPavel has a plan: a permutation p... | [{"input": "100\n87 69 49 86 96 12 10 79 29 66 48 77 73 62 70 52 22 28 97 35 91 5 33 82 65 85 68 80 64 8 38 23 94 34 75 53 57 6 100 2 56 50 55 58 74 9 18 44 40 3 43 45 99 51 21 92 89 36 88 54 42 14 78 71 25 76 13 11 27 72 7 32 93 46 83 30 26 37 39 31 95 59 47 24 67 16 4 15 1 98 19 81 84 61 90 41 17 20 63 60\n1 1 1 0 1 ... | code_stdio |
[
{
"content": "In order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game.\n\nTzuyu gave Sana two integers $a$ and $b$ and a really important quest.\n\nIn order to complete the quest, Sana has to output the smallest possible value of ($a \\oplus x$) + ($b \\oplus x$) for any given $x$, ... | [{"input": "6\n6 12\n8 4\n90 1219\n55 14\n6484 2912\n2 1\n", "output": "10\n12\n1177\n57\n4660\n3\n"}, {"input": "6\n6 12\n13 4\n90 1219\n55 14\n6484 2912\n2 1\n", "output": "10\n9\n1177\n57\n4660\n3\n"}, {"input": "6\n6 12\n8 6\n90 1219\n55 14\n6484 2912\n2 1\n", "output": "10\n14\n1177\n57\n4660\n3\n"}, {"input": "6\... | code_stdio |
[
{
"content": "You have $n$ barrels lined up in a row, numbered from left to right from one. Initially, the $i$-th barrel contains $a_i$ liters of water.\n\nYou can pour water from one barrel to another. In one act of pouring, you can choose two different barrels $x$ and $y$ (the $x$-th barrel shouldn't be empty... | [{"input": "2\n4 1\n19 5 2 5\n3 2\n0 0 1\n", "output": "24\n1\n"}, {"input": "2\n4 1\n5 16 5 5\n3 2\n0 0 1\n", "output": "21\n1\n"}, {"input": "2\n4 3\n10 1 1 2\n3 2\n0 1 1\n", "output": "14\n2\n"}, {"input": "2\n4 1\n5 16 5 5\n3 2\n0 0 2\n", "output": "21\n2\n"}, {"input": "2\n4 1\n5 11 5 5\n3 1\n1 0 1\n", "output": "... | code_stdio |
[
{
"content": "Consider an n × m grid. Initially all the cells of the grid are colored white. Lenny has painted some of the cells (at least one) black. We call a painted grid convex if one can walk from any black cell to any another black cell using a path of side-adjacent black cells changing his direction at m... | [{"input": "50 2\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWB\nWB\nWB\nWB\nWB\nWB\nWB\nWB\nWB\nWB\nBB\nBB\nBB\nBB\nBB\nBB\nBB\nBB\nBB\nBB\nBB\nBB\nBB\nBB\nBB\nBW\nBW\nBW\nBW\nBW\nBW\nBW\nWW\nWW\nWW\n", "output": "NO\n"}, {"input": "50 2\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nWW\nBW\... | code_stdio |
[
{
"content": "Your task is to implement a double linked list.\n\nWrite a program which performs the following operations:\n\n* insert x: insert an element with key x into the front of the list.\n* delete x: delete the first element which has the key of x from the list. If there is not such element, you need not... | [{"input": "9\ninsert 19\ninsert 2\ninsert 2\ninsert 0\ndelete 3\ninsert 6\ndelete 5\ndeleteFirst\ndeleteLast", "output": "0 2 2\n"}, {"input": "9\ninsert 19\ninsert 3\ninsert 3\ninsert 0\ndelete 6\ninsert 6\ndeldte 5\ndeleteFirst\ndeleteLast", "output": "0 3 3\n"}, {"input": "9\ninsert 10\ninsert 2\ninsert 4\ninsert 1... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is constraints.\n\nIvan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wants to use some of these microtransactions — and he won't start playing until... | [{"input": "78 36\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\n1 52\n2 6\n9 43\n10 52\n4 63\n9 35\n10 67\n9 17\n3 43\n4 38\n1 27\n9 44\n6 74\n7 3\n8 18\n1 52\n1 68\n5 51\n5 2\n7 50\n1 72\n1 37\n8 64\n10 30\n... | code_stdio |
[
{
"content": "One day Vitaly was going home late at night and wondering: how many people aren't sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at that moment.\n\nVitaly sees a building of n floors and 2·m windows on each floor. On each floor the... | [{"input": "100 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 0\n1 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\n1 1\n0 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\n1 1\n1 1\n1 0\n1 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\n1 1\n1 1\n1 1\n1 1\n1 1\n1 0\n1 1\n1 1\n1 1\n1 1\n1... | code_stdio |
[
{
"content": "There are $n + 1$ cities, numbered from $0$ to $n$. $n$ roads connect these cities, the $i$-th road connects cities $i - 1$ and $i$ ($i \\in [1, n]$).\n\nEach road has a direction. The directions are given by a string of $n$ characters such that each character is either L or R. If the $i$-th chara... | [{"input": "2\n6\nLRRRLL\n3\nLRL\n", "output": "\n1 3 2 3 1 3 2\n1 4 1 4\n"}, {"input": "2\n6\nLRRRLL\n3\nLRL\n", "output": "1 3 2 3 1 3 2\n1 4 1 4\n"}, {"input": "2\n6\nLLRRRL\n3\nLRL\n", "output": "1 2 3 2 3 1 3\n1 4 1 4\n"}, {"input": "2\n6\nLLRRRL\n3\nRLL\n", "output": "1 2 3 2 3 1 3\n3 1 3 2\n"}, {"input": "2\n6\n... | code_stdio |
[
{
"content": "You are given a string S of length N consisting of lowercase English letters.\nWe will cut this string at one position into two strings X and Y.\nHere, we would like to maximize the number of different letters contained in both X and Y.\nFind the largest possible number of different letters contai... | [{"input": "45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n", "output": "9\n"}, {"input": "45\ntgxgtqkyjfhyzutjjdllptdpxrbrylqfqjynmfbfucbio", "output": "10\n"}, {"input": "45\nbnxgtqkykfhyzutjjdllptdpxrtrylqfqjygmfbftcbio", "output": "11\n"}, {"input": "45\nblxhtqkyjehxzutkjdmlpidpurtrzlbfribgmhqfzcyto", "output":... | code_stdio |
[
{
"content": "\"The Chamber of Secrets has been opened again\" — this news has spread all around Hogwarts and some of the students have been petrified due to seeing the basilisk. Dumbledore got fired and now Harry is trying to enter the Chamber of Secrets. These aren't good news for Lord Voldemort. The problem ... | [{"input": "20 20\n..................#.\n.#.............#....\n....................\n....................\n....#...........#...\n....................\n......#......#......\n....................\n........#...#.......\n....................\n.........#...#......\n....................\n....................\n......#........... | code_stdio |
[
{
"content": "Cat Noku has obtained a map of the night sky. On this map, he found a constellation with n stars numbered from 1 to n. For each i, the i-th star is located at coordinates (xi, yi). No two stars are located at the same position.\n\nIn the evening Noku is going to take a look at the night sky. He wo... | [{"input": "10\n25280705 121178189\n219147240 -570920213\n-829849659 923854124\n18428128 -781819137\n-876779400 528386329\n-780997681 387686853\n-101900553 749998368\n58277314 355353788\n732128908 336416193\n840698381 600685123\n", "output": "5 3 6\n"}, {"input": "10\n25280705 121178189\n219147240 -570920213\n-82984965... | code_stdio |
[
{
"content": "We have a sequence of k numbers: d_0,d_1,...,d_{k - 1}.\nProcess the following q queries in order:\n - The i-th query contains three integers n_i, x_i, and m_i.\nLet a_0,a_1,...,a_{n_i - 1} be the following sequence of n_i numbers: \\begin{eqnarray} a_j = \\begin{cases} x_i & ( j = 0 ) \\\\ ... | [{"input": "7 3\n27 18 28 18 28 46 1000000000\n1000000000 1 7\n1000000000 2 10\n1000000000 3 12\n", "output": "224489796\n214285714\n559523809\n"}, {"input": "7 3\n27 18 15 18 28 73 1000000000\n1000000010 1 13\n1000000000 2 10\n1000010000 2 12", "output": "615384622\n300000000\n678578214\n"}, {"input": "7 3\n27 18 15 1... | code_stdio |
[
{
"content": "Chef is the new king of the country Chefland. As first and most important responsibility he wants to reconstruct the road system of Chefland. There are N (1 to N) cities in the country and each city i has a population Pi. Chef wants to build some bi-directional roads connecting different cities su... | [{"input": "2\n2\n12 10\n4\n3 10 21 13", "output": "120\n132\n"}, {"input": "2\n2\n5 10\n4\n19 10 11 13", "output": "50\n430\n"}, {"input": "2\n2\n5 10\n4\n17 10 11 13", "output": "50\n410\n"}, {"input": "2\n2\n6 10\n4\n17 10 11 13", "output": "60\n410\n"}, {"input": "2\n2\n2 10\n4\n17 10 11 13", "output": "20\n410\n"}... | code_stdio |
[
{
"content": "Many modern text editors automatically check the spelling of the user's text. Some editors even suggest how to correct typos.\n\nIn this problem your task to implement a small functionality to correct two types of typos in a word. We will assume that three identical letters together is a typo (for... | [{"input": "aabbccddaabbccddaabbccddaabbccddaaxaabbccbdaabbccddaabbccddaabbccddaaxyaabbccddaabbccddaabbccddaabbccddaaxyzaabbccddaabbccddaabbccddaabbccddaaxyzqaabbccddaadbccddaabbccddaabbccddaaqwertyaabbccddaabbccddaabbccddaabbccddaa\n", "output": "aabccdaabccdaabccdaabccdaaxaabccbdaabccdaabccdaabccdaaxyaabccdaabccdaabc... | code_stdio |
[
{
"content": "Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any other.\n\nThe boys decided to have fun and came up with a plan. Namely, in s... | [{"input": "5 20\n5 5 1 4\n1 4 3\n2 4 1\n1 5 5\n5 1 4\n5 1 5\n1 5 5\n5 4 4\n2 3 3\n4 4 1\n1 4 1\n4 5 4\n1 4 5\n4 1 5\n2 4 2\n4 3 3\n2 5 5\n1 5 4\n3 3 4\n5 5 1\n3 4 1\n", "output": "3\n3\n3\n2\n3\n3\n2\n3\n2\n2\n2\n2\n2\n3\n3\n2\n2\n3\n3\n3\n"}, {"input": "5 20\n4 1 1 4\n2 2 5\n3 2 5\n2 3 4\n4 2 5\n4 1 2\n5 3 1\n2 1 2\n... | code_stdio |
[
{
"content": "A cheetah and a cheater are going to play the game of Nim. In this game they use N piles of stones. Initially the i-th pile contains a_i stones. The players take turns alternately, and the cheetah plays first. In each turn, the player chooses one of the piles, and takes one or more stones from the... | [{"input": "3\n101\n100\n100", "output": "-1\n"}, {"input": "3\n011\n100\n100", "output": "-1\n"}, {"input": "3\n100\n110\n100", "output": "-1\n"}, {"input": "3\n010\n100\n100", "output": "-1\n"}, {"input": "3\n011\n100\n101", "output": "-1\n"}, {"input": "3\n100\n110\n110", "output": "-1\n"}, {"input": "3\n100\n110\n1... | code_stdio |
[
{
"content": "In 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.\n\nFor half a year after opening, the toll will be halved for vehicles that pass the departure IC or arrival IC between 17... | [{"input": "2\n17 24\n4\n17 45\n2\n17 25\n7\n-1 35\n0", "output": "250\n1500\n"}, {"input": "2\n13 25\n6\n17 14\n4\n17 25\n7\n1 10\n0", "output": "1150\n1300\n"}, {"input": "2\n17 25\n4\n17 45\n4\n17 19\n7\n19 35\n0", "output": "250\n1300\n"}, {"input": "2\n17 24\n4\n17 45\n4\n17 25\n7\n-1 35\n0", "output": "250\n1300\... | code_stdio |
[
{
"content": "Nate U. Smith runs a railroad company in a metropolitan area. In addition to his railroad company, there are rival railroad companies in this metropolitan area. The two companies are in a competitive relationship with each other.\n\nIn this metropolitan area, all lines are routed by the line segme... | [{"input": "2\n-10 1 10 1\n4\n-6 2 -2 -2 1 1\n-6 -2 -2 2 1 0\n12 2 1 -2 0 0\n11 -2 2 2 1 1\n8 12 -7 -3\n8\n4 -5 4 -2 1 2\n4 -2 4 9 1 0\n6 9 6 14 1 1\n-5 6 7 6 0 0\n1 0 1 10 0 0\n-5 0 -5 10 0 1\n-7 -1 7 0 0 1\n-1 -1 -1 -3 0 1", "output": "2\n3\n"}, {"input": "2\n-10 2 10 1\n4\n-6 2 -2 -2 1 1\n-6 -2 -2 2 1 0\n12 2 1 -2 0... | code_stdio |
[
{
"content": "There is Kannon-do in the mountain behind Ichiro's house. There are 30 steps from the foot to this Kannon-do, and Ichiro goes to Kannon-do almost every day. Ichiro can go up the stairs up to 3 steps with one foot. While playing, I noticed that there are so many types of stair climbing (the number ... | [{"input": "1\n1\n30\n27\n0", "output": "1\n1\n14740\n2369\n"}, {"input": "1\n17\n28\n27\n0", "output": "1\n6\n4357\n2369\n"}, {"input": "1\n1\n30\n25\n0", "output": "1\n1\n14740\n701\n"}, {"input": "1\n17\n28\n24\n0", "output": "1\n6\n4357\n381\n"}, {"input": "1\n18\n20\n25\n0", "output": "1\n10\n34\n701\n"}, {"input"... | code_stdio |
[
{
"content": "Problem\n\nThere is a grid of $ R \\ times C $ squares with $ (0, 0) $ in the upper left and $ (R-1, C-1) $ in the lower right. When you are in a square ($ e $, $ f $), from there $ (e + 1, f) $, $ (e-1, f) $, $ (e, f + 1) $, $ (e) , f-1) $, $ (e, 0) $, $ (e, C-1) $, $ (0, f) $, $ (R-1, f) $ can b... | [{"input": "421 435 361 230 182 16", "output": "196 792283366\n"}, {"input": "421 547 377 188 235 13", "output": "156 501147202\n"}, {"input": "421 435 196 169 388 12", "output": "46 766230083\n"}, {"input": "421 435 196 169 388 10", "output": "44 669339083\n"}, {"input": "421 435 320 169 135 9", "output": "146 6610838... | code_stdio |
[
{
"content": "As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server has a name and an ip (names aren't necessarily unique, but ips are). Dustin kno... | [{"input": "10 10\nittmcs 112.147.123.173\njkt 228.40.73.178\nfwckqtz 88.28.31.198\nkal 224.226.34.213\nnacuyokm 49.57.13.44\nfouynv 243.18.250.17\ns 45.248.83.247\ne 75.69.23.169\nauwoqlch 100.44.219.187\nlkldjq 46.123.169.140\ngjcylatwzi 46.123.169.140;\ndxfi 88.28.31.198;\ngv 46.123.169.140;\nety 88.28.31.198;\notbm... | code_stdio |
[
{
"content": "Some number of people (this number is even) have stood in a circle. The people stand in the circle evenly. They are numbered clockwise starting from a person with the number $1$. Each person is looking through the circle's center at the opposite person.\n\nA sample of a circle of $6$ persons. The ... | [{"input": "7\n6 4 4\n2 3 0\n0 4 10\n5 3 4\n1 3 2\n4 5 12\n4 3 2\n", "output": "-1\n-1\n-1\n-1\n4\n-1\n-1\n"}, {"input": "7\n6 2 4\n2 3 0\n2 4 10\n5 3 4\n1 3 2\n2 5 8\n4 3 2\n", "output": "8\n-1\n-1\n-1\n4\n-1\n-1\n"}, {"input": "7\n6 2 4\n2 3 1\n2 4 10\n5 3 4\n1 3 2\n2 5 4\n4 3 2\n", "output": "8\n-1\n-1\n-1\n4\n1\n-1... | code_stdio |
[
{
"content": "R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listening to \"The White Buttons\" and their hit song \"Dacan... | [{"input": "100000000 100000000 100000000\n", "output": "266578227200000000\n"}, {"input": "100000000 100000000 100000000\n", "output": "266578227200000000\n"}, {"input": "100000000 100000010 100000000\n", "output": "266578239852872360\n"}, {"input": "100000000 50000000 100000000\n", "output": "191720992950000000\n"}, ... | code_stdio |
[
{
"content": "You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.\n\nLet's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s... | [{"input": "12\nlylfekzszgqx\noewrpuflwlir\n", "output": "nbqykcppkvzu\n"}, {"input": "12\nlylfekzszgqx\noewrpuflwril\n", "output": "nbqykcppkyzr\n"}, {"input": "12\nlylfekzszgqx\noewrpuflwlir\n", "output": "nbqykcppkvzu"}, {"input": "10\nzzzzzzzzzx\nzzzzzzzzzz\n", "output": "zzzzzzzzzy\n"}, {"input": "10\nzyzzzzzzzx\n... | code_stdio |
[
{
"content": "Let's call an integer array $a_1, a_2, \\dots, a_n$ good if $a_i \\neq i$ for each $i$.\n\nLet $F(a)$ be the number of pairs $(i, j)$ ($1 \\le i < j \\le n$) such that $a_i + a_j = i + j$.\n\nLet's say that an array $a_1, a_2, \\dots, a_n$ is excellent if:\n\n$a$ is good;\n\n$l \\le a_i \\le r$ fo... | [{"input": "10\n20000 -431912570 597469643\n20000 -13928452 414987414\n20000 -472808872 367983694\n20000 -84913058 517394906\n20000 -514402152 597357115\n20000 -720971736 526102810\n20000 -416160739 748291750\n20000 -665939649 743938438\n20000 -80741314 634025883\n20000 -824743396 138091345\n", "output": "248035877\n91... | code_stdio |
[
{
"content": "You are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.\n\nWe define a syllable as a string that contains exactly one vowel and any arbitrary number (possibly none) of consonants. In English alphabet following letters are ... | [{"input": "4\n13 11 15 15\nto be or not to be that is the question\nwhether tis nobler in the mind to suffer\nthe slings and arrows of outrageous fortune\nor to take arms against a sea of troubles\n", "output": "YES\n"}, {"input": "4\n13 11 15 15\nto be or not to be that is the question\nwhether tis nobler in the mind... | code_stdio |
[
{
"content": "You have N apples, called Apple 1, Apple 2, Apple 3, ..., Apple N. The flavor of Apple i is L+i-1, which can be negative.\nYou can make an apple pie using one or more of the apples. The flavor of the apple pie will be the sum of the flavors of the apples used.\nYou planned to make an apple pie usi... | [{"input": "100 -100\n", "output": "-5049\n"}, {"input": "100 100\n", "output": "14850\n"}, {"input": "30 -50\n", "output": "-1044\n"}, {"input": "82 -82\n", "output": "-3402\n"}, {"input": "65 -64\n", "output": "-2080\n"}, {"input": "18 -124", "output": "-1972\n"}, {"input": "33 -124", "output": "-3472\n"}, {"input": ... | code_stdio |
[
{
"content": "Pasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits.\n\nAlso Pasha has a number k and two sequences of length n / k (n is divisible by k) a_1, a_2, ..., a_{n} / k and b_1, b_2, ..., b_{n} / k. Let's split ... | [{"input": "100 1\n5 3 1 5 6 2 4 8 3 3 1 1 2 8 2 3 8 2 5 2 6 2 3 5 2 1 2 1 2 8 4 3 3 5 1 4 2 2 2 5 8 2 2 6 2 9 3 4 1 8 1 5 5 6 6 2 2 7 3 3 4 2 4 1 2 6 6 4 9 4 3 2 3 8 2 3 1 4 1 4 1 3 5 3 5 5 2 3 4 1 1 8 1 5 6 9 4 2 5 1\n6 0 4 5 3 1 0 7 5 3 5 4 5 4 0 2 1 6 2 2 4 3 1 9 5 9 2 2 6 8 6 5 9 6 4 9 9 7 5 4 5 6 0 3 2 0 8 0 3 9 ... | code_stdio |
[
{
"content": "In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.\n\nIntegers M_1, D_1, M_2, and D_2 will be given as input.\nIt is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.\nDetermine whether the date 2019-M_1-D_1 is the last day of a month.\n\nConstraints... | [{"input": "11 17\n11 122", "output": "0\n"}, {"input": "11 11\n11 101", "output": "0\n"}, {"input": "11 17\n11 17", "output": "0\n"}, {"input": "11 16\n11 28", "output": "0\n"}, {"input": "11 24\n11 28", "output": "0\n"}, {"input": "11 16\n11 31", "output": "0\n"}, {"input": "11 16\n11 46", "output": "0\n"}, {"input":... | code_stdio |
[
{
"content": "There are $n$ students standing in a circle in some order. The index of the $i$-th student is $p_i$. It is guaranteed that all indices of students are distinct integers from $1$ to $n$ (i. e. they form a permutation).\n\nStudents want to start a round dance. A clockwise round dance can be started ... | [{"input": "5\n4\n1 2 3 4\n3\n1 3 2\n5\n1 2 3 5 4\n1\n1\n5\n3 2 1 5 4\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"input": "5\n4\n1 2 3 4\n3\n1 3 2\n5\n1 2 3 5 4\n1\n1\n5\n3 2 1 5 4\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"input": "1\n12\n12 2 14 5 6 15 4 12 20 21 1 2\n", "output": "NO\n"}, {"input": "1\n12\n12 2 1... | code_stdio |
[
{
"content": "Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion: An 'L' indicates he should move one unit left. An 'R' indicates he should move one unit right. A 'U' indicates he should move one unit up. A 'D' indicates he ... | [{"input": "RDDLLDLUUUDDRDRURLUUURLLDDLRLUURRLLRRLDRLLUDRLRULLDLRRLRLRLRUDUUDLULURLLDUURULURLLRRRURRRDRUUDLDRLRDRLRRDDLDLDLLUDRUDRLLLLDRDUULRUURRDLULLULDUDULRURRDDDLLUDRLUDDLDDDRRDDDULLLLDLDRLRRLRRDDRLULURRUDRDUUUULDURUDRDLDDUDUDRRURDULRRUDRLRRDLUURURDLDRLRDUDDDLDDDURURLUULRDUUULRURUDUDRRUDULLLUUUDRLLDRRDDLRUDRDRDLLRUR... | code_stdio |
[
{
"content": "Igor has fallen in love with Tanya. Now Igor wants to show his feelings and write a number on the fence opposite to Tanya's house. Igor thinks that the larger the number is, the more chance to win Tanya's heart he has. \n\nUnfortunately, Igor could only get v liters of paint. He did the math and c... | [{"input": "62800\n867 936 2 888 474 530 287 1101 220\n", "output": "33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333... | code_stdio |
[
{
"content": "I have a lot of friends. Every friend is very small.\nI often go out with my friends. Put some friends in your backpack and go out together.\nEvery morning I decide which friends to go out with that day. Put friends one by one in an empty backpack.\nI'm not very strong. Therefore, there is a limit... | [{"input": "6 50\n10\n30\n13\n18\n12\n16", "output": "15\n"}, {"input": "6 37\n6\n16\n13\n18\n12\n16", "output": "10\n"}, {"input": "6 50\n6\n16\n13\n18\n12\n16", "output": "12\n"}, {"input": "6 37\n5\n16\n13\n18\n26\n33", "output": "5\n"}, {"input": "6 37\n6\n16\n13\n18\n26\n16", "output": "7\n"}, {"input": "6 50\n6\n... | code_stdio |
[
{
"content": "A basketball competition is held where the number of players in a team does not have a maximum or minimum limit (not necessarily $5$ players in one team for each match). There are $N$ candidate players in the competition that will be trained by Pak Chanek, the best basketball coach on earth. The $... | [{"input": "8 1000\n13 14 15 15 15 15 15 16\n", "output": "0\n"}, {"input": "8 155\n13 13 11 16 18 16 19 16\n", "output": "0\n"}, {"input": "8 300\n13 14 15 15 15 15 15 16\n", "output": "0\n"}, {"input": "8 12\n13 14 15 15 15 15 15 16\n", "output": "8\n"}, {"input": "8 12\n12 12 10 14 12 11 15 11\n", "output": "5\n"}, ... | code_stdio |
[
{
"content": "Chef wrote some text on a piece of paper and now he wants to know how many holes are in the text. What is a hole? If you think of the paper as the plane and a letter as a curve on the plane, then each letter divides the plane into regions. For example letters \"A\", \"D\", \"O\", \"P\", \"R\" divi... | [{"input": "2\nFEHCEDOC\nDRINKEATCODE", "output": "2\n5\n"}, {"input": "2\nFEHCEEOC\nDRINKEATCODE", "output": "1\n5\n"}, {"input": "2\nCOEECHFE\nDRJNKEATBODE", "output": "1\n7\n"}, {"input": "2\nEFJEFCOB\nDRJNKEAUBODE", "output": "3\n7\n"}, {"input": "2\nEJDEFCOB\nDQJNKEATBODE", "output": "4\n7\n"}, {"input": "2\nEJDEF... | code_stdio |
[
{
"content": "The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her n students and give each of them a jigsaw puzzle (which, as wikipedia states, is a tiling puzzle that requires the assembly of nume... | [{"input": "50 50\n374 573 323 744 190 806 485 247 628 336 491 606 702 321 991 678 337 579 86 240 993 208 668 686 855 205 363 177 719 249 896 919 782 434 59 647 787 996 286 216 636 212 546 903 958 559 544 126 608 993\n", "output": "937\n"}, {"input": "50 50\n374 573 323 744 190 806 485 247 628 336 491 606 702 321 991 6... | code_stdio |
[
{
"content": "In the year 2xxx, an expedition team landing on a planet found strange objects made by an ancient species living on that planet. They are transparent boxes containing opaque solid spheres (Figure 1). There are also many lithographs which seem to contain positions and radiuses of spheres.\n\n<image... | [{"input": "3\n95 20 180 18\n125 20 185 18\n40 26 195 10\n1\n6 5 5 4\n2\n5 5 5 4\n5 10 5 2\n2\n5 5 11 6\n0 7 5 3\n16\n2338 3465 29034 1351\n1571 14389 25019 842\n1706 8015 21355 1155\n1899 4359 33815 888\n2160 10364 20511 2353\n333 8835 6587 63\n2598 3176 23679 618\n1613 14217 8003 1505\n3140 4754 25986 929\n2707 9945 ... | code_stdio |
[
{
"content": "There are a lot of things which could be cut — trees, paper, \"the rope\". In this problem you are going to cut a sequence of integers.\n\nThere is a sequence of integers, which contains the equal number of even and odd numbers. Given a limited budget, you need to make maximum possible number of c... | [{"input": "100 30\n100 99 100 99 99 100 100 99 100 99 99 100 100 100 99 99 99 100 99 99 99 99 100 99 99 100 100 99 100 99 99 99 100 99 100 100 99 100 100 100 100 100 99 99 100 99 99 100 99 100 99 99 100 100 99 100 99 99 100 99 100 100 100 100 99 99 99 100 99 100 99 100 100 100 99 100 100 100 99 100 99 99 100 100 100 1... | code_stdio |
[
{
"content": "Are you going to Scarborough Fair?\n\nParsley, sage, rosemary and thyme.\n\nRemember me to one who lives there.\n\nHe once was the true love of mine.\n\nWillem is taking the girl to the highest building in island No.28, however, neither of them knows how to get there.\n\nWillem asks his friend, Gr... | [{"input": "67 39\nacbcbccccbabaabcabcaaaaaaccbcbbcbaaaacbbcccbcbabbcacccbbabbabbabaac\n4 36 a b\n25 38 a a\n3 44 b c\n35 57 b a\n4 8 a c\n20 67 c a\n30 66 b b\n27 40 a a\n2 56 a b\n10 47 c a\n22 65 c b\n29 42 a b\n1 46 c b\n57 64 b c\n20 29 b a\n14 51 c a\n12 55 b b\n20 20 a c\n2 57 c a\n22 60 c b\n16 51 c c\n31 64 a ... | code_stdio |
[
{
"content": "You will be given an integer a and a string s consisting of lowercase English letters as input.\nWrite a program that prints s if a is not less than 3200 and prints red if a is less than 3200.\n\n-----Constraints-----\n - 2800 \\leq a < 5000\n - s is a string of length between 1 and 10 (inclusive)... | [{"input": "4999\nzzzzzzzzzz\n", "output": "zzzzzzzzzz\n"}, {"input": "4998\nrainbow\n", "output": "rainbow\n"}, {"input": "3201\npurple\n", "output": "purple\n"}, {"input": "3200\npink\n", "output": "pink\n"}, {"input": "2999\nwhite\n", "output": "red\n"}, {"input": "3199\npink\n", "output": "red\n"}, {"input": "3200\... | code_stdio |
[
{
"content": "The secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator, you have decided to determine the number of people in your target who meet at least one of the followi... | [{"input": "100\n3 -1 100 3\n-1\n2 4 3", "output": "1\n"}, {"input": "100\n3 0 001 4\n-2\n2 10 3", "output": "2\n"}, {"input": "100\n3 0 001 4\n-3\n2 10 3", "output": "2\n"}, {"input": "100\n3 -1 100 3\n-1\n2 6 3", "output": "1\n"}, {"input": "100\n3 -1 100 3\n-1\n2 3 3", "output": "0\n"}, {"input": "100\n3 -1 000 4\n-... | code_stdio |
[
{
"content": "Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\n* add(i, x): add x to ai.\n* getSum(s, t): print the sum of as, as+1,...,at.\n\n\n\nNote that the initial values of ai (i = 1, 2, . . . , n) are 0.\n\nConstraints\n\n* 1 ≤ n ≤ 100000\n* 1 ≤ q ≤ ... | [{"input": "4 5\n0 1 1\n0 2 10\n1 2 3\n1 1 2\n1 1 3", "output": "10\n11\n11\n"}, {"input": "4 5\n1 1 1\n1 4 3\n0 3 3\n1 1 2\n1 2 3", "output": "0\n0\n0\n3\n"}, {"input": "4 5\n0 1 1\n1 2 3\n1 2 3\n1 1 2\n1 2 2", "output": "0\n0\n1\n0\n"}, {"input": "4 5\n0 1 0\n1 2 2\n1 1 2\n1 1 0\n1 4 2", "output": "0\n0\n0\n0\n"}, {"... | code_stdio |
[
{
"content": "There is a square field of size $n \\times n$ in which two cells are marked. These cells can be in the same row or column.\n\nYou are to mark two more cells so that they are the corners of a rectangle with sides parallel to the coordinate axes.\n\nFor example, if $n=4$ and a rectangular field look... | [{"input": "6\n4\n..*.\n....\n*...\n....\n2\n*.\n.*\n2\n.*\n.*\n3\n*.*\n...\n...\n5\n.....\n..*..\n.....\n.*...\n.....\n4\n....\n....\n*...\n*...\n", "output": "\n*.*.\n....\n*.*.\n....\n**\n**\n**\n**\n*.*\n*.*\n...\n.....\n.**..\n.....\n.**..\n.....\n....\n....\n**..\n**..\n"}, {"input": "6\n4\n..*.\n....\n*...\n....... | code_stdio |
[
{
"content": "It is known that fleas in Berland can jump only vertically and horizontally, and the length of the jump is always equal to s centimeters. A flea has found herself at the center of some cell of the checked board of the size n × m centimeters (each cell is 1 × 1 centimeters). She can jump as she wis... | [{"input": "402841 635488 1119470\n", "output": "256000621408\n"}, {"input": "303307 400683 1450639\n", "output": "121529958681\n"}, {"input": "458717 400683 1450639\n", "output": "183800103711\n"}, {"input": "458717 255447 1450639\n", "output": "117177881499\n"}, {"input": "726292 261665 1483264\n", "output": "1900451... | code_stdio |
[
{
"content": "The numbers of all offices in the new building of the Tax Office of IT City will have lucky numbers.\n\nLucky number is a number that consists of digits 7 and 8 only. Find the maximum number of offices in the new building of the Tax Office given that a door-plate can hold a number not longer than ... | [{"input": "55\n", "output": "72057594037927934\n"}, {"input": "54\n", "output": "36028797018963966\n"}, {"input": "54\n", "output": "36028797018963966"}, {"input": "55\n", "output": "72057594037927934"}, {"input": "49\n", "output": "1125899906842622\n"}, {"input": "49\n", "output": "1125899906842622"}, {"input": "43\n... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.