messages listlengths 1 1 | ground_truth stringlengths 88 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya learns to type. He has an unusual keyboard at his disposal: it is rectangular and it has n rows of keys containing m keys in each row. Besides, the keys are of two types. Some of the keys have lowercase Latin letter... | [{"type": "stdin_stdout", "input": "10 10 2\nfriuxvShvg\nerslojqtgu\nzeqsmdewry\nwvhbeeyeSu\ngkofbjaavr\ntwkcdxugps\nnzlylSmafu\nstamkpxnzt\nuwxwximkrm\nmzxyboazbl\n100\nmRIfAtrLKmztpVkAmojDCiIgseBwlUilBIiyDQhqNhNAqVLLIobuCIretLdSvixNNdCiouFMXtwHZFlObCeaygmIiFBfaCirbmCa\n", "output": "19\n"}, {"type": "stdin_stdout", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFirecrackers scare Nian the monster, but they're wayyyyy too noisy! Maybe fireworks make a nice complement.\n\nLittle Tommy is watching a firework show. As circular shapes spread across the sky, a splendid view unfolds on... | [{"type": "stdin_stdout", "input": "3\n-10 4 10\n10 4 10\n0 -7 10\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "3\n-10 4 10\n14 4 10\n0 -7 10\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "3\n-2 -5 4\n-5 -1 5\n-6 -2 16\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "3\n-2 -5 4\n-5 -1 5\n-6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a cost matrix of dimensions m X n. The problem of finding the minimal path from top-left corner to some cell in the matrix is well studied. Here, we are gonna add a little twist.\n\nTo refresh your memory, t... | [{"type": "stdin_stdout", "input": "2\n2 2\n-2 1\n1 7\n2\n1 0 0\n0 0 2\n2 2\n0 2\n## 4\n3\n1 1 2\n1 1 2\n1 1 2\n\nELPMAS", "output": "-1\nNot so many paths\nNot so many paths\nNot so many paths\nNot so many paths\n"}, {"type": "stdin_stdout", "input": "2\n2 2\n0 2\n1 7\n2\n1 0 2\n0 0 2\n2 2\n0 2\n## 4\n3\n1 1 1\n1 1 2\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHave you ever been a part of the exciting game Passing the Parcel ? Sid is on a school picnic with his classmates. The teacher decides to make the whole class play the game of Passing the Parcel. Since the \nwinner of the... | [{"type": "stdin_stdout", "input": "6\nabba\n\nSAMPLE", "output": "5\n"}, {"type": "stdin_stdout", "input": "6\nbbba\n\nSAMPLE", "output": "4\n"}, {"type": "stdin_stdout", "input": "6\nabaa\n\nSAMPLE", "output": "3\n"}, {"type": "stdin_stdout", "input": "6\nabba\n\nELPMAS", "output": "5\n"}, {"type": "stdin_stdout", "i... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRoy has a string S of length N. String S is made of lower case English alphabets. He likes sorted strings. So he wonders how many substrings of S are sorted. \n\nGiven the string S, your task is to count the number of s... | [{"type": "stdin_stdout", "input": "4\n1\ncab\n3\naab\n4\naabd\n7\nzyxTAMPLE", "output": "1\n6\n10\n10\n"}, {"type": "stdin_stdout", "input": "4\n3\nabc\n3\nbba\n4\naabc\n3\nzyxSAMPLE", "output": "6\n4\n10\n3\n"}, {"type": "stdin_stdout", "input": "4\n3\nabc\n3\nbba\n4\naabc\n3\nzxxSAMPLE", "output": "6\n4\n10\n4\n"}, ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn his childhood, Utkarsh had a Graph having N nodes and N-1 edges. It was always possible to go from any node to any other node via a path. \nNow after so many years he has discovered the same Graph in the store room o... | [{"type": "stdin_stdout", "input": "60763 1494\n52004 12938\n18442 7602\n43931 22561\n48729 11667\n38628 28838\n44614 9005\n38681 20584\n51510 5055\n37897 2682\n43654 9484\n30586 27863\n58148 26139\n38459 13617\n54141 6829\n57425 16687\n59078 1031\n30625 1543\n24716 4165\n14692 10813\n50670 17418\n50132 21555\n26626 77... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTakahashi loves the number 7 and multiples of K.\n\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\n\nIf the sequence contains no multip... | [{"type": "stdin_stdout", "input": "1041437", "output": "245040\n"}, {"type": "stdin_stdout", "input": "2243343", "output": "747780\n"}, {"type": "stdin_stdout", "input": "1558339", "output": "177360\n"}, {"type": "stdin_stdout", "input": "451457", "output": "220458\n"}, {"type": "stdin_stdout", "input": "342119", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn 2937, DISCO creates a new universe called DISCOSMOS to celebrate its 1000-th anniversary.\n\nDISCOSMOS can be described as an H \\times W grid. Let (i, j) (1 \\leq i \\leq H, 1 \\leq j \\leq W) denote the square at the... | [{"type": "stdin_stdout", "input": "1486 120 1001", "output": "960152848\n"}, {"type": "stdin_stdout", "input": "328 102 1011", "output": "261361566\n"}, {"type": "stdin_stdout", "input": "328 102 1111", "output": "647647330\n"}, {"type": "stdin_stdout", "input": "328 117 1011", "output": "407646568\n"}, {"type": "stdi... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn order to pass the entrance examination tomorrow, Taro has to study for T more hours.\n\nFortunately, he can leap to World B where time passes X times as fast as it does in our world (World A).\n\nWhile (X \\times t) ho... | [{"type": "stdin_stdout", "input": "-1 011", "output": "-0.0909090909091\n"}, {"type": "stdin_stdout", "input": "1 106", "output": "0.00943396226415\n"}, {"type": "stdin_stdout", "input": "1 011", "output": "0.0909090909091\n"}, {"type": "stdin_stdout", "input": "13 18", "output": "0.722222222222\n"}, {"type": "stdin_s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a farm whose length and width are A yard and B yard, respectively. A farmer, John, made a vertical road and a horizontal road inside the farm from one border to another, as shown below: (The gray part represents ... | [{"type": "stdin_stdout", "input": "-33 13", "output": "-408\n"}, {"type": "stdin_stdout", "input": "-36 13", "output": "-444\n"}, {"type": "stdin_stdout", "input": "-36 17", "output": "-592\n"}, {"type": "stdin_stdout", "input": "-1 -105", "output": "212\n"}, {"type": "stdin_stdout", "input": "-2 -105", "output": "318... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a 3 \\times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.\nAccording to Takahashi, there are six integer... | [{"type": "stdin_stdout", "input": "19 -1 0\n2 3 6\n4 -4 -1", "output": "No\n"}, {"type": "stdin_stdout", "input": "12 -1 3\n2 2 3\n2 -4 2", "output": "No\n"}, {"type": "stdin_stdout", "input": "12 -1 0\n2 2 3\n2 -4 2", "output": "No\n"}, {"type": "stdin_stdout", "input": "12 -1 0\n2 2 3\n4 -4 2", "output": "No\n"}, {"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a grid with H rows and W columns of squares. We will represent the square at the i-th row from the top and j-th column from the left as (i,\\ j). Also, we will define the distance between the squares (i_1,\\ j_1) ... | [{"type": "stdin_stdout", "input": "6 7 12", "output": "RRRRRRR\nRRRRRRR\nRRRRRRR\nRRRRRRR\nRRRRRRR\nYRRRRRR\n"}, {"type": "stdin_stdout", "input": "7 6 1", "output": "RBRBRB\nBRBRBR\nRBRBRB\nBRBRBR\nRBRBRB\nBRBRBR\nRBRBRB\n"}, {"type": "stdin_stdout", "input": "6 6 12", "output": "RRRRRR\nRRRRRR\nRRRRRR\nRRRRRR\nRRRRR... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N.\nBut he couldn't see some parts of the list. Invisible part is denoted `?`.\n\nPlease calculate all possible index of th... | [{"type": "stdin_stdout", "input": "2\ntourist\neptr\ne", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\nssvuhnr\nerrs\nf", "output": "2\n"}, {"type": "stdin_stdout", "input": "2\nhupouvt\netor\ni", "output": "3\n"}, {"type": "stdin_stdout", "input": "2\nsourist\neptr\ne", "output": "1\n"}, {"type": "stdin_std... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a graph with N vertices, numbered 0 through N-1. Edges are yet to be added.\n\nWe will process Q queries to add edges. In the i-th (1≦i≦Q) query, three integers A_i, B_i and C_i will be given, and we will add infi... | [{"type": "stdin_stdout", "input": "2 1\n0 0 1000000010", "output": "1000000011\n"}, {"type": "stdin_stdout", "input": "2 1\n1 0 1000000010", "output": "1000000010\n"}, {"type": "stdin_stdout", "input": "2 1\n0 0 1000000100", "output": "1000000101\n"}, {"type": "stdin_stdout", "input": "2 1\n0 0 1000001010", "output": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn cryptography, Caesar cipher is one of the simplest and most widely known encryption method. Caesar cipher is a type of substitution cipher in which each letter in the text is replaced by a letter some fixed number of p... | [{"type": "stdin_stdout", "input": "xlmw mw xli tmgxyvi xlex m xsso mr ilx xvmt.", "output": "this is the picture that i took in eht trip.\n"}, {"type": "stdin_stdout", "input": "xlmw mw xli tmgxyvi xlex m ossx mr ilx xvmt.", "output": "this is the picture that i koot in eht trip.\n"}, {"type": "stdin_stdout", "input":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIt is known that each weight of 1 gram, 3 gram, 9 gram, and 27 gram can be weighed from 1 gram to 40 gram in 1 gram increments using a balance. For example, if you put a weight of 3 grams and a weight you want to weigh on... | [{"type": "stdin_stdout", "input": "1204", "output": "+--00--+\n"}, {"type": "stdin_stdout", "input": "1942", "output": "+0-000-+\n"}, {"type": "stdin_stdout", "input": "384", "output": "+---+-0\n"}, {"type": "stdin_stdout", "input": "567", "output": "+-+0000\n"}, {"type": "stdin_stdout", "input": "397", "output": "+--... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nA city in Canada where JOI lives is divided into a grid pattern by w roads that extend straight in the north-south direction and h roads that extend straight in the east-west direction.\n\nThe w roads in the no... | [{"type": "stdin_stdout", "input": "10 4\n13 70\n0 0", "output": "26\n55422\n"}, {"type": "stdin_stdout", "input": "10 4\n13 80\n0 0", "output": "26\n77629\n"}, {"type": "stdin_stdout", "input": "4 5\n13 34\n0 0", "output": "11\n61707\n"}, {"type": "stdin_stdout", "input": "8 4\n15 33\n0 0", "output": "20\n41241\n"}, {... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCurrently, people's entertainment is limited to programming contests. The activity of the entertainment club of a junior high school to which she belongs is to plan and run a programming contest. Her job is not to create ... | [{"type": "stdin_stdout", "input": "1 2 1 1 1 0\n1 2 1 0 0 -1\n1 0 0 0 1 1\n3 -1 0 0 2 0\n3 1 0 1 3 1\n0 2 0 2 -1 0\n0 0 1 1 0 7\n2 0 0 1 0 0\n0 0 0 0 0 0", "output": "1\n0\n1\n1\n3\n0\n2\n1\n"}, {"type": "stdin_stdout", "input": "1 2 1 1 1 0\n1 2 1 0 0 -1\n1 0 0 0 1 1\n3 -1 0 0 2 0\n3 0 0 1 3 1\n0 2 0 2 -1 0\n0 0 1 1 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNatsuki and her friends were taken to the space by an alien and made friends with a lot of aliens. During the space travel, she discovered that aliens’ hands were often very different from humans’. Generally speaking, in ... | [{"type": "stdin_stdout", "input": "23 4\n2 3\n3 1\n6 4\n5 2", "output": "1966080\n"}, {"type": "stdin_stdout", "input": "23 4\n2 3\n3 1\n6 6\n5 2", "output": "2621440\n"}, {"type": "stdin_stdout", "input": "24 4\n2 3\n3 2\n4 4\n5 2", "output": "6291456\n"}, {"type": "stdin_stdout", "input": "19 4\n2 2\n3 4\n4 3\n9 5",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProblem Statement\n\nNathan O. Davis is a student at the department of integrated systems.\n\nToday's agenda in the class is audio signal processing. Nathan was given a lot of homework out. One of the homework was to writ... | [{"type": "stdin_stdout", "input": "5\n1 x 0 4 x\n2\nx x\n2\n1 2\n2\n3 0\n2\n1000000000 x\n4\nx 4 1 x\n0", "output": "ambiguous\nnone\nambiguous\nnone\nambiguous\nambiguous\n"}, {"type": "stdin_stdout", "input": "5\n1 x 0 4 x\n2\nx x\n2\n1 2\n2\n3 0\n2\n0000000000 x\n4\nx 4 1 x\n0", "output": "ambiguous\nnone\nambiguou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3\n\n\nOutput\n\n1\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.\n\nWrite Python code to solve this probl... | [{"type": "stdin_stdout", "input": "20093", "output": "276\n"}, {"type": "stdin_stdout", "input": "5663", "output": "100\n"}, {"type": "stdin_stdout", "input": "1761", "output": "292\n"}, {"type": "stdin_stdout", "input": "2283", "output": "36\n"}, {"type": "stdin_stdout", "input": "1253", "output": "88\n"}, {"type": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the building of Jewelry Art Gallery (JAG), there is a long corridor in the east-west direction. There is a window on the north side of the corridor, and $N$ windowpanes are attached to this window. The width of each wi... | [{"type": "stdin_stdout", "input": "8 10 18\n2 12 16 14 18 4 17 10", "output": "430\n"}, {"type": "stdin_stdout", "input": "8 10 18\n2 12 16 14 18 6 17 10", "output": "410\n"}, {"type": "stdin_stdout", "input": "8 10 18\n2 12 16 14 18 4 17 11", "output": "420\n"}, {"type": "stdin_stdout", "input": "8 10 18\n2 12 18 14 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFor a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$.\n\nConstraints\n\n* $1 \\leq ... | [{"type": "stdin_stdout", "input": "5\n0 3 2 4 3 1 1 2\n1 2 3 3 3 4\n2 3 0 3 3 2 4 1\n3 4 0 1 0 -1 1 0 3 3\n4 2 0 1 3 3", "output": "0 0\n1 1\n2 4\n3 1\n4 5\n"}, {"type": "stdin_stdout", "input": "5\n0 3 2 4 3 1 1 2\n1 2 1 4 3 4\n2 3 0 10 3 0 4 1\n3 4 0 1 0 1 1 1 1 3\n4 2 2 1 3 3", "output": "0 0\n1 2\n2 4\n3 1\n4 5\n"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWrite a program which calculates the area and perimeter of a given rectangle.\n\nConstraints\n\n* 1 ≤ a, b ≤ 100\n\nInput\n\nThe length a and breadth b of the rectangle are given in a line separated by a single space.\n\n... | [{"type": "stdin_stdout", "input": "-10 2", "output": "-20 -16\n"}, {"type": "stdin_stdout", "input": "-16 -2", "output": "32 -36\n"}, {"type": "stdin_stdout", "input": "-16 -1", "output": "16 -34\n"}, {"type": "stdin_stdout", "input": "-16 1", "output": "-16 -30\n"}, {"type": "stdin_stdout", "input": "4 122", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nEverybody loves magic, especially magicians who compete for glory on the Byteland Magic Tournament. Magician Cyael is one such magician.\nCyael has been having some issues with her last performances and today she’ll have ... | [{"type": "stdin_stdout", "input": "2\n2\n0 -5\n16 0\n2\n-1 -45\n-3 -2", "output": "16.0000000\nBad Judges\n"}, {"type": "stdin_stdout", "input": "2\n2\n0 -5\n15 0\n2\n-3 -22\n-4 -4", "output": "15.0000000\nBad Judges\n"}, {"type": "stdin_stdout", "input": "2\n2\n0 -5\n17 0\n2\n-3 -22\n-4 -4", "output": "17.0000000\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe Fair Nut is going to travel to the Tree Country, in which there are n cities. Most of the land of this country is covered by forest. Furthermore, the local road system forms a tree (connected graph without cycles). Nu... | [{"type": "stdin_stdout", "input": "10\n4 85 87 24 19 100 27 11 117 120\n5 4 118\n8 9 18\n2 9 98\n8 1 61\n7 2 17\n3 9 25\n10 8 57\n1 4 80\n6 1 0\n", "output": "235\n"}, {"type": "stdin_stdout", "input": "10\n4 85 87 24 19 100 27 11 117 79\n5 4 118\n8 9 18\n2 9 168\n8 1 61\n7 2 17\n3 9 74\n10 8 57\n1 4 80\n6 1 0\n", "ou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAsya loves animals very much. Recently, she purchased n kittens, enumerated them from 1 and n and then put them into the cage. The cage consists of one row of n cells, enumerated with integers from 1 to n from left to rig... | [{"type": "stdin_stdout", "input": "64\n2 20\n37 55\n42 29\n36 54\n35 50\n60 41\n25 61\n31 51\n9 43\n26 28\n48 56\n13 64\n17 19\n8 12\n52 16\n24 44\n1 18\n58 15\n5 30\n3 7\n62 22\n53 14\n11 38\n10 49\n47 59\n40 45\n33 4\n23 39\n63 57\n32 46\n34 6\n27 21\n20 55\n29 54\n35 60\n61 51\n9 26\n48 13\n19 12\n52 44\n1 58\n5 7\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nCat Furrier Transform is a popular algorithm among cat programmers to create longcats. As one of the greatest cat programmers ever exist, Neko wants to utilize this algorithm to create the perfect longcat.\n\nAssume that ... | [{"type": "stdin_stdout", "input": "699050\n", "output": "35\n19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 1\n"}, {"type": "stdin_stdout", "input": "349525\n", "output": "34\n18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2\n"}, {"type": "stdin_stdout", "input": "174762\n", "output": "31\n17 16 15 14 13 12 11 10 9 8 7 6 5 4 3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nTokitsukaze and CSL are playing a little game of stones.\n\nIn the beginning, there are n piles of stones, the i-th pile of which has a_i stones. The two players take turns making moves. Tokitsukaze moves first. On each t... | [{"type": "stdin_stdout", "input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125468\n", "output": "sjfnb\n"}, {"type": "stdin_stdout", "input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125477\n", "output": "cslnb\n"}, {"type": "stdin_stdout", "input": "14\n9 9 1000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAnia has a large integer S. Its decimal representation has length n and doesn't contain any leading zeroes. Ania is allowed to change at most k digits of S. She wants to do it in such a way that S still won't contain any ... | [{"type": "stdin_stdout", "input": "400 224\n34034718296316650556302576767095880542740697596682657060609028712014739414658241556774411582749368771597248873201583574900424227251655547840887764275893533353440635216728376201808545879398359535670372855472971530695051695650262058940466340529417646357776899296790403916961389... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nNow elections are held in Berland and you want to win them. More precisely, you want everyone to vote for you.\n\nThere are n voters, and two ways to c... | [{"type": "stdin_stdout", "input": "3\n3\n0 9\n1 10\n1 9\n7\n1 0\n1 1\n1 6\n6 2\n1 1\n4 0\n3 1\n6\n2 10\n2 4\n2 8\n2 14\n1 5\n5 5\n", "output": "0\n0\n4\n"}, {"type": "stdin_stdout", "input": "3\n3\n0 5\n1 10\n1 10\n7\n0 1\n1 1\n1 3\n6 2\n1 1\n4 0\n3 1\n6\n2 10\n2 4\n2 8\n2 7\n4 5\n5 5\n", "output": "0\n0\n9\n"}, {"typ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou play a strategic video game (yeah, we ran out of good problem legends). In this game you control a large army, and your goal is to conquer n castles of your opponent.\n\nLet's describe the game process in detail. Init... | [{"type": "stdin_stdout", "input": "10 10 2\n2 1 1615\n2 1 1326\n0 0 3880\n2 0 1596\n1 2 4118\n0 0 4795\n0 1 927\n0 0 4555\n0 1 3284\n2 2 1910\n10 6\n2 1\n8 3\n8 7\n6 3\n4 1\n7 4\n6 4\n7 2\n10 9\n", "output": "27079\n"}, {"type": "stdin_stdout", "input": "10 10 0\n0 2 1413\n0 0 4466\n0 0 1302\n0 0 2959\n0 2 1182\n0 0 4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a rectangular matrix of size n × m consisting of integers from 1 to 2 ⋅ 10^5.\n\nIn one move, you can:\n\n * choose any element of the matrix and change its value to any integer between 1 and n ⋅ m, inclusi... | [{"type": "stdin_stdout", "input": "7 8\n110137 66175 74657 124739 63011 153464 30956 8\n9 62369 169892 183765 84737 20941 35760 132079\n20802 67434 149925 53269 150062 35286 50218 112696\n153864 26 7405 121648 170439 115181 195278 127323\n136381 197880 57522 109132 104537 38 39 47930\n51739 77547 43 169711 18955 13495... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIchihime is the current priestess of the Mahjong Soul Temple. She claims to be human, despite her cat ears.\n\nThese days the temple is holding a math contest. Usually, Ichihime lacks interest in these things, but this ti... | [{"type": "stdin_stdout", "input": "14\n2374453 2374454 8591131 23094546\n5813291 5813292 9709163 35032815\n4280399 23049698 23049701 34728360\n15184184 18688462 22400847 22400849\n24397371 31462070 33936330 33936331\n21376685 28241116 38909200 38909202\n29491847 31628480 31628482 45225214\n15144763 15414479 36902879 3... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe define x mod y as the remainder of division of x by y (\\% operator in C++ or Java, mod operator in Pascal).\n\nLet's call an array of positive integers [a_1, a_2, ..., a_k] stable if for every permutation p of integer... | [{"type": "stdin_stdout", "input": "500000 250000\n", "output": "803991687\n"}, {"type": "stdin_stdout", "input": "500000 471528\n", "output": "588862109\n"}, {"type": "stdin_stdout", "input": "500000 121854\n", "output": "377057930\n"}, {"type": "stdin_stdout", "input": "123456 78901\n", "output": "963821949\n"}, {"ty... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBertown is a city with n buildings in a straight line.\n\nThe city's security service discovered that some buildings were mined. A map was compiled, which is a string of length n, where the i-th character is \"1\" if ther... | [{"type": "stdin_stdout", "input": "2\n1 1\n01000010\n10 1\n01101110\n", "output": "2\n11\n"}, {"type": "stdin_stdout", "input": "2\n2 1\n11000110\n10 1\n01101111\n", "output": "4\n11\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n01010010\n10 1\n01101100\n", "output": "3\n11\n"}, {"type": "stdin_stdout", "input": "2\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers l and r in binary representation. Let g(x, y) be equal to the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of all integers from x to y inclusive (that is x ⊕ (x+1) ⊕ ... ⊕ ... | [{"type": "stdin_stdout", "input": "168\n011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n1001000000110110000010101110101001001101001011011101111001010000101100011111111111001000111011001001100101101... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nBaby Ehab is known for his love for a certain operation. He has an array a of length n, and he decided to keep doing the following operation on it: \n\n * he picks 2 adjacent elements; he then removes them and places a s... | [{"type": "stdin_stdout", "input": "15\n2\n660632533 660632533\n2\n774306959 774306959\n2\n971739496 784083784\n2\n775353256 672614891\n2\n403290217 403290217\n2\n651261320 651261320\n2\n894672621 894672621\n2\n46281693 620415865\n2\n92929999 409128591\n2\n26890011 630323358\n2\n443724284 443724284\n2\n308822599 308822... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter defeating a Blacklist Rival, you get a chance to draw 1 reward slip out of x hidden valid slips. Initially, x=3 and these hidden valid slips are Cash Slip, Impound Strike Release Marker and Pink Slip of Rival's Car.... | [{"type": "stdin_stdout", "input": "10\n0.1000 0.1000 0.8000 0.5460931614544986\n0.1111 0.1111 0.7778 0.1111\n0.0001 0.0001 0.9998 1.174827513717328\n0.8000 0.1000 0.1000 0.1000\n0.1000 0.8000 0.1000 0.992075111118174\n0.9000 0.0999 0.0001 0.9000\n0.0999 0.9000 0.0001 0.9000\n0.3333 0.6666 0.0001 0.873181103672425\n0.6... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\n\"This problem is rubbish! There is not statement, and there are only 5 test cases. The problemsetter took liberties with this problem!\" — people complained in the comments to one round on Codeforces. And even more... No... | [{"type": "stdin_stdout", "input": "5\n", "output": "1"}, {"type": "stdin_stdout", "input": "4\n", "output": "2"}, {"type": "stdin_stdout", "input": "2\n", "output": "3"}, {"type": "stdin_stdout", "input": "3\n", "output": "1"}, {"type": "stdin_stdout", "input": "1\n", "output": "2"}] | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the capital city of Berland, Bertown, demonstrations are against the recent election of the King of Berland. Berland opposition, led by Mr. Ovalny, believes that the elections were not fair enough and wants to organize... | [{"type": "stdin_stdout", "input": "100 10\n9199\n89 409 428 408 309 400 259 393 212 273 472 654 533 774 663 484 695 801 587 518 521 578 767 644 532 785 500 944 582 680 899 882 589 601 614 633 877 543 770 614 852 715 932 627 639 658 765 957 898 545 977 751 740 869 885 831 834 702 934 954 500 626 605 921 755 661 707 952... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe World Programming Olympics Medal is a metal disk, consisting of two parts: the first part is a ring with outer radius of r1 cm, inner radius of r2 cm, (0 < r2 < r1) made of metal with density p1 g/cm3. The second part... | [{"type": "stdin_stdout", "input": "10 24 2621 2533 3148 3544 4273 4921 2950 3780 4483\n10 1687 4906 4246 2814 1874 3020 3039 3971 102 492\n10 3458 2699 2463 4395 3607 550 1608 958 3970 3077\n4 891\n", "output": "4919.7621246685\n"}, {"type": "stdin_stdout", "input": "10 24 2621 2533 3148 3544 4273 4921 2950 3780 4461\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a programming language in which every program is a non-empty sequence of \"<\" and \">\" signs and digits. Let's explain how the interpreter of this programming language works. A program is interpreted using move... | [{"type": "stdin_stdout", "input": "2 100\n44\n1 2\n2 2\n2 2\n1 2\n1 1\n2 2\n2 2\n1 2\n1 1\n1 1\n1 2\n1 1\n1 2\n1 1\n2 2\n1 1\n1 2\n2 2\n1 2\n1 2\n2 2\n2 2\n1 2\n1 1\n1 1\n1 2\n1 1\n2 2\n1 2\n1 2\n2 2\n1 2\n1 2\n2 2\n1 2\n2 2\n1 1\n1 1\n1 2\n1 2\n2 2\n1 2\n1 1\n1 2\n1 2\n2 2\n1 1\n2 2\n1 2\n1 1\n2 2\n1 1\n1 2\n2 2\n1 2... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAs you know, Vova has recently become a new shaman in the city of Ultima Thule. So, he has received the shaman knowledge about the correct bracket sequences. The shamans of Ultima Thule have been using lots of different t... | [{"type": "stdin_stdout", "input": "62\n2 3 1 1 2 2 2 2 1 2 3 3 3 3 2 1 3 2 3 3 2 2 2 2 2 2 3 3 2 3 3 1 1 1 1 1 3 3 1 2 1 1 1 1 2 1 1 3 2 2 1 1 3 1 1 1 1 1 1 1 1 2\n8 8 14 28 9 61 44 53 46\n", "output": "YES\n2 3 1 1 2 -2 2 -2 -1 2 3 -3 3 -3 -2 -1 -3 -2 3 -3 2 -2 2 -2 2 -2 3 -3 2 3 -3 1 -1 1 -1 1 3 -3 1 2 1 -1 1 -1 -2 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn a far away land, there are two cities near a river. One day, the cities decide that they have too little space and would like to reclaim some of the river area into land.\n\nThe river area can be represented by a grid ... | [{"type": "stdin_stdout", "input": "100 44\n41 1\n13 1\n52 1\n83 1\n64 2\n86 2\n12 1\n77 1\n100 2\n97 2\n58 1\n33 2\n8 1\n72 2\n2 1\n88 1\n50 2\n4 1\n18 1\n36 2\n46 2\n57 1\n29 2\n22 1\n75 2\n44 2\n80 2\n84 1\n62 1\n42 1\n94 1\n96 2\n31 2\n45 2\n10 2\n17 1\n5 1\n53 1\n98 2\n21 1\n82 1\n15 1\n68 2\n91 1\n", "output": "W... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDima has a birthday soon! It's a big day! Saryozha's present to Dima is that Seryozha won't be in the room and won't disturb Dima and Inna as they celebrate the birthday. Inna's present to Dima is a stack, a queue and a d... | [{"type": "stdin_stdout", "input": "55\n73792\n39309\n73808\n47389\n34803\n87947\n32460\n14649\n70151\n35816\n8272\n78886\n71345\n61907\n16977\n85362\n0\n43792\n8118\n83254\n89459\n32230\n87068\n82617\n94847\n83528\n37629\n31438\n97413\n62260\n13651\n47564\n43543\n61292\n51025\n64106\n0\n19282\n35422\n19657\n95170\n102... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x ≥ 0) divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1 sections.\n\nYou are minimalist. There... | [{"type": "stdin_stdout", "input": "1201 495 438 1293\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "241 1202 830 417\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1201 492 438 690\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "241 1247 830 417\n", "output": "1\n"}, {"type": "stdin_stdout... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flowers. Therefore a dinner can be represented as a s... | [{"type": "stdin_stdout", "input": "3 1\n1 3\n2 3\n4 10\n", "output": "14\n12\n2032\n"}, {"type": "stdin_stdout", "input": "3 1\n1 3\n2 3\n4 6\n", "output": "14\n12\n112\n"}, {"type": "stdin_stdout", "input": "3 1\n2 6\n1 3\n4 4\n", "output": "124\n14\n16\n"}, {"type": "stdin_stdout", "input": "3 1\n1 3\n2 5\n1 6\n", "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou have written on a piece of paper an array of n positive integers a[1], a[2], ..., a[n] and m good pairs of integers (i1, j1), (i2, j2), ..., (im, jm). Each good pair (ik, jk) meets the following conditions: ik + jk is... | [{"type": "stdin_stdout", "input": "20 19\n512 524288 268435456 2048 16384 8192 524288 16777216 128 536870912 256 1 32768 2097152 131072 268435456 262144 134217728 8388608 16\n3 20\n5 12\n19 20\n10 15\n3 18\n3 4\n6 19\n3 14\n3 16\n5 10\n3 12\n5 20\n12 17\n8 9\n13 18\n2 11\n7 12\n6 11\n2 15\n", "output": "106\n"}, {"typ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya plays one very well-known and extremely popular MMORPG game. His game character has k skill; currently the i-th of them equals to ai. Also this game has a common rating table in which the participants are ranked acc... | [{"type": "stdin_stdout", "input": "10 10 10\n8 8 8 8 8 8 8 8 8 8\n2 5 8\n2 4 8\n2 1 8\n2 7 8\n2 10 8\n2 9 8\n2 6 8\n2 3 8\n2 2 8\n2 8 8\n", "output": "10\n3 9 8 2 1 7 4 10 6 5 "}, {"type": "stdin_stdout", "input": "10 10 10\n8 8 8 8 8 8 8 8 8 8\n3 1 8\n3 2 8\n3 3 8\n3 6 8\n3 9 8\n3 8 8\n3 4 8\n3 7 8\n3 5 8\n3 10 8\n",... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe developers of Looksery have to write an efficient algorithm that detects faces on a picture. Unfortunately, they are currently busy preparing a contest for you, so you will have to do it for them. \n\nIn this problem ... | [{"type": "stdin_stdout", "input": "9 46\nuuexbaacesjclggslacermcbkxlcxhdgqtacdwfryxzuxc\naclrsaefakndbnzlkefenuphgcgoedhkaxefjtnkgfeaca\nefuqunpmfxdyyffyhvracozzrxlpekhtsrfhlilfmyhefg\numyacfzffvicqtdpiulefnwcojuwtfbvlxkfsiapdnzpqo\nactefvuxqptremlqjhdbdwacjxdxitxjktecvefacamjcz\neflarseklqrkayhosverpfefzirqigzlxezabh... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nFind the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that a ≤ x ≤ b and x is divisible by k.\n\nInput\n\nThe only line contains three space-sepa... | [{"type": "stdin_stdout", "input": "1 -1000000000000000000 1000000000000000000\n", "output": "2000000000000000001\n"}, {"type": "stdin_stdout", "input": "2 -1000000000000000000 1000000000000000000\n", "output": "1000000000000000001\n"}, {"type": "stdin_stdout", "input": "100000000000000321 -1000000000000000000 10000000... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWay to go! Heidi now knows how many brains there must be for her to get one. But throwing herself in the midst of a clutch of hungry zombies is quite a risky endeavor. Hence Heidi wonders: what is the smallest number of b... | [{"type": "stdin_stdout", "input": "1000000000\n", "output": "231564544\n"}, {"type": "stdin_stdout", "input": "1000000100\n", "output": "231564594\n"}, {"type": "stdin_stdout", "input": "1000010100\n", "output": "231569594\n"}, {"type": "stdin_stdout", "input": "1038818275\n", "output": "519409137\n"}, {"type": "stdin... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nPolycarp is crazy about round numbers. He especially likes the numbers divisible by 10k.\n\nIn the given number of n Polycarp wants to remove the least number of digits to get a number that is divisible by 10k. For exampl... | [{"type": "stdin_stdout", "input": "1000000001 10\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "1234567890 14\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "1000002333 6\n", "output": "9\n"}, {"type": "stdin_stdout", "input": "1010101010 2\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "20... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nHeidi's friend Jenny is asking Heidi to deliver an important letter to one of their common friends. Since Jenny is Irish, Heidi thinks that this might be a prank. More precisely, she suspects that the message she is asked... | [{"type": "stdin_stdout", "input": "11\n1 0 6646\n2 0 8816\n3 2 9375\n4 2 5950\n5 1 8702\n6 2 2657\n7 2 885\n8 7 2660\n9 2 5369\n10 6 3798\n", "output": "18191\n"}, {"type": "stdin_stdout", "input": "11\n1 0 6646\n2 0 8816\n3 2 9375\n4 2 5950\n5 1 8702\n6 2 2657\n7 2 885\n8 7 2660\n9 2 2694\n10 6 3798\n", "output": "18... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIvan wants to write a letter to his friend. The letter is a string s consisting of lowercase Latin letters.\n\nUnfortunately, when Ivan started writing the letter, he realised that it is very long and writing the whole le... | [{"type": "stdin_stdout", "input": "aaaaaaabaaaabbbbaaaaaaabbaaaaaaaaaabbabaaaaaabaaaaabaaaaaaaabaaaaaaaaaaaaaaaabaaaaaabaaaaaaaaabbaaabaaaaabbaaabaaaaabaaabaaaaaabaaaaaaaaaaabaabaaabaaaaabbbbaaaaaaaaaaaaaaabaaaaaaaaababaaabaaaaaaaaaabaaaaaaaabaaaabbbbaaaaaaabbaaaaaaaaaabbabaaaaaabaaaaabaaaaaaaabaaaaaaaaaaaaaaaabaaaaaa... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA never-ending, fast-changing and dream-like world unfolds, as the secret door opens.\n\nA world is an unordered graph G, in whose vertex set V(G) there are two special vertices s(G) and t(G). An initial world has vertex ... | [{"type": "stdin_stdout", "input": "50 33\n", "output": "805999139\n"}, {"type": "stdin_stdout", "input": "48 20\n", "output": "804531912\n"}, {"type": "stdin_stdout", "input": "33 22\n", "output": "804201731\n"}, {"type": "stdin_stdout", "input": "45 19\n", "output": "486112971\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a1, a2, ..., an consisting of n integers, and an integer k. You have to split the array into exactly k non-empty subsegments. You'll then compute the minimum integer on each subsegment, and take the... | [{"type": "stdin_stdout", "input": "39 1\n676941771 -923780377 -163050076 -230110947 -208029500 329620771 13954060 158950156 -252501602 926390671 -678745080 -921892226 -100127643 610420285 602175224 -839193819 471391946 910035173 777969600 -736144413 -489685522 60986249 830784148 278642552 -375298304 197973611 -3544823... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAre you going to Scarborough Fair?\n\nParsley, sage, rosemary and thyme.\n\nRemember me to one who lives there.\n\nHe once was the true love of mine.\n\nWillem is taking the girl to the highest building in island No.28, h... | [{"type": "stdin_stdout", "input": "67 39\nacbcbccccbabaabcabcaaaaaaccbcbbcbaaaacbbcccbcbabbcacccbbabbabbabaac\n4 36 a b\n25 38 a a\n3 44 b c\n35 57 b a\n4 8 a c\n20 67 c a\n30 66 b b\n27 40 a a\n2 56 a b\n10 47 c a\n22 65 c b\n29 42 a b\n1 46 c b\n57 64 b c\n20 29 b a\n14 51 c a\n12 55 b b\n20 20 a c\n2 57 c a\n22 60 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAs the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server ha... | [{"type": "stdin_stdout", "input": "10 10\nittmcs 112.147.123.173\njkt 228.40.73.178\nfwckqtz 88.28.31.198\nkal 224.226.34.213\nnacuyokm 49.57.13.44\nfouynv 243.18.250.17\ns 45.248.83.247\ne 75.69.23.169\nauwoqlch 100.44.219.187\nlkldjq 46.123.169.140\ngjcylatwzi 46.123.169.140;\ndxfi 88.28.31.198;\ngv 46.123.169.140;\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRight now she actually isn't. But she will be, if you don't solve this problem.\n\nYou are given integers n, k, A and B. There is a number x, which is initially equal to n. You are allowed to perform two types of operatio... | [{"type": "stdin_stdout", "input": "1999999999\n1000000000\n1385852\n184569875\n", "output": "1385852183184023\n"}, {"type": "stdin_stdout", "input": "1000999777\n1934999345\n2356346\n34534565\n", "output": "2358701818178496\n"}, {"type": "stdin_stdout", "input": "1000000000\n1999999999\n789987\n184569875\n", "output":... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNikita likes tasks on order statistics, for example, he can easily find the k-th number in increasing order on a segment of an array. But now Nikita wonders how many segments of an array there are such that a given number... | [{"type": "stdin_stdout", "input": "10 29\n88 57 -3 -9 16 48 -84 80 -73 -46\n", "output": "5 13 11 11 8 4 3 0 0 0 0 "}, {"type": "stdin_stdout", "input": "10 29\n88 57 0 -9 16 48 -84 80 -73 -46\n", "output": "5 13 11 11 8 4 3 0 0 0 0\n"}, {"type": "stdin_stdout", "input": "10 29\n88 57 0 -9 16 95 -84 80 -73 -46\n", "ou... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIts NU-Tech'15 and participants are pouring in large numbers. Its the first day of the fest and everybody has gathered around the registration desks but are confused on receiving a set of very large numbers on the registr... | [{"type": "stdin_stdout", "input": "300\n597113957311329435059958607533989736968628782267274168518699460337218773748101061458441626465444212519430749480506686309043987608687487248528856082640815820249994912217851402293932229282858441360639287639165414669686844134145129476519392505401548164433358465142649416718580658059... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLittle Vaishnavi is bored during the vacation which is going on. Being the only little girl in the neighbourhood she did not have any one else to play with. Her parents are so strict that they will not let her out of the ... | [{"type": "stdin_stdout", "input": "2\n1 -1\n1 -1\n\nSMAPLE", "output": "-8\n-8\n"}, {"type": "stdin_stdout", "input": "2\n1 -1\n2 -1\n\nSMALPE", "output": "-8\n-1\n"}, {"type": "stdin_stdout", "input": "2\n1 2\n1 -2\n\nSMAPLE", "output": "16\n-16\n"}, {"type": "stdin_stdout", "input": "2\n2 -1\n1 -1\n\nSMAPLE", "outpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAlfie was a prisoner in mythland. Though Alfie was a witty and intelligent guy.He was confident of escaping prison.After few days of observation,He figured out that the prison consists of (N × N) cells.i.e The shape of pr... | [{"type": "stdin_stdout", "input": "3\n4\n0 1 1 0 \n0 1 1 -1 \n1 0 -1 1 \n0 1 1 0 \n4\n-1 0 1 1 \n0 0 0 0 \n2 1 1 0 \n1 0 0 0 \n2\n0 1 1 -1 \n0 0 1 2 \n0 0 0 0 \n0 1 0 1 \n \nSAMPME", "output": "0\n2\n1\n"}, {"type": "stdin_stdout", "input": "3\n4\n0 1 0 0 \n0 1 1 -1 \n1 0 0 0 \n0 1 1 0 \n4\n0 0 1 1 \n0 0 0 0 \n1 1 1 0... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\n\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\n\nRecently, they learned the operation called xor (exclusive ... | [{"type": "stdin_stdout", "input": "4\n141 1 -1 2", "output": "-4 -144 142 -141\n"}, {"type": "stdin_stdout", "input": "4\n102 2 -1 2", "output": "-1 -101 102 -101\n"}, {"type": "stdin_stdout", "input": "4\n102 2 -1 1", "output": "-4 -104 101 -101\n"}, {"type": "stdin_stdout", "input": "4\n13 -17 0 0", "output": "-17 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nGiven is an integer N.\n\nTakahashi chooses an integer a from the positive integers not greater than N with equal probability.\n\nFind the probability that a is odd.\n\nConstraints\n\n* 1 \\leq N \\leq 100\n\nInput\n\nInp... | [{"type": "stdin_stdout", "input": "-1297", "output": "0.499614494988\n"}, {"type": "stdin_stdout", "input": "-1739", "output": "0.499712478436\n"}, {"type": "stdin_stdout", "input": "-2609", "output": "0.499808355692\n"}, {"type": "stdin_stdout", "input": "-4637", "output": "0.499892171663\n"}, {"type": "stdin_stdout"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn the State of Takahashi in AtCoderian Federation, there are N cities, numbered 1, 2, ..., N. M bidirectional roads connect these cities. The i-th road connects City A_i and City B_i. Every road connects two distinct cit... | [{"type": "stdin_stdout", "input": "10 39\n7 2\n7 1\n5 6\n5 8\n9 10\n2 8\n8 7\n3 10\n10 1\n8 10\n2 3\n7 4\n3 9\n4 10\n3 4\n6 1\n6 7\n9 5\n9 7\n6 9\n9 4\n4 6\n7 5\n8 3\n2 5\n9 2\n10 7\n8 6\n8 9\n7 3\n5 3\n4 5\n6 3\n2 10\n5 10\n4 2\n6 2\n8 4\n10 6", "output": "21"}, {"type": "stdin_stdout", "input": "13 5\n1 2\n1 3\n3 4\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA railroad running from west to east in Atcoder Kingdom is now complete.\n\nThere are N stations on the railroad, numbered 1 through N from west to east.\n\nTomorrow, the opening ceremony of the railroad will take place.\... | [{"type": "stdin_stdout", "input": "4\n1 13 1\n44 17 22\n101 4096 64", "output": "4197\n4197\n4197\n0\n"}, {"type": "stdin_stdout", "input": "4\n1 13 1\n44 17 22\n120 4096 64", "output": "4216\n4216\n4216\n0\n"}, {"type": "stdin_stdout", "input": "4\n1 18 1\n44 17 22\n111 4096 64", "output": "4207\n4207\n4207\n0\n"}, {... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nWe have a grid with H rows and W columns of squares. Snuke is painting these squares in colors 1, 2, ..., N. Here, the following conditions should be satisfied:\n\n* For each i (1 ≤ i ≤ N), there are exactly a_i squares p... | [{"type": "stdin_stdout", "input": "3 5\n5\n1 2 5 4 3", "output": "1 2 2 3 3\n4 4 3 3 3\n4 4 5 5 5\n"}, {"type": "stdin_stdout", "input": "3 5\n5\n1 2 6 4 2", "output": "1 2 2 3 3\n4 3 3 3 3\n4 4 4 5 5\n"}, {"type": "stdin_stdout", "input": "3 5\n5\n1 1 3 5 5", "output": "1 2 3 3 3\n4 4 4 4 4\n5 5 5 5 5\n"}, {"type": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nSnuke loves working out. He is now exercising N times.\n\nBefore he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i.\n\nFind Snuke's power after he exercises N times... | [{"type": "stdin_stdout", "input": "100001", "output": "755072381\n"}, {"type": "stdin_stdout", "input": "110001", "output": "817497558\n"}, {"type": "stdin_stdout", "input": "110011", "output": "422312314\n"}, {"type": "stdin_stdout", "input": "101001", "output": "249638241\n"}, {"type": "stdin_stdout", "input": "1100... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have ob... | [{"type": "stdin_stdout", "input": "5\n3 10\n48 28\n31 199\n300 23\n3 4", "output": "12600\n"}, {"type": "stdin_stdout", "input": "5\n3 11\n87 28\n31 199\n300 23\n3 2", "output": "13000\n"}, {"type": "stdin_stdout", "input": "5\n3 11\n33 28\n31 269\n300 23\n3 2", "output": "12000\n"}, {"type": "stdin_stdout", "input": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nI have a sequence defined as follows:\n\n* All even-numbered terms are equal to the previous term multiplied by 2.\n* All odd-numbered terms are equal to the previous term divided by 3.\n\n\n\nCreate a program that reads ... | [{"type": "stdin_stdout", "input": "12.245545640480573\n11.553343685171598\n20.008357034777177", "output": "95.6966714867\n90.2872413915\n156.361604975\n"}, {"type": "stdin_stdout", "input": "12.245545640480573\n13.018962096503808\n20.008357034777177", "output": "95.6966714867\n101.740777865\n156.361604975\n"}, {"type"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nIn April 2008, Aizuwakamatsu City succeeded in making yakitori with a length of 20 m 85 cm. The chicken used at this time is Aizu local chicken, which is a specialty of Aizu. Aizu local chicken is very delicious, but it i... | [{"type": "stdin_stdout", "input": "17 5128 240 126 32\n20 4907 303 151 7\n60 73980 2086 337 15\n3 3216 562 010 6\n40 8478 221 53 307\n23 27966 5 92 13\n50 107893 4497 65 20\n199 88677 2825 226 8\n0", "output": "21 0\n7 18\n15 126\n5 40\n37 5\n13 303\n20 276\n8 292\n"}, {"type": "stdin_stdout", "input": "49 5128 240 25... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThe educational program (AHK Education) of the Aiz Broadcasting Association broadcasts a handicraft program for children, \"Play with Tsukuro\". This time I will make a box with sticks, but I would like to see if I can ma... | [{"type": "stdin_stdout", "input": "0 1 1 4 11 16 3 2 0 0 5 13", "output": "no\n"}, {"type": "stdin_stdout", "input": "0 1 1 4 11 16 6 2 0 0 5 13", "output": "no\n"}, {"type": "stdin_stdout", "input": "0 1 1 4 11 16 6 2 1 0 5 13", "output": "no\n"}, {"type": "stdin_stdout", "input": "0 1 1 4 2 20 6 2 2 0 13 13", "outpu... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nRailroad Trip\n\nThere are N cities in the JOI country, numbered 1, 2, ..., and N, respectively. In addition, there are N − 1 railroads, which are numbered 1, 2, ..., and N − 1, respectively. The railroad i (1 ≤ i ≤ N − 1... | [{"type": "stdin_stdout", "input": "4 4\n1 3 2 4\n147 131 100\n100 50 80\n250 70 130", "output": "577\n"}, {"type": "stdin_stdout", "input": "4 4\n1 3 3 4\n147 131 100\n100 50 80\n250 70 130", "output": "447\n"}, {"type": "stdin_stdout", "input": "4 4\n1 3 2 4\n120 90 100\n110 50 96\n250 138 130", "output": "616\n"}, {... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere is a mysterious planet called Yaen, whose space is 2-dimensional. There are many beautiful stones on the planet, and the Yaen people love to collect them. They bring the stones back home and make nice mobile arts of... | [{"type": "stdin_stdout", "input": "5\n1.562976116968605\n3\n1\n2\n2\n1.7218698683022837\n3\n1\n4\n1\n2.1448962816069557\n3\n1\n2\n3\n3.0434166674596996\n4\n2\n2\n1\n3\n2.5055384306161197\n2\n1\n2\n6\n2", "output": "1.500000000\n1.500000000\n1.750000000\n2.266666667\n1.000000000\n"}, {"type": "stdin_stdout", "input": "... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nMaking Lunch Boxes\n\nTaro has been hooked on making lunch boxes recently. Taro has obtained a new lunch box recipe book today, and wants to try as many of the recipes listed in the book as possible.\n\nEnough of the ingr... | [{"type": "stdin_stdout", "input": "4 3\n110\n101\n011\n110\n1 1\n1\n1\n1\n1\n1\n1\n1\n4 5\n10000\n01000\n00100\n00010\n6 6\n111111\n011000\n100000\n000010\n100001\n100100\n0 0", "output": "3\n0\n0\n0\n0\n6\n"}, {"type": "stdin_stdout", "input": "4 3\n110\n101\n011\n110\n7 1\n0\n1\n1\n1\n1\n1\n1\n4 5\n10000\n01000\n001... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA permutation of N numbers from 1 to N A1, A2, ……, AN is given. You can perform the operation reverse (i, j) to reverse the order of the numbers in the interval [i, j] (1 ≤ i ≤ j ≤ N) for this permutation. For example, if... | [{"type": "stdin_stdout", "input": "10\n3 -1 5 1 7 4 14 6 17 13", "output": "9\n"}, {"type": "stdin_stdout", "input": "10\n3 -1 5 1 7 4 14 6 17 8", "output": "9\n"}, {"type": "stdin_stdout", "input": "10\n2 -1 5 1 7 4 14 6 17 8", "output": "9\n"}, {"type": "stdin_stdout", "input": "10\n2 -1 5 1 7 4 12 6 17 8", "output"... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAfter many years of research, Ikta has acquired the ability to predict the future! The time and money he spent on this research was enormous, but it's finally time to be rewarded. To get the money back, Ikta decided to st... | [{"type": "stdin_stdout", "input": "3 3 10\n18 1 13\n15 3 3\n5 10 0", "output": "100\n"}, {"type": "stdin_stdout", "input": "3 3 10\n10 14 13\n14 2 6\n5 4 1", "output": "28\n"}, {"type": "stdin_stdout", "input": "3 3 10\n18 4 13\n15 3 3\n5 11 1", "output": "34\n"}, {"type": "stdin_stdout", "input": "3 3 10\n18 4 13\n15... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nD: Shiritori Compression\n\nproblem\n\nEbi-chan and Kana-chan did a shiritori. Ebi-chan is looking at the memo of the word that came out in Shiritori.\n\nEbi-chan wants to remove redundant continuous subsequences from thi... | [{"type": "stdin_stdout", "input": "7\nbanana\nta\ntomb\nbus\nsound\ndoes\nsome", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\nananab\nta\nsomb\nbus\nsound\ndoes\nsemo", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\nbanaoa\nta\ntomb\nbus\nsound\ndoes\nsome", "output": "2\n"}, {"type": "stdin_stdout... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nThere are $ 2 $ teams, Team UKU and Team Ushi. Initially, Team UKU has $ N $ people and Team Uku has $ M $ people. Team UKU and Team Ushi decided to play a game called \"U & U\". \"U & U\" has a common score fo... | [{"type": "stdin_stdout", "input": "1000000000000000000 1000000000010000000", "output": "4\n"}, {"type": "stdin_stdout", "input": "1000000001000000000 1000000000010000000", "output": "2\n"}, {"type": "stdin_stdout", "input": "1000001001000000000 1000000000010000000", "output": "2\n"}, {"type": "stdin_stdout", "input": ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nA state with $n$ flags of ON or OFF can be represented by a sequence of bits where $0, 1, ..., n-1$ th flag corresponds to 1 (ON) or 0 (OFF). The state can be managed by the corresponding decimal integer, because the sequ... | [{"type": "stdin_stdout", "input": "3\n3 0 1 4\n1 3\n3 0 1 2\n13\n1 1\n2 1\n3 1\n4 2\n5 1\n6 2\n7 2\n8 2", "output": "0\n1\n1\n0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "3\n3 0 1 2\n1 3\n3 0 1 2\n13\n1 1\n2 1\n3 1\n4 2\n5 2\n6 2\n7 2\n8 2", "output": "0\n0\n1\n0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nDevuLand is a very strange place. There are n villages in it. Some of the villages are occupied by dinosaurs while the remaining ones by villagers.\n\tYou are given the information of DevuLand\n\tby an array D of size n. ... | [{"type": "stdin_stdout", "input": "3\n2\n5 -5\n2\n-5 5\n3\n-1 3 -2", "output": "5\n5\n3\n"}, {"type": "stdin_stdout", "input": "3\n2\n5 -5\n2\n-5 5\n3\n1 2 -3", "output": "5\n5\n4\n"}, {"type": "stdin_stdout", "input": "3\n1\n5 -5\n2\n-5 5\n3\n1 2 -3", "output": "5\n5\n4\n"}, {"type": "stdin_stdout", "input": "3\n2\n5... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nAt the end of a busy day, The Chef and his assistants play a game together. The game is not just for fun but also used to decide who will have to clean the kitchen. The Chef is a Game Master, so his concern is how to mana... | [{"type": "stdin_stdout", "input": "1\n9 3 3\n-1 23\n1 1\n-1 -1", "output": "19\n"}, {"type": "stdin_stdout", "input": "1\n0 2 3\n5 37\n6 -1\n-1 49", "output": "46\n"}, {"type": "stdin_stdout", "input": "1\n9 3 3\n0 16\n1 1\n-1 -1", "output": "13\n"}, {"type": "stdin_stdout", "input": "1\n4 4 3\n2 0\n0 14\n-1 10", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nNatasha is going to fly on a rocket to Mars and return to Earth. Also, on the way to Mars, she will land on n - 2 intermediate planets. Formally: we number all the planets from 1 to n. 1 is Earth, n is Mars. Natasha will ... | [{"type": "stdin_stdout", "input": "90\n35\n1 68 16 30 24 1 1 1 35 1 1 67 1 1 1 1 33 16 37 77 83 1 77 26 1 1 68 67 70 62 1 47 1 1 1 84 1 65 1 32 83 1 1 1 28 1 71 76 84 1 1 5 1 74 10 1 1 1 38 87 13 1 7 66 81 49 1 9 1 11 1 25 1 1 1 1 7 1 1 36 61 47 51 1 1 69 40 1 37 1\n40 1 21 1 19 51 37 52 64 1 86 1 5 24 1 1 1 19 36 1 1... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya has two arrays A and B of lengths n and m, respectively.\n\nHe can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it with a ... | [{"type": "stdin_stdout", "input": "49\n18 1 7 2 1 1 50 22 8 2 2 1 30 2 46 10 1 4 5 18 25 21 38 11 2 15 29 8 7 2 45 12 14 16 16 23 11 1 1 4 48 18 3 1 1 23 4 10 7\n50\n5 25 34 22 19 4 4 2 40 52 1 4 1 3 47 9 4 1 8 47 4 5 1 1 9 22 9 2 2 1 1 48 7 2 8 16 4 2 41 12 3 30 21 10 2 2 5 1 31 13\n", "output": "14\n"}, {"type": "st... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nLet's call the following process a transformation of a sequence of length n.\n\nIf the sequence is empty, the process ends. Otherwise, append the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_div... | [{"type": "stdin_stdout", "input": "40471\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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": "Solve the following coding problem using the programming language python:\n\nThis problem differs from one which was on the online contest.\n\nThe sequence a1, a2, ..., an is called increasing, if ai < ai + 1 for i < n.\n\nThe sequence s1, s2, ..., sk is called the subsequence of the sequence a1, ... | [{"type": "stdin_stdout", "input": "83\n95 164 123 111 177 71 38 225 103 59 210 209 117 139 115 140 66 21 39 84 14 227 0 43 90 233 96 98 232 237 108 139 55 220 14 225 134 39 68 167 193 125 86 216 87 14 94 75 255 24 165 98 177 191 239 123 98 90 29 52 155 231 187 90 180 1 31 237 167 145 242 115 61 190 47 41 61 206 191 24... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya likes taking part in Codeforces contests. When a round is over, Vasya follows all submissions in the system testing tab.\n\nThere are n solutions, the i-th of them should be tested on a_i tests, testing one solution... | [{"type": "stdin_stdout", "input": "100 10\n3 114 77 78 105 87 6 122 141 100 75 118 64 18 88 37 109 72 31 101 36 10 62 18 52 17 149 115 22 150 138 48 46 42 104 8 63 21 117 58 87 80 7 131 125 118 67 13 144 43 59 67 74 13 124 77 86 148 107 11 51 9 87 52 147 22 7 22 143 12 121 123 17 35 33 87 91 140 92 38 106 10 66 26 40 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n stones arranged on an axis. Initially the i-th stone is located at the coordinate s_i. There may be more than one stone in a single place.\n\nYou can perform zero or more operations of the following type: \n\n... | [{"type": "stdin_stdout", "input": "20\n53 86 76 100 16 12 13 97 79 23 28 64 42 10 23 56 59 76 48 12\n48 49 49 49 48 49 48 49 49 49 48 48 48 49 49 49 49 49 49 48\n", "output": "YES\n19\n14 1 4\n14 16 7\n14 17 10\n14 12 15\n14 3 2\n6 3 25\n6 18 11\n20 18 16\n20 9 20\n7 9 10\n7 2 25\n5 2 12\n5 8 20\n10 8 25\n15 8 3\n15 4... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOnce upon a time there were several little pigs and several wolves on a two-dimensional grid of size n × m. Each cell in this grid was either empty, containing one little pig, or containing one wolf.\n\nA little pig and a... | [{"type": "stdin_stdout", "input": "10 10\n..P..WWP.W\nPP.WPPPPPP\nWWPP.PPWPP\nPPPPW..PPW\nPP.PW.P.PW\nWW..PPWWP.\n..PW...PP.\n.PPPP.PPPW\nPP.PWP..P.\nPWPPP..WWP\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "10 10\nWPPPPWPPWP\nPPPWPPPPPP\nPWPPPPWPPP\nPPPPWPPPWP\nWPPPPPPPPP\nPPPWPPWPPP\nPWPPPPPPWP\nPPPPWPPPP... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given two matrices A and B. Each matrix contains exactly n rows and m columns. Each element of A is either 0 or 1; each element of B is initially 0.\n\nYou may perform some operations with matrix B. During each op... | [{"type": "stdin_stdout", "input": "5 50\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nVasya will fancy any number as long as it is an integer power of two. Petya, on the other hand, is very conservative and only likes a single integer p (which may be positive, negative, or zero). To combine their tastes, t... | [{"type": "stdin_stdout", "input": "1000000000 -1000\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "1000000010 -1000\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "1010000000 -1000\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "1000000000 1000\n", "output": "16\n"}, {"type": "stdin_stdo... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are planning to buy an apartment in a n-floor building. The floors are numbered from 1 to n from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the b... | [{"type": "stdin_stdout", "input": "10 2\n7 6 15 6 16 18 2 17 17\n12 11 3 10 9 1 10 1 5\n", "output": "0 7 13 18 24 35 36 38 41 46\n"}, {"type": "stdin_stdout", "input": "10 2\n7 6 18 6 16 18 1 17 17\n6 9 3 10 9 1 10 1 5\n", "output": "0 7 13 18 24 35 36 37 40 45 \n"}, {"type": "stdin_stdout", "input": "10 2\n7 6 18 6 ... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nThere are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1).\n\nYou're given k subsets A_1, …, A_k of \\{1, 2, ..., n\\}, such that the intersection of any three subsets is empty. In... | [{"type": "stdin_stdout", "input": "19 5\n1001001001100000110\n2\n2 3\n2\n5 6\n2\n8 9\n5\n12 13 14 15 16\n1\n19\n", "output": "0\n1\n1\n1\n2\n2\n2\n3\n3\n3\n3\n4\n4\n4\n4\n4\n4\n4\n5\n"}, {"type": "stdin_stdout", "input": "8 6\n00110011\n3\n1 3 8\n5\n1 2 5 6 7\n2\n6 8\n2\n3 5\n2\n4 7\n1\n2\n", "output": "1\n1\n1\n1\n1\... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nOnce again, Boris needs the help of Anton in creating a task. This time Anton needs to solve the following problem:\n\nThere are two arrays of integers a and b of length n. It turned out that array a contains only element... | [{"type": "stdin_stdout", "input": "5\n3\n1 -1 0\n1 1 -2\n3\n0 1 1\n0 2 2\n2\n1 -1\n1 44\n2\n-1 0\n-1 -38\n5\n1 1 -1 1 -1\n1 1 -1 1 -1\n", "output": "YES\nNO\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "5\n3\n0 -1 -1\n1 1 -2\n3\n0 1 1\n0 1 2\n2\n1 0\n1 41\n2\n-1 0\n-1 -41\n5\n0 1 -1 1 -1\n0 1 -1 1 -1\n", "out... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given a garland consisting of n lamps. States of the lamps are represented by the string s of length n. The i-th character of the string s_i equals '0' if the i-th lamp is turned off or '1' if the i-th lamp is tur... | [{"type": "stdin_stdout", "input": "6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n1\n1 1\n0\n", "output": "1\n2\n5\n4\n0\n0\n"}, {"type": "stdin_stdout", "input": "6\n9 2\n010001010\n9 3\n111100000\n7 4\n1111111\n10 3\n1001110101\n1 1\n0\n1 1\n0\n", "output": "1\n2\n5\n4\n0\n0\n"}, {"type": "s... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n integers. Indices of the array start from zero (i. e. the first element is a_0, the second one is a_1, and so on).\n\nYou can reverse at most one subarray (continuous subsegment) o... | [{"type": "stdin_stdout", "input": "4\n8\n1 3 3 4 11 6 2 9\n5\n1 2 1 2 1\n10\n5 13 6 5 14 0 4 9 13 5\n4\n0 1 2 1\n", "output": "24\n5\n50\n3\n"}, {"type": "stdin_stdout", "input": "4\n8\n0 4 3 6 11 6 2 9\n5\n1 2 1 2 1\n10\n5 13 6 5 14 0 4 9 13 5\n4\n0 1 2 1\n", "output": "25\n5\n50\n3\n"}, {"type": "stdin_stdout", "inp... | code_stdio |
[
{
"content": "Solve the following coding problem using the programming language python:\n\nZiota 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 d... | [{"type": "stdin_stdout", "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"}, {"type": "stdin_stdout", "input":... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.