messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 2
values |
|---|---|---|
[
{
"content": "Arseniy is already grown-up and independent. His mother decided to leave him alone for m days and left on a vacation. She have prepared a lot of food, left some money and washed all Arseniy's clothes. \n\nTen minutes before her leave she realized that it would be also useful to prepare instruction... | [{"input": "10 3 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n8 10\n", "output": "0\n"}, {"input": "10 1 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n8 10\n", "output": "0\n"}, {"input": "10 1 3\n2 2 1 3 1 2 1 2 2 2\n10 8\n9 6\n3 10\n", "output": "0\n"}, {"input": "10 1 3\n2 2 1 3 1 2 1 2 3 2\n10 8\n9 6\n3 10\n", "output": "0\n"}, {"input... | code_stdio |
[
{
"content": "Read problems statements in English, Mandarin Chinese and Russian as well. \n\nSherlock is stuck. There is a N X N grid in which some cells are empty (denoted by ‘.’), while some cells have rocks in them (denoted by ‘#’). Sherlock is on the South of the grid. He has to watch what is happening on t... | [{"input": "2\n3\n#..\n..#\n#..\n3\n#.#\n#.#\n#.#", "output": "3\n0\n"}, {"input": "2\n3\n#..\n\"..\n#..\n3\n#.#\n#.#\n#.#", "output": "6\n0\n"}, {"input": "2\n3\n$..\n..#\n#..\n3\n\"-#\n#.#\n\"#.", "output": "3\n1\n"}, {"input": "2\n3\n$..\n.#.\n#..\n3\n\"-#\n#.#\n\".#", "output": "4\n0\n"}, {"input": "2\n3\n#..\n..#\... | code_stdio |
[
{
"content": "There are $n$ students in a school class, the rating of the $i$-th student on Codehorses is $a_i$. You have to form a team consisting of $k$ students ($1 \\le k \\le n$) such that the ratings of all team members are distinct.\n\nIf it is impossible to form a suitable team, print \"NO\" (without qu... | [{"input": "100 100\n63 100 75 32 53 24 73 98 76 15 70 48 8 81 88 58 95 78 27 92 14 16 72 43 46 39 66 38 64 42 59 9 22 51 4 6 10 94 28 99 68 80 35 50 45 20 47 7 30 26 49 91 77 19 96 57 65 1 11 13 31 12 82 87 93 34 62 3 21 79 56 41 89 18 44 23 74 86 2 33 69 36 61 67 25 83 5 84 90 37 40 29 97 60 52 55 54 71 17 85\n", "ou... | code_stdio |
[
{
"content": "You are given an integer n. You have to apply m operations to it.\n\nIn a single operation, you must replace every digit d of the number with the decimal representation of integer d + 1. For example, 1912 becomes 21023 after applying the operation once.\n\nYou have to find the length of n after ap... | [{"input": "5\n178 170\n26 25\n64 84\n19 12\n20 136\n", "output": "764520\n12\n1015\n6\n32483\n"}, {"input": "5\n178 170\n26 25\n64 84\n19 12\n38 136\n", "output": "764520\n12\n1015\n6\n46148\n"}, {"input": "5\n178 170\n26 25\n64 84\n19 6\n20 136\n", "output": "764520\n12\n1015\n3\n32483\n"}, {"input": "5\n176 143\n16 ... | code_stdio |
[
{
"content": "There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.\n\nConstraints\n\n* 0\\leq A,B,C\\leq 100\n* A, B an... | [{"input": "31 61 59", "output": "Yes\n"}, {"input": "31 61 51", "output": "Yes\n"}, {"input": "31 86 59", "output": "Yes\n"}, {"input": "39 69 59", "output": "Yes\n"}, {"input": "31 49 59", "output": "No\n"}, {"input": "39 49 59", "output": "No\n"}, {"input": "39 49 10", "output": "No\n"}, {"input": "51 49 10", "outpu... | code_stdio |
[
{
"content": "A bracket sequence is a string containing only characters \"(\" and \")\".\n\nA regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters \"1\" and \"+\" between the original characters of the sequence. For example, bracket ... | [{"input": "10\n()()(\n)((\n)()(((()(\n(((()(\n)(()((\n))\n()()()()\n))()))((\n)\n))())(\n", "output": "2\n"}, {"input": "10\n()()(\n)((\n)()(((()(\n(((()(\n)(()((\n))\n()()()()\n))()))((\n)\n))())(\n", "output": "2\n"}, {"input": "10\n()()(\n)((\n)()((((((\n(((()(\n)(()((\n))\n()()()()\n))()))((\n)\n))())(\n", "output... | code_stdio |
[
{
"content": "Your company was appointed to lay new asphalt on the highway of length $n$. You know that every day you can either repair one unit of the highway (lay new asphalt over one unit of the highway) or skip repairing.\n\nSkipping the repair is necessary because of the climate. The climate in your region... | [{"input": "3\n10 1 1\n11 4 10\n1000000 1 1000100\n", "output": "10\n16\n500049499900\n"}, {"input": "3\n10 1 1\n16 4 10\n1000000 1 1000100\n", "output": "10\n18\n500049499900\n"}, {"input": "3\n10 1 1\n16 4 10\n1000001 1 1000100\n", "output": "10\n18\n500050500001\n"}, {"input": "3\n10 1 1\n16 8 10\n1000001 1 1000100\... | code_stdio |
[
{
"content": "Monocarp wants to draw four line segments on a sheet of paper. He wants the $i$-th segment to have its length equal to $a_i$ ($1 \\le i \\le 4$). These segments can intersect with each other, and each segment should be either horizontal or vertical.\n\nMonocarp wants to draw the segments in such a... | [{"input": "4\n1 1 5 4\n4 16 10 4\n2 1 4 1\n100 21 54 111\n", "output": "4\n40\n2\n2100\n"}, {"input": "4\n0 5 2 4\n6 14 10 3\n2 0 5 1\n101 40 47 111\n", "output": "0\n30\n0\n4040\n"}, {"input": "4\n1 1 5 8\n4 16 10 4\n2 1 4 1\n100 21 54 111\n", "output": "5\n40\n2\n2100\n"}, {"input": "4\n1 1 3 4\n4 16 5 4\n2 0 4 1\n1... | code_stdio |
[
{
"content": "There is a grid of squares with H+1 horizontal rows and W vertical columns.\n\nYou will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \\ldots, B_i-th squares f... | [{"input": "4 4\n1 4\n1 1\n2 0\n3 4", "output": "-1\n-1\n-1\n-1\n"}, {"input": "4 5\n0 4\n0 1\n4 5\n3 4", "output": "1\n2\n-1\n-1\n"}, {"input": "4 34\n2 3\n1 2\n2 2\n2 14", "output": "1\n2\n3\n4\n"}, {"input": "4 34\n2 3\n2 2\n2 2\n2 14", "output": "1\n2\n3\n4\n"}, {"input": "4 12\n2 4\n-1 1\n4 3\n2 4", "output": "1\n... | code_stdio |
[
{
"content": "Takahashi is meeting up with Aoki.\nThey have planned to meet at a place that is D meters away from Takahashi's house in T minutes from now.\nTakahashi will leave his house now and go straight to the place at a speed of S meters per minute.\nWill he arrive in time?\n\n-----Constraints-----\n - 1 \... | [{"input": "7202 7775 4325\n", "output": "Yes\n"}, {"input": "3982 4784 8417\n", "output": "Yes\n"}, {"input": "2156 1932 5902\n", "output": "Yes\n"}, {"input": "1 10000 10000\n", "output": "Yes\n"}, {"input": "522 4575 6426\n", "output": "Yes\n"}, {"input": "3447 629 3497\n", "output": "Yes\n"}, {"input": "9445 8772 8... | code_stdio |
[
{
"content": "## Your Story\n\"A *piano* in the home meant something.\" - *Fried Green Tomatoes at the Whistle Stop Cafe*\n\nYou've just realized a childhood dream by getting a beautiful and beautiful-sounding upright piano from a friend who was leaving the country. You immediately started doing things like pla... | [{"input": "2017", "output": "[\"white\"]", "fn_name": "black_or_white_key"}, {"input": "100", "output": "[\"black\"]", "fn_name": "black_or_white_key"}, {"input": "111", "output": "[\"white\"]", "fn_name": "black_or_white_key"}, {"input": "200", "output": "[\"black\"]", "fn_name": "black_or_white_key"}, {"input": "12"... | code_functional |
[
{
"content": "Given a string and an array of integers representing indices, capitalize all letters at the given indices. \n\nFor example:\n\n* `capitalize(\"abcdef\",[1,2,5]) = \"aBCdeF\"`\n* `capitalize(\"abcdef\",[1,2,5,100]) = \"aBCdeF\"`. There is no index 100.\n\nThe input will be a lowercase string with n... | [{"input": "\"abracadabra\"\n[2, 6, 9, 10]", "output": "[\"abRacaDabRA\"]", "fn_name": "capitalize"}, {"input": "\"indexinglessons\"\n[0]", "output": "[\"Indexinglessons\"]", "fn_name": "capitalize"}, {"input": "\"codewars\"\n[1, 3, 5, 50]", "output": "[\"cOdEwArs\"]", "fn_name": "capitalize"}, {"input": "\"codewarrior... | code_functional |
[
{
"content": "Ilya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer. The state of a bank account can be a negative number. This means that the o... | [{"input": "-1000000000\n", "output": "-100000000\n"}, {"input": "-1000000000\n", "output": "-100000000\n"}, {"input": "-1015555150\n", "output": "-101555510\n"}, {"input": "-1620057635\n", "output": "-162005763\n"}, {"input": "-1246147339\n", "output": "-124614733\n"}, {"input": "-1005651079\n", "output": "-100565107\... | code_stdio |
[
{
"content": "Addition is easy to calculate by hand, but if some numbers are missing, is it easy to fill in the missing numbers? For example, in the following long division, if there is a condition that the numbers 1 to 9 appear only once, how many numbers will fit in the C and E squares? In this case, 8 is cor... | [{"input": "-1 -1 -1 -1 -1 -1 -1 -1 -1", "output": "168"}, {"input": "-1 -1 -1 -1 -1 -1 3 4 6", "output": "0\n"}, {"input": "-1 -1 -1 -1 -1 -1 3 2 6", "output": "0\n"}, {"input": "-1 -1 -1 -1 -1 -2 3 2 6", "output": "0\n"}, {"input": "-1 -1 -1 -1 -1 -1 8 4 6", "output": "12"}, {"input": "-1 -1 -1 0 -1 -2 3 2 6", "outpu... | code_stdio |
[
{
"content": "One popular blog site edits the uploaded photos like this. It cuts a rectangular area out of them so that the ratio of height to width (i.e. the height / width quotient) can vary from 0.8 to 1.25 inclusively. Besides, at least one side of the cut area should have a size, equal to some power of num... | [{"input": "1010000000 1000000000\n", "output": "671088640 536870912\n"}, {"input": "1010000000 1000000010\n", "output": "671088640 536870912\n"}, {"input": "1010000000 1000000001\n", "output": "671088640 536870912\n"}, {"input": "1011000000 1000000010\n", "output": "671088640 536870912\n"}, {"input": "1000000010 10000... | code_stdio |
[
{
"content": "Example\n\nInput\n\n3 3 1 2 4\n1 2\n2 3\n3 1\n\n\nOutput\n\nIMPOSSIBLE\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": "4 1 2 1 2\n1 2\n2 3\n11 0", "output": "IMPOSSIBLE\n"}, {"input": "8 1 2 1 2\n1 2\n2 3\n11 0", "output": "IMPOSSIBLE\n"}, {"input": "3 3 2 2 4\n1 2\n2 3\n3 1", "output": "IMPOSSIBLE\n"}, {"input": "3 3 2 1 4\n1 2\n2 3\n3 1", "output": "IMPOSSIBLE\n"}, {"input": "4 3 2 1 4\n1 2\n2 3\n3 1", "output": "IMPOSSIB... | code_stdio |
[
{
"content": "Let's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\n* The number of numbers which have the same place with numbers A imagined (Hit)\n* The number of numbers included (but different place) in the numbers A imagined (Blow)\n\... | [{"input": "9 1 8 3\n6 1 4 3\n8 6 -1 -1\n2 7 3 1", "output": "2 0\n0 0\n"}, {"input": "4 1 8 2\n6 1 2 3\n8 6 -1 -1\n2 7 3 1", "output": "1 1\n0 0\n"}, {"input": "5 0 8 2\n6 1 2 3\n7 6 -1 -1\n2 7 3 1", "output": "0 1\n0 1\n"}, {"input": "9 0 8 2\n6 1 5 9\n7 22 13 2\n2 6 7 1", "output": "0 1\n0 2\n"}, {"input": "11 1 8 3... | code_stdio |
[
{
"content": "Oleg the bank client and Igor the analyst are arguing again. This time, they want to pick a gift as a present for their friend, ZS the coder. After a long thought, they decided that their friend loves to eat carrots the most and thus they want to pick the best carrot as their present.\n\nThere are... | [{"input": "40\n2 2 88 105 2 2 2 2 2 2 2 2 2 2 4 2 2 2 2 2 2 2 2 2 2 2 2 7 7 2 2 2 2 0 2 2 2 2 2 2\n", "output": "2 2 2 2 2 2 2 2 2 2 4 2 4 2 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 105 88 105 88 105 88 105 105\n"}, {"input": "40\n2 2 88 105 2 2 2 2 2 1 2 2 2 2 4 2 2 2 2 2 2 2 2 2 2 2 2 7 7 2 2 2 2 0 2 2 2 2 2 2\n", "outpu... | code_stdio |
[
{
"content": "There are $n$ computers in a row, all originally off, and Phoenix wants to turn all of them on. He will manually turn on computers one at a time. At any point, if computer $i-1$ and computer $i+1$ are both on, computer $i$ $(2 \\le i \\le n-1)$ will turn on automatically if it is not already on. N... | [{"input": "100 999999733\n", "output": "499246611\n"}, {"input": "350 999999733\n", "output": "255248393\n"}, {"input": "397 999999733\n", "output": "239189389\n"}, {"input": "398 999999733\n", "output": "875462745\n"}, {"input": "399 999999733\n", "output": "530105147\n"}, {"input": "400 999999733\n", "output": "5640... | code_stdio |
[
{
"content": "You are given a tree with N vertices.\n\nHere, a tree is a kind of graph, and more specifically, a connected undirected graph with N-1 edges, where N is the number of its vertices.\n\nThe i-th edge (1≤i≤N-1) connects Vertices a_i and b_i, and has a length of c_i.\nYou are also given Q queries and ... | [{"input": "30\n20 2 885820291\n9 3 833676138\n21 8 969316096\n13 10 732239064\n14 12 568976928\n4 14 362005859\n4 17 46938898\n4 21 706609800\n13 4 114271135\n18 13 475446302\n20 22 582315387\n7 23 941896909\n18 7 546231774\n30 24 698675648\n30 25 13971027\n11 26 760254873\n30 27 731457744\n1 28 242926757\n15 1 704423... | code_stdio |
[
{
"content": "Japan achieved the second straight victory in the national baseball competition WBC !! A baseball tournament was held at Aizu Gakuen High School as baseball became more popular. In this tournament, a round-robin league match will be held and the ranking will be decided in the following ways.\n\n1.... | [{"input": "6\nA 1 0 0 2 -1\nB 0 0 1 2 -1\nC 2 1 1 1 1\nD 2 0 -1 0 2\nE 2 0 0 0 0\nF 1 1 1 2 2\n4\nh 1 1 1\ng 0 2 2\nx -1 0 0\n` 0 2 2\n0", "output": "E\nD\nA\nB\nF\nC\nx\ng\n`\nh\n"}, {"input": "6\nA 1 0 0 2 -1\nB 0 0 1 1 0\nC 1 1 1 1 1\nD 1 1 0 0 2\nE 2 0 -1 0 0\nF 1 2 0 2 1\n4\ng 1 1 1\nh 0 1 2\nx 0 -1 0\na 0 2 2\n0... | code_stdio |
[
{
"content": "Johnny drives a truck and must deliver a package from his hometown to the district center. His hometown is located at point 0 on a number line, and the district center is located at the point d.\n\nJohnny's truck has a gas tank that holds exactly n liters, and his tank is initially full. As he dri... | [{"input": "281 12 23\n178 650197\n129 288456\n34 1664910\n43 683515\n305 957083\n103 724815\n105 308008\n252 1280706\n74 87088\n229 146026\n85 241042\n35 39127\n62 47524\n217 760274\n156 562141\n10 209057\n50 714473\n201 164128\n97 624021\n120 102709\n147 388268\n317 1546753\n190 1448117\n", "output": "-1\n"}, {"input... | code_stdio |
[
{
"content": "Fast Forwarding\n\nMr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants to find how to wind the tape to watch his favorite scene as quickly as possibl... | [{"input": "2139", "output": "21\n"}, {"input": "1374", "output": "22\n"}, {"input": "3723", "output": "23\n"}, {"input": "138", "output": "12\n"}, {"input": "149", "output": "13\n"}, {"input": "132", "output": "14\n"}, {"input": "374", "output": "16\n"}, {"input": "315", "output": "15\n"}, {"input": "933", "output": "... | code_stdio |
[
{
"content": "When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notation. Serezha started playing with them immediately and shuffled them because he wasn't yet able to read... | [{"input": "400\nzzzerrzrzzrozrezooreroeoeezerrzeerooereezeeererrezrororoorrzezoeerrorzrezzrzoerrzorrooerzrzeozrrorzzzzeoeereeroeozezeozoozooereoeorrzoroeoezooeerorreeorezeozeroerezoerooooeerozrrorzozeroereerozeozeoerroroereeeerzzrzeeozrezzozeoooeerzzzorozrzezrrorozezoorzzerzroeeeerorreeoezoeroeeezerrzeorzoeorzoeeororz... | code_stdio |
[
{
"content": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. You would like to sort this sequence in ascending order by repeating the following operation:\n\n* Choose an element in the sequence and move it to the beginning or the end of the sequence.\n\n\n\nF... | [{"input": "8\n6\n3\n2\n1\n7\n4\n8\n5", "output": "5\n"}, {"input": "8\n6\n3\n1\n2\n5\n4\n8\n7", "output": "6\n"}, {"input": "8\n6\n3\n2\n1\n4\n7\n8\n5", "output": "5\n"}, {"input": "8\n6\n3\n2\n1\n7\n4\n5\n8", "output": "5\n"}, {"input": "8\n6\n3\n2\n1\n7\n4\n8\n5", "output": "5\n"}, {"input": "8\n6\n3\n2\n1\n5\n4\n8\... | code_stdio |
[
{
"content": "Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother Yusuf came and started to press the keys randomly. Unfortunately Max has forg... | [{"input": "80124649014054971081213608137817466046254652492627741860478258558206397113198232823859870363821007188476405951611069347299689170240023979048198711745011542774268179055311013054073075176122755643483380248999657649211459997766221072399103579977409770898200358240970169892326442892826731631357561876251276209119... | code_stdio |
[
{
"content": "Knights' tournaments were quite popular in the Middle Ages. A lot of boys were dreaming of becoming a knight, while a lot of girls were dreaming of marrying a knight on a white horse.\n\nIn this problem we consider one of these tournaments. \n\nLet's us call a tournament binary, if it runs accordi... | [{"input": "14", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0... | code_stdio |
[
{
"content": "A motorcade of n trucks, driving from city «Z» to city «З», has approached a tunnel, known as Tunnel of Horror. Among truck drivers there were rumours about monster DravDe, who hunts for drivers in that tunnel. Some drivers fear to go first, others - to be the last, but let's consider the general ... | [{"input": "20\n7892 2 0 24\n4201 1 2 23\n3667 1 3 22\n6388 1 4 21\n2406 1 5 20\n1148 1 6 19\n3958 1 7 18\n7363 1 8 17\n9025 2 9 15\n1909 1 11 14\n73 1 12 13\n5477 2 13 11\n1869 1 15 10\n107 1 16 9\n523 1 17 8\n6589 2 18 6\n6277 2 20 4\n3881 1 22 3\n5771 1 23 2\n622 2 24 0\n", "output": "20\n1 2 3 4 5 6 7 8 9 10 11 12 ... | code_stdio |
[
{
"content": "Snuke Festival 2017 will be held in a tree with N vertices numbered 1,2, ...,N. The i-th edge connects Vertex a_i and b_i, and has joyfulness c_i.\n\nThe staff is Snuke and N-1 black cats. Snuke will set up the headquarters in some vertex, and from there he will deploy a cat to each of the other N... | [{"input": "19\n19 14 48\n11 19 23\n17 14 30\n7 11 15\n2 19 15\n2 18 21\n19 10 43\n12 11 25\n3 11 4\n5 19 50\n4 11 19\n9 12 29\n14 13 3\n14 6 12\n14 15 17\n5 1 6\n8 18 13\n7 16 14", "output": "103\n238\n71\n266\n373\n193\n232\n207\n302\n361\n298\n302\n54\n371\n250\n220\n322\n238\n373\n"}, {"input": "19\n19 14 48\n11 19... | code_stdio |
[
{
"content": "# Task\n Sorting is one of the most basic computational devices used in Computer Science. \n \n Given a sequence (length ≤ 1000) of 3 different key values (7, 8, 9), your task is to find the minimum number of exchange operations necessary to make the sequence sorted. \n\n One operation is the swit... | [{"input": "[9, 9, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7]", "output": "[6]", "fn_name": "exchange_sort"}, {"input": "[9, 9, 9, 7, 7, 8, 9, 7, 8, 9, 7, 9]", "output": "[4]", "fn_name": "exchange_sort"}, {"input": "[8, 8, 7, 9, 9, 9, 8, 9, 7]", "output": "[4]", "fn_name": "exchange_sort"}, {"input": "[7, 7, 8, 8, 9, 9]",... | code_functional |
[
{
"content": "There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all.\n\nThere are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.\n\nEating the same type of cake two days in a row would be no fun, so Mr. Takahashi would like to de... | [{"input": "110 2\n110", "output": "109\n"}, {"input": "12 3\n2 2 -1", "output": "0\n"}, {"input": "13 8\n-1 1 1", "output": "0\n"}, {"input": "100 2\n100", "output": "99\n"}, {"input": "7 3\n-1 1 1", "output": "0\n"}, {"input": "7 5\n-1 1 1", "output": "0\n"}, {"input": "12 3\n2 1 2", "output": "0\n"}, {"input": "7 8\... | code_stdio |
[
{
"content": "Write a program which reads a $ n \\times m$ matrix $A$ and a $m \\times 1$ vector $b$, and prints their product $Ab$.\n\nA column vector with m elements is represented by the following equation.\n\n\\\\[ b = \\left( \\begin{array}{c} b_1 \\\\\\ b_2 \\\\\\ : \\\\\\ b_m \\\\\\ \\end{array} \\right)... | [{"input": "3 4\n1 4 -2 1\n0 3 0 -1\n4 1 0 0\n0\n-2\n3\n0", "output": "-14\n-6\n-2\n"}, {"input": "3 4\n0 7 -13 0\n0 0 0 1\n4 2 2 0\n1\n1\n3\n-1", "output": "-32\n-1\n12\n"}, {"input": "3 4\n0 7 -13 0\n0 0 0 1\n4 2 2 0\n1\n2\n3\n-1", "output": "-25\n-1\n14\n"}, {"input": "3 4\n0 7 -13 0\n0 0 0 1\n4 2 4 0\n1\n2\n3\n-1",... | code_stdio |
[
{
"content": "We have N gemstones labeled 1 through N.\nYou can perform the following operation any number of times (possibly zero).\n - Select a positive integer x, and smash all the gems labeled with multiples of x.\nThen, for each i, if the gem labeled i remains without getting smashed, you will receive a_i ... | [{"input": "99\n122741031 -204980087 525357399 -35985856 -416421742 611495756 -929791499 -703341024 312660354 -8716403 -885125673 332761853 -601694152 -453492700 658205998 -888173729 58182557 620328675 -664005151 -864927032 645923185 675352889 -954440570 -792010737 -826546996 -44381354 332330747 -64136214 -790678352 -2... | code_stdio |
[
{
"content": "Bitwise exclusive OR (or bitwise addition modulo two) is a binary operation which is equivalent to applying logical exclusive OR to every pair of bits located on the same positions in binary notation of operands. In other words, a binary digit of the result is equal to 1 if and only if bits on the... | [{"input": "9992164445234764941\n8162963574901971597\n", "output": "914600435166396672 9077564010068368269"}, {"input": "1367480970723947\n584615739735395\n", "output": "391432615494276 976048355229671"}, {"input": "339671107814\n208405902980\n", "output": "65632602417 274038505397"}, {"input": "1870807699\n259801747\n... | code_stdio |
[
{
"content": "Let's suppose you have an array a, a stack s (initially empty) and an array b (also initially empty).\n\nYou may perform the following operations until both a and s are empty:\n\n Take the first element of a, push it into s and remove it from a (if a is not empty); Take the top element from s, a... | [{"input": "40 39\n25 4 26 34 35 11 22 23 21 2 1 28 20 8 36 5 27 15 39 7 24 14 17 19 33 6 38 16 18 3 32 10 30 13 37 31 29 9 12\n", "output": "-1\n"}, {"input": "40 39\n25 4 26 34 35 11 22 23 21 2 1 28 20 8 36 5 27 15 39 7 24 14 17 19 33 6 38 16 18 3 32 10 30 13 37 31 29 9 12\n", "output": "-1"}, {"input": "40 38\n32 35... | code_stdio |
[
{
"content": "Recall that string $a$ is a subsequence of a string $b$ if $a$ can be obtained from $b$ by deletion of several (possibly zero or all) characters. For example, for the string $a$=\"wowwo\", the following strings are subsequences: \"wowwo\", \"wowo\", \"oo\", \"wow\", \"\", and others, but the follo... | [{"input": "ovvvvovovvvvovoovovovovvvvvvvoovoovvovvoooooovo\n", "output": "463\n"}, {"input": "ovvvvovovvvvovoovovovovvvvvvvoovoovvovvoooooovo\n", "output": "463\n"}, {"input": "vvovooovovvovoovoovvvvovovvvov\n", "output": "100\n"}, {"input": "vovvvovovvvvoovoovovvovooovovv\n", "output": "100\n"}, {"input": "vovvvvvovo... | code_stdio |
[
{
"content": "Students of group 199 have written their lectures dismally. Now an exam on Mathematical Analysis is approaching and something has to be done asap (that is, quickly). Let's number the students of the group from 1 to n. Each student i (1 ≤ i ≤ n) has a best friend p[i] (1 ≤ p[i] ≤ n). In fact, each ... | [{"input": "10\n9 10 6 8 5 3 1 7 4 2\n7 6 2 9 5 10 8 4 1 3\n", "output": "8 3 10 1 5 2 4 9 7 6 "}, {"input": "10\n2 9 1 7 6 8 5 4 10 3\n6 8 5 1 9 10 2 3 4 7\n", "output": "5 6 7 3 2 9 1 10 8 4 "}, {"input": "10\n5 9 7 1 4 10 3 6 2 8\n8 3 9 10 6 5 2 1 7 4\n", "output": "10 7 2 6 8 1 9 4 3 5 "}, {"input": "5\n4 1 2 5 3\n... | code_stdio |
[
{
"content": "You are given n points on the plane. The polygon formed from all the n points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from 1 to n, in clockwise order.\n\nWe define the distance betwe... | [{"input": "20\n-2967010 48581504\n-2967318 48581765\n-2967443 48581988\n-2967541 48582265\n-2967443 48582542\n-2967318 48582765\n-2967010 48583026\n-2966691 48583154\n-2966252 48583234\n-2965813 48583154\n-2965494 48583026\n-2965186 48582765\n-2965061 48582542\n-2964963 48582265\n-2965061 48581988\n-2965186 48581765\n... | code_stdio |
[
{
"content": "# Esolang Interpreters #2 - Custom Smallfuck Interpreter\n\n## About this Kata Series\n\n\"Esolang Interpreters\" is a Kata Series that originally began as three separate, independent esolang interpreter Kata authored by [@donaldsebleung](http://codewars.com/users/donaldsebleung) which all shared ... | [{"input": "\"*>*>>>*>*>>>>>*>[>*]\"\n\"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\"", "output": "[\"11001... | code_functional |
[
{
"content": "There is an H \\times W grid (H vertical, W horizontal), where each square contains a lowercase English letter.\nSpecifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i.\nSnuke can apply the following operation to this grid any number... | [{"input": "12 12\nbimonigaloaf\nfaurwlkbleht\ndexwimqxzxbb\nlxdgyoifcxid\nydxiliocfdgx\nnfoabgilamoi\nibxbdqmzxxwe\npqirylfrcrnf\nwtehfkllbura\nyfrnpflcrirq\nwvcclwgiubrk\nlkbrwgwuiccv\n", "output": "YES\n"}, {"input": "12 12\ntcjbfnoikqgi\nqnnpryzflcef\nagdzieukjutu\nffzyepnqclrn\nkuuetzdaujig\noywsialqlusj\nkqjvjhyc... | code_stdio |
[
{
"content": "You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.\n\nHere, a subsequenc... | [{"input": "5\naabbc", "output": "17\n"}, {"input": "5\nabcda", "output": "23\n"}, {"input": "5\nbdacf", "output": "31\n"}, {"input": "5\nabcaa", "output": "15\n"}, {"input": "5\nabbaa", "output": "11\n"}, {"input": "5\naabba", "output": "11\n"}, {"input": "5\nabbba", "output": "11\n"}, {"input": "5\nbbbaa", "output": ... | code_stdio |
[
{
"content": "There are N mountains in a circle, called Mountain 1, Mountain 2, ..., Mountain N in clockwise order. N is an odd number.\nBetween these mountains, there are N dams, called Dam 1, Dam 2, ..., Dam N. Dam i (1 \\leq i \\leq N) is located between Mountain i and i+1 (Mountain N+1 is Mountain 1).\nWhen... | [{"input": "4347\n260851 113568 146755 277208 291368 365593 306158 216020 344668 347475 275144 352224 284362 117882 195739 364750 445348 416819 269652 99635 82915 80392 51627 75388 237943 322687 343290 419290 298882 162789 250158 343046 283281 278723 215017 105840 263209 271290 119076 276553 322767 277981 268358 302036... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is the maximum value of $n$.\n\nYou are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equal to $n$.\n\nThe positive integer is called good if it can be represented as... | [{"input": "100\n2\n8\n5\n6\n5\n4\n4\n6\n12\n2\n9\n5\n10\n8\n4\n10\n9\n6\n9\n4\n5\n6\n4\n4\n7\n1\n2\n2\n5\n6\n1\n5\n10\n9\n10\n16\n3\n2\n2\n3\n2\n7\n9\n2\n9\n5\n7\n8\n1\n5\n2\n5\n1\n3\n8\n4\n7\n9\n3\n1\n7\n1\n2\n4\n7\n2\n7\n1\n1\n10\n8\n5\n7\n12\n10\n8\n1\n7\n5\n10\n7\n6\n6\n6\n7\n4\n9\n3\n4\n9\n10\n7\n1\n1\n6\n9\n3\n8... | code_stdio |
[
{
"content": "A car number in Berland consists of exactly n digits. A number is called beautiful if it has at least k equal digits. Vasya wants to change the digits in his car's number so that the number became beautiful. To replace one of n digits Vasya has to pay the sum of money, equal to the absolute differ... | [{"input": "490 406\n69376206583505466779821214863898994183223683064168986020986087427466188663988162816834873783630551758344308091300551677259892974326315461675692547390099840313192163258859011559750513086756892636598304230038445861422033560468535920495378496152301219687339355030990474992436599674672102617346048230206... | code_stdio |
[
{
"content": "Several days ago you bought a new house and now you are planning to start a renovation. Since winters in your region can be very cold you need to decide how to heat rooms in your house.\n\nYour house has $n$ rooms. In the $i$-th room you can install at most $c_i$ heating radiators. Each radiator c... | [{"input": "69\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 15\n2 6\n2 6\n2 6\n2 6\n2 6\n2 11\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 7\n2 11\n2 6\n2 6\n2 6\n2 6\n4 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2 6\n2... | code_stdio |
[
{
"content": "Boy Valera likes strings. And even more he likes them, when they are identical. That's why in his spare time Valera plays the following game. He takes any two strings, consisting of lower case Latin letters, and tries to make them identical. According to the game rules, with each move Valera can c... | [{"input": "aaaaaaaaaa\naaaaaaaaaa\n50\na a 47\na a 40\na a 22\na a 48\na a 37\na a 26\na a 40\na a 28\na a 8\na a 46\na a 42\na a 37\na a 1\na a 0\na a 16\na a 34\na a 12\na a 50\na a 45\na a 49\na a 12\na a 8\na a 32\na a 17\na a 13\na a 1\na a 1\na a 33\na a 1\na a 15\na a 9\na a 11\na a 31\na a 5\na a 18\na a 13\na... | code_stdio |
[
{
"content": "Taro and Hanako have numbers of cards in their hands. Each of the cards has a score on it. Taro and Hanako wish to make the total scores of their cards equal by exchanging one card in one's hand with one card in the other's hand. Which of the cards should be exchanged with which?\n\nNote that they... | [{"input": "2 2\n1\n6\n3\n14\n6 5\n3\n4\n5\n2\n4\n7\n11\n2\n7\n4\n1\n4 5\n10\n-1\n3\n11\n1\n9\n6\n0\n1\n7 4\n1\n0\n4\n0\n2\n1\n4\n4\n2\n1\n-1\n2 3\n0\n1\n2\n4\n2\n0 0", "output": "-1\n2 2\n3 0\n2 -1\n-1\n"}, {"input": "2 2\n1\n6\n3\n14\n6 5\n3\n4\n5\n2\n4\n7\n11\n2\n7\n4\n1\n4 5\n10\n-1\n3\n11\n1\n9\n6\n0\n1\n7 4\n1\n0... | code_stdio |
[
{
"content": "Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own.\n\nRuling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's peace. To fight back, Zane and Inzane have enacted a very effective law: from ... | [{"input": "11 1 5\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n6 11\n7 8\n8 9\n9 10\n10 11\n", "output": "0\n\n"}, {"input": "11 1 5\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n", "output": "0\n"}, {"input": "11 1 5\n6\n1 2\n2 3\n3 4\n4 5\n5 6\n6 7\n7 8\n8 9\n9 10\n10 11\n", "output": "0\n"}, {"input": "10 1 5\n5\n1 2\n1... | code_stdio |
[
{
"content": "There is a frog living in a big pond. He loves jumping between lotus leaves floating on the pond. Interestingly, these leaves have strange habits. First, a leaf will sink into the water after the frog jumps from it. Second, they are aligned regularly as if they are placed on the grid points as in ... | [{"input": "10 10\n.o....o...\no.oo......\n..oo..oo..\n..o.......\n..oo..oo..\n.o.o...o..\no..U.o....\noo......oo\noo........\noo..oo....", "output": "RDLLLURUUURDDLLUURRDDLULLDDRR\n"}, {"input": "10 10\n.o....o...\no.oo......\n..oo..oo..\n..o.......\n..oo..oo..\n..o...o.o.\no..U.o....\noo......oo\noo........\noo..oo..... | code_stdio |
[
{
"content": "Given any integer x, Aoki can do the operation below.\nOperation: Replace x with the absolute difference of x and K.\nYou are given the initial value of an integer N. Find the minimum possible value taken by N after Aoki does the operation zero or more times.\n\n-----Constraints-----\n - 0 ≤ N ≤ 1... | [{"input": "999999482938498888 1000000000000000000\n", "output": "517061501112\n"}, {"input": "34439284758432890 4389039281938432\n", "output": "673029497074566\n"}, {"input": "542309233112233445 542309233112233445\n", "output": "0\n"}, {"input": "435893948572830341 43\n", "output": "12\n"}, {"input": "10 9999999999999... | code_stdio |
[
{
"content": "Since you are the best Wraith King, Nizhniy Magazin «Mir» at the centre of Vinnytsia is offering you a discount.\n\nYou are given an array a of length n and an integer c. \n\nThe value of some array b of length k is the sum of its elements except for the $\\lfloor \\frac{k}{c} \\rfloor$ smallest. ... | [{"input": "100 20\n9149 9142 7686 5769 1871 4565 5670 8587 663 637 3421 4267 6884 8142 7634 5748 936 316 9300 771 6906 9230 8994 9690 7155 9393 6274 3183 932 7460 1611 6122 4031 6922 5466 1499 5290 4907 4673 5665 9744 1602 9891 8260 6351 4640 9930 9756 5242 3752 82 3287 824 6897 5579 9095 883 6231 5738 6690 10553 1195... | code_stdio |
[
{
"content": "Consider a sequence of digits of length $2^k$ $[a_1, a_2, \\ldots, a_{2^k}]$. We perform the following operation with it: replace pairs $(a_{2i+1}, a_{2i+2})$ with $(a_{2i+1} + a_{2i+2})\\bmod 10$ for $0\\le i<2^{k-1}$. For every $i$ where $a_{2i+1} + a_{2i+2}\\ge 10$ we get a candy! As a result, ... | [{"input": "20\n4 8 6 6 3 0 1 8 3 6 1 4 3 2 1 3 6 4 5 4\n15\n16 19\n3 10\n9 9\n3 18\n6 7\n15 18\n12 19\n17 18\n12 12\n6 9\n3 10\n1 2\n2 3\n4 19\n16 16\n", "output": "1\n3\n0\n5\n0\n1\n2\n1\n0\n1\n3\n1\n1\n5\n0\n"}, {"input": "20\n4 8 6 6 3 0 1 8 3 6 1 4 3 2 1 3 6 4 5 4\n15\n16 19\n3 10\n9 9\n3 18\n6 7\n15 18\n12 19\n17... | code_stdio |
[
{
"content": "<image>\n\n\nA directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can undertake task B after both task A and task B ... | [{"input": "26 0\n1 0\n0 6\n-1 1\n18 9\n12 1\n0 2", "output": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n"}, {"input": "21 -1\n1 2\n0 6\n-1 1\n11 4\n7 1\n0 1", "output": "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n"}, {"input": "17 0\n1 ... | code_stdio |
[
{
"content": "Little Nastya has a hobby, she likes to remove some letters from word, to obtain another word. But it turns out to be pretty hard for her, because she is too young. Therefore, her brother Sergey always helps her.\n\nSergey gives Nastya the word t and wants to get the word p out of it. Nastya remov... | [{"input": "aaaaaaaadbaaabbbbbddaaabdadbbbbbdbbabbbabaabdbbdababbbddddbdaabbddbbbbabbbbbabadaadabaaaadbbabbbaddb\naaaaaaaaaaaaaa\n61 91 5 43 53 81 7 96 6 9 34 78 79 12 8 63 22 76 18 46 41 56 3 20 57 21 75 73 100 94 35 69 32 4 70 95 88 44 68 10 71 98 23 89 36 62 28 51 24 30 74 55 27 80 38 48 93 1 19 84 13 11 86 60 87 33... | code_stdio |
[
{
"content": "There are many blue cards and red cards on the table. For each card, an integer number greater than 1 is printed on its face. The same number may be printed on several cards.\n\nA blue card and a red card can be paired when both of the numbers printed on them have a common divisor greater than 1. ... | [{"input": "4 3\n2 6 6 15\n2 3 5\n2 3\n4 9\n8 16 32\n4 2\n4 9 11 13\n2 7\n5 5\n2 3 5 1001 1001\n7 11 13 17 34\n10 10\n2 3 5 7 12 11 13 15 17 29\n3 11 1 22 18 22 26 30 34 38\n20 20\n314 144 903 63 137 609 44 626 75 473\n876 421 909 519 755 840 374 368 570 872\n363 650 155 265 64 26 426 391 15 421\n373 984 564 54 823 477... | code_stdio |
[
{
"content": "During her tantrums the princess usually smashes some collectable porcelain. Every furious shriek is accompanied with one item smashed.\n\nThe collection of porcelain is arranged neatly on n shelves. Within each shelf the items are placed in one row, so that one can access only the outermost items... | [{"input": "1 68\n100 26 58 15 8 69 66 49 97 18 74 27 39 19 76 37 25 4 88 75 17 79 41 21 44 39 7 42 63 82 92 87 41 85 25 30 43 80 165 106 98 88 16 15 97 74 81 76 33 19 64 3 14 72 17 36 33 21 34 59 38 75 48 1 57 20 81 56 74 67 14 89 51 30 1 66 20 58 64 58 16 99 33 97 31 5 54 87 6 64 70 40 93 25 50 62 53 80 75 68 13\n", ... | code_stdio |
[
{
"content": "You are given a integer $n$ ($n > 0$). Find any integer $s$ which satisfies these conditions, or report that there are no such numbers:\n\nIn the decimal representation of $s$: $s > 0$, $s$ consists of $n$ digits, no digit in $s$ equals $0$, $s$ is not divisible by any of it's digits. \n\n\n-... | [{"input": "4\n7648\n1421\n37753\n53050\n", "output": "2333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333... | code_stdio |
[
{
"content": "There are N squares in a row. The leftmost square contains the integer A, and the rightmost contains the integer B. The other squares are empty.\n\nAohashi would like to fill the empty squares with integers so that the following condition is satisfied:\n\n* For any two adjacent squares, the (absol... | [{"input": "491995 412925347 465710940 59999126 59999339", "output": "NO\n"}, {"input": "1788 122437383 681218449 90629745 148553464", "output": "YES\n"}, {"input": "1788 122437383 541607279 90629745 148553464", "output": "YES\n"}, {"input": "1788 122437383 943846071 90629745 148553464", "output": "YES\n"}, {"input": "... | code_stdio |
[
{
"content": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nLet next(x) be the minimum lucky number which is larger than or equals x. Pe... | [{"input": "117335682 1000000001\n", "output": "1373020883634915584\n"}, {"input": "696386388 1000000010\n", "output": "1049164104211999364\n"}, {"input": "777777777 1000000000\n", "output": "987654325123456789\n"}, {"input": "777777778 1000000000\n", "output": "987654324345679012\n"}, {"input": "777777777 1000000010\n... | code_stdio |
[
{
"content": "A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: 2 squares forward and 2 squares to the right, 2 squares forward and 2 squares to the left, 2 squares backward and 2 to the right and 2 squares ba... | [{"input": "6\nK.......\n........\n.##..##.\n#..##..#\n........\n...##...\n.#....#.\n..####.K\n\n.......K\n........\n.##..##.\n#..##..#\n........\n...##...\n.#....#.\nK.####..\n\nK.......\n........\n.##..##.\n#..##..#\n........\n...##...\n.#....#.\nK.####..\n\n.......K\n........\n.##..##.\n#..##..#\n........\n...##...\... | code_stdio |
[
{
"content": "One day, Ikta, an elementary school student, received a piece of paper with mathematical formulas from his grandfather. Apparently, the grandfather will give you as much money as the answer to the formula. Ikta has only learned addition, subtraction, and multiplication, so only addition, subtracti... | [{"input": "(198876743*1-210*4-89)", "output": "3533045339395\n"}, {"input": "(198876744*1-210*4-89)", "output": "3533045357160\n"}, {"input": "(198776744*1-210*4-89)", "output": "3531268857160\n"}, {"input": "(198777744*1-210*4-89)", "output": "3531286622160\n"}, {"input": "(198777744*1-120*4-89)", "output": "20106368... | code_stdio |
[
{
"content": "Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one.\n\nGukiZ has strings a, b, and c. He wants to obtain string k by swapping some letters in a, so that k should contain as many non-overlapping substrings equal either to b or c as possibl... | [{"input": "brtakoktrosttttttttttosafasfkalsfkodfdasiofhadfhasdsajfdsafoasodsafahaihfdisoadspapsapiosapdsajdipsahdhasuirhaeuifhhfkjgosooooooooodafdfioottttafdsafaddfuiasdjfjasdo\nokat\ntako\n", "output": "takotakotakotakotakoaaaaaaaaaaaaaaaaaaaaaabddddddddddddddddddeffffffffffffffffffghhhhhhhhhiiiiiiiiijjjjjloooooooooo... | code_stdio |
[
{
"content": "Example\n\nInput\n\n6\n2\n3\n1\n1\n4\n2\n\n\nOutput\n\nYes\nYes\nYes\nNo\nYes\nNo\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": "6\n2\n3\n2\n1\n11\n2", "output": "Yes\nYes\nYes\nNo\nYes\nYes\n"}, {"input": "6\n2\n10\n0\n4\n4\n1", "output": "Yes\nYes\nNo\nYes\nYes\nYes\n"}, {"input": "6\n6\n8\n1\n2\n5\n3", "output": "Yes\nYes\nYes\nYes\nYes\nYes\n"}, {"input": "6\n2\n6\n2\n1\n11\n2", "output": "Yes\nYes\nYes\nNo\nYes\nYes\n"}, {"input... | code_stdio |
[
{
"content": "A famous Berland's painter Kalevitch likes to shock the public. One of his last obsessions is chess. For more than a thousand years people have been playing this old game on uninteresting, monotonous boards. Kalevitch decided to put an end to this tradition and to introduce a new attitude to chess... | [{"input": "BBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\nBWBBWBWB\n", "output": "12\n"}, {"input": "BWBBBWWB\nBWBBBWWB\nBBBBBBBB\nBBBBBBBB\nBWBBBWWB\nBBBBBBBB\nBBBBBBBB\nBBBBBBBB\n", "output": "10\n"}, {"input": "BBBBBBBB\nBBBBBBBB\nBBBBBBBB\nWBBBWBBW\nBBBBBBBB\nBBBBBBBB\nWBBBWBBW\nBBBBBBBB\n",... | code_stdio |
[
{
"content": "It's now the season of TAKOYAKI FESTIVAL!\nThis year, N takoyaki (a ball-shaped food with a piece of octopus inside) will be served. The deliciousness of the i-th takoyaki is d_i.\nAs is commonly known, when you eat two takoyaki of deliciousness x and y together, you restore x \\times y health poi... | [{"input": "50\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100\n", "output": "12250000\n"}, {"input": "41\n49 91 82 7 70 97 50 3 58 42 57 3 46 10 46 36 78 58 29 7 49 5... | code_stdio |
[
{
"content": "There are four points: $A(x_1, y_1)$, $B(x_2, y_2)$, $C(x_3, y_3)$, and $D(x_4, y_4)$. Write a program which determines whether the line $AB$ and the line $CD$ are parallel. If those two lines are parallel, your program should prints \"YES\" and if not prints \"NO\".\n\n\n\nInput\n\nInput consists... | [{"input": "2\n2.926287414400688 0.6174638399148507 2.2117258079089996 2.51039017960215 2.2432914589132955 0.3458310450303873 3.950438914943076 1.6292131026754104\n5.957858300757107 3.314602021400227 10.473008708157936 7.081122407685485 15.460510197185764 6.858362845609268 7.533578119892425 12.180352827357845", "output... | code_stdio |
[
{
"content": "# Task\n Suppose there are `n` people standing in a circle and they are numbered 1 through n in order. \n \n Person 1 starts off with a sword and kills person 2. He then passes the sword to the next person still standing, in this case person 3. Person 3 then uses the sword to kill person 4, and pa... | [{"input": "15", "output": "[15]", "fn_name": "circle_slash"}, {"input": "31", "output": "[31]", "fn_name": "circle_slash"}, {"input": "11", "output": "[7]", "fn_name": "circle_slash"}, {"input": "16", "output": "[1]", "fn_name": "circle_slash"}, {"input": "5", "output": "[3]", "fn_name": "circle_slash"}, {"input": "1"... | code_functional |
[
{
"content": "To introduce the problem think to my neighbor who drives a tanker truck. \nThe level indicator is down and he is worried\nbecause he does not know if he will be able to make deliveries. \nWe put the truck on a horizontal ground and measured the height of the liquid in the tank.\n\nFortunately the ... | [{"input": "3\n10\n7853", "output": "[1981]", "fn_name": "tankvol"}, {"input": "4\n10\n7853", "output": "[2933]", "fn_name": "tankvol"}, {"input": "2\n10\n7853", "output": "[1118]", "fn_name": "tankvol"}, {"input": "5\n7\n3848", "output": "[2940]", "fn_name": "tankvol"}, {"input": "4\n9\n6361", "output": "[2731]", "fn_... | code_functional |
[
{
"content": "You're given a string of dominos. For each slot, there are 3 options:\n\n * \"|\" represents a standing domino\n\n * \"/\" represents a knocked over domino\n\n * \" \" represents a space where there is no domino\n\nFor example: \n\n```python\n\"||| ||||//| |/\"\n```\n\nWhat you must do is find ... | [{"input": "\"||| ||||//| |/\"", "output": "[\"/// ||||//| |/\"]", "fn_name": "domino_reaction"}, {"input": "\"||||| |||\"", "output": "[\"///// |||\"]", "fn_name": "domino_reaction"}, {"input": "\"|||||/|||\"", "output": "[\"//////|||\"]", "fn_name": "domino_reaction"}, {"input": "\"|||||\"", "output": "[\"/////\"]", ... | code_functional |
[
{
"content": "There are N people numbered 1 to N. Each of them is either an honest person whose testimonies are always correct or an unkind person whose testimonies may be correct or not.\nPerson i gives A_i testimonies. The j-th testimony by Person i is represented by two integers x_{ij} and y_{ij}. If y_{ij} ... | [{"input": "15\n14\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n14\n1 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n14\n1 1\n2 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n14\n1 1\n2 1\n3 1\n5 1\n6 1\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13... | code_stdio |
[
{
"content": "Problem\n\nLet $ f (x) $ be the sum of each digit when the non-negative integer $ x $ is expressed in binary.\nGiven a positive integer $ N $, output the largest of $ f (0) $, $ f (1) $, ..., $ f (N) $.\n\n\nExample of calculating the function $ f (5) $:\nWhen 5 is expressed in binary, it is 101 a... | [{"input": "10830", "output": "13\n"}, {"input": "1663", "output": "10\n"}, {"input": "2604", "output": "11\n"}, {"input": "5020", "output": "12\n"}, {"input": "170", "output": "7\n"}, {"input": "264", "output": "8\n"}, {"input": "585", "output": "9\n"}, {"input": "120", "output": "6\n"}, {"input": "119", "output": "6\... | code_stdio |
[
{
"content": "All cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position x_{i} — a coordinate on the Ox axis. No two cities are located at a single point.\n\nLineland residents love to send letters to each other. A person may send a letter only if the recipient... | [{"input": "50\n-50000 -49459 -48875 -48456 -48411 -48096 -47901 -47500 -47150 -46808 -46687 -46679 -46337 -45747 -45604 -45194 -44752 -44242 -44231 -44122 -43636 -43274 -42916 -42881 -42386 -42095 -41830 -41618 -41145 -40897 -40534 -40007 -39761 -39389 -39104 -38909 -38630 -38561 -38364 -38255 -38214 -38084 -37959 -37... | code_stdio |
[
{
"content": "You are given an array of positive integers $a = [a_0, a_1, \\dots, a_{n - 1}]$ ($n \\ge 2$).\n\nIn one step, the array $a$ is replaced with another array of length $n$, in which each element is the greatest common divisor (GCD) of two neighboring elements (the element itself and its right neighbo... | [{"input": "1\n97\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "0\n"}, {"input": "1\n97\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... | code_stdio |
[
{
"content": "There is a grid with H rows and W columns.\n\nThe square at the i-th row and j-th column contains a string S_{i,j} of length 5.\n\nThe rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet... | [{"input": "15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake sna... | code_stdio |
[
{
"content": "In some other world, today is December D-th.\nWrite a program that prints Christmas if D = 25, Christmas Eve if D = 24, Christmas Eve Eve if D = 23 and Christmas Eve Eve Eve if D = 22.\n\n-----Constraints-----\n - 22 \\leq D \\leq 25\n - D is an integer.\n\n-----Input-----\nInput is given from Sta... | [{"input": "-1279", "output": "Christmas Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve Eve... | code_stdio |
[
{
"content": "Your company’s next product will be a new game, which is a three-dimensional variant of the classic game “Tic-Tac-Toe”. Two players place balls in a three-dimensional space (board), and try to make a sequence of a certain length.\n\nPeople believe that it is fun to play the game, but they still ca... | [{"input": "3 3 3\n1 1\n1 1\n1 1\n3 3 7\n3 2\n1 3\n1 1\n2 3\n2 1\n3 3\n3 1\n4 3 15\n1 1\n2 2\n1 1\n3 3\n3 3\n1 1\n3 3\n3 3\n4 4\n1 1\n4 4\n4 4\n4 4\n4 1\n2 2\n0 0 0", "output": "Draw\nWhite 6\nBlack 15\n"}, {"input": "3 3 3\n1 1\n1 1\n1 1\n3 3 7\n3 3\n1 3\n1 1\n2 3\n2 1\n3 3\n3 1\n4 3 15\n1 1\n2 2\n1 1\n3 3\n3 3\n1 1\n... | code_stdio |
[
{
"content": "This is the easy version of the problem. The difference between versions is the constraints on $n$ and $a_i$. You can make hacks only if all versions of the problem are solved.\n\nFirst, Aoi came up with the following idea for the competitive programming problem:\n\nYuzu is a girl who collecting c... | [{"input": "123 79\n49 100 128 149 148 22 89 81 46 142 119 70 22 134 134 80 69 145 144 33 28 127 70 27 91 94 98 29 153 53 102 138 113 123 135 143 87 77 84 27 106 8 156 27 97 150 53 31 126 135 40 79 150 79 69 7 3 49 84 14 24 39 13 103 54 98 122 95 71 157 79 114 136 101 38 25 150 103 150 158 109 121 74 76 3 46 133 31 38 ... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nYou are given two positive integers – A and B. You have to check whether A is divisible by all the prime divisors of B.\n\n------ Input ------ \n\nThe first line of the input contains an integer T denoting the number of test cases. The... | [{"input": "3\n120 75\n184 16\n16 18", "output": "Yes\nYes\nNo\n"}, {"input": "3\n120 75\n184 16\n16 36", "output": "Yes\nYes\nNo\n"}, {"input": "3\n120 75\n184 16\n0 11", "output": "Yes\nYes\nYes\n"}, {"input": "3\n120 75\n128 16\n7 11", "output": "Yes\nYes\nNo\n"}, {"input": "3\n120 137\n128 16\n7 11", "output": "No\... | code_stdio |
[
{
"content": "The brave Knight came to the King and asked permission to marry the princess. The King knew that the Knight was brave, but he also wanted to know if he was smart enough. So he asked him to solve the following task.\n\nThere is a permutation $p_i$ of numbers from 1 to $2n$. You can make two types o... | [{"input": "15\n11 22 13 24 15 26 17 28 19 30 21 2 23 4 25 6 27 8 29 10 1 12 3 14 5 16 7 18 9 20\n", "output": "10\n"}, {"input": "15\n11 22 13 24 15 26 17 28 19 30 21 2 23 4 25 6 27 8 29 10 1 12 3 14 5 16 7 18 9 20\n", "output": "10\n"}, {"input": "9\n16 5 18 7 2 9 4 11 6 13 8 15 10 17 12 1 14 3\n", "output": "7\n"}, ... | code_stdio |
[
{
"content": "# Task\n Given an integer `product`, find the smallest positive integer the product of whose digits is equal to product. If there is no such integer, return -1 instead.\n\n# Example\n\n For `product = 1`, the output should be `11`;\n \n `1 x 1 = 1` (1 is not a valid result, because it has only 1 d... | [{"input": "450", "output": "[2559]", "fn_name": "digits_product"}, {"input": "12", "output": "[26]", "fn_name": "digits_product"}, {"input": "19", "output": "[-1]", "fn_name": "digits_product"}, {"input": "13", "output": "[-1]", "fn_name": "digits_product"}, {"input": "10", "output": "[25]", "fn_name": "digits_product... | code_functional |
[
{
"content": "We are still with squared integers.\n\nGiven 4 integers `a, b, c, d` we form the sum of the squares of `a` and `b`\nand then the sum of the squares of `c` and `d`. We multiply the two sums hence a number `n` and we try to\ndecompose `n` in a sum of two squares `e` and `f` (e and f integers >= 0) s... | [{"input": "7\n96\n-1\n81", "output": "[[[471, 7783], [663, 7769]]]", "fn_name": "prod2sum"}, {"input": "-14\n12\n-10\n8", "output": "[[[8, 236], [44, 232]]]", "fn_name": "prod2sum"}, {"input": "10\n11\n12\n13", "output": "[[[2, 263], [23, 262]]]", "fn_name": "prod2sum"}, {"input": "1\n20\n-4\n-5", "output": "[[[75, 10... | code_functional |
[
{
"content": "There is a new attraction in Singapore Zoo: The Infinite Zoo.\n\nThe Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\\&v=v$, where $\\&$ denotes the bitwise AND operat... | [{"input": "5\n1 4\n3 12\n2 15\n6 6\n10 5\n", "output": "YES\nYES\nNO\nYES\nNO\n"}, {"input": "5\n1 4\n3 6\n1 8\n10 3\n5 5\n", "output": "YES\nYES\nYES\nNO\nYES\n"}, {"input": "5\n1 2\n3 12\n2 6\n3 4\n3 5\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"input": "5\n1 1\n3 17\n2 18\n6 4\n3 5\n", "output": "YES\nYES\nNO\nNO\... | code_stdio |
[
{
"content": "Complete the solution so that it strips all text that follows any of a set of comment markers passed in. Any whitespace at the end of the line should also be stripped out. \n\n**Example:**\n\nGiven an input string of:\n```\napples, pears # and bananas\ngrapes\nbananas !apples\n```\n\nThe output ex... | [{"input": "\"apples, pears # and bananas\\ngrapes\\navocado @apples\"\n[\"@\", \"!\"]", "output": "[\"apples, pears # and bananas\\ngrapes\\navocado\"]", "fn_name": "solution"}, {"input": "\"apples, pears # and bananas\\ngrapes\\nbananas !apples\"\n[]", "output": "[\"apples, pears # and bananas\\ngrapes\\nbananas !app... | code_functional |
[
{
"content": "Most C/C++ programmers know about excellent opportunities that preprocessor #define directives give; but many know as well about the problems that can arise because of their careless use.\n\nIn this problem we consider the following model of #define constructions (also called macros). Each macro h... | [{"input": "5\n#define iiXEqDYeyVmIYsOaO fj/x-9-6/x*x+ 1/ 7*2-x -x+9+235*23*Ww+x-2*K+2-x/70\n#define XVgLzhoTUxoBr ( x+x/x/x*6-x)* x+K/24206-2 /5/8-x-7/Ww/K-x+6 \n#define QdfRBaJk 470551685-( 54-x)-30\n#define gEJcAGnF x+x-x+(x/x+9)/x-41-1/fj/1157561+x/x -x/26/x+K*x\n#define lO 7-1*(x*58 )-K*fj /722113691/x/K+2\n2+4*... | code_stdio |
[
{
"content": "Find the length between 2 co-ordinates. The co-ordinates are made of integers between -20 and 20 and will be given in the form of a 2D array:\n\n(0,0) and (5,-7) would be [ [ 0 , 0 ] , [ 5, -7 ] ]\n\nThe function must return the answer rounded to 2 decimal places in the form of a string.\n\n```py... | [{"input": "[[0, 0], [10, 15]]", "output": "[\"18.03\"]", "fn_name": "length_of_line"}, {"input": "[[-3, 4], [10, 5]]", "output": "[\"13.04\"]", "fn_name": "length_of_line"}, {"input": "[[0, 0], [-5, -6]]", "output": "[\"7.81\"]", "fn_name": "length_of_line"}, {"input": "[[0, 0], [-7, 4]]", "output": "[\"8.06\"]", "fn_... | code_functional |
[
{
"content": "A connected undirected graph is called a vertex cactus, if each vertex of this graph belongs to at most one simple cycle.\n\nA simple cycle in a undirected graph is a sequence of distinct vertices v1, v2, ..., vt (t > 2), such that for any i (1 ≤ i < t) exists an edge between vertices vi and vi + ... | [{"input": "40 43\n1 2\n1 3\n1 4\n4 5\n5 6\n1 7\n5 8\n7 9\n2 10\n10 11\n11 12\n2 13\n13 14\n14 15\n15 16\n16 17\n17 18\n18 19\n19 20\n20 21\n21 22\n22 23\n23 24\n24 25\n25 2\n3 26\n26 27\n27 28\n28 29\n29 30\n30 31\n31 32\n32 3\n4 33\n33 34\n34 35\n35 36\n36 37\n37 4\n5 38\n38 39\n39 40\n40 5\n25\n6 24\n31 14\n40 34\n1... | code_stdio |
[
{
"content": "There are n points marked on the plane. The points are situated in such a way that they form a regular polygon (marked points are its vertices, and they are numbered in counter-clockwise order). You can draw n - 1 segments, each connecting any two marked points, in such a way that all points have ... | [{"input": "10\n0 1 1 0 -1 -2 1 0 0 0\n1 0 0 0 1 0 0 0 0 0\n0 0 1 2 1 0 1 1 0 0\n0 0 1 0 0 0 0 -1 0 0\n-1 0 -1 0 0 0 0 0 1 0\n0 0 -1 0 0 1 -1 0 0 1\n2 0 0 0 0 0 1 0 0 2\n0 -1 0 0 0 0 0 0 0 0\n0 0 0 0 0 -1 0 0 0 0\n0 1 0 -2 0 0 -1 -1 0 0\n", "output": "0\n"}, {"input": "10\n0 1 1 0 -1 -2 1 0 0 0\n1 0 0 0 1 0 0 0 0 0\n0 ... | code_stdio |
[
{
"content": "Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 and so on.\n\nKyota Ootori has just learned about cyclic representation of a p... | [{"input": "50 20365011074\n", "output": "2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49\n"}, {"input": "50 5608642004\n", "output": "1 2 4 3 5 6 8 7 9 10 11 13 12 15 14 17 16 18 20 19 22 21 23 24 25 26 28 27 30 29 31 32 33 34... | code_stdio |
[
{
"content": "Create a function named `divisors`/`Divisors` that takes an integer `n > 1` and returns an array with all of the integer's divisors(except for 1 and the number itself), from smallest to largest. If the number is prime return the string '(integer) is prime' (`null` in C#) (use `Either String a` in ... | [{"input": "24", "output": "[[2, 3, 4, 6, 8, 12]]", "fn_name": "divisors"}, {"input": "13", "output": "[\"13 is prime\"]", "fn_name": "divisors"}, {"input": "29", "output": "[\"29 is prime\"]", "fn_name": "divisors"}, {"input": "3", "output": "[\"3 is prime\"]", "fn_name": "divisors"}, {"input": "253", "output": "[[11,... | code_functional |
[
{
"content": "```if-not:sql\nImplement a function that receives two IPv4 addresses, and returns the number of addresses between them (including the first one, excluding the last one).\n```\n\n```if:sql\nGiven a database of first and last IPv4 addresses, calculate the number of addresses between them (including ... | [{"input": "\"180.0.0.0\"\n\"181.0.0.0\"", "output": "[16777216]", "fn_name": "ips_between"}, {"input": "\"10.11.12.13\"\n\"10.11.13.0\"", "output": "[243]", "fn_name": "ips_between"}, {"input": "\"170.0.0.0\"\n\"170.1.0.0\"", "output": "[65536]", "fn_name": "ips_between"}, {"input": "\"1.2.3.4\"\n\"5.6.7.8\"", "output... | code_functional |
[
{
"content": "This problem is same as the previous one, but has larger constraints.\n\nIt was a Sunday morning when the three friends Selena, Shiro and Katie decided to have a trip to the nearby power station (do not try this at home). After arriving at the power station, the cats got impressed with a large pow... | [{"input": "25\n-10000 -10000\n-10000 -5000\n-10000 0\n-10000 5000\n-10000 10000\n-7452 -10000\n-5000 -5000\n-5000 0\n-5000 5000\n-5000 10000\n-1 -10000\n0 -5000\n0 0\n0 5000\n0 10000\n5000 -13650\n5000 -5000\n5000 0\n5000 5000\n5000 10000\n10000 -10000\n10000 -5000\n10000 0\n10000 5000\n10000 10000\n", "output": "1410... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is the length of the string. You can hack this problem if you solve it. But you can hack the previous problem only if you solve both problems.\n\nKirk has a binary string $s$ (a string which consists of zeroes and ones) of length $n$ and he is ask... | [{"input": "0111001100111011101000\n", "output": "0011001100001011101000\n"}, {"input": "0111001100111111101000\n", "output": "0011001100000011101000\n"}, {"input": "0111011100111111101000\n", "output": "0001001100000011101000\n"}, {"input": "0111011100111101101000\n", "output": "0001001100001101101000\n"}, {"input": "... | code_stdio |
[
{
"content": "Surrounding Area\n\nLand fence\n\nEnglish text is not available in this practice contest.\n\nTwo real estate agents were boarding a passenger ship to the southern island. Blue sky, refreshing breeze ... The two enjoyed a voyage with other passengers. However, one day a tornado suddenly sank a pass... | [{"input": "10 10\n.....W....\n....W.W...\n...W...W..\n....W...W.\n.....W...W\n......W.W.\nBBB....W..\n..BB.BB.BB\n....B..B..\n...B.B..W.\n5 3\n...B.\n...BB\n.....\n1 1\n.\n0 0", "output": "10 21\n12 0\n0 0\n"}, {"input": "10 10\n.....W....\n....W.W...\n...W...W..\n....W...W.\n.....W...W\n......W.W.\nBBB....W..\n..B..B... | code_stdio |
[
{
"content": "Consider some set of distinct characters $A$ and some string $S$, consisting of exactly $n$ characters, where each character is present in $A$.\n\nYou are given an array of $m$ integers $b$ ($b_1 < b_2 < \\dots < b_m$). \n\nYou are allowed to perform the following move on the string $S$:\n\n Choo... | [{"input": "1000000000 2 2\n1 500000000\n", "output": "933660593\n"}, {"input": "1000000000 2 2\n1 500000000\n", "output": "933660593\n"}, {"input": "1000000000 2 2\n2 500000000\n", "output": "811805447\n"}, {"input": "1000000000 2 3\n1 500000000\n", "output": "947751250\n"}, {"input": "1000000000 2 2\n2 182433767\n", ... | code_stdio |
[
{
"content": "There are n employees in Alternative Cake Manufacturing (ACM). They are now voting on some very important question and the leading world media are trying to predict the outcome of the vote.\n\nEach of the employees belongs to one of two fractions: depublicans or remocrats, and these two fractions ... | [{"input": "100\nRDRRDRDDDDRDRRDDRDRRDDRRDDRRRDRRRDDDRDDRDDRRDRDRRRDRDRRRDRRDDDRDDRRRDRDRRRDDRDRDDDDDDDRDRRDDDDDDRRDD\n", "output": "D\n"}, {"input": "100\nRRDRRDDDDDDDRDRRRDRDRDDDRDDDRDDRDRRDRRRDRRDRRRRRRRDRRRRRRDDDRRDDRRRDRRRDDRRDRRDDDDDRRDRDDRDDRRRDRRDD\n", "output": "R\n"}, {"input": "100\nRRDRRDDDDDDDRDRRRDRDRDDDR... | code_stdio |
[
{
"content": "Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permutations. Iahubina is angry that she is no more important for Iahub. When Iahub goes away, Iahubina comes to his office and sabotage his research work.\n\nThe girl finds an important p... | [{"input": "20\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n", "output": "927799753\n"}, {"input": "20\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n", "output": "927799753\n"}, {"input": "10\n4 10 -1 1 6 8 9 2 -1 -1\n", "output": "4\n"}, {"input": "10\n4 10 -1 1 6 8 9 2 -1 -1\n", "outp... | code_stdio |
[
{
"content": "Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles.\n\nVasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles into a new candle. As a result, this new... | [{"input": "1000 1000\n", "output": "1001\n"}, {"input": "1000 1000\n", "output": "1001\n"}, {"input": "1000 2\n", "output": "1999\n"}, {"input": "1000 3\n", "output": "1499\n"}, {"input": "1000 4\n", "output": "1333\n"}, {"input": "1000 3\n", "output": "1499\n"}, {"input": "1000 2\n", "output": "1999\n"}, {"input": "1... | code_stdio |
[
{
"content": "Eve is a beginner stand-up comedian. Her first show gathered a grand total of two spectators: Alice and Bob.\n\nEve prepared $a_1 + a_2 + a_3 + a_4$ jokes to tell, grouped by their type:\n\ntype 1: both Alice and Bob like them;\n\ntype 2: Alice likes them, but Bob doesn't;\n\ntype 3: Bob likes the... | [{"input": "15\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 100000000 100000000 100000000\n1 10000... | code_stdio |
[
{
"content": "After their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.\n\nAt the start of the day they have x ice cream packs. Since the ice cream is free, people start standing in the queue before Kay and Gerda's house even in the nig... | [{"input": "6 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n", "output": "7000000000 0\n"}, {"input": "6 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n", "output": "7000000000 0\n"}, {"input": "6 1000000000\n+ 1000000000... | code_stdio |
[
{
"content": "This is the easy version of this problem. The only difference between easy and hard versions is the constraints on $k$ and $m$ (in this version $k=2$ and $m=3$). Also, in this version of the problem, you DON'T NEED to output the answer by modulo.\n\nYou are given a sequence $a$ of length $n$ consi... | [{"input": "10\n3\n1 1 1\n1\n1\n4\n3 4 3 3\n1\n1\n7\n7 1 1 3 3 4 5\n3\n3 2 1\n9\n4 1 7 1 1 6 1 1 7\n5\n3 5 3 3 3\n1\n1\n9\n8 9 5 7 4 1 3 5 4\n", "output": "1\n0\n4\n0\n8\n1\n11\n10\n0\n12\n"}, {"input": "10\n3\n1 1 1\n1\n1\n4\n3 4 3 3\n1\n1\n7\n7 1 1 3 3 4 5\n3\n3 2 1\n9\n4 1 7 1 1 6 1 1 7\n5\n3 5 3 3 3\n1\n1\n9\n8 9 5... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.