messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Mahmoud and Ehab continue their adventures! As everybody in the evil land knows, Dr. Evil likes bipartite graphs, especially trees.\n\nA tree is a connected acyclic graph. A bipartite graph is a graph, whose vertices can be partitioned into 2 sets in such a way, that for each edge (u, v) that belo... | [{"input": "10\n7 6\n2 10\n7 1\n8 5\n9 3\n2 3\n8 7\n10 8\n10 4\n", "output": "15\n"}, {"input": "10\n7 6\n2 7\n4 1\n8 5\n9 4\n5 3\n8 7\n10 8\n10 4\n", "output": "16\n"}, {"input": "10\n2 6\n3 7\n8 4\n4 10\n6 9\n9 7\n3 10\n1 2\n5 8\n", "output": "16\n"}, {"input": "10\n7 6\n2 7\n4 1\n8 5\n9 4\n5 3\n8 7\n10 8\n10 4\n", "... | code_stdio |
[
{
"content": "A: A-Z Cat / A-Z Cat\n\nstory\n\nAizunyan is a second-year student who belongs to the programming contest club of Wakagamatsu High School, commonly known as the Prokon club. It's so cute. Aizu Nyan was asked by her friend Joy to take care of her cat. It is a rare cat called A-Z cat. Aizunyan named... | [{"input": "AOZUNYANPERIPERO", "output": "AZ\n"}, {"input": "OREQIRMQEAYNUYOA", "output": "-1\n"}, {"input": "OREPIREPNAYNUZOA", "output": "AZ\n"}, {"input": "OREPIRNPEAYNUZOA", "output": "AZ\n"}, {"input": "OREQIRNPEAYNUZOA", "output": "AZ\n"}, {"input": "OREQIRMPEAYNUZOA", "output": "AZ\n"}, {"input": "AOZUNYAEPMRIQE... | code_stdio |
[
{
"content": "Recently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk. \n\nEmpirically Polycarp learned that the dog needs at least k walks for any two consecutive days in order to feel good. For example, if k = 5 and yeste... | [{"input": "100 500\n64 140 15 221 24 106 73 30 275 97 296 55 5 30 47 199 130 44 72 170 7 204 359 40 128 117 45 192 344 112 0 11 196 78 73 53 222 93 88 151 99 283 60 71 4 87 226 46 66 74 23 89 77 60 397 181 0 101 358 54 124 155 19 218 9 140 161 130 308 85 103 85 300 128 19 108 225 136 100 54 30 24 129 245 128 88 160 12... | code_stdio |
[
{
"content": "There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these.\n\nOnly Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditi... | [{"input": "12 14 3\ncaababaccaba", "output": "No\nYes\nYes\nYes\nYes\nYes\nYes\nNo\nNo\nYes\nYes\nYes\n"}, {"input": "12 14 3\nabaccababaac", "output": "Yes\nYes\nYes\nNo\nNo\nYes\nYes\nYes\nYes\nYes\nYes\nNo\n"}, {"input": "12 16 2\ncabbabaacaaa", "output": "No\nYes\nYes\nYes\nYes\nNo\nYes\nYes\nNo\nYes\nYes\nYes\n"}... | code_stdio |
[
{
"content": "Let's call a positive integer $n$ ordinary if in the decimal notation all its digits are the same. For example, $1$, $2$ and $99$ are ordinary numbers, but $719$ and $2021$ are not ordinary numbers.\n\nFor a given number $n$, find the number of ordinary numbers among the numbers from $1$ to $n$.\n... | [{"input": "6\n2\n2\n3\n8\n10\n100\n", "output": "2\n2\n3\n8\n9\n18\n"}, {"input": "6\n2\n2\n3\n4\n10\n100\n", "output": "2\n2\n3\n4\n9\n18\n"}, {"input": "6\n1\n2\n3\n4\n5\n100\n", "output": "\n1\n2\n3\n4\n5\n18\n"}, {"input": "6\n1\n2\n3\n4\n5\n100\n", "output": "1\n2\n3\n4\n5\n18\n"}, {"input": "6\n1\n2\n3\n4\n8\n10... | code_stdio |
[
{
"content": "Appleman and Toastman play a game. Initially Appleman gives one group of n numbers to the Toastman, then they start to complete the following tasks:\n\n * Each time Toastman gets a group of numbers, he sums up all the numbers and adds this sum to the score. Then he gives the group to the Appleman... | [{"input": "10\n1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000\n", "output": "64000000\n"}, {"input": "10\n171308 397870 724672 431255 228496 892002 542924 718337 888642 161821\n", "output": "40204082\n"}, {"input": "10\n888642 724672 724672 431255 431255 397870 397870 397870 397870 228... | code_stdio |
[
{
"content": "Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.\n\nIn the given sequence moving up is described by character U and moving right is described by character R... | [{"input": "100\nUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\n", "output": "100\n"}, {"input": "100\nUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU\n", "output": "100\n"}, {"input": "100\nRRURRUUUURURRRURRRRUR... | code_stdio |
[
{
"content": "Consider the set of all nonnegative integers: ${0, 1, 2, \\dots}$. Given two integers $a$ and $b$ ($1 \\le a, b \\le 10^4$). We paint all the numbers in increasing number first we paint $0$, then we paint $1$, then $2$ and so on.\n\nEach number is painted white or black. We paint a number $i$ acco... | [{"input": "4\n10 10\n1 10\n6 9\n7 3\n", "output": "Infinite\nFinite\nInfinite\nFinite\n"}, {"input": "4\n10 10\n1 10\n3 9\n7 3\n", "output": "Infinite\nFinite\nInfinite\nFinite\n"}, {"input": "4\n10 10\n1 10\n6 9\n7 3\n", "output": "Infinite\nFinite\nInfinite\nFinite\n"}, {"input": "4\n10 8\n1 10\n6 9\n7 3\n", "output... | code_stdio |
[
{
"content": "I love Fibonacci numbers in general, but I must admit I love some more than others. \n\nI would like for you to write me a function that when given a number (n) returns the n-th number in the Fibonacci Sequence.\n\nFor example:\n\n```python\n nth_fib(4) == 2\n```\n\nBecause 2 is the 4th number ... | [{"input": "22", "output": "[10946]", "fn_name": "nth_fib"}, {"input": "23", "output": "[17711]", "fn_name": "nth_fib"}, {"input": "24", "output": "[28657]", "fn_name": "nth_fib"}, {"input": "25", "output": "[46368]", "fn_name": "nth_fib"}, {"input": "18", "output": "[1597]", "fn_name": "nth_fib"}, {"input": "19", "out... | code_functional |
[
{
"content": "Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it.\n\nThe consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \\times 1.08 yen (rounded down... | [{"input": "1101", "output": "1020\n"}, {"input": "1111", "output": "1029\n"}, {"input": "1100", "output": "1019\n"}, {"input": "1011", "output": "937\n"}, {"input": "239", "output": "222\n"}, {"input": "442", "output": "410\n"}, {"input": "452", "output": "419\n"}, {"input": "192", "output": "178\n"}, {"input": "322",... | code_stdio |
[
{
"content": "problem\n\nGiven the squares of $ R * C $. Each square is either an empty square or a square with a hole. The given square meets the following conditions.\n\n* The cells with holes are connected. (You can move a square with a hole in the cross direction to any square with a hole)\n* Empty cells ar... | [{"input": "3 5\n.....\n.#.#.\n.###.\n.#.#.\n.....", "output": "3\n"}, {"input": "3 1\n.....\n.#.#.\n.###.\n.#.#.\n.....", "output": "0\n"}, {"input": "2 5\n.....\n.#.#.\n.###.\n.#.#.\n.....", "output": "2\n"}, {"input": "4 2\n.....\n.#.#/\n.###.\n.#.#.\n.....", "output": "1\n"}, {"input": "0 1\n.....\n.#.#.\n.###.\n.#... | code_stdio |
[
{
"content": "There are n cities in the country where the Old Peykan lives. These cities are located on a straight line, we'll denote them from left to right as c_1, c_2, ..., c_{n}. The Old Peykan wants to travel from city c_1 to c_{n} using roads. There are (n - 1) one way roads, the i-th road goes from city ... | [{"input": "100 6\n15 20 32 8 29 10 33 15 9 26 28 21 34 7 41 23 9 17 16 15 14 29 25 31 24 26 13 18 19 40 9 16 36 32 39 11 4 31 37 28 32 40 7 18 45 21 15 45 6 15 27 22 27 41 28 7 22 43 25 40 6 7 32 31 36 14 5 27 31 28 23 9 13 14 7 25 28 33 40 22 44 9 29 26 41 30 16 15 31 42 13 40 36 44 17 29 32 29 38 13\n4 4 3 4 3 4 3 3... | code_stdio |
[
{
"content": "# Task\nYou are a lifelong fan of your local football club, and proud to say you rarely miss a game. Even though you're a superfan, you still hate boring games. Luckily, boring games often end in a draw, at which point the winner is determined by a penalty shoot-out, which brings some excitement t... | [{"input": "100\n[100, 100]", "output": "[2]", "fn_name": "penaltyShots"}, {"input": "10\n[10, 10]", "output": "[2]", "fn_name": "penaltyShots"}, {"input": "2\n[1, 2]", "output": "[3]", "fn_name": "penaltyShots"}, {"input": "5\n[5, 5]", "output": "[2]", "fn_name": "penaltyShots"}, {"input": "0\n[0, 0]", "output": "[6]"... | code_functional |
[
{
"content": "There is a very secret base in Potatoland where potato mash is made according to a special recipe. The neighbours from Porridgia decided to seize this recipe and to sell it to Pilauland. For this mission they have been preparing special agent Pearlo for many years. When, finally, Pearlo learned al... | [{"input": "...\nX.X\n...\n", "output": "YES\n"}, {"input": "X.X\n.X.\nX.X\n", "output": "YES\n"}, {"input": "...\nXXX\n...\n", "output": "YES\n"}, {"input": "X..\n.X.\n..X\n", "output": "YES\n"}, {"input": "XXX\nX.X\nXXX\n", "output": "YES\n"}, {"input": "...\n.X.\n...\n", "output": "YES\n"}, {"input": "XXX\n.X.\nXXX\... | code_stdio |
[
{
"content": "Niwango has N cards, numbered 1,2,\\ldots,N. He will now arrange these cards in a row.\n\nNiwango wants to know if there is a way to arrange the cards while satisfying all the N conditions below. To help him, determine whether such a way exists. If the answer is yes, also find the lexicographicall... | [{"input": "13\n4 3 4 0 12 4 11 5 4 11 13 13 12", "output": "1 2 4 3 5 6 7 8 9 10 13 11 12\n"}, {"input": "13\n4 3 2 0 12 4 8 10 4 11 13 13 12", "output": "1 2 4 3 5 6 7 9 8 11 12 10 13\n"}, {"input": "13\n2 3 2 0 12 4 8 10 4 11 13 13 12", "output": "1 3 4 2 5 6 7 9 8 11 12 10 13\n"}, {"input": "13\n4 3 4 0 12 3 11 5 4... | code_stdio |
[
{
"content": "Given are two sequences a=\\{a_0,\\ldots,a_{N-1}\\} and b=\\{b_0,\\ldots,b_{N-1}\\} of N non-negative integers each.\nSnuke will choose an integer k such that 0 \\leq k < N and an integer x not less than 0, to make a new sequence of length N, a'=\\{a_0',\\ldots,a_{N-1}'\\}, as follows:\n - a_i'= a... | [{"input": "5\n0 0 0 0 0\n2 2 2 2 2\n", "output": "0 2\n1 2\n2 2\n3 2\n4 2\n"}, {"input": "5\n0 0 0 0 0\n2 2 2 2 2", "output": "0 2\n1 2\n2 2\n3 2\n4 2"}, {"input": "6\n0 1 3 7 6 4\n1 5 4 6 2 3\n", "output": "2 2\n5 5\n"}, {"input": "6\n0 1 3 7 6 4\n1 5 4 6 2 3", "output": "2 2\n5 5"}, {"input": "6\n0 1 2 7 6 4\n1 5 4 ... | code_stdio |
[
{
"content": "Theofanis has a riddle for you and if you manage to solve it, he will give you a Cypriot snack halloumi for free (Cypriot cheese).\n\nYou are given an integer $n$. You need to find two integers $l$ and $r$ such that $-10^{18} \\le l < r \\le 10^{18}$ and $l + (l + 1) + \\ldots + (r - 1) + r = n$.\... | [{"input": "7\n1\n3\n20\n2\n110\n23\n4838829180358\n", "output": "0 1\n-2 3\n-19 20\n-1 2\n-109 110\n-22 23\n-4838829180357 4838829180358\n"}, {"input": "7\n1\n2\n12\n2\n101\n56\n3000000000000\n", "output": "0 1\n-1 2\n-11 12\n-1 2\n-100 101\n-55 56\n-2999999999999 3000000000000\n"}, {"input": "7\n1\n3\n32\n2\n110\n23\... | code_stdio |
[
{
"content": "Example\n\nInput\n\n4\nDurett 7\nGayles 3\nFacenda 6\nDaughtery 0\n1\n+ Mccourtney 2\n\n\nOutput\n\nMccourtney is not working now.\nDurett is working hard now.\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your com... | [{"input": "4\nDurett 10\nGayles 4\nF`cenda 10\nyrethguaD 0\n1\n+ Mccourtney 1", "output": "Mccourtney is not working now.\nF`cenda is working hard now.\n"}, {"input": "4\nDurett 10\nGaxles 4\nFacenda 10\nyrethguaD 0\n1\n+ yentruoccM 2", "output": "yentruoccM is not working now.\nFacenda is working hard now.\n"}, {"inp... | code_stdio |
[
{
"content": "Petya has noticed that when he types using a keyboard, he often presses extra buttons and adds extra letters to the words. Of course, the spell-checking system underlines the words for him and he has to click every word and choose the right variant. Petya got fed up with correcting his mistakes hi... | [{"input": "qybldcgfhdhhhhhhhhhhopqkhuczzytzluiahwbqjltgafvvoecititchjwdoljiehubngmtjckqymldhoncgtqhxnqvoagnrmur\nqybldcgfhdhhhhhhhhhopqkhuczzytzluiahwbqjltgafvvoecititchjwdoljiehubngmtjckqymldhoncgtqhxnqvoagnrmur\n", "output": "10\n11 12 13 14 15 16 17 18 19 20 "}, {"input": "aaaaaaaaaaa\naaaaaaaaaa\n", "output": "11\... | code_stdio |
[
{
"content": "Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out. This time he found an old dusty graph theory notebook with a description of a graph.\n\nIt is an undirected weighted graph on n vertices. It is a complete graph: each p... | [{"input": "15 10\n2 3\n5 4\n5 12\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n6 4\n5 12\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n5 8\n5 6\n5 7\n3 8\n3 10\n11 12\n12 13\n13 14\n14 15\n", "output": "0\n"}, {"input": "15 10\n2 3\n... | code_stdio |
[
{
"content": "Once Bob needed to find the second order statistics of a sequence of integer numbers. Lets choose each number from the sequence exactly once and sort them. The value on the second position is the second order statistics of the given sequence. In other words it is the smallest element strictly grea... | [{"input": "99\n10 -84 -100 -100 73 -64 -100 -94 33 -100 -100 -100 -100 71 64 24 7 -100 -32 -100 -100 77 -100 62 -12 55 45 -100 -100 -80 -100 -100 -100 -100 -100 -100 -100 -100 -100 -39 -48 -100 -34 47 -100 -100 -100 -100 -100 -77 -100 -100 -100 -100 -100 -100 -52 40 -55 -100 -44 -100 72 33 70 -100 -100 -78 -100 -3 100... | code_stdio |
[
{
"content": "You are given two arrays $a$ and $b$, both of length $n$.\n\nYou can perform the following operation any number of times (possibly zero): select an index $i$ ($1 \\leq i \\leq n$) and swap $a_i$ and $b_i$.\n\nLet's define the cost of the array $a$ as $\\sum_{i=1}^{n} \\sum_{j=i + 1}^{n} (a_i + a_j... | [{"input": "1\n100\n77 18 18 20 58 11 45 18 21 15 44 87 77 65 94 83 68 73 43 84 75 100 66 39 63 44 60 16 100 4 83 53 37 11 95 71 38 57 66 31 40 60 36 37 92 79 30 55 46 25 54 45 85 38 29 82 60 11 11 69 30 1 53 100 62 61 17 75 99 9 31 8 100 53 57 8 11 26 95 72 50 77 90 88 80 84 53 50 23 3 78 27 76 82 4 7 36 13 63 100\n1 ... | code_stdio |
[
{
"content": "BerOilGasDiamondBank has branches in n cities, at that n is an even number. The bank management wants to publish a calendar with the names of all those cities written in two columns: the calendar should consist of exactly n / 2 lines of strictly equal length, each of which contains exactly two nam... | [{"input": "58\nesgdfmf\nxfkluadj\nqhvh\njwhuyhm\nmgi\nysgc\nvhhenku\npb\ntr\nu\njyrpjnpd\nkluadjo\nopb\ncopb\ngcyhceo\nr\ndjo\nxfklu\neo\nadjo\nfkluadjo\nybe\nwljwh\nqhvhh\nrhgotp\nyhceo\nuyhm\nvdd\nyhm\nysgcyhc\nvddrhg\nril\nwljwhu\nx\nqh\nhceo\ntfcopb\nmgitfc\nvddrh\nmgitfco\nxf\nmgitf\ncyoybe\notp\no\nljwhuyhm\nysg... | code_stdio |
[
{
"content": "The only difference between easy and hard versions are constraints on $n$ and $k$.\n\nYou are messaging in one of the popular social networks via your smartphone. Your smartphone can show at most $k$ most recent conversations with your friends. Initially, the screen is empty (i.e. the number of di... | [{"input": "10 4\n2 3 3 1 1 4 1 2 3 3\n", "output": "4\n4 1 3 2\n"}, {"input": "10 4\n2 3 3 1 1 2 1 2 5 3\n", "output": "4\n5 1 3 2\n"}, {"input": "10 4\n2 3 3 2 1 4 1 2 3 3\n", "output": "4\n4 1 3 2\n"}, {"input": "10 4\n2 3 3 1 1 3 1 4 3 3\n", "output": "4\n4 1 3 2\n"}, {"input": "10 4\n2 3 3 2 2 3 1 4 3 3\n", "outpu... | code_stdio |
[
{
"content": "Andrewid the Android is a galaxy-known detective. Now he does not investigate any case and is eating chocolate out of boredom.\n\nA bar of chocolate can be presented as an n × n table, where each cell represents one piece of chocolate. The columns of the table are numbered from 1 to n from left to... | [{"input": "20 10\n10 11 U\n12 9 U\n6 15 L\n17 4 U\n11 10 L\n7 14 L\n4 17 U\n2 19 L\n8 13 L\n14 7 U\n", "output": "11\n9\n6\n4\n1\n7\n2\n2\n8\n7\n"}, {"input": "20 10\n10 11 U\n12 9 U\n6 15 L\n17 4 U\n11 10 L\n7 14 L\n4 17 U\n2 19 L\n8 13 L\n14 7 U\n", "output": "11\n9\n6\n4\n1\n7\n2\n2\n8\n7\n"}, {"input": "10 10\n5 6... | code_stdio |
[
{
"content": "An extension of a complex number is called a quaternion. It is a convenient number that can be used to control the arm of a robot because it is convenient for expressing the rotation of an object. Quaternions are $ using four real numbers $ x $, $ y $, $ z $, $ w $ and special numbers (extended im... | [{"input": "2\n2 0 2 1 89 0 26 7\n13 11 25 8 -1 3 0 -2\n0", "output": "119 -12 230 103\n-30 -22 21 -109\n"}, {"input": "2\n2 0 2 5 89 0 26 4\n7 11 25 8 -1 3 0 -2\n0", "output": "106 -122 230 453\n-24 -40 21 -97\n"}, {"input": "2\n2 0 2 5 89 0 26 4\n7 11 25 8 -1 3 1 -2\n0", "output": "106 -122 230 453\n-49 -48 28 -86\n"... | code_stdio |
[
{
"content": "Vasya has recently finished writing a book. Now he faces the problem of giving it the title. Vasya wants the title to be vague and mysterious for his book to be noticeable among others. That's why the title should be represented by a single word containing at least once each of the first k Latin l... | [{"input": "26\nabcdefghijklmnopqrstuvwxyzfgvnsltvvohywvqhuhtydghtthgdythuhqvwyhovvtlsnvgfzyxwvutsrqponmlkjihgfedcba\n", "output": "abcdefghijklmnopqrstuvwxyzfgvnsltvvohywvqhuhtydghtthgdythuhqvwyhovvtlsnvgfzyxwvutsrqponmlkjihgfedcba\n"}, {"input": "26\nab?defg??j??mnopqrs?uv?x???u?vpd??s?s??s?t?v?vp?is?iqp??v??ush?s??a... | code_stdio |
[
{
"content": "There are N squares arranged in a row, numbered 1 to N from left to right. Takahashi will stack building blocks on these squares, on which there are no blocks yet.\n\nHe wants to stack blocks on the squares evenly, so he will repeat the following operation until there are H blocks on every square:... | [{"input": "118261 6796 8504", "output": "331359071\n"}, {"input": "118261 3351 8683", "output": "422737594\n"}, {"input": "194739 3351 8683", "output": "984464655\n"}, {"input": "31415 14324 4472", "output": "527193753\n"}, {"input": "197694 6796 8504", "output": "116621440\n"}, {"input": "118261 6796 4795", "output":... | code_stdio |
[
{
"content": "This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters.\n\nMr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way.\n\nYou are given a string s consisting of uppercase English letters. Determine whether th... | [{"input": "CODDFESTIVAL", "output": "Yes\n"}, {"input": "EDOCLAVFTSEI", "output": "Yes\n"}, {"input": "ECOFLAVDTSEI", "output": "Yes\n"}, {"input": "DOECSDKSIVAF", "output": "Yes\n"}, {"input": "DOECRDKSIVAF", "output": "Yes\n"}, {"input": "DOFCRDKSIVAF", "output": "Yes\n"}, {"input": "DOFCQDKSIVAF", "output": "Yes\n"... | code_stdio |
[
{
"content": "You are given a rebus of form ? + ? - ? + ? = n, consisting of only question marks, separated by arithmetic operation '+' and '-', equality and positive integer n. The goal is to replace each question mark with some positive integer from 1 to n, such that equality holds.\n\nInput\n\nThe only line ... | [{"input": "? + ? + ? - ? + ? - ? - ? - ? - ? - ? + ? - ? + ? + ? - ? + ? - ? + ? + ? - ? + ? - ? + ? + ? + ? - ? - ? - ? + ? - ? - ? + ? - ? - ? + ? - ? + ? + ? - ? + ? - ? - ? + ? + ? - ? - ? - ? + ? - ? - ? - ? + ? - ? - ? - ? + ? - ? - ? - ? - ? - ? - ? - ? + ? - ? - ? - ? - ? - ? - ? - ? - ? + ? - ? + ? - ? - ? + ... | code_stdio |
[
{
"content": "Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open the box. She hopes that you can help her in that.\n\nThe b... | [{"input": "BYOVRR\n", "output": "15\n"}, {"input": "OVBRYG\n", "output": "30\n"}, {"input": "RRYOGB\n", "output": "15\n"}, {"input": "VOBYGO\n", "output": "15\n"}, {"input": "GRBYVO\n", "output": "30\n"}, {"input": "YROVBG\n", "output": "30\n"}, {"input": "GYYBRO\n", "output": "15\n"}, {"input": "RYGOBG\n", "output": ... | code_stdio |
[
{
"content": "Example\n\nInput\n\n3\n0 2 7\n2 0 4\n5 8 0\n\n\nOutput\n\n11\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": "3\n0 3 10\n1 0 4\n19 11 0", "output": "15\n"}, {"input": "3\n0 6 13\n4 0 3\n24 12 0", "output": "20\n"}, {"input": "3\n0 12 13\n6 0 6\n27 8 0", "output": "25\n"}, {"input": "3\n0 12 18\n6 0 6\n27 8 0", "output": "30\n"}, {"input": "3\n0 3 10\n4 0 4\n19 11 0", "output": "17\n"}, {"input": "3\n0 3 10\n7 0 4\n... | code_stdio |
[
{
"content": "You are given a string S of length 2N consisting of lowercase English letters.\n\nThere are 2^{2N} ways to color each character in S red or blue. Among these ways, how many satisfy the following condition?\n\n* The string obtained by reading the characters painted red from left to right is equal t... | [{"input": "18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "output": "9075135300"}, {"input": "18\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`aaaa", "output": "0\n"}, {"input": "18\naaaaaaaaaaaaaaaaaaaaaaabaaaaaaa`aaaa", "output": "0\n"}, {"input": "18\naaaaaaaaaaaaaaaaaaaaaaabbaaaaaa`aaaa", "output": "0\n"}, {"input": "18\naaaa`aaaa... | code_stdio |
[
{
"content": "Today's Random Number\n\nE869120 You ran a campaign called \"Today's Random Numbers\" for N days. This is a project to generate a random number once a day and post the value on Twitter.\n\nThe \"random numbers of the day\" on day $ 1, 2, 3, \\ dots, N $ were $ A_1, A_2, A_3, \\ dots, A_N $, respec... | [{"input": "5\n15 -1 21 0 20", "output": "2\n"}, {"input": "5\n15 -1 21 0 22", "output": "2\n"}, {"input": "5\n-2 -1 -1 14 2", "output": "2\n"}, {"input": "5\n-2 -1 -1 21 2", "output": "2\n"}, {"input": "5\n-2 -1 -2 21 2", "output": "2\n"}, {"input": "5\n-2 -1 -2 35 2", "output": "2\n"}, {"input": "5\n-3 -1 -2 35 2", "... | code_stdio |
[
{
"content": "Currently Tiny is learning Computational Geometry. When trying to solve a problem called \"The Closest Pair Of Points In The Plane\", he found that a code which gave a wrong time complexity got Accepted instead of Time Limit Exceeded.\n\nThe problem is the follows. Given n points in the plane, fin... | [{"input": "3119 2029631\n", "output": "0 0\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n0 10\n0 11\n0 12\n0 13\n0 14\n0 15\n0 16\n0 17\n0 18\n0 19\n0 20\n0 21\n0 22\n0 23\n0 24\n0 25\n0 26\n0 27\n0 28\n0 29\n0 30\n0 31\n0 32\n0 33\n0 34\n0 35\n0 36\n0 37\n0 38\n0 39\n0 40\n0 41\n0 42\n0 43\n0 44\n0 45\n0 46\n0 47\n0 ... | code_stdio |
[
{
"content": "Turbulent times are coming, so you decided to buy sugar in advance. There are $n$ shops around that sell sugar: the $i$-th shop sells one pack of sugar for $a_i$ coins, but only one pack to one customer each day. So in order to buy several packs, you need to visit several shops.\n\nAnother problem... | [{"input": "1\n100 37\n29 33 45 64 95 33 45 76 86 5 52 16 27 24 80 5 44 19 96 8 77 67 21 17 22 56 28 3 84 27 39 12 60 35 75 6 68 71 81 5 76 85 73 54 8 4 58 4 22 5 11 51 72 31 67 93 38 94 96 22 73 34 33 84 21 60 89 88 30 21 44 57 5 16 11 65 20 68 68 41 25 78 43 96 61 10 40 98 55 35 19 79 21 4 62 41 63 2 80 44\n", "outpu... | code_stdio |
[
{
"content": "You can not just take the file and send it. When Polycarp trying to send a file in the social network \"Codehorses\", he encountered an unexpected problem. If the name of the file contains three or more \"x\" (lowercase Latin letters \"x\") in a row, the system considers that the file content does... | [{"input": "100\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n", "output": "98\n"}, {"input": "100\nuxxxxxlmexxxxxxxwnxxexxxxxcxxfydxxxxxxvmdxxxxxxisxxxxxxxxidkxxxpxxxxxxxxmnuxxxxjxxxqcxxwmxxxxxxxxmrx\n", "output": "41\n"}, {"input": "100\nxxxxxxxxxxxjtxxxxxxxxcx... | code_stdio |
[
{
"content": "Recently a Golden Circle of Beetlovers was found in Byteland. It is a circle route going through $n \\cdot k$ cities. The cities are numerated from $1$ to $n \\cdot k$, the distance between the neighboring cities is exactly $1$ km.\n\nSergey does not like beetles, he loves burgers. Fortunately for... | [{"input": "100000 100000\n50000 6424\n", "output": "1250000000 1250000000\n"}, {"input": "100000 101000\n50000 6424\n", "output": "39453125 1262500000\n"}, {"input": "98752 97209\n41218 39020\n", "output": "21427641 3199861056\n"}, {"input": "98752 97209\n41218 39020\n", "output": "21427641 3199861056\n"}, {"input": "... | code_stdio |
[
{
"content": "Sereja has an n × m rectangular table a, each cell of the table contains a zero or a number one. Sereja wants his table to meet the following requirement: each connected component of the same values forms a rectangle with sides parallel to the sides of the table. Rectangles should be filled with c... | [{"input": "21 10 8\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n0 0 1 1 1 0 0 0 0 0\n0 0 0 1 1 0 0 0 0 0\n1 1 1 0 0 1 1 1 1 1\n0 0 0 1 1 0 0 0 0 0\n1 1 1 0 0 1 1 1 1 1\n1 1 1 0 0 1 1 1 1 1\n0 0 0 1 1 0 0 0 0 0\n1 0 1 0 0 1 1 1 1 1\n0 1 0 1 1 0 0 0 0 0\n0 0 0... | code_stdio |
[
{
"content": "You are given an array a consisting of n integers. We denote the subarray a[l..r] as the array [a_l, a_{l + 1}, ..., a_r] (1 ≤ l ≤ r ≤ n).\n\nA subarray is considered good if every integer that occurs in this subarray occurs there exactly thrice. For example, the array [1, 2, 2, 2, 1, 1, 2, 2, 2] ... | [{"input": "100\n79 79 79 97 97 97 64 64 64 2 2 2 38 38 38 65 65 65 10 10 10 25 24 25 53 53 53 73 73 73 11 11 11 29 29 29 93 93 93 73 73 73 89 89 89 72 72 72 49 49 49 78 78 78 92 92 92 90 90 90 95 95 95 92 92 92 12 12 12 65 65 65 81 81 81 5 5 5 21 21 21 94 94 94 51 51 51 44 44 44 55 55 55 47 47 47 24 24 24 79\n", "outp... | code_stdio |
[
{
"content": "After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus.\n\n * Initially, there is a pile that contains x 100-ye... | [{"input": "1481100 701689\n", "output": "Hanako\n"}, {"input": "1616877 635412\n", "output": "Hanako\n"}, {"input": "232743 679597\n", "output": "Hanako\n"}, {"input": "1000000 1000001\n", "output": "Ciel\n"}, {"input": "497151 208819\n", "output": "Hanako\n"}, {"input": "552196 895657\n", "output": "Hanako\n"}, {"inp... | code_stdio |
[
{
"content": "Given two numbers (m and n) :\n\n- convert all numbers from m to n to binary\n- sum them as if they were in base 10 \n- convert the result to binary\n- return as string\n\nEg: with the numbers 1 and 4\n\n\n 1 // 1 to binary is 1\n+ 10 // 2 to binary is 10\n+ 11 // 3 to binary is 11\n+100 // 4 to... | [{"input": "100\n1000", "output": "[\"111111001111110110011011000101110101110\"]", "fn_name": "binary_pyramid"}, {"input": "1\n100", "output": "[\"10011101010010110000101010\"]", "fn_name": "binary_pyramid"}, {"input": "100\n100", "output": "[\"100001100100101000100\"]", "fn_name": "binary_pyramid"}, {"input": "21\n60"... | code_functional |
[
{
"content": "On Bertown's main street n trees are growing, the tree number i has the height of ai meters (1 ≤ i ≤ n). By the arrival of the President of Berland these trees were decided to be changed so that their heights formed a beautiful sequence. This means that the heights of trees on ends (the 1st one an... | [{"input": "10\n73905 73906 73907 85732 73909 73909 73908 73907 73906 73905\n", "output": "1\n"}, {"input": "10\n60718 99414 65042 65043 65044 38495 95782 65042 65041 65040\n", "output": "4\n"}, {"input": "10\n60718 99414 65042 89001 65044 38495 95782 65042 65041 65040\n", "output": "5\n"}, {"input": "10\n60718 99414 1... | code_stdio |
[
{
"content": "We start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by s_i. \n\nThere is one cursor. The cursor's location ℓ is denoted by an integer in \\{0, …, |s|\\}, with the following meaning: \n\n ... | [{"input": "9\n1500\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1111112111111112\n1500\n1111111111221111111\n1500\n111111122\n1500\n11111121111121111111\n", "output": "1504\n1599\n1502\n1598\n1502\n1510\n1657\n1502\n1763\n"}, {"input": "9\n1676\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1... | code_stdio |
[
{
"content": "In this task Anna and Maria play the following game. Initially they have a checkered piece of paper with a painted n × m rectangle (only the border, no filling). Anna and Maria move in turns and Anna starts. During each move one should paint inside the last-painted rectangle a new lesser rectangle... | [{"input": "1000 1000 250\n", "output": "263321201\n"}, {"input": "580 1000 203\n", "output": "693824000\n"}, {"input": "1000 1000 20\n", "output": "155086097\n"}, {"input": "1000 1000 100\n", "output": "58573582\n"}, {"input": "1000 1000 39\n", "output": "227950512\n"}, {"input": "840 474 207\n", "output": "895622621\... | code_stdio |
[
{
"content": "# Task\n Define crossover operation over two equal-length strings A and B as follows:\n\n the result of that operation is a string of the same length as the input strings result[i] is chosen at random between A[i] and B[i]. \n \n Given array of strings `arr` and a string result, find for how many ... | [{"input": "[\"abc\", \"aaa\", \"aba\", \"bab\"]\n\"bbb\"", "output": "[2]", "fn_name": "strings_crossover"}, {"input": "[\"aacccc\", \"bbcccc\"]\n\"abdddd\"", "output": "[0]", "fn_name": "strings_crossover"}, {"input": "[\"a\", \"b\", \"c\", \"d\", \"e\"]\n\"c\"", "output": "[4]", "fn_name": "strings_crossover"}, {"in... | code_functional |
[
{
"content": "For an integer n not less than 0, let us define f(n) as follows:\n - f(n) = 1 (if n < 2)\n - f(n) = n f(n-2) (if n \\geq 2)\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\n-----Constraints-----\n - 0 \\leq N \\leq 10^{18}\n\n-----Input-----\nInput is g... | [{"input": "1000000000000000000\n", "output": "124999999999999995\n"}, {"input": "999003990299500294\n", "output": "124875498787437525\n"}, {"input": "1000000000010000000", "output": "125000000001249993\n"}, {"input": "1000000000010001000", "output": "125000000001250117\n"}, {"input": "1010000000010001000", "output": "... | code_stdio |
[
{
"content": "Matrix of given integers\n\n\na1,1 a1,2 ... a1, n\na2,1 a2,2 ... a2, n\n::\nan, 1 an, 2 ... an, n\n\n\nThen, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends.\n\n\n\nInput\n\nThe input data is... | [{"input": "4\n1 3 -9 2\n2 7 -1 5\n-8 3 2 -1\n5 -1 -3 1", "output": "15\n"}, {"input": "4\n1 3 -9 0\n2 7 -1 5\n-8 3 2 -2\n3 -1 -3 1", "output": "14\n"}, {"input": "4\n1 3 -9 2\n2 4 -1 5\n-8 3 2 -1\n5 -1 -6 1", "output": "12\n"}, {"input": "4\n1 3 -9 2\n2 4 -1 5\n-8 3 0 -1\n5 -1 -6 1", "output": "10\n"}, {"input": "4\n1... | code_stdio |
[
{
"content": "One day, Yuhao came across a problem about checking if some bracket sequences are correct bracket sequences.\n\nA bracket sequence is any non-empty sequence of opening and closing parentheses. A bracket sequence is called a correct bracket sequence if it's possible to obtain a correct arithmetic e... | [{"input": "30\n)(((())()())()(\n))(()()()(\n))()((\n)())(()\n())())((\n((((())\n(((()))(\n(())\n)()(((()(()\n((())))(\n)()()())((\n))))(()\n()(((()\n)()()(\n(())())\n(()()(())(\n)()((\n)(()(())))\n))))(())((\n)()(()(((((\n(()))((\n()())\n((()()()))\n()((((((((()\n)(()(\n)(((())(()\n)((((()(\n(((()()((\n())()(\n)))()()... | code_stdio |
[
{
"content": "Rng has a connected undirected graph with N vertices. Currently, there are M edges in the graph, and the i-th edge connects Vertices A_i and B_i.\n\nRng will add new edges to the graph by repeating the following operation:\n\n* Operation: Choose u and v (u \\neq v) such that Vertex v can be reache... | [{"input": "16 5\n1 2\n2 3\n3 3\n0 14\n0 6", "output": "115\n"}, {"input": "69 5\n1 2\n3 3\n1 3\n4 4\n5 8", "output": "2341\n"}, {"input": "71 5\n1 2\n3 3\n1 3\n4 4\n5 8", "output": "2480\n"}, {"input": "46 5\n1 2\n3 3\n1 3\n0 4\n5 8", "output": "1030\n"}, {"input": "15 5\n1 2\n2 3\n3 3\n0 5\n4 2", "output": "100\n"}, ... | code_stdio |
[
{
"content": "Alice likes snow a lot! Unfortunately, this year's winter is already over, and she can't expect to have any more of it. Bob has thus bought her a gift — a large snow maker. He plans to make some amount of snow every day. On day i he will make a pile of snow of volume Vi and put it in her garden.\n... | [{"input": "13\n1 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 "}, {"input": "13\n1 1 1 1 1 1 1 1 1 2 1 1 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1 1 1 1 1 1 2 1 1\n"}, {"input": "13\n1 1 1 1 1 1 1 1 1 2 1 2 1\n1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1... | code_stdio |
[
{
"content": "Squid loves painting vertices in graphs.\n\nThere is a simple undirected graph consisting of N vertices numbered 1 through N, and M edges. Initially, all the vertices are painted in color 0. The i-th edge bidirectionally connects two vertices a_i and b_i. The length of every edge is 1.\n\nSquid pe... | [{"input": "14 10\n1 4\n9 12\n7 11\n2 10\n14 7\n14 3\n6 14\n8 14\n5 13\n8 1\n2\n8 7 4\n14 7 85\n6 1 6\n6 11 5\n10 3 1\n20 9 4\n10 2 12\n8 4 3", "output": "85\n0\n85\n85\n0\n85\n85\n85\n0\n0\n85\n0\n0\n85\n"}, {"input": "14 10\n1 4\n9 12\n7 11\n2 10\n14 7\n14 3\n6 14\n8 14\n5 13\n8 1\n3\n8 7 4\n14 7 85\n6 1 6\n6 11 5\n1... | code_stdio |
[
{
"content": "Your task is to write a program of a simple dictionary which implements the following instructions:\n\n* insert str: insert a string str in to the dictionary\n* find str: if the distionary contains str, then print 'yes', otherwise print 'no'\n\nNotes\n\nTemplate in C\n\nConstraints\n\n* A string c... | [{"input": "13\ninsert AAA\ninsert AAC\ninsert AGA\ninsert AGF\ninsert TTT\nfind AAA\nfind CCC\nfind CCC\ninsert CCC\nfind CCC\ninsert T\nfind TTT\nfind T", "output": "yes\nno\nno\nyes\nyes\nyes\n"}, {"input": "13\ninsert AAA\ninsert CAA\ninsert AGA\ninsert AGG\ninsert TTT\nfind AAA\nfind CCC\nfind CCC\ninsert CCC\nfin... | code_stdio |
[
{
"content": "Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.\n\nAs you may know, the coolest photos are on the film (because you can specify the hashtag #film f... | [{"input": "5 5\nW G B W G\nG B W G B\nB W G B W\nW G B W G\nG B W G B\n", "output": "#Black&White\n"}, {"input": "5 5\nW G B W G\nG B W G B\nB W G B W\nW G B W G\nG B W G B\n", "output": "#Black&White"}, {"input": "5 5\nW G B Y M\nG B Y M C\nB Y M C W\nY M C W G\nM C W G B\n", "output": "#Color\n"}, {"input": "5 5\nW ... | code_stdio |
[
{
"content": "The busses in Berland are equipped with a video surveillance system. The system records information about changes in the number of passengers in a bus after stops.\n\nIf $x$ is the number of passengers in a bus just before the current bus stop and $y$ is the number of passengers in the bus just af... | [{"input": "102 1\n1 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 1\n", "output": "0\n"}, {"input": "102 1\n1 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... | code_stdio |
[
{
"content": "Give you N cards. Only one natural number is written on each card. However, the same number is never written.\n\nFrom now on, as a question, I will say an appropriate natural number. Please answer the largest remainder you get when you divide the number on the card you have by the number I said.\n... | [{"input": "3 3\n9 3 10\n12\n6\n1", "output": "10\n4\n0\n"}, {"input": "3 3\n6 2 16\n20\n7\n2", "output": "16\n6\n0\n"}, {"input": "3 3\n2 1 21\n20\n12\n2", "output": "2\n9\n1\n"}, {"input": "3 3\n9 3 8\n12\n12\n2", "output": "9\n9\n1\n"}, {"input": "3 3\n9 5 8\n12\n11\n1", "output": "9\n9\n0\n"}, {"input": "3 3\n6 2 2... | code_stdio |
[
{
"content": "Problem\n\nJennifer and Marian presented Carla with the string S.\nHowever, Carla is not happy to receive the string S.\nI wanted the string T.\nThe three decided to work together to change the string S to the string T.\n\n\nJennifer first sorts the letters in any order.\n\nMarian then exchanges t... | [{"input": "5\naaabb\nxywyz", "output": "2\n"}, {"input": "5\naaacb\nxywyz", "output": "1\n"}, {"input": "5\nbcaaa\nxywyz", "output": "1\n"}, {"input": "5\nbcaaa\nxywyy", "output": "0\n"}, {"input": "5\nbcaba\nxywyy", "output": "1\n"}, {"input": "5\ncbaba\nxywyy", "output": "1\n"}, {"input": "5\ncbbba\nxywyy", "output"... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nChef has a box full of infinite number of identical coins. One day while playing, he made N piles each containing equal number of coins. Chef suddenly remembered an important task and left the room for sometime. While he was away, his ... | [{"input": "1\n4\n1 -1 2 2", "output": "2\n"}, {"input": "1\n4\n1 1 -1 4", "output": "2\n"}, {"input": "1\n4\n1 2 2 -1", "output": "2\n"}, {"input": "1\n4\n0 2 2 -1", "output": "2\n"}, {"input": "1\n4\n1 -1 2 3", "output": "3\n"}, {"input": "1\n4\n-1 2 0 4", "output": "3\n"}, {"input": "1\n4\n1 -1 1 5", "output": "2\n"... | code_stdio |
[
{
"content": "problem\n\nYou have to play a darts game with the following rules.\n\nYou can throw up to four arrows towards the target. You don't have to throw all four, you don't have to throw one. The target is divided into N parts. The score P1, ..., PN is written in each part. The total score S of the place... | [{"input": "4 67\n12\n28\n28\n11\n3 21\n10\n11\n3\n0 0", "output": "67\n21\n"}, {"input": "4 67\n12\n41\n28\n20\n3 21\n10\n11\n3\n0 0", "output": "65\n21\n"}, {"input": "4 102\n2\n39\n13\n11\n3 14\n5\n11\n4\n0 0", "output": "102\n14\n"}, {"input": "4 58\n12\n14\n28\n11\n3 21\n5\n11\n3\n0 0", "output": "56\n21\n"}, {"in... | code_stdio |
[
{
"content": "There are N mountains ranging from east to west, and an ocean to the west.\nAt the top of each mountain, there is an inn. You have decided to choose where to stay from these inns.\nThe height of the i-th mountain from the west is H_i.\nYou can certainly see the ocean from the inn at the top of the... | [{"input": "20\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100\n", "output": "20\n"}, {"input": "20\n54 53 68 68 35 35 62 61 74 73 94 94 94 94 86 85 65 64 68 68\n", "output": "8\n"}, {"input": "20\n8 12 14 17 23 26 38 41 45 46 48 56 60 66 69 85 86 94 98 99\n", "output": "20\n"}, {"input... | code_stdio |
[
{
"content": "CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard.\n\nHe intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length.\n\nSo Mr. Takahashi decided to perform an op... | [{"input": "EDOC6102LAVITSEF", "output": "16\n"}, {"input": "1DO2LAVI6REGE0TC", "output": "15\n"}, {"input": "VT0EGER6ICAL2OD0", "output": "10\n"}, {"input": "VV1EFFR7ICAK2OD0", "output": "11\n"}, {"input": "VW1EFFR7ICAK3OD0", "output": "12\n"}, {"input": "107DFFRV3CALWODI", "output": "13\n"}, {"input": "D6OV>JT1DJEC20... | code_stdio |
[
{
"content": "n people came to a party. Then those, who had no friends among people at the party, left. Then those, who had exactly 1 friend among those who stayed, left as well. Then those, who had exactly 2, 3, ..., n - 1 friends among those who stayed by the moment of their leaving, did the same.\n\nWhat is ... | [{"input": "1\n108\n", "output": "106\n"}, {"input": "1\n157\n", "output": "155\n"}, {"input": "1\n168\n", "output": "166\n"}, {"input": "1\n299\n", "output": "297\n"}, {"input": "1\n111\n", "output": "109\n"}, {"input": "1\n140\n", "output": "138\n"}, {"input": "1\n266\n", "output": "264\n"}, {"input": "1\n372\n", "ou... | code_stdio |
[
{
"content": "Assume `\"#\"` is like a backspace in string. This means that string `\"a#bc#d\"` actually is `\"bd\"`\n\nYour task is to process a string with `\"#\"` symbols.\n\n\n## Examples\n\n```\n\"abc#d##c\" ==> \"ac\"\n\"abc##d######\" ==> \"\"\n\"#######\" ==> \"\"\n\"\" ==> ... | [{"input": "\"831####jns###s#cas/*####-5##s##6+yqw87e##hfklsd-=-28##fds##\"", "output": "[\"6+yqw8hfklsd-=-f\"]", "fn_name": "clean_string"}, {"input": "\"####gfdsgf##hhs#dg####fjhsd###dbs########afns#######sdanfl##db#####s#a\"", "output": "[\"sa\"]", "fn_name": "clean_string"}, {"input": "\"gfh#jds###d#dsd####dasdaskh... | code_functional |
[
{
"content": "Bear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.\n\nRight now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to his brother's weight.\n\nLimak eats a lot and his weight is tripled after ever... | [{"input": "10 10\n", "output": "1\n"}, {"input": "10 10\n", "output": "1\n"}, {"input": "10 10\n", "output": "1\n"}, {"input": "11 12\n", "output": "1\n"}, {"input": "1 43\n", "output": "10\n"}, {"input": "11 15\n", "output": "1\n"}, {"input": "11 16\n", "output": "1\n"}, {"input": "15 15\n", "output": "1\n"}, {"input... | code_stdio |
[
{
"content": "One day Vasya heard a story: \"In the city of High Bertown a bus number 62 left from the bus station. It had n grown-ups and m kids...\"\n\nThe latter events happen to be of no importance to us. Vasya is an accountant and he loves counting money. So he wondered what maximum and minimum sum of mone... | [{"input": "100000 100000\n", "output": "100000 199999\n"}, {"input": "100000 100001\n", "output": "100001 200000\n"}, {"input": "110000 100001\n", "output": "110000 210000\n"}, {"input": "127948 126156\n", "output": "127948 254103\n"}, {"input": "117241 111295\n", "output": "117241 228535\n"}, {"input": "120119 80236\... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nIn a far away dystopian world, the measure of the quality of a person’s life is the numbers of likes he gets for an article about their life. For a person to stay alive, he has to acquire at least L number of likes before D days pass.\... | [{"input": "2\n5 2 10 1\n13 3 3 2", "output": "ALIVE AND KICKING\nALIVE AND KICKING\n"}, {"input": "2\n5 2 10 1\n25 3 3 2", "output": "ALIVE AND KICKING\nALIVE AND KICKING\n"}, {"input": "2\n5 2 10 1\n25 3 3 4", "output": "ALIVE AND KICKING\nALIVE AND KICKING\n"}, {"input": "2\n5 2 10 1\n15 3 3 4", "output": "ALIVE AND... | code_stdio |
[
{
"content": "Gildong's town has a train system that has $100$ trains that travel from the bottom end to the top end and $100$ trains that travel from the left end to the right end. The trains starting from each side are numbered from $1$ to $100$, respectively, and all trains have the same speed. Let's take a ... | [{"input": "3\n1 2\n1\n3 4\n3 2\n2 3 11\n2 1\n9 14\n2 12 16 28 42 57 59 86 99\n3 9 14 19 25 26 20 35 41 59 85 87 99 100\n", "output": "0\n1\n2\n"}, {"input": "3\n1 2\n1\n1 4\n3 2\n1 3 4\n2 4\n9 14\n2 14 16 28 33 57 59 92 99\n3 9 14 19 25 26 28 35 41 59 85 87 99 100\n", "output": "1\n1\n4\n"}, {"input": "3\n1 2\n1\n3 4\... | code_stdio |
[
{
"content": "There are $n$ chips arranged in a circle, numbered from $1$ to $n$. \n\nInitially each chip has black or white color. Then $k$ iterations occur. During each iteration the chips change their colors according to the following rules. For each chip $i$, three chips are considered: chip $i$ itself and ... | [{"input": "101 2\nBWBWBWWWBWBWBWWWBWWWBWWWBWBBBBBWBWBBBWBWBWWBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWWBWBWBWB\n", "output": "BBBWWWWWWWBWWWWWWWWWWWWWWBBBBBBBBBBBBBBWWWWBBBBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWWWWWWWBWBBB\n"}, {"input": "101 2\nBWBWBWBWWWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBBW... | code_stdio |
[
{
"content": "problem\n\nMobiles are widely known as moving works of art. The IOI Japan Committee has decided to create mobiles to publicize JOI. JOI public relations mobiles are sticks, strings, and weights. It is constructed as follows using the three types of elements of.\n\n* One end of the bar is painted b... | [{"input": "1\n7 22 0 0\n4\n2 2 0 4\n1 3 0 0\n9 10 2 1\n3 2 0 0\n0", "output": "29\n190\n"}, {"input": "1\n7 11 0 0\n4\n2 2 0 4\n1 3 0 0\n3 8 2 1\n3 2 0 0\n0", "output": "18\n110\n"}, {"input": "1\n7 22 0 0\n4\n2 2 0 4\n1 3 0 0\n3 8 2 1\n3 2 0 0\n0", "output": "29\n110\n"}, {"input": "1\n6 10 0 0\n4\n3 5 0 4\n1 6 0 0\n... | code_stdio |
[
{
"content": "Reading books is one of Sasha's passions. Once while he was reading one book, he became acquainted with an unusual character. The character told about himself like that: \"Many are my names in many countries. Mithrandir among the Elves, Tharkûn to the Dwarves, Olórin I was in my youth in the West ... | [{"input": "tttdddssstttssstttdddddddddttttttdddsssdddtttsssdddsssssstttddddddtttdddssstttsssttttttdddtttsssssstttssssssssstttsssssstttssstttdddddddddsssdddssssssdddssstttsssdddssstttdddttttttdddddddddsssssstttdddtttssssssdddddddddttttttdddtttsssdddssstttsssdddssssssdddsssdddddddddtttssstttsssssstttssssssssstttsssssstt... | code_stdio |
[
{
"content": "Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's introduce a coordinate system so that the car rental service is at the point 0, and the cine... | [{"input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 194 362 128 157 336 162 77 90 96\n", "output": "1\n"}, {"input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 194 362 128 157 336 162 77 90 96\n", "output": "1\n"}, {"input": "4 13 400 600\n13 30\n1 19\n1 160\n1 113\n58 73 15 319 194 362 200 15... | code_stdio |
[
{
"content": "In Python, code blocks don't have explicit begin/end or curly braces to mark beginning and end of the block. Instead, code blocks are defined by indentation.\n\nWe will consider an extremely simplified subset of Python with only two types of statements.\n\nSimple statements are written in a single... | [{"input": "156\nf\ns\nf\ns\nf\ns\ns\ns\ns\nf\ns\ns\nf\nf\ns\nf\nf\nf\nf\ns\ns\ns\nf\ns\ns\nf\nf\nf\nf\nf\nf\ns\ns\ns\ns\nf\ns\nf\ns\nf\ns\nf\nf\nf\nf\ns\ns\nf\nf\ns\ns\ns\ns\nf\ns\nf\ns\nf\ns\nf\ns\ns\ns\nf\ns\ns\nf\ns\nf\nf\ns\ns\ns\nf\nf\nf\nf\ns\ns\nf\nf\nf\nf\nf\nf\nf\ns\nf\ns\ns\ns\nf\nf\ns\ns\ns\ns\ns\nf\nf\nf\n... | code_stdio |
[
{
"content": "Example\n\nInput\n\n3\n3 0 1\n\n\nOutput\n\n2\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": "3\n152 -3 2", "output": "0\n"}, {"input": "3\n-1 -1 1", "output": "0\n"}, {"input": "3\n13 -2 3", "output": "0\n"}, {"input": "3\n25 -2 3", "output": "0\n"}, {"input": "3\n25 -2 4", "output": "0\n"}, {"input": "3\n25 -2 1", "output": "0\n"}, {"input": "3\n25 -3 1", "output": "0\n"}, {"input": "3\n33 -3 1", ... | code_stdio |
[
{
"content": "The territory of Berland is represented by a rectangular field n × m in size. The king of Berland lives in the capital, located on the upper left square (1, 1). The lower right square has coordinates (n, m). One day the king decided to travel through the whole country and return back to the capita... | [{"input": "101 100\n", "output": "0\n1 1\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n34 1\n35 1\n36 1\n37 1\n38 1\n39 1\n40 1\n41 1\n42 1\n43 1\n44 1\n45 1\n46 1\n47 1\n48 1\n49 ... | code_stdio |
[
{
"content": "A: four tea\n\nproblem\n\nTea is indispensable for programming contests. Tea has the effect of relieving constant tension [citation needed]\n\nThere are N players participating in the contest, so I would like to prepare tea for this number of people. There are four types of tea packages, A, B, C, ... | [{"input": "10\n1 2 10 2\n0 0 0 15", "output": "2\n"}, {"input": "10\n1 1 3 2\n0 2 3 16", "output": "2\n"}, {"input": "10\n0 1 3 2\n1 2 3 16", "output": "0\n"}, {"input": "10\n0 1 6 1\n0 0 1 50", "output": "1\n"}, {"input": "10\n1 1 6 2\n1 1 2 1", "output": "10\n"}, {"input": "10\n0 3 0 3\n0 2 0 2", "output": "15\n"}, ... | code_stdio |
[
{
"content": "# Task\n\n**_Given_** a **_list of digits_**, *return the **_smallest number_** that could be formed from these digits, using the digits only once (ignore duplicates).* \n___\n\n# Notes:\n\n* Only **_positive integers_** *will be passed to the function (> 0 ), no negatives or zeros.*\n___\n# Input... | [{"input": "[3, 6, 5, 5, 9, 8, 7, 6, 3, 5, 9]", "output": "[356789]", "fn_name": "min_value"}, {"input": "[1, 9, 1, 3, 7, 4, 6, 6, 7]", "output": "[134679]", "fn_name": "min_value"}, {"input": "[5, 6, 9, 9, 7, 6, 4]", "output": "[45679]", "fn_name": "min_value"}, {"input": "[6, 7, 8, 7, 6, 6]", "output": "[678]", "fn_n... | code_functional |
[
{
"content": "There is a tree with N vertices numbered 1 through N. The i-th of the N-1 edges connects vertices a_i and b_i.\n\nInitially, each vertex is uncolored.\n\nTakahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perform the following operation, starting from Tak... | [{"input": "6\n2 1\n2 3\n3 4\n2 5\n5 6", "output": "Second\n"}, {"input": "6\n1 2\n2 3\n6 4\n1 5\n5 6", "output": "Second\n"}, {"input": "6\n1 2\n1 3\n2 4\n1 5\n5 6", "output": "Second\n"}, {"input": "6\n2 1\n2 3\n1 4\n2 5\n5 6", "output": "Second\n"}, {"input": "6\n1 1\n2 3\n1 4\n2 5\n5 6", "output": "Second\n"}, {"in... | code_stdio |
[
{
"content": "Problem\n\nBeans are popular at Otsu University. N beans are lined up in a straight line. Each is numbered from 0 to N-1, and the hardness of the i-th bean is ai.\n\nCyan considers the ideal bean hardness to be D. However, Cyan doesn't want to go get the beans that are too far away because he is t... | [{"input": "10\n4 5 1 21 9 000 12 17 0 6\n5\n2 3 20\n2 2 101\n8 9 9\n5 5 10\n0 9 20", "output": "1\n100\n3\n10\n1\n"}, {"input": "10\n4 5 0 42 9 000 12 9 0 6\n5\n0 2 20\n2 5 101\n8 9 9\n5 5 17\n0 1 20", "output": "15\n59\n3\n17\n15\n"}, {"input": "10\n4 5 0 42 9 000 12 9 0 6\n5\n0 2 20\n2 5 101\n8 9 14\n5 5 23\n0 9 20"... | code_stdio |
[
{
"content": "President of Berland has a very vast office-room, where, apart from him, work his subordinates. Each subordinate, as well as President himself, has his own desk of a unique colour. Each desk is rectangular, and its sides are parallel to the office walls. One day President decided to establish an a... | [{"input": "24 11 N\n.NNNNNNNNNN\n.NNNNNNNNNN\n........RRR\n........RRR\n........RRR\n..MMMMMMRRR\n..MMMMMMRRR\n..MMMMMMRRR\n..MMMMMM...\n....XXXXXXX\n...........\n.....CCCCCC\n.....CCCCCC\n.HHHHHHHHHH\n..VVVVV....\n..VVVVV....\n..VVVVV....\n..VVVVV.I..\n..VVVVV.I..\n..VVVVV.I..\n..VVVVV.I..\n..VVVVV....\n..VVVVV....\n... | code_stdio |
[
{
"content": "There are N cards placed on a grid with H rows and W columns of squares.\n\nThe i-th card has an integer A_i written on it, and it is placed on the square at the R_i-th row from the top and the C_i-th column from the left.\n\nMultiple cards may be placed on the same square.\n\nYou will first pick ... | [{"input": "13 5 6\n1 3 36945\n4 6 19698\n4 6 73389\n3 6 3031\n3 1 4771\n1 4 4784\n2 1 36357\n2 -1 24830\n5 6 160809\n4 6 36941\n0 2 30739\n1 4 68417\n-1 5 78537", "output": "556519\n"}, {"input": "13 5 6\n1 3 36945\n4 6 19698\n4 6 73389\n3 6 3031\n3 1 4771\n1 4 4784\n2 1 36357\n2 -1 24830\n5 6 84109\n4 6 36941\n0 2 30... | code_stdio |
[
{
"content": "You are given two integer arrays a_0, a_1, ..., a_{N - 1} and b_0, b_1, ..., b_{M - 1}. Calculate the array c_0, c_1, ..., c_{(N - 1) + (M - 1)}, defined by c_i = \\sum_{j = 0}^i a_j b_{i - j} \\bmod 998244353.\n\nConstraints\n\n* 1 \\leq N, M \\leq 524288\n* 0 \\leq a_i, b_i < 998244353\n* All va... | [{"input": "4 5\n1 4 3 2\n-1 0 43 8 2", "output": "998244352 998244349 40 178 163 118 22 4\n"}, {"input": "4 5\n2 2 3 4\n5 0 12 13 18", "output": "10 10 39 70 98 123 106 72\n"}, {"input": "4 5\n2 2 3 3\n5 1 12 13 18", "output": "10 12 41 68 101 111 93 54\n"}, {"input": "4 5\n1 2 3 5\n2 -1 23 8 30", "output": "2 3 27 61... | code_stdio |
[
{
"content": "Snuke has N hats. The i-th hat has an integer a_i written on it.\n\nThere are N camels standing in a circle. Snuke will put one of his hats on each of these camels.\n\nIf there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `... | [{"input": "4\n2 -5 -1 2", "output": "No\n"}, {"input": "4\n1 2 4 11", "output": "No\n"}, {"input": "4\n0 2 4 11", "output": "No\n"}, {"input": "4\n0 4 4 11", "output": "No\n"}, {"input": "4\n0 4 4 20", "output": "No\n"}, {"input": "4\n0 4 1 20", "output": "No\n"}, {"input": "4\n0 4 1 33", "output": "No\n"}, {"input": ... | code_stdio |
[
{
"content": "There are two types of burgers in your restaurant — hamburgers and chicken burgers! To assemble a hamburger you need two buns and a beef patty. To assemble a chicken burger you need two buns and a chicken cutlet. \n\nYou have $b$ buns, $p$ beef patties and $f$ chicken cutlets in your restaurant. Y... | [{"input": "7\n2 1 1\n1 1\n100 101 100\n101 100\n2 101 110\n000 111\n010 3 1\n101 100\n010 77 14\n110 99\n010 001 3\n100 99\n362 51 11\n011 165\n", "output": "1\n5050\n111\n403\n550\n397\n2376\n"}, {"input": "7\n2 1 2\n1 1\n100 100 000\n101 110\n2 101 000\n011 110\n010 3 1\n101 100\n010 77 14\n110 126\n110 001 6\n100 9... | code_stdio |
[
{
"content": "Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.\n\nIn this problem you should implement the similar functionality.\n\nYou are given a string which only consists of: uppercase... | [{"input": "255\nT___J(M_XZJlr_lH___mqJA_p__kW)ko__F_M_Aro__ZA_G_M_P_____j_V(J_Jk_dkR_ta_lbIUhKFfo_y_DluW)IVFj_gouRfMhabn()_e___q_vo__QPEGBI_TpVVI_clPwwb_m_yL_cMVKgi___RJb_J_f____tPCyntLOr_s_x_N_SyqQw_zP_mycsW_o_c_o_Yzb_UVa_ATd(BYH_gl___Y__Uzok_Y_IA_XL_D__bkJ____e__K_quk)\n", "output": "10 25\n"}, {"input": "255\ngB(ZK... | code_stdio |
[
{
"content": "Consider a currency system in which there are notes of six denominations, namely, Rs. 1, Rs. 2, Rs. 5, Rs. 10, Rs. 50, Rs. 100.\nIf the sum of Rs. N is input, write a program to computer smallest number of notes that will combine to give Rs. N.\n\n-----Input-----\n\nThe first line contains an inte... | [{"input": "3 \n1200\n1258\n242", "output": "12\n16\n7\n"}, {"input": "3 \n1200\n493\n380", "output": "12\n11\n7\n"}, {"input": "3 \n1200\n806\n380", "output": "12\n10\n7\n"}, {"input": "3 \n1200\n360\n242", "output": "12\n5\n7\n"}, {"input": "3 \n1200\n360\n255", "output": "12\n5\n4\n"}, {"input": "3 \n1200\n500\n392"... | code_stdio |
[
{
"content": "A few years ago Sajjad left his school and register to another one due to security reasons. Now he wishes to find Amir, one of his schoolmates and good friends.\n\nThere are n schools numerated from 1 to n. One can travel between each pair of them, to do so, he needs to buy a ticket. The ticker be... | [{"input": "300997\n", "output": "150498\n"}, {"input": "273658\n", "output": "136828\n"}, {"input": "222057\n", "output": "111028\n"}, {"input": "456496\n", "output": "228247\n"}, {"input": "220343\n", "output": "110171\n"}, {"input": "100000\n", "output": "49999\n"}, {"input": "100000\n", "output": "49999\n"}, {"inpu... | code_stdio |
[
{
"content": "With one die of 6 sides we will have six different possible results:``` 1, 2, 3, 4, 5, 6``` .\n\nWith 2 dice of six sides, we will have 36 different possible results:\n``` \n(1,1),(1,2),(2,1),(1,3),(3,1),(1,4),(4,1),(1,5),\n(5,1), (1,6),(6,1),(2,2),(2,3),(3,2),(2,4),(4,2),\n(2,5),(5,2)(2,6),(6,2)... | [{"input": "[3, 15, 8, 20]", "output": "[44]", "fn_name": "eq_dice"}, {"input": "[5, 6, 4]", "output": "[5]", "fn_name": "eq_dice"}, {"input": "[6, 6]", "output": "[3]", "fn_name": "eq_dice"}, {"input": "[3, 3]", "output": "[0]", "fn_name": "eq_dice"}, {"input": "[3, 6]", "output": "[0]", "fn_name": "eq_dice"}, {"input... | code_functional |
[
{
"content": "You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.\n\n<image>\n\nAn ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he makes a step from one vertex to another one along some ... | [{"input": "10000000\n", "output": "192336614\n"}, {"input": "1000000\n", "output": "266233856\n"}, {"input": "4000000\n", "output": "882155933\n"}, {"input": "9999999\n", "output": "730778875\n"}, {"input": "9999998\n", "output": "576926295\n"}, {"input": "9000000\n", "output": "295060537\n"}, {"input": "1000010\n", "... | code_stdio |
[
{
"content": "You are given an array of $n$ positive integers $a_1, a_2, \\ldots, a_n$. Your task is to calculate the number of arrays of $n$ positive integers $b_1, b_2, \\ldots, b_n$ such that:\n\n$1 \\le b_i \\le a_i$ for every $i$ ($1 \\le i \\le n$), and\n\n$b_i \\neq b_{i+1}$ for every $i$ ($1 \\le i \\le... | [{"input": "100\n23 39 85 46 97 72 41 70 37 18 8 40 33 61 12 79 51 78 61 66 85 97 78 14 70 47 100 40 15 40 61 52 19 30 14 91 82 56 10 6 68 24 97 61 31 78 18 45 88 6 37 38 51 86 37 42 58 30 79 56 50 14 61 18 13 20 57 3 93 15 24 74 32 21 71 93 2 66 25 75 75 10 86 82 30 31 6 49 15 33 100 35 1 96 87 83 29 21 41 22\n", "out... | code_stdio |
[
{
"content": "The Little Elephant loves playing with arrays. He has array a, consisting of n positive integers, indexed from 1 to n. Let's denote the number with index i as ai. \n\nAdditionally the Little Elephant has m queries to the array, each query is characterised by a pair of integers lj and rj (1 ≤ lj ≤ ... | [{"input": "6 6\n1 2 2 3 3 3\n1 2\n2 2\n1 3\n2 4\n4 6\n1 6\n", "output": "1\n0\n2\n1\n1\n3\n"}, {"input": "6 6\n1 2 2 3 3 3\n1 2\n2 2\n1 3\n2 4\n4 6\n1 3\n", "output": "1\n0\n2\n1\n1\n2\n"}, {"input": "6 6\n1 2 2 3 2 3\n1 2\n2 2\n1 3\n2 4\n4 6\n1 6\n", "output": "1\n0\n2\n1\n0\n1\n"}, {"input": "6 6\n1 2 2 3 3 3\n1 2\n... | code_stdio |
[
{
"content": "You have a playlist consisting of $n$ songs. The $i$-th song is characterized by two numbers $t_i$ and $b_i$ — its length and beauty respectively. The pleasure of listening to set of songs is equal to the total length of the songs in the set multiplied by the minimum beauty among them. For example... | [{"input": "10 1\n135600 59157\n2735 28902\n43406 39542\n24166 178402\n18565 14980\n69958 53925\n23473 81878\n89682 3949\n18757 31637\n35580 45873\n", "output": "8021689200\n"}, {"input": "10 1\n135600 59157\n2735 28902\n43406 39542\n24166 93361\n18565 14980\n69958 53925\n23473 81878\n89682 3949\n18757 31637\n31665 458... | code_stdio |
[
{
"content": "Filled with optimism, Hyunuk will host a conference about how great this new year will be!\n\nThe conference will have $n$ lectures. Hyunuk has two candidate venues $a$ and $b$. For each of the $n$ lectures, the speaker specified two time intervals $[sa_i, ea_i]$ ($sa_i \\le ea_i$) and $[sb_i, eb_... | [{"input": "4\n544431836 544432042 793496989 793497079\n544429970 544430041 793496343 793496350\n544432412 544432541 793497670 793498269\n544431029 544431033 793494552 793494859\n", "output": "YES\n"}, {"input": "4\n922033367 922033530 246113700 246113747\n922034178 922034457 246112224 246112584\n922032889 922035756 24... | code_stdio |
[
{
"content": "On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $k$ ($k \\ge 3$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.\n\nMountains are des... | [{"input": "5\n8 6\n1 2 4 1 2 7 1 2\n5 3\n3 2 3 2 1\n10 8\n7 4 7 6 2 3 0 1 -1 1\n15 10\n3 14 4 8 2 1 4 5 21 2 0 4 2 1 3\n7 5\n1 2 3 4 2 6 2\n", "output": "3 2\n2 2\n4 2\n4 1\n3 3\n"}, {"input": "5\n8 6\n1 2 4 1 2 7 1 2\n5 3\n3 2 3 2 1\n10 8\n7 4 7 6 2 3 0 1 -1 1\n15 10\n3 14 4 8 2 1 4 5 21 2 0 4 2 0 3\n7 5\n1 2 3 2 2 6... | code_stdio |
[
{
"content": "Kode Festival is an anual contest where the hardest stone in the world is determined. (Kode is a Japanese word for \"hardness\".)\n\nThis year, 2^N stones participated. The hardness of the i-th stone is A_i.\n\nIn the contest, stones are thrown at each other in a knockout tournament.\n\nWhen two s... | [{"input": "3\n2\n1\n-3\n4\n-1\n25\n110\n1014", "output": "872\n"}, {"input": "3\n2\n1\n-3\n4\n-1\n25\n111\n1014", "output": "871\n"}, {"input": "3\n2\n1\n-3\n4\n-2\n25\n111\n1014", "output": "870\n"}, {"input": "3\n2\n1\n-3\n4\n-3\n25\n111\n1014", "output": "869\n"}, {"input": "3\n2\n-1\n-3\n7\n-2\n25\n101\n309", "out... | code_stdio |
[
{
"content": "Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 < i2 < ... < ik ≤ n) a group of size k. \n\nJzzhu wonders, how many groups exists such that ai1 & ai2 & ... & aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + ... | [{"input": "55\n0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 5 6 7 8 9 6 7 8 9 7 8 9 8 9 9\n", "output": "621247139\n"}, {"input": "55\n0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 2 3 4 10 6 7 8 9 3 4 5 6 7 8 9 4 5 6 7 8 9 5 6 7 8 9 6 7 8 9 7 8 9 8 9 9\n", "output": "186945693"}, {"input": ... | code_stdio |
[
{
"content": "On an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers.\n\nThere are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y c... | [{"input": "1 1\n1\n-1\n-1\n3\n21\n1\n0", "output": "-1\n"}, {"input": "1 2\n1\n-1\n-1\n6\n21\n1\n0", "output": "-3\n"}, {"input": "1 2\n1\n-1\n-2\n0\n21\n1\n0", "output": "-5\n"}, {"input": "1 1\n0\n-1\n-6\n2\n21\n1\n2", "output": "-2\n"}, {"input": "1 2\n1\n-1\n-4\n0\n21\n2\n0", "output": "-9\n"}, {"input": "2 1\n2\n... | code_stdio |
[
{
"content": "Little girl Tanya is learning how to decrease a number by one, but she does it wrong with a number consisting of two or more digits. Tanya subtracts one from a number by the following algorithm: if the last digit of the number is non-zero, she decreases the number by one; if the last digit of th... | [{"input": "1000000000 0\n", "output": "1000000000\n"}, {"input": "1559848638 5\n", "output": "1559848633\n"}, {"input": "1100000000 0\n", "output": "1100000000\n"}, {"input": "1086932676 10\n", "output": "108693264\n"}, {"input": "1000010000 0\n", "output": "1000010000\n"}, {"input": "1086932676 2\n", "output": "10869... | code_stdio |
[
{
"content": "Illumination\n\nIlluminations are displayed in the corridors every year at the JOI High School Cultural Festival. The illuminations consist of N light bulbs, which are lined up in a row from the west side to the east side of the corridor. Each light bulb is either on or off.\n\nA machine that oper... | [{"input": "10\n0 4 2 -1 18 -6 -1 -1 4 5", "output": "10\n"}, {"input": "10\n0 4 2 -2 18 -6 -1 -1 4 5", "output": "10\n"}, {"input": "10\n0 4 2 -2 18 -2 -1 -1 4 5", "output": "10\n"}, {"input": "10\n0 4 2 -2 18 -2 -1 -1 5 5", "output": "10\n"}, {"input": "10\n0 4 2 -2 18 -4 -1 -1 5 5", "output": "10\n"}, {"input": "10\... | code_stdio |
[
{
"content": "Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following problem. Given a string s how many ways are there to extract k ≥ 1 non-overl... | [{"input": "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\nvvvvvvvv\n", "output": "2728075\n"}, {"input": "vvvvwvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\nvvvvvvvv\n", "output": "1295664\n"}, {"input": "vnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssn\nnssnssns\n", "output": "943392\n"}, {"input": "kpjmawawa... | code_stdio |
[
{
"content": "Parsa has a humongous tree on $n$ vertices.\n\nOn each vertex $v$ he has written two integers $l_v$ and $r_v$.\n\nTo make Parsa's tree look even more majestic, Nima wants to assign a number $a_v$ ($l_v \\le a_v \\le r_v$) to each vertex $v$ such that the beauty of Parsa's tree is maximized.\n\nNim... | [{"input": "3\n2\n2 10\n6 6\n1 2\n3\n1 3\n13 6\n7 15\n1 2\n2 3\n6\n10 14\n12 20\n21 19\n2 12\n10 17\n3 17\n3 2\n6 5\n1 5\n2 6\n4 6\n", "output": "4\n18\n48\n"}, {"input": "3\n2\n0 6\n3 13\n1 2\n3\n1 3\n10 6\n12 9\n1 2\n2 3\n6\n3 14\n9 20\n12 19\n1 12\n11 17\n3 17\n3 3\n6 5\n1 2\n2 6\n4 6\n", "output": "13\n11\n57\n"}, ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.