messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
1 value
[ { "content": "Solve the following coding problem using the programming language python:\n\nD: The Diversity of Prime Factorization\n\nProblem\n\nEbi-chan has the FACTORIZATION MACHINE, which can factorize natural numbers M (greater than 1) in O ($ \\ log $ M) time! But unfortunately, the machine could display o...
[{"type": "stdin_stdout", "input": "3\n2 3 11", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n2 2 11", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n2 2 13", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n2 3 17", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n2 2 15", "output": "0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.\n\nWrite a program which reads a list of N integers an...
[{"type": "stdin_stdout", "input": "11\n13\n20\n9\n10\n11\n13\n33\n14\n16\n12\n17", "output": "4\n"}, {"type": "stdin_stdout", "input": "11\n25\n20\n9\n10\n11\n13\n33\n14\n16\n12\n17", "output": "3\n"}, {"type": "stdin_stdout", "input": "11\n7\n10\n9\n10\n11\n13\n17\n14\n15\n16\n17", "output": "5\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDraw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n\n.#.#.#.#.\n.#.#.#.#.#\n.#.#.#.#.\n.#.#.#.#.#\n.#...
[{"type": "stdin_stdout", "input": "11 21\n10 0\n5 0\n2 4\n2 0\n0 0", "output": "#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has a sequence a consisting of n integers a_1, a_2, ..., a_n. Vasya may pefrom the following operation: choose some number from the sequence and swap any pair of bits in its binary representation. For example, Vasya...
[{"type": "stdin_stdout", "input": "5\n1000000000000000000 352839520853234088 175235832528365792 753467583475385837 895062156280564685\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "4\n1 2 1 16\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "3\n10 7 14\n", "output": "2\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are playing a strange game with Li Chen. You have a tree with n nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from 1 to n. Neither of you ...
[{"type": "stdin_stdout", "input": "2\n6\n5 3 2 4 1 6\n1 2\n1 3\n1 4\n4 5\n4 6\n4\n1 3 4 5\n3\n3 5 2\n6\n5 3 2 4 1 6\n1 2\n1 3\n1 4\n4 5\n4 6\n3\n1 2 3\n3\n4 1 6\n", "output": "B 4\nA 4\nC -1\nB 2\nC 1\n"}, {"type": "stdin_stdout", "input": "2\n6\n5 3 2 8 1 6\n1 2\n1 3\n1 4\n4 5\n4 6\n4\n1 3 4 5\n3\n3 5 2\n6\n5 3 2 4 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHasan loves playing games and has recently discovered a game called TopScore. In this soccer-like game there are p players doing penalty shoot-outs. Winner is the one who scores the most. In case of ties, one of the top-s...
[{"type": "stdin_stdout", "input": "93 2364 1182\n", "output": "952630216\n"}, {"type": "stdin_stdout", "input": "83 2813 123\n", "output": "758958584\n"}, {"type": "stdin_stdout", "input": "100 5000 30\n", "output": "860412292\n"}, {"type": "stdin_stdout", "input": "45 2315 860\n", "output": "256332294\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has an array a consisting of n integers.\n\nHe wants to play a game with this array. The game consists of several moves. On the first move he chooses any element and deletes it (after the first move the array con...
[{"type": "stdin_stdout", "input": "2\n1000000 1000000\n", "output": "1000000\n"}, {"type": "stdin_stdout", "input": "2\n1000010 1001000\n", "output": "1000010\n"}, {"type": "stdin_stdout", "input": "2\n1000110 1001000\n", "output": "1000110\n"}, {"type": "stdin_stdout", "input": "2\n1000110 1000000\n", "output": "1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a huge decimal number consisting of n digits. It is guaranteed that this number has no leading zeros. Each digit of this number is either 0 or 1.\n\nYou may perform several (possibly zero) operations with th...
[{"type": "stdin_stdout", "input": "213 5 3\n111001111110111001101011111100010010011001000001111010110110011000100000101010111110010001111110001010011001101000000011111110101001101100100100110100000111111100010100011010010001011100111011000001110000111000101\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "213 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a string s β€” a sequence of commands for your toy robot. The robot is placed in some cell of a rectangular grid. He can perform four commands:\n\n * 'W' β€” move one cell up; \n * 'S' β€” move one cell down; \n * '...
[{"type": "stdin_stdout", "input": "3\nDSAWWAW\nD\nWA\n", "output": "8\n2\n4\n"}, {"type": "stdin_stdout", "input": "3\nDSAWWAW\nD\nAW\n", "output": "8\n2\n4\n"}, {"type": "stdin_stdout", "input": "3\nWSAWDAW\nD\nAW\n", "output": "4\n2\n4\n"}, {"type": "stdin_stdout", "input": "3\nDAAWWSW\nD\nAW\n", "output": "6\n2\n4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a ...
[{"type": "stdin_stdout", "input": "1000000000000 68088352351238212 100000 99999\n", "output": "680883461725 61788 319116476487\n"}, {"type": "stdin_stdout", "input": "1108577267933 48182461851369906 125899 19927\n", "output": "382707249106 95156 725869923671\n"}, {"type": "stdin_stdout", "input": "1252579684821 112616...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSo the Beautiful Regional Contest (BeRC) has come to an end! n students took part in the contest. The final standings are already known: the participant in the i-th place solved p_i problems. Since the participants are pr...
[{"type": "stdin_stdout", "input": "5\n12\n5 4 4 3 2 2 1 1 1 1 1 1\n4\n4 3 2 2\n1\n1000100\n20\n20 19 18 17 16 15 14 13 15 11 10 9 8 7 6 5 4 3 2 1\n32\n125 64 63 58 58 58 58 58 37 37 37 37 34 34 28 28 28 28 28 28 24 24 19 17 17 17 17 16 16 16 16 11\n", "output": "1 2 3\n0 0 0\n0 0 0\n1 2 7\n1 2 11\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday, Osama gave Fadi an integer X, and Fadi was wondering about the minimum possible value of max(a, b) such that LCM(a, b) equals X. Both a and b should be positive integers.\n\nLCM(a, b) is the smallest positive integ...
[{"type": "stdin_stdout", "input": "1000000000000\n", "output": "4096 244140625\n"}, {"type": "stdin_stdout", "input": "1000000010000\n", "output": "170000 5882353\n"}, {"type": "stdin_stdout", "input": "205078485761\n", "output": "185921 1103041\n"}, {"type": "stdin_stdout", "input": "873109054817\n", "output": "14596...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGildong was hiking a mountain, walking by millions of trees. Inspired by them, he suddenly came up with an interesting idea for trees in data structures: What if we add another edge in a tree?\n\nThen he found that such t...
[{"type": "stdin_stdout", "input": "14\n4 9\n3 7\n4 1\n3 2\n14 9\n7 6\n10 13\n8 7\n5 7\n7 10\n1 3\n12 3\n7 11\n20\n13 6 14 9 1\n6 4 3 7 9\n9 3 6 13 7\n6 11 11 5 9\n14 5 2 3 4\n13 12 4 2 7\n13 14 7 3 2\n9 5 13 13 6\n8 9 7 3 7\n14 10 11 12 7\n6 12 13 1 1\n8 13 8 10 8\n1 5 13 10 7\n1 4 13 2 6\n1 5 6 4 10\n6 9 11 8 5\n9 7 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLee tried so hard to make a good div.2 D problem to balance his recent contest, but it still doesn't feel good at all. Lee invented it so tediously slow that he managed to develop a phobia about div.2 D problem setting in...
[{"type": "stdin_stdout", "input": "7\n2\n2\n6\n8\n5\n110\n1478999\n", "output": "0\n0\n24\n96\n12\n782548134\n793574295\n"}, {"type": "stdin_stdout", "input": "7\n3\n2\n5\n8\n5\n101\n2000000\n", "output": "4\n0\n12\n96\n12\n981997171\n804665184\n"}, {"type": "stdin_stdout", "input": "3\n1234567\n1268501\n1268499\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4...
[{"type": "stdin_stdout", "input": "583291\n", "output": "135712853\n"}, {"type": "stdin_stdout", "input": "652615\n", "output": "960319213\n"}, {"type": "stdin_stdout", "input": "482331\n", "output": "722928541\n"}, {"type": "stdin_stdout", "input": "336161\n", "output": "234634596\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider an infinite triangle made up of layers. Let's number the layers, starting from one, from the top of the triangle (from top to bottom). The k-th layer of the triangle contains k points, numbered from left to right...
[{"type": "stdin_stdout", "input": "4\n3\n1 4 2\n1 3 1\n2\n2 4\n2 3\n2\n1 1000000000\n1 1000000000\n4\n3 10 5 8\n2 5 2 4\n", "output": "\n0\n1\n999999999\n2\n"}, {"type": "stdin_stdout", "input": "4\n3\n1 10 2\n1 3 1\n2\n4 7\n2 2\n2\n1 1000000000\n1 1000000000\n4\n3 18 5 8\n2 4 2 4\n", "output": "3\n2\n999999999\n7\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the ...
[{"type": "stdin_stdout", "input": "21 21\n42856481 2\n562905883 2\n942536731 2\n206667673 2\n451074408 2\n27 1\n29 1\n172761267 2\n23 1\n24 1\n106235116 2\n126463249 2\n29 1\n9 1\n83859496 2\n5 1\n25 1\n337838080 2\n109402491 2\n5 1\n24 1\n", "output": "3142600975.0\n1 13\n1 7\n1 6\n1 17\n1 21\n1 10\n1 9\n1 14\n1 20\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEverything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.\n\nTwo young parents abac and bbad think what name to give to their...
[{"type": "stdin_stdout", "input": "abbabaaabaaabbbbabbbbbababababaaaabbabbbbabbbbbabbbbababbaaaaabbbabbbbabbbbbbabaabababaabbbabababbaz\nabaaabaabbbbaabbbbaabababbaabaabababbbaabbbaaabbabbabbbbbbbbaabbbbbabababbbbaaabaaaabbbbbbbbabababba\n", "output": "abaaabaabbbbaabbbbaabababbaabaabababbbaabbbaaabbabbabbbbbbbbaabbbb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo players play the following game. Initially, the players have a knife and a rectangular sheet of paper, divided into equal square grid cells of unit size. The players make moves in turn, the player who can't make a mov...
[{"type": "stdin_stdout", "input": "5 5 46\n3 5 3 1\n2 1 2 0\n1 2 1 0\n4 1 0 1\n4 3 4 1\n0 4 5 4\n3 0 3 4\n3 2 0 2\n4 5 4 3\n4 1 3 1\n1 4 1 1\n1 1 2 1\n3 2 1 2\n3 2 3 4\n2 0 2 2\n1 0 1 2\n1 1 4 1\n0 4 3 4\n3 0 3 3\n3 1 3 4\n5 1 3 1\n3 0 3 5\n4 1 1 1\n2 5 2 3\n4 2 4 1\n1 3 1 5\n1 2 1 4\n4 2 4 1\n3 2 3 0\n0 4 3 4\n1 3 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo 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 ...
[{"type": "stdin_stdout", "input": "1488496828 607500000\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1183431925 540244525\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1270836736 387420489\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "509607936 306110016\n", "output": "24\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA monster is attacking the Cyberland!\n\nMaster Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).\n\nDuring the bat...
[{"type": "stdin_stdout", "input": "100 100 100\n100 100 100\n100 100 100\n", "output": "100"}, {"type": "stdin_stdout", "input": "50 100 51\n100 100 100\n1 100 100\n", "output": "1384"}, {"type": "stdin_stdout", "input": "100 100 1\n100 100 100\n1 100 100\n", "output": "1891"}, {"type": "stdin_stdout", "input": "1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: \n\n 1. They are equal. \n 2. If we split string...
[{"type": "stdin_stdout", "input": "yhwepqwyhwepqwyhwepqweahnqtueahnqtueahnqtuyhwepqwyhwepqwyhwepqwyhwepqweahnqtueahnqtuyhwepqweahnqtueahnqtueahnqtueahnqtueahnqtueahnqtu\neahnqtueahnqtueahnqtuyhwepqweahnqtuyhwepqwyhwepqweahnqtuyhwepqweahnqtuyhwepqweahnqtueahnqtuyhwepqweahnqtueahnqtuyhwepqwyhwepqwyhwepqw\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Overall the game has n mandatory quests. To perform each of them, you need to take exactly two companions.\n...
[{"type": "stdin_stdout", "input": "25\n26668 10412 12658\n25216 11939 10247\n28514 22515 5833\n4955 19029 22405\n12552 6903 19634\n12315 1671 505\n20848 9175 6060\n12990 5827 16433\n9184 30621 25596\n31818 7826 11221\n18090 4476 30078\n30915 11014 16950\n3119 29529 21390\n775 4290 11723\n29679 14840 3566\n4491 29480 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEmily's birthday is next week and Jack has decided to buy a present for her. He knows she loves books so he goes to the local bookshop, where there are n books on sale from one of m genres.\n\nIn the bookshop, Jack decide...
[{"type": "stdin_stdout", "input": "100 10\n7 4 5 5 10 10 5 8 5 7 4 5 4 6 8 8 2 6 3 3 10 7 10 8 6 2 7 3 9 7 7 2 4 5 2 4 9 5 10 1 10 3 10 4 1 3 4 2 6 9 9 10 10 6 2 5 6 1 9 10 4 10 3 4 10 5 5 4 10 4 5 3 7 10 2 7 3 6 9 6 1 6 5 2 4 6 6 4 4 1 5 1 6 6 6 8 8 6 2 6\n", "output": "4433\n"}, {"type": "stdin_stdout", "input": "10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. \"Do I give such a hard task?\" β€” the HR manager thought. \"Just raise number 5 to the power of n and get la...
[{"type": "stdin_stdout", "input": "2000000000000000000\n", "output": "25\n"}, {"type": "stdin_stdout", "input": "1000000000000000000\n", "output": "25\n"}, {"type": "stdin_stdout", "input": "1000001000000000000\n", "output": "25\n"}, {"type": "stdin_stdout", "input": "1440563777463828705\n", "output": "25\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a complete undirected graph. For each pair of vertices you are given the length of the edge that connects them. Find the shortest paths between each pair of vertices in the graph and return the length of the...
[{"type": "stdin_stdout", "input": "10\n0 1 100 100 100 100 100 100 100 100\n1 0 1 100 100 100 100 100 100 100\n100 1 0 1 100 100 100 100 100 100\n100 100 1 0 1 100 100 100 100 100\n100 100 100 1 1 1 100 100 100 100\n100 100 100 100 1 0 1 100 100 100\n100 100 100 100 100 1 0 1 100 100\n100 100 100 100 100 100 1 0 1 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a functional graph. It is a directed graph, in which from each vertex goes exactly one arc. The vertices are numerated from 0 to n - 1.\n\nGraph is given as the array f0, f1, ..., fn - 1, where fi β€” the numb...
[{"type": "stdin_stdout", "input": "20 10\n13 10 5 6 18 5 12 13 15 1 10 3 9 16 7 9 7 11 9 13\n2634 7980 171 3503 6601 9378 4618 8243 9343 1979 4172 7441 9722 9863 6041 4790 1737 7586 6461 228\n", "output": " 62163 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou already know that Valery's favorite sport is biathlon. Due to your help, he learned to shoot without missing, and his skills are unmatched at the shooting range. But now a smaller task is to be performed, he should le...
[{"type": "stdin_stdout", "input": "20 20 2\nbaaaaaaaaaaaaaaaaaaa\nbfffffffacfffffffffa\nbgggggggaccgggggggga\nbhhhhhhhaccchhhhhhha\nbiiiiiiiacccciiiiiia\nbjjjjjjjacccccjjjjja\nbkkkkkkkacccccckkkka\nblllllllacccccccllla\nbbbbbbbbSccccccccmma\nbddddddddddcccccccna\nbodddddddcccccccccca\nbppddddddddTaaaaaaaa\nbqqqddddddd...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA substring of some string is called the most frequent, if the number of its occurrences is not less than number of occurrences of any other substring.\n\nYou are given a set of strings. A string (not necessarily from thi...
[{"type": "stdin_stdout", "input": "76\namnctposz\nmnctpos\nos\nu\ne\nam\namnc\neamnctpo\nl\nx\nq\nposzq\neamnc\nctposzq\nctpos\nmnc\ntpos\namnctposzql\ntposzq\nmnctposz\nnctpos\nctposzql\namnctpos\nmnct\np\nux\nposzql\ntpo\nmnctposzql\nmnctp\neamnctpos\namnct\ntposzql\nposz\nz\nct\namnctpo\noszq\neamnct\ntposz\ns\nmn\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of points on a straight line. Each point has a color assigned to it. For point a, its neighbors are the points which don't have any other points between them and a. Each point has at most two neighbors...
[{"type": "stdin_stdout", "input": "bbbbbbbbaaaaaaaaaaaccccccaaaaaaaaaaaaaaccccccccaaaaaaaaabbbbbbccbbbaaaaaabccccccaaaacaaacccccccccccb\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaabbbbbbbbaaaaaaaaabbbbbaaaaaaaaaaabbbbbbaaabbbbaaabbbbbbaaa\n", "output": "12\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x1 = a, another one is in the point x2 = b. \n\nEach of the friends can move by one along the line in any direction...
[{"type": "stdin_stdout", "input": "967\n102\n", "output": "187489\n"}, {"type": "stdin_stdout", "input": "967\n142\n", "output": "170569\n"}, {"type": "stdin_stdout", "input": "967\n282\n", "output": "117649\n"}, {"type": "stdin_stdout", "input": "944\n193\n", "output": "141376\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a chessboard of size 1 Γ— n. It is guaranteed that n is even. The chessboard is painted like this: \"BWBW...BW\".\n\nSome cells of the board are occupied by the chess pieces. Each cell contains no more than o...
[{"type": "stdin_stdout", "input": "100\n93 54 57 61 68 66 70 96 64 82 80 75 69 77 76 94 67 86 90 73 74 58 100 83 92 89 56 99 88 59 95 72 81 51 85 71 97 60 91 63 65 98 79 84 53 62 87 55 52 78\n", "output": "1225\n"}, {"type": "stdin_stdout", "input": "100\n42 54 57 61 68 66 70 96 64 82 80 75 69 77 76 94 67 86 90 73 74 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChandan gave his son a cube with side N. The N X N X N cube is made up of small 1 X 1 X 1 cubes.\n\nChandan's son is extremely notorious just like him. So he dropped the cube inside a tank filled with Coke. The cube got ...
[{"type": "stdin_stdout", "input": "100\n1\n309579963\n243055591\n5088942\n67447030\n103253146\n273252973\n650883927\n441154465\n321589935\n8534862\n78034215\n507899336\n10234960\n546375125\n406736745\n11895840\n13562012\n476857905\n14375130\n132265502\n34023480\n244909071\n48571656\n125529908\n3548150\n409554603\n1131...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLeonard has decided to quit living with Dr. Sheldon Cooper and has started to live with Penny. Yes, you read it right. (And you read it here for the first time!) He is fed up of Sheldon, after all. Since, Sheldon no more ...
[{"type": "stdin_stdout", "input": "1\n3 2\n1 -1\n2 -1\n0 1\n\nSAMPLE", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n2 3\n0 0\n2 -1\n0 1\n\nSANPLE", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n3 2\n1 2\n2 -1\n1 1\n\nSAMPLE", "output": "2\n"}, {"type": "stdin_stdout", "input": "1\n3 2\n1 0\n2 -1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a square matrix of size n (it will be an odd integer). Rows are\nindexed 0 to n-1 from top to bottom and columns are indexed 0 to n-1\nform left to right. Matrix consists of only '*' and '.'.\n'*' appears on...
[{"type": "stdin_stdout", "input": "1\n7\n.......\n.*.....\n.......\n.......\n.......\n.......\n.......\n\nSAMPLE", "output": "4\n"}, {"type": "stdin_stdout", "input": "1\n7\n.......\n.*.....\n.......\n.......\n.......\n.......\n.......\n\nSAMQLE", "output": "4\n"}, {"type": "stdin_stdout", "input": "1\n5\n.......\n.*....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have N integers. The i-th number is A_i.\n\n\\\\{A_i\\\\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\\leq i < j \\leq N.\n\n\\\\{A_i\\\\} is said to be setwise coprime wh...
[{"type": "stdin_stdout", "input": "3\n17 10 15", "output": "setwise coprime\n"}, {"type": "stdin_stdout", "input": "3\n26 10 15", "output": "setwise coprime\n"}, {"type": "stdin_stdout", "input": "3\n7 10 31", "output": "pairwise coprime\n"}, {"type": "stdin_stdout", "input": "3\n7 19 4", "output": "pairwise coprime\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPrint the circumference of a circle of radius R.\n\nConstraints\n\n* 1 \\leq R \\leq 100\n* All values in input are integers.\n\nInput\n\nInput is given from Standard Input in the following format:\n\n\nR\n\n\nOutput\n\nP...
[{"type": "stdin_stdout", "input": "73", "output": "458.67252742410977361942"}, {"type": "stdin_stdout", "input": "1", "output": "6.28318530717958623200"}, {"type": "stdin_stdout", "input": "-105", "output": "-659.734457254\n"}, {"type": "stdin_stdout", "input": "-143", "output": "-898.495498927\n"}, {"type": "stdin_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a tree with N vertices. The i-th edge connects Vertex A_i and B_i bidirectionally.\n\nTakahashi is standing at Vertex u, and Aoki is standing at Vertex v.\n\nNow, they will play a game of tag as follows:\n\n* 1. I...
[{"type": "stdin_stdout", "input": "9 6 1\n1 2\n2 3\n3 4\n4 5\n5 6\n4 7\n4 8\n8 9", "output": "4\n"}, {"type": "stdin_stdout", "input": "9 6 1\n1 2\n2 4\n3 4\n4 5\n5 6\n4 7\n4 8\n8 9", "output": "3\n"}, {"type": "stdin_stdout", "input": "9 6 1\n1 2\n2 3\n3 6\n4 5\n7 6\n4 7\n4 7\n8 9", "output": "5\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a sequence of length N: A_1, A_2, ..., A_N. For each integer i between 1 and N (inclusive), answer the following question:\n\n* Find the maximum value among the N-1 elements other than A_i in the sequence.\n...
[{"type": "stdin_stdout", "input": "3\n-1\n0\n13", "output": "13\n13\n0\n"}, {"type": "stdin_stdout", "input": "3\n-2\n0\n16", "output": "16\n16\n0\n"}, {"type": "stdin_stdout", "input": "3\n0\n1\n13", "output": "13\n13\n1\n"}, {"type": "stdin_stdout", "input": "3\n0\n1\n12", "output": "12\n12\n1\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N cubes stacked vertically on a desk.\n\nYou are given a string S of length N. The color of the i-th cube from the bottom is red if the i-th character in S is `0`, and blue if that character is `1`.\n\nYou can p...
[{"type": "stdin_stdout", "input": "11011010001001", "output": "14\n"}, {"type": "stdin_stdout", "input": "11001010001001", "output": "12\n"}, {"type": "stdin_stdout", "input": "11001000001001", "output": "10\n"}, {"type": "stdin_stdout", "input": "11001000101001", "output": "12\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn elementary school student Takahashi has come to a variety store.\n\nHe has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it?\n\nNote that he lives ...
[{"type": "stdin_stdout", "input": "1977 001 1111", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1977 011 1111", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1977 011 1110", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1977 011 0110", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is locked within a building.\n\nThis building consists of HΓ—W rooms, arranged in H rows and W columns. We will denote the room at the i-th row and j-th column as (i,j). The state of this room is represented by a...
[{"type": "stdin_stdout", "input": "11 12 2\n\n\n#$...\nS###\n##.#.\n.###", "output": "1\n"}, {"type": "stdin_stdout", "input": "11 12 2\n\n\n#$...\nS###\n##.#.\n.\"##", "output": "1\n"}, {"type": "stdin_stdout", "input": "11 12 2\n\n\n#$...\nS###\n.#.##\n.\"##", "output": "1\n"}, {"type": "stdin_stdout", "input": "7 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string.\n\nHere, a mirror string is a string S such that the following sequence of operations on S results in the same ...
[{"type": "stdin_stdout", "input": "qbdp", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "dqpb", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "dpqb", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "bpqd", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "bqpd", "output": "Yes\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light.\n\nThree mirrors of length N are set so that they form an equilateral triangle. Let the vertices of the triangl...
[{"type": "stdin_stdout", "input": "1435 1", "output": "4302\n"}, {"type": "stdin_stdout", "input": "1556 2", "output": "4662\n"}, {"type": "stdin_stdout", "input": "457 3", "output": "1368\n"}, {"type": "stdin_stdout", "input": "371 4", "output": "1110\n"}, {"type": "stdin_stdout", "input": "702 4", "output": "2100\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day, Taro received a strange email with only the number \"519345213244\" in the text. The email was from my cousin, who was 10 years older than me, so when I called and asked, \"Oh, I sent it with a pocket bell becaus...
[{"type": "stdin_stdout", "input": "341143514535\n158\n143565553551655311343411652235654535651124615163\n551544654451431564\n4\n3411\n6363636363\n153414", "output": "naruto\nNA\ndo you wanna go to aizu?\nyes sure!\nNA\nna\n?????\nend\n"}, {"type": "stdin_stdout", "input": "341143514535\n158\n143565553551655311343411652...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nYou are looking for a constellation in a picture of the starry sky. The photo always contains exactly one figure with the same shape, orientation, and size as the constellation you are looking for. However, the...
[{"type": "stdin_stdout", "input": "5\n8 5\n6 4\n4 3\n7 10\n0 10\n10\n10 5\n2 7\n9 7\n8 10\n10 2\n1 2\n8 1\n6 7\n6 0\n0 0\n5\n904207 809784\n845370 244806\n499091 59863\n638406 182509\n435076 362268\n10\n757559 866424\n114810 239537\n519926 989458\n461089 424480\n674361 448440\n81851 150384\n459107 795405\n299682 6700\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet us consider sets of positive integers less than or equal to n. Note that all elements of a set are different. Also note that the order of elements doesn't matter, that is, both {3, 5, 9} and {5, 9, 3} mean the same se...
[{"type": "stdin_stdout", "input": "9 3 23\n10 3 22\n10 3 28\n16 10 107\n26 8 102\n20 10 105\n24 10 155\n3 4 3\n4 2 11\n0 0 0", "output": "1\n5\n0\n20\n32200\n5448\n10222\n0\n0\n"}, {"type": "stdin_stdout", "input": "9 3 23\n9 3 22\n10 3 28\n16 10 107\n26 8 102\n20 10 105\n24 10 155\n3 4 3\n4 2 11\n0 0 0", "output": "1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDifferential pulse code modulation is one of the compression methods mainly used when compressing audio signals.\n\nThe audio signal is treated as an integer sequence (impulse sequence) on the computer. The integer sequen...
[{"type": "stdin_stdout", "input": "2 7\n-1\n2\n1\n0\n-1\n-4\n-4\n131\n137\n2 7\n4\n2\n1\n0\n-1\n-2\n-4\n124\n123\n10 7\n-4\n-2\n-1\n0\n1\n2\n7\n106\n84\n135\n134\n132\n128\n124\n122\n121\n122\n5 1\n61\n0\n-1\n0\n-1\n0\n4 1\n0\n255\n-1\n255\n0\n0 0", "output": "26\n0\n1684\n294308\n65283\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nAOR Ika is studying to pass the test.\n\nAOR Ika-chan solved the $ N $ question. After that, round the solved problem according to the following procedure.\n\n1. Check the correctness of the answer.\n2. If the ...
[{"type": "stdin_stdout", "input": "3\nnxx", "output": "2\n"}, {"type": "stdin_stdout", "input": "3\nnwx", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\nxxo", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\nxwn", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\nowx", "output": "3\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the sum of the weights of edges of the Minimum-Cost Arborescence with the root r for a given weighted directed graph G = (V, E).\n\nConstraints\n\n* 1 ≀ |V| ≀ 100\n* 0 ≀ |E| ≀ 1,000\n* 0 ≀ wi ≀ 10,000\n* G has arbore...
[{"type": "stdin_stdout", "input": "6 10 0\n0 2 14\n0 0 1\n0 3 5\n1 4 7\n2 1 6\n1 3 2\n4 1 3\n4 2 2\n1 3 10\n0 5 3", "output": "32\n"}, {"type": "stdin_stdout", "input": "6 10 0\n0 2 14\n0 0 1\n0 3 5\n1 4 7\n2 1 6\n1 3 2\n4 1 3\n4 2 2\n1 3 0\n0 5 3", "output": "30\n"}, {"type": "stdin_stdout", "input": "6 10 0\n0 2 14\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nComputation of the date either previous or forthcoming dates is quiet easy. But it is quiet difficult to calculate the day from a particular given date. \nYou are required to find a day from a particular date given to you...
[{"type": "stdin_stdout", "input": "14 2 2012", "output": "Wednesday\n"}, {"type": "stdin_stdout", "input": "14 4 2012", "output": "Wednesday\n"}, {"type": "stdin_stdout", "input": "14 4 1177", "output": "Wednesday\n"}, {"type": "stdin_stdout", "input": "20 4 1177", "output": "Wednesday\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has n coins, the value of the i-th coin is a_i. It is guaranteed that all the values are integer powers of 2 (i.e. a_i = 2^d for some non-negative integer number d).\n\nPolycarp wants to know answers on q queries...
[{"type": "stdin_stdout", "input": "1 10\n8\n1\n2\n3\n4\n5\n6\n7\n13\n17\n16\n", "output": "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "1 10\n8\n1\n2\n3\n4\n5\n6\n7\n13\n9\n16\n", "output": "-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "1 10\n8\n1\n2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInteger factorisation is hard. The RSA Factoring Challenge offered $100 000 for factoring RSA-1024, a 1024-bit long product of two prime numbers. To this date, nobody was able to claim the prize. We want you to factorise ...
[{"type": "stdin_stdout", "input": "7\n23569587128941503608758705497896615341310167 19159186913861939168106155455634552943308781 39153944492809625164528354461072312867479663 55790232814800866674553713074623995505775167 69463531589589278075905483512846478425014803 59642761923423334795004049937608748448281703 38990994935...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGrigory has n magic stones, conveniently numbered from 1 to n. The charge of the i-th stone is equal to c_i.\n\nSometimes Grigory gets bored and selects some inner stone (that is, some stone with index i, where 2 ≀ i ≀ n ...
[{"type": "stdin_stdout", "input": "10\n62159435 282618243 791521863 214307200 976959598 590907019 166397456 708291256 85377387 569889619\n296371399 546807332 272720717 689420404 273026579 74510326 749070707 104458586 450770185 466655231\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "10\n589934963 440265648 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a string s of length n consisting of only characters > and <. You may do some operations with this string, for each operation you have to choose some character that still remains in the string. If you choose a ch...
[{"type": "stdin_stdout", "input": "14\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n<\n", "output": "0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "14\n1\n>\n1\n>\n1\n=\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n>\n1\n<\n", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a graph with 3 β‹… n vertices and m edges. You are to find a matching of n edges, or an independent set of n vertices.\n\nA set of edges is called a matching if no two edges share an endpoint.\n\nA set of vert...
[{"type": "stdin_stdout", "input": "1\n8 39\n1 2\n3 4\n5 6\n7 8\n1 9\n3 10\n3 11\n5 12\n5 13\n10 14\n7 15\n9 4\n10 2\n11 2\n12 1\n13 3\n14 2\n15 2\n9 4\n10 4\n11 4\n12 4\n13 4\n14 4\n15 4\n14 6\n10 6\n11 6\n12 6\n13 6\n14 6\n15 6\n9 8\n7 8\n11 8\n12 14\n13 8\n14 8\n15 8\n", "output": "IndSet\n9 11 12 13 15 16 17 18\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people have broken into the theater basement and each of them has taken exact...
[{"type": "stdin_stdout", "input": "10\n100000000 200000000 300000000 20 500000000 600000000 700000000 800000000 900000000 1000000000\n", "output": "244999999 20\n"}, {"type": "stdin_stdout", "input": "10\n100000000 200000000 300000000 28 500000000 600000000 700000000 800000000 900000000 1000000000\n", "output": "12249...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour friend Jeff Zebos has been trying to run his new online company, but it's not going very well. He's not getting a lot of sales on his website which he decided to call Azamon. His big problem, you think, is that he's ...
[{"type": "stdin_stdout", "input": "3\nAZAMON ALPPE\nAZOMAN ABABILAAAAAAAAAAA\nAPPLE ANAOAB\n", "output": "AAZMON\nAAOMZN\nAEPLP\n"}, {"type": "stdin_stdout", "input": "3\nAZANOM APPLE\nAAZMON ABABILAAAAAAAAAAA\nAPPLF ANANAB\n", "output": "AAZNOM\nAAMZON\nAFPLP\n"}, {"type": "stdin_stdout", "input": "3\nZAAMON APPLE\nA...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEhab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array's longest increasing subsequence?\n...
[{"type": "stdin_stdout", "input": "4\n7\n6 6 12 8 6 6 6\n1\n2\n5\n4 5 9 2 7\n7\n1 2 7 1 6 20 2\n", "output": "3\n1\n5\n5\n"}, {"type": "stdin_stdout", "input": "4\n7\n6 6 12 8 6 5 6\n1\n2\n5\n4 5 9 2 7\n7\n1 2 7 1 6 20 2\n", "output": "4\n1\n5\n5\n"}, {"type": "stdin_stdout", "input": "4\n7\n6 6 8 8 6 6 6\n1\n2\n5\n4 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHilbert's Hotel is a very unusual hotel since the number of rooms is infinite! In fact, there is exactly one room for every integer, including zero and negative integers. Even stranger, the hotel is currently at full capa...
[{"type": "stdin_stdout", "input": "10\n3\n-14 -33 142\n16\n45 -84 35 85 69 -64 93 -70 0 -102 2 -52 -55 38 33 -98\n2\n5 0\n4\n-65 -113 5 6\n5\n82 -66 113 -81 -35\n5\n-125 107 -1 2 -10\n1\n25\n1\n-19\n1\n-8\n12\n32 41 43 -157 57 8 -86 111 -25 96 28 -44\n", "output": "NO\nNO\nNO\nNO\nNO\nNO\nYES\nYES\nYES\nNO\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types β€” shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, P...
[{"type": "stdin_stdout", "input": "4\n4 4\n1000000000 0\n12 15\n8 7\n", "output": "2\n0\n9\n5\n"}, {"type": "stdin_stdout", "input": "4\n4 4\n1010000000 0\n12 15\n8 7\n", "output": "2\n0\n9\n5\n"}, {"type": "stdin_stdout", "input": "4\n4 4\n1000000000 0\n7 15\n8 7\n", "output": "2\n0\n7\n5\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUtkarsh 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 ...
[{"type": "stdin_stdout", "input": "5\n16 1\n3 2\n9 1\n65 19\n14195 55\n", "output": "Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n"}, {"type": "stdin_stdout", "input": "5\n10 1\n3 2\n9 1\n65 19\n14195 55\n", "output": "Utkarsh\nUtkarsh\nUtkarsh\nUtkarsh\nUtkarsh\n"}, {"type": "stdin_stdout", "input": "5\n16 1\n4 2\n9 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp often uses his smartphone. He has already installed n applications on it. Application with number i takes up a_i units of memory.\n\nPolycarp wants to free at least m units of memory (by removing some application...
[{"type": "stdin_stdout", "input": "5\n5 13\n6 4 2 2 2\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 10 2 3\n1 1 2 2 1\n4 10\n4 1 3 1\n1 2 1 2\n4 9\n2 2 1 2\n1 1 2 1\n", "output": "5\n-1\n2\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "5\n5 7\n6 4 2 2 2\n2 1 1 2 1\n1 3\n2\n1\n5 10\n2 3 10 2 3\n1 1 2 2 1\n4 10\n4 1 3 1\n1 2 1 2\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change eve...
[{"type": "stdin_stdout", "input": "20 101 100\n1 16 20 3 19 10 12 18 4 17 13 6 8 5 2 15 7 16 9 11\n69 53 101 100 41 38 63 84 96 21 57 100 13 43 90 86 7 20 87 88 59 49 80 82 40 18 9 1 2 67 12 15 83 79 16 22 56 35 60 102 85 28 65 8 6 46 39 25 48 65 47 98 37 27 45 12 72 44 52 75 26 31 14 47 81 95 70 34 97 11 34 73 51 89 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n armchairs, numbered from 1 to n from left to right. Some armchairs are occupied by people (at most one person per armchair), others are not. The number of occupied armchairs is not greater than n/2.\n\nFor som...
[{"type": "stdin_stdout", "input": "100\n1 1 0 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 0 0 1\n", "output": "482\n"}, {"type": "stdin_stdout", "input": "100\n1 1 0 0 1 1 1 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSherlock Holmes and Dr. Watson played some game on a checkered board n Γ— n in size. During the game they put numbers on the board's squares by some tricky rules we don't know. However, the game is now over and each square...
[{"type": "stdin_stdout", "input": "12\n8 42 23 20 39 5 23 86 26 65 93 82\n48 35 12 4 59 19 19 28 38 81 97 99\n93 24 31 44 97 50 44 99 50 7 10 64\n79 43 65 29 84 43 46 41 89 16 6 1\n34 90 33 1 7 12 46 84 67 30 1 58\n58 21 100 66 56 22 7 24 72 73 86 37\n2 17 85 6 2 73 85 44 43 79 34 65\n3 53 29 76 87 2 27 19 11 42 71 38...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Smart Beaver from ABBYY began to develop a new educational game for children. The rules of the game are fairly simple and are described below.\n\nThe playing field is a sequence of n non-negative integers ai numbered ...
[{"type": "stdin_stdout", "input": "120\n242 524 420 973 816 432 247 666 134 849 145 366 608 930 613 315 863 628 97 109 65 704 741 314 736 17 872 971 559 648 223 771 171 327 782 837 303 393 292 339 730 834 794 868 540 251 789 893 23 305 116 220 699 863 580 992 861 393 98 253 544 171 336 207 348 496 316 285 286 727 613 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne foggy Stockholm morning, Karlsson decided to snack on some jam in his friend Lillebror Svantenson's house. Fortunately for Karlsson, there wasn't anybody in his friend's house. Karlsson was not going to be hungry any ...
[{"type": "stdin_stdout", "input": "15\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n0 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "8\n0 1\n1 0\n0 1\n1 1\n0 1\n1 0\n0 1\n1 0\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "8\n1 0\n1 0\n1 0\n0 1\n0 1\n1 1\n1 1\n0 1\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima got into number sequences. Now he's got sequence a1, a2, ..., an, consisting of n positive integers. Also, Dima has got a function f(x), which can be defined with the following recurrence:\n\n * f(0) = 0; \n * f(2Β·...
[{"type": "stdin_stdout", "input": "8\n851991424 32517099 310793856 771296843 342626527 58796623 49544509 517126753\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "8\n851991424 32517099 310793856 440880219 342626527 58796623 49544509 517126753\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "8\n8519914...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMad scientist Mike has just finished constructing a new device to search for extraterrestrial intelligence! He was in such a hurry to launch it for the first time that he plugged in the power wires without giving it a pro...
[{"type": "stdin_stdout", "input": "+--+--+------+++++++-+-+++--++---+--+-+---+--+++-+++-------+++++-+-++++--+-+-+++++++----+----+++----+-+++-+++-----+++-+-++-+-+++++-+--++----+--+-++-----+-+-++++---+++---+-+-+-++++--+--+++---+++++-+---+-----+++-++--+++---++-++-+-+++-+-+-+---+++--+--++++-+-+--++-------+--+---++-----+++...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave his room for some reason. But Dima and Inna love each other so much that they decided to get criminal...\n\nDima construc...
[{"type": "stdin_stdout", "input": "5 5\n1 5 9403 40347\n1 3 13851 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n", "output": "30945\n"}, {"type": "stdin_stdout", "input": "5 5\n1 5 9403 40347\n1 3 19888 29314\n4 5 1315 561894\n3 5 2748 33090\n5 3 10717 32306\n", "output": "30945"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe blinds are known to consist of opaque horizontal stripes that can be rotated thus regulating the amount of light flowing in the room. There are n blind stripes with the width of 1 in the factory warehouse for blind pr...
[{"type": "stdin_stdout", "input": "100 17\n20 61 7 74 87 84 87 35 64 7 36 5 72 20 62 29 29 58 67 51 50 45 82 20 76 79 39 21 5 39 94 13 65 11 3 21 26 2 15 56 20 75 49 27 64 48 51 96 32 80 57 10 57 48 36 83 51 25 45 65 24 22 3 92 45 52 52 58 15 90 23 43 56 88 46 50 72 70 60 47 91 68 40 24 16 44 82 90 17 17 51 71 25 94 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Berland capital (as you very well know) contains n junctions, some pairs of which are connected by two-way roads. Unfortunately, the number of traffic jams in the capital has increased dramatically, that's why it was ...
[{"type": "stdin_stdout", "input": "70 71\n56 50\n52 51\n6 5\n56 67\n29 17\n13 41\n39 10\n61 13\n3 22\n49 11\n2 20\n44 59\n30 4\n8 39\n37 26\n8 58\n21 57\n29 63\n69 24\n66 21\n44 55\n29 40\n44 37\n62 8\n53 64\n44 2\n15 28\n11 42\n67 53\n6 1\n52 14\n23 33\n59 16\n22 48\n2 34\n36 61\n61 32\n26 65\n56 49\n52 68\n6 25\n29 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to the first friend and cnt2 numbers to the second friend. Moreover, you want all presented numbers to be ...
[{"type": "stdin_stdout", "input": "500000000 500000000 29983 29989\n", "output": "1000000001\n"}, {"type": "stdin_stdout", "input": "500000000 500000000 29959 29983\n", "output": "1000000001\n"}, {"type": "stdin_stdout", "input": "500000000 336720481 29983 29989\n", "output": "836720481\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmr loves Geometry. One day he came up with a very interesting problem.\n\nAmr has a circle of radius r and center in point (x, y). He wants the circle center to be in new position (x', y').\n\nIn one step Amr can put a p...
[{"type": "stdin_stdout", "input": "100000 -100000 -100000 100000 100000\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "100000 -100000 -100000 100000 100010\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "100000 -100000 -100000 100100 100010\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAndrewid the Android is a galaxy-famous detective. He is now investigating the case of vandalism at the exhibition of contemporary art.\n\nThe main exhibit is a construction of n matryoshka dolls that can be nested one in...
[{"type": "stdin_stdout", "input": "100 19\n6 62 72 83 91 94 97\n3 61 84 99\n1 63\n5 46 53 56 69 78\n5 41 43 49 74 89\n5 55 57 79 85 87\n3 47 59 98\n3 64 76 82\n3 48 66 75\n2 60 88\n2 67 77\n4 40 51 73 95\n41 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 44 71 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe GCD table G of size n Γ— n for an array of positive integers a of length n is defined by formula \n\n<image>\n\nLet us remind you that the greatest common divisor (GCD) of two positive integers x and y is the greatest ...
[{"type": "stdin_stdout", "input": "5\n537163 537163 537163 537163 537163 537163 1074326 537163 537163 537163 515139317 1074326 537163 537163 537163 539311652 321760637 170817834 537163 537163 537163 537163 537163 537163 392666153\n", "output": "539311652 515139317 392666153 321760637 170817834 "}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging...
[{"type": "stdin_stdout", "input": "119 119 119 119 119\n10 10 10 10 10\n0 20\n", "output": "1310\n"}, {"type": "stdin_stdout", "input": "78 119 119 119 119\n10 10 10 10 10\n0 20\n", "output": "1310\n"}, {"type": "stdin_stdout", "input": "78 119 176 119 119\n10 10 10 10 10\n0 20\n", "output": "1310\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAndrew and Jerry are playing a game with Harry as the scorekeeper. The game consists of three rounds. In each round, Andrew and Jerry draw randomly without replacement from a jar containing n balls, each labeled with a di...
[{"type": "stdin_stdout", "input": "20\n12 37 81 56 61 2 26 27 59 69 24 7 71 76 45 54 89 17 95 20\n", "output": "0.1930989940\n"}, {"type": "stdin_stdout", "input": "20\n12 37 81 56 61 2 36 27 59 69 24 7 71 76 45 54 89 17 95 20\n", "output": "0.1903993293\n"}, {"type": "stdin_stdout", "input": "20\n12 37 81 56 61 2 36 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, y...
[{"type": "stdin_stdout", "input": "100 20 100 19121\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwhwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwww\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 20 100 19121\nwwwhwhwhhhwhwwwwhwhwwwwhwwwhwhwhhwwhwhhwhwhhhwwhwhwhwwwhwwhwwwhhwwhhwhwwhwwwhhhwwwhhhhhw...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya commutes by train every day. There are n train stations in the city, and at the i-th station it's possible to buy only tickets to stations from i + 1 to ai inclusive. No tickets are sold at the last station.\n\nLet ...
[{"type": "stdin_stdout", "input": "10\n2 10 8 7 8 8 10 9 10\n", "output": "63\n"}, {"type": "stdin_stdout", "input": "10\n2 10 8 7 8 9 10 9 10\n", "output": "62\n"}, {"type": "stdin_stdout", "input": "10\n3 10 8 7 8 9 10 9 10\n", "output": "61\n"}, {"type": "stdin_stdout", "input": "10\n2 10 8 6 8 8 10 9 10\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnastasia loves going for a walk in Central Uzhlyandian Park. But she became uninterested in simple walking, so she began to collect Uzhlyandian pebbles. At first, she decided to collect all the pebbles she could find in ...
[{"type": "stdin_stdout", "input": "9 13\n132 166 200 62 168 51 185 192 118\n", "output": "51\n"}, {"type": "stdin_stdout", "input": "9 13\n132 166 200 62 168 58 185 192 118\n", "output": "52\n"}, {"type": "stdin_stdout", "input": "9 13\n132 166 200 62 168 58 106 192 118\n", "output": "49\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe year of 2012 is coming...\n\nAccording to an ancient choradrican legend in this very year, in 2012, Diablo and his brothers Mephisto and Baal will escape from hell, and innumerable hordes of demons will enslave the hu...
[{"type": "stdin_stdout", "input": "22\nCleo likes Snowy\nCleo likes Troll\nChapay likes Dracul\nSnowy likes Troll\nDracul likes Chapay\nDracul likes Snowy\nChapay likes Cleo\nSnowy likes Chapay\nDracul likes Troll\nAnka likes Hexadecimal\nSnowy likes Anka\nHexadecimal likes Cleo\nHexadecimal likes Troll\nDracul likes ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo boys decided to compete in text typing on the site \"Key races\". During the competition, they have to type a text consisting of s characters. The first participant types one character in v1 milliseconds and has ping ...
[{"type": "stdin_stdout", "input": "1000 1000 1000 1000 1000\n", "output": "Friendship\n"}, {"type": "stdin_stdout", "input": "13 849 819 723 918\n", "output": "Friendship\n"}, {"type": "stdin_stdout", "input": "2 313 856 964 421\n", "output": "Friendship\n"}, {"type": "stdin_stdout", "input": "37 261 207 1 1000\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProgrammer Vasya is studying a new programming language &K*. The &K* language resembles the languages of the C family in its syntax. However, it is more powerful, which is why the rules of the actual C-like languages are ...
[{"type": "stdin_stdout", "input": "10\ntypedef &void**** youdyfpinzk\ntypeof &youdyfpinzk***\ntypedef &&&&youdyfpinzk****** nfbsgpjzhxzskmxc\ntypeof nfbsgpjzhxzskmxc***\ntypedef &&&void*** puerqioirikxej\ntypeof &puerqioirikxej********\ntypedef &puerqioirikxej******** xzgzsamjdufuyxz\ntypeof &xzgzsamjdufuyxz******\nty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's denote a function \n\n<image>\n\nYou are given an array a consisting of n integers. You have to calculate the sum of d(ai, aj) over all pairs (i, j) such that 1 ≀ i ≀ j ≀ n.\n\nInput\n\nThe first line contains one i...
[{"type": "stdin_stdout", "input": "100\n591 417 888 251 792 847 685 3 182 461 102 348 555 956 771 901 712 878 580 631 342 333 285 899 525 725 537 718 929 653 84 788 104 355 624 803 253 853 201 995 536 184 65 205 540 652 549 777 248 405 677 950 431 580 600 846 328 429 134 983 526 103 500 963 400 23 276 704 570 757 410 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHexadecimal likes drawing. She has drawn many graphs already, both directed and not. Recently she has started to work on a still-life Β«interesting graph and applesΒ». An undirected graph is called interesting, if each of i...
[{"type": "stdin_stdout", "input": "50 21\n27 16\n42 35\n15 28\n46 17\n30 39\n47 18\n35 25\n26 24\n24 30\n28 41\n40 38\n11 21\n33 20\n43 10\n37 14\n1 43\n32 49\n49 6\n10 45\n21 50\n39 3\n", "output": "YES\n29\n1 2\n2 3\n4 5\n4 6\n5 7\n7 8\n8 9\n9 11\n12 13\n12 14\n13 15\n16 17\n18 19\n19 20\n22 23\n22 25\n23 26\n27 29\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStrings can be efficiently stored as a data structure, to have efficient searching methods.\nA new startup is going to use this method, but they don't have much space. So they want to check beforehand how much memory will...
[{"type": "stdin_stdout", "input": "5\neu\neq\nbd\nbe\ndbp\n\nSAMQLE", "output": "10\n"}, {"type": "stdin_stdout", "input": "5\net\nqe\nbd\ndc\ndbp\n\nSAMQLE", "output": "11\n"}, {"type": "stdin_stdout", "input": "5\nte\nqe\nbd\ndb\np`d\n\nDAQMKS", "output": "12\n"}, {"type": "stdin_stdout", "input": "5\neu\nqe\nbd\nbd...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYesterday Oz heard a story about insect colony. The specialty of insects is that they splits sometimes i.e an insect of size A can split into two insects of positive integral sizes B and C such that A = B + C. Also someti...
[{"type": "stdin_stdout", "input": "10\n75 995991040 245669642 566366239 458028006 823890903 945174886 530827147 711604994 720763988 183796976 748924885 868038355 870234651 273702889 972313979 607688156 495203509 981301128 72001489 8444522 970980434 30653173 738175457 455018413 940530064 537884091 418532701 982359437 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a positive integer N. How many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\nConstraints\n\n* 2 \\leq N \\leq 10^6\n* All values in input are integers.\n\nInput\n\nInput is given from Standa...
[{"type": "stdin_stdout", "input": "1000000", "output": "13969985"}, {"type": "stdin_stdout", "input": "214", "output": "1178\n"}, {"type": "stdin_stdout", "input": "257", "output": "1466\n"}, {"type": "stdin_stdout", "input": "197", "output": "1070\n"}, {"type": "stdin_stdout", "input": "101", "output": "482\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.\n\nWe will choose one or more of these sardines and put them into a cooler. However, two sardines on bad term...
[{"type": "stdin_stdout", "input": "10\n2 0\n2 -1\n-1 -1\n1 20\n0 -1\n-18 -1\n1 -1\n1 1\n-5 -1\n4 0", "output": "399\n"}, {"type": "stdin_stdout", "input": "10\n2 0\n0 0\n-1 2\n-1 13\n-2 -26\n-11 -1\n2 -1\n0 1\n0 0\n0 4", "output": "161\n"}, {"type": "stdin_stdout", "input": "10\n2 -1\n0 0\n-1 2\n-1 13\n0 -26\n-16 -1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere 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 ope...
[{"type": "stdin_stdout", "input": "12\n367101616 467388357 159541726 1477792495 1190847685 1723370727 668687333 270216579 135685914 125686970 1191846896 1765707086", "output": "469392584\n"}, {"type": "stdin_stdout", "input": "12\n367101616 467388357 127795962 1640220090 1190847685 1723370727 402149677 270216579 13568...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has a string S of length N consisting of lowercase English letters. On this string, he will perform the following operation K times:\n\n* Let T be the string obtained by reversing S, and U be the string obtained...
[{"type": "stdin_stdout", "input": "10 2\nbbbabbbaaa", "output": "aaaaaaaaaa\n"}, {"type": "stdin_stdout", "input": "10 3\nbbaabbbaab", "output": "aaaaaaaabb\n"}, {"type": "stdin_stdout", "input": "10 2\nbaabbbaabb", "output": "aaaabbbaab\n"}, {"type": "stdin_stdout", "input": "10 2\nbaabbaaabb", "output": "aaaaaabbbb\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N people numbered 1 to N. Each person wears a red hat or a blue hat.\n\nYou are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`.\n\nDe...
[{"type": "stdin_stdout", "input": "4\nRBRR", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\nRRCR", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\nRRAR", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\nRARR", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "4\nRCRR", "output": "Yes...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are some coins in the xy-plane. The positions of the coins are represented by a grid of characters with H rows and W columns. If the character at the i-th row and j-th column, s_{ij}, is `#`, there is one coin at po...
[{"type": "stdin_stdout", "input": "13 27\n......#.........#.......#..\n...#.....###..\n..............#####...##...\n...#######......#...#######\n...#.....#.....###...#...#.\n...#######....#.#.#.#.###.#\n..............#.#.#...#.#..\n.#.#.#...###..\n...........#...#./.#######\n..#######..#...#...#.....#\n..#.....#..#......
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n\"Pizza At\", a fast food chain, offers three kinds of pizza: \"A-pizza\", \"B-pizza\" and \"AB-pizza\". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza com...
[{"type": "stdin_stdout", "input": "1143 3132 1087 90000 100000", "output": "217400000\n"}, {"type": "stdin_stdout", "input": "1500 2445 500 90000 100000", "output": "100000000\n"}, {"type": "stdin_stdout", "input": "1500 3132 752 90000 100000", "output": "150400000\n"}, {"type": "stdin_stdout", "input": "1500 3132 574...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke has a string S consisting of three kinds of letters: `a`, `b` and `c`.\n\nHe has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a su...
[{"type": "stdin_stdout", "input": "bacaccbabab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "bacaacbcbab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "babcbcaacab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "bababccacab", "output": "YES\n"}, {"type": "stdin_stdout", "input": "bacaccba...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.\nThere are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deli...
[{"type": "stdin_stdout", "input": "8\n121 1 -1 -1 -3 3 0 1", "output": "124\n"}, {"type": "stdin_stdout", "input": "8\n0 -4 -1 21 -2 -15 4 2", "output": "36\n"}, {"type": "stdin_stdout", "input": "8\n0 -3 -1 27 -6 -18 4 2", "output": "45\n"}, {"type": "stdin_stdout", "input": "8\n-2 -1 0 1 3 -143 0 1", "output": "146\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusiv...
[{"type": "stdin_stdout", "input": "1000000001000000000", "output": "999867657\n"}, {"type": "stdin_stdout", "input": "1100000001000000000", "output": "355035671\n"}, {"type": "stdin_stdout", "input": "1100000001000010000", "output": "391646023\n"}, {"type": "stdin_stdout", "input": "1100000001001010000", "output": "10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTaro went to a toy store to buy a game of life made by Aizu Hobby. Life games are played using a board with squares and roulette. As shown in the figure, the board has one start point and one goal point, which are connect...
[{"type": "stdin_stdout", "input": "1 2 0\n1\n1 2 1\n1\n1 2 101\n1 2 1\n1\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 100\n4 3 32\n0 0 0", "output": "0\n101\n100\n50\n22\n"}, {"type": "stdin_stdout", "input": "1 2 0\n1\n1 2 1\n1\n1 2 100\n1 2 1\n1\n1 2 100\n2 2 1\n1 2\n1 2 100\n4 5 3\n1 2 3 4\n1 1 2\n2 2 ...
code_stdio