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\nYou've got an array a, consisting of n integers. The array elements are indexed from 1 to n. Let's determine a two step operation like that:\n\n 1. First we build by the array a an array s of partial sums, consisting of ...
[{"type": "stdin_stdout", "input": "42 42\n42 42 42 42 74 42 42 42 3 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 59 42 42 42 42 42\n", "output": "42 1806 39732 595980 6853802 64426782 515432400 608248315 553670947 820980301 784579711 753219887 714714707 805611691 208784644 262712997...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R.\nTa...
[{"type": "stdin_stdout", "input": "3 4 5 2\n", "output": "Balanced\n"}, {"type": "stdin_stdout", "input": "0 8 7 1", "output": "Balanced\n"}, {"type": "stdin_stdout", "input": "4 3 5 2", "output": "Balanced\n"}, {"type": "stdin_stdout", "input": "8 3 8 3", "output": "Balanced\n"}, {"type": "stdin_stdout", "input": "12...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the school computer room there are n servers which are responsible for processing several computing tasks. You know the number of scheduled tasks for each server: there are m_{i} tasks assigned to the i-th server.\n\nI...
[{"type": "stdin_stdout", "input": "10\n19999 19999 20000 20000 29860 20000 12103 20000 19999 17191\n", "output": "10536\n"}, {"type": "stdin_stdout", "input": "10\n19999 19999 20000 39539 29860 20000 12103 20000 19999 17191\n", "output": "25661\n"}, {"type": "stdin_stdout", "input": "10\n11328 19999 20000 39539 29860 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA permutation of length n is an integer sequence such that each integer from 0 to (n - 1) appears exactly once in it. For example, sequence [0, 2, 1] is a permutation of length 3 while both [0, 2, 2] and [1, 2, 3] are not...
[{"type": "stdin_stdout", "input": "100\n99 5 40 32 4 31 38 57 94 47 26 16 89 72 9 80 55 86 78 90 42 41 46 74 56 97 21 48 66 27 93 85 88 59 64 95 10 45 12 22 84 60 8 98 62 51 14 65 39 30 11 71 92 19 76 43 87 54 15 53 37 6 25 18 96 35 13 91 2 3 0 23 1 7 49 75 81 33 50 52 63 44 69 36 17 61 24 20 68 34 73 29 70 83 58 79 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have N items that you want to put them into a knapsack. Item i has value vi and weight wi.\n\nYou want to find a subset of items to put such that:\n\n* The total value of the items is as large as possible.\n* The item...
[{"type": "stdin_stdout", "input": "4 3\n4 0\n5 2\n2 1\n13 1", "output": "22\n"}, {"type": "stdin_stdout", "input": "4 6\n4 0\n5 2\n2 1\n13 1", "output": "24\n"}, {"type": "stdin_stdout", "input": "4 5\n0 2\n5 2\n2 1\n8 3", "output": "13\n"}, {"type": "stdin_stdout", "input": "4 5\n4 2\n5 2\n2 0\n8 3", "output": "15\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEugeny loves listening to music. He has n songs in his play list. We know that song number i has the duration of t_{i} minutes. Eugeny listens to each song, perhaps more than once. He listens to song number i c_{i} times....
[{"type": "stdin_stdout", "input": "10 10\n3 1\n2 7\n5 1\n7 2\n9 10\n9 5\n2 5\n4 8\n9 9\n1 9\n26 34 37 141 146 201 239 245 296 299\n", "output": "4\n4\n5\n6\n6\n8\n9\n9\n10\n10\n"}, {"type": "stdin_stdout", "input": "10 10\n3 1\n2 7\n5 1\n7 2\n9 10\n9 5\n2 5\n4 10\n9 15\n1 9\n26 34 37 141 146 201 239 245 296 299\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke built an online judge to hold a programming contest.\n\nWhen a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. ...
[{"type": "stdin_stdout", "input": "ACABA", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "ACBAA", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "ACAAA", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "AAACA", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "AAAC@", "output": "Yes\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly k months. He looked at the calendar and learned that at the moment is the month number...
[{"type": "stdin_stdout", "input": "September\n0\n", "output": "September\n"}, {"type": "stdin_stdout", "input": "November\n46\n", "output": "September\n"}, {"type": "stdin_stdout", "input": "December\n240\n", "output": "December\n"}, {"type": "stdin_stdout", "input": "December\n81\n", "output": "September\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a set $S$ of integers, perform a sequence of the following operations. Note that multiple elements can have equivalent values in $S$.\n\n* insert($x$): Insert $x$ to $S$ and report the number of elements in $S$ after ...
[{"type": "stdin_stdout", "input": "10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n0 2\n1 3\n0 4\n3 1 4", "output": "1\n2\n3\n4\n2\n4\n1\n5\n1\n1\n2\n3\n4\n"}, {"type": "stdin_stdout", "input": "10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n1 1\n1 3\n0 4\n3 1 4", "output": "1\n2\n3\n4\n2\n2\n1\n4\n1\n1\n3\n4\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S of length N consisting of lowercase English letters.\nSnuke can do this operation any number of times: remove fox occurring as a substring from s and concatenate the remaining parts of s.\nWhat is the ...
[{"type": "stdin_stdout", "input": "90585\nfohfoxuvgjxpybcfoxmefomtzopbsprupidgsybejhphoymfoxxaobhdxbmfoxqioqjzehbmufpownifoxhwlrybqsqijgkdmbpfoxzlobcfoxfpdznrbcqqjqglhqgnuooojywfoxfsqesfoxagdfmfoxlzlhjxrfkwmrktsintfocipouajpsqucpoydkfogknyjffoxddeqsrdeupfownwreitzyflusfoxrhmoffoxqfoxsmyurkfotmlxhekuksfotxukcdfopfoxrcr...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMadoka decided to entrust the organization of a major computer game tournament \"OSU\"!\n\nIn this tournament, matches are held according to the \"Olympic system\". In other words, there are $2^n$ participants in the tour...
[{"type": "stdin_stdout", "input": "100000 1000000000\n", "output": "607723520\n"}, {"type": "stdin_stdout", "input": "100000 53228\n", "output": "871774727\n"}, {"type": "stdin_stdout", "input": "11994 11995\n", "output": "685385528\n"}, {"type": "stdin_stdout", "input": "87532 32150\n", "output": "165162987\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDo you know a story about the three musketeers? Anyway, you will learn about its origins now.\n\nRichelimakieu is a cardinal in the city of Bearis. He is tired of dealing with crime by himself. He needs three brave warrio...
[{"type": "stdin_stdout", "input": "987 50\n221 959\n221 553\n959 695\n553 959\n819 437\n371 295\n695 553\n959 347\n595 699\n652 628\n553 347\n868 589\n695 221\n282 714\n351 703\n104 665\n755 436\n556 511\n695 347\n221 347\n243 874\n695 847\n863 501\n583 145\n786 221\n38 286\n72 397\n808 658\n724 437\n911 548\n405 759\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ models in the shop numbered from $1$ to $n$, with sizes $s_1, s_2, \\ldots, s_n$.\n\nOrac will buy some of the models and will arrange them in the order of increasing numbers (i.e. indices, but not sizes).\n...
[{"type": "stdin_stdout", "input": "4\n23\n3198 4895 1585 3916 2650 5552 876 2731 1971 126 2152 6910 1096 4103 1074 2594 2897 3983 3830 3460 729 576 3281\n1\n0000000010\n2\n1 1\n100\n1 2 3 4 5 2 7 10 9 14 11 12 13 14 24 16 17 33 19 20 21 22 23 24 25 26 27 28 29 41 31 32 56 34 35 36 37 38 39 40 41 42 43 44 45 46 54 48 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA permutation p of size n is the sequence p1, p2, ..., pn, consisting of n distinct integers, each of them is from 1 to n (1 ≤ pi ≤ n).\n\nA lucky permutation is such permutation p, that any integer i (1 ≤ i ≤ n) meets th...
[{"type": "stdin_stdout", "input": "17877\n", "output": "2 17877 4 17875 6 17873 8 17871 10 17869 12 17867 14 17865 16 17863 18 17861 20 17859 22 17857 24 17855 26 17853 28 17851 30 17849 32 17847 34 17845 36 17843 38 17841 40 17839 42 17837 44 17835 46 17833 48 17831 50 17829 52 17827 54 17825 56 17823 58 17821 60 178...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call an array $a$ of $m$ integers $a_1, a_2, \\ldots, a_m$ Decinc if $a$ can be made increasing by removing a decreasing subsequence (possibly empty) from it.\n\nFor example, if $a = [3, 2, 4, 1, 5]$, we can remove ...
[{"type": "stdin_stdout", "input": "20\n2 1 13 10 12 18 15 19 5 14 16 9 3 8 17 11 7 20 6 4\n", "output": "90\n"}, {"type": "stdin_stdout", "input": "10\n7 10 1 8 3 9 2 4 6 5\n", "output": "39\n"}, {"type": "stdin_stdout", "input": "6\n4 5 2 6 1 3\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "3\n2 3 1\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHearing that energy drinks increase rating in those sites, Takahashi decides to buy up M cans of energy drinks.\nThere are N stores that sell energy drinks. In the i-th store, he can buy at most B_i cans of energy drinks ...
[{"type": "stdin_stdout", "input": "1 100000\n1000000000 100000\n", "output": "100000000000000\n"}, {"type": "stdin_stdout", "input": "1 100000\n1000000100 100000", "output": "100000010000000\n"}, {"type": "stdin_stdout", "input": "1 100000\n1000000110 100010", "output": "100000011000000\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\...
[{"type": "stdin_stdout", "input": "10\n4 8 480392999\n3 4 32525297\n9 7 417904789\n6 2 836294777\n5 3 616099185\n1 7 830574407\n8 10 838073755\n6 10 547050646\n2 1 12607780\n", "output": "0"}, {"type": "stdin_stdout", "input": "5\n1 2 1000000000\n2 3 747774\n3 4 4\n4 5 8447854\n", "output": " ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPig is visiting a friend.\n\nPig's house is located at point 0, and his friend's house is located at point m on an axis.\n\nPig can use teleports to move along the axis.\n\nTo use a teleport, Pig should come to a certain ...
[{"type": "stdin_stdout", "input": "70 100\n0 99\n1 87\n1 94\n1 4\n2 72\n3 39\n3 69\n4 78\n5 85\n7 14\n8 59\n12 69\n14 15\n14 76\n17 17\n19 53\n19 57\n19 21\n21 35\n21 83\n24 52\n24 33\n27 66\n27 97\n30 62\n30 74\n30 64\n32 63\n35 49\n37 60\n40 99\n40 71\n41 83\n42 66\n42 46\n45 83\n51 76\n53 69\n54 82\n54 96\n54 88\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan had string s consisting of small English letters. However, his friend Julia decided to make fun of him and hid the string s. Ivan preferred making a new string to finding the old one. \n\nIvan knows some information ...
[{"type": "stdin_stdout", "input": "18\nabacab 2 329 401\nabadabacabae 1 293\nbacab 1 2\nabacabadabacabaga 1 433\nc 1 76\nbaca 1 26\ndab 1 72\nabagabaca 1 445\nabaea 1 397\ndabac 1 280\nab 2 201 309\nca 1 396\nabacabadab 1 497\nac 1 813\ncaba 1 444\nad 1 167\nbadab 1 358\naba 1 421\n", "output": "abacabaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "YES"}, {"type": "stdin_stdout", "input": "999129999\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "917261049\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "80321920...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N cities and M roads.\nThe i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally.\nThere may be more than one road that connects the same pair of two cities.\nFor each city, how many ro...
[{"type": "stdin_stdout", "input": "17 1\n2 8\n3 4\n1 5\n2 8\n4 7\n8 2\n4 1\n0 14", "output": "0\n1\n0\n0\n0\n0\n0\n1\n0\n0\n0\n0\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "13 7\n2 4\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8", "output": "2\n3\n2\n3\n2\n0\n1\n1\n0\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNaturally, the magical girl is very good at performing magic. She recently met her master wizard Devu, who gifted her R potions of red liquid, \nB potions of blue liquid, and G potions of green liquid.\n\n- \nThe red liqu...
[{"type": "stdin_stdout", "input": "3\n0 0 0 1\n2\n0\n0\n0 -1 -1 0\n3\n4\n-1\n3 1 2 1\n2 1 0\n1 12\n0 15", "output": "1\n4\n12\n"}, {"type": "stdin_stdout", "input": "3\n0 0 0 1\n2\n0\n0\n0 -1 -1 0\n3\n5\n-1\n3 1 2 1\n2 1 0\n1 12\n0 15", "output": "1\n5\n12\n"}, {"type": "stdin_stdout", "input": "3\n0 0 1 0\n1\n0\n0\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task.\n\nTwo matrices $A$ and $B$ are given, each of them has size $n \\times m$. Nastya can perfo...
[{"type": "stdin_stdout", "input": "4 9\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "4 9\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor an array of non-negative integers $a$ of size $n$, we construct another array $d$ as follows: $d_1 = a_1$, $d_i = |a_i - a_{i - 1}|$ for $2 \\le i \\le n$.\n\nYour task is to restore the array $a$ from a given array $...
[{"type": "stdin_stdout", "input": "69\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an integer a as input, print the value a + a^2 + a^3.\n\n-----Constraints-----\n - 1 \\leq a \\leq 10\n - a is an integer.\n\n-----Input-----\nInput is given from Standard Input in the following format:\na\n\n-----O...
[{"type": "stdin_stdout", "input": "1109", "output": "1365169019\n"}, {"type": "stdin_stdout", "input": "488", "output": "116452904\n"}, {"type": "stdin_stdout", "input": "762", "output": "443032134\n"}, {"type": "stdin_stdout", "input": "767", "output": "451806719\n"}, {"type": "stdin_stdout", "input": "853", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNearly each project of the F company has a whole team of developers working on it. They often are in different rooms of the office in different cities and even countries. To keep in touch and track the results of the proj...
[{"type": "stdin_stdout", "input": "110 5\n- 60\n- 58\n+ 25\n- 32\n+ 86\n", "output": "105\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 26 27 28 29 30 31 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 59 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMichael and Joe are playing a game. The game is played on a grid with $n$ rows and $m$ columns, filled with distinct integers. We denote the square on the $i$-th ($1\\le i\\le n$) row and $j$-th ($1\\le j\\le m$) column b...
[{"type": "stdin_stdout", "input": "18\n1 1\n-37\n1 2\n47 0\n1 2\n-48 -7\n2 1\n37\n-8\n2 1\n-3\n27\n2 2\n46 36\n-33 -9\n2 2\n-20 24\n-6 -33\n2 2\n-50 -45\n50 10\n2 2\n-38 -12\n1 8\n3 3\n42 4 -29\n-27 28 -16\n-35 -13 26\n3 3\n-46 40 -27\n-32 28 -24\n37 13 -13\n3 3\n-38 -17 30\n22 -50 7\n-26 18 -3\n3 3\n-2 26 29\n41 11 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring a recent research Berland scientists found out that there were n cities in Ancient Berland, joined by two-way paths. Any two cities are joined by no more than one path. No path joins a city with itself. According t...
[{"type": "stdin_stdout", "input": "183\n", "output": "8372\n1 92\n1 93\n1 94\n1 95\n1 96\n1 97\n1 98\n1 99\n1 100\n1 101\n1 102\n1 103\n1 104\n1 105\n1 106\n1 107\n1 108\n1 109\n1 110\n1 111\n1 112\n1 113\n1 114\n1 115\n1 116\n1 117\n1 118\n1 119\n1 120\n1 121\n1 122\n1 123\n1 124\n1 125\n1 126\n1 127\n1 128\n1 129\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThor is getting used to the Earth. As a gift Loki gave him a smartphone. There are n applications on this phone. Thor is fascinated by this phone. He has only one minor issue: he can't count the number of unread notificat...
[{"type": "stdin_stdout", "input": "10 85\n2 2\n1 10\n1 1\n2 6\n1 2\n1 4\n1 7\n2 1\n1 1\n3 3\n1 9\n1 6\n1 8\n1 10\n3 8\n2 8\n1 6\n1 3\n1 9\n1 6\n1 3\n1 8\n1 1\n1 6\n1 10\n2 1\n2 10\n1 10\n1 1\n1 10\n1 6\n2 2\n1 8\n1 3\n1 4\n1 9\n1 5\n1 5\n2 2\n2 4\n1 7\n1 1\n2 4\n2 9\n1 1\n1 7\n1 8\n3 14\n1 10\n2 2\n1 3\n1 10\n1 6\n3 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble.\n\nThe point is to trick the spectator's attention. Initiall...
[{"type": "stdin_stdout", "input": "100 50\n11 28\n11 1\n98 58\n38 27\n24 27\n67 37\n90 48\n91 14\n43 29\n3 64\n24 6\n53 19\n97 65\n13 27\n75 53\n37 82\n69 75\n94 99\n1 26\n95 60\n45 27\n100 82\n71 49\n86 99\n74 58\n88 68\n39 63\n38 23\n22 39\n29 58\n62 83\n62 1\n61 58\n2 30\n41 48\n83 90\n1 17\n73 81\n23 53\n71 16\n43...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array consisting of all integers from $[l, r]$ inclusive. For example, if $l = 2$ and $r = 5$, the array would be $[2, 3, 4, 5]$. What's the minimum number of elements you can delete to make the bitwise A...
[{"type": "stdin_stdout", "input": "5\n1 1\n1 8\n7 10\n1 10\n100000 186611\n", "output": "0\n4\n1\n5\n31072\n"}, {"type": "stdin_stdout", "input": "5\n1 2\n1 13\n4 5\n4 10\n110000 200000\n", "output": "1\n6\n0\n3\n21072\n"}, {"type": "stdin_stdout", "input": "5\n1 2\n1 13\n4 5\n1 10\n110000 200000\n", "output": "1\n6\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's denote the median of a sequence $s$ with odd length as the value in the middle of $s$ if we sort $s$ in non-decreasing order. For example, let $s = [1, 2, 5, 7, 2, 3, 12]$. After sorting, we get sequence $[1, 2, 2, ...
[{"type": "stdin_stdout", "input": "4\n3 5 1\n1\n13 3 3\n1 4 7\n15 5 3\n2 5 10\n17 18 7\n2 3 5 7 5 11 12\n", "output": "NO\nYES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "4\n3 5 1\n1\n11 3 3\n1 3 7\n15 5 3\n4 5 6\n13 7 7\n2 3 5 7 9 11 12\n", "output": "NO\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "4\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlternate Escape\n\nAlice House\n\nAlice and Bob are playing board games. This board game is played using a board with squares in rows H and columns and one frame. In this game, the upper left square of the board is set a...
[{"type": "stdin_stdout", "input": "3 3 2 2\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n0 0 0 0\n 1 1 1\n3 3 2 1\n 1 0 1\n1 0 1 1\n 1 0 0\n0 0 0 0\n 0 0 1\n1 1 0 1\n 1 0 1\n1 3 1 1\n 1 1 1\n1 0 0 1\n 1 0 1\n2 2 1 1\n 1 0\n1 0 0\n 0 0\n0 0 0\n 0 0\n0 0 0 0", "output": "Yes\nYes\nYes\nNo\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:\n\n* If the number of cookies in his hand is odd, eat one of those cookies...
[{"type": "stdin_stdout", "input": "231274241 358979323 84", "output": "393502366 196751183\n"}, {"type": "stdin_stdout", "input": "377378637 358979323 84", "output": "490905292 245452646\n"}, {"type": "stdin_stdout", "input": "7425724 358979323 157", "output": "122135010 244270020\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKaren is getting ready for a new school day!\n\n [Image] \n\nIt is currently hh:mm, given in a 24-hour format. As you know, Karen loves palindromes, and she believes that it is good luck to wake up when the time is a pali...
[{"type": "stdin_stdout", "input": "05:51\n", "output": "250\n"}, {"type": "stdin_stdout", "input": "15:52\n", "output": "250\n"}, {"type": "stdin_stdout", "input": "06:59\n", "output": "182\n"}, {"type": "stdin_stdout", "input": "17:31\n", "output": "151\n"}, {"type": "stdin_stdout", "input": "07:59\n", "output": "122...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these bel...
[{"type": "stdin_stdout", "input": "2 12\naa\n+ 1 a\n+ 2 a\n+ 3 a\n- 1\n+ 1 a\n- 2\n+ 2 a\n- 3\n+ 3 a\n+ 2 a\n- 1\n- 3\n", "output": "YES\nYES\nNO\nYES\nNO\nYES\nNO\nYES\nNO\nNO\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "2 12\naa\n+ 1 a\n+ 2 a\n+ 3 a\n- 1\n+ 1 a\n- 2\n+ 2 a\n- 3\n+ 3 a\n+ 2 a\n- 1\n- 3\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a string S of length N consisting of uppercase English letters.\nHow many times does ABC occur in S as contiguous subsequences (see Sample Inputs and Outputs)?\n\n-----Constraints-----\n - 3 \\leq N \\leq 50\n - S...
[{"type": "stdin_stdout", "input": "50\nABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCABCAB\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "50\nBMZBMWEYYDIADTLCOUEGMDBYFWURPWBPUVHIFNUAPWYNDMHTQV\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "50\nKGKBHTYTSZOTWFLEGSJZZSZFWTZFPNSCGUEMWRCZQXYCIVDQNK\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDreamoon is a big fan of the Codeforces contests.\n\nOne day, he claimed that he will collect all the places from $1$ to $54$ after two more rated contests. It's amazing!\n\nBased on this, you come up with the following p...
[{"type": "stdin_stdout", "input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n11 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1\n1\n4 57\n80 60 40 20\n", "output": "5\n101\n2\n2\n60\n"}, {"type": "stdin_stdout", "input": "5\n6 2\n3 1 1 5 7 10\n1 100\n100\n11 1\n1 1 1 1 1 1 1 1 1 1 1\n1 1\n1\n4 57\n61 60 40 20\n", "output": "5\n101\n2\n2\n61\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nReminder: the median of the array $[a_1, a_2, \\dots, a_{2k+1}]$ of odd number of elements is defined as follows: let $[b_1, b_2, \\dots, b_{2k+1}]$ be the elements of the array in the sorted order. Then median of this ar...
[{"type": "stdin_stdout", "input": "3\n1\n1 1\n3\n6 5 4 1 2 3\n5\n13 4 10 22 2 5 10 3 16 16\n", "output": "0\n1\n0\n"}, {"type": "stdin_stdout", "input": "3\n1\n-1 2\n3\n11 1 0 2 2 5\n5\n13 2 7 13 1 5 1 3 23 14\n", "output": "3\n0\n2\n"}, {"type": "stdin_stdout", "input": "3\n1\n1 2\n3\n6 5 4 1 2 1\n5\n13 4 7 14 2 10 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDark Assembly is a governing body in the Netherworld. Here sit the senators who take the most important decisions for the player. For example, to expand the range of the shop or to improve certain characteristics of the c...
[{"type": "stdin_stdout", "input": "8 1 8109\n1944 40\n9732 40\n9214 80\n1770 40\n7837 50\n7430 100\n1753 30\n3991 60\n", "output": "0.6441514424\n"}, {"type": "stdin_stdout", "input": "8 3 6395\n8159 90\n4143 50\n6954 50\n5011 20\n9872 10\n7689 90\n8811 70\n2058 10\n", "output": "0.5175644027\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs a big fan of Formula One, Charlie is really happy with the fact that he has to organize ticket sells for the next Grand Prix race in his own city. Unfortunately, the finacial crisis is striking everywhere and all the b...
[{"type": "stdin_stdout", "input": "100000 100000 1\n", "output": "3.999900002193968e-05\n"}, {"type": "stdin_stdout", "input": "15566 14608 0\n", "output": "0.061604676559388505\n"}, {"type": "stdin_stdout", "input": "100000 100000 10\n", "output": "0.00120926220494\n"}, {"type": "stdin_stdout", "input": "100000 10000...
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 1119 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\nYou are given a matrix of size $n \\times n$ filled with lowercase English letters. You can change no more than $k$ letters in this matrix.\n\nConsider all paths from the upper left corner to the lower right corner that m...
[{"type": "stdin_stdout", "input": "7 6\nypnxnnp\npnxonpm\nnxanpou\nxnnpmud\nnhtdudu\nnpmuduh\npmutsnz\n", "output": "aaaaaaadudsnz\n"}, {"type": "stdin_stdout", "input": "7 6\nypnxnnp\npnxonpm\nnxanpou\nxnnpmud\nnhtdudu\nhudumpn\npmutsnz\n", "output": "aaaaaaadudpnz\n"}, {"type": "stdin_stdout", "input": "7 6\nypnxpnn...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are now in a bookshop with your friend Alice to buy a book, \"The Winning Strategy for the Programming Koshien Contest,” just released today. As you definitely want to buy it, you are planning to borrow some money fro...
[{"type": "stdin_stdout", "input": "0111 12618 3831", "output": "3720\n"}, {"type": "stdin_stdout", "input": "0101 15626 3831", "output": "3730\n"}, {"type": "stdin_stdout", "input": "0110 15626 3831", "output": "3721\n"}, {"type": "stdin_stdout", "input": "0111 27455 5699", "output": "5588\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet S be the sum of divisors of an integer N excluding the number itself. When N = S, N is called a perfect number, when N> S, N is called a defendant number, and when N <S, N is called an abundant number. Create a progra...
[{"type": "stdin_stdout", "input": "1\n2\n2\n1\n1\n14\n16\n27\n66290451\n187711252\n124798312\n100001000\n0", "output": "deficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\ndeficient number\na...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N lines in the xy-plane. The i-th line is represented by A_ix+B_iy=C_i. Any two lines among the N+2 lines, the above N lines plus the x-axis and y-axis, cross each other at exactly one point.\n\nFor each pair 1 ...
[{"type": "stdin_stdout", "input": "7\n1 7 8\n-2 4 9\n3 -8 -5\n9 2 -14\n6 7 5\n-8 -9 3\n3 8 10", "output": "-1.722222222222222 1.325000000000000"}, {"type": "stdin_stdout", "input": "7\n1 7 9\n-2 4 9\n3 -8 -5\n17 2 -14\n4 11 5\n-8 -9 3\n1 8 10", "output": "-1.027777778 1.210526316\n"}, {"type": "stdin_stdout", "input":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Max has got himself into popular CCG \"BrainStone\". As \"BrainStone\" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them:\n\nMax owns n creatures, i-t...
[{"type": "stdin_stdout", "input": "10 9 0\n620118469 704168608\n528098892 341451371\n15150469 449838744\n960504540 722185004\n271837337 344050133\n940943201 419522619\n85569623 788965215\n161962866 563795701\n943389281 445744350\n610994199 473866838\n", "output": "5253588583\n"}, {"type": "stdin_stdout", "input": "10 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n segments on the Ox-axis. You can drive a nail in any integer point on the Ox-axis line nail so, that all segments containing this point, are considered nailed down. If the nail passes through endpoint of s...
[{"type": "stdin_stdout", "input": "35\n-47 61\n-73 -15\n9 43\n43 -4\n13 -6\n48 -65\n49 -84\n-6 76\n40 6\n-41 11\n-63 -42\n-7 -7\n47 -98\n-17 61\n79 99\n47 -98\n61 31\n85 72\n-50 -17\n-67 45\n14 -50\n-45 61\n-6 -96\n-47 -83\n56 -58\n-24 -15\n14 20\n-95 -82\n47 93\n-4 -7\n70 9\n91 -18\n-71 31\n55 -20\n81 -8\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn February, 30th n students came in the Center for Training Olympiad Programmers (CTOP) of the Berland State University. They came one by one, one after another. Each of them went in, and before sitting down at his desk,...
[{"type": "stdin_stdout", "input": "185\n28 4 4 26 15 21 14 35 22 28 26 24 2 35 21 34 1 23 35 10 6 16 31 0 30 9 18 33 1 22 24 26 22 10 8 27 14 33 16 16 26 22 1 28 32 1 35 12 31 0 21 6 6 5 29 27 1 29 23 22 30 19 37 17 2 2 2 25 3 23 28 0 3 31 34 5 2 23 27 7 26 25 33 27 15 31 31 4 3 21 1 1 23 30 0 13 24 33 26 5 1 17 23 25...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have five variables x_1, x_2, x_3, x_4, and x_5.\nThe variable x_i was initially assigned a value of i.\nSnuke chose one of these variables and assigned it 0.\nYou are given the values of the five variables after this ...
[{"type": "stdin_stdout", "input": "0 2 3 4 5\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 2 0 4 5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 0 3 4 5\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 2 3 0 5\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "1 2 3 4 0\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya came across three Berland coins. They didn't have any numbers that's why Vasya didn't understand how their denominations differ. He supposed that if one coin is heavier than the other one, then it should be ...
[{"type": "stdin_stdout", "input": "A&gt;B\nC&lt;B\nC;tg&A\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "A&lt:B\nB&gt;C\nC&gt;A\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "&Agt;B\nC&lt;B\nC;tg&A\n", "output": "Impossible\n"}, {"type": "stdin_stdout", "input": "B:tl&A\nB&gt;C\nC...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have an array a consisting of n distinct positive integers, numbered from 1 to n. Define p_k as $$$p_k = ∑_{1 ≤ i, j ≤ k} a_i mod a_j, where x \\bmod y denotes the remainder when x is divided by y. You have to find an...
[{"type": "stdin_stdout", "input": "100\n15 37 41 48 50 55 62 81 82 101 129 139 141 143 146 154 163 169 170 218 220 237 240 247 249 258 266 271 281 286 288 295 308 328 330 332 338 341 349 392 394 396 408 424 436 440 443 451 452 463 465 469 472 483 484 496 506 512 524 542 550 551 570 574 586 604 610 612 618 629 635 637 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Absurdistan, there are n towns (numbered 1 through n) and m bidirectional railways. There is also an absurdly simple road network — for each pair of different towns x and y, there is a bidirectional road between towns ...
[{"type": "stdin_stdout", "input": "4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "10 5\n2 5\n1 2\n1 4\n1 3\n3 2\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "4 5\n1 3\n2 1\n3 4\n4 2\n2 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 5\n2 5\n1 2\n1 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA continued fraction of height n is a fraction of form $a_{1} + \\frac{1}{a_{2} + \\frac{1}{\\ldots + \\frac{1}{a_{n}}}}$. You are given two rational numbers, one is represented as [Image] and the other one is represented...
[{"type": "stdin_stdout", "input": "633468529243155234 4\n90\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "742143496299253703 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNeko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher.\n\nNeko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least c...
[{"type": "stdin_stdout", "input": "1000000000 264865600\n", "output": "102701600\n"}, {"type": "stdin_stdout", "input": "1000000000 264865600\n", "output": "102701600"}, {"type": "stdin_stdout", "input": "999999973 800000007\n", "output": "199999823\n"}, {"type": "stdin_stdout", "input": "159488527 938932258\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMike has n strings s1, s2, ..., sn each consisting of lowercase English letters. In one move he can choose a string si, erase the first character and append it to the end of the string. For example, if he has the string \...
[{"type": "stdin_stdout", "input": "33\nnkgcmrfvxe\nvxenkgcmrf\nrfvxenkgcm\nvxenkgcmrf\nxenkgcmrfv\nenkgcmrfvx\nenkgcmrfvx\nnkgcmrfvxe\nkgcmrfvxen\ncmrfvxenkg\ncmrfvxenkg\nxenkgcmrfv\nrfvxenkgcm\nrfvxenkgcm\nnkgcmrfvxe\nxenkgcmrfv\nrfvxenkgcm\nxenkgcmrfv\nxenkgcmrfv\ngcmrfvxenk\nmrfvxenkgc\nfvxenkgcmr\nvxenkgcmrf\nenkg...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArkady decides to observe a river for n consecutive days. The river's water level on each day is equal to some real value.\n\nArkady goes to the riverside each day and makes a mark on the side of the channel at the height...
[{"type": "stdin_stdout", "input": "100\n0 1 2 2 3 0 1 5 6 6 0 0 8 7 1 9 9 4 10 11 12 2 12 12 12 12 9 13 14 8 15 15 15 19 15 7 17 17 18 19 9 10 21 0 22 9 2 24 24 4 24 7 25 14 5 8 28 29 30 31 31 31 0 3 15 31 8 33 6 35 35 35 36 36 37 37 38 39 28 0 2 23 75 9 9 0 6 25 41 41 12 42 43 43 36 44 51 45 43 4\n", "output": "2385\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday Adilbek is taking his probability theory test. Unfortunately, when Adilbek arrived at the university, there had already been a long queue of students wanting to take the same test. Adilbek has estimated that he will...
[{"type": "stdin_stdout", "input": "20 25\n1 1 1 1 1 1 2 2 1 1 2 1 2 2 1 2 1 1 2 2\n", "output": "846324940\n"}, {"type": "stdin_stdout", "input": "20 26\n1 2 1 1 1 2 1 1 2 2 2 1 2 1 2 1 1 2 2 1\n", "output": "509799974\n"}, {"type": "stdin_stdout", "input": "20 27\n1 2 1 2 1 2 1 2 2 1 2 2 1 2 2 2 1 1 2 1\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some st...
[{"type": "stdin_stdout", "input": "100 34\n16 0 10 11 12 13 0 5 4 14 6 15 4 9 1 20 19 14 1 7 14 11 10 20 6 9 12 8 3 19 20 4 17 17 8 11 14 18 5 20 17 0 3 18 14 12 11 12 5 5 11 7 9 17 4 8 4 10 0 0 12 9 15 3 15 14 19 12 6 8 17 19 4 18 19 3 8 3 9 1 6 15 4 16 1 18 13 16 3 5 20 11 10 9 9 17 20 15 12\n", "output": "312\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has recently got himself a new job. He now earns so much that his old wallet can't even store all the money he has.\n\nBerland bills somehow come in lots of different sizes. However, all of them are shaped as rec...
[{"type": "stdin_stdout", "input": "69\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n+ 1 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected weighted connected graph with $n$ vertices and $m$ edges without loops and multiple edges.\n\nThe $i$-th edge is $e_i = (u_i, v_i, w_i)$; the distance between vertices $u_i$ and $v_i$ along the...
[{"type": "stdin_stdout", "input": "8 10\n1 2 1\n2 3 2\n2 4 5\n1 4 2\n6 3 3\n6 1 3\n3 5 2\n3 7 1\n4 8 1\n6 2 4\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "8 10\n1 2 1\n2 3 4\n2 4 5\n1 4 2\n6 3 3\n6 1 3\n3 5 2\n3 7 1\n4 8 1\n6 2 4\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "8 10\n1 2 1\n2 3 2\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nGiven $ N $ a pair of non-negative integers $ (a_i, b_i) $ and non-negative integers $ A $, $ B $.\nI want to do as many of the following operations as possible.\n\n\n* $ | a_i --b_i | \\ leq A $ or $ B \\ leq ...
[{"type": "stdin_stdout", "input": "10 1 12\n15 70\n36 -1\n18 43\n26 46\n33 20\n58 10\n0 -1\n80 5\n98 32\n23 84", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 1 12\n15 70\n36 -1\n18 43\n26 46\n33 20\n58 10\n0 -1\n80 5\n98 32\n23 30", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 1 12\n15 70\n58 -1\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOverall there are m actors in Berland. Each actor has a personal identifier — an integer from 1 to m (distinct actors have distinct identifiers). Vasya likes to watch Berland movies with Berland actors, and he has k favor...
[{"type": "stdin_stdout", "input": "50 25\n8 18 41 25 16 39 2 47 49 37 40 23 3 35 15 7 11 28 22 48 10 17 38 46 44\n4\nswyzirxhx\n28\n43 32 14 5 0 17 25 39 0 0 36 0 0 34 27 22 6 13 26 0 0 41 12 16 0 0 0 23\nzyn\n3\n36 12 47\np\n33\n38 0 35 0 6 20 43 9 15 37 17 23 2 0 0 0 0 0 34 0 28 10 33 0 5 4 7 12 36 46 0 0 45\nycaqpk...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGildong has an interesting machine that has an array $a$ with $n$ integers. The machine supports two kinds of operations:\n\nIncrease all elements of a suffix of the array by $1$.\n\nDecrease all elements of a suffix of t...
[{"type": "stdin_stdout", "input": "7\n2\n0 1\n3\n-1 0 2\n4\n110 133 106 95\n4\n-3 -5 -2 1\n6\n1 8 3 8 4 1\n5\n5 0 0 0 5\n9\n-367741579 319422997 -415264583 -125558838 -300860379 721691728 294512916 -383235489 425814447\n", "output": "0\n1\n15\n4\n14\n5\n3449059550\n"}, {"type": "stdin_stdout", "input": "7\n2\n0 1\n3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCaisa is going to have a party and he needs to buy the ingredients for a big chocolate cake. For that he is going to the biggest supermarket in town.\n\nUnfortunately, he has just s dollars for sugar. But that's not a rea...
[{"type": "stdin_stdout", "input": "69 9\n39 15\n70 44\n90 89\n84 58\n83 97\n24 28\n90 18\n7 96\n43 86\n99 50\n77 12\n12 34\n100 19\n21 86\n55 30\n99 29\n26 92\n82 67\n78 14\n64 16\n98 12\n31 39\n36 86\n73 36\n87 29\n42 23\n58 15\n35 52\n91 56\n39 6\n88 45\n38 36\n57 12\n79 71\n40 33\n98 42\n34 36\n23 79\n69 68\n50 47\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLunar New Year is approaching, and Bob is planning to go for a famous restaurant — \"Alice's\".\n\nThe restaurant \"Alice's\" serves $n$ kinds of food. The cost for the $i$-th kind is always $c_i$. Initially, the restaura...
[{"type": "stdin_stdout", "input": "10 15\n132 138 38 75 14 115 129 68 119 118\n728344 513371 120930 757031 137753 453796 348671 185533 966778 521678\n4 58\n1 8\n8 22\n3 98\n2 111\n6 158\n2 82\n1 170\n1 26\n1 4\n4 76\n10 106\n5 100\n4 116\n7 62\n", "output": "43907798\n5826752\n4081726\n15058400\n56984181\n67179393\n33...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMedicine faculty of Berland State University has just finished their admission campaign. As usual, about $80\\%$ of applicants are girls and majority of them are going to live in the university dormitory for the next $4$ ...
[{"type": "stdin_stdout", "input": "10\n5620 2478 4051 7060 10510 2170 6912 2031 1781 7454\n1 1 1 1 1 1 1 1 1 1\n", "output": "5620\n"}, {"type": "stdin_stdout", "input": "10\n5620 1555 4051 7060 10510 2170 6912 2031 1781 7454\n1 1 1 1 1 1 1 1 1 1\n", "output": "5620\n"}, {"type": "stdin_stdout", "input": "10\n7846 835...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a sequence of integers $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ which is sorted by ascending order, eliminate all equivalent elements.\n\nConstraints\n\n* $1 \\leq n \\leq 100,000$\n* $-1000,000,000 \\leq a_i \\leq 1,00...
[{"type": "stdin_stdout", "input": "4\n-2 -1 1 2", "output": "-2 -1 1 2\n"}, {"type": "stdin_stdout", "input": "4\n-2 -1 0 2", "output": "-2 -1 0 2\n"}, {"type": "stdin_stdout", "input": "4\n-2 -1 0 4", "output": "-2 -1 0 4\n"}, {"type": "stdin_stdout", "input": "4\n-1 0 1 10", "output": "-1 0 1 10\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAndrew often reads articles in his favorite magazine 2Char. The main feature of these articles is that each of them uses at most two distinct letters. Andrew decided to send an article to the magazine, but as he hasn't wr...
[{"type": "stdin_stdout", "input": "31\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "31\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\nfml\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolygons are the most fundamental objects in geometric processing. Complex figures are often represented and handled as polygons with many short sides. If you are interested in the processing of geometric data, you'd bett...
[{"type": "stdin_stdout", "input": "3\n1 1\n3 4\n6 -1\n\n7\n1 -1\n10 10\n-1 20\n3 33\n0 70\n100 40\n100 -1\n\n0", "output": "1 9.5\n2 5426.0\n"}, {"type": "stdin_stdout", "input": "3\n1 1\n3 4\n6 -1\n\n7\n1 -1\n10 10\n-1 20\n3 33\n0 40\n100 40\n100 0\n\n0", "output": "1 9.5\n2 3921.5\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSo many wall designs to choose from! Even modulo 106 + 3, it's an enormous number. Given that recently Heidi acquired an unlimited supply of bricks, her choices are endless! She really needs to do something to narrow them...
[{"type": "stdin_stdout", "input": "100000000 100 100\n", "output": "807624\n"}, {"type": "stdin_stdout", "input": "100000100 100 100\n", "output": "515397\n"}, {"type": "stdin_stdout", "input": "100000000 100 1\n", "output": "245069\n"}, {"type": "stdin_stdout", "input": "100000000 1 100\n", "output": "389182\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp and Vasiliy love simple logical games. Today they play a game with infinite chessboard and one pawn for each player. Polycarp and Vasiliy move in turns, Polycarp starts. In each turn Polycarp can move his pawn fr...
[{"type": "stdin_stdout", "input": "100000 99999 100000 100000\n", "output": "Polycarp\n"}, {"type": "stdin_stdout", "input": "100000 100000 100000 99999\n", "output": "Vasiliy\n"}, {"type": "stdin_stdout", "input": "55000 60000 55003 60100\n", "output": "Polycarp\n"}, {"type": "stdin_stdout", "input": "23039 21508 541...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is distributing N balls to K persons.\n\nIf each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the pe...
[{"type": "stdin_stdout", "input": "-2 135", "output": "-137\n"}, {"type": "stdin_stdout", "input": "-2 240", "output": "-242\n"}, {"type": "stdin_stdout", "input": "-4 240", "output": "-244\n"}, {"type": "stdin_stdout", "input": "3 130", "output": "-127\n"}, {"type": "stdin_stdout", "input": "2 130", "output": "-128\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a bus route as shown in Figure 1. There are 10 stops, each numbered 0-9. The bus turns back at stop 0, but the other side is a circulation route, which circulates in the order of 5 → 6 → 7 → 8 → 9 → 5 as shown in...
[{"type": "stdin_stdout", "input": "2\n1 8\n8 0", "output": "1 2 3 4 5 6 7 8\n8 9 5 4 3 2 1 0\n"}, {"type": "stdin_stdout", "input": "2\n1 9\n8 1", "output": "1 2 3 4 5 6 7 8 9\n8 9 5 4 3 2 1\n"}, {"type": "stdin_stdout", "input": "2\n2 8\n6 2", "output": "2 3 4 5 6 7 8\n6 7 8 9 5 4 3 2\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLimak is a grizzly bear who desires power and adoration. He wants to win in upcoming elections and rule over the Bearland.\n\nThere are n candidates, including Limak. We know how many citizens are going to vote for each c...
[{"type": "stdin_stdout", "input": "100\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nJOI took six subjects: physics, chemistry, biology, earth science, history, and geography. Each test was scored on a 100-point scale.\n\nJOI chooses 3 subjects from 4 subjects of physics, chemistry, biology, an...
[{"type": "stdin_stdout", "input": "100\n-3\n8\n108\n-12\n-4", "output": "212\n"}, {"type": "stdin_stdout", "input": "100\n-7\n8\n108\n-12\n-1", "output": "215\n"}, {"type": "stdin_stdout", "input": "100\n66\n-13\n-1\n-2\n2", "output": "167\n"}, {"type": "stdin_stdout", "input": "100\n106\n-5\n-1\n-2\n3", "output": "20...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLast year the world's largest square was built in Berland. It is known that the square can be represented as an infinite plane with an introduced Cartesian system of coordinates. On that square two sets of concentric circ...
[{"type": "stdin_stdout", "input": "100000 -100000 100000 100000\n", "output": " 200001\n"}, {"type": "stdin_stdout", "input": "100000 100000 100000 -100000\n", "output": " 200001\n"}, {"type": "stdin_stdou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima and Inna are doing so great! At the moment, Inna is sitting on the magic lawn playing with a pink pony. Dima wanted to play too. He brought an n × m chessboard, a very tasty candy and two numbers a and b.\n\nDima put...
[{"type": "stdin_stdout", "input": "1000000 1000000 1000000 0000000 1000000 1000000\n", "output": "Poor Inna and pony!"}, {"type": "stdin_stdout", "input": "1000100 1000000 1000000 0000000 1000000 1000000\n", "output": "Poor Inna and pony!"}, {"type": "stdin_stdout", "input": "1000100 1000010 1000000 0000000 1000000 10...
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\nExample\n\nInput\n\nacmicpc\ntsukuba\n\n\nOutput\n\nNo\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem. Yo...
[{"type": "stdin_stdout", "input": "acmicpc\nttukuba", "output": "No\n"}, {"type": "stdin_stdout", "input": "acmpcic\nttukuba", "output": "No\n"}, {"type": "stdin_stdout", "input": "acmpcid\nttukuba", "output": "No\n"}, {"type": "stdin_stdout", "input": "acmpcid\nttakubu", "output": "No\n"}, {"type": "stdin_stdout", "i...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^4\n - 1 \\leq A \\leq B \\leq 36\n - All inp...
[{"type": "stdin_stdout", "input": "100 4 16\n", "output": "4554\n"}, {"type": "stdin_stdout", "input": "101 0 154", "output": "5151\n"}, {"type": "stdin_stdout", "input": "111 1 181", "output": "6216\n"}, {"type": "stdin_stdout", "input": "110 2 100", "output": "5994\n"}, {"type": "stdin_stdout", "input": "100 2 100",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSlava plays his favorite game \"Peace Lightning\". Now he is flying a bomber on a very specific map.\n\nFormally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each cell there can...
[{"type": "stdin_stdout", "input": "11124\n", "output": "16686\n2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a graph with N vertices, numbered 0 through N-1. Edges are yet to be added.\n\nWe will process Q queries to add edges. In the i-th (1≦i≦Q) query, three integers A_i, B_i and C_i will be given, and we will add infi...
[{"type": "stdin_stdout", "input": "2 1\n0 0 1000000010", "output": "1000000011\n"}, {"type": "stdin_stdout", "input": "2 1\n1 0 1000000010", "output": "1000000010\n"}, {"type": "stdin_stdout", "input": "2 1\n0 0 1000000100", "output": "1000000101\n"}, {"type": "stdin_stdout", "input": "2 1\n0 0 1000001010", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne tradition of ACM-ICPC contests is that a team gets a balloon for every solved problem. We assume that the submission time doesn't matter and teams are sorted only by the number of balloons they have. It means that one...
[{"type": "stdin_stdout", "input": "7\n14000000003 1000000000000000000\n81000000000 88000000000\n5000000000 10778591928\n15000000000 39000000000\n46000000000 51000000000\n0 0000000000\n0 0\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\n14000000003 1000000000000000000\n81000000000 88000000000\n5000000000 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPeter loves any kinds of cheating. A week before ICPC, he broke into Doctor's PC and sneaked a look at all the problems that would be given in ICPC. He solved the problems, printed programs out, and brought into ICPC. Sin...
[{"type": "stdin_stdout", "input": "3\n10 20 47\n7\n56 26 62 143 38 80 7", "output": "117\n1108\n"}, {"type": "stdin_stdout", "input": "3\n10 20 47\n7\n56 44 62 143 38 80 7", "output": "117\n1210\n"}, {"type": "stdin_stdout", "input": "3\n10 20 47\n7\n56 44 62 143 38 80 6", "output": "117\n1203\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPalindromic characteristics of string s with length |s| is a sequence of |s| integers, where k-th number is the total number of non-empty substrings of s which are k-palindromes.\n\nA string is 1-palindrome if and only if...
[{"type": "stdin_stdout", "input": "wyemcafatp\n", "output": "11 1 0 0 0 0 0 0 0 0 \n"}, {"type": "stdin_stdout", "input": "wyemcafatp\n", "output": "11 1 0 0 0 0 0 0 0 0 "}, {"type": "stdin_stdout", "input": "wyempafatc\n", "output": "11 1 0 0 0 0 0 0 0 0\n"}, {"type": "stdin_stdout", "input": "wyempaf`tc\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOf course our child likes walking in a zoo. The zoo has n areas, that are numbered from 1 to n. The i-th area contains ai animals in it. Also there are m roads in the zoo, and each road connects two distinct areas. Natura...
[{"type": "stdin_stdout", "input": "10 19\n13637 26970 19043 3616 12880 19387 12539 25190 2452 1261\n1 2\n1 3\n1 4\n2 5\n3 6\n6 7\n3 8\n5 9\n3 10\n4 10\n9 3\n2 8\n4 3\n2 3\n7 10\n7 8\n5 10\n5 6\n7 4\n", "output": "8241.4222222222\n"}, {"type": "stdin_stdout", "input": "10 19\n15704 19758 26631 25050 22778 15041 8487 26...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp plays a computer game. There are $n$ different sets of armor and $m$ different weapons in this game. If a character equips the $i$-th set of armor and wields the $j$-th weapon, their power is usually equal to $i ...
[{"type": "stdin_stdout", "input": "2 10\n20\n2 2\n2 3\n2 4\n1 5\n1 2\n1 6\n1 1\n1 10\n2 10\n1 4\n2 8\n2 1\n1 9\n1 8\n2 5\n1 7\n2 7\n1 3\n2 9\n2 6\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "2 10\n20\n2 6\n2 3\n1 1\n2 1\n2 9\n1 6\n1 2\n1 9\n1 10\n2 7\n2 4\n2 5\n1 5\n2 2\n2 8\n1 3\n1 8\n1 4\n1 7\n2 10\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a rectangular table 3 × n. Each cell contains an integer. You can move from one cell to another if they share a side.\n\nFind such path from the upper left cell to the bottom right cell of the table that doe...
[{"type": "stdin_stdout", "input": "10\n1086100980 -928074266 -409520915 770775361 240764400 108297300 -280070452 588179696 -920283246 736937716\n422602209 -940948979 -483879926 -525886137 -79749893 -958247281 844561102 553768085 269384580 -975129348\n-485518332 -130037110 493465239 494308146 958976404 706037260 154106...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the snake exhibition, there are $n$ rooms (numbered $0$ to $n - 1$) arranged in a circle, with a snake in each room. The rooms are connected by $n$ conveyor belts, and the $i$-th conveyor belt connects the rooms $i$ an...
[{"type": "stdin_stdout", "input": "36\n2\n--\n2\n>-\n2\n<-\n2\n->\n2\n>>\n2\n<>\n2\n-<\n2\n><\n2\n<<\n3\n---\n3\n>--\n3\n<--\n3\n->-\n3\n>>-\n3\n<>-\n3\n-<-\n3\n><-\n3\n<<-\n3\n-->\n3\n>->\n3\n<->\n3\n->>\n3\n>>>\n3\n<>>\n3\n-<>\n3\n><>\n3\n<<>\n3\n--<\n3\n>-<\n3\n<-<\n3\n-><\n3\n>><\n3\n<><\n3\n-<<\n3\n><<\n3\n<<<\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Polycarp noticed that some of the buttons of his keyboard are malfunctioning. For simplicity, we assume that Polycarp's keyboard contains $26$ buttons (one for each letter of the Latin alphabet). Each button is e...
[{"type": "stdin_stdout", "input": "1\nammsdsdadasdsadssadassadsadasdsadsadr\n", "output": "adrs\n"}, {"type": "stdin_stdout", "input": "1\nammsdsdadasdsadssadassadsadasdsadsadr\n", "output": "adrs\n"}, {"type": "stdin_stdout", "input": "1\nammsdsdaeasdsadssadassadsadasdsadsads\n", "output": "ades\n"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArkady is playing Battleship. The rules of this game aren't really important.\n\nThere is a field of $n \\times n$ cells. There should be exactly one $k$-decker on the field, i. e. a ship that is $k$ cells long oriented e...
[{"type": "stdin_stdout", "input": "19 6\n##..............###\n#......#####.....##\n.....#########.....\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\nLittle Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a \"domino show\".\n\nChris arranges n dominoes in a line,...
[{"type": "stdin_stdout", "input": "400\n.L.R.LR.LRL.R.LR.LR..L....RLR.L..R..LRLRLR.LRL..RLR.LRLRLRLR.LR..LRL.RLR...LRLR.LRL.R.LR..LR.LRLR...LRLRL.R.L.....RL..RL.RLRL.RL.RL...RL..R.LRLRL..R.LRL...R..LRL.RLRL...RL..RLRLRLRL.R..LRL.R..LRLRL.R.L.R.L.RL.RLRLRL....R.LR..L..RL.RL.RLRLR.L..RLRL.RLR..LRLR.L.R..L.R.LR.LRL.....R...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is always an integer in Takahashi's mind.\nInitially, the integer in Takahashi's mind is 0. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by 1...
[{"type": "stdin_stdout", "input": "-+--\n", "output": "-2\n"}, {"type": "stdin_stdout", "input": "----\n", "output": "-4\n"}, {"type": "stdin_stdout", "input": "--+-\n", "output": "-2\n"}, {"type": "stdin_stdout", "input": "+---\n", "output": "-2\n"}, {"type": "stdin_stdout", "input": "+-++\n", "output": "2\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nChef's team is going to participate at the legendary math battles. One of the main task in the competition is to calculate the number of wa...
[{"type": "stdin_stdout", "input": "5\n-2 -8\n11 0\n109 35\n0 -2\n-4 0", "output": "0\n0\n4375\n0\n0\n"}, {"type": "stdin_stdout", "input": "5\n-3 0\n11 1\n148 35\n0 -2\n-4 0", "output": "0\n0\n18334\n0\n0\n"}, {"type": "stdin_stdout", "input": "5\n-3 0\n5 1\n148 35\n0 -2\n-4 0", "output": "0\n1\n18334\n0\n0\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.\n\nStrictly speaking, it makes a photo of a...
[{"type": "stdin_stdout", "input": "2\n240945287 28477772 1496174734 106174079\n", "output": "97526692469552229\n"}, {"type": "stdin_stdout", "input": "2\n240945287 28477772 1496174734 174902664\n", "output": "96930557139611326\n"}, {"type": "stdin_stdout", "input": "2\n240945287 45763153 1496174734 174902664\n", "outp...
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": "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": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given integer n, count the totatives of n, that is, the positive integers less than or equal to n that are relatively prime to n.\n\n\n\nInput\n\n\nn\n\n\nAn integer n (1 ≤ n ≤ 1000000000).\n\nOutput\n\nThe number of ...
[{"type": "stdin_stdout", "input": "1101011", "output": "1084512\n"}, {"type": "stdin_stdout", "input": "1100111", "output": "1097712\n"}, {"type": "stdin_stdout", "input": "1010111", "output": "1003752\n"}, {"type": "stdin_stdout", "input": "1111111", "output": "1106224\n"}, {"type": "stdin_stdout", "input": "1011001"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n3R2 as DJ Mashiro - Happiness Breeze Ice - DJ Mashiro is dead or alive\n\nNEKO#ΦωΦ has just got a new maze game on her PC!\n\nThe game's main puzzle is a maze, in the forms of a $2 \\times n$ rectangle grid. NEKO's task i...
[{"type": "stdin_stdout", "input": "10 83\n1 3\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n2 2\n1 4\n2 2\n2 3\n2 3\n2 3\n2 3\n2 3\n2 3\n1 4\n1 5\n1 7\n2 2\n2 2\n1 5\n2 2\n1 3\n2 1\n2 6\n1 5\n2 6\n2 9\n1 2\n2 5\n1 2\n2 5\n2 4\n2 4\n1 2\n1 2\n1 4\n2 6\n2 6\n2 4\n2 4\n1 2\n1 2\n2 4\n2 4\n2 3\n2 3\n1 2\n2 9\n1 2\n1 2\n1 2\n2 6\n2 6\n2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a legend in the IT City college. A student that failed to answer all questions on the game theory exam is given one more chance by his professor. The student has to play a game with the professor.\n\nThe game is ...
[{"type": "stdin_stdout", "input": "1250846005844530517\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000001000000000000\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2039244416399039339\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000001000000001000\n", "output": "2\n"}, {"type": "s...
code_stdio