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\nOverlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.\n\nArkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dime...
[{"type": "stdin_stdout", "input": "100\n????????????????????????????????????????????????????????????????????????????????????????????????????\n", "output": "Yes"}, {"type": "stdin_stdout", "input": "100\nC?M?M?M?YM??YMYC?MCYMYM??Y??YC?CYC???YM?YM??MYMY?CYCYMYC?YC?C?CYCMY??CMC?YMCMYCYCYMYM?CYM?M?MCMCMY?Y\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou're given a row with n chairs. We call a seating of people \"maximal\" if the two following conditions hold:\n\n 1. There are no neighbors adjacent to anyone seated. \n 2. It's impossible to seat one more person with...
[{"type": "stdin_stdout", "input": "459\n000111000101010000100001001010111110011011010001100101111010111011101110111101111101100101100011011001100110001001111001101000111001011100110100011111011111000010000110010011100110011011111110011100001101001111000100111011001000001011111100110100001001001100101011100001110110100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMehta is a forever alone and desperate guy. He has a crush on N girls of his society. He wants to impress them all and so he needs to do their task collectively.All the girls give him a number which he stores in an array ...
[{"type": "stdin_stdout", "input": "5\n21\n22\n23\n24\n25\n\nELPMAS", "output": "10\n"}, {"type": "stdin_stdout", "input": "5\n21\n22\n27\n24\n25\n\nELPMAS", "output": "10\n"}, {"type": "stdin_stdout", "input": "5\n21\n22\n23\n24\n25\n\nSALPLE", "output": "10\n"}, {"type": "stdin_stdout", "input": "5\n42\n22\n27\n24\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types.\n\n* `0 u v`: Add an edge (u, v).\n* `1 u v`: Print 1 if u and v are in the same connected component, 0 otherwise.\n...
[{"type": "stdin_stdout", "input": "4 7\n0 0 1\n-1 1 1\n-1 2 3\n1 0 1\n1 2 2\n-1 0 3\n-1 1 1", "output": "1\n0\n1\n1\n0\n1\n"}, {"type": "stdin_stdout", "input": "4 7\n0 0 1\n-1 2 1\n-1 2 3\n1 0 1\n1 2 2\n-1 0 3\n-1 1 1", "output": "0\n0\n1\n1\n0\n1\n"}, {"type": "stdin_stdout", "input": "9 7\n1 1 1\n-1 0 1\n-1 2 3\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i. There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\n\...
[{"type": "stdin_stdout", "input": "6 5\n8 6 18 1 4 1\n1 3\n4 0\n4 0\n4 6\n4 6", "output": "3\n"}, {"type": "stdin_stdout", "input": "6 5\n8 6 18 1 4 0\n1 3\n4 0\n4 0\n4 6\n4 6", "output": "4\n"}, {"type": "stdin_stdout", "input": "6 5\n13 6 9 1 2 1\n1 3\n1 1\n4 0\n3 3\n4 6", "output": "2\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action K times:\n\n* If Takahashi has one or more cookies, eat one of his cookies.\n* Otherwise, if Aoki has one or more cookies, eat one of...
[{"type": "stdin_stdout", "input": "498881727339 49011419508 0000000100000", "output": "498881627339 49011419508\n"}, {"type": "stdin_stdout", "input": "498881727339 49011419508 0000001100000", "output": "498880627339 49011419508\n"}, {"type": "stdin_stdout", "input": "498881727339 50858735181 0000001100000", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S consisting of `L` and `R`.\n\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\n\nThe ch...
[{"type": "stdin_stdout", "input": "RLRLLRLRRRRLLLLL", "output": "1 1 2 1 0 1 1 0 0 0 4 5 0 0 0 0\n"}, {"type": "stdin_stdout", "input": "RRRLLRLLRRLRLLLL", "output": "0 0 3 2 0 2 1 0 0 1 2 3 2 0 0 0\n"}, {"type": "stdin_stdout", "input": "RRRLLRLLLRRLLRLL", "output": "0 0 3 2 0 2 2 0 0 0 2 2 0 2 1 0\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:\n\n* The graph is simple and connected.\n* There exists an integer S such that, for ev...
[{"type": "stdin_stdout", "input": "4", "output": "4\n1 2\n1 3\n2 4\n3 4\n"}, {"type": "stdin_stdout", "input": "4", "output": "4\n1 2\n1 3\n2 4\n3 4\n"}, {"type": "stdin_stdout", "input": "3", "output": "2\n1 3\n2 3"}, {"type": "stdin_stdout", "input": "000", "output": "0\n"}, {"type": "stdin_stdout", "input": "001", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPrint all the integers that satisfies the following in ascending order:\n\n* Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.\n\nConstraints\n\n...
[{"type": "stdin_stdout", "input": "0 32 110", "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\n26\n27\n28\n29\n30\n31\n32\n"}, {"type": "stdin_stdout", "input": "8 35 011", "output": "8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n25\n26\n27\n28\n29\n30\n31\n32\n33\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i.\n\nTwo people X and Y will play a game using this deck. Initially, X has a card with Z writte...
[{"type": "stdin_stdout", "input": "1 1 1\n1010000000", "output": "1009999999\n"}, {"type": "stdin_stdout", "input": "1 1 1\n1010100000", "output": "1010099999\n"}, {"type": "stdin_stdout", "input": "3 100 100\n10 1001 000", "output": "1001\n"}, {"type": "stdin_stdout", "input": "1 1 1\n1000000000", "output": "99999999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue o...
[{"type": "stdin_stdout", "input": "5 5 6\n11010\n01110\n10111\n11111\n01010\n1 1 5 5\n1 2 4 5\n2 3 3 5\n3 3 3 2\n3 1 3 5\n1 1 3 4", "output": "-2\n-2\n0\n0\n2\n1\n"}, {"type": "stdin_stdout", "input": "5 5 6\n11010\n01110\n10111\n11111\n01010\n1 1 5 5\n1 2 4 5\n3 3 3 5\n3 3 3 2\n3 1 3 5\n1 1 3 4", "output": "-2\n-2\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?\n\nConstraints\n\n* 0 ≤ a ≤ b ≤ 10^{18}\n* 1 ≤ x ≤ 10^{18}\n\nInput...
[{"type": "stdin_stdout", "input": "-1 1010010100000100000 4", "output": "252502525000025001\n"}, {"type": "stdin_stdout", "input": "-1 1010010110000100000 3", "output": "336670036666700001\n"}, {"type": "stdin_stdout", "input": "-1 1010010111000100000 3", "output": "336670037000033334\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n12:17 (UTC): The sample input 1 and 2 were swapped. The error is now fixed. We are very sorry for your inconvenience.\n\nThere are N children in AtCoder Kindergarten, conveniently numbered 1 through N. Mr. Evi will distri...
[{"type": "stdin_stdout", "input": "4 13\n4 1 2 1\n4 1 10 1", "output": "714238057\n"}, {"type": "stdin_stdout", "input": "4 30\n3 1 1 1\n4 2 10 1", "output": "605469785\n"}, {"type": "stdin_stdout", "input": "4 12\n3 1 2 1\n11 1 5 2", "output": "809171659\n"}, {"type": "stdin_stdout", "input": "4 13\n4 1 2 1\n4 1 12 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe problem of hiding a part of a formula and searching for the hidden number is called verbal arithmetic. This time, I'm dealing with an expression in which some numbers in the expression are hidden by X. Enter the follo...
[{"type": "stdin_stdout", "input": "123+5X6=X79\n12X+4X7=X79\nXX22+89=X2XX", "output": "NA\nNA\nNA\n"}, {"type": "stdin_stdout", "input": "127+5X6=X39\n12X+4X7=X79\nXX22+89=X2XX", "output": "NA\nNA\nNA\n"}, {"type": "stdin_stdout", "input": "127+5X6=X39\n12X+4X7=X79\nXX32+89=X2XX", "output": "NA\nNA\nNA\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakeshi, who loves hot springs, is planning a trip to a hot spring resort on his next long vacation. I would like to travel by connecting to a long-distance bus and reach my destination with as little money as possible. T...
[{"type": "stdin_stdout", "input": "2 1\n1 2 5\n3 2\n1 2 5\n2 3 36\n6 9\n3 2 7\n1 2 14\n2 5 27\n2 6 10\n2 2 21\n4 2 20\n3 5 2\n4 5 12\n4 6 14\n0 0", "output": "5\n0\n0\n"}, {"type": "stdin_stdout", "input": "2 1\n1 2 5\n3 2\n1 2 5\n2 3 36\n6 9\n3 2 7\n1 2 14\n2 5 27\n2 6 10\n2 2 21\n4 2 20\n3 5 2\n4 5 12\n8 6 14\n0 0",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's solve the puzzle by programming.\n\nThe numbers n x n are arranged in a grid pattern. Some of the numbers are circled and we will call them the starting point. The rules of the puzzle are as follows:\n\n* Draw one l...
[{"type": "stdin_stdout", "input": "3\n-3 1 1\n2 -4 1\n2 1 -1\n3\n-2 1 1\n1 0 -6\n1 -5 3\n4\n-8 11 -2 1\n2 -7 -2 2\n1 -1 1 2\n1 1 1 -1\n6\n2 0 3 -7 0 2\n1 -10 1 1 4 2\n2 10 5 2 -6 0\n2 4 -23 2 1 8\n3 3 -8 2 3 7\n-7 2 5 2 -3 -18\n6\n3 2 3 -7 1 2\n1 -10 1 0 3 2\n2 6 5 0 -6 1\n0 4 -23 2 2 5\n4 3 -2 2 3 5\n-7 2 4 1 -5 -12\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a chain consisting of multiple circles on a plane. The first (last) circle of the chain only intersects with the next (previous) circle, and each intermediate circle intersects only with the two neighboring circl...
[{"type": "stdin_stdout", "input": "10\n802 0 10\n814 0 4\n820 1 4\n826 1 4\n832 3 5\n838 9 5\n845 7 3\n849 10 3\n853 14 4\n857 18 3\n3\n0 0 5\n8 0 5\n8 8 5\n3\n0 0 5\n7 3 6\n16 1 5\n9\n-1 3 5\n8 0 8\n19 2 11\n23 14 6\n23 21 6\n23 28 6\n19 40 8\n8 42 8\n0 39 5\n11\n0 0 5\n8 0 5\n18 8 10\n8 16 5\n0 16 5\n-1 24 5\n3 32 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe committee members of the Kitoshima programming contest had decided to use crypto-graphic software for their secret communication. They had asked a company, Kodai Software, to develop cryptographic software that employ...
[{"type": "stdin_stdout", "input": "4\nA\nAMD\nCAT\nDOG\nZ XUW ZVX Z YZT.\n2\nZA\nAY\nZA.\n2\n@A\nBB\nCC.\n16\nA\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\nM\nN\nO\nONMLKJIHGFEDCBA\nA B C D E F G H I J K L M N O ABCDEFGHIJKLMNO.\n0", "output": "A DOG AMD A CAT.\nZA.\nBB.\nO N M L K J I H G F E D C B A ONMLKJIHGFEDCBA.\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBackground\n\nThe kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves lowercase letters as much as programming. Yu-kun ...
[{"type": "stdin_stdout", "input": "13 4\n? a ? ? z a ?\n1 1\n0 2\n2 4\n4 5\n2 6\n0 6", "output": "aaaazab110224\n"}, {"type": "stdin_stdout", "input": "13 2\n? a ? ? z ` ?\n1 1\n0 2\n2 4\n4 5\n2 6\n0 6", "output": "aaaaz`b110224\n"}, {"type": "stdin_stdout", "input": "13 2\n? a ? @ z ` ?\n1 1\n0 2\n2 4\n4 5\n2 6\n0 6"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMaki is a house cat. One day she fortunately came at a wonderful-looking dried fish. Since she felt not hungry on that day, she put it up in her bed. However there was a problem; a rat was living in her house, and he was ...
[{"type": "stdin_stdout", "input": "3\n0 -1 100 001\n60 100 50\n100 110 10\n25 75 50\n4\n0 0 100 000\n50 50 50\n150 50 50\n50 150 50\n150 117 50\n0", "output": "0\n0\n"}, {"type": "stdin_stdout", "input": "3\n0 0 100 101\n60 100 50\n100 100 10\n80 80 50\n4\n0 0 100 100\n50 50 50\n150 50 50\n50 150 50\n150 150 50\n0", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem Statement\n\nMr. Takatsuki, who is planning to participate in the Aizu training camp, has a poor house and always tries to save as much paper as possible. She decided to play a ghost leg with other participants to...
[{"type": "stdin_stdout", "input": "10 4\n4\n3\n1\n2", "output": "3\n"}, {"type": "stdin_stdout", "input": "12 4\n4\n1\n1\n2", "output": "3\n"}, {"type": "stdin_stdout", "input": "10 4\n4\n1\n1\n2", "output": "3\n"}, {"type": "stdin_stdout", "input": "10 4\n4\n3\n1\n3", "output": "3\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nB: Hokkaido University Hard\n\nNote\n\nPlease note that the question settings are the same as question A, except for the constraints.\n\nstory\n\nHomura-chan, who passed Hokkaido University and is excited about the beginn...
[{"type": "stdin_stdout", "input": "3 3\nB.B\nB..\n.BB", "output": "4\n"}, {"type": "stdin_stdout", "input": "2 3\nB.B\nB..\n.BB", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 3\nB-B\n..B\n.BA", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 1\nB-B\n..B\n.BA", "output": "0\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:\n\n* add(s, t, x): add x to as, as+1, ..., at.\n* get(i): output the value of ai.\n\n\n\nNote that the initial values of...
[{"type": "stdin_stdout", "input": "3 5\n0 1 0 1\n0 2 3 2\n0 3 3 3\n1 2\n1 3", "output": "2\n5\n"}, {"type": "stdin_stdout", "input": "3 5\n0 1 2 1\n0 2 3 2\n0 3 3 3\n1 2\n1 3", "output": "3\n5"}, {"type": "stdin_stdout", "input": "6 3\n1 2\n0 1 4 -1\n1 2", "output": "0\n-1\n"}, {"type": "stdin_stdout", "input": "-1 1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has got an undirected graph consisting of n vertices and m edges. This graph doesn't contain any self-loops or multiple edges. Self-loop is an edge connecting a vertex to itself. Multiple edges are a pair of edges s...
[{"type": "stdin_stdout", "input": "100000 3950493829\n", "output": "0 11111\n"}, {"type": "stdin_stdout", "input": "233159 100970714\n", "output": "0 218947\n"}, {"type": "stdin_stdout", "input": "107865 257541069\n", "output": "0 85169\n"}, {"type": "stdin_stdout", "input": "134480 71136624\n", "output": "0 122551\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLunar New Year is approaching, and Bob received a gift from his friend recently — a recursive sequence! He loves this sequence very much and wants to play with it.\n\nLet f_1, f_2, …, f_i, … be an infinite sequence of pos...
[{"type": "stdin_stdout", "input": "26\n150393140 360409816 380562806 954731482 34457876 66727907 376298532 679315200 260466665 597680044 95770656 948689469 209020313 926343072 66801160 426280560 927872284 389224547 492602065 324416078 776983298 191080523 167234113 791882865 365749226 28861923\n755656155 336170357\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a robot staying at X=0 on the Ox axis. He has to walk to X=n. You are controlling this robot and controlling how he goes. The robot has a battery and an accumulator with a solar panel.\n\nThe i-th segment of the ...
[{"type": "stdin_stdout", "input": "100 1 1\n0 0 0 1 1 0 1 0 1 0 1 0 -1 1 0 0 1 1 0 1 2 0 1 1 1 1 1 1 1 0 1 1 1 0 -1 0 0 0 -1 0 1 0 0 1 1 0 1 0 0 1 0 1 1 0 0 1 0 0 0 1 1 1 1 1 0 0 1 0 0 1 0 0 0 0 1 0 0 0 1 1 0 1 1 0 1 1 1 0 1 1 -1 1 1 0 0 1 1 0 1 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "100 1 1\n0 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a consisting of n integers a_1, a_2, ... , a_n.\n\nIn one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert...
[{"type": "stdin_stdout", "input": "2\n5\n3 1 10 4 1\n7\n1 0 1 1 1 2 2\n", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "2\n5\n3 1 10 5 1\n7\n1 0 1 1 1 2 2\n", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "2\n5\n3 1 10 5 1\n7\n1 0 1 1 1 2 4\n", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOld timers of Summer Informatics School can remember previous camps in which each student was given a drink of his choice on the vechorka (late-evening meal). Or may be the story was more complicated?\n\nThere are n stude...
[{"type": "stdin_stdout", "input": "20 4\n1\n1\n1\n1\n1\n2\n2\n2\n2\n2\n3\n3\n3\n3\n3\n4\n4\n4\n4\n4\n", "output": "18\n"}, {"type": "stdin_stdout", "input": "16 12\n1\n1\n1\n2\n2\n4\n3\n3\n3\n4\n4\n4\n5\n5\n6\n6\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "16 12\n1\n1\n1\n2\n2\n4\n3\n3\n3\n4\n4\n4\n5\n1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a system of pipes. It consists of two rows, each row consists of n pipes. The top left pipe has the coordinates (1, 1) and the bottom right — (2, n).\n\nThere are six types of pipes: two types of straight pi...
[{"type": "stdin_stdout", "input": "6\n7\n2323216\n1615124\n1\n3\n4\n2\n13\n24\n2\n12\n34\n3\n536\n345\n2\n46\n101\n", "output": "YES\nYES\nYES\nNO\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "6\n7\n2323216\n1615124\n1\n5\n4\n2\n13\n24\n2\n12\n34\n3\n536\n345\n2\n46\n101\n", "output": "YES\nYES\nYES\nNO\nYES\nNO\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Central Company has an office with a sophisticated security system. There are 10^6 employees, numbered from 1 to 10^6.\n\nThe security system logs entrances and departures. The entrance of the i-th employee is denoted...
[{"type": "stdin_stdout", "input": "20\n384933 946658 407136 242739 -242739 -407136 -946658 -384933 384933 -384933 319281 407136 804861 -407136 415987 946658 -946658 -415987 -804861 -319281\n", "output": "3\n8 2 10 \n"}, {"type": "stdin_stdout", "input": "20\n384933 946658 407136 242739 -242739 -407136 -946658 -384933 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe map of Bertown can be represented as a set of n intersections, numbered from 1 to n and connected by m one-way roads. It is possible to move along the roads from any intersection to any other intersection. The length ...
[{"type": "stdin_stdout", "input": "20 50\n20 3\n5 16\n1 3\n10 11\n10 15\n15 9\n20 9\n14 6\n16 5\n13 4\n11 5\n3 20\n13 17\n11 8\n11 6\n12 14\n16 18\n17 13\n18 7\n3 1\n8 10\n17 15\n7 2\n9 13\n5 11\n6 1\n2 16\n8 18\n10 8\n4 13\n9 15\n14 12\n1 6\n9 20\n7 18\n6 14\n7 6\n18 16\n2 7\n3 11\n15 17\n3 12\n14 10\n4 14\n19 4\n11 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider the infinite sequence s of positive integers, created by repeating the following steps:\n\n 1. Find the lexicographically smallest triple of positive integers (a, b, c) such that \n * a ⊕ b ⊕ c = 0, where ⊕ d...
[{"type": "stdin_stdout", "input": "9\n2\n2\n6\n4\n14\n11\n13\n8\n17\n", "output": "2\n2\n12\n4\n9\n11\n7\n10\n32\n"}, {"type": "stdin_stdout", "input": "9\n2\n2\n3\n4\n10\n12\n12\n8\n11\n", "output": "2\n2\n3\n4\n6\n13\n13\n10\n11\n"}, {"type": "stdin_stdout", "input": "9\n2\n2\n6\n4\n14\n17\n13\n8\n17\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday Johnny wants to increase his contribution. His plan assumes writing n blogs. One blog covers one topic, but one topic can be covered by many blogs. Moreover, some blogs have references to each other. Each pair of bl...
[{"type": "stdin_stdout", "input": "25 50\n25 2\n6 17\n11 4\n3 18\n11 20\n6 7\n24 15\n1 8\n13 5\n12 25\n15 18\n14 21\n13 6\n5 10\n3 14\n1 2\n23 13\n12 20\n6 4\n8 9\n3 5\n10 7\n20 2\n20 18\n7 4\n8 25\n15 6\n24 14\n2 23\n2 13\n11 3\n16 21\n18 10\n22 1\n5 24\n6 18\n22 23\n4 13\n8 18\n5 20\n22 17\n20 7\n19 15\n10 12\n2 3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a_1, a_2, ..., a_n where all a_i are integers and greater than 0.\n\nIn one operation, you can choose two different indices i and j (1 ≤ i, j ≤ n). If gcd(a_i, a_j) is equal to the minimum element o...
[{"type": "stdin_stdout", "input": "4\n1\n8\n6\n4 4 6 6 2 9\n4\n4 5 6 10\n5\n10 10 2 2 4\n", "output": "YES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "4\n1\n8\n6\n4 4 6 6 2 9\n4\n4 5 6 7\n5\n10 10 2 2 4\n", "output": "YES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "4\n1\n8\n6\n4 4 6 6 2 15\n4\n4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a knapsack with the capacity of W. There are also n items, the i-th one has weight w_i. \n\nYou want to put some of these items into the knapsack in such a way that their total weight C is at least half of its si...
[{"type": "stdin_stdout", "input": "3\n1 3\n3\n6 2\n19 8 19 69 9 4\n7 12\n1 1 1 17 1 1 1\n", "output": "1\n1 \n-1\n6\n1 2 3 5 6 7 \n"}, {"type": "stdin_stdout", "input": "3\n1 3\n3\n6 2\n19 8 19 69 9 4\n7 12\n1 1 1 17 1 1 1\n", "output": "1\n1 \n-1\n6\n1 2 3 5 6 7 \n"}, {"type": "stdin_stdout", "input": "3\n1 3\n3\n6 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya organized a strange birthday party. He invited n friends and assigned an integer k_i to the i-th of them. Now Petya would like to give a present to each of them. In the nearby shop there are m unique presents availa...
[{"type": "stdin_stdout", "input": "6\n6 6\n2 3 1 5 6 6\n629717071 992393438 995305242 999968259 999970082 999971487\n6 6\n2 5 2 2 4 3\n756869732 979591024 993778447 1268827656 999873038 999943064\n6 6\n5 1 4 5 6 4\n733550952 979779220 979918868 983712198 991976436 995169050\n6 6\n4 2 2 3 2 4\n257971677 920812339 98100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a multiset S initially consisting of n distinct non-negative integers. A multiset is a set, that can contain some elements multiple times.\n\nYou will perform the following operation k times: \n\n * Add the...
[{"type": "stdin_stdout", "input": "7\n5 1000000000\n4 2 3 0 1\n4 0\n5 2 0 1\n3 0\n100 0 1\n6 1234567\n1 2 3 4 5 0\n3 114514\n8 0 4\n1 1000000\n0\n1 10000000\n1\n", "output": "1000000005\n4\n3\n1234573\n4\n1000001\n1\n"}, {"type": "stdin_stdout", "input": "7\n5 1000000000\n4 2 3 0 1\n4 0\n5 2 0 1\n3 0\n100 0 2\n6 12345...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n points on an infinite plane. The i-th point has coordinates (x_i, y_i) such that x_i > 0 and y_i > 0. The coordinates are not necessarily integer.\n\nIn one move you perform the following operations: \n\n * c...
[{"type": "stdin_stdout", "input": "10\n4 4 2 4\n2 2 1 3\n1 1 2 1\n12 1 5 4\n8 5 2 3\n4 3 3 3\n1 3 2 6\n5 2 3 1\n4 1 2 5\n7 1 5 1\n", "output": "2\n6 1\n8 10\n"}, {"type": "stdin_stdout", "input": "10\n4 4 2 4\n2 2 1 3\n1 1 2 1\n12 1 5 4\n4 5 2 3\n4 6 3 3\n1 3 2 6\n5 2 3 1\n4 1 2 5\n7 1 5 4\n", "output": "2\n1 7\n6 3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLolek and Bolek are about to travel abroad by plane. The local airport has a special \"Choose Your Plane\" offer. The offer's conditions are as follows:\n\n * it is up to a passenger to choose a plane to fly on; \n * if...
[{"type": "stdin_stdout", "input": "510 132\n50 76 77 69 94 30 47 65 14 62 18 121 26 35 49 17 105 93 47 16 78 3 7 74 7 37 30 36 30 83 121 113 7 58 86 10 65 57 34 102 55 44 43 47 106 44 115 75 109 70 47 45 16 57 62 55 20 88 74 40 45 84 41 1 9 53 65 25 67 31 115 2 63 51 123 70 65 65 18 14 75 14 103 26 117 105 36 104 81 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSereja has a sequence that consists of n positive integers, a1, a2, ..., an. \n\nFirst Sereja took a piece of squared paper and wrote all distinct non-empty non-decreasing subsequences of sequence a. Then for each sequenc...
[{"type": "stdin_stdout", "input": "42\n18468 6335 26501 20291 15725 11479 29359 26963 24465 5706 28146 23282 16828 9962 492 2996 11943 4828 5437 32392 14605 3903 154 293 12383 17422 18717 19719 19896 5448 21727 14772 11539 1870 19913 25668 26300 17036 9895 28704 23812 31323\n", "output": "226510822\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPaladin Manao caught the trail of the ancient Book of Evil in a swampy area. This area contains n settlements numbered from 1 to n. Moving through the swamp is very difficult, so people tramped exactly n - 1 paths. Each o...
[{"type": "stdin_stdout", "input": "50 2 5\n9 14\n46 34\n40 35\n44 30\n32 16\n1 38\n48 2\n17 14\n50 25\n6 1\n45 19\n21 15\n22 11\n15 33\n8 28\n2 32\n10 22\n37 3\n43 39\n25 16\n9 19\n16 3\n28 32\n20 45\n24 32\n4 18\n49 39\n13 45\n26 4\n11 33\n14 37\n42 19\n31 45\n38 3\n34 8\n18 29\n35 34\n29 16\n7 46\n19 28\n27 33\n30 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub wants to enhance his multitasking abilities. In order to do this, he wants to sort n arrays simultaneously, each array consisting of m integers.\n\nIahub can choose a pair of distinct indices i and j (1 ≤ i, j ≤ m, ...
[{"type": "stdin_stdout", "input": "2 9 1\n836096 600367 472071 200387 79763\n863406 505282 233544 157810 152591\n", "output": "36\n2 1\n3 1\n4 1\n5 1\n6 1\n7 1\n8 1\n9 1\n3 2\n4 2\n5 2\n6 2\n7 2\n8 2\n9 2\n4 3\n5 3\n6 3\n7 3\n8 3\n9 3\n5 4\n6 4\n7 4\n8 4\n9 4\n6 5\n7 5\n8 5\n9 5\n7 6\n8 6\n9 6\n8 7\n9 7\n9 8\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.\n\nThere are n columns of toy cubes in the b...
[{"type": "stdin_stdout", "input": "100\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 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider a football tournament where n teams participate. Each team has two football kits: for home games, and for away games. The kit for home games of the i-th team has color xi and the kit for away games of this team h...
[{"type": "stdin_stdout", "input": "30\n25 8\n25 4\n21 9\n25 1\n7 16\n23 21\n22 17\n27 29\n7 29\n20 3\n13 23\n7 13\n16 18\n25 14\n13 17\n28 15\n10 23\n25 18\n2 3\n23 13\n30 8\n13 15\n20 15\n11 29\n10 23\n5 16\n4 14\n4 30\n7 20\n11 1\n", "output": "29 29\n31 27\n29 29\n29 29\n30 28\n30 28\n29 29\n29 29\n29 29\n29 29\n31...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDreamoon likes to play with sets, integers and <image>. <image> is defined as the largest positive integer that divides both a and b.\n\nLet S be a set of exactly four distinct integers greater than 0. Define S to be of r...
[{"type": "stdin_stdout", "input": "3081 11\n", "output": "203335\n11 22 33 55\n77 88 99 121\n143 154 165 187\n209 220 231 253\n275 286 297 319\n341 352 363 385\n407 418 429 451\n473 484 495 517\n539 550 561 583\n605 616 627 649\n671 682 693 715\n737 748 759 781\n803 814 825 847\n869 880 891 913\n935 946 957 979\n1001 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA new e-mail service \"Berlandesk\" is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that's why they ask you to help. You're suggested to impl...
[{"type": "stdin_stdout", "input": "10\nzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzzzzzz\nzzzzzzzzzzzzzzzzzzzzzzz...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPasha got a very beautiful string s for his birthday, the string consists of lowercase Latin letters. The letters in the string are numbered from 1 to |s| from left to right, where |s| is the length of the given string.\n...
[{"type": "stdin_stdout", "input": "xwcxggxvfqbdklewbxkjzibmufnaywuxsqvwakefxbbkfandvigasbhbatsxyqxicrosatfsfybedklsaztyyiuurfbrzmwumujy\n100\n14 43 30 13 8 19 33 7 16 14 15 35 5 18 44 1 35 1 18 7 50 47 9 49 28 29 39 37 27 17 19 12 5 24 37 42 37 23 35 31 10 26 5 38 40 34 42 47 2 40 43 32 16 25 14 45 35 38 46 48 49 27 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA tree of size n is an undirected connected graph consisting of n vertices without cycles.\n\nConsider some tree with n vertices. We call a tree invariant relative to permutation p = p1p2... pn, if for any two vertices of...
[{"type": "stdin_stdout", "input": "11\n7 3 5 2 10 1 9 6 8 4 11\n", "output": "YES\n11 1\n11 2\n11 3\n11 4\n11 5\n11 6\n11 7\n11 8\n11 9\n11 10\n"}, {"type": "stdin_stdout", "input": "8\n1 2 6 4 5 7 8 3\n", "output": "YES\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n"}, {"type": "stdin_stdout", "input": "6\n2 1 6 5 3 4\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMarina loves Sasha. But she keeps wondering whether Sasha loves her. Of course, the best way to know it is fortune telling. There are many ways of telling fortune, but Marina has picked the easiest one. She takes in her h...
[{"type": "stdin_stdout", "input": "100\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 99 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply this time machine to a well-known data structure: multiset.\n\nArtem want...
[{"type": "stdin_stdout", "input": "10\n1 1 1000000000\n1 4 1000000000\n2 2 1000000000\n1 5 1000000000\n1 8 1000000000\n2 15 1000000000\n3 3 1000000000\n3 10 1000000000\n3 6 1000000000\n3 7 1000000000\n", "output": "0\n3\n2\n2\n"}, {"type": "stdin_stdout", "input": "20\n1 1 1\n1 2 2\n1 3 3\n1 4 4\n1 5 5\n2 4 5\n2 12 4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, on a programming lesson little Petya showed how quickly he can create files and folders on the computer. But he got soon fed up with this activity, and he decided to do a much more useful thing. He decided to ca...
[{"type": "stdin_stdout", "input": "C:<span class=\"tex-span\">\\</span>folder1<span class=\"tex-span\">\\</span>folder2<span class=\"tex-span\">\\</span>folder3<span class=\"tex-span\">\\</span>file1.txt\nC:<span class=\"tex-span\">\\</span>folder1<span class=\"tex-span\">\\</span>folder2<span class=\"tex-span\">\\</s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nn hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as po...
[{"type": "stdin_stdout", "input": "1000000000 1000000000 1000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "100000000 999834114 93836827\n", "output": "29998\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000010 1000000000\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "100000000 9998...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Vasya likes very much to play with sets consisting of positive integers. To make the game more interesting, Vasya chose n non-empty sets in such a way, that no two of them have common elements.\n\nOne day he wanted...
[{"type": "stdin_stdout", "input": "10\n2 32 157\n2 86 157\n2 86 32\n2 154 157\n2 32 154\n2 86 154\n2 157 38\n2 32 38\n2 38 86\n2 38 154\n2 69 157\n2 69 32\n2 69 86\n2 69 154\n2 38 69\n2 172 157\n2 32 172\n2 86 172\n2 172 154\n2 172 38\n2 69 172\n2 157 110\n2 32 110\n2 86 110\n2 154 110\n2 110 38\n2 110 69\n2 172 110\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has an array of integers of length n.\n\nVasya performs the following operations on the array: on each step he finds the longest segment of consecutive equal integers (the leftmost, if there are several such segment...
[{"type": "stdin_stdout", "input": "100\n45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 69 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is winter now, and Max decided it's about time he watered the garden.\n\nThe garden can be represented as n consecutive garden beds, numbered from 1 to n. k beds contain water taps (i-th tap is located in the bed xi), ...
[{"type": "stdin_stdout", "input": "1\n177 99\n1 4 7 10 11 13 14 15 16 17 19 21 22 24 25 26 27 28 32 34 35 38 39 40 42 45 46 52 54 55 57 58 59 60 62 64 65 67 70 71 74 77 78 79 80 81 83 84 88 92 93 94 95 100 101 102 104 106 107 108 109 110 112 113 114 115 116 118 122 123 124 125 127 128 129 130 134 135 137 138 139 140 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence of n positive integers d1, d2, ..., dn (d1 < d2 < ... < dn). Your task is to construct an undirected graph such that:\n\n * there are exactly dn + 1 vertices; \n * there are no self-loops; \n *...
[{"type": "stdin_stdout", "input": "100\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAllen wants to enter a fan zone that occupies a round square and has n entrances.\n\nThere already is a queue of a_i people in front of the i-th entrance. Each entrance allows one person from its queue to enter the fan zo...
[{"type": "stdin_stdout", "input": "30\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 10000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA square pyramid of balls consists of square layers of balls stacked on top of each other. The i th (1-based indexing )layer from the top consists of exactly i^2 balls. Image\n\nYou have received one such beautiful square...
[{"type": "stdin_stdout", "input": "100\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 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nXenny had N numbers and he loved equal triplets (An equal triplet is group of 3 numbers that are equal).\nHe defined a K-equal-triplet as a triplet in which all 3 integers were equal to K.\nGiven an integer K, he wanted t...
[{"type": "stdin_stdout", "input": "1\n4 10\n-1 7 4 3 -1\n\nSAMQLE", "output": "0/1\n"}, {"type": "stdin_stdout", "input": "1\n5 12\n1 4 4 4 -1\n\nSAMPLE", "output": "0/1\n"}, {"type": "stdin_stdout", "input": "1\n5 12\n1 4 4 6 -1\n\nSAMPLE", "output": "0/1\n"}, {"type": "stdin_stdout", "input": "1\n5 12\n1 4 4 4 -1\n\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a rooted binary tree with N vertices, where the vertices are numbered 1 to N. Vertex 1 is the root, and the parent of Vertex i (i \\geq 2) is Vertex \\left[ \\frac{i}{2} \\right].\n\nEach vertex has one item in it...
[{"type": "stdin_stdout", "input": "15\n123 119\n129 120\n132 112\n126 109\n118 103\n115 109\n102 100\n130 120\n105 105\n132 115\n104 102\n107 107\n127 116\n121 104\n121 115\n8\n8 234\n9 244\n10 226\n11 227\n12 240\n13 237\n14 206\n15 227", "output": "256\n255\n250\n247\n255\n259\n223\n253"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have A balls with the string S written on each of them and B balls with the string T written on each of them.\nFrom these balls, Takahashi chooses one with the string U written on it and throws it away.\nFind the numbe...
[{"type": "stdin_stdout", "input": "red blue\n11 -1\nred", "output": "10 -1\n"}, {"type": "stdin_stdout", "input": "red blue\n11 -2\nred", "output": "10 -2\n"}, {"type": "stdin_stdout", "input": "red bleu\n12 -1\nred", "output": "11 -1\n"}, {"type": "stdin_stdout", "input": "red bulf\n-2 -1\nred", "output": "-3 -1\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is going to buy N items one by one.\n\nThe price of the i-th item he buys is A_i yen (the currency of Japan).\n\nHe has M discount tickets, and he can use any number of them when buying an item.\n\nIf Y tickets ...
[{"type": "stdin_stdout", "input": "10 -1\n1000100000 1000100000 1110000000 1100000000 1000001000 1000000000 1000000000 1010010001 1000000001 1100000000", "output": "10320211002\n"}, {"type": "stdin_stdout", "input": "10 0\n1000100000 1000100000 1110000000 1100000000 1000001000 1000000000 1000000000 1010010000 10000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes:\n\n* Red boxes, each containing R red balls\n* Green boxes, each containing G green balls\n* Blue boxes, eac...
[{"type": "stdin_stdout", "input": "13 2 1 3000", "output": "174001\n"}, {"type": "stdin_stdout", "input": "13 1 1 3000", "output": "347886\n"}, {"type": "stdin_stdout", "input": "13 2 1 3118", "output": "187920\n"}, {"type": "stdin_stdout", "input": "22 2 1 3118", "output": "111399\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer sequence of length N: A_1,A_2,...,A_N. Let us perform Q operations in order. The i-th operation is described by two integers X_i and Y_i. In this operation, we will choose one of the following two...
[{"type": "stdin_stdout", "input": "16 0\n6\n2\n2\n-1\n4\n-1\n-1\n1\n1\n5 8\n13 14\n9 5\n8 3\n1 16", "output": "33\n"}, {"type": "stdin_stdout", "input": "9 0\n6\n2\n2\n-1\n4\n-1\n-1\n1\n1\n5 8\n13 14\n9 5\n8 3\n1 16", "output": "22\n"}, {"type": "stdin_stdout", "input": "9 5\n3\n2\n2\n1\n13\n11\n-1\n1\n1\n3 5\n15 9\n9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi and Aoki love calculating things, so they will play with numbers now.\n\nFirst, they came up with one positive integer each. Takahashi came up with X, and Aoki came up with Y. Then, they will enjoy themselves by...
[{"type": "stdin_stdout", "input": "10 10 14\n1100110011\n1011001101", "output": "100001000000000010001000\n100001000000000000100010\n"}, {"type": "stdin_stdout", "input": "10 10 14\n1110110011\n1011001101", "output": "100001000000000100001000\n100001000000000000100010\n"}, {"type": "stdin_stdout", "input": "10 10 14\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke is giving cookies to his three goats.\n\nHe has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins)....
[{"type": "stdin_stdout", "input": "-4 -10", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "-1 14", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "-2 28", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "-2 40", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "-1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSmeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.\n\nYou are given Smeke's current rating, x. Print `AB...
[{"type": "stdin_stdout", "input": "0000", "output": "ABC\n"}, {"type": "stdin_stdout", "input": "2936", "output": "ARC\n"}, {"type": "stdin_stdout", "input": "0100", "output": "ABC\n"}, {"type": "stdin_stdout", "input": "1432", "output": "ARC\n"}, {"type": "stdin_stdout", "input": "1100", "output": "ABC\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro Aizu's company has a boss who hates being indivisible. When Taro goes out to eat with his boss, he pays by splitting the bill, but when the payment amount is not divisible by the number of participants, his boss alwa...
[{"type": "stdin_stdout", "input": "4 15000\n520\n41\n129\n500\n3 1047\n6\n20\n25\n3 359208\n5\n14\n17\n0 0", "output": "14983\n1039\n359207\n"}, {"type": "stdin_stdout", "input": "4 15000\n305\n260\n136\n500\n3 400\n10\n23\n30\n3 599838\n5\n1\n12\n0 0", "output": "14983\n397\n599831\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA plurality of trampolines are arranged in a line at 10 m intervals. Each trampoline has its own maximum horizontal distance within which the jumper can jump safely. Starting from the left-most trampoline, the jumper jump...
[{"type": "stdin_stdout", "input": "4\n163\n51\n2\n32", "output": "yes\n"}, {"type": "stdin_stdout", "input": "4\n001\n103\n-1\n0", "output": "no\n"}, {"type": "stdin_stdout", "input": "4\n001\n136\n-1\n0", "output": "no\n"}, {"type": "stdin_stdout", "input": "4\n001\n155\n-1\n0", "output": "no\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Ohgas are a prestigious family based on Hachioji. The head of the family, Mr. Nemochi Ohga, a famous wealthy man, wishes to increase his fortune by depositing his money to an operation company. You are asked to help M...
[{"type": "stdin_stdout", "input": "4\n1000000\n8\n2\n0 0.7358189007888192 3000\n1 0.17615020446016216 3825\n6620000\n7\n2\n0 0.6920348397011968 48227\n0 0.0740966796875 40942\n56271855\n4\n4\n0 0.19624457693261887 30754\n1 0.00634765625 26165\n0 1.6296802800223897 27575\n0 0.8924194187554844 10932\n6380784\n0\n4\n1 0....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHere is a very simple variation of the game backgammon, named “Minimal Backgammon”. The game is played by only one player, using only one of the dice and only one checker (the token used by the player).\n\nThe game board ...
[{"type": "stdin_stdout", "input": "10 1 0 0\n7 1 0 0\n13 0 0 0\n6 11 1 1\n2\n5\n7 1 0 6\n1\n1\n3\n4\n5\n6\n0 0 0 0", "output": "0.000000\n0.000000\n0.000000\n0.829031\n0.000000\n"}, {"type": "stdin_stdout", "input": "6 1 0 0\n7 1 0 0\n7 2 0 0\n12 3 1 1\n2\n5\n8 10 0 6\n1\n3\n4\n4\n5\n6\n0 0 0 0", "output": "0.166667\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<!--\n\nProblem C\n\n-->\n\nBalance Scale\n\nYou, an experimental chemist, have a balance scale and a kit of weights for measuring weights of powder chemicals.\n\nFor work efficiency, a single use of the balance scale sho...
[{"type": "stdin_stdout", "input": "4 2\n9 2 7 21\n2 9\n6 2\n1 3 6 12 16 16\n2 9\n5 2\n7 3 6 12 11\n2 8\n7 5\n15 16 88 48 51 75 111\n36 54 57 148 102\n0 0", "output": "10\n-1\n-1\n2\n"}, {"type": "stdin_stdout", "input": "4 2\n9 2 7 11\n2 9\n6 2\n1 3 12 12 16 9\n2 9\n5 2\n7 3 6 12 11\n2 8\n7 5\n15 16 57 48 51 75 111\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMiki is a high school student. She has a part time job, so she cannot take enough sleep on weekdays. She wants to take good sleep on holidays, but she doesn't know the best length of sleeping time for her. She is now tryi...
[{"type": "stdin_stdout", "input": "15 -1 0\n3.507493431634293\n1.3168078857315408\n0.8923013066938583", "output": "-5115018.0145617081\n"}, {"type": "stdin_stdout", "input": "15 -1 0\n2.5963136238190727\n1.3168078857315408\n0.4906502505511706", "output": "1186.1864007578\n"}, {"type": "stdin_stdout", "input": "15 -1 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nB: Periodic Sequence-\n\nproblem\n\nDr. Period, a professor at H University, is studying a property called the cycle that is supposed to be hidden in all things. As a generally known basic cycle, a cycle hidden in a seque...
[{"type": "stdin_stdout", "input": "6\n-1 -14 10 -3 2 -1", "output": "1\n"}, {"type": "stdin_stdout", "input": "6\n-1 -14 18 -3 2 -1", "output": "1\n"}, {"type": "stdin_stdout", "input": "6\n-1 -14 18 -1 2 -1", "output": "1\n"}, {"type": "stdin_stdout", "input": "6\n-1 -10 18 -1 2 -1", "output": "1\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given two segments s1 and s2, print \"1\" if they are intersect, \"0\" otherwise.\n\ns1 is formed by end points p0 and p1, and s2 is formed by end points p2 and p3.\n\nConstraints\n\n* 1 ≤ q ≤ 1000\n* -10000 ≤ xpi, yp...
[{"type": "stdin_stdout", "input": "3\n-1 0 0 -1 2 1 4 -2\n1 -1 -1 0 4 2 6 -1\n0 -1 6 1 0 -2 5 0", "output": "0\n0\n0\n"}, {"type": "stdin_stdout", "input": "3\n-1 0 -1 -1 2 1 4 -2\n1 0 0 0 4 1 6 -1\n0 -1 12 1 1 -2 0 0", "output": "0\n0\n1\n"}, {"type": "stdin_stdout", "input": "3\n-1 0 0 -1 2 1 4 -2\n1 0 0 0 4 1 6 -1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a given sequence of integers $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$, perform the following operations.\n\n* count($b, e, k$): print the number of the specific values $k$ in $a_b, a_{b+1}, ..., a_{e-1}$.\n\nConstraints...
[{"type": "stdin_stdout", "input": "9\n1 4 1 4 2 1 3 5 6\n12\n2 9 1\n2 6 1\n3 7 5", "output": "2\n2\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "9\n1 4 1 4 4 -1 4 5 6\n8\n0 9 1\n1 12 1\n3 7 9", "output": "2\n1\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "9\n6 4 0 4 4 -1 3 5 6\n8\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne of Arkady's friends works at a huge radio telescope. A few decades ago the telescope has sent a signal s towards a faraway galaxy. Recently they've received a response t which they believe to be a response from aliens...
[{"type": "stdin_stdout", "input": "01\nzbrronwaofovklkopelo\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "01\nzbrronwaofovklkopeln\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "01\nzbrrnnwaofovklkopeln\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "01\nzbrrnnwaofovklkopelo\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe German University in Cairo (GUC) dorm houses are numbered from 1 to n. Underground water pipes connect these houses together. Each pipe has certain direction (water can flow only in this direction and not vice versa),...
[{"type": "stdin_stdout", "input": "44 42\n4 37 166\n34 25 47\n28 19 367\n20 14 811\n8 3 878\n39 1 925\n35 9 206\n32 18 1008\n16 44 503\n5 20 426\n22 34 896\n44 43 471\n17 33 577\n40 22 317\n24 31 818\n37 11 292\n21 39 888\n6 8 983\n43 36 170\n11 21 662\n36 17 942\n18 7 356\n2 32 220\n12 5 774\n19 27 193\n13 40 63\n15 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInaka has a disc, the circumference of which is n units. The circumference is equally divided by n points numbered clockwise from 1 to n, such that points i and i + 1 (1 ≤ i < n) are adjacent, and so are points n and 1.\n...
[{"type": "stdin_stdout", "input": "30000 28\n10601 1119\n11119 20601\n9493 25771\n14351 4869\n13101 3619\n23101 13619\n29869 9351\n6119 15601\n3101 23619\n1851 22369\n11851 2369\n8619 18101\n19579 20882\n18619 28101\n16851 7369\n8101 28619\n24869 4351\n24351 14869\n27369 6851\n9869 19351\n5601 26119\n3976 21301\n21851...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToad Pimple has an array of integers a_1, a_2, …, a_n.\n\nWe say that y is reachable from x if x<y and there exists an integer array p such that x = p_1 < p_2 < … < p_k=y, and a_{p_i} \\& a_{p_{i+1}} > 0 for all integer...
[{"type": "stdin_stdout", "input": "5 3\n1 3 -1 2 -1\n1 2\n2 5\n1 4\n", "output": "Shi\nShi\nShi\n"}, {"type": "stdin_stdout", "input": "5 3\n1 3 -1 2 -1\n1 2\n2 5\n1 5\n", "output": "Shi\nShi\nShi\n"}, {"type": "stdin_stdout", "input": "5 3\n1 3 -1 2 1\n1 3\n2 4\n1 4\n", "output": "Shi\nShi\nShi\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings of equal length s and t consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.\n\nDuring each operation you choose two adjacent characters...
[{"type": "stdin_stdout", "input": "3\nxabb\naabx\ntechnocup\ntechnocup\na\nz\n", "output": "YES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "3\nxabb\naabx\nteohnccup\ntechnocup\na\nz\n", "output": "YES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "3\nxabb\naabx\ntdohnccup\ntechnocup\na\nz\n", "output": "YES\nYE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n seats in the train's car and there is exactly one passenger occupying every seat. The seats are numbered from 1 to n from left to right. The trip is long, so each passenger will become hungry at some moment of...
[{"type": "stdin_stdout", "input": "100 1000000000\n12 803 439 1031 435 300 497 520 718 573 782 523 328 88 275 159 128 389 920 869 503 80 490 289 22 889 353 799 29 131 1138 123 405 221 727 135 248 348 299 833 19 943 471 410 635 626 784 1205 213 724 550 437 860 536 718 173 406 832 520 748 512 29 466 982 574 848 11 693 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDaisy is a senior software engineer at RainyDay, LLC. She has just implemented three new features in their product: the first feature makes their product work, the second one makes their product fast, and the third one ma...
[{"type": "stdin_stdout", "input": "16\n1 1 1\n1 1 0\n1 1 0\n1 1 0\n1 1 0\n1 0 1\n1 0 1\n1 0 1\n1 0 1\n0 1 1\n0 1 1\n0 1 1\n0 1 1\n1 1 1\n1 1 1\n1 1 1\n1 1 1\n0 0 0\n1 0 0\n0 1 0\n1 1 0\n0 0 0\n1 0 0\n0 0 1\n1 0 1\n0 0 0\n0 1 0\n0 0 1\n0 1 1\n1 0 0\n0 1 0\n0 0 1\n", "output": "Possible\n1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is a frequent user of the very popular messenger. He's chatting with his friends all the time. He has n friends, numbered from 1 to n.\n\nRecall that a permutation of size n is an array of size n such that each i...
[{"type": "stdin_stdout", "input": "100 100\n82 51 81 14 37 17 78 92 64 15 8 86 89 8 87 77 66 10 15 12 100 25 92 47 21 78 20 63 13 49 41 36 41 79 16 87 87 69 1 76 80 60 100 49 70 59 72 8 38 71 15 97 71 14 76 90 81 4 59 46 39 28 92 3 28 22 53 99 59 52 74 43 92 43 42 23 44 9 82 47 7 48 12 12 3 55 37 71 46 22 84 52 98 41 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two positive integers n and k. Print the k-th positive integer that is not divisible by n.\n\nFor example, if n=3, and k=7, then all numbers that are not divisible by 3 are: 1, 2, 4, 5, 7, 8, 10, 11, 13 .......
[{"type": "stdin_stdout", "input": "6\n2 7\n4 12\n2 1000000000\n7 97\n1000000000 1000000000\n2 1\n", "output": "\n13\n\n15\n\n1999999999\n\n113\n\n1000000001\n\n1\n"}, {"type": "stdin_stdout", "input": "6\n2 7\n4 12\n4 1000000000\n7 97\n1000000000 1000000000\n2 1\n", "output": "\n13\n\n15\n\n1333333333\n\n113\n\n100000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA new agent called Killjoy invented a virus COVID-2069 that infects accounts on Codeforces. Each account has a rating, described by an integer (it can possibly be negative or very large).\n\nKilljoy's account is already i...
[{"type": "stdin_stdout", "input": "7\n2 7\n7 1313\n2 14\n8 1211\n2 9\n12 121\n2 121\n121 312\n2 121\n136 121\n2 7\n1313 7\n2 8\n1211 8\n", "output": "1\n2\n2\n1\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "7\n2 7\n7 1313\n2 8\n8 1211\n2 9\n12 121\n2 121\n121 312\n2 121\n312 121\n2 7\n1313 7\n2 8\n1211 8\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChef Monocarp has just put n dishes into an oven. He knows that the i-th dish has its optimal cooking time equal to t_i minutes.\n\nAt any positive integer minute T Monocarp can put no more than one dish out of the oven. ...
[{"type": "stdin_stdout", "input": "1\n200\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 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\nPolycarp has a favorite sequence a[1 ... n] consisting of n integers. He wrote it out on the whiteboard as follows:\n\n * he wrote the number a_1 to the left side (at the beginning of the whiteboard); \n * he wrote the ...
[{"type": "stdin_stdout", "input": "6\n7\n1324 4 5 2 9 1 1\n4\n9 2 7 1\n11\n8 4 3 1 2 7 8 7 9 4 2\n1\n42\n2\n11 7\n8\n1 1 1 1 1 1 1 1\n", "output": "1324 1 4 1 5 9 2 \n9 1 2 7 \n8 2 4 4 3 9 1 7 2 8 7 \n42 \n11 7 \n1 1 1 1 1 1 1 1 \n"}, {"type": "stdin_stdout", "input": "6\n7\n1324 4 5 3 9 1 1\n4\n9 4 7 2\n11\n15 4 5 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSuppose you are living with two cats: A and B. There are n napping spots where both cats usually sleep.\n\nYour cats like to sleep and also like all these spots, so they change napping spot each hour cyclically: \n\n * C...
[{"type": "stdin_stdout", "input": "7\n2 1\n2 2\n3 1\n3 2\n3 3\n5 5\n69 1337\n", "output": "\n1\n2\n1\n3\n2\n2\n65\n"}, {"type": "stdin_stdout", "input": "7\n2 1\n2 2\n3 1\n3 2\n3 3\n5 5\n69 1154\n", "output": "1\n2\n1\n3\n2\n2\n14\n"}, {"type": "stdin_stdout", "input": "7\n2 1\n2 2\n3 1\n3 2\n5 3\n5 5\n69 1154\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY came up with another splendid problem for the ABBYY Cup participants! This time the Beaver invites the contest participants to check out a problem on sorting documents by their subjects. Let's ...
[{"type": "stdin_stdout", "input": "7000\nTREASURY BALANCES AT FED FELL ON MARCH 27\nWASHINGTON, March 30 - Treasury balances at the Federal\nReserve fell on March 27 to 2.424 billion dlrs from 2.508\nbillion dlrs on the previous business day, the Treasury said in\nsti latest budget statement.\nBalances in tax and loan...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVictor and Peter are playing hide-and-seek. Peter has hidden, and Victor is to find him. In the room where they are playing, there is only one non-transparent wall and one double-sided mirror. Victor and Peter are points ...
[{"type": "stdin_stdout", "input": "-7366 1446\n-7727 -1428\n-2680 -3822 -5191 -5553\n-7304 -6313 -9229 1377\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "-4752 -3262\n-4582 6436\n-8997 -6490 -4630 1426\n-9865 -6697 -2371 -5622\n", "output": "YES"}, {"type": "stdin_stdout", "input": "-4752 -3262\n-4582 643...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the proj...
[{"type": "stdin_stdout", "input": "110 5\n- 60\n- 58\n+ 25\n- 32\n+ 86\n", "output": "105\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 31 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 59 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a game called \"I Wanna Be the Guy\", consisting of n levels. Little X and his friend Little Y are addicted to the game. Each of them wants to pass the whole game.\n\nLittle X can pass only p levels of the game. ...
[{"type": "stdin_stdout", "input": "100\n75 83 69 73 30 76 37 48 14 41 42 21 35 15 50 61 86 85 46 3 31 13 78 10 2 44 80 95 56 82 38 75 77 4 99 9 84 53 12 11 36 74 39 72 43 89 57 28 54 1 51 66 27 22 93 59 68 88 91 29 7 20 63 8 52 23 64 58 100 79 65 49 96 71 33 45\n83 50 89 73 34 28 99 67 77 44 19 60 68 42 8 27 94 85 14 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSomeday, Drazil wanted to go on date with Varda. Drazil and Varda live on Cartesian plane. Drazil's home is located in point (0, 0) and Varda's home is located in point (a, b). In each step, he can move in a unit distance...
[{"type": "stdin_stdout", "input": "-1000000000 -1000000000 2000000000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "-1000000000 1000000000 2000000000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "-1000000000 -1000000000 1000000000\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "-100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRikhail Mubinchik believes that the current definition of prime numbers is obsolete as they are too complex and unpredictable. A palindromic number is another matter. It is aesthetically pleasing, and it has a number of r...
[{"type": "stdin_stdout", "input": "10000 239\n", "output": "1168638\n"}, {"type": "stdin_stdout", "input": "10000 1538\n", "output": "11620"}, {"type": "stdin_stdout", "input": "11275 615\n", "output": "263862"}, {"type": "stdin_stdout", "input": "10100 1538\n", "output": "11940"}, {"type": "stdin_stdout", "input": "1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA schoolboy named Vasya loves reading books on programming and mathematics. He has recently read an encyclopedia article that described the method of median smoothing (or median filter) and its many applications in scienc...
[{"type": "stdin_stdout", "input": "168\n0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array a with n elements. Each element of a is either 0 or 1.\n\nLet's denote the length of the longest subsegment of consecutive elements in a, consisting of only numbers one, as f(a). You can change no m...
[{"type": "stdin_stdout", "input": "10 5\n0 0 1 0 0 1 1 0 1 1\n", "output": "10\n1 1 1 1 1 1 1 1 1 1 "}, {"type": "stdin_stdout", "input": "10 2\n1 0 0 1 0 1 0 1 0 1\n", "output": "5\n1 0 0 1 1 1 1 1 0 1 "}, {"type": "stdin_stdout", "input": "10 3\n0 0 1 0 0 1 0 0 1 1\n", "output": "6\n0 0 1 0 1 1 1 1 1 1 "}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSmall, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead.\n\nAs you may know, th...
[{"type": "stdin_stdout", "input": "5 5\nW G B W G\nG B W G B\nB W G B W\nW G B W G\nG B W G B\n", "output": "#Black&White\n"}, {"type": "stdin_stdout", "input": "5 5\nW G B Y M\nG B Y M C\nB Y M C W\nY M C W G\nM C W G B\n", "output": "#Color\n"}, {"type": "stdin_stdout", "input": "5 5\nW G B Y M\nG B Y M C\nB Y M C W...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string \...
[{"type": "stdin_stdout", "input": "33\nnkgcmrfvxe\nvxenkgcmrf\nrfvxenkgcm\nvxenkgcmrf\nxenkgcmrfv\nenkgcmrfvx\nenkgcmrfvx\nnkgcmrfvxe\nkgcmrfvxen\ncmrfvxenkg\ncmrfvxenkg\nxenkgcmrfv\nrfvxenkgcm\nrfvxenkgcm\nnkgcmrfvxe\nxenkgcmrfv\nrfvxenkgcm\nxenkgcmrfv\nxenkgcmrfv\ngcmrfvxenk\nmrfvxenkgc\nfvxenkgcmr\nvxenkgcmrf\nenkg...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After starting from the point x = 0, it reaches the point x = a, immediately turns back and then moves to the point x = 0. After returning ...
[{"type": "stdin_stdout", "input": "1000000 1000000000 999999 10000\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "1000000 1000000 500000 10000\n", "output": "10000\n"}, {"type": "stdin_stdout", "input": "1000000 1100000 500000 10000\n", "output": "10000\n"}, {"type": "stdin_stdout", "input": "1000000 150000...
code_stdio