messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "$n$ boys and $m$ girls came to the party. Each boy presented each girl some integer number of sweets (possibly zero). All boys are numbered with integers from $1$ to $n$ and all girls are numbered with integers from $1$ to $m$. For all $1 \\leq i \\leq n$ the minimal number of sweets, which $i$-th... | [{"input": "2 2\n100000000 100000000\n100000000 100000000\n", "output": "400000000\n"}, {"input": "2 2\n000000000 100000000\n100000000 100000000\n", "output": "200000000\n"}, {"input": "2 2\n100000000 100000000\n100000000 100010000\n", "output": "400010000\n"}, {"input": "2 2\n000000000 100000000\n100000000 110000000\n... | code_stdio |
[
{
"content": "# Task\n You are given a binary string (a string consisting of only '1' and '0'). The only operation that can be performed on it is a Flip operation. \n \n It flips any binary character ( '0' to '1' and vice versa) and all characters to the `right` of it.\n\n For example, applying the Flip operati... | [{"input": "\"1010101011111111111111000000000\"", "output": "[10]", "fn_name": "bin_str"}, {"input": "\"00000000111111111\"", "output": "[1]", "fn_name": "bin_str"}, {"input": "\"10101010101010\"", "output": "[14]", "fn_name": "bin_str"}, {"input": "\"000001111100000\"", "output": "[2]", "fn_name": "bin_str"}, {"input"... | code_functional |
[
{
"content": "Daniel is organizing a football tournament. He has come up with the following tournament format: In the first several (possibly zero) stages, while the number of teams is even, they split in pairs and play one game for each pair. At each stage the loser of each pair is eliminated (there are no d... | [{"input": "288230376151711743\n", "output": "144115188344291328\n288230376151711744\n"}, {"input": "288230376151711743\n", "output": "144115188344291328\n288230376151711744\n"}, {"input": "72057594037927935\n", "output": "36028797153181696\n72057594037927936\n"}, {"input": "72057594037927935\n", "output": "36028797153... | code_stdio |
[
{
"content": "## Euler's Method\n\nWe want to calculate the shape of an unknown curve which starts at a given point \nwith a given slope. This curve satisfies an ordinary differential equation (ODE):\n\n```math\n\\frac{dy}{dx} = f(x, y);\\\\\ny(x_0) = y_0\n```\n\nThe starting point `$ A_0 (x_0, y_0) $` is known... | [{"input": "1000", "output": "[0.000251]", "fn_name": "ex_euler"}, {"input": "1200", "output": "[0.000209]", "fn_name": "ex_euler"}, {"input": "1500", "output": "[0.000167]", "fn_name": "ex_euler"}, {"input": "2000", "output": "[0.000125]", "fn_name": "ex_euler"}, {"input": "100", "output": "[0.002524]", "fn_name": "ex... | code_functional |
[
{
"content": "Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions: take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color; take any two (not n... | [{"input": "200\nBBRGRRBBRGGGBGBGBGRRGRGRGRBGRGRRBBGRGBGRRGRRRGGBBRGBGBGBRBBBBBBBGGBRGGRRRGGRGBGBGGBRRRRBRRRBRBBGGBGBRGRGBBBBGGBGBBBGBGRRBRRRGBGGBBBRBGRBRRGGGRRGBBBGBGRRRRRRGGRGRGBBBRGGGBGGGBRBBRRGBGRGRBRRRBRBGRGGBRBB\n", "output": "BGR\n"}, {"input": "200\nRGRGRRRRRGRRGRRRGRGRRRGGRGRRGGGRRGGRRRRRRRRRRRGRRGRRRGRRRGRRRR... | code_stdio |
[
{
"content": "> Kyoto University Programming Contest is a programming contest voluntarily held by some Kyoto University students. This contest is abbreviated as Kyoto University Programming Contest and called KUPC.\n>\n> source: Kyoto University Programming Contest Information\n\nThe problem-preparing committee... | [{"input": "9 3\nAPPLE\nANT\nATCODER\nBLOCK\nBULL\nBOSS\nCAT\nGOD\nEGG", "output": "3\n"}, {"input": "9 3\nAPPLE\nBNT\nATCODER\nBLOCK\nBULL\nBOSS\nCTA\nDOG\nEGG", "output": "2\n"}, {"input": "9 1\nELQPA\nUNB\nATCODER\nLCOLB\nKLUB\nOSSB\nTCA\nGCO\nGGE", "output": "9\n"}, {"input": "9 2\nLAPPE\nBNT\nRCDOETA\nKCOLC\nUBLM\... | code_stdio |
[
{
"content": "A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward. Examples of numerical palindromes are: \n\n* 232\n* 110011\n* 54322345\n\nComplete the function to test if the given number (`num`) **can be rearranged** to form a numerical palindrome... | [{"input": "\"Hello world!\"", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "\"357665\"", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "\"ololo\"", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"input": "-42", "output": "[\"Not valid\"]", "fn_name": "palindrome"}, {"inp... | code_functional |
[
{
"content": "There are n lights aligned in a row. These lights are numbered 1 to n from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on (this light should be switched off at that moment) if there's at least one adjacen... | [{"input": "100 100\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 100\n", "ou... | code_stdio |
[
{
"content": "After several latest reforms many tourists are planning to visit Berland, and Berland people understood that it's an opportunity to earn money and changed their jobs to attract tourists. Petya, for example, left the IT corporation he had been working for and started to sell souvenirs at the market... | [{"input": "70 203\n1 105\n1 105\n1 105\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\n3 300\... | code_stdio |
[
{
"content": "Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n.\n\nVasya thinks that an array's beauty is the greatest common divisor of all its elements. His mom, of course, wants to give him as beautiful an array as possible (with largest possible be... | [{"input": "25 7\n67 18 36 85 64 22 32 66 17 64 66 65 119 36 16 52 19 70 38 51 17 32 85 16 64\n", "output": "16\n"}, {"input": "25 7\n67 18 36 85 64 22 32 66 17 64 66 65 82 36 16 52 19 70 38 51 17 32 85 16 64\n", "output": "16\n"}, {"input": "25 7\n67 18 36 85 64 22 32 66 17 64 66 65 82 36 16 52 19 70 38 51 17 32 85 16... | code_stdio |
[
{
"content": "Malek has recently found a treasure map. While he was looking for a treasure he found a locked door. There was a string s written on the door consisting of characters '(', ')' and '#'. Below there was a manual on how to open the door. After spending a long time Malek managed to decode the manual a... | [{"input": "(#(()(((()((##)(()((((#()(((#((#)(((((((()((((((#)))(((()((((##(#)(()()((((#)(#()#((()))(((##((#(#(#\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n27\n"}, {"input": "(#(()(((()((##)(()((((#()(((#((#)(((((((()((((((#)))(((()((((##(#)(()()((((#)(#()#((())((((##((#(#(#\n", "output": "1\n1\n... | code_stdio |
[
{
"content": "One Martian boy called Zorg wants to present a string of beads to his friend from the Earth — Masha. He knows that Masha likes two colours: blue and red, — and right in the shop where he has come, there is a variety of adornments with beads of these two colours. All the strings of beads have a sma... | [{"input": "50 161245081749292\n", "output": "00101100010110000001101000110001001101000011000011\n"}, {"input": "50 250144743882708\n", "output": "01010101010010111011000010110101001100000110000101\n"}, {"input": "50 264823400156610\n", "output": "01100000110111100000001000001110010101010011111110\n"}, {"input": "50 28... | code_stdio |
[
{
"content": "Along a road running in an east-west direction, there are A shrines and B temples.\nThe i-th shrine from the west is located at a distance of s_i meters from the west end of the road, and the i-th temple from the west is located at a distance of t_i meters from the west end of the road.\nAnswer th... | [{"input": "1 1 3\n1\n10000000000\n2\n9999999999\n5000000000\n", "output": "10000000000\n10000000000\n14999999998\n"}, {"input": "1 1 3\n1\n10000100000\n2\n9999999999\n5000000000", "output": "10000100000\n10000200000\n15000099998\n"}, {"input": "1 1 3\n1\n10000000000\n2\n9999999999\n1416092751", "output": "10000000000\... | code_stdio |
[
{
"content": "In this kata we want to convert a string into an integer. The strings simply represent the numbers in words.\n\nExamples:\n\n* \"one\" => 1\n* \"twenty\" => 20\n* \"two hundred forty-six\" => 246\n* \"seven hundred eighty-three thousand nine hundred and nineteen\" => 783919\n\nAdditional Notes:\n\... | [{"input": "\"eight hundred eighty-eight thousand eight hundred and eighty-eight\"", "output": "[888888]", "fn_name": "parse_int"}, {"input": "\"six hundred sixty-six thousand six hundred sixty-six\"", "output": "[666666]", "fn_name": "parse_int"}, {"input": "\"ninety-nine thousand nine hundred and ninety-nine\"", "out... | code_functional |
[
{
"content": "Example\n\nInput\n\n7\n>>\n\n\nOutput\n\n7\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "7\n>=", "output": "7\n"}, {"input": "7\n=>", "output": "7\n"}, {"input": "7\n?=", "output": "7\n"}, {"input": "7\n=?", "output": "7\n"}, {"input": "7\n<?", "output": "7\n"}, {"input": "7\n?<", "output": "7\n"}, {"input": "7\n><", "output": "7\n"}, {"input": "7\n>?", "output": "7\n"}, {"input": "7\n?>", "out... | code_stdio |
[
{
"content": "One day, at the \"Russian Code Cup\" event it was decided to play football as an out of competition event. All participants was divided into n teams and played several matches, two teams could not play against each other more than once.\n\nThe appointed Judge was the most experienced member — Pave... | [{"input": "248 54\n", "output": "13392\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n1 10\n1 11\n1 12\n1 13\n1 14\n1 15\n1 16\n1 17\n1 18\n1 19\n1 20\n1 21\n1 22\n1 23\n1 24\n1 25\n1 26\n1 27\n1 28\n1 29\n1 30\n1 31\n1 32\n1 33\n1 34\n1 35\n1 36\n1 37\n1 38\n1 39\n1 40\n1 41\n1 42\n1 43\n1 44\n1 45\n1 46\n1 47\n1 48\n1 49\... | code_stdio |
[
{
"content": "Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a d_1 meter long road between his house and the first shop and a d_2 meter long road between his house and the second shop. Also, th... | [{"input": "100000000 100000000 100000000\n", "output": "300000000\n"}, {"input": "100000000 100000000 100000000\n", "output": "300000000\n"}, {"input": "73676138 150324676 35182\n", "output": "147422640\n"}, {"input": "73676138 230952454 17921\n", "output": "147388118\n"}, {"input": "73676138 230952454 18157\n", "outp... | code_stdio |
[
{
"content": "On a random day, Neko found $n$ treasure chests and $m$ keys. The $i$-th chest has an integer $a_i$ written on it and the $j$-th key has an integer $b_j$ on it. Neko knows those chests contain the powerful mysterious green Grapes, thus Neko wants to open as many treasure chests as possible.\n\nThe... | [{"input": "10 10\n522312461 931001459 598654597 488228616 544064902 21923894 329635457 980089248 988262691 654502493\n967529230 543358150 835120075 128123793 809901567 613170206 152157661 479980560 859252956 318029856\n", "output": "10\n"}, {"input": "10 10\n522312461 931001459 598654597 488228616 544064902 21923894 3... | code_stdio |
[
{
"content": "Polycarpus just has been out of luck lately! As soon as he found a job in the \"Binary Cat\" cafe, the club got burgled. All ice-cream was stolen.\n\nOn the burglary night Polycarpus kept a careful record of all club visitors. Each time a visitor entered the club, Polycarpus put down character \"+... | [{"input": "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", "ou... | code_stdio |
[
{
"content": "Mr. Morishita was in trouble ... I had Mr. Anehara write a program, but the program crashed.\n\nMr. Anehara wrote a program that reads the formula in Reverse Polish Notation and outputs the calculation result. According to the crash log, it seems that the cause was that it was divided by 0. This m... | [{"input": "2\na 1 5\na 1 10\n5\n1 a a - -1", "output": "correct\n"}, {"input": "2\na 1 5\nb 1 10\n5\n1 a a - -1", "output": "correct\n"}, {"input": "2\na 1 5\na 0 10\n5\n1 a a - -1", "output": "correct\n"}, {"input": "2\na 1 5\nb 1 10\n5\n1 a b - -1", "output": "correct\n"}, {"input": "2\na 1 8\na 0 10\n5\n1 a a - -1"... | code_stdio |
[
{
"content": "A class of students wrote a multiple-choice test.\n\nThere are $n$ students in the class. The test had $m$ questions, each of them had $5$ possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer for question $i$ worth $a_i$ points. Incorrect an... | [{"input": "10 10\nCBBBBBBBBB\nABBBBEBBBB\nBDBBBBBBBB\nBCBBBBBBBB\nBABBBBBEBB\nEBBBBBBBBB\nBBBCBDCBBB\nBEBBEBBBBB\nBBBBBBBBBB\nBBBDBBBACB\n840 678 490 153 1118 84 256 405 468 856\n", "output": "45122\n"}, {"input": "10 10\nCBBBBBBBBB\nABBBBEBBBB\nBDBBBBBBBB\nBBBBBBBBBB\nBABBBBBEBB\nEBBBBBBBBB\nBBBCBDCBBB\nBEBBEBBBBB\nB... | code_stdio |
[
{
"content": "After a hard quarter in the office you decide to get some rest on a vacation. So you will book a flight for you and your girlfriend and try to leave all the mess behind you.\n\nYou will need a rental car in order for you to get around in your vacation. The manager of the car rental makes you some ... | [{"input": "10", "output": "[350]", "fn_name": "rental_car_cost"}, {"input": "3", "output": "[100]", "fn_name": "rental_car_cost"}, {"input": "4", "output": "[140]", "fn_name": "rental_car_cost"}, {"input": "5", "output": "[180]", "fn_name": "rental_car_cost"}, {"input": "6", "output": "[220]", "fn_name": "rental_car_c... | code_functional |
[
{
"content": "In a far away kingdom lived the King, the Prince, the Shoemaker, the Dressmaker and many other citizens. They lived happily until great trouble came into the Kingdom. The ACMers settled there.\n\nMost damage those strange creatures inflicted upon the kingdom was that they loved high precision numb... | [{"input": "7002108534951820589946967018226114921984364117669853212254634761258884835434844673935047882480101006606512119541798298905598015607366335061012709906661245805358900665571472645463994925687210711492820804158354236327017974683658305043146543214454877759341394.202118562635032813887482826821207122147112325980213... | code_stdio |
[
{
"content": "You are given three multisets of pairs of colored sticks: $R$ pairs of red sticks, the first pair has length $r_1$, the second pair has length $r_2$, $\\dots$, the $R$-th pair has length $r_R$; $G$ pairs of green sticks, the first pair has length $g_1$, the second pair has length $g_2$, $\\dots... | [{"input": "16 26 8\n13 13 0 24 56 74 72 4 172 98 43 4 6 30 82 12\n31 6 76 15 88 37 22 64 44 55 18 67 12 65 10 24 83 23 27 101 198 2 58 59 34 38\n31 61 138 21 67 86 63 6\n", "output": "101183\n"}, {"input": "16 26 8\n13 13 0 24 56 74 88 4 172 98 43 4 6 30 82 12\n31 6 76 15 88 37 22 64 44 55 18 67 12 65 10 24 83 23 27 1... | code_stdio |
[
{
"content": "To celebrate the opening of the Winter Computer School the organizers decided to buy in n liters of cola. However, an unexpected difficulty occurred in the shop: it turned out that cola is sold in bottles 0.5, 1 and 2 liters in volume. At that, there are exactly a bottles 0.5 in volume, b one-lite... | [{"input": "10000 5000 5000 5000\n", "output": "6253751\n"}, {"input": "10000 4534 2345 4231\n", "output": "2069003\n"}, {"input": "8765 2432 2789 4993\n", "output": "1697715\n"}, {"input": "8987 4000 2534 4534\n", "output": "2536267\n"}, {"input": "7777 4444 3333 2222\n", "output": "1236544\n"}, {"input": "2500 5000 5... | code_stdio |
[
{
"content": "Converting a 24-hour time like \"0830\" or \"2030\" to a 12-hour time (like \"8:30 am\" or \"8:30 pm\") sounds easy enough, right? Well, let's see if you can do it!\n\nYou will have to define a function named \"to12hourtime\", and you will be given a four digit time string (in \"hhmm\" format) as... | [{"input": "\"0000\"", "output": "[\"12:00 am\"]", "fn_name": "to12hourtime"}, {"input": "\"0001\"", "output": "[\"12:01 am\"]", "fn_name": "to12hourtime"}, {"input": "\"0002\"", "output": "[\"12:02 am\"]", "fn_name": "to12hourtime"}, {"input": "\"0003\"", "output": "[\"12:03 am\"]", "fn_name": "to12hourtime"}, {"input... | code_functional |
[
{
"content": "One day Polycarp decided to rewatch his absolute favourite episode of well-known TV series \"Tufurama\". He was pretty surprised when he got results only for season 7 episode 3 with his search query of \"Watch Tufurama season 3 episode 7 online full hd free\". This got Polycarp confused — what if ... | [{"input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "45\n"}, {"input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "45\n"}, {"input": "8\n13 2 7 6 ... | code_stdio |
[
{
"content": "You are given a permutation p = (p_1, \\ldots, p_N) of \\\\{ 1, \\ldots, N \\\\}. You can perform the following two kinds of operations repeatedly in any order:\n\n* Pay a cost A. Choose integers l and r (1 \\leq l < r \\leq N), and shift (p_l, \\ldots, p_r) to the left by one. That is, replace p_... | [{"input": "4 1000000000 1000000000\n4 3 2 1", "output": "3000000000"}, {"input": "9 29 154\n2 3 6 7 6 1 2 12 8", "output": "174"}, {"input": "9 67 124\n5 3 4 7 6 1 3 24 8", "output": "402"}, {"input": "9 59 165\n5 4 4 5 8 1 2 12 7", "output": "354"}, {"input": "9 50 87\n16 2 4 7 6 1 3 12 8", "output": "300"}, {"input"... | code_stdio |
[
{
"content": "Hey CodeWarrior,\n\nwe've got a lot to code today!\n\nI hope you know the basic string manipulation methods, because this kata will be all about them.\n\nHere we go...\n\n## Background\n\nWe've got a very long string, containing a bunch of User IDs. This string is a listing, which seperates each u... | [{"input": "\"uid12 ab, uid#, uidMiXeDcHaRs\"", "output": "[[\"12 ab\", \"\", \"mixedchars\"]]", "fn_name": "get_users_ids"}, {"input": "\" uidin name whitespace\"", "output": "[[\"in name whitespace\"]]", "fn_name": "get_users_ids"}, {"input": "\"uid##doublehashtag\"", "output": "[[\"doublehashtag\"]]", "fn_name": "g... | code_functional |
[
{
"content": "Consider an N \\times N matrix. Let us denote by a_{i, j} the entry in the i-th row and j-th column. For a_{i, j} where i=1 or j=1 holds, its value is one of 0, 1 and 2 and given in the input. The remaining entries are defined as follows:\n - a_{i,j} = \\mathrm{mex}(a_{i-1,j}, a_{i,j-1}) (2 \\leq ... | [{"input": "902\n0 1 1 2 0 2 0 2 2 0 2 0 0 1 0 2 1 0 0 1 1 1 2 0 0 2 0 2 1 2 0 2 2 0 1 2 0 0 2 1 1 0 2 0 0 1 2 0 0 1 0 0 1 1 2 0 0 0 2 2 0 2 1 0 0 2 2 0 0 2 2 1 0 2 2 2 2 0 0 0 1 1 2 0 2 0 1 2 1 1 0 0 1 2 2 2 1 0 2 0 1 2 2 1 2 2 0 0 2 0 1 0 1 0 2 0 0 2 0 0 2 1 2 1 0 2 2 1 1 2 0 2 1 0 1 2 0 0 2 0 0 1 1 2 0 1 2 2 0 0 0 1... | code_stdio |
[
{
"content": "# One is the loneliest number\n\n## Task\n\nThe range of vision of a digit is its own value. `1` can see one digit to the left and one digit to the right,` 2` can see two digits, and so on.\n\nThus, the loneliness of a digit `N` is the sum of the digits which it can see.\n\nGiven a non-negative in... | [{"input": "65432165432", "output": "[false]", "fn_name": "loneliest"}, {"input": "8854778", "output": "[false]", "fn_name": "loneliest"}, {"input": "123456", "output": "[true]", "fn_name": "loneliest"}, {"input": "34315", "output": "[true]", "fn_name": "loneliest"}, {"input": "11111", "output": "[true]", "fn_name": "l... | code_functional |
[
{
"content": "You are given a set S of strings consisting of `0` and `1`, and an integer K.\n\nFind the longest string that is a subsequence of K or more different strings in S. If there are multiple strings that satisfy this condition, find the lexicographically smallest such string.\n\nHere, S is given in the... | [{"input": "4 1\n1\n01\n1101\n01011110\n1101110011011100", "output": "0000\n"}, {"input": "4 1\n1\n01\n1111\n00111110\n0101110011111101", "output": "0001\n"}, {"input": "4 4\n-1\n01\n1111\n10111010\n1101100011111101", "output": "000\n"}, {"input": "4 6\n1\n01\n1111\n10111010\n1101110011111101", "output": "100\n"}, {"in... | code_stdio |
[
{
"content": "Extended Euclid Algorithm\n\n\n\n\nGiven positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b.\n\nConstraints\n\n* 1 ≤ a, b ≤ 109\n\nInput\n\n\na b\n\n\nTwo positive integers a and b are given separated by a s... | [{"input": "810 11", "output": "-3 221\n"}, {"input": "277 5", "output": "-2 111\n"}, {"input": "195 10", "output": "1 -19\n"}, {"input": "174 10", "output": "-2 35\n"}, {"input": "41 52", "output": "-19 15\n"}, {"input": "789 7", "output": "3 -338\n"}, {"input": "383 5", "output": "2 -153\n"}, {"input": "41 59", "outp... | code_stdio |
[
{
"content": "T is playing a game with his friend, HL.\n\nThere are n piles of stones, the i-th pile initially has a_i stones. \n\nT and HL will take alternating turns, with T going first. In each turn, a player chooses a non-empty pile and then removes a single stone from it. However, one cannot choose a pile ... | [{"input": "4\n5\n1 3 1 3 4\n1\n4\n1\n5\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"}, {"input": "4\n5\n1 3 1 3 4\n1\n3\n1\n5\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"}, {"input": "4\n5\n1 3 1 3 4\n1\n1\n1\n5\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"}, {"input": "4\n5\n1 3 2 3 1\n1\n1\n1\n5\n2\n3 3\n", "output": "HL\nT\nT\nHL\n"},... | 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 4 8 9 2\n1 8 0 8 7 8 1 8 7 4 0 9 4 2 1 7 3 7 3 7 1 8 7 14 4 10 11 7 3 5 9 7 4 9 6 10 4 5 5 2 5 2 8 4 5 3 1 6 8 8 10 6 7 2 1 6 2 8 3 9 7 4 18 6 7 8 5 2 5 16 3 8 4 11 0 3 5 10 6 1 4 8 14 17 2 2 9 3 7 3 3 3 10 19 3 5 3 1 3 3\n", "output": "1584\n"}, {"input": "100 4 8 9 2\n1 8 0 8 7 8 1 8 7 4 7 9 4 2 1 7 3... | code_stdio |
[
{
"content": "Computer graphics uses polygon models as a way to represent three-dimensional shapes. A polygon model is a model that creates a surface by giving the coordinates of vertices and how to connect those vertices.\n\nA general polygon model can handle any polygon, but this time we will consider a polyg... | [{"input": "6\n3 3 1\n1 2 4\n1 4 3\n-1 3 4\n5 -1 1\n2 3 1", "output": "0\n"}, {"input": "6\n3 3 1\n1 2 4\n1 4 3\n-1 4 4\n10 0 1\n2 3 1", "output": "0\n"}, {"input": "6\n3 1 1\n2 0 4\n0 4 1\n-1 4 4\n9 -1 2\n2 3 1", "output": "0\n"}, {"input": "6\n3 3 1\n1 2 4\n1 4 3\n-1 3 4\n5 0 1\n2 3 1", "output": "0\n"}, {"input": "6... | code_stdio |
[
{
"content": "F: Miko Mi String-\n\nstory\n\nMikko Mikkomi ~! Everyone's idol, Miko Miko Tazawa! Today ~, with Mikoto ~, practice the string algorithm, let's do it ☆\n\nMiko's special ~~ character making ~~ The slogan \"MikoMikomi\" becomes \"MikoMikoMi\" in Roman letters! In other words, if A = “Mi” and B = “K... | [{"input": "iNobiNociN", "output": "mitomerarenaiWA\n"}, {"input": "iNoaiNociN", "output": "mitomerarenaiWA\n"}, {"input": "iNoaiNochN", "output": "mitomerarenaiWA\n"}, {"input": "NhcoNiaoNi", "output": "mitomerarenaiWA\n"}, {"input": "NhcoNiNoai", "output": "mitomerarenaiWA\n"}, {"input": "NhcoNjNoai", "output": "mito... | code_stdio |
[
{
"content": "[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of the input is an integer between 0 and 26, inclusive.\n\n\n-----Output-----\n\nO... | [{"input": "MDJivQRiOIVRcCdkSuUlNbMEOkIVJRMTAnHbkVaOmOblLfignh\n25\n", "output": "MDJIVQRIOIVRCCDKSUULNBMEOKIVJRMTANHBKVAOMOBLLFIGNH\n"}, {"input": "aaaaaaAAAaaaaAaaAaaAaaaaAAaAAAaaAAaaaAAaaaaaAaaAAa\n2\n", "output": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"}, {"input": "aaaaAaaaaaaAAaaAaaAaAaaaAaaaaaAAaaA... | code_stdio |
[
{
"content": "### Introduction and Warm-up (Highly recommended)\n\n### [Playing With Lists/Arrays Series](https://www.codewars.com/collections/playing-with-lists-slash-arrays)\n___\n\n## Task\n\n**_Given_** an *array/list [] of integers* , **_Find the product of the k maximal_** numbers.\n___\n\n### Notes \n\n*... | [{"input": "[13, 12, -27, -302, 25, 37, 133, 155, -1]\n5", "output": "[247895375]", "fn_name": "max_product"}, {"input": "[14, 29, -28, 39, -16, -48]\n4", "output": "[-253344]", "fn_name": "max_product"}, {"input": "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n5", "output": "[0]", "fn_name": "max_product"}, {"input": "[10, 2, 3, 8,... | code_functional |
[
{
"content": "On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.\n\nThere are $n$ bricks lined in a row on the ground. Chouti has got $m$ paint buckets of different colors at hand, so he painted each brick in one of those $m$ colors.\n\nHaving finished p... | [{"input": "1411 1081 1082\n", "output": "238077838\n"}, {"input": "1841 1185 1765\n", "output": "773828348\n"}, {"input": "2000 1234 1800\n", "output": "550745740\n"}, {"input": "2000 2000 1999\n", "output": "694730459\n"}, {"input": "1411 1081 1082\n", "output": "238077838\n"}, {"input": "2000 1234 1800\n", "output":... | code_stdio |
[
{
"content": "On a weekend, Qingshan suggests that she and her friend Daniel go hiking. Unfortunately, they are busy high school students, so they can only go hiking on scratch paper.\n\nA permutation $p$ is written from left to right on the paper. First Qingshan chooses an integer index $x$ ($1\\le x\\le n$) a... | [{"input": "50\n3 10 13 26 31 27 22 20 9 8 33 30 12 21 16 7 17 11 6 24 14 5 19 25 29 36 37 40 41 44 45 46 47 48 49 50 43 42 39 38 35 34 32 28 23 18 15 4 2 1\n", "output": "1\n"}, {"input": "50\n3 10 13 26 31 27 22 20 9 8 33 30 12 21 16 7 17 11 6 24 14 5 19 25 29 36 37 40 41 44 45 46 47 48 49 50 43 42 39 38 35 34 32 28 ... | code_stdio |
[
{
"content": "Two coordinates (a1, a2) and (b1, b2) on a two-dimensional grid of r × c are given. The cost of moving from a cell (e, f) to one of the cells (e + 1, f), (e-1, f), (e, f + 1), (e, f-1) is 1. And. You can also move between (e, c-1) and (e, 0), and between (r-1, f) and (0, f) at a cost of 1. At this... | [{"input": "1226 500 1 0 107 129", "output": "14190866\n"}, {"input": "912 500 2 -1 107 239", "output": "98025026\n"}, {"input": "500 500 -1 0 107 239", "output": "68765037\n"}, {"input": "1174 500 0 0 107 298", "output": "74076242\n"}, {"input": "1226 500 1 0 107 168", "output": "37811899\n"}, {"input": "272 500 -1 0 ... | code_stdio |
[
{
"content": "Adding tip to a restaurant bill in a graceful way can be tricky, thats why you need make a function for it.\n\nThe function will receive the restaurant bill (always a positive number) as an argument. You need to 1) **add at least 15%** in tip, 2) round that number up to an *elegant* value and 3) r... | [{"input": "983212", "output": "[1500000]", "fn_name": "graceful_tipping"}, {"input": "1149", "output": "[1500]", "fn_name": "graceful_tipping"}, {"input": "86", "output": "[100]", "fn_name": "graceful_tipping"}, {"input": "99", "output": "[150]", "fn_name": "graceful_tipping"}, {"input": "12", "output": "[15]", "fn_na... | code_functional |
[
{
"content": "There are 3N participants in AtCoder Group Contest. The strength of the i-th participant is represented by an integer a_i. They will form N teams, each consisting of three participants. No participant may belong to multiple teams.\n\nThe strength of a team is defined as the second largest strength... | [{"input": "10\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1100000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000... | code_stdio |
[
{
"content": "We have a chocolate bar partitioned into H horizontal rows and W vertical columns of squares.\nThe square (i, j) at the i-th row from the top and the j-th column from the left is dark if S_{i,j} is 0, and white if S_{i,j} is 1.\nWe will cut the bar some number of times to divide it into some numbe... | [{"input": "10 1000 10000\n11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111... | code_stdio |
[
{
"content": "Find places where a string P is found within a text T. Print all indices of T where P found. The indices of T start with 0.\n\nConstraints\n\n* 1 ≤ length of T ≤ 1000\n* 1 ≤ length of P ≤ 1000\n* The input consists of alphabetical characters and digits\n\nInput\n\nIn the first line, a text T is gi... | [{"input": "aaaaaa\naa", "output": "0\n1\n2\n3\n4\n"}, {"input": "aaaaab\naa", "output": "0\n1\n2\n3\n"}, {"input": "`aaaaa\naa", "output": "1\n2\n3\n4\n"}, {"input": "aaabaa\naa", "output": "0\n1\n4\n"}, {"input": "aaaaba\naa", "output": "0\n1\n2\n"}, {"input": "abaaaa\naa", "output": "2\n3\n4\n"}, {"input": "aa`aaa\n... | code_stdio |
[
{
"content": "Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her squirrel.\n\nAri draws a regular convex polygon on the floor and numbers it's vertices 1, 2, ..., n in clockwise order. Then starting from the vertex 1 she draws a ray in the direct... | [{"input": "54321\n", "output": "2950553761\n"}, {"input": "54320\n", "output": "2950445124\n"}, {"input": "54319\n", "output": "2950336489\n"}, {"input": "54318\n", "output": "2950227856\n"}, {"input": "54317\n", "output": "2950119225\n"}, {"input": "54316\n", "output": "2950010596\n"}, {"input": "54315\n", "output": ... | code_stdio |
[
{
"content": "You are given a string $s$ consisting of $n$ characters. Each character of $s$ is either 0 or 1.\n\nA substring of $s$ is a contiguous subsequence of its characters.\n\nYou have to choose two substrings of $s$ (possibly intersecting, possibly the same, possibly non-intersecting — just any two subs... | [{"input": "7\n1110010\n", "output": "1111110\n"}, {"input": "5\n11010\n", "output": "11111\n"}, {"input": "5\n10110\n", "output": "11111\n"}, {"input": "5\n10111\n", "output": "11111\n"}, {"input": "5\n11011\n", "output": "11111\n"}, {"input": "5\n11000\n", "output": "11110\n"}, {"input": "5\n10000\n", "output": "1100... | code_stdio |
[
{
"content": "-----Input-----\n\nThe first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points on a plane.\n\nEach of the next n lines contains two real coordinates x_{i} and y_{i} of the $i^{\\text{th}}$ point, specified with exactly 2 fractional digits. All coordinates are between - 1000 a... | [{"input": "14\n99.19 -882.27\n468.09 310.41\n-539.17 665.55\n-355.65 -90.01\n490.35 -966.88\n-102.77 252.81393817771362\n981.63 -976.33\n-362.0898056216629 -435.09\n-43.98678039025838 -37.28\n948.1448687933764 530.68\n49.38 -299.65\n503.33 684.17\n199.7398403612267 328.89\n31.24 65.36\n", "output": "-55.688"}, {"input... | code_stdio |
[
{
"content": "Carl is a beginner magician. He has a blue, b violet and c orange magic spheres. In one move he can transform two spheres of the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at least x blue, y violet and z orange spheres. Can he get them ... | [{"input": "1000000 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\n"}, {"input": "1000000 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\n"}, {"input": "1000100 1000000 1000000\n1000000 1000000 1000000\n", "output": "Yes\n"}, {"input": "1000000 500000 1000000\n500000 1000000 500000\n", "outpu... | code_stdio |
[
{
"content": "Lindsey Buckingham told Stevie Nicks \"Go your own way\". Nicks is now sad and wants to go away as quickly as possible, but she lives in a 2D hexagonal world.\n\nConsider a hexagonal tiling of the plane as on the picture below. [Image] \n\nNicks wishes to go from the cell marked $(0, 0)$ to a cert... | [{"input": "2\n-3 1\n1 3 5 7 9 11\n1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "18\n1000000000000000000\n"}, {"input": "2\n-3 1\n1 3 5 7 9 11\n1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000 1100000000 1000000000\n", "output": "18\n1000000000... | code_stdio |
[
{
"content": "How many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?\n - The n-th and subsequent elements are all equal. That is, if n \\leq i,j, a_i = a_j.\n - For every integer i, the a_i elements immediately following the i-th element are all equal. That is, i... | [{"input": "1000000\n", "output": "267909856\n"}, {"input": "654321\n", "output": "968545283\n"}, {"input": "999745\n", "output": "371558098\n"}, {"input": "999880\n", "output": "488039603\n"}, {"input": "999999\n", "output": "373070711\n"}, {"input": "380467\n", "output": "858853071\n"}, {"input": "407774\n", "output"... | code_stdio |
[
{
"content": "Tanya wants to go on a journey across the cities of Berland. There are $n$ cities situated along the main railroad line of Berland, and these cities are numbered from $1$ to $n$. \n\nTanya plans her journey as follows. First of all, she will choose some city $c_1$ to start her journey. She will vi... | [{"input": "15\n10 10 10 1 2 3 4 5 6 7 8 9 10 11 12\n", "output": "78\n"}, {"input": "10\n10 60 12 13 14 15 16 66 18 130\n", "output": "130\n"}, {"input": "9\n18 11 24 7 18 10 1 20 17\n", "output": "24\n"}, {"input": "9\n4 10 21 7 23 9 15 11 12\n", "output": "44\n"}, {"input": "10\n12 14 1 2 3 4 5 6 7 8\n", "output": "... | code_stdio |
[
{
"content": "There are n wizards. They are numbered from 1 to n, and the i-th wizard has the magical power ri (1 ≤ i ≤ n). Now they are confronting a powerful wizard, whose enemy's magical power is S. n Wizards are good at fighting together, especially two people. When two wizards cooperate, the magical power ... | [{"input": "3 11\n0\n3\n10\n0 0", "output": "1\n"}, {"input": "3 11\n0\n3\n18\n0 0", "output": "2\n"}, {"input": "3 11\n0\n3\n20\n0 0", "output": "2\n"}, {"input": "3 13\n1\n3\n10\n0 0", "output": "0\n"}, {"input": "3 11\n0\n3\n17\n0 0", "output": "2\n"}, {"input": "3 22\n1\n3\n10\n0 0", "output": "0\n"}, {"input": "3 ... | code_stdio |
[
{
"content": "Sereja has a bracket sequence s_1, s_2, ..., s_{n}, or, in other words, a string s of length n, consisting of characters \"(\" and \")\".\n\nSereja needs to answer m queries, each of them is described by two integers l_{i}, r_{i} (1 ≤ l_{i} ≤ r_{i} ≤ n). The answer to the i-th query is the length ... | [{"input": "(()((((()(())((((((((()((((((()((((\n71\n15 29\n17 18\n5 26\n7 10\n16 31\n26 35\n2 30\n16 24\n2 24\n7 12\n15 18\n12 13\n25 30\n1 30\n12 13\n16 20\n6 35\n20 28\n18 23\n9 31\n12 35\n14 17\n8 16\n3 10\n12 33\n7 19\n2 33\n7 17\n21 27\n10 30\n29 32\n9 28\n18 32\n28 31\n31 33\n4 26\n15 27\n10 17\n8 14\n11 28\n8 2... | code_stdio |
[
{
"content": "You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n - Choose two among A, B and C, then increase both by 1.\n - Choose one among A, B and C, then increase... | [{"input": "27 39 17\n", "output": "17\n"}, {"input": "19 43 41\n", "output": "13\n"}, {"input": "39 49 21\n", "output": "19\n"}, {"input": "26 37 19\n", "output": "16\n"}, {"input": "13 48 20\n", "output": "33\n"}, {"input": "31 41 5\n", "output": "23\n"}, {"input": "50 50 50\n", "output": "0\n"}, {"input": "50 50 49\... | code_stdio |
[
{
"content": "For building the encrypted string:Take every 2nd char from the string, then the other chars, that are not every 2nd char, and concat them as new String.\nDo this n times!\n\nExamples:\n```\n\"This is a test!\", 1 -> \"hsi etTi sats!\"\n\"This is a test!\", 2 -> \"hsi etTi sats!\" -> \"s eT ashi ... | [{"input": "\"hskt svr neetn!Ti aai eyitrsig\"\n1", "output": "[\"This kata is very interesting!\"]", "fn_name": "decrypt"}, {"input": "\"This is a test!\"\n-1", "output": "[\"This is a test!\"]", "fn_name": "decrypt"}, {"input": "\"This is a test!\"\n0", "output": "[\"This is a test!\"]", "fn_name": "decrypt"}, {"inpu... | code_functional |
[
{
"content": "Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water.\n\nThe only dry land there is an archipelago of n narrow islands located in a row. For more comfort let's represent them as non-intersecting segme... | [{"input": "3 2\n1000000000000000 1000000000000000\n3000000000000000 4000000000000000\n6000000000000000 7000000000000000\n2000000000000000 4000000000000000\n", "output": "Yes\n1 2 \n"}, {"input": "3 2\n1000000000000000 1000000000000000\n3000000000000000 4000000000000000\n6000000000000000 7000000000000000\n2000000000000... | code_stdio |
[
{
"content": "There are $n$ pillars aligned in a row and numbered from $1$ to $n$.\n\nInitially each pillar contains exactly one disk. The $i$-th pillar contains a disk having radius $a_i$.\n\nYou can move these disks from one pillar to another. You can take a disk from pillar $i$ and place it on top of pillar ... | [{"input": "100\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 100\n", "output... | code_stdio |
[
{
"content": "Let's call a set of positive integers a_1, a_2, ..., a_k quadratic if the product of the factorials of its elements is a square of an integer, i. e. ∏_{i=1}^{k} a_i! = m^2, for some integer m.\n\nYou are given a positive integer n.\n\nYour task is to find a quadratic subset of a set 1, 2, ..., n o... | [{"input": "17027\n", "output": "17024\n1 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 ... | code_stdio |
[
{
"content": "# Task\n In ChessLand there is a small but proud chess bishop with a recurring dream. \n \n In the dream the bishop finds itself on an `n × m` chessboard with mirrors along each edge, and it is not a bishop but a ray of light. This ray of light moves only along diagonals (the bishop can't imagine ... | [{"input": "[17, 19]\n[16, 18]\n[1, 1]\n239239239", "output": "[[10, 2]]", "fn_name": "chess_bishop_dream"}, {"input": "[1, 1]\n[0, 0]\n[1, -1]\n1000000000", "output": "[[0, 0]]", "fn_name": "chess_bishop_dream"}, {"input": "[17, 19]\n[14, 8]\n[1, -1]\n239239", "output": "[[4, 17]]", "fn_name": "chess_bishop_dream"}, {... | code_functional |
[
{
"content": "Devu is a dumb guy, his learning curve is very slow. You are supposed to teach him n subjects, the i^{th} subject has c_{i} chapters. When you teach him, you are supposed to teach all the chapters of a subject continuously.\n\nLet us say that his initial per chapter learning power of a subject is ... | [{"input": "20 8\n6 16 0 2 6 10 1 4 1 5 3 5 9 2 2 8 0 2 3 3\n", "output": "109\n"}, {"input": "20 8\n6 16 0 2 6 13 1 4 6 5 3 5 9 2 2 8 0 2 3 3\n", "output": "121\n"}, {"input": "20 8\n6 16 0 2 6 10 1 4 6 5 3 5 9 2 2 8 0 2 3 3\n", "output": "118\n"}, {"input": "20 10\n6 6 1 2 6 4 5 3 6 5 4 5 6 5 4 6 6 2 3 3\n", "output"... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \nSpring is interesting season of year. Chef is thinking about different things, but last time he thinks about interesting game - \"Strange Matrix\". \nChef has a matrix that consists of n rows, each contains m elements. Initially, the ele... | [{"input": "18 6 1\n0 3\n-1 7 \n3 2 \n4 1\n6 3\n7 2", "output": "5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n5\n"}, {"input": "15 2 6\n3 0\n3 4 \n5 0 \n4 1\n4 0\n7 3", "output": "1\n1\n1\n0\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"input": "13 4 6\n3 2\n3 4 \n5 0 \n4 0\n4 0\n7 3", "output": "3\n3\n4\n-1\n3\n3\n3\n... | code_stdio |
[
{
"content": "Little Dima has two sequences of points with integer coordinates: sequence (a_1, 1), (a_2, 2), ..., (a_{n}, n) and sequence (b_1, 1), (b_2, 2), ..., (b_{n}, n).\n\nNow Dima wants to count the number of distinct sequences of points of length 2·n that can be assembled from these sequences, such that... | [{"input": "100\n2 2 10 3 5 6 4 7 9 8 2 7 5 5 1 7 5 9 2 2 10 3 6 10 9 9 10 7 3 9 7 8 8 3 9 3 9 3 3 6 3 7 9 9 7 10 9 1 1 3 6 2 9 5 9 9 6 2 6 5 6 8 2 10 1 1 6 8 8 4 5 2 6 8 8 5 9 2 3 3 7 7 10 5 4 2 10 6 7 6 5 4 10 6 10 3 9 9 1 5\n3 5 6 4 2 3 2 9 3 8 3 1 10 7 4 3 6 9 3 5 9 5 3 10 4 7 9 7 4 3 3 6 9 8 1 1 10 9 1 6 8 8 8 2 1... | code_stdio |
[
{
"content": "Theofanis really likes sequences of positive integers, thus his teacher (Yeltsa Kcir) gave him a problem about a sequence that consists of only special numbers.\n\nLet's call a positive number special if it can be written as a sum of different non-negative powers of $n$. For example, for $n = 4$ n... | [{"input": "3\n6 10\n4 20\n105 276\n", "output": "222\n272\n456030397\n"}, {"input": "3\n6 11\n2 17\n105 194\n", "output": "223\n17\n136912005\n"}, {"input": "3\n6 7\n4 20\n105 276\n", "output": "43\n272\n456030397\n"}, {"input": "3\n6 7\n2 12\n105 276\n", "output": "43\n12\n456030397\n"}, {"input": "3\n2 26\n0 10\n105... | code_stdio |
[
{
"content": "You have decided to give an allowance to your child depending on the outcome of the game that he will play now.\nThe game is played as follows:\n - There are three \"integer panels\", each with a digit between 1 and 9 (inclusive) printed on it, and one \"operator panel\" with a + printed on it.\n ... | [{"input": "-1 12 1", "output": "120\n"}, {"input": "9 9 9\n", "output": "108\n"}, {"input": "9 2 8\n", "output": "100\n"}, {"input": "7 9 7\n", "output": "104\n"}, {"input": "9 9 4\n", "output": "103\n"}, {"input": "1 11 1", "output": "112\n"}, {"input": "1 21 1", "output": "212\n"}, {"input": "2 21 1", "output": "213... | code_stdio |
[
{
"content": "Levian works as an accountant in a large company. Levian knows how much the company has earned in each of the n consecutive months — in the i-th month the company had income equal to a_i (positive income means profit, negative income means loss, zero income means no change). Because of the general... | [{"input": "17\n-542470641 -617247806 1649173051 111521800 509758067 -860452587 447120886 234437807 707835273\n5\n", "output": "17\n"}, {"input": "17\n-542470641 -617247806 998970243 699622219 732907519 -860452587 447120886 203125491 707835273\n5\n", "output": "17\n"}, {"input": "17\n-542470641 -617247806 998970243 699... | code_stdio |
[
{
"content": "A breakthrough among computer games, \"Civilization XIII\", is striking in its scale and elaborate details. Let's take a closer look at one of them.\n\nThe playing area in the game is split into congruent cells that are regular hexagons. The side of each cell is equal to 1. Each unit occupies exac... | [{"input": "1000000\n", "output": "1209197264797\n"}, {"input": "1010000\n", "output": "1233502153639\n"}, {"input": "1010100\n", "output": "1233746427001\n"}, {"input": "999811\n", "output": "1208740231393\n"}, {"input": "999998\n", "output": "1209192430093\n"}, {"input": "999999\n", "output": "1209194850235\n"}, {"in... | code_stdio |
[
{
"content": "You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.\n\nYou want to find a subset of items to put such that:\n\n* The total value of the items is as large as possible.\n* The items have combined weight at most $W$, that is capac... | [{"input": "5 1000001100\n3 1 1000000010\n7 10 1000100110\n7 3 1000000000\n11 27 1100000000\n2 7 1000000000", "output": "3000002572\n"}, {"input": "5 1000000000\n1 1 1000000000\n7 11 1000100000\n4 4 1000000000\n6 20 1000000100\n3 5 1000000000", "output": "1000000000\n"}, {"input": "5 1000000000\n4 1 1000000000\n11 2 10... | code_stdio |
[
{
"content": "One day a highly important task was commissioned to Vasya — writing a program in a night. The program consists of n lines of code. Vasya is already exhausted, so he works like that: first he writes v lines of code, drinks a cup of tea, then he writes as much as <image> lines, drinks another cup of... | [{"input": "1001000000 10\n", "output": "900900002\n"}, {"input": "1000010000 10\n", "output": "900009002\n"}, {"input": "1000100000 10\n", "output": "900090002\n"}, {"input": "1000101000 10\n", "output": "900090903\n"}, {"input": "1000000000 10\n", "output": "900000001"}, {"input": "177583558 15\n", "output": "1657446... | code_stdio |
[
{
"content": "It's bonus time in the big city! The fatcats are rubbing their paws in anticipation... but who is going to make the most money? \n\nBuild a function that takes in two arguments (salary, bonus). Salary will be an integer, and bonus a boolean.\n\nIf bonus is true, the salary should be multiplied by ... | [{"input": "10000\ntrue", "output": "[\"$100000\"]", "fn_name": "bonus_time"}, {"input": "25000\ntrue", "output": "[\"$250000\"]", "fn_name": "bonus_time"}, {"input": "10000\nfalse", "output": "[\"$10000\"]", "fn_name": "bonus_time"}, {"input": "60000\nfalse", "output": "[\"$60000\"]", "fn_name": "bonus_time"}, {"input... | code_functional |
[
{
"content": "Polycarp lives on the coordinate axis $Ox$ and travels from the point $x=a$ to $x=b$. It moves uniformly rectilinearly at a speed of one unit of distance per minute.\n\nOn the axis $Ox$ at the point $x=c$ the base station of the mobile operator is placed. It is known that the radius of its coverag... | [{"input": "9\n4 17 0 0\n0 6 0 0\n5 0 7 3\n52 2 20 010\n-11 20 -40 0\n2 2 0 0\n-2 0 1 4\n-1 4 0 2\n0 4 -10 0\n", "output": "13\n6\n4\n30\n31\n0\n0\n2\n4\n"}, {"input": "9\n1 10 7 1\n3 3 1 0\n8 2 10 4\n10 2 10 100\n-10 20 -17 2\n-3 1 0 0\n-3 1 2 0\n2 3 0 3\n-1 1 -2 2\n", "output": "7\n0\n4\n0\n30\n4\n4\n0\n1\n"}, {"inpu... | code_stdio |
[
{
"content": "You are given a string $s$ consisting of lowercase Latin letters and $q$ queries for this string.\n\nRecall that the substring $s[l; r]$ of the string $s$ is the string $s_l s_{l + 1} \\dots s_r$. For example, the substrings of \"codeforces\" are \"code\", \"force\", \"f\", \"for\", but not \"code... | [{"input": "dfcbbcfeeedbaea\n15\n1 1 e\n1 4 b\n2 10 15\n1 7 b\n1 12 c\n2 6 8\n2 1 6\n1 7 c\n1 2 f\n1 10 a\n2 7 11\n1 10 a\n1 14 b\n1 1 f\n2 1 11\n", "output": "4\n3\n4\n4\n6\n"}, {"input": "decbbcfeeedbafa\n15\n1 1 e\n1 4 b\n2 10 15\n1 7 b\n1 12 c\n2 6 8\n2 1 6\n1 7 c\n1 2 f\n1 10 a\n2 7 11\n1 10 a\n1 14 b\n1 1 f\n2 1 ... | code_stdio |
[
{
"content": "Taro Aizu's company has a boss who hates being indivisible. When Taro goes out to eat with his boss, he pays by splitting the bill, but when the payment amount is not divisible by the number of participants, his boss always pays for it.\n\nOne day, Taro became the secretary of the dinner party. Mr... | [{"input": "4 15000\n520\n41\n129\n500\n3 1047\n6\n20\n25\n3 359208\n5\n14\n17\n0 0", "output": "14983\n1039\n359207\n"}, {"input": "4 15000\n305\n260\n136\n500\n3 400\n10\n23\n30\n3 599838\n5\n1\n12\n0 0", "output": "14983\n397\n599831\n"}, {"input": "4 29657\n305\n131\n129\n500\n3 400\n10\n20\n30\n3 337371\n1\n14\n12... | code_stdio |
[
{
"content": "A great king of a certain country suddenly decided to visit the land of a friendly country. The country is famous for trains, and the king visits various stations.\n\nThere are 52 train stations, each with a single uppercase or lowercase alphabetic name (no overlapping names). The line of this tra... | [{"input": "2\n1 2\nadd\n3\n12 4 0\nDDDA\n5\n3 1 3 5 2\ndcdkIlkP\n0", "output": "Zbc\nrzDo\nabafGijM\n"}, {"input": "2\n1 2\nadd\n3\n12 4 1\nDDDA\n5\n3 1 3 5 2\ndcdkIlkP\n0", "output": "Zbc\nrzCo\nabafGijM\n"}, {"input": "2\n1 0\nadd\n3\n12 4 1\nDDDA\n5\n3 1 3 5 2\ndcdkIlkP\n0", "output": "Zdc\nrzCo\nabafGijM\n"}, {"in... | code_stdio |
[
{
"content": "Professor GukiZ makes a new robot. The robot are in the point with coordinates (x_1, y_1) and should go to the point (x_2, y_2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So the robot can move in one of the 8 directions. Find t... | [{"input": "-1000000000 -1000000000\n1000000000 -1000000000\n", "output": "2000000000\n"}, {"input": "-1000000000 -1000000000\n1000000000 -1000000000\n", "output": "2000000000\n"}, {"input": "-1000000000 -1000000000\n1000000000 1000000000\n", "output": "2000000000\n"}, {"input": "-1000000000 1000000000\n1000000000 -100... | code_stdio |
[
{
"content": "Given an array of numbers, return a string made up of four parts:\n\na) a four character 'word', made up of the characters derived from the first two and last two numbers in the array. order should be as read left to right (first, second, second last, last),\n\nb) the same as above, post sorting t... | [{"input": "[82, 98, 72, 71, 71, 72, 62, 67, 68, 115, 117, 112, 122, 121, 93]", "output": "[\"Rby]->Cyz-zyC>->Cyz\"]", "fn_name": "sort_transform"}, {"input": "[111, 121, 122, 124, 125, 126, 117, 118, 119, 121, 122, 73]", "output": "[\"oyzI-Io}~-~}oI-Io}~\"]", "fn_name": "sort_transform"}, {"input": "[78, 117, 110, 99,... | code_functional |
[
{
"content": "Given is a string S of length N.\nFind the maximum length of a non-empty string that occurs twice or more in S as contiguous substrings without overlapping.\nMore formally, find the maximum positive integer len such that there exist integers l_1 and l_2 ( 1 \\leq l_1, l_2 \\leq N - len + 1 ) that ... | [{"input": "5000\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb... | code_stdio |
[
{
"content": "One day Nikita found the string containing letters \"a\" and \"b\" only. \n\nNikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters \"a\" and the 2-nd contains only lett... | [{"input": "bbabbbbbaaba\n", "output": "10\n"}, {"input": "bbbbbbabaaaa\n", "output": "11\n"}, {"input": "bbabbbbabbbb\n", "output": "10\n"}, {"input": "baabbbbbaaba\n", "output": "10\n"}, {"input": "baabaaaabbaa\n", "output": "10\n"}, {"input": "baabbbbbabba\n", "output": "10\n"}, {"input": "bbabbbabbbbb\n", "output":... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nThe following is an easy game that the setter of this problem played when he was 8:\n\nA boatman, a wolf, a sheep, and a cabbage are on the bank of a river. They have a small boat that is capable of carrying the boatman and at most one... | [{"input": "2\n3 0\n1 2\n1 4\n1 -1\n1 14\n2 3\n2 4", "output": "YES\nYES\n"}, {"input": "2\n3 0\n1 2\n1 4\n1 -1\n1 14\n2 1\n2 4", "output": "YES\nYES\n"}, {"input": "2\n3 0\n1 2\n1 4\n1 -1\n1 14\n2 1\n2 2", "output": "YES\nYES\n"}, {"input": "2\n3 0\n1 2\n1 4\n1 -1\n1 14\n0 1\n2 2", "output": "YES\nYES\n"}, {"input": "... | code_stdio |
[
{
"content": "Hacker Zhorik wants to decipher two secret messages he intercepted yesterday. Yeah message is a sequence of encrypted blocks, each of them consists of several bytes of information.\n\nZhorik knows that each of the messages is an archive containing one or more files. Zhorik knows how each of these ... | [{"input": "50 50\n5733 740 547 3647 5382 5109 6842 7102 5879 1502 3574 1628 7905 4357 8569 9564 8268 3542 2487 8532 425 7713 2585 925 6458 2697 2844 69 324 9030 495 4428 6724 3524 3304 4874 1303 2098 1136 1048 2464 7316 274 9586 534 2450 2368 8060 7795 70692\n1918 4122 6806 4914 6517 6278 9842 9480 6609 4221 9373 1728... | code_stdio |
[
{
"content": "There is a fence in front of Polycarpus's home. The fence consists of n planks of the same width which go one after another from left to right. The height of the i-th plank is h_{i} meters, distinct planks can have distinct heights. [Image] Fence for n = 7 and h = [1, 2, 6, 1, 1, 7, 1] \n\nPolycar... | [{"input": "10 5\n1 2 3 1 2 2 3 1 4 5\n", "output": "1\n"}, {"input": "10 2\n3 1 4 1 4 6 2 1 4 6\n", "output": "7\n"}, {"input": "10 4\n1 1 1 4 4 4 4 4 4 3\n", "output": "1\n"}, {"input": "10 2\n3 1 4 1 4 6 2 1 4 6\n", "output": "7\n"}, {"input": "10 4\n1 1 1 4 4 4 4 4 4 3\n", "output": "1\n"}, {"input": "10 5\n1 2 3 1... | code_stdio |
[
{
"content": "You are given an array a_1, a_2, ..., a_n and an array b_1, b_2, ..., b_n.\n\nFor one operation you can sort in non-decreasing order any subarray a[l ... r] of the array a.\n\nFor example, if a = [4, 2, 2, 1, 3, 1] and you choose subbarray a[2 ... 5], then the array turns into [4, 1, 2, 2, 3, 1]. ... | [{"input": "10\n3\n1 2 1\n3 1 2\n1\n1\n1\n19\n15 10 19 11 6 16 1 5 1 14 8 6 8 7 1 8 1 5 13\n7 13 18 9 16 11 1 2 17 13 1 16 13 19 4 3 9 7 3\n15\n9 3 2 15 8 4 10 10 2 12 1 9 5 7 8\n4 5 6 15 1 7 9 10 3 2 1 2 14 6 12\n16\n5 6 11 12 8 2 3 12 2 4 6 15 2 8 15 7\n15 5 3 12 14 2 9 11 14 13 13 14 14 1 7 7\n17\n8 10 4 6 11 7 14 4... | code_stdio |
[
{
"content": "Two players play a game.\n\nInitially there are $n$ integers $a_1, a_2, \\ldots, a_n$ written on the board. Each turn a player selects one number and erases it from the board. This continues until there is only one number left on the board, i. e. $n - 1$ turns are made. The first player makes the ... | [{"input": "10\n58 26 65 15 13 81 111 48 22 50\n", "output": "48\n"}, {"input": "10\n58 26 65 15 13 81 111 48 22 55\n", "output": "48\n"}, {"input": "10\n58 26 77 15 53 81 68 48 22 65\n", "output": "53\n"}, {"input": "10\n58 26 77 15 13 81 68 48 22 65\n", "output": "48\n"}, {"input": "10\n58 26 77 15 13 81 68 48 22 50\... | code_stdio |
[
{
"content": "First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. \n\nFor ex... | [{"input": "prntaxhysjfcfmrjngdsitlguahtpnwgbaxptubgpwcfxqehrulbxfcjssgocqncscduvyvarvwxzvmjoatnqfsvsilubexmwugedtzavyamqjqtkxzuslielibjnvkpvyrbndehsqcaqzcrmomqqwskwcypgqoawxdutnxmeivnfpzwvxiyscbfnloqjhjacsfnkfmbhgzpujrqdbaemjsqphokkiplblbflvadcyykcqrdohfasstobwrobslaofbasylwiizrpozvhtwyxtzl\n", "output": "505\nac\nacs... | code_stdio |
[
{
"content": "An ant moves on the real line with constant speed of $1$ unit per second. It starts at $0$ and always moves to the right (so its position increases by $1$ each second).\n\nThere are $n$ portals, the $i$-th of which is located at position $x_i$ and teleports to position $y_i < x_i$. Each portal can... | [{"input": "5\n370534603 100000000 1\n600000000 400000000 0\n800000000 300000000 0\n900000000 700000000 1\n1000000000 500000000 0\n", "output": "444580501\n"}, {"input": "5\n370534603 100000000 1\n600000000 400000000 0\n800000000 300000000 0\n900000000 700000000 1\n1010000000 500000000 0\n", "output": "454580501\n"}, {... | code_stdio |
[
{
"content": "The full exploration sister is a very talented woman. Your sister can easily count the number of routes in a grid pattern if it is in the thousands. You and your exploration sister are now in a room lined with hexagonal tiles. The older sister seems to be very excited about the hexagon she sees fo... | [{"input": "-2 1 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n2 5", "output": "-1\n"}, {"input": "-2 1 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n3 5", "output": "-1\n"}, {"input": "-2 0 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n3 5", "output": "-1\n"}, {"input": "-4 0 -1 2\n6\n-1 2\n2 0\n1 -2\n1 1\n-1 -1\n-1 -1\n... | code_stdio |
[
{
"content": "Ksusha is a beginner coder. Today she starts studying arrays. She has array a_1, a_2, ..., a_{n}, consisting of n positive integers.\n\nHer university teacher gave her a task. Find such number in the array, that all array elements are divisible by it. Help her and find the number!\n\n\n-----Input-... | [{"input": "5\n506904227 214303304 136194869 838256937 183952885\n", "output": "-1\n"}, {"input": "5\n506904227 214303304 136194869 838256937 183952885\n", "output": "-1\n"}, {"input": "5\n238711016 214303304 136194869 838256937 183952885\n", "output": "-1\n"}, {"input": "5\n310947607 214303304 136194869 838256937 1839... | code_stdio |
[
{
"content": "Someone gave Alyona an array containing n positive integers a_1, a_2, ..., a_{n}. In one operation, Alyona can choose any element of the array and decrease it, i.e. replace with any positive integer that is smaller than the current one. Alyona can repeat this operation as many times as she wants. ... | [{"input": "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 10000000\n", "output": "9\n"}, {"input": "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 10000000\n", "output": "9\n"}, {"input": "10\n1 1 1 10000000 10000000 10000000 10000000 10000000 10000000 11000000\n", "output": "9\n"}, {... | code_stdio |
[
{
"content": "A positive integer number n is written on a blackboard. It consists of not more than 105 digits. You have to transform it into a beautiful number by erasing some of the digits, and you want to erase as few digits as possible.\n\nThe number is called beautiful if it consists of at least one digit, ... | [{"input": "53684795681792590016697187295561462737810600000146840941336328677293748561247888801665863139922929397968535048060292988802347668853531069156825523164438370977880256909710958836918627008217572514193873141535365258436916984535972865113877338591947508645026570682995314540038481160747606741045307222213966802022... | code_stdio |
[
{
"content": "Chuck has lost count of how many asses he has kicked...\n\nChuck stopped counting at 100,000 because he prefers to kick things in the face instead of counting. That's just who he is.\n\nTo stop having to count like a mere mortal chuck developed his own special code using the hairs on his beard. Yo... | [{"input": "\" 76 B2L4D0A8C6.-T%8.90. lkd\"", "output": "[true]", "fn_name": "body_count"}, {"input": "\"ffr65A C8K4D9U7V5.-Y%8.00.\"", "output": "[true]", "fn_name": "body_count"}, {"input": "\"PP P6A6T5F5S3.-Z%1.11.hgr\"", "output": "[true]", "fn_name": "body_count"}, {"input": "\"d G8H1E2O9N3.-W%8.56. f\""... | code_functional |
[
{
"content": "An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \\leq i \\leq N) is given to you as a character c_i; R stands for red and W stands for white.\nYou can do the following two kinds of operations any number of times in any order:\n - Choos... | [{"input": "8\nWRWWRWRR\n", "output": "3\n"}, {"input": "8\nRRWRWWRW", "output": "1\n"}, {"input": "8\nRRWWWRRW", "output": "2\n"}, {"input": "8\nWRWWWRRR", "output": "3\n"}, {"input": "8\nWWWWRRRR", "output": "4\n"}, {"input": "8\nRRWRVWRW", "output": "1\n"}, {"input": "8\nWRRWWWRR", "output": "2\n"}, {"input": "8\nRR... | code_stdio |
[
{
"content": "While playing with geometric figures Alex has accidentally invented a concept of a $n$-th order rhombus in a cell grid.\n\nA $1$-st order rhombus is just a square $1 \\times 1$ (i.e just a cell).\n\nA $n$-th order rhombus for all $n \\geq 2$ one obtains from a $n-1$-th order rhombus adding all cel... | [{"input": "100\n", "output": "19801\n"}, {"input": "100\n", "output": "19801"}, {"input": "72\n", "output": "10225\n"}, {"input": "94\n", "output": "17485\n"}, {"input": "77\n", "output": "11705\n"}, {"input": "86\n", "output": "14621\n"}, {"input": "98\n", "output": "19013\n"}, {"input": "75\n", "output": "11101\n"},... | code_stdio |
[
{
"content": "Tired of boring office work, Denis decided to open a fast food restaurant.\n\nOn the first day he made $a$ portions of dumplings, $b$ portions of cranberry juice and $c$ pancakes with condensed milk.\n\nThe peculiarity of Denis's restaurant is the procedure of ordering food. For each visitor Denis... | [{"input": "7\n1 4 1\n0 0 0\n16 0 1\n2 2 2\n2 3 2\n3 2 2\n0 4 4\n", "output": "3\n0\n2\n4\n5\n5\n3\n"}, {"input": "7\n0 1 1\n0 0 0\n11 1 1\n2 2 4\n3 3 3\n4 2 3\n0 6 1\n", "output": "2\n0\n3\n5\n6\n5\n2\n"}, {"input": "7\n1 2 1\n0 0 0\n16 1 1\n2 2 2\n2 3 2\n3 2 2\n0 4 4\n", "output": "3\n0\n3\n4\n5\n5\n3\n"}, {"input": ... | code_stdio |
[
{
"content": "M-kun is a brilliant air traffic controller.\n\nOn the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude.\nEach of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i ... | [{"input": "8\n285 224 U\n130 175 R\n111 322 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L", "output": "SAFE\n"}, {"input": "8\n285 224 U\n130 175 R\n101 322 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L", "output": "SAFE\n"}, {"input": "8\n285 224 U\n130 175 R\n111 198 D\n121 188 L\n201 116 U\n11... | code_stdio |
[
{
"content": "Shell Sort\n\nShell Sort is a generalization of Insertion Sort to arrange a list of $n$ elements $A$.\n\n\n1 insertionSort(A, n, g)\n2 for i = g to n-1\n3 v = A[i]\n4 j = i - g\n5 while j >= 0 && A[j] > v\n6 A[j+g] = A[j]\n7 j = j - g\n8 ... | [{"input": "5\n10\n1\n5\n9\n1", "output": "2\n4 1\n1\n1\n1\n5\n9\n10\n"}, {"input": "5\n10\n1\n5\n7\n1", "output": "2\n4 1\n1\n1\n1\n5\n7\n10\n"}, {"input": "5\n6\n1\n10\n7\n1", "output": "2\n4 1\n4\n1\n1\n6\n7\n10\n"}, {"input": "5\n6\n1\n1\n13\n2", "output": "2\n4 1\n4\n1\n1\n2\n6\n13\n"}, {"input": "5\n6\n1\n2\n13\n... | code_stdio |
[
{
"content": "Monocarp is playing a computer game. In this game, his character fights different monsters.\n\nA fight between a character and a monster goes as follows. Suppose the character initially has health $h_C$ and attack $d_C$; the monster initially has health $h_M$ and attack $d_M$. The fight consists o... | [{"input": "2\n1000000000000000 1\n1000000000000000 200000\n0 1 1\n1000000000000000 200000\n1000000000000000 1\n0 1 1\n", "output": "NO\nYES\n"}, {"input": "2\n1000000000000000 1\n1000000000000000 1000000000\n1000 10000 10000000000\n9 2\n16 4\n0 10 10\n", "output": "NO\nNO\n"}, {"input": "4\n25 4\n9 20\n1 1 10\n25 4\n1... | code_stdio |
[
{
"content": "The Queen of England has n trees growing in a row in her garden. At that, the i-th (1 ≤ i ≤ n) tree from the left has height a_{i} meters. Today the Queen decided to update the scenery of her garden. She wants the trees' heights to meet the condition: for all i (1 ≤ i < n), a_{i} + 1 - a_{i} = k, ... | [{"input": "50 5\n232 6 17 6 21 26 27 36 41 88 665 56 61 66 71 76 602 86 28 712 101 106 111 116 121 126 131 136 141 146 151 156 161 166 755 176 181 186 191 196 201 206 211 216 5 226 172 236 241 246\n", "output": "12\n- 1 231\n- 3 6\n+ 4 10\n+ 7 4\n- 10 42\n- 11 614\n- 17 521\n+ 19 63\n- 20 616\n- 35 584\n+ 45 216\n+ 47... | code_stdio |
[
{
"content": "VK news recommendation system daily selects interesting publications of one of n disjoint categories for each user. Each publication belongs to exactly one category. For each category i batch algorithm selects a_i publications.\n\nThe latest A/B test suggests that users are reading recommended pub... | [{"input": "40\n19 20 8 13 13 17 1 14 15 20 14 17 2 9 9 10 19 16 6 12 9 7 20 5 12 6 4 4 12 5 4 11 8 1 2 8 11 19 18 4\n52258 5648 46847 9200 101064 79328 64407 54479 1788 60107 8234 64215 15419 84411 50307 78075 92548 17867 43456 7970 1390 99373 97297 90662 82950 678 79356 51351 2794 82477 16508 19254 81295 9711 72350 1... | code_stdio |
[
{
"content": "You are given three strings A, B and C. Check whether they form a word chain.\nMore formally, determine whether both of the following are true:\n - The last character in A and the initial character in B are the same.\n - The last character in B and the initial character in C are the same.\nIf both... | [{"input": "aaaaaaaaab aaaaaaaaaa aaaaaaaaab\n", "output": "NO\n"}, {"input": "baaaa`aaaa aabaaaaaaa aaaaa`aaab", "output": "YES\n"}, {"input": "baaaaaaa`` `aaaaaabaa aaaaa`aaab", "output": "YES\n"}, {"input": "baaabaaa`` `aaaaaabaa aaaaa`aaab", "output": "YES\n"}, {"input": "baaabaaa`` `aaabaabaa aaaaa`aaab", "output"... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.