messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "The mayor of Amida, the City of Miracle, is not elected like any other city. Once exhausted by long political struggles and catastrophes, the city has decided to leave the fate of all candidates to the lottery in order to choose all candidates fairly and to make those born under the lucky star the...
[{"input": "4 3 1\n3 1 2\n0 1 3\n4 3 4\n1 0 1\n0 0 0", "output": "2\n1\n"}, {"input": "4 3 1\n3 1 1\n0 1 3\n4 3 4\n1 0 1\n0 0 0", "output": "3\n1\n"}, {"input": "6 4 1\n3 -1 2\n2 2 3\n3 3 4\n0 2 4\n0 0 0", "output": "1\n"}, {"input": "6 4 1\n3 -1 2\n2 2 3\n3 3 4\n1 2 4\n0 0 0", "output": "1\n"}, {"input": "4 4 1\n3 2 0...
code_stdio
[ { "content": "Gerald plays the following game. He has a checkered field of size n × n cells, where m various cells are banned. Before the game, he has to put a few chips on some border (but not corner) board cells. Then for n - 1 minutes, Gerald every minute moves each chip into an adjacent cell. He moves each ...
[{"input": "14 5\n4 2\n5 4\n3 3\n2 3\n1 2\n", "output": "17\n"}, {"input": "14 5\n4 2\n3 8\n3 3\n2 3\n1 2\n", "output": "18\n"}, {"input": "14 5\n4 2\n5 4\n3 3\n2 3\n1 1\n", "output": "17\n"}, {"input": "14 5\n4 2\n9 4\n3 3\n2 3\n1 1\n", "output": "17\n"}, {"input": "14 5\n4 2\n9 4\n3 3\n2 3\n1 2\n", "output": "17\n"},...
code_stdio
[ { "content": "Dr. Asimov, a robotics researcher, released cleaning robots he developed (see Problem B). His robots soon became very popular and he got much income. Now he is pretty rich. Wonderful.\n\nFirst, he renovated his house. Once his house had 9 rooms that were arranged in a square, but now his house has...
[{"input": "34 1\n1 6\n2 6\n0 0", "output": "..................................\n.EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE.\n.E..............................E.\n.E.EEEEEEEEEEEEEEEEEEEEEEEEEEEE.E.\n.E.E..........................E.E.\n.E.E.EEEEEEEEEEEEEEEEEEEEEEEE.E.E.\n.E.E.E......................E.E.E.\n.E.E.E.EEEEEEEEEEEEEEEE...
code_stdio
[ { "content": "Vanya is doing his maths homework. He has an expression of form $x_{1} \\diamond x_{2} \\diamond x_{3} \\diamond \\ldots \\diamond x_{n}$, where x_1, x_2, ..., x_{n} are digits from 1 to 9, and sign [Image] represents either a plus '+' or the multiplication sign '*'. Vanya needs to add one pair of...
[{"input": "3+9+3+1+6+4+7+9+5+8+2+6+1+4+4+5+1+7+5+4+6+4+3+1*9+7+7+4+5+2+3+2+6+5+5+8+7+8+2+3*3+8+3+4+9+8*5+9+2+8+2+8+6+6+9+6+4+2+5+3+1+2+6+6+2+4+6+4+2+7+2+7+6+9+9+3+6+7+8+3+3+2+3+7+9+7+8+5+5+5*1+3+2+5+8+5*6+5+4*6+2+5+5+4+9+8+3+5+1+3+1+6+2+2+1+3+2+3+3+3+2+8+3+2+8+8+5+2+6+6+3+1+1+5+5*1+5+7+5+8+4+1*7+5+9+5+8+1*8+5+9+3+1+8+...
code_stdio
[ { "content": "Mr. Funt now lives in a country with a very specific tax laws. The total income of mr. Funt during this year is equal to n (n ≥ 2) burles and the amount of tax he has to pay is calculated as the maximum divisor of n (not equal to n, of course). For example, if n = 6 then Funt has to pay 3 burles, ...
[{"input": "1999999927\n", "output": "1\n"}, {"input": "1000000009\n", "output": "1\n"}, {"input": "1847133842\n", "output": "2\n"}, {"input": "1076153021\n", "output": "3\n"}, {"input": "1908903481\n", "output": "3\n"}, {"input": "2000000000\n", "output": "2\n"}, {"input": "1000000007\n", "output": "1\n"}, {"input": "...
code_stdio
[ { "content": "Vasya is writing an operating system shell, and it should have commands for working with directories. To begin with, he decided to go with just two commands: cd (change the current directory) and pwd (display the current directory).\n\nDirectories in Vasya's operating system form a traditional hie...
[{"input": "11\npwd\ncd /home/vasya\npwd\ncd ..\npwd\ncd vasya/../../petya\npwd\ncd /a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a/a\npwd\ncd ..\npwd\n", "output": "/\n/h...
code_stdio
[ { "content": "Alice and Bob are playing a game with $n$ piles of stones. It is guaranteed that $n$ is an even number. The $i$-th pile has $a_i$ stones.\n\nAlice and Bob will play a game alternating turns with Alice going first.\n\nOn a player's turn, they must choose exactly $\\frac{n}{2}$ nonempty piles and in...
[{"input": "50\n42 31 49 11 28 38 49 32 15 22 10 18 43 39 46 32 10 19 13 32 19 40 34 28 28 39 19 3 1 47 10 18 19 31 21 7 39 37 34 45 19 21 35 46 10 24 45 33 20 40\n", "output": "Alice\n"}, {"input": "50\n42 31 49 11 28 38 49 32 15 22 10 18 43 39 46 32 10 19 13 32 19 40 34 28 28 39 19 3 1 47 10 18 19 31 21 7 39 37 34 45...
code_stdio
[ { "content": "# Task\n\nWrite a function `deNico`/`de_nico()` that accepts two parameters:\n- `key`/`$key` - string consists of unique letters and digits\n- `message`/`$message` - string with encoded message \n\nand decodes the `message` using the `key`. \n\nFirst create a numeric key basing on the provided `k...
[{"input": "\"crazy\"\n\"cseerntiofarmit on \"", "output": "[\"secretinformation\"]", "fn_name": "de_nico"}, {"input": "\"crazy\"\n\"cseerntiofarmit on\"", "output": "[\"secretinformation\"]", "fn_name": "de_nico"}, {"input": "\"ba\"\n\"2143658709\"", "output": "[\"1234567890\"]", "fn_name": "de_nico"}, {"input": "\"a...
code_functional
[ { "content": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges.\n\nThe i-th (1≤i≤M) edge connects vertex a_i and vertex b_i with a distance of c_i.\n\nHere, a self-loop is an edge where a_i = b_i (1≤i≤M), and double edges are two ...
[{"input": "100 1000\n1 2 1\n1 3 1\n1 4 1\n1 5 1\n1 6 1\n1 7 1\n1 8 1\n1 9 1\n1 10 1\n1 11 1\n1 12 1\n1 13 1\n1 14 1\n1 15 1\n1 16 1\n1 17 1\n1 18 1\n1 19 1\n1 20 1\n1 21 1\n1 22 1\n1 23 1\n1 24 1\n1 25 1\n1 26 1\n1 27 1\n1 28 1\n1 29 1\n1 30 1\n1 31 1\n1 32 1\n1 33 1\n1 34 1\n1 35 1\n1 36 1\n1 37 1\n1 38 1\n1 39 1\n1 ...
code_stdio
[ { "content": "Ivan is collecting coins. There are only $N$ different collectible coins, Ivan has $K$ of them. He will be celebrating his birthday soon, so all his $M$ freinds decided to gift him coins. They all agreed to three terms: Everyone must gift as many coins as others. All coins given to Ivan must be d...
[{"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "-1\n"}, {"input": "1000000000000000000 1000000000000000000 1000010000000000000 1000000000000000000\n", "output": "-1\n"}, {"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\...
code_stdio
[ { "content": "A film festival is coming up in the city N. The festival will last for exactly n days and each day will have a premiere of exactly one film. Each film has a genre — an integer from 1 to k.\n\nOn the i-th day the festival will show a movie of genre a_{i}. We know that a movie of each of k genres oc...
[{"input": "129 37\n15 22 28 15 30 16 11 20 4 26 14 37 29 17 15 15 14 18 1 9 16 22 13 32 5 18 25 11 6 33 33 22 17 9 1 5 27 27 37 4 6 1 3 18 17 33 6 17 2 24 23 1 1 37 35 21 21 17 18 6 31 17 29 18 10 10 30 31 8 3 25 20 34 11 12 12 24 13 5 27 20 31 28 1 36 2 4 13 14 9 33 25 4 26 36 6 2 7 15 9 20 33 24 33 28 12 23 1 28 12 ...
code_stdio
[ { "content": "The problem describes the properties of a command line. The description somehow resembles the one you usually see in real operating systems. However, there are differences in the behavior. Please make sure you've read the statement attentively and use it as a formal document.\n\nIn the Pindows ope...
[{"input": "\"RUn.exe O\" \"\" \" 2ne, \" two! . \" \"\n", "output": "<RUn.exe O>\n<>\n< 2ne, >\n<two!>\n<.>\n< >\n"}, {"input": "\"RUn.exe O\" \"\" \" 2ne, \" two! . \" \"\n", "output": "<RUn.exe O>\n<>\n< 2ne, >\n<two!>\n<.>\n< >\n"}, {"input": "\"RUn.exe N\" \"\" \" 2ne, \" two! . \" \"\n", "output": "<RUn...
code_stdio
[ { "content": "You are an adventurer currently journeying inside an evil temple. After defeating a couple of weak zombies, you arrived at a square room consisting of tiles forming an n × n grid. The rows are numbered 1 through n from top to bottom, and the columns are numbered 1 through n from left to right. At ...
[{"input": "17\n.EEEEE...EEEE..EE\nEEE..E...EEEEE..E\n.E..E..EEE.EE...E\n.EEE.EE..EE...E..\nE..EEEEEE.EE.....\nE.EE...EEEEEEE.E.\nEEEE....EE..E.EEE\n...EEEEE.E..EE...\nEEE.E..EEEE.EEE..\n..E.E....EEE.....\nEE..E..E.E..EEEEE\nEEE..E.EEEEE.E...\n..EEEEE.E..EE.EE.\nEE.E...E..E..E.EE\n..E.EEE.EE..EE.E.\nE..EE........E.E.\n...
code_stdio
[ { "content": "Imagine a triangle of numbers which follows this pattern:\n\n * Starting with the number \"1\", \"1\" is positioned at the top of the triangle. As this is the 1st row, it can only support a single number.\n * The 2nd row can support the next 2 numbers: \"2\" and \"3\"\n * Likewise, the 3rd row, ca...
[{"input": "10000", "output": "[500000005000]", "fn_name": "cumulative_triangle"}, {"input": "1000", "output": "[500000500]", "fn_name": "cumulative_triangle"}, {"input": "500", "output": "[62500250]", "fn_name": "cumulative_triangle"}, {"input": "150", "output": "[1687575]", "fn_name": "cumulative_triangle"}, {"input"...
code_functional
[ { "content": "You are given a sequence A_1, A_2, ..., A_N and an integer K.\n\nPrint the maximum possible length of a sequence B that satisfies the following conditions:\n\n* B is a (not necessarily continuous) subsequence of A.\n* For each pair of adjacents elements of B, the absolute difference of the element...
[{"input": "10 3\n1\n5\n2\n1\n1\n6\n11\n11\n4\n2", "output": "6\n"}, {"input": "10 3\n0\n5\n4\n3\n14\n11\n9\n5\n3\n4", "output": "6\n"}, {"input": "10 3\n0\n5\n4\n3\n11\n11\n9\n7\n6\n1", "output": "5\n"}, {"input": "10 1\n2\n8\n0\n3\n8\n11\n14\n7\n6\n1", "output": "4\n"}, {"input": "10 3\n1\n5\n2\n1\n1\n6\n12\n11\n4\n2...
code_stdio
[ { "content": "You are given two matrices $A$ and $B$. Each matrix contains exactly $n$ rows and $m$ columns. Each element of $A$ is either $0$ or $1$; each element of $B$ is initially $0$.\n\nYou may perform some operations with matrix $B$. During each operation, you choose any submatrix of $B$ having size $2 \...
[{"input": "5 50\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0\...
code_stdio
[ { "content": "Chef Shifu and Chef Po are participating in the Greatest Dumpling Fight of 2012.\nOf course, Masterchef Oogway has formed the rules of the fight.\n\nThere is a long horizontal rope of infinite length with a center point P.\nInitially both Chef Shifu and Chef Po will stand on the center P of the ro...
[{"input": "3\n2 4 3 8 12\n1 4 0 2 -1\n11 22 10 18 16", "output": "13\n-1\n1\n"}, {"input": "3\n2 4 3 8 12\n1 4 4 2 -1\n10 22 12 9 16", "output": "13\n-1\n5\n"}, {"input": "3\n2 4 3 8 12\n1 4 0 2 -1\n11 22 10 7 16", "output": "13\n-1\n3\n"}, {"input": "3\n3 4 3 11 12\n1 6 0 1 0\n19 14 16 1 16", "output": "25\n1\n33\n"}...
code_stdio
[ { "content": "Interest rates are attached to the money deposited in banks, and the calculation method and interest rates vary from bank to bank. The combination of interest and principal is called principal and interest, but as a method of calculating principal and interest, there are \"single interest\" that c...
[{"input": "2\n7\n1 5 2\n-1 9 2\n2\n14\n1 5 2\n-1 13 1\n0", "output": "-1\n-1\n"}, {"input": "2\n7\n1 5 2\n-1 12 2\n2\n14\n0 5 2\n0 10 1\n0", "output": "-1\n0\n"}, {"input": "2\n14\n1 3 0\n17 6 2\n2\n12\n1 5 2\n1 12 1\n0", "output": "17\n1\n"}, {"input": "2\n25\n1 10 1\n3 7 2\n2\n7\n-1 16 1\n1 1 0\n0", "output": "3\n-1...
code_stdio
[ { "content": "Ostap already settled down in Rio de Janiero suburb and started to grow a tree in his garden. Recall that a tree is a connected undirected acyclic graph. \n\nOstap's tree now has n vertices. He wants to paint some vertices of the tree black such that from any vertex u there is at least one black v...
[{"input": "64 3\n13 10\n60 54\n23 35\n4 41\n59 18\n41 36\n48 13\n64 8\n30 19\n53 3\n34 11\n24 27\n21 25\n5 55\n51 11\n3 45\n24 57\n47 38\n55 26\n8 20\n29 42\n44 3\n7 15\n9 1\n17 4\n41 9\n15 29\n60 13\n31 36\n53 52\n59 14\n12 52\n24 31\n47 28\n29 23\n2 49\n30 44\n28 31\n25 22\n9 58\n64 11\n45 35\n59 44\n62 8\n49 53\n32...
code_stdio
[ { "content": "We have N balance beams numbered 1 to N. The length of each beam is 1 meters. Snuke walks on Beam i at a speed of 1/A_i meters per second, and Ringo walks on Beam i at a speed of 1/B_i meters per second.\n\nSnuke and Ringo will play the following game:\n\n* First, Snuke connects the N beams in any...
[{"input": "10\n1375710043 178537096\n1332309236 80797230\n164044598 544580992\n117241210 865935868\n383133839 231371336\n378371075 681212831\n304570952 16537461\n1789737664 267238505\n844917655 218662351\n662961957 100386692", "output": "1121712759 3406064155"}, {"input": "10\n646213683 228215172\n705445072 318106937\...
code_stdio
[ { "content": "You are given a sequence a1, a2, ..., aN. Find the smallest possible value of ai + aj, where 1 ≤ i < j ≤ N.\n\n-----Input-----\nThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. \nThe first line of each description consist...
[{"input": "1\n4\n15 1 11 10", "output": "11\n"}, {"input": "1\n4\n16 2 20 10", "output": "12\n"}, {"input": "1\n4\n-4 -1 0 -2", "output": "-6\n"}, {"input": "1\n4\n2 -1 0 -2", "output": "-3\n"}, {"input": "1\n4\n-1 1 0 -3", "output": "-4\n"}, {"input": "1\n4\n-2 1 0 -3", "output": "-5\n"}, {"input": "1\n4\n16 2 11 8",...
code_stdio
[ { "content": "Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:\n\n\nSelectionSort(A)\n1 for i = 0 to A.length-1\n2 mini = i\n3 for j = i to A.length-1\n4 if A[j] < A[mini]\n5 mini =...
[{"input": "6\n-1 -1 -1 1 -1 -1", "output": "-1 -1 -1 -1 -1 1\n2\n"}, {"input": "6\n-1 -1 -1 1 -2 -1", "output": "-2 -1 -1 -1 -1 1\n3\n"}, {"input": "6\n-1 -1 -1 1 -3 -1", "output": "-3 -1 -1 -1 -1 1\n3\n"}, {"input": "6\n-1 -1 -1 1 -4 -1", "output": "-4 -1 -1 -1 -1 1\n3\n"}, {"input": "6\n-1 -1 0 1 -3 -1", "output": "...
code_stdio
[ { "content": "# Explanation\n\nIt's your first day in the robot factory and your supervisor thinks that you should start with an easy task. So you are responsible for purchasing raw materials needed to produce the robots.\n\nA complete robot weights `50` kilogram. Iron is the only material needed to create a ro...
[{"input": "[38, 38, 73, 9, 3, 47, 86, 67, 75, 52, 46, 86, 30, 37, 80, 48, 52, 0, 85, 72]\n11", "output": "[29229344539]", "fn_name": "calculate_scrap"}, {"input": "[71, 82, 47, 72, 5, 75, 69, 30, 16, 43, 10, 11, 64, 53, 12, 78, 23, 7, 24, 85]\n12", "output": "[1465387910]", "fn_name": "calculate_scrap"}, {"input": "[4...
code_functional
[ { "content": "Kicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of each team controls the goalkeeper and the full-backs (plays defence), the othe...
[{"input": "1 100\n100 1\n99 99\n99 99\n", "output": "Team 1\n"}, {"input": "80 79\n79 30\n80 81\n40 80\n", "output": "Team 2\n"}, {"input": "48 41\n15 47\n11 38\n19 31\n", "output": "Team 1\n"}, {"input": "51 54\n95 28\n42 28\n17 48\n", "output": "Team 1\n"}, {"input": "19 56\n59 46\n40 70\n67 34\n", "output": "Team 2...
code_stdio
[ { "content": "Professor GukiZ is concerned about making his way to school, because massive piles of boxes are blocking his way. \n\nIn total there are n piles of boxes, arranged in a line, from left to right, i-th pile (1 ≤ i ≤ n) containing ai boxes. Luckily, m students are willing to help GukiZ by removing al...
[{"input": "5 3\n999999999 999999999 999999999 999999999 19992232\n", "output": " 1339997413"}, {"input": "19 100000\n1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1\n", "output": " 20"}, {"input": "20 20\n0 0 0 0 0 ...
code_stdio
[ { "content": "Did you hear about the Nibiru collision ? It is a supposed disastrous encounter between the earth and a large planetary object. Astronomers reject this idea. But why listen to other people's beliefs and opinions. We are coders above all, so what better way than to verify it by a small code. The ea...
[{"input": "3\n-1 0 R\n2\n1 -1 U\n1 1 D\n1 1 U\n1\n1 0 U\n0 0 R\n1\n4 -1 L", "output": "SAFE\nSAFE\nSAFE\n"}, {"input": "3\n0 0 R\n2\n1 -4 U\n2 3 D\n1 2 U\n1\n2 -1 U\n0 0 R\n1\n7 1 L", "output": "SAFE\nSAFE\nSAFE\n"}, {"input": "3\n0 0 R\n2\n1 -4 U\n2 3 D\n0 2 U\n1\n2 -1 U\n0 0 R\n1\n7 1 L", "output": "SAFE\nSAFE\nSAFE...
code_stdio
[ { "content": "Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: \"Little bears, wait a little, I want to make your pieces ...
[{"input": "1488496828 607500000\n", "output": "-1\n"}, {"input": "1183431925 540244525\n", "output": "-1\n"}, {"input": "1270836736 387420489\n", "output": "-1\n"}, {"input": "100000007 800000011\n", "output": "-1\n"}, {"input": "900000011 800000011\n", "output": "-1\n"}, {"input": "900000011 999900017\n", "output": "...
code_stdio
[ { "content": "We call a 4-digit integer with three or more consecutive same digits, such as 1118, good.\nYou are given a 4-digit integer N. Answer the question: Is N good?\n\n-----Constraints-----\n - 1000 ≤ N ≤ 9999\n - N is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following fo...
[{"input": "1118\n", "output": "Yes\n"}, {"input": "7777\n", "output": "Yes\n"}, {"input": "1234\n", "output": "No\n"}, {"input": "4000", "output": "Yes\n"}, {"input": "15093", "output": "No\n"}, {"input": "12733", "output": "No\n"}, {"input": "24549", "output": "No\n"}, {"input": "16730", "output": "No\n"}, {"input": ...
code_stdio
[ { "content": "During the last Sereja's Codesecrof round the server crashed many times, so the round was decided to be made unrated for some participants. \n\nLet's assume that n people took part in the contest. Let's assume that the participant who got the first place has rating a_1, the second place participan...
[{"input": "10 -6\n5 2 1 9 5 2 4 4 9 2\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 -6\n5 2 1 8 5 2 4 4 9 2\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 0\n5 14 1 1 5 1 1 4 9 2\n", "output": "2\n3\n4\n5\n6\n7\n8\n9\n"}, {"input": "10 -4\n5 4 1 7 5 1 2 4 15 2\n", "output": "2\n3\n4\n5\n7\n8\n9\n"...
code_stdio
[ { "content": "# Task\nImagine `n` horizontal lines and `m` vertical lines.\n\nSome of these lines intersect, creating rectangles.\n\nHow many rectangles are there?\n\n# Examples\n\nFor `n=2, m=2,` the result should be `1`.\n\nthere is only one 1x1 rectangle.\n\nFor `n=2, m=3`, the result should be `3`.\n\nthere...
[{"input": "100\n100", "output": "[24502500]", "fn_name": "rectangles"}, {"input": "2\n3", "output": "[3]", "fn_name": "rectangles"}, {"input": "2\n2", "output": "[1]", "fn_name": "rectangles"}, {"input": "1\n1", "output": "[0]", "fn_name": "rectangles"}, {"input": "0\n1", "output": "[0]", "fn_name": "rectangles"}, {"i...
code_functional
[ { "content": "Dawid has four bags of candies. The i-th of them contains a_i candies. Also, Dawid has two friends. He wants to give each bag to one of his two friends. Is it possible to distribute the bags in such a way that each friend receives the same amount of candies in total?\n\nNote, that you can't keep b...
[{"input": "100 100 100 100\n", "output": "YES\n"}, {"input": "100 101 100 100\n", "output": "NO\n"}, {"input": "100 101 99 100\n", "output": "YES\n"}, {"input": "100 100 99 100\n", "output": "NO\n"}, {"input": "100 98 99 97\n", "output": "YES\n"}, {"input": "70 100 10 86\n", "output": "NO\n"}, {"input": "76 97 99 74\n...
code_stdio
[ { "content": "Given are integers S and P.\nIs there a pair of positive integers (N,M) such that N + M = S and N \\times M = P?\n\n-----Constraints-----\n - All values in input are integers.\n - 1 \\leq S,P \\leq 10^{12}\n\n-----Input-----\nInput is given from Standard Input in the following format:\nS P\n\n----...
[{"input": "1000000000000 999999999999\n", "output": "Yes\n"}, {"input": "50000000002 100000000000\n", "output": "Yes\n"}, {"input": "978530427494 321593407609\n", "output": "No\n"}, {"input": "203939391324 871114841657\n", "output": "No\n"}, {"input": "119381456309 353176041209\n", "output": "No\n"}, {"input": "340495...
code_stdio
[ { "content": "Input\n\nThe input contains two integers a1, a2 (0 ≤ ai ≤ 109), separated by a single space.\n\nOutput\n\nOutput a single integer.\n\nExamples\n\nInput\n\n3 14\n\n\nOutput\n\n44\n\n\nInput\n\n27 12\n\n\nOutput\n\n48\n\n\nInput\n\n100 200\n\n\nOutput\n\n102\n\nWrite Python code to solve this proble...
[{"input": "1000000000 1000000000\n", "output": "1000000001\n"}, {"input": "1000000000 0000000000\n", "output": "1000000000\n"}, {"input": "1000000000 999999999\n", "output": "1999999999\n"}, {"input": "937477084 827336327\n", "output": "1661110812\n"}, {"input": "957747793 424238335\n", "output": "1491580217\n"}, {"in...
code_stdio
[ { "content": "For given a sequence $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$, print the previous permutation and the next permutation in lexicographic order.\n\nConstraints\n\n* $1 \\leq n \\leq 9$\n* $a_i$ consist of $1, 2, ..., n$\n\nInput\n\nA sequence is given in the following format.\n\n\n$n$\n$a_0 \\; a_1 \\...
[{"input": "3\n-1 12 -1", "output": "-1 -1 12\n-1 12 -1\n12 -1 -1\n"}, {"input": "3\n-1 16 -1", "output": "-1 -1 16\n-1 16 -1\n16 -1 -1\n"}, {"input": "3\n-1 13 -1", "output": "-1 -1 13\n-1 13 -1\n13 -1 -1\n"}, {"input": "3\n-1 18 -1", "output": "-1 -1 18\n-1 18 -1\n18 -1 -1\n"}, {"input": "3\n-1 20 -1", "output": "-1 ...
code_stdio
[ { "content": "problem\n\nOnce upon a time there were settlements and many people lived there. People built buildings of various shapes and sizes. But those buildings have already been lost, only the literature and the pillars found in the ruins. Was a clue to the location of the building.\n\nThere is a descript...
[{"input": "10\n2 0\n1 1\n1 0\n1 -1\n2 5\n0 1\n2 1\n1 4\n1 14\n18 1\n10\n4 14\n4 0\n2 1\n0 2\n1 4\n0 5\n4 1\n1 1\n2 6\n5 -1\n0", "output": "1\n0\n"}, {"input": "10\n16 0\n0 1\n1 1\n1 0\n2 7\n0 3\n3 1\n1 3\n1 14\n18 2\n10\n2 7\n5 5\n2 1\n0 2\n1 4\n1 4\n4 1\n1 1\n1 6\n5 4\n0", "output": "0\n17\n"}, {"input": "10\n16 4\n4...
code_stdio
[ { "content": "There are N empty boxes arranged in a row from left to right.\nThe integer i is written on the i-th box from the left (1 \\leq i \\leq N).\nFor each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.\nWe say a set of choices to put a ball or not in the boxes is go...
[{"input": "16416\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 1 1 1 1 1 1 1 1 1 1 1 1 1...
code_stdio
[ { "content": "Consider 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 ⊕ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_oper...
[{"input": "9\n2\n2\n6\n4\n14\n11\n13\n8\n17\n", "output": "2\n2\n12\n4\n9\n11\n7\n10\n32\n"}, {"input": "9\n2\n2\n3\n4\n10\n12\n12\n8\n11\n", "output": "2\n2\n3\n4\n6\n13\n13\n10\n11\n"}, {"input": "9\n2\n2\n6\n4\n14\n17\n13\n8\n17\n", "output": "2\n2\n12\n4\n9\n32\n7\n10\n32\n"}, {"input": "9\n2\n2\n3\n4\n8\n10\n20\n...
code_stdio
[ { "content": "Recently, the Fair Nut has written k strings of length n, consisting of letters \"a\" and \"b\". He calculated c — the number of strings that are prefixes of at least one of the written strings. Every string was counted only one time.\n\nThen, he lost his sheet with strings. He remembers that all ...
[{"input": "100 1000000000\nbbabbaabbbaaaaabbabbbaaabbbbabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbaabbbbabaabbbabbaaaaabbbbaab\nbbabbaabbbaaaaabbabbbaaabbbbabbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaababbbabbbbaaaaabbaaaaaaaab\n", "output": "41073741883\n"}, {"input": "100 1000000000\naaaaaaaaaaabbaaaaabbbababaaaab...
code_stdio
[ { "content": "Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered from 1 to n. Each edge, namely edge i, has a color c_{i}, connecting vertex a_{i} and b_{i}.\n\nMr. Kitayuta wants you to process the following q queries.\n\nIn the i-th qu...
[{"input": "5 7\n1 5 1\n2 5 1\n3 5 1\n4 5 1\n1 2 2\n2 3 2\n3 4 2\n5\n1 5\n5 1\n2 5\n1 5\n1 4\n", "output": "1\n1\n1\n1\n2\n"}, {"input": "5 7\n1 1 1\n2 5 1\n3 5 1\n4 5 1\n1 2 2\n2 3 2\n3 4 2\n5\n1 5\n5 1\n2 5\n1 5\n1 4\n", "output": "0\n0\n1\n0\n1\n"}, {"input": "5 7\n1 1 1\n2 5 1\n3 5 1\n4 5 2\n1 2 2\n2 3 2\n3 4 2\n5\...
code_stdio
[ { "content": "You are given a bracket sequence consisting of $n$ characters '(' and/or )'. You perform several operations with it.\n\nDuring one operation, you choose the shortest prefix of this string (some amount of first characters of the string) that is good and remove it from the string.\n\nThe prefix is c...
[{"input": "8\n3\n)()\n8\n)()()(((\n4\n(()(\n5\n(())(\n6\n))((()\n5\n))())\n1\n)\n2\n)(\n", "output": "1 0\n3 1\n1 2\n2 1\n3 0\n2 1\n0 1\n0 2\n"}, {"input": "5\n3\n)()\n8\n)()()(((\n4\n(()(\n5\n(())(\n6\n))((()\n", "output": "1 0\n3 1\n1 2\n2 1\n3 0\n"}, {"input": "5\n2\n()\n3\n())\n4\n((((\n5\n)((()\n6\n)((()(\n", "ou...
code_stdio
[ { "content": "Welcome! Everything is fine.\n\nYou have arrived in The Medium Place, the place between The Good Place and The Bad Place. You are assigned a task that will either make people happier or torture them for eternity.\n\nYou have a list of k pairs of people who have arrived in a new inhabited neighborh...
[{"input": "2\n3\n1 2 3\n3 2 4\n2 4 0\n4 5 10\n5 6 5\n1\n1 2 2\n1 5 2\n1 4 6\n", "output": "12 32\n2 2\n"}, {"input": "2\n3\n1 2 3\n3 2 4\n2 4 3\n4 5 6\n5 6 5\n2\n1 2 1\n1 3 0\n1 4 3\n", "output": "15 33\n4 4\n"}, {"input": "2\n3\n1 2 3\n3 2 4\n2 4 3\n4 5 6\n5 6 5\n2\n1 2 0\n1 3 2\n1 4 3\n", "output": "15 33\n5 5\n"}, ...
code_stdio
[ { "content": "Dreamoon likes coloring cells very much.\n\nThere is a row of $n$ cells. Initially, all cells are empty (don't contain any color). Cells are numbered from $1$ to $n$.\n\nYou are given an integer $m$ and $m$ integers $l_1, l_2, \\ldots, l_m$ ($1 \\le l_i \\le n$)\n\nDreamoon will perform $m$ operat...
[{"input": "2000 100\n5 128 1368 1679 1265 313 1854 1512 1924 338 38 1971 238 1262 1834 1878 1749 784 770 1617 191 395 303 214 1910 1300 741 1966 1367 24 268 403 1828 1033 1424 218 1146 925 1501 1760 1164 1881 1628 1596 1358 1360 29 1343 922 618 1537 1839 1114 1381 704 464 692 1450 1590 1121 670 300 1053 1730 1024 1292...
code_stdio
[ { "content": "### Description:\n\n Remove all exclamation marks from sentence except at the end.\n\n### Examples\n\n```\nremove(\"Hi!\") == \"Hi!\"\nremove(\"Hi!!!\") == \"Hi!!!\"\nremove(\"!Hi\") == \"Hi\"\nremove(\"!Hi!\") == \"Hi!\"\nremove(\"Hi! Hi!\") == \"Hi Hi!\"\nremove(\"Hi\") == \"Hi\"\n```\n\nWrite P...
[{"input": "\"Hi! Hi!\"", "output": "[\"Hi Hi!\"]", "fn_name": "remove"}, {"input": "\"Hi!!!\"", "output": "[\"Hi!!!\"]", "fn_name": "remove"}, {"input": "\"!Hi!\"", "output": "[\"Hi!\"]", "fn_name": "remove"}, {"input": "\"Hi!\"", "output": "[\"Hi!\"]", "fn_name": "remove"}, {"input": "\"!Hi\"", "output": "[\"Hi\"]", ...
code_functional
[ { "content": "Given a string of characters, I want the function `findMiddle()`/`find_middle()` to return the middle number in the product of each digit in the string.\n\nExample: 's7d8jd9' -> 7, 8, 9 -> 7\\*8\\*9=504, thus 0 should be returned as an integer.\n\nNot all strings will contain digits. In this case ...
[{"input": "\"asd.f855dasd.gasdfgsdfgh-sdfghsdfg/asdfga=sdfg\"", "output": "[0]", "fn_name": "find_middle"}, {"input": "\"asd.fasd.ga654sdfgsdfgh-sdfghsdfg/asdfga=sdfg\"", "output": "[2]", "fn_name": "find_middle"}, {"input": "\"asd.fasd.gasdfgsdfgh-sdfghsdfg/asdfga=sdfg\"", "output": "[-1]", "fn_name": "find_middle"},...
code_functional
[ { "content": "You are the head of a large enterprise. $n$ people work at you, and $n$ is odd (i. e. $n$ is not divisible by $2$).\n\nYou have to distribute salaries to your employees. Initially, you have $s$ dollars for it, and the $i$-th employee should get a salary from $l_i$ to $r_i$ dollars. You have to dis...
[{"input": "3\n3 26\n10 12\n1 4\n13 26\n1 1337\n-1 1000000001\n5 26\n4 3\n1 4\n3 7\n2 12\n2 14\n", "output": "12\n1337\n7\n"}, {"input": "3\n3 25\n10 12\n1 4\n10 13\n1 1337\n1 1000000001\n5 26\n4 3\n0 4\n3 11\n2 12\n2 14\n", "output": "12\n1337\n7\n"}, {"input": "3\n3 26\n10 12\n1 4\n13 26\n1 1337\n-1 1000000001\n5 26\...
code_stdio
[ { "content": "Valery is very interested in magic. Magic attracts him so much that he sees it everywhere. He explains any strange and weird phenomenon through intervention of supernatural forces. But who would have thought that even in a regular array of numbers Valera manages to see something beautiful and magi...
[{"input": "150\n0 -2 1 -2 0 0 0 0 -2 0 -2 -1 0 0 2 0 1 -2 1 -1 0 0 0 2 -2 2 -1 0 0 0 -2 0 2 0 1 0 -2 0 -2 -1 -1 -2 -2 2 0 0 1 -2 -2 -1 -2 0 2 1 1 -1 1 0 -2 2 0 0 0 1 -1 0 -2 -1 0 -2 2 1 1 0 0 2 0 0 2 -1 0 0 2 0 2 0 -2 -1 1 -2 1 0 0 -2 -1 -1 0 0 2 -1 -1 -1 -1 -2 0 0 2 -1 -1 1 0 0 1 -1 0 0 -1 2 2 0 0 0 -1 -2 0 1 0 -1 0 ...
code_stdio
[ { "content": "We had a string s consisting of n lowercase Latin letters. We made k copies of this string, thus obtaining k identical strings s_1, s_2, ..., s_{k}. After that, in each of these strings we swapped exactly two characters (the characters we swapped could be identical, but they had different indices ...
[{"input": "100 3\nzsk\nzsk\nzsk\nzsk\nskz\nskz\nkzs\nskz\nkzs\nkzs\nzsk\nkzs\nkzs\nkzs\nskz\nkzs\nskz\nskz\nkzs\nzsk\nkzs\nkzs\nkzs\nskz\nskz\nskz\nzsk\nskz\nzsk\nskz\nkzs\nskz\nskz\nskz\nkzs\nzsk\nzsk\nkzs\nskz\nskz\nkzs\nkzs\nskz\nkzs\nkzs\nskz\nkzs\nskz\nkzs\nkzs\nskz\nkzs\nkzs\nkzs\nkzs\nskz\nkzs\nskz\nskz\nskz\ns...
code_stdio
[ { "content": "One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if she had arranged the numbers correctly, but ...
[{"input": "50\n363510947 363510954 363510943 363510964 363510969 363510950 363510951 363510960 363510967 363510952 363510956 363510948 363510944 363510946 363510965 363510946 363510963 363510962 363510947 363510955 363510954 363510948 363510961 363510964 363510963 363510945 363510965 363510953 363510952 363510968 3635...
code_stdio
[ { "content": "Wilbur is playing with a set of n points on the coordinate plane. All points have non-negative integer coordinates. Moreover, if some point (x, y) belongs to the set, then all points (x', y'), such that 0 ≤ x' ≤ x and 0 ≤ y' ≤ y also belong to this set.\n\nNow Wilbur wants to number the points in ...
[{"input": "40\n0 0\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n0 7\n0 8\n0 9\n0 10\n0 11\n0 12\n1 0\n1 1\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n2 0\n3 0\n4 0\n5 0\n6 0\n7 0\n8 0\n9 0\n10 0\n11 0\n12 0\n13 0\n14 0\n15 0\n16 0\n17 0\n18 0\n19 0\n20 0\n0 1 2 -1 -2 3 4 -3 5 6 7 8 0 -4 -5 1 -6 -7 -8 -9 -10 -11 9 2 -12 -13 -14 3 10 -15 11 4 -16...
code_stdio
[ { "content": "One day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm × b mm sheet of paper (a > b). Usually the first step in making an origami is making a square piece of paper from the rectangular sheet by folding the sheet along the bisector of the righ...
[{"input": "1000000000000 999999999999\n", "output": "1000000000000\n"}, {"input": "1000000000000 999999999999\n", "output": "1000000000000\n"}, {"input": "1000000000000 999999999998\n", "output": "500000000000\n"}, {"input": "1000000000000 999999999998\n", "output": "500000000000\n"}, {"input": "1370863279309 12652739...
code_stdio
[ { "content": "Little Petya likes arrays that consist of non-negative integers a lot. Recently his mom has presented him one such array consisting of n elements. Petya immediately decided to find there a segment of consecutive elements, such that the xor of all numbers from this segment was maximal possible. Hel...
[{"input": "99\n3511 2076 9314 3598 7737 271 4110 4454 5830 8661 8584 8227 2236 2626 1025 3806 3162 2837 6071 9627 1836 7729 6629 4054 9377 3261 1325 8859 3610 7616 5052 9736 1249 6224 7031 6074 4196 8075 4005 5419 5664 8214 4391 731 8714 8622 6122 6976 4057 1770 8025 3778 2792 994 5204 1826 6083 5438 8409 8029 1962 31...
code_stdio
[ { "content": "Consider the array `[3,6,9,12]`. If we generate all the combinations with repetition that sum to `12`, we get `5` combinations: `[12], [6,6], [3,9], [3,3,6], [3,3,3,3]`. The length of the sub-arrays (such as `[3,3,3,3]` should be less than or equal to the length of the initial array (`[3,6,9,12]`)...
[{"input": "[3, 6, 9, 12, 14, 18]\n30", "output": "[21]", "fn_name": "find"}, {"input": "[3, 6, 9, 12]\n12", "output": "[5]", "fn_name": "find"}, {"input": "[3, 6, 9, 12]\n15", "output": "[5]", "fn_name": "find"}, {"input": "[1, 4, 5, 8]\n8", "output": "[3]", "fn_name": "find"}, {"input": "[1, 2, 3]\n10", "output": "[0...
code_functional
[ { "content": "A wise man told Kerem \"Different is good\" once, so Kerem wants all things in his life to be different. \n\nKerem recently got a string s consisting of lowercase English letters. Since Kerem likes it when things are different, he wants all substrings of his string s to be distinct. Substring is a...
[{"input": "45\naaabbbcccdddeeefffgghhiijjkkkkkkkkkkkkkkkkkkk\n", "output": "-1\n"}, {"input": "45\naaabbbcccdddeeefffgghhiijjkkkkkkkkkkkkkkkkkkk\n", "output": "-1\n"}, {"input": "45\naaabbbcccdedeeefffgghhiijjkkkkkkkkkkkkkkkkkkk\n", "output": "-1\n"}, {"input": "45\naaabbbcccdedeeefffgghhijjjkkkkkkkkkkkkkkkkkkk\n", "o...
code_stdio
[ { "content": "Alice is the leader of the State Refactoring Party, and she is about to become the prime minister. \n\nThe elections have just taken place. There are $n$ parties, numbered from $1$ to $n$. The $i$-th party has received $a_i$ seats in the parliament.\n\nAlice's party has number $1$. In order to bec...
[{"input": "100\n100 48 48 22 21 27 51 43 53 34 54 37 45 37 27 53 39 53 37 44 55 44 31 36 55 47 45 23 40 32 55 54 40 38 30 25 28 20 39 20 53 50 41 26 29 37 42 55 23 27 51 30 39 50 24 30 22 50 56 32 60 45 50 43 27 25 52 59 47 58 28 56 49 39 33 52 26 46 23 42 45 58 42 50 49 25 28 30 46 43 26 32 40 53 60 21 54 16 57 50\n"...
code_stdio
[ { "content": "You are given a permutation p of numbers 1, 2, ..., n. Let's define f(p) as the following sum:$f(p) = \\sum_{i = 1}^{n} \\sum_{j = i}^{n} \\operatorname{min}(p_{i}, p_{i + 1}, \\ldots p_{j})$\n\nFind the lexicographically m-th permutation of length n in the set of permutations having the maximum p...
[{"input": "50 562949953421311\n", "output": "49 50 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1\n"}, {"input": "50 562949953421310\n", "output": "48 50 49 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23...
code_stdio
[ { "content": "**Introduction**\n Little Petya very much likes sequences. However, recently he received a sequence as a gift from his mother.\n Petya didn't like it at all! He decided to make a single replacement. After this replacement, Petya would like to the sequence in increasing order.\n He asks himself: Wh...
[{"input": "[5, 6, 1, 2, 3, 1, 3, 45, 7, 1000000000]", "output": "[[1, 1, 1, 2, 3, 3, 5, 6, 7, 45]]", "fn_name": "sort_number"}, {"input": "[1, 2, 3, 4, 5]", "output": "[[1, 1, 2, 3, 4]]", "fn_name": "sort_number"}, {"input": "[4, 2, 1, 3, 5]", "output": "[[1, 1, 2, 3, 4]]", "fn_name": "sort_number"}, {"input": "[2, 3,...
code_functional
[ { "content": "Playing with Stones\n\nKoshiro and Ukiko are playing a game with black and white stones. The rules of the game are as follows:\n\n1. Before starting the game, they define some small areas and place \"one or more black stones and one or more white stones\" in each of the areas.\n2. Koshiro and Ukik...
[{"input": "4\n24 99\n15 68\n12 155\n95 79", "output": "0\n"}, {"input": "4\n24 99\n15 97\n12 149\n95 79", "output": "0\n"}, {"input": "4\n39 99\n15 97\n12 149\n95 79", "output": "0\n"}, {"input": "4\n24 99\n15 68\n12 90\n95 66", "output": "0\n"}, {"input": "4\n24 99\n15 44\n12 90\n95 66", "output": "0\n"}, {"input": "...
code_stdio
[ { "content": "A text editor is a useful software tool that can help people in various situations including writing and programming. Your job in this problem is to construct an offline text editor, i.e., to write a program that first reads a given text and a sequence of editing commands and finally reports the t...
[{"input": "3\nA sample input\n9\nforward word\ndelete char\nforward word\ndelete char\nforward word\ndelete char\nbackward word\nbackward word\nforward word\nHallow, Word.\n7\nforward char\ndelete word\ninsert \"ello, \"\nforward word\nbackward char\nbackward char\ninsert \"l\"\n\n3\nforward vord\nbackward word\ndelet...
code_stdio
[ { "content": "Erelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficult from time to time. In the course of solving one of the crosswords, Leha ha...
[{"input": "26 26\nabcdefghijklmnopqrstuvwxyz\nffffffffffffffffffffffffff\n", "output": "25\n1 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 \n"}, {"input": "26 26\nabcdefghijklmnopqrstuvwxyz\nffffffffffffffffffffffffff\n", "output": "25\n1 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2...
code_stdio
[ { "content": "Polycarp likes squares and cubes of positive integers. Here is the beginning of the sequence of numbers he likes: $1$, $4$, $8$, $9$, ....\n\nFor a given number $n$, count the number of integers from $1$ to $n$ that Polycarp likes. In other words, find the number of such $x$ that $x$ is a square o...
[{"input": "20\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n1000000000\n", "output": "32591\n32591\n32591\n32591\n32591\n32591\n32591\n3...
code_stdio
[ { "content": "You are given two arrays `arr1` and `arr2`, where `arr2` always contains integers.\n\nWrite the function `find_array(arr1, arr2)` such that:\n\nFor `arr1 = ['a', 'a', 'a', 'a', 'a']`, `arr2 = [2, 4]`\n`find_array returns ['a', 'a']`\n\nFor `arr1 = [0, 1, 5, 2, 1, 8, 9, 1, 5]`, `arr2 = [1, 4, 7]`\n...
[{"input": "[\"this\", \"is\", \"test\"]\n[0, 1, 2]", "output": "[[\"this\", \"is\", \"test\"]]", "fn_name": "find_array"}, {"input": "[0, 1, 5, 2, 1, 8, 9, 1, 5]\n[1, 4, 7]", "output": "[[1, 1, 1]]", "fn_name": "find_array"}, {"input": "[\"a\", \"a\", \"a\", \"a\", \"a\"]\n[2, 4]", "output": "[[\"a\", \"a\"]]", "fn_na...
code_functional
[ { "content": "Mr. Chanek has an integer represented by a string $s$. Zero or more digits have been erased and are denoted by the character _. There are also zero or more digits marked by the character X, meaning they're the same digit.\n\nMr. Chanek wants to count the number of possible integer $s$, where $s$ i...
[{"input": "________\n", "output": "3600000\n"}, {"input": "X_______\n", "output": "3600000\n"}, {"input": "_____X__\n", "output": "3600000\n"}, {"input": "_______X\n", "output": "3600000\n"}, {"input": "________\n", "output": "3600000\n"}, {"input": "_____X__\n", "output": "3600000\n"}, {"input": "X_______\n", "output...
code_stdio
[ { "content": "Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nPrincess Rupsa saw one of her friends playing a special game. The game goes as follows:\n\nN+1 numbers occur sequentially (one at a time) from A_{0} to A_{N}.\nYou must write the numbers on a sheet of paper, such tha...
[{"input": "2\n1\n1 0\n2\n10 -1 -1", "output": "0\n999999949\n"}, {"input": "2\n1\n2 4\n2\n1 -1 1", "output": "16\n1000000003\n"}, {"input": "2\n1\n1 2\n2\n1 -1 0", "output": "4\n1000000003\n"}, {"input": "2\n1\n1 2\n2\n1 0 -1", "output": "4\n1000000005\n"}, {"input": "2\n1\n0 2\n2\n1 0 -1", "output": "0\n1000000005\n"...
code_stdio
[ { "content": "Aizu Gakuen High School holds a school festival every year. The most popular of these is the haunted house. The most popular reason is that 9 classes do haunted houses instead of 1 or 2 classes. Each one has its own unique haunted house. Therefore, many visitors come from the neighborhood these da...
[{"input": "1a 132 243\n1c 324 183\n1f 93 199\n2b 372 163\n2c 229 346\n2e 391 206\n3a 118 168\n3b 263 293\n3d 281 102", "output": "1a 375 99300\n1c 507 119700\n1f 292 78300\n2b 535 123300\n2c 575 149600\n2e 597 140000\n3a 286 74000\n3b 556 140500\n3d 383 86800\n"}, {"input": "1a 132 243\n1c 324 183\n1f 93 199\n3b 372 1...
code_stdio
[ { "content": "Problem statement\n\nWhen you heard that this year's KUPC can be joined as a team, you decided to talk to your friends and join as a team.\n\nEventually, $ 4 $ people, including you, got together.\n\nIndividual strength is expressed in ratings, and $ 4 $ person ratings are $ a $, $ b $, $ c $, and...
[{"input": "-127 10 -1 -1", "output": "115\n"}, {"input": "-127 10 -1 -3", "output": "113\n"}, {"input": "-1 -12 2 137", "output": "124\n"}, {"input": "2 -2 -158 -1", "output": "153\n"}, {"input": "1 -2 -158 -1", "output": "154\n"}, {"input": "1 -2 -256 -1", "output": "252\n"}, {"input": "-127 26 -1 -1", "output": "99\...
code_stdio
[ { "content": "Petya is preparing for his birthday. He decided that there would be $n$ different dishes on the dinner table, numbered from $1$ to $n$. Since Petya doesn't like to cook, he wants to order these dishes in restaurants.\n\nUnfortunately, all dishes are prepared in different restaurants and therefore ...
[{"input": "4\n4\n3 7 4 5\n2 1 2 4\n4\n1 2 3 4\n3 3 3 3\n2\n1 2\n10 10\n2\n10 10\n1 2\n", "output": "5\n3\n2\n3\n"}, {"input": "4\n4\n3 11 4 2\n2 1 2 4\n4\n1 2 3 4\n3 3 3 3\n2\n1 2\n10 10\n2\n10 10\n1 2\n", "output": "3\n3\n2\n3"}, {"input": "4\n4\n3 7 4 5\n3 1 2 4\n4\n1 2 3 4\n3 3 3 10\n2\n0 2\n10 10\n2\n10 10\n1 0\n"...
code_stdio
[ { "content": "Analyzing the mistakes people make while typing search queries is a complex and an interesting work. As there is no guaranteed way to determine what the user originally meant by typing some query, we have to use different sorts of heuristics.\n\nPolycarp needed to write a code that could, given tw...
[{"input": "250\niiffiehchidfgigdbcciahdehjjfacbbaaadagaibjjcehjcbjdhaadebaejiicgidbhajfbfejcdicgfbcchgbahfccbefdcddbjjhejigiafhdjbiiehadfficicbebeeegcebideijidbgdecffeaegjfjbbcfiabfbaiddbjgidebdiccfcgfbcbbfhaejaibeicghecchjbiaceaibfgibhgcfgifiedcbhhfadhccfdhejeggcah\njbadcfjffcfabbecfabgcafgfcgfeffjjhhdaajjgcbgbechhia...
code_stdio
[ { "content": "For years, the Day of city N was held in the most rainy day of summer. New mayor decided to break this tradition and select a not-so-rainy day for the celebration. The mayor knows the weather forecast for the $n$ days of summer. On the $i$-th day, $a_i$ millimeters of rain will fall. All values $a...
[{"input": "100 7 7\n1656 322 975 921 115 647 61 232 127 277 839 797 261 968 788 381 191 117 663 959 475 166 471 984 17 473 57 809 65 881 1109 725 587 933 466 537 1017 706 927 173 636 372 644 82 835 893 792 494 808 977 479 109 1858 21 625 104 626 569 524 504 16 257 274 285 404 629 247 609 521 602 483 271 45 442 503 438...
code_stdio
[ { "content": "Write a function ```x(n)``` that takes in a number ```n``` and returns an ```nxn``` array with an ```X``` in the middle. The ```X``` will be represented by ```1's``` and the rest will be ```0's```. \nE.g.\n```python\nx(5) == [[1, 0, 0, 0, 1],\n [0, 1, 0, 1, 0],\n [0, 0, 1, 0, 0]...
[{"input": "6", "output": "[[[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 0, 1]]]", "fn_name": "x"}, {"input": "5", "output": "[[[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]]", "fn_name": "x"}, {"input": "4", "ou...
code_functional
[ { "content": "You are given n switches and m lamps. The i-th switch turns on some subset of the lamps. This information is given as the matrix a consisting of n rows and m columns where a_{i}, j = 1 if the i-th switch turns on the j-th lamp and a_{i}, j = 0 if the i-th switch is not connected to the j-th lamp.\...
[{"input": "4 15\n111110100011010\n111111011010110\n101000001011001\n100110000111011\n", "output": "YES\n"}, {"input": "4 15\n111110100011010\n111111011010110\n101000001011001\n100110000111011\n", "output": "YES\n"}, {"input": "4 15\n111110100011010\n111111011010110\n101000001011001\n100110000111001\n", "output": "YES\...
code_stdio
[ { "content": "You are given n points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertices at the given points.\n\n\n-----Input-----\n\nThe first line of the input contains integer n (1 ≤ n ≤ 2000) — the number of points.\n\nEach o...
[{"input": "20\n0 17\n1 8\n1 9\n2 5\n2 11\n3 0\n5 10\n5 13\n6 7\n7 3\n12 13\n13 7\n14 16\n15 10\n15 18\n17 2\n17 12\n18 14\n19 18\n20 17\n", "output": "18\n"}, {"input": "20\n0 17\n1 8\n1 9\n2 5\n2 11\n3 0\n5 10\n5 13\n6 7\n7 3\n12 13\n13 7\n14 16\n15 10\n15 18\n17 2\n17 12\n18 14\n19 18\n20 17\n", "output": "18\n"}, {...
code_stdio
[ { "content": "A well-known art union called \"Kalevich is Alive!\" manufactures objects d'art (pictures). The union consists of n painters who decided to organize their work as follows.\n\nEach painter uses only the color that was assigned to him. The colors are distinct for all painters. Let's assume that the ...
[{"input": "10 3\n6 10 3\n2 7 12\n7 4 7\n10 3 2\n6 5 12\n8 4 4\n5 9 11\n6 7 7\n2 6 10\n2 6 2\n", "output": "19 35 42 44 56 60 71 78 88 90\n"}, {"input": "10 3\n6 10 3\n2 7 12\n7 4 7\n6 3 0\n6 5 12\n8 4 4\n5 15 11\n6 7 3\n2 6 10\n2 6 2\n", "output": "19 35 42 42 54 58 69 72 82 84\n"}, {"input": "10 3\n6 10 3\n3 7 12\n7 ...
code_stdio
[ { "content": "You are given a simple weighted connected undirected graph, consisting of $n$ vertices and $m$ edges.\n\nA path in the graph of length $k$ is a sequence of $k+1$ vertices $v_1, v_2, \\dots, v_{k+1}$ such that for each $i$ $(1 \\le i \\le k)$ the edge $(v_i, v_{i+1})$ is present in the graph. A pat...
[{"input": "15 15 23\n13 10 12\n11 14 12\n2 15 5\n4 10 8\n10 2 4\n10 7 5\n3 10 1\n5 6 11\n1 13 8\n9 15 4\n4 2 9\n11 15 1\n11 12 14\n10 8 12\n3 6 11\n", "output": "3250\n"}, {"input": "15 15 23\n13 11 12\n11 14 12\n2 15 5\n4 10 8\n10 2 4\n10 7 5\n3 10 1\n5 6 11\n1 13 8\n9 15 4\n4 2 9\n11 15 1\n11 12 14\n10 8 12\n3 6 11\...
code_stdio
[ { "content": "The following problem is well-known: given integers n and m, calculate $2^{n} \\operatorname{mod} m$, \n\nwhere 2^{n} = 2·2·...·2 (n factors), and $x \\operatorname{mod} y$ denotes the remainder of division of x by y.\n\nYou are asked to solve the \"reverse\" problem. Given integers n and m, calcu...
[{"input": "100000000\n100000000\n", "output": "100000000\n"}, {"input": "100000000\n100000000\n", "output": "100000000\n"}, {"input": "100000000\n100001000\n", "output": "100001000\n"}, {"input": "100000000\n110001000\n", "output": "110001000\n"}, {"input": "99999999\n100000000\n", "output": "100000000\n"}, {"input": ...
code_stdio
[ { "content": "The R2 company has n employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming challenging. For that, R2 uses a famous instant messaging program Spyke.\n\nR2 has m Spyke chats just to discuss all sorts of issues. In each chat, some group of...
[{"input": "7 6 5\n0 1 0 1 1 1\n0 1 1 0 1 1\n1 0 1 1 1 0\n1 0 1 1 1 1\n1 1 1 1 1 0\n1 1 1 0 1 0\n1 0 1 0 0 0\n4 1\n2 6\n7 3\n7 1\n5 3\n", "output": "1 2 4 4 3 4 2 \n"}, {"input": "7 6 5\n0 1 0 1 1 1\n0 1 1 0 1 1\n1 0 1 1 1 0\n1 0 1 1 1 1\n1 1 1 1 1 0\n1 1 1 0 1 0\n1 0 1 0 0 0\n4 1\n2 6\n7 3\n7 1\n5 3\n", "output": "1 2...
code_stdio
[ { "content": "The Little Elephant loves to play with color cards.\n\nHe has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In one move the Little Elephant can turn any card to the other side. Th...
[{"input": "100\n1 2\n2 1\n2 1\n1 2\n1 1\n1 2\n2 1\n1 1\n2 2\n2 1\n2 1\n1 1\n1 1\n2 1\n2 1\n2 1\n2 1\n2 1\n1 1\n2 1\n1 1\n1 1\n2 2\n1 2\n1 2\n1 2\n2 2\n1 2\n1 2\n2 1\n1 2\n2 1\n1 2\n2 2\n1 1\n2 1\n1 2\n2 1\n2 1\n1 2\n2 1\n2 1\n1 2\n2 1\n1 1\n1 2\n1 1\n1 1\n2 2\n2 2\n2 1\n2 1\n1 2\n2 2\n1 1\n2 1\n2 2\n1 1\n1 1\n1 2\n2 2...
code_stdio
[ { "content": "There is a vampire family of N members. Vampires are also known as extreme gourmets. Of course vampires' foods are human blood. However, not all kinds of blood is acceptable for them. Vampires drink blood that K blood types of ones are mixed, and each vampire has his/her favorite amount for each b...
[{"input": "2 3\n5 4 5\n1 2 3\n3 2 1\n3 5\n1 2 3 4 5\n0 1 -1 1 2\n-1 1 1 2 2\n1 0 3 1 1\n0 0", "output": "Yes\nYes\n"}, {"input": "2 3\n5 4 5\n1 2 3\n3 2 1\n3 5\n1 2 3 7 5\n0 1 -1 1 2\n-1 1 1 2 2\n1 0 3 1 1\n0 0", "output": "Yes\nYes\n"}, {"input": "2 3\n5 4 5\n1 2 3\n3 2 1\n3 5\n1 2 3 7 5\n0 1 -1 1 2\n-1 1 1 0 2\n1 0 ...
code_stdio
[ { "content": "You are given n numbers a1, a2, ..., an. You can perform at most k operations. For each operation you can multiply one of the numbers by x. We want to make <image> as large as possible, where <image> denotes the bitwise OR. \n\nFind the maximum possible value of <image> after performing at most k ...
[{"input": "5 1 3\n1 5 13 8 16\n", "output": " 63\n"}, {"input": "5 10 8\n0 0 0 0 0\n", "output": " 0\n"}, {"input": "5 10 8\n1000000000 1000001000 1000000000 1000000000 1000000000\n", "output": "1...
code_stdio
[ { "content": "Long time ago there was a symmetric array $a_1,a_2,\\ldots,a_{2n}$ consisting of $2n$ distinct integers. Array $a_1,a_2,\\ldots,a_{2n}$ is called symmetric if for each integer $1 \\le i \\le 2n$, there exists an integer $1 \\le j \\le 2n$ such that $a_i = -a_j$.\n\nFor each integer $1 \\le i \\le ...
[{"input": "6\n2\n8 12 8 12\n2\n7 7 9 11\n2\n7 11 7 11\n1\n1 1\n4\n40 56 48 40 160 56 117 48\n6\n240 154 210 162 174 154 186 240 174 186 162 210\n", "output": "YES\nNO\nNO\nNO\nNO\nYES\n"}, {"input": "6\n2\n8 12 8 12\n2\n7 7 9 11\n2\n0 11 7 11\n1\n1 1\n4\n40 56 48 40 160 56 117 48\n6\n240 154 210 162 174 154 186 240 17...
code_stdio
[ { "content": "You are given an array consisting of $n$ integers $a_1, a_2, \\dots , a_n$ and an integer $x$. It is guaranteed that for every $i$, $1 \\le a_i \\le x$.\n\nLet's denote a function $f(l, r)$ which erases all values such that $l \\le a_i \\le r$ from the array $a$ and returns the resulting array. Fo...
[{"input": "100 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", "ou...
code_stdio
[ { "content": "The princess is going to escape the dragon's cave, and she needs to plan it carefully.\n\nThe princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to su...
[{"input": "2\n100\n10\n10\n739\n", "output": "22\n"}, {"input": "1\n100\n1\n1\n1000\n", "output": "152\n"}, {"input": "2\n100\n13\n10\n739\n", "output": "22\n"}, {"input": "1\n100\n2\n1\n1000\n", "output": "151\n"}, {"input": "2\n100\n24\n10\n739\n", "output": "21\n"}, {"input": "100\n99\n1\n1\n1000\n", "output": "0\n...
code_stdio
[ { "content": "Write a function that takes one or more arrays and returns a new array of unique values in the order of the original provided arrays.\n\nIn other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.\n\nThe unique numbers s...
[{"input": "[1, 3, 2]\n[5, 2, 1, 4]\n[2, 1]", "output": "[[1, 3, 2, 5, 4]]", "fn_name": "unite_unique"}, {"input": "[]\n[1, 2, 1, 2]\n[2, 1, 1, 2, 1]", "output": "[[1, 2]]", "fn_name": "unite_unique"}, {"input": "[]\n[4, \"a\", 2]\n[]", "output": "[[4, \"a\", 2]]", "fn_name": "unite_unique"}, {"input": "[1, 2]\n[3, 4]"...
code_functional
[ { "content": "Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by a string s. The string s consists of only letters 'B' and 'G', where 'B' represents a boy and 'G'...
[{"input": "8\n-1\nBB\n0\nBG\n1\nGBGB\n2\nBGG\n2\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB", "output": "-1\n0\n0\n1\n1\n3\n1\n0\n"}, {"input": "8\n1\nBB\n0\nBG\n0\nBBGG\n1\nAGG\n0\nBGGB\n1\nBBBGG\n2\nBBGG\n2\nBGB", "output": "-1\n0\n1\n-1\n1\n3\n1\n0\n"}, {"input": "8\n1\nBB\n0\nBG\n0\nBBGG\n1\nAGG\n0\nBGGB\n1\nBBBGG\n2\nBBGG\n...
code_stdio
[ { "content": "Problem:\n\nYou are given n natural numbers a1,a2,a3…… an. Let SOD of a number be defined as the Sum of Digits of that number. Compute the value of\n\n{ [ SOD(a1) + SOD(a2) + …….. SOD(an) ] % 9 } – { [ SOD( a1 + a2 + ….. an ) ] % 9 }\n\nInput:\n\nThe first line consists of the value of n. Next n l...
[{"input": "975\n83120057411220087360668125140646348919041806702329314488483800118463434852377449595\n9717806464488721715522935873810745984496672189178897548\n96811324979237301769049529676571\n1036276136291119718301618513101612705490251717930737781164655306138110273308573272031338\n43586\n666957580799011908835864604532...
code_stdio
[ { "content": "Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.\n\nA k-tree is an infinite rooted tree where:\n\n each vertex has exactly k children; each edge has some weight; if we look at the ...
[{"input": "100 100 1\n", "output": "988185646\n"}, {"input": "100 50 50\n", "output": "661237556\n"}, {"input": "100 13 11\n", "output": "883875774\n"}, {"input": "90 100 30\n", "output": "697322870\n"}, {"input": "100 50 50\n", "output": "661237556\n"}, {"input": "100 100 1\n", "output": "988185646\n"}, {"input": "90...
code_stdio
[ { "content": "You are given a string $t$ consisting of $n$ lowercase Latin letters and an integer number $k$.\n\nLet's define a substring of some string $s$ with indices from $l$ to $r$ as $s[l \\dots r]$.\n\nYour task is to construct such string $s$ of minimum possible length that there are exactly $k$ positio...
[{"input": "50 68\npyndtohzaimzvqkvdkwlmccauhlmmljruldlobtadxclrvncea\n", "output": "pyndtohzaimzvqkvdkwlmccauhlmmljruldlobtadxclrvnceapyndtohzaimzvqkvdkwlmccauhlmmljruldlobtadxclrvnceapyndtohzaimzvqkvdkwlmccauhlmmljruldlobtadxclrvnceapyndtohzaimzvqkvdkwlmccauhlmmljruldlobtadxclrvnceapyndtohzaimzvqkvdkwlmccauhlmmljruld...
code_stdio
[ { "content": "problem\n\nOne day in the cold winter, JOI Taro decided to break the thin ice in the plaza and play. The square is rectangular and is divided into m sections in the east-west direction and n sections in the north-south direction, that is, m × n. In addition, there are sections with and without thi...
[{"input": "3\n3\n1 1 0\n1 0 1\n1 1 0\n5\n3\n1 1 1 0 1\n1 1 0 1 0\n1 0 0 0 1\n0\n0", "output": "5\n5\n"}, {"input": "3\n3\n1 1 0\n1 0 1\n0 1 0\n5\n3\n1 1 0 0 1\n1 1 0 1 0\n1 0 0 0 1\n0\n0", "output": "3\n5\n"}, {"input": "3\n3\n1 1 0\n1 0 1\n0 1 0\n5\n3\n1 1 0 0 1\n1 1 0 1 0\n1 1 1 0 1\n0\n0", "output": "3\n7\n"}, {"in...
code_stdio
[ { "content": "[Image] \n\nAs some of you know, cubism is a trend in art, where the problem of constructing volumetrical shape on a plane with a combination of three-dimensional geometric shapes comes to the fore. \n\nA famous sculptor Cicasso, whose self-portrait you can contemplate, hates cubism. He is more im...
[{"input": "53\n1014364 40727 75774 243769 314 406417 5272684 14138 10640282 64955 2763 5667043 2121887 204672692 567643 60183 5183 11361359 2792918 199155 174809 16182540 21 392221 19434423 9140891 159733 15438 67903 3816799 616 429181 30392293 413992581 10847741 20771 16366654 1163 414283 156163 55907108 310278 95949...
code_stdio
[ { "content": "Create a program that reads poker hand data and outputs the role for each. However, this issue follows the rules below.\n\n* Poker is a competition with 5 playing cards.\n* No more than 5 cards with the same number.\n* There is no joker.\n* Suppose you only consider the following poker roles: (The...
[{"input": "1,2,4,3,1\n3,3,1,3,12\n12,13,11,12,12\n7,6,7,6,7\n3,3,2,3,3\n6,7,8,9,10\n11,13,11,1,13\n11,12,13,1,1", "output": "one pair\nthree card\nthree card\nfull house\nfour card\nstraight\ntwo pair\none pair\n"}, {"input": "1,2,3,4,1\n2,3,1,3,12\n12,13,11,12,12\n7,6,7,6,6\n3,3,2,4,3\n6,7,8,9,10\n11,13,10,1,13\n11,1...
code_stdio
[ { "content": "Description\n\nTHE BY DOLM @ STER is a training simulation game scheduled to be released on EXIDNA by 1rem on April 1, 2010. For the time being, it probably has nothing to do with an arcade game where the network connection service stopped earlier this month.\nThis game is a game in which members ...
[{"input": "3 10\nDobkeradops\n7 5 23 10\nPataPata\n1 0 2 1\ndop\n1 7 11 21\n2 300\nBydp System ahplA\n2 11 4 7\nGreen Inferno\n300 300 300 300", "output": "210\n1650\n"}, {"input": "3 10\nDobkeradops\n7 5 23 10\nPataPata\n1 1 2 1\ndop\n1 7 11 14\n2 300\nBydp System Alpha\n7 11 4 7\nGreen Inferno\n300 300 300 300", "ou...
code_stdio
[ { "content": "Tokitsukaze and CSL are playing a little game of stones.\n\nIn the beginning, there are $n$ piles of stones, the $i$-th pile of which has $a_i$ stones. The two players take turns making moves. Tokitsukaze moves first. On each turn the player chooses a nonempty pile and removes exactly one stone fr...
[{"input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125468\n", "output": "sjfnb\n"}, {"input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125477\n", "output": "cslnb\n"}, {"input": "14\n9 9 1000 2000 39999 48888 16 32 123456 959658 111 987584 125632 125468\n", "outp...
code_stdio
[ { "content": "You are given two integers $n$ and $k$. Your task is to find if $n$ can be represented as a sum of $k$ distinct positive odd (not divisible by $2$) integers or not.\n\nYou have to answer $t$ independent test cases.\n\n\n-----Input-----\n\nThe first line of the input contains one integer $t$ ($1 \\...
[{"input": "11\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "11\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "11\n4 2\n4 2\n4 2\n4 2...
code_stdio
[ { "content": "Little girl Susie went shopping with her mom and she wondered how to improve service quality. \n\nThere are n people in the queue. For each person we know time t_{i} needed to serve him. A person will be disappointed if the time he waits is more than the time needed to serve him. The time a person...
[{"input": "26\n1000 4110030 64221 131521030 942374833 1003 2055015 32110 770511 16440130 263042057 32880256 128439 557559573 16051 8220066 469240078 65760513 256878 790176315 4012 2005 1027508 928528684 8030 1005954322\n", "output": "20\n"}, {"input": "26\n1000 4110030 64221 131521030 942374833 1003 2055015 32110 5137...
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": "6\n3 2 2 10 13 8\n", "output": "1\n"}, {"input": "6\n3 2 2 12 13 8\n", "output": "1\n"}, {"input": "6\n3 2 2 12 13 2\n", "output": "2\n"}, {"input": "6\n3 2 4 12 13 2\n", "output": "0\n"}, {"input": "6\n3 2 4 12 13 3\n", "output": "0\n"}, {"input": "6\n0 2 4 12 13 3\n", "output": "0\n"}, {"input": "6\n0 2 4...
code_stdio
[ { "content": "This is yet another problem on regular bracket sequences.\n\nA bracket sequence is called regular, if by inserting \"+\" and \"1\" into it we get a correct mathematical expression. For example, sequences \"(())()\", \"()\" and \"(()(()))\" are regular, while \")(\", \"(()\" and \"(()))(\" are not....
[{"input": "(?(((???))(??)?)?))))(?)????(()()???(?)????(??(??????)()(????(?)))))??(???(??)?(??)????????(????(?()\n39 78\n1 83\n2 35\n28 89\n53 53\n96 67\n16 46\n43 28\n25 73\n8 97\n57 41\n15 25\n47 49\n23 18\n97 77\n38 33\n68 80\n38 98\n62 8\n61 79\n84 50\n71 48\n12 16\n97 95\n16 70\n72 58\n55 85\n88 42\n49 56\n39 122\...
code_stdio
[ { "content": "The clique problem is one of the most well-known NP-complete problems. Under some simplification it can be formulated as follows. Consider an undirected graph G. It is required to find a subset of vertices C of the maximum size such that any two of them are connected by an edge in graph G. Sounds ...
[{"input": "12\n66 4\n12 4\n60 4\n24 4\n48 4\n0 4\n36 4\n30 4\n6 4\n54 4\n42 4\n18 4\n", "output": "6\n"}, {"input": "12\n66 4\n12 4\n60 4\n24 4\n48 4\n0 4\n36 4\n30 4\n6 4\n54 4\n42 4\n18 4\n", "output": "6"}, {"input": "12\n66 4\n12 4\n60 4\n24 4\n48 4\n0 4\n36 4\n4 4\n6 4\n54 4\n42 4\n18 4\n", "output": "6"}, {"inpu...
code_stdio
[ { "content": "You are given a ternary string (it is a string which consists only of characters '0', '1' and '2').\n\nYou can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace \"01\" with \"10\" or vice versa) or any two adjacent (consecutive) characters '1' and '2' (i.e. replace \"12\" wi...
[{"input": "100022202\n", "output": "000122202\n"}, {"input": "100022202\n", "output": "000122202\n"}, {"input": "11222121\n", "output": "11112222\n"}, {"input": "11222121\n", "output": "11112222\n"}, {"input": "2112120\n", "output": "1112220\n"}, {"input": "2112120\n", "output": "1112220\n"}, {"input": "100210\n", "ou...
code_stdio
[ { "content": "Yaroslav likes algorithms. We'll describe one of his favorite algorithms.\n\n 1. The algorithm receives a string as the input. We denote this input string as a. \n 2. The algorithm consists of some number of command. Сommand number i looks either as si >> wi, or as si <> wi, where si and wi are ...
[{"input": "10\n448\n727\n1418\n278\n870\n913\n2072\n300\n36\n1312\n", "output": "0??<>1\n1??<>2\n2??<>3\n3??<>4\n4??<>5\n5??<>6\n6??<>7\n7??<>8\n8??<>9\n9??>>??0\n??<>1\n?0>>0?\n?1>>1?\n?2>>2?\n?3>>3?\n?4>>4?\n?5>>5?\n?6>>6?\n?7>>7?\n?8>>8?\n?9>>9?\n?>>??\n>>?\n"}, {"input": "10\n1429\n605\n903\n154\n293\n383\n422\n71...
code_stdio
[ { "content": "You are given two integers $a$ and $b$. You may perform any number of operations on them (possibly zero).\n\nDuring each operation you should choose any positive integer $x$ and set $a := a - x$, $b := b - 2x$ or $a := a - 2x$, $b := b - x$. Note that you may choose different values of $x$ in diff...
[{"input": "3\n0 0\n2 1\n2 -1\n", "output": "YES\nYES\nNO\n"}, {"input": "3\n11 2\n-1 0\n1 2\n", "output": "NO\nNO\nYES\n"}, {"input": "3\n2 14\n2 1\n-1 0\n", "output": "NO\nYES\nNO\n"}, {"input": "3\n0 0\n2 1\n-1 0\n", "output": "YES\nYES\nNO\n"}, {"input": "3\n0 0\n2 1\n-2 0\n", "output": "YES\nYES\nNO\n"}, {"input":...
code_stdio
[ { "content": "Not to be confused with chessboard.\n\n [Image] \n\n\n-----Input-----\n\nThe first line of input contains a single integer N (1 ≤ N ≤ 100) — the number of cheeses you have.\n\nThe next N lines describe the cheeses you have. Each line contains two space-separated strings: the name of the cheese and...
[{"input": "42\nquxukow soft\nwcn soft\npbwg soft\nlrp hard\nphdvfz soft\nidkvymji soft\nobq soft\nyhx soft\nijygw soft\nztzz soft\nuwdhnwu soft\ndgnuuej hard\nhntyyzr soft\nqxf hard\nztg soft\nhnpq soft\nuhznu soft\nitelgl hard\nggceadhw hard\nrxq soft\nkznmshem hard\nlri hard\ndalh soft\ngyzzuht hard\nzvx soft\nbjffl...
code_stdio