messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "A string is called square if it is some string written twice in a row. For example, the strings \"aa\", \"abcabc\", \"abab\" and \"baabaa\" are square. But the strings \"aaa\", \"abaaab\" and \"abcdabc\" are not square.\n\nFor a given string $s$ determine if it is square.\n\n\n-----Input-----\n\nT... | [{"input": "10\na\naa\naaa\naaaa\nabab\nabcabc\nabacaba\nxxyy\nxyyx\nxyxy\n", "output": "NO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\n"}, {"input": "10\na\naa\naaa\naaaa\nabab\nabcabc\nabacaba\nyxxy\nxyyx\nxyxy\n", "output": "NO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\n"}, {"input": "10\nb\naa\naaa\naaaa\nabab\nabcabc... | code_stdio |
[
{
"content": "You have to write two methods to *encrypt* and *decrypt* strings.\nBoth methods have two parameters:\n```\n1. The string to encrypt/decrypt\n2. The Qwerty-Encryption-Key (000-999) \n```\n\nThe rules are very easy:\n```\nThe crypting-regions are these 3 lines from your keyboard:\n1. \"qwertyuiop\"\... | [{"input": "\"Do the kata Kobayashi Maru Test. Endless fun and excitement when finding a solution.\"\n583", "output": "[\"Sr pgi jlpl Jr,lqlage Zlow Piapc I.skiaa dw. l.s ibnepizi.p ugi. de.se.f l arkwper.c\"]", "fn_name": "encrypt"}, {"input": "\"This is a test.\"\n348", "output": "[\"Iaqh qh g iyhi,\"]", "fn_name": "... | code_functional |
[
{
"content": "Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wants his coins to be arranged in a row in such a way that firstly come coins out of... | [{"input": "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 50 4 80 72 39\n", "output... | code_stdio |
[
{
"content": "A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.\n\nOleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money from the safes. There are many safes arranged in a line,... | [{"input": "8 3 13\n12\n3 3 3 12 7 6 10 1 8 8 7 12\n", "output": "8\n"}, {"input": "8 3 13\n12\n3 3 3 8 7 6 10 1 8 8 7 12\n", "output": "8\n"}, {"input": "8 5 13\n12\n3 3 3 8 7 6 10 1 7 8 7 11\n", "output": "8\n"}, {"input": "8 5 13\n12\n3 3 3 8 7 0 10 1 7 8 7 11\n", "output": "7\n"}, {"input": "6 3 13\n12\n3 3 3 5 7 6... | code_stdio |
[
{
"content": "Sheldon Cooper, Leonard Hofstadter and Penny decide to go for drinks at Cheese cake factory. Sheldon proposes to make a game out of this. Sheldon proposes as follows, \nTo decide the amount of beverage they plan to consume, say X.\n\nThen order for a random number of different drinks, say {A, B, C... | [{"input": "8\n4 8 9 7 45 6 3 27\n156", "output": "False"}, {"input": "8\n4 8 9 7 45 6 3 27\n56", "output": "True"}, {"input": "6\n45 55 5 7 23 4\n107", "output": "True"}, {"input": "7\n2 5 4 9 7 33 6\n44", "output": "True"}, {"input": "4\n55 45 2 23\n58", "output": "False"}, {"input": "4\n4 3 25 5\n33", "output": "Tru... | code_stdio |
[
{
"content": "Monocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts $100^{500}$ seconds, during which Monocarp attacks the dragon with a poisoned dagger. The $i$-th attack is performed at the beginning of the $a_i$-th second from the ba... | [{"input": "4\n2 13\n1 5\n3 11\n1 4 20\n5 3\n1 2 4 8 7\n4 1000\n5 25 95 1337\n", "output": "9\n4\n1\n455\n"}, {"input": "4\n2 1\n1 5\n3 10\n2 4 10\n5 3\n1 2 4 5 7\n4 1000\n3 25 124 1337\n", "output": "1\n4\n1\n440\n"}, {"input": "4\n2 5\n1 5\n3 10\n2 4 10\n5 3\n1 2 4 5 7\n4 1000\n3 25 64 1337\n", "output": "3\n4\n1\n47... | code_stdio |
[
{
"content": "Champernown constant is an irrational number represented in decimal by \"0.\" followed by concatenation of all positive integers in the increasing order. The first few digits of this constant are: 0.123456789101112...\n\nYour task is to write a program that outputs the K digits of Chapnernown cons... | [{"input": "11 17\n11 14\n0 0", "output": "01112131415161718\n01112131415161\n"}, {"input": "4 7\n2 26\n0 0", "output": "4567891\n23456789101112131415161718\n"}, {"input": "2 5\n1 26\n0 0", "output": "23456\n12345678910111213141516171\n"}, {"input": "9 15\n11 14\n0 0", "output": "910111213141516\n01112131415161\n"}, {"... | code_stdio |
[
{
"content": "Your back at your newly acquired decrypting job for the secret organization when a new assignment comes in. Apparently the enemy has been communicating using a device they call \"The Mirror\". \nIt is a rudimentary device with encrypts the message by switching its letter with its mirror opposit... | [{"input": "\"this is a secret\"\n\" *\"", "output": "[\"this*is*a*secret\"]", "fn_name": "mirror"}, {"input": "\"gsrh rh z hvxivg\"", "output": "[\"this is a secret\"]", "fn_name": "mirror"}, {"input": "\"Welcome home\"\n\"w\"", "output": "[\"welcome home\"]", "fn_name": "mirror"}, {"input": "\"Welcome home\"", "outpu... | code_functional |
[
{
"content": "Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 Γ n table).\n\nAt the beginning of the game Alice puts k ships on the field without telling their positions to Bob. Each ship looks as a 1 Γ a rectang... | [{"input": "50 7 3\n50\n17 47 1 12 21 25 6 5 49 27 34 8 16 38 11 44 48 9 2 20 3 22 33 23 36 41 15 35 31 30 50 7 45 42 37 29 14 26 24 46 19 4 10 28 18 43 32 39 40 13\n", "output": "19\n"}, {"input": "50 1 1\n50\n1 13 21 37 30 48 23 19 6 49 36 14 9 24 44 10 41 28 20 2 15 11 45 3 25 33 50 38 35 47 31 4 12 46 32 8 42 26 5 ... | code_stdio |
[
{
"content": "Look for the Winner!\n\nThe citizens of TKB City are famous for their deep love in elections and vote counting. Today they hold an election for the next chairperson of the electoral commission. Now the voting has just been closed and the counting is going to start. The TKB citizens have strong des... | [{"input": "1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nB A A B A C A C C B\n10\nV U U U U W V W V W\n0", "output": "A 1\nTIE\nTIE\nK 4\nX 5\nA 10\nU 10\n"}, {"input": "1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nB A A B A C A C C B\n10\nV T U U U W W W V W\n0", "output":... | code_stdio |
[
{
"content": "The whole world got obsessed with robots,and to keep pace with the progress, great Berland's programmer Draude decided to build his own robot. He was working hard at the robot. He taught it to walk the shortest path from one point to another, to record all its movements, but like in many Draude's ... | [{"input": "RLRRRRRDRRDRRRRDLRRRRRRRDLRLDDLRRRRLDLDRDRRRRDRDRDRDLRRURRLRRRRDRRRRRRRRLDDRLRRDRRRRRRRDRDRLDRDDDRDR\n", "output": "BUG\n"}, {"input": "DDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLLRRRRRRRRRRRRRRRRRRRRRRRRRRRUUUUUUUUUUUUUUUUUUUUUUUU\n", "output": "BUG\n"}, {"input": "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU... | code_stdio |
[
{
"content": "There is a bookshelf which can fit $n$ books. The $i$-th position of bookshelf is $a_i = 1$ if there is a book on this position and $a_i = 0$ otherwise. It is guaranteed that there is at least one book on the bookshelf.\n\nIn one move, you can choose some contiguous segment $[l; r]$ consisting of ... | [{"input": "5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1\n", "output": "2\n0\n2\n4\n1\n"}, {"input": "5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 1 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1\n", "output": "2\n0\n1\n4\n1\n"}, {"input": "5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 0 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 ... | code_stdio |
[
{
"content": "Polycarp took $n$ videos, the duration of the $i$-th video is $a_i$ seconds. The videos are listed in the chronological order, i.e. the $1$-st video is the earliest, the $2$-nd video is the next, ..., the $n$-th video is the last.\n\nNow Polycarp wants to publish exactly $k$ ($1 \\le k \\le n$) po... | [{"input": "6 3\n3 3 1 4 1 6\n", "output": "Yes\n2 3 1 \n"}, {"input": "6 3\n3 3 1 4 1 6\n", "output": "Yes\n2 3 1 "}, {"input": "3 3\n1 1 1\n", "output": "Yes\n1 1 1 \n"}, {"input": "3 3\n1 1 1\n", "output": "Yes\n1 1 1 "}, {"input": "3 1\n1 10 100\n", "output": "Yes\n3 \n"}, {"input": "3 1\n1 10 100\n", "output": "Ye... | code_stdio |
[
{
"content": "Vasya writes his own library for building graphical user interface. Vasya called his creation VTK (VasyaToolKit). One of the interesting aspects of this library is that widgets are packed in each other. \n\nA widget is some element of graphical interface. Each widget has width and height, and occu... | [{"input": "20\nVBox hykl\nVBox enwv\nenwv.pack(hykl)\nVBox dlepf\ndlepf.pack(hykl)\nenwv.set_border(30)\nWidget mjrrik(54,21)\nhykl.set_border(2)\ndlepf.set_border(22)\nenwv.set_border(3)\nenwv.pack(dlepf)\ndlepf.pack(mjrrik)\nhykl.set_spacing(96)\nenwv.set_border(32)\ndlepf.set_border(72)\nWidget j(54,86)\nhykl.pack(... | code_stdio |
[
{
"content": "Akari has n kinds of flowers, one of each kind.\nShe is going to choose one or more of these flowers to make a bouquet.\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\nHow many different bouquets are there that Akari can make?\nFind the count mod... | [{"input": "1000000000 199999 200000\n", "output": "382492393\n"}, {"input": "1000000000 141421 173205\n", "output": "34076506\n"}, {"input": "750063539 163676 194328\n", "output": "801789004\n"}, {"input": "686442509 103497 190629\n", "output": "506071717\n"}, {"input": "699889611 31932 135902\n", "output": "784137353... | code_stdio |
[
{
"content": "Well, the series which Stepan watched for a very long time, ended. In total, the series had n episodes. For each of them, Stepan remembers either that he definitely has watched it, or that he definitely hasn't watched it, or he is unsure, has he watched this episode or not. \n\nStepan's dissatisfa... | [{"input": "100 100\n????????????????????????????????????????????????????????????????????????????????????????????????????\n", "output": "YES\n"}, {"input": "100 100\n????????????????????????????????????????????????????????????????????????????????????????????????????\n", "output": "YES\n"}, {"input": "100 000\n?????????... | code_stdio |
[
{
"content": "Let $LCM(x, y)$ be the minimum positive integer that is divisible by both $x$ and $y$. For example, $LCM(13, 37) = 481$, $LCM(9, 6) = 18$.\n\nYou are given two integers $l$ and $r$. Find two integers $x$ and $y$ such that $l \\le x < y \\le r$ and $l \\le LCM(x, y) \\le r$.\n\n\n-----Input-----\n\... | [{"input": "69\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nYou are given an array A of N integers. You are to fulfill M queries. Each query has one of the following three types:\n\nC d : Rotate the array A clockwise by d units.\nA d : Rotate the array A anticlockwise by d units.\nR d : Query f... | [{"input": "5 3\n0 13 10 -1 -2\nR -1\nC 1\nR 4\n@ 1\nS 2", "output": "-1\n-2\n"}, {"input": "5 3\n0 13 10 -1 -2\nR -2\nC 1\nR 4\n@ 1\nS 2", "output": "10\n-2\n"}, {"input": "5 3\n0 13 10 -1 -2\nR 0\nC 1\nR 4\n@ 1\nS 2", "output": "-2\n-2\n"}, {"input": "5 3\n0 13 10 -1 -2\nR 0\nC 1\nR 1\n@ 2\nT 2", "output": "-2\n13\n"... | code_stdio |
[
{
"content": "Calculate the product of all elements in an array.\n```if:csharp\nIf the array is *null*, you should throw `ArgumentNullException` and if the array is empty, you should throw `InvalidOperationException`.\n\nAs a challenge, try writing your method in just one line of code. It's possible to have onl... | [{"input": "[5, 4, 1, 3, 9]", "output": "[540]", "fn_name": "product"}, {"input": "[-2, 6, 7, 8]", "output": "[-672]", "fn_name": "product"}, {"input": "[0, 2, 9, 7]", "output": "[0]", "fn_name": "product"}, {"input": "null", "output": "[null]", "fn_name": "product"}, {"input": "[10]", "output": "[10]", "fn_name": "pro... | code_functional |
[
{
"content": "Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.\n\nThe camera's memory is d megabytes. Valera's camera can t... | [{"input": "50 50\n6 10\n10 0\n1 9\n8 2\n4 9\n0 7\n2 0\n7 5\n4 8\n13 7\n2 4\n5 6\n6 8\n3 2\n4 6\n7 8\n6 9\n7 7\n7 3\n9 5\n3 10\n7 2\n4 3\n2 0\n6 5\n5 3\n1 7\n1 7\n9 1\n10 4\n10 5\n4 2\n10 10\n0 7\n1 2\n10 1\n1 7\n3 7\n8 7\n5 2\n6 1\n3 1\n4 7\n7 10\n1 5\n10 8\n5 5\n5 1\n3 3\n1 6\n2 1\n", "output": "3\n6 23 50 \n"}, {"in... | code_stdio |
[
{
"content": "Take an integer `n (n >= 0)` and a digit `d (0 <= d <= 9)` as an integer. Square all numbers `k (0 <= k <= n)` between 0 and n. Count the numbers of \ndigits `d` used in the writing of all the `k**2`. Call `nb_dig` (or nbDig or ...) the function taking `n` and `d` as parameters and returning this ... | [{"input": "11549\n1", "output": "[11905]", "fn_name": "nb_dig"}, {"input": "12526\n1", "output": "[13558]", "fn_name": "nb_dig"}, {"input": "14956\n1", "output": "[17267]", "fn_name": "nb_dig"}, {"input": "11011\n2", "output": "[9481]", "fn_name": "nb_dig"}, {"input": "12224\n8", "output": "[7733]", "fn_name": "nb_dig... | code_functional |
[
{
"content": "Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an ... | [{"input": "1000 1000 999\n", "output": "756641425\n"}, {"input": "1000 501 501\n", "output": "646597996\n"}, {"input": "1000 888 888\n", "output": "644649893\n"}, {"input": "1000 500 500\n", "output": "646597996\n"}, {"input": "1000 1000 999\n", "output": "756641425"}, {"input": "1000 501 347\n", "output": "385628187\... | code_stdio |
[
{
"content": "Ken loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one... | [{"input": "6 8\n1 2\n2 1\n3 4\n4 11\n5 0\n1 5\n1 5\n4 6\n1 4", "output": "-1\n"}, {"input": "6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n", "output": "2\n"}, {"input": "6 8\n1 4\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 1\n1 6", "output": "-1\n"}, {"input": "6 8\n1 2\n2 1\n3 4\n4 6\n5 0\n1 5\n1 5\n4 6\n1 4", "output": "-... | code_stdio |
[
{
"content": "Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to grow a tree from them.\n\nThe tree looks like a polyline on... | [{"input": "11\n9969 9945 12703 11114 8159 10000 9928 9985 6747 9181 9933\n", "output": "5991155360\n"}, {"input": "11\n9969 9945 12703 9914 8159 10000 9928 9985 6747 9939 9933\n", "output": "5907768442\n"}, {"input": "11\n9969 9945 12703 9914 8159 10000 9928 9985 6747 9181 9933\n", "output": "5840383266\n"}, {"input":... | code_stdio |
[
{
"content": "Each month Blake gets the report containing main economic indicators of the company \"Blake Technologies\". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes corresponding revenue. Before the report gets to Blake, it pa... | [{"input": "100 30\n65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 74 57 115 16 55 102 79 97 21 80 41 56 49 103 61 66 1 36 44 43 82 37 38 106 27 114 51 112 55 87 41 69 31 86 58 27 46 99 18 105 91 38 5 9 2 109 39 2 27 ... | code_stdio |
[
{
"content": "<image>\n\nThe International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business.\n\nOne of the unique features of this contest is the great number of judges that sometimes counts up to one hundred. The number of jud... | [{"input": "3\n1000\n342\n-1\n5\n-1\n2\n18\n11\n932\n5\n420\n1100\n0\n200\n685\n8\n353\n143\n402\n274\n283\n31\n402\n523\n0", "output": "342\n10\n435\n309\n"}, {"input": "3\n1000\n342\n0\n5\n2\n2\n11\n11\n932\n5\n148\n1000\n0\n200\n400\n8\n353\n242\n1097\n274\n283\n107\n402\n523\n0", "output": "342\n8\n249\n346\n"}, {"... | code_stdio |
[
{
"content": "You have integer $n$. Calculate how many ways are there to fully cover belt-like area of $4n-2$ triangles with diamond shapes. \n\nDiamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. \n\n$2$ coverings are different if some $2$ triangles are cov... | [{"input": "1\n1000000000\n", "output": "1000000000\n"}, {"input": "1\n1000000000\n", "output": "1000000000\n"}, {"input": "1\n1111011001\n", "output": "1111011001\n"}, {"input": "1\n1011011001\n", "output": "1011011001\n"}, {"input": "1\n1011001001\n", "output": "1011001001\n"}, {"input": "1\n1011001101\n", "output": ... | code_stdio |
[
{
"content": "You are given string s consists of opening and closing brackets of four kinds <>, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace < by the bracket {, but you can't replace it by ) or >.\n\nThe f... | [{"input": "))>)}}>>]}]{{}{({)>{(((}>>))<[})}{}(){}}}]>><){<{<><{[[]{<(<{{])(({[<}({)[}>>([>>(>]>[{]{}<<)()]})])}([>]{}(>{(<([([<(\n", "output": "Impossible\n"}, {"input": "))>)}}>>]}]{{}{({)>{(((}>>))<[})}{}(){}}}]>><){;{<><{[[]{<(<{{])(({[<}({)[}>>([>>(>]>[{]{}<<)()]})])}([>]{}(>{(<([([<(\n", "output": "Impossible\n"... | code_stdio |
[
{
"content": "It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has g_{i} Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special e... | [{"input": "100 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 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 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 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1... | code_stdio |
[
{
"content": "We will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\nGiven are N strings s... | [{"input": "1000\ninqmubaqoc\ndxdglvihpa\npnagqofdzf\ndxegqbbhza\nlxwdrvmekl\nwccdceedww\ncedcwwwced\nkmemzhaioi\nrnkmsbaaei\nccddwwwcee\nqghqrvbxgg\ncgavbvslgb\nwcwswceded\nwecwwdcced\nypecevpoyy\nlxwdbvmqkl\nwobwicidod\nedwccewdwc\nrragafedvf\nyvnbozkgqy\nlxddbvmqkl\nrpwaqejdgf\nrnkwqewjni\ndwcecdwcwe\nwdcwwcedce\nrn... | code_stdio |
[
{
"content": "You stumbled upon a new kind of chess puzzles. The chessboard you are given is not necesserily $8 \\times 8$, but it still is $N \\times N$. Each square has some number written on it, all the numbers are from $1$ to $N^2$ and all the numbers are pairwise distinct. The $j$-th square in the $i$-th r... | [{"input": "10\n16 92 81 8 70 28 72 91 87 13\n32 17 93 83 5 69 27 74 89 88\n43 31 22 99 79 4 65 26 71 90\n50 41 29 15 98 80 9 68 24 73\n59 51 38 35 18 96 82 6 67 25\n57 60 49 45 37 19 97 85 7 66\n76 53 61 46 40 36 14 95 86 3\n11 75 55 58 48 44 34 20 94 84\n2 10 77 56 62 52 39 30 23 100\n64 1 12 78 54 63 47 42 33 21\n",... | code_stdio |
[
{
"content": "Write a function which reduces fractions to their simplest form! Fractions will be presented as an array/tuple (depending on the language), and the reduced fraction must be returned as an array/tuple:\n\n```\ninput: [numerator, denominator]\noutput: [newNumerator, newDenominator]\nexample: [45,... | [{"input": "[10956590, 13611876]", "output": "[[30605, 38022]]", "fn_name": "reduce_fraction"}, {"input": "[24622321, 24473455]", "output": "[[42673, 42415]]", "fn_name": "reduce_fraction"}, {"input": "[35884747, 5576447]", "output": "[[76841, 11941]]", "fn_name": "reduce_fraction"}, {"input": "[4255316, 11425973]", "o... | code_functional |
[
{
"content": "One way to create a task is to learn from life. You can choose some experience in real life, formalize it and then you will get a new task.\n\nLet's think about a scene in real life: there are lots of people waiting in front of the elevator, each person wants to go to a certain floor. We can forma... | [{"input": "100 1\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 1... | code_stdio |
[
{
"content": "A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.\n\nGiven an array $a$ of length $n$, consisting only of the numbers $0$ and $1$, and the number $k$. Exactly $k$ times the follow... | [{"input": "100 1000000000\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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "216163471\n"}, {"input": "100 1000000000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0... | code_stdio |
[
{
"content": "Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers.\n\nHe has created a method to know how strong his army is. Let the... | [{"input": "4\n7 12 15 5\n", "output": "55\n"}, {"input": "4\n5 12 4 6\n", "output": "57\n"}, {"input": "4\n5 12 5 6\n", "output": "50\n"}, {"input": "4\n7 6 15 5\n", "output": "49\n"}, {"input": "4\n7 12 1 6\n", "output": "37\n"}, {"input": "4\n5 12 1 6\n", "output": "35\n"}, {"input": "4\n4 6 12 5\n", "output": "57\n... | code_stdio |
[
{
"content": "Constraints\n\n* 1 β€ |V| β€ 100\n* 0 β€ |E| β€ 9900\n* -2 Γ 107 β€ di β€ 2 Γ 107\n* There are no parallel edges\n* There are no self-loops\n\nInput\n\nAn edge-weighted graph G (V, E).\n\n\n|V| |E|\ns0 t0 d0\ns1 t1 d1\n:\ns|E|-1 t|E|-1 d|E|-1\n\n\n|V| is the number of vertices and |E| is the number of e... | [{"input": "15 6\n1 2 2\n1 3 -5\n1 2 3\n1 11 4\n2 0 1\n3 2 12", "output": "0 INF INF INF INF INF INF INF INF INF INF INF INF INF INF\n4 0 3 -5 INF INF INF INF INF INF INF 4 INF INF INF\n1 INF 0 INF INF INF INF INF INF INF INF INF INF INF INF\n13 INF 12 0 INF INF INF INF INF INF INF INF INF INF INF\nINF INF INF INF 0 IN... | code_stdio |
[
{
"content": "There is an infinite 2-dimensional grid. The robot stands in cell $(0, 0)$ and wants to reach cell $(x, y)$. Here is a list of possible commands the robot can execute:\n\nmove north from cell $(i, j)$ to $(i, j + 1)$;\n\nmove east from cell $(i, j)$ to $(i + 1, j)$;\n\nmove south from cell $(i, j)... | [{"input": "100\n0 0\n0 1\n1 0\n1 1\n0 2\n1 2\n2 0\n2 1\n2 2\n0 3\n1 3\n2 3\n3 0\n3 1\n3 2\n3 3\n0 4\n1 4\n2 4\n3 4\n4 0\n4 1\n4 2\n4 3\n4 4\n0 5\n1 5\n2 5\n3 5\n4 5\n5 0\n5 1\n5 2\n5 3\n5 4\n5 5\n0 6\n1 6\n2 6\n3 6\n4 6\n5 6\n6 0\n6 1\n6 2\n6 3\n6 4\n6 5\n6 6\n0 7\n1 7\n2 7\n3 7\n4 7\n5 7\n6 7\n7 0\n7 1\n7 2\n7 3\n7 4... | code_stdio |
[
{
"content": "There is a rooted tree (see Notes) with N vertices numbered 1 to N. Each of the vertices, except the root, has a directed edge coming from its parent. Note that the root may not be Vertex 1.\n\nTakahashi has added M new directed edges to this graph. Each of these M edges, u \\rightarrow v, extends... | [{"input": "6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n3 6\n6 5", "output": "6\n4\n2\n0\n6\n3\n"}, {"input": "6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n3 6\n4 5", "output": "6\n4\n2\n0\n4\n3\n"}, {"input": "6 3\n3 1\n4 3\n4 1\n4 2\n6 1\n4 6\n3 6\n4 5", "output": "6\n4\n4\n0\n4\n3\n"}, {"input": "6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n3 6... | code_stdio |
[
{
"content": "$n$ heroes fight against each other in the Arena. Initially, the $i$-th hero has level $a_i$.\n\nEach minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it is the same two heroes that were fighting during the last minute).\n\nWhen t... | [{"input": "2\n8\n1 9 1 9 8 10 10 10\n5\n10 10 10 10 10\n", "output": "6\n0\n"}, {"input": "2\n8\n1 9 1 9 8 10 10 10\n5\n10 10 10 10 10\n", "output": "6\n0\n"}, {"input": "2\n8\n1 9 1 9 8 10 16 10\n5\n10 10 10 10 10\n", "output": "6\n0\n"}, {"input": "2\n8\n1 9 2 9 8 10 16 10\n5\n10 10 10 10 10\n", "output": "7\n0\n"},... | code_stdio |
[
{
"content": "Lee was cleaning his house for the party when he found a messy string under the carpets. Now he'd like to make it clean accurately and in a stylish way...\n\nThe string $s$ he found is a binary string of length $n$ (i. e. string consists only of 0-s and 1-s).\n\nIn one move he can choose two conse... | [{"input": "5\n10\n0010111111\n4\n0000\n8\n01011111\n10\n1011010100\n1\n0\n", "output": "000111111\n0000\n0011111\n0\n0\n"}, {"input": "5\n10\n0010111111\n4\n1111\n8\n01011111\n10\n1011010100\n1\n0\n", "output": "000111111\n1111\n0011111\n0\n0\n"}, {"input": "5\n10\n0010111111\n4\n0001\n8\n11011111\n10\n1011010100\n1\n... | code_stdio |
[
{
"content": "Let's imagine we have a popular online RPG. A player begins with a score of 0 in class E5. A1 is the highest level a player can achieve.\n\nNow let's say the players wants to rank up to class E4. To do so the player needs to achieve at least 100 points to enter the qualifying stage.\n\nWrite a scr... | [{"input": "332532105", "output": "[\"Well done! You have advanced to the qualifying stage. Win 2 out of your next 3 games to rank up.\"]", "fn_name": "playerRankUp"}, {"input": "100", "output": "[\"Well done! You have advanced to the qualifying stage. Win 2 out of your next 3 games to rank up.\"]", "fn_name": "playerR... | code_functional |
[
{
"content": "There is a house with 4 levels.\nIn that house there is an elevator.\nYou can program this elevator to go up or down,\ndepending on what button the user touches inside the elevator.\n\nValid levels must be only these numbers: `0,1,2,3`\n\nValid buttons must be only these strings: `'0','1','2','3'`... | [{"input": "\"length\"\n\"length\"", "output": "[0]", "fn_name": "goto"}, {"input": "null\n\"2\"", "output": "[0]", "fn_name": "goto"}, {"input": "\"2\"\n\"3\"", "output": "[0]", "fn_name": "goto"}, {"input": "1.5\n\"3\"", "output": "[0]", "fn_name": "goto"}, {"input": "1\n\"0\"", "output": "[-1]", "fn_name": "goto"}, ... | code_functional |
[
{
"content": "With a friend we used to play the following game on a chessboard\n(8, rows, 8 columns).\nOn the first row at the *bottom* we put numbers:\n\n`1/2, 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9`\n\nOn row 2 (2nd row from the bottom) we have:\n\n`1/3, 2/4, 3/5, 4/6, 5/7, 6/8, 7/9, 8/10`\n\nOn row 3:\n\n`1/4, 2/... | [{"input": "3000001", "output": "[[9000006000001, 2]]", "fn_name": "game"}, {"input": "750001", "output": "[[562501500001, 2]]", "fn_name": "game"}, {"input": "3000000", "output": "[[4500000000000]]", "fn_name": "game"}, {"input": "750000", "output": "[[281250000000]]", "fn_name": "game"}, {"input": "120000", "output":... | code_functional |
[
{
"content": "It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to highlight an important problem.\n\nThere are $n$ displays placed along a road, and the $i$-th of them can display a text with font size $s_i$ only. Maria S... | [{"input": "20\n804301132 586588704 822785255 552472140 16115810 148658854 66743034 628305150 677780684 931815125 208050516 401554301 954478790 571480982 387546138 832279893 641889899 80960260 717802881 172455365\n61699500 83254572 29028223 27833657 55743179 118122387 94729965 147554867 62937826 3626886 131711239 36649... | code_stdio |
[
{
"content": "An African crossword is a rectangular table n Γ m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.\n\nTo solve the crossword you should cross out all repeated letters in rows and columns.... | [{"input": "14 27\npzoshpvvjdpmwfoeojapmkxjrnk\nitoojpcorxjdxrwyewtmmlhjxhx\ndoyopbwusgsmephixzcilxpskxh\nygpvepeuxjbnezdrnjfwdhjwjka\nrfjlbypoalbtjwrpjxzenmeipfg\nkhjhrtktcnajrnbefhpavxxfnlx\nvwlwumqpfegjgvoezevqsolaqih\npdrvrtzqsoujqfeitkqgtxwckrl\nxtepjflcxcrfomhqimhimnzfxzg\nwhkfkfvvjkwmwhfgeovwowshyhw\nolchgmhiehu... | code_stdio |
[
{
"content": "Did you know that Chwee kueh, a cuisine of Singapore, means water rice cake ? Its a variety of the most popular South Indian savory cake, only that we call it here idli :). The tastiest idlis are made in Chennai, by none other than our famous chef, Dexter Murugan. Being very popular, he is flown f... | [{"input": "3\n4\n1 4 2 3\n2\n1 2\n10\n1 0 3 4 1 6 7", "output": "-1\n-1\n-1\n"}, {"input": "3\n4\n1 4 2 3\n2\n1 2\n10\n1 0 3 1 1 6 7", "output": "-1\n-1\n-1\n"}, {"input": "3\n4\n1 4 1 3\n2\n1 2\n7\n1 -1 3 4 6 6 7", "output": "-1\n-1\n-1\n"}, {"input": "3\n4\n1 4 2 3\n2\n1 2\n10\n1 1 3 4 1 6 7", "output": "-1\n-1\n-1\... | code_stdio |
[
{
"content": "You are given $n$ chips on a number line. The $i$-th chip is placed at the integer coordinate $x_i$. Some chips can have equal coordinates.\n\nYou can perform each of the two following types of moves any (possibly, zero) number of times on any chip:\n\n Move the chip $i$ by $2$ to the left or $2$... | [{"input": "66\n17474 17509 20550 10873 31311 10156 24680 28012 29609 8266 18126 20151 648 2722 13599 9467 8289 17005 1 31436 21443 265 21543 32682 11647 30228 15498 1331 8459 20026 24054 23702 15400 7243 3017 10315 451 22673 6648 30210 27673 27232 4178 13529 23071 28654 8969 23505 27681 14437 5230 21635 5033 9271 2559... | code_stdio |
[
{
"content": "The Little Elephant from the Zoo of Lviv has an array A that consists of N positive integers. Let A[i] be the i-th number in this array (i = 1, 2, ..., N).\n\nFind the minimal number x > 1 such that x is a divisor of all integers from array A. More formally, this x should satisfy the following rel... | [{"input": "2\n3\n3 4 16\n3\n1 10 6", "output": "-1\n-1\n"}, {"input": "2\n1\n1 4 6\n1\n1 13 10", "output": "-1\n-1\n"}, {"input": "2\n2\n2 3 8\n3\n0 0 11", "output": "-1\n11\n"}, {"input": "2\n3\n10 5 0\n3\n4 38 3", "output": "5\n-1\n"}, {"input": "2\n1\n2 4 12\n3\n1 12 5", "output": "2\n-1\n"}, {"input": "2\n2\n2 4 1... | code_stdio |
[
{
"content": "Compare given two sequence $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ and $B = \\\\{b_0, b_1, ..., b_{m-1}$ lexicographically.\n\nConstraints\n\n* $1 \\leq n, m \\leq 1,000$\n* $0 \\leq a_i, b_i \\leq 1,000$\n\nInput\n\nThe input is given in the following format.\n\n\n$n$\n$a_0 \\; a_1, ..., \\; a_{n-... | [{"input": "4\n0 4 12 1\n5\n1 2 5 4 1", "output": "1\n"}, {"input": "4\n1 4 1 1\n2\n-1 4 5 4 2", "output": "0\n"}, {"input": "4\n1 4 1 1\n2\n-1 4 9 4 2", "output": "0\n"}, {"input": "4\n1 4 1 1\n2\n-2 4 9 4 2", "output": "0\n"}, {"input": "4\n1 4 1 1\n2\n-4 4 9 4 2", "output": "0\n"}, {"input": "4\n1 4 1 1\n2\n-4 8 9 4... | code_stdio |
[
{
"content": "We have N colored balls arranged in a row from left to right; the color of the i-th ball from the left is c_i.\nYou are given Q queries. The i-th query is as follows: how many different colors do the l_i-th through r_i-th balls from the left have?\n\n-----Constraints-----\n - 1\\leq N,Q \\leq 5 \\... | [{"input": "10 10\n6 5 -1 5 2 0 7 13 14 2\n5 6\n2 4\n6 7\n2 2\n7 8\n7 9\n2 8\n6 9\n8 10\n6 8", "output": "2\n2\n2\n1\n2\n3\n6\n4\n3\n3\n"}, {"input": "10 10\n6 5 -1 5 2 0 7 13 14 2\n5 6\n2 4\n6 7\n2 2\n7 8\n7 9\n2 8\n6 5\n8 10\n6 8", "output": "2\n2\n2\n1\n2\n3\n6\n0\n3\n3\n"}, {"input": "10 10\n6 5 -1 5 2 0 7 13 14 2\... | code_stdio |
[
{
"content": "Vasya is preparing a contest, and now he has written a statement for an easy problem. The statement is a string of length $n$ consisting of lowercase Latin latters. Vasya thinks that the statement can be considered hard if it contains a subsequence hard; otherwise the statement is easy. For exampl... | [{"input": "25\ndadddhrdhradrdzzzahazaddr\n582987584 321035417 414785252 587245865 701672370 65936511 563890835 134108386 387506178 22811155 989335244 1206131752 445085282 809768866 105799145 196558041 1131981383 134067229 875977231 488184174 41982468 225574390 702881847 937432062 185455403\n", "output": "445085282\n"}... | code_stdio |
[
{
"content": "Everyone knows passphrases. One can choose passphrases from poems, songs, movies names and so on but frequently\nthey can be guessed due to common cultural references.\nYou can get your passphrases stronger by different means. One is the following:\n\nchoose a text in capital letters including or... | [{"input": "\"FOR THIS REASON IT IS RECOMMENDED THAT PASSPHRASES NOT BE REUSED ACROSS DIFFERENT OR UNIQUE SITES AND SERVICES.\"\n15", "output": "[\".hTrXkGtH ScP HtIxH TjFxCj gD IcTgTuUxS HhDgRp sThJtG Tq iDc hThPgWeHhPe iPwI StScTbBdRtG Hx iX CdHpTg hXwI GdU\"]", "fn_name": "play_pass"}, {"input": "\"TO BE HONEST WITH... | code_functional |
[
{
"content": "Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was introduced. Now, each player character has exactly n skills. Each skill is represented by a non-negative integer ai β the current skill level. All skills have the same maximu... | [{"input": "1 1000000000 1000 1000 1000000000000000\n1000000000\n", "output": "1000000001000\n1000000000 \n"}, {"input": "1 1000001000 1000 1000 1000000000000000\n1000000000\n", "output": "1000001001000\n1000001000\n"}, {"input": "1 1000000000 1000 1000 1000000000000010\n1000000000\n", "output": "1000000001000\n1000000... | code_stdio |
[
{
"content": "The \"Bulls and Cows\" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it.\n\nThe thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one... | [{"input": "10\n0132 0 1\n6801 0 1\n8749 1 1\n8036 0 0\n7384 0 2\n8594 0 1\n9307 1 0\n7390 0 1\n6127 1 1\n0381 0 1\n", "output": "Incorrect data\n"}, {"input": "10\n8795 0 3\n4971 1 1\n5032 0 1\n5479 0 3\n2501 0 1\n9052 1 1\n3649 0 1\n1927 1 0\n9173 0 1\n8014 0 2\n", "output": "Incorrect data\n"}, {"input": "10\n9360 0... | code_stdio |
[
{
"content": "We say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\nYou are given Q queries.\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i β€ x β€ r_i.\n\n-----Constraints-----\n - 1β€Qβ€10^5\n - 1β€l_iβ€r_iβ€10^5\n - l... | [{"input": "6\n1 53\n7 129\n37 55\n19 51\n103 169\n13 33", "output": "4\n4\n1\n1\n1\n1\n"}, {"input": "6\n1 53\n7 129\n65 55\n19 51\n17 169\n13 49", "output": "4\n4\n-1\n1\n4\n2\n"}, {"input": "6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n", "output": "4\n4\n1\n1\n1\n2\n"}, {"input": "6\n1 53\n7 119\n37 55\n19 83\n73 39... | code_stdio |
[
{
"content": "Takahashi likes the sound when he buys a drink from a vending machine.\nThat sound can be heard by spending A yen (the currency of Japan) each time.\nTakahashi has B yen. He will hear the sound as many times as he can with that money, but at most C times, as he would be satisfied at that time.\nHo... | [{"input": "100 100 100\n", "output": "1\n"}, {"input": "1 100 100\n", "output": "100\n"}, {"input": "011 -1 106", "output": "-1\n"}, {"input": "001 -1 106", "output": "-1\n"}, {"input": "101 -1 106", "output": "-1\n"}, {"input": "1 100 99\n", "output": "99\n"}, {"input": "111 -1 33", "output": "-1\n"}, {"input": "001 ... | code_stdio |
[
{
"content": "Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.\n\nThe teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, ... | [{"input": "2+3+3+1+2+2+2+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n"}, {"input": "2+1+2+2+1+3+2+3+1+1+2+1+2+2+3+1+1+3+3+3+2+2+3+2+2+2+1+2+1+2+3+2+2+2+1+3+1+3+3... | code_stdio |
[
{
"content": "The development of algae in a pond is as follows.\nLet the total weight of the algae at the beginning of the year i be x_i gram. For iβ₯2000, the following formula holds:\n - x_{i+1} = rx_i - D\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\n-----Cons... | [{"input": "28 -2 -1", "output": "-26\n-726\n-20326\n-569126\n-15935526\n-446194726\n-12493452326\n-349816665126\n-9794866623526\n-274256265458726\n"}, {"input": "17 -2 -1", "output": "-15\n-253\n-4299\n-73081\n-1242375\n-21120373\n-359046339\n-6103787761\n-103764391935\n-1763994662893\n"}, {"input": "13 0 -1", "output... | code_stdio |
[
{
"content": "Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\n-----Constraints... | [{"input": "1000\n", "output": "ABC\n"}, {"input": "2000\n", "output": "ARC\n"}, {"input": "0000", "output": "ABC\n"}, {"input": "2936", "output": "ARC\n"}, {"input": "0100", "output": "ABC\n"}, {"input": "1432", "output": "ARC\n"}, {"input": "1100", "output": "ABC\n"}, {"input": "1101", "output": "ABC\n"}, {"input": "... | code_stdio |
[
{
"content": "A checksum is an algorithm that scans a packet of data and returns a single number. The idea is that if the packet is changed, the checksum will also change, so checksums are often used for detecting\ntransmission errors, validating document contents, and in many other situations where it is neces... | [{"input": "\"ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ\"", "output": "[848640]", "fn_name": "quicksum"}, ... | code_functional |
[
{
"content": "The GCD table G of size n Γ n for an array of positive integers a of length n is defined by formula \n\n<image>\n\nLet us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest integer that is divisor of both x and y, it is denoted as <image>. For exampl... | [{"input": "5\n537163 537163 537163 537163 537163 537163 1074326 537163 537163 537163 515139317 1074326 537163 537163 537163 539311652 321760637 170817834 537163 537163 537163 537163 537163 537163 392666153\n", "output": "539311652 515139317 392666153 321760637 170817834 "}, {"input": "5\n2029 6087 2029 2029 6087 2029 ... | code_stdio |
[
{
"content": "A new school year is approaching, which also means students will be taking tests. \n\nThe tests in this kata are to be graded in different ways. A certain number of points will be given for each correct answer and a certain number of points will be deducted for each incorrect answer. For ommitted ... | [{"input": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 2, 0, 0, 0, 0, 1, 1, 2, 2, 2, 2, 0]\n6\n0\n1.5", "output": "[87]", "fn_name": "score_test"}, {"input": "[0, 1, 2, 0, 0, 2, 0, 1, 2, 1, 0, 0, 1, 0, 2, 1, 0, 2, 2, 0]\n9\n3\n2", "output": "[84]", "fn_name": "score_test"}, {"input": "[0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 2, ... | code_functional |
[
{
"content": "There is a rectangular grid of size $n \\times m$. Each cell has a number written on it; the number on the cell ($i, j$) is $a_{i, j}$. Your task is to calculate the number of paths from the upper-left cell ($1, 1$) to the bottom-right cell ($n, m$) meeting the following constraints:\n\n You can ... | [{"input": "10 10 524287\n1 2 4 8 16 32 64 128 256 512\n2 4 8 16 32 64 128 256 512 1024\n4 8 16 32 64 128 256 512 1024 2048\n8 16 32 64 128 256 512 1024 2048 4096\n16 32 64 128 256 512 1024 2048 4096 8192\n32 64 128 256 512 1024 2048 4096 8192 16384\n64 128 256 512 1024 2048 4096 8192 16384 32768\n128 256 512 1024 2048... | code_stdio |
[
{
"content": "A subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.\nFor example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci are not.\nYou are given a string A consisti... | [{"input": "frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n", "output": "aca\n"}, {"input": "frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhzktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnf... | code_stdio |
[
{
"content": "Β«One dragon. Two dragon. Three dragonΒ», β the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.\n\nHowever, just counting dragons was boring as well, so she entertained herself at best she could. Tonight she imagined that all dragons were... | [{"input": "10\n10\n10\n10\n100000\n", "output": "10000\n"}, {"input": "10\n10\n10\n4\n100000\n", "output": "30000\n"}, {"input": "10\n10\n16\n4\n100000\n", "output": "30000\n"}, {"input": "1\n1\n1\n1\n100000\n", "output": "100000\n"}, {"input": "9\n7\n10\n10\n42357\n", "output": "13312\n"}, {"input": "9\n7\n11\n10\n42... | code_stdio |
[
{
"content": "The `depth` of an integer `n` is defined to be how many multiples of `n` it is necessary to compute before all `10` digits have appeared at least once in some multiple. \n\nexample:\n```\nlet see n=42\n\nMultiple value digits comment\n42*1 42 2,4 \n42*2 ... | [{"input": "25", "output": "[36]", "fn_name": "compute_depth"}, {"input": "8", "output": "[12]", "fn_name": "compute_depth"}, {"input": "13", "output": "[8]", "fn_name": "compute_depth"}, {"input": "7", "output": "[10]", "fn_name": "compute_depth"}, {"input": "42", "output": "[9]", "fn_name": "compute_depth"}, {"input"... | code_functional |
[
{
"content": "Mr Keks is a typical white-collar in Byteland.\n\nHe has a bookshelf in his office with some books on it, each book has an integer positive price.\n\nMr Keks defines the value of a shelf as the sum of books prices on it. \n\nMiraculously, Mr Keks was promoted and now he is moving into a new office... | [{"input": "30 4\n893642632982367 772277951746295 510759449350295 826812150840579 1060893142351815 525992742241552 154832018679993 645715002371268 27232975419720 475004229372388 200177708355593 810661468479466 49618609534806 301608930846726 97042172725806 441637617418914 594900693592862 626510702147446 653604971179679 ... | code_stdio |
[
{
"content": "In one school with Vasya there is a student Kostya. Kostya does not like physics, he likes different online games. Every day, having come home, Kostya throws his bag in the farthest corner and sits down at his beloved computer. Kostya even eats glued to the game. A few days ago Kostya bought a new... | [{"input": "3 3 2 5\ndesolator\nrefresher\nperseverance\nvanguard: desolator 1, refresher 1\nmaelstorm: perseverance 2\n1 desolator\n2 perseverance\n1 refresher\n2 desolator\n2 perseverance\n", "output": "1\nvanguard 1\n2\ndesolator 1\nmaelstorm 1\n0\n"}, {"input": "2 3 2 5\ndesolator\nrefresher\nperseverance\nvanguard... | code_stdio |
[
{
"content": "Prime numbers are widely applied for cryptographic and communication technology. A twin prime is a prime number that differs from another prime number by 2. For example, (5, 7) and (11, 13) are twin prime pairs.\n\nIn this problem, we call the greater number of a twin prime \"size of the twin prim... | [{"input": "12\n110\n200\n300\n0", "output": "5 7\n107 109\n197 199\n281 283\n"}, {"input": "12\n110\n200\n227\n0", "output": "5 7\n107 109\n197 199\n197 199\n"}, {"input": "12\n110\n200\n329\n0", "output": "5 7\n107 109\n197 199\n311 313\n"}, {"input": "12\n110\n200\n239\n0", "output": "5 7\n107 109\n197 199\n227 229\... | code_stdio |
[
{
"content": "DO YOU EXPECT ME TO FIND THIS OUT?\n\nWHAT BASE AND/XOR LANGUAGE INCLUDES string?\n\nDON'T BYTE OF MORE THAN YOU CAN CHEW\n\nYOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FAR\n\nSAYING \"ABRACADABRA\" WITHOUT A MAGIC AND WON'T DO YOU ANY GOOD\n\nTHE LAST STACK RUPTURES. ALL DIE. OH, THE EMBAR... | [{"input": "10\n5 5 10 10 10 2 4 3 4 10\n", "output": "0\n"}, {"input": "10\n5 5 10 10 10 2 4 3 4 10\n", "output": "0\n"}, {"input": "10\n5 5 10 10 10 1 4 3 4 10\n", "output": "0\n"}, {"input": "10\n3 5 10 10 10 1 4 3 4 10\n", "output": "0\n"}, {"input": "10\n3 5 10 10 10 1 4 3 5 10\n", "output": "0\n"}, {"input": "10\... | code_stdio |
[
{
"content": "In this Kata, you will implement the [Luhn Algorithm](http://en.wikipedia.org/wiki/Luhn_algorithm), which is used to help validate credit card numbers.\n\nGiven a positive integer of up to 16 digits, return ```true``` if it is a valid credit card number, and ```false``` if it is not.\n\nHere is th... | [{"input": "4111111111111111", "output": "[true]", "fn_name": "validate"}, {"input": "2626262626262626", "output": "[true]", "fn_name": "validate"}, {"input": "8675309", "output": "[false]", "fn_name": "validate"}, {"input": "922030", "output": "[false]", "fn_name": "validate"}, {"input": "912030", "output": "[true]", ... | code_functional |
[
{
"content": "Smith wakes up at the side of a dirty, disused bathroom, his ankle chained to pipes. Next to him is tape-player with a hand-written message \"Play Me\". He finds a tape in his own back pocket. After putting the tape in the tape-player, he sees a key hanging from a ceiling, chained to some kind of ... | [{"input": "15 6\naaa\naaabbb\naaabb\naaaaa\naaaaaa\naaaa\naaabbbb\naaaaa\naaaaaa\naaaa\naaabbbb\naabbbb\naa\naa\naab\na\n?a?\n??\n?aa?bb?\n?aa?aa?\n??aaa?\n", "output": "0\n4\n2\n5\n6\n7\n"}, {"input": "15 6\naaa\naaabbb\naaabb\naaaaa\naaaaaa\naaaa\naaabbbb\naaaaa\naaaaaa\naaaa\naaabbbb\naabbbc\naa\naa\naab\na\n?a?\n?... | code_stdio |
[
{
"content": "We define the \"unfairness\" of a list/array as the *minimal* difference between max(x1,x2,...xk) and min(x1,x2,...xk), for all possible combinations of k elements you can take from the list/array; both minimum and maximum of an empty list/array are considered to be 0.\n\n**More info and constrain... | [{"input": "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n10", "output": "[0]", "fn_name": "min_unfairness"}, {"input": "[1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]\n10", "output": "[1]", "fn_name": "min_unfairness"}, {"input": "[1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]\n9", "output": "[0]", "fn_name... | code_functional |
[
{
"content": "Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card.\n\nThe players take turns and Ciel takes the first turn. In Ciel's turn she takes a card from the top of any non-empty pile, and in Jiro's turn he takes ... | [{"input": "3\n3 1000 1000 1000\n6 1000 1000 1000 1000 1000 1010\n5 1000 1000 1000 1000 1000\n", "output": "7000 7010\n"}, {"input": "3\n3 1000 1000 1000\n6 1000 1000 1000 1000 1000 1010\n5 1000 1000 0000 1000 1000\n", "output": "7000 6010\n"}, {"input": "3\n3 1000 1000 1000\n6 1000 1000 1000 1000 1000 1011\n5 1000 100... | code_stdio |
[
{
"content": "You are given two arrays $a$ and $b$ both consisting of $n$ positive (greater than zero) integers. You are also given an integer $k$.\n\nIn one move, you can choose two indices $i$ and $j$ ($1 \\le i, j \\le n$) and swap $a_i$ and $b_j$ (i.e. $a_i$ becomes $b_j$ and vice versa). Note that $i$ and ... | [{"input": "5\n2 1\n1 2\n3 4\n5 5\n5 5 6 11 5\n1 2 5 4 3\n5 3\n1 2 3 4 5\n10 9 10 10 9\n4 0\n2 2 4 3\n2 4 2 3\n4 4\n1 2 2 1\n4 4 5 4\n", "output": "6\n32\n39\n11\n17\n"}, {"input": "5\n2 1\n1 2\n3 4\n5 5\n5 10 6 6 5\n1 2 5 4 3\n5 5\n1 2 3 4 5\n10 9 10 10 9\n4 0\n2 2 4 3\n2 4 2 0\n4 4\n1 2 0 1\n4 4 5 4\n", "output": "6\... | code_stdio |
[
{
"content": "Make a program that filters a list of strings and returns a list with only your friends name in it.\n\nIf a name has exactly 4 letters in it, you can be sure that it has to be a friend of yours! Otherwise, you can be sure he's not...\n\nEx: Input = [\"Ryan\", \"Kieran\", \"Jason\", \"Yous\"], Outp... | [{"input": "[\"Jimm\", \"Cari\", \"aret\", \"truehdnviegkwgvke\", \"sixtyiscooooool\"]", "output": "[[\"Jimm\", \"Cari\", \"aret\"]]", "fn_name": "friend"}, {"input": "[\"This\", \"IS\", \"enough\", \"TEst\", \"CaSe\"]", "output": "[[\"This\", \"TEst\", \"CaSe\"]]", "fn_name": "friend"}, {"input": "[\"Hell\", \"Is\", \... | code_functional |
[
{
"content": "Leha like all kinds of strange things. Recently he liked the function F(n, k). Consider all possible k-element subsets of the set [1, 2, ..., n]. For subset find minimal element in it. F(n, k) β mathematical expectation of the minimal element among all k-element subsets.\n\nBut only function does ... | [{"input": "7\n4 12 5 15 8 2 5\n2 1 2 0 1 1 1\n", "output": "4 12 2 15 8 5 5\n"}, {"input": "7\n4 12 5 8 10 2 3\n2 1 2 1 1 1 2\n", "output": "4 12 3 10 8 5 2\n"}, {"input": "7\n4 12 5 8 10 2 3\n2 2 2 1 1 1 2\n", "output": "5 4 3 12 10 8 2\n"}, {"input": "7\n4 12 5 15 8 2 5\n2 1 2 1 1 1 2\n", "output": "5 15 4 12 8 5 2\... | code_stdio |
[
{
"content": "This is the hard version of the problem. The only difference is that in this version $n \\leq 200000$. You can make hacks only if both versions of the problem are solved.\n\nThere are $n$ potions in a line, with potion $1$ on the far left and potion $n$ on the far right. Each potion will increase ... | [{"input": "12\n-3 -3 -7 -1 -1 -7 4 2 -4 -1 0 -11\n", "output": "5\n"}, {"input": "12\n-3 -3 -5 -1 -1 -7 4 2 -4 -1 0 -11\n", "output": "5\n"}, {"input": "12\n-1 -3 -5 -1 -1 -7 4 2 -4 -1 0 -11\n", "output": "5\n"}, {"input": "12\n-1 -3 -5 -1 -1 -7 4 2 -5 -1 0 -11\n", "output": "5\n"}, {"input": "12\n-1 -3 -5 -1 -1 -7 2 ... | code_stdio |
[
{
"content": "Write a program which computes the digit number of sum of two integers a and b.\n\nConstraints\n\n* 0 β€ a, b β€ 1,000,000\n* The number of datasets β€ 200\n\nInput\n\nThere are several test cases. Each test case consists of two non-negative integers a and b which are separeted by a space in a line. ... | [{"input": "-2 -1\n2 -15\n0110 -1", "output": "2\n3\n3\n"}, {"input": "10 10\n2 36\n1000 25", "output": "2\n2\n4\n"}, {"input": "-1 -1\n0 -1\n0111 14", "output": "2\n2\n3\n"}, {"input": "-2 -1\n0 -1\n0011 14", "output": "2\n2\n2\n"}, {"input": "2 -1\n-6 1\n1001 -14", "output": "1\n2\n3\n"}, {"input": "6 7\n1 99\n1000 1... | code_stdio |
[
{
"content": "Takahashi has decided to distribute N AtCoder Crackers to K users of as evenly as possible.\nWhen all the crackers are distributed, find the minimum possible (absolute) difference between the largest number of crackers received by a user and the smallest number received by a user.\n\n-----Constrai... | [{"input": "100 100\n", "output": "0\n"}, {"input": "100 10\n", "output": "0\n"}, {"input": "111 136", "output": "1\n"}, {"input": "110 112", "output": "1\n"}, {"input": "011 127", "output": "1\n"}, {"input": "99 33\n", "output": "0\n"}, {"input": "100 1\n", "output": "0\n"}, {"input": "99 49\n", "output": "1\n"}, {"in... | code_stdio |
[
{
"content": "You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them.\n\nFor example, if K = 3, print `ACLACLACL`.\n\nConstraints\n\n* 1 \\leq K \\leq 5\n* All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the followin... | [{"input": "451", "output": "ACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACLACL... | code_stdio |
[
{
"content": "Hilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capacity, meaning there is exactly one guest in every room. The hotel's manager, ... | [{"input": "10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n82 -66 113 -81 -35\n5\n-125 107 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n", "output": "NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n"}, {"input": "10\n3\n-14 -33 142\... | code_stdio |
[
{
"content": "A tatami mat, a Japanese traditional floor cover, has a rectangular form with aspect ratio 1:2. When spreading tatami mats on a floor, it is prohibited to make a cross with the border of the tatami mats, because it is believed to bring bad luck.\n\nYour task is to write a program that reports how ... | [{"input": "6 12\n2 18\n0 0", "output": "4\n872\n"}, {"input": "5 18\n18 4\n0 0", "output": "10\n25\n"}, {"input": "14 14\n8 3\n0 0", "output": "2\n10\n"}, {"input": "8 10\n18 4\n0 0", "output": "1\n25\n"}, {"input": "8 9\n18 3\n0 0", "output": "2\n110\n"}, {"input": "7 2\n18 4\n0 0", "output": "13\n25\n"}, {"input": "... | code_stdio |
[
{
"content": "We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.\n\nSnuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.\n\nFind the... | [{"input": "4 4\n1 1\n-1 3\n4 0\n3 4", "output": "1\n"}, {"input": "7 4\n-1 2\n1 3\n7 0\n0 0", "output": "1\n"}, {"input": "7 4\n-1 2\n1 6\n7 0\n0 0", "output": "1\n"}, {"input": "10 4\n1 2\n2 3\n4 0\n0 0", "output": "2\n"}, {"input": "4 4\n1 2\n-1 3\n4 0\n3 4", "output": "1\n"}, {"input": "7 4\n-1 0\n1 6\n7 0\n0 0", "... | code_stdio |
[
{
"content": "Brave Ponta and his best friend, Brave Gonta, have come to Luida's bar in search of friends to embark on an epic adventure. There are many warriors, monks and wizards in the tavern who are itching to go on an adventure.\n\nGonta, who is kind-hearted, cared for Ponta and said, \"You can choose your... | [{"input": "5\n1 4 3 2 20\n19\n1 3 4 10\n0", "output": "10\n2\n"}, {"input": "5\n1 4 3 2 20\n19\n2 3 4 10\n0", "output": "10\n1\n"}, {"input": "5\n2 0 3 4 20\n29\n1 3 4 10\n0", "output": "11\n2\n"}, {"input": "5\n2 0 3 4 20\n29\n1 6 4 10\n0", "output": "11\n1\n"}, {"input": "5\n2 0 3 4 20\n29\n1 6 4 16\n0", "output": "... | code_stdio |
[
{
"content": "As meticulous Gerald sets the table, Alexander finished another post on Codeforces and begins to respond to New Year greetings from friends. Alexander has n friends, and each of them sends to Alexander exactly one e-card. Let us number his friends by numbers from 1 to n in the order in which they ... | [{"input": "10\n5 1 6 2 8 3 4 10 9 7\n3 1 10 6 8 5 2 7 9 4\n2 9 1 4 10 6 8 7 3 5\n10 1 7 8 3 2 4 6 5 9\n3 2 10 4 7 8 5 6 1 9\n5 6 3 10 8 7 2 9 4 1\n6 5 1 3 2 7 9 10 8 4\n1 10 9 3 7 8 4 2 6 5\n6 8 4 5 9 1 2 10 7 3\n9 6 8 5 10 3 1 7 2 4\n5 7 4 8 9 6 1 10 3 2\n", "output": "5 1 1 1 4 5 5 1 4 5 \n"}, {"input": "10\n5 1 6 2... | code_stdio |
[
{
"content": "You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan).\nIn how many ways can we select some of these coins so that they are X yen in total?\nCoins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin,... | [{"input": "30\n40\n50\n6000\n", "output": "213\n"}, {"input": "30\n40\n77\n6000", "output": "293\n"}, {"input": "30\n47\n77\n6000", "output": "319\n"}, {"input": "30\n112\n134\n6415", "output": "0\n"}, {"input": "30\n112\n134\n8208", "output": "0\n"}, {"input": "30\n112\n134\n3602", "output": "0\n"}, {"input": "30\n16... | code_stdio |
[
{
"content": "A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7.\n\nThe Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 β€ X β€ M) such that the number of digits 4 in the substring T[1,... | [{"input": "4\n47\n47\n477\n4747477", "output": "2\n2\n3\n23\n"}, {"input": "4\n44\n74\n477\n4747477", "output": "3\n2\n3\n23\n"}, {"input": "4\n47\n44\n477\n4747477", "output": "2\n3\n3\n23\n"}, {"input": "4\n44\n44\n477\n4747477", "output": "3\n3\n3\n23\n"}, {"input": "4\n74\n47\n477\n4747477", "output": "2\n2\n3\n23... | code_stdio |
[
{
"content": "There are $n$ cities numbered from $1$ to $n$, and city $i$ has beauty $a_i$.\n\nA salesman wants to start at city $1$, visit every city exactly once, and return to city $1$.\n\nFor all $i\\ne j$, a flight from city $i$ to city $j$ costs $\\max(c_i,a_j-a_i)$ dollars, where $c_i$ is the price floor... | [{"input": "30\n13 1\n111 5\n50 5\n61 0\n76 98\n110 1\n17 1\n4 17\n72 28\n75 90\n16 0\n13 12\n57 0\n47 12\n34 13\n61 120\n3 1\n134 100\n89 94\n88 10\n42 3\n93 33\n6 5\n81 48\n31 17\n32 0\n11 5\n69 1\n58 1\n3 21\n", "output": "750\n"}, {"input": "30\n13 1\n59 5\n50 5\n61 0\n76 98\n110 1\n17 1\n4 17\n72 28\n75 90\n16 0\n... | code_stdio |
[
{
"content": "Example\n\nInput\n\n5 3\n4\n2\n5\n\n\nOutput\n\n5\n2\n4\n1\n3\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": "92 1\n1\n-2\n2", "output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n7... | code_stdio |
[
{
"content": "There are n psychos standing in a line. Each psycho is assigned a unique integer from 1 to n. At each step every psycho who has an id greater than the psycho to his right (if exists) kills his right neighbor in the line. Note that a psycho might kill and get killed at the same step. \n\nYou're giv... | [{"input": "100\n61 96 25 10 50 71 38 77 76 75 59 100 89 66 6 99 2 13 3 23 91 93 22 92 4 86 90 44 39 31 9 47 28 95 18 54 1 73 94 78 60 20 42 84 97 83 16 81 67 64 74 46 82 5 88 80 14 48 53 79 30 11 62 21 41 70 63 58 51 56 57 17 87 72 27 85 68 49 52 8 12 98 43 37 35 69 55 32 26 40 29 65 19 24 34 33 15 45 36 7\n", "output... | code_stdio |
[
{
"content": "You are given a tree consisting exactly of $n$ vertices. Tree is a connected undirected graph with $n-1$ edges. Each vertex $v$ of this tree has a value $a_v$ assigned to it.\n\nLet $dist(x, y)$ be the distance between the vertices $x$ and $y$. The distance between the vertices is the number of ed... | [{"input": "8\n9 4 1 7 10 1 1 10\n1 2\n2 3\n1 4\n1 5\n5 6\n5 7\n5 8\n", "output": "121\n"}, {"input": "8\n9 4 1 8 10 1 1 10\n1 2\n2 3\n1 4\n1 5\n5 6\n5 7\n5 8\n", "output": "124\n"}, {"input": "8\n9 3 1 8 10 1 1 10\n1 2\n2 3\n1 4\n1 5\n5 6\n5 7\n5 8\n", "output": "123\n"}, {"input": "8\n9 4 1 7 10 1 6 5\n1 2\n2 3\n1 4\... | code_stdio |
[
{
"content": "Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.\n\nTo solve the issue, Dima decided to split the strip into two non-empty parts so that each of t... | [{"input": "100\n8820100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026601\n", "output": "88201000000000000000000000000000000000000000000000000000000000000000000000000000000000000026601\n"}, {"input": "100\n8820100000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "You have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis.\n\n\n-----Input-----\n\nThe first line contains a single positive integer n (2 β€ n β€ 10^5).\n\nThe following n lines c... | [{"input": "23\n-1 1\n-1 2\n-2 4\n-7 -8\n-3 3\n-9 -14\n-5 3\n-6 2\n-7 11\n-4 4\n-8 5\n1 1\n-1 -1\n-1 -2\n-2 -4\n-7 8\n-3 -3\n-9 14\n-5 -3\n-6 -2\n-7 -11\n-4 -4\n-8 -5\n", "output": "Yes\n"}, {"input": "23\n-1 1\n-1 2\n-2 4\n-7 -8\n-3 3\n-9 -14\n-5 3\n-6 2\n-7 11\n-4 4\n-8 5\n1 1\n-1 -1\n-1 -2\n-2 -4\n-7 8\n-3 -3\n-9 14... | code_stdio |
[
{
"content": "Catherine received an array of integers as a gift for March 8. Eventually she grew bored with it, and she started calculated various useless characteristics for it. She succeeded to do it for each one she came up with. But when she came up with another oneΒ β xor of all pairwise sums of elements in... | [{"input": "100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 44 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 41 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 115 86 87 88 89 90 91 92 93 94 95 133 97 98 99 100\n", "outp... | code_stdio |
[
{
"content": "We'll call an array of n non-negative integers a[1], a[2], ..., a[n] interesting, if it meets m constraints. The i-th of the m constraints consists of three integers li, ri, qi (1 β€ li β€ ri β€ n) meaning that value <image> should be equal to qi. \n\nYour task is to find any interesting array of n e... | [{"input": "3 2\n1 2 536870912\n2 3 536870911\n", "output": "YES\n536870912 1073741823 536870911 "}, {"input": "3 2\n1 2 193688642\n2 3 942984520\n", "output": "YES\n193688642 1002437962 942984520\n"}, {"input": "3 2\n1 2 536870912\n2 3 942984520\n", "output": "YES\n536870912 942984520 942984520\n"}, {"input": "3 2\n1 ... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \nA new school in Byteland is now in the process of renewing some classrooms with new, stronger and better chairs, so that the students can stay still and pay attention to class :)\n\nHowever, due to budget and logistic reasons, it's onl... | [{"input": "2\n8\n29", "output": "255\n536870911\n"}, {"input": "2\n8\n49", "output": "255\n949480668\n"}, {"input": "2\n21\n9", "output": "2097151\n511\n"}, {"input": "2\n4\n22", "output": "15\n4194303\n"}, {"input": "2\n0\n20", "output": "0\n1048575\n"}, {"input": "2\n8\n15", "output": "255\n32767\n"}, {"input": "2\n... | code_stdio |
[
{
"content": "Write a function `getDrinkByProfession`/`get_drink_by_profession()` that receives as input parameter a string, and produces outputs according to the following table:\n\n\n\n\nInput\nOutput\n\n\n\"Jabroni\"\n\"Patron Tequila\"\n\n\n\"School Counselor\"\n\"Anything with Alcohol\"\n\n\nΒ \"Programmer\... | [{"input": "\"scHOOl counselor\"", "output": "[\"Anything with Alcohol\"]", "fn_name": "get_drink_by_profession"}, {"input": "\"scHOOl COUnselor\"", "output": "[\"Anything with Alcohol\"]", "fn_name": "get_drink_by_profession"}, {"input": "\"prOgramMer\"", "output": "[\"Hipster Craft Beer\"]", "fn_name": "get_drink_by_... | code_functional |
[
{
"content": "A superhero fights with a monster. The battle consists of rounds, each of which lasts exactly $n$ minutes. After a round ends, the next round starts immediately. This is repeated over and over again.\n\nEach round has the same scenario. It is described by a sequence of $n$ numbers: $d_1, d_2, \\do... | [{"input": "1000000000000 10\n-10 5 -2 -2 -10 -7 -5 -9 -3 -4\n", "output": "212765957448\n"}, {"input": "1000000000000 10\n-10 9 -2 -2 -10 -7 -5 -9 -3 -4\n", "output": "232558139536\n"}, {"input": "1000000000000 10\n-14 9 -2 -2 -10 -7 -5 -9 -3 -4\n", "output": "212765957448\n"}, {"input": "1000000000000 10\n-6 5 -2 -2 ... | code_stdio |
[
{
"content": "Ikta, who hates to lose, has recently been enthusiastic about playing games using the Go board. However, neither Go nor Gomoku can beat my friends at all, so I decided to give a special training to the lesser-known game Phutball.\n\nThis game is a difficult game, so I decided to give special train... | [{"input": "...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n...............\n....../........\n...............\n...............\n...............\n...............\n...............\n......O........\n..... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.