messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Pooja would like to withdraw X US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal the bank charges 0.50 US.\n\nCalcula... | [{"input": "1013 120.00", "output": "120.00\n"}, {"input": "1676 120.00", "output": "120.00\n"}, {"input": "1038 120.00", "output": "120.00\n"}, {"input": "1022 120.00", "output": "120.00\n"}, {"input": "1471 120.00", "output": "120.00\n"}, {"input": "1808 120.00", "output": "120.00\n"}, {"input": "114 120.00", "output... | code_stdio |
[
{
"content": "Since Sonya has just learned the basics of matrices, she decided to play with them a little bit.\n\nSonya imagined a new type of matrices that she called rhombic matrices. These matrices have exactly one zero, while all other cells have the Manhattan distance to the cell containing the zero. The c... | [{"input": "20\n1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4\n", "output": "4 5\n2 2\n"}, {"input": "20\n1 0 2 3 5 3 2 1 3 2 3 1 4 2 1 4 2 3 2 4\n", "output": "4 5\n2 2\n"}, {"input": "18\n2 2 3 2 4 3 3 3 0 2 4 2 1 3 2 1 1 1\n", "output": "3 6\n2 3\n"}, {"input": "20\n1 0 2 3 5 10 2 2 5 4 3 2 2 2 1 3 0 3 2 4\n", "output": "... | code_stdio |
[
{
"content": "Vasya has n days of vacations! So he decided to improve his IT skills and do sport. Vasya knows the following information about each of this n days: whether that gym opened and whether a contest was carried out in the Internet on that day. For the i-th day there are four options:\n\n 1. on this d... | [{"input": "100\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "100\n"}, {"input": "100\n3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0 3 0... | code_stdio |
[
{
"content": "Snuke prepared 6 problems for a upcoming programming contest. For each of those problems, Rng judged whether it can be used in the contest or not.\n\nYou are given a string S of length 6. If the i-th character of s is `1`, it means that the i-th problem prepared by Snuke is accepted to be used; `0... | [{"input": "001011", "output": "3\n"}, {"input": "100000", "output": "1\n"}, {"input": "011011", "output": "4\n"}, {"input": "100100", "output": "2\n"}, {"input": "111011", "output": "5\n"}, {"input": "111111", "output": "6\n"}, {"input": "101100", "output": "3\n"}, {"input": "110100", "output": "3\n"}, {"input": "0100... | code_stdio |
[
{
"content": "You are given <var>Q</var> tuples of integers <var>(L_i, A_i, B_i, M_i)</var>. For each tuple, answer the following question. \nThere is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}.\nThe initial term is A, and the common difference is B. That is, s_i = A + B \\times i hold... | [{"input": "31940 139378099479290043 26943708742238 1000000000\n", "output": "997629525\n"}, {"input": "1 999999999999999999 999999999999999999 998244353\n", "output": "716070897\n"}, {"input": "345 493299812499659259 1418510335032035 998244353\n", "output": "390889114\n"}, {"input": "18 912087068546306627 316457441004... | code_stdio |
[
{
"content": "Allen wants to enter a fan zone that occupies a round square and has $n$ entrances.\n\nThere already is a queue of $a_i$ people in front of the $i$-th entrance. Each entrance allows one person from its queue to enter the fan zone in one minute.\n\nAllen uses the following strategy to enter the fan... | [{"input": "30\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000... | code_stdio |
[
{
"content": "Let's define a multiplication operation between a string $a$ and a positive integer $x$: $a \\cdot x$ is the string that is a result of writing $x$ copies of $a$ one after another. For example, \"abc\" $\\cdot~2~=$ \"abcabc\", \"a\" $\\cdot~5~=$ \"aaaaa\".\n\nA string $a$ is divisible by another s... | [{"input": "13\na\na\na\na\na\na\na\na\na\na\na\na\nb\na\na\na\na\na\na\na\na\na\na\na\nb\na\n", "output": "a\na\na\na\na\na\n-1\na\na\na\na\na\n-1\n"}, {"input": "13\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\nb\na\n", "output": "a\na\na\na\na\na\na\na\na\na\na\na\n-1\n"}, {"input": "13\na... | code_stdio |
[
{
"content": "You are given a sequence $s$ consisting of $n$ digits from $1$ to $9$.\n\nYou have to divide it into at least two segments (segment — is a consecutive sequence of elements) (in other words, you have to place separators between some digits of the sequence) in such a way that each element belongs to... | [{"input": "21\n3\n123\n3\n123\n3\n123\n3\n123\n3\n123\n3\n213\n3\n123\n3\n123\n3\n123\n3\n321\n3\n123\n3\n321\n3\n132\n3\n322\n3\n321\n3\n341\n3\n123\n3\n421\n3\n421\n3\n421\n3\n421\n", "output": "YES\n2\n1 23\nYES\n2\n1 23\nYES\n2\n1 23\nYES\n2\n1 23\nYES\n2\n1 23\nYES\n2\n2 13\nYES\n2\n1 23\nYES\n2\n1 23\nYES\n2\n1 ... | code_stdio |
[
{
"content": "During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. \n\nLet's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a1, the second place participant... | [{"input": "10 0\n5 9 1 12 4 2 2 4 12 1\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 0\n5 16 1 7 4 2 2 5 18 3\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 0\n5 16 1 7 4 2 2 4 18 3\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 0\n5 16 1 7 7 2 2 4 18 3\n", "output": "2\n3\n4\n5\n6\n7\n8... | code_stdio |
[
{
"content": "Consider a billiard table of rectangular size $n \\times m$ with four pockets. Let's introduce a coordinate system with the origin at the lower left corner (see the picture). [Image] \n\nThere is one ball at the point $(x, y)$ currently. Max comes to the table and strikes the ball. The ball start... | [{"input": "1000000000 999999999 999999998 999999999 -1 -1\n", "output": "1000000000 999999999\n"}, {"input": "1000000000 999999999 999999998 999999999 -1 -1\n", "output": "1000000000 999999999"}, {"input": "1000000000 999999999 999999998 999999999 -1 1\n", "output": "1000000000 999999999\n"}, {"input": "1000000000 999... | code_stdio |
[
{
"content": "Valera is a collector. Once he wanted to expand his collection with exactly one antique item.\n\nValera knows n sellers of antiques, the i-th of them auctioned k_{i} items. Currently the auction price of the j-th object of the i-th seller is s_{ij}. Valera gets on well with each of the n sellers. ... | [{"input": "3 999999\n22 1000000 1000000 1250369 623205 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000100 1506663 1001000 1010000 999999 1000000 1000000 1010000 352800 999999 1000000\n14 999999 999999 1521826 1368902 999999 1000000 999999 1556972 999999 999999 418013 999999 1000000 999999\n5 999999 100000... | code_stdio |
[
{
"content": "You are given a Young diagram. \n\nGiven diagram is a histogram with $n$ columns of lengths $a_1, a_2, \\ldots, a_n$ ($a_1 \\geq a_2 \\geq \\ldots \\geq a_n \\geq 1$). [Image] Young diagram for $a=[3,2,2,2,1]$. \n\nYour goal is to find the largest number of non-overlapping dominos that you can dra... | [{"input": "100\n1980 1932 1906 1898 1892 1883 1877 1858 3146 1833 1777 1710 1689 1678 1660 1653 1648 1647 1644 1639 1635 1635 1593 1571 1534 1470 1440 1435 1389 1272 1269 1268 1263 1255 1249 1237 1174 1174 1128 529 1067 981 1707 979 951 915 911 906 863 826 810 810 802 785 764 752 743 710 705 451 676 661 639 1208 616 5... | code_stdio |
[
{
"content": "Write a function that will encrypt a given sentence into International Morse Code, both the input and out puts will be strings.\n\nCharacters should be separated by a single space.\nWords should be separated by a triple space.\n\nFor example, \"HELLO WORLD\" should return -> \".... . .-.. .-.. ---... | [{"input": "\"THE QUICK BROWN FOX\"", "output": "[\"- .... . --.- ..- .. -.-. -.- -... .-. --- .-- -. ..-. --- -..-\"]", "fn_name": "encryption"}, {"input": "\"WOLFRAM ALPHA 1\"", "output": "[\".-- --- .-.. ..-. .-. .- -- .- .-.. .--. .... .- .----\"]", "fn_name": "encryption"}, {"input": "\"Final basic test\... | code_functional |
[
{
"content": "Let's introduce a number system which is based on a roman digits. There are digits I, V, X, L which correspond to the numbers 1, 5, 10 and 50 respectively. The use of other roman digits is not allowed.\n\nNumbers in this system are written as a sequence of one or more digits. We define the value o... | [{"input": "1000000000\n", "output": "48999999753\n"}, {"input": "1000000100\n", "output": "49000004653\n"}, {"input": "1517731607\n", "output": "74368848496\n"}, {"input": "1000001100\n", "output": "49000053653\n"}, {"input": "1000001000\n", "output": "49000048753\n"}, {"input": "600000000\n", "output": "29399999753\n... | code_stdio |
[
{
"content": "The internet is a very confounding place for some adults. Tom has just joined an online forum and is trying to fit in with all the teens and tweens. It seems like they're speaking in another language! Help Tom fit in by translating his well-formatted English into n00b language.\n\nThe following ru... | [{"input": "\"Sometimes I use ? in the middle of a sentence; is that ok?!\"", "output": "[\"OMG ZOMETIMEZ I UZE ?????????????? IN the MIDDLE of A zentence; IZ that OK??????????????!1!1!1!1!1!1!1\"]", "fn_name": "n00bify"}, {"input": "\"Before you know it... wait, what does this have to do with UNO!?\"", "output": "[\"O... | code_functional |
[
{
"content": "A and B are preparing themselves for programming contests.\n\nB loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.\n\nInitially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some ... | [{"input": "10\n460626451 802090732 277246428 661369649 388684428 784303821 376287098 656422756 9301599 25720377\n277246428 388684428 661369649 460626451 656422756 802090732 9301599 784303821 376287098\n376287098 802090732 388684428 9301599 656422756 784303821 460626451 277246428\n", "output": "25720377\n661369649\n"},... | code_stdio |
[
{
"content": "A high school has a strange principal. On the first day, he has his students perform an odd opening day ceremony:\n\nThere are number of lockers \"n\" and number of students \"n\" in the school. The principal asks the first student to go to every locker and open it. Then he has the second student ... | [{"input": "950811894", "output": "[30835]", "fn_name": "num_of_open_lockers"}, {"input": "3991700", "output": "[1997]", "fn_name": "num_of_open_lockers"}, {"input": "74864", "output": "[273]", "fn_name": "num_of_open_lockers"}, {"input": "128", "output": "[11]", "fn_name": "num_of_open_lockers"}, {"input": "500", "out... | code_functional |
[
{
"content": "Polycarp found a rectangular table consisting of $n$ rows and $m$ columns. He noticed that each cell of the table has its number, obtained by the following algorithm \"by columns\":\n\ncells are numbered starting from one;\n\ncells are numbered from left to right by columns, and inside each column... | [{"input": "5\n1 1 1\n2 2 3\n3 10 11\n100 100 7312\n1001000 1000010 1000000000000\n", "output": "1\n2\n14\n1174\n1000009998991\n"}, {"input": "5\n1 1 1\n2 2 2\n3 10 11\n100 100 7312\n1001000 1000010 1000000000000\n", "output": "1\n3\n14\n1174\n1000009998991\n"}, {"input": "5\n1 1 1\n2 2 2\n3 10 11\n100 100 7312\n100100... | code_stdio |
[
{
"content": "A tree is an undirected connected graph without cycles.\n\nYou are given a tree of n vertices. Find the number of ways to choose exactly k vertices in this tree (i. e. a k-element subset of vertices) so that all pairwise distances between the selected vertices are equal (in other words, there exis... | [{"input": "8\n\n3 2\n3 1\n1 2\n\n5 5\n4 1\n5 4\n1 3\n2 4\n\n10 2\n2 5\n3 10\n9 4\n7 1\n6 2\n9 6\n3 1\n8 7\n10 2\n\n2 2\n2 1\n\n7 4\n5 1\n1 4\n3 6\n6 4\n3 7\n2 3\n\n10 4\n8 4\n1 6\n7 1\n5 1\n10 2\n8 9\n2 3\n2 4\n6 9\n\n5 5\n1 5\n3 5\n1 2\n4 2\n\n8 3\n1 2\n5 8\n5 4\n2 7\n7 6\n8 7\n3 2\n", "output": "3\n0\n45\n1\n0\n0\n0... | code_stdio |
[
{
"content": "Nikolay has a lemons, b apples and c pears. He decided to cook a compote. According to the recipe the fruits should be in the ratio 1: 2: 4. It means that for each lemon in the compote should be exactly 2 apples and exactly 4 pears. You can't crumble up, break up or cut these fruits into pieces. T... | [{"input": "1000\n1000\n1000\n", "output": "1750\n"}, {"input": "1000\n1000\n1001\n", "output": "1750\n"}, {"input": "1000\n1010\n1001\n", "output": "1750\n"}, {"input": "1000\n500\n1000\n", "output": "1750\n"}, {"input": "1000\n1000\n1000\n", "output": "1750"}, {"input": "1000\n507\n1000\n", "output": "1750\n"}, {"inp... | code_stdio |
[
{
"content": "Ziota found a video game called \"Monster Invaders\".\n\nSimilar to every other shooting RPG game, \"Monster Invaders\" involves killing monsters and bosses with guns.\n\nFor the sake of simplicity, we only consider two different types of monsters and three different types of guns.\n\nNamely, the ... | [{"input": "100 5 5 9 3\n3 4 2 3 4 3 8 5 2 1 1 4 1 1 10 10 7 5 2 9 4 2 10 10 8 2 4 9 6 2 6 7 7 5 7 7 1 8 10 9 9 3 10 3 10 1 1 8 3 6 4 5 5 4 9 5 9 4 8 2 10 8 9 1 5 9 7 2 1 7 9 3 2 9 1 5 4 2 3 10 6 7 8 2 10 1 6 2 1 6 10 9 1 2 2 7 2 8 4 4\n", "output": "1597\n"}, {"input": "100 5 5 9 3\n3 4 2 3 4 3 8 5 2 1 1 4 1 1 10 10 7... | code_stdio |
[
{
"content": "You are given a bracket sequence $s$ consisting of $n$ opening '(' and closing ')' brackets.\n\nA regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of the sequence. For exa... | [{"input": "20\n(())(()((((()())()((\n", "output": "0\n"}, {"input": "20\n(())(((((((()())()()\n", "output": "0\n"}, {"input": "20\n(()())()((((()(())((\n", "output": "0\n"}, {"input": "20\n(())((((()(((())()()\n", "output": "0\n"}, {"input": "20\n(())(()(((())())()((\n", "output": "0\n"}, {"input": "19\n)(()()()()))((... | code_stdio |
[
{
"content": "As you might remember from the previous round, Vova is currently playing a strategic game known as Rage of Empires.\n\nVova managed to build a large army, but forgot about the main person in the army - the commander. So he tries to hire a commander, and he wants to choose the person who will be re... | [{"input": "5\n1 1\n1 4\n3 6 3\n1 4\n3 10 3\n", "output": "1\n0\n"}, {"input": "5\n1 3\n1 4\n3 11 3\n2 4\n3 6 2\n", "output": "0\n0\n"}, {"input": "5\n1 3\n1 4\n3 12 3\n1 4\n3 4 3\n", "output": "0\n2\n"}, {"input": "5\n1 3\n1 4\n3 8 3\n2 4\n3 6 3\n", "output": "0\n0\n"}, {"input": "5\n1 3\n1 4\n3 6 3\n1 4\n3 6 3\n", "o... | code_stdio |
[
{
"content": "You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.\n\nWe remind that in a sequence of numbers a_1, a_2, ..., a_{k} the element a_{i} is a record if for every integer j (1 ≤ j < i) the following holds: a_{j} < a_{i}. \n... | [{"input": "92\n42 64 33 89 57 9 24 44 87 67 92 84 39 88 26 27 85 62 22 83 23 71 14 13 73 79 15 49 2 12 76 53 81 40 31 3 72 58 1 61 7 82 20 54 46 77 11 16 28 48 6 45 36 43 60 38 18 4 32 74 10 91 19 86 75 51 50 52 78 25 65 8 55 30 90 69 59 63 56 80 29 68 70 17 35 41 37 47 66 34 5 21\n", "output": "1\n"}, {"input": "92\n... | code_stdio |
[
{
"content": "Alice has a birthday today, so she invited home her best friend Bob. Now Bob needs to find a way to commute to the Alice's home.\n\nIn the city in which Alice and Bob live, the first metro line is being built. This metro line contains $n$ stations numbered from $1$ to $n$. Bob lives near the stati... | [{"input": "10 3\n0 1 1 0 1 0 0 2 -1 0\n1 4 1 2 -1 0 1 1 -1 1\n", "output": "NO\n"}, {"input": "10 10\n1 0 0 0 0 0 0 0 0 1\n0 0 0 0 0 0 0 0 0 0\n", "output": "YES\n"}, {"input": "10 10\n1 0 0 0 0 0 0 0 0 1\n0 0 0 0 0 0 0 0 0 0\n", "output": "YES\n"}, {"input": "10 3\n0 1 1 0 1 0 0 2 -1 0\n1 2 1 1 -1 0 1 1 0 1\n", "outp... | code_stdio |
[
{
"content": "Little Elephant loves magic squares very much.\n\nA magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square, the sum of integers in all its rows, columns... | [{"input": "0 100000 100000\n100000 0 100000\n100000 100000 0\n", "output": "100000 100000 100000\n100000 100000 100000\n100000 100000 100000\n"}, {"input": "0 100000 100000\n100000 0 100000\n100000 100000 0\n", "output": "100000 100000 100000\n100000 100000 100000\n100000 100000 100000\n"}, {"input": "0 98721 99776\n9... | code_stdio |
[
{
"content": "problem\n\nThere are fine icicles under the eaves of JOI's house in Canada. Because of this, JOI decided to investigate the icicles.\n\nThere are N (2 ≤ N ≤ 100000 = 105) icicles under the eaves of JOI's house. These icicles are aligned and i cm (1 ≤ i ≤ N) from the left edge of the eaves. There a... | [{"input": "1 56\n4\n-1\n-1\n-1", "output": "52\n"}, {"input": "2 71\n14\n6\n0\n0", "output": "122\n"}, {"input": "2 30\n14\n6\n3\n0", "output": "40\n"}, {"input": "2 17\n2\n3\n3\n-1", "output": "29\n"}, {"input": "2 38\n14\n6\n0\n0", "output": "56\n"}, {"input": "4 10\n7\n1\n3\n5", "output": "21\n"}, {"input": "4 11\n... | code_stdio |
[
{
"content": "Third day at your new cryptoanalyst job and you come across your toughest assignment yet. Your job is to implement a simple keyword cipher. A keyword cipher is a type of monoalphabetic substitution where two parameters are provided as such (string, keyword). The string is encrypted by taking the k... | [{"input": "\"alpha bravo charlie\"\n\"delta\"", "output": "[\"djofd eqdvn lfdqjga\"]", "fn_name": "keyword_cipher"}, {"input": "\"WELCOME HOME\"\n\"gridlocked\"", "output": "[\"wlfimhl kmhl\"]", "fn_name": "keyword_cipher"}, {"input": "\"one two three\"\n\"rails\"", "output": "[\"mks twm tdpss\"]", "fn_name": "keyword... | code_functional |
[
{
"content": "Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magi... | [{"input": "150\n0 -2 1 -2 0 0 0 0 -2 0 -2 -1 0 0 2 0 1 -2 1 -1 0 0 0 2 -2 2 -1 0 0 -1 -2 0 2 0 1 0 -2 0 -2 -1 0 -2 -2 2 0 0 1 -2 -2 -1 -2 0 2 1 1 -1 1 0 -2 2 0 0 0 1 -1 0 -2 -1 0 -2 1 1 1 0 0 2 0 0 2 -1 0 0 2 0 2 0 -2 -1 1 -2 1 0 0 -2 -1 -1 0 0 2 -1 -1 -1 -1 -2 0 0 2 -1 -1 1 0 0 1 -1 0 0 -1 2 2 0 0 0 -1 -2 0 1 0 -1 -1... | code_stdio |
[
{
"content": "Jabber ID on the national Berland service «Babber» has a form <username>@<hostname>[/resource], where \n\n * <username> — is a sequence of Latin letters (lowercase or uppercase), digits or underscores characters «_», the length of <username> is between 1 and 16, inclusive. \n * <hostname> — is a... | [{"input": "IGsma3L6YTJRrXS@1g.yR3mC.c.xoCns7Wo1.9C.Oe.5ebkR/_97Ltj3\n", "output": "YES\n"}, {"input": "IGsma3K6YTJRrXS@1g.yR3mC.c.xoCns7Wo1.9C.Oe.5ebkR/_97Ltj3\n", "output": "YES\n"}, {"input": "POTjlYcxAZsbyZPDh@sPm.z6aVaO.H1wEUhD9YvROQFUk/M_jTHS_6!\n", "output": "NO\n"}, {"input": "POTjlYcxAZsbyZPDh9sPm.z6aVaO.H1wEU... | code_stdio |
[
{
"content": "There is an airplane which has n rows from front to back. There will be m people boarding this airplane.\n\nThis airplane has an entrance at the very front and very back of the plane.\n\nEach person has some assigned seat. It is possible for multiple people to have the same assigned seat. The peop... | [{"input": "1000000 1000000\n", "output": "233176135\n"}, {"input": "1000000 1000000\n", "output": "233176135\n"}, {"input": "1000001 1000000\n", "output": "109334147\n"}, {"input": "1000000 500000\n", "output": "211837745\n"}, {"input": "1000000 500000\n", "output": "211837745\n"}, {"input": "1000000 481032\n", "outpu... | code_stdio |
[
{
"content": "A boy named Vasya has taken part in an Olympiad. His teacher knows that in total Vasya got at least x points for both tours of the Olympiad. The teacher has the results of the first and the second tour of the Olympiad but the problem is, the results have only points, no names. The teacher has to k... | [{"input": "10 168884\n75796 42057 25891 51127 40493 78380 30331 47660 58338 90812\n50469 28184 75581 61837 25050 90975 98279 81022 90217 31015\n", "output": "1 3\n"}, {"input": "10 168884\n29651 42057 25891 51127 40493 78380 30331 47660 58338 90812\n50469 28184 75581 61837 25050 90975 98279 81022 90217 31015\n", "outp... | code_stdio |
[
{
"content": "Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...\n\n$n$ friends live in a city which can be represented as a number line. The $i$-th friend lives in a house with an integer coordinate $x_i$. The $i$-th friend can come celebrate the New Ye... | [{"input": "10\n10 7 10 10 7 10 7 7 10 10\n", "output": "2 6\n"}, {"input": "10\n10 7 10 10 7 10 7 7 10 10\n", "output": "2 6\n"}, {"input": "10\n10 7 10 10 7 10 7 5 10 10\n", "output": "2 7\n"}, {"input": "10\n1 2 3 4 5 6 7 8 9 10\n", "output": "4 10\n"}, {"input": "10\n1 2 3 4 5 6 7 8 9 10\n", "output": "4 10\n"}, {"... | code_stdio |
[
{
"content": "# Rock Paper Scissors\n\nLet's play! You have to return which player won! In case of a draw return `Draw!`.\n\nExamples:\n\n\n\nWrite Python code to solve this problem. Define a top-level function named `rps` that takes the input arguments descri... | [{"input": "\"scissors\"\n\"paper\"", "output": "[\"Player 1 won!\"]", "fn_name": "rps"}, {"input": "\"paper\"\n\"scissors\"", "output": "[\"Player 2 won!\"]", "fn_name": "rps"}, {"input": "\"rock\"\n\"scissors\"", "output": "[\"Player 1 won!\"]", "fn_name": "rps"}, {"input": "\"scissors\"\n\"rock\"", "output": "[\"Pla... | code_functional |
[
{
"content": "Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded.\n\nFor example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to 10. Both ways are correct.\n\nFor given n find out ... | [{"input": "1000000000\n", "output": "1000000000\n"}, {"input": "1031575393\n", "output": "1031575390\n"}, {"input": "1022742286\n", "output": "1022742290\n"}, {"input": "1259496606\n", "output": "1259496610\n"}, {"input": "1938879055\n", "output": "1938879050\n"}, {"input": "1178556713\n", "output": "1178556710\n"}, {... | code_stdio |
[
{
"content": "Notes\n\nTemplate in C\n\nConstraints\n\n* 1 ≤ n ≤ 100000\n* 1 ≤ q ≤ 1000\n* 1 ≤ timei ≤ 50000\n* 1 ≤ length of namei ≤ 10\n* 1 ≤ Sum of timei ≤ 1000000\n\nInput\n\nn q\nname1 time1\nname2 time2\n...\nnamen timen\n\n\nIn the first line the number of processes n and the quantum q are given separate... | [{"input": "5 100\np1 150\np2 216\np3 200\np4 548\np5 20", "output": "p5 420\np1 470\np3 670\np2 786\np4 1134\n"}, {"input": "5 100\np1 150\np2 216\no3 200\np4 548\np5 20", "output": "p5 420\np1 470\no3 670\np2 786\np4 1134\n"}, {"input": "5 100\np1 150\np2 216\no3 200\np4 548\nq5 20", "output": "q5 420\np1 470\no3 670... | code_stdio |
[
{
"content": "Given a string (`str`) containing a base-10 integer between `0` and `10000`, convert the integer to its binary representation. At that point, obtain a count of the maximum amount of consecutive 0s. From there, return the count in written form with a capital letter.\n\nIn the very first example, we... | [{"input": "\"8192\"", "output": "[\"Thirteen\"]", "fn_name": "max_consec_zeros"}, {"input": "\"2048\"", "output": "[\"Eleven\"]", "fn_name": "max_consec_zeros"}, {"input": "\"4096\"", "output": "[\"Twelve\"]", "fn_name": "max_consec_zeros"}, {"input": "\"6144\"", "output": "[\"Eleven\"]", "fn_name": "max_consec_zeros"... | code_functional |
[
{
"content": "N problems have been chosen by the judges, now it's time to assign scores to them!\n\nProblem i must get an integer score A_i between 1 and N, inclusive. The problems have already been sorted by difficulty: A_1 \\le A_2 \\le \\ldots \\le A_N must hold. Different problems can have the same score, t... | [{"input": "157 925309799", "output": "391028716"}, {"input": "134 925309799", "output": "114482723"}, {"input": "134 569368125", "output": "166407741"}, {"input": "134 788899135", "output": "506695346"}, {"input": "48 126674882", "output": "104179983"}, {"input": "45 713052776", "output": "108412121"}, {"input": "90 3... | code_stdio |
[
{
"content": "You are given a text that consists of lowercase Latin letters, spaces and punctuation marks (dot, comma, exclamation mark and question mark). A word is defined as a sequence of consecutive Latin letters.\n\nYour task is to add spaces to the text by the following rules:\n\n * if there is no punctu... | [{"input": "ajdwlf ibvlfqadt sqdn aoj nsjtivfrsp !mquqfgzrbp w ow aydap ry s . jwlvg ? ocf segwvfauqt kicxdzjsxhi xorefcdtqc v zhvjjwhl bczcvve ayhkkl ujtdzbxg nggh fnuk xsspgvyz aze zjubgkwff?hgj spteldqbdo vkxtgnl uxckibqs vpzeaq roj jzsxme gmfpbjp uz ... | code_stdio |
[
{
"content": "Snuke has a rooted tree with N+1 vertices.\nThe vertices are numbered 0 through N, and Vertex 0 is the root of the tree.\nThe parent of Vertex i (1 \\leq i \\leq N) is Vertex p_i.\nBesides this tree, Snuke also has an box which is initially empty and many marbles, and playing with them.\nThe play ... | [{"input": "31\n0 1 0 2 4 0 4 1 6 4 3 9 7 3 7 2 15 6 12 10 12 16 5 3 20 1 25 20 23 24 23\n", "output": "730395550\n"}, {"input": "31\n0 1 0 2 4 0 4 1 6 4 3 9 7 3 7 3 15 6 12 10 12 16 5 3 20 1 25 20 23 24 23", "output": "831058846\n"}, {"input": "31\n0 1 0 2 4 0 4 0 6 4 3 9 7 3 7 3 15 6 12 10 12 16 5 3 20 1 25 20 23 24 ... | code_stdio |
[
{
"content": "Vasya plays the Geometry Horse.\n\nThe game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value. \n\nThere are n types of geometric figures. The number of figures of type ki... | [{"input": "16\n196661091 17\n765544213 322\n134522506 115\n914609421 163\n219016066 227\n835576807 856\n682158845 914\n11248128 145\n876496017 854\n141052597 530\n163180278 315\n407245991 60\n294673989 270\n2976249 26\n674132026 519\n347829904 23\n16\n6280951514 53396669509 79113951711 87247958777 121933859963 2190625... | code_stdio |
[
{
"content": "You are planning to buy an apartment in a $n$-floor building. The floors are numbered from $1$ to $n$ from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the bottom) floor.\n\nLet: $a_i$ for all $i$ from $1$ to $n-1$ be the time ... | [{"input": "10 2\n7 6 15 6 16 18 2 17 17\n12 11 3 10 9 1 10 1 5\n", "output": "0 7 13 18 24 35 36 38 41 46\n"}, {"input": "10 2\n7 6 18 6 16 18 1 17 17\n6 9 3 10 9 1 10 1 5\n", "output": "0 7 13 18 24 35 36 37 40 45 \n"}, {"input": "10 2\n7 6 18 6 16 18 1 17 17\n6 17 3 10 9 1 10 1 5\n", "output": "0 7 13 18 24 35 36 37... | code_stdio |
[
{
"content": "How many ways are there to choose two distinct positive integers totaling N, disregarding the order?\n\nConstraints\n\n* 1 \\leq N \\leq 10^6\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 answer.\n\nExamples\n\nInput\n\n... | [{"input": "3256265", "output": "1628132\n"}, {"input": "1527191", "output": "763595\n"}, {"input": "1743342", "output": "871670\n"}, {"input": "1412384", "output": "706191\n"}, {"input": "1339977", "output": "669988\n"}, {"input": "245898", "output": "122948\n"}, {"input": "235323", "output": "117661\n"}, {"input": "1... | code_stdio |
[
{
"content": "You are given a string $s$ of 0's and 1's. You are allowed to perform the following operation:\n\nchoose a non-empty contiguous substring of $s$ that contains an equal number of 0's and 1's;\n\nflip all characters in the substring, that is, replace all 0's with 1's, and vice versa;\n\nreverse the ... | [{"input": "64\n0000\n1000\n0100\n1100\n0010\n1010\n0110\n1110\n0001\n1001\n0101\n1101\n0011\n1011\n0111\n1111\n0000\n1000\n0100\n1100\n0010\n1010\n0110\n1110\n0001\n1001\n0101\n1101\n0011\n1011\n0111\n1111\n0000\n1000\n0100\n1100\n0010\n1010\n0110\n1110\n0001\n1001\n0101\n1101\n0011\n1011\n0111\n1111\n0000\n1000\n0100... | code_stdio |
[
{
"content": "Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw.\n\nThe first player wrote number a, the second player wrote ... | [{"input": "2 5\n", "output": "3 0 3\n"}, {"input": "2 4\n", "output": "2 1 3\n"}, {"input": "5 3\n", "output": "2 1 3\n"}, {"input": "1 6\n", "output": "3 0 3\n"}, {"input": "5 1\n", "output": "3 1 2\n"}, {"input": "6 3\n", "output": "2 0 4\n"}, {"input": "2 3\n", "output": "2 0 4\n"}, {"input": "5 6\n", "output": "5 ... | code_stdio |
[
{
"content": "Vasya tries to break in a safe. He knows that a code consists of n numbers, and every number is a 0 or a 1. Vasya has made m attempts to enter the code. After each attempt the system told him in how many position stand the right numbers. It is not said in which positions the wrong numbers stand. V... | [{"input": "35 10\n11101100001010011101100010101111111 5\n11101100010011101100001010101011011 5\n11101100001101111110000011101111010 5\n11101100101001111100000110111111001 5\n11101100001011000100001011101111011 5\n10101000001011111010000010001111011 5\n11101100001011111100010000111110001 0\n1110100000111111110000001010... | code_stdio |
[
{
"content": "# Two samurai generals are discussing dinner plans after a battle, but they can't seem to agree.\n\nThe discussion gets heated and you are cannot risk favoring either of them as this might damage your political standing with either of the two clans the samurai generals belong to. Thus, the only th... | [{"input": "\"eat a burger and drink a coke\"\n\"drink a coke\"", "output": "[\"drink a coke\"]", "fn_name": "common_ground"}, {"input": "\"i like turtles\"\n\"what are you talking about\"", "output": "[\"death\"]", "fn_name": "common_ground"}, {"input": "\"eat chicken\"\n\"eat chicken and rice\"", "output": "[\"eat ch... | code_functional |
[
{
"content": "You are given an array $a_1, a_2, \\dots, a_n$ and an integer $k$.\n\nYou are asked to divide this array into $k$ non-empty consecutive subarrays. Every element in the array should be included in exactly one subarray. Let $f(i)$ be the index of subarray the $i$-th element belongs to. Subarrays are... | [{"input": "7 6\n-3 0 -1 -2 -2 -4 -1\n", "output": "-45\n"}, {"input": "7 6\n-6 1 -1 -1 -2 -4 -1\n", "output": "-43\n"}, {"input": "7 7\n-3 0 -1 -2 -2 -4 -1\n", "output": "-55\n"}, {"input": "7 6\n-5 1 -1 -1 -2 -4 -1\n", "output": "-42\n"}, {"input": "7 6\n-3 0 -1 -2 -2 -4 0\n", "output": "-39\n"}, {"input": "7 6\n-6 0... | code_stdio |
[
{
"content": "In number world, two different numbers are friends if they have a lot in common, but also each one has unique perks.\n\nMore precisely, two different numbers $a$ and $b$ are friends if $gcd(a,b)$, $\\frac{a}{gcd(a,b)}$, $\\frac{b}{gcd(a,b)}$ can form sides of a triangle.\n\nThree numbers $a$, $b$ ... | [{"input": "100\n42 486 341 527 189 740 490 388 989 489 711 174 305 844 971 492 998 954 832 442 424 619 906 154 293 395 439 735 738 915 453 748 786 550 871 932 693 326 53 904 732 835 354 364 691 669 203 719 282 875 573 672 695 640 58 872 732 751 557 779 102 39 213 844 289 137 50 951 284 671 474 829 906 736 395 366 22 1... | code_stdio |
[
{
"content": "You're given a tree with $n$ vertices.\n\nYour task is to determine the maximum possible number of edges that can be removed in such a way that all the remaining connected components will have even size.\n\n\n-----Input-----\n\nThe first line contains an integer $n$ ($1 \\le n \\le 10^5$) denoting... | [{"input": "10\n7 1\n8 4\n8 10\n4 7\n6 10\n9 3\n3 5\n2 10\n2 5\n", "output": "4\n"}, {"input": "10\n8 1\n8 4\n8 10\n4 7\n6 10\n9 3\n3 5\n2 10\n2 5\n", "output": "4\n"}, {"input": "10\n4 1\n10 4\n8 10\n4 7\n6 5\n9 2\n3 5\n2 10\n2 5\n", "output": "0\n"}, {"input": "10\n4 1\n10 4\n8 10\n4 7\n6 1\n9 2\n3 5\n2 10\n2 5\n", "... | code_stdio |
[
{
"content": "Tak has N cards. On the i-th (1 \\leq i \\leq N) card is written an integer x_i. He is selecting one or more cards from these N cards, so that the average of the integers written on the selected cards is exactly A. In how many ways can he make his selection?\n\nConstraints\n\n* 1 \\leq N \\leq 50\... | [{"input": "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3", "output": "4294967295\n"}, {"input": "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3", "output": "2147483647\n"}, {"input": "33 3\n3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 0 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3", "output": ... | code_stdio |
[
{
"content": "Complete the function/method (depending on the language) to return `true`/`True` when its argument is an array that has the same nesting structures and same corresponding length of nested arrays as the first array.\n\nFor example:\n\n```python\n# should return True\nsame_structure_as([ 1, 1, 1 ], ... | [{"input": "[1, \"[\", \"]\"]\n[\"[\", \"]\", 1]", "output": "[true]", "fn_name": "same_structure_as"}, {"input": "[1, [[[1]]]]\n[2, [[[2]]]]", "output": "[true]", "fn_name": "same_structure_as"}, {"input": "[1, [1, 1]]\n[[2, 2], 2]", "output": "[false]", "fn_name": "same_structure_as"}, {"input": "[1, [1, 1]]\n[2, [2]... | code_functional |
[
{
"content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nPhantasialand boasts of its famous theme park. The park is frequently visited. It is quite large park that some tourists visit it more than once to fully appreciate its offerings. One day, our Chefs decided to visit ... | [{"input": "4\n1 -1 12 11", "output": "12\n"}, {"input": "4\n1 -2 12 11", "output": "11\n"}, {"input": "4\n-1 -1 0 36", "output": "17\n"}, {"input": "4\n-2 -2 0 36", "output": "16\n"}, {"input": "4\n-1 -1 0 42", "output": "20\n"}, {"input": "4\n1 -2 13 38", "output": "25\n"}, {"input": "4\n2 -2 13 38", "output": "26\n"... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ integers.\n\nYour task is to say the number of such positive integers $x$ such that $x$ divides each number from the array. In other words, you have to find the number of common divisors of all elements in the array.\n\nFor example, if the array $a$ wil... | [{"input": "6\n10000100623 10000100623 10000100623 10000100623 10000100623 10000100623\n", "output": "2\n"}, {"input": "6\n10000100623 10000100623 10000100623 10000100623 10000100623 10000100623\n", "output": "2\n"}, {"input": "5\n153965681607 99999999977 99999999977 99999999977 99999999977\n", "output": "1\n"}, {"inpu... | code_stdio |
[
{
"content": "Count the number of distinct sequences a_1, a_2, ..., a_{n} (1 ≤ a_{i}) consisting of positive integers such that gcd(a_1, a_2, ..., a_{n}) = x and $\\sum_{i = 1}^{n} a_{i} = y$. As this number could be large, print the answer modulo 10^9 + 7.\n\ngcd here means the greatest common divisor.\n\n\n--... | [{"input": "495219 444706662\n", "output": "115165527\n"}, {"input": "495219 444706662\n", "output": "115165527\n"}, {"input": "1000000000 1000000000\n", "output": "1\n"}, {"input": "9357 18255507\n", "output": "745979764\n"}, {"input": "225 315096300\n", "output": "413133630\n"}, {"input": "34601 35742833\n", "output"... | code_stdio |
[
{
"content": "There is a grid with N rows and N columns of squares. Let (i, j) be the square at the i-th row from the top and the j-th column from the left.\nEach of the central (N-2) \\times (N-2) squares in the grid has a black stone on it.\nEach of the 2N - 1 squares on the bottom side and the right side has... | [{"input": "176527 15\n1 81279\n2 22308\n2 133061\n1 80744\n2 44603\n1 170938\n2 139754\n2 15220\n1 172794\n1 159290\n2 156968\n1 56426\n2 77429\n1 97459\n2 71282\n", "output": "31159505795\n"}, {"input": "176527 15\n2 81279\n2 22308\n2 145342\n1 106634\n2 60988\n1 170938\n2 139754\n2 15220\n1 172794\n1 159290\n2 15696... | code_stdio |
[
{
"content": "There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i.\n\nYou and Lunlun the dachshund alternately perform the following operation (starting from you):\n\n* Choose one or more apples from the tree and eat them. H... | [{"input": "3\n000000\n24912\n20652", "output": "second\n"}, {"input": "3\n100000\n30000\n29639", "output": "first\n"}, {"input": "3\n000000\n30000\n29639", "output": "first\n"}, {"input": "3\n000001\n30000\n29639", "output": "first\n"}, {"input": "3\n000011\n30000\n29639", "output": "first\n"}, {"input": "3\n000010\n3... | code_stdio |
[
{
"content": "You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not re... | [{"input": "5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 1... | code_stdio |
[
{
"content": "These days Arkady works as an air traffic controller at a large airport. He controls a runway which is usually used for landings only. Thus, he has a schedule of planes that are landing in the nearest future, each landing lasts $1$ minute.\n\nHe was asked to insert one takeoff in the schedule. The... | [{"input": "66 20\n0 16\n0 45\n0 58\n1 6\n1 19\n2 7\n2 9\n3 9\n3 25\n3 57\n4 38\n4 58\n5 21\n5 40\n6 16\n6 19\n6 58\n7 6\n7 26\n7 51\n8 13\n8 36\n8 55\n9 1\n9 15\n9 33\n10 12\n10 37\n11 15\n11 34\n12 8\n12 37\n12 55\n13 26\n14 0\n14 34\n14 36\n14 48\n15 23\n15 29\n15 43\n16 8\n16 41\n16 45\n17 5\n17 7\n17 15\n17 29\n17... | code_stdio |
[
{
"content": "# Definition\n\n**_Disarium number_** is the number that *The sum of its digits powered with their respective positions is equal to the number itself*.\n\n____\n\n# Task\n\n**_Given_** a number, **_Find if it is Disarium or not_** . \n____\n\n# Warm-up (Highly recommended)\n\n# [Playing With Numbe... | [{"input": "2646798", "output": "[\"Disarium !!\"]", "fn_name": "disarium_number"}, {"input": "1306", "output": "[\"Disarium !!\"]", "fn_name": "disarium_number"}, {"input": "2427", "output": "[\"Disarium !!\"]", "fn_name": "disarium_number"}, {"input": "1048576", "output": "[\"Not !!\"]", "fn_name": "disarium_number"}... | code_functional |
[
{
"content": "Let’s get to know our hero: Agent #134 - Mr. Slayer.\n\nHe was sent by his CSV agency to Ancient Rome in order to resolve some important national issues. However, something incredible has happened - the enemies have taken Julius Caesar as a prisoner!!!\n\nCaesar, not a simple man as you know, mana... | [{"input": "\"ksdjai8983hdk?}{\"\n15", "output": "[\"zHsypx8983wsz?}{\"]", "fn_name": "caesar_crypto_encode"}, {"input": "\"eBIIL TLOIA!\"\n-127", "output": "[\"Hello world!\"]", "fn_name": "caesar_crypto_encode"}, {"input": "\"Hello world!\"\n127", "output": "[\"eBIIL TLOIA!\"]", "fn_name": "caesar_crypto_encode"}, {"... | code_functional |
[
{
"content": "For long time scientists study the behavior of sharks. Sharks, as many other species, alternate short movements in a certain location and long movements between locations.\n\nMax is a young biologist. For $n$ days he watched a specific shark, and now he knows the distance the shark traveled in eac... | [{"input": "127\n64 96 63 112 62 95 61 120 60 94 59 111 58 93 57 124 56 92 55 110 54 91 53 119 52 90 51 109 50 89 49 126 48 88 47 108 46 87 45 118 44 86 43 107 42 85 41 123 40 84 39 106 38 83 37 117 36 82 35 105 34 81 33 127 32 80 31 104 30 79 29 116 28 78 27 103 26 77 25 122 24 76 23 102 22 75 21 115 20 74 19 101 18 7... | code_stdio |
[
{
"content": "A linear congruential generator produces a series R(⋅) of pseudo-random numbers by the following for- mulas:\n\n<image>\n\nwhere S, A, C, and M are all parameters. In this problem, 0 ≤ S, A, C ≤ 15 and M = 256.\n\nNow suppose we have some input string I(⋅), where each character in the string is an... | [{"input": "5\n0 1 3 11 0\n5\n-1 12 2 0 7\n10\n46 2 28 27 203 31 14 81 122 141\n0", "output": "9 15 10\n6 11 13\n6 13 6\n"}, {"input": "5\n10 4 3 3 1\n5\n7 12 2 0 7\n10\n372 8 42 18 176 40 12 56 169 141\n0", "output": "0 1 1\n6 11 13\n0 15 15\n"}, {"input": "5\n5 1 3 11 0\n5\n0 12 2 0 7\n10\n46 2 28 27 203 31 14 81 122... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \nLeonid is developing new programming language. The key feature of his language is fast multiplication and raising to a power operations. He is asking you to help with the following task. \nYou have an expression S and positive integer M.... | [{"input": "2\n1000 2**3*3**1\n100000 4**2*2**11", "output": "24\n32768\n"}, {"input": "2\n1001 2**3*2**1\n100000 4**2*2**11", "output": "16\n32768\n"}, {"input": "2\n1000 2**4*3**1\n111000 4**2*2**11", "output": "48\n32768\n"}, {"input": "2\n1100 2**3*3**1\n110000 4**1*3**11", "output": "24\n48588\n"}, {"input": "2\n1... | code_stdio |
[
{
"content": "Many internet protocols these days include the option of associating a\nmedia type with the content being sent.\nThe type is usually inferred from the file extension.\nYou are to write a program that facilitates the lookup of media types for\na number of files.\nYou will be given a table of media ... | [{"input": "3 7\nhtml lmth/txft\nlht text/itml\ngnp image/png\nsug lmx+gvt/ehami\ntxt text/plajn\nindex.html\nthis.file.has.lots.of.dots.txt\nnoaotsdsall\nvires.uxe\ndont.let.the.png.fool.you\ncXT.trettam.esaT", "output": "unknown\nunknown\nlmth/txft\nunknown\nunknown\nunknown\nunknown\n"}, {"input": "2 7\nhmtl text/ht... | code_stdio |
[
{
"content": "Our brave travelers reached an island where pirates had buried treasure. However as the ship was about to moor, the captain found out that some rat ate a piece of the treasure map.\n\nThe treasure map can be represented as a rectangle n × m in size. Each cell stands for an islands' square (the squ... | [{"input": "20 20\n####################\n############.####.##\n#######..####..#####\n######............##\n######.....#...###.#\n#####E..........##.#\n#.##.#.........#####\n##NR....KO.....#####\n##B........#...#####\n#Y.W...H.......#####\n#####Z.....#...#####\n######...#.#...#####\n#A.......#.#...#####\n######.....#...... | code_stdio |
[
{
"content": "Since the giant heads have appeared in the sky all humanity is in danger, so all Ricks and Mortys from all parallel universes are gathering in groups to find a solution to get rid of them. \n\nThere are n parallel universes participating in this event (n Ricks and n Mortys). I. e. each of n univer... | [{"input": "100 50\n2 62 -62\n2 19 -19\n2 38 -38\n2 -84 84\n2 -16 16\n2 67 -67\n2 41 -41\n2 -32 32\n2 32 -32\n2 -62 62\n2 89 -89\n2 -84 84\n2 96 -96\n2 -11 11\n2 59 -59\n2 -13 13\n2 -70 70\n2 -3 3\n2 -41 41\n2 -74 74\n2 47 -47\n2 87 -87\n2 17 -17\n2 20 -20\n2 -14 14\n2 -67 67\n2 -95 95\n2 -15 15\n2 -49 49\n2 75 -75\n2 ... | code_stdio |
[
{
"content": "In this Kata, you will be given a lower case string and your task will be to remove `k` characters from that string using the following rule:\n```Python\n- first remove all letter 'a', followed by letter 'b', then 'c', etc...\n- remove the leftmost character first.\n```\n\n```Python\nFor example: ... | [{"input": "\"cccaabababaccbc\"\n3", "output": "[\"cccbbabaccbc\"]", "fn_name": "solve"}, {"input": "\"hxehmvkybeklnj\"\n5", "output": "[\"xmvkyklnj\"]", "fn_name": "solve"}, {"input": "\"abracadabra\"\n0", "output": "[\"abracadabra\"]", "fn_name": "solve"}, {"input": "\"abracadabra\"\n1", "output": "[\"bracadabra\"]",... | code_functional |
[
{
"content": "Every Turkish citizen has an identity number whose validity can be checked by these set of rules:\n\n- It is an 11 digit number\n- First digit can't be zero\n- Take the sum of 1st, 3rd, 5th, 7th and 9th digit and multiply it by 7.\nThen subtract the sum of 2nd, 4th, 6th and 8th digits from this va... | [{"input": "\"x5810a78432\"", "output": "[false]", "fn_name": "check_valid_tr_number"}, {"input": "\"03868894286\"", "output": "[false]", "fn_name": "check_valid_tr_number"}, {"input": "692352217312", "output": "[false]", "fn_name": "check_valid_tr_number"}, {"input": "12762438338", "output": "[false]", "fn_name": "che... | code_functional |
[
{
"content": "Makoto has a big blackboard with a positive integer $n$ written on it. He will perform the following action exactly $k$ times:\n\nSuppose the number currently written on the blackboard is $v$. He will randomly pick one of the divisors of $v$ (possibly $1$ and $v$) and replace $v$ with this divisor... | [{"input": "1000000000000000 10000\n", "output": "215514159\n"}, {"input": "1000000000000000 10000\n", "output": "215514159\n"}, {"input": "1000000000001000 10000\n", "output": "150774797\n"}, {"input": "1172768550854780 8998\n", "output": "789402181\n"}, {"input": "1292761461062695 8123\n", "output": "574008655\n"}, {... | code_stdio |
[
{
"content": "YouKn0wWho has two even integers x and y. Help him to find an integer n such that 1 ≤ n ≤ 2 ⋅ 10^{18} and n mod x = y mod n. Here, a mod b denotes the remainder of a after division by b. If there are multiple such integers, output any. It can be shown that such an integer always exists under the g... | [{"input": "4\n4 8\n4 1\n420 420\n167306 42068\n", "output": "8\n5\n420\n209374\n"}, {"input": "4\n4 8\n4 1\n420 420\n167306 11758\n", "output": "8\n5\n420\n179064\n"}, {"input": "4\n6 8\n4 1\n420 420\n167306 11758\n", "output": "7\n5\n420\n179064\n"}, {"input": "4\n4 8\n4 2\n420 420\n83876 42068\n", "output": "8\n6\n4... | code_stdio |
[
{
"content": "Life is not easy. Sometimes it is beyond your control. Now, as contestants of ACM ICPC, you might be just tasting the bitter of life. But don't worry! Do not look only on the dark side of life, but look also on the bright side. Life may be an enjoyable game of chance, like throwing dice. Do or die... | [{"input": "1\nnorth\n3\nnorth\neasu\nsouth\n0", "output": "5\n1\n"}, {"input": "1\nnorth\n0\nnorth\ntsae\nosuth\n-1", "output": "5\n"}, {"input": "1\nnorth\n0\nmorth\ntsae\nosuth\n-1", "output": "5\n"}, {"input": "1\nnorth\n0\nmorth\ntsae\nostth\n-1", "output": "5\n"}, {"input": "1\nnorth\n0\nntroh\ntsaf\nsouth\n-1", ... | code_stdio |
[
{
"content": "Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $n$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who... | [{"input": "25\n5 1 1\n5 2 3\n5 5 5\n5 5 1\n5 4 4\n10 1 2\n10 3 7\n10 10 10\n10 3 1\n10 7 6\n1000000 21232 1234\n999999 999999 999999\n1000000 300001 966605\n1000000 290001 679121\n500000 111099 123456\n100 1 1\n1000000000 1 1000000000\n1000000000 1 500000000\n100000000 1 12345678\n1000000000 1 499999999\n1000000000 1 ... | code_stdio |
[
{
"content": "It's the fourth quater of the Super Bowl and your team is down by 4 points. You're 10 yards away from the endzone, if your team doesn't score a touchdown in the next four plays you lose. On a previous play, you were injured and rushed to the hospital. Your hospital room has no internet, tv, or rad... | [{"input": "[[3, \"run\"], [3, \"run\"], [3, \"run\"], [10, \"turnover\"]]", "output": "[false]", "fn_name": "did_we_win"}, {"input": "[[10, \"run\"], [10, \"sack\"], [10, \"pass\"], [1, \"sack\"]]", "output": "[false]", "fn_name": "did_we_win"}, {"input": "[[5, \"pass\"], [5, \"pass\"], [10, \"sack\"], [10, \"run\"]]"... | code_functional |
[
{
"content": "Since Grisha behaved well last year, at New Year's Eve he was visited by Ded Moroz who brought an enormous bag of gifts with him! The bag contains n sweet candies from the good ol' bakery, each labeled from 1 to n corresponding to its tastiness. No two candies have the same tastiness.\n\nThe choic... | [{"input": "1000000000000000000 1000000000000000000\n", "output": "1152921504606846975\n"}, {"input": "1100000000000000000 1000000000000000000\n", "output": "1152921504606846975\n"}, {"input": "1100000000010000000 1000000000000000000\n", "output": "1152921504606846975\n"}, {"input": "1005016953863700545 145946161059548... | code_stdio |
[
{
"content": "You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. In addition, each vertex has a label, `A` or `B`. The label of Vertex i is s_i. Edge i bidirectionally connects vertex a_i and b_i.\n\nThe phantom thief Nuso... | [{"input": "13 23\nABAAAABBBBAAB\n7 1\n10 6\n1 11\n2 10\n2 8\n2 11\n11 12\n8 3\n7 11\n11 2\n13 13\n11 9\n4 1\n9 7\n9 6\n8 13\n8 6\n4 10\n8 7\n4 3\n2 1\n8 12\n6 9", "output": "Yes\n"}, {"input": "13 23\nABAAAABBBBAAB\n7 1\n10 6\n1 11\n2 10\n2 8\n2 11\n11 12\n8 3\n7 12\n11 2\n13 13\n11 9\n4 1\n9 7\n9 6\n8 13\n8 6\n4 10\n... | code_stdio |
[
{
"content": "In this kata, you will make a function that converts between `camelCase`, `snake_case`, and `kebab-case`.\n\nYou must write a function that changes to a given case. It must be able to handle all three case types:\n\n```python\npy> change_case(\"snakeCase\", \"snake\")\n\"snake_case\"\npy> change_c... | [{"input": "\"doHTMLRequest\"\n\"kebab\"", "output": "[\"do-h-t-m-l-request\"]", "fn_name": "change_case"}, {"input": "\"some-lisp-name\"\n\"camel\"", "output": "[\"someLispName\"]", "fn_name": "change_case"}, {"input": "\"map_to_all\"\n\"kebab\"", "output": "[\"map-to-all\"]", "fn_name": "change_case"}, {"input": "\"s... | code_functional |
[
{
"content": "Create a function that takes a number and finds the factors of it, listing them in **descending** order in an **array**.\n\nIf the parameter is not an integer or less than 1, return `-1`. In C# return an empty array.\n\nFor Example:\n`factors(54)` should return `[54, 27, 18, 9, 6, 3, 2, 1]`\n\nWri... | [{"input": "54", "output": "[[54, 27, 18, 9, 6, 3, 2, 1]]", "fn_name": "factors"}, {"input": "\"hello world\"", "output": "[-1]", "fn_name": "factors"}, {"input": "49", "output": "[[49, 7, 1]]", "fn_name": "factors"}, {"input": "-12", "output": "[-1]", "fn_name": "factors"}, {"input": "\"a\"", "output": "[-1]", "fn_nam... | code_functional |
[
{
"content": "AtCoDeer has three cards, one red, one green and one blue.\n\nAn integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.\n\nWe will arrange the cards in the order red, green and blue from left to right, and read them as a three-di... | [{"input": "4 3 2\n", "output": "YES\n"}, {"input": "2 3 4\n", "output": "NO\n"}, {"input": "7 3 2", "output": "YES\n"}, {"input": "7 6 0", "output": "YES\n"}, {"input": "2 6 0", "output": "YES\n"}, {"input": "9 6 0", "output": "YES\n"}, {"input": "0 6 0", "output": "YES\n"}, {"input": "5 6 0", "output": "YES\n"}, {"in... | code_stdio |
[
{
"content": "*This is the advanced version of the \n[Minimum and Maximum Product of k Elements](https://www.codewars.com/kata/minimum-and-maximum-product-of-k-elements/) kata.*\n\n---\n\nGiven a list of **integers** and a positive integer `k` (> 0), find the minimum and maximum possible product of `k` elements... | [{"input": "[0, -1, -2, -3, -4]\n3", "output": "[[-24, 0]]", "fn_name": "find_min_max_product"}, {"input": "[0, -1, -2, -3, -4]\n2", "output": "[[0, 12]]", "fn_name": "find_min_max_product"}, {"input": "[-1, -2, -3, -4]\n3", "output": "[[-24, -6]]", "fn_name": "find_min_max_product"}, {"input": "[-1, -2, -3, -4]\n2", "... | code_functional |
[
{
"content": "In some village, there are 999 towers that are 1,(1+2),(1+2+3),...,(1+2+3+...+999) meters high from west to east, at intervals of 1 meter.\nIt had been snowing for a while before it finally stopped. For some two adjacent towers located 1 meter apart, we measured the lengths of the parts of those t... | [{"input": "290178 291177\n", "output": "208323\n"}, {"input": "336594 337545\n", "output": "115131\n"}, {"input": "124075 124692\n", "output": "65961\n"}, {"input": "82747 83560\n", "output": "247331\n"}, {"input": "61024 61453\n", "output": "30782\n"}, {"input": "130815 131327\n", "output": "1\n"}, {"input": "498500 ... | code_stdio |
[
{
"content": "Two boys decided to compete in text typing on the site \"Key races\". During the competition, they have to type a text consisting of s characters. The first participant types one character in v_1 milliseconds and has ping t_1 milliseconds. The second participant types one character in v_2 millisec... | [{"input": "1000 1000 1000 1000 1000\n", "output": "Friendship\n"}, {"input": "1000 1000 1000 1000 1000\n", "output": "Friendship\n"}, {"input": "13 849 819 723 918\n", "output": "Friendship\n"}, {"input": "13 849 819 723 918\n", "output": "Friendship\n"}, {"input": "37 261 207 1 1000\n", "output": "Friendship\n"}, {"i... | code_stdio |
[
{
"content": "In the popular spreadsheets systems (for example, in Excel) the following numeration of columns is used. The first column has number A, the second — number B, etc. till column 26 that is marked by Z. Then there are two-letter numbers: column 27 has number AA, 28 — AB, column 52 is marked by AZ. Af... | [{"input": "10\nR50C12\nR23C47\nY96\nR44C13\nR19C21\nR95C73\nBK12\nR51C74\nAY34\nR63C25\n", "output": "L50\nAU23\nR96C25\nM44\nU19\nBU95\nR12C63\nBV51\nR34C51\nY63\n"}, {"input": "10\nR50C12\nR23C47\nY96\nR44C13\nR19C21\nR95C73\nBK12\nR51C74\nAY34\nR62C25\n", "output": "L50\nAU23\nR96C25\nM44\nU19\nBU95\nR12C63\nBV51\n... | code_stdio |
[
{
"content": "You're given Q queries of the form (L, R). \n\nFor each query you have to find the number of such x that L ≤ x ≤ R and there exist integer numbers a > 0, p > 1 such that x = a^{p}.\n\n\n-----Input-----\n\nThe first line contains the number of queries Q (1 ≤ Q ≤ 10^5).\n\nThe next Q lines contains ... | [{"input": "20\n862 928\n758 964\n541 789\n622 943\n328 900\n14 764\n217 1554\n461 847\n442 468\n544 1157\n518 529\n938 993\n620 851\n690 944\n484 601\n320 910\n98 1355\n816 794\n765 880\n551 1280\n", "output": "1\n4\n5\n6\n14\n32\n30\n9\n0\n12\n1\n1\n5\n4\n4\n15\n35\n0\n2\n13\n"}, {"input": "20\n862 928\n758 964\n541 ... | code_stdio |
[
{
"content": "Having written another programming contest, three Rabbits decided to grab some lunch. The coach gave the team exactly k time units for the lunch break.\n\nThe Rabbits have a list of n restaurants to lunch in: the i-th restaurant is characterized by two integers f_{i} and t_{i}. Value t_{i} shows t... | [{"input": "2 3\n1000000000 1\n2 2\n", "output": "1000000000\n"}, {"input": "2 3\n1000000000 1\n2 2\n", "output": "1000000000\n"}, {"input": "2 4\n1000000000 1\n2 2\n", "output": "1000000000\n"}, {"input": "2 4\n1000000000 1\n2 0\n", "output": "1000000000\n"}, {"input": "2 4\n1000000000 1\n3 0\n", "output": "1000000000... | code_stdio |
[
{
"content": "For a positive integer n, we denote the integer obtained by reversing the decimal notation of n (without leading zeroes) by rev(n). For example, rev(123) = 321 and rev(4000) = 4.\n\nYou are given a positive integer D. How many positive integers N satisfy rev(N) = N + D?\n\nConstraints\n\n* D is an... | [{"input": "864197532", "output": "1920"}, {"input": "1663355059", "output": "0\n"}, {"input": "3070868988", "output": "0\n"}, {"input": "2599007699", "output": "0\n"}, {"input": "4586279406", "output": "0\n"}, {"input": "1877134154", "output": "0\n"}, {"input": "1149390088", "output": "0\n"}, {"input": "6200730", "out... | code_stdio |
[
{
"content": "You are given two integer arrays a and b of length n.\n\nYou can reverse at most one subarray (continuous subsegment) of the array a. \n\nYour task is to reverse such a subarray that the sum ∑_{i=1}^n a_i ⋅ b_i is maximized.\n\nInput\n\nThe first line contains one integer n (1 ≤ n ≤ 5000).\n\nThe ... | [{"input": "100\n8 4 3 5 10 9 5 8 5 7 4 9 4 6 8 8 2 6 3 3 10 7 10 8 6 2 7 4 9 7 7 2 4 5 2 4 9 5 10 1 10 5 10 4 1 3 4 2 6 9 9 9 10 6 2 5 3 1 8 10 4 10 3 4 9 5 5 4 10 4 5 3 7 10 2 7 3 8 6 6 1 0 5 5 4 6 6 4 4 1 5 1 6 6 6 8 8 6 2 6\n0 4 0 5 7 5 4 10 4 10 1 2 1 5 8 2 8 7 1 9 9 5 6 9 4 6 9 9 10 17 4 3 7 4 10 10 9 4 4 7 9 1 1... | code_stdio |
[
{
"content": "After the contest in comparing numbers, Shapur's teacher found out that he is a real genius and that no one could possibly do the calculations faster than him even using a super computer!\n\nSome days before the contest, the teacher took a very simple-looking exam and all his n students took part ... | [{"input": "Iran_\nPersian;\nW_o;n;d;e;r;f;u;l;\n7\nWonderfulPersianIran\nwonderful_PersIAN_IRAN;;_\nWONDERFUL___IRAN__PERSIAN__;;\nIra__Persiann__Wonderful\nWonder;;fulPersian___;I;r;a;n;\n__________IranPersianWonderful__________\nPersianIran_is_Wonderful\n", "output": "ACC\nACC\nACC\nWA\nACC\nACC\nWA\n"}, {"input": "... | code_stdio |
[
{
"content": "You are developing frog-shaped robots, and decided to race them against each other.\n\nFirst, you placed N robots onto a number line. These robots are numbered 1 through N. The current coordinate of robot i is x_i. Here, all x_i are integers, and 0 < x_1 < x_2 < ... < x_N.\n\nYou will repeatedly p... | [{"input": "13\n4 11 8 9 10 12 14 15 16 18 20 21 22", "output": "311014372\n"}, {"input": "13\n4 16 8 9 10 19 14 24 18 18 20 21 22", "output": "790015972\n"}, {"input": "13\n4 11 8 6 10 19 14 24 16 18 20 21 22", "output": "916006393\n"}, {"input": "13\n4 14 4 9 10 12 14 15 16 18 20 65 22", "output": "437004793\n"}, {"i... | code_stdio |
[
{
"content": "Based on the information of the time when study started and the time when study ended, check whether the total time studied in one day is t or more, and if not, create a program to find the shortage time. Time is one unit per hour, and minutes and seconds are not considered. The time is expressed ... | [{"input": "10\n3\n6 11\n12 15\n18 22\n14\n2\n6 14\n13 20\n0", "output": "OK\nOK\n"}, {"input": "10\n3\n6 11\n12 15\n34 22\n14\n2\n6 14\n13 20\n0", "output": "14\nOK\n"}, {"input": "10\n3\n20 11\n2 15\n34 22\n13\n2\n4 14\n13 33\n0", "output": "18\nOK\n"}, {"input": "10\n3\n12 11\n2 15\n34 22\n14\n2\n6 14\n13 20\n0", "o... | code_stdio |
[
{
"content": "Berland has n cities connected by m bidirectional roads. No road connects a city to itself, and each pair of cities is connected by no more than one road. It is not guaranteed that you can get from any city to any other one, using only the existing roads.\n\nThe President of Berland decided to mak... | [{"input": "10 45\n3 5\n2 3\n4 8\n2 5\n6 8\n10 7\n2 1\n3 7\n5 10\n6 1\n9 8\n3 1\n2 10\n6 7\n1 7\n7 9\n6 9\n9 3\n4 2\n2 6\n5 6\n5 8\n3 4\n10 8\n7 8\n4 6\n9 1\n5 5\n7 4\n1 10\n9 2\n2 8\n6 10\n9 8\n1 5\n7 2\n10 3\n3 8\n2 10\n1 1\n10 7\n1 3\n1 8\n10 2\n4 10\n", "output": "0\n"}, {"input": "10 45\n3 5\n2 3\n4 8\n2 5\n6 8\n5... | code_stdio |
[
{
"content": "My friend John likes to go to the cinema. He can choose between system A and system B.\n```\nSystem A : he buys a ticket (15 dollars) every time\nSystem B : he buys a card (500 dollars) and a first ticket for 0.90 times the ticket price, \nthen for each additional ticket he pays 0.90 times the pri... | [{"input": "2500\n20\n0.9", "output": "[135]", "fn_name": "movie"}, {"input": "100\n10\n0.95", "output": "[24]", "fn_name": "movie"}, {"input": "500\n15\n0.9", "output": "[43]", "fn_name": "movie"}, {"input": "250\n20\n0.9", "output": "[21]", "fn_name": "movie"}, {"input": "500\n20\n0.9", "output": "[34]", "fn_name": "... | code_functional |
[
{
"content": "Three swimmers decided to organize a party in the swimming pool! At noon, they started to swim from the left side of the pool.\n\nIt takes the first swimmer exactly $a$ minutes to swim across the entire pool and come back, exactly $b$ minutes for the second swimmer and $c$ minutes for the third. H... | [{"input": "10\n992222955174044630 49635415 8474 173727148\n618311281854681640 657834994 40173216 75996939\n710602478618400425 332897175 71490165 534449640\n768753872531302819 113476460 449 799174641\n633188994852953277 834175592 3132 788542124\n964246686346975322 539872840 295075 782348226\n683685407217150496 18798310... | code_stdio |
[
{
"content": "Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number a and Antisimon receives number b. They also have a heap of n stones. The players take turns to make a move and Simon starts. During a move a pl... | [{"input": "100 100 100\n", "output": "0\n"}, {"input": "100 101 100\n", "output": "0\n"}, {"input": "100 100 10\n", "output": "0\n"}, {"input": "100 110 10\n", "output": "0\n"}, {"input": "34 106 143\n", "output": "1\n"}, {"input": "165 49 110\n", "output": "1\n"}, {"input": "100 1 100\n", "output": "0\n"}, {"input": ... | code_stdio |
[
{
"content": "There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles c... | [{"input": "30\nRLLRLRLLRRRLRRRLLLLLLRRRLRRLRL\n128 610 1680 2436 2896 2994 3008 3358 3392 4020 4298 4582 4712 4728 5136 5900 6088 6232 6282 6858 6934 7186 7224 7256 7614 8802 8872 9170 9384 9794\n", "output": "7\n"}, {"input": "30\nRLLRLRLLRRRLRRRLLLLLLRRRLRRLRL\n128 610 1680 2436 2896 2994 3008 3358 3392 4020 4298 45... | code_stdio |
[
{
"content": "You are given an array $a$ of $n$ integers, and another integer $k$ such that $2k \\le n$.\n\nYou have to perform exactly $k$ operations with this array. In one operation, you have to choose two elements of the array (let them be $a_i$ and $a_j$; they can be equal or different, but their positions... | [{"input": "1\n88 38\n9 143 135 72 74 12 120 27 108 183 18 24 163 122 140 155 166 188 197 14 134 66 188 161 79 100 40 55 161 118 121 18 72 141 136 31 39 187 2 98 16 118 120 196 127 66 135 186 49 16 17 50 107 192 50 23 62 110 83 124 197 127 185 129 131 182 45 147 174 115 89 109 177 7 70 43 75 5 157 93 59 26 176 105 32 8... | code_stdio |
[
{
"content": "Heiankyo is known as a town with a grid of roads.\n\nHokusai, a cat who lives in Heiankyo, has to go from his home to a secret place on the outskirts of town every day for patrol. However, I get tired of following the same path every day, and there is a risk of being followed, so Hokusai wants to ... | [{"input": "4\n0 2\n0\n1 2\n2\n0 0 0 1\n0 0 1 0\n4 0\n4\n1 0 0 0\n3 5 2 3\n4 0 4 0\n0 2 0 4\n15 5\n0", "output": "1\nMiserable Hokusai!\nMiserable Hokusai!\n15504\n"}, {"input": "4\n2 2\n0\n1 2\n2\n0 0 0 1\n0 0 1 0\n4 0\n4\n1 0 0 0\n3 3 2 3\n4 0 4 0\n0 2 0 3\n15 3\n0", "output": "6\nMiserable Hokusai!\nMiserable Hokusa... | code_stdio |
[
{
"content": "Do you know \"sed,\" a tool provided with Unix? Its most popular use is to substitute every occurrence of a string contained in the input string (actually each input line) with another string β. More precisely, it proceeds as follows.\n\n1. Within the input string, every non-overlapping (but poss... | [{"input": "2\na bb\nb aa\nb\nbbbbbbbb\n1\nb aa\nb\naaaaa\n3\nbb aab\nabc aadc\nad dee\nabc\ndeeeeeeeec\n10\na acb\nb bai\nc acf\nd bec\ne bbh\nf fag\ng abe\nh bag\ni aaj\nj bbb\na\nabaceaabe\n0", "output": "-1\n-1\n-1\n-1\n"}, {"input": "2\na bb\nb aa\nb\nbbbbbbbb\n1\nb aa\nb\naaaaa\n3\nbb aab\nabc aadc\nad dee\nbac\n... | code_stdio |
[
{
"content": "Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.\n\nHer problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that remaining number is a representation of some ... | [{"input": "1111111111101111111111111111111111111011111111111111111111111101111011111101111111111101111111111111\n", "output": "yes\n"}, {"input": "0110111111111111111111011111111110110111110111111111111111111111111111111111111110111111111111111111\n", "output": "yes\n"}, {"input": "110011000111101100110110100000111011... | code_stdio |
[
{
"content": "So the Beautiful Regional Contest (BeRC) has come to an end! $n$ students took part in the contest. The final standings are already known: the participant in the $i$-th place solved $p_i$ problems. Since the participants are primarily sorted by the number of solved problems, then $p_1 \\ge p_2 \\g... | [{"input": "5\n12\n5 4 4 3 2 2 1 1 1 1 1 1\n4\n4 3 2 2\n1\n1000100\n20\n20 19 18 17 16 15 14 13 15 11 10 9 8 7 6 5 4 3 2 1\n32\n125 64 63 58 58 58 58 58 37 37 37 37 34 34 28 28 28 28 28 28 24 24 19 17 17 17 17 16 16 16 16 11\n", "output": "1 2 3\n0 0 0\n0 0 0\n1 2 7\n1 2 11\n"}, {"input": "5\n12\n5 4 4 3 2 2 1 1 1 1 1 ... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.