messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "You have an array $a_1, a_2, \\dots, a_n$. \n\nLet's call some subarray $a_l, a_{l + 1}, \\dots , a_r$ of this array a subpermutation if it contains all integers from $1$ to $r-l+1$ exactly once. For example, array $a = [2, 2, 1, 3, 2, 3, 1]$ contains $6$ subarrays which are subpermutations: $[a_2... | [{"input": "99\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99\n", "output": "9... | code_stdio |
[
{
"content": "Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A. Also there are m roads connecting the cities. One can go from city ui to vi (and vise versa) using the i-th road, the length of this road is xi. Finally, there are k train route... | [{"input": "3 3 6\n1 2 499999999\n2 3 500000000\n1 3 948187054\n2 499999999\n2 500000000\n2 499999999\n3 999999999\n3 1000000000\n3 1000000000\n", "output": "6\n"}, {"input": "3 3 6\n1 2 499999999\n2 3 500000000\n1 2 999999999\n2 499999999\n2 500000000\n2 499999999\n3 999999999\n3 1000000000\n3 1000000000\n", "output":... | code_stdio |
[
{
"content": "In some country there are exactly n cities and m bidirectional roads connecting the cities. Cities are numbered with integers from 1 to n. If cities a and b are connected by a road, then in an hour you can go along this road either from city a to city b, or from city b to city a. The road network ... | [{"input": "10 11\n1 3\n2 3\n3 8\n4 5\n4 6\n3 7\n3 8\n4 9\n4 10\n7 9\n8 10\n1 5 3\n6 2 3\n", "output": "-1\n"}, {"input": "10 11\n1 3\n2 3\n3 4\n4 5\n4 6\n3 7\n3 8\n4 9\n4 10\n7 9\n8 10\n1 5 3\n6 2 3\n", "output": "6\n"}, {"input": "9 9\n1 2\n2 3\n2 4\n4 5\n5 7\n5 6\n4 8\n8 9\n9 6\n1 7 4\n3 6 3\n", "output": "-1\n"}, {... | code_stdio |
[
{
"content": "Given a set of $N$ axis-aligned rectangular seals, find the number of overlapped seals on the region which has the maximum number of overlapped seals.\n\nConstraints\n\n* $ 1 \\leq N \\leq 100000 $\n* $ 0 \\leq x1_i < x2_i \\leq 1000 $\n* $ 0 \\leq y1_i < y2_i \\leq 1000 $\n* $ x1_i, y1_i, x2_i, y... | [{"input": "3\n0 0 1 2\n0 0 2 2\n0 0 2 2", "output": "3\n"}, {"input": "3\n0 0 2 4\n0 0 2 2\n0 0 2 2", "output": "3\n"}, {"input": "3\n0 0 1 2\n0 0 2 3\n0 0 2 2", "output": "3\n"}, {"input": "3\n0 1 2 4\n0 0 2 2\n0 0 2 2", "output": "3\n"}, {"input": "3\n0 0 1 2\n0 0 2 6\n0 0 2 2", "output": "3\n"}, {"input": "3\n0 0 0... | code_stdio |
[
{
"content": "It is 2050 and romance has long gone, relationships exist solely for practicality.\n\nMatchMyHusband is a website that matches busy working women with perfect house husbands. You have been employed by MatchMyHusband to write a function that determines who matches!!\n\nThe rules are... a match occu... | [{"input": "[15, 24, 12]\n4", "output": "[\"No match!\"]", "fn_name": "match"}, {"input": "[11, 25, 36]\n1", "output": "[\"No match!\"]", "fn_name": "match"}, {"input": "[17, 31, 21]\n2", "output": "[\"No match!\"]", "fn_name": "match"}, {"input": "[35, 35, 29]\n0", "output": "[\"No match!\"]", "fn_name": "match"}, {"i... | code_functional |
[
{
"content": "Polycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.\n\nLet's assume that a song consists of some number of words (that don't contain WUB). To make the ... | [{"input": "\"WUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUABWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUBWUB\"", "output": "[\"WUAB\"]", "fn_name": "song_decoder"}, {"input": "\"WUBYYRTSMNWUWUBWUBWUBCWUBWUBWUBCWUBWUBWUBFSYUINDWOBVWUBWUBWUBFWU... | code_functional |
[
{
"content": "The final round of Bayan Programming Contest will be held in Tehran, and the participants will be carried around with a yellow bus. The bus has 34 passenger seats: 4 seats in the last row and 3 seats in remaining rows. [Image] \n\nThe event coordinator has a list of k participants who should be p... | [{"input": "001\n", "output": "+------------------------+\n|O.#.#.#.#.#.#.#.#.#.#.|D|)\n|#.#.#.#.#.#.#.#.#.#.#.|.|\n|#.......................|\n|#.#.#.#.#.#.#.#.#.#.#.|.|)\n+------------------------+\n"}, {"input": "011\n", "output": "+------------------------+\n|O.O.O.O.#.#.#.#.#.#.#.|D|)\n|O.O.O.#.#.#.#.#.#.#.#.|.|\n... | code_stdio |
[
{
"content": "Consider an infinite triangle made up of layers. Let's number the layers, starting from one, from the top of the triangle (from top to bottom). The $k$-th layer of the triangle contains $k$ points, numbered from left to right. Each point of an infinite triangle is described by a pair of numbers $(... | [{"input": "4\n3\n1 10 2\n1 3 1\n2\n4 7\n2 2\n2\n1 1000000000\n1 1000000000\n4\n3 18 5 8\n2 4 2 4\n", "output": "3\n2\n999999999\n7\n"}, {"input": "4\n3\n1 10 2\n1 3 1\n2\n3 2\n2 2\n2\n1 1000000000\n1 1000000000\n4\n3 18 5 9\n2 4 2 4\n", "output": "3\n1\n999999999\n7\n"}, {"input": "4\n3\n1 10 2\n1 3 1\n2\n5 7\n2 2\n2\... | code_stdio |
[
{
"content": "Takahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi. Each point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distance from the Takahashi's residence, measured counter-c... | [{"input": "314159265 7\n35438742\n77271666\n139044510\n156626166\n160332356\n331169608\n453863319", "output": "1023255587\n"}, {"input": "314159265 7\n35438742\n77271666\n122238627\n156626166\n160332356\n331169608\n453863319", "output": "1040061470\n"}, {"input": "314159265 7\n21662711\n77271666\n89022761\n156626166\n... | code_stdio |
[
{
"content": "Recently Vasya learned that, given two points with different x coordinates, you can draw through them exactly one parabola with equation of type y = x^2 + bx + c, where b and c are reals. Let's call such a parabola an U-shaped one.\n\nVasya drew several distinct points with integer coordinates on ... | [{"input": "5\n1 0\n1 -1\n0 -1\n-1 0\n-1 -1\n", "output": "1\n"}, {"input": "1\n-751115 -16747294\n", "output": "0\n"}, {"input": "1\n-751115 -11499666\n", "output": "0\n"}, {"input": "1\n-751115 -14990265\n", "output": "0\n"}, {"input": "1\n-867280 -14990265\n", "output": "0\n"}, {"input": "1\n-867280 -20447796\n", "o... | code_stdio |
[
{
"content": "You are given a string $s$. You have to reverse it — that is, the first letter should become equal to the last letter before the reversal, the second letter should become equal to the second-to-last letter before the reversal — and so on. For example, if your goal is to reverse the string \"abddea... | [{"input": "500\npqmpmpqmppqqmmmqppqmpqqmmmppmmqmqmqpqmmpmmpmqpmqpppmppmqqmmmpmqqqppqpmpqpmppppqqqqpmppqppqpqmpmpmqqmmpmqmmpqqmqpmqpmpmqpmpmmqppmqmpqmmmmmmpmmqmmqmmqqmmqqpmppqmppmpppmmmmppmmpqqqqmppqqqqqmpqpmpqmmpqmqpqpmmqqqqpmqqqppmmppmppppppmmpmqpmqmpmqmmpqqmqqmpqppqpmqqmpqqmpmmmpqmqmqmpqmpppqqmqmpmqmmpqmpqqmmqqpqpqm... | code_stdio |
[
{
"content": "# Valid HK Phone Number\n\n## Overview\n\nIn Hong Kong, a valid phone number has the format ```xxxx xxxx``` where ```x``` is a decimal digit (0-9). For example:\n\n## Task\n\nDefine two functions, ```isValidHKPhoneNumber``` and ```hasValidHKPhoneNumber```, that ```return```s whether a given strin... | [{"input": "\" 1234 5678 \"", "output": "[false]", "fn_name": "is_valid_HK_phone_number"}, {"input": "\"sklfjsdklfjsf\"", "output": "[false]", "fn_name": "is_valid_HK_phone_number"}, {"input": "\"3857 4756\"", "output": "[false]", "fn_name": "is_valid_HK_phone_number"}, {"input": "\"abcd efgh\"", "output": "[fal... | code_functional |
[
{
"content": "```if-not:sql\nCreate a function (or write a script in Shell) that takes an integer as an argument and returns \"Even\" for even numbers or \"Odd\" for odd numbers.\n```\n\n```if:sql\n## SQL Notes:\nYou will be given a table, `numbers`, with one column `number`.\n\nReturn a table with a column `is... | [{"input": "1545452", "output": "[\"Even\"]", "fn_name": "even_or_odd"}, {"input": "74156741", "output": "[\"Odd\"]", "fn_name": "even_or_odd"}, {"input": "100000", "output": "[\"Even\"]", "fn_name": "even_or_odd"}, {"input": "-456", "output": "[\"Even\"]", "fn_name": "even_or_odd"}, {"input": "-123", "output": "[\"Odd... | code_functional |
[
{
"content": "Professor GukiZ likes programming contests. He especially likes to rate his students on the contests he prepares. Now, he has decided to prepare a new contest. \n\nIn total, n students will attend, and before the start, every one of them has some positive integer rating. Students are indexed from ... | [{"input": "70\n11 54 37 62 1 46 13 17 38 47 28 29 63 5 61 34 49 66 32 59 3 41 58 28 23 62 41 64 20 5 14 41 10 37 51 32 65 46 61 8 15 19 16 44 31 42 19 46 66 25 26 58 60 5 19 18 69 53 20 40 45 27 24 41 32 23 57 56 62 10\n", "output": "62 18 35 7 70 23 61 57 34 22 43 42 6 66 10 37 21 2 38 13 69 29 14 43 49 7 29 5 51 66 ... | code_stdio |
[
{
"content": "In the final of CODE FESTIVAL in some year, there are N participants. The height and power of Participant i is H_i and P_i, respectively.\n\nRingo is hosting a game of stacking zabuton (cushions).\n\nThe participants will line up in a row in some order, and they will in turn try to add zabuton to ... | [{"input": "10\n1 3\n8 4\n8 3\n10 1\n12 4\n2 3\n4 2\n9 2\n8 3\n0 1", "output": "6\n"}, {"input": "10\n1 3\n0 4\n15 3\n10 1\n8 4\n2 3\n4 2\n9 1\n8 3\n0 1", "output": "7\n"}, {"input": "10\n2 3\n0 4\n15 3\n10 1\n8 4\n2 1\n4 2\n9 1\n8 0\n0 1", "output": "8\n"}, {"input": "10\n2 3\n0 0\n15 3\n10 1\n8 4\n2 1\n4 2\n9 1\n8 0\... | code_stdio |
[
{
"content": "In this Kata, you will be given a multi-dimensional array containing `2 or more` sub-arrays of integers. Your task is to find the maximum product that can be formed by taking any one element from each sub-array.\n\n```\nExamples:\nsolve( [[1, 2],[3, 4]] ) = 8. The max product is given by 2 * 4\nso... | [{"input": "[[-2, -15, -12, -8, -16], [-4, -15, -7], [-10, -5]]", "output": "[-40]", "fn_name": "solve"}, {"input": "[[-11, -6], [-20, -20], [18, -4], [-20, 1]]", "output": "[17600]", "fn_name": "solve"}, {"input": "[[14, 2], [0, -16], [-12, -16]]", "output": "[3584]", "fn_name": "solve"}, {"input": "[[-1, 2, -3, 4], [... | code_functional |
[
{
"content": "Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be consid... | [{"input": "-2 2 -3 -1 461 1\n3 0 4 0 13 -1", "output": "No\n"}, {"input": "-1 2 -3 -1 461 1\n3 0 4 0 13 -1", "output": "No\n"}, {"input": "-1 2 -3 -1 461 1\n3 0 6 0 13 -1", "output": "No\n"}, {"input": "-1 2 -3 -1 461 2\n3 0 6 0 13 -1", "output": "No\n"}, {"input": "0 1 0 -1 197 -1\n10 0 1 1 16 4", "output": "No\n"}, ... | code_stdio |
[
{
"content": "Easy and hard versions are actually different problems, so read statements of both problems completely and carefully.\n\nSummer vacation has started so Alice and Bob want to play and joy, but... Their mom doesn't think so. She says that they have to read some amount of books before all entertainme... | [{"input": "27 5 1\n232 0 1\n72 0 1\n235 0 1\n2 0 1\n158 0 -1\n267 0 0\n242 1 1\n1 0 0\n64 0 0\n139 1 1\n250 0 1\n208 0 1\n127 0 1\n29 0 0\n53 0 1\n100 0 1\n52 0 1\n229 0 0\n1 0 1\n29 0 0\n17 0 1\n74 0 1\n211 0 1\n248 0 1\n15 0 0\n252 0 0\n159 0 1\n", "output": "-1\n"}, {"input": "27 5 1\n232 0 1\n72 0 1\n235 0 1\n2 0 ... | code_stdio |
[
{
"content": "A wildlife study involving ducks is taking place in North America. Researchers are visiting some wetlands in a certain area taking a survey of what they see. The researchers will submit reports that need to be processed by your function.\n\n\n## Input\n\nThe input for your function will be an arra... | [{"input": "[\"King Eider 20\", \"King Eider 2\", \"Lesser Scaup 25\", \"Masked Duck 2\", \"Mottled Duck 10\", \"Muscovy Duck 1\", \"Northern Pintail 3\", \"Northern Shoveler 30\"]", "output": "[[\"KINEID\", 22, \"LESSCA\", 25, \"MASDUC\", 2, \"MOTDUC\", 10, \"MUSDUC\", 1, \"NORPIN\", 3, \"NORSHO\", 30]]", "fn_name": "... | code_functional |
[
{
"content": "Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's \"Black Square\", Polycarp wants to paint minimum possible number of white cells with black so that all black cells form a square.\n\nYou are to deter... | [{"input": "20 10\nWWBWWWBBWW\nWWWWWBWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWBBBWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWWWWWWWWWW\nWBWWWWWBWW\nWBWWBWWWBW\nWWBWBWWWWW\nWWWBWWBBWW\nWWBBWBWBWW\nBBWWWWWBWW\nWWBWWBBBWW\nWWWBWBBWWW\nWWWBBWBWWW\nWWWWWWWWWW\nWWWBWWWWWW\nWWWWWWWWWW\n", "output": "-1\n"}, {"input": "20 10\nWWWWWWWWWW\nWWWWWWWWW... | code_stdio |
[
{
"content": "Amr bought a new video game \"Guess Your Way Out!\". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height h. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node. \n\nLet's index all the le... | [{"input": "50 1125899906842624\n", "output": "2251799813685246\n"}, {"input": "50 1125899906842624\n", "output": "2251799813685246"}, {"input": "50 905353992267944\n", "output": "1871650493613618\n"}, {"input": "50 844424930131968\n", "output": "1407374883553280\n"}, {"input": "50 865276010242491\n", "output": "190973... | code_stdio |
[
{
"content": "You are playing a computer card game called Splay the Sire. Currently you are struggling to defeat the final boss of the game.\n\nThe boss battle consists of $n$ turns. During each turn, you will get several cards. Each card has two parameters: its cost $c_i$ and damage $d_i$. You may play some of... | [{"input": "5\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 100\n1 1\n1 1\n", "output": "211\n"}, {"input": "5\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 100\n1 1\n1 1\n", "output": "211\n"}, {"input": "5\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1\n1 1\n3\n1 1\n1 1... | code_stdio |
[
{
"content": "Given a triangle of consecutive odd numbers:\n\n```\n 1\n 3 5\n 7 9 11\n 13 15 17 19\n21 23 25 27 29\n...\n```\n\nfind the triangle's row knowing its index (the rows are 1-indexed), e.g.:\n\n```\nodd_row(1) == [1]\nodd_row(2) == [3, ... | [{"input": "93", "output": "[[8557, 8559, 8561, 8563, 8565, 8567, 8569, 8571, 8573, 8575, 8577, 8579, 8581, 8583, 8585, 8587, 8589, 8591, 8593, 8595, 8597, 8599, 8601, 8603, 8605, 8607, 8609, 8611, 8613, 8615, 8617, 8619, 8621, 8623, 8625, 8627, 8629, 8631, 8633, 8635, 8637, 8639, 8641, 8643, 8645, 8647, 8649, 8651, 86... | code_functional |
[
{
"content": "Sereja is a coder and he likes to take part in Codesorfes rounds. However, Uzhland doesn't have good internet connection, so Sereja sometimes skips rounds.\n\nCodesorfes has rounds of two types: Div1 (for advanced coders) and Div2 (for beginner coders). Two rounds, Div1 and Div2, can go simultaneo... | [{"input": "1122 54\n2 1031\n1 363 364\n1 14 15\n1 902 903\n1 1052 1053\n2 170\n2 36\n2 194\n1 340 341\n1 1018 1019\n1 670 671\n1 558 559\n2 431\n2 351\n2 201\n1 1104 1105\n2 1056\n2 823\n1 274 275\n2 980\n1 542 543\n1 807 808\n2 157\n2 895\n1 505 506\n2 658\n1 484 485\n1 533 534\n1 384 385\n2 779\n2 888\n1 137 138\n1 ... | code_stdio |
[
{
"content": "This problem is different from the hard version. In this version Ujan makes exactly one exchange. You can hack this problem only if you solve both problems.\n\nAfter struggling and failing many times, Ujan decided to try to clean up his house again. He decided to get his strings in order first.\n\... | [{"input": "10\n11\nartiovnldnp\nartiovsldsp\n2\naa\nzz\n2\naa\nxy\n2\nab\nba\n2\nza\nzz\n3\nabc\nbca\n16\naajjhdsjfdsfkadf\naajjhjsjfdsfkajf\n2\nix\nii\n2\noo\nqo\n2\npp\npa\n", "output": "Yes\nYes\nNo\nNo\nNo\nNo\nYes\nNo\nNo\nNo\n"}, {"input": "10\n11\nartiovnldnp\nartiovsldsp\n2\naa\nzz\n2\naa\nxy\n2\nab\nba\n2\nza... | code_stdio |
[
{
"content": "You are given a permutation $p_1, p_2, \\ldots, p_n$ of integers from $1$ to $n$ and an integer $k$, such that $1 \\leq k \\leq n$. A permutation means that every number from $1$ to $n$ is contained in $p$ exactly once.\n\nLet's consider all partitions of this permutation into $k$ disjoint segment... | [{"input": "100 77\n59 92 18 16 45 82 63 43 50 68 19 13 53 79 48 28 94 49 25 77 54 8 61 66 40 100 99 20 35 14 52 56 22 17 57 36 23 90 4 65 84 42 30 27 3 15 87 32 93 74 46 91 41 9 34 12 11 7 10 86 78 72 81 73 51 55 58 97 39 31 5 24 29 88 95 6 44 37 60 62 83 33 47 21 2 38 26 98 71 75 96 70 76 69 64 89 67 1 80 85\n", "out... | code_stdio |
[
{
"content": "Dima and Seryozha live in an ordinary dormitory room for two. One day Dima had a date with his girl and he asked Seryozha to leave the room. As a compensation, Seryozha made Dima do his homework.\n\nThe teacher gave Seryozha the coordinates of n distinct points on the abscissa axis and asked to co... | [{"input": "50\n384672 661179 -775591 -989608 611120 442691 601796 502406 384323 -315945 -934146 873993 -156910 -94123 -930137 208544 816236 466922 473696 463604 794454 -872433 -149791 -858684 -467655 -555239 623978 -217138 -408658 493342 -733576 -350871 711210 884148 -426172 519986 -356885 527171 661680 977247 141654 ... | code_stdio |
[
{
"content": "Natasha's favourite numbers are $n$ and $1$, and Sasha's favourite numbers are $m$ and $-1$. One day Natasha and Sasha met and wrote down every possible array of length $n+m$ such that some $n$ of its elements are equal to $1$ and another $m$ elements are equal to $-1$. For each such array they co... | [{"input": "2000 2000\n", "output": "674532367\n"}, {"input": "1134 1092\n", "output": "134680101\n"}, {"input": "1087 1050\n", "output": "973930225\n"}, {"input": "1994 1981\n", "output": "596939902\n"}, {"input": "1891 1294\n", "output": "696966158\n"}, {"input": "1132 1727\n", "output": "878164775\n"}, {"input": "10... | code_stdio |
[
{
"content": "You should write a simple function that takes string as input and checks if it is a valid Russian postal code, returning `true` or `false`.\n\nA valid postcode should be 6 digits with no white spaces, letters or other symbols. Empty string should also return false. \n\nPlease also keep in mind tha... | [{"input": "\"\\n245980\"", "output": "[false]", "fn_name": "zipvalidate"}, {"input": "\"245980\\n\"", "output": "[false]", "fn_name": "zipvalidate"}, {"input": "\" 310587 \"", "output": "[false]", "fn_name": "zipvalidate"}, {"input": "\"1111111\"", "output": "[false]", "fn_name": "zipvalidate"}, {"input": "\"245980a\"... | code_functional |
[
{
"content": "Welcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction. \n\nFrom the window in your room, you see the sequence of n hills, where i-th of them has height a_{i}. The Innopolis administration wants to build some houses on the hills. However,... | [{"input": "100\n1777 339 1249 1644 785 810 228 549 1892 464 1067 639 65 1653 981 1858 863 1980 1174 427 1710 345 309 826 31 1898 255 661 1836 443 802 195 177 752 979 1842 1689 399 568 1906 129 1571 1263 696 911 810 1877 1932 1389 1128 112 619 184 434 22 1269 386 324 1635 1440 705 300 455 1635 1069 1660 1174 572 1237 4... | code_stdio |
[
{
"content": "We call a string good, if after merging all the consecutive equal characters, the resulting string is palindrome. For example, \"aabba\" is good, because after the merging step it will become \"aba\".\n\nGiven a string, you have to find two values: the number of good substrings of even length; t... | [{"input": "bbabaaabaaaabaabbababbbabababaabaaaaabbaabbbbbaababaabbbaabaabaaaababaabaabbabaaabaabbbabbaaaaaaabaabababaaabaaabbbabbabbaabaaabaabbbbbabbababbbbbbbababbababbbabbbbbababaaaababaabbabaaabbaaabaabbbbabbaaababbbbbbaaabbaaabbaaabaaaaaababaabababaabaaabaaaabaabbabbabbbbabbaaabaabbaababaaabbbbbaabbbbabbbabaabaaab... | code_stdio |
[
{
"content": "Mad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecule.\n\nA molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom has a valence number — the number of bonds the atom must form with other ato... | [{"input": "1000000 1000000 1000000\n", "output": "500000 500000 500000\n"}, {"input": "1000000 1000000 1000000\n", "output": "500000 500000 500000\n"}, {"input": "688348 726472 442198\n", "output": "486311 240161 202037\n"}, {"input": "602752 645534 784262\n", "output": "232012 413522 370740\n"}, {"input": "602752 645... | code_stdio |
[
{
"content": "A remote island chain contains n islands, labeled 1 through n. Bidirectional bridges connect the islands to form a simple cycle — a bridge connects islands 1 and 2, islands 2 and 3, and so on, and additionally a bridge connects islands n and 1. The center of each island contains an identical pedes... | [{"input": "12\n0 1 2 3 4 5 6 7 8 9 10 11\n1 2 9 8 6 4 5 10 3 7 0 11\n1 2\n2 3\n3 4\n4 5\n4 6\n6 7\n3 8\n8 9\n9 10\n2 11\n11 12\n", "output": "NO\n"}, {"input": "12\n0 1 2 3 4 5 6 7 8 9 10 11\n1 2 9 8 6 4 5 10 3 7 0 11\n1 2\n2 3\n3 4\n4 5\n4 6\n6 7\n3 8\n8 9\n9 10\n8 11\n11 12\n", "output": "NO"}, {"input": "10\n2 7 4 ... | code_stdio |
[
{
"content": "One day Polycarpus got hold of two non-empty strings s and t, consisting of lowercase Latin letters. Polycarpus is quite good with strings, so he immediately wondered, how many different pairs of \"x y\" are there, such that x is a substring of string s, y is a subsequence of string t, and the con... | [{"input": "pfdempfohomnpgbeegikfmflnalbbajpnpgeacaicoehopgnabnklheepnlnflohjegcciflmfjhachnhekckfjgoffhkblncidn\nidlhklpclcghngeggpjdgefccihndpoikojdjnbkdfjgaanoolfmnifnmbpeeghpicehjdiipnlfnjpglidpnnnjfmjfhbcogojkcfflmmfcgajbjbfaikhmjofbnjnaolbcdkelcieeodbfjcfiblhhmeelmpcmmcdhjcnnfklgedjjbaljndjonanlojclboeelkab\n", "... | code_stdio |
[
{
"content": "Michael and Joe are playing a game. The game is played on a grid with $n$ rows and $m$ columns, filled with distinct integers. We denote the square on the $i$-th ($1\\le i\\le n$) row and $j$-th ($1\\le j\\le m$) column by $(i, j)$ and the number there by $a_{ij}$.\n\nMichael starts by saying two ... | [{"input": "18\n1 1\n-37\n1 2\n47 0\n1 2\n-48 -7\n2 1\n37\n-8\n2 1\n-3\n27\n2 2\n46 36\n-33 -9\n2 2\n-20 24\n-6 -33\n2 2\n-50 -45\n50 10\n2 2\n-38 -12\n1 8\n3 3\n42 4 -29\n-27 28 -16\n-35 -13 26\n3 3\n-46 40 -27\n-32 28 -24\n37 13 -13\n3 3\n-38 -17 30\n22 -50 7\n-26 18 -3\n3 3\n-2 26 29\n41 11 28\n-31 -16 1\n3 3\n-25 1... | code_stdio |
[
{
"content": "During a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According to a well-known tradition, the road network was built so that it would be impo... | [{"input": "183\n", "output": "8372\n1 92\n1 93\n1 94\n1 95\n1 96\n1 97\n1 98\n1 99\n1 100\n1 101\n1 102\n1 103\n1 104\n1 105\n1 106\n1 107\n1 108\n1 109\n1 110\n1 111\n1 112\n1 113\n1 114\n1 115\n1 116\n1 117\n1 118\n1 119\n1 120\n1 121\n1 122\n1 123\n1 124\n1 125\n1 126\n1 127\n1 128\n1 129\n1 130\n1 131\n1 132\n1 13... | code_stdio |
[
{
"content": "Thor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notifications generated by those applications (maybe Loki put a curse on it so he can'... | [{"input": "10 85\n2 2\n1 10\n1 1\n2 6\n1 2\n1 4\n1 7\n2 1\n1 1\n3 3\n1 9\n1 6\n1 8\n1 10\n3 8\n2 8\n1 6\n1 3\n1 9\n1 6\n1 3\n1 8\n1 1\n1 6\n1 10\n2 1\n2 10\n1 10\n1 1\n1 10\n1 6\n2 2\n1 8\n1 3\n1 4\n1 9\n1 5\n1 5\n2 2\n2 4\n1 7\n1 1\n2 4\n2 9\n1 1\n1 7\n1 8\n3 14\n1 10\n2 2\n1 3\n1 10\n1 6\n3 32\n2 3\n1 5\n2 10\n2 2\n... | code_stdio |
[
{
"content": "The employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble.\n\nThe point is to trick the spectator's attention. Initially, the spectator stands in front of a line of n plastic cups. Then the magici... | [{"input": "100 50\n11 28\n11 1\n98 58\n38 27\n24 27\n67 37\n90 48\n91 14\n43 29\n3 64\n24 6\n53 19\n97 65\n13 27\n75 53\n37 82\n69 75\n94 99\n1 26\n95 60\n45 27\n100 82\n71 49\n86 99\n74 58\n88 68\n39 63\n38 23\n22 39\n29 58\n62 83\n62 1\n61 58\n2 30\n41 48\n83 90\n1 17\n73 81\n23 53\n71 16\n43 29\n27 78\n54 48\n6 89\... | code_stdio |
[
{
"content": "## Task\n In your favorite game, you must shoot a target with a water-gun to gain points. Each target can be worth a different amount of points. \n \n You are guaranteed to hit every target that you try to hit. You cannot hit consecutive targets though because targets are only visible for one seco... | [{"input": "[26, 54, 36, 35, 63, 58, 31, 80, 59, 61, 34, 54, 62, 73, 89, 7, 98, 91, 78]", "output": "[615]", "fn_name": "target_game"}, {"input": "[73, 80, 40, 86, 14, 96, 10, 56, 61, 84, 82, 36, 85]", "output": "[490]", "fn_name": "target_game"}, {"input": "[36, 42, 93, 29, 0, 33, 15, 84, 14, 24, 81, 11]", "output": "... | code_functional |
[
{
"content": "Polycarp has $x$ of red and $y$ of blue candies. Using them, he wants to make gift sets. Each gift set contains either $a$ red candies and $b$ blue candies, or $a$ blue candies and $b$ red candies. Any candy can belong to at most one gift set.\n\nHelp Polycarp to find the largest number of gift se... | [{"input": "9\n10 12 1 5\n1 2 2 2\n52 109 13 53\n1000000000 1000000000 1 1\n1000100000 1 1 1000000000\n1 1000000000 1000000001 2\n1 2 1 1\n14 11 2 2\n4 1 2 5\n", "output": "3\n0\n2\n1000000000\n1\n0\n1\n5\n0\n"}, {"input": "9\n10 12 1 16\n1 2 2 3\n52 474 13 53\n1000000000 1001000001 2 1\n1000100000 1 1 1100000000\n1 10... | code_stdio |
[
{
"content": "You are given an array consisting of all integers from $[l, r]$ inclusive. For example, if $l = 2$ and $r = 5$, the array would be $[2, 3, 4, 5]$. What's the minimum number of elements you can delete to make the bitwise AND of the array non-zero?\n\nA bitwise AND is a binary operation that takes t... | [{"input": "5\n1 1\n1 8\n7 10\n1 10\n100000 186611\n", "output": "0\n4\n1\n5\n31072\n"}, {"input": "5\n1 2\n1 13\n4 5\n4 10\n110000 200000\n", "output": "1\n6\n0\n3\n21072\n"}, {"input": "5\n1 2\n1 13\n4 5\n1 10\n110000 200000\n", "output": "1\n6\n0\n5\n21072\n"}, {"input": "5\n1 1\n1 8\n7 14\n2 16\n100010 186611\n", "... | code_stdio |
[
{
"content": "Description\n\nSince the cubic equation: ax ^ 3 + bx ^ 2 + cx + d = 0 is given, please check the number of positive real roots and the number of negative real roots, respectively.\n\nThe number of roots shall be counted including the multiple roots.\n\n\n\nInput\n\nThe input consists of multiple t... | [{"input": "2\n1 -1 4 -1\n-1 -10 -2 2", "output": "1 0\n1 2\n"}, {"input": "2\n1 -1 -1 1\n-1 -10 3 1", "output": "2 1\n1 2\n"}, {"input": "2\n1 -2 -1 2\n-2 -10 3 0", "output": "2 1\n1 1\n"}, {"input": "2\n2 -1 -2 0\n-2 -10 1 1", "output": "1 1\n1 2\n"}, {"input": "2\n1 -2 -1 -1\n-5 0 -1 0", "output": "1 0\n0 0\n"}, {"i... | code_stdio |
[
{
"content": "Let's denote the median of a sequence $s$ with odd length as the value in the middle of $s$ if we sort $s$ in non-decreasing order. For example, let $s = [1, 2, 5, 7, 2, 3, 12]$. After sorting, we get sequence $[1, 2, 2, \\underline{3}, 5, 7, 12]$, and the median is equal to $3$.\n\nYou have a seq... | [{"input": "4\n3 5 1\n1\n13 3 3\n1 4 7\n15 5 3\n2 5 10\n17 18 7\n2 3 5 7 5 11 12\n", "output": "NO\nYES\nYES\nNO\n"}, {"input": "4\n3 5 1\n1\n11 3 3\n1 3 7\n15 5 3\n4 5 6\n13 7 7\n2 3 5 7 9 11 12\n", "output": "NO\nYES\nYES\nYES\n"}, {"input": "4\n3 5 1\n1\n7 3 3\n1 3 7\n15 5 3\n4 5 10\n13 11 7\n2 3 5 7 9 11 12\n", "ou... | code_stdio |
[
{
"content": "Alternate Escape\n\nAlice House\n\nAlice and Bob are playing board games. This board game is played using a board with squares in rows H and columns and one frame. In this game, the upper left square of the board is set as the 1st row and 1st column, and the rows are counted downward and the colum... | [{"input": "3 3 2 2\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n3 3 2 1\n 1 0 1\n1 0 1 1\n 1 0 0\n0 0 0 0\n 0 0 1\n1 1 0 1\n 1 0 1\n1 3 1 1\n 1 1 1\n1 0 0 1\n 1 0 1\n2 2 1 1\n 1 0\n1 0 0\n 0 0\n0 0 0\n 0 0\n0 0 0 0", "output": "Yes\nYes\nYes\nNo\n"}, {"input": "3 3 2 3\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\... | code_stdio |
[
{
"content": "You are given a number $n$ and an array $b_1, b_2, \\ldots, b_{n+2}$, obtained according to the following algorithm:\n\nsome array $a_1, a_2, \\ldots, a_n$ was guessed;\n\narray $a$ was written to array $b$, i.e. $b_i = a_i$ ($1 \\le i \\le n$);\n\nThe $(n+1)$-th element of the array $b$ is the su... | [{"input": "1\n12\n400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 505032704\n", "output": "-1\n"}, {"input": "1\n12\n400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 400000000 ... | code_stdio |
[
{
"content": "Osaki\n\nOsaki\n\nEnglish text is not available in this practice contest.\n\nThe Yamanote Line is a circular railway line laid in the 23 wards of Tokyo. The total route distance is 34.5km, and one lap takes about one hour. There are 29 stations in total. The line color is Uguisu color. The peak co... | [{"input": "3\n05:47:15 04:45:90\n12:12:59 12:13:00\n16:30:20 21:18:53\n6\n00:00:00 03:00:00\n01:00:00 03:00:00\n02:00:00 03:00:00\n03:00:00 04:00:00\n03:00:00 05:00:00\n03:00:00 06:00:00\n0", "output": "1\n3\n"}, {"input": "3\n05:47:15 09:54:40\n12:12:59 12:13:00\n16:30:20 21:18:53\n6\n00:00:00 03:00:00\n01:00:00 03:0... | code_stdio |
[
{
"content": "In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:\n\n* If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in hi... | [{"input": "231274241 358979323 84", "output": "393502366 196751183\n"}, {"input": "377378637 358979323 84", "output": "490905292 245452646\n"}, {"input": "7425724 358979323 157", "output": "122135010 244270020\n"}, {"input": "314159265 358979323 84", "output": "448759046 224379523"}, {"input": "7425724 358979323 84", ... | code_stdio |
[
{
"content": "You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character \"0\" and \"1\") a and b. Then you try to turn a into b using two types of opera... | [{"input": "0\n00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "Karen is getting ready for a new school day!\n\n [Image] \n\nIt is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a palindrome.\n\nWhat is the minimum number of minutes she should sleep, such that,... | [{"input": "05:51\n", "output": "250\n"}, {"input": "15:52\n", "output": "250\n"}, {"input": "06:59\n", "output": "182\n"}, {"input": "17:31\n", "output": "151\n"}, {"input": "07:59\n", "output": "122\n"}, {"input": "07:10\n", "output": "171\n"}, {"input": "06:00\n", "output": "241\n"}, {"input": "06:01\n", "output": "... | code_stdio |
[
{
"content": "During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now wonder if the followers of each religion could coexist in p... | [{"input": "2 12\naa\n+ 1 a\n+ 2 a\n+ 3 a\n- 1\n+ 1 a\n- 2\n+ 2 a\n- 3\n+ 3 a\n+ 2 a\n- 1\n- 3\n", "output": "YES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nNO\nYES\n"}, {"input": "2 12\naa\n+ 1 a\n+ 2 a\n+ 3 a\n- 1\n+ 1 a\n- 2\n+ 2 a\n- 3\n+ 3 a\n+ 2 a\n- 1\n- 3\n", "output": "YES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO... | code_stdio |
[
{
"content": "We have a string S of length N consisting of uppercase English letters.\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\n-----Constraints-----\n - 3 \\leq N \\leq 50\n - S consists of uppercase English letters.\n\n-----Input-----\nInput is given fr... | [{"input": "50\nABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCAB\n", "output": "16\n"}, {"input": "50\nBMZBMWEYYDIADTLCOUEGMDBYFWURPWBPUVHIFNUAPWYNDMHTQV\n", "output": "0\n"}, {"input": "50\nKGKBHTYTSZOTWFLEGSJZZSZFWTZFPNSCGUEMWRCZQXYCIVDQNK\n", "output": "0\n"}, {"input": "50\nABBCACBCCACAAACAACACBCACABBAAABBBBCBAAB... | code_stdio |
[
{
"content": "# How many urinals are free?\nIn men's public toilets with urinals, there is this unwritten rule that you leave at least one urinal free\nbetween you and the next person peeing. \nFor example if there are 3 urinals and one person is already peeing in the left one, you will choose the\nurinal on th... | [{"input": "\"1011000001\"", "output": "[-1]", "fn_name": "get_free_urinals"}, {"input": "\"10001\"", "output": "[1]", "fn_name": "get_free_urinals"}, {"input": "\"00000\"", "output": "[3]", "fn_name": "get_free_urinals"}, {"input": "\"01000\"", "output": "[1]", "fn_name": "get_free_urinals"}, {"input": "\"00010\"", "o... | code_functional |
[
{
"content": "Dreamoon is a big fan of the Codeforces contests.\n\nOne day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing!\n\nBased on this, you come up with the following problem:\n\nThere is a person who participated in $n$ Codeforces rounds. His p... | [{"input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n11 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1\n1\n4 57\n80 60 40 20\n", "output": "5\n101\n2\n2\n60\n"}, {"input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n11 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1\n1\n4 57\n61 60 40 20\n", "output": "5\n101\n2\n2\n61\n"}, {"input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n... | code_stdio |
[
{
"content": "Reminder: the median of the array $[a_1, a_2, \\dots, a_{2k+1}]$ of odd number of elements is defined as follows: let $[b_1, b_2, \\dots, b_{2k+1}]$ be the elements of the array in the sorted order. Then median of this array is equal to $b_{k+1}$.\n\nThere are $2n$ students, the $i$-th student has... | [{"input": "3\n1\n1 1\n3\n6 5 4 1 2 3\n5\n13 4 10 22 2 5 10 3 16 16\n", "output": "0\n1\n0\n"}, {"input": "3\n1\n-1 2\n3\n11 1 0 2 2 5\n5\n13 2 7 13 1 5 1 3 23 14\n", "output": "3\n0\n2\n"}, {"input": "3\n1\n1 2\n3\n6 5 4 1 2 1\n5\n13 4 7 14 2 10 14 3 34 16\n", "output": "1\n2\n3\n"}, {"input": "3\n1\n1 -1\n3\n6 5 4 1 ... | code_stdio |
[
{
"content": "Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:\n\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x... | [{"input": "6\nD 3\nH 2\nD 1\nS 3\nC 2\nC 1", "output": "Not stable\nD 1\nC 1\nC 2\nH 2\nD 3\nS 3\n"}, {"input": "6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 0", "output": "Not stable\nC 0\nD 1\nH 2\nD 2\nS 3\nD 3\n"}, {"input": "6\nD 3\nH 0\nD 1\nS 3\nC 2\nC 1", "output": "Not stable\nH 0\nD 1\nC 1\nC 2\nS 3\nD 3\n"}, {"input": "6\... | code_stdio |
[
{
"content": "Given a string, swap the case for each of the letters.\n\ne.g. CodEwArs --> cODeWaRS\n\n### Examples\n\n```\n\"\" -> \"\"\n\"CodeWars\" -> \"cODEwARS\"\n\"abc\" -> \"ABC\"\n\"ABC\" -> \"abc\"\n\"123235\" -> \"123235\"\n```\n\nWrite Python code to solve this ... | [{"input": "\"ThIs iS A l0NG sENTence witH nUMbERs in IT 123 456\"", "output": "[\"tHiS Is a L0ng SentENCE WITh NumBerS IN it 123 456\"]", "fn_name": "swap"}, {"input": "\"H_E_l-l_0 WO|||Rld\"", "output": "[\"h_e_L-L_0 wo|||rLD\"]", "fn_name": "swap"}, {"input": "\"EeEEeeEEEeee\"", "output": "[\"eEeeEEeeeEEE\"]", "fn_n... | code_functional |
[
{
"content": "The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (x_{i}, y_{i}), a maximum brightness c, equal for all stars, and an initial brightness s_{i} (0 ≤ s_{i} ≤ c).\n\nOver time the stars twinkle. At moment 0 the i-th star has brightness s_{i}. Let a... | [{"input": "3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n1 2 2 4 4\n2 2 1 4 7\n1 50 50 51 51\n", "output": "3\n3\n5\n0\n"}, {"input": "3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n1 2 2 4 4\n2 2 1 4 7\n1 60 50 51 51\n", "output": "3\n3\n5\n0\n"}, {"input": "3 4 5\n1 1 2\n2 3 0\n3 3 1\n0 1 1 100 100\n0 2 2 4 4\n2 2 1 4 7\n1... | code_stdio |
[
{
"content": "The Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.\n\nThe playing field is a sequence of n non-negative integers ai numbered from 1 to n. The goal of the game is to make numbers a1, a2, ..., ak (i.e. so... | [{"input": "120\n242 524 420 973 816 432 247 666 134 849 145 366 1119 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 616 304 811 592 916 91 ... | code_stdio |
[
{
"content": "You are now in a bookshop with your friend Alice to buy a book, \"The Winning Strategy for the Programming Koshien Contest,” just released today. As you definitely want to buy it, you are planning to borrow some money from Alice in case the amount you have falls short of the price. If the amount y... | [{"input": "0111 12618 3831", "output": "3720\n"}, {"input": "0101 15626 3831", "output": "3730\n"}, {"input": "0110 15626 3831", "output": "3721\n"}, {"input": "0111 27455 5699", "output": "5588\n"}, {"input": "0111 27455 8862", "output": "8751\n"}, {"input": "0111 27455 1408", "output": "1297\n"}, {"input": "0111 294... | code_stdio |
[
{
"content": "Let S be the sum of divisors of an integer N excluding the number itself. When N = S, N is called a perfect number, when N> S, N is called a defendant number, and when N <S, N is called an abundant number. Create a program that determines whether a given integer is a perfect number, a missing numb... | [{"input": "1\n2\n2\n1\n1\n14\n16\n27\n66290451\n187711252\n124798312\n100001000\n0", "output": "deficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\nabundant number\n"}, {"in... | code_stdio |
[
{
"content": "Recently Max has got himself into popular CCG \"BrainStone\". As \"BrainStone\" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them:\n\nMax owns n creatures, i-th of them can be described with two numbers — its health hp_{i} and its damag... | [{"input": "10 9 0\n620118469 704168608\n528098892 341451371\n15150469 449838744\n960504540 722185004\n271837337 344050133\n940943201 419522619\n85569623 788965215\n161962866 563795701\n943389281 445744350\n610994199 473866838\n", "output": "5253588583\n"}, {"input": "10 9 0\n620118469 704168608\n528098892 341451371\n1... | code_stdio |
[
{
"content": "Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. \n\nAlyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the array. The i-th subarray is described with... | [{"input": "10 10\n1 5\n7 10\n2 10\n2 5\n2 9\n5 9\n3 10\n4 9\n6 9\n2 7\n", "output": "4\n0 1 2 3 0 1 2 3 0 1\n"}, {"input": "10 10\n1 34\n4 4\n4 8\n5 17\n1 9\n3 8\n1 6\n1 9\n1 6\n6 9\n", "output": "1\n0 0 0 0 0 0 0 0 0 0 \n"}, {"input": "10 10\n1 17\n4 8\n4 8\n5 9\n1 9\n3 8\n1 6\n1 9\n1 6\n6 9\n", "output": "4\n0 1 2 3... | code_stdio |
[
{
"content": "You are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through endpoint of some segment, this segment is considered to be nailed too. What is the smalles... | [{"input": "35\n-47 61\n-73 -15\n9 43\n43 -4\n13 -6\n48 -65\n49 -84\n-6 76\n40 6\n-41 11\n-63 -42\n-7 -7\n47 -98\n-17 61\n79 99\n47 -98\n61 31\n85 72\n-50 -17\n-67 45\n14 -50\n-45 61\n-6 -96\n-47 -83\n56 -58\n-24 -15\n14 20\n-95 -82\n47 93\n-4 -7\n70 9\n91 -18\n-71 31\n55 -20\n81 -8\n", "output": "8\n-82 -42 -15 -7 13 ... | code_stdio |
[
{
"content": "In this problem you will write a simple generator of Brainfuck (https://en.wikipedia.org/wiki/Brainfuck) calculators.\n\nYou are given an arithmetic expression consisting of integers from 0 to 255 and addition/subtraction signs between them. Output a Brainfuck program which, when executed, will pr... | [{"input": "0-255-255-255-255+255+255+255+255+255\n", "output": "++++++++++++++++++++++++++++++++++++++++++++++++++.>\n+++++++++++++++++++++++++++++++++++++++++++++++++++++.>\n+++++++++++++++++++++++++++++++++++++++++++++++++++++.>\n"}, {"input": "0-255-255-255-255+255+255+255+255+255\n", "output": "+++++++++++++++++++... | code_stdio |
[
{
"content": "On February, 30th n students came in the Center for Training Olympiad Programmers (CTOP) of the Berland State University. They came one by one, one after another. Each of them went in, and before sitting down at his desk, greeted with those who were present in the room by shaking hands. Each of th... | [{"input": "185\n28 4 4 26 15 21 14 35 22 28 26 24 2 35 21 34 1 23 35 10 6 16 31 0 30 9 18 33 1 22 24 26 22 10 8 27 14 33 16 16 26 22 1 28 32 1 35 12 31 0 21 6 6 5 29 27 1 29 23 22 30 19 37 17 2 2 2 25 3 23 28 0 3 31 34 5 2 23 27 7 26 25 33 27 15 31 31 4 3 21 1 1 23 30 0 13 24 33 26 5 1 17 23 25 36 0 20 0 32 2 2 36 24 ... | code_stdio |
[
{
"content": "An abundant number or excessive number is a number for which the sum of its proper divisors is greater than the number itself. \n\nThe integer 12 is the first abundant number. Its proper divisors are 1, 2, 3, 4 and 6 for a total of 16 (> 12).\n\nDerive function `abundantNumber(num)/abundant_number... | [{"input": "14771", "output": "[false]", "fn_name": "abundant_number"}, {"input": "11410", "output": "[true]", "fn_name": "abundant_number"}, {"input": "11690", "output": "[true]", "fn_name": "abundant_number"}, {"input": "118", "output": "[false]", "fn_name": "abundant_number"}, {"input": "5830", "output": "[true]", "... | code_functional |
[
{
"content": "You've got array A, consisting of n integers and a positive integer k. Array A is indexed by integers from 1 to n.\n\nYou need to permute the array elements so that value $\\sum_{i = 1}^{n - k}|A [ i ] - A [ i + k ]|$ became minimal possible. In particular, it is allowed not to change order of ele... | [{"input": "40 4\n600000080 -199999981 -599999907 -199999935 -199999904 -599999919 200000022 600000032 600000046 -999999980 -199999917 600000027 200000075 -999999949 -599999911 -999999969 600000017 -199999999 -999999923 -599999924 600000091 -599999973 -599999936 600000011 -199999951 600000030 -199999900 -1114561877 200... | code_stdio |
[
{
"content": "One day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be worth more. Vasya weighed all the three pairs of coins on pan balance scales ... | [{"input": "A>B\nC<B\nC;tg&A\n", "output": "Impossible\n"}, {"input": "A<:B\nB>C\nC>A\n", "output": "Impossible\n"}, {"input": "&Agt;B\nC<B\nC;tg&A\n", "output": "Impossible\n"}, {"input": "B:tl&A\nB>C\nC>A\n", "output": "Impossible\n"}, {"input": "&Agt;B\nC<B\nCgt;&A\n", "output": "Impossible... | code_stdio |
[
{
"content": "You have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as $$$p_k = ∑_{1 ≤ i, j ≤ k} a_i mod a_j, where x \\bmod y denotes the remainder when x is divided by y. You have to find and print p_1, p_2, \\ldots, p_n$$$. \n\nInput\n\nThe first line contains n — t... | [{"input": "100\n15 37 41 48 50 55 62 81 82 101 129 139 141 143 146 154 163 169 170 218 220 237 240 247 249 258 266 271 281 286 288 295 308 328 330 332 338 341 349 392 394 396 408 424 436 440 443 451 452 463 465 469 472 483 484 496 506 512 524 542 550 551 570 574 586 604 610 612 618 629 635 637 638 643 652 672 673 678 ... | code_stdio |
[
{
"content": "Very simple, given a number, find its opposite.\n\nExamples:\n```\n1: -1\n14: -14\n-34: 34\n```\n\n~~~if:sql\nYou will be given a table: `opposite`, with a column: `number`. Return a table with a column: `res`.\n~~~\n\nWrite Python code to solve this problem. Define a top-level function named `opp... | [{"input": "-95858588225", "output": "[95858588225]", "fn_name": "opposite"}, {"input": "1425.2222", "output": "[-1425.2222]", "fn_name": "opposite"}, {"input": "-3.1458", "output": "[3.1458]", "fn_name": "opposite"}, {"input": "25.6", "output": "[-25.6]", "fn_name": "opposite"}, {"input": "1", "output": "[-1]", "fn_na... | code_functional |
[
{
"content": "In Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns x and y if and only if there is no railway between them. Travelling to a diff... | [{"input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "-1\n"}, {"input": "10 5\n2 5\n1 2\n1 4\n1 3\n3 2\n", "output": "-1\n"}, {"input": "4 5\n1 3\n2 1\n3 4\n4 2\n2 3\n", "output": "2\n"}, {"input": "5 5\n2 5\n1 2\n1 4\n1 3\n3 2\n", "output": "2\n"}, {"input": "5 5\n4 5\n1 2\n2 4\n1 3\n3 2\n", "output": "3\n"}, {... | code_stdio |
[
{
"content": "Consider writing each of the integers from 1 to N \\times M in a grid with N rows and M columns, without duplicates. Takahashi thinks it is not fun enough, and he will write the numbers under the following conditions:\n\n* The largest among the values in the i-th row (1 \\leq i \\leq N) is A_i.\n*... | [{"input": "14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 73 178 179 167 180 176 169 182 177 175 159 173", "output": "146891838\n"}, {"input": "14 13\n158 167 181 147 178 151 179 182 176 169 180 129 175 168\n181 150 178 179 167 180 176 169 182 177 175 159 173", "output": "343772227"}, {"input": "8... | code_stdio |
[
{
"content": "A continued fraction of height n is a fraction of form $a_{1} + \\frac{1}{a_{2} + \\frac{1}{\\ldots + \\frac{1}{a_{n}}}}$. You are given two rational numbers, one is represented as [Image] and the other one is represented as a finite fraction of height n. Check if they are equal.\n\n\n-----Input--... | [{"input": "633468529243155234 4\n90\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\n", "output": "NO\n"}, {"input": "742143496299253703 2\n90\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nChef is judging a game called \"Broken telephone\". There are total N players taking part in the game. They are all sitting in a line. In the start of the game, first player is given a secret message written on a sheet of paper. Then t... | [{"input": "3\n7\n1 1 2 3 3 3 2\n5\n1 -1 1 1 1\n4\n5 5 5 5", "output": "5\n3\n0\n"}, {"input": "3\n7\n1 1 1 3 3 5 3\n5\n1 3 1 1 -1\n4\n1 5 9 5", "output": "5\n5\n4\n"}, {"input": "3\n7\n1 1 2 3 3 3 2\n5\n1 -1 1 1 1\n4\n1 5 5 5", "output": "5\n3\n2\n"}, {"input": "3\n7\n1 1 2 3 3 3 2\n5\n1 -2 1 1 1\n4\n1 7 5 5", "output... | code_stdio |
[
{
"content": "Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.\n\nNeko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least common multiple of $a+k$ and $b+k$ is the smallest possible. If there are mult... | [{"input": "1000000000 264865600\n", "output": "102701600\n"}, {"input": "1000000000 264865600\n", "output": "102701600"}, {"input": "999999973 800000007\n", "output": "199999823\n"}, {"input": "159488527 938932258\n", "output": "100326050\n"}, {"input": "179237079 691088384\n", "output": "332614226\n"}, {"input": "112... | code_stdio |
[
{
"content": "Mike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string \"coolmike\", in one move he can transform it into the string \"oolmikec\".\n\... | [{"input": "33\nnkgcmrfvxe\nvxenkgcmrf\nrfvxenkgcm\nvxenkgcmrf\nxenkgcmrfv\nenkgcmrfvx\nenkgcmrfvx\nnkgcmrfvxe\nkgcmrfvxen\ncmrfvxenkg\ncmrfvxenkg\nxenkgcmrfv\nrfvxenkgcm\nrfvxenkgcm\nnkgcmrfvxe\nxenkgcmrfv\nrfvxenkgcm\nxenkgcmrfv\nxenkgcmrfv\ngcmrfvxenk\nmrfvxenkgc\nfvxenkgcmr\nvxenkgcmrf\nenkgcmrfvx\ncmrfvxenkg\ncmrf... | code_stdio |
[
{
"content": "Arkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.\n\nArkady goes to the riverside each day and makes a mark on the side of the channel at the height of the water level, but if it coincides with a mark made before, no new mark... | [{"input": "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 23 75 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "output": "2385\n"}, {"input": "100\n0 1... | code_stdio |
[
{
"content": "Today Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will be able to start the test only $T$ seconds after coming. \n\nFortunately, Ad... | [{"input": "20 25\n1 1 1 1 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 2\n", "output": "846324940\n"}, {"input": "20 26\n1 2 1 1 1 2 1 1 2 2 2 1 2 1 2 1 1 2 2 1\n", "output": "509799974\n"}, {"input": "20 27\n1 2 1 2 1 2 1 2 2 1 2 2 1 2 2 2 1 1 2 1\n", "output": "867942829\n"}, {"input": "20 29\n2 2 1 2 2 1 1 1 2 2 2 2 2 2 1 1 2 2 2... | code_stdio |
[
{
"content": "A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.\n\nThe stones are located at integer distance... | [{"input": "100 34\n16 0 10 11 12 13 0 5 4 14 6 15 4 9 1 20 19 14 1 7 14 11 10 20 6 9 12 8 3 19 20 4 17 17 8 11 14 18 5 20 17 0 3 18 14 12 11 12 5 5 11 7 9 17 4 8 4 10 0 0 12 9 15 3 15 14 19 12 6 8 17 19 4 18 19 3 8 3 9 1 6 15 4 16 1 18 13 16 3 5 20 11 10 9 9 17 20 15 12\n", "output": "312\n"}, {"input": "100 34\n16 0 ... | code_stdio |
[
{
"content": "You are given a string S of length n with each character being one of the first m lowercase English letters. \n\nCalculate how many different strings T of length n composed from the first m lowercase English letters exist such that the length of LCS (longest common subsequence) between S and T is ... | [{"input": "100 26\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\n", "output": "237400\n"}, {"input": "100 27\njysrixyptvsesnapfljeqkytlpeepjopspmkviqdqbdkylvfiawhdjjdvqqvcjmmsgfdmpjwahuwhgsyfcgnefzmqlvtvqqfbfsf\n", "output": "246900\n"}, {"input": "100 30\njysrix... | code_stdio |
[
{
"content": "Polycarp has recently got himself a new job. He now earns so much that his old wallet can't even store all the money he has.\n\nBerland bills somehow come in lots of different sizes. However, all of them are shaped as rectangles (possibly squares). All wallets are also produced in form of rectangl... | [{"input": "69\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1... | code_stdio |
[
{
"content": "Chef has a sequence of $N$ integers, $A_1, A_2, ... , A_N$. He likes this sequence if it contains a subsequence of $M$ integers, $B_1, B_2, ... , B_M$ within it.\nA subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of th... | [{"input": "2\n6\n0 2 2 1 11 6\n3\n2 3 0\n6\n22 5 12 19 1 4\n2\n4 15", "output": "No\nNo\n"}, {"input": "2\n6\n1 2 3 4 7 6\n3\n2 3 4\n6\n22 5 6 33 1 4\n2\n4 15", "output": "Yes\nNo\n"}, {"input": "2\n6\n1 2 3 4 5 6\n3\n2 3 4\n6\n22 5 1 33 1 4\n2\n4 15", "output": "Yes\nNo\n"}, {"input": "2\n6\n0 2 3 4 7 6\n3\n2 3 4\n6\... | code_stdio |
[
{
"content": "You are given an undirected weighted connected graph with $n$ vertices and $m$ edges without loops and multiple edges.\n\nThe $i$-th edge is $e_i = (u_i, v_i, w_i)$; the distance between vertices $u_i$ and $v_i$ along the edge $e_i$ is $w_i$ ($1 \\le w_i$). The graph is connected, i. e. for any pa... | [{"input": "8 10\n1 2 1\n2 3 2\n2 4 5\n1 4 2\n6 3 3\n6 1 3\n3 5 2\n3 7 1\n4 8 1\n6 2 4\n", "output": "1\n"}, {"input": "8 10\n1 2 1\n2 3 4\n2 4 5\n1 4 2\n6 3 3\n6 1 3\n3 5 2\n3 7 1\n4 8 1\n6 2 4\n", "output": "0\n"}, {"input": "8 10\n1 2 1\n2 3 2\n2 4 5\n1 4 2\n6 3 3\n6 1 3\n3 5 2\n3 7 1\n4 8 2\n6 2 4\n", "output": "1\... | code_stdio |
[
{
"content": "Problem\n\nGiven $ N $ a pair of non-negative integers $ (a_i, b_i) $ and non-negative integers $ A $, $ B $.\nI want to do as many of the following operations as possible.\n\n\n* $ | a_i --b_i | \\ leq A $ or $ B \\ leq | a_i --b_i | \\ leq Take out and delete the element $ i $ that satisfies 2A ... | [{"input": "10 1 12\n15 70\n36 -1\n18 43\n26 46\n33 20\n58 10\n0 -1\n80 5\n98 32\n23 84", "output": "1\n"}, {"input": "10 1 12\n15 70\n36 -1\n18 43\n26 46\n33 20\n58 10\n0 -1\n80 5\n98 32\n23 30", "output": "1\n"}, {"input": "10 1 12\n15 70\n58 -1\n18 43\n26 46\n33 20\n58 10\n0 -1\n80 5\n98 32\n23 30", "output": "1\n"}... | code_stdio |
[
{
"content": "Taro's summer vacation starts tomorrow, and he has decided to make plans for it now.\n\nThe vacation consists of N days. For each i (1 \\leq i \\leq N), Taro will choose one of the following activities and do it on the i-th day:\n\n* A: Swim in the sea. Gain a_i points of happiness.\n* B: Catch bu... | [{"input": "7\n3 1 176\n0 1 0\n-2 2 0\n2 4 2\n-1 12 1\n0 1 22\n0 1 -4", "output": "215\n"}, {"input": "7\n6 2 176\n1 3 -1\n-2 0 0\n3 9 3\n-1 4 2\n-4 1 4\n0 1 -5", "output": "192\n"}, {"input": "7\n6 2 176\n2 3 -3\n0 0 -1\n6 9 4\n-1 7 2\n-4 1 7\n0 1 -8", "output": "199\n"}, {"input": "7\n9 1 66\n-1 1 2\n-1 2 0\n2 4 1\n0... | code_stdio |
[
{
"content": "Overall there are m actors in Berland. Each actor has a personal identifier — an integer from 1 to m (distinct actors have distinct identifiers). Vasya likes to watch Berland movies with Berland actors, and he has k favorite actors. He watched the movie trailers for the next month and wrote the fo... | [{"input": "50 25\n8 18 41 25 16 39 2 47 49 37 40 23 3 35 15 7 11 28 22 48 10 17 38 46 44\n4\nswyzirxhx\n28\n43 32 14 5 0 17 25 39 0 0 36 0 0 34 27 22 6 13 26 0 0 41 12 16 0 0 0 23\nzyn\n3\n36 12 47\np\n33\n38 0 35 0 6 20 43 9 15 37 17 23 2 0 0 0 0 0 34 0 28 10 33 0 5 4 7 12 36 46 0 0 45\nycaqpkbu\n31\n41 26 16 0 0 36 ... | code_stdio |
[
{
"content": "Gildong has an interesting machine that has an array $a$ with $n$ integers. The machine supports two kinds of operations:\n\nIncrease all elements of a suffix of the array by $1$.\n\nDecrease all elements of a suffix of the array by $1$.\n\nA suffix is a subsegment (contiguous elements) of the arr... | [{"input": "7\n2\n0 1\n3\n-1 0 2\n4\n110 133 106 95\n4\n-3 -5 -2 1\n6\n1 8 3 8 4 1\n5\n5 0 0 0 5\n9\n-367741579 319422997 -415264583 -125558838 -300860379 721691728 294512916 -383235489 425814447\n", "output": "0\n1\n15\n4\n14\n5\n3449059550\n"}, {"input": "7\n2\n0 1\n3\n-1 0 2\n4\n110 133 106 49\n4\n-3 -5 -2 1\n6\n1 8... | code_stdio |
[
{
"content": "Caisa is going to have a party and he needs to buy the ingredients for a big chocolate cake. For that he is going to the biggest supermarket in town.\n\nUnfortunately, he has just s dollars for sugar. But that's not a reason to be sad, because there are n types of sugar in the supermarket, maybe h... | [{"input": "69 9\n39 15\n70 44\n90 89\n84 58\n83 97\n24 28\n90 18\n7 96\n43 86\n99 50\n77 12\n12 34\n100 19\n21 86\n55 30\n99 29\n26 92\n82 67\n78 14\n64 16\n98 12\n31 39\n36 86\n73 36\n87 29\n42 23\n58 15\n35 52\n91 56\n39 6\n88 45\n38 36\n57 12\n79 71\n40 33\n98 42\n34 36\n23 79\n69 68\n50 47\n23 6\n22 90\n96 79\n88 ... | code_stdio |
[
{
"content": "Lunar New Year is approaching, and Bob is planning to go for a famous restaurant — \"Alice's\".\n\nThe restaurant \"Alice's\" serves $n$ kinds of food. The cost for the $i$-th kind is always $c_i$. Initially, the restaurant has enough ingredients for serving exactly $a_i$ dishes of the $i$-th kind... | [{"input": "10 15\n132 138 38 75 14 115 129 68 119 118\n728344 513371 120930 757031 137753 453796 348671 185533 966778 521678\n4 58\n1 8\n8 22\n3 98\n2 111\n6 158\n2 82\n1 170\n1 26\n1 4\n4 76\n10 106\n5 100\n4 116\n7 62\n", "output": "43907798\n5826752\n4081726\n15058400\n56984181\n67179393\n33037922\n108948627\n13563... | code_stdio |
[
{
"content": "Medicine faculty of Berland State University has just finished their admission campaign. As usual, about $80\\%$ of applicants are girls and majority of them are going to live in the university dormitory for the next $4$ (hopefully) years.\n\nThe dormitory consists of $n$ rooms and a single mouse!... | [{"input": "10\n5620 2478 4051 7060 10510 2170 6912 2031 1781 7454\n1 1 1 1 1 1 1 1 1 1\n", "output": "5620\n"}, {"input": "10\n5620 1555 4051 7060 10510 2170 6912 2031 1781 7454\n1 1 1 1 1 1 1 1 1 1\n", "output": "5620\n"}, {"input": "10\n7846 8354 1188 6898 8046 7561 8043 8588 8684 3699\n1 1 2 3 4 5 6 7 8 9\n", "outp... | code_stdio |
[
{
"content": "Count how often sign changes in array.\n\n### result\nnumber from `0` to ... . Empty array returns `0`\n\n### example\n\nWrite Python code to solve this problem. Define a top-level function named `catch_sign_change` that takes the input arguments described above and returns the answer directly -- ... | [{"input": "[1, -2, -7, -4, 4, -2, 0, -3, 3]", "output": "[6]", "fn_name": "catch_sign_change"}, {"input": "[-2, -2, -5, -4, 5, 2, 0, 6, 0]", "output": "[1]", "fn_name": "catch_sign_change"}, {"input": "[-8, 4, -1, 5, -3, -3, -2, -2]", "output": "[4]", "fn_name": "catch_sign_change"}, {"input": "[13, -7, -6, 2, -1, 1, ... | code_functional |
[
{
"content": "You have $n$ gifts and you want to give all of them to children. Of course, you don't want to offend anyone, so all gifts should be equal between each other. The $i$-th gift consists of $a_i$ candies and $b_i$ oranges.\n\nDuring one move, you can choose some gift $1 \\le i \\le n$ and do one of th... | [{"input": "5\n3\n3 5 12\n3 2 3\n5\n1 2 3 4 5\n5 4 1 2 1\n3\n1 1 1\n2 2 2\n6\n1 1000000000 1000000000 1000000000 1000000000 1000000000\n1 1 2 1 1 1\n3\n10 24 8\n7 5 4\n", "output": "12\n16\n0\n4999999995\n19\n"}, {"input": "5\n3\n3 5 12\n3 2 3\n5\n1 2 6 4 5\n5 4 1 2 1\n3\n1 1 1\n2 2 2\n6\n1 1000000000 1000000000 100000... | code_stdio |
[
{
"content": "- Kids drink toddy.\n- Teens drink coke.\n- Young adults drink beer.\n- Adults drink whisky.\n\nMake a function that receive age, and return what they drink.\n\n**Rules:**\n\n- Children under 14 old.\n- Teens under 18 old.\n- Young under 21 old.\n- Adults have 21 or more.\n\n**Examples:**\n\n```py... | [{"input": "22", "output": "[\"drink whisky\"]", "fn_name": "people_with_age_drink"}, {"input": "21", "output": "[\"drink whisky\"]", "fn_name": "people_with_age_drink"}, {"input": "13", "output": "[\"drink toddy\"]", "fn_name": "people_with_age_drink"}, {"input": "0", "output": "[\"drink toddy\"]", "fn_name": "people_... | code_functional |
[
{
"content": "Yae joins a journey plan, in which parties will be held several times during the itinerary. She wants to participate in all of them and will carry several dresses with her. But the number of dresses she can carry with her may be smaller than that of the party opportunities. In that case, she has t... | [{"input": "1 118", "output": "118\n"}, {"input": "1 -11", "output": "-11\n"}, {"input": "1 -12", "output": "-12\n"}, {"input": "1 -21", "output": "-21\n"}, {"input": "10 10", "output": "1\n"}, {"input": "1 26", "output": "26\n"}, {"input": "1 43", "output": "43\n"}, {"input": "1 65", "output": "65\n"}, {"input": "1 18... | code_stdio |
[
{
"content": "Dee is lazy but she's kind and she likes to eat out at all the nice restaurants and gastropubs in town. To make paying quick and easy she uses a simple mental algorithm she's called The Fair %20 Rule. She's gotten so good she can do this in a few seconds and it always impresses her dates but she's... | [{"input": "125\n1", "output": "[14]", "fn_name": "calc_tip"}, {"input": "125\n0", "output": "[12]", "fn_name": "calc_tip"}, {"input": "125\n-1", "output": "[5]", "fn_name": "calc_tip"}, {"input": "144\n1", "output": "[15]", "fn_name": "calc_tip"}, {"input": "144\n0", "output": "[13]", "fn_name": "calc_tip"}, {"input":... | code_functional |
[
{
"content": "For a sequence of integers $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ which is sorted by ascending order, eliminate all equivalent elements.\n\nConstraints\n\n* $1 \\leq n \\leq 100,000$\n* $-1000,000,000 \\leq a_i \\leq 1,000,000,000$\n* $a_0 \\leq a_1 \\leq ... \\leq a_{n-1}$\n\nInput\n\nA sequence ... | [{"input": "4\n-2 -1 1 2", "output": "-2 -1 1 2\n"}, {"input": "4\n-2 -1 0 2", "output": "-2 -1 0 2\n"}, {"input": "4\n-2 -1 0 4", "output": "-2 -1 0 4\n"}, {"input": "4\n-1 0 1 10", "output": "-1 0 1 10\n"}, {"input": "4\n-4 -1 0 1", "output": "-4 -1 0 1\n"}, {"input": "4\n-4 -2 0 1", "output": "-4 -2 0 1\n"}, {"input... | code_stdio |
[
{
"content": "The vowel substrings in the word `codewarriors` are `o,e,a,io`. The longest of these has a length of 2. Given a lowercase string that has alphabetic characters only (both vowels and consonants) and no spaces, return the length of the longest vowel substring.\nVowels are any of `aeiou`. \n\n\n```if... | [{"input": "\"ultrarevolutionariees\"", "output": "[3]", "fn_name": "solve"}, {"input": "\"chrononhotonthuooaos\"", "output": "[5]", "fn_name": "solve"}, {"input": "\"iiihoovaeaaaoougjyaw\"", "output": "[8]", "fn_name": "solve"}, {"input": "\"strengthlessnesses\"", "output": "[1]", "fn_name": "solve"}, {"input": "\"cub... | code_functional |
[
{
"content": "Andrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't written any article, he just decided to take a random one from magazine 26Char.... | [{"input": "31\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\n", "output": "0\n"}, {"input": "31\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml... | code_stdio |
[
{
"content": "Polygons are the most fundamental objects in geometric processing. Complex figures are often represented and handled as polygons with many short sides. If you are interested in the processing of geometric data, you'd better try some programming exercises about basic operations on polygons.\n\nYour... | [{"input": "3\n1 1\n3 4\n6 -1\n\n7\n1 -1\n10 10\n-1 20\n3 33\n0 70\n100 40\n100 -1\n\n0", "output": "1 9.5\n2 5426.0\n"}, {"input": "3\n1 1\n3 4\n6 -1\n\n7\n1 -1\n10 10\n-1 20\n3 33\n0 40\n100 40\n100 0\n\n0", "output": "1 9.5\n2 3921.5\n"}, {"input": "3\n2 1\n2 4\n11 0\n\n7\n2 -2\n0 14\n0 28\n3 33\n-2 41\n100 49\n110 ... | code_stdio |
[
{
"content": "You are given a permutation, p_1, p_2, …, p_n.\n\nImagine that some positions of the permutation contain bombs, such that there exists at least one position without a bomb.\n\nFor some fixed configuration of bombs, consider the following process. Initially, there is an empty set, A.\n\nFor each i ... | [{"input": "10\n7 10 1 8 3 9 2 4 6 5\n7 6 5 3 8 10 4 1 9 2\n", "output": "10 9 8 7 6 6 5 5 5 1 \n"}, {"input": "10\n7 10 1 8 3 9 2 4 6 5\n7 6 5 3 8 10 2 1 9 2\n", "output": "10 9 8 7 6 6 5 5 5 2\n"}, {"input": "10\n7 10 1 8 3 9 2 4 6 5\n7 6 5 3 8 10 4 1 2 2\n", "output": "10 9 8 7 6 6 5 5 5 5\n"}, {"input": "10\n7 10 1... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.