messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "Two players, Red and Blue, are at it again, and this time they're playing with crayons! The mischievous duo is now vandalizing a rooted tree, by coloring the nodes while playing their favorite game.\n\nThe game works as follows: there is a tree of size n, rooted at node 1, where each node is initi...
[{"input": "21 2\n1 2\n2 3\n2 4\n4 5\n10 6\n6 7\n13 8\n8 9\n1 10\n3 11\n11 12\n12 13\n3 15\n14 15\n20 16\n14 17\n14 18\n14 19\n14 20\n17 21\n", "output": "-70\n"}, {"input": "21 1\n1 2\n2 3\n2 4\n4 5\n10 6\n6 7\n14 8\n8 9\n9 10\n3 11\n11 12\n12 13\n5 14\n14 15\n14 16\n14 17\n14 18\n14 19\n14 20\n14 21\n", "output": "-9...
code_stdio
[ { "content": "A card pyramid of height $1$ is constructed by resting two cards against each other. For $h>1$, a card pyramid of height $h$ is constructed by placing a card pyramid of height $h-1$ onto a base. A base consists of $h$ pyramids of height $1$, and $h-1$ cards on top. For example, card pyramids of he...
[{"input": "50\n11833308\n5211498\n64660\n9077929\n2699416\n2432035\n234901\n1337830\n8457191\n10523566\n5722429\n5452712\n5511654\n8587879\n348160\n3141182\n2661936\n395300\n6950223\n2119926\n4407089\n3559060\n10228325\n5752720\n1607500\n647047\n8904557\n1954681\n698061\n9852830\n1972893\n13760200\n5944868\n9527673\n2...
code_stdio
[ { "content": "William arrived at a conference dedicated to cryptocurrencies. Networking, meeting new people, and using friends' connections are essential to stay up to date with the latest news from the world of cryptocurrencies.\n\nThe conference has $n$ participants, who are initially unfamiliar with each oth...
[{"input": "10 8\n1 2\n2 3\n3 4\n1 4\n6 7\n8 9\n8 10\n1 4\n", "output": "1\n2\n3\n4\n5\n5\n6\n8\n"}, {"input": "7 6\n1 2\n3 4\n2 4\n7 6\n6 5\n1 7\n", "output": "1\n1\n3\n3\n3\n6\n"}, {"input": "4 3\n2 1\n4 1\n1 2\n", "output": "1\n2\n3\n"}, {"input": "3 2\n1 3\n3 1\n", "output": "1\n2\n"}, {"input": "4 2\n2 4\n3 4\n", ...
code_stdio
[ { "content": "# Task\n You are given two string `a` an `s`. Starting with an empty string we can do the following two operations:\n```\nappend the given string a to the end of the current string.\nerase one symbol of the current string.```\nYour task is to find the least number of operations needed to construct...
[{"input": "\"abcdefgh\"\n\"hgfedcba\"", "output": "[64]", "fn_name": "string_constructing"}, {"input": "\"aba\"\n\"abbabba\"", "output": "[9]", "fn_name": "string_constructing"}, {"input": "\"aba\"\n\"abaa\"", "output": "[4]", "fn_name": "string_constructing"}, {"input": "\"aba\"\n\"a\"", "output": "[3]", "fn_name": "...
code_functional
[ { "content": "One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.\n\nBut there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a probl...
[{"input": "____________________________________________________________________________________________________\n", "output": "NO\n"}, {"input": "__________________________________________________________________________________________________`_\n", "output": "NO\n"}, {"input": "_`____________________________________...
code_stdio
[ { "content": "You are given array $a_1, a_2, \\dots, a_n$. Find the subsegment $a_l, a_{l+1}, \\dots, a_r$ ($1 \\le l \\le r \\le n$) with maximum arithmetic mean $\\frac{1}{r - l + 1}\\sum\\limits_{i=l}^{r}{a_i}$ (in floating-point numbers, i.e. without any rounding).\n\nIf there are many such subsegments find...
[{"input": "101\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "101\n"}, {"input": "101\n2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...
code_stdio
[ { "content": "Two pirates Polycarpus and Vasily play a very interesting game. They have n chests with coins, the chests are numbered with integers from 1 to n. Chest number i has a_{i} coins. \n\nPolycarpus and Vasily move in turns. Polycarpus moves first. During a move a player is allowed to choose a positive ...
[{"input": "99\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000...
code_stdio
[ { "content": "After lessons Nastya decided to read a book. The book contains $n$ chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.\n\nYesterday evening Nastya did not manage to finish reading the book, so she marked the pa...
[{"input": "49\n1 17\n18 115\n116 211\n212 269\n270 345\n346 404\n405 441\n442 467\n468 526\n527 583\n584 664\n665 757\n758 794\n795 802\n803 882\n883 920\n921 960\n961 962\n963 1006\n1007 1081\n1082 1112\n1113 1149\n1150 1217\n1218 1282\n1283 1287\n1288 1365\n1366 1374\n1375 1379\n1380 1478\n1479 1524\n1525 1549\n1550...
code_stdio
[ { "content": "As you have noticed, there are lovely girls in Arpa’s land.\n\nPeople in Arpa's land are numbered from 1 to n. Everyone has exactly one crush, i-th person's crush is person with the number crushi.\n\n<image>\n\nSomeday Arpa shouted Owf loudly from the top of the palace and a funny game started in ...
[{"input": "100\n84 94 72 32 61 90 61 2 76 42 35 82 90 29 51 27 65 99 38 41 44 73 100 58 56 64 54 31 14 58 57 64 90 49 73 80 74 19 31 86 73 44 39 43 28 95 23 5 85 5 74 81 34 44 86 30 50 57 94 56 53 42 53 87 92 78 53 49 78 60 37 63 41 19 15 68 25 77 87 48 23 100 54 27 68 84 43 92 76 55 2 94 100 20 92 18 76 83 100 99\n",...
code_stdio
[ { "content": "The electrical resistance is the opposition to the passage of electric current. If two resistors with resistance R1 and R2 are connected to each other, the resultant resistance R depends on how their ends are connected. If they are connected in Series, they simply add up to give R = R1 + R2. If th...
[{"input": "3\n1 36\n2 16\n100 11111", "output": "1/1\n2/3\n10456/4100\n"}, {"input": "3\n1 20\n4 17\n100 10010", "output": "1/1\n13/4\n5501/5775\n"}, {"input": "3\n1 20\n4 17\n101 10010", "output": "1/1\n13/4\n1266/7041\n"}, {"input": "3\n1 10\n1 12\n100 10000", "output": "1/1\n1/1\n4301/9525\n"}, {"input": "3\n1 20\n...
code_stdio
[ { "content": "At the school where the twins Ami and Mami attend, the summer vacation has already begun, and a huge amount of homework has been given this year as well. However, the two of them were still trying to go out without doing any homework today. It is obvious that you will see crying on the last day of...
[{"input": "4\n1 2\n3 1\n4 1\n2 1\n3\n10 4\n1 2\n1 2\n1\n1000 1000\n10\n5 62\n10 68\n15 132\n20 73\n25 75\n30 77\n35 79\n40 82\n45 100\n815 283\n6\n106 21\n53 55\n118 77\n19 13\n83 42\n2 1\n0", "output": "15\n24\n3000\n2072\n590\n"}, {"input": "4\n1 2\n3 1\n4 1\n2 2\n3\n10 4\n1 2\n1 2\n1\n1000 1000\n10\n5 62\n10 68\n15...
code_stdio
[ { "content": "Sasha and Dima want to buy two $n$-tier cakes. Each cake should consist of $n$ different tiers: from the size of $1$ to the size of $n$. Tiers should go in order from the smallest to the biggest (from top to bottom).\n\nThey live on the same street, there are $2 \\cdot n$ houses in a row from left...
[{"input": "10\n8 8 3 9 7 1 9 6 10 6 4 2 7 3 4 10 5 5 1 2\n", "output": "123\n"}, {"input": "10\n8 8 3 9 7 1 9 6 10 6 4 2 7 3 4 10 5 5 1 2\n", "output": "123\n"}, {"input": "9\n1 3 6 1 4 9 2 8 3 4 8 7 5 7 2 5 9 6\n", "output": "89\n"}, {"input": "9\n1 3 6 1 4 9 2 8 3 4 8 7 5 7 2 5 9 6\n", "output": "89\n"}, {"input": "...
code_stdio
[ { "content": "Everything is great about Ilya's city, except the roads. The thing is, the only ZooVille road is represented as n holes in a row. We will consider the holes numbered from 1 to n, from left to right.\n\nIlya is really keep on helping his city. So, he wants to fix at least k holes (perharps he can f...
[{"input": "3 3 3\n1 2 1000000000\n2 3 1000000000\n1 1 1000000000\n", "output": "2000000000\n"}, {"input": "10 7 1\n3 5 15\n8 9 8\n5 6 8\n9 10 6\n1 4 2\n1 4 10\n8 10 13\n", "output": "2\n"}, {"input": "10 7 1\n3 5 15\n8 9 8\n4 6 8\n9 10 6\n1 4 2\n1 4 10\n8 10 13\n", "output": "2\n"}, {"input": "10 7 1\n3 5 15\n8 9 8\n4...
code_stdio
[ { "content": "Example\n\nInput\n\n2 2 2 0 0 0 5\n\n\nOutput\n\n1 3 3 1 0\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": "2 2 4 1 0 1 35", "output": "1 4 6 4 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\n"}, {"input": "1 1 4 0 0 0 24", "output": "1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"input": "1 1 4 0 0 1 24", "output": "1 2 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n"}, {"input": "1 2 4 0 0 ...
code_stdio
[ { "content": "Fafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.\n\nFafa finds doing this every time is very tiring for him. So, he decided to ...
[{"input": "100000\n", "output": "35\n"}, {"input": "83160\n", "output": "127\n"}, {"input": "127925\n", "output": "23\n"}, {"input": "99999\n", "output": "11\n"}, {"input": "65536\n", "output": "16\n"}, {"input": "40320\n", "output": "95\n"}, {"input": "30030\n", "output": "63\n"}, {"input": "10000\n", "output": "24\n...
code_stdio
[ { "content": "A Madhav array has the following property:\n\n```a[0] = a[1] + a[2] = a[3] + a[4] + a[5] = a[6] + a[7] + a[8] + a[9] = ...```\n\nComplete the function/method that returns `true` if the given array is a Madhav array, otherwise it returns `false`.\n\n*Edge cases: An array of length* `0` *or* `1` *sh...
[{"input": "[6, 2, 4, 2, 2, 2, 1, 5, 0, 0, -12, 13, -5, 4, 1]", "output": "[false]", "fn_name": "is_madhav_array"}, {"input": "[6, 2, 4, 2, 2, 2, 1, 5, 0, 0, -12, 13, -5, 4, 6]", "output": "[true]", "fn_name": "is_madhav_array"}, {"input": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, -2, -1]", "output": "[true]", "fn_name"...
code_functional
[ { "content": "We have N integers A_1, A_2, ..., A_N.\nThere are \\frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?\n\n-----Constraints-----\n - All values in input are ...
[{"input": "30 413\n-170202098 -268409015 537203564 983211703 11883920 -443999067 -286607651 -159124657 -358352725 526800997 -1907718835 648738515 -1273635706 -1268616353 37909651 -1 1196187672 -20098238 0 -948955241 1 -214720580 287839163 -18897162 694477644 0 -425610555 158912296 842295515 0", "output": "546429541592...
code_stdio
[ { "content": "This is the easy version of the problem. The only difference is that in this version k = 0.\n\nThere is an array a_1, a_2, …, a_n of n positive integers. You should divide it into a minimal number of continuous segments, such that in each segment there are no two numbers (on different positions), ...
[{"input": "2\n14 0\n1 16 1 81 1 36 1 1024 1 1000000 1 1048576 1 4194304\n14 0\n1 16 1 112 1 36 1 1024 1 1000000 1 1048576 1 4194304\n", "output": "14\n13\n"}, {"input": "2\n14 0\n2 16 1 81 1 36 1 1024 1 1000000 1 1048576 1 4194304\n14 0\n1 16 1 112 1 36 1 1024 1 1000000 1 1048576 1 4194304\n", "output": "13\n13\n"}, {...
code_stdio
[ { "content": "After a long journey, the super-space-time immigrant ship carrying you finally discovered a planet that seems to be habitable. The planet, named JOI, is a harsh planet with three types of terrain, \"Jungle,\" \"Ocean,\" and \"Ice,\" as the name implies. A simple survey created a map of the area ar...
[{"input": "4 7\n4\nJIOJOIJ\nIJIOJOO\nJOIJOOI\nOOJJIJO\n5 7 0 7\n2 2 3 0\n2 3 2 2\n1 1 0 7", "output": "-1 -2 -1\n-1 0 -1\n0 0 0\n0 0 0\n"}, {"input": "4 7\n4\nJIOJOIJ\nIJIOJOO\nJOIJOOI\nOOJJIJO\n5 2 0 7\n2 2 2 0\n2 3 2 2\n1 1 0 7", "output": "-8 -10 -6\n0 0 -1\n0 0 0\n0 0 0\n"}, {"input": "4 7\n4\nJIOJOIJ\nOJIOJOI\nJO...
code_stdio
[ { "content": "## Check Digits\n\nSome numbers are more important to get right during data entry than others: a common example is product codes.\n\nTo reduce the possibility of mistakes, product codes can be crafted in such a way that simple errors are detected. This is done by calculating a single-digit value b...
[{"input": "\"9735597355\"", "output": "[\"97355973550\"]", "fn_name": "add_check_digit"}, {"input": "\"111111111\"", "output": "[\"1111111118\"]", "fn_name": "add_check_digit"}, {"input": "\"12388878\"", "output": "[\"123888782\"]", "fn_name": "add_check_digit"}, {"input": "\"036532\"", "output": "[\"0365327\"]", "fn_...
code_functional
[ { "content": "Given an integer x, find 2 integers a and b such that: \n\n * 1 ≤ a,b ≤ x \n * b divides a (a is divisible by b). \n * a ⋅ b>x. \n * a/b<x. \n\nInput\n\nThe only line contains the integer x (1 ≤ x ≤ 100).\n\nOutput\n\nYou should output two integers a and b, satisfying the given conditions, sep...
[{"input": "100\n", "output": "11 11\n"}, {"input": "82\n", "output": "10 10\n"}, {"input": "92\n", "output": "10 10\n"}, {"input": "90\n", "output": "10 10\n"}, {"input": "86\n", "output": "10 10\n"}, {"input": "98\n", "output": "10 10\n"}, {"input": "87\n", "output": "10 10\n"}, {"input": "85\n", "output": "10 10\n"}...
code_stdio
[ { "content": "You have three tasks, all of which need to be completed.\nFirst, you can complete any one task at cost 0.\nThen, just after completing the i-th task, you can complete the j-th task at cost |A_j - A_i|.\nHere, |x| denotes the absolute value of x.\nFind the minimum total cost required to complete al...
[{"input": "100 100 000", "output": "100\n"}, {"input": "100 111 000", "output": "111\n"}, {"input": "100 111 001", "output": "110\n"}, {"input": "100 111 010", "output": "101\n"}, {"input": "110 001 010", "output": "109\n"}, {"input": "100 000 000", "output": "100\n"}, {"input": "100 100 100\n", "output": "0\n"}, {"in...
code_stdio
[ { "content": "Joisino is working as a receptionist at a theater.\nThe theater has 100000 seats, numbered from 1 to 100000.\nAccording to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).\nHow many people are sitting at the ...
[{"input": "2\n151 -2\n0 4", "output": "-147\n"}, {"input": "2\n276 -2\n0 4", "output": "-272\n"}, {"input": "2\n276 -1\n0 4", "output": "-271\n"}, {"input": "2\n276 -1\n0 7", "output": "-268\n"}, {"input": "2\n276 -2\n0 7", "output": "-269\n"}, {"input": "2\n331 -1\n0 7", "output": "-323\n"}, {"input": "2\n331 -1\n0 3...
code_stdio
[ { "content": "`late_clock` function receive an array with 4 digits and should return the latest time that can be built with those digits.\nThe time should be in `HH:MM` format.\n\nExamples:\n```\n[1, 9, 8, 3] => 19:38\n[9, 1, 2, 5] => 21:59\n```\n\nYou can suppose the input is correct and you can build from it ...
[{"input": "[9, 1, 2, 5]", "output": "[\"21:59\"]", "fn_name": "late_clock"}, {"input": "[1, 9, 8, 3]", "output": "[\"19:38\"]", "fn_name": "late_clock"}, {"input": "[0, 2, 2, 2]", "output": "[\"22:20\"]", "fn_name": "late_clock"}, {"input": "[3, 5, 0, 2]", "output": "[\"23:50\"]", "fn_name": "late_clock"}, {"input": "...
code_functional
[ { "content": "There is a beautiful garden of stones in Innopolis.\n\nIts most beautiful place is the $n$ piles with stones numbered from $1$ to $n$.\n\nEJOI participants have visited this place twice. \n\nWhen they first visited it, the number of stones in piles was $x_1, x_2, \\ldots, x_n$, correspondingly. On...
[{"input": "50\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100...
code_stdio
[ { "content": "There are N stones arranged in a row. The i-th stone from the left is painted in the color C_i.\n\nSnuke will perform the following operation zero or more times:\n\n* Choose two stones painted in the same color. Repaint all the stones between them, with the color of the chosen stones.\n\n\n\nFind ...
[{"input": "7\n1\n2\n10\n2\n1\n6\n2", "output": "5\n"}, {"input": "7\n1\n2\n1\n2\n3\n3\n2", "output": "6\n"}, {"input": "7\n1\n3\n1\n2\n1\n3\n2", "output": "7\n"}, {"input": "7\n1\n3\n1\n2\n4\n3\n2", "output": "5\n"}, {"input": "7\n1\n3\n1\n2\n2\n3\n2", "output": "5\n"}, {"input": "7\n1\n2\n2\n2\n3\n3\n2", "output": "2...
code_stdio
[ { "content": "Eugeny has array a = a_1, a_2, ..., a_{n}, consisting of n integers. Each integer a_{i} equals to -1, or to 1. Also, he has m queries: Query number i is given as a pair of integers l_{i}, r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n). The response to the query will be integer 1, if the elements of array a can b...
[{"input": "10 10\n-1 1 -1 1 -1 -1 -1 -1 -1 -1\n6 10\n4 5\n3 6\n2 3\n3 5\n4 5\n3 4\n1 7\n1 1\n1 1\n", "output": "0\n1\n1\n1\n0\n1\n1\n0\n0\n0\n"}, {"input": "10 10\n-1 1 -1 1 -1 -1 -1 -1 -1 -1\n6 13\n4 5\n3 6\n2 3\n0 5\n4 5\n3 4\n1 4\n1 1\n1 1\n", "output": "0\n1\n1\n1\n0\n1\n1\n1\n0\n0\n"}, {"input": "10 10\n-1 1 -1 1...
code_stdio
[ { "content": "After winning gold and silver in IOI 2014, Akshat and Malvika want to have some fun. Now they are playing a game on a grid made of n horizontal and m vertical sticks.\n\nAn intersection point is any point on the grid which is formed by the intersection of one horizontal stick and one vertical stic...
[{"input": "100 100\n", "output": "Malvika\n"}, {"input": "100 100\n", "output": "Malvika\n"}, {"input": "98 100\n", "output": "Malvika\n"}, {"input": "100 98\n", "output": "Malvika\n"}, {"input": "98 100\n", "output": "Malvika\n"}, {"input": "100 98\n", "output": "Malvika\n"}, {"input": "28 100\n", "output": "Malvika\...
code_stdio
[ { "content": "Read problems statements in Russian also. \nChef plays with the sequence of N numbers. During a single move Chef is able to choose a non-decreasing subsequence of the sequence and to remove it from the sequence. Help him to remove all the numbers in the minimal number of moves. \n\n------ Input --...
[{"input": "4\n20 -1 -2 -4", "output": "4\n"}, {"input": "4\n0 -2 6 10", "output": "2\n"}, {"input": "4\n1 -2 6 10", "output": "2\n"}, {"input": "4\n2 -2 6 10", "output": "2\n"}, {"input": "4\n4 -2 6 10", "output": "2\n"}, {"input": "4\n2 -1 6 10", "output": "2\n"}, {"input": "4\n0 -1 6 10", "output": "2\n"}, {"input":...
code_stdio
[ { "content": "Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.\n\nYou are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place ...
[{"input": "128982\n", "output": "17 16 15 14 13 11 10 9 8 7 5 3 2\n"}, {"input": "97205\n", "output": "17 15 14 13 12 10 9 8 6 5 3 1 \n"}, {"input": "97205\n", "output": "17 15 14 13 12 10 9 8 6 5 3 1\n"}, {"input": "32698\n", "output": "15 14 13 12 11 10 9 8 6 5 4 2\n"}, {"input": "97260\n", "output": "17 15 14 13 12...
code_stdio
[ { "content": "The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called \"Testing Pants for Sadness\".\n\nThe test consists of n questions; the questions are to be answered strictly in the order in which they are ...
[{"input": "50\n515844718 503470143 928669067 209884122 322869098 241621928 844696197 105586164 552680307 968792756 135928721 842094825 298782438 829020472 791637138 285482545 811025527 428952878 887796419 11883658 546401594 6272027 100292274 308219869 372132044 955814846 644008184 521195760 919389466 215065725 6877641...
code_stdio
[ { "content": "You are given $n$ strings $s_1, s_2, \\ldots, s_n$ consisting of lowercase Latin letters.\n\nIn one operation you can remove a character from a string $s_i$ and insert it to an arbitrary position in a string $s_j$ ($j$ may be equal to $i$). You may perform this operation any number of times. Is it...
[{"input": "4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc\n", "output": "YES\nNO\nYES\nNO\n"}, {"input": "4\n2\ncaa\ncbb\n3\ncba\ncba\ncbb\n4\nccab\ncbac\nbca\nacbcc\n4\nacb\ncaf\nc\ncbafc\n", "output": "YES\nNO\nYES\nNO\n"}, {"input": "1\n26\na\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\n...
code_stdio
[ { "content": "Naman has two binary strings $s$ and $t$ of length $n$ (a binary string is a string which only consists of the characters \"0\" and \"1\"). He wants to convert $s$ into $t$ using the following operation as few times as possible.\n\nIn one operation, he can choose any subsequence of $s$ and rotate ...
[{"input": "12\n011001010101\n111001010101\n", "output": "-1\n"}, {"input": "12\n011101010101\n101001010101\n", "output": "-1\n"}, {"input": "12\n011001010101\n111001010101\n", "output": "-1"}, {"input": "12\n011101010101\n111001010101\n", "output": "1\n"}, {"input": "10\n1010011110\n1011101101\n", "output": "-1\n"}, {...
code_stdio
[ { "content": "Leha is planning his journey from Moscow to Saratov. He hates trains, so he has decided to get from one city to another by car.\n\nThe path from Moscow to Saratov can be represented as a straight line (well, it's not that straight in reality, but in this problem we will consider it to be straight)...
[{"input": "100\n3 3 3 4 7 8 8 8 9 9 10 12 12 13 14 14 15 15 16 17 17 20 21 21 22 22 23 25 29 31 36 37 37 38 39 40 41 41 41 42 43 44 45 46 46 47 47 49 49 49 51 52 52 53 54 55 59 59 59 60 62 63 63 64 66 69 70 71 71 72 74 76 76 77 77 78 78 79 80 81 81 82 82 84 85 86 87 87 87 89 91 92 92 92 92 97 98 99 100 100\n", "output...
code_stdio
[ { "content": "Two friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x_1 = a, another one is in the point x_2 = b. \n\nEach of the friends can move by one along the line in any direction unlimited number of times. When a friend moves, the tiredness of a friend ...
[{"input": "864\n179\n", "output": "117649\n"}, {"input": "967\n102\n", "output": "187489\n"}, {"input": "967\n142\n", "output": "170569\n"}, {"input": "967\n282\n", "output": "117649\n"}, {"input": "944\n193\n", "output": "141376\n"}, {"input": "1\n1000\n", "output": "250000\n"}, {"input": "1000\n1\n", "output": "2500...
code_stdio
[ { "content": "Given are integer sequence of length N, A = (A_1, A_2, \\cdots, A_N), and an integer K.\nFor each X such that 1 \\le X \\le K, find the following value:\n\\left(\\displaystyle \\sum_{L=1}^{N-1} \\sum_{R=L+1}^{N} (A_L+A_R)^X\\right) \\bmod 998244353\n\n-----Constraints-----\n - All values in input ...
[{"input": "192 275\n426 445 272 81 447 129 497 202 275 325 482 284 417 156 432 402 228 37 357 239 418 211 179 6 340 68 368 16 440 263 93 449 491 310 355 68 431 80 257 218 434 328 176 355 221 80 422 45 11 67 467 174 191 4 335 34 465 480 221 395 1 152 325 231 302 153 396 22 489 399 107 466 432 2 468 333 475 292 84 10 19...
code_stdio
[ { "content": "The problem statement looms below, filling you with determination.\n\nConsider a grid in which some cells are empty and some cells are filled. Call a cell in this grid exitable if, starting at that cell, you can exit the grid by moving up and left through only empty cells. This includes the cell i...
[{"input": "3 3\nXX.\n...\n.XX\n10\n1 3\n1 3\n1 2\n1 2\n3 3\n1 3\n2 3\n3 3\n2 3\n2 2\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "3 3\n..X\nX.X\n..X\n10\n2 3\n2 2\n3 3\n1 3\n1 1\n3 3\n3 3\n1 1\n1 2\n1 1\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "3 ...
code_stdio
[ { "content": "There are $n$ beautiful skyscrapers in New York, the height of the $i$-th one is $h_i$. Today some villains have set on fire first $n - 1$ of them, and now the only safety building is $n$-th skyscraper.\n\nLet's call a jump from $i$-th skyscraper to $j$-th ($i < j$) discrete, if all skyscrapers be...
[{"input": "8\n7 2 5 5 1 2 5 2\n", "output": "4\n"}, {"input": "8\n7 2 5 5 1 2 2 2\n", "output": "5\n"}, {"input": "8\n7 2 5 5 2 2 5 2\n", "output": "4\n"}, {"input": "8\n4 3 5 5 1 2 5 2\n", "output": "4\n"}, {"input": "5\n110 1 100 1 100\n", "output": "2\n"}, {"input": "8\n7 2 5 5 3 2 5 2\n", "output": "3\n"}, {"input...
code_stdio
[ { "content": "Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game.\n\nRules of the game are very simple: at first number o...
[{"input": "100\n4 3\n3 4\n5 1\n2 5\n5 3\n1 5\n6 3\n2 4\n5 2\n2 6\n5 2\n1 5\n6 3\n1 5\n6 3\n3 4\n5 2\n1 5\n6 1\n1 5\n4 2\n3 5\n6 3\n2 6\n6 3\n1 4\n6 2\n3 4\n4 1\n3 6\n5 1\n2 4\n5 1\n3 4\n6 2\n3 5\n4 1\n2 6\n4 3\n2 6\n5 2\n3 6\n6 2\n3 5\n4 3\n1 5\n5 3\n3 6\n4 2\n3 4\n6 1\n3 4\n5 2\n2 6\n5 2\n2 4\n6 2\n3 6\n4 3\n2 4\n4 3...
code_stdio
[ { "content": "Kuro has just learned about permutations and he is really excited to create a new permutation type. He has chosen $n$ distinct positive integers and put all of them in a set $S$. Now he defines a magical permutation to be: A permutation of integers from $0$ to $2^x - 1$, where $x$ is a non-negativ...
[{"input": "69\n1034 414 632 614 62 855 915 385 1098 8 462 1750 1227 960 450 25 1307 578 37 262 482 1143 844 696 1004 1008 70 1137 509 1217 561 557 192 513 792 794 1335 1201 1290 543 698 55 119 536 1088 162 1074 676 246 457 662 595 1054 1252 778 165 703 1222 326 158 145 272 729 381 1087 1261 717 113 73\n", "output": "1...
code_stdio
[ { "content": "The Kingdom of Kremland is a tree (a connected undirected graph without cycles) consisting of $n$ vertices. Each vertex $i$ has its own value $a_i$. All vertices are connected in series by edges. Formally, for every $1 \\leq i < n$ there is an edge between the vertices of $i$ and $i+1$.\n\nDenote ...
[{"input": "44\n42 44 4 24 29 17 32 30 30 9 28 9 22 16 20 41 17 19 41 23 28 19 38 44 1 34 41 34 19 36 32 37 22 31 4 3 27 23 21 21 26 39 20 8\n", "output": "6926\n"}, {"input": "44\n42 44 4 24 29 17 32 30 30 9 28 9 22 16 20 41 17 19 41 23 28 19 38 44 1 34 41 34 19 36 32 37 22 31 4 3 27 23 21 21 26 39 20 8\n", "output": ...
code_stdio
[ { "content": "In 40XX, the Earth was invaded by aliens! Already most of the Earth has been dominated by aliens, leaving Tsuruga Castle Fortress as the only remaining defense base. Suppression units are approaching the Tsuruga Castle Fortress one after another.\n\n<image>\n\n\nBut hope remains. The ultimate defe...
[{"input": "110 5\n111 101 5 5\n110 110 2 3\n-112 -100 5 11\n-208 160 109 90\n-110 159 10 3\n26 11\n15 -1 5 2\n25 0 5 1\n35 0 5 1\n118 0 5 1\n55 0 5 1\n65 0 5 1\n149 -1 5 1\n169 0 1 1\n90 0 5 1\n-19 -1 5 20\n-30 0 500 5\n0 0", "output": "1\n4\n"}, {"input": "100 5\n111 101 5 5\n110 110 2 3\n-112 -100 5 11\n-208 160 109...
code_stdio
[ { "content": "There are n points on a straight line, and the i-th point among them is located at x_{i}. All these coordinates are distinct.\n\nDetermine the number m — the smallest number of points you should add on the line to make the distances between all neighboring points equal. \n\n\n-----Input-----\n\nTh...
[{"input": "10\n711183437 845779129 -106125616 -481773790 66231250 -183390793 -711197523 -196001897 -440633306 -873649505\n", "output": "156311685\n"}, {"input": "10\n711183437 845779129 -106125616 -481773790 66231250 -183390793 -711197523 -196001897 -440633306 -873649505\n", "output": "156311685\n"}, {"input": "7\n996...
code_stdio
[ { "content": "Your task is to return the number of visible dots on a die after it has been rolled(that means the total count of dots that would not be touching the table when rolled)\n\n6, 8, 10, 12, 20 sided dice are the possible inputs for \"numOfSides\" \n\ntopNum is equal to the number that is on top, or th...
[{"input": "19\n20", "output": "[208]", "fn_name": "totalAmountVisible"}, {"input": "15\n20", "output": "[204]", "fn_name": "totalAmountVisible"}, {"input": "6\n20", "output": "[195]", "fn_name": "totalAmountVisible"}, {"input": "8\n20", "output": "[197]", "fn_name": "totalAmountVisible"}, {"input": "12\n12", "output":...
code_functional
[ { "content": "There are N towns numbered 1 to N and M roads. The i-th road connects Town A_i and Town B_i bidirectionally and has a length of C_i.\nTakahashi will travel between these towns by car, passing through these roads. The fuel tank of his car can contain at most L liters of fuel, and one liter of fuel ...
[{"input": "5 4 0\n1 2 2\n3 5 2\n3 4 3\n4 5 2\n20\n2 1\n3 1\n3 1\n5 1\n1 2\n3 2\n4 2\n5 2\n1 3\n2 3\n4 3\n5 3\n1 4\n2 4\n3 4\n5 4\n1 5\n2 5\n3 5\n4 5", "output": "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n"}, {"input": "5 4 1\n1 2 2\n3 2 2\n3 4 1\n4 5 3\n20\n2 1\n3 1\n3 1\n5 1\n1 2...
code_stdio
[ { "content": "Write a program that, given a word, computes the scrabble score for that word.\n\n## Letter Values\n\nYou'll need these:\n\n```\nLetter Value\nA, E, I, O, U, L, N, R, S, T 1\nD, G 2\nB, C, M, P 3\nF, H, V, W, Y ...
[{"input": "\"MULTIBILLIONAIRE\"", "output": "[20]", "fn_name": "scrabble_score"}, {"input": "\"alacrity\"", "output": "[13]", "fn_name": "scrabble_score"}, {"input": "\"st re et\"", "output": "[6]", "fn_name": "scrabble_score"}, {"input": "\"quirky\"", "output": "[22]", "fn_name": "scrabble_score"}, {"input": "\"stree...
code_functional
[ { "content": "There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. \n\nHan Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0...
[{"input": "10 -4 -4\n2 -4\n2 0\n-4 2\n5 -4\n-3 -5\n1 4\n-4 2\n-3 5\n0 -3\n2 4\n", "output": "8\n"}, {"input": "10 -4 -4\n2 -4\n2 0\n-4 2\n5 -4\n-3 -5\n1 4\n-4 2\n-3 5\n0 -3\n2 4\n", "output": "8\n"}, {"input": "10 -4 -4\n1 -4\n2 0\n-4 2\n5 -4\n-3 -5\n1 4\n-4 2\n-3 5\n0 -3\n2 4\n", "output": "8\n"}, {"input": "10 -4 -4...
code_stdio
[ { "content": "Hanh lives in a shared apartment. There are $n$ people (including Hanh) living there, each has a private fridge. \n\n$n$ fridges are secured by several steel chains. Each steel chain connects two different fridges and is protected by a digital lock. The owner of a fridge knows passcodes of all cha...
[{"input": "10\n10 10\n8 9 2 10 3 8 10 9 1 10\n10 10\n3 10 3 13 12 14 3 3 4 4\n10 5\n7 13 10 14 5 12 5 5 7 11\n10 10\n12 13 3 6 12 9 6 6 5 7\n10 10\n4 10 15 13 13 15 9 8 8 14\n10 10\n2 3 8 5 9 7 11 12 7 9\n10 10\n12 15 11 10 1 8 10 3 4 2\n10 5\n8 11 7 14 7 9 5 2 8 9\n10 10\n4 9 9 9 10 4 1 12 13 15\n10 10\n12 2 7 5 15 8...
code_stdio
[ { "content": "While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 2016 Robot Rap Battle Tournament, she notices th...
[{"input": "13 78\n10 2\n6 5\n5 7\n10 3\n6 13\n4 7\n4 13\n1 12\n13 2\n1 7\n10 5\n10 13\n12 2\n10 6\n5 3\n10 8\n9 11\n6 1\n4 5\n12 3\n6 7\n8 2\n1 9\n4 11\n5 8\n6 3\n9 5\n5 2\n13 11\n10 4\n12 7\n5 13\n12 8\n10 12\n6 12\n5 11\n1 8\n7 8\n12 4\n10 7\n1 5\n1 2\n10 11\n2 11\n12 13\n9 7\n8 3\n12 9\n9 2\n6 9\n10 9\n7 11\n12 5\n...
code_stdio
[ { "content": "It is September 9 in Japan now.\nYou are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?\n\n-----Constraints-----\n - 10≤N≤99\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n-----Output-----\nIf 9 is contained in ...
[{"input": "29\n", "output": "Yes\n"}, {"input": "91\n", "output": "Yes\n"}, {"input": "929", "output": "Yes\n"}, {"input": "109", "output": "Yes\n"}, {"input": "189", "output": "Yes\n"}, {"input": "1223", "output": "No\n"}, {"input": "72\n", "output": "No\n"}, {"input": "69", "output": "Yes\n"}, {"input": "115", "outp...
code_stdio
[ { "content": "You are given two binary strings $a$ and $b$ of the same length. You can perform the following two operations on the string $a$:\n\n Swap any two bits at indices $i$ and $j$ respectively ($1 \\le i, j \\le n$), the cost of this operation is $|i - j|$, that is, the absolute difference between $i$ ...
[{"input": "91\n0010010000110001001011011011111001000110001000100111110010010001100110010111100111011111100\n1101110110000100110000100011010110111101100000011011100111111000110000001101101111100100101\n", "output": "43\n"}, {"input": "91\n001001000011000100101101101111100100011000100010011111001001000110011001011110011...
code_stdio
[ { "content": "Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the track of everything.\n\nDuring an audit, you were surpri...
[{"input": "111\n15 45 14 65 49 25 102 86 14 80 54 73 43 78 42 32 47 60 55 66 84 69 49 22 26 72 89 52 26 80 71 35 56 2 88 23 23 53 65 92 46 73 29 65 88 99 19 99 87 10 47 96 109 20 60 89 63 105 29 92 109 20 95 65 31 89 107 3 3 50 58 9 28 39 104 42 41 36 70 49 59 96 16 9 3 108 38 42 2 67 32 86 20 6 101 70 101 91 38 10 74...
code_stdio
[ { "content": "Santosh has a farm at Byteland. He has a very big family to look after. His life takes a sudden turn and he runs into a financial crisis. After giving all the money he has in his hand, he decides to sell his plots. The speciality of his land is that it is rectangular in nature. Santosh comes to k...
[{"input": "2\n15 28\n13 1", "output": "420\n13\n"}, {"input": "2\n11 28\n13 1", "output": "308\n13\n"}, {"input": "2\n11 28\n12 1", "output": "308\n12\n"}, {"input": "2\n11 51\n12 1", "output": "561\n12\n"}, {"input": "2\n18 51\n12 1", "output": "102\n12\n"}, {"input": "2\n18 55\n12 1", "output": "990\n12\n"}, {"input...
code_stdio
[ { "content": "Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a \"Double Cola\" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue...
[{"input": "0000011000\n", "output": "Sheldon\n"}, {"input": "381237714\n", "output": "Sheldon\n"}, {"input": "872651351\n", "output": "Leonard\n"}, {"input": "347025213\n", "output": "Sheldon\n"}, {"input": "425568842\n", "output": "Leonard\n"}, {"input": "758393876\n", "output": "Sheldon\n"}, {"input": "215431553\n",...
code_stdio
[ { "content": "Alperen has two strings, $s$ and $t$ which are both initially equal to \"a\".\n\nHe will perform $q$ operations of two types on the given strings:\n\n$1 \\;\\; k \\;\\; x$ — Append the string $x$ exactly $k$ times at the end of string $s$. In other words, $s := s + \\underbrace{x + \\dots + x}_{k ...
[{"input": "3\n5\n2 1 aa\n1 2 a\n2 3 a\n1 2 b\n2 3 abca\n2\n1 5 mihai\n2 2 buiucani\n3\n1 5 b\n2 3 a\n2 4 paiu\n", "output": "YES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nYES\n"}, {"input": "1\n8\n2 7 z\n1 2 xpt\n2 5 aosu\n2 3 veel\n1 3 dnx\n1 8 tgly\n2 5 rqlmvchcir\n1 10 qklu\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYE...
code_stdio
[ { "content": "You are given two arrays A and B consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose k numbers in array A and choose m numbers in array B so that any number chosen in the first array is strictly less than any number chosen in the second array.\n\n\n-----I...
[{"input": "20 30\n19 29\n2 1 2 2 3 3 4 4 7 7 7 9 8 8 8 8 1 0 9 10\n6 9 9 7 9 9 9 9 5 9 9 9 9 18 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10\n", "output": "NO\n"}, {"input": "20 30\n19 29\n2 1 2 2 2 3 4 4 7 10 7 8 8 8 8 8 9 9 9 9\n6 9 9 9 9 9 9 9 9 9 9 9 9 18 9 9 10 10 10 10 10 10 10 10 10 10 10 10 10 10\n", "output"...
code_stdio
[ { "content": "There are N children standing in a line from left to right. The activeness of the i-th child from the left is A_i.\nYou can rearrange these children just one time in any order you like.\nWhen a child who originally occupies the x-th position from the left in the line moves to the y-th position fro...
[{"input": "2000\n919697266 557620328 306200382 938985256 815342630 163392675 302065984 171634774 595091891 878051152 45556321 599365418 836259090 519017787 53355189 239963918 892242532 41911517 32213197 241306129 182967761 735538395 277915827 947333936 397686688 951038946 390763995 565454633 980862050 263983172 856918...
code_stdio
[ { "content": "A binary search tree can be unbalanced depending on features of data. For example, if we insert $n$ elements into a binary search tree in ascending order, the tree become a list, leading to long search times. One of strategies is to randomly shuffle the elements to be inserted. However, we should ...
[{"input": "16\ninsert 21 99\ninsert 3 80\ninsert 1 12\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 141 47\ninsert 26 6\ninsert 12 10\ninsert 6 139\nprint\nfind 21\nfind 22\ndelete 35\ndelete 99\nprint", "output": " 1 3 6 12 14 21 26 42 80 141\n 6 3 1 21 14 12 80 26 42 141\nyes\nno\n 1 3 6 12 14 21 26 42 80 141\n 6...
code_stdio
[ { "content": "One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of n non-negative integers.\n\nIf there are exactly K distinct values in the array, the...
[{"input": "50 20\n592183311 362557946 154127088 616872926 395353745 675069471 509655682 79915471 356656666 937992998 304422065 724106263 472338455 792258113 796069631 1325917135 201799298 566151622 722278085 827802227 703159587 690854023 925377265 11010958 69791159 990158269 535460930 167415727 999216963 237203826 693...
code_stdio
[ { "content": "There are N squares aligned in a row. The i-th square from the left contains an integer a_i.\n\nInitially, all the squares are white. Snuke will perform the following operation some number of times:\n\n* Select K consecutive squares. Then, paint all of them white, or paint all of them black. Here,...
[{"input": "10 5\n5 -4 -5 -16 -4 0 2 -4 -1 3", "output": "10\n"}, {"input": "10 5\n6 -4 -5 -16 -4 0 2 -4 -1 3", "output": "11\n"}, {"input": "10 5\n6 -4 -5 -16 -4 0 2 -4 -2 3", "output": "11\n"}, {"input": "10 5\n5 -4 -5 -8 -4 7 2 -4 0 14", "output": "24\n"}, {"input": "10 5\n5 -4 -5 -16 -4 0 1 -4 -1 3", "output": "9\n...
code_stdio
[ { "content": "One common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of $n$ non-negative integers.\n\nIf there are exactly $K$ distinct values in the array,...
[{"input": "50 20\n592183311 362557946 154127088 616872926 395353745 675069471 509655682 79915471 356656666 937992998 304422065 724106263 472338455 792258113 796069631 663370025 201799298 566151622 722278085 508905399 703159587 690854023 925377265 11010958 69791159 990158269 535460930 167415727 999216963 237203826 6939...
code_stdio
[ { "content": "The integers 14 and 15, are contiguous (1 the difference between them, obvious) and have the same number of divisors.\n```python\n14 ----> 1, 2, 7, 14 (4 divisors)\n15 ----> 1, 3, 5, 15 (4 divisors)\n```\nThe next pair of contiguous integers with this property is 21 and 22.\n```python\n21 -----> 1...
[{"input": "11\n5000", "output": "[567]", "fn_name": "count_pairs_int"}, {"input": "6\n1000", "output": "[214]", "fn_name": "count_pairs_int"}, {"input": "7\n1500", "output": "[189]", "fn_name": "count_pairs_int"}, {"input": "7\n2500", "output": "[309]", "fn_name": "count_pairs_int"}, {"input": "7\n3000", "output": "[3...
code_functional
[ { "content": "There is a graph of $n$ rows and $10^6 + 2$ columns, where rows are numbered from $1$ to $n$ and columns from $0$ to $10^6 + 1$:\n\nLet's denote the node in the row $i$ and column $j$ by $(i, j)$.\n\nInitially for each $i$ the $i$-th row has exactly one obstacle — at node $(i, a_i)$. You want to m...
[{"input": "4\n2 3 1\n999999 1000000\n2 3 2\n999999 1000000\n2 3 1\n1000000 1584412\n2 3 1\n100 1000000\n", "output": "1\n2\n0\n0\n"}, {"input": "4\n2 3 1\n285716 1000000\n2 3 2\n999999 1000000\n2 3 1\n1000000 1584412\n2 3 1\n100 1000000\n", "output": "0\n2\n0\n0\n"}, {"input": "4\n2 3 1\n999999 1000000\n2 3 2\n999999 ...
code_stdio
[ { "content": "Some large corporation where Polycarpus works has its own short message service center (SMSC). The center's task is to send all sorts of crucial information. Polycarpus decided to check the efficiency of the SMSC. \n\nFor that, he asked to give him the statistics of the performance of the SMSC for...
[{"input": "40\n313 97063\n372 23668\n377 56079\n428 88458\n435 57330\n454 88869\n456 75553\n466 87607\n468 4542\n469 30243\n471 8958\n472 59745\n473 90985\n474 32247\n475 71576\n476 14016\n477 91574\n478 38345\n479 93280\n480 89902\n481 41828\n482 3233\n483 66725\n484 23523\n485 46772\n486 95688\n487 19864\n488 10295\...
code_stdio
[ { "content": "Let's denote a function \n\n$d(x, y) = \\left\\{\\begin{array}{ll}{y - x,} & {\\text{if}|x - y|> 1} \\\\{0,} & {\\text{if}|x - y|\\leq 1} \\end{array} \\right.$\n\nYou are given an array a consisting of n integers. You have to calculate the sum of d(a_{i}, a_{j}) over all pairs (i, j) such that 1 ...
[{"input": "100\n591 417 888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983 526 103 500 963 400 23 276 704 570 757 410 658 507 620 984 244 486 ...
code_stdio
[ { "content": "The Berland University is preparing to celebrate the 256-th anniversary of its founding! A specially appointed Vice Rector for the celebration prepares to decorate the campus. In the center of the campus n ice sculptures were erected. The sculptures are arranged in a circle at equal distances from...
[{"input": "97\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 -1 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 -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\n", "output": "-1\n"}, {"input": "97\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 -1 -...
code_stdio
[ { "content": "Iahub got bored, so he invented a game to be played on paper. \n\nHe writes n integers a_1, a_2, ..., a_{n}. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j (1 ≤ i ≤ j ≤ n) and flips all values a_{k} for which their positions are in ...
[{"input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "100\n"}, {"input": "100\n0 1 0 1 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 1 1 1 1 1 1 0 0 1 1 1 0 1...
code_stdio
[ { "content": "Takahashi is drawing a segment on grid paper.\n\nFrom a certain square, a square that is x squares to the right and y squares above, is denoted as square (x, y).\n\nWhen Takahashi draws a segment connecting the lower left corner of square (A, B) and the lower left corner of square (C, D), find the...
[{"input": "124 -2 -1 -1", "output": "125\n"}, {"input": "241 -2 -1 -1", "output": "242\n"}, {"input": "121 -1 -1 0", "output": "122\n"}, {"input": "116 1 -2 -1", "output": "118\n"}, {"input": "209 -1 -1 0", "output": "210\n"}, {"input": "116 1 -2 -2", "output": "120\n"}, {"input": "124 1 1 -2", "output": "123\n"}, {"i...
code_stdio
[ { "content": "In genetics a reading frame is a way to divide a sequence of nucleotides (DNA bases) into a set of consecutive non-overlapping triplets (also called codon). Each of this triplets is translated into an amino-acid during a translation process to create proteins.\n\nIn a single strand of DNA you find...
[{"input": "\"AGGTGACACCGCAAGCCTTATATTAGC\"", "output": "[[\"R*HRKPYIS\", \"GDTASLIL\", \"VTPQALY*\", \"ANIRLAVSP\", \"LI*GLRCH\", \"*YKACGVT\"]]", "fn_name": "translate_with_frame"}, {"input": "\"AGGTGACACCGCAAGCCTTATATTAGC\"\n[1, 2]", "output": "[[\"R*HRKPYIS\", \"GDTASLIL\"]]", "fn_name": "translate_with_frame"}, {"...
code_functional
[ { "content": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nOne day Petya was delivered a string s, containing only digits. He needs to ...
[{"input": "00000000000000000000000000000000000000000000000000\n", "output": "-1\n"}, {"input": "110996812575168252737244204200508745829735318381381\n", "output": "7\n"}, {"input": "122094830270541438292052920866473330280784608392695\n", "output": "4\n"}, {"input": "00000000000000000000000000000100000000000000000000\n"...
code_stdio
[ { "content": "There are $n$ students in a university. The number of students is even. The $i$-th student has programming skill equal to $a_i$. \n\nThe coach wants to form $\\frac{n}{2}$ teams. Each team should consist of exactly two students, and each student should belong to exactly one team. Two students can ...
[{"input": "100\n1 1 100 100 1 100 1 1 1 1 1 1 100 1 100 100 100 1 1 100 100 100 100 100 1 100 1 100 1 1 1 100 1 1 100 1 100 1 1 1 100 100 1 1 1 100 100 100 100 100 1 100 100 1 1 1 1 100 1 1 100 1 1 1 1 100 100 100 1 100 1 100 100 100 1 1 100 100 100 100 1 100 1 100 100 1 100 1 100 100 100 100 100 100 1 1 1 100 100 1\n...
code_stdio
[ { "content": "Inaka has a disc, the circumference of which is $n$ units. The circumference is equally divided by $n$ points numbered clockwise from $1$ to $n$, such that points $i$ and $i + 1$ ($1 \\leq i < n$) are adjacent, and so are points $n$ and $1$.\n\nThere are $m$ straight segments on the disc, the endp...
[{"input": "30000 28\n10601 1119\n11119 20601\n9493 25771\n14351 4869\n13101 3619\n23101 13619\n29869 9351\n6119 15601\n3101 23619\n1851 22369\n11851 2369\n8619 18101\n19579 20882\n18619 28101\n16851 7369\n8101 28619\n24869 4351\n24351 14869\n27369 6851\n9869 19351\n5601 26119\n3976 21301\n21851 12369\n25601 16119\n244...
code_stdio
[ { "content": "You got a box with a combination lock. The lock has a display showing n digits. There are two buttons on the box, each button changes digits on the display. You have quickly discovered that the first button adds 1 to all the digits (all digits 9 become digits 0), and the second button shifts all t...
[{"input": "200\n79025531557298703099245700860027432585447902553155729870309924570086002743258544790255315572987030992457008600274325854479025531557298703099245700860027432585447902553155729870309924570086002743258544\n", "output": "002743258544790255315572987030992457008600274325854479025531557298703099245700860027432...
code_stdio
[ { "content": "A histogram is made of a number of contiguous bars, which have same width.\n\nFor a given histogram with $N$ bars which have a width of 1 and a height of $h_i$ = $h_1, h_2, ... , h_N$ respectively, find the area of the largest rectangular area.\n\nConstraints\n\n* $1 \\leq N \\leq 10^5$\n* $0 \\le...
[{"input": "8\n1 20 9 13 4 10 1 26", "output": "27\n"}, {"input": "8\n1 36 9 13 4 10 1 26", "output": "36\n"}, {"input": "8\n1 36 9 13 4 10 1 38", "output": "38\n"}, {"input": "8\n1 20 3 13 4 7 1 26", "output": "26\n"}, {"input": "8\n5 13 10 10 1 2 0 2", "output": "30\n"}, {"input": "8\n5 13 15 19 0 2 0 2", "output": "...
code_stdio
[ { "content": "Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.\n\nEach apple weights 100 grams or 200 grams. Of course Kitahara Haruki doesn't want to offend any of his friend. Therefore the total weight of the apples given to Tou...
[{"input": "100\n200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200 200...
code_stdio
[ { "content": "# Introduction \n\nDigital Cypher assigns a unique number to each letter of the alphabet:\n\n```\n a b c d e f g h i j k l m n o p q r s t u v w x y z\n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26\n```\n\nIn the encrypted word we write the ...
[{"input": "\"notencrypted\"\n[14, 15, 20, 5, 14, 3, 18, 25, 16, 20, 5, 4]", "output": "[0]", "fn_name": "find_the_key"}, {"input": "\"masterpiece\"\n[14, 10, 22, 29, 6, 27, 19, 18, 6, 12, 8]", "output": "[1939]", "fn_name": "find_the_key"}, {"input": "\"tenthousand\"\n[21, 5, 14, 20, 8, 16, 21, 19, 1, 14, 5]", "output...
code_functional
[ { "content": "There are n walruses sitting in a circle. All of them are numbered in the clockwise order: the walrus number 2 sits to the left of the walrus number 1, the walrus number 3 sits to the left of the walrus number 2, ..., the walrus number 1 sits to the left of the walrus number n.\n\nThe presenter ha...
[{"input": "32 10540\n", "output": "12\n"}, {"input": "84 10000\n", "output": "10\n"}, {"input": "37 25195\n", "output": "29\n"}, {"input": "123 1008\n", "output": "18\n"}, {"input": "75 10000\n", "output": "19\n"}, {"input": "26 10010\n", "output": "11\n"}, {"input": "50 10000\n", "output": "40"}, {"input": "57 6218\n...
code_stdio
[ { "content": "Problem statement\n\nCards with ranks of $ 2 $ and $ 8 $ are powerful in card game millionaires. Therefore, we call an integer consisting of only the numbers $ 2 $ and $ 8 $ in $ 10 $ decimal notation a good integer. The best integers are listed from the smallest to $ 2, 8, 22, 28, 82, 88, \\ cdot...
[{"input": "-104", "output": "-1\n"}, {"input": "-102", "output": "-1\n"}, {"input": "-118", "output": "-1\n"}, {"input": "-114", "output": "-1\n"}, {"input": "-206", "output": "-1\n"}, {"input": "-168", "output": "-1\n"}, {"input": "-101", "output": "-1\n"}, {"input": "-109", "output": "-1\n"}, {"input": "-106", "outp...
code_stdio
[ { "content": "Given an array $A_1, A_2, ..., A_N$, count the number of subarrays of array $A$ which are non-decreasing.\n\nA subarray $A[i, j]$, where $1 ≤ i ≤ j ≤ N$ is a sequence of integers $A_i, A_i+1, ..., A_j$.\nA subarray $A[i, j]$ is non-decreasing if $A_i ≤ A_i+1 ≤ A_i+2 ≤ ... ≤ A_j$. You have to count...
[{"input": "2\n4\n-1 1 2 2\n1\n4", "output": "10\n1\n"}, {"input": "2\n4\n1 2 2 3\n1\n5", "output": "10\n1\n"}, {"input": "2\n4\n1 2 2 3\n1\n2", "output": "10\n1\n"}, {"input": "2\n4\n2 13 0 2\n1\n4", "output": "6\n1\n"}, {"input": "2\n4\n2 2 2 3\n1\n2", "output": "10\n1\n"}, {"input": "2\n4\n0 1 2 2\n1\n4", "output": ...
code_stdio
[ { "content": "Monocarp is playing a game \"Assimilation IV\". In this game he manages a great empire: builds cities and conquers new lands.\n\nMonocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur,...
[{"input": "3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3\n", "output": "\n166374062\n"}, {"input": "3 5\n1 4 4 3 4\n1 4 1 4 2\n1 4 4 4 3\n", "output": "166374062\n"}, {"input": "3 5\n1 4 4 3 4\n1 4 2 4 2\n1 4 4 4 3\n", "output": "831870297\n"}, {"input": "3 5\n1 4 4 3 4\n1 4 2 4 2\n1 3 4 4 3\n", "output": "166374062\n"}, {"inp...
code_stdio
[ { "content": "You are given two set of points. The first set is determined by the equation A1x + B1y + C1 = 0, and the second one is determined by the equation A2x + B2y + C2 = 0.\n\nWrite the program which finds the number of points in the intersection of two given sets.\n\nInput\n\nThe first line of the input...
[{"input": "100 100 100\n-100 100 -100\n", "output": "1"}, {"input": "12 -32 89\n0 67 -23\n", "output": "1"}, {"input": "-1 1 -1\n-1 1 -1\n", "output": "-1\n"}, {"input": "0 -1 -1\n-1 -1 -1\n", "output": "1\n"}, {"input": "-1 -1 0\n-1 -1 -1\n", "output": "0\n"}, {"input": "0 -1 -1\n-2 -1 -1\n", "output": "1\n"}, {"inpu...
code_stdio
[ { "content": "The legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are hungry, so he instructs his cow Bessie to bring out the snacks! Moo!\n\nThere are $n$ snacks flavors, numbered with integers $1, 2, \\ldots, n$. Bessie has $n$ snack...
[{"input": "100000 12\n8 11\n1 9\n5 4\n11 12\n7 11\n3 4\n6 5\n12 15\n15 13\n13 14\n7 11\n11 14\n", "output": "2\n"}, {"input": "100000 12\n8 10\n1 9\n5 4\n11 12\n7 11\n3 4\n3 5\n12 15\n15 13\n13 14\n7 8\n11 14\n", "output": "2\n"}, {"input": "100000 12\n8 11\n1 9\n5 4\n11 12\n7 11\n3 4\n3 5\n12 15\n15 13\n13 14\n7 8\n1...
code_stdio
[ { "content": "problem\n\nAOR Ika is at the $ S $ th bus stop at time $ 0 $ and wants to go from there to the $ G $ th bus stop. The number of bus stops $ N $ and $ M $ routes (*) connecting different bus stops are given. The bus stops are numbered $ 1, \\ dots, and N $, respectively. Each route consists of $ 4 ...
[{"input": "2 2 1 2\n1 2 16 110\n2 2 7 1526", "output": "16\n"}, {"input": "2 1 1 2\n1 2 12 100\n1 -1 5 500", "output": "12\n"}, {"input": "2 2 1 2\n1 2 19 110\n2 2 7 1526", "output": "19\n"}, {"input": "2 2 1 2\n1 2 19 010\n2 2 7 1526", "output": "19\n"}, {"input": "2 2 1 2\n1 2 19 110\n2 2 3 1526", "output": "19\n"},...
code_stdio
[ { "content": "A fraction whose numerator is 1 and whose denominator is a positive integer is called a unit fraction. A representation of a positive rational number p/q as the sum of finitely many unit fractions is called a partition of p/q into unit fractions. For example, 1/2 + 1/6 is a partition of 2/3 into u...
[{"input": "2 3 120 3\n2 3 300 3\n2 3 299 3\n2 3 12 3\n2 3 12000 7\n54 1343 12000 7\n2 3 300 1\n2 1 200 5\n2 4 54 2\n0 0 0 0", "output": "4\n7\n6\n2\n42\n0\n0\n9\n3\n"}, {"input": "2 3 120 3\n2 3 300 3\n2 3 299 3\n2 3 12 3\n2 3 12000 7\n54 795 12000 7\n2 4 300 1\n2 1 200 5\n2 4 54 2\n0 0 0 0", "output": "4\n7\n6\n2\n42...
code_stdio
[ { "content": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. HW characters from A_{11} to A_{HW} represent the colors of the squares. A_{ij} is `#` if the square at the i-th row from the top and the j-th column from the left is black, ...
[{"input": "6 6\n..#..#\n......\n..#..\n......\n.#....\n-...#.", "output": "3\n"}, {"input": "2 6\n#.#...\n......\n..#0.\n......\n.#.-..\n--..#-", "output": "4\n"}, {"input": "6 6\n..#..#\n......\n..#..\n......\n.#....\n../.#.", "output": "3\n"}, {"input": "6 6\n..#..#\n......\n..#..\n......\n.#....\n-..-#.", "output":...
code_stdio
[ { "content": "There are $n$ candies in a row, they are numbered from left to right from $1$ to $n$. The size of the $i$-th candy is $a_i$.\n\nAlice and Bob play an interesting and tasty game: they eat candy. Alice will eat candy from left to right, and Bob — from right to left. The game ends if all the candies ...
[{"input": "7\n11\n3 1 4 1 5 9 1 4 10 3 5\n1\n1000\n3\n1 2 1\n13\n1 2 3 4 5 6 7 8 9 10 11 12 13\n2\n2 1\n6\n1 1 1 1 1 2\n7\n1 2 1 1 1 1 1\n", "output": "6 23 23\n1 1000 0\n2 1 3\n6 45 46\n2 2 1\n4 4 3\n4 4 4\n"}, {"input": "7\n11\n3 1 4 2 5 9 1 4 10 3 5\n1\n1000\n3\n1 2 1\n13\n1 2 3 4 5 6 7 8 9 10 11 12 13\n2\n2 1\n6\n...
code_stdio
[ { "content": "One day Alice visited Byteland to purchase jewels for her upcoming wedding anniversary.\nIn Byteland, every Jewelry shop has their own discount methods to attract the customers. One discount method called Buy1-Get1 caught Alice's attention. That is, Alice buys one jewel, then she can get one addit...
[{"input": "4\nssss\nrsas\nsa\ns", "output": "2\n3\n2\n1\n"}, {"input": "4\ntsss\nsasr\nas\nt", "output": "3\n3\n2\n1\n"}, {"input": "4\nssss\natrs\nat\nt", "output": "2\n4\n2\n1\n"}, {"input": "4\nrsss\natsr\nbt\nt", "output": "3\n4\n2\n1\n"}, {"input": "4\nrstq\narsr\nra\nt", "output": "4\n3\n2\n1\n"}, {"input": "4\n...
code_stdio
[ { "content": "Ivan has got an array of n non-negative integers a_1, a_2, ..., a_{n}. Ivan knows that the array is sorted in the non-decreasing order. \n\nIvan wrote out integers 2^{a}_1, 2^{a}_2, ..., 2^{a}_{n} on a piece of paper. Now he wonders, what minimum number of integers of form 2^{b} (b ≥ 0) need to be...
[{"input": "26\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "5\n"}, {"input": "26\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "5\n"}, {"input": "1\n2000000000\n", "output": "2000000000\n"}, {"input": "1\n2000000000\n", "output": "2000000000\n"}, {"input": "1\n1646661570\n", ...
code_stdio
[ { "content": "You are given two integers K and S.\nThree variable X, Y and Z takes integer values satisfying 0≤X,Y,Z≤K.\nHow many different assignments of values to X, Y and Z are there such that X + Y + Z = S?\n\nConstraints\n\n* 2≤K≤2500\n* 0≤S≤3K\n* K and S are integers.\n\nInput\n\nThe input is given from S...
[{"input": "100 58", "output": "1770\n"}, {"input": "100 50", "output": "1326\n"}, {"input": "101 60", "output": "1891\n"}, {"input": "111 72", "output": "2701\n"}, {"input": "111 79", "output": "3240\n"}, {"input": "278 24", "output": "325\n"}, {"input": "278 20", "output": "231\n"}, {"input": "100 22", "output": "276...
code_stdio
[ { "content": "You have two integers $l$ and $r$. Find an integer $x$ which satisfies the conditions below:\n\n $l \\le x \\le r$. All digits of $x$ are different. \n\nIf there are multiple answers, print any of them.\n\n\n-----Input-----\n\nThe first line contains two integers $l$ and $r$ ($1 \\le l \\le r \\...
[{"input": "98766 110000\n", "output": "102345\n"}, {"input": "98766 110010\n", "output": "102345\n"}, {"input": "72073 145777\n", "output": "72081\n"}, {"input": "11097 145777\n", "output": "12034\n"}, {"input": "38912 145777\n", "output": "38912\n"}, {"input": "11097 157931\n", "output": "12034\n"}, {"input": "25610 ...
code_stdio
[ { "content": "Hierarchical Democracy\n\nThe presidential election in Republic of Democratia is carried out through multiple stages as follows.\n\n1. There are exactly two presidential candidates.\n2. At the first stage, eligible voters go to the polls of his/her electoral district. The winner of the district is...
[{"input": "6\n[[123][4567][89]]\n[[5][3][6][3][9]]\n[[[99][59][63][85][51]][[1539][7995][466]][[51][57][79][99][3][91][59]]]\n[[[37][95][31][77][25]][[43][5][5][5][85]][[71][3][51][89][29]][[57][94][5][69][31]][[99][59][65][73][31]]]\n[[[[9][7][3]][[3][5][7]][[7][9][5]]][[[9][9][3]][[5][9][9]][[7][7][3]]][[[5][9][7]][...
code_stdio
[ { "content": "One important contest will take place on the most famous programming platform (Topforces) very soon!\n\nThe authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty cont...
[{"input": "1\n37\n166320 83160 41580 33264 27720 23760 20790 18480 16632 15120 13860 11880 11088 10395 9240 10676 7920 7560 6930 6160 5940 9910 5040 4752 4620 4158 3960 3780 3696 3465 3080 3024 2970 2772 2640 29 23\n", "output": "186906\n"}, {"input": "1\n37\n166320 83160 41580 33264 27720 23760 20790 18480 16632 1512...
code_stdio
[ { "content": "Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to $120^{\\circ}$. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Ge...
[{"input": "1000 1000 1000 1000 1000 1000\n", "output": "6000000\n"}, {"input": "1000 1000 1000 1000 1000 1000\n", "output": "6000000\n"}, {"input": "718 466 729 470 714 481\n", "output": "2102808\n"}, {"input": "677 303 685 288 692 296\n", "output": "1365807\n"}, {"input": "1000 1000 1 1000 1000 1\n", "output": "20040...
code_stdio
[ { "content": "problem\n\nThere are n islands in JOI, and each island is numbered from 1 to n. Currently, the JOI country is developing a route network connecting each island.\n\nYou work at a ticket center that handles ship tickets. There are many people in JOI who want to travel between islands by boat, as che...
[{"input": "3 8\n1 3 1 10\n0 2 3\n1 2 3 20\n1 1 2 5\n0 3 2\n1 1 3 7\n1 2 1 9\n0 2 3\n5 16\n1 1 3 343750\n1 1 3 3343\n1 1 4 347392\n1 2 5 5497\n1 2 3 123394\n1 2 4 545492\n1 2 5 458\n1 3 4 343983\n1 3 5 843468\n1 4 5 2780\n0 2 1\n0 4 1\n0 3 2\n0 4 2\n0 4 3\n0 5 3\n0 0", "output": "-1\n15\n12\n126737\n129975\n123394\n323...
code_stdio
[ { "content": "There are N stones, numbered 1, 2, \\ldots, N. For each i (1 \\leq i \\leq N), the height of Stone i is h_i.\n\nThere is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N:\n\n* If the frog is currently on Stone i, jump to Stone i + 1 or S...
[{"input": "6\n30 10 60 10 60 57", "output": "33\n"}, {"input": "6\n30 12 60 33 60 18", "output": "54\n"}, {"input": "6\n30 12 21 33 60 18", "output": "36\n"}, {"input": "6\n30 0 26 33 122 14", "output": "30\n"}, {"input": "6\n30 10 99 10 60 50", "output": "60\n"}, {"input": "6\n30 10 35 18 154 1", "output": "39\n"}, {...
code_stdio
[ { "content": "Luckily, Serval got onto the right bus, and he came to the kindergarten on time. After coming to kindergarten, he found the toy bricks very funny.\n\nHe has a special interest to create difficult problems for others to solve. This time, with many $1 \\times 1 \\times 1$ toy bricks, he builds up a ...
[{"input": "2 58 77\n0 0 0 0 6 0 0 0 40 0 0 0 0 22 0 0 41 74 0 0 0 0 0 0 0 15 0 0 60 5 69 0 0 30 0 0 23 60 0 35 0 0 0 0 0 0 69 0 0 0 0 0 0 0 0 0 0 0\n0 74\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\n0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0...
code_stdio
[ { "content": "Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains a number, all numbers on the cards are distinct. The players take turns, Sereja moves first. During his turn a player can take one card: either the leftmost card in a row, or t...
[{"input": "95\n122 29 188 265 292 287 183 225 222 187 155 256 64 148 173 278 218 136 290 17 31 130 2 87 57 283 255 280 68 166 174 142 102 39 116 206 288 154 26 78 296 172 184 232 77 91 277 8 249 186 94 93 207 251 257 195 101 299 193 124 293 65 58 35 24 302 220 189 252 125 27 284 247 182 141 103 198 97 234 83 281 216 8...
code_stdio
[ { "content": "This is an easier version of the problem with smaller constraints.\n\nKorney Korneevich dag up an array $a$ of length $n$. Korney Korneevich has recently read about the operation bitwise XOR , so he wished to experiment with it. For this purpose, he decided to find all integers $x \\ge 0$ such tha...
[{"input": "100\n227 40 465 412 346 400 165 362 247 431 171 215 164 437 34 169 62 223 21 202 372 423 9 336 2 155 92 291 141 187 306 310 340 314 405 387 299 216 9 173 117 478 165 112 311 277 304 454 137 57 337 28 366 374 418 189 2 416 65 309 193 471 406 213 180 85 327 71 341 128 191 239 125 317 21 236 217 292 40 450 173...
code_stdio
[ { "content": "Alice became interested in periods of integer numbers. We say positive $X$ integer number is periodic with length $L$ if there exists positive integer number $P$ with $L$ digits such that $X$ can be written as $PPPP…P$. For example:\n\n$X = 123123123$ is periodic number with length $L = 3$ and $L ...
[{"input": "98779\n163329605173223304180189399899081111990037\n", "output": "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
code_stdio
[ { "content": "# Introduction\n\nThe first century spans from the **year 1** *up to* and **including the year 100**, **The second** - *from the year 101 up to and including the year 200*, etc.\n\n# Task : \nGiven a year, return the century it is in.\n\nWrite Python code to solve this problem. Define a top-level ...
[{"input": "1705", "output": "[18]", "fn_name": "century"}, {"input": "1900", "output": "[19]", "fn_name": "century"}, {"input": "1601", "output": "[17]", "fn_name": "century"}, {"input": "2000", "output": "[20]", "fn_name": "century"}, {"input": "356", "output": "[4]", "fn_name": "century"}, {"input": "89", "output": ...
code_functional