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\nNatsuki and her friends were taken to the space by an alien and made friends with a lot of aliens. During the space travel, she discovered that aliens’ hands were often very different from humans’. Generally speaking, in ...
[{"type": "stdin_stdout", "input": "23 4\n2 3\n3 1\n6 4\n5 2", "output": "1966080\n"}, {"type": "stdin_stdout", "input": "23 4\n2 3\n3 1\n6 6\n5 2", "output": "2621440\n"}, {"type": "stdin_stdout", "input": "24 4\n2 3\n3 2\n4 4\n5 2", "output": "6291456\n"}, {"type": "stdin_stdout", "input": "19 4\n2 2\n3 4\n4 3\n9 5",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of $n$ integers $a_1$, $a_2$, ..., $a_n$, and a set $b$ of $k$ distinct integers from $1$ to $n$.\n\nIn one operation, you may choose two integers $i$ and $x$ ($1 \\le i \\le n$, $x$ can be any inte...
[{"type": "stdin_stdout", "input": "100 2\n96 58 6 51 50 14 42 14 8 23 50 87 18 38 66 12 60 34 67 79 73 79 100 94 89 73 4 13 30 3 34 26 41 65 18 71 29 3 40 65 77 83 51 20 38 45 43 64 7 12 97 42 88 32 62 61 92 17 83 14 3 23 5 58 3 64 17 35 23 86 65 22 44 81 30 95 62 63 17 85 3 3 17 56 26 94 59 84 3 88 70 53 52 74 12 47 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPavel cooks barbecue. There are n skewers, they lay on a brazier in a row, each on one of n positions. Pavel wants each skewer to be cooked some time in every of n positions in two directions: in the one it was directed o...
[{"type": "stdin_stdout", "input": "100\n87 69 49 86 96 12 10 79 29 66 48 77 73 62 70 52 22 28 97 35 91 5 33 82 65 85 68 80 64 8 38 23 94 34 75 53 57 6 100 2 56 50 55 58 74 9 18 44 40 3 43 45 99 51 21 92 89 36 88 54 42 14 78 71 25 76 13 11 27 72 7 32 93 46 83 30 26 37 39 31 95 59 47 24 67 16 4 15 1 98 19 81 84 61 90 41...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn order to celebrate Twice's 5th anniversary, Tzuyu and Sana decided to play a game.\n\nTzuyu gave Sana two integers $a$ and $b$ and a really important quest.\n\nIn order to complete the quest, Sana has to output the sma...
[{"type": "stdin_stdout", "input": "6\n6 12\n8 4\n90 1219\n55 14\n6484 2912\n2 1\n", "output": "10\n12\n1177\n57\n4660\n3\n"}, {"type": "stdin_stdout", "input": "6\n6 12\n13 4\n90 1219\n55 14\n6484 2912\n2 1\n", "output": "10\n9\n1177\n57\n4660\n3\n"}, {"type": "stdin_stdout", "input": "6\n6 12\n8 6\n90 1219\n55 14\n64...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have $n$ barrels lined up in a row, numbered from left to right from one. Initially, the $i$-th barrel contains $a_i$ liters of water.\n\nYou can pour water from one barrel to another. In one act of pouring, you can c...
[{"type": "stdin_stdout", "input": "2\n4 1\n19 5 2 5\n3 2\n0 0 1\n", "output": "24\n1\n"}, {"type": "stdin_stdout", "input": "2\n4 1\n5 16 5 5\n3 2\n0 0 1\n", "output": "21\n1\n"}, {"type": "stdin_stdout", "input": "2\n4 3\n10 1 1 2\n3 2\n0 1 1\n", "output": "14\n2\n"}, {"type": "stdin_stdout", "input": "2\n4 1\n5 16 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGuy-Manuel and Thomas are going to build a polygon spaceship.\n\nYou're given a strictly convex (i. e. no three points are collinear) polygon P which is defined by coordinates of its vertices. Define P(x,y) as a polygon o...
[{"type": "stdin_stdout", "input": "8\n-440365664 -1386303283\n107345267 -994221803\n248590739 -968608613\n473576011 -880752952\n138674534 994450706\n-164464580 986382989\n-522092561 852888831\n-874210729 485546704\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "8\n-440365664 -897818514\n107345267 -994221803\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nIvan plays a computer game that contains some microtransactions to make characters look cooler. Since Ivan wants his character to be really cool, he wa...
[{"type": "stdin_stdout", "input": "78 36\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0\n1 52\n2 6\n9 43\n10 52\n4 63\n9 35\n10 67\n9 17\n3 43\n4 38\n1 27\n9 44\n6 74\n7 3\n8 18\n1 52\n1 68\n5 51\n5 2\n7 50\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Vitaly was going home late at night and wondering: how many people aren't sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at that moment.\n\nVitaly...
[{"type": "stdin_stdout", "input": "100 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 0\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n0 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 0\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\...
[{"type": "stdin_stdout", "input": "86451 754 85 84\n", "output": "4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n + 1$ cities, numbered from $0$ to $n$. $n$ roads connect these cities, the $i$-th road connects cities $i - 1$ and $i$ ($i \\in [1, n]$).\n\nEach road has a direction. The directions are given by a string of ...
[{"type": "stdin_stdout", "input": "2\n6\nLRRRLL\n3\nLRL\n", "output": "\n1 3 2 3 1 3 2\n1 4 1 4\n"}, {"type": "stdin_stdout", "input": "2\n6\nLRRRLL\n3\nLRL\n", "output": "1 3 2 3 1 3 2\n1 4 1 4\n"}, {"type": "stdin_stdout", "input": "2\n6\nLLRRRL\n3\nLRL\n", "output": "1 2 3 2 3 1 3\n1 4 1 4\n"}, {"type": "stdin_stdo...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA permutation is a sequence of $n$ integers from $1$ to $n$, in which all numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.\n\nPo...
[{"type": "stdin_stdout", "input": "4\n7\n3 3 4 4 7 7 7\n4\n1 2 3 4\n7\n3 4 5 5 5 7 7\n1\n1\n", "output": "\n3 1 4 2 7 5 6 \n3 2 4 1 7 6 5 \n1 2 3 4 \n1 2 3 4 \n3 4 5 1 2 7 6 \n3 4 5 2 1 7 6 \n1 \n1 \n"}, {"type": "stdin_stdout", "input": "4\n7\n3 3 4 4 7 7 7\n4\n1 2 3 4\n7\n3 4 5 5 5 7 7\n1\n1\n", "output": "3 1 4 2 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n\"The Chamber of Secrets has been opened again\" — this news has spread all around Hogwarts and some of the students have been petrified due to seeing the basilisk. Dumbledore got fired and now Harry is trying to enter th...
[{"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\nWe have a sequence of k numbers: d_0,d_1,...,d_{k - 1}.\nProcess the following q queries in order:\n - The i-th query contains three integers n_i, x_i, and m_i.\nLet a_0,a_1,...,a_{n_i - 1} be the following sequence of n_...
[{"type": "stdin_stdout", "input": "7 3\n27 18 28 18 28 46 1000000000\n1000000000 1 7\n1000000000 2 10\n1000000000 3 12\n", "output": "224489796\n214285714\n559523809\n"}, {"type": "stdin_stdout", "input": "7 3\n27 18 15 18 28 73 1000000000\n1000000010 1 13\n1000000000 2 10\n1000010000 2 12", "output": "615384622\n3000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMisha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any...
[{"type": "stdin_stdout", "input": "5 20\n5 5 1 4\n1 4 3\n2 4 1\n1 5 5\n5 1 4\n5 1 5\n1 5 5\n5 4 4\n2 3 3\n4 4 1\n1 4 1\n4 5 4\n1 4 5\n4 1 5\n2 4 2\n4 3 3\n2 5 5\n1 5 4\n3 3 4\n5 5 1\n3 4 1\n", "output": "3\n3\n3\n2\n3\n3\n2\n3\n2\n2\n2\n2\n2\n3\n3\n2\n2\n3\n3\n3\n"}, {"type": "stdin_stdout", "input": "5 20\n4 1 1 4\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn 20XX, the Aizu Chuo Road, which has a total distance of 58km and 6 sections from Atsushiokanomachi, Kitakata City to Minamiaizucho, is scheduled to be completed and opened.\n\nFor half a year after opening, the toll wi...
[{"type": "stdin_stdout", "input": "2\n17 24\n4\n17 45\n2\n17 25\n7\n-1 35\n0", "output": "250\n1500\n"}, {"type": "stdin_stdout", "input": "2\n13 25\n6\n17 14\n4\n17 25\n7\n1 10\n0", "output": "1150\n1300\n"}, {"type": "stdin_stdout", "input": "2\n17 25\n4\n17 45\n4\n17 19\n7\n19 35\n0", "output": "250\n1300\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNate U. Smith runs a railroad company in a metropolitan area. In addition to his railroad company, there are rival railroad companies in this metropolitan area. The two companies are in a competitive relationship with eac...
[{"type": "stdin_stdout", "input": "2\n-10 1 10 1\n4\n-6 2 -2 -2 1 1\n-6 -2 -2 2 1 0\n12 2 1 -2 0 0\n11 -2 2 2 1 1\n8 12 -7 -3\n8\n4 -5 4 -2 1 2\n4 -2 4 9 1 0\n6 9 6 14 1 1\n-5 6 7 6 0 0\n1 0 1 10 0 0\n-5 0 -5 10 0 1\n-7 -1 7 0 0 1\n-1 -1 -1 -3 0 1", "output": "2\n3\n"}, {"type": "stdin_stdout", "input": "2\n-10 2 10 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is Kannon-do in the mountain behind Ichiro's house. There are 30 steps from the foot to this Kannon-do, and Ichiro goes to Kannon-do almost every day. Ichiro can go up the stairs up to 3 steps with one foot. While p...
[{"type": "stdin_stdout", "input": "1\n1\n30\n27\n0", "output": "1\n1\n14740\n2369\n"}, {"type": "stdin_stdout", "input": "1\n17\n28\n27\n0", "output": "1\n6\n4357\n2369\n"}, {"type": "stdin_stdout", "input": "1\n1\n30\n25\n0", "output": "1\n1\n14740\n701\n"}, {"type": "stdin_stdout", "input": "1\n17\n28\n24\n0", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nThere is a grid of $ R \\ times C $ squares with $ (0, 0) $ in the upper left and $ (R-1, C-1) $ in the lower right. When you are in a square ($ e $, $ f $), from there $ (e + 1, f) $, $ (e-1, f) $, $ (e, f + 1...
[{"type": "stdin_stdout", "input": "421 435 361 230 182 16", "output": "196 792283366\n"}, {"type": "stdin_stdout", "input": "421 547 377 188 235 13", "output": "156 501147202\n"}, {"type": "stdin_stdout", "input": "421 435 196 169 388 12", "output": "46 766230083\n"}, {"type": "stdin_stdout", "input": "421 435 196 169...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server ha...
[{"type": "stdin_stdout", "input": "10 10\nittmcs 112.147.123.173\njkt 228.40.73.178\nfwckqtz 88.28.31.198\nkal 224.226.34.213\nnacuyokm 49.57.13.44\nfouynv 243.18.250.17\ns 45.248.83.247\ne 75.69.23.169\nauwoqlch 100.44.219.187\nlkldjq 46.123.169.140\ngjcylatwzi 46.123.169.140;\ndxfi 88.28.31.198;\ngv 46.123.169.140;\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSome number of people (this number is even) have stood in a circle. The people stand in the circle evenly. They are numbered clockwise starting from a person with the number $1$. Each person is looking through the circle'...
[{"type": "stdin_stdout", "input": "7\n6 4 4\n2 3 0\n0 4 10\n5 3 4\n1 3 2\n4 5 12\n4 3 2\n", "output": "-1\n-1\n-1\n-1\n4\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "7\n6 2 4\n2 3 0\n2 4 10\n5 3 4\n1 3 2\n2 5 8\n4 3 2\n", "output": "8\n-1\n-1\n-1\n4\n-1\n-1\n"}, {"type": "stdin_stdout", "input": "7\n6 2 4\n2 3 1\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nR3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular loc...
[{"type": "stdin_stdout", "input": "100000000 100000000 100000000\n", "output": "266578227200000000\n"}, {"type": "stdin_stdout", "input": "100000000 100000000 100000000\n", "output": "266578227200000000\n"}, {"type": "stdin_stdout", "input": "100000000 100000010 100000000\n", "output": "266578239852872360\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.\n\nLet's consider list of all strings consisting of exactly $k$ lowercase Latin letter...
[{"type": "stdin_stdout", "input": "12\nlylfekzszgqx\noewrpuflwlir\n", "output": "nbqykcppkvzu\n"}, {"type": "stdin_stdout", "input": "12\nlylfekzszgqx\noewrpuflwril\n", "output": "nbqykcppkyzr\n"}, {"type": "stdin_stdout", "input": "12\nlylfekzszgqx\noewrpuflwlir\n", "output": "nbqykcppkvzu"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nFind the angle between the two given angles θ1 and θ2. Here, the angle between them is defined as \"θ1 & plus; t'when t'is the one with the smallest absolute value among the t satisfying θ1 & plus; t = θ2 − t\"...
[{"type": "stdin_stdout", "input": "20\n594", "output": "127.0000000000\n"}, {"type": "stdin_stdout", "input": "20\n704", "output": "182.0000000000\n"}, {"type": "stdin_stdout", "input": "20\n682", "output": "171.0000000000\n"}, {"type": "stdin_stdout", "input": "20\n253", "output": "316.5000000000\n"}, {"type": "stdin...
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\nLet's call an integer array $a_1, a_2, \\dots, a_n$ good if $a_i \\neq i$ for each $i$.\n\nLet $F(a)$ be the number of pairs $(i, j)$ ($1 \\le i < j \\le n$) such that $a_i + a_j = i + j$.\n\nLet's say that an array $a_1,...
[{"type": "stdin_stdout", "input": "10\n20000 -431912570 597469643\n20000 -13928452 414987414\n20000 -472808872 367983694\n20000 -84913058 517394906\n20000 -514402152 597357115\n20000 -720971736 526102810\n20000 -416160739 748291750\n20000 -665939649 743938438\n20000 -80741314 634025883\n20000 -824743396 138091345\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a text consisting of n lines. Each line contains some space-separated words, consisting of lowercase English letters.\n\nWe define a syllable as a string that contains exactly one vowel and any arbitrary num...
[{"type": "stdin_stdout", "input": "4\n13 11 15 15\nto be or not to be that is the question\nwhether tis nobler in the mind to suffer\nthe slings and arrows of outrageous fortune\nor to take arms against a sea of troubles\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "4\n13 11 15 15\nto be or not to be that...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPasha has recently bought a new phone jPager and started adding his friends' phone numbers there. Each phone number consists of exactly n digits.\n\nAlso Pasha has a number k and two sequences of length n / k (n is divisi...
[{"type": "stdin_stdout", "input": "100 1\n5 3 1 5 6 2 4 8 3 3 1 1 2 8 2 3 8 2 5 2 6 2 3 5 2 1 2 1 2 8 4 3 3 5 1 4 2 2 2 5 8 2 2 6 2 9 3 4 1 8 1 5 5 6 6 2 2 7 3 3 4 2 4 1 2 6 6 4 9 4 3 2 3 8 2 3 1 4 1 4 1 3 5 3 5 5 2 3 4 1 1 8 1 5 6 9 4 2 5 1\n6 0 4 5 3 1 0 7 5 3 5 4 5 4 0 2 1 6 2 2 4 3 1 9 5 9 2 2 6 8 6 5 9 6 4 9 9 7 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019.\n\nIntegers M_1, D_1, M_2, and D_2 will be given as input.\nIt is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1.\nDeter...
[{"type": "stdin_stdout", "input": "11 17\n11 122", "output": "0\n"}, {"type": "stdin_stdout", "input": "11 11\n11 101", "output": "0\n"}, {"type": "stdin_stdout", "input": "11 17\n11 17", "output": "0\n"}, {"type": "stdin_stdout", "input": "11 16\n11 28", "output": "0\n"}, {"type": "stdin_stdout", "input": "11 24\n11 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ students standing in a circle in some order. The index of the $i$-th student is $p_i$. It is guaranteed that all indices of students are distinct integers from $1$ to $n$ (i. e. they form a permutation).\n\n...
[{"type": "stdin_stdout", "input": "5\n4\n1 2 3 4\n3\n1 3 2\n5\n1 2 3 5 4\n1\n1\n5\n3 2 1 5 4\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "5\n4\n1 2 3 4\n3\n1 3 2\n5\n1 2 3 5 4\n1\n1\n5\n3 2 1 5 4\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "1\n12\n12 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMemory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion: An 'L' indicates he should move one unit left. An 'R' indicates he should move one ...
[{"type": "stdin_stdout", "input": "RDDLLDLUUUDDRDRURLUUURLLDDLRLUURRLLRRLDRLLUDRLRULLDLRRLRLRLRUDUUDLULURLLDUURULURLLRRRURRRDRUUDLDRLRDRLRRDDLDLDLLUDRUDRLLLLDRDUULRUURRDLULLULDUDULRURRDDDLLUDRLUDDLDDDRRDDDULLLLDLDRLRRLRRDDRLULURRUDRDUUUULDURUDRDLDDUDUDRRURDULRRUDRLRRDLUURURDLDRLRDUDDDLDDDURURLUULRDUUULRURUDUDRRUDULLLU...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nI have a lot of friends. Every friend is very small.\nI often go out with my friends. Put some friends in your backpack and go out together.\nEvery morning I decide which friends to go out with that day. Put friends one b...
[{"type": "stdin_stdout", "input": "6 50\n10\n30\n13\n18\n12\n16", "output": "15\n"}, {"type": "stdin_stdout", "input": "6 37\n6\n16\n13\n18\n12\n16", "output": "10\n"}, {"type": "stdin_stdout", "input": "6 50\n6\n16\n13\n18\n12\n16", "output": "12\n"}, {"type": "stdin_stdout", "input": "6 37\n5\n16\n13\n18\n26\n33", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. She decided to prepare a goodbye present for her n students and give each of them a jigsaw puzzle (whic...
[{"type": "stdin_stdout", "input": "50 50\n374 573 323 744 190 806 485 247 628 336 491 606 702 321 991 678 337 579 86 240 993 208 668 686 855 205 363 177 719 249 896 919 782 434 59 647 787 996 286 216 636 212 546 903 958 559 544 126 608 993\n", "output": "937\n"}, {"type": "stdin_stdout", "input": "50 50\n374 573 323 7...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the year 2xxx, an expedition team landing on a planet found strange objects made by an ancient species living on that planet. They are transparent boxes containing opaque solid spheres (Figure 1). There are also many l...
[{"type": "stdin_stdout", "input": "3\n95 20 180 18\n125 20 185 18\n40 26 195 10\n1\n6 5 5 4\n2\n5 5 5 4\n5 10 5 2\n2\n5 5 11 6\n0 7 5 3\n16\n2338 3465 29034 1351\n1571 14389 25019 842\n1706 8015 21355 1155\n1899 4359 33815 888\n2160 10364 20511 2353\n333 8835 6587 63\n2598 3176 23679 618\n1613 14217 8003 1505\n3140 47...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou're given an array $a_1, \\ldots, a_n$ of $n$ non-negative integers.\n\nLet's call it sharpened if and only if there exists an integer $1 \\le k \\le n$ such that $a_1 < a_2 < \\ldots < a_k$ and $a_k > a_{k+1} > \\ldot...
[{"type": "stdin_stdout", "input": "10\n1\n248618\n3\n23 21 11\n6\n110 11 15 10 1 14\n4\n0 2 1 0\n2\n0 0\n2\n0 1\n2\n1 0\n2\n1 0\n3\n0 1 0\n3\n1 0 1\n", "output": "YES\nYES\nYES\nYES\nNO\nYES\nYES\nYES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "10\n1\n248618\n3\n23 21 11\n6\n110 11 15 0 1 14\n4\n0 2 1 0\n2\n0 0\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAre you going to Scarborough Fair?\n\nParsley, sage, rosemary and thyme.\n\nRemember me to one who lives there.\n\nHe once was the true love of mine.\n\nWillem is taking the girl to the highest building in island No.28, h...
[{"type": "stdin_stdout", "input": "67 39\nacbcbccccbabaabcabcaaaaaaccbcbbcbaaaacbbcccbcbabbcacccbbabbabbabaac\n4 36 a b\n25 38 a a\n3 44 b c\n35 57 b a\n4 8 a c\n20 67 c a\n30 66 b b\n27 40 a a\n2 56 a b\n10 47 c a\n22 65 c b\n29 42 a b\n1 46 c b\n57 64 b c\n20 29 b a\n14 51 c a\n12 55 b b\n20 20 a c\n2 57 c a\n22 60 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou will be given an integer a and a string s consisting of lowercase English letters as input.\nWrite a program that prints s if a is not less than 3200 and prints red if a is less than 3200.\n\n-----Constraints-----\n -...
[{"type": "stdin_stdout", "input": "4999\nzzzzzzzzzz\n", "output": "zzzzzzzzzz\n"}, {"type": "stdin_stdout", "input": "4998\nrainbow\n", "output": "rainbow\n"}, {"type": "stdin_stdout", "input": "3201\npurple\n", "output": "purple\n"}, {"type": "stdin_stdout", "input": "3200\npink\n", "output": "pink\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe secret organization AiZu AnalyticS has launched a top-secret investigation. There are N people targeted, with identification numbers from 1 to N. As an AZAS Information Strategy Investigator, you have decided to deter...
[{"type": "stdin_stdout", "input": "100\n3 -1 100 3\n-1\n2 4 3", "output": "1\n"}, {"type": "stdin_stdout", "input": "100\n3 0 001 4\n-2\n2 10 3", "output": "2\n"}, {"type": "stdin_stdout", "input": "100\n3 0 001 4\n-3\n2 10 3", "output": "2\n"}, {"type": "stdin_stdout", "input": "100\n3 -1 100 3\n-1\n2 6 3", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is a harder version of the problem. In this version, n ≤ 300 000.\n\nVasya is an experienced developer of programming competitions' problems. As all great minds at some time, Vasya faced a creative crisis. To improve...
[{"type": "stdin_stdout", "input": "500\n)))())(())((()))()((())())((()))()()(()(()))((()))(()()())()(())()()()(()()(()))((()))(((()))()())()((()))()()(()()(()())())(((()))()())(()())(()()(())())()((()))()()((())())(())()()()()()()(())()()(()())(((())))(()())((()))()((()))()(((()())))()(()(())())()(()())(()())(())((())...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term \"equivalence relation\". These relations are very important in many areas of mathematics. For examp...
[{"type": "stdin_stdout", "input": "2000\n", "output": "323848720\n"}, {"type": "stdin_stdout", "input": "4000\n", "output": "341934157\n"}, {"type": "stdin_stdout", "input": "2345\n", "output": "832335061\n"}, {"type": "stdin_stdout", "input": "2500\n", "output": "544067513\n"}, {"type": "stdin_stdout", "input": "2780...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are beta testing the new secret Terraria update. This update will add quests to the game!\n\nSimply, the world map can be represented as an array of length $n$, where the $i$-th column of the world has height $a_i$.\n...
[{"type": "stdin_stdout", "input": "38 1\n2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999 2 999999999\n7 2\n", "output": "1999999994\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a square field of size $n \\times n$ in which two cells are marked. These cells can be in the same row or column.\n\nYou are to mark two more cells so that they are the corners of a rectangle with sides parallel ...
[{"type": "stdin_stdout", "input": "6\n4\n..*.\n....\n*...\n....\n2\n*.\n.*\n2\n.*\n.*\n3\n*.*\n...\n...\n5\n.....\n..*..\n.....\n.*...\n.....\n4\n....\n....\n*...\n*...\n", "output": "\n*.*.\n....\n*.*.\n....\n**\n**\n**\n**\n*.*\n*.*\n...\n.....\n.**..\n.....\n.**..\n.....\n....\n....\n**..\n**..\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnchored Balloon\n\nA balloon placed on the ground is connected to one or more anchors on the ground with ropes. Each rope is long enough to connect the balloon and the anchor. No two ropes cross each other. Figure E-1 sh...
[{"type": "stdin_stdout", "input": "3\n10 10 20\n10 -10 25\n-10 10 120\n1\n10 10 16\n2\n10 10 20\n10 -10 20\n2\n100 0 101\n-90 0 91\n2\n0 0 53\n40 40 102\n3\n10 10 20\n10 -10 20\n-10 -10 20\n3\n1 5 13\n5 -3 13\n-3 -2 13\n3\n98 97 168\n-82 -80 193\n-170 -160 211\n4\n90 -100 160\n-80 -80 150\n90 137 150\n80 80 245\n4\n85...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe numbers of all offices in the new building of the Tax Office of IT City will have lucky numbers.\n\nLucky number is a number that consists of digits 7 and 8 only. Find the maximum number of offices in the new building...
[{"type": "stdin_stdout", "input": "55\n", "output": "72057594037927934\n"}, {"type": "stdin_stdout", "input": "54\n", "output": "36028797018963966\n"}, {"type": "stdin_stdout", "input": "54\n", "output": "36028797018963966"}, {"type": "stdin_stdout", "input": "55\n", "output": "72057594037927934"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a$ consisting of $n$ integers. You have to find the length of the smallest (shortest) prefix of elements you need to erase from $a$ to make it a good array. Recall that the prefix of the array $a=[...
[{"type": "stdin_stdout", "input": "5\n4\n1 2 3 4\n7\n4 8 3 16 4 10 2\n3\n0 1 1\n7\n1 3 1 4 5 3 2\n5\n5 3 3 2 5\n", "output": "0\n4\n0\n2\n3\n"}, {"type": "stdin_stdout", "input": "5\n4\n1 2 3 4\n7\n13 3 4 8 4 5 2\n3\n1 1 1\n7\n1 3 1 7 5 0 2\n5\n5 4 3 2 3\n", "output": "0\n4\n0\n5\n3\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the hard version of the problem. The difference between the versions is that the easy version has no swap operations. You can make hacks only if all versions of the problem are solved.\n\nPikachu is a cute and fri...
[{"type": "stdin_stdout", "input": "5\n2 0\n1 2\n2 1\n1 2\n1 2\n2 1\n2 1\n1 2\n3 9\n1 2 3\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n3 0\n3 2 1\n", "output": "2\n2\n2\n2\n2\n3\n4\n4\n3\n3\n3\n3\n4\n4\n3\n3\n"}, {"type": "stdin_stdout", "input": "5\n2 0\n1 2\n2 1\n1 2\n1 2\n2 1\n2 1\n1 2\n3 9\n1 2 3\n1 2\n1 3\n2 3\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nG --Derangement / Derangement\n\nStory\n\nPerson D is doing research on permutations. At one point, D found a permutation class called \"Derangement\". \"It's cool to have a perfect permutation !!! And it starts with D !!...
[{"type": "stdin_stdout", "input": "5\n4 0 0 10 12", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n4 1 0 10 12", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n4 1 0 10 19", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n4 1 0 10 38", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSnuke received a triangle as a birthday present. The coordinates of the three vertices were (x_1, y_1), (x_2, y_2), and (x_3, y_3).\n\nHe wants to draw two circles with the same radius inside the triangle such that the tw...
[{"type": "stdin_stdout", "input": "-1 -1\n1 1\n2 0", "output": "0.402627528107\n"}, {"type": "stdin_stdout", "input": "3 -1\n2 5\n1 16", "output": "0.143556168892\n"}, {"type": "stdin_stdout", "input": "-3 1\n1 1\n2 -1", "output": "0.548232156368\n"}, {"type": "stdin_stdout", "input": "6 -2\n2 5\n1 18", "output": "0.9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDefine a cyclic sequence of size $n$ as an array $s$ of length $n$, in which $s_n$ is adjacent to $s_1$.\n\nMuxii has a ring represented by a cyclic sequence $a$ of size $n$.\n\nHowever, the ring itself hates equal adjace...
[{"type": "stdin_stdout", "input": "1\n100\n60 76 89 77 41 81 42 49 39 37 48 56 26 38 85 50 40 13 20 24 79 21 22 9 92 11 45 58 55 62 69 82 97 67 18 32 88 84 19 96 7 36 83 95 52 98 44 53 12 75 90 87 28 3 1 6 15 65 68 94 30 99 78 63 46 86 47 73 72 66 74 80 35 70 51 33 16 93 34 10 23 71 17 5 2 64 43 100 29 8 27 31 14 25 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFind the number, modulo 998244353, of sequences of length N consisting of 0, 1 and 2 such that none of their contiguous subsequences totals to X.\n\nConstraints\n\n* 1 \\leq N \\leq 3000\n* 1 \\leq X \\leq 2N\n* N and X a...
[{"type": "stdin_stdout", "input": "102 205", "output": "214138673\n"}, {"type": "stdin_stdout", "input": "169 205", "output": "909969555\n"}, {"type": "stdin_stdout", "input": "613 159", "output": "832714847\n"}, {"type": "stdin_stdout", "input": "325 205", "output": "688557253\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOnce little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is 1 square me...
[{"type": "stdin_stdout", "input": "hvewdvwdwudrwarwmddwnazmwauzatrmwptwwevavpmwrtruwnpwantewrnwmepdwvtmnveanunrvrtwpvhhnuhnmpptdttzmmndtvudmzhhannmmnahdpzamuvhzaavnhtnumwrwvttdetvuewaaennddwuvzvaptdzrzhtetwwzmzedrwuvrwznprhdvnavrruvvhzuwpdtmpwmzrwvermrhdamv\nuvzhwtpuputnahwwarduzddhpnwwvettprwavdmnztdnrddmarmvuevtdezn...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the pet store on sale there are:\n\n$a$ packs of dog food;\n\n$b$ packs of cat food;\n\n$c$ packs of universal food (such food is suitable for both dogs and cats).\n\nPolycarp has $x$ dogs and $y$ cats. Is it possible ...
[{"type": "stdin_stdout", "input": "7\n1 1 4 2 3\n0 0 0 0 0\n5 5 0 4 6\n1 1 1 1 1\n50000000 50000000 100000000 100000000 100000000\n0 0 0 100000000 100000000\n1 3 2 2 5\n", "output": "YES\nYES\nNO\nYES\nYES\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "3\n0 0 0 0 0\n2 1 0 2 2\n60 600 609 700 500\n", "output": "YES\nN...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe city administration of IT City decided to fix up a symbol of scientific and technical progress in the city's main square, namely an indicator board that shows the effect of Moore's law in real time.\n\nMoore's law is ...
[{"type": "stdin_stdout", "input": "10000 671249297\n", "output": "16096020.300745647400617599487304687500"}, {"type": "stdin_stdout", "input": "10001 671249297\n", "output": "16097629.902775721624493598937988281250"}, {"type": "stdin_stdout", "input": "11001 671249297\n", "output": "17707231.93285028636455535888671875...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou received as a gift a very clever robot walking on a rectangular board. Unfortunately, you understood that it is broken and behaves rather strangely (randomly). The board consists of N rows and M columns of cells. The ...
[{"type": "stdin_stdout", "input": "1000 1000\n162 276\n", "output": "3351.9999999997744\n"}, {"type": "stdin_stdout", "input": "1000 1000\n153 276\n", "output": "3387.9999999997344\n"}, {"type": "stdin_stdout", "input": "1000 1000\n162 234\n", "output": "3351.999999903682\n"}, {"type": "stdin_stdout", "input": "663 90...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEhab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices numbered from 0 to n - 1. For all 0 ≤ u < v < n, vert...
[{"type": "stdin_stdout", "input": "1000000000000\n", "output": "20140978692096\n"}, {"type": "stdin_stdout", "input": "1000100000000\n", "output": "20142429742080\n"}, {"type": "stdin_stdout", "input": "1000100000010\n", "output": "20142429742357\n"}, {"type": "stdin_stdout", "input": "1001100000010\n", "output": "201...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDo you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that each of ...
[{"type": "stdin_stdout", "input": "10\n536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132\n", "output": "536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 536259132 "}, {"type": "stdin_stdout", "input": "10\n876584065 876584063 87...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer array $a_1, a_2, \\dots, a_n$ and integer $k$.\n\nIn one step you can\n\neither choose some index $i$ and decrease $a_i$ by one (make $a_i = a_i - 1$);\n\nor choose two indices $i$ and $j$ and set...
[{"type": "stdin_stdout", "input": "1\n98 282\n103 948 349 26 241 933 394 546 476 785 441 397 658 308 801 940 760 29 717 343 99 530 389 797 955 322 662 763 654 781 1814 185 622 960 363 84 375 998 331 572 236 837 604 874 376 362 649 482 860 718 54 298 574 1726 16 943 71 292 615 829 460 301 358 245 585 438 24 561 252 416...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAn X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you sta...
[{"type": "stdin_stdout", "input": "7\n50\n30\n50\n100\n50\n80\n30\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "7\n50\n30\n50\n100\n50\n80\n35", "output": "5\n"}, {"type": "stdin_stdout", "input": "7\n50\n40\n91\n110\n50\n34\n59", "output": "6\n"}, {"type": "stdin_stdout", "input": "7\n50\n30\n50\n100\n50\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or is a wall. You can go from one cell to another only if both cells are empty and have a common side.\n\nPavel drew a grid m...
[{"type": "stdin_stdout", "input": "19 20 196\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\nIt's holiday. Mashmokh and his boss, Bimokh, are playing a game invented by Mashmokh. \n\nIn this game Mashmokh writes sequence of n distinct integers on the board. Then Bimokh makes several (possibly zero) moves. On the ...
[{"type": "stdin_stdout", "input": "16199 5506872\n", "output": "5498774 10997548 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 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor integers b (b \\geq 2) and n (n \\geq 1), let the function f(b,n) be defined as follows:\n\n* f(b,n) = n, when n < b\n* f(b,n) = f(b,\\,{\\rm floor}(n / b)) + (n \\ {\\rm mod} \\ b), when n \\geq b\n\n\n\nHere, {\\rm ...
[{"type": "stdin_stdout", "input": "31415926535\n13", "output": "15707963262\n"}, {"type": "stdin_stdout", "input": "31415926535\n2", "output": "31415926534\n"}, {"type": "stdin_stdout", "input": "31415926535\n4", "output": "31415926532\n"}, {"type": "stdin_stdout", "input": "31415926535\n3", "output": "15707963267\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from 1 to n. We say that this permutation maps value 1 into the value p1, value 2 into the value p2 a...
[{"type": "stdin_stdout", "input": "50 20365011074\n", "output": "2 1 4 3 6 5 8 7 10 9 12 11 14 13 16 15 18 17 20 19 22 21 24 23 26 25 28 27 30 29 32 31 34 33 36 35 38 37 40 39 42 41 44 43 46 45 48 47 50 49 "}, {"type": "stdin_stdout", "input": "50 5608642004\n", "output": "1 2 4 3 5 6 8 7 9 10 11 13 12 15 14 17 16 18 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven a set of integers (it can contain equal elements).\n\nYou have to split it into two subsets $A$ and $B$ (both of them can contain equal elements or be empty). You have to maximize the value of $mex(A)+mex(B)$.\n\nHe...
[{"type": "stdin_stdout", "input": "1\n100\n0 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 91 92 93 94 9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDescription\n\nIn 200X, the mysterious circle K, which operates at K University, announced K Poker, a new game they created on the 4th floor of K East during the university's cultural festival.\nAt first glance, this game...
[{"type": "stdin_stdout", "input": "3\n0 1 0 1 0 0 0 -1 0 1 0 -1 0\n1 0 0 0 0 0 1 0 0 0 0 0 2\n0 1 1 0 1 1 1 0 1 0 0 5 5\n3 1 1 1 0 1 0 0 1 0 3 -1 1\n1 1 2 7 5 10 20 50 100\n7H 6H 2H 5H 3H\n9S 9C 9H 8H 8D\nKS KH QH JD TS\n10\n1 1 1 1 1 1 1 1 1 0 1 1 1\n0 1 1 1 1 1 1 1 1 1 1 1 1\n1 1 1 1 2 1 1 1 1 1 1 1 0\n1 1 1 1 1 1 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSummer is coming! It's time for Iahub and Iahubina to work out, as they both want to look hot at the beach. The gym where they go is a matrix a with n lines and m columns. Let number a[i][j] represents the calories burned...
[{"type": "stdin_stdout", "input": "4 5\n22972 40786 3691 85313 46694\n33077 16067 3134 97367 68508\n4250 35501 17327 14435 32518\n64673 65438 56977 123599 27280\n", "output": "753143\n"}, {"type": "stdin_stdout", "input": "4 5\n22972 40786 3691 85313 46694\n33077 16067 3134 97367 129038\n4250 35501 17327 14435 32518\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n100 years have passed since the last victory of the man versus computer in Go. Technologies made a huge step forward and robots conquered the Earth! It's time for the final fight between human and robot that will decide t...
[{"type": "stdin_stdout", "input": "68 -9959\n-3666\n-3501\n9169\n5724\n1478\n-643\n-3039\n-5537\n-4295\n-1856\n-6720\n6827\n-39\n-9509\n-7005\n1942\n-5173\n-4564\n2390\n4604\n-6098\n-9847\n-9708\n2382\n7421\n8716\n9718\n9895\n-4553\n-8275\n4771\n1538\n-8131\n9912\n-4334\n-3702\n7035\n-106\n-1298\n-6190\n1321\n332\n767...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3\nNNN\nNNN\nNNN\n\n\nOutput\n\nTaro\n\nThe input will be stdin and you should print your solution to stdout\n\n\nNow solve the problem and return the code.\n\nWrite Python code to solve this problem. ...
[{"type": "stdin_stdout", "input": "3\nNNN\nNNO\nNNN", "output": "Taro\n"}, {"type": "stdin_stdout", "input": "3\nNMN\nNNO\nNNN", "output": "Taro\n"}, {"type": "stdin_stdout", "input": "3\nNMN\nNNP\nNNN", "output": "Taro\n"}, {"type": "stdin_stdout", "input": "3\nMMN\nNNO\nNNN", "output": "Taro\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRng is baking cookies.\n\nInitially, he can bake one cookie per second.\n\nHe can also eat the cookies baked by himself. When there are x cookies not yet eaten, he can choose to eat all those cookies. After he finishes ea...
[{"type": "stdin_stdout", "input": "1000000000000 1000000100000", "output": "1000000000000\n"}, {"type": "stdin_stdout", "input": "1000010000000 1000100100001", "output": "1000010000000\n"}, {"type": "stdin_stdout", "input": "1000110000000 1000100100001", "output": "1000102100111\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a positive integer $n$.\n\nLet $S(x)$ be sum of digits in base 10 representation of $x$, for example, $S(123) = 1 + 2 + 3 = 6$, $S(0) = 0$.\n\nYour task is to find two integers $a, b$, such that $0 \\leq a, ...
[{"type": "stdin_stdout", "input": "1000000000000\n", "output": "109\n"}, {"type": "stdin_stdout", "input": "1000000000000\n", "output": "109\n"}, {"type": "stdin_stdout", "input": "999999999992\n", "output": "200\n"}, {"type": "stdin_stdout", "input": "290687942106\n", "output": "153\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array of positive integers a_1, a_2, ..., a_{n} × T of length n × T. We know that for any i > n it is true that a_{i} = a_{i} - n. Find the length of the longest non-decreasing sequence of the given array...
[{"type": "stdin_stdout", "input": "100 10000000\n300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 300 30...
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\nGiven a positive integer n, find k integers (not necessary distinct) such that all these integers are strictly greater than 1, and their product is equal to n.\n\nInput\n\nThe first line contains two integers n and k (2 ≤...
[{"type": "stdin_stdout", "input": "100000 10\n", "output": "2 2 2 2 2 5 5 5 5 5\n"}, {"type": "stdin_stdout", "input": "2048 11\n", "output": "2 2 2 2 2 2 2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "1024 10\n", "output": "2 2 2 2 2 2 2 2 2 2\n"}, {"type": "stdin_stdout", "input": "100000 8\n", "output": "2 2 2 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEmail address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters. \n\nBob is a system administrator in «Bersoft» company. He keeps a list of email addresses of th...
[{"type": "stdin_stdout", "input": "c@ir@xf@ap@fk@sp@wm@ec@qw@vg@by@iu@tr@wu@pv@lj@dd@tc@qj@ok@hm@bs@ul@ez@cg@ht@xf@ag@tr@hz@ap@tx@ly@dg@hu@nd@uv@il@ii@cn@nc@nb@cy@kp@dk@xa@da@ta@yr@yv@qg@db@je@wz@rn@yh@xi@mj@kc@uj@yu@cf@ps@ao@fo@le@d\n", "output": "c@i,r@x,f@a,p@f,k@s,p@w,m@e,c@q,w@v,g@b,y@i,u@t,r@w,u@p,v@l,j@d,d@t,c@...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Russian here \nThe Head Chef is studying the motivation and satisfaction level of his chefs . The motivation and satisfaction of a Chef can be represented as an integer . The Head Chef wants to...
[{"type": "stdin_stdout", "input": "1\n6 1\n0 12 11\n7 5 10\n7", "output": "19\n"}, {"type": "stdin_stdout", "input": "1\n6 1\n0 10 11\n7 5 10\n7", "output": "18\n"}, {"type": "stdin_stdout", "input": "1\n10 1\n1 5 -1\n6 -1 2\n1", "output": "-2\n"}, {"type": "stdin_stdout", "input": "1\n10 1\n1 5 -2\n6 -1 2\n1", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe game of billiards involves two players knocking 3 balls around\non a green baize table. Well, there is more to it, but for our\npurposes this is sufficient.\nThe game consists of several rounds and in each round both ...
[{"type": "stdin_stdout", "input": "5\n140 82\n141 134\n90 110\n339 106\n88 90", "output": "1 278\n"}, {"type": "stdin_stdout", "input": "5\n140 82\n176 134\n90 110\n289 106\n88 90", "output": "1 263\n"}, {"type": "stdin_stdout", "input": "5\n140 147\n141 71\n172 110\n339 30\n40 90", "output": "1 434\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAka Beko, trying to escape from 40 bandits, got lost in the city of A. Aka Beko wants to go to City B, where the new hideout is, but the map has been stolen by a bandit.\n\nKobborg, one of the thieves, sympathized with Ak...
[{"type": "stdin_stdout", "input": "0100\n0101\n10100\n10000\n0101011\n1011\n011111\n#", "output": "Yes\nNo\nYes\nNo\nYes\nYes\nYes\n"}, {"type": "stdin_stdout", "input": "0100\n0100\n10100\n10000\n0101011\n1001\n011111\n#", "output": "Yes\nYes\nYes\nNo\nYes\nNo\nYes\n"}, {"type": "stdin_stdout", "input": "0100\n0100\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA positive integer may be expressed as a sum of different prime numbers (primes), in one way or another. Given two positive integers n and k, you should count the number of ways to express n as a sum of k different primes...
[{"type": "stdin_stdout", "input": "24 3\n24 2\n2 1\n1 1\n4 2\n18 3\n17 1\n17 3\n17 4\n110 5\n1000 10\n1120 14\n0 0", "output": "2\n3\n1\n0\n0\n2\n1\n0\n1\n79\n200102899\n2079324314\n"}, {"type": "stdin_stdout", "input": "24 3\n24 2\n2 1\n1 1\n4 2\n33 3\n17 1\n17 3\n17 4\n100 5\n1000 10\n1120 14\n0 0", "output": "2\n3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th w...
[{"type": "stdin_stdout", "input": "15\n18 6 18 21 14 20 13 9 18 20 28 13 19 25 21\n", "output": "10 -1 8 8 6 6 0 -1 2 2 3 -1 -1 0 -1 "}, {"type": "stdin_stdout", "input": "15\n14 4 5 12 6 19 14 19 12 22 23 17 14 21 27\n", "output": "7 -1 -1 0 -1 6 1 4 -1 3 2 0 -1 -1 -1 "}, {"type": "stdin_stdout", "input": "15\n14 4 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given circle $A$ with radius $r_a$ and with central coordinate $(x_a, y_a)$ and circle $B$ with radius $r_b$ and with central coordinate $(x_b, y_b)$.\n\nWrite a program which prints:\n\n* \"2\" if $B$ is in $A$,\...
[{"type": "stdin_stdout", "input": "2\n1.3018830993798196 1.1804991696233216 6.678597997840617 2.1321559253491804 2.072303142011048 4.898405435743801\n1.6154186783950772 0.39921226227011497 2.512872370263131 5.273208013897418 2.169775861927481 3.924014997809771", "output": "2\n1\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nUser ainta has a stack of n red and blue balls. He can apply a certain operation which changes the colors of the balls inside the stack.\n\n While the top ball inside the stack is red, pop the ball from the top of the st...
[{"type": "stdin_stdout", "input": "50\nBRRRBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n", "output": "1125899906842609\n"}, {"type": "stdin_stdout", "input": "50\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n", "output": "1125899906842623\n"}, {"type": "stdin_stdout", "input": "50\nBBBBBBBBBBBBBBBBBBBBBBBBBB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA trick of fate caused Hatsumi and Taku to come to know each other. To keep the encounter in memory, they decided to calculate the difference between their ages. But the difference in ages varies depending on the day it i...
[{"type": "stdin_stdout", "input": "1505 13 9\n2619 11 3", "output": "1114\n"}, {"type": "stdin_stdout", "input": "2137 -1 28\n1419 -2 1", "output": "719\n"}, {"type": "stdin_stdout", "input": "2137 -1 28\n1818 -1 1", "output": "320\n"}, {"type": "stdin_stdout", "input": "2137 -1 28\n3039 -1 1", "output": "902\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBetter things, cheaper. There is a fierce battle at the time sale held in some supermarkets today. \"LL-do\" here in Aizu is one such supermarket, and we are holding a slightly unusual time sale to compete with other chai...
[{"type": "stdin_stdout", "input": "6 5\n1 1 . 0 0 4\n1 . . . . .\n. . 2 2 . .\n. . 2 2 3 3\nP . - . . .\n5\n0 50 5 10\n1 20 0 10\n2 10 5 15\n3 150 3 10\n4 100 8 9\n0 0", "output": "330\n"}, {"type": "stdin_stdout", "input": "6 5\n1 0 . 0 0 4\n1 . . . . .\n. . 2 2 . .\n. . 2 2 3 3\nP . . . . .\n5\n0 50 8 10\n1 20 0 10\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a grid, consisting of n rows and m columns. Each cell of the grid is either free or blocked. One of the free cells contains a lab. All the cells beyond the borders of the grid are also blocked.\n\nA crazy robot h...
[{"type": "stdin_stdout", "input": "1\n3 31\n############################..#\n.............................L.\n############################..#\n", "output": "############################++#\n+++++++++++++++++++++++++++++L+\n############################++#\n"}, {"type": "stdin_stdout", "input": "1\n3 31\n###############...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given several queries. Each query consists of three integers p, q and b. You need to answer whether the result of p/q in notation with base b is a finite fraction.\n\nA fraction in notation with base b is finite i...
[{"type": "stdin_stdout", "input": "11\n1 1000000000000000000 10000000\n2 999 9\n2 999 333111\n0 15 14\n17 128 2\n13 311992186885373952 18\n1971402979058461 97576870171850009 100\n14 19 23\n3 21914624432020321 23\n0 21914624432020321 46\n3 21914624432020321 47\n", "output": "Finite\nInfinite\nFinite\nFinite\nFinite\nFi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a + b = ?, and that the base of the pos...
[{"type": "stdin_stdout", "input": "1000 1000\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1000 539\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "999 1000\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "1000 999\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "998 1000\n", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe have a grid with H rows and W columns of squares. We will represent the square at the i-th row from the top and j-th column from the left as (i,\\ j). Also, we will define the distance between the squares (i_1,\\ j_1) ...
[{"type": "stdin_stdout", "input": "6 7 12", "output": "RRRRRRR\nRRRRRRR\nRRRRRRR\nRRRRRRR\nRRRRRRR\nYRRRRRR\n"}, {"type": "stdin_stdout", "input": "7 6 1", "output": "RBRBRB\nBRBRBR\nRBRBRB\nBRBRBR\nRBRBRB\nBRBRBR\nRBRBRB\n"}, {"type": "stdin_stdout", "input": "6 6 12", "output": "RRRRRR\nRRRRRR\nRRRRRR\nRRRRRR\nRRRRR...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n seats in the train's car and there is exactly one passenger occupying every seat. The seats are numbered from 1 to n from left to right. The trip is long, so each passenger will become hungry at some moment of...
[{"type": "stdin_stdout", "input": "100 1000000000\n12 803 439 918 435 300 497 520 718 573 782 523 328 88 275 159 128 389 920 869 503 80 490 289 22 889 353 799 29 131 587 123 405 221 727 135 248 348 299 833 19 943 471 410 635 626 784 712 213 724 550 661 860 536 718 173 406 832 520 748 512 29 466 982 574 848 11 693 915 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMishka is trying really hard to avoid being kicked out of the university. In particular, he was doing absolutely nothing for the whole semester, miraculously passed some exams so that just one is left.\n\nThere were $n$ c...
[{"type": "stdin_stdout", "input": "200\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel is participating in a party in Prime Kingdom. There are n foxes there (include Fox Ciel). The i-th fox is ai years old.\n\nThey will have dinner around some round tables. You want to distribute foxes such that:\n...
[{"type": "stdin_stdout", "input": "178\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 12 6 6 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring their New Year holidays, Alice and Bob play the following game using an array $a$ of $n$ integers:\n\nPlayers take turns, Alice moves first.\n\nEach turn a player chooses any element and removes it from the array.\...
[{"type": "stdin_stdout", "input": "4\n4\n5 0 6 3\n3\n1 2 1\n4\n2 4 2 2\n2\n14 2\n", "output": "Alice\nAlice\nAlice\nAlice\n"}, {"type": "stdin_stdout", "input": "4\n4\n5 0 6 3\n3\n1 2 1\n4\n2 4 2 2\n2\n14 3\n", "output": "Alice\nAlice\nAlice\nAlice\n"}, {"type": "stdin_stdout", "input": "4\n4\n5 2 10 3\n3\n6 2 0\n4\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRingo Kingdom Congress is voting on a bill.\n\nN members are present, and the i-th member (1 ≤ i ≤ N) has w_i white ballots and b_i blue ballots. Each member i will put all the w_i white ballots into the box if he/she is ...
[{"type": "stdin_stdout", "input": "1 60\n11 10\n5 8\n3 4\n13 -1\n4 7", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 60\n11 10\n5 8\n4 4\n13 -1\n4 7", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 60\n11 10\n5 8\n4 4\n13 -1\n7 7", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 60\n11 10\n5 8\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA factory produces thimbles in bulk. Typically, it can produce up to a thimbles a day. However, some of the machinery is defective, so it can currently only produce b thimbles each day. The factory intends to choose a k-d...
[{"type": "stdin_stdout", "input": "5 2 2 1 8\n1 1 2\n1 5 3\n1 2 1\n2 2\n1 4 0\n1 3 2\n2 1\n2 3\n", "output": "3\n4\n4\n"}, {"type": "stdin_stdout", "input": "5 2 2 1 8\n1 1 1\n1 5 3\n1 2 1\n2 2\n1 4 2\n1 3 2\n2 1\n2 3\n", "output": "3\n6\n4\n"}, {"type": "stdin_stdout", "input": "5 2 2 1 8\n1 1 2\n1 5 3\n1 2 1\n2 2\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThree friends are going to meet each other. Initially, the first friend stays at the position $x = a$, the second friend stays at the position $x = b$ and the third friend stays at the position $x = c$ on the coordinate a...
[{"type": "stdin_stdout", "input": "8\n4 6 16\n7 6 35\n12 5 1\n2 15 3\n1 1000000000 0000000000\n1 1000000000 459694946\n2 0 9\n4 2 6\n", "output": "20\n54\n18\n22\n1999999996\n1999999994\n14\n4\n"}, {"type": "stdin_stdout", "input": "8\n4 6 16\n7 6 35\n12 5 1\n2 15 3\n1 1000000000 0000000000\n1 1000000000 459694946\n1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe only difference between easy and hard versions is constraints.\n\nThe BerTV channel every day broadcasts one episode of one of the $k$ TV shows. You know the schedule for the next $n$ days: a sequence of integers $a_1...
[{"type": "stdin_stdout", "input": "4\n5 2 2\n1 2 1 2 2\n9 3 3\n3 3 3 2 2 4 1 1 1\n4 18 4\n10 8 6 4\n16 10 8\n3 1 7 1 5 4 2 6 7 6 5 8 9 8 11 3\n", "output": "1\n1\n4\n6\n"}, {"type": "stdin_stdout", "input": "4\n5 2 4\n1 2 1 2 1\n9 3 3\n3 3 3 2 2 4 1 1 1\n4 18 4\n10 8 6 4\n16 10 8\n3 1 4 2 5 4 2 6 5 6 5 10 9 8 9 3\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya used to be an accountant before the war began and he is one of the few who knows how to operate a computer, so he was assigned as the programmer.\n\nWe all know that programs often store sets of integers. For exampl...
[{"type": "stdin_stdout", "input": "56\npair pair pair int int pair pair pair pair pair int pair int int pair pair int pair pair pair int pair int int pair int pair int pair pair pair pair int pair pair int int pair int int pair int int int int int pair pair pair pair pair pair pair pair pair int pair pair int pair pai...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya decided to have a look at the results of Berland 1910 Football Championship’s finals. Unfortunately he didn't find the overall score of the match; however, he got hold of a profound description of the match'...
[{"type": "stdin_stdout", "input": "89\nH\nVOCI\nVOCI\nH\nVOCI\nH\nH\nVOCI\nVOCI\nVOCI\nH\nH\nH\nVOCI\nVOCI\nVOCI\nH\nVOCI\nVOCI\nH\nVOCI\nVOCI\nVOCI\nH\nVOCI\nH\nVOCI\nH\nVOCI\nH\nVOCI\nVOCI\nH\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI\nH\nVOCI\nVOCI\nVOCI\nVOCI\nH\nVOCI\nH\nH\nVOCI\nH\nVOCI\nH\nVOCI\nVOCI\nVOCI\nVOCI\nVOCI...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMonocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer $x$ with $p$ zeros appended to its end.\n\nNow Monocarp asks you to compare these two numbers. Can you help him?\n...
[{"type": "stdin_stdout", "input": "23\n1 3\n100 1\n2 3\n200 1\n3 3\n300 1\n4 3\n400 1\n5 3\n500 1\n6 3\n600 1\n1 7\n1000000 4\n10 9\n1000000 4\n100 14\n1000010 4\n1000 7\n1000000 4\n10000 6\n1000000 4\n100000 5\n1000000 4\n1000000 4\n1000000 4\n1000000 4\n100000 5\n1000000 4\n10000 6\n1000000 4\n1000 7\n1000000 4\n100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwilight Sparkle once got a crystal from the Crystal Mine. A crystal of size n (n is odd; n > 1) is an n × n matrix with a diamond inscribed into it.\n\nYou are given an odd integer n. You need to draw a crystal of size n...
[{"type": "stdin_stdout", "input": "101\n", "output": "**************************************************D**************************************************\n*************************************************DDD*************************************************\n************************************************DDDDD******...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA prime number n (11, 19, 23, etc.) that divides by 4 and has 3 has an interesting property. The results of calculating the remainder of the square of a natural number (1, 2, ..., n -1) of 1 or more and less than n divide...
[{"type": "stdin_stdout", "input": "11\n173\n0", "output": "4\n4\n4\n4\n4\n84\n86\n86\n84\n86\n84\n86\n86\n84\n84\n86\n86\n84\n84\n84\n84\n86\n86\n86\n86\n84\n84\n84\n84\n84\n86\n86\n86\n84\n86\n84\n86\n84\n84\n84\n84\n84\n84\n86\n84\n84\n86\n84\n86\n86\n86\n84\n86\n84\n86\n84\n84\n86\n84\n84\n84\n84\n86\n86\n84\n86\n8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt a geometry lesson Bob learnt that a triangle is called right-angled if it is nondegenerate and one of its angles is right. Bob decided to draw such a triangle immediately: on a sheet of paper he drew three points with ...
[{"type": "stdin_stdout", "input": "-100 -100 100 100 -100 100\n", "output": "RIGHT\n"}, {"type": "stdin_stdout", "input": "-100 -100 100 -100 0 73\n", "output": "NEITHER\n"}, {"type": "stdin_stdout", "input": "-45 -87 -34 -79 -60 -62\n", "output": "NEITHER\n"}, {"type": "stdin_stdout", "input": "-45 -87 -44 -79 -60 -6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTanya has $n$ candies numbered from $1$ to $n$. The $i$-th candy has the weight $a_i$.\n\nShe plans to eat exactly $n-1$ candies and give the remaining candy to her dad. Tanya eats candies in order of increasing their num...
[{"type": "stdin_stdout", "input": "105\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 4 5 5 5 6\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "105\n5 5 5...
code_stdio