messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Takahashi and Aoki are going to together construct a sequence of integers.\nFirst, Takahashi will provide a sequence of integers a, satisfying all of the following conditions:\n - The length of a is N.\n - Each element in a is an integer between 1 and K, inclusive.\n - a is a palindrome, that is, ... | [{"input": "1000000000 1000000000\n", "output": "875699961\n"}, {"input": "1000000000 146388030\n", "output": "329875629\n"}, {"input": "1000000000 121963892\n", "output": "419967204\n"}, {"input": "1000000000 153662193\n", "output": "749048454\n"}, {"input": "1000001000 1000000000", "output": "212353005\n"}, {"input":... | code_stdio |
[
{
"content": "We have N+1 integers: 10^{100}, 10^{100}+1, ..., 10^{100}+N.\nWe will choose K or more of these integers. Find the number of possible values of the sum of the chosen numbers, modulo (10^9+7).\n\n-----Constraints-----\n - 1 \\leq N \\leq 2\\times 10^5\n - 1 \\leq K \\leq N+1\n - All values in input... | [{"input": "123333 101429\n", "output": "175623902\n"}, {"input": "141421 35623\n", "output": "220280457\n"}, {"input": "154242 56347\n", "output": "520400358\n"}, {"input": "105711 80705\n", "output": "801552417\n"}, {"input": "223214 200001", "output": "534704743\n"}, {"input": "402106 200001", "output": "533363909\n... | code_stdio |
[
{
"content": "Ivan unexpectedly saw a present from one of his previous birthdays. It is array of $n$ numbers from $1$ to $200$. Array is old and some numbers are hard to read. Ivan remembers that for all elements at least one of its neighbours ls not less than it, more formally:\n\n$a_{1} \\le a_{2}$,\n\n$a_{n}... | [{"input": "37\n52 52 66 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 -1 92 92 5 25 48 79 79\n", "output": "903952722\n"}, {"input": "37\n52 52 66 149 149 130 47 47 26 110 185 -1 73 73 65 -1 -1 130 -1 -1 -1 94 97 190 -1 -1 49 49 54 -1 92 92 5 25 48 79 79\n", "output": "903952722\... | code_stdio |
[
{
"content": "General primality test are often computationally expensive, so in the biggest prime number race the idea is to study special sub-families of prime number and develop more effective tests for them. \n\n[Mersenne Primes](https://en.wikipedia.org/wiki/Mersenne_prime) are prime numbers of the form: Mn... | [{"input": "11215", "output": "[false]", "fn_name": "lucas_lehmer"}, {"input": "11213", "output": "[true]", "fn_name": "lucas_lehmer"}, {"input": "101", "output": "[false]", "fn_name": "lucas_lehmer"}, {"input": "10", "output": "[false]", "fn_name": "lucas_lehmer"}, {"input": "33", "output": "[false]", "fn_name": "luca... | code_functional |
[
{
"content": "Karafs is some kind of vegetable in shape of an 1 × h rectangle. Tavaspolis people love Karafs and they use Karafs in almost any kind of food. Tavas, himself, is crazy about Karafs. [Image] \n\nEach Karafs has a positive integer height. Tavas has an infinite 1-based sequence of Karafses. The heigh... | [{"input": "447 74474 4\n47 777474 1358\n74 744744 74477\n477 477447 777\n7 477777 444444\n", "output": "-1\n-1\n-1\n7\n"}, {"input": "447 74474 4\n47 777474 747\n74 744744 74477\n477 477447 777\n7 477777 444444\n", "output": "-1\n-1\n-1\n7\n"}, {"input": "447 74474 4\n47 777474 747\n74 744744 74477\n477 477447 777\n7 ... | code_stdio |
[
{
"content": "Your task is to determine the top 3 place finishes in a pole vault competition involving several different competitors. This is isn't always so simple, and it is often a source of confusion for people who don't know the actual rules.\n\nHere's what you need to know:\n\nAs input, you will receive a... | [{"input": "[{\"name\": \"Anna\", \"results\": [\"XO\", \"O\", \"XO\", \"XO\"]}, {\"name\": \"Allison\", \"results\": [\"XO\", \"O\", \"XXO\", \"XXX\"]}, {\"name\": \"Olivia\", \"results\": [\"O\", \"XO\", \"XXO\", \"XXX\"]}, {\"name\": \"Rhiana\", \"results\": [\"XO\", \"O\", \"XO\", \"XO\"]}, {\"name\": \"Zola\", \"r... | code_functional |
[
{
"content": "One day, Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He is interested in properties of the sequence a.\n\nFor a nonempty contiguous subsequence a_l, ..., a_r (1 \\leq l \\leq r \\leq N) of the sequence a, its beauty is defined as a_l + ... +... | [{"input": "8 2\n13 0 11 2 14 4 11 8", "output": "55\n"}, {"input": "8 4\n10 2 18 7 21 1 10 1", "output": "58\n"}, {"input": "8 4\n10 2 28 7 23 0 10 3", "output": "70\n"}, {"input": "8 2\n18 0 28 5 17 1 16 1", "output": "84\n"}, {"input": "8 2\n13 0 11 2 14 5 6 4", "output": "51\n"}, {"input": "8 2\n13 0 11 2 14 5 6 7"... | code_stdio |
[
{
"content": "Zonk is addictive dice game. In each round player rolls 6 dice. Then (s)he composes combinations from them. Each combination gives certain points. \n\nThen player can take one or more dice combinations to his hand and re-roll remaining dice or save his score. Dice in player's hand won't be taken i... | [{"input": "[1, 1, 1, 1, 1, 1]", "output": "[4000]", "fn_name": "get_score"}, {"input": "[3, 3, 3, 3, 3, 3]", "output": "[1200]", "fn_name": "get_score"}, {"input": "[4, 4, 4, 4, 4, 4]", "output": "[1600]", "fn_name": "get_score"}, {"input": "[5, 5, 5, 5, 5, 5]", "output": "[2000]", "fn_name": "get_score"}, {"input": "... | code_functional |
[
{
"content": "King of Berland Berl IV has recently died. Hail Berl V! As a sign of the highest achievements of the deceased king the new king decided to build a mausoleum with Berl IV's body on the main square of the capital.\n\nThe mausoleum will be constructed from 2n blocks, each of them has the shape of a c... | [{"input": "30 50\n17 >= 29\n19 <= 18\n3 > 50\n54 >= 56\n47 < 15\n50 <= 33\n49 < 8\n57 <= 16\n30 > 35\n49 < 21\n3 >= 37\n56 <= 51\n46 > 51\n35 >= 48\n32 < 15\n12 <= 4\n38 > 57\n55 < 9\n49 <= 1\n9 >= 38\n60 = 60\n1 > 12\n40 >= 43\n13 > 38\n24 >= 39\n9 < 2\n12 > 58\n15 >= 30\n13 > 50\n42 <= 16\n23 >= 54\n16 < 10\n1 > 43\... | code_stdio |
[
{
"content": "Professor Matsuzaki is a scientist studying the truth of the universe. Life, the universe, all the answers are said to be 42, but Professor Matsuzaki thinks that this alone is not enough to elucidate the truth of the universe. Professor Matsuzaki believes that the truth of the universe is represen... | [{"input": "0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 6\n11 1\n11 2\n11 3\n100001 100\n-1 -1", "output": "42\n4\n5\n6\n22\n24\n26\n28\n30\n30\n26\n30\n32\n200274\n"}, {"input": "0 55\n0 1\n0 2\n0 3\n10 1\n10 2\n10 3\n10 4\n10 5\n10 1\n11 1\n11 2\n11 3\n100001 100\n-1 -1", "output": "42\n4\n5\n6\n22\n24\n26\... | code_stdio |
[
{
"content": "A robot is put at the origin in a two-dimensional plane.\nInitially, the robot is facing in the positive x-axis direction.\nThis robot will be given an instruction sequence s.\ns consists of the following two kinds of letters, and will be executed in order from front to back.\n - F : Move in the c... | [{"input": "FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT... | code_stdio |
[
{
"content": "You are given a string $s$ of length $n$ consisting only of lowercase Latin letters.\n\nA substring of a string is a contiguous subsequence of that string. So, string \"forces\" is substring of string \"codeforces\", but string \"coder\" is not.\n\nYour task is to calculate the number of ways to r... | [{"input": "420\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa... | code_stdio |
[
{
"content": "In the Bus of Characters there are $n$ rows of seat, each having $2$ seats. The width of both seats in the $i$-th row is $w_i$ centimeters. All integers $w_i$ are distinct.\n\nInitially the bus is empty. On each of $2n$ stops one passenger enters the bus. There are two types of passengers: an in... | [{"input": "10\n24 53 10 128 141 9 15 62 32 47\n00100000000111111111\n", "output": "6 3 3 7 1 9 10 2 8 4 5 5 4 8 2 10 9 1 7 6\n"}, {"input": "10\n24 53 10 128 141 9 15 97 32 47\n00100000000111111111\n", "output": "6 3 3 7 1 9 10 2 8 4 5 5 4 8 2 10 9 1 7 6\n"}, {"input": "10\n24 53 10 99 83 9 15 62 33 47\n00100000000111... | code_stdio |
[
{
"content": "We have a tree with N vertices, whose i-th edge connects Vertex u_i and Vertex v_i.\nVertex i has an integer a_i written on it.\nFor every integer k from 1 through N, solve the following problem:\n - We will make a sequence by lining up the integers written on the vertices along the shortest path ... | [{"input": "10\n1 2 4 2 11 1 7 11 0 4\n1 3\n2 3\n3 4\n7 5\n2 6\n6 7\n1 8\n2 9\n2 10", "output": "1\n2\n2\n2\n4\n2\n3\n2\n2\n3\n"}, {"input": "10\n1 2 4 0 12 1 7 11 0 4\n1 5\n2 3\n3 4\n7 5\n2 6\n6 7\n1 8\n2 9\n2 10", "output": "1\n2\n3\n3\n2\n2\n2\n2\n2\n3\n"}, {"input": "10\n1 2 6 2 7 1 2 10 0 4\n1 3\n2 3\n3 4\n10 5\n2... | code_stdio |
[
{
"content": "We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings \"ab\" in the string and replace it with the string \"bba\". If we have no \"ab\" as a substring, our job is done. Print the minimum number of steps we should perform to make... | [{"input": "abaaaaaabaaaabbabbaaabbbbabababaaaaabbaabbaaaaabbbaababaaaaaaabbbbbaaaaabaababbabababbabbbbabbbaabbabbbabaabbaabbaaaaaab\n", "output": "502032780\n"}, {"input": "abaaaaaabaaaabbabbaaabbababababaaaaabbaabbaaaaabbbaababaaaaaaabbbbbaaaaabbababbabababbabbbbabbbaabbabbbabaabbaabbaaaaaab\n", "output": "366132879\... | code_stdio |
[
{
"content": "Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.\nShe will concatenate all of the strings in some order, to produce a long string.\nAmong all strings that she can produce in this way, find the lexicographically smallest one.\nHere, a string s=s_1s_2s_3...s_n is... | [{"input": "3 3\ndxx\naxx\ncxx\n", "output": "axxcxxdxx\n"}, {"input": "3 3\ndxx\naxx\ndxx", "output": "axxdxxdxx\n"}, {"input": "3 3\ndxx\naxx\nxxd", "output": "axxdxxxxd\n"}, {"input": "3 3\ndxx\nxxa\nxxd", "output": "dxxxxaxxd\n"}, {"input": "3 3\ncxx\nxxa\nxxd", "output": "cxxxxaxxd\n"}, {"input": "3 3\ndxx\n`xx\nc... | code_stdio |
[
{
"content": "Suppose there is a $h \\times w$ grid consisting of empty or full cells. Let's make some definitions:\n\n $r_{i}$ is the number of consecutive full cells connected to the left side in the $i$-th row ($1 \\le i \\le h$). In particular, $r_i=0$ if the leftmost cell of the $i$-th row is empty. $c_{... | [{"input": "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 12 16 10 11 15 4\n", "output": "974740338\n"}, {"input": "19 16\n16 16 16 16 15 15 0 5 0 4 9 9 1 4 4 0 8 16 12\n6 12 19 15 8 6 19 19 14 6 9 16 10 11 15 4\n", "output": "797922655\n"}, {"input": "19 16\n16 16 16 16 15 15 0 5 0 4 ... | code_stdio |
[
{
"content": "In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.\n\nWrite a program which reads an integer x and print it as is. Note that mu... | [{"input": "3\n14\n11\n14\n2\n58\n0", "output": "Case 1: 3\nCase 2: 14\nCase 3: 11\nCase 4: 14\nCase 5: 2\nCase 6: 58\n"}, {"input": "3\n5\n11\n14\n26\n34\n0", "output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 14\nCase 5: 26\nCase 6: 34\n"}, {"input": "3\n14\n15\n14\n2\n58\n0", "output": "Case 1: 3\nCase 2: 14\nCase... | code_stdio |
[
{
"content": "You have a statistic of price changes for one product represented as an array of $n$ positive integers $p_0, p_1, \\dots, p_{n - 1}$, where $p_0$ is the initial price of the product and $p_i$ is how the price was increased during the $i$-th month.\n\nUsing these price changes you are asked to calc... | [{"input": "2\n4 1\n20100 1 202 525\n3 101\n1 0 1\n", "output": "32197\n0\n"}, {"input": "2\n4 1\n20100 1 182 525\n3 101\n1 0 1\n", "output": "32217\n0\n"}, {"input": "2\n4 1\n33029 1 202 525\n3 101\n1 0 1\n", "output": "19268\n0\n"}, {"input": "2\n4 1\n20100 1 182 649\n3 101\n1 0 1\n", "output": "44617\n0\n"}, {"input... | code_stdio |
[
{
"content": "All of the animals are having a feast! Each animal is bringing one dish. There is just one rule: the dish must start and end with the same letters as the animal's name. For example, the great blue heron is bringing garlic naan and the chickadee is bringing chocolate cake.\n\nWrite a function `feas... | [{"input": "\"great blue heron\"\n\"garlic naan\"", "output": "[true]", "fn_name": "feast"}, {"input": "\"blue-footed booby\"\n\"blueberry\"", "output": "[true]", "fn_name": "feast"}, {"input": "\"chickadee\"\n\"chocolate cake\"", "output": "[true]", "fn_name": "feast"}, {"input": "\"brown bear\"\n\"bear claw\"", "outp... | code_functional |
[
{
"content": "<image> <image>\n\n*The two images are equivalent, feel free to use either one.\n\nInput\n\nThe input contains a single integer a (-100 ≤ a ≤ 100).\n\nOutput\n\nOutput the result – an integer number.\n\nExample\n\nInput\n\n\n1\n\n\nOutput\n\n\n1\n\nWrite Python code to solve this problem. Your pro... | [{"input": "-1079\n", "output": "-1164239\n"}, {"input": "-340\n", "output": "-115598\n"}, {"input": "-449\n", "output": "-201599\n"}, {"input": "-685\n", "output": "-469223\n"}, {"input": "-432\n", "output": "-186622\n"}, {"input": "-346\n", "output": "-119714\n"}, {"input": "-410\n", "output": "-168098\n"}, {"input":... | code_stdio |
[
{
"content": "There are S sheep and W wolves.\nIf the number of wolves is greater than or equal to that of sheep, the wolves will attack the sheep.\nIf the wolves will attack the sheep, print unsafe; otherwise, print safe.\n\n-----Constraints-----\n - 1 \\leq S \\leq 100\n - 1 \\leq W \\leq 100\n\n-----Input---... | [{"input": "100 100\n", "output": "unsafe\n"}, {"input": "10 10\n", "output": "unsafe\n"}, {"input": "99 99\n", "output": "unsafe\n"}, {"input": "74 74\n", "output": "unsafe\n"}, {"input": "63 64\n", "output": "unsafe\n"}, {"input": "1 100\n", "output": "unsafe\n"}, {"input": "-1 -1", "output": "unsafe\n"}, {"input": "... | code_stdio |
[
{
"content": "In a very ancient country the following game was popular. Two people play the game. Initially first player writes a string s1, consisting of exactly nine digits and representing a number that does not exceed a. After that second player looks at s1 and writes a string s2, consisting of exactly nine... | [{"input": "1000000000 100050 1000001\n", "output": "1 000000101\n"}, {"input": "702034015 6007275 9777625\n", "output": "1 000000001\n"}, {"input": "123456789 1234561 1234567\n", "output": "1 000549636\n"}, {"input": "972037745 4602117 5090186\n", "output": "1 000000011\n"}, {"input": "585173560 4799128 5611727\n", "o... | code_stdio |
[
{
"content": "The pair of integer numbers `(m, n)`, such that `10 > m > n > 0`, (below 10), that its sum, `(m + n)`, and rest, `(m - n)`, are perfect squares, is (5, 4).\n\nLet's see what we have explained with numbers.\n```\n5 + 4 = 9 = 3²\n5 - 4 = 1 = 1²\n(10 > 5 > 4 > 0)\n```\n\nThe pair of numbers `(m, n)`... | [{"input": "150", "output": "[[149, 140]]", "fn_name": "closest_pair_tonum"}, {"input": "200", "output": "[[197, 28]]", "fn_name": "closest_pair_tonum"}, {"input": "100", "output": "[[97, 72]]", "fn_name": "closest_pair_tonum"}, {"input": "30", "output": "[[29, 20]]", "fn_name": "closest_pair_tonum"}, {"input": "50", "... | code_functional |
[
{
"content": "# Task\n Alireza and Ali have a `3×3 table` and playing on that. they have 4 table(2×2) A,B,C and D in this table.\n \n At beginning all of 9 numbers in 3×3 table is zero.\n \n Alireza in each move choose a 2×2 table from A, B, C and D and increase all of 4 numbers in that by one.\n \n He asks Ali... | [{"input": "[[3, 7, 4], [5, 16, 11], [2, 9, 7]]", "output": "[[3, 4, 2, 7]]", "fn_name": "table_game"}, {"input": "[[1, 3, 2], [5, 10, 5], [4, 7, 3]]", "output": "[[1, 2, 4, 3]]", "fn_name": "table_game"}, {"input": "[[1, 2, 1], [2, 4, 2], [1, 2, 1]]", "output": "[[1, 1, 1, 1]]", "fn_name": "table_game"}, {"input": "[[... | code_functional |
[
{
"content": "Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had.\n\nConstraints\n\n* 1 \\leq N \\leq 10^5\n* 0 \\leq K \\leq N-1\n*... | [{"input": "38823 9265", "output": "550080294\n"}, {"input": "11695 7143", "output": "10362628\n"}, {"input": "31415 9265", "output": "287927211"}, {"input": "11695 9265", "output": "2953665\n"}, {"input": "11695 8033", "output": "6706953\n"}, {"input": "3903 337", "output": "10168461\n"}, {"input": "4275 337", "output... | code_stdio |
[
{
"content": "Food contains three nutrients called \"protein\", \"fat\" and \"carbohydrate\", which are called three major nutrients. It is calculated that protein and carbohydrate are 4 kcal (kilocalories) and fat is 9 kcal per 1 g (gram). For example, according to the table below, the number 1 cake contains 7... | [{"input": "4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 110\n2\n1 8 10 116\n-1 4 18 33\n10 10 50 300\n0", "output": "NA\nNA\n"}, {"input": "4\n1 7 14 47\n2 5 35 55\n3 6 3 59\n4 6 5 15\n10 15 50 110\n2\n1 8 10 116\n0 4 18 33\n10 10 50 300\n0", "output": "NA\nNA\n"}, {"input": "4\n1 7 14 47\n2 5 35 55\n3 6 3 59... | code_stdio |
[
{
"content": "Andrew, Fedor and Alex are inventive guys. Now they invent the game with strings for two players.\n\nGiven a group of n non-empty strings. During the game two players build the word together, initially the word is empty. The players move in turns. On his step player must add a single letter in the... | [{"input": "5 6\nabas\ndsfdf\nabacaba\ndartsidius\nkolobok\n", "output": "Second\n"}, {"input": "5 6\nabas\ndsfdf\nabacaba\ndartsidius\nkolobok\n", "output": "Second\n"}, {"input": "5 6\nabas\ndsfdf\nabacaba\ndartsidius\nkobolok\n", "output": "Second\n"}, {"input": "5 6\nabas\ndsfdf\nabacaba\ndadtsirius\nkolobok\n", "o... | code_stdio |
[
{
"content": "I'm traveling to a country with a rabbit. There are n cities in this country numbered from 1 to n, and the rabbit is now in city 1. City i is a point on the coordinate plane (xi, yi) ).\n\nRabbits travel to meet the following conditions.\n\n* The travel path is a polygonal line, each part of which... | [{"input": "5\n101.13623414746552 91.04161232454778\n1 -1\n1 10\n0 3\n19 -1\n20 7", "output": "9\n"}, {"input": "5\n100.60853142327974 90.65666260699702\n1 0\n1 10\n8 3\n10 -1\n12 10", "output": "2\n"}, {"input": "5\n100.60853142327974 90.65666260699702\n1 0\n1 10\n8 3\n19 -1\n12 10", "output": "3\n"}, {"input": "5\n10... | code_stdio |
[
{
"content": "Numbers of black and white points are placed on a plane. Let's imagine that a straight line of infinite length is drawn on the plane. When the line does not meet any of the points, the line divides these points into two groups. If the division by such a line results in one group consisting only of... | [{"input": "3 3\n100 700\n200 200\n600 600\n500 100\n605 300\n800 578\n3 3\n100 300\n400 600\n400 100\n600 400\n500 900\n300 300\n3 4\n300 300\n935 300\n400 600\n100 100\n200 900\n500 900\n158 110\n1 2\n300 300\n100 100\n500 500\n1 1\n100 100\n200 100\n2 2\n0 0\n500 700\n1000 1400\n1500 2100\n2 2\n0 0\n1000 1000\n1010 ... | code_stdio |
[
{
"content": "Consider a tic-tac-toe on a 3x3 board. Tic-tac-toe is a two-player battle game. Decide the first attack and the second attack, one hits Kuroishi and one hits Shiraishi. The winner is the person who puts stones one by one on the board alternately and arranges three of his own stones first in either... | [{"input": "bbw\nbww\n+b+\nbwb\nwbx\nwbw\n0", "output": "NA\nNA\n"}, {"input": "caw\nwbw\n+b+\nbwb\nwxb\nwbw\n0", "output": "NA\nNA\n"}, {"input": "bbw\nbww\n+b+\nbwb\nwbx\nwbv\n0", "output": "NA\nNA\n"}, {"input": "cbw\nbww\n+b+\nbwb\nwbx\nwbw\n0", "output": "NA\nNA\n"}, {"input": "caw\nwbw\n+b+\nbwb\nwxb\nwbv\n0", "o... | code_stdio |
[
{
"content": "Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes.\n\nThe exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the... | [{"input": "10\n3 5 1 3\n0 0 1\n2 1 4\n2 5 2 3\n1 0\n3 2\n1 20 2 4\n0\n16\n6 20 2 5\n1 1 0 1 0 0\n0 8 2 9 11 6\n4 12 3 6\n1 0 1 1\n8 3 5 6\n6 20 3 12\n0 1 0 0 1 0\n20 11 3 20 16 17\n7 17 1 6\n1 1 0 1 0 0 0\n1 8 0 11 15 15 10\n6 17 2 6\n0 0 1 0 0 1\n7 11 2 7 10 12\n5 17 2 5\n1 1 1 1 0\n17 11 10 6 4\n1 1 1 2\n0\n1\n", "o... | code_stdio |
[
{
"content": "\"Hey, it's homework time\" — thought Polycarpus and of course he started with his favourite subject, IT. Polycarpus managed to solve all tasks but for the last one in 20 minutes. However, as he failed to solve the last task after some considerable time, the boy asked you to help him.\n\nThe seque... | [{"input": "100\n340 14 3275 2283 2673 1107 817 2243 1226 32 2382 3638 4652 418 68 4962 387 764 4647 159 1846 225 2760 4904 3150 403 3 2439 91 4428 92 4705 75 348 1566 1465 69 6 49 4 62 4643 564 1090 3447 1871 2255 139 24 99 2669 969 86 61 4550 158 4537 3993 1589 872 2907 1888 401 80 1825 1483 63 1 2264 4068 4113 2548 ... | code_stdio |
[
{
"content": "Vasya is reading a e-book. The file of the book consists of $n$ pages, numbered from $1$ to $n$. The screen is currently displaying the contents of page $x$, and Vasya wants to read the page $y$. There are two buttons on the book which allow Vasya to scroll $d$ pages forwards or backwards (but he ... | [{"input": "5\n20 10 2 9\n1000000000 2 89 4\n1000000000 2 89 8\n1000000000 142 1 1000000000\n1000000000 1000000000 4 3\n", "output": "4\n23\n12\n1\n333333332\n"}, {"input": "5\n20 10 2 9\n1000000000 2 89 4\n1000000000 2 89 5\n1000000000 142 1 1000000000\n1000000000 1000000000 4 3\n", "output": "4\n23\n-1\n1\n333333332\... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nChef loves to prepare delicious dishes. This time, Chef has decided to prepare a special dish for you, and needs to gather several apples to do so.\n\nChef has N apple trees in his home garden. Each tree has a certain (non-zero) number... | [{"input": "2\n3\n3 14 3\n4\n1 2 3 3", "output": "2\n3\n"}, {"input": "2\n3\n1 14 3\n4\n1 2 3 3", "output": "3\n3\n"}, {"input": "2\n2\n3 3 1\n4\n1 12 3 3", "output": "2\n3\n"}, {"input": "2\n3\n6 14 3\n4\n1 2 3 3", "output": "3\n3\n"}, {"input": "2\n3\n1 14 3\n4\n1 2 3 2", "output": "3\n3\n"}, {"input": "2\n3\n3 3 3\n... | code_stdio |
[
{
"content": "Write a function\n```python\nalternate_sort(l)\n```\nthat combines the elements of an array by sorting the elements ascending by their **absolute value** and outputs negative and non-negative integers alternatingly (starting with the negative value, if any).\n\nE.g.\n```python\nalternate_sort([5, ... | [{"input": "[-5, -2, 3, 9, 4, -2, -8, 0, 9, -9]", "output": "[[-2, 0, -2, 3, -5, 4, -8, 9, -9, 9]]", "fn_name": "alternate_sort"}, {"input": "[5, -42, -8, 2, -3, -4, -9]", "output": "[[-3, 2, -4, 5, -8, -9, -42]]", "fn_name": "alternate_sort"}, {"input": "[5, -42, 2, -3, -4, 8, 9]", "output": "[[-3, 2, -4, 5, -42, 8, 9... | code_functional |
[
{
"content": "Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer d_{i}, which can be equal to 0, 1 or - 1. To pass the level, he needs to find a «good» subset of ... | [{"input": "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n6 4\n4 2\n9 1\n5 10\n9 8\n10 7\n5 1\n6 2\n", "output": "0\n\n"}, {"input": "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n4 4\n4 2\n9 1\n5 10\n9 8\n10 7\n5 1\n6 2\n", "output": "0\n\n"}, {"input": "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n6 4\n4 2\n9 ... | code_stdio |
[
{
"content": "We define $x \\bmod y$ as the remainder of division of $x$ by $y$ ($\\%$ operator in C++ or Java, mod operator in Pascal).\n\nLet's call an array of positive integers $[a_1, a_2, \\dots, a_k]$ stable if for every permutation $p$ of integers from $1$ to $k$, and for every non-negative integer $x$, ... | [{"input": "500000 250000\n", "output": "803991687\n"}, {"input": "500000 250000\n", "output": "803991687\n"}, {"input": "500000 471528\n", "output": "588862109\n"}, {"input": "500000 121854\n", "output": "377057930\n"}, {"input": "123456 78901\n", "output": "963821949\n"}, {"input": "123456 78901\n", "output": "963821... | code_stdio |
[
{
"content": "Some programming contest problems are really tricky: not only do they\nrequire a different output format from what you might have expected, but\nalso the sample output does not show the difference. For an example,\nlet us look at permutations.\n\nA permutation of the integers 1 to n is an\norderin... | [{"input": "4\n-2 1 2 4\n5\n-1 3 0 3 0\n1\n1\n0", "output": "not ambiguous\nnot ambiguous\nambiguous\n"}, {"input": "4\n-1 4 2 4\n5\n0 3 4 3 0\n1\n1\n0", "output": "not ambiguous\nnot ambiguous\nambiguous\n"}, {"input": "4\n-1 4 2 1\n5\n0 3 4 3 0\n1\n1\n0", "output": "not ambiguous\nnot ambiguous\nambiguous\n"}, {"inpu... | code_stdio |
[
{
"content": "Lexicographic permutations are ordered combinations of a set of items ordered in a specific way.\n\nFor instance, the first 8 permutations of the digits 0123, in lexicographic order, are:\n\n```\n1st 0123\n2nd 0132\n3rd 0213\n4th 0231\n5th 0312\n6th 0321\n7th 1023\n8th 1032\n```\n\nYour task is to... | [{"input": "1000000\n10", "output": "[\"2783915460\"]", "fn_name": "nth_perm"}, {"input": "3000000\n10", "output": "[\"8241697530\"]", "fn_name": "nth_perm"}, {"input": "1234567\n10", "output": "[\"3469702158\"]", "fn_name": "nth_perm"}, {"input": "654321\n10", "output": "[\"1827653409\"]", "fn_name": "nth_perm"}, {"in... | code_functional |
[
{
"content": "There are n boys and m girls attending a theatre club. To set a play \"The Big Bang Theory\", they need to choose a group containing exactly t actors containing no less than 4 boys and no less than one girl. How many ways are there to choose a group? Of course, the variants that only differ in the... | [{"input": "30 30 30\n", "output": "118264581548187697"}, {"input": "30 29 19\n", "output": "1396982287132530\n"}, {"input": "30 30 19\n", "output": "2044156982307300\n"}, {"input": "30 29 42\n", "output": "277508869722315\n"}, {"input": "21 30 30\n", "output": "114456652814979\n"}, {"input": "30 30 44\n", "output": "1... | code_stdio |
[
{
"content": "There is a special offer in Vasya's favourite supermarket: if the customer buys $a$ chocolate bars, he or she may take $b$ additional bars for free. This special offer can be used any number of times.\n\nVasya currently has $s$ roubles, and he wants to get as many chocolate bars for free. Each cho... | [{"input": "16\n1 1 1 1\n1 1 1 1000000000\n1 1 1000000000 1\n1 1 1000000000 1000000000\n1 1000000000 1 1\n1 1000000000 1 1000000000\n1 1000000000 1000000000 1\n1 1000000000 1000000000 1000000000\n1000000000 1 1 1\n1000000000 1 1 1000000000\n1000000000 1 1000000000 1\n1000000000 1 1000000000 1000000000\n1000000000 10000... | code_stdio |
[
{
"content": "There is a bar of chocolate with a height of H blocks and a width of W blocks.\nSnuke is dividing this bar into exactly three pieces.\nHe can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle.\nSnuke is trying to divide the bar as evenly as possible.\nMore s... | [{"input": "100000 100000\n", "output": "50000\n"}, {"input": "100100 100000", "output": "50000\n"}, {"input": "100100 110000", "output": "50050\n"}, {"input": "100111 100001", "output": "83371\n"}, {"input": "100100 100010", "output": "50005\n"}, {"input": "110111 100001", "output": "86704\n"}, {"input": "101111 01000... | code_stdio |
[
{
"content": "Tattah is asleep if and only if Tattah is attending a lecture. This is a well-known formula among Tattah's colleagues.\n\nOn a Wednesday afternoon, Tattah was attending Professor HH's lecture. At 12:21, right before falling asleep, he was staring at the digital watch around Saher's wrist. He notic... | [{"input": "04:50\n", "output": "05:50\n"}, {"input": "02:17\n", "output": "02:20\n"}, {"input": "12:14\n", "output": "12:21\n"}, {"input": "03:44\n", "output": "04:40\n"}, {"input": "00:17\n", "output": "01:10\n"}, {"input": "15:51\n", "output": "20:02\n"}, {"input": "23:31\n", "output": "23:32\n"}, {"input": "07:56\n... | code_stdio |
[
{
"content": "J: City\n\nSanta decides to deliver a present to a city.\n\nThe city has a rectangular shape divided into north-south $ H $ parcels x east-west $ W $ parcels, with one house delivering gifts to each parcel.\n\nThe $ X $ th section from the north and the $ Y $ th section from the west are represent... | [{"input": "2 -2 11 0", "output": "Yes\n"}, {"input": "0 -1 12 1", "output": "Yes\n"}, {"input": "-1 2 0 14", "output": "Yes\n"}, {"input": "0 -1 1 11", "output": "Yes\n"}, {"input": "1 -2 11 0", "output": "Yes\n"}, {"input": "3 1 2 12", "output": "Yes\n"}, {"input": "2 2 0 14", "output": "Yes\n"}, {"input": "0 2 0 14"... | code_stdio |
[
{
"content": "Vasya plays the LionAge II. He was bored of playing with a stupid computer, so he installed this popular MMORPG, to fight with his friends. Vasya came up with the name of his character — non-empty string s, consisting of a lowercase Latin letters. However, in order not to put up a front of friends... | [{"input": "emrvvhupytoxzhqxmuop 1\n49\ng g -558\nd g 845\nd k -745\nb g -773\nf f -733\nb s -491\na s -894\ng d -565\ns k -756\nb a 373\nb d 398\nk f 250\na b 531\nf g -27\nf b 125\na g -555\ns f 540\ng b 194\nk s -636\ns b -955\nd a -520\ng f -97\nf s -204\ns a 171\nb k -304\ns g -160\na a -567\na f -455\nd d -571\nd... | code_stdio |
[
{
"content": "Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K.\n\n-----Constraints-----\n - 2 \\leq K \\leq 10^5\n - K is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nK\n\n-----Output-----\nPrint the smallest possib... | [{"input": "79992\n", "output": "36\n"}, {"input": "10989", "output": "27\n"}, {"input": "37450", "output": "3\n"}, {"input": "70620", "output": "6\n"}, {"input": "11849", "output": "5\n"}, {"input": "48730", "output": "4\n"}, {"input": "45794", "output": "3\n"}, {"input": "34375", "output": "2\n"}, {"input": "31041", ... | code_stdio |
[
{
"content": "Problem Statement\n\nThe Animal School is a primary school for animal children. You are a fox attending this school.\n\nOne day, you are given a problem called \"Arithmetical Restorations\" from the rabbit teacher, Hanako. Arithmetical Restorations are the problems like the following:\n\n* You are... | [{"input": "3?4\n?21\n5?5\n14??\n?7?5\n3?9?\n?????\n?????\n?????\n0", "output": "10\n100\n200039979\n"}, {"input": "3?5\n1?1\n5?6\n41??\n5?7?\n9??2\n?????\n?????\n?????\n0", "output": "45\n823\n200039979\n"}, {"input": "3?5\n1?1\n5?6\n41??\n5?6?\n9??2\n?????\n?????\n?????\n0", "output": "45\n833\n200039979\n"}, {"input... | code_stdio |
[
{
"content": "There are N positive integers written on a blackboard: A_1, ..., A_N.\nSnuke can perform the following operation when all integers on the blackboard are even:\n - Replace each integer X on the blackboard by X divided by 2.\nFind the maximum possible number of operations that Snuke can perform.\n\n... | [{"input": "6\n382253568 723152896 37802240 379425024 404894720 471526144\n", "output": "8\n"}, {"input": "6\n348324507 1154626501 32183854 379425024 590201381 471526144", "output": "0\n"}, {"input": "6\n586050932 1154626501 32183854 379425024 590201381 471526144", "output": "0\n"}, {"input": "6\n586050932 1154626501 3... | code_stdio |
[
{
"content": "There are n integers b_1, b_2, ..., b_{n} written in a row. For all i from 1 to n, values a_{i} are defined by the crows performing the following procedure:\n\n The crow sets a_{i} initially 0. The crow then adds b_{i} to a_{i}, subtracts b_{i} + 1, adds the b_{i} + 2 number, and so on until the... | [{"input": "10\n-38980 0001000000 -1000000000 1000000000 -1000000000 1000010010 -1000000000 1010000010 -1556535198 1000000000\n", "output": "961020 -999000000 0 0 10010 10010 10000010 -546535188 -556535198 1000000000\n"}, {"input": "10\n-38980 0001000000 -1000000000 1000000000 -1000000000 1000010011 -1000000000 1010000... | code_stdio |
[
{
"content": "Let's call (yet again) a string good if its length is even, and every character in odd position of this string is different from the next character (the first character is different from the second, the third is different from the fourth, and so on). For example, the strings good, string and xyyx ... | [{"input": "100\nababbaaabaaabaabbabbaaabbabaaabbbabbbbbbbbababbbbbabbaaaabbbabbaababaabaababbbabababbbababbbbaabbbba\n", "output": "34\nababbaabababbabaabbabaabbababababaabbabaabababababbabababababaabba\n"}, {"input": "100\nabbbbaabbbbababbbabababbbabaabaababaabbabbbaaaabbabbbbbababbbbbbbbabbbaaababbaaabbabbaabaaabaaa... | code_stdio |
[
{
"content": "You are given two polynomials:\n\n * P(x) = a0·xn + a1·xn - 1 + ... + an - 1·x + an and \n * Q(x) = b0·xm + b1·xm - 1 + ... + bm - 1·x + bm. \n\n\n\nCalculate limit <image>.\n\nInput\n\nThe first line contains two space-separated integers n and m (0 ≤ n, m ≤ 100) — degrees of polynomials P(x) an... | [{"input": "69 69\n-7 38 -3 -22 65 -78 -65 -99 -76 63 0 -4 -78 -51 54 -61 -53 60 80 34 -96 162 -78 -96 21 -10 -86 33 -9 -81 -19 -2 -76 -3 -66 -80 -55 -21 -50 37 -86 -37 47 44 76 -39 54 -25 41 -86 -3 -25 -67 94 18 67 27 -5 -30 -69 2 -76 7 -97 -52 -35 -55 -20 92 2\n90 -94 37 41 -27 -54 96 -15 -60 -29 -75 -93 -57 62 7 -88... | code_stdio |
[
{
"content": "You have a fence consisting of $n$ vertical boards. The width of each board is $1$. The height of the $i$-th board is $a_i$. You think that the fence is great if there is no pair of adjacent boards having the same height. More formally, the fence is great if and only if for all indices from $2$ to... | [{"input": "3\n3\n3 4\n2 1\n3 7\n3\n2 3\n2 2\n2 0\n4\n1 7\n12 2\n2 15\n1000000000 8\n", "output": "0\n2\n0\n"}, {"input": "3\n3\n3 4\n2 1\n3 4\n3\n2 3\n2 2\n2 0\n4\n1 7\n12 2\n2 15\n1000000000 8\n", "output": "0\n2\n0\n"}, {"input": "3\n3\n3 4\n2 1\n3 7\n3\n2 3\n2 2\n2 0\n4\n1 7\n12 2\n3 15\n1000000000 8\n", "output": ... | code_stdio |
[
{
"content": "The Collatz Conjecture states that for any natural number n, if n is even, divide it by 2. If n is odd, multiply it by 3 and add 1. If you repeat the process continuously for n, n will eventually reach 1.\n\nFor example, if n = 20, the resulting sequence will be:\n\n[20, 10, 5, 16, 8, 4, 2, 1] \n\... | [{"input": "73567465519280238573", "output": "[362]", "fn_name": "collatz"}, {"input": "1000000000000000", "output": "[276]", "fn_name": "collatz"}, {"input": "1000000000", "output": "[101]", "fn_name": "collatz"}, {"input": "500", "output": "[111]", "fn_name": "collatz"}, {"input": "100", "output": "[26]", "fn_name": ... | code_functional |
[
{
"content": "How many ways are there to place a black and a white knight on an N * M chessboard such that they do not attack each other? The knights have to be placed on different squares. A knight can move two squares horizontally and one square vertically, or two squares vertically and one square horizontall... | [{"input": "3\n29 5\n2 2\n16 7", "output": "20112\n12\n11796\n"}, {"input": "3\n16 3\n4 3\n12 4", "output": "2084\n104\n2048\n"}, {"input": "3\n29 3\n2 2\n16 7", "output": "7154\n12\n11796\n"}, {"input": "3\n16 2\n4 3\n12 3", "output": "936\n104\n1136\n"}, {"input": "3\n16 2\n4 3\n12 4", "output": "936\n104\n2048\n"}, ... | code_stdio |
[
{
"content": "You are given a positive decimal number x.\n\nYour task is to convert it to the \"simple exponential notation\".\n\nLet x = a·10^{b}, where 1 ≤ a < 10, then in general case the \"simple exponential notation\" looks like \"aEb\". If b equals to zero, the part \"Eb\" should be skipped. If a is an in... | [{"input": "2206815224318443962208128404511577750057653265995300414539703580103256087275661997018352502651118684\n", "output": "2.206815224318443962208128404511577750057653265995300414539703580103256087275661997018352502651118684E99\n"}, {"input": "22068152243184439622081284045115777500576532659953004145397035801032560... | code_stdio |
[
{
"content": "After learning a lot about space exploration, a little girl named Ana wants to change the subject.\n\nAna is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tir... | [{"input": "20\niw\nix\nudb\nbg\noi\nuo\njsm\num\ns\nquy\nqo\nbxct\nng\nrmr\nnu\nps\nio\nkh\nw\nk\n", "output": "5\n"}, {"input": "20\niw\nix\nudb\nbg\noi\nuo\njsm\nmu\ns\nquy\nqo\nbxct\nng\nrmr\nnu\nps\nio\nkh\nw\nk\n", "output": "5\n"}, {"input": "20\niw\nix\nudb\nbg\nni\nuo\njsm\nmu\ns\nquy\nqo\nbxct\nng\nrmr\nnu\np... | 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 has K favorite lucky strings A_{1}, A_{2}, ..., A_{K}. He thinks that the lucky string S is good if either |S| ≥ 47 or for some j from 1 to K we have ... | [{"input": "2 4\n2\n752\n25003\n1329\n10896\n39952297003683893618248919566249112695937429123", "output": "Good\nGood\nBad\nGood\n"}, {"input": "2 4\n1\n752\n28466\n1329\n10896\n95142413585696281004906476796906063037090967865", "output": "Bad\nGood\nGood\nGood\n"}, {"input": "2 4\n24\n501\n16429\n1329\n10896\n9514241358... | code_stdio |
[
{
"content": "\"Search\" is an operation to obtain the desired information from a large amount of information. Familiar examples include \"finding your own exam number from a large number of exam numbers\" when announcing your success, or \"finding Taro Aizu's phone number\" from your phone book. This search op... | [{"input": "7\n11\n15\n-2\n53\n51\n17\n109\n42\n4\n1\n2\n3\n10\n-1\n0", "output": "3\n2\n"}, {"input": "7\n11\n15\n-2\n53\n51\n17\n109\n42\n4\n1\n2\n3\n10\n-2\n0", "output": "3\n2\n"}, {"input": "7\n11\n15\n-2\n53\n51\n17\n109\n42\n4\n2\n2\n3\n10\n-2\n0", "output": "3\n2\n"}, {"input": "7\n11\n15\n-1\n53\n51\n56\n109\n... | code_stdio |
[
{
"content": "Given is a string S. Each character in S is either a digit (0, ..., 9) or ?.\nAmong the integers obtained by replacing each occurrence of ? with a digit, how many have a remainder of 5 when divided by 13? An integer may begin with 0.\nSince the answer can be enormous, print the count modulo 10^9+7... | [{"input": "???????????????2?????????????8???????????6????????5?6?5????1???8????1???????????????????????????????????3??????9????????????3??6???????????6???????????????????3???????????9???????3????6?5?????????????????2???????????5418??????????8????????9????????????0????????????????????????9????????????????????9??????8??... | code_stdio |
[
{
"content": "You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges.\n\nThe i-th edge (1 \\leq i \\leq M) connects Vertex a_i and Vertex b_i. \nAn edge whose removal disconnects the graph is called a bridge.\n\nFind the number of the edges tha... | [{"input": "7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7\n", "output": "4\n"}, {"input": "7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7", "output": "4"}, {"input": "6 5\n1 2\n2 3\n3 4\n4 5\n5 6\n", "output": "5\n"}, {"input": "6 5\n1 2\n2 3\n3 4\n3 5\n5 6", "output": "5\n"}, {"input": "6 5\n1 2\n2 3\n3 4\n4 5\n2 6", "output": "5\n"... | code_stdio |
[
{
"content": "Taro went to a toy store to buy a game of life made by Aizu Hobby. Life games are played using a board with squares and roulette. As shown in the figure, the board has one start point and one goal point, which are connected by a single grid. First, the pieces are placed in the square at the starti... | [{"input": "1 2 0\n1\n1 2 1\n1\n1 2 101\n1 2 1\n1\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 100\n4 3 32\n0 0 0", "output": "0\n101\n100\n50\n22\n"}, {"input": "1 2 0\n1\n1 2 1\n1\n1 2 100\n1 2 1\n1\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 100\n4 3 32\n0 0 0", "output": "0\n100\n100\n50\... | code_stdio |
[
{
"content": "Let's start from some definitions.\n\nStrings A and B are called anagrams if it's possible to rearrange the letters of string A using all the original letters exactly once and achieve string B; in other words A and B are permutations of each other. For example, remote and meteor are anagrams, race... | [{"input": "3\nmpei\nelepgaot\nitco", "output": "no such string\n"}, {"input": "3\nmpei\nglepeaot\nitco", "output": "no such string\n"}, {"input": "3\niepm\nglepeaot\nitco", "output": "no such string\n"}, {"input": "3\niepm\ngleoeaot\nitco", "output": "no such string\n"}, {"input": "3\niepm\ngleoeaot\nhtco", "output": ... | code_stdio |
[
{
"content": "Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are \"a\", \"o\", \"u\", \"i\", and \"e\". Other letters are consonant.\n\nIn Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel.... | [{"input": "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen\n", "output": "YES\n"}, {"input": "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen\n", "output": "YES\n"}, {"input": "auuaoonntanonnuewannnopuuinniwoonenn... | code_stdio |
[
{
"content": "The Bubble Cup hypothesis stood unsolved for 130 years. Who ever proves the hypothesis will be regarded as one of the greatest mathematicians of our time! A famous mathematician Jerry Mao managed to reduce the hypothesis to this problem:\n\nGiven a number m, how many polynomials P with coefficient... | [{"input": "100\n751 557 779 329 39 213 844 289 137 50 951 284 671 474 829 906 736 395 366 22 133 418 552 649 636 109 974 775 852 971 384 945 335 961 472 651 335 543 560 135 85 952 558 838 147 644 688 727 940 978 309 705 409 27 774 951 92 277 835 804 589 103 529 11 304 171 655 378 792 876 1161 36 125 378 152 958 746 98... | code_stdio |
[
{
"content": "Bob is about to take a hot bath. \n\nThere are two taps to fill the bath: a hot water tap and a cold water tap. The cold water's temperature is t1, and the hot water's temperature is t2. The cold water tap can transmit any integer number of water units per second from 0 to x1, inclusive. Similarly... | [{"input": "1000000 1000000 1000000 1000000 1000000\n", "output": "1000000 1000000\n"}, {"input": "1000000 1000000 999999 999998 1000000\n", "output": "999999 999998\n"}, {"input": "129630 805489 631548 761110 577559\n", "output": "227930 447929\n"}, {"input": "581106 975502 703094 487920 637713\n", "output": "675578 1... | code_stdio |
[
{
"content": "You are given four integers $a$, $b$, $x$ and $y$. Initially, $a \\ge x$ and $b \\ge y$. You can do the following operation no more than $n$ times:\n\n Choose either $a$ or $b$ and decrease it by one. However, as a result of this operation, value of $a$ cannot become less than $x$, and value of $... | [{"input": "7\n10 10 8 5 3\n12 8 8 7 2\n12343 43 4543 39 123212\n1000000000 1000000000 1 1 1\n1000000000 1000000000 1 1 1000000000\n10 11 2 1 5\n10 11 9 1 10\n", "output": "70\n77\n177177\n999999999000000000\n999999999\n55\n10\n"}, {"input": "7\n10 10 8 5 3\n12 8 0 7 2\n12343 43 4543 39 123212\n1000000000 1000000000 1 ... | code_stdio |
[
{
"content": "Bob likes to draw camels: with a single hump, two humps, three humps, etc. He draws a camel by connecting points on a coordinate plane. Now he's drawing camels with t humps, representing them as polylines in the plane. Each polyline consists of n vertices with coordinates (x1, y1), (x2, y2), ..., ... | [{"input": "19 7\n", "output": "197939352\n"}, {"input": "20 8\n", "output": "503245466\n"}, {"input": "19 8\n", "output": "109824208\n"}, {"input": "20 7\n", "output": "468541040\n"}, {"input": "20 9\n", "output": "90700276\n"}, {"input": "19 6\n", "output": "69183464\n"}, {"input": "20 6\n", "output": "96046590\n"}, ... | code_stdio |
[
{
"content": "The grasshopper is located on the numeric axis at the point with coordinate $x_0$.\n\nHaving nothing else to do he starts jumping between integer points on the axis. Making a jump from a point with coordinate $x$ with a distance $d$ to the left moves the grasshopper to a point with a coordinate $x... | [{"input": "9\n0 1\n0 2\n10 10\n10 197\n177 25\n10000000000 1895528572\n-433494437 87178291199\n1 0\n-1 1\n", "output": "-1\n1\n11\n-187\n202\n10000000000\n-87611785637\n1\n0\n"}, {"input": "9\n0 1\n0 2\n10 11\n10 197\n177 25\n10000000000 1895528572\n-433494437 87178291199\n1 0\n-1 1\n", "output": "-1\n1\n22\n-187\n202... | code_stdio |
[
{
"content": "Takahashi found an undirected connected graph with N vertices and M edges. The vertices are numbered 1 through N. The i-th edge connects vertices a_i and b_i, and has a weight of c_i.\n\nHe will play Q rounds of a game using this graph. In the i-th round, two vertices S_i and T_i are specified, an... | [{"input": "4 6\n1 3 10\n4 1 10\n2 4 8\n3 2 2\n3 4 8\n2 1 3\n1\n2 3", "output": "11\n"}, {"input": "4 6\n1 3 10\n4 1 10\n2 4 6\n3 2 2\n3 4 8\n2 2 3\n1\n2 3", "output": "16\n"}, {"input": "4 6\n2 1 10\n4 1 23\n2 4 6\n2 2 4\n3 4 4\n3 2 6\n1\n2 3", "output": "14\n"}, {"input": "4 6\n2 1 10\n4 1 10\n2 4 6\n3 2 2\n3 4 5\n2 ... | code_stdio |
[
{
"content": "Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new control element was delivered to the store recently and Artem immediately bought it.\n\nThat element can store information about the matrix of inte... | [{"input": "13 21 1\n2 11\n", "output": "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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0... | code_stdio |
[
{
"content": "We will call a string that can be obtained by concatenating two equal strings an even string.\nFor example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.\nYou are given an even string S consisting of lowercase English letters.\nFind the length of the longest even string that can be o... | [{"input": "akasakaakasakasakaakas\n", "output": "14\n"}, {"input": "akasakaakasakasaka`kas", "output": "14\n"}, {"input": "akasakaakasakasakb`kas", "output": "14\n"}, {"input": "akakasaakasakasakaakas", "output": "4\n"}, {"input": "akakasaakasakas`kaakas", "output": "4\n"}, {"input": "akakasaakasakbs`kaakas", "output"... | code_stdio |
[
{
"content": "Alex decided to go on a touristic trip over the country.\n\nFor simplicity let's assume that the country has $n$ cities and $m$ bidirectional roads connecting them. Alex lives in city $s$ and initially located in it. To compare different cities Alex assigned each city a score $w_i$ which is as hig... | [{"input": "30 30\n81 86 81 91 90 100 98 89 96 97 88 99 68 23 82 107 94 80 99 67 70 90 81 74 91 100 92 89 74 98\n16 26\n20 3\n23 16\n17 27\n30 22\n18 23\n14 30\n25 4\n3 8\n18 9\n29 26\n27 21\n26 6\n10 7\n28 5\n1 30\n28 30\n12 15\n17 25\n26 15\n30 2\n5 15\n14 20\n10 4\n24 16\n8 7\n11 30\n19 8\n21 9\n13 15\n2\n", "output... | code_stdio |
[
{
"content": "Given is a string S of length N-1. Each character in S is `<` or `>`.\n\nA sequence of N non-negative integers, a_1,a_2,\\cdots,a_N, is said to be good when the following condition is satisfied for all i (1 \\leq i \\leq N-1):\n\n* If S_i= `<`: a_i<a_{i+1}\n* If S_i= `>`: a_i>a_{i+1}\n\n\n\nFind t... | [{"input": "<>>><<<<<><<>>><", "output": "29\n"}, {"input": "<>>>><<<<><<<>><", "output": "28\n"}, {"input": "<>><<<><<<<>>>><", "output": "26\n"}, {"input": "<<>><<><<<<>>>><", "output": "24\n"}, {"input": "<>>>><<<<><<>><<", "output": "27\n"}, {"input": "<>>>>><<<><<<><<", "output": "30\n"}, {"input": "<>>><>><<><<<>... | code_stdio |
[
{
"content": "A non-empty string is called palindrome, if it reads the same from the left to the right and from the right to the left. For example, \"abcba\", \"a\", and \"abba\" are palindromes, while \"abab\" and \"xy\" are not.\n\nA string is called a substring of another string, if it can be obtained from t... | [{"input": "21\narozaupalanalapuazora\n", "output": "aaaaaaaallnoopprruuzz\n"}, {"input": "16\ngagadbcgghhchbdf\n", "output": "aabbccddfgggghhh\n"}, {"input": "15\nabacabadabacaba\n", "output": "aaaaaaaabbbbccd\n"}, {"input": "10\nmsunonames\n", "output": "aemmnnossu\n"}, {"input": "9\nabcabcabc\n", "output": "aaabbbcc... | code_stdio |
[
{
"content": "You've got a string a_1, a_2, ..., a_n, consisting of zeros and ones.\n\nLet's call a sequence of consecutive elements a_i, a_{i + 1}, …, a_j (1≤ i≤ j≤ n) a substring of string a. \n\nYou can apply the following operations any number of times:\n\n * Choose some substring of string a (for example,... | [{"input": "25 999999998 999999999\n1011001110101010100110001\n", "output": "7999999985\n"}, {"input": "25 999999998 999999999\n1011001110101010100110101\n", "output": "8999999983\n"}, {"input": "25 999999998 999999999\n1011001110101010100111001\n", "output": "7999999985"}, {"input": "4 360253575 1080814150\n1101\n", "... | code_stdio |
[
{
"content": "Gildong is playing a video game called Block Adventure. In Block Adventure, there are $n$ columns of blocks in a row, and the columns are numbered from $1$ to $n$. All blocks have equal heights. The height of the $i$-th column is represented as $h_i$, which is the number of blocks stacked in the $... | [{"input": "1\n30 0 0\n-1 1 0 -1 1 0 0 0 0 0 0 -1 2 1 -1 -1 0 -1 0 0 0 1 1 -2 2 0 -1 2 0 -1 -2 -1 0 1 0 0 1 1 -1 1 0 0 1 1 0 0 1 0 0 0 0 1 0 -1 2 0 1 1 1 0 0 1 -1 0 1 -1 1 -1 -2 -1 0 0 0 0 -1 0 2 0 0 0 -1 -2 0 1 1 -1 1 1 0 1 -1 -1 -1 -4 -2 0 0\n", "output": "NO\n"}, {"input": "1\n30 0 0\n-1 1 0 -1 1 0 0 0 0 0 0 -1 2 1 ... | code_stdio |
[
{
"content": "Nezzar's favorite digit among $1,\\ldots,9$ is $d$. He calls a positive integer lucky if $d$ occurs at least once in its decimal representation.\n\nGiven $q$ integers $a_1,a_2,\\ldots,a_q$, for each $1 \\le i \\le q$ Nezzar would like to know if $a_i$ can be equal to a sum of several (one or more)... | [{"input": "2\n3 3\n24 21 27\n10 4\n74 13 26 95 102 51 34 58 42 60\n", "output": "YES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "2\n3 3\n27 21 27\n10 4\n74 13 26 95 102 51 34 58 42 60\n", "output": "YES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "2\n3 3\n27... | code_stdio |
[
{
"content": "Given a complete binary tree with the height of H, we index the nodes respectively top-down and left-right from 1. The i-th node stores a positive integer V_{i}. Define P_{i} as follows: P_{i}=V_{i} if the i-th node is a leaf, otherwise P_{i}=max(V_{i}*P_{L}, V_{i}*P_{R}), where L and R are the in... | [{"input": "2\n2 1 6\n3\n7 2 26 2 16 8 13\n0", "output": "12\n2366\n"}, {"input": "2\n1 2 3\n3\n6 2 10 2 12 20 13\n0", "output": "3\n1200\n"}, {"input": "2\n1 2 3\n3\n6 2 10 2 12 9 17\n0", "output": "3\n1020\n"}, {"input": "2\n2 1 3\n3\n7 2 14 2 16 8 13\n0", "output": "6\n1274\n"}, {"input": "2\n2 1 3\n3\n7 2 26 2 16 8... | code_stdio |
[
{
"content": "Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base.\n\nLet we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. T... | [{"input": "5 3 10000 3241\n5 12 2\n", "output": "58892\n"}, {"input": "5 3 3521 10000\n5 12 2\n", "output": "58168\n"}, {"input": "5 3 10000 2737\n5 12 2\n", "output": "52844\n"}, {"input": "5 3 3521 10010\n5 12 2\n", "output": "58198\n"}, {"input": "5 3 3521 10000\n6 12 2\n", "output": "58168\n"}, {"input": "5 3 1000... | code_stdio |
[
{
"content": "Alan decided to get in shape for the summer, so he created a precise workout plan to follow. His plan is to go to a different gym every day during the next N days and lift $X[i]$ grams on day $i$. In order to improve his workout performance at the gym, he can buy exactly one pre-workout drink at t... | [{"input": "5 00000\n10000 30000 30000 40000 19505\n27261\n14 2 8 5 6\n", "output": "16\n"}, {"input": "5 00000\n10000 30000 30000 40000 19505\n27261\n14 0 8 5 6\n", "output": "14\n"}, {"input": "5 10000\n10000 40000 30000 30000 20000\n10000\n5 2 8 3 6\n", "output": "-1\n"}, {"input": "5 10000\n10000 37530 30000 30000 ... | code_stdio |
[
{
"content": "You are given a following process. \n\nThere is a platform with $n$ columns. $1 \\times 1$ squares are appearing one after another in some columns on this platform. If there are no squares in the column, a square will occupy the bottom row. Otherwise a square will appear at the top of the highest ... | [{"input": "1000 10\n999 999 998 34 454 546 343 35 34 1000\n", "output": "0\n"}, {"input": "1000 10\n999 999 998 34 454 546 343 35 34 1000\n", "output": "0\n"}, {"input": "1000 10\n999 999 998 34 454 546 343 69 34 1000\n", "output": "0\n"}, {"input": "1000 10\n999 999 998 34 454 546 343 67 34 1000\n", "output": "0\n"},... | code_stdio |
[
{
"content": "Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove t... | [{"input": "43 959134961 -868367850 142426380\n921743429 63959718 -797293233 122041422 -407576197 700139744 299598010 168207043 362252658 591926075 941946099 812263640 -76679927 -824267725 89529990 -73303355 83596189 -982699817 -235197848 654773327 125211479 -497091570 -2301804 203486596 -126652024 309810546 -581289415... | code_stdio |
[
{
"content": "Polycarpus has got n candies and m friends (n ≥ m). He wants to make a New Year present with candies to each friend. Polycarpus is planning to present all candies and he wants to do this in the fairest (that is, most equal) manner. He wants to choose such a_{i}, where a_{i} is the number of candie... | [{"input": "100 100\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 "}, {"input": "100 100\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | code_stdio |
[
{
"content": "# Task\n Timed Reading is an educational tool used in many schools to improve and advance reading skills. A young elementary student has just finished his very first timed reading exercise. Unfortunately he's not a very good reader yet, so whenever he encountered a word longer than maxLength, he s... | [{"input": "5\n\"Now and then, however, he is horribly thoughtless, and seems to take a real delight in giving me pain.\"", "output": "[14]", "fn_name": "timed_reading"}, {"input": "6\n\"Zebras evolved among the Old World horses within the last four million years.\"", "output": "[11]", "fn_name": "timed_reading"}, {"in... | code_functional |
[
{
"content": "In Byteland they have a very strange monetary system.\n\nEach Bytelandian gold coin has an integer number written on it. A coin n\ncan be exchanged in a bank into three coins: n/2, n/3 and n/4.\nBut these numbers are all rounded down (the banks have to make a profit).\n\nYou can also sell Byteland... | [{"input": "12\n10", "output": "13\n10\n"}, {"input": "12\n19", "output": "13\n19\n"}, {"input": "12\n11", "output": "13\n11\n"}, {"input": "12\n21", "output": "13\n22\n"}, {"input": "12\n27", "output": "13\n28\n"}, {"input": "12\n12", "output": "13\n13\n"}, {"input": "12\n15", "output": "13\n15\n"}, {"input": "12\n14"... | code_stdio |
[
{
"content": "Sherlock Holmes and Dr. Watson played some game on a checkered board n × n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square of the board contains exactly one number. To understand who has won, they ne... | [{"input": "12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 29 76 87 2 27 19 11 42 71 38\n69 82 73 52 44 23 92 1... | code_stdio |
[
{
"content": "Theory\n This section does not need to be read and can be skipped, but it does provide some clarity into the inspiration behind the problem.\nIn music theory, a major scale consists of seven notes, or scale degrees, in order (with tonic listed twice for demonstrative purposes):\n\nTonic, the base ... | [{"input": "[-11, -9, -7, -6, -4, -2, 0, 1, 3, 6, 8, 10, 12, 13, 15]", "output": "[true]", "fn_name": "is_tune"}, {"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]", "output": "[false]", "fn_name": "is_tune"}, {"input": "[-4, -2, 0, 1, 3, 6, 8, 10, 12, 13, 15]", "output": "[true]", "fn_name": "is_tune"}, {"input": "[1... | code_functional |
[
{
"content": "You have $2n$ integers $1, 2, \\dots, 2n$. You have to redistribute these $2n$ elements into $n$ pairs. After that, you choose $x$ pairs and take minimum elements from them, and from the other $n - x$ pairs, you take maximum elements.\n\nYour goal is to obtain the set of numbers $\\{b_1, b_2, \\do... | [{"input": "3\n1\n1\n5\n1 4 5 9 10\n2\n3 4\n", "output": "\n1\n3\n1\n"}, {"input": "3\n1\n1\n5\n1 4 5 9 10\n2\n3 4\n", "output": "1\n3\n1\n"}, {"input": "3\n1\n1\n5\n1 4 5 9 10\n2\n1 4\n", "output": "1\n3\n1\n"}, {"input": "3\n1\n1\n5\n1 4 5 9 10\n2\n2 4\n", "output": "1\n3\n2\n"}, {"input": "3\n1\n1\n5\n1 4 5 7 10\n2\... | code_stdio |
[
{
"content": "On a two-dimensional plane, there are N red points and N blue points.\nThe coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).\nA red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than tha... | [{"input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n6 3\n-1 4\n8 4\n14 17", "output": "3\n"}, {"input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n6 3\n-1 4\n8 4\n9 17", "output": "3\n"}, {"input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n8 3\n-1 4\n14 4\n9 4", "output": "2\n"}, {"input": "5\n0 0\n4 1\n5 5\n6 6\n13 11\n2 2\n3 3\n1 4\n8... | code_stdio |
[
{
"content": "Find the maximum possible sum of the digits (in base 10) of a positive integer not greater than N.\n\nConstraints\n\n* 1\\leq N \\leq 10^{16}\n* N is an integer.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nN\n\n\nOutput\n\nPrint the maximum possible sum of the digi... | [{"input": "1265641936938969", "output": "135\n"}, {"input": "2005985506723837", "output": "136\n"}, {"input": "5193523582167964", "output": "139\n"}, {"input": "4944180382968715", "output": "138\n"}, {"input": "7493811264493993", "output": "141\n"}, {"input": "813322357948504", "output": "133\n"}, {"input": "127248513... | code_stdio |
[
{
"content": "Berland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The cities are connected by one-way roads, the travel time for each of the road is a positive integer.\n\nOnce a year the President visited his historic home town t, for which ... | [{"input": "2 9 1 2\n1 2 1000000\n1 2 1000000\n1 2 1100000\n1 2 1000000\n1 2 2\n1 2 1000000\n1 2 1000000\n1 2 1000000\n1 2 1000000\n", "output": "CAN 999999\nCAN 999999\nCAN 1099999\nCAN 999999\nYES\nCAN 999999\nCAN 999999\nCAN 999999\nCAN 999999\n"}, {"input": "2 9 1 2\n1 2 1000000\n1 2 1000000\n1 2 1000000\n1 2 10000... | code_stdio |
[
{
"content": "There is an array of strings. All strings contains similar _letters_ except one. Try to find it!\n\n```python\nfind_uniq([ 'Aa', 'aaa', 'aaaaa', 'BbBb', 'Aaaa', 'AaAaAa', 'a' ]) # => 'BbBb'\nfind_uniq([ 'abc', 'acb', 'bac', 'foo', 'bca', 'cab', 'cba' ]) # => 'foo'\n```\n\nStrings may contain space... | [{"input": "[\"Tom Marvolo Riddle\", \"I am Lord Voldemort\", \"Harry Potter\"]", "output": "[\"Harry Potter\"]", "fn_name": "find_uniq"}, {"input": "[\"foobar\", \"barfo\", \"fobara\", \" \", \"fobra\", \"oooofrab\"]", "output": "[\" \"]", "fn_name": "find_uniq"}, {"input": "[\"Aa\", \"aaa\", \"aaaaa\", \"BbBb\", ... | code_functional |
[
{
"content": "You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n.\nIt is known that each of the n integers 1,...,n appears at least once in this sequence.\nFor each integer k=1,...,n+1, find the number of the different subsequences (not necessarily con... | [{"input": "32\n29 19 7 10 26 32 27 4 11 20 2 8 16 23 5 14 6 12 17 22 18 30 28 24 15 1 25 3 13 21 19 31 9\n", "output": "32\n525\n5453\n40919\n237336\n1107568\n4272048\n13884156\n38567100\n92561040\n193536720\n354817320\n573166440\n818809200\n37158313\n166803103\n166803103\n37158313\n818809200\n573166440\n354817320\n19... | code_stdio |
[
{
"content": "A tetromino is a figure formed by joining four squares edge to edge. We will refer to the following seven kinds of tetromino as I-, O-, T-, J-, L-, S- and Z-tetrominos, respectively:\n\na60bcb8e9e8f22e3af51049eda063392.png\n\nSnuke has many tetrominos. The number of I-, O-, T-, J-, L-, S- and Z-te... | [{"input": "10 1 2 0 0 -1 0", "output": "11\n"}, {"input": "1 13 1 0 1 -1 2", "output": "13\n"}, {"input": "10 2 0 0 4 -1 0", "output": "16\n"}, {"input": "1 26 1 0 1 -1 2", "output": "26\n"}, {"input": "10 3 0 0 4 -1 0", "output": "17\n"}, {"input": "1 26 1 0 2 -1 2", "output": "28\n"}, {"input": "10 1 0 0 4 -1 0", "o... | code_stdio |
[
{
"content": "YouKn0wWho has an integer sequence $a_1, a_2, \\ldots a_n$. Now he will split the sequence $a$ into one or more consecutive subarrays so that each element of $a$ belongs to exactly one subarray. Let $k$ be the number of resulting subarrays, and $h_1, h_2, \\ldots, h_k$ be the lengths of the longes... | [{"input": "4\n7\n1 12 3 0 1 1 5\n3\n2 2 5\n5\n1 3 2 4 4\n4\n4 5 -1 1\n", "output": "YES\nYES\nYES\nYES\n"}, {"input": "4\n7\n1 11 3 2 1 1 5\n3\n2 2 5\n5\n1 3 2 4 4\n4\n4 5 -2 1\n", "output": "YES\nYES\nYES\nYES\n"}, {"input": "4\n7\n1 4 3 2 -1 1 -1\n3\n1 6 0\n3\n1 4 2 4 2\n4\n4 2 1 1\n", "output": "YES\nYES\nYES\nYES\... | code_stdio |
[
{
"content": "You have a large rectangular board which is divided into $n \\times m$ cells (the board has $n$ rows and $m$ columns). Each cell is either white or black.\n\nYou paint each white cell either red or blue. Obviously, the number of different ways to paint them is $2^w$, where $w$ is the number of whi... | [{"input": "5 4\noooo\no*oo\noooo\n**oo\nooo*\n", "output": "239616\n"}, {"input": "5 4\noooo\no*oo\noooo\n**oo\nooo*\n", "output": "239616\n"}, {"input": "5 4\noooo\no*oo\noooo\n**oo\n*ooo\n", "output": "249856\n"}, {"input": "5 4\noooo\no*oo\noooo\no*o*\nooo*\n", "output": "233472\n"}, {"input": "5 4\noooo\no*oo\nooo... | code_stdio |
[
{
"content": "You are given an array $d_1, d_2, \\dots, d_n$ consisting of $n$ integer numbers.\n\nYour task is to split this array into three parts (some of which may be empty) in such a way that each element of the array belongs to exactly one of the three parts, and each of the parts forms a consecutive cont... | [{"input": "5\n2 3 5 4 10\n", "output": "10\n"}, {"input": "1\n1000000000\n", "output": "0\n"}, {"input": "1\n1000000000\n", "output": "0\n"}, {"input": "1\n1000000100\n", "output": "0\n"}, {"input": "5\n1 15 4 2 1\n", "output": "1\n"}, {"input": "1\n1000000110\n", "output": "0\n"}, {"input": "5\n2 3 5 4 6\n", "output"... | code_stdio |
[
{
"content": "There are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type a_{i}.\n\nLet's call a sequence of consecutive pearls a segment. Let's call a segment good if it contains two pearls of the same type.\n\nSplit the row of the pea... | [{"input": "10\n460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451\n", "output": "5\n1 2\n3 4\n5 6\n7 8\n9 10\n"}, {"input": "10\n460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451\n", "output": "5\n1 2\n3 4\n5 6\n7 8\n9 1... | code_stdio |
[
{
"content": "Alice has a string consisting of characters 'A', 'B' and 'C'. Bob can use the following transitions on any substring of our string in any order any number of times: A $\\rightarrow$ BC B $\\rightarrow$ AC C $\\rightarrow$ AB AAA $\\rightarrow$ empty string \n\nNote that a substring is one or ... | [{"input": "AAAAAA\nAAAAAA\n30\n3 4 1 2\n3 3 4 4\n5 6 3 4\n3 3 2 3\n6 6 1 5\n2 4 4 6\n1 6 2 5\n6 6 3 4\n3 5 1 4\n4 5 3 6\n2 3 2 4\n3 4 4 4\n6 6 4 6\n3 3 2 5\n1 5 3 3\n4 6 1 2\n6 6 6 6\n3 3 3 4\n6 6 6 6\n5 6 4 4\n6 6 5 5\n2 3 1 4\n3 6 4 5\n3 5 6 6\n4 5 2 6\n5 6 6 6\n1 4 2 5\n4 5 2 5\n4 5 1 3\n2 2 4 6\n", "output": "1110... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.