messages listlengths 1 1 | ground_truth stringlengths 156 726k | dataset stringclasses 1
value |
|---|---|---|
[
{
"content": "There is one apple tree in Arkady's garden. It can be represented as a set of junctions connected with branches so that there is only one way to reach any junctions from any other one using branches. The junctions are enumerated from $1$ to $n$, the junction $1$ is called the root.\n\nA subtree of... | [{"input": "10\n1 1 2 4 2 4 1 8 8\n", "output": "1 1 1 1 1 1 2 2 3 6 \n"}, {"input": "10\n1 2 2 3 3 4 4 5 5\n", "output": "1 1 1 1 1 2 2 3 5 5 \n"}, {"input": "10\n1 1 1 1 1 1 1 1 1\n", "output": "1 1 1 1 1 1 1 1 1 9 \n"}, {"input": "10\n1 2 2 3 3 4 4 5 5\n", "output": "1 1 1 1 1 2 2 3 5 5 \n"}, {"input": "10\n1 1 1 1 ... | code_stdio |
[
{
"content": "Once Max found an electronic calculator from his grandfather Dovlet's chest. He noticed that the numbers were written with seven-segment indicators (https://en.wikipedia.org/wiki/Seven-segment_display). [Image] \n\nMax starts to type all the values from a to b. After typing each number Max resets ... | [{"input": "222145 353252\n", "output": "3860750\n"}, {"input": "222145 353252\n", "output": "3860750\n"}, {"input": "188883 353252\n", "output": "4803878\n"}, {"input": "188883 240204\n", "output": "1479377\n"}, {"input": "443 390308\n", "output": "10631342\n"}, {"input": "426 390308\n", "output": "10631576\n"}, {"inp... | code_stdio |
[
{
"content": "You've got another problem dealing with arrays. Let's consider an arbitrary sequence containing n (not necessarily different) integers a1, a2, ..., an. We are interested in all possible pairs of numbers (ai, aj), (1 ≤ i, j ≤ n). In other words, let's consider all n2 pairs of numbers, picked from t... | [{"input": "100 4755\n5 4 3 5 1 2 5 1 1 3 5 4 4 1 1 1 1 5 4 4 5 1 5 5 1 2 1 3 1 5 1 3 3 3 2 2 2 1 1 5 1 3 4 1 1 3 2 5 2 2 5 5 4 4 1 3 4 3 3 4 5 3 3 3 1 2 1 4 2 4 4 1 5 1 3 5 5 5 5 3 4 4 3 1 2 5 2 3 5 4 2 4 5 3 2 4 2 4 3 1\n", "output": "3 3\n"}, {"input": "100 9043\n4 1 4 2 1 4 2 2 1 1 4 2 4 2 4 1 4 2 2 1 2 2 2 2 1 1 2... | code_stdio |
[
{
"content": "Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.\nThe exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up.\nThese buttons are numbered 1 through N.\nWhen Button i is lighten up and you press it, the light is turned off, and then Button a_i... | [{"input": "5\n3\n-1\n4\n3\n4", "output": "-1\n"}, {"input": "5\n3\n3\n4\n2\n4\n", "output": "3\n"}, {"input": "5\n1\n3\n5\n2\n4", "output": "-1\n"}, {"input": "5\n1\n3\n5\n4\n4", "output": "-1\n"}, {"input": "5\n1\n3\n5\n2\n5", "output": "-1\n"}, {"input": "5\n3\n-1\n4\n2\n4", "output": "3\n"}, {"input": "5\n1\n3\n5\n... | code_stdio |
[
{
"content": "There is a pond with a rectangular shape.\nThe pond is divided into a grid with H rows and W columns of squares.\nWe will denote the square at the i-th row from the top and j-th column from the left by (i,\\ j).\nSome of the squares in the pond contains a lotus leaf floating on the water.\nOn one ... | [{"input": "100 100\noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo\nooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo... | code_stdio |
[
{
"content": "Hamed has recently found a string t and suddenly became quite fond of it. He spent several days trying to find all occurrences of t in other strings he had. Finally he became tired and started thinking about the following problem. Given a string s how many ways are there to extract k ≥ 1 non-overl... | [{"input": "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\nvvvvvvvv\n", "output": "2728075\n"}, {"input": "vnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssnssn\nnssnssns\n", "output": "943392\n"}, {"input": "kpjmawawawawawawawawawawawawawawawawawawawawawawaw\nwawawawa\n", "output": "834052\n"}, {"input": "vvvvvvvvvv... | code_stdio |
[
{
"content": "Polycarpus plays with red and blue marbles. He put n marbles from the left to the right in a row. As it turned out, the marbles form a zebroid.\n\nA non-empty sequence of red and blue marbles is a zebroid, if the colors of the marbles in this sequence alternate. For example, sequences (red; blue; ... | [{"input": "1000000\n", "output": "986892583"}, {"input": "491526\n", "output": "913830480\n"}, {"input": "470705\n", "output": "732073783\n"}, {"input": "201682\n", "output": "291520502\n"}, {"input": "117284\n", "output": "184689149\n"}, {"input": "728546\n", "output": "731715891\n"}, {"input": "721975\n", "output": ... | code_stdio |
[
{
"content": "Nuske has a grid with N rows and M columns of squares. The rows are numbered 1 through N from top to bottom, and the columns are numbered 1 through M from left to right. Each square in the grid is painted in either blue or white. If S_{i,j} is 1, the square at the i-th row and j-th column is blue;... | [{"input": "5 5 6\n11010\n01110\n10111\n11111\n01010\n1 1 5 5\n1 2 4 5\n2 3 3 5\n3 3 3 2\n3 1 3 5\n1 1 3 4", "output": "-2\n-2\n0\n0\n2\n1\n"}, {"input": "5 5 6\n11010\n01110\n10111\n11111\n01010\n1 1 5 5\n1 2 4 5\n3 3 3 5\n3 3 3 2\n3 1 3 5\n1 1 3 4", "output": "-2\n-2\n1\n0\n2\n1\n"}, {"input": "5 5 6\n11010\n01110\n1... | code_stdio |
[
{
"content": "You are given a grid with n rows and m columns, where each cell has a non-negative integer written on it. We say the grid is good if for each cell the following condition holds: if it has a number k > 0 written on it, then exactly k of its neighboring cells have a number greater than 0 written on ... | [{"input": "5\n3 4\n0 0 0 0\n0 1 0 0\n-1 0 0 0\n2 2\n3 0\n0 0\n2 2\n0 0\n0 0\n2 3\n-1 0 0\n0 0 0\n4 4\n0 0 0 -1\n0 2 0 2\n0 1 -1 0\n0 0 0 0\n", "output": "YES\n2 3 3 2\n3 4 4 3\n2 3 3 2\nNO\nYES\n2 2\n2 2\nYES\n2 3 2\n2 3 2\nYES\n2 3 3 2\n3 4 4 3\n3 4 4 3\n2 3 3 2\n"}, {"input": "5\n3 4\n0 0 0 0\n0 1 0 0\n-1 0 0 0\n2 2... | code_stdio |
[
{
"content": "For a positive integer X, let f(X) be the number of positive divisors of X.\nGiven a positive integer N, find \\sum_{K=1}^N K\\times f(K).\n\n-----Constraints-----\n - 1 \\leq N \\leq 10^7\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n-----Output-----\nPrint... | [{"input": "10000000\n", "output": "838627288460105\n"}, {"input": "11001000", "output": "1020696029789074\n"}, {"input": "11000000", "output": "1020504841032058\n"}, {"input": "11001001", "output": "1020696117797082\n"}, {"input": "11001101", "output": "1020713851493884\n"}, {"input": "11001110", "output": "1020715369... | code_stdio |
[
{
"content": "Vasya wrote down two strings s of length n and t of length m consisting of small English letters 'a' and 'b'. What is more, he knows that string t has a form \"abab...\", namely there are letters 'a' on odd positions and letters 'b' on even positions.\n\nSuddenly in the morning, Vasya found that s... | [{"input": "340\nbaa?b?abab??ab??aaabaa???bbbb??abaaaba?a?b?bb?ab?bbaa??aaaa???aaa?b???ba?a??b?bb?bbbabb?bb?a?a?bbbabbba?b?ababbb?b?a??bbb??bb?ababb?abbbbba??aabbaab?aaa??a???bbaa?bb?bb?babaa?bb?a???b?abbb???bb?a?a??b?b?abbba?b??a?bab??baa?aabaabb?abbbab?aa???bbaab?bbab?ba?aab?b?baabb???aaa??bb?ab?aa?aaa????babbbb???ba... | code_stdio |
[
{
"content": "For a string S, let f(S) be the lexicographically smallest cyclic shift of S. For example, if S = `babca`, f(S) = `ababc` because this is the smallest among all cyclic shifts (`babca`, `abcab`, `bcaba`, `cabab`, `ababc`).\n\nYou are given three integers X, Y, and Z. You want to construct a string ... | [{"input": "7 32 3", "output": "abbbbbbbbabbbbbbbbacabbbbbbbbacabbbbbbbbac\n"}, {"input": "7 23 3", "output": "abbbbbacacacabbbbbbabbbbbbabbbbbb\n"}, {"input": "17 7 3", "output": "aabaacaacaacaababaababaabab\n"}, {"input": "13 7 3", "output": "aacababaacababaacababab\n"}, {"input": "7 12 3", "output": "abbbabbbacabbba... | code_stdio |
[
{
"content": "Three numbers A, B and C are the inputs. Write a program to find second largest among them.\n\n-----Input-----\n\nThe first line contains an integer T, the total number of testcases. Then T lines follow, each line contains three integers A, B and C. \n\n-----Output-----\nFor each test case, displa... | [{"input": "3 \n120 14 400\n10213 312 10\n10 3 450", "output": "120\n312\n10\n"}, {"input": "3 \n117 14 384\n10213 312 10\n10 3 450", "output": "117\n312\n10\n"}, {"input": "3 \n178 14 384\n10213 312 10\n10 3 450", "output": "178\n312\n10\n"}, {"input": "3 \n303 14 384\n10213 312 10\n10 0 450", "output": "303\n312\n10\... | code_stdio |
[
{
"content": "A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the larges... | [{"input": "100 99 98 97\n", "output": "196\n195\n98\n"}, {"input": "100 50 19 10\n", "output": "100\n50\n19\n"}, {"input": "100 50 19 25\n", "output": "100\n51\n25\n"}, {"input": "100 50 19 30\n", "output": "100\n61\n30\n"}, {"input": "99 98 50 97\n", "output": "196\n195\n97\n"}, {"input": "99 50 25 49\n", "output": "... | code_stdio |
[
{
"content": "Efim just received his grade for the last test. He studies in a special school and his grade can be equal to any positive decimal fraction. First he got disappointed, as he expected a way more pleasant result. Then, he developed a tricky plan. Each second, he can ask his teacher to round the grade... | [{"input": "320 142\n2704701300865535.432223312233434114130011113220102420131323010344144201124303144444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444447444444444444444444444444444444615444444482101673308979557675074444444444444446867245414595534444693160... | code_stdio |
[
{
"content": "Jon Snow now has to fight with White Walkers. He has n rangers, each of which has his own strength. Also Jon Snow has his favourite number x. Each ranger can fight with a white walker only if the strength of the white walker equals his strength. He however thinks that his rangers are weak and need... | [{"input": "119 12 653\n877 938 872 962 590 500 422 249 141 163 609 452 594 768 316 530 838 945 658 636 997 938 941 272 102 8 713 862 572 809 301 462 282 478 12 544 157 204 367 789 136 251 754 43 349 355 560 325 463 659 666 644 992 603 799 597 364 234 903 377 896 92 971 308 617 712 480 772 170 68 318 947 741 568 63 483... | code_stdio |
[
{
"content": "You are given an integer $N$ and a string consisting of '+' and digits. You are asked to transform the string into a valid formula whose calculation result is smaller than or equal to $N$ by modifying some characters. Here, you replace one character with another character any number of times, and ... | [{"input": "2000\n0234++7890", "output": "3\n"}, {"input": "2000\n0987++4320", "output": "3\n"}, {"input": "2000\n0947++8320", "output": "3\n"}, {"input": "2000\n0947++3820", "output": "3\n"}, {"input": "2000\n0947++3028", "output": "3\n"}, {"input": "2000\n0947++3128", "output": "3\n"}, {"input": "2000\n09+74+3128", "... | code_stdio |
[
{
"content": "Princess'Marriage\n\nMarriage of a princess\n\nEnglish text is not available in this practice contest.\n\nA brave princess in a poor country, knowing that gambling payouts are determined by the parimutuel method, felt more familiar with gambling and was convinced of her victory in gambling. As a r... | [{"input": "2 8\n7 6\n4 10\n3 2\n5 10\n3 10\n5 10\n0 0", "output": "18\n110\n"}, {"input": "2 8\n7 6\n4 10\n3 3\n5 10\n3 10\n5 10\n0 0", "output": "18\n100\n"}, {"input": "2 8\n5 6\n5 5\n3 3\n4 10\n13 10\n5 10\n0 0", "output": "10\n190\n"}, {"input": "2 8\n5 6\n5 5\n3 3\n3 10\n13 10\n5 10\n0 0", "output": "10\n180\n"},... | code_stdio |
[
{
"content": "Ivan's classes at the university have just finished, and now he wants to go to the local CFK cafe and eat some fried chicken.\n\nCFK sells chicken chunks in small and large portions. A small portion contains 3 chunks; a large one — 7 chunks. Ivan wants to eat exactly x chunks. Now he wonders wheth... | [{"input": "100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100... | code_stdio |
[
{
"content": "Alice has learnt factorization recently. Bob doesn't think she has learnt it properly and hence he has decided to quiz her. Bob gives Alice a very large number and asks her to find out the number of factors of that number. To make it a little easier for her, he represents the number as a product o... | [{"input": "3\n3\n3 7 13\n3\n2 4 13\n2\n40 10", "output": "8\n8\n15\n"}, {"input": "3\n3\n3 7 13\n3\n2 4 13\n2\n40 12", "output": "8\n8\n24\n"}, {"input": "3\n3\n3 9 6\n3\n3 4 13\n2\n28 5", "output": "10\n12\n12\n"}, {"input": "3\n3\n6 5 14\n3\n2 12 6\n2\n8 6", "output": "24\n15\n10\n"}, {"input": "3\n3\n3 4 14\n3\n2 5... | code_stdio |
[
{
"content": "Stylish is a programming language whose syntax comprises names, that are sequences of Latin alphabet letters, three types of grouping symbols, periods ('.'), and newlines. Grouping symbols, namely round brackets ('(' and ')'), curly brackets ('{' and '}'), and square brackets ('[' and ']'), must m... | [{"input": "5 4\n(Folmow.my.style\n.........starting.from.round.brackets)\n{then.curly.brackets\n.....[.and.finally\n.......square.brackets.]}\n(Thank.you\n{for.showing.me\n[all\nthe.secrets]})\n4 2\n(This.time.I.will.show.you\n.........(how.to.use.round.brackets)\n.........[but.not.about.square.bsackets]\n.........{no... | code_stdio |
[
{
"content": "During the hypnosis session, Nicholas suddenly remembered a positive integer $n$, which doesn't contain zeros in decimal notation.\n\nSoon, when he returned home, he got curious: what is the maximum number of digits that can be removed from the number so that the number becomes not prime, that is,... | [{"input": "7\n3\n237\n5\n44444\n3\n337\n2\n35\n3\n773\n1\n4\n30\n626221626221626221626221626221\n", "output": "2\n27\n1\n4\n2\n33\n2\n35\n2\n77\n1\n4\n1\n6\n"}, {"input": "7\n3\n237\n5\n44444\n3\n337\n2\n35\n3\n773\n1\n8\n30\n626221626221626221626221626221\n", "output": "2\n27\n1\n4\n2\n33\n2\n35\n2\n77\n1\n8\n1\n6\n"... | code_stdio |
[
{
"content": "IT City company developing computer games invented a new way to reward its employees. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is divisible by all numbers from 2 ... | [{"input": "2558402827158016680\n", "output": "1015239217126197\n"}, {"input": "1000000000000000000\n", "output": "396825396825396\n"}, {"input": "1209365011581446835\n", "output": "479906750627558\n"}, {"input": "1155798879255295086\n", "output": "458650348910831\n"}, {"input": "1000000000000001000\n", "output": "3968... | code_stdio |
[
{
"content": "Let {\\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.\nFrom n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\\rm comb}(a_i,a_j) is maximized.\nIf there are multiple pairs that maximize the value, any of them is ac... | [{"input": "5\n20 13 1 4 20", "output": "20 13\n"}, {"input": "5\n36 13 1 8 10", "output": "36 13\n"}, {"input": "5\n36 13 1 8 17", "output": "36 17\n"}, {"input": "5\n1 10 -1 2 16", "output": "16 10\n"}, {"input": "5\n2 11 1 12 15", "output": "15 11\n"}, {"input": "5\n1 10 -1 2 24", "output": "24 10\n"}, {"input": "5\... | code_stdio |
[
{
"content": "Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome. \n\nA palindrome is a string that reads the same backward as forward, for example strings \"z\", \"aaa\", \"aba\", \"abccba\" are pa... | [{"input": "scfwrjevejrwfcs\n", "output": "YES\n"}, {"input": "thdaonpepdoadht\n", "output": "YES\n"}, {"input": "scfwrievejrwfcs\n", "output": "YES\n"}, {"input": "thdaodpepnoadht\n", "output": "YES\n"}, {"input": "jsfzcbnhsccuqsj\n", "output": "NO\n"}, {"input": "mhifbmmmmbmihm\n", "output": "YES\n"}, {"input": "cojh... | code_stdio |
[
{
"content": "When you play the game of thrones, you win, or you die. There is no middle ground.\n\nCersei Lannister, A Game of Thrones by George R. R. Martin\n\nThere are $n$ nobles, numbered from $1$ to $n$. Noble $i$ has a power of $i$. There are also $m$ \"friendships\". A friendship between nobles $a$ and ... | [{"input": "20 53\n1 2\n1 4\n1 5\n1 6\n1 7\n1 8\n1 20\n2 3\n2 6\n2 16\n2 17\n3 6\n3 18\n3 20\n4 6\n4 7\n4 8\n4 9\n4 14\n4 18\n5 11\n5 13\n5 17\n5 18\n5 19\n6 8\n6 13\n7 8\n7 10\n7 15\n7 17\n7 18\n8 15\n8 16\n9 10\n9 15\n10 11\n10 17\n10 20\n11 15\n11 16\n12 14\n12 15\n12 16\n12 19\n14 16\n14 19\n16 17\n16 19\n16 20\n17... | code_stdio |
[
{
"content": "You are given a sequence $a_1, a_2, \\dots, a_n$ consisting of $n$ integers.\n\nYou can choose any non-negative integer $D$ (i.e. $D \\ge 0$), and for each $a_i$ you can:\n\n add $D$ (only once), i. e. perform $a_i := a_i + D$, or subtract $D$ (only once), i. e. perform $a_i := a_i - D$, or lea... | [{"input": "100\n49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49 49 100 2 100 49 49... | code_stdio |
[
{
"content": "Polycarp takes part in a quadcopter competition. According to the rules a flying robot should:\n\n start the race from some point of a field, go around the flag, close cycle returning back to the starting point. \n\nPolycarp knows the coordinates of the starting point (x_1, y_1) and the coordin... | [{"input": "-100 -100\n-100 100\n", "output": "406\n"}, {"input": "-100 -100\n100 -100\n", "output": "406\n"}, {"input": "100 -100\n-100 -100\n", "output": "406\n"}, {"input": "-100 100\n-100 -100\n", "output": "406\n"}, {"input": "-100 100\n-100 -192\n", "output": "590\n"}, {"input": "101 -100\n-100 -100\n", "output":... | code_stdio |
[
{
"content": "Woken up by the alarm clock Igor the financial analyst hurried up to the work. He ate his breakfast and sat in his car. Sadly, when he opened his GPS navigator, he found that some of the roads in Bankopolis, the city where he lives, are closed due to road works. Moreover, Igor has some problems wi... | [{"input": "7 7\n.S.****\n...*.*.\n.****..\n.*.**.*\n..T*...\n***..*.\n**+****\n", "output": "YES\n"}, {"input": "7 7\n.S.****\n...*.*.\n.****..\n.*.**.*\n..T*...\n***..*.\n****+**\n", "output": "YES\n"}, {"input": "7 7\n.S.****\n...*.*.\n.****..\n.****..\n..T*...\n***..*.\n**+****\n", "output": "YES\n"}, {"input": "7 ... | code_stdio |
[
{
"content": "AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. ... | [{"input": "5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 1... | code_stdio |
[
{
"content": "The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.\n\nThe slogan of the company consists of n characters, so t... | [{"input": "100 50\n5B2N,CXCWOIWH71XV!HCFEUCN3U88JDRIFRO2VHY?!N.RGH.?W14X5S.Y00RIY6YA19BPD0T,WECXYI,O2RF1U4NX9,F5AVLPOYK\n", "output": "LEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT\nLEFT... | code_stdio |
[
{
"content": "Tomash keeps wandering off and getting lost while he is walking along the streets of Berland. It's no surprise! In his home town, for any pair of intersections there is exactly one way to walk from one intersection to the other one. The capital of Berland is very different!\n\nTomash has noticed t... | [{"input": "8 56\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n2 1\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n3 1\n3 2\n3 4\n3 5\n3 6\n3 7\n3 8\n4 1\n4 2\n4 3\n4 5\n4 6\n4 7\n4 8\n5 1\n5 2\n5 3\n5 4\n5 6\n5 7\n5 8\n6 1\n6 2\n6 3\n6 4\n6 5\n6 7\n6 8\n7 1\n7 2\n7 3\n7 4\n7 5\n7 6\n7 8\n8 1\n8 2\n8 3\n8 4\n8 5\n8 6\n8 7\n", "output": "840\n"},... | code_stdio |
[
{
"content": "Katie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems.\n\nToday is Shiro's birthday. She really loves pizza so she wants to invite her friends to the pizza restauran... | [{"input": "1000000000000000000\n", "output": "1000000000000000001\n"}, {"input": "1043714136496022950\n", "output": "1043714136496022951\n"}, {"input": "1837625121252532586\n", "output": "1837625121252532587\n"}, {"input": "1568485437674580780\n", "output": "1568485437674580781\n"}, {"input": "1000000000000010000\n", ... | code_stdio |
[
{
"content": "String can be called correct if it consists of characters \"0\" and \"1\" and there are no redundant leading zeroes. Here are some examples: \"0\", \"10\", \"1001\".\n\nYou are given a correct string s.\n\nYou can perform two different operations on this string: swap any pair of adjacent charact... | [{"input": "100\n1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n", "output": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n"}, {"input": "100\n10000000000000000000000000000000000000000000000000000000000000000... | code_stdio |
[
{
"content": "As you might know, cooking is the process of taking a food item and subjecting it to various processes(like heating, roasting, baking etc).\nA food item gets prepared after it has been subjected to exactly N processes.\nThe order in which the processes are applied matters(heating and then baking i... | [{"input": "3\n-2 2\n5 10\n1 11", "output": "2\n555841676\n110\n"}, {"input": "3\n-2 2\n4 15\n1 12", "output": "2\n286982263\n132\n"}, {"input": "3\n-16 2\n10 13\n1 6", "output": "2\n131267026\n30\n"}, {"input": "3\n-8 2\n10 13\n1 5", "output": "2\n131267026\n20\n"}, {"input": "3\n-16 2\n10 13\n1 3", "output": "2\n1312... | code_stdio |
[
{
"content": "Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string s. \n\nString p is called a substring of string s if you can read it starting from some position in the string s. For example, string \"aba\" has six substrings: \"a\", \"b\", \"a\", \"ab\", \"ba\", \"aba\".\n\nDr. Moriart... | [{"input": "ksmbytfyhhnstlecripupiwdhbkhfpfmimrbqgszohcqnezcybvwasxmkxfupvuecsctcpadccnqexsglwaiyxcoyheefcjmdedesgjqdtqgrvfjonzesffousooutsjumrxl\nhgjqihcfbnmgufonaiudbjegexexthrzcdkuimwogpbyovemztzcmqnrbhabxyyxyfuzpyhjgnioexbezzupcxlyzuuncstiiqsjzdtqppqhxilvqimlpjejiqbwpeekzweeyvthvjffgfvqauqrugajjjzibgzhxphcvtncjzecb... | code_stdio |
[
{
"content": "In order to put away old things and welcome a fresh new year, a thorough cleaning of the house is a must.\n\nLittle Tommy finds an old polynomial and cleaned it up by taking it modulo another. But now he regrets doing this...\n\nGiven two integers p and k, find a polynomial f(x) with non-negative ... | [{"input": "1000000000000000000 2\n", "output": "61\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 0 1 0 0 1 1 1 0 0 0 0 1 0 0 0 1 0 0 1 \n"}, {"input": "1000000000000000000 2\n", "output": "61\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 0 1... | code_stdio |
[
{
"content": "Stick n circular stickers with a radius of 1 on a square origami paper with a side length of 10. The stickers can be stacked. Create a program that reads the coordinates of the position where the stickers are to be attached and outputs the number of stickers at the place where the stickers overlap... | [{"input": "15\n3.13979,8.51743\n2.39506,3.84915\n2.68432,5.39095\n5.61904,9.16332\n7.85653,4.75593\n2.84021,5.41511\n1.79500,8.59211\n7.55389,8.17604\n4.70665,4.66125\n1.63470,4.42538\n7.34959,4.61981\n5.09003,8.11122\n5.24373,1.30066\n0.13517,1.83659\n7.57313,1.58150\n0", "output": "4\n"}, {"input": "15\n3.13979,8.51... | code_stdio |
[
{
"content": "This is the harder version of the problem. In this version, 1 ≤ n, m ≤ 2⋅10^5. You can hack this problem if you locked it. But you can hack the previous problem only if you locked both problems.\n\nYou are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained by... | [{"input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 2\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n1\n3\n2\n4\n1\n3\n2\n4\n3\n4\n3\n4\n"}, {"input": "5\n3 1 4 1 2\n15\n5 5\n5 4\n5 3\n5 3\n5 1\n4 4\n4 3\n4 2\n4 1\n3 3\n3 2\n3 1\n2 2\n2 1\n1 1\n", "output": "2\n1\n4\n4\n3\n2\n4\n1\n3\n2\n4\n3... | code_stdio |
[
{
"content": "Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and a closing curved bracket at the end of the line. \n\nUnfort... | [{"input": "{a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a}\n", "ou... | code_stdio |
[
{
"content": "Valera the horse lives on a plane. The Cartesian coordinate system is defined on this plane. Also an infinite spiral is painted on the plane. The spiral consists of segments: [(0, 0), (1, 0)], [(1, 0), (1, 1)], [(1, 1), ( - 1, 1)], [( - 1, 1), ( - 1, - 1)], [( - 1, - 1), (2, - 1)], [(2, - 1), ... | [{"input": "37 -100\n", "output": "400\n"}, {"input": "100 100\n", "output": "397\n"}, {"input": "-96 -96\n", "output": "383\n"}, {"input": "100 100\n", "output": "397\n"}, {"input": "37 -100\n", "output": "400\n"}, {"input": "-96 -96\n", "output": "383\n"}, {"input": "56 -100\n", "output": "400\n"}, {"input": "99 100\... | code_stdio |
[
{
"content": "Polycarp loves geometric progressions — he collects them. However, as such progressions occur very rarely, he also loves the sequences of numbers where it is enough to delete a single element to get a geometric progression.\n\nIn this task we shall define geometric progressions as finite sequences... | [{"input": "10\n-10000 -10000 -10000 -10000 10000 -10000 -10000 -10000 -10000 10000\n", "output": "2\n"}, {"input": "10\n-10000 -10000 -10000 -10000 10000 -10000 -10000 -10000 -12453 10000\n", "output": "2\n"}, {"input": "14\n-1 -2 -4 -8 -16 -32 -64 -128 -256 -512 -1024 -2048 -4096 -8192\n", "output": "0\n"}, {"input":... | code_stdio |
[
{
"content": "Create a program to determine the positional relationship between a triangle and a circle on a plane. All target figures shall include boundaries. The triangle is given the position of three vertices, and the circle is given the position of the center and the radius. The position is given by a set... | [{"input": "1 1\n6 0\n3 3\n3 0\n3\n3 11\n1 3\n11 16\n12 4\n5\n15 4\n17 12\n22 5\n7 22\n3\n5 13\n16 2\n16 9\n5 3\n1\n0 0", "output": "b\nd\nd\nd\n"}, {"input": "1 1\n6 0\n3 3\n3 2\n3\n3 11\n1 3\n11 16\n12 7\n5\n15 3\n17 7\n22 5\n7 12\n4\n5 13\n13 2\n16 9\n5 3\n2\n0 0", "output": "c\nd\nd\nd\n"}, {"input": "3 2\n3 1\n3 3... | code_stdio |
[
{
"content": "This problem is an extension of the problem \"Wonderful Coloring - 1\". It has quite many differences, so you should read this statement completely.\n\nRecently, Paul and Mary have found a new favorite sequence of integers $a_1, a_2, \\dots, a_n$. They want to paint it using pieces of chalk of $k$... | [{"input": "12\n10 3\n3 1 1 1 1 3 3 10 10 2\n4 4\n1 1 1 2\n1 1\n1\n13 1\n5 1 4 1 5 9 2 11 1 3 5 8 9\n13 2\n3 1 4 1 5 9 2 6 5 3 4 7 9\n13 3\n3 1 4 1 5 9 2 6 5 3 5 8 9\n10 3\n3 1 1 1 1 10 3 10 10 2\n4 4\n1 1 1 1\n1 1\n1\n13 1\n5 1 4 1 10 9 2 11 5 3 5 8 9\n13 2\n3 1 4 1 5 9 2 6 5 3 5 8 9\n13 3\n3 1 4 1 5 9 2 8 5 3 5 8 9\n... | code_stdio |
[
{
"content": "Berland annual chess tournament is coming!\n\nOrganizers have gathered 2·n chess players who should be divided into two teams with n people each. The first team is sponsored by BerOil and the second team is sponsored by BerMobile. Obviously, organizers should guarantee the win for the team of BerO... | [{"input": "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | code_stdio |
[
{
"content": "The mobile application store has a new game called \"Subway Roller\".\n\nThe protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of three rows and n columns. At the beginning of the game the hero is ... | [{"input": "1\n100 26\ns................PPPP.CCCCC..UUUUUU.........YYYQQQQQQQ...GGGGG............MMM.....JJJJ..............\n.OOOOOO....EEE....................................................SSSSSS........LLLLLL......NNNIIII.\n......FFFFFF...VVVV..ZZZBBB...KKKKK..WWWWWWWXXX..RRRRRRR......AAAAADDDDDDD.HHH............TTT... | code_stdio |
[
{
"content": "You are given names of two days of the week.\n\nPlease, determine whether it is possible that during some non-leap year the first day of some month was equal to the first day of the week you are given, while the first day of the next month was equal to the second day of the week you are given. Bot... | [{"input": "wednesday\nwednesday\n", "output": "YES\n"}, {"input": "wednesday\nwednesday\n", "output": "YES\n"}, {"input": "wednesday\nsaturday\n", "output": "YES\n"}, {"input": "wednesday\nsaturday\n", "output": "YES\n"}, {"input": "wednesday\nsaturday\n", "output": "YES\n"}, {"input": "wednesday\nthursday\n", "output... | code_stdio |
[
{
"content": "Mr. A came to Aizu for sightseeing. You can overlook the Aizu Basin from the window of the hotel where you stayed. As I was looking at the scenery, I noticed a piece of the photo on the floor. Apparently I took the outside view from the window. \"Which area did you take?\" A asked, holding the pho... | [{"input": "8 4\n2 1 3 1 1 5 1 3\n2 3 2 4 1 0 2 1\n0 3 -1 2 1 1 4 2\n1 2 3 2 1 1 5 4\n0 2 0 1 1 3 2 1\n1 3 1 2 2 4 3 2\n5 1 2 1 4 1 1 5\n4 1 1 -1 1 2 2 1\n2 -1 -1 -1\n0 3 -1 -1\n-1 2 2 4\n-1 1 -1 1\n5 3\n1 0 2 3 5\n2 3 7 2 1\n2 5 4 2 2\n8 9 0 3 3\n3 6 0 4 7\n-1 -1 2\n-1 3 5\n0 4 -1\n0 0", "output": "4 2\nNA\n"}, {"inp... | code_stdio |
[
{
"content": "There are N strings of lowercase alphabet only. The i-th string is S_i. Every string is unique.\n\nProvide answers for the Q queries below. The i-th query has the following format:\n\nQuery: An integer k_i and a string p_{i,1}p_{i,2}...p_{i,26} that results from permuting {`a`,`b`,...,`z`} are giv... | [{"input": "8\nabrakatabra\nabadaba\nabracadabra\natcoder\ngrand\ncontest\nababa\na\n6\n3 abcdefghijklmnopqrstuvwxyz\n6 qwertyuiopasdfhgjklzxcvbnm\n8 poiuytrewqlkjhgfdsamnbvcxz\n2 qazwsxedcrfvtgbyhnujmikolp\n1 plokmijnuhbygvtfcrdxeszwaq\n4 mnbvcxzasdfghjklpoiuytrewq", "output": "4\n8\n2\n3\n4\n7\n"}, {"input": "8\nabra... | code_stdio |
[
{
"content": "To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives.\n\nHe is famous across the country for his ability to foresee the future. He already knows that the pri... | [{"input": "7\n100 130 243 130 115 115 150", "output": "3165\n"}, {"input": "7\n100 130 243 130 115 115 271", "output": "5706\n"}, {"input": "7\n110 130 243 130 115 115 271", "output": "5161\n"}, {"input": "7\n110 130 136 130 115 115 271", "output": "2794\n"}, {"input": "7\n100 130 130 130 11 115 150", "output": "17702... | code_stdio |
[
{
"content": "Takahashi loves the number 7 and multiples of K.\nWhere is the first occurrence of a multiple of K in the sequence 7,77,777,\\ldots? (Also see Output and Sample Input/Output below.)\nIf the sequence contains no multiples of K, print -1 instead.\n\n-----Constraints-----\n - 1 \\leq K \\leq 10^6\n -... | [{"input": "999983\n", "output": "999982\n"}, {"input": "999863\n", "output": "999862\n"}, {"input": "999953\n", "output": "999952\n"}, {"input": "531441\n", "output": "531441\n"}, {"input": "823543\n", "output": "100842\n"}, {"input": "823543\n", "output": "100842\n"}, {"input": "224593\n", "output": "111194\n"}, {"in... | code_stdio |
[
{
"content": "Little penguin Polo adores strings. But most of all he adores strings of length n.\n\nOne day he wanted to find a string that meets the following conditions: The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct. No tw... | [{"input": "93563 25\n", "output": "abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab... | code_stdio |
[
{
"content": "Little girl Tanya climbs the stairs inside a multi-storey building. Every time Tanya climbs a stairway, she starts counting steps from $1$ to the number of steps in this stairway. She speaks every number aloud. For example, if she climbs two stairways, the first of which contains $3$ steps, and th... | [{"input": "48\n1 2 3 4 1 2 3 1 1 2 3 1 2 3 4 1 1 2 3 4 1 2 3 4 1 2 3 4 1 1 1 1 2 1 2 1 1 2 1 2 1 2 3 1 1 1 2 1\n", "output": "22\n4 3 1 3 4 1 4 4 4 1 1 1 2 2 1 2 2 3 1 1 2 1 "}, {"input": "48\n1 2 3 4 1 2 3 1 1 2 1 1 2 3 4 1 1 2 3 4 1 2 3 4 1 2 3 4 1 1 2 1 2 1 2 1 1 1 1 2 1 2 3 1 2 1 2 1\n", "output": "22\n4 3 1 2 1 4... | code_stdio |
[
{
"content": "Given are two strings s and t consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the following condition is finite, and find the maximum value of such i if the number is finite.\n - There exists a non-negative integer j such that the concatenatio... | [{"input": "aa\naaaaaaa\n", "output": "-1\n"}, {"input": "abcabab\nab\n", "output": "3\n"}, {"input": "aba\nbaaab\n", "output": "0\n"}, {"input": "aa\naaaaaaa", "output": "-1"}, {"input": "aa\nabaaaaa", "output": "0"}, {"input": "abcaabb\nab", "output": "1"}, {"input": "aa\naaaaaba", "output": "0"}, {"input": "accaabb\... | code_stdio |
[
{
"content": "Read problems statements in Mandarin Chinese and Russian as well. \n\nChef wants to implement wildcard pattern matching supporting only the wildcard '?'. The wildcard character '?' can be substituted by any single lower case English letter for matching. He has two strings X and Y of equal length, ... | [{"input": "2\ns?o?r\nsco??\nstor?\nsco??", "output": "Yes\nNo\n"}, {"input": "2\ns?or?\nsco??\nstor?\nsco??", "output": "Yes\nNo\n"}, {"input": "2\ns?or?\nsco??\nstor?\nsco??", "output": "Yes\nNo"}, {"input": "2\nr?o?s\nsco??\nstor?\nsco??", "output": "No\nNo\n"}, {"input": "2\nr?o?s\nsco??\n?rots\nsco??", "output": "... | code_stdio |
[
{
"content": "Your friend recently came up with a card game called UT-Rummy.\n\nThe cards used in this game are numbered red, green, or blue and any number from 1 to 9. Each player in this game has 9 cards in his or her hand, chooses one from his or her hand, discards it, and draws one from the deck instead. In... | [{"input": "5\n1 2 3 6 4 5 7 13 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nR R R R R Q R R R\n1 3 3 4 4 4 5 5 5\nR R B R R R R R R\n1 1 1 3 4 5 6 6 10\nR R B G G G R R S\n2 2 2 3 3 3 1 1 2\nR G B R G B R G B", "output": "0\n0\n0\n0\n0\n"}, {"input": "5\n1 2 3 6 4 5 7 13 7\nR R R R R R G G G\n1 2 2 3 4 4 4 4 5\nQ R R R R ... | code_stdio |
[
{
"content": "Dwarfs have planted a very interesting plant, which is a triangle directed \"upwards\". This plant has an amusing feature. After one year a triangle plant directed \"upwards\" divides into four triangle plants: three of them will point \"upwards\" and one will point \"downwards\". After another ye... | [{"input": "1000000000000000000\n", "output": "899770636\n"}, {"input": "1221245149414588849\n", "output": "459720998\n"}, {"input": "1033757552205836488\n", "output": "556130197\n"}, {"input": "1365148398628465905\n", "output": "906250341\n"}, {"input": "1000000000001000000\n", "output": "351480341\n"}, {"input": "115... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ integers. Indices of the array start from zero (i. e. the first element is $a_0$, the second one is $a_1$, and so on).\n\nYou can reverse at most one subarray (continuous subsegment) of this array. Recall that the subarray of $a$ with borders $l$ and $r... | [{"input": "4\n8\n1 3 3 4 11 6 2 9\n5\n1 2 1 2 1\n10\n5 13 6 5 14 0 4 9 13 5\n4\n0 1 2 1\n", "output": "24\n5\n50\n3\n"}, {"input": "4\n8\n0 4 3 6 11 6 2 9\n5\n1 2 1 2 1\n10\n5 13 6 5 14 0 4 9 13 5\n4\n0 1 2 1\n", "output": "25\n5\n50\n3\n"}, {"input": "4\n8\n1 3 3 6 11 6 2 9\n5\n1 2 1 2 1\n10\n5 13 6 5 14 0 4 9 13 5\n... | code_stdio |
[
{
"content": "You are given a directed acyclic graph, consisting of $n$ vertices and $m$ edges. The vertices are numbered from $1$ to $n$. There are no multiple edges and self-loops.\n\nLet $\\mathit{in}_v$ be the number of incoming edges (indegree) and $\\mathit{out}_v$ be the number of outgoing edges (outdegr... | [{"input": "10 45\n3 8\n3 7\n3 5\n3 2\n3 1\n3 4\n3 10\n3 6\n3 9\n8 7\n8 5\n8 2\n8 1\n8 4\n8 10\n8 6\n8 9\n7 5\n7 2\n7 1\n7 4\n7 10\n7 6\n7 9\n5 2\n5 1\n5 4\n5 10\n5 6\n5 9\n2 1\n2 4\n2 10\n2 6\n2 9\n1 4\n1 10\n1 6\n1 9\n4 10\n4 6\n4 9\n10 6\n10 9\n6 9\n", "output": "8\n"}, {"input": "200000 12\n137434 3309\n195674 1635... | code_stdio |
[
{
"content": "Kuro and Shiro are playing with a board composed of n squares lining up in a row.\nThe squares are numbered 1 to n from left to right, and Square s has a mark on it.\nFirst, for each square, Kuro paints it black or white with equal probability, independently from other squares. Then, he puts on Sq... | [{"input": "7775\n", "output": "499126064\n499126064\n796234435\n114971967\n891826170\n38460928\n746758804\n102098624\n582205169\n762199467\n509915249\n602954502\n392594249\n215817236\n170876474\n643293880\n150463555\n628074695\n355316779\n513918741\n157394975\n757039573\n277888730\n825789360\n896475652\n681510732\n825... | code_stdio |
[
{
"content": "Example\n\nInput\n\n3\ny 7\ny 6\nn 5\n\n\nOutput\n\n1\n\nWrite Python code to solve this problem. Your program should read the input from stdin and write the output to stdout. Enclose your complete solution in a single ```python code block.",
"role": "user"
}
] | [{"input": "3\ny 11\ny 3\nn 10", "output": "1\n"}, {"input": "3\ny 11\nx 3\nn 10", "output": "1\n"}, {"input": "3\nx 2\ny 10\nn 10", "output": "1\n"}, {"input": "3\ny 11\nw 3\nn 10", "output": "1\n"}, {"input": "3\nx 0\ny 10\nn 10", "output": "1\n"}, {"input": "3\ny 0\ny 10\nn 10", "output": "1\n"}, {"input": "3\ny 11\... | code_stdio |
[
{
"content": "A bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person.\n\nYou have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of n (n ≥ 3) positive distinct integers (i.e. different, no duplicates are allowed).\n\nFind the larg... | [{"input": "4\n3\n8 0 2\n4\n6 9 7 2\n9\n1 2 3 4 5 1 7 8 9\n3\n39 242 165\n", "output": "3\n1 2 3\n4\n1 2 3 4\n9\n1 2 3 4 5 6 7 8 9\n3\n1 2 3\n"}, {"input": "4\n3\n8 1 2\n4\n6 9 4 6\n9\n1 2 3 4 5 1 7 8 13\n3\n200 199 198\n", "output": "2\n1 3\n4\n1 2 3 4\n9\n1 2 3 4 5 6 7 8 9\n3\n1 2 3\n"}, {"input": "4\n3\n8 1 2\n4\n6 ... | code_stdio |
[
{
"content": "Fukushima Prefecture is also famous for producing fruits, and among them, peaches and apples boast one of the highest production volumes in Japan. By the way, when I made a print manuscript of an English pamphlet for sale, I mistakenly wrote the description about apples and the description about p... | [{"input": "the cost of one peach is higher than th`t of one apple.", "output": "the cost of one apple is higher than th`t of one peach.\n"}, {"input": "the cost of ooe peach is higher than th`t of one apple.", "output": "the cost of ooe apple is higher than th`t of one peach.\n"}, {"input": "the cost of ooe peach is h... | code_stdio |
[
{
"content": "Akaki, a patissier, can make N kinds of doughnut using only a certain powder called \"Okashi no Moto\" (literally \"material of pastry\", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she ne... | [{"input": "5 3000\n150\n130\n150\n130\n110\n", "output": "26\n"}, {"input": "5 3000\n150\n130\n150\n130\n100", "output": "28\n"}, {"input": "5 3000\n236\n130\n150\n130\n100", "output": "27\n"}, {"input": "5 3000\n150\n173\n150\n212\n101", "output": "26\n"}, {"input": "5 3000\n50\n130\n150\n130\n100", "output": "53\n"}... | code_stdio |
[
{
"content": "You are given an array $a$ consisting of $n$ positive integers.\n\nYou are allowed to perform this operation any number of times (possibly, zero):\n\nchoose an index $i$ ($2 \\le i \\le n$), and change $a_i$ to $a_i - a_{i-1}$.\n\nIs it possible to make $a_i=0$ for all $2\\le i\\le n$?\n\n\n-----I... | [{"input": "1\n100\n1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n", "output": "YES\n"}, {"input": "10\n2\n1 1\n10\n1 2 3 4 5 6 7 8 9 10\n2\n1000000000 1\n2\n1000000... | code_stdio |
[
{
"content": "In a new version of the famous Pinball game, one of the most important parts of the game field is a sequence of n bumpers. The bumpers are numbered with integers from 1 to n from left to right. There are two types of bumpers. They are denoted by the characters '<' and '>'. When the ball hits the b... | [{"input": "100\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", "output": "100\n"}, {"input": "100\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n", "output": "100\n"}, {"input": "100\n<<<<<<<<<<<<<<<<<<<<<... | code_stdio |
[
{
"content": "You are given two integers a and b. In one turn, you can do one of the following operations: \n\n * Take an integer c (c > 1 and a should be divisible by c) and replace a with a/c; \n * Take an integer c (c > 1 and b should be divisible by c) and replace b with b/c. \n\n\n\nYour goal is to make ... | [{"input": "8\n36 48 2\n36 48 3\n36 48 4\n2 8 1\n2 8 2\n1000000000 1000000000 1000000000\n1 2 1\n2 2 2\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\n"}, {"input": "8\n36 48 2\n36 48 3\n36 48 4\n2 8 1\n2 8 2\n1000000000 1000000000 1000100000\n1 2 1\n2 1 1\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\nYES\nYES\n"},... | code_stdio |
[
{
"content": "Kuro has recently won the \"Most intelligent cat ever\" contest. The three friends then decided to go to Katie's home to celebrate Kuro's winning. After a big meal, they took a small break then started playing games.\n\nKuro challenged Katie to create a game with only a white paper, a pencil, a pa... | [{"input": "50 1\n-1 -1 -1 -1 -1 0 -1 -1 -1 0 1 0 -1 0 1 -1 -1 -1 1 0 1 -1 0 1 0 1 0 0 1 1 -1 1 -1 -1 1 1 -1 -1 0 -1 -1 1 -1 1 -1 1 1 0 0 -1\n", "output": "279519499\n"}, {"input": "50 1\n-1 -1 -1 -1 -1 0 -1 -1 -1 0 1 0 -1 0 1 -1 -1 -1 1 0 1 -1 0 1 0 1 0 0 0 1 -1 1 -1 -1 1 1 -1 -1 0 -1 -1 1 -1 1 -1 1 1 0 0 -1\n", "outp... | code_stdio |
[
{
"content": "Valera has array a, consisting of n integers a_0, a_1, ..., a_{n} - 1, and function f(x), taking an integer from 0 to 2^{n} - 1 as its single argument. Value f(x) is calculated by formula $f(x) = \\sum_{i = 0}^{n - 1} a_{i} \\cdot b i t(i)$, where value bit(i) equals one if the binary representati... | [{"input": "43\n761 2165 6131 8874 8980 119 8300 9006 6278 7582 4740 6321 10042 6869 3788 17625 1707 5070 3809 335 2494 8255 1123 1430 190 5712 7313 3286 15423 133 1032 3067 8043 5297 5398 12168 13897 2141 1436 10227 362 8438 2300\n0111011100100011110010011110011011010001101\n", "output": "235367\n"}, {"input": "43\n76... | code_stdio |
[
{
"content": "AtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K.\nHere, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square.\nBelow is an example of a checked pattern ... | [{"input": "6 2\n1 2 B\n2 1 W\n2 2 B\n1 0 B\n0 6 W\n4 5 W\n", "output": "4\n"}, {"input": "6 2\n0 2 B\n2 1 W\n0 2 B\n1 0 B\n0 6 W\n-1 5 W", "output": "4\n"}, {"input": "3 2\n0 2 B\n2 1 W\n0 2 B\n1 0 B\n0 6 W\n-1 5 W", "output": "3\n"}, {"input": "6 2\n1 2 B\n2 1 W\n0 2 B\n1 0 B\n0 6 W\n4 5 W", "output": "3\n"}, {"input... | code_stdio |
[
{
"content": "You are given a sequence of length N: A_1, A_2, ..., A_N.\nFor each integer i between 1 and N (inclusive), answer the following question:\n - Find the maximum value among the N-1 elements other than A_i in the sequence.\n\n-----Constraints-----\n - 2 \\leq N \\leq 200000\n - 1 \\leq A_i \\leq 2000... | [{"input": "2\n200000\n1\n", "output": "1\n200000\n"}, {"input": "3\n-1\n0\n13", "output": "13\n13\n0\n"}, {"input": "3\n-2\n0\n16", "output": "16\n16\n0\n"}, {"input": "3\n0\n1\n13", "output": "13\n13\n1\n"}, {"input": "3\n0\n1\n12", "output": "12\n12\n1\n"}, {"input": "3\n1\n2\n12", "output": "12\n12\n2\n"}, {"input"... | code_stdio |
[
{
"content": "We arrange the numbers between 1 and N (1 <= N <= 10000) in increasing order and decreasing order like this:\n\n\n1 2 3 4 5 6 7 8 9 . . . N\nN . . . 9 8 7 6 5 4 3 2 1\n\n\nTwo numbers faced each other form a pair. Your task is to compute the number of pairs P such that both numbers in the pairs ar... | [{"input": "1\n10\n13\n373", "output": "0\n0\n3\n20\n"}, {"input": "1\n175\n19\n12", "output": "0\n14\n4\n2\n"}, {"input": "1\n175\n19\n16", "output": "0\n14\n4\n0\n"}, {"input": "1\n12\n7\n115", "output": "0\n2\n2\n12\n"}, {"input": "1\n12\n9\n115", "output": "0\n2\n3\n12\n"}, {"input": "1\n10\n7\n189", "output": "0\n... | code_stdio |
[
{
"content": "Given is a string S representing the day of the week today.\nS is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.\nAfter how many days is the next Sunday (tomorrow or later)?\n\n-----Constraints-----\n - S is SUN, MON, TUE... | [{"input": "SAT\n", "output": "1\n"}, {"input": "SUN\n", "output": "7\n"}, {"input": "FRI\n", "output": "2\n"}, {"input": "MON\n", "output": "6\n"}, {"input": "THU\n", "output": "3\n"}, {"input": "TUE\n", "output": "5\n"}, {"input": "WED\n", "output": "4\n"}, {"input": "SUN", "output": "7"}, {"input": "SAT", "output": ... | code_stdio |
[
{
"content": "Given is a positive integer N.\nHow many tuples (A,B,C) of positive integers satisfy A \\times B + C = N?\n\n-----Constraints-----\n - 2 \\leq N \\leq 10^6\n - All values in input are integers.\n\n-----Input-----\nInput is given from Standard Input in the following format:\nN\n\n-----Output-----\... | [{"input": "1000000\n", "output": "13969985\n"}, {"input": "877046\n", "output": "12137262\n"}, {"input": "999931\n", "output": "13968881\n"}, {"input": "999901\n", "output": "13968459\n"}, {"input": "999927\n", "output": "13968843\n"}, {"input": "105008\n", "output": "1230314\n"}, {"input": "333589\n", "output": "4293... | code_stdio |
[
{
"content": "Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters.\n\nLet A be a set of positions in the string. Let's call it pretty if following conditions are met: letters on positions from A in the string are all dist... | [{"input": "200\nrsgraosldglhdoorwhkrsehjpuxrjuwgeanjgezhekprzarelduuaxdnspzjuooguuwnzkowkuhzduakdrzpnslauejhrrkalwpurpuuswdgeadlhjwzjgegwpknepazwwleulppwrlgrgedlwdzuodzropsrrkxusjnuzshdkjrxxpgzanzdrpnggdwxarpwohxdepJ\n", "output": "17\n"}, {"input": "200\nMkuxcDWdcnqsrlTsejehQKrTwoOBRCUAywqSnZkDLRmVBDVoOqdZHbrInQQyeRF... | code_stdio |
[
{
"content": "Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.\n\nFor example, let's say that Vitaly... | [{"input": "3 6 1000000\n", "output": "786609214\n"}, {"input": "8 9 1000000\n", "output": "573697309\n"}, {"input": "1 2 1000000\n", "output": "786609214\n"}, {"input": "1 2 1000000\n", "output": "786609214\n"}, {"input": "8 9 1000000\n", "output": "573697309\n"}, {"input": "3 6 1000000\n", "output": "786609214\n"}, {... | code_stdio |
[
{
"content": "Given are positive integers A and B.\nLet us choose some number of positive common divisors of A and B.\nHere, any two of the chosen divisors must be coprime.\nAt most, how many divisors can we choose?Definition of common divisor\nAn integer d is said to be a common divisor of integers x and y whe... | [{"input": "1000000000000 1000000000000\n", "output": "3\n"}, {"input": "642507465600 642507465600\n", "output": "10\n"}, {"input": "963761198400 963761198400\n", "output": "10\n"}, {"input": "200560490130 200560490130\n", "output": "12\n"}, {"input": "698726868840 271727115660\n", "output": "11\n"}, {"input": "2508779... | code_stdio |
[
{
"content": "Your program fails again. This time it gets \"Wrong answer on test 233\".\n\nThis is the easier version of the problem. In this version $1 \\le n \\le 2000$. You can hack this problem only if you solve and lock both problems.\n\nThe problem is about a test containing $n$ one-choice-questions. Each... | [{"input": "98 102\n79 30 51 48 80 91 32 16 39 54 79 17 48 24 8 66 9 94 45 14 85 82 54 89 44 92 26 62 47 5 75 33 102 24 63 39 91 31 33 55 81 63 81 87 26 19 41 108 46 56 91 97 67 30 94 81 40 5 22 8 23 34 5 77 43 66 67 15 7 154 26 22 19 71 26 82 69 52 40 4 98 27 63 74 68 74 55 75 25 51 18 100 22 66 50 38 43 43\n", "outpu... | code_stdio |
[
{
"content": "problem\n\nA mysterious $ X $ [cm] plant grows in one place. This plant has the following mysterious properties.\n\n* Say \"nobiro\" to this plant and it will grow $ A $ [cm].\n* Say \"tidime\" to this plant and it will grow $ B $ [cm].\n* If you say \"karero\" to this plant, it will be $ 0 $ [cm]... | [{"input": "109 30 5\n0\norioan\nnobiro\nuifimd", "output": "109\n"}, {"input": "112 30 9\n0\norioan\nniboro\ntieimd", "output": "112\n"}, {"input": "84 122 10\n0\noobrjn\nonciro\nudfimi", "output": "84\n"}, {"input": "17 122 12\n0\nnjrbop\nnndiro\nudfimi", "output": "17\n"}, {"input": "20 122 12\n0\nnjrbop\nnndiro\nud... | code_stdio |
[
{
"content": "Nick's company employed n people. Now Nick needs to build a tree hierarchy of «supervisor-surbodinate» relations in the company (this is to say that each employee, except one, has exactly one supervisor). There are m applications written in the following form: «employee ai is ready to become a sup... | [{"input": "7\n10 0 4 7 3 8 6\n10\n3 2 4\n6 4 3\n6 5 1\n1 2 1\n6 7 6\n7 3 9\n1 6 3\n3 2 1\n6 4 4\n1 4 4\n", "output": "23\n"}, {"input": "7\n10 0 4 7 3 8 6\n10\n3 2 4\n6 4 3\n6 5 1\n1 2 1\n6 7 6\n7 3 9\n1 6 3\n3 2 1\n6 4 7\n1 4 4\n", "output": "23\n"}, {"input": "6\n10 2 4 3 1 6\n10\n1 4 10\n1 6 9\n6 4 1\n4 2 5\n4 5 7\... | code_stdio |
[
{
"content": "There are $b$ boys and $g$ girls participating in Olympiad of Metropolises. There will be a board games tournament in the evening and $n$ participants have accepted the invitation. The organizers do not know how many boys and girls are among them.\n\nOrganizers are preparing red badges for girls a... | [{"input": "100\n200\n150\n", "output": "101\n"}, {"input": "300\n299\n300\n", "output": "300\n"}, {"input": "199\n199\n199\n", "output": "200\n"}, {"input": "297\n297\n298\n", "output": "297\n"}, {"input": "299\n259\n300\n", "output": "259\n"}, {"input": "288\n188\n300\n", "output": "177\n"}, {"input": "300\n299\n300\... | code_stdio |
[
{
"content": "Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below. \n\nAlice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the ... | [{"input": "1000000\n", "output": "998677\n"}, {"input": "908209\n", "output": "453632\n"}, {"input": "999958\n", "output": "250008\n"}, {"input": "570570\n", "output": "285282\n"}, {"input": "959878\n", "output": "239978\n"}, {"input": "959806\n", "output": "239958\n"}, {"input": "959818\n", "output": "239958\n"}, {"i... | code_stdio |
[
{
"content": "problem\n\nGiven a sequence $ a_i $ of length $ N $. Output all integers $ K (1 \\ le K \\ le N) $ that satisfy the following conditions.\n\nCondition: Well sorted $ a_1, \\ cdots, a_K $ matches $ a_ {N-K + 1}, \\ cdots, a_N $.\n\n\n\n\n\nExample\n\nInput\n\n8\n5 2 4 9 4 9 2 5\n\n\nOutput\n\n1 2 4... | [{"input": "8\n0 1 1 -24 -1 1 1 0", "output": "1 2 3 5 6 7 8\n"}, {"input": "8\n-1 0 12 16 3 1 0 -1", "output": "1 2 6 7 8\n"}, {"input": "8\n-1 0 12 8 3 1 0 -1", "output": "1 2 6 7 8\n"}, {"input": "8\n5 2 4 4 4 14 2 5", "output": "1 2 6 7 8\n"}, {"input": "8\n5 2 4 9 4 9 2 5", "output": "1 2 4 6 7 8"}, {"input": "8\n... | code_stdio |
[
{
"content": "Takahashi is doing a research on sets of points in a plane. Takahashi thinks a set S of points in a coordinate plane is a good set when S satisfies both of the following conditions:\n\n* The distance between any two points in S is not \\sqrt{D_1}.\n* The distance between any two points in S is not... | [{"input": "33 4 2", "output": "0 0\n0 1\n0 4\n0 5\n0 8\n0 9\n0 12\n0 13\n0 16\n0 17\n0 20\n0 21\n0 24\n0 25\n0 28\n0 29\n0 32\n0 33\n0 36\n0 37\n0 40\n0 41\n0 44\n0 45\n0 48\n0 49\n0 52\n0 53\n0 56\n0 57\n0 60\n0 61\n0 64\n0 65\n2 2\n2 3\n2 6\n2 7\n2 10\n2 11\n2 14\n2 15\n2 18\n2 19\n2 22\n2 23\n2 26\n2 27\n2 30\n2 31... | code_stdio |
[
{
"content": "Let's consider one interesting word game. In this game you should transform one word into another through special operations. \n\nLet's say we have word w, let's split this word into two non-empty parts x and y so, that w = xy. A split operation is transforming word w = xy into word u = yx. For ex... | [{"input": "dkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjijdkjij\ndddkikjjidkkidijjjjkkjjikjdikiidijjikikjijjiijdikkjjjiddjjijkkkjkiijijkijdjjikikdjjjijdddjkjjdij... | code_stdio |
[
{
"content": "Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.\n\nAll characters in this game are lowercase English letters. There are two players: Mister B and his competitor.\n\nInitially the players have a ... | [{"input": "12 12 876543210 1000000000\n", "output": "13"}, {"input": "10 12 220000011 220000032\n", "output": "11"}, {"input": "3 10 498103029 1063506054\n", "output": "4\n"}, {"input": "13 8 654321109 654321126\n", "output": "13\n"}, {"input": "5 6 1000000000 1000001000\n", "output": "6\n"}, {"input": "3 12 498103029... | code_stdio |
[
{
"content": "You are an environmental activist at heart but the reality is harsh and you are just a cashier in a cinema. But you can still do something!\n\nYou have $n$ tickets to sell. The price of the $i$-th ticket is $p_i$. As a teller, you have a possibility to select the order in which the tickets will be... | [{"input": "4\n1\n100\n50 1\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n10 2\n15 3\n107\n3\n1000000000 1000000000 1000000000\n50 1\n50 1\n3000000000\n5\n200 100 100 100 100\n69 5\n31 2\n90\n", "output": "-1\n6\n3\n4\n"}, {"input": "4\n1\n100\n50 1\n49 1\n100\n8\n100 200 100 200 100 200 100 100\n10 2\n15 3\n107\n3\n... | code_stdio |
[
{
"content": "There are 2N balls, N white and N black, arranged in a row. The integers from 1 through N are written on the white balls, one on each ball, and they are also written on the black balls, one on each ball.\nThe integer written on the i-th ball from the left (1 ≤ i ≤ 2N) is a_i, and the color of this... | [{"input": "2000\nB 1731\nW 1129\nW 285\nB 1447\nW 1836\nW 1278\nW 1648\nW 1593\nW 710\nB 470\nW 264\nW 1693\nW 103\nW 1622\nW 1883\nW 824\nB 1337\nB 115\nW 1645\nB 1682\nW 245\nW 453\nW 606\nW 996\nW 394\nW 1795\nW 1930\nB 809\nB 1761\nW 1552\nW 656\nB 1527\nB 74\nB 1269\nW 527\nB 422\nW 1387\nW 1020\nB 206\nB 815\nW ... | code_stdio |
[
{
"content": "Monocarp has got an array $a$ consisting of $n$ integers. Let's denote $k$ as the mathematic mean of these elements (note that it's possible that $k$ is not an integer).\n\nThe mathematic mean of an array of $n$ elements is the sum of elements divided by the number of these elements (i. e. sum div... | [{"input": "4\n4\n8 8 12 14\n3\n50 25 10\n5\n1 4 7 3 5\n7\n-1 2 3 4 1 0 7\n", "output": "0\n0\n2\n0\n"}, {"input": "4\n4\n8 8 12 14\n3\n44 25 10\n5\n1 4 7 3 5\n7\n-1 2 3 4 1 0 7\n", "output": "0\n0\n2\n0\n"}, {"input": "4\n4\n8 8 18 14\n3\n44 25 10\n5\n1 4 7 3 5\n7\n-1 2 3 4 1 0 7\n", "output": "0\n0\n2\n0\n"}, {"input... | code_stdio |
[
{
"content": "There are $n$ candles on a Hanukkah menorah, and some of its candles are initially lit. We can describe which candles are lit with a binary string $s$, where the $i$-th candle is lit if and only if $s_i=1$.\n\nInitially, the candle lights are described by a string $a$. In an operation, you select ... | [{"input": "5\n5\n10010\n11010\n2\n01\n11\n3\n110\n111\n9\n100010111\n111101100\n4\n001011011\n011010111\n", "output": "-1\n1\n-1\n-1\n-1\n"}, {"input": "5\n5\n11000\n01000\n2\n01\n10\n3\n000\n101\n9\n100011111\n101101100\n9\n001001000\n011000101\n", "output": "-1\n2\n-1\n-1\n-1\n"}, {"input": "5\n5\n11000\n11010\n2\n0... | code_stdio |
[
{
"content": "You are given a directed graph of $n$ vertices and $m$ edges. Vertices are numbered from $1$ to $n$. There is a token in vertex $1$.\n\nThe following actions are allowed: Token movement. To move the token from vertex $u$ to vertex $v$ if there is an edge $u \\to v$ in the graph. This action take... | [{"input": "50 49\n1 3\n6 46\n47 25\n11 49\n47 10\n26 10\n12 38\n45 38\n24 39\n34 22\n36 3\n21 16\n43 44\n45 23\n2 31\n26 13\n28 42\n43 30\n12 27\n32 44\n24 25\n28 20\n15 19\n6 48\n41 7\n15 17\n8 9\n2 48\n33 5\n33 23\n4 19\n40 31\n11 9\n40 39\n35 27\n14 37\n32 50\n41 20\n21 13\n14 42\n18 30\n35 22\n36 5\n18 7\n4 49\n29... | code_stdio |
[
{
"content": "Relative B came to Mr. A's house. He is 3 years old and loves blocks. The block he has is shaped like Figure 1.\n\n<image>\n\nFigure 1\n\nMr. B is laying blocks on the board. When I asked him, \"What are you making?\", He replied cheerfully, \"Maze !!\". The maze he says is the arrangement of bloc... | [{"input": "20 21\n1 0\n14 8\n7\n4 0 1 1\n6 -1 1 3\n2 0 3 3\n1 0 5 0\n5 1 7 3\n2 -1 2 7\n2 -1 6 8\n20 20\n9 9\n1 1\n6\n2 0 1 1\n1 0 5 0\n2 1 1 4\n5 0 1 0\n4 1 6 10\n4 0 8 5\n0 0", "output": "NG\nNG\n"}, {"input": "20 21\n1 0\n14 8\n7\n4 0 1 1\n6 -1 1 3\n2 0 3 3\n1 0 5 0\n5 1 7 3\n2 -1 2 7\n2 -1 4 8\n20 20\n9 9\n1 1\n6\... | code_stdio |
[
{
"content": "There is BMI (Body Mass Index) as an index showing the degree of obesity. The BMI value is calculated using the following formula.\n\nBMI = weight (kg) / (height (m)) 2\n\nThe closer the BMI value is to the standard value, the more \"ideal body shape\" is considered. Therefore, if the standard val... | [{"input": "6\n2 165 27\n-1 317 60\n2 68 72\n11 160 75\n7 185 001\n10 182 113\n3\n3 37 105\n0 229 6\n2 204 75\n0", "output": "11\n2\n"}, {"input": "6\n2 95 27\n-1 317 60\n2 68 72\n11 160 75\n7 185 101\n10 182 113\n3\n3 37 105\n0 229 6\n1 204 75\n0", "output": "11\n1\n"}, {"input": "6\n2 179 27\n-1 317 107\n2 50 72\n11 ... | code_stdio |
[
{
"content": "In Aramic language words can only represent objects.\n\nWords in Aramic have special properties: A word is a root if it does not contain the same letter more than once. A root and all its permutations represent the same object. The root $x$ of a word $y$ is the word that contains all letters t... | [{"input": "10\nbda bbb cda dca dda dcb bcd dcb ada ddd\n", "output": "6\n"}, {"input": "10\ncda bbb cda dca dda dcb bcd dcb ada ddd\n", "output": "5\n"}, {"input": "10\nbda bbb cda dca dda dcb bcd dcb ada edd\n", "output": "6\n"}, {"input": "10\nbda bbb adc dca dda dcb bcd dcb ada edd\n", "output": "6\n"}, {"input": "... | code_stdio |
[
{
"content": "International Coding Procedures Company (ICPC) writes all its code in Jedi Script (JS) programming language. JS does not get compiled, but is delivered for execution in its source form. Sources contain comments, extra whitespace (including trailing and leading spaces), and other non-essential feat... | [{"input": "8\n< > << >> in out fun in>>out\n6\n# let's rock\nin>>out in >> out inout>>outin bin>>out # yay!\nfun>>in>>out funin>>out out>>in <in> > <out>\nin> >> >>> >>>> >>>>>out\n# what's going on here?\n<> <> <> <> <fun> <funfun> <not so fun>\n", "output": "in>>outin>> out a>>b c>>out fun>>in>>outd>>out out>>in<in>... | code_stdio |
[
{
"content": "n! = n × (n − 1) × (n − 2) × ... × 3 × 2 × 1\n\nIs called the factorial of n. For example, the factorial of 12\n\n12! = 12 x 11 x 10 x 9 x 8 x 7 x 6 x 5 x 4 x 3 x 2 x 1 = 479001600\n\nAnd there are two consecutive 0s at the end.\n\nWrite a program that inputs the integer n and outputs the number o... | [{"input": "2\n51\n11000\n0", "output": "0\n12\n2748\n"}, {"input": "2\n58\n10011\n0", "output": "0\n13\n2501\n"}, {"input": "2\n59\n10111\n0", "output": "0\n13\n2525\n"}, {"input": "2\n62\n10110\n0", "output": "0\n14\n2525\n"}, {"input": "2\n50\n10101\n0", "output": "0\n12\n2523\n"}, {"input": "2\n80\n11010\n0", "outp... | code_stdio |
[
{
"content": "The Tower of Hanoi is a well-known mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top, thus making a conical shape.\n\... | [{"input": "0 10000 10000\n10000 0 10000\n10000 10000 0\n40\n", "output": "10995116277750000\n"}, {"input": "0 10000 10000\n10000 0 10000\n10000 10000 0\n40\n", "output": "10995116277750000\n"}, {"input": "0 00000 10000\n10000 0 10000\n10000 10000 0\n40\n", "output": "8551757104850000\n"}, {"input": "0 4499 7885\n10073... | code_stdio |
[
{
"content": "You are given an integer m as a product of integers a1, a2, ... an <image>. Your task is to find the number of distinct decompositions of number m into the product of n ordered positive integers.\n\nDecomposition into n products, given in the input, must also be considered in the answer. As the an... | [{"input": "50\n675 25000 2025 50 450 31250 3750 225 1350 250 72 187500 12000 281250 187500 30000 45000 90000 90 1200 9000 56250 5760 270000 3125 3796875 2250 101250 40 2500 175781250 1250000 45000 2250 3000 31250 46875 135000 421875000 36000 360 140625000 13500 1406250 229 250 75000 62500 150 6\n", "output": "60487335... | code_stdio |
[
{
"content": "Arpa is researching the Mexican wave.\n\nThere are n spectators in the stadium, labeled from 1 to n. They start the Mexican wave at time 0. \n\n At time 1, the first spectator stands. At time 2, the second spectator stands. ... At time k, the k-th spectator stands. At time k + 1, the (k + 1)-... | [{"input": "1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"input": "1000000000 1000000000 1400000000\n", "output": "600000000\n"}, {"input": "1000000000 1000000000 1400000000\n", "output": "600000000\n"}, {"input": "1100000000... | code_stdio |
[
{
"content": "A robot is standing at the origin of the infinite two-dimensional plane. Each second the robot moves exactly $1$ meter in one of the four cardinal directions: north, south, west, and east. For the first step the robot can choose any of the four directions, but then at the end of every second it ha... | [{"input": "1000\n", "output": "251001\n"}, {"input": "1000\n", "output": "251001\n"}, {"input": "777\n", "output": "303420\n"}, {"input": "998\n", "output": "250000\n"}, {"input": "999\n", "output": "501000\n"}, {"input": "777\n", "output": "303420\n"}, {"input": "999\n", "output": "501000\n"}, {"input": "998\n", "out... | code_stdio |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.