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\nWe have a tree with N vertices numbered 1 to N.\nThe i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i.\nYour objective is to paint each vertex in the tree white or black (it is fine to paint...
[{"type": "stdin_stdout", "input": "1954\n568 757 961730273\n550 1885 428046284\n495 564 599174480\n1444 1861 204768778\n292 1156 425880342\n557 1842 556767010\n658 678 605336669\n69 1546 725755442\n151 1906 272636023\n375 931 121557459\n644 1239 150615956\n379 392 702779205\n156 518 166442662\n914 1880 467238632\n194 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have an undirected graph G with N vertices numbered 1 to N and N edges as follows:\n - For each i=1,2,...,N-1, there is an edge between Vertex i and Vertex i+1.\n - There is an edge between Vertex X and Vertex Y.\nFor ...
[{"type": "stdin_stdout", "input": "2000 999 1001\n", "output": "2000\n1999\n1998\n1997\n1996\n1995\n1994\n1993\n1992\n1991\n1990\n1989\n1988\n1987\n1986\n1985\n1984\n1983\n1982\n1981\n1980\n1979\n1978\n1977\n1976\n1975\n1974\n1973\n1972\n1971\n1970\n1969\n1968\n1967\n1966\n1965\n1964\n1963\n1962\n1961\n1960\n1959\n195...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring the lunch break all n Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working.\n\nStanding in a queue that...
[{"type": "stdin_stdout", "input": "10\n419946 201769\n245945 0\n842799 113073\n836998 245945\n0 794376\n692107 836998\n113073 904403\n904403 987165\n201769 692107\n794376 842799\n", "output": "419946 794376 201769 842799 692107 113073 836998 904403 245945 987165 \n"}, {"type": "stdin_stdout", "input": "10\n189071 8522...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLong ago, Vasily built a good fence at his country house. Vasily calls a fence good, if it is a series of n consecutively fastened vertical boards of centimeter width, the height of each in centimeters is a positive integ...
[{"type": "stdin_stdout", "input": "50\n1 3083990 976356336 922018335 1 170272482 1 547248035 1 1 1 1 1 928379588 1 1 1 270052499 315045369 1 1 556091215 1 655608230 424079072 1 1 185387009 77360256 1 1 942696777 228860271 1 487787709 1 437229749 167886535 1 1 904578415 319694007 1 313704390 1 1 957736320 771147030 458...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one...
[{"type": "stdin_stdout", "input": "100 1000000000 42 97\n2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2 5 1 8 8 1 5 2 1 2\n", "output": "590949100\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn exam for n students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that students with adjacent numbers (i and i + 1) always studied side by side and be...
[{"type": "stdin_stdout", "input": "128\n", "output": "128\n127 125 123 121 119 117 115 113 111 109 107 105 103 101 99 97 95 93 91 89 87 85 83 81 79 77 75 73 71 69 67 65 63 61 59 57 55 53 51 49 47 45 43 41 39 37 35 33 31 29 27 25 23 21 19 17 15 13 11 9 7 5 3 1 128 126 124 122 120 118 116 114 112 110 108 106 104 102 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a program you want to execute as a set of tasks organized in a dependency graph. The dependency graph is a directed acyclic graph: each task can depend on results of one or several other tasks, and there are...
[{"type": "stdin_stdout", "input": "10 39\n0 1 0 1 0 1 1 0 1 1\n0 1\n0 2\n0 3\n0 4\n0 5\n0 6\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n1 8\n1 9\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n2 9\n3 4\n3 6\n3 7\n3 8\n3 9\n4 5\n4 6\n4 7\n4 9\n5 6\n5 7\n5 8\n5 9\n6 8\n6 9\n7 8\n7 9\n8 9\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "10 39...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.\n\nEach comment on Polycarp's website is a non-empty string consisting of uppercase and...
[{"type": "stdin_stdout", "input": "A,3,B,2,C,0,D,1,E,0,F,1,G,0,H,1,I,1,J,0,K,1,L,0,M,2,N,0,O,1,P,0\n", "output": "4\nA K M \nB F H L N O \nC D G I P \nE J \n"}, {"type": "stdin_stdout", "input": "hello,2,ok,0,bye,0,test,0,one,1,two,2,a,0,b,0\n", "output": "3\nhello test one \nok bye two \na b \n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOm Nom really likes candies and doesn't like spiders as they frequently steal candies. One day Om Nom fancied a walk in a park. Unfortunately, the park has some spiders and Om Nom doesn't want to see them at all. [Image] ...
[{"type": "stdin_stdout", "input": "2 100 59\n....................................................................................................\n.DR.D..DLLR.LDRR..L.LDRRRDLD.LDRR.LLR.R...DRLD.RRLL.L.D..R.LD.DL....LR.LR.DRLD.....L.D..RD...D.LL.R.\n", "output": "0 0 0 1 0 0 0 1 1 0 0 2 0 0 0 1 1 1 0 1 0 0 0 1 1 2 0 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?\n\nGiven a n × n checkerboard. Each cell of the board has either character 'x', or character 'o...
[{"type": "stdin_stdout", "input": "19\noxoxoxoxooxoooxxoox\nxxxxxxxxoxxoxoooooo\noxoxoxooxxxooxxxooo\nxxoxxxooxooxxxoxxox\noxoxooxxxooooxxoxox\nxxxoooxoxxoxxoxxxoo\noxooxxxoooooxxoooxo\nxxooxooxoxxoxxoxxoo\noxxxxooooxxxooooxxx\nooxooxoxxoxxoxooxoo\nxxxooooxxxooooxoxox\noooxoxooxxoxooxooxx\nxxoooxxxooooxxoooxo\nooxxxoo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Ms Swan bought an orange in a shop. The orange consisted of n·k segments, numbered with integers from 1 to n·k. \n\nThere were k children waiting for Ms Swan at home. The children have recently learned about the o...
[{"type": "stdin_stdout", "input": "27 3\n12 77 80\n", "output": "8 21 18 13 5 27 14 2 20 23 12 17 10 4 6 11 3 26 1 24 16 9 7 25 22 19 15 \n43 32 46 48 51 37 41 49 77 30 40 28 34 38 44 35 31 45 52 50 47 29 36 53 42 39 33 \n62 61 78 63 81 55 70 79 67 73 58 69 59 64 80 54 56 57 68 72 65 60 71 66 74 75 76 \n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Summer Informatics School, if a student doesn't behave well, teachers make a hole in his badge. And today one of the teachers caught a group of $n$ students doing yet another trick. \n\nLet's assume that all these stud...
[{"type": "stdin_stdout", "input": "100\n73 81 39 85 48 49 37 20 66 41 79 32 54 71 31 50 48 29 10 85 81 20 20 20 48 54 70 40 71 31 49 77 50 33 12 87 19 12 54 39 87 10 20 39 81 18 70 53 86 7 33 37 62 9 77 54 50 30 70 81 66 12 41 12 20 23 87 73 91 75 94 49 18 71 81 32 79 85 30 94 48 10 41 62 73 90 40 70 90 91 33 100 79 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's denote that some array $b$ is bad if it contains a subarray $b_l, b_{l+1}, \\dots, b_{r}$ of odd length more than $1$ ($l < r$ and $r - l + 1$ is odd) such that $\\forall i \\in \\{0, 1, \\dots, r - l\\}$ $b_{l + i}...
[{"type": "stdin_stdout", "input": "10 11\n-1 11 -1 -1 -1 -1 10 -1 -1 -1\n", "output": "100000000\n"}, {"type": "stdin_stdout", "input": "10 14\n-1 9 11 11 -1 -1 -1 -1 -1 -1\n", "output": "62748517\n"}, {"type": "stdin_stdout", "input": "10 14\n-1 -1 6 -1 -1 -1 9 -1 -1 -1\n", "output": "810903912\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are three horses living in a horse land: one gray, one white and one gray-and-white. The horses are really amusing animals, which is why they adore special cards. Each of those cards must contain two integers, the f...
[{"type": "stdin_stdout", "input": "5 1000000000\n812747000 266266300 444091950 694572960 414735290\n", "output": "28926258177\n"}, {"type": "stdin_stdout", "input": "2 1000000000\n2 1000000000\n", "output": "28926258177\n"}, {"type": "stdin_stdout", "input": "1 1000000000\n1000000000\n", "output": "281663002102\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAll cities of Lineland are located on the Ox coordinate axis. Thus, each city is associated with its position x_{i} — a coordinate on the Ox axis. No two cities are located at a single point.\n\nLineland residents love to...
[{"type": "stdin_stdout", "input": "10\n-857422304 -529223472 82412729 145077145 188538640 265299215 527377039 588634631 592896147 702473706\n", "output": "328198832 1559896010\n328198832 1231697178\n62664416 939835033\n43461495 1002499449\n43461495 1045960944\n76760575 1122721519\n61257592 1384799343\n4261516 14460569...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIahub is a big fan of tourists. He wants to become a tourist himself, so he planned a trip. There are n destinations on a straight road that Iahub wants to visit. Iahub starts the excursion from kilometer 0. The n destina...
[{"type": "stdin_stdout", "input": "50\n3987477 8934938 4067156 6712855 7269334 5039822 9533601 9335400 5992073 2619268 438734 8620973 4347619 4307947 2249161 815221 7615258 8244100 8341666 5908546 6646952 4812769 6215114 7479369 6290438 5623785 6466133 9953199 3525873 4326034 3510072 8117068 2342953 1717542 9766539 65...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Berland recently a new collection of toys went on sale. This collection consists of 10^9 types of toys, numbered with integers from 1 to 10^9. A toy from the new collection of the i-th type costs i bourles.\n\nTania ha...
[{"type": "stdin_stdout", "input": "5 10000\n1000000000 888888888 777777777 666666666 959595959\n", "output": "140\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnn and Borya have n piles with candies and n is even number. There are a_{i} candies in pile with number i.\n\nAnn likes numbers which are square of some integer and Borya doesn't like numbers which are square of any int...
[{"type": "stdin_stdout", "input": "100\n444272562 25 25 0 49 73291074 64 100 638092144 756033694 0 700405846 16 25 25 100 36 25 269573395 288578186 366853675 36 81 49 4 0 25 49 9 64 0 4 36 36 49 0 64 64 532899768 1 64 9 549673690 25 64 4 817183855 25 146555318 36 495564252 100 49 9 36 100 49 100 4 100 9 64 9 432227412...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Berland Forest can be represented as an infinite cell plane. Every cell contains a tree. That is, contained before the recent events.\n\nA destructive fire raged through the Forest, and several trees were damaged by i...
[{"type": "stdin_stdout", "input": "20 20\n....................\n....................\n..XXXXXXXXXXXXXXXXXX\n..XXXXXXXXXXXXXXXXXX\n..XXXXXXXXXXXXXXXXXX\n..XXXXXXXXXXXXXXXXXX\n..XXXXXXXXXXXXXXXXXX\n..XXXXXXXXXXXXXXXXXX\n..XXXXXXXXXXXXXXXXXX\n..XXXXXXXXXXXXXXXXXX\n..XXXXXXXXXXXXXXXXXX\n..XXXXXXXXXXXXXXXXXX\n..XXXXXXXXXXX...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDZY loves chessboard, and he enjoys playing with it.\n\nHe has a chessboard of n rows and m columns. Some cells of the chessboard are bad, others are good. For every good cell, DZY wants to put a chessman on it. Each ches...
[{"type": "stdin_stdout", "input": "8 35\n......................-............\n...-..........-........-...........\n...........-.......................\n-..................................\n...................................\n...........-............-.........-\n.........-.........-.--............\n......................
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDreamoon has a string s and a pattern string p. He first removes exactly x characters from s obtaining string s' as a result. Then he calculates $\\operatorname{occ}(s^{\\prime}, p)$ that is defined as the maximal number ...
[{"type": "stdin_stdout", "input": "a\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmr loves Chemistry, and specially doing experiments. He is preparing for a new interesting experiment.\n\nAmr has n different types of chemicals. Each chemical i has an initial volume of a_{i} liters. For this experiment...
[{"type": "stdin_stdout", "input": "20\n1 2 3 4 6 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 100000\n", "output": "113"}, {"type": "stdin_stdout", "input": "20\n1 2 3 4 6 8 16 20 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536\n", "output": "99"}, {"type": "stdin_stdout", "input": "17\n100000 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNura wants to buy k gadgets. She has only s burles for that. She can buy each gadget for dollars or for pounds. So each gadget is selling only for some type of currency. The type of currency and the cost in that currency ...
[{"type": "stdin_stdout", "input": "1 93 46 46\n1\n1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2 1\n1 2\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOhana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: ...
[{"type": "stdin_stdout", "input": "20\n10101011101000011010\n11111010001100110101\n01011100010000001111\n10110100000101010011\n11010001110111101101\n00100110011011101010\n01000110101011001100\n01101100111101101101\n10111010010100111100\n00010010110001101110\n10111110010000101010\n10010111110100100100\n1101011100111111...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n servers in a laboratory, each of them can perform tasks. Each server has a unique id — integer from 1 to n.\n\nIt is known that during the day q tasks will come, the i-th of them is characterized with three in...
[{"type": "stdin_stdout", "input": "1 10\n4 1 1\n9 1 1\n10 1 1\n12 1 1\n13 1 1\n15 1 1\n16 1 1\n18 1 1\n19 1 1\n20 1 1\n", "output": "1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n"}, {"type": "stdin_stdout", "input": "4 10\n1 1 1\n3 1 2\n4 1 2\n6 1 2\n8 1 2\n13 1 2\n16 1 1\n17 1 2\n19 3 1\n20 1 1\n", "output": "1\n1\n2\n1\n1\n1\n1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider 2n rows of the seats in a bus. n rows of the seats on the left and n rows of the seats on the right. Each row can be filled by two people. So the total capacity of the bus is 4n.\n\nConsider that m (m ≤ 4n) peopl...
[{"type": "stdin_stdout", "input": "100 103\n", "output": "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nКак известно, в теплую погоду многие жители крупных городов пользуются сервисами городского велопроката. Вот и Аркадий сегодня будет добираться от школы до дома, используя городские велосипеды.\n\nШкола и дом находятся на...
[{"type": "stdin_stdout", "input": "50 15001\n1269 1580 5431 5916 6642 14145 15760 19922 20589 22062 24138 33454 33505 35916 37012 42577 43140 49457 54720 55188 56205 56639 56870 57997 58379 59088 59297 61805 61861 63005 64013 68848 71182 71497 72715 73008 75616 76042 76614 80690 83089 85033 86408 92392 92763 93833 950...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTavas is a strange creature. Usually \"zzz\" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. [Image] \n\nToday Tavas fell asleep in Malekas' place. While he was sl...
[{"type": "stdin_stdout", "input": "173700 6\nbcabcbcbcbaaacaccaacaccaabacabaacbcacbbccaccbcacbabcaccccccaacacabbbbbacabbaaacbcbbaccaccabbbbaabbacacbabccaabcabbbcacaaccbabbcaaaaaabccbbcabcacbcbcabcbcbbaabacaaccccabacaaaccacaaabbacacabbcccacbaabcacacbbaaaccaccbaccccccbccaabcacaacabaccababacabcccbcbbacbabacbcbabacbbaccaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n[Image] \n\n\n-----Input-----\n\nThe input contains a single integer $a$ ($0 \\le a \\le 15$).\n\n\n-----Output-----\n\nOutput a single integer.\n\n\n-----Example-----\nInput\n3\n\nOutput\n13\n\nThe input will be stdin an...
[{"type": "stdin_stdout", "input": "3\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "0\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "6\n", "output": "10\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAcingel is a small town. There was only one doctor here — Miss Ada. She was very friendly and nobody has ever said something bad about her, so who could've expected that Ada will be found dead in her house? Mr Gawry, worl...
[{"type": "stdin_stdout", "input": "20 5\n8 1 13 19 3 14 5 2 4 6 12 18 20 17 16 15 11 10 7 9\n12 18 20 17 16 15 11 10 7 9 8 1 13 19 3 14 5 2 4 6\n5 2 4 6 12 18 20 17 16 15 11 10 7 9 8 1 13 19 3 14\n5 2 4 6 12 18 20 17 16 15 11 10 7 9 8 1 13 19 3 14\n8 1 13 19 3 14 5 2 4 6 12 18 20 17 16 15 11 10 7 9\n", "output": "86\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two lists of segments $[al_1, ar_1], [al_2, ar_2], \\dots, [al_n, ar_n]$ and $[bl_1, br_1], [bl_2, br_2], \\dots, [bl_n, br_n]$.\n\nInitially, all segments $[al_i, ar_i]$ are equal to $[l_1, r_1]$ and all se...
[{"type": "stdin_stdout", "input": "3\n3 5\n1 2\n3 4\n2 1000000000\n1 1\n999999999 999999999\n10 3\n5 10\n7 8\n", "output": "7\n2000000000\n0\n"}, {"type": "stdin_stdout", "input": "1\n200000 598920770\n24529366 24846325\n35694819 90253337\n", "output": "703962247\n"}, {"type": "stdin_stdout", "input": "1\n200000 88635...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya has recently started working as a programmer in the IT city company that develops computer games.\n\nBesides game mechanics implementation to create a game it is necessary to create tool programs that can be used by...
[{"type": "stdin_stdout", "input": "870 396 187 223 444 202 222 732\n", "output": "999.794532443395 550.781715159771\n699.893362547183 538.645476249672\n784.946681273591 467.322738124836\n314.602137963862 -93.569417800670\n484.708775416679 -236.214894050342\n955.053318726409 324.677261875164\n1040.106637452818 253.3545...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n[Image] \n\nIt's the end of July – the time when a festive evening is held at Jelly Castle! Guests from all over the kingdom gather here to discuss new trends in the world of confectionery. Yet some of the things discusse...
[{"type": "stdin_stdout", "input": "433 3\nFZDDHMJGBZCHFUXBBPIEBBEFDWOMXXEPOMDGSMPIUZOMRZQNSJAVNATGIWPDFISKFQXJNVFXPHOZDAEZFDAHDXXQKZMGNSGKQNWGNGJGJZVVITKNFLVCPMZSDMCHBTVAWYVZLIXXIADXNYILEYNIQHKMOGMVOCWGHCWIYMPEPADSJAAKEGTUSEDWAHMNYJDIHBKHVUHLYGNGZDBULRXLSAJHPCMNWCEAAPYMHDTYWPADOTJTXTXUKLCHWKUSZRHEKQEFPVJEJJHRWCKYOIWAL...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Kingdom of Kremland is a tree (a connected undirected graph without cycles) consisting of $n$ vertices. Each vertex $i$ has its own value $a_i$. All vertices are connected in series by edges. Formally, for every $1 \\...
[{"type": "stdin_stdout", "input": "44\n42 44 4 24 29 17 32 30 30 9 28 9 22 16 20 41 17 19 41 23 28 19 38 44 1 34 41 34 19 36 32 37 22 31 4 3 27 23 21 21 26 39 20 8\n", "output": "6926"}, {"type": "stdin_stdout", "input": "40\n35 33 20 13 21 4 16 21 22 35 20 39 32 29 27 5 24 3 12 10 15 13 2 31 1 11 20 39 17 37 21 10 36...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDevu and his brother love each other a lot. As they are super geeks, they only like to play with arrays. They are given two arrays a and b by their father. The array a is given to Devu and b to his brother. \n\nAs Devu is...
[{"type": "stdin_stdout", "input": "10 10\n23 100 38 38 73 54 59 69 44 86\n100 100 100 100 100 100 100 100 100 100\n", "output": "416\n"}, {"type": "stdin_stdout", "input": "1 1\n401114\n998223974\n", "output": "997822860\n"}, {"type": "stdin_stdout", "input": "1 1\n1000000000\n1000000000\n", "output": "0\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe research center Q has developed a new multi-core processor. The processor consists of n cores and has k cells of cache memory. Consider the work of this processor.\n\nAt each cycle each core of the processor gets one ...
[{"type": "stdin_stdout", "input": "100 1 100\n59\n37\n53\n72\n37\n15\n8\n93\n92\n74\n11\n11\n68\n16\n92\n40\n76\n20\n10\n86\n76\n5\n9\n95\n5\n81\n44\n57\n10\n24\n22\n2\n57\n6\n26\n67\n48\n95\n34\n97\n55\n33\n70\n66\n51\n70\n74\n65\n35\n85\n37\n9\n27\n43\n65\n6\n5\n57\n54\n27\n22\n41\n8\n29\n10\n50\n9\n68\n78\n9\n92\n3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA permutation of length $k$ is a sequence of $k$ integers from $1$ to $k$ containing each integer exactly once. For example, the sequence $[3, 1, 2]$ is a permutation of length $3$.\n\nWhen Neko was five, he thought of an...
[{"type": "stdin_stdout", "input": "30\n14 20 2 18 17 14 13 2 2 12 9 2 9 15 26 11 20 23 6 9 22 1 6 19 17 1 9 15 15\n23 27 15 20 29 22 25 11 26 14 27 19 15 29 27 29 23 27 13 29 26 15 21 23 26 14 25 21 18\n", "output": "12 14 1 15 21 6 13 25 9 29 15 18 20 23 27 26 22 14 23 19 2 26 17 29 11 2 15 9 27 20 \n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTeacher thinks that we make a lot of progress. Now we are even allowed to use decimal notation instead of counting sticks. After the test the teacher promised to show us a \"very beautiful number\". But the problem is, he...
[{"type": "stdin_stdout", "input": "100 1\n", "output": "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"}, {"type": "stdin_stdout", "input": "88 9\n", "output": "1011235955056179775280898876404494382022471910112359550561797752808988764044943820224719"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis problem differs from the next one only in the presence of the constraint on the equal length of all numbers $a_1, a_2, \\dots, a_n$. Actually, this problem is a subtask of the problem D2 from the same contest and the...
[{"type": "stdin_stdout", "input": "10\n4915446 7629450 1632197 6804641 4858420 8397903 3657129 9543999 8324770 9285052\n", "output": "280933096"}, {"type": "stdin_stdout", "input": "9\n824676 969582 907196 835924 807294 691340 523083 581257 830608\n", "output": "892416655"}, {"type": "stdin_stdout", "input": "5\n10000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPermutation p is an ordered set of integers p_1, p_2, ..., p_{n}, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote the i-th element of permutation p as p_{i}. We'll call number n ...
[{"type": "stdin_stdout", "input": "13\n", "output": "695720788\n"}, {"type": "stdin_stdout", "input": "15\n", "output": "150347555\n"}, {"type": "stdin_stdout", "input": "11\n", "output": "890786230\n"}, {"type": "stdin_stdout", "input": "9\n", "output": "734832000\n"}, {"type": "stdin_stdout", "input": "7\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has recently got a job as a cashier at a local store. His day at work is $L$ minutes long. Vasya has already memorized $n$ regular customers, the $i$-th of which comes after $t_{i}$ minutes after the beginning of th...
[{"type": "stdin_stdout", "input": "1 1000000000 1\n0 1000000000\n", "output": "0"}, {"type": "stdin_stdout", "input": "0 1000000000 1000000000\n", "output": "1"}, {"type": "stdin_stdout", "input": "0 1000000000 1\n", "output": "1000000000"}, {"type": "stdin_stdout", "input": "0 1000000000 1\n", "output": "1000000000"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRoman and Denis are on the trip to the programming competition. Since the trip was long, they soon got bored, and hence decided to came up with something. Roman invented a pizza's recipe, while Denis invented a string mul...
[{"type": "stdin_stdout", "input": "4\nqe\nnd\niqryhukieskfvaeettersinksrmazelxtgvartuz\nvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter a hard day Vitaly got very hungry and he wants to eat his favorite potato pie. But it's not that simple. Vitaly is in the first room of the house with n room located in a line and numbered starting from one from lef...
[{"type": "stdin_stdout", "input": "100\nqDpInBmCrFwXpDbFgOzVvOcEmJrUcToAdEwEgTvBvBfWwRpGyEaXgDdRwVlQnYgWmWhMrHaIzPyXvGaFlRsVzHhZrOuVpXrKxFzAmWwPlFtNfPtJxVmLuHjKfYyArHrEnSwSzOvDpQhCgCqLlAcNpGhXrEeFuCmAqIkXyYtSsQwIxJzNiIuTgEbVuWrMwPrAlLyKaZ\n", "output": "42\n"}, {"type": "stdin_stdout", "input": "26\nzAyBxCwDvEuFtGsHrI...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe kingdom of Lazyland is the home to $n$ idlers. These idlers are incredibly lazy and create many problems to their ruler, the mighty King of Lazyland. \n\nToday $k$ important jobs for the kingdom ($k \\le n$) should be...
[{"type": "stdin_stdout", "input": "19 2\n1 1 1 2 2 1 1 2 1 2 2 2 2 2 2 2 1 2 2\n92 91 86 3 32 40 25 14 51 10 53 35 28 51 60 73 31 22 66\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "18 12\n6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6\n47 4 41 56 75 16 29 45 100 76 53 48 79 30 56 84 60 86\n", "output": "425\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven is a string S consisting of L and R.\nLet N be the length of S. There are N squares arranged from left to right, and the i-th character of S from the left is written on the i-th square from the left.\nThe character ...
[{"type": "stdin_stdout", "input": "RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAmidakuji is a traditional method of lottery in Japan.\nTo make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 [cm], and th...
[{"type": "stdin_stdout", "input": "100 8 8\n", "output": "467571711\n"}, {"type": "stdin_stdout", "input": "100 8 3\n", "output": "938282570\n"}, {"type": "stdin_stdout", "input": "100 8 1\n", "output": "755868507\n"}, {"type": "stdin_stdout", "input": "15 8 5\n", "output": "437760187\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order:\n - Choose two among A, B a...
[{"type": "stdin_stdout", "input": "27 39 17\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "19 43 41\n", "output": "13\n"}, {"type": "stdin_stdout", "input": "39 49 21\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "26 37 19\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "13 48 20\n", "ou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has a maze, which is a grid of H \\times W squares with H horizontal rows and W vertical columns.\nThe square at the i-th row from the top and the j-th column is a \"wall\" square if S_{ij} is #, and a \"road\" ...
[{"type": "stdin_stdout", "input": "20 20\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\nIn some other world, today is Christmas.\nMr. Takaha decides to make a multi-dimensional burger in his party. A level-L burger (L is an integer greater than or equal to 0) is the following thing:\n - A level-0 burger is a...
[{"type": "stdin_stdout", "input": "50 4321098765432109\n", "output": "2160549382716056\n"}, {"type": "stdin_stdout", "input": "50 2251799813685246\n", "output": "1125899906842623\n"}, {"type": "stdin_stdout", "input": "50 2251799813685247\n", "output": "1125899906842624\n"}, {"type": "stdin_stdout", "input": "50 22517...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day, liouzhou_101 got a chat record of Freda and Rainbow. Out of curiosity, he wanted to know which sentences were said by Freda, and which were said by Rainbow. According to his experience, he thought that Freda alwa...
[{"type": "stdin_stdout", "input": "10\nmiao..FLhPl_Wjslala.\nmiao. tdEGtfdJlala.\nGAzEUlala.\nKCcmOa .aKBlZyYsdu.V\nmiao.lala.\njKylnM,FXK\nmiao.GBWqjGH.v\nmiao.RefxS Cni.\nOxaaEihuHQR_s,\nmiao.a,Axtlala.\n", "output": "OMG>.< I don't know!\nOMG>.< I don't know!\nFreda's\nOMG>.< I don't know!\nOMG>.< I don't know!\nOM...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n(Легенда будет поправлена позже) У нас есть n целых чисел. Первое число становится корнем дерева, для остальных нужно реализовать добавление в дерево поиска и вывести для каждого n - 1 числа его непосредственного предка в...
[{"type": "stdin_stdout", "input": "10\n991309218 517452607 870021923 978357992 136426010 10601767 302627526 883615372 163475700 600546765\n", "output": "991309218 517452607 870021923 517452607 136426010 136426010 978357992 302627526 870021923\n"}, {"type": "stdin_stdout", "input": "2\n656402233 488475947\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me? \n\n — Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night? \n\nAt this point the Smart Be...
[{"type": "stdin_stdout", "input": "20\n-808998072 733614990 579897311 -337992089 579897311 120800519 -337992089 -803027570 733614990 -686536765 733614990 -803027570 -803027570 733614990 120800519 -803027570 -686536765 579897311 -808998072 -686536765\n", "output": "4215055101 13\n1 4 7 8 10 12 13 15 16 17 18 19 20 "}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKate has a set $S$ of $n$ integers $\\{1, \\dots, n\\} $. \n\nShe thinks that imperfection of a subset $M \\subseteq S$ is equal to the maximum of $gcd(a, b)$ over all pairs $(a, b)$ such that both $a$ and $b$ are in $M$ ...
[{"type": "stdin_stdout", "input": "104\n", "output": "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 3 4 5 5 5 6 7 7 7 7 8 9 9 10 11 11 11 11 12 13 13 13 13 14 15 15 16 17 17 17 18 19 19 19 20 21 21 22 23 23 24 25 25 26 27 27 28 29 29 30 31 31 32 33 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHarry Potter is on a mission to destroy You-Know-Who's Horcruxes. The first Horcrux that he encountered in the Chamber of Secrets is Tom Riddle's diary. The diary was with Ginny and it forced her to open the Chamber of Se...
[{"type": "stdin_stdout", "input": "9\nliyzmbjwnzryjokufuxcqtzwworjeoxkbaqrujrhdidqdvwdfzilwszgnzglnnbogaclckfnbqovtziuhwvyrqwmskx\nliyzmbjwnzryjokufuxcqtzwworjeoxkbaqrujrhdidqdvwdfzilwszgnzglnnbogaclckfnbqovtziuhwvyrqwmskx\nliyzmbjwnzryjokufuxcqtzwworjeoxkbaqrujrhdidqdvwdfzilwszgnzglnnbogaclckfnbqovtziuhwvyrqwmskx\nhr...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Nikita found the string containing letters \"a\" and \"b\" only. \n\nNikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-s...
[{"type": "stdin_stdout", "input": "bbabbbbbaaba\n", "output": "10"}, {"type": "stdin_stdout", "input": "bbabbbaabbbb\n", "output": "9"}, {"type": "stdin_stdout", "input": "bbabbbababaa\n", "output": "9"}, {"type": "stdin_stdout", "input": "aabbaababbab\n", "output": "8"}, {"type": "stdin_stdout", "input": "babbbaab\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane. \n\nHan Solo has the newest duplex ...
[{"type": "stdin_stdout", "input": "10 -4 -4\n2 -4\n2 0\n-4 2\n5 -4\n-3 -5\n1 4\n-4 2\n-3 5\n0 -3\n2 4\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "10 5 -3\n1 1\n2 -1\n2 2\n1 -2\n4 -5\n1 4\n0 1\n1 -4\n-2 0\n-4 -5\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "10 -3 3\n3 -5\n4 3\n0 -2\n0 0\n3 -3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an easier version of the problem. In this version, $n \\le 2000$.\n\nThere are $n$ distinct points in three-dimensional space numbered from $1$ to $n$. The $i$-th point has coordinates $(x_i, y_i, z_i)$. The numbe...
[{"type": "stdin_stdout", "input": "10\n-93796614 30297417 22968703\n-91631822 -13274485 54175787\n-91631822 30297417 22968703\n-75960156 -13274485 22968703\n-75960156 30297417 22968703\n-91631822 -92047004 65302423\n-91631822 30297417 -16296706\n-75960156 88346795 54175787\n-93796614 30297417 -16296706\n-75960156 3029...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGildong has bought a famous painting software cfpaint. The working screen of cfpaint is square-shaped consisting of $n$ rows and $n$ columns of square cells. The rows are numbered from $1$ to $n$, from top to bottom, and ...
[{"type": "stdin_stdout", "input": "9 4\nBWBBWWWWW\nWWBWBWWWW\nWBWBBBBBB\nBWWWBBBWW\nWWBWBWBWW\nWBWWBBWWB\nWWWBWBWBW\nBBWBBBWWW\nWWWWBBWBW\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "7 3\nWWWWWWW\nBWWWWWB\nWWWWBWW\nWBBBWWB\nBBWWBBB\nWBBWWWW\nBWBBBWB\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe R2 company has n employees working for it. The work involves constant exchange of ideas, sharing the stories of success and upcoming challenging. For that, R2 uses a famous instant messaging program Spyke.\n\nR2 has m...
[{"type": "stdin_stdout", "input": "7 6 5\n0 1 0 1 1 1\n0 1 1 0 1 1\n1 0 1 1 1 0\n1 0 1 1 1 1\n1 1 1 1 1 0\n1 1 1 0 1 0\n1 0 1 0 0 0\n4 1\n2 6\n7 3\n7 1\n5 3\n", "output": "1 2 4 4 3 4 2 "}, {"type": "stdin_stdout", "input": "10 1 10\n0\n0\n0\n0\n0\n0\n1\n0\n1\n0\n7 1\n9 1\n9 1\n7 1\n9 1\n9 1\n9 1\n7 1\n9 1\n9 1\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink \"Beecola\", which can be bought in n different shops in the city. It's known that th...
[{"type": "stdin_stdout", "input": "12\n35345 58181 32223 84621 35905 73863 99537 30666 67771 39229 36847 29038\n23\n55052824\n82504840\n35160556\n78141700\n73401989\n86305919\n39430705\n31939373\n23501765\n4406029\n61436920\n14295390\n34275309\n28028753\n85724689\n70158847\n2396455\n66994588\n84024224\n30175981\n65622...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe cities of Byteland and Berland are located on the axis $Ox$. In addition, on this axis there are also disputed cities, which belong to each of the countries in their opinion. Thus, on the line $Ox$ there are three typ...
[{"type": "stdin_stdout", "input": "15\n-9518 R\n-6858 P\n-6726 B\n-6486 R\n-4496 P\n-4191 P\n-772 B\n-258 R\n-194 P\n1035 R\n2297 P\n4816 B\n5779 R\n9342 B\n9713 B\n", "output": "25088\n"}, {"type": "stdin_stdout", "input": "8\n-839 P\n-820 P\n-488 P\n-334 R\n-83 B\n187 R\n380 B\n804 P\n", "output": "2935\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBecause of budget cuts one IT company established new non-financial reward system instead of bonuses.\n\nTwo kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a c...
[{"type": "stdin_stdout", "input": "498\n", "output": "5392730685240975000"}, {"type": "stdin_stdout", "input": "500\n", "output": "5567867859752100000"}, {"type": "stdin_stdout", "input": "321\n", "output": "163013183025830865"}, {"type": "stdin_stdout", "input": "139\n", "output": "212332162372330"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMahmoud wrote a message s of length n. He wants to send it as a birthday present to his friend Moaz who likes strings. He wrote it on a magical paper but he was surprised because some characters disappeared while writing ...
[{"type": "stdin_stdout", "input": "55\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\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\n", "output": "383381198\n55\n1\n"}, {"type": "stdin_stdout", "input": "100\nygdbmqpyofbcoqom...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya came up to the blackboard and wrote out n distinct integers from 1 to n in some order in a circle. Then he drew arcs to join the pairs of integers (a, b) (a ≠ b), that are either each other's immediate neigh...
[{"type": "stdin_stdout", "input": "25\n17 14\n19 1\n24 16\n23 13\n20 15\n24 23\n18 25\n4 1\n18 9\n2 17\n14 12\n25 2\n13 6\n21 9\n19 3\n11 18\n10 13\n12 19\n3 17\n12 1\n10 6\n15 1\n18 21\n11 21\n23 22\n8 11\n11 16\n10 23\n2 9\n25 7\n15 5\n22 24\n13 22\n5 10\n5 20\n4 15\n5 6\n12 4\n3 14\n16 22\n8 24\n7 17\n25 9\n21 8\n8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKris works in a large company \"Blake Technologies\". As a best engineer of the company he was assigned a task to develop a printer that will be able to print horizontal and vertical strips. First prototype is already bui...
[{"type": "stdin_stdout", "input": "10 1 1\n2 1 1000000000\n", "output": "1000000000 \n1000000000 \n1000000000 \n1000000000 \n1000000000 \n1000000000 \n1000000000 \n1000000000 \n1000000000 \n1000000000 \n"}, {"type": "stdin_stdout", "input": "1 10 1\n1 1 1000000000\n", "output": "1000000000 1000000000 1000000000 100000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGardener Alexey teaches competitive programming to high school students. To congratulate Alexey on the Teacher's Day, the students have gifted him a collection of wooden sticks, where every stick has an integer length. No...
[{"type": "stdin_stdout", "input": "11\n9969 9945 9994 9914 9959 10000 9928 9985 9973 9939 9933\n", "output": "6051630681"}, {"type": "stdin_stdout", "input": "11\n2367 2279 5630 8823 5312 8316 2915 6412 4111 7540 4263\n", "output": "2020697314"}, {"type": "stdin_stdout", "input": "11\n9991 9968 9984 9924 9915 9925 995...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMisha was interested in water delivery from childhood. That's why his mother sent him to the annual Innovative Olympiad in Irrigation (IOI). Pupils from all Berland compete there demonstrating their skills in watering. It...
[{"type": "stdin_stdout", "input": "100 74 20\n9 15 16 18 55 41 64 44 5 1 27 31 36 25 71 28 71 35 47 40 21 53 31 11 24 1 69 67 58 16 19 52 33 17 63 1 49 28 17 52 46 60 53 21 21 60 19 63 11 61 8 27 3 22 38 31 45 69 61 18 58 22 8 71 17 1 64 70 56 10 66 47 70 1 45 8 66 8 66 25 39 45 47 7 41 24 41 72 16 42 28 7 15 10 38 29...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nn people are standing on a coordinate axis in points with positive integer coordinates strictly less than 10^6. For each person we know in which direction (left or right) he is facing, and his maximum speed.\n\nYou can pu...
[{"type": "stdin_stdout", "input": "26 10\n495492 7 1\n256604 5 2\n511773 3 2\n590712 4 1\n206826 7 2\n817878 4 2\n843915 1 1\n349160 3 1\n351298 4 1\n782251 8 2\n910928 4 1\n662354 4 2\n468621 2 2\n466991 7 2\n787303 6 2\n221623 8 2\n343518 6 1\n141123 7 1\n24725 6 1\n896603 3 2\n918129 8 2\n706071 6 2\n512369 2 2\n60...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). ...
[{"type": "stdin_stdout", "input": "220\n1 1 3 1 3 1 1 3 1 3 3 3 3 1 3 3 1 3 3 3 3 3 1 1 1 3 1 1 1 3 2 3 3 3 1 1 3 3 1 1 3 3 3 3 1 3 3 1 1 1 2 3 1 1 1 2 3 3 3 2 3 1 1 3 1 1 1 3 2 1 3 2 3 1 1 3 3 3 1 3 1 1 1 3 3 2 1 3 2 1 1 3 3 1 1 1 2 1 1 3 2 1 2 1 1 1 3 1 3 3 1 2 3 3 3 3 1 3 1 1 1 1 2 3 1 1 1 1 1 1 3 2 3 1 3 1 3 1 1 3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlyona has recently bought a miniature fridge that can be represented as a matrix with $h$ rows and $2$ columns. Initially there is only one shelf at the bottom of the fridge, but Alyona can install arbitrary number of sh...
[{"type": "stdin_stdout", "input": "100 2000\n61 77 55 79 29 99 68 31 78 53 80 91 78 52 84 95 92 84 23 65 86 89 84 98 83 40 50 88 53 74 52 53 52 61 69 90 81 95 98 100 92 79 94 93 80 84 76 34 40 56 65 72 95 91 95 80 45 89 58 96 99 96 78 64 43 96 50 68 62 92 59 65 77 64 94 92 69 97 48 76 53 92 100 94 88 70 29 100 93 78 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n pearls in a row. Let's enumerate them with integers from 1 to n from the left to the right. The pearl number i has the type a_{i}.\n\nLet's call a sequence of consecutive pearls a segment. Let's call a segment...
[{"type": "stdin_stdout", "input": "10\n460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451 460626451\n", "output": "5\n1 2\n3 4\n5 6\n7 8\n9 10\n"}, {"type": "stdin_stdout", "input": "10\n933677171 80672280 80672280 933677171 933677171 933677171 933677171 80672280 80672280 9336771...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Apple, a gourmet, works as editor-in-chief of a gastronomic periodical. He travels around the world, tasting new delights of famous chefs from the most fashionable restaurants. Mr. Apple has his own signature method o...
[{"type": "stdin_stdout", "input": "10 24\n<><>>>><>>><>>>>>>>><<>>\n<><>>>><>>><>>>>>>>><<>>\n>><>>>><>>><>>>>>>>><>>>\n<<<><><<<<<<><<><>>><<<>\n<<<=<=<<<<<<><<=<>==<<<>\n>><>>>><>>><>>>>>>>><>>>\n>>>>>>>>>>>>>>>>>>>>>>>>\n<<<<<<<<<<<<=<<<<=<<<<<<\n<><>>>><>>><>>>>>>>><<>>\n<><>>>><>>><>>>>>>>><<>>\n", "output": "Yes...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or subtract it from arbitrary array elements. Formally,...
[{"type": "stdin_stdout", "input": "100 5 100\n-45 -36 -55 -96 -49 8 -88 -87 -82 51 27 -33 -65 0 -1 -42 -58 -19 -11 77 -54 14 -49 -90 -35 -9 -2 -48 0 -21 44 22 37 -32 -81 64 28 85 -77 44 18 -74 -50 62 8 -74 41 -15 -91 -93 -2 57 -12 2 -2 -90 84 6 -62 -14 72 85 86 -71 -59 57 -89 -4 78 56 56 24 -15 -78 27 -30 -31 -52 -92 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.\n\nAfter two hours of playing the game Vova has tracked the monster and ana...
[{"type": "stdin_stdout", "input": "9 1 20\n4 19\n", "output": "53\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nSTRIKE\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nSTRIKE\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHE...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVanya wants to pass n exams and get the academic scholarship. He will get the scholarship if the average grade mark for all the exams is at least avg. The exam grade cannot exceed r. Vanya has passed the exams and got gra...
[{"type": "stdin_stdout", "input": "9 846678 205000\n102282 593538\n246630 24854\n545346 409737\n334264 443193\n37717 191227\n154582 913095\n97105 345066\n65504 578960\n163348 394257\n", "output": "2441209588\n"}, {"type": "stdin_stdout", "input": "10 10 10\n9 8\n3 9\n3 6\n10 5\n5 5\n6 10\n10 3\n6 7\n2 3\n9 8\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice became interested in periods of integer numbers. We say positive $X$ integer number is periodic with length $L$ if there exists positive integer number $P$ with $L$ digits such that $X$ can be written as $PPPP…P$. F...
[{"type": "stdin_stdout", "input": "3\n29939939929\n", "output": "100100100100\n"}, {"type": "stdin_stdout", "input": "3\n3021001003\n", "output": "100100100100\n"}, {"type": "stdin_stdout", "input": "10\n9969441321\n", "output": "9969441322\n"}, {"type": "stdin_stdout", "input": "3\n999999999\n", "output": "1001001001...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnatoly lives in the university dorm as many other students do. As you know, cockroaches are also living there together with students. Cockroaches might be of two colors: black and red. There are n cockroaches living in A...
[{"type": "stdin_stdout", "input": "166\nrbbbbbbbbbbbbrbrrbbrbbbrbbbbbbbbbbrbbbbbbrbbbrbbbbbrbbbbbbbrbbbbbbbrbbrbbbbbbbbrbbbbbbbbbbbbbbrrbbbrbbbbbbbbbbbbbbrbrbbbbbbbbbbbrbbbbbbbbbbbbbbrbbbbbbbbbbbbbbbbbbbbbb\n", "output": "70\n"}, {"type": "stdin_stdout", "input": "100\nbrbbbrrrbbrbrbbrbbrbbbbrbbrrbbbrrbbbbrbrbbbbbbbbb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSuppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for ...
[{"type": "stdin_stdout", "input": "5 5 3\n.....\n.....\n*...*\n*....\n.*...\n", "output": "18\n"}, {"type": "stdin_stdout", "input": "4 4 2\n....\n....\n....\n....\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "3 3 4\n.*.\n*.*\n.*.\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 3 1\n.*.\n.*.\n.*...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got an undirected graph, consisting of n vertices and m edges. We will consider the graph's vertices numbered with integers from 1 to n. Each vertex of the graph has a color. The color of the i-th vertex is an inte...
[{"type": "stdin_stdout", "input": "50 47\n21 17 47 15 50 47 47 41 28 18 27 47 29 28 32 26 16 26 8 22 27 10 45 21 17 30 31 38 14 8 9 40 29 35 41 24 22 14 40 46 44 34 40 31 48 40 8 50 1 28\n7 5\n50 2\n42 5\n36 28\n8 44\n36 3\n40 15\n33 18\n5 50\n1 6\n25 20\n39 24\n45 35\n14 27\n14 39\n17 47\n19 49\n28 7\n7 13\n34 3\n22 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp has got two strings $s$ and $t$ having equal length. Both strings consist of lowercase Latin letters \"a\" and \"b\". \n\nMonocarp wants to make these two strings $s$ and $t$ equal to each other. He can do the fo...
[{"type": "stdin_stdout", "input": "101\nbabbbbabbbbaabbbbbbbabbbababababbbbbbbbabaababbababbaaabbababbbbbbbbbaabbbababbbbbabbbbbabbbaabbbaabb\nbbabbbbbbabbbbbbbbbbbabbbbbbbbbbabbabbbbbbbbbbbabbababbbabbabbbbbbbbbbbbbaabbbabbbbabbabbbbababbbbbab\n", "output": "20\n2 7\n12 13\n21 25\n27 29\n31 40\n42 43\n45 50\n54 55\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.\n\nTo solve the issu...
[{"type": "stdin_stdout", "input": "100\n8820100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000026601\n", "output": "88201000000000000000000000000000000000000000000000000000000000000000000000000000000000000026601\n"}, {"type": "stdin_stdout", "input": "99\n92858678988128683760262...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe zombies are gathering in their secret lair! Heidi will strike hard to destroy them once and for all. But there is a little problem... Before she can strike, she needs to know where the lair is. And the intel she has i...
[{"type": "stdin_stdout", "input": "10\n0000000000\n0000000000\n0000000000\n0000000000\n0000000000\n0000000000\n0012100000\n0024200000\n0012100000\n0000000000\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "10\n0000000000\n0122210000\n0244420100\n0122210000\n0000000000\n0000000000\n0000000000\n0000000000\n00...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe define $x \\bmod y$ as the remainder of division of $x$ by $y$ ($\\%$ operator in C++ or Java, mod operator in Pascal).\n\nLet's call an array of positive integers $[a_1, a_2, \\dots, a_k]$ stable if for every permutat...
[{"type": "stdin_stdout", "input": "500000 250000\n", "output": "803991687\n"}, {"type": "stdin_stdout", "input": "123456 78901\n", "output": "963821949\n"}, {"type": "stdin_stdout", "input": "500000 500\n", "output": "882447093\n"}, {"type": "stdin_stdout", "input": "500000 200\n", "output": "123055441\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n incoming messages for Vasya. The i-th message is going to be received after t_{i} minutes. Each message has a cost, which equals to A initially. After being received, the cost of a message decreases by B each ...
[{"type": "stdin_stdout", "input": "108 576 610 844 573\n242 134 45 515 430 354 405 179 174 366 155 4 300 176 96 36 508 70 75 316 118 563 55 340 128 214 138 511 507 437 454 478 341 443 421 573 270 362 208 107 256 471 436 378 336 507 383 352 450 411 297 34 179 551 119 524 141 288 387 9 283 241 304 214 503 559 416 447 49...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBreaking Good is a new video game which a lot of gamers want to have. There is a certain level in the game that is really difficult even for experienced gamers.\n\nWalter William, the main character of the game, wants to ...
[{"type": "stdin_stdout", "input": "13 58\n9 12 0\n8 11 0\n4 8 0\n2 12 1\n9 1 1\n10 6 1\n5 2 1\n3 9 0\n8 3 0\n9 10 0\n8 5 1\n11 3 0\n11 1 0\n2 6 1\n12 3 1\n11 6 0\n1 12 0\n2 1 1\n11 13 0\n6 8 1\n11 5 1\n8 9 0\n1 4 0\n12 7 1\n5 12 0\n11 7 0\n10 2 0\n5 10 1\n9 4 1\n7 5 1\n2 11 0\n13 12 1\n10 3 1\n1 13 0\n7 1 0\n6 3 0\n7 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana). \n\nHe has n dollars. Ho...
[{"type": "stdin_stdout", "input": "859 453892 543\n", "output": "126416972"}, {"type": "stdin_stdout", "input": "1000 1000000000 1000\n", "output": "0"}, {"type": "stdin_stdout", "input": "634 87973 214\n", "output": "14497197"}, {"type": "stdin_stdout", "input": "432 10000 241\n", "output": "12587552"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKaavi, the mysterious fortune teller, deeply believes that one's fate is inevitable and unavoidable. Of course, she makes her living by predicting others' future. While doing divination, Kaavi believes that magic spells c...
[{"type": "stdin_stdout", "input": "babbaaababbbbabbaaaababbbaabababbaabbaababbaaabaabbabaabbaababababbaabaaabaaaaababbaabaaaaabaabbabaaababbbb\nbbaabbbbabbbbaaaaaababbbabaaabbbbabababbbaabbbbbabaababbaabaaabaabbababababaaaaabaabbabaaabaaaaaaaaaaaaabbb\n", "output": "284471294"}, {"type": "stdin_stdout", "input": "cbaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKefa wants to celebrate his first big salary by going to restaurant. However, he needs company. \n\nKefa has n friends, each friend will agree to go to the restaurant if Kefa asks. Each friend is characterized by the amou...
[{"type": "stdin_stdout", "input": "15 1234\n2738 322313356\n1160 970909702\n2594 902749351\n3126 324754476\n3151 177963947\n3424 396145897\n5578 737768323\n3423 687640543\n381 848813098\n1058 197211286\n936 650181776\n1025 776492538\n3598 142176544\n3595 680519527\n1191 32199940\n", "output": "3634263641\n"}, {"type":...
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\nFinally! Vasya have come of age and that means he can finally get a passport! To do it, he needs to visit the passport office, but it's not that simple. There's only one receptionist at the passport office and people can ...
[{"type": "stdin_stdout", "input": "37 3813 32\n117\n1 1 4 5 6 8 10 13 13 16 18 19 20 23 30 32 33 38 49 59 66 69 96 157 160 183 205 292 301 320 349 360 370 372 384 400 410 413 423 434 434 445 451 463 464 490 494 496 497 517 528 532 556 572 607 647 668 689 708 729 748 806 819 879 905 905 915 925 928 931 959 970 1133 114...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp loves ciphers. He has invented his own cipher called Right-Left.\n\nRight-Left cipher is used for strings. To encrypt the string $s=s_{1}s_{2} \\dots s_{n}$ Polycarp uses the following algorithm: he writes down ...
[{"type": "stdin_stdout", "input": "qwertyuioasdfghjklrtyuiodfghjklqwertyuioasdfssddxb\n", "output": "dfogihujyktlrqlwkejrhtgyfudisoaaosidufystsrdedwxqb\n"}, {"type": "stdin_stdout", "input": "qwertyuioasdfghjklrtyuiodfghjklqwertyuioasdfssdda\n", "output": "dfogihujyktlrqlwkejrhtgyfudisoaaosidufystsrdedwaq\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnton likes to play chess, and so does his friend Danik.\n\nOnce they have played n games in a row. For each game it's known who was the winner — Anton or Danik. None of the games ended with a tie.\n\nNow Anton wonders, w...
[{"type": "stdin_stdout", "input": "379\nAADAAAAAADDAAAAAADAADADADDAAAAADADDAADAAAADDDADAAAAAAADAADAAAAAAADAAAAAAAAADAAAAAAADAAAAAAAAAAADDDADAAAAAAAADAADADAAAADAAAAAAAAAAAAAAAAADAAAADDDAADAAAAAAADAAADAAADAADDDADDAAADAAAAAADDDADDDAAADAAAADAAAAAAAAADAAADAAAAAAAAADAAAAAAAAAAAAAAAAAADADAAAAAAAAAAADAAAAADAAAADAAAAAAAAAAAAAD...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\nFind the maximum possible value of M_1 + M_2 ...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "499999999500000000\n"}, {"type": "stdin_stdout", "input": "999999999\n", "output": "499999998500000001\n"}, {"type": "stdin_stdout", "input": "999999998\n", "output": "499999997500000003\n"}, {"type": "stdin_stdout", "input": "234679769\n", "output": "275372...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N dots in a two-dimensional plane. The coordinates of the i-th dot are (x_i, y_i).\nWe will repeat the following operation as long as possible:\n - Choose four integers a, b, c, d (a \\neq c, b \\neq d) such tha...
[{"type": "stdin_stdout", "input": "1000\n75100 60743\n9726 45312\n39324 37026\n6218 24919\n37911 86455\n24562 12622\n88324 30198\n33847 67328\n2909 91511\n42029 31498\n41511 74704\n96712 15653\n86190 59227\n59789 67915\n15677 3177\n66597 62255\n27003 69079\n83921 51556\n49566 24925\n44399 87252\n70161 73909\n7368 2727...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the number of sequences of length K consisting of positive integers such that the product of any two adjacent elements is at most N, modulo 10^9+7.\n\n-----Constraints-----\n - 1\\leq N\\leq 10^9\n - 1 2\\leq K\\leq ...
[{"type": "stdin_stdout", "input": "1000000000 100\n", "output": "926307829\n"}, {"type": "stdin_stdout", "input": "314159265 35\n", "output": "457397712\n"}, {"type": "stdin_stdout", "input": "900000000 89\n", "output": "780773257\n"}, {"type": "stdin_stdout", "input": "899999999 92\n", "output": "409296605\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has a water bottle with the shape of a rectangular prism whose base is a square of side a~\\mathrm{cm} and whose height is b~\\mathrm{cm}. (The thickness of the bottle can be ignored.)\nWe will pour x~\\mathrm{c...
[{"type": "stdin_stdout", "input": "100 100 1000000\n", "output": "0.0000000000\n"}, {"type": "stdin_stdout", "input": "82 84 416241\n", "output": "28.3216596827\n"}, {"type": "stdin_stdout", "input": "22 75 24126\n", "output": "66.3790171829\n"}, {"type": "stdin_stdout", "input": "45 72 83481\n", "output": "53.8288157...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has N sticks that are distinguishable from each other. The length of the i-th stick is L_i.\nHe is going to form a triangle using three of these sticks. Let a, b, and c be the lengths of the three sticks used. H...
[{"type": "stdin_stdout", "input": "2000\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 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs a token of his gratitude, Takahashi has decided to give his mother an integer sequence.\nThe sequence A needs to satisfy the conditions below:\n - A consists of integers between X and Y (inclusive).\n - For each 1\\leq...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "314159265 358979323846264338\n", "output": "31\n"}, {"type": "stdin_stdout", "input": "275278675 992237867823568722\n", "output": "32\n"}, {"type": "stdin_stdout", "input": "10000 1099511...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor an integer n not less than 0, let us define f(n) as follows:\n - f(n) = 1 (if n < 2)\n - f(n) = n f(n-2) (if n \\geq 2)\nGiven is an integer N. Find the number of trailing zeros in the decimal notation of f(N).\n\n---...
[{"type": "stdin_stdout", "input": "1000000000000000000\n", "output": "124999999999999995\n"}, {"type": "stdin_stdout", "input": "999003990299500294\n", "output": "124875498787437525\n"}, {"type": "stdin_stdout", "input": "237590337949089028\n", "output": "29698792243636116\n"}, {"type": "stdin_stdout", "input": "19073...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Chris is very keen on his toy blocks. His teacher, however, wants Chris to solve more problems, so he decided to play a trick on Chris.\n\nThere are exactly s blocks in Chris's set, each block has a unique number f...
[{"type": "stdin_stdout", "input": "10\n1 100000 199999 299998 399997 499996 599995 699994 799993 899992\n", "output": "10\n100009 200008 300007 400006 500005 600004 700003 800002 900001 1000000 \n"}, {"type": "stdin_stdout", "input": "10\n63649 456347 779 458642 201571 534312 583774 283450 377377 79066\n", "output": "...
code_stdio