messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a set of vertices and $E$ is a set of edges; Adjacency list representation and Adjacency matrix representation.\n\nAn adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$ lists, one for each vertex in $V$... | [{"input": "4\n1 1 0 4\n2 1 1\n-1 -1\n4 1 2", "output": "0 0 0 1\n1 0 0 0\n0 0 0 0\n0 1 0 0\n"}, {"input": "4\n1 2 2 4\n2 1 4\n3 -1\n4 1 3", "output": "0 1 0 1\n0 0 0 1\n0 0 0 0\n0 0 1 0\n"}, {"input": "4\n1 2 1 4\n2 1 4\n1 -1\n4 1 3", "output": "1 0 0 1\n0 0 0 1\n0 0 0 0\n0 0 1 0\n"}, {"input": "4\n1 2 2 4\n2 1 4\n3 -... | code_stdio |
[
{
"content": "Given are integers A, B, and N.\nFind the maximum possible value of floor(Ax/B) - A × floor(x/B) for a non-negative integer x not greater than N.\nHere floor(t) denotes the greatest integer not greater than the real number t.\n\n-----Constraints-----\n - 1 ≤ A ≤ 10^{6}\n - 1 ≤ B ≤ 10^{12}\n - 1 ≤ ... | [{"input": "1000000 1000000000000 1000000000000\n", "output": "999999\n"}, {"input": "1000000 948240928204 329810943092\n", "output": "347813\n"}, {"input": "133333 329230329032 493028310923\n", "output": "133332\n"}, {"input": "998999 1 998998998323\n", "output": "0\n"}, {"input": "39209 9404 9402\n", "output": "39200... | code_stdio |
[
{
"content": "Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is \\{0,1,…,M-1\\}, for some positive integer M. Ajs draws a number from... | [{"input": "36 81\n4 5 7 8 13 14 16 17 22 23 25 26 31 32 34 35 40 41 43 44 49 50 52 53 58 59 61 62 67 68 70 71 76 77 79 80\n", "output": "9\n3 12 21 30 39 48 57 66 75\n"}, {"input": "36 156\n8 1 8 9 26 14 13 33 22 32 24 70 31 32 34 35 40 41 52 44 49 50 36 53 46 56 61 62 98 132 70 71 76 132 79 80\n", "output": "0\n"}, {... | code_stdio |
[
{
"content": "Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer di, which can be equal to 0, 1 or - 1. To pass the level, he needs to find a «good» subset of edg... | [{"input": "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n6 2\n4 2\n9 2\n5 10\n9 8\n10 7\n5 1\n6 2\n", "output": "0\n\n"}, {"input": "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n6 4\n4 4\n9 2\n5 10\n9 8\n10 7\n5 1\n6 2\n", "output": "0\n\n"}, {"input": "10 10\n-1 -1 -1 -1 -1 -1 -1 -1 -1 -1\n6 7\n8 3\n6 2\n4 2\n9 ... | code_stdio |
[
{
"content": "Professor Pathfinder is a distinguished authority on the structure of hyperlinks in the World Wide Web. For establishing his hypotheses, he has been developing software agents, which automatically traverse hyperlinks and analyze the structure of the Web. Today, he has gotten an intriguing idea to ... | [{"input": "5 6\n/home/ACM/index.html\nlmth.xedni/CPCI/\n/ICPC/general.html\n/ICPC/japanese/index.html\n/ICPC/secret/confidential/2005/index.html\n/home/ACM/\n/ho/e/ICPC/..mACM/\n/ICPC/secret/\n/ICPC/secret/index.html\n/ICPC\n/ICPC/../ICPC/index.html\n/ICPC\n/ICPC/general.html\n/ICPC/japanese/.././\n/ICPC/japandse/./..... | code_stdio |
[
{
"content": "Utkarsh is forced to play yet another one of Ashish's games. The game progresses turn by turn and as usual, Ashish moves first.\n\nConsider the 2D plane. There is a token which is initially at $(0,0)$. In one move a player must increase either the $x$ coordinate or the $y$ coordinate of the token ... | [{"input": "5\n16 1\n3 2\n9 1\n65 19\n14195 55\n", "output": "Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n"}, {"input": "5\n10 1\n3 2\n9 1\n65 19\n14195 55\n", "output": "Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n"}, {"input": "5\n16 1\n4 2\n9 1\n34 20\n14195 91\n", "output": "Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUt... | code_stdio |
[
{
"content": "Snuke loves constructing integer sequences.\nThere are N piles of stones, numbered 1 through N.\nThe pile numbered i consists of a_i stones.\nSnuke will construct an integer sequence s of length Σa_i, as follows:\n - Among the piles with the largest number of stones remaining, let x be the index o... | [{"input": "10\n1 3 2 6 2 4 4 5 8 1", "output": "10\n14\n0\n10\n0\n0\n0\n0\n2\n0\n"}, {"input": "10\n1 3 1 6 3 4 6 6 4 1", "output": "10\n14\n0\n11\n0\n0\n0\n0\n0\n0\n"}, {"input": "10\n1 4 0 1 1 4 4 0 22 1", "output": "8\n12\n0\n0\n0\n0\n0\n0\n18\n0\n"}, {"input": "10\n2 3 0 0 2 4 4 0 35 1", "output": "13\n4\n0\n0\n0\... | code_stdio |
[
{
"content": "There are two persons, numbered 0 and 1, and a variable x whose initial value is 0. The two persons now play a game. The game is played in N rounds. The following should be done in the i-th round (1 \\leq i \\leq N):\n\n* Person S_i does one of the following:\n* Replace x with x \\oplus A_i, where... | [{"input": "3\n2\n0 0\n14\n0\n1 0\n16\n6\n2 6 3 11 14 7\n011000", "output": "0\n0\n0\n"}, {"input": "3\n2\n1 2\n14\n0\n0 0\n16\n6\n2 6 3 12 14 7\n011000", "output": "1\n0\n0\n"}, {"input": "3\n2\n1 2\n14\n0\n1 0\n16\n6\n2 6 3 12 14 7\n011000", "output": "1\n0\n0\n"}, {"input": "3\n2\n1 2\n14\n0\n1 0\n16\n6\n2 6 3 11 14... | code_stdio |
[
{
"content": "For given three integers $a, b, c$, print the minimum value and the maximum value.\n\nConstraints\n\n* $-1,000,000,000 \\leq a, b, c \\leq 1,000,000,000$\n\nInput\n\nThe input is given in the following format.\n\n\n$a \\; b \\; c\\;$\n\n\nThree integers $a, b, c$ are given in a line.\n\nOutput\n\n... | [{"input": "-30 -1 -1", "output": "-30 -1\n"}, {"input": "-22 -1 -1", "output": "-22 -1\n"}, {"input": "-22 -2 -2", "output": "-22 -2\n"}, {"input": "-2 10 -1", "output": "-2 10\n"}, {"input": "-2 28 -1", "output": "-2 28\n"}, {"input": "10 -4 -1", "output": "-4 10\n"}, {"input": "12 -5 -1", "output": "-5 12\n"}, {"inp... | code_stdio |
[
{
"content": "Ania has a large integer S. Its decimal representation has length n and doesn't contain any leading zeroes. Ania is allowed to change at most k digits of S. She wants to do it in such a way that S still won't contain any leading zeroes and it'll be minimal possible. What integer will Ania finish w... | [{"input": "400 224\n34034718296316650556302576767095880542740697596682657060609028712014739414658241556774411582749368771597248873201583574900424227251655547840887764275893533353440635216728376201808545879398359535670372855472971530695051695650262058940466340529417646357776899296790403916961389072619545914097176242329... | code_stdio |
[
{
"content": "Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.\n\nConstraints\n\n* 1\\leq N,K\\leq 100\n* N and K are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nN K\n\n\nOutput\n\nIf we can choose K intege... | [{"input": "135 27", "output": "YES\n"}, {"input": "135 47", "output": "YES\n"}, {"input": "149 47", "output": "YES\n"}, {"input": "149 50", "output": "YES\n"}, {"input": "151 50", "output": "YES\n"}, {"input": "151 14", "output": "YES\n"}, {"input": "178 14", "output": "YES\n"}, {"input": "178 24", "output": "YES\n"},... | code_stdio |
[
{
"content": "There is an array with n elements a_1, a_2, ..., a_{n} and the number x.\n\nIn one operation you can select some i (1 ≤ i ≤ n) and replace element a_{i} with a_{i} & x, where & denotes the bitwise and operation.\n\nYou want the array to have at least two equal elements after applying some operatio... | [{"input": "5 119899\n60825 99853 69251 68402 1266\n", "output": "-1\n"}, {"input": "5 65537\n60825 99853 69251 68402 1266\n", "output": "2\n"}, {"input": "5 65537\n60825 99853 69251 68402 1266\n", "output": "2\n"}, {"input": "5 132\n10060 81912 13624 40413 19012\n", "output": "2\n"}, {"input": "5 132\n10060 81912 1362... | code_stdio |
[
{
"content": "The Chef has prepared the appetizers in the shapes of letters to spell a special message for the guests. There are n appetizers numbered from 0 to n-1 such that if the appetizers are arrayed in this order, they will display the message. The Chef plans to display them in this order on a table that ... | [{"input": "2\n2 chef\n4 eipelpparuoyojne", "output": "cehf\nerlopopniupjeyae\n"}, {"input": "2\n2 chef\n4 enjoyourappmepie", "output": "cehf\neayejpuinpopomre\n"}, {"input": "2\n2 cief\n4 enjoyourappmepie", "output": "ceif\neayejpuinpopomre\n"}, {"input": "2\n2 cgef\n4 enjoyourapplepie", "output": "cegf\neayejpuinpopo... | code_stdio |
[
{
"content": "There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.\nThere are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.\nObs. i is said to be good when its elevation is higher than those of all obse... | [{"input": "6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n", "output": "3\n"}, {"input": "6 5\n8 6 18 1 4 1\n1 3\n4 0\n4 0\n4 6\n4 6", "output": "3\n"}, {"input": "6 5\n8 6 18 1 4 0\n1 3\n4 0\n4 0\n4 6\n4 6", "output": "4\n"}, {"input": "6 5\n13 6 9 1 2 1\n1 3\n1 1\n4 0\n3 3\n4 6", "output": "2\n"}, {"input": "6 5\n8 6 9 ... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian. \nAll bandits are afraid of Sheriff. Sheriff constantly fights crime, but when bandits lay low, he gets bored and starts to entertain himself. \nThis time Sheriff gathered all the bandits in his garden and ordered them to line up. After th... | [{"input": "2\n2\n1 2 3\n5\n2 3 1 5 4", "output": "1\n6\n"}, {"input": "2\n3\n1 2 3\n5\n4 3 1 5 2", "output": "1\n5\n"}, {"input": "2\n3\n2 1 3\n5\n4 3 1 5 2", "output": "2\n5\n"}, {"input": "2\n2\n1 2 3\n5\n4 3 1 5 2", "output": "1\n5\n"}, {"input": "2\n1\n1 2 3\n5\n2 3 1 5 4", "output": "1\n6\n"}, {"input": "2\n1\n1 ... | code_stdio |
[
{
"content": "Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell $(0, 0)$ on an infinite grid.\n\nYou also have the sequence of instructions of this robot. It is written as the string $s$ consisting of characters 'L', 'R', 'U' and 'D'. If the robot is in the cell $(x,... | [{"input": "6\nLRU\nDURLDRUDRULRDURDDL\nLRUDDLRUDRUL\nLLLLRRRR\nURDUR\nLLL\n", "output": "2\nLR\n14\nLLLUUUURRRDDDD\n12\nLLLUUURRRDDD\n2\nLR\n2\nUD\n0\n\n"}, {"input": "6\nLRU\nDURLDRUDRULRDURDDL\nLRUDDLRUDRUL\nLLLLRRRR\nURDUR\nLLL\n", "output": "2\nLR\n14\nLLLUUUURRRDDDD\n12\nLLLUUURRRDDD\n2\nLR\n2\nUD\n0\n\n"}, {"inp... | code_stdio |
[
{
"content": "Let's imagine that you're playing the following simple computer game. The screen displays n lined-up cubes. Each cube is painted one of m colors. You are allowed to delete not more than k cubes (that do not necessarily go one after another). After that, the remaining cubes join together (so that t... | [{"input": "99 10 17\n3 2 2 9 7 10 10 10 10 6 6 6 3 7 3 3 1 2 2 2 2 2 10 10 2 2 7 7 7 7 1 8 8 8 8 10 9 10 10 10 5 5 2 2 5 5 5 1 4 9 9 2 2 3 3 2 2 9 9 9 9 9 9 9 7 4 8 8 4 8 8 10 10 4 5 9 9 10 5 5 5 5 5 8 8 8 8 2 2 2 2 1 8 8 5 10 10 2 2\n", "output": "11\n"}, {"input": "99 10 17\n3 2 2 9 7 10 10 10 10 6 6 6 3 7 3 3 7 2 2... | code_stdio |
[
{
"content": "British mathematician John Littlewood once said about Indian mathematician Srinivasa Ramanujan that \"every positive integer was one of his personal friends.\"\n\nIt turns out that positive integers can also be friends with each other! You are given an array a of distinct positive integers. \n\nDe... | [{"input": "1\n69\n2 4 10 16 22 28 19 40 37 52 92 43 70 76 118 88 94 100 106 112 118 124 130 200 142 148 154 160 166 324 178 184 190 196 300 208 214 129 226 167 238 244 250 209 262 322 274 280 286 462 298 304 310 316 322 328 169 110 591 352 358 364 370 376 382 388 391 397 403\n", "output": "25\n"}, {"input": "1\n69\n2 ... | code_stdio |
[
{
"content": "Our hardworking chef is bored of sleeping in his restaurants. He has decided to settle down. The first thing he must do is to find a suitable location to build a palatial home. \n\nThink of the city as a two-dimensional grid. There are N restaurants in the city. Each of the chef's restaurant is ... | [{"input": "3\n5\n0 0\n-1 -1\n2 0\n-1 1\n0 -2\n5\n31 11\n30 -41\n20 13\n25 28\n25 38\n2\n-1 0\n1 2", "output": "1\n1\n9\n"}, {"input": "3\n5\n-1 0\n-1 0\n1 4\n0 0\n0 -1\n5\n31 11\n52 -41\n18 1\n25 18\n25 60\n2\n-1 -1\n2 5", "output": "1\n1\n28\n"}, {"input": "3\n5\n-1 0\n-1 0\n1 4\n0 0\n0 -1\n5\n31 11\n52 -41\n18 1\n25... | code_stdio |
[
{
"content": "This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.\n\nToday is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice ... | [{"input": "2\n1000000000 1000000000\n", "output": "0\n1000000000 1000000000 "}, {"input": "2\n1000000000 1000000000\n", "output": "0\n1000000000 1000000000 "}, {"input": "10\n1 2 3 3 3 3 3 3 4 5\n", "output": "3\n3 1 3 2 3 3 4 3 5 3 "}, {"input": "10\n1 2 3 3 3 3 3 6 4 5\n", "output": "4\n3 1 3 2 4 3 5 3 6 3\n"}, {"in... | code_stdio |
[
{
"content": "Sagheer is playing a game with his best friend Soliman. He brought a tree with n nodes numbered from 1 to n and rooted at node 1. The i-th node has a_{i} apples. This tree has a special property: the lengths of all paths from the root to any leaf have the same parity (i.e. all paths have even leng... | [{"input": "21\n6194737 6429360 6047962 1014039 9196042 2483033 9232471 5444322 4437778 6614229 4791649 7417126 7679607 790939 3062370 174847 8404336 832859 2083127 9041108 3074902\n1 2 3 4 4 6 7 2 9 10 9 12 12 1 15 1 17 1 19 19\n", "output": "0\n"}, {"input": "21\n6194737 6429360 6047962 1014039 9196042 2483033 923247... | code_stdio |
[
{
"content": "Problem\n\nOne day, mo3tthi and tubuann decided to play a game with magic pockets and biscuits.\nNow there are $ K $ pockets, numbered $ 1,2, \\ ldots, K $.\nThe capacity of the $ i $ th pocket is $ M_i $, which initially contains $ N_i $ biscuits.\nmo3tthi and tubuann start with mo3tthi and perfo... | [{"input": "10\n2 14\n5 17\n7 20\n12 41\n21 48\n112 112\n4 5\n7 14\n3367 8923\n1 29", "output": "mo3tthi\n"}, {"input": "10\n2 14\n5 17\n7 20\n12 41\n21 48\n112 112\n4 5\n7 14\n3367 8923\n1 36", "output": "mo3tthi\n"}, {"input": "10\n2 14\n5 9\n7 20\n12 41\n21 48\n112 112\n4 5\n7 14\n2344 8923\n1 29", "output": "mo3tth... | code_stdio |
[
{
"content": "There are N blocks, numbered 1, 2, \\ldots, N. For each i (1 \\leq i \\leq N), Block i has a weight of w_i, a solidness of s_i and a value of v_i.\n\nTaro has decided to build a tower by choosing some of the N blocks and stacking them vertically in some order. Here, the tower must satisfy the foll... | [{"input": "5\n1 10000 1000000001\n1 10000 1000000000\n1 10000 1000000000\n1 10000 1000000000\n1 10000 1000000000", "output": "5000000001\n"}, {"input": "5\n1 11000 1000000001\n1 10100 1000000000\n1 10000 1000000000\n1 00000 1000000000\n1 00000 1000000000", "output": "4000000001\n"}, {"input": "5\n1 11000 1000000001\n1... | code_stdio |
[
{
"content": "Compute A + B.\n\nConstraints\n\n* -1000 ≤ A, B ≤ 1000\n\nInput\n\nThe input will consist of a series of pairs of integers A and B separated by a space, one pair of integers per line. The input will be terminated by EOF.\n\nOutput\n\nFor each pair of input integers A and B, you must output the sum... | [{"input": "1 2\n10 5\n101 20", "output": "3\n15\n121\n"}, {"input": "1 2\n10 4\n101 20", "output": "3\n14\n121\n"}, {"input": "1 2\n10 4\n101 37", "output": "3\n14\n138\n"}, {"input": "1 2\n11 4\n101 37", "output": "3\n15\n138\n"}, {"input": "1 3\n11 4\n101 37", "output": "4\n15\n138\n"}, {"input": "1 6\n11 4\n101 37"... | code_stdio |
[
{
"content": "In the city of Saint Petersburg, a day lasts for $2^{100}$ minutes. From the main station of Saint Petersburg, a train departs after $1$ minute, $4$ minutes, $16$ minutes, and so on; in other words, the train departs at time $4^k$ for each integer $k \\geq 0$. Team BowWow has arrived at the statio... | [{"input": "1000010011100010111000001101000011001010011101011001101100000001011011000000101101101011101111011011\n", "output": "50\n"}, {"input": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\n", "output": "50\n"}, {"input": "10000100111000101110000011010000110010... | code_stdio |
[
{
"content": "You are given a rooted tree consisting of $n$ vertices numbered from $1$ to $n$. The root of the tree is a vertex number $1$.\n\nA tree is a connected undirected graph with $n-1$ edges.\n\nYou are given $m$ queries. The $i$-th query consists of the set of $k_i$ distinct vertices $v_i[1], v_i[2], \... | [{"input": "10 6\n1 2\n1 3\n1 4\n2 5\n2 6\n5 7\n7 8\n7 9\n9 10\n4 3 8 9 10\n3 2 4 6\n3 4 1 5\n3 4 8 2\n2 6 10\n3 5 4 7\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "10 6\n1 2\n1 3\n1 4\n2 5\n2 6\n5 7\n7 8\n7 9\n9 10\n4 3 8 9 10\n3 2 4 6\n3 4 1 5\n3 4 8 1\n2 6 10\n3 5 4 7\n", "output": "YES\nYES\nYES\nYES\... | code_stdio |
[
{
"content": "You are given a string $s$ consisting of $n$ lowercase Latin letters.\n\nLet's define a substring as a contiguous subsegment of a string. For example, \"acab\" is a substring of \"abacaba\" (it starts in position $3$ and ends in position $6$), but \"aa\" or \"d\" aren't substrings of this string. ... | [{"input": "12\nparapapapaaa\n", "output": "YES\n1 2\n"}, {"input": "12\nparapapapaaa\n", "output": "YES\n1 2\n"}, {"input": "12\nparap`papaaa\n", "output": "YES\n1 2\n"}, {"input": "12\nparaq`papaaa\n", "output": "YES\n1 2\n"}, {"input": "12\noaraq`papaaa\n", "output": "YES\n1 2\n"}, {"input": "12\noaraq`papaab\n", "o... | code_stdio |
[
{
"content": "A new set of desks just arrived, and it's about time! Things were getting quite cramped in the office. You've been put in charge of creating a new seating chart for the engineers. The desks are numbered, and you sent out a survey to the engineering team asking each engineer the number of the desk ... | [{"input": "50\n73 1\n65 73\n16 65\n57 65\n33 16\n34 57\n98 16\n84 98\n55 34\n64 84\n80 55\n75 64\n28 75\n20 75\n42 75\n88 42\n50 20\n48 28\n32 48\n58 88\n92 76\n76 53\n53 15\n15 1\n1 10\n10 71\n71 37\n37 95\n95 63\n63 92\n45 97\n97 51\n51 96\n96 12\n12 62\n62 31\n31 5\n5 29\n29 19\n19 49\n49 6\n6 40\n40 18\n18 22\n22 ... | code_stdio |
[
{
"content": "Two positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)?\n\n\n-----Input-----\n\nThe first line of the input contains two integers s and x (2 ≤ s ≤ 10^12, 0 ≤ x ≤ 10^12), the sum and bitwise xor of the pair of positive in... | [{"input": "549755813887 549755813887\n", "output": "549755813886\n"}, {"input": "549755813888 549755813886\n", "output": "274877906944\n"}, {"input": "547616456703 547599679487\n", "output": "68719476736\n"}, {"input": "274861129991 274861129463\n", "output": "34359738368\n"}, {"input": "549688705887 549688703839\n", ... | code_stdio |
[
{
"content": "There are N slimes standing on a number line. The i-th slime from the left is at position x_i.\n\nIt is guaruanteed that 1 \\leq x_1 < x_2 < \\ldots < x_N \\leq 10^{9}.\n\nNiwango will perform N-1 operations. The i-th operation consists of the following procedures:\n\n* Choose an integer k between... | [{"input": "12\n367101616 467388357 159541726 1477792495 1190847685 1723370727 668687333 270216579 135685914 125686970 1191846896 1765707086", "output": "469392584\n"}, {"input": "12\n367101616 467388357 127795962 1640220090 1190847685 1723370727 402149677 270216579 135685914 923078537 628600728 1765707086", "output": ... | code_stdio |
[
{
"content": "A binary string is a string that consists of characters $0$ and $1$.\n\nLet $\\operatorname{MEX}$ of a binary string be the smallest digit among $0$, $1$, or $2$ that does not occur in the string. For example, $\\operatorname{MEX}$ of $001011$ is $2$, because $0$ and $1$ occur in the string at lea... | [{"input": "6\n01\n1111\n01100\n101\n0000\n01010\n", "output": "1\n0\n2\n1\n1\n2\n"}, {"input": "6\n01\n1111\n01100\n100\n0000\n01010\n", "output": "1\n0\n2\n1\n1\n2\n"}, {"input": "6\n01\n1011\n01100\n100\n0000\n01010\n", "output": "1\n1\n2\n1\n1\n2\n"}, {"input": "6\n01\n1001\n01100\n111\n0000\n01010\n", "output": "1... | code_stdio |
[
{
"content": "A Bingo game is played by one gamemaster and several players. At the beginning of a game, each player is given a card with M × M numbers in a matrix (See Figure 10).\n\n<image>\n\nAs the game proceeds, the gamemaster announces a series of numbers one by one. Each player punches a hole in his card ... | [{"input": "4 3\n10 25 11 20 6 2 1 15 23\n5 21 1 12 23 17 7 26 2\n8 18 4 22 13 27 16 5 11\n19 9 24 2 11 5 14 28 16\n4 3\n12 13 20 24 28 32 15 16 17\n12 13 21 25 29 33 16 17 18\n12 13 22 26 30 34 17 18 15\n12 13 23 27 31 35 18 15 16\n4 3\n11 12 13 14 15 16 17 18 19\n21 22 23 24 25 26 27 28 29\n31 32 33 34 35 36 37 38 39... | code_stdio |
[
{
"content": "The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called \"Testing Pants for Sadness\".\n\nThe test consists of n questions; the questions are to be answered strictly in the order in which they are ... | [{"input": "50\n515844718 503470143 928669067 209884122 322869098 241621928 844696197 105586164 552680307 968792756 135928721 842094825 298782438 829020472 791637138 285482545 811025527 428952878 887796419 11883658 546401594 6272027 100292274 308219869 372132044 955814846 644008184 521195760 919389466 215065725 6877641... | code_stdio |
[
{
"content": "You are playing some computer game. One of its levels puts you in a maze consisting of n lines, each of which contains m cells. Each cell either is free or is occupied by an obstacle. The starting cell is in the row r and column c. In one step you can move one square up, left, down or right, if th... | [{"input": "21 7\n3 6\n5 2\n......*\n.****.*\n.****.*\n....*.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n*.**.**\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**.**.*\n**....*\n**....*\n*******\n", "output": "22\n"}, {"input": "21 7\n3 6\n5 2\n.*.....\n.****.*\n.****.*\n....*.*\n**.**.*\n**.**.*\n... | code_stdio |
[
{
"content": "Find the number of ways to choose a pair of an even number and an odd number from the positive integers between 1 and K (inclusive). The order does not matter.\n\n-----Constraints-----\n - 2\\leq K\\leq 100\n - K is an integer.\n\n-----Input-----\nInput is given from Standard Input in the followin... | [{"input": "-2373", "output": "1407782\n"}, {"input": "-1265", "output": "400056\n"}, {"input": "-1867", "output": "871422\n"}, {"input": "-1056", "output": "278784\n"}, {"input": "-1235", "output": "381306\n"}, {"input": "-1494", "output": "558009\n"}, {"input": "-1464", "output": "535824\n"}, {"input": "-931", "outpu... | code_stdio |
[
{
"content": "There is a robot on a checkered field that is endless in all directions. Initially, the robot is located in the cell with coordinates (0, 0). He will execute commands which are described by a string of capital Latin letters 'L', 'R', 'D', 'U'. When a command is executed, the robot simply moves in ... | [{"input": "4\nL\nLUUDR\nLLUU\nDDDUUUUU\n", "output": "-1 0\n-1 2\n0 0\n0 1\n"}, {"input": "4\nL\nLUUDR\nLLUU\nUUUUUDDD\n", "output": "-1 0\n-1 2\n0 0\n0 4\n"}, {"input": "4\nL\nLUUDR\nLLUU\nUDUUUDDU\n", "output": "-1 0\n-1 2\n0 0\n0 2\n"}, {"input": "4\nL\nLDUUR\nLLUU\nUUUUDDDU\n", "output": "-1 0\n-1 1\n0 0\n0 3\n"},... | code_stdio |
[
{
"content": "There are n kangaroos with pockets. Each kangaroo has a size (integer number). A kangaroo can go into another kangaroo's pocket if and only if the size of kangaroo who hold the kangaroo is at least twice as large as the size of kangaroo who is held.\n\nEach kangaroo can hold at most one kangaroo, ... | [{"input": "100\n154\n60\n97\n638\n139\n150\n570\n579\n601\n647\n804\n237\n245\n549\n288\n347\n778\n282\n916\n441\n974\n145\n957\n1006\n655\n702\n930\n618\n132\n520\n972\n48\n94\n54\n682\n433\n896\n134\n845\n636\n242\n842\n125\n141\n240\n130\n409\n666\n948\n938\n604\n110\n474\n484\n364\n40\n807\n271\n438\n288\n201\n814... | code_stdio |
[
{
"content": "Mitya has a rooted tree with n vertices indexed from 1 to n, where the root has index 1. Each vertex v initially had an integer number a_v ≥ 0 written on it. For every vertex v Mitya has computed s_v: the sum of all values written on the vertices on the path from vertex v to the root, as well as h... | [{"input": "25\n1 2 1 4 4 4 1 2 8 5 1 8 1 6 9 6 10 10 7 10 8 17 14 6\n846 -1 941 -1 1126 1691 988 -1 1352 1235 -1 -1 864 -1 -1 -1 -1 -1 -1 -1 -1 1508 1802 1713 -1\n", "output": "4346\n"}, {"input": "25\n1 2 1 4 4 4 1 2 8 5 1 8 1 6 9 6 10 10 7 10 11 17 14 6\n846 -1 676 -1 1126 1691 988 -1 1352 1235 -1 -1 864 -1 -1 -1 -1... | code_stdio |
[
{
"content": "Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k.\n\n\n-----Input-----\n\nThe only line contains two integers n and k (1 ≤ n, k ≤ 10^9).\n\n\n-----Output-----\n\nPrint the smallest integer x > n, so it is divis... | [{"input": "1000000000 1000000000\n", "output": "2000000000\n"}, {"input": "1000000010 1000000000\n", "output": "2000000000\n"}, {"input": "1398941105 1000000001\n", "output": "2000000002\n"}, {"input": "1000100010 1000010000\n", "output": "2000020000\n"}, {"input": "1000100010 1100010000\n", "output": "1100010000\n"},... | code_stdio |
[
{
"content": "Takahashi is not good at problems about trees in programming contests, and Aoki is helping him practice.\n\nFirst, Takahashi created a tree with N vertices numbered 1 through N, and wrote 0 at each edge.\n\nThen, Aoki gave him M queries. The i-th of them is as follows:\n\n* Increment the number wr... | [{"input": "10 0\n1 1\n2 6\n11 2\n-1 4\n0 10", "output": "YES\n"}, {"input": "10 -1\n1 1\n2 6\n11 2\n-1 5\n0 5", "output": "YES\n"}, {"input": "10 -1\n1 1\n2 3\n11 2\n-1 5\n0 5", "output": "YES\n"}, {"input": "10 0\n1 1\n11 6\n5 2\n-1 4\n1 3", "output": "YES\n"}, {"input": "10 0\n1 1\n2 6\n11 2\n-1 4\n1 5", "output": "... | code_stdio |
[
{
"content": "()\n\nProblem Statement\n\nThere is a string S. Initially, S is an empty string.\nPerform the following processing in order of n.\n\n* Add x_i p_i (=\" (\" or\") \") to the end of S.\n\n\n\nAfter processing, determine if S is a well-balanced string.\n\n\"The string is balanced\" is defined as foll... | [{"input": "5\n( 2\n) 0\n( 3\n) 1\n) 4", "output": "YES\n"}, {"input": "5\n( 2\n) 0\n( 1\n( 1\n) 4", "output": "YES\n"}, {"input": "5\n( -1\n) 0\n' 1\n( 1\n( 4", "output": "NO\n"}, {"input": "5\n( -1\n) 0\n' 1\n( 2\n( 4", "output": "NO\n"}, {"input": "5\n* 0\n* 0\n( 2\n* 2\n' 0", "output": "YES\n"}, {"input": "5\n) 0\n... | code_stdio |
[
{
"content": "The city of Fishtopia can be imagined as a grid of 4 rows and an odd number of columns. It has two main villages; the first is located at the top-left cell (1,1), people who stay there love fishing at the Tuna pond at the bottom-right cell (4, n). The second village is located at (4, 1) and its pe... | [{"input": "100 80\n", "output": "YES\n....................................................................................................\n.########################################...........................................................\n.########################################....................................... | code_stdio |
[
{
"content": "The only difference between easy and hard versions is constraints.\n\nIf you write a solution in Python, then prefer to send it in PyPy to speed up execution time.\n\nA session has begun at Beland State University. Many students are taking exams.\n\nPolygraph Poligrafovich is going to examine a gr... | [{"input": "10 50\n10 10 10 10 10 10 10 10 10 10\n", "output": "0 0 0 0 0 1 2 3 4 5 \n"}, {"input": "10 50\n10 10 10 10 10 10 10 10 10 10\n", "output": "0 0 0 0 0 1 2 3 4 5 "}, {"input": "10 71\n10 10 10 10 10 10 10 10 10 10\n", "output": "0 0 0 0 0 0 0 1 2 3\n"}, {"input": "10 71\n10 10 10 10 10 10 10 10 10 14\n", "ou... | code_stdio |
[
{
"content": "Dima got into number sequences. Now he's got sequence a_1, a_2, ..., a_{n}, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence: f(0) = 0; f(2·x) = f(x); f(2·x + 1) = f(x) + 1. \n\nDima wonders, how many pairs of indexes (i, ... | [{"input": "8\n851991424 32517099 310793856 776130403 342626527 58796623 49544509 517126753\n", "output": "2\n"}, {"input": "8\n851991424 32517099 310793856 771296843 342626527 58796623 49544509 517126753\n", "output": "1\n"}, {"input": "8\n851991424 32517099 310793856 440880219 342626527 58796623 49544509 517126753\n"... | code_stdio |
[
{
"content": "The hero of our story, Valera, and his best friend Arcady are still in school, and therefore they spend all the free time playing turn-based strategy \"GAGA: Go And Go Again\". The gameplay is as follows. \n\nThere are two armies on the playing field each of which consists of n men (n is always ev... | [{"input": "110000000\n", "output": "165000000\n"}, {"input": "134067708\n", "output": "201101562\n"}, {"input": "111000000\n", "output": "166500000\n"}, {"input": "111000010\n", "output": "166500015\n"}, {"input": "111001010\n", "output": "166501515\n"}, {"input": "110001010\n", "output": "165001515\n"}, {"input": "10... | code_stdio |
[
{
"content": "Snuke, a water strider, lives in a rectangular pond that can be seen as a grid with H east-west rows and W north-south columns. Let (i,j) be the square at the i-th row from the north and j-th column from the west.\nSome of the squares have a lotus leaf on it and cannot be entered.\nThe square (i,j... | [{"input": "3 10 -1\n3 3 3 4\n.....\n.@..@\n-.@..", "output": "-1\n"}, {"input": "3 10 -1\n3 4 3 4\n.....\n.@..@\n-.@..", "output": "0\n"}, {"input": "3 10 0\n3 3 3 4\n.....\n.@..@\n-.@..", "output": "-1\n"}, {"input": "5 10 0\n3 3 3 4\n.....\n.@..@\n-.@..", "output": "-1\n"}, {"input": "5 12 0\n3 3 3 4\n.....\n.@..@\n... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese , Russian and Vietnamese as well. \n\nChef belongs to a very rich family which owns many gold mines. Today, he brought N gold coins and decided to form a triangle using these coins. Isn't it strange?\n\nChef has a unusual way of forming a triangle using... | [{"input": "3\n5\n13\n106", "output": "2\n4\n14\n"}, {"input": "3\n5\n13\n68", "output": "2\n4\n11\n"}, {"input": "3\n5\n1\n106", "output": "2\n1\n14\n"}, {"input": "3\n5\n1\n122", "output": "2\n1\n15\n"}, {"input": "3\n1\n17\n11", "output": "1\n5\n4\n"}, {"input": "3\n1\n11\n14", "output": "1\n4\n4\n"}, {"input": "3\n... | code_stdio |
[
{
"content": "After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.\n\nOnce upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1.... | [{"input": "7 4\n1 1 3 3 5 3\n2\n2\n3\n5\n", "output": "2\n2\n3\n5\n"}, {"input": "7 4\n1 1 3 3 5 3\n2\n4\n3\n5\n", "output": "2\n4\n3\n5\n"}, {"input": "7 4\n1 1 3 3 5 3\n2\n3\n3\n5\n", "output": "2\n3\n3\n5\n"}, {"input": "7 4\n1 1 3 3 5 3\n2\n4\n3\n3\n", "output": "2\n4\n3\n3\n"}, {"input": "7 4\n1 1 3 3 5 6\n2\n4\n... | code_stdio |
[
{
"content": "Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins.\n\nAcross all the set... | [{"input": "1 1000000000 1000000000\n", "output": "2000000000\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "2\n"}, {"input": "2 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "1000000000 999999999 999999999\n", "output": "-1\n"}, {"input": "999999999 1000000000 999999998\n", "output": ... | code_stdio |
[
{
"content": "This problem consists of three subproblems: for solving subproblem F1 you will receive 8 points, for solving subproblem F2 you will receive 15 points, and for solving subproblem F3 you will receive 10 points.\n\nManao has developed a model to predict the stock price of a company over the next n da... | [{"input": "10 4\n2\n7\n1\n9\n8\n10\n5\n10\n1\n20\n", "output": "38\n"}, {"input": "10 4\n1\n7\n1\n9\n8\n10\n5\n10\n1\n20\n", "output": "39\n"}, {"input": "10 5\n2\n13\n3\n9\n8\n7\n9\n7\n1\n18\n", "output": "36\n"}, {"input": "10 5\n2\n13\n3\n9\n8\n7\n2\n7\n1\n18\n", "output": "39\n"}, {"input": "10 2\n2\n22\n5\n9\n10\... | code_stdio |
[
{
"content": "For a finite set of integers X, let f(X)=\\max X - \\min X.\nGiven are N integers A_1,...,A_N.\nWe will choose K of them and let S be the set of the integers chosen. If we distinguish elements with different indices even when their values are the same, there are {}_N C_K ways to make this choice. ... | [{"input": "10 6\n1000000000 1000000000 1000000000 1000000000 1000000000 0 0 0 0 0\n", "output": "999998537\n"}, {"input": "10 8\n1000000000 1100000000 1000001010 1000000000 1000000000 0 0 -2 0 0", "output": "600007816\n"}, {"input": "10 8\n1000000000 1100000000 1000001010 1100000000 1000000000 0 0 -2 0 0", "output": "... | code_stdio |
[
{
"content": "Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, 2, ..., n} is such function $g : \\{1,2, \\ldots, n \\} \\rightarrow \\{1,2, \\ldots, n \\}$, that for any $x \\in \\{1,2, \\ldots, n \\}$ the formula g(g(x)) = g(x) holds.\n\nLet's denote as f^{(}... | [{"input": "142\n34 88 88 88 88 88 131 53 88 130 131 88 88 130 88 131 53 130 130 34 88 88 131 130 53 88 88 34 131 130 88 131 130 34 130 53 53 34 53 34 130 34 88 88 130 88 131 130 34 53 88 34 53 88 130 53 34 53 88 131 130 34 88 88 130 88 130 130 131 131 130 53 131 130 131 130 53 34 131 34 88 53 88 53 34 130 88 88 130 53... | code_stdio |
[
{
"content": "How Many Divisors?\n\nWrite a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.\n\nConstraints\n\n* 1 ≤ a, b, c ≤ 10000\n* a ≤ b\n\nInput\n\nThree integers a, b and c are given in a line separated by a single space.\n\nOutput\n\nPrint the number... | [{"input": "4 32 120", "output": "10\n"}, {"input": "13 14 107", "output": "0\n"}, {"input": "5 14 149", "output": "0\n"}, {"input": "13 14 80", "output": "0\n"}, {"input": "5 14 241", "output": "0\n"}, {"input": "2 14 241", "output": "0\n"}, {"input": "2 14 113", "output": "0\n"}, {"input": "2 19 113", "output": "0\n"... | code_stdio |
[
{
"content": "Gilbert is the network admin of Ginkgo company. His boss is mad about the messy network cables on the floor. He finally walked up to Gilbert and asked the lazy network admin to illustrate how computers and switches are connected. Since he is a programmer, he is very reluctant to move throughout th... | [{"input": "4\n 0 2 2 2\n 2 0 2 2\n 2 2 -1 2\n 2 2 2 0\n4\n -1 2 4 4\n 2 -1 4 4\n 4 4 -1 2\n 4 4 2 0\n2\n 0 12\n 12 0\n0", "output": "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2\n"}, {"input": "4\n -1 2 2 2\n 2 0 2 2\n 2 2 -1 2\n 2 2 2 0\n4\n 0 2 4 4\n 2 0 4 ... | code_stdio |
[
{
"content": "You are given a directed graph consisting of n vertices and m edges (each edge is directed, so it can be traversed in only one direction). You are allowed to remove at most one edge from it.\n\nCan you make this graph acyclic by removing at most one edge from it? A directed graph is called acyclic... | [{"input": "500 50\n396 340\n47 341\n422 140\n492 209\n263 248\n461 300\n124 495\n33 6\n93 384\n389 182\n130 297\n217 329\n131 136\n355 94\n388 275\n115 368\n279 462\n126 285\n185 287\n223 221\n207 167\n203 127\n39 245\n394 444\n166 99\n399 328\n3 276\n142 325\n284 153\n65 3\n102 5\n459 168\n156 17\n99 162\n293 194\n49... | code_stdio |
[
{
"content": "According to a new ISO standard, a flag of every country should have, strangely enough, a chequered field n × m, each square should be wholly painted one of 26 colours. The following restrictions are set: \n\n * In each row at most two different colours can be used. \n * No two adjacent squares ... | [{"input": "1 500\nwljexjwjwsxhascgpyezfotqyieywzyzpnjzxqebroginhlpsvtbgmbckgqixkdveraxlgleieeagubywaacncxoouibbhwyxhjiczlymscsqlttecvundzjqtuizqwsjalmizgeekugacatlwhiiyaamjuiafmyzxadbxsgwhfawotawfxkpyzyoceiqfppituvaqmgfjinulkbkgpnibaefqaqiptctoqhcnnfihmzijnwpxdikwefpxicbspdkppznpiqrpkyvcxapoaofjbliepgfwmppgwypgflzdtzv... | code_stdio |
[
{
"content": "Can you imagine our life if we removed all zeros from it? For sure we will have many problems.\n\nIn this problem we will have a simple example if we removed all zeros from our life, it's the addition operation. Let's assume you are given this equation a + b = c, where a and b are positive integer... | [{"input": "1000000000\n1000000000\n", "output": "YES\n"}, {"input": "1000000000\n1000010000\n", "output": "NO\n"}, {"input": "1000000000\n1001010000\n", "output": "NO\n"}, {"input": "999999999\n999999999\n", "output": "YES\n"}, {"input": "341781108\n1068141937\n", "output": "NO\n"}, {"input": "501871728\n1015604246\n"... | code_stdio |
[
{
"content": "Sereja loves all sorts of algorithms. He has recently come up with a new algorithm, which receives a string as an input. Let's represent the input string of the algorithm as q = q_1q_2... q_{k}. The algorithm consists of two steps:\n\n Find any continuous subsequence (substring) of three characte... | [{"input": "yxzyzxzzxyyzzxxxzyyzzyzxxzxyzyyzxyzxyxxyzxyxzyzxyzxyyxzzzyzxyyxyzxxy\n10\n17 67\n6 35\n12 45\n56 56\n14 30\n25 54\n1 1\n46 54\n3 33\n19 40\n", "output": "NO\nNO\nNO\nYES\nYES\nNO\nYES\nNO\nNO\nYES\n"}, {"input": "yxzyzxzzxyyzzxxxzyyzzyzxxzxyzyyzxyzxyxxyzxyxzyzxyzxyyxzzzyzxyyxyzxxy\n10\n17 67\n6 35\n12 45\n5... | code_stdio |
[
{
"content": "Takahashi, who is a novice in competitive programming, wants to learn M algorithms.\nInitially, his understanding level of each of the M algorithms is 0.\nTakahashi is visiting a bookstore, where he finds N books on algorithms.\nThe i-th book (1\\leq i\\leq N) is sold for C_i yen (the currency of ... | [{"input": "12 12 48311\n2997 79802 84238 34346 35199 2284 77696 46340 54797 36702 97764 42765 11582\n82923 47331 39508 81928 63775 90952 64439 99662 74546 15843 11552 23897 87476\n26261 21259 714 72469 92132 94958 69101 38760 4916 38769 60706 90149 70017\n35433 97674 53722 44881 95786 42614 79922 49582 34615 36414 806... | code_stdio |
[
{
"content": "A renowned abstract artist Sasha, drawing inspiration from nowhere, decided to paint a picture entitled \"Special Olympics\". He justly thought that, if the regular Olympic games have five rings, then the Special ones will do with exactly two rings just fine.\n\nLet us remind you that a ring is a ... | [{"input": "-100 -97 20 40\n-151 -97 30 100\n", "output": "1\n"}, {"input": "-123 -29 20 40\n-39 -19 99 100\n", "output": "0\n"}, {"input": "-100 -97 20 40\n-90 -97 30 100\n", "output": "2"}, {"input": "-45 -93 20 40\n-36 -93 31 127\n", "output": "2\n"}, {"input": "-26 -65 20 40\n52 -123 98 100\n", "output": "0\n"}, {"... | code_stdio |
[
{
"content": "Fennec and Snuke are playing a board game.\nOn the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms ... | [{"input": "7\n3 6\n1 2\n3 1\n7 4\n5 7\n1 4\n", "output": "Fennec\n"}, {"input": "7\n3 6\n2 2\n3 1\n7 4\n5 7\n1 4", "output": "Fennec\n"}, {"input": "7\n3 6\n2 2\n3 1\n7 4\n4 7\n1 4", "output": "Fennec\n"}, {"input": "7\n3 6\n1 2\n3 2\n7 4\n5 7\n1 4", "output": "Fennec\n"}, {"input": "7\n3 6\n2 2\n3 1\n5 4\n4 7\n1 4", ... | code_stdio |
[
{
"content": "Consider the following equation: \n\n<image> where sign [a] represents the integer part of number a.\n\nLet's find all integer z (z > 0), for which this equation is unsolvable in positive integers. The phrase \"unsolvable in positive integers\" means that there are no such positive integers x and ... | [{"input": "14\n", "output": " 373391776\n"}, {"input": "38\n", "output": " 90046024\n"}, {"input": "25\n", "output": " 470083777\n"}, {"input": "22\n", "out... | code_stdio |
[
{
"content": "Problem statement\n\nThere is a rational number sequence $ X_0, X_1, X_2, ..., X_N $. Each term is defined as follows.\n\n\n1. $ X_0 = 0 $\n2. $ X_i = X_ {i-1} $ $ op_i $ $ Y_i $ ($ 1 \\ leq i \\ leq N $). However, $ op_i $ is $ + $, $ − $, $ × $, $ ÷ $ Either.\n\n\n\nFind $ X_N $.\n\nConstraint\n... | [{"input": "4\n-1 2\n12 0\n1 -3\n3 13", "output": "-39\n"}, {"input": "4\n-2 4\n7 1\n-1 8\n2 25", "output": "-25\n"}, {"input": "4\n-1 -2\n2 3\n3 2\n2 22", "output": "-28\n"}, {"input": "4\n-1 -2\n2 5\n3 2\n2 22", "output": "-32\n"}, {"input": "4\n-1 -2\n2 1\n3 2\n2 22", "output": "-24\n"}, {"input": "4\n-6 1\n58 0\n0 ... | code_stdio |
[
{
"content": "Marcin is a coach in his university. There are $n$ students who want to attend a training camp. Marcin is a smart coach, so he wants to send only the students that can work calmly with each other.\n\nLet's focus on the students. They are indexed with integers from $1$ to $n$. Each of them can be d... | [{"input": "10\n206158430208 206162624513 68719476737 137506062337 206162624513 4194305 68719476737 206225539072 137443147777 109376694609\n202243898 470292528 170057449 290025540 127995253 514454151 607963029 768676450 611202521 68834463\n", "output": "2704208829\n"}, {"input": "10\n206158430208 206162624513 687194767... | code_stdio |
[
{
"content": "Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process... | [{"input": "1256336691\n", "output": "2931452299 10050693537\n"}, {"input": "1359531323\n", "output": "6797656627 10876250593\n"}, {"input": "1544906479\n", "output": "1581910903 12359251841\n"}, {"input": "1278463385\n", "output": "2301234121 10227707089\n"}, {"input": "1369156222\n", "output": "110960153 10953249785\... | code_stdio |
[
{
"content": "Recently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with $n$ elements. The $i$-th element is $a_i$ ($i$ = $1, 2, \\ldots, n$). He gradually takes the first two leftmost elements from the deque (let's call them $A$ and $B$, respecti... | [{"input": "71 57\n9 26 80 2 65 60 63 1 15 109 114 1 58 27 41 97 42 9 42 56 87 22 10 28 34 90 13 70 71 56 65 21 0 78 47 96 56 77 32 83 28 16 10 41 0 18 118 12 27 112 4 67 21 41 111 20 21 52 74 10 83 74 43 123 2 15 0 63 68 7 72\n81\n47\n81\n81\n5\n9\n41\n76\n81\n92\n95\n94\n78\n93\n47\n30\n152\n3\n45\n50\n42\n88\n17\n3\... | code_stdio |
[
{
"content": "Given is a permutation P_1, \\ldots, P_N of 1, \\ldots, N.\nFind the number of integers i (1 \\leq i \\leq N) that satisfy the following condition: \n - For any integer j (1 \\leq j \\leq i), P_i \\leq P_j.\n\n-----Constraints-----\n - 1 \\leq N \\leq 2 \\times 10^5\n - P_1, \\ldots, P_N is a per... | [{"input": "8\n5 7 4 2 6 8 1 3\n", "output": "4\n"}, {"input": "8\n5 14 4 2 6 8 1 3", "output": "4\n"}, {"input": "8\n5 28 4 2 6 8 1 3", "output": "4\n"}, {"input": "8\n5 14 4 2 6 4 1 3", "output": "4\n"}, {"input": "8\n5 28 4 2 8 8 1 3", "output": "4\n"}, {"input": "8\n5 7 4 2 6 8 1 0", "output": "5\n"}, {"input": "6\... | code_stdio |
[
{
"content": "You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!\n\nYou have n tickets to sell. The price of the i-th ticket is p_i. As a teller, you have a possibility to select the order in which the tickets will be sold ... | [{"input": "4\n1\n100\n50 2\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n16 2\n15 3\n107\n3\n1000000000 1000000000 1000000000\n50 1\n50 1\n4850788900\n5\n200 100 100 100 100\n105 5\n31 1\n90\n", "output": "-1\n6\n-1\n2\n"}, {"input": "4\n1\n100\n50 2\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n16 2\n15 3\n107\n3... | code_stdio |
[
{
"content": "You've been in love with Coronavirus-chan for a long time, but you didn't know where she lived until now. And just now you found out that she lives in a faraway place called Naha. \n\nYou immediately decided to take a vacation and visit Coronavirus-chan. Your vacation lasts exactly $x$ days and th... | [{"input": "48 14\n1 1 1 1 1 6 1 1 1 1 1 1 3 3 1 1 1 1 1 2 2 2 1 1 1 1 1 1 2 1 4 1 1 1 1 1 1 1 1 1 1 7 1 1 1 1 1 5\n", "output": "42\n"}, {"input": "48 14\n1 1 1 1 1 6 1 1 1 1 1 1 3 3 1 1 2 1 1 2 2 2 1 1 1 1 1 1 2 1 4 1 1 1 1 1 1 1 1 1 1 7 1 1 1 1 1 5\n", "output": "42\n"}, {"input": "48 14\n1 1 1 1 1 6 1 1 1 1 2 1 3 3... | code_stdio |
[
{
"content": "Imagine that there is a group of three friends: A, B and С. A owes B 20 rubles and B owes C 20 rubles. The total sum of the debts is 40 rubles. You can see that the debts are not organized in a very optimal manner. Let's rearrange them like that: assume that A owes C 20 rubles and B doesn't owe an... | [{"input": "100 48\n1 56 6\n2 42 3\n3 52 1\n9 26 8\n10 96 8\n11 39 2\n12 51 6\n12 68 7\n13 40 5\n14 18 10\n14 70 6\n15 37 8\n15 38 8\n15 82 6\n15 85 5\n16 48 3\n16 50 9\n16 71 9\n17 18 3\n17 100 10\n20 73 3\n22 32 9\n22 89 9\n23 53 3\n24 53 1\n27 78 10\n30 50 5\n33 94 8\n34 87 9\n35 73 3\n36 51 8\n37 88 10\n37 97 2\n40... | code_stdio |
[
{
"content": "In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.\n\nFor class A, after \">'\" is followed by one or more \"=\", \"#\" comes, and after the same number of \"=\" as before, \"~\" (half-wi... | [{"input": "3\n>(======#======~\n~~=Q=Q=Q=Q=Q=Q=Q=^=QQ>\n>'===#==~>=", "output": "NA\nNA\nNA\n"}, {"input": "3\n>(======#======~\n~~=Q=Q=Q=Q===Q=Q=^QQQ>\n>'===#==~>=", "output": "NA\nNA\nNA\n"}, {"input": "3\n>(======#======~\n~~=P=Q=Q=Q===Q=Q=^QQQ>\n>'===#==~>=", "output": "NA\nNA\nNA\n"}, {"input": "3\n>(======#=====... | code_stdio |
[
{
"content": "There are N Snuke Cats numbered 1, 2, \\ldots, N, where N is even.\nEach Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.\nRecently, they learned the operation called xor (exclusive OR).What is xor?\n\nFor n non-negative integers x_1, x_2, \\ldots, x_n, their xor... | [{"input": "4\n141 1 -1 2", "output": "-4 -144 142 -141\n"}, {"input": "4\n102 2 -1 2", "output": "-1 -101 102 -101\n"}, {"input": "4\n102 2 -1 1", "output": "-4 -104 101 -101\n"}, {"input": "4\n13 -17 0 0", "output": "-17 13 -30 -30\n"}, {"input": "4\n12 -17 2 0", "output": "-19 14 -29 -31\n"}, {"input": "4\n12 -17 2 ... | code_stdio |
[
{
"content": "Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function ... | [{"input": "100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 93 -76 -98 -22 -31 16 -50 6 -20 -85 1 64 -88 -8 -15 -6 -57 25 91 10 2 -90 74 -66 -42 73 28 49 -85 59 96 79 -25 49 -59 -89 -75 12 -96 -33 -65 -8 -100 -81 17 99 -91 -5 7 -21 1 85 63 86 -26 85 -31 11 -75 35 -82 15 98 93 -55 66 70 36 -38 8 92 -63 -5 6... | code_stdio |
[
{
"content": "Ramesses came to university to algorithms practice, and his professor, who is a fairly known programmer, gave him the following task.\n\nYou are given two matrices $A$ and $B$ of size $n \\times m$, each of which consists of $0$ and $1$ only. You can apply the following operation to the matrix $A$... | [{"input": "10 10\n1 1 1 0 1 1 0 0 0 1\n1 1 1 1 0 0 0 0 0 1\n0 1 0 0 0 0 0 0 1 0\n0 0 0 0 0 1 0 0 0 0\n0 1 1 1 0 1 1 1 0 0\n0 0 0 1 1 1 0 1 0 0\n0 0 0 0 1 1 0 0 1 1\n0 0 0 1 1 0 1 1 1 1\n1 1 0 1 1 0 1 1 0 0\n1 0 0 0 0 0 0 0 1 0\n0 1 0 1 0 1 1 1 0 0\n0 1 1 0 0 0 0 0 0 1\n0 1 0 0 0 1 0 0 0 0\n0 1 0 0 1 1 1 0 0 1\n0 1 1 0... | code_stdio |
[
{
"content": "Recently a new building with a new layout was constructed in Monocarp's hometown. According to this new layout, the building consists of three types of apartments: three-room, five-room, and seven-room apartments. It's also known that each room of each apartment has exactly one window. In other wo... | [{"input": "4\n30\n67\n8\n14\n", "output": "10 0 0\n20 0 1\n1 1 0\n3 1 0\n"}, {"input": "4\n30\n44\n8\n14\n", "output": "10 0 0\n13 1 0\n1 1 0\n3 1 0\n"}, {"input": "4\n18\n44\n14\n14\n", "output": "6 0 0\n13 1 0\n3 1 0\n3 1 0\n"}, {"input": "4\n30\n44\n8\n11\n", "output": "10 0 0\n13 1 0\n1 1 0\n2 1 0\n"}, {"input": "... | code_stdio |
[
{
"content": "A railroad running from west to east in Atcoder Kingdom is now complete.\nThere are N stations on the railroad, numbered 1 through N from west to east.\nTomorrow, the opening ceremony of the railroad will take place.\nOn this railroad, for each integer i such that 1≤i≤N-1, there will be trains tha... | [{"input": "4\n12 13 1\n44 17 17\n66 4096 64\n", "output": "4162\n4162\n4162\n0\n"}, {"input": "4\n1 13 1\n44 17 22\n101 4096 64", "output": "4197\n4197\n4197\n0\n"}, {"input": "4\n1 13 1\n44 17 22\n120 4096 64", "output": "4216\n4216\n4216\n0\n"}, {"input": "4\n1 18 1\n44 17 22\n111 4096 64", "output": "4207\n4207\n42... | code_stdio |
[
{
"content": "The development of a text editor is a hard problem. You need to implement an extra module for brackets coloring in text.\n\nYour editor consists of a line with infinite length and cursor, which points to the current character. Please note that it points to only one of the characters (and not betwe... | [{"input": "21\n(RRRRR)LLLL(RRR)LL(R)\n", "output": "-1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 2 2 2 -1 -1 3 "}, {"input": "21\n(RRRRR)LLLL(RRR)LL(R)\n", "output": "-1 -1 -1 -1 -1 -1 1 1 1 1 1 -1 -1 -1 -1 2 2 2 -1 -1 3 "}, {"input": "11\n'R)R(R)Ra)c\n", "output": "0 0 -1 -1 -1 -1 -1 -1 -1 -1 -1\n"}, {"input": "11\n'R)R(R... | code_stdio |
[
{
"content": "An art exhibition will be held in JOI. At the art exhibition, various works of art from all over the country will be exhibited.\n\nN works of art were collected as candidates for the works of art to be exhibited. These works of art are numbered 1, 2, ..., N. Each work of art has a set value called... | [{"input": "3\n1 12\n26 -1\n2 0", "output": "12\n"}, {"input": "3\n1 11\n80 0\n2 -1", "output": "11\n"}, {"input": "3\n0 17\n14 1\n13 2", "output": "17\n"}, {"input": "3\n0 16\n54 3\n5 1", "output": "16\n"}, {"input": "3\n0 16\n48 3\n0 2", "output": "18\n"}, {"input": "3\n0 16\n48 3\n0 4", "output": "20\n"}, {"input": ... | code_stdio |
[
{
"content": "We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i).\n\nAmong them, we are looking for the points such that the distance from the origin is at most D. How many such points are there?\n\nWe remind you that the distance between the origin and the point (p, ... | [{"input": "20 101000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n191679 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-178807 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n10994 -163796\n138819 -185986\n-69848 -96669", "... | code_stdio |
[
{
"content": "You are given a set of n elements indexed from 1 to n. The weight of i-th element is w_{i}. The weight of some subset of a given set is denoted as $W(S) =|S|\\cdot \\sum_{i \\in S} w_{i}$. The weight of some partition R of a given set into k subsets is $W(R) = \\sum_{S \\in R} W(S)$ (recall that a... | [{"input": "6 2\n2578 6301 8624 6020 8513 9486\n", "output": "4401332\n"}, {"input": "6 3\n4759 5555 7401 8003 2501 6345\n", "output": "7431260\n"}, {"input": "6 2\n2578 6301 8624 6020 8513 9486\n", "output": "4401332\n"}, {"input": "6 3\n4759 5555 7401 8003 2501 6345\n", "output": "7431260\n"}, {"input": "6 2\n2578 63... | code_stdio |
[
{
"content": "There are two bus stops denoted A and B, and there n buses that go from A to B every day. The shortest path from A to B takes t units of time but some buses might take longer paths. Moreover, buses are allowed to overtake each other during the route.\n\nAt each station one can find a sorted list o... | [{"input": "2 1000000000\n999999999 1000000000\n1 2\n", "output": "Yes\n1999999999 2000000000\n"}, {"input": "2 1000000000\n1 1000000000\n2 2\n", "output": "Yes\n2000000000 2000000001\n"}, {"input": "2 1000010000\n1 1000000000\n2 2\n", "output": "Yes\n2000010000 2000010001\n"}, {"input": "2 1000000000\n130296385 100000... | code_stdio |
[
{
"content": "Rng is preparing a problem set for a qualification round of CODEFESTIVAL.\n\nHe has N candidates of problems. The difficulty of the i-th candidate is D_i.\n\nThere must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be ... | [{"input": "7\n100 200 500 700 238 1600 2000\n6\n100 200 500 700 1600 1600", "output": "NO\n"}, {"input": "7\n100 200 500 700 238 1600 2000\n6\n100 200 500 337 1600 1600", "output": "NO\n"}, {"input": "7\n100 200 500 700 1200 1600 2000\n6\n100 200 500 700 1600 1600", "output": "NO"}, {"input": "7\n100 200 500 700 238 1... | code_stdio |
[
{
"content": "Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that costs b points. Besides, Misha submitted the problem c mi... | [{"input": "1500 1000 176 177\n", "output": "Misha\n"}, {"input": "2750 1750 134 147\n", "output": "Misha\n"}, {"input": "3250 1000 160 138\n", "output": "Misha\n"}, {"input": "1250 2000 101 180\n", "output": "Misha\n"}, {"input": "2250 2250 163 145\n", "output": "Vasya\n"}, {"input": "1750 1250 179 180\n", "output": "... | code_stdio |
[
{
"content": "Manao has a monitor. The screen of the monitor has horizontal to vertical length ratio a:b. Now he is going to watch a movie. The movie's frame has horizontal to vertical length ratio c:d. Manao adjusts the view in such a way that the movie preserves the original frame ratio, but also occupies as ... | [{"input": "999 1000 1365 999\n", "output": "122333/455000\n"}, {"input": "999 1010 1365 999\n", "output": "126883/459550\n"}, {"input": "999 1000 1000 999\n", "output": "1999/1000000\n"}, {"input": "999 1000 1000 999\n", "output": "1999/1000000\n"}, {"input": "999 1000 1206 999\n", "output": "23111/134000\n"}, {"input... | code_stdio |
[
{
"content": "The biggest event of the year – Cota 2 world championship \"The Innernational\" is right around the corner. $2^n$ teams will compete in a double-elimination format (please, carefully read problem statement even if you know what is it) to identify the champion. \n\nTeams are numbered from $1$ to $2... | [{"input": "16 50\n57794 44224 38309 41637 11732 44974 655 27143 11324 49584 3371 17159 26557 38800 33033 18231 26264 14765 33584 30879 46988 60703 52973 47349 22720 51251 54716 29642 7041 54896 12197 38530 51481 43063 55463 2057 48064 41953 16250 21272 34003 51464 50389 30417 45901 38895 25949 798 29404 55166\n", "out... | code_stdio |
[
{
"content": "On March 14, the day of the number $\\pi$ is celebrated all over the world. This is a very important mathematical constant equal to the ratio of the circumference of a circle to its diameter.\n\nPolycarp was told at school that the number $\\pi$ is irrational, therefore it has an infinite number o... | [{"input": "9\n000\n3\n4141592653\n141592653589793238462643383279\n31420\n31415\n314159265358\n27182\n314159265358979323846264338327\n", "output": "0\n1\n0\n0\n3\n5\n12\n0\n30\n"}, {"input": "3\n314\n315\n314\n", "output": "3\n2\n3\n"}, {"input": "2\n0314\n0003000\n", "output": "0\n0\n"}, {"input": "1\n31415653588880\n... | code_stdio |
[
{
"content": "This problem consists of three subproblems: for solving subproblem C1 you will receive 4 points, for solving subproblem C2 you will receive 4 points, and for solving subproblem C3 you will receive 8 points.\n\nManao decided to pursue a fighter's career. He decided to begin with an ongoing tourname... | [{"input": "40 3\n1 62395\n5 40319\n4 165445\n10 137479\n10 47829\n8 9741\n5 148106\n10 25494\n10 162856\n2 106581\n0 194523\n9 148086\n1 100862\n6 147600\n6 107486\n6 166873\n7 16721\n4 22192\n0 8827\n1 197146\n10 8949\n0 150443\n9 148348\n3 143935\n1 139371\n7 128821\n10 107760\n4 141821\n1 35852\n9 107522\n10 54717\... | code_stdio |
[
{
"content": "Vasya has got three integers n, m and k. He'd like to find three integer points (x_1, y_1), (x_2, y_2), (x_3, y_3), such that 0 ≤ x_1, x_2, x_3 ≤ n, 0 ≤ y_1, y_2, y_3 ≤ m and the area of the triangle formed by these points is equal to nm/k.\n\nHelp Vasya! Find such points (if it's possible). If th... | [{"input": "1000000000 1000000000 2\n", "output": "YES\n0 0\n1000000000 0\n0 1000000000\n"}, {"input": "1000000000 1000000001 2\n", "output": "YES\n0 0\n1000000000 0\n0 1000000001\n"}, {"input": "1000000010 1000000001 2\n", "output": "YES\n0 0\n1000000010 0\n0 1000000001\n"}, {"input": "236887699 1000000000 2\n", "outp... | code_stdio |
[
{
"content": "Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches.\n\nFirst, as they know that kingdom police is bad at math, robbers use the positional numeral system with base 7. Second, they ... | [{"input": "1000000000 1000000000\n", "output": "0\n"}, {"input": "1010000000 1000000000\n", "output": "0\n"}, {"input": "1000000000 1000000100\n", "output": "0\n"}, {"input": "282475250 282475250\n", "output": "0\n"}, {"input": "421414245 4768815\n", "output": "0\n"}, {"input": "421414245 5452708\n", "output": "0\n"},... | code_stdio |
[
{
"content": "With the motto \"Creating your own path,\" a shrine created a fortune-telling fortune with its own hands. Ask the person who draws the lottery to throw six stones first, then the line segment connecting the first and second of the thrown stones, the line segment connecting the third and fourth, th... | [{"input": "-1 -2 9 6\n3 -2 7 6\n-1 0 9 0\n2 2 0 -1\n1 2 2 0\n-3 -1 3 1\n0 0 0 0", "output": "syo-kichi\nsyo-kichi\n"}, {"input": "-1 -2 22 6\n3 -2 7 10\n-1 0 9 0\n3 2 0 -1\n1 1 2 1\n-3 -1 3 1\n0 0 0 0", "output": "syo-kichi\nkyo\n"}, {"input": "-1 -1 22 6\n3 -2 7 10\n-1 0 9 0\n3 2 0 -1\n1 1 2 1\n-3 -1 3 1\n0 0 0 0", "... | code_stdio |
[
{
"content": "It is important to use strong passwords to make the Internet more secure. At the same time, it is very important not to reuse the same password. No matter how strong your password is, if the plaintext is leaked in one place, it will be very easy to break. Of course, if all applications hash passwo... | [{"input": "passxord", "output": "INVALID\n"}, {"input": "parsxosd", "output": "INVALID\n"}, {"input": "parsxpsd", "output": "INVALID\n"}, {"input": "qarsxpsd", "output": "INVALID\n"}, {"input": "qarxspsd", "output": "INVALID\n"}, {"input": "dspsxraq", "output": "INVALID\n"}, {"input": "qarxspsc", "output": "INVALID\n"... | code_stdio |
[
{
"content": "The door of Snuke's laboratory is locked with a security code.\nThe security code is a 4-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.\nYou are given the current security code S. If S is hard to enter, print Bad; otherwise, print... | [{"input": "8080\n", "output": "Good\n"}, {"input": "0930\n", "output": "Good\n"}, {"input": "8901\n", "output": "Good\n"}, {"input": "3695\n", "output": "Good\n"}, {"input": "4649\n", "output": "Good\n"}, {"input": "12101", "output": "Good\n"}, {"input": "12904", "output": "Good\n"}, {"input": "24106", "output": "Good... | code_stdio |
[
{
"content": "You are given a 4-character string S consisting of uppercase English letters.\nDetermine if S consists of exactly two kinds of characters which both appear twice in S.\n\n-----Constraints-----\n - The length of S is 4.\n - S consists of uppercase English letters.\n\n-----Input-----\nInput is given... | [{"input": "ASSA\n", "output": "Yes\n"}, {"input": "FFEE\n", "output": "Yes\n"}, {"input": "AVVA\n", "output": "Yes\n"}, {"input": "HHTT\n", "output": "Yes\n"}, {"input": "ILIL\n", "output": "Yes\n"}, {"input": "STOP\n", "output": "No\n"}, {"input": "FREE\n", "output": "No\n"}, {"input": "ZZZZ\n", "output": "No\n"}, {"... | code_stdio |
[
{
"content": "Robbers, who attacked the Gerda's cab, are very successful in covering from the kingdom police. To make the goal of catching them even harder, they use their own watches.\n\nFirst, as they know that kingdom police is bad at math, robbers use the positional numeral system with base 7. Second, they ... | [{"input": "1000000000 1000000000\n", "output": "0\n"}, {"input": "1000000000 1000000000\n", "output": "0\n"}, {"input": "1000000000 1000000001\n", "output": "0\n"}, {"input": "1000000000 1000000011\n", "output": "0\n"}, {"input": "1100000000 1000000011\n", "output": "0\n"}, {"input": "282475250 282475250\n", "output":... | code_stdio |
[
{
"content": "Unlike Knights of a Round Table, Knights of a Polygonal Table deprived of nobility and happy to kill each other. But each knight has some power and a knight can kill another knight if and only if his power is greater than the power of victim. However, even such a knight will torment his conscience... | [{"input": "11 10\n1 2 3 4 5 6 7 8 9 10 11\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1000000000 2000000000 3000000000 4000000000 5000000000 6000000000 7000000000 8000000000 9000000000 10000000000 11000000000 "}, {"input": "11... | code_stdio |
[
{
"content": "Let's define a forest as a non-directed acyclic graph (also without loops and parallel edges). One day Misha played with the forest consisting of n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degree_{v} and s_{v}, were the first integer is the number of vertices adjacen... | [{"input": "19\n1 13\n0 0\n1 9\n1 11\n1 11\n2 3\n2 30\n0 -1\n1 5\n1 2\n0 0\n5 29\n1 6\n2 11\n0 0\n0 0\n0 0\n0 -1\n2 13\n", "output": "10\n0 13\n2 9\n3 11\n4 11\n8 5\n12 6\n13 11\n5 11\n6 18\n11 18\n\n"}, {"input": "19\n1 13\n0 0\n1 9\n1 11\n1 11\n2 3\n2 30\n0 -1\n1 5\n1 2\n0 0\n5 29\n1 6\n2 11\n0 0\n0 0\n0 0\n0 0\n2 13... | code_stdio |
[
{
"content": "There is a tree T with N vertices, numbered 1 through N. For each 1 ≤ i ≤ N - 1, the i-th edge connects vertices a_i and b_i.\n\nSnuke is constructing a directed graph T' by arbitrarily assigning direction to each edge in T. (There are 2^{N - 1} different ways to construct T'.)\n\nFor a fixed T', ... | [{"input": "10\n2 4\n2 5\n8 3\n10 7\n1 7\n2 8\n9 10\n8 6\n10 8", "output": "220\n"}, {"input": "10\n1 4\n2 5\n1 3\n10 1\n1 6\n4 8\n9 8\n7 10\n10 2", "output": "122\n"}, {"input": "10\n2 4\n2 5\n2 3\n10 7\n1 6\n2 10\n9 5\n8 7\n10 6", "output": "194\n"}, {"input": "10\n1 4\n2 5\n1 3\n10 1\n1 6\n4 8\n9 3\n7 10\n10 2", "ou... | code_stdio |
[
{
"content": "Rational numbers are numbers represented by ratios of two integers. For a prime number p, one of the elementary theorems in the number theory is that there is no rational number equal to √p. Such numbers are called irrational numbers. It is also known that there are rational numbers arbitrarily cl... | [{"input": "2 10\n5 10\n19 111\n0 0", "output": "10/7 7/5\n9/4 2/1\n109/25 61/14\n"}, {"input": "11 5\n10 10\n5 100\n0 0", "output": "4/1 3/1\n10/3 3/1\n85/38 38/17\n"}, {"input": "2 5\n3 14\n26 111\n0 0", "output": "3/2 4/3\n7/4 12/7\n51/10 107/21\n"}, {"input": "8 24\n3 10\n5 110\n0 0", "output": "17/6 14/5\n7/4 5/3\... | code_stdio |
[
{
"content": "Chef's new hobby is painting, but he learned the fact that it's not easy to paint 2D pictures in a hard way, after wasting a lot of canvas paper, paint and of course time. From now on, he decided to paint 1D pictures only.\nChef's canvas is N millimeters long and is initially all white. For simpli... | [{"input": "3\n4\n1 6 4 -2\n0\n0 9 -1 10\n0\n-1 3 6", "output": "No\nNo\nNo\n"}, {"input": "3\n4\n1 6 4 0\n0\n-1 9 -1 10\n0\n-1 3 6", "output": "No\nNo\nNo\n"}, {"input": "3\n4\n1 6 4 1\n0\n-1 9 -1 10\n0\n-1 3 6", "output": "No\nNo\nNo\n"}, {"input": "3\n4\n2 9 1 3\n3\n1 1 1 10\n0\n18 3 1", "output": "No\nYes\nNo\n"}, ... | code_stdio |
[
{
"content": "Mr. Takahashi has a string s consisting of lowercase English letters. He repeats the following operation on s exactly K times.\n\n* Choose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of `z` is `a`.\n\n\n\nFor example, if you perform an operation ... | [{"input": "codefestival\n101", "output": "aaaafeaaiaal\n"}, {"input": "cdoeffstival\n101", "output": "aaaaffaaiaal\n"}, {"input": "cdoeffstival\n111", "output": "aaaaafativam\n"}, {"input": "lavitsffeodc\n111", "output": "aaaaaaaaeadg\n"}, {"input": "caoeffstivdl\n111", "output": "aaaaaaativdo\n"}, {"input": "cdoefest... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.