messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a.\n\nThen, by using a random generator they choose a random integer c in the range between 1 and n (any integer... | [{"input": "1000000000 1000000000\n", "output": "999999999\n"}, {"input": "1000000000 1000000000\n", "output": "999999999"}, {"input": "1000000000 100000000\n", "output": "100000001\n"}, {"input": "1000000000 500000000\n", "output": "500000001\n"}, {"input": "1199670843 346250868\n", "output": "346250869\n"}, {"input":... | code_stdio |
[
{
"content": "Nathan O. Davis is trying to capture a game and struggling to get a very rare item. This rare item can be obtained by arranging special patterns in a row on a casino slot machine. The slot machine has N reels, and pressing the button once stops the currently rotating leftmost reel. Therefore, you ... | [{"input": "1 5 7 11 10\n11\n2 5 5 11 10\n2 4\n2 1 1 256 0\n128 255\n2 0 0 1 0\n1234 5678\n2 1 1 100 0\n99 98\n2 1 1 100 0\n99 99\n2 1 1 10000 0\n1 0\n3 1 2 10000 0\n2 1\n0 0 0 0 0", "output": "-1\n-1\n255\n-1\n198\n199\n10000\n-1\n"}, {"input": "1 5 7 11 10\n10\n2 5 7 11 10\n2 4\n2 1 1 256 0\n128 255\n2 0 0 1 0\n1234 ... | code_stdio |
[
{
"content": "Given the list of numbers, you are to sort them in non decreasing order.\n\n-----Input-----\nt – the number of numbers in list, then t lines follow [t <= 10^6]. \n\nEach line contains one integer: N [0 <= N <= 10^6]\n\n-----Output-----\nOutput given numbers in non decreasing order.\n\n-----Example... | [{"input": "5\n0\n0\n10\n11\n2", "output": "0\n0\n2\n10\n11\n"}, {"input": "5\n1\n1\n3\n11\n2", "output": "1\n1\n2\n3\n11\n"}, {"input": "5\n1\n1\n3\n11\n4", "output": "1\n1\n3\n4\n11\n"}, {"input": "5\n1\n0\n3\n11\n4", "output": "0\n1\n3\n4\n11\n"}, {"input": "5\n1\n0\n3\n17\n4", "output": "0\n1\n3\n4\n17\n"}, {"input... | code_stdio |
[
{
"content": "To make it difficult to withdraw money, a certain bank allows its customers to withdraw only one of the following amounts in one operation:\n - 1 yen (the currency of Japan)\n - 6 yen, 6^2(=36) yen, 6^3(=216) yen, ...\n - 9 yen, 9^2(=81) yen, 9^3(=729) yen, ...\nAt least how many operations are re... | [{"input": "44852\n", "output": "16\n"}, {"input": "43637\n", "output": "16\n"}, {"input": "99788\n", "output": "15\n"}, {"input": "35861\n", "output": "15\n"}, {"input": "100000\n", "output": "7\n"}, {"input": "182896", "output": "14\n"}, {"input": "135433", "output": "10\n"}, {"input": "59049\n", "output": "1\n"}, {"... | code_stdio |
[
{
"content": "Diameter of a Tree\n\n\n\n\nGiven a tree T with non-negative weight, find the diameter of the tree.\n\nThe diameter of a tree is the maximum distance between two nodes in a tree.\n\nConstraints\n\n* 1 ≤ n ≤ 100,000\n* 0 ≤ wi ≤ 1,000\n\nInput\n\n\nn\ns1 t1 w1\ns2 t2 w2\n:\nsn-1 tn-1 wn-1\n\n\nThe f... | [{"input": "4\n1 0 -2\n2 1 10\n1 3 4", "output": "14\n"}, {"input": "4\n1 0 1\n0 2 12\n2 3 -1", "output": "13\n"}, {"input": "4\n1 0 0\n2 1 11\n0 3 11", "output": "22\n"}, {"input": "4\n1 0 -1\n2 1 15\n1 3 4", "output": "19\n"}, {"input": "4\n1 1 -1\n2 0 10\n0 3 6", "output": "16\n"}, {"input": "4\n0 1 2\n0 3 1\n2 3 12... | code_stdio |
[
{
"content": "Takahashi has a strong stomach. He never gets a stomachache from eating something whose \"best-by\" date is at most X days earlier.\nHe gets a stomachache if the \"best-by\" date of the food is X+1 or more days earlier, though.\nOther than that, he finds the food delicious if he eats it not later ... | [{"input": "-2 -1 10", "output": "dangerous\n"}, {"input": "-1 13 12", "output": "delicious\n"}, {"input": "3 7 12\n", "output": "dangerous\n"}, {"input": "-1 7 12", "output": "dangerous\n"}, {"input": "-1 7 14", "output": "dangerous\n"}, {"input": "13 2 -1", "output": "delicious\n"}, {"input": "13 4 -1", "output": "de... | code_stdio |
[
{
"content": "For a dynamic array $A = \\\\{a_0, a_1, ...\\\\}$ of integers, perform a sequence of the following operations:\n\n* pushBack($x$): add element $x$ at the end of $A$\n* randomAccess($p$):print element $a_p$\n* popBack(): delete the last element of $A$\n\n\n\n$A$ is a 0-origin array and it is empty ... | [{"input": "8\n0 -1\n0 14\n0 1\n2\n0 4\n1 0\n1 0\n1 1", "output": "-1\n-1\n14\n"}, {"input": "8\n0 -1\n0 9\n1 1\n2\n0 4\n1 0\n1 0\n1 1", "output": "9\n-1\n-1\n4\n"}, {"input": "8\n0 -1\n0 2\n0 3\n2\n0 4\n1 0\n1 0\n1 0", "output": "-1\n-1\n-1\n"}, {"input": "8\n0 -1\n0 9\n0 1\n2\n0 4\n1 0\n1 0\n1 1", "output": "-1\n-1\n... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \nRoman has no idea, why this problem is called Stone. He also has no idea on how to solve the followong problem: given array of N integers A and a number K. During a turn the maximal value over all A_{i} is chosen, let's call it MAX. Then... | [{"input": "4 0\n5 -1 14 -1", "output": "5 -1 14 -1\n"}, {"input": "4 0\n6 -1 14 -1", "output": "6 -1 14 -1\n"}, {"input": "4 1\n1 -1 19 4", "output": "18 20 0 15\n"}, {"input": "4 1\n5 -1 15 0", "output": "10 16 0 15\n"}, {"input": "4 1\n5 -1 23 0", "output": "18 24 0 23\n"}, {"input": "4 1\n3 0 14 -1", "output": "11 ... | code_stdio |
[
{
"content": "You are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some positive integer number of centimeters (different sticks can be increased by a different length), but in total by at most l centimeters. In particular, it is allowed... | [{"input": "300000 300000 300000 300000\n", "output": "4500090000549998\n"}, {"input": "300000 300000 313966 300000\n", "output": "4499976425036741\n"}, {"input": "300000 330804 313966 300000\n", "output": "4499890982537731\n"}, {"input": "53553 262850 271957 182759\n", "output": "834977070873802\n"}, {"input": "100000... | code_stdio |
[
{
"content": "Ekiden competitions are held every year in Aizukuni. The country of Aiz is dotted with N towns, each numbered from 1 to N. Several towns are connected by roads that allow them to come and go directly to each other. You can also follow several roads between any town. The course of the tournament is... | [{"input": "7 11\n2 4 2\n1 6 2\n2 4 2\n1 5 10\n2 6 2\n6 4 1\n6 5 1\n3 6 1\n4 7 0\n5 5 6\n6 7 1", "output": "4\n3\n4\n5\n7\n"}, {"input": "7 11\n2 1 2\n1 3 1\n2 3 2\n3 4 4\n2 6 1\n4 4 1\n3 5 2\n3 6 1\n4 7 3\n5 7 7\n6 7 1", "output": "4\n1\n2\n6\n7\n"}, {"input": "7 11\n2 2 2\n1 3 2\n3 3 2\n3 4 4\n2 6 1\n4 4 1\n3 5 1\n3 ... | code_stdio |
[
{
"content": "Vasya has got a magic matrix a of size n × m. The rows of the matrix are numbered from 1 to n from top to bottom, the columns are numbered from 1 to m from left to right. Let a_{ij} be the element in the intersection of the i-th row and the j-th column.\n\nVasya has also got a chip. Initially, the... | [{"input": "13 8\n3 2 1 4 8 2 5 9\n8 2 10 8 9 3 2 8\n3 6 8 3 11 7 6 4\n4 2 10 5 7 5 1 3\n10 9 3 6 4 10 10 2\n10 3 7 1 4 5 7 10\n5 3 1 6 1 10 3 6\n10 7 6 8 1 8 4 1\n7 8 1 10 8 5 3 6\n3 8 10 6 7 6 5 5\n1 5 9 8 4 8 5 10\n6 9 10 7 5 10 5 4\n3 9 2 4 8 2 5 4\n8 1\n", "output": "140693813\n"}, {"input": "13 8\n3 2 1 4 8 2 5 9... | code_stdio |
[
{
"content": "There are K items placed on a grid of squares with R rows and C columns. Let (i, j) denote the square at the i-th row (1 \\leq i \\leq R) and the j-th column (1 \\leq j \\leq C). The i-th item is at (r_i, c_i) and has the value v_i.\nTakahashi will begin at (1, 1), the start, and get to (R, C), th... | [{"input": "4 5 10\n2 5 12\n1 5 12\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 5 21\n3 5 10\n1 3 10\n", "output": "142\n"}, {"input": "4 5 3\n1 5 11\n1 -1 12\n2 3 61\n2 3 20\n0 0 33\n3 3 10\n4 4 31\n14 6 21\n-1 2 17\n2 3 10", "output": "61\n"}, {"input": "4 5 10\n2 5 12\n1 5 7\n2 3 15\n1 2 20\n1 1 28\n2 4 26\n3 2 27\n4 ... | code_stdio |
[
{
"content": "You are given a grid with 2 rows and 3 columns of squares.\nThe color of the square at the i-th row and j-th column is represented by the character C_{ij}.\nWrite a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise.\n\n-----Constraints-----\n -... | [{"input": "pot\ntop\n", "output": "YES\n"}, {"input": "tab\nbet\n", "output": "NO\n"}, {"input": "eye\neel\n", "output": "NO\n"}, {"input": "spp\npps", "output": "YES\n"}, {"input": "tbb\nbet", "output": "NO\n"}, {"input": "eye\nele", "output": "NO\n"}, {"input": "pos\ntop", "output": "NO\n"}, {"input": "btb\nbet", "o... | code_stdio |
[
{
"content": "To satisfy his love of matching socks, Phoenix has brought his $n$ socks ($n$ is even) to the sock store. Each of his socks has a color $c_i$ and is either a left sock or right sock.\n\nPhoenix can pay one dollar to the sock store to either:\n\nrecolor a sock to any color $c'$ $(1 \\le c' \\le n)$... | [{"input": "4\n6 3 3\n1 2 3 2 2 2\n6 2 4\n1 1 2 2 2 2\n6 5 1\n6 5 4 3 2 1\n4 0 4\n4 4 4 3\n", "output": "\n2\n3\n5\n3\n"}, {"input": "4\n6 3 3\n1 2 3 2 2 2\n6 2 4\n1 1 2 2 2 2\n6 5 1\n6 5 4 3 2 1\n4 0 4\n4 4 4 3\n", "output": "2\n3\n5\n3\n"}, {"input": "4\n6 3 3\n1 2 6 2 2 2\n6 2 4\n1 1 2 2 2 2\n6 5 1\n6 5 4 3 2 1\n4 0... | code_stdio |
[
{
"content": "In the good old Hachioji railroad station located in the west of Tokyo, there are several parking lines, and lots of freight trains come and go every day.\n\nAll freight trains travel at night, so these trains containing various types of cars are settled in your parking lines early in the morning.... | [{"input": "3 5\n0W 1W\n0W 2W\n0W 2E\n0E 1E\n1E 2E\naabbcdcee\n-\n-\n-\n-\nbbaadeecc\n3 3\n0E 1W\n1E 2W\n2E 0W\naabb\nbbcc\naa\nbbbb\ncc\naaaa\n3 4\n0E 1W\n0E 2E\n1E 2W\n2E 0W\nababab\n-\n-\naaabbb\n-\n-\n0 0", "output": "5\n2\n5\n"}, {"input": "3 5\n0W 1W\n0W 2W\n0W 2E\n0E 1E\n1E 2E\naabbccdee\n-\n-\n-\n-\nbbaadeecc\n... | code_stdio |
[
{
"content": "Polycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user requests for this time period. For each query, we know its time... and nothing ... | [{"input": "10 3 30000\n00:06:54\n00:42:06\n03:49:45\n04:38:35\n05:33:30\n05:51:46\n10:46:34\n14:34:59\n14:40:06\n14:53:13\n", "output": "6\n1\n2\n3\n3\n3\n3\n4\n5\n6\n6\n"}, {"input": "10 3 30000\n00:06:54\n00:42:06\n03:49:45\n04:38:35\n05:33:30\n05:51:56\n10:46:34\n14:34:59\n14:40:06\n14:53:13\n", "output": "6\n1\n2\... | code_stdio |
[
{
"content": "Takahashi has decided to make a Christmas Tree for the Christmas party in AtCoder, Inc.\n\nA Christmas Tree is a tree with N vertices numbered 1 through N and N-1 edges, whose i-th edge (1\\leq i\\leq N-1) connects Vertex a_i and b_i.\n\nHe would like to make one as follows:\n\n* Specify two non-n... | [{"input": "10\n1 2\n1 3\n1 4\n2 5\n6 10\n6 7\n7 8\n4 9\n10 5", "output": "2 6\n"}, {"input": "10\n1 2\n1 3\n3 4\n2 5\n6 5\n6 7\n7 8\n5 9\n10 5", "output": "2 5\n"}, {"input": "10\n1 2\n1 3\n3 4\n2 5\n7 5\n6 7\n7 8\n5 9\n10 5", "output": "3 5\n"}, {"input": "10\n1 2\n1 3\n1 4\n2 5\n7 5\n6 7\n7 8\n5 9\n10 5", "output": ... | code_stdio |
[
{
"content": "Sasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since Sasha isn't an ordinary guy, he prefers to relax unusually. During leisure time Sasha likes to upsolve unsolved problems because upsolving is very useful.\n\nT... | [{"input": "2\n114243 620721\n", "output": "0\n"}, {"input": "2\n182166 620721\n", "output": "0\n"}, {"input": "2\n182166 383547\n", "output": "0\n"}, {"input": "2\n60202 951227\n", "output": "0\n"}, {"input": "2\n60202 620721\n", "output": "0\n"}, {"input": "6\n5 2 2 3 10 6\n", "output": "1\n"}, {"input": "6\n5 2 2 4 ... | code_stdio |
[
{
"content": "You've got two rectangular tables with sizes na × ma and nb × mb cells. The tables consist of zeroes and ones. We will consider the rows and columns of both tables indexed starting from 1. Then we will define the element of the first table, located at the intersection of the i-th row and the j-th ... | [{"input": "14 28\n1000000010111011101010010101\n1110010011000011000110001001\n0001100110101000010110110011\n0101101011010101110100100101\n0100100101000011011111100010\n0001111000100000101000110101\n1011100111110101000110101010\n1111011011110100100000101000\n0011111101110001010010001110\n1011100011110000001011100100\n0... | code_stdio |
[
{
"content": "A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.\n\nLimak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not discarded) cards.\n\nHe is allowed to at most once dis... | [{"input": "100 100 100 100 100\n", "output": "200\n"}, {"input": "100 100 100 100 100\n", "output": "200\n"}, {"input": "100 100 100 100 000\n", "output": "100\n"}, {"input": "100 100 100 000 000\n", "output": "0\n"}, {"input": "100 100 99 99 98\n", "output": "296\n"}, {"input": "98 99 100 99 100\n", "output": "296\n"... | code_stdio |
[
{
"content": "Innokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Innokenty wants that all short names consist of three letters.\n\nEach club's ful... | [{"input": "10\nIJGDI KHB\nHBI CKKCG\nFHE GCAA\nEDCGH HHICE\nGFH AIHD\nHED KIK\nDCK BCFIJ\nFFIHE FDB\nJGB AKKI\nIJD CAG\n", "output": "YES\nIJG\nHBI\nFHE\nEDC\nGFH\nHED\nDCK\nFFI\nJGB\nIJD\n"}, {"input": "10\nIJGDI KHB\nHBI CKKCG\nFHE GCAA\nEDCGH HHICE\nGFH AIHD\nHED KIK\nDCK BCFIJ\nFFIHE FDB\nJGB AKKI\nIJD CAG\n", "ou... | code_stdio |
[
{
"content": "Short Phrase\n\nA Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following condition:\n\n> (The Condition for a Short Phrase)\n> The sequence of words can be ... | [{"input": "9\ndo\nhte\nbest\nand\nenjoy\ntoday\nat\nacm\nicpc\n14\noh\nyes\nby\nfar\nit\nis\nwow\nso\nbad\nto\nme\nyou\nknow\nhey\n15\nabcde\nfghijkl\nmnopq\nrstuvwx\nyzz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\n0", "output": "1\n2\n6\n"}, {"input": "9\ndo\nhte\nbest\nand\nenjoy\ntoday\... | code_stdio |
[
{
"content": "You will receive 5 points for solving this problem.\n\nManao has invented a new operation on strings that is called folding. Each fold happens between a pair of consecutive letters and places the second part of the string above first part, running in the opposite direction and aligned to the posit... | [{"input": "LEHLLLLLLHAFGEGLLHAFDLHHLLLLLDGGEHGGHLLLLLLLLDFLCBLLEFLLCBLLCGLEDLGGLECLDGLEHLLLGELLLEGLLLLGDLLLDALD\n", "output": "49\n"}, {"input": "LEHLLLLLLHAFGEGLLHAFDLHHMLLLLDGGEHGGHLLLLLLLLDFLCBLLEFLLCBLLCGLEDLGGLECLDGLEHLLLGELLLEGLLLLGDLLLDALD\n", "output": "47\n"}, {"input": "LEHLLLLLLHAFGEGLLHAFDLHHMLLKLDGGEHGGHL... | code_stdio |
[
{
"content": "You are given a n × m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A right triangle is a triangle in which one angle is a right angle (that is, a 90... | [{"input": "14 29\n**.*************..*.*********\n**..****.*********.**.*.****.\n********.**..*..*...*....**..\n****.**.***.*.***..*..***.*..\n***.****.***..*.***.*.****.*.\n*.*..***.***********.*.*.****\n****.*.***.*..****.**.**..***\n.*******..**...***.*.********\n*...**********...**...*.***.*\n*.******...*.***.**..*... | code_stdio |
[
{
"content": "Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0, 1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbered from 1 to n in order.\n\nThe stones always fall to th... | [{"input": "llrlrlllrrllrllllrlrrlrlrrllrlrlrrlrrrrrrlllrrlrrrrrlrrrlrlrlrrlllllrrrrllrrlrlrrrllllrlrrlrrlrlrrll\n", "output": "3\n5\n9\n10\n13\n18\n20\n21\n23\n25\n26\n29\n31\n33\n34\n36\n37\n38\n39\n40\n41\n45\n46\n48\n49\n50\n51\n52\n54\n55\n56\n58\n60\n62\n63\n69\n70\n71\n72\n75\n76\n78\n80\n81\n82\n87\n89\n90\n92\... | code_stdio |
[
{
"content": "There is an empty array.\nThe following N operations will be performed to insert integers into the array.\nIn the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.\nFind the K-th smallest integer in the array after the N operations.\nFor example, the 4-th smallest i... | [{"input": "10 878093\n1 100000\n1 110001\n1 100000\n1 100001\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000", "output": "100000\n"}, {"input": "10 878093\n1 100000\n1 110001\n1 100000\n1 101001\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000", ... | code_stdio |
[
{
"content": "You are given a string q. A sequence of k strings s_1, s_2, ..., s_{k} is called beautiful, if the concatenation of these strings is string q (formally, s_1 + s_2 + ... + s_{k} = q) and the first characters of these strings are distinct.\n\nFind any beautiful sequence of strings or determine that ... | [{"input": "26\nlllplzkkzflzflffzznnnnfgflqlttlmtnkzlztskngyymitqagattkdllyutzimsrskpapcmuupjdopxqlnhqcscwvdtxbflefy\n", "output": "YES\nlll\npl\nz\nkkz\nflzflffzz\nnnnnf\ngfl\nql\nttl\nmtnkzlzt\nskng\nyym\nitq\nagattk\ndlly\nutzims\nrskpap\ncmuup\njd\nop\nxqln\nhqcsc\nw\nvdtx\nbfl\nefy\n"}, {"input": "26\nlllplzkkzflz... | code_stdio |
[
{
"content": "You are given two integers $a$ and $m$. Calculate the number of integers $x$ such that $0 \\le x < m$ and $\\gcd(a, m) = \\gcd(a + x, m)$.\n\nNote: $\\gcd(a, b)$ is the greatest common divisor of $a$ and $b$.\n\n\n-----Input-----\n\nThe first line contains the single integer $T$ ($1 \\le T \\le 50... | [{"input": "10\n164 252\n94 226\n38 254\n196 255\n35 256\n174 257\n251 495\n246 527\n9 260\n149 261\n", "output": "36\n112\n126\n128\n128\n256\n240\n480\n96\n168\n"}, {"input": "10\n164 252\n94 253\n171 254\n196 255\n35 256\n174 257\n251 258\n239 259\n9 260\n98 261\n", "output": "36\n220\n126\n128\n128\n256\n84\n216\n9... | code_stdio |
[
{
"content": "Melody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new identity that allowed her to kill the Eleventh Doctor.\n\nHeidi figured out tha... | [{"input": "1219679533107\n", "output": "1 609839766552\n"}, {"input": "1044191868535\n", "output": "1 522095934266\n"}, {"input": "1041721920937\n", "output": "1 520860960467\n"}, {"input": "1025662663437\n", "output": "1 512831331717\n"}, {"input": "1026828404677\n", "output": "1 513414202337\n"}, {"input": "14523797... | code_stdio |
[
{
"content": "There are $n$ benches in the Berland Central park. It is known that $a_i$ people are currently sitting on the $i$-th bench. Another $m$ people are coming to the park and each of them is going to have a seat on some bench out of $n$ available.\n\nLet $k$ be the maximum number of people sitting on o... | [{"input": "100\n3241\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n10... | code_stdio |
[
{
"content": "On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has base cost a_{i} Egyptian pounds. If Sagheer buys k items with indices x_1, x... | [{"input": "90 61394040\n2480 6212 4506 829 8191 797 5336 6722 3178 1007 5849 3061 3588 6684 5983 5452 7654 5321 660 2569 2809 2179 679 4858 6887 2580 6880 6120 4159 5542 4999 8703 2386 8221 7046 1229 1662 4542 7089 3548 4298 1973 1854 2473 5507 241 359 5248 7907 5201 9624 4596 1723 2622 4800 4716 693 961 7402 9004 799... | code_stdio |
[
{
"content": "There are many anime that are about \"love triangles\": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters can either mutually love each other or mutua... | [{"input": "28567 13\n28079 24675 1\n18409 26720 1\n980 10815 1\n20794 16571 1\n7376 19861 1\n10805 706 1\n4255 16391 1\n27376 18263 1\n10019 28444 1\n6574 28053 1\n5036 16610 1\n3543 7122 1\n512 9554 1\n", "output": "928433852\n"}, {"input": "28567 13\n28079 24675 1\n18409 26720 1\n980 12226 1\n20794 16571 1\n7376 198... | code_stdio |
[
{
"content": "Bob is playing a game named \"Walk on Matrix\".\n\nIn this game, player is given an n × m matrix A=(a_{i,j}), i.e. the element in the i-th row in the j-th column is a_{i,j}. Initially, player is located at position (1,1) with score a_{1,1}. \n\nTo reach the goal, position (n,m), player can move ri... | [{"input": "127382\n", "output": "2 3\n258454 131072 0\n127382 258454 127382\n"}, {"input": "117079\n", "output": "2 3\n248151 131072 0\n117079 248151 117079\n"}, {"input": "101472\n", "output": "2 3\n232544 131072 0\n101472 232544 101472\n"}, {"input": "100461\n", "output": "2 3\n231533 131072 0\n100461 231533 100461\... | code_stdio |
[
{
"content": "Little Petya loves looking for numbers' divisors. One day Petya came across the following problem:\n\nYou are given n queries in the form \"xi yi\". For each query Petya should count how many divisors of number xi divide none of the numbers xi - yi, xi - yi + 1, ..., xi - 1. Help him.\n\nInput\n\n... | [{"input": "20\n68260 0\n819 1\n54174 1\n20460 1\n25696 2\n81647 4\n17736 4\n91307 5\n5210 4\n87730 2\n4653 8\n11044 6\n15776 4\n17068 7\n73738 7\n36004 12\n83183 7\n75700 12\n84270 14\n16120 5\n", "output": "12\n11\n6\n44\n18\n1\n9\n7\n6\n12\n8\n8\n21\n3\n14\n3\n3\n13\n18\n26\n"}, {"input": "20\n68260 0\n819 1\n54174 ... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nOnce Chef decided to divide the tangerine into several parts. At first, he numbered tangerine's segments from 1 to n in the clockwise order starting from some segment. Then he intended to divide the fruit into several parts. In order t... | [{"input": "2\n10 3 2\n1 5\n5 5\n6 10\n1 5\n6 10\n10 3 0\n4 5\n10 1\n12 18\n1 10", "output": "Yes\nYes\n"}, {"input": "2\n10 3 2\n1 5\n5 5\n6 10\n1 5\n6 10\n10 3 0\n4 5\n10 1\n12 9\n1 10", "output": "Yes\nYes\n"}, {"input": "2\n10 3 2\n1 4\n10 5\n6 10\n1 5\n6 10\n10 3 0\n4 5\n10 1\n6 9\n1 10", "output": "Yes\nYes\n"}, ... | code_stdio |
[
{
"content": "Vasya has a beautiful garden where wonderful fruit trees grow and yield fantastic harvest every year. But lately thieves started to sneak into the garden at nights and steal the fruit too often. Vasya can’t spend the nights in the garden and guard the fruit because there’s no house in the garden! ... | [{"input": "10 10\n1 0 1 1 1 1 1 1 1 1\n1 1 1 0 1 1 0 1 1 1\n1 0 1 0 1 1 1 1 0 1\n1 1 0 1 1 1 0 0 0 1\n0 1 0 1 1 1 0 1 1 1\n1 0 1 0 1 0 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 0 1 1\n1 1 1 1 0 1 1 1 1 1\n0 1 1 1 1 0 1 1 0 1\n10 10\n", "output": "79\n"}, {"input": "10 10\n1 0 1 1 1 1 1 1 1 1\n1 1 1 0 1 1 0 1 1 1\n1 ... | code_stdio |
[
{
"content": "You are given a string $s$ of length $n$, which consists only of the first $k$ letters of the Latin alphabet. All letters in string $s$ are uppercase.\n\nA subsequence of string $s$ is a string that can be derived from $s$ by deleting some of its symbols without changing the order of the remaining... | [{"input": "76 26\nABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXY\n", "output": "26\n"}, {"input": "76 26\nABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXY\n", "output": "26"}, {"input": "22 1\nAAAAAAAAAAAAAAAAAAAAAA\n", "output": "22\n"}, {"input": "22 1\nAAAAA... | code_stdio |
[
{
"content": "Chef talks a lot on his mobile phone. As a result he exhausts his talk-value (in Rokdas) very quickly. One day at a mobile recharge shop, he noticed that his service provider gives add-on plans which can lower his calling rates (Rokdas/minute). One of the plans said \"Recharge for 28 Rokdas and en... | [{"input": "4\n1.00 90 1\n1 1.7525489781557062 28\n1.3670910027404404 200 2\n2 0.75 40\n5 1.2448234862135843 101\n1.690723151930112 50 2\n1 1.4388842285899601 65\n2 2.296376152318535 100\n1.00 000 2\n3 1.1116288236865874 10\n4 1.5704897737882006 36", "output": "0\n1\n0\n0\n"}, {"input": "4\n1.00 200 1\n1 0.50 42\n1.00 ... | code_stdio |
[
{
"content": "We have a grid with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left.\nThe square (i, j) has two numbers A_{ij} and B_{ij} written on it.\nFirst, for each square, Takahashi paints one of the written numbers red and... | [{"input": "80 80\n80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80\n80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 80 ... | code_stdio |
[
{
"content": "In Morse code, an letter of English alphabet is represented as a string of some length from $1$ to $4$. Moreover, each Morse code representation of an English letter contains only dots and dashes. In this task, we will represent a dot with a \"0\" and a dash with a \"1\".\n\nBecause there are $2^1... | [{"input": "100\n1\n0\n0\n1\n0\n0\n1\n1\n0\n0\n1\n0\n0\n0\n0\n0\n1\n1\n0\n0\n0\n1\n1\n1\n1\n0\n0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n0\n0\n0\n0\n0\n0\n1\n1\n0\n0\n1\n1\n1\n1\n0\n1\n0\n0\n0\n1\n0\n0\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n0\n1\n1\n0\n0\n1\n0\n0\n1\n1\n0\n0\n0\n1\n0\n0\n0\n0\n0\n0\n1\n1\n0\n0\n0\n0\n1\n0\n0\n0\n1\n", ... | code_stdio |
[
{
"content": "Create a program that reads the attendance numbers of students in a class and the data that stores the ABO blood group and outputs the number of people for each blood type. There are four types of ABO blood types: A, B, AB, and O.\n\n\n\nInput\n\nA comma-separated pair of attendance numbers and bl... | [{"input": "1,B\n2,A\n3,B\n4,AB\n5,B\n5,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A", "output": "5\n4\n3\n2\n"}, {"input": "1,B\n2,B\n3,B\n4,AB\n5,B\n6,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A", "output": "4\n5\n3\n2\n"}, {"input": "1,B\n2,A\n3,B\n4,AB\n5,A\n6,O\n7,A\n8,O\n9,AB\n11,A\n11,A\n12,B\n13,AB\n14... | code_stdio |
[
{
"content": "Problem statement\n\nMeatishi can increase or decrease the number of fingers.\nThere are n buns in front of Nikunishi-kun.\nMeatishi is trying to count the number of steamed buns by breaking his finger.\nThere are only two shapes that Nishikun's fingers can take, whether they are broken or not.\nN... | [{"input": "1237235", "output": "21\n"}, {"input": "140502", "output": "18\n"}, {"input": "299812", "output": "19\n"}, {"input": "763679", "output": "20\n"}, {"input": "17679", "output": "15\n"}, {"input": "33209", "output": "16\n"}, {"input": "96405", "output": "17\n"}, {"input": "1241", "output": "11\n"}, {"input": "... | code_stdio |
[
{
"content": "As we all know Barney's job is \"PLEASE\" and he has not much to do at work. That's why he started playing \"cups and key\". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the middle cup. $\\left. \\begin{array}{l}{\\text... | [{"input": "12\n254904759290707697 475737283258450340 533306428548398547 442127134828578937 779740159015946254 272877594683860919 93000149670491971 349640818793278778 498293278222136720 551099726729989816 149940343283925029 1677751211246811281\n", "output": "144527324/433581971\n"}, {"input": "12\n254904759290707697 50... | code_stdio |
[
{
"content": "There is an ice cream shop named Ten Ice Cream. At this store, we always have 10 types of ice cream on the shelves. The store manager creates a daily graph showing how well ice cream is selling for reference in product development.\n\nFor such a store manager, you decided to create a program that ... | [{"input": "15\n2\n6\n7\n0\n1\n9\n8\n7\n4\n8\n9\n1\n9\n4\n2\n1\n2\n1\n0\n0", "output": "*\n**\n**\n-\n**\n-\n*\n**\n**\n***\n-\n-\n*\n-\n-\n-\n-\n-\n-\n-\n*\n-\n-\n-\n-\n-\n-\n-\n-\n-\n"}, {"input": "15\n1\n6\n7\n0\n1\n9\n8\n7\n4\n8\n9\n1\n9\n4\n2\n1\n2\n1\n0\n0", "output": "*\n***\n*\n-\n**\n-\n*\n**\n**\n***\n-\n-\n*... | code_stdio |
[
{
"content": "A string is called square if it is some string written twice in a row. For example, the strings \"aa\", \"abcabc\", \"abab\" and \"baabaa\" are square. But the strings \"aaa\", \"abaaab\" and \"abcdabc\" are not square.\n\nFor a given string $s$ determine if it is square.\n\n\n-----Input-----\n\nT... | [{"input": "10\na\naa\naaa\naaaa\nabab\nabcabc\nabacaba\nxxyy\nxyyx\nxyxy\n", "output": "NO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\n"}, {"input": "10\na\naa\naaa\naaaa\nabab\nabcabc\nabacaba\nyxxy\nxyyx\nxyxy\n", "output": "NO\nYES\nNO\nYES\nYES\nYES\nNO\nNO\nNO\nYES\n"}, {"input": "10\nb\naa\naaa\naaaa\nabab\nabcabc... | code_stdio |
[
{
"content": "Recently, Dima met with Sasha in a philatelic store, and since then they are collecting coins together. Their favorite occupation is to sort collections of coins. Sasha likes having things in order, that is why he wants his coins to be arranged in a row in such a way that firstly come coins out of... | [{"input": "100\n98 52 63 2 18 96 31 58 84 40 41 45 66 100 46 71 26 48 81 20 73 91 68 76 13 93 17 29 64 95 79 21 55 75 19 85 54 51 89 78 15 87 43 59 36 1 90 35 65 56 62 28 86 5 82 49 3 99 33 9 92 32 74 69 27 22 77 16 44 94 34 6 57 70 23 12 61 25 8 11 67 47 83 88 10 14 30 7 97 60 42 37 24 38 53 50 4 80 72 39\n", "output... | code_stdio |
[
{
"content": "A robber has attempted to rob a bank but failed to complete his task. However, he had managed to open all the safes.\n\nOleg the bank client loves money (who doesn't), and decides to take advantage of this failed robbery and steal some money from the safes. There are many safes arranged in a line,... | [{"input": "8 3 13\n12\n3 3 3 12 7 6 10 1 8 8 7 12\n", "output": "8\n"}, {"input": "8 3 13\n12\n3 3 3 8 7 6 10 1 8 8 7 12\n", "output": "8\n"}, {"input": "8 5 13\n12\n3 3 3 8 7 6 10 1 7 8 7 11\n", "output": "8\n"}, {"input": "8 5 13\n12\n3 3 3 8 7 0 10 1 7 8 7 11\n", "output": "7\n"}, {"input": "6 3 13\n12\n3 3 3 5 7 6... | code_stdio |
[
{
"content": "Sheldon Cooper, Leonard Hofstadter and Penny decide to go for drinks at Cheese cake factory. Sheldon proposes to make a game out of this. Sheldon proposes as follows, \nTo decide the amount of beverage they plan to consume, say X.\n\nThen order for a random number of different drinks, say {A, B, C... | [{"input": "8\n4 8 9 7 45 6 3 27\n156", "output": "False"}, {"input": "8\n4 8 9 7 45 6 3 27\n56", "output": "True"}, {"input": "6\n45 55 5 7 23 4\n107", "output": "True"}, {"input": "7\n2 5 4 9 7 33 6\n44", "output": "True"}, {"input": "4\n55 45 2 23\n58", "output": "False"}, {"input": "4\n4 3 25 5\n33", "output": "Tru... | code_stdio |
[
{
"content": "Monocarp is playing yet another computer game. In this game, his character has to kill a dragon. The battle with the dragon lasts $100^{500}$ seconds, during which Monocarp attacks the dragon with a poisoned dagger. The $i$-th attack is performed at the beginning of the $a_i$-th second from the ba... | [{"input": "4\n2 13\n1 5\n3 11\n1 4 20\n5 3\n1 2 4 8 7\n4 1000\n5 25 95 1337\n", "output": "9\n4\n1\n455\n"}, {"input": "4\n2 1\n1 5\n3 10\n2 4 10\n5 3\n1 2 4 5 7\n4 1000\n3 25 124 1337\n", "output": "1\n4\n1\n440\n"}, {"input": "4\n2 5\n1 5\n3 10\n2 4 10\n5 3\n1 2 4 5 7\n4 1000\n3 25 64 1337\n", "output": "3\n4\n1\n47... | code_stdio |
[
{
"content": "Champernown constant is an irrational number represented in decimal by \"0.\" followed by concatenation of all positive integers in the increasing order. The first few digits of this constant are: 0.123456789101112...\n\nYour task is to write a program that outputs the K digits of Chapnernown cons... | [{"input": "11 17\n11 14\n0 0", "output": "01112131415161718\n01112131415161\n"}, {"input": "4 7\n2 26\n0 0", "output": "4567891\n23456789101112131415161718\n"}, {"input": "2 5\n1 26\n0 0", "output": "23456\n12345678910111213141516171\n"}, {"input": "9 15\n11 14\n0 0", "output": "910111213141516\n01112131415161\n"}, {"... | code_stdio |
[
{
"content": "Alice and Bob love playing one-dimensional battle ships. They play on the field in the form of a line consisting of n square cells (that is, on a 1 × n table).\n\nAt the beginning of the game Alice puts k ships on the field without telling their positions to Bob. Each ship looks as a 1 × a rectang... | [{"input": "50 7 3\n50\n17 47 1 12 21 25 6 5 49 27 34 8 16 38 11 44 48 9 2 20 3 22 33 23 36 41 15 35 31 30 50 7 45 42 37 29 14 26 24 46 19 4 10 28 18 43 32 39 40 13\n", "output": "19\n"}, {"input": "50 1 1\n50\n1 13 21 37 30 48 23 19 6 49 36 14 9 24 44 10 41 28 20 2 15 11 45 3 25 33 50 38 35 47 31 4 12 46 32 8 42 26 5 ... | code_stdio |
[
{
"content": "Look for the Winner!\n\nThe citizens of TKB City are famous for their deep love in elections and vote counting. Today they hold an election for the next chairperson of the electoral commission. Now the voting has just been closed and the counting is going to start. The TKB citizens have strong des... | [{"input": "1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nB A A B A C A C C B\n10\nV U U U U W V W V W\n0", "output": "A 1\nTIE\nTIE\nK 4\nX 5\nA 10\nU 10\n"}, {"input": "1\nA\n4\nA A B B\n5\nL M N L N\n6\nK K K K K K\n6\nX X X Y Z X\n10\nB A A B A C A C C B\n10\nV T U U U W W W V W\n0", "output":... | code_stdio |
[
{
"content": "The whole world got obsessed with robots,and to keep pace with the progress, great Berland's programmer Draude decided to build his own robot. He was working hard at the robot. He taught it to walk the shortest path from one point to another, to record all its movements, but like in many Draude's ... | [{"input": "RLRRRRRDRRDRRRRDLRRRRRRRDLRLDDLRRRRLDLDRDRRRRDRDRDRDLRRURRLRRRRDRRRRRRRRLDDRLRRDRRRRRRRDRDRLDRDDDRDR\n", "output": "BUG\n"}, {"input": "DDDDDDDDDDDDDDDDDDDDDDDDDLLLLLLLLLLLLLLLLLLLLLLLLRRRRRRRRRRRRRRRRRRRRRRRRRRRUUUUUUUUUUUUUUUUUUUUUUUU\n", "output": "BUG\n"}, {"input": "UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU... | code_stdio |
[
{
"content": "There is a bookshelf which can fit $n$ books. The $i$-th position of bookshelf is $a_i = 1$ if there is a book on this position and $a_i = 0$ otherwise. It is guaranteed that there is at least one book on the bookshelf.\n\nIn one move, you can choose some contiguous segment $[l; r]$ consisting of ... | [{"input": "5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1\n", "output": "2\n0\n2\n4\n1\n"}, {"input": "5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 1 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1\n", "output": "2\n0\n1\n4\n1\n"}, {"input": "5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 0 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 ... | code_stdio |
[
{
"content": "Polycarp took $n$ videos, the duration of the $i$-th video is $a_i$ seconds. The videos are listed in the chronological order, i.e. the $1$-st video is the earliest, the $2$-nd video is the next, ..., the $n$-th video is the last.\n\nNow Polycarp wants to publish exactly $k$ ($1 \\le k \\le n$) po... | [{"input": "6 3\n3 3 1 4 1 6\n", "output": "Yes\n2 3 1 \n"}, {"input": "6 3\n3 3 1 4 1 6\n", "output": "Yes\n2 3 1 "}, {"input": "3 3\n1 1 1\n", "output": "Yes\n1 1 1 \n"}, {"input": "3 3\n1 1 1\n", "output": "Yes\n1 1 1 "}, {"input": "3 1\n1 10 100\n", "output": "Yes\n3 \n"}, {"input": "3 1\n1 10 100\n", "output": "Ye... | code_stdio |
[
{
"content": "Vasya writes his own library for building graphical user interface. Vasya called his creation VTK (VasyaToolKit). One of the interesting aspects of this library is that widgets are packed in each other. \n\nA widget is some element of graphical interface. Each widget has width and height, and occu... | [{"input": "20\nVBox hykl\nVBox enwv\nenwv.pack(hykl)\nVBox dlepf\ndlepf.pack(hykl)\nenwv.set_border(30)\nWidget mjrrik(54,21)\nhykl.set_border(2)\ndlepf.set_border(22)\nenwv.set_border(3)\nenwv.pack(dlepf)\ndlepf.pack(mjrrik)\nhykl.set_spacing(96)\nenwv.set_border(32)\ndlepf.set_border(72)\nWidget j(54,86)\nhykl.pack(... | code_stdio |
[
{
"content": "Akari has n kinds of flowers, one of each kind.\nShe is going to choose one or more of these flowers to make a bouquet.\nHowever, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.\nHow many different bouquets are there that Akari can make?\nFind the count mod... | [{"input": "1000000000 199999 200000\n", "output": "382492393\n"}, {"input": "1000000000 141421 173205\n", "output": "34076506\n"}, {"input": "750063539 163676 194328\n", "output": "801789004\n"}, {"input": "686442509 103497 190629\n", "output": "506071717\n"}, {"input": "699889611 31932 135902\n", "output": "784137353... | code_stdio |
[
{
"content": "Well, the series which Stepan watched for a very long time, ended. In total, the series had n episodes. For each of them, Stepan remembers either that he definitely has watched it, or that he definitely hasn't watched it, or he is unsure, has he watched this episode or not. \n\nStepan's dissatisfa... | [{"input": "100 100\n????????????????????????????????????????????????????????????????????????????????????????????????????\n", "output": "YES\n"}, {"input": "100 100\n????????????????????????????????????????????????????????????????????????????????????????????????????\n", "output": "YES\n"}, {"input": "100 000\n?????????... | code_stdio |
[
{
"content": "Let $LCM(x, y)$ be the minimum positive integer that is divisible by both $x$ and $y$. For example, $LCM(13, 37) = 481$, $LCM(9, 6) = 18$.\n\nYou are given two integers $l$ and $r$. Find two integers $x$ and $y$ such that $l \\le x < y \\le r$ and $l \\le LCM(x, y) \\le r$.\n\n\n-----Input-----\n\... | [{"input": "69\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \n\nYou are given an array A of N integers. You are to fulfill M queries. Each query has one of the following three types:\n\nC d : Rotate the array A clockwise by d units.\nA d : Rotate the array A anticlockwise by d units.\nR d : Query f... | [{"input": "5 3\n0 13 10 -1 -2\nR -1\nC 1\nR 4\n@ 1\nS 2", "output": "-1\n-2\n"}, {"input": "5 3\n0 13 10 -1 -2\nR -2\nC 1\nR 4\n@ 1\nS 2", "output": "10\n-2\n"}, {"input": "5 3\n0 13 10 -1 -2\nR 0\nC 1\nR 4\n@ 1\nS 2", "output": "-2\n-2\n"}, {"input": "5 3\n0 13 10 -1 -2\nR 0\nC 1\nR 1\n@ 2\nT 2", "output": "-2\n13\n"... | code_stdio |
[
{
"content": "Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.\n\nThe camera's memory is d megabytes. Valera's camera can t... | [{"input": "50 50\n6 10\n10 0\n1 9\n8 2\n4 9\n0 7\n2 0\n7 5\n4 8\n13 7\n2 4\n5 6\n6 8\n3 2\n4 6\n7 8\n6 9\n7 7\n7 3\n9 5\n3 10\n7 2\n4 3\n2 0\n6 5\n5 3\n1 7\n1 7\n9 1\n10 4\n10 5\n4 2\n10 10\n0 7\n1 2\n10 1\n1 7\n3 7\n8 7\n5 2\n6 1\n3 1\n4 7\n7 10\n1 5\n10 8\n5 5\n5 1\n3 3\n1 6\n2 1\n", "output": "3\n6 23 50 \n"}, {"in... | code_stdio |
[
{
"content": "Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an ... | [{"input": "1000 1000 999\n", "output": "756641425\n"}, {"input": "1000 501 501\n", "output": "646597996\n"}, {"input": "1000 888 888\n", "output": "644649893\n"}, {"input": "1000 500 500\n", "output": "646597996\n"}, {"input": "1000 1000 999\n", "output": "756641425"}, {"input": "1000 501 347\n", "output": "385628187\... | code_stdio |
[
{
"content": "Ken loves ken-ken-pa (Japanese version of hopscotch). Today, he will play it on a directed graph G.\nG consists of N vertices numbered 1 to N, and M edges. The i-th edge points from Vertex u_i to Vertex v_i.\nFirst, Ken stands on Vertex S. He wants to reach Vertex T by repeating ken-ken-pa. In one... | [{"input": "6 8\n1 2\n2 1\n3 4\n4 11\n5 0\n1 5\n1 5\n4 6\n1 4", "output": "-1\n"}, {"input": "6 8\n1 2\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 6\n1 6\n", "output": "2\n"}, {"input": "6 8\n1 4\n2 3\n3 4\n4 5\n5 1\n1 4\n1 5\n4 1\n1 6", "output": "-1\n"}, {"input": "6 8\n1 2\n2 1\n3 4\n4 6\n5 0\n1 5\n1 5\n4 6\n1 4", "output": "-... | code_stdio |
[
{
"content": "Gardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. Now Alexey wants to grow a tree from them.\n\nThe tree looks like a polyline on... | [{"input": "11\n9969 9945 12703 11114 8159 10000 9928 9985 6747 9181 9933\n", "output": "5991155360\n"}, {"input": "11\n9969 9945 12703 9914 8159 10000 9928 9985 6747 9939 9933\n", "output": "5907768442\n"}, {"input": "11\n9969 9945 12703 9914 8159 10000 9928 9985 6747 9181 9933\n", "output": "5840383266\n"}, {"input":... | code_stdio |
[
{
"content": "Each month Blake gets the report containing main economic indicators of the company \"Blake Technologies\". There are n commodities produced by the company. For each of them there is exactly one integer in the final report, that denotes corresponding revenue. Before the report gets to Blake, it pa... | [{"input": "100 30\n65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 65 74 57 115 16 55 102 79 97 21 80 41 56 49 103 61 66 1 36 44 43 82 37 38 106 27 114 51 112 55 87 41 69 31 86 58 27 46 99 18 105 91 38 5 9 2 109 39 2 27 ... | code_stdio |
[
{
"content": "<image>\n\nThe International Clown and Pierrot Competition (ICPC), is one of the most distinguished and also the most popular events on earth in the show business.\n\nOne of the unique features of this contest is the great number of judges that sometimes counts up to one hundred. The number of jud... | [{"input": "3\n1000\n342\n-1\n5\n-1\n2\n18\n11\n932\n5\n420\n1100\n0\n200\n685\n8\n353\n143\n402\n274\n283\n31\n402\n523\n0", "output": "342\n10\n435\n309\n"}, {"input": "3\n1000\n342\n0\n5\n2\n2\n11\n11\n932\n5\n148\n1000\n0\n200\n400\n8\n353\n242\n1097\n274\n283\n107\n402\n523\n0", "output": "342\n8\n249\n346\n"}, {"... | code_stdio |
[
{
"content": "You have integer $n$. Calculate how many ways are there to fully cover belt-like area of $4n-2$ triangles with diamond shapes. \n\nDiamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it. \n\n$2$ coverings are different if some $2$ triangles are cov... | [{"input": "1\n1000000000\n", "output": "1000000000\n"}, {"input": "1\n1000000000\n", "output": "1000000000\n"}, {"input": "1\n1111011001\n", "output": "1111011001\n"}, {"input": "1\n1011011001\n", "output": "1011011001\n"}, {"input": "1\n1011001001\n", "output": "1011001001\n"}, {"input": "1\n1011001101\n", "output": ... | code_stdio |
[
{
"content": "You are given string s consists of opening and closing brackets of four kinds <>, {}, [], (). There are two types of brackets: opening and closing. You can replace any bracket by another of the same type. For example, you can replace < by the bracket {, but you can't replace it by ) or >.\n\nThe f... | [{"input": "))>)}}>>]}]{{}{({)>{(((}>>))<[})}{}(){}}}]>><){<{<><{[[]{<(<{{])(({[<}({)[}>>([>>(>]>[{]{}<<)()]})])}([>]{}(>{(<([([<(\n", "output": "Impossible\n"}, {"input": "))>)}}>>]}]{{}{({)>{(((}>>))<[})}{}(){}}}]>><){;{<><{[[]{<(<{{])(({[<}({)[}>>([>>(>]>[{]{}<<)()]})])}([>]{}(>{(<([([<(\n", "output": "Impossible\n"... | code_stdio |
[
{
"content": "It's that time of the year, Felicity is around the corner and you can see people celebrating all around the Himalayan region. The Himalayan region has n gyms. The i-th gym has g_{i} Pokemon in it. There are m distinct Pokemon types in the Himalayan region numbered from 1 to m. There is a special e... | [{"input": "100 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1... | code_stdio |
[
{
"content": "We will call a string obtained by arranging the characters contained in a string a in some order, an anagram of a.\nFor example, greenbin is an anagram of beginner. As seen here, when the same character occurs multiple times, that character must be used that number of times.\nGiven are N strings s... | [{"input": "1000\ninqmubaqoc\ndxdglvihpa\npnagqofdzf\ndxegqbbhza\nlxwdrvmekl\nwccdceedww\ncedcwwwced\nkmemzhaioi\nrnkmsbaaei\nccddwwwcee\nqghqrvbxgg\ncgavbvslgb\nwcwswceded\nwecwwdcced\nypecevpoyy\nlxwdbvmqkl\nwobwicidod\nedwccewdwc\nrragafedvf\nyvnbozkgqy\nlxddbvmqkl\nrpwaqejdgf\nrnkwqewjni\ndwcecdwcwe\nwdcwwcedce\nrn... | code_stdio |
[
{
"content": "You stumbled upon a new kind of chess puzzles. The chessboard you are given is not necesserily $8 \\times 8$, but it still is $N \\times N$. Each square has some number written on it, all the numbers are from $1$ to $N^2$ and all the numbers are pairwise distinct. The $j$-th square in the $i$-th r... | [{"input": "10\n16 92 81 8 70 28 72 91 87 13\n32 17 93 83 5 69 27 74 89 88\n43 31 22 99 79 4 65 26 71 90\n50 41 29 15 98 80 9 68 24 73\n59 51 38 35 18 96 82 6 67 25\n57 60 49 45 37 19 97 85 7 66\n76 53 61 46 40 36 14 95 86 3\n11 75 55 58 48 44 34 20 94 84\n2 10 77 56 62 52 39 30 23 100\n64 1 12 78 54 63 47 42 33 21\n",... | code_stdio |
[
{
"content": "One way to create a task is to learn from life. You can choose some experience in real life, formalize it and then you will get a new task.\n\nLet's think about a scene in real life: there are lots of people waiting in front of the elevator, each person wants to go to a certain floor. We can forma... | [{"input": "100 1\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 100 100 100 100 100 1... | code_stdio |
[
{
"content": "A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.\n\nGiven an array $a$ of length $n$, consisting only of the numbers $0$ and $1$, and the number $k$. Exactly $k$ times the follow... | [{"input": "100 1000000000\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 1 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 0 0 0 0 0 0 0 0\n", "output": "216163471\n"}, {"input": "100 1000000000\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0... | code_stdio |
[
{
"content": "Winter is here at the North and the White Walkers are close. John Snow has an army consisting of n soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers.\n\nHe has created a method to know how strong his army is. Let the... | [{"input": "4\n7 12 15 5\n", "output": "55\n"}, {"input": "4\n5 12 4 6\n", "output": "57\n"}, {"input": "4\n5 12 5 6\n", "output": "50\n"}, {"input": "4\n7 6 15 5\n", "output": "49\n"}, {"input": "4\n7 12 1 6\n", "output": "37\n"}, {"input": "4\n5 12 1 6\n", "output": "35\n"}, {"input": "4\n4 6 12 5\n", "output": "57\n... | code_stdio |
[
{
"content": "Constraints\n\n* 1 ≤ |V| ≤ 100\n* 0 ≤ |E| ≤ 9900\n* -2 × 107 ≤ di ≤ 2 × 107\n* There are no parallel edges\n* There are no self-loops\n\nInput\n\nAn edge-weighted graph G (V, E).\n\n\n|V| |E|\ns0 t0 d0\ns1 t1 d1\n:\ns|E|-1 t|E|-1 d|E|-1\n\n\n|V| is the number of vertices and |E| is the number of e... | [{"input": "15 6\n1 2 2\n1 3 -5\n1 2 3\n1 11 4\n2 0 1\n3 2 12", "output": "0 INF INF INF INF INF INF INF INF INF INF INF INF INF INF\n4 0 3 -5 INF INF INF INF INF INF INF 4 INF INF INF\n1 INF 0 INF INF INF INF INF INF INF INF INF INF INF INF\n13 INF 12 0 INF INF INF INF INF INF INF INF INF INF INF\nINF INF INF INF 0 IN... | code_stdio |
[
{
"content": "There is an infinite 2-dimensional grid. The robot stands in cell $(0, 0)$ and wants to reach cell $(x, y)$. Here is a list of possible commands the robot can execute:\n\nmove north from cell $(i, j)$ to $(i, j + 1)$;\n\nmove east from cell $(i, j)$ to $(i + 1, j)$;\n\nmove south from cell $(i, j)... | [{"input": "100\n0 0\n0 1\n1 0\n1 1\n0 2\n1 2\n2 0\n2 1\n2 2\n0 3\n1 3\n2 3\n3 0\n3 1\n3 2\n3 3\n0 4\n1 4\n2 4\n3 4\n4 0\n4 1\n4 2\n4 3\n4 4\n0 5\n1 5\n2 5\n3 5\n4 5\n5 0\n5 1\n5 2\n5 3\n5 4\n5 5\n0 6\n1 6\n2 6\n3 6\n4 6\n5 6\n6 0\n6 1\n6 2\n6 3\n6 4\n6 5\n6 6\n0 7\n1 7\n2 7\n3 7\n4 7\n5 7\n6 7\n7 0\n7 1\n7 2\n7 3\n7 4... | code_stdio |
[
{
"content": "There is a rooted tree (see Notes) with N vertices numbered 1 to N. Each of the vertices, except the root, has a directed edge coming from its parent. Note that the root may not be Vertex 1.\n\nTakahashi has added M new directed edges to this graph. Each of these M edges, u \\rightarrow v, extends... | [{"input": "6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n3 6\n6 5", "output": "6\n4\n2\n0\n6\n3\n"}, {"input": "6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n3 6\n4 5", "output": "6\n4\n2\n0\n4\n3\n"}, {"input": "6 3\n3 1\n4 3\n4 1\n4 2\n6 1\n4 6\n3 6\n4 5", "output": "6\n4\n4\n0\n4\n3\n"}, {"input": "6 3\n2 1\n2 3\n4 1\n4 2\n6 1\n2 6\n3 6... | code_stdio |
[
{
"content": "$n$ heroes fight against each other in the Arena. Initially, the $i$-th hero has level $a_i$.\n\nEach minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it is the same two heroes that were fighting during the last minute).\n\nWhen t... | [{"input": "2\n8\n1 9 1 9 8 10 10 10\n5\n10 10 10 10 10\n", "output": "6\n0\n"}, {"input": "2\n8\n1 9 1 9 8 10 10 10\n5\n10 10 10 10 10\n", "output": "6\n0\n"}, {"input": "2\n8\n1 9 1 9 8 10 16 10\n5\n10 10 10 10 10\n", "output": "6\n0\n"}, {"input": "2\n8\n1 9 2 9 8 10 16 10\n5\n10 10 10 10 10\n", "output": "7\n0\n"},... | code_stdio |
[
{
"content": "Lee was cleaning his house for the party when he found a messy string under the carpets. Now he'd like to make it clean accurately and in a stylish way...\n\nThe string $s$ he found is a binary string of length $n$ (i. e. string consists only of 0-s and 1-s).\n\nIn one move he can choose two conse... | [{"input": "5\n10\n0010111111\n4\n0000\n8\n01011111\n10\n1011010100\n1\n0\n", "output": "000111111\n0000\n0011111\n0\n0\n"}, {"input": "5\n10\n0010111111\n4\n1111\n8\n01011111\n10\n1011010100\n1\n0\n", "output": "000111111\n1111\n0011111\n0\n0\n"}, {"input": "5\n10\n0010111111\n4\n0001\n8\n11011111\n10\n1011010100\n1\n... | code_stdio |
[
{
"content": "It is the middle of 2018 and Maria Stepanovna, who lives outside Krasnokamensk (a town in Zabaikalsky region), wants to rent three displays to highlight an important problem.\n\nThere are $n$ displays placed along a road, and the $i$-th of them can display a text with font size $s_i$ only. Maria S... | [{"input": "20\n804301132 586588704 822785255 552472140 16115810 148658854 66743034 628305150 677780684 931815125 208050516 401554301 954478790 571480982 387546138 832279893 641889899 80960260 717802881 172455365\n61699500 83254572 29028223 27833657 55743179 118122387 94729965 147554867 62937826 3626886 131711239 36649... | code_stdio |
[
{
"content": "An African crossword is a rectangular table n × m in size. Each cell of the table contains exactly one letter. This table (it is also referred to as grid) contains some encrypted word that needs to be decoded.\n\nTo solve the crossword you should cross out all repeated letters in rows and columns.... | [{"input": "14 27\npzoshpvvjdpmwfoeojapmkxjrnk\nitoojpcorxjdxrwyewtmmlhjxhx\ndoyopbwusgsmephixzcilxpskxh\nygpvepeuxjbnezdrnjfwdhjwjka\nrfjlbypoalbtjwrpjxzenmeipfg\nkhjhrtktcnajrnbefhpavxxfnlx\nvwlwumqpfegjgvoezevqsolaqih\npdrvrtzqsoujqfeitkqgtxwckrl\nxtepjflcxcrfomhqimhimnzfxzg\nwhkfkfvvjkwmwhfgeovwowshyhw\nolchgmhiehu... | code_stdio |
[
{
"content": "Did you know that Chwee kueh, a cuisine of Singapore, means water rice cake ? Its a variety of the most popular South Indian savory cake, only that we call it here idli :). The tastiest idlis are made in Chennai, by none other than our famous chef, Dexter Murugan. Being very popular, he is flown f... | [{"input": "3\n4\n1 4 2 3\n2\n1 2\n10\n1 0 3 4 1 6 7", "output": "-1\n-1\n-1\n"}, {"input": "3\n4\n1 4 2 3\n2\n1 2\n10\n1 0 3 1 1 6 7", "output": "-1\n-1\n-1\n"}, {"input": "3\n4\n1 4 1 3\n2\n1 2\n7\n1 -1 3 4 6 6 7", "output": "-1\n-1\n-1\n"}, {"input": "3\n4\n1 4 2 3\n2\n1 2\n10\n1 1 3 4 1 6 7", "output": "-1\n-1\n-1\... | code_stdio |
[
{
"content": "You are given $n$ chips on a number line. The $i$-th chip is placed at the integer coordinate $x_i$. Some chips can have equal coordinates.\n\nYou can perform each of the two following types of moves any (possibly, zero) number of times on any chip:\n\n Move the chip $i$ by $2$ to the left or $2$... | [{"input": "66\n17474 17509 20550 10873 31311 10156 24680 28012 29609 8266 18126 20151 648 2722 13599 9467 8289 17005 1 31436 21443 265 21543 32682 11647 30228 15498 1331 8459 20026 24054 23702 15400 7243 3017 10315 451 22673 6648 30210 27673 27232 4178 13529 23071 28654 8969 23505 27681 14437 5230 21635 5033 9271 2559... | code_stdio |
[
{
"content": "The Little Elephant from the Zoo of Lviv has an array A that consists of N positive integers. Let A[i] be the i-th number in this array (i = 1, 2, ..., N).\n\nFind the minimal number x > 1 such that x is a divisor of all integers from array A. More formally, this x should satisfy the following rel... | [{"input": "2\n3\n3 4 16\n3\n1 10 6", "output": "-1\n-1\n"}, {"input": "2\n1\n1 4 6\n1\n1 13 10", "output": "-1\n-1\n"}, {"input": "2\n2\n2 3 8\n3\n0 0 11", "output": "-1\n11\n"}, {"input": "2\n3\n10 5 0\n3\n4 38 3", "output": "5\n-1\n"}, {"input": "2\n1\n2 4 12\n3\n1 12 5", "output": "2\n-1\n"}, {"input": "2\n2\n2 4 1... | code_stdio |
[
{
"content": "Compare given two sequence $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ and $B = \\\\{b_0, b_1, ..., b_{m-1}$ lexicographically.\n\nConstraints\n\n* $1 \\leq n, m \\leq 1,000$\n* $0 \\leq a_i, b_i \\leq 1,000$\n\nInput\n\nThe input is given in the following format.\n\n\n$n$\n$a_0 \\; a_1, ..., \\; a_{n-... | [{"input": "4\n0 4 12 1\n5\n1 2 5 4 1", "output": "1\n"}, {"input": "4\n1 4 1 1\n2\n-1 4 5 4 2", "output": "0\n"}, {"input": "4\n1 4 1 1\n2\n-1 4 9 4 2", "output": "0\n"}, {"input": "4\n1 4 1 1\n2\n-2 4 9 4 2", "output": "0\n"}, {"input": "4\n1 4 1 1\n2\n-4 4 9 4 2", "output": "0\n"}, {"input": "4\n1 4 1 1\n2\n-4 8 9 4... | code_stdio |
[
{
"content": "We have N colored balls arranged in a row from left to right; the color of the i-th ball from the left is c_i.\nYou are given Q queries. The i-th query is as follows: how many different colors do the l_i-th through r_i-th balls from the left have?\n\n-----Constraints-----\n - 1\\leq N,Q \\leq 5 \\... | [{"input": "10 10\n6 5 -1 5 2 0 7 13 14 2\n5 6\n2 4\n6 7\n2 2\n7 8\n7 9\n2 8\n6 9\n8 10\n6 8", "output": "2\n2\n2\n1\n2\n3\n6\n4\n3\n3\n"}, {"input": "10 10\n6 5 -1 5 2 0 7 13 14 2\n5 6\n2 4\n6 7\n2 2\n7 8\n7 9\n2 8\n6 5\n8 10\n6 8", "output": "2\n2\n2\n1\n2\n3\n6\n0\n3\n3\n"}, {"input": "10 10\n6 5 -1 5 2 0 7 13 14 2\... | code_stdio |
[
{
"content": "Vasya is preparing a contest, and now he has written a statement for an easy problem. The statement is a string of length $n$ consisting of lowercase Latin latters. Vasya thinks that the statement can be considered hard if it contains a subsequence hard; otherwise the statement is easy. For exampl... | [{"input": "25\ndadddhrdhradrdzzzahazaddr\n582987584 321035417 414785252 587245865 701672370 65936511 563890835 134108386 387506178 22811155 989335244 1206131752 445085282 809768866 105799145 196558041 1131981383 134067229 875977231 488184174 41982468 225574390 702881847 937432062 185455403\n", "output": "445085282\n"}... | code_stdio |
[
{
"content": "Lesha plays the recently published new version of the legendary game hacknet. In this version character skill mechanism was introduced. Now, each player character has exactly n skills. Each skill is represented by a non-negative integer ai — the current skill level. All skills have the same maximu... | [{"input": "1 1000000000 1000 1000 1000000000000000\n1000000000\n", "output": "1000000001000\n1000000000 \n"}, {"input": "1 1000001000 1000 1000 1000000000000000\n1000000000\n", "output": "1000001001000\n1000001000\n"}, {"input": "1 1000000000 1000 1000 1000000000000010\n1000000000\n", "output": "1000000001000\n1000000... | code_stdio |
[
{
"content": "The \"Bulls and Cows\" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it.\n\nThe thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one... | [{"input": "10\n0132 0 1\n6801 0 1\n8749 1 1\n8036 0 0\n7384 0 2\n8594 0 1\n9307 1 0\n7390 0 1\n6127 1 1\n0381 0 1\n", "output": "Incorrect data\n"}, {"input": "10\n8795 0 3\n4971 1 1\n5032 0 1\n5479 0 3\n2501 0 1\n9052 1 1\n3649 0 1\n1927 1 0\n9173 0 1\n8014 0 2\n", "output": "Incorrect data\n"}, {"input": "10\n9360 0... | code_stdio |
[
{
"content": "We say that a odd number N is similar to 2017 when both N and (N+1)/2 are prime.\nYou are given Q queries.\nIn the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.\n\n-----Constraints-----\n - 1≤Q≤10^5\n - 1≤l_i≤r_i≤10^5\n - l... | [{"input": "6\n1 53\n7 129\n37 55\n19 51\n103 169\n13 33", "output": "4\n4\n1\n1\n1\n1\n"}, {"input": "6\n1 53\n7 129\n65 55\n19 51\n17 169\n13 49", "output": "4\n4\n-1\n1\n4\n2\n"}, {"input": "6\n1 53\n13 91\n37 55\n19 51\n73 91\n13 49\n", "output": "4\n4\n1\n1\n1\n2\n"}, {"input": "6\n1 53\n7 119\n37 55\n19 83\n73 39... | code_stdio |
[
{
"content": "Takahashi likes the sound when he buys a drink from a vending machine.\nThat sound can be heard by spending A yen (the currency of Japan) each time.\nTakahashi has B yen. He will hear the sound as many times as he can with that money, but at most C times, as he would be satisfied at that time.\nHo... | [{"input": "100 100 100\n", "output": "1\n"}, {"input": "1 100 100\n", "output": "100\n"}, {"input": "011 -1 106", "output": "-1\n"}, {"input": "001 -1 106", "output": "-1\n"}, {"input": "101 -1 106", "output": "-1\n"}, {"input": "1 100 99\n", "output": "99\n"}, {"input": "111 -1 33", "output": "-1\n"}, {"input": "001 ... | code_stdio |
[
{
"content": "Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.\n\nThe teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, ... | [{"input": "2+3+3+1+2+2+2+1+1+2+1+3+2+2+3+3+2+2+3+3+3+1+1+1+3+3+3+2+1+3+2+3+2+1+1+3+3+3+1+2+2+1+2+2+1+2+1+3+1+1\n", "output": "1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+2+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3+3\n"}, {"input": "2+1+2+2+1+3+2+3+1+1+2+1+2+2+3+1+1+3+3+3+2+2+3+2+2+2+1+2+1+2+3+2+2+2+1+3+1+3+3... | code_stdio |
[
{
"content": "The development of algae in a pond is as follows.\nLet the total weight of the algae at the beginning of the year i be x_i gram. For i≥2000, the following formula holds:\n - x_{i+1} = rx_i - D\nYou are given r, D and x_{2000}. Calculate x_{2001}, ..., x_{2010} and print them in order.\n\n-----Cons... | [{"input": "28 -2 -1", "output": "-26\n-726\n-20326\n-569126\n-15935526\n-446194726\n-12493452326\n-349816665126\n-9794866623526\n-274256265458726\n"}, {"input": "17 -2 -1", "output": "-15\n-253\n-4299\n-73081\n-1242375\n-21120373\n-359046339\n-6103787761\n-103764391935\n-1763994662893\n"}, {"input": "13 0 -1", "output... | code_stdio |
[
{
"content": "Smeke 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.\nYou are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.\n\n-----Constraints... | [{"input": "1000\n", "output": "ABC\n"}, {"input": "2000\n", "output": "ARC\n"}, {"input": "0000", "output": "ABC\n"}, {"input": "2936", "output": "ARC\n"}, {"input": "0100", "output": "ABC\n"}, {"input": "1432", "output": "ARC\n"}, {"input": "1100", "output": "ABC\n"}, {"input": "1101", "output": "ABC\n"}, {"input": "... | code_stdio |
[
{
"content": "The GCD table G of size n × n for an array of positive integers a of length n is defined by formula \n\n<image>\n\nLet us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest integer that is divisor of both x and y, it is denoted as <image>. For exampl... | [{"input": "5\n537163 537163 537163 537163 537163 537163 1074326 537163 537163 537163 515139317 1074326 537163 537163 537163 539311652 321760637 170817834 537163 537163 537163 537163 537163 537163 392666153\n", "output": "539311652 515139317 392666153 321760637 170817834 "}, {"input": "5\n2029 6087 2029 2029 6087 2029 ... | code_stdio |
[
{
"content": "There is a rectangular grid of size $n \\times m$. Each cell has a number written on it; the number on the cell ($i, j$) is $a_{i, j}$. Your task is to calculate the number of paths from the upper-left cell ($1, 1$) to the bottom-right cell ($n, m$) meeting the following constraints:\n\n You can ... | [{"input": "10 10 524287\n1 2 4 8 16 32 64 128 256 512\n2 4 8 16 32 64 128 256 512 1024\n4 8 16 32 64 128 256 512 1024 2048\n8 16 32 64 128 256 512 1024 2048 4096\n16 32 64 128 256 512 1024 2048 4096 8192\n32 64 128 256 512 1024 2048 4096 8192 16384\n64 128 256 512 1024 2048 4096 8192 16384 32768\n128 256 512 1024 2048... | code_stdio |
[
{
"content": "A subsequence of a string S is a string that can be obtained by deleting zero or more characters from S without changing the order of the remaining characters.\nFor example, arc, artistic and (an empty string) are all subsequences of artistic; abc and ci are not.\nYou are given a string A consisti... | [{"input": "frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhyktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnfgmnjcvtlpnclfkpervxmdbvrbrdn\n", "output": "aca\n"}, {"input": "frqnvhydscshfcgdemurlfrutcpzhopfotpifgepnqjxupnskapziurswqazdwnwbgdhzktfyhqqxpoidfhjdakoxraiedxskywuepzfniuyskxiyjpjlxuqnf... | code_stdio |
[
{
"content": "«One dragon. Two dragon. Three dragon», — the princess was counting. She had trouble falling asleep, and she got bored of counting lambs when she was nine.\n\nHowever, just counting dragons was boring as well, so she entertained herself at best she could. Tonight she imagined that all dragons were... | [{"input": "10\n10\n10\n10\n100000\n", "output": "10000\n"}, {"input": "10\n10\n10\n4\n100000\n", "output": "30000\n"}, {"input": "10\n10\n16\n4\n100000\n", "output": "30000\n"}, {"input": "1\n1\n1\n1\n100000\n", "output": "100000\n"}, {"input": "9\n7\n10\n10\n42357\n", "output": "13312\n"}, {"input": "9\n7\n11\n10\n42... | code_stdio |
[
{
"content": "Mr Keks is a typical white-collar in Byteland.\n\nHe has a bookshelf in his office with some books on it, each book has an integer positive price.\n\nMr Keks defines the value of a shelf as the sum of books prices on it. \n\nMiraculously, Mr Keks was promoted and now he is moving into a new office... | [{"input": "30 4\n893642632982367 772277951746295 510759449350295 826812150840579 1060893142351815 525992742241552 154832018679993 645715002371268 27232975419720 475004229372388 200177708355593 810661468479466 49618609534806 301608930846726 97042172725806 441637617418914 594900693592862 626510702147446 653604971179679 ... | code_stdio |
[
{
"content": "In one school with Vasya there is a student Kostya. Kostya does not like physics, he likes different online games. Every day, having come home, Kostya throws his bag in the farthest corner and sits down at his beloved computer. Kostya even eats glued to the game. A few days ago Kostya bought a new... | [{"input": "3 3 2 5\ndesolator\nrefresher\nperseverance\nvanguard: desolator 1, refresher 1\nmaelstorm: perseverance 2\n1 desolator\n2 perseverance\n1 refresher\n2 desolator\n2 perseverance\n", "output": "1\nvanguard 1\n2\ndesolator 1\nmaelstorm 1\n0\n"}, {"input": "2 3 2 5\ndesolator\nrefresher\nperseverance\nvanguard... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.