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\nYurii is sure he can do everything. Can he solve this task, though?\n\nHe has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simultaneously satisfied: \n\...
[{"type": "stdin_stdout", "input": "10\n997230370 58052053 240970544 715275815 250707702 156801523 44100666 64791577 43523002 480196854\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n997230370 58052053 240970544 715275815 250707702 42457490 44100666 64791577 43523002 480196854\n", "output": "1\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have 2n integers 1, 2, ..., 2n. You have to redistribute these 2n elements into n pairs. After that, you choose x pairs and take minimum elements from them, and from the other n - x pairs, you take maximum elements.\n...
[{"type": "stdin_stdout", "input": "3\n1\n1\n5\n1 4 5 9 10\n2\n3 4\n", "output": "\n1\n3\n1\n"}, {"type": "stdin_stdout", "input": "3\n1\n1\n5\n1 4 5 9 10\n2\n1 4\n", "output": "1\n3\n1\n"}, {"type": "stdin_stdout", "input": "3\n1\n1\n5\n1 4 5 9 10\n2\n2 4\n", "output": "1\n3\n2\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess thinks they should just go to bed e...
[{"type": "stdin_stdout", "input": "267 111\n", "output": "0.7727518243505415\n"}, {"type": "stdin_stdout", "input": "768 487\n", "output": "0.7203654732552364\n"}, {"type": "stdin_stdout", "input": "377 205\n", "output": "0.7393583121158366\n"}, {"type": "stdin_stdout", "input": "815 180\n", "output": "0.8467179193191...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a square field of size n Γ— 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 to the c...
[{"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\nA median in an array with the length of n is an element which occupies position number <image> after we sort the elements in the non-decreasing order (the array elements are numbered starting with 1). A median of an array...
[{"type": "stdin_stdout", "input": "100 813\n285 143 378 188 972 950 222 557 170 755 470 164 1433 553 146 820 842 62 496 1893 746 944 677 828 465 577 791 277 303 218 561 653 925 692 871 424 626 795 813 343 418 280 123 364 496 447 435 452 645 36 311 315 830 289 450 675 23 212 421 661 7 217 468 877 172 141 475 409 178 71...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere have recently been elections in the zoo. Overall there were 7 main political parties: one of them is the Little Elephant Political Party, 6 other parties have less catchy names.\n\nPolitical parties find their numbe...
[{"type": "stdin_stdout", "input": "987549745\n", "output": "206294274\n"}, {"type": "stdin_stdout", "input": "674810014\n", "output": "550536983\n"}, {"type": "stdin_stdout", "input": "545794012\n", "output": "829479797\n"}, {"type": "stdin_stdout", "input": "301542785\n", "output": "763583849\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSince most contestants do not read this part, I have to repeat that Bitlandians are quite weird. They have their own jobs, their own working method, their own lives, their own sausages and their own games!\n\nSince you ar...
[{"type": "stdin_stdout", "input": "3\n101 186 223\n", "output": "BitAryo\n"}, {"type": "stdin_stdout", "input": "3\n184 222 102\n", "output": "BitAryo\n"}, {"type": "stdin_stdout", "input": "3\n299 290 288\n", "output": "BitLGM\n"}, {"type": "stdin_stdout", "input": "3\n299 299 298\n", "output": "BitLGM\n"}, {"type": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan has got an array of n non-negative integers a1, a2, ..., an. Ivan knows that the array is sorted in the non-decreasing order. \n\nIvan wrote out integers 2a1, 2a2, ..., 2an on a piece of paper. Now he wonders, what m...
[{"type": "stdin_stdout", "input": "26\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1\n2000000000\n", "output": "2000000000\n"}, {"type": "stdin_stdout", "input": "1\n1646661570\n", "output": "1646661570\n"}, {"type": "stdin_stdout", "input": "1\n11016434...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and each hamster either sat down or stood up.\n\nFor another exercise, Pasha needs exactly <image> ...
[{"type": "stdin_stdout", "input": "200\nxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n", "output": "100\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBizon the Champion isn't just charming, he also is very smart.\n\nWhile some of us were learning the multiplication table, Bizon the Champion had fun in his own manner. Bizon the Champion painted an n Γ— m multiplication t...
[{"type": "stdin_stdout", "input": "499997 499989 248758432143\n", "output": "225563648440"}, {"type": "stdin_stdout", "input": "500000 500000 250000000000\n", "output": "250000000000"}, {"type": "stdin_stdout", "input": "172200 409931 42943608085\n", "output": "18254872778\n"}, {"type": "stdin_stdout", "input": "18365...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatically receive...
[{"type": "stdin_stdout", "input": "KASFLS\nASJBGGDLJFDDFHHTHJH\n42\n2 a 68 y\n4 h 64 r\n5 a 24 y\n6 h 20 r\n2 a 16 r\n9 a 96 y\n10 h 36 r\n12 a 44 y\n13 h 69 r\n16 a 62 r\n18 a 99 r\n20 h 12 r\n21 a 68 y\n25 h 40 y\n26 h 54 r\n28 h 91 r\n29 a 36 r\n33 a 91 y\n36 h 93 r\n37 h 60 r\n38 a 82 r\n41 a 85 y\n42 a 62 r\n46 a...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDrazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.\n\nThere are n boys and m girls among his friends. Let's ...
[{"type": "stdin_stdout", "input": "5880582 100615605\n33 994430 2580881 208833 773217 5288222 4144306 1283201 4501728 3876492 4261396 1313993 1567121 1408932 5225554 2622889 3029881 1790677 5350621 1743001 3413796 5100735 3105904 1969283 453573 429283 4544410 2070808 3695158 1066291 2639099 4258365 908486 3326551\n24 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a.\n\nThen, by using a random gener...
[{"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "999999999\n"}, {"type": "stdin_stdout", "input": "1000000000 100000000\n", "output": "100000001\n"}, {"type": "stdin_stdout", "input": "1000000000 500000000\n", "output": "500000001\n"}, {"type": "stdin_stdout", "input": "1199670843 346250868\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan wants to make a necklace as a present to his beloved girl. A necklace is a cyclic sequence of beads of different colors. Ivan says that necklace is beautiful relative to the cut point between two adjacent beads, if t...
[{"type": "stdin_stdout", "input": "20\n19259 5236 2272 7238 560 938 6209 91 1540 2821 35 6097 12593 1092 6181 7553 4095 280 12810 2723\n", "output": "0\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter observing the results of Spy Syndrome, Yash realised the errors of his ways. He now believes that a super spy such as Siddhant can't use a cipher as basic and ancient as Caesar cipher. After many weeks of observatio...
[{"type": "stdin_stdout", "input": "71\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\n8\na\nba\naaa\naaaa\naaaaa\naaaaaa\naaaabaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\n", "output": "a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter their adventure with the magic mirror Kay and Gerda have returned home and sometimes give free ice cream to kids in the summer.\n\nAt the start of the day they have x ice cream packs. Since the ice cream is free, pe...
[{"type": "stdin_stdout", "input": "6 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n", "output": "7000000000 0\n"}, {"type": "stdin_stdout", "input": "6 1000000000\n+ 1000000000\n+ 0000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n+ 1000000000\n", "output": "6000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an interactive problem. You have to use flush operation right after printing each line. For example, in C++ you should use function fflush(stdout), in Java β€” System.out.flush(), in Pascal β€” flush(output) and in Py...
[{"type": "stdin_stdout", "input": "24\n4\n1 2 3 4\n4\n1 2 4 3\n4\n1 3 2 4\n4\n1 3 4 2\n4\n1 4 2 3\n4\n1 4 3 2\n4\n2 1 3 4\n4\n2 1 4 3\n4\n2 3 1 4\n4\n2 3 4 1\n4\n2 4 1 3\n4\n2 4 3 1\n4\n3 1 2 4\n4\n3 1 4 2\n4\n3 2 1 4\n4\n3 2 4 1\n4\n3 4 1 2\n4\n3 4 2 1\n4\n4 1 2 3\n4\n4 1 3 2\n4\n4 2 1 3\n4\n4 2 3 1\n4\n4 3 1 2\n4\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully concentrate and repeatedly presses the keys that need to ...
[{"type": "stdin_stdout", "input": "babbbbabbabbbababbabbbbbbabaabaababaaabbbbbabbbbaaaaabbaaabbaabaabbbbabbbababbabaaabbababaaababbbaaa\n", "output": "babababababababababababa\n"}, {"type": "stdin_stdout", "input": "aaabbbabaaabababbaaababbababbbabbbbaabaabbaaabbaaaaabbbbabbbbbaaababaabaababbbbbbabbababbbabbabbbbab\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has just attempted to pass the driving test. He ran over the straight road with the signs of four types.\n\n * speed limit: this sign comes with a positive integer number β€” maximal speed of the car after the sig...
[{"type": "stdin_stdout", "input": "11\n1 100\n3 70\n4\n2\n3 120\n5\n3 120\n6\n1 150\n4\n3 300\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "11\n1 100\n3 57\n4\n2\n3 120\n5\n3 120\n6\n1 150\n4\n3 300\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "11\n1 110\n3 70\n4\n2\n3 120\n5\n3 120\n6\n1 150\n4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can's capacity bi (ai ≀ bi).\n\nJafar has decided to pour all remaining cola into just 2 cans, determine if he can do this ...
[{"type": "stdin_stdout", "input": "10\n15 26 15 14 14 39 40 4 25 39\n27 72 16 44 69 48 53 17 63 42\n", "output": "no\n"}, {"type": "stdin_stdout", "input": "10\n15 26 15 14 14 39 40 5 25 39\n27 72 16 44 69 48 53 17 63 42\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10\n15 26 15 14 14 39 40 5 25 39\n27 72 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an array a1, a2, ..., an of n integers, find the largest number in the array that is not a perfect square.\n\nA number x is said to be a perfect square if there exists an integer y such that x = y2.\n\nInput\n\nThe ...
[{"type": "stdin_stdout", "input": "71\n908209 289 44521 240100 680625 274576 212521 91809 506944 499849 3844 15376 592900 58081 240100 984064 732736 257049 600625 180625 130321 580644 261121 75625 46225 853776 485809 700569 817216 268324 293764 528529 25921 399424 175561 99856 295936 20736 611524 13924 470596 574564 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWelcome to another task about breaking the code lock! Explorers Whitfield and Martin came across an unusual safe, inside of which, according to rumors, there are untold riches, among which one can find the solution of the...
[{"type": "stdin_stdout", "input": "100\nmntyyerijtaaditeyqvxstrwxoxglpaubigaggtrepaegniybvfmssawvhrgjjhwwkwuqhtyrimxvolcstyllbhlcursvgfafpts\nbsgmhsgavsbgtwiiqaigmtyjxihphxdlseeajfywugawigrjruttuykthfrvwagpcsxlxsopnarqcvetnbtvfrvlyymwoyelrlta\n", "output": "300\n67 1 100 88 1 100 93 1 100 70 1 100 46 1 100 96 1 100 88...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp has created his own training plan to prepare for the programming contests. He will train for n days, all days are numbered from 1 to n, beginning from the first.\n\nOn the i-th day Polycarp will necessarily solve...
[{"type": "stdin_stdout", "input": "69\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "35\n"}, {"type": "stdin_stdout", "input": "69\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the modification of the problem used during the official round. Unfortunately, author's solution of the original problem appeared wrong, so the problem was changed specially for the archive.\n\nOnce upon a time in...
[{"type": "stdin_stdout", "input": "9949\n", "output": "307719457689743128298492861497180324397986774674234939670103343582839949843260265155046613013945400801415123028273388247235932017894817398309825952296257005831495862389554310376537787393094576718901293512769236851428349025597989172462502154215215274376199660914517...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nM-kun is a brilliant air traffic controller.\n\nOn the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude.\nEach of the airplanes flies at a constant speed of 0.1 per second...
[{"type": "stdin_stdout", "input": "8\n285 224 U\n130 175 R\n111 322 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L", "output": "SAFE\n"}, {"type": "stdin_stdout", "input": "8\n285 224 U\n130 175 R\n101 322 D\n121 188 L\n201 116 U\n112 121 R\n145 239 D\n185 107 L", "output": "SAFE\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi is distributing N balls to K persons.\n\nIf each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the pe...
[{"type": "stdin_stdout", "input": "-2 135", "output": "-137\n"}, {"type": "stdin_stdout", "input": "-2 240", "output": "-242\n"}, {"type": "stdin_stdout", "input": "-4 240", "output": "-244\n"}, {"type": "stdin_stdout", "input": "3 130", "output": "-127\n"}, {"type": "stdin_stdout", "input": "2 130", "output": "-128\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string S. Each character of S is uppercase or lowercase English letter. Determine if S satisfies all of the following conditions:\n\n* The initial character of S is an uppercase `A`.\n* There is exactly on...
[{"type": "stdin_stdout", "input": "AtCoddr", "output": "AC\n"}, {"type": "stdin_stdout", "input": "redoctA", "output": "WA\n"}, {"type": "stdin_stdout", "input": "BcycliC", "output": "WA\n"}, {"type": "stdin_stdout", "input": "etCodAr", "output": "WA\n"}, {"type": "stdin_stdout", "input": "redpctA", "output": "WA\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt is September 9 in Japan now.\n\nYou are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?\n\nConstraints\n\n* 10≀N≀99\n\nInput\n\nInput is given from Standard Input in the f...
[{"type": "stdin_stdout", "input": "929", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "109", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "189", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "1223", "output": "No\n"}, {"type": "stdin_stdout", "input": "69", "output": "Yes\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHow many infinite sequences a_1, a_2, ... consisting of {{1, ... ,n}} satisfy the following conditions?\n\n* The n-th and subsequent elements are all equal. That is, if n \\leq i,j, a_i = a_j.\n* For every integer i, the ...
[{"type": "stdin_stdout", "input": "138065", "output": "144629245\n"}, {"type": "stdin_stdout", "input": "132361", "output": "413027178\n"}, {"type": "stdin_stdout", "input": "219101", "output": "267179376\n"}, {"type": "stdin_stdout", "input": "412635", "output": "541957737\n"}, {"type": "stdin_stdout", "input": "1475...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.\n\n\n\nInput\n\nThe input is a...
[{"type": "stdin_stdout", "input": "6 2\n12 8\n0 0", "output": "Wednesday\nWednesday\n"}, {"type": "stdin_stdout", "input": "4 1\n2 18\n0 0", "output": "Thursday\nWednesday\n"}, {"type": "stdin_stdout", "input": "6 2\n7 17\n0 0", "output": "Wednesday\nSaturday\n"}, {"type": "stdin_stdout", "input": "1 1\n5 19\n0 0", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor a positive integer n\n\n* If n is even, divide by 2.\n* If n is odd, multiply by 3 and add 1.\n\n\n\nIf you repeat the above operation, the result will be 1. A problem called \"Colatz conjecture\" is that repeating th...
[{"type": "stdin_stdout", "input": "3\n1043\n0", "output": "7\n124\n"}, {"type": "stdin_stdout", "input": "3\n3340\n0", "output": "7\n136\n"}, {"type": "stdin_stdout", "input": "3\n109\n0", "output": "7\n113\n"}, {"type": "stdin_stdout", "input": "3\n440\n0", "output": "7\n115\n"}, {"type": "stdin_stdout", "input": "3\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe cloth coasters produced and sold by Aizu Takada City are known for their symmetrical design and great beauty. As part of quality control, Aizu Takada City has installed cameras on the production line to automatically ...
[{"type": "stdin_stdout", "input": "7 8\n00100010\n00011000\n10111101\n01100110\n01000110\n10111101\n00011000\n00100100\n2\n5 3\n0 6\n1\n6 16\n3\n6 10\n3 3\n3 6\n2\n6 3\n6 6\n0\n3\n1 8\n6 8", "output": "0\n"}, {"type": "stdin_stdout", "input": "7 8\n00100000\n00011000\n10111101\n01100110\n01000110\n10111101\n00011000\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N towns in JOI, which are connected by M bidirectional roads. There are shopping malls in K towns, and the people go to one of those towns through the road to shop.\n\nDepending on the location of your home, you...
[{"type": "stdin_stdout", "input": "10 3 1\n1 2 5\n3 3 2\n3 1 1\n2", "output": "7\n"}, {"type": "stdin_stdout", "input": "11 3 1\n1 1 1\n2 3 0\n3 1 1\n1", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 3 1\n1 2 2\n2 3 2\n3 1 1\n1", "output": "3\n"}, {"type": "stdin_stdout", "input": "10 3 1\n1 2 2\n2 3 2\n2 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYOKARI TAMURA is a nationally famous artist. This month YOKARI will be touring live for D days. Divide this country into C different regions when deciding on a tour schedule. YOKARI benefits from performing live in an are...
[{"type": "stdin_stdout", "input": "5 5 8 2\n1 1 0 1 0\n0 5 1 0 1\n1 1 1 9 1\n1 1 9 0 1\n1 1 2 1 0\n2 1 0 1 1\n0 9 2 0 1\n1 1 1 9 1\n1 1 1 0 1\n1 1 1 1 0\n1 1 13 0\n3\n7\n1 1 5 0\n3\n9\n1 2 10 1\n10 7\n5 10\n2 1 11 1\n6\n8\n4\n7\n2 1 20 0\n4\n13\n3\n11\n2 1 5 0\n4\n8\n3\n6\n0 0 0 0", "output": "17\n3\n0\n10\n14\n13\n4\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's play a new board game ``Life Line''.\n\nThe number of the players is greater than 1 and less than 10.\n\nIn this game, the board is a regular triangle in which many small regular triangles are arranged (See Figure l...
[{"type": "stdin_stdout", "input": "4 4\n 2\n 2 3\n 1 0 4\n1 1 4 0\n4 5\n 2\n 2 3\n 3 0 4\n1 1 4 0\n4 1\n 2\n 2 3\n 3 0 4\n1 1 7 0\n4 1\n 1\n 1 1\n 1 1 1\n1 1 1 0\n4 2\n 1\n 1 0\n 1 1 1\n1 1 1 0\n4 1\n 0\n 2 2\n 5 0 7\n0 5 7 0\n4 2\n 0\n 0 3\n 1 0 4\n0 1 0 4\n4 3\n 0\n 3 3\n 3 2 3\n0 3 0 3\n4 2\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nFind the area of ​​a regular N / K polygon inscribed in a circle with a radius of 1.\n\nHowever, a regular N / K polygon is defined as \"the outermost figure that takes N points on the circumference at equal in...
[{"type": "stdin_stdout", "input": "110111 100", "output": "3.1415923987\n"}, {"type": "stdin_stdout", "input": "010111 100", "output": "3.1415624160\n"}, {"type": "stdin_stdout", "input": "010111 110", "output": "3.1415593799\n"}, {"type": "stdin_stdout", "input": "010011 110", "output": "3.1415587116\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nExample\n\nInput\n\n3\ny 7\ny 6\nn 5\n\n\nOutput\n\n1\n\nThe input will be given via stdin and the output should be printed to stdout by your code.\n\nNow solve the problem by providing the code.\n\nWrite Python code to s...
[{"type": "stdin_stdout", "input": "3\ny 11\ny 3\nn 10", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\ny 11\nx 3\nn 10", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\nx 2\ny 10\nn 10", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\ny 11\nw 3\nn 10", "output": "1\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem\n\nNeat lives on the world line for a total of 360 days until the 30th of every month for 1 year and 12 months. In that world, N consecutive holidays with the same schedule were applied to people all over the worl...
[{"type": "stdin_stdout", "input": "8\n2 9 297 297\n8 6 359 211\n8 16 28 233\n7 9 113 143\n3 18 315 190\n10 18 277 300\n9 5 276 88\n3 5 322 40", "output": "297\n"}, {"type": "stdin_stdout", "input": "8\n2 9 297 297\n8 6 359 211\n8 16 28 288\n7 9 113 143\n3 18 315 190\n10 18 277 300\n9 5 276 88\n3 5 322 40", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have $N$ items that you want to put them into a knapsack of capacity $W$. Item $i$ ($1 \\le i \\le N$) has weight $w_i$ and value $v_i$ for the weight.\n\nWhen you put some items into the knapsack, the following condi...
[{"type": "stdin_stdout", "input": "1 96\n113 10\n111 20\n120 31", "output": "113.0000000000\n"}, {"type": "stdin_stdout", "input": "1 77\n119 10\n111 20\n120 31", "output": "119.0000000000\n"}, {"type": "stdin_stdout", "input": "1 77\n197 10\n111 20\n120 31", "output": "197.0000000000\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWrite a program which calculates the area and circumference of a circle for given radius r.\n\nConstraints\n\n* 0 < r < 10000\n\nInput\n\nA real number r is given.\n\nOutput\n\nPrint the area and circumference of the circ...
[{"type": "stdin_stdout", "input": "-210", "output": "138544.236023275 -1319.46891451\n"}, {"type": "stdin_stdout", "input": "-215", "output": "145220.120412152 -1350.88484104\n"}, {"type": "stdin_stdout", "input": "-113", "output": "40114.996593678 -709.999939711\n"}, {"type": "stdin_stdout", "input": "-114", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two positive integers d and s. Find minimal positive integer n which is divisible by d and has sum of digits equal to s.\n\nInput\n\nThe first line contains two positive integers d and s (1 ≀ d ≀ 500, 1 ≀ s ...
[{"type": "stdin_stdout", "input": "500 5000\n", "output": "99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob is an active user of the social network Faithbug. On this network, people are able to engage in a mutual friendship. That is, if a is a friend of b, then b is also a friend of a. Each user thus has a non-negative amou...
[{"type": "stdin_stdout", "input": "35\n21 26 18 7 28 2 16 13 16 25 6 32 11 5 31 17 18 3 24 33 14 27 29 1 20 4 12 9 10 30 34 8 19 23 22\n", "output": "0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 \n"}, {"type": "stdin_stdout", "input": "35\n21 26 18 4 28 3 15 13 16 25 6 25 11 5 31 17 9 3 24 33 14 27 29 1 20 4 12 7 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCan the greatest common divisor and bitwise operations have anything in common? It is time to answer this question.\n\nSuppose you are given a positive integer a. You want to choose some integer b from 1 to a - 1 inclusiv...
[{"type": "stdin_stdout", "input": "9\n30\n11\n12\n122\n136\n92\n1984716\n217\n14628115\n", "output": "31\n15\n15\n127\n255\n127\n2097151\n255\n16777215\n"}, {"type": "stdin_stdout", "input": "9\n30\n7\n12\n122\n136\n92\n1984716\n204\n14628115\n", "output": "31\n1\n15\n127\n255\n127\n2097151\n255\n16777215\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, on the course of algorithms and data structures, Valeriy learned how to use a deque. He built a deque filled with n elements. The i-th element is a_i (i = 1, 2, …, n). He gradually takes the first two leftmost e...
[{"type": "stdin_stdout", "input": "71 57\n9 26 80 10 65 60 63 1 15 85 71 1 58 27 41 97 42 15 42 56 87 22 10 28 34 90 13 70 71 56 65 21 0 78 47 191 56 77 32 83 28 16 10 41 0 18 92 12 27 58 4 67 21 41 99 20 21 52 74 10 83 45 43 65 2 15 1 63 46 97 72\n150\n21\n81\n81\n5\n9\n41\n76\n81\n92\n95\n94\n78\n93\n47\n30\n92\n3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne common way of digitalizing sound is to record sound intensity at particular time moments. For each time moment intensity is recorded as a non-negative integer. Thus we can represent a sound file as an array of n non-n...
[{"type": "stdin_stdout", "input": "50 20\n592183311 362557946 154127088 616872926 395353745 675069471 509655682 79915471 356656666 937992998 304422065 724106263 472338455 792258113 796069631 1325917135 201799298 566151622 722278085 827802227 703159587 690854023 925377265 11010958 69791159 990158269 535460930 167415727...
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\nA team of three programmers is going to play a contest. The contest consists of n problems, numbered from 1 to n. Each problem is printed on a separate sheet of paper. The participants have decided to divide the problem s...
[{"type": "stdin_stdout", "input": "11 7 9\n4 8 9 12 14 16 19 21 22 23 27\n1 2 3 11 17 18 26\n5 6 7 10 13 15 20 24 25\n", "output": "15"}, {"type": "stdin_stdout", "input": "5 10 6\n14 3 6 12 21\n7 1 5 8 10 11 13 17 18 20\n9 2 4 15 16 19\n", "output": "11"}, {"type": "stdin_stdout", "input": "1 5 1\n6\n5 1 2 4 7\n3\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n water tanks in a row, i-th of them contains a_i liters of water. The tanks are numbered from 1 to n from left to right.\n\nYou can perform the following operation: choose some subsegment [l, r] (1≀ l ≀ r ≀ n),...
[{"type": "stdin_stdout", "input": "65\n1000000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 16 19 20 21 22 23 44 25 26 35 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 104 59 60 61 62 63 64\n", "output": "15417.723076923077\n15417.723076923077\n15417.723076923077\n15417.7230769...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an undirected unweighted graph consisting of n vertices and m edges (which represents the map of Bertown) and the array of prices p of length m. It is guaranteed that there is a path between each pair of ver...
[{"type": "stdin_stdout", "input": "2\n4 3 2 3 4\n2 4 3\n1 2\n1 3\n1 4\n7 9 1 5 7\n2 10 4 8 5 6 7 3 3\n1 2\n1 3\n1 4\n3 2\n3 5\n4 2\n5 6\n1 4\n6 7\n", "output": "11\n12\n"}, {"type": "stdin_stdout", "input": "2\n4 3 2 3 4\n1 5 3\n1 2\n1 3\n1 4\n7 9 2 5 7\n3 10 4 8 5 8 7 3 3\n2 2\n2 3\n1 4\n3 2\n3 5\n4 3\n5 6\n1 4\n6 7\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAyush, Ashish and Vivek are busy preparing a new problem for the next Codeforces round and need help checking if their test cases are valid.\n\nEach test case consists of an integer n and two arrays a and b, of size n. If...
[{"type": "stdin_stdout", "input": "24\n4\n1 2 3 4\n1 2 3 4\n4\n1 2 3 4\n1 2 4 3\n4\n1 2 3 4\n1 3 2 4\n4\n1 2 3 4\n1 3 4 2\n4\n1 2 3 4\n1 4 2 3\n4\n1 2 3 4\n1 4 3 2\n4\n1 2 3 4\n2 1 3 4\n4\n1 2 3 4\n2 1 4 3\n4\n1 2 3 4\n2 3 1 4\n4\n1 2 3 4\n2 3 4 1\n4\n1 2 3 4\n2 4 1 3\n4\n1 2 3 4\n2 4 3 1\n4\n1 2 3 4\n3 1 2 4\n4\n1 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a tree (connected graph without cycles) consisting of n vertices. The tree is unrooted β€” it is just a connected undirected graph without cycles.\n\nIn one move, you can choose exactly k leaves (leaf is such ...
[{"type": "stdin_stdout", "input": "4\n8 10\n1 2\n1 5\n7 6\n6 8\n3 1\n8 4\n7 1\n10 1\n1 2\n1 10\n2 3\n1 5\n1 6\n2 4\n7 10\n10 9\n8 10\n7 2\n3 1\n1 5\n4 6\n7 4\n1 2\n1 4\n5 1\n1 4\n2 1\n4 3\n5 3\n", "output": "0\n9\n3\n4\n"}, {"type": "stdin_stdout", "input": "4\n8 10\n1 2\n1 5\n7 6\n6 8\n3 1\n8 4\n4 1\n10 3\n1 2\n1 10\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n beautiful skyscrapers in New York, the height of the i-th one is h_i. Today some villains have set on fire first n - 1 of them, and now the only safety building is n-th skyscraper.\n\nLet's call a jump from i-...
[{"type": "stdin_stdout", "input": "8\n7 2 5 5 1 2 5 2\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "8\n7 2 5 5 1 2 2 2\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "8\n7 2 5 5 2 2 5 2\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "8\n4 3 5 5 1 2 5 2\n", "output": "4\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the snake exhibition, there are n rooms (numbered 0 to n - 1) arranged in a circle, with a snake in each room. The rooms are connected by n conveyor belts, and the i-th conveyor belt connects the rooms i and (i+1) mod ...
[{"type": "stdin_stdout", "input": "36\n2\n--\n2\n>-\n2\n<-\n2\n->\n2\n>>\n2\n<>\n2\n-<\n2\n><\n2\n<<\n3\n---\n3\n>--\n3\n<--\n3\n->-\n3\n>>-\n3\n<>-\n3\n-<-\n3\n><-\n3\n<<-\n3\n-->\n3\n>->\n3\n<->\n3\n->>\n3\n>>>\n3\n<>>\n3\n-<>\n3\n><>\n3\n<<>\n3\n--<\n3\n>-<\n3\n<-<\n3\n-><\n3\n>><\n3\n<><\n3\n-<<\n3\n><<\n3\n<<<\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHr0d1y has q queries on a binary string s of length n. A binary string is a string containing only characters '0' and '1'.\n\nA query is described by a pair of integers l_i, r_i (1 ≀ l_i < r_i ≀ n). \n\nFor each query, he...
[{"type": "stdin_stdout", "input": "2\n6 3\n001000\n2 4\n1 3\n3 5\n4 2\n1111\n1 4\n2 3\n", "output": "\nYES\nNO\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "2\n6 3\n001000\n2 4\n1 3\n3 5\n4 2\n1111\n1 4\n1 3\n", "output": "YES\nNO\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "2\n6 3\n001000\n2 5\n1 3\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp remembered the 2020-th year, and he is happy with the arrival of the new 2021-th year. To remember such a wonderful moment, Polycarp wants to represent the number n as the sum of a certain number of 2020 and a ce...
[{"type": "stdin_stdout", "input": "5\n1\n4041\n4042\n8081\n8079\n", "output": "\nNO\nYES\nYES\nYES\nNO\n"}, {"type": "stdin_stdout", "input": "5\n1\n4041\n4042\n12391\n8079\n", "output": "NO\nYES\nYES\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "5\n1\n4041\n4042\n8081\n4273\n", "output": "NO\nYES\nYES\nYES\nNO\n"},...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a permutation a consisting of n numbers 1, 2, ..., n (a permutation is an array in which each element from 1 to n occurs exactly once).\n\nYou can perform the following operation: choose some subarray (conti...
[{"type": "stdin_stdout", "input": "3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3\n", "output": "\n1\n0\n2\n"}, {"type": "stdin_stdout", "input": "3\n4\n1 3 2 10\n3\n1 2 3\n5\n3 1 4 0 0\n", "output": "1\n0\n2\n"}, {"type": "stdin_stdout", "input": "3\n4\n1 3 2 7\n3\n1 2 3\n5\n2 1 4 5 -1\n", "output": "1\n0\n2\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs Sherlock Holmes was investigating another crime, he found a certain number of clues. Also, he has already found direct links between some of those clues. The direct links between the clues are mutual. That is, the dire...
[{"type": "stdin_stdout", "input": "30 70 288262020\n27 18\n5 19\n23 17\n16 17\n29 17\n1 22\n23 5\n10 13\n22 26\n14 3\n8 3\n29 9\n9 1\n3 9\n16 4\n9 22\n10 22\n20 1\n3 7\n23 19\n26 8\n24 1\n5 7\n28 29\n20 11\n16 12\n6 9\n24 29\n30 4\n5 26\n18 21\n5 21\n30 6\n12 13\n16 23\n28 14\n30 1\n7 27\n7 19\n27 17\n5 30\n30 27\n28 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFibonacci strings are defined as follows: \n\n * f1 = Β«aΒ» \n * f2 = Β«bΒ» \n * fn = fn - 1 fn - 2, n > 2\n\n\n\nThus, the first five Fibonacci strings are: \"a\", \"b\", \"ba\", \"bab\", \"babba\".\n\nYou are given a Fib...
[{"type": "stdin_stdout", "input": "50 100\na\na\nb\na\na\nb\nb\nb\na\na\nb\nb\na\na\na\na\nb\nb\na\nb\nb\nb\na\na\na\na\na\na\nb\nb\na\nb\na\nb\na\nb\na\nb\nb\nb\na\na\nb\na\na\na\nb\na\nb\na\na\na\nb\na\nb\na\na\nb\na\na\nb\na\na\na\na\nb\na\nb\na\nb\nb\na\nb\nb\nb\na\nb\nb\nb\nb\nb\nb\nb\nb\nb\nb\na\na\na\nb\nb\nb\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA bracket sequence is a string, containing only characters \"(\", \")\", \"[\" and \"]\".\n\nA correct bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting chara...
[{"type": "stdin_stdout", "input": "[()][([[]])][[[]()]][()[]]()()([[][]][[]][](()))[[[(())]]][]()(([([])(([[[]]()])(()))]((())))([()]([()[[[]([][[[[][(())([[]()])]]][[(())]([])]()][[](())]()[])]()[][]]([[]])[]])[(()[()((()[][()]))][])[]()()([]())](()[][][])()()[]()))[]()[]\n", "output": "61\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\n10 5\n34 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 10\n7 13\n34 3\n2...
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": "10 10\n4 8 4 10 2 10 8 10 4 6\n", "output": " 25\n"}, {"type": "stdin_stdout", "input": "10 10\n9 3 6 6 3 3 6 3 6 9\n", "output": " 25\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGreg has a weighed directed graph, consisting of n vertices. In this graph any pair of distinct vertices has an edge between them in both directions. Greg loves playing with the graph and now he has invented a new game:\n...
[{"type": "stdin_stdout", "input": "9\n0 85236 27579 82251 69479 24737 87917 15149 52311\n59640 0 74687 34711 3685 30121 4961 7552 83399\n33376 68733 0 81357 18042 74297 15466 29476 5865\n7493 5601 3321 0 20263 55901 58229 55361 87633\n26751 17161 76681 58775 0 39745 50717 56887 90055\n18885 76353 47089 43601 21561 0 6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou helped Dima to have a great weekend, but it's time to work. Naturally, Dima, as all other men who have girlfriends, does everything wrong.\n\nInna and Dima are now in one room. Inna tells Dima off for everything he do...
[{"type": "stdin_stdout", "input": "50 10\n1 2 3 4 5 4 7 8 9 10 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "50 10\n1 2 3 4 5 1 7 8 9 10 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1 10 1 1 1 1 1 1 1 1 1\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Berland Armed Forces System consists of n ranks that are numbered using natural numbers from 1 to n, where 1 is the lowest rank and n is the highest rank.\n\nOne needs exactly di years to rise from rank i to rank i + ...
[{"type": "stdin_stdout", "input": "100\n63 65 21 41 95 23 3 4 12 23 95 50 75 63 58 34 71 27 75 31 23 94 96 74 69 34 43 25 25 55 44 19 43 86 68 17 52 65 36 29 72 96 84 25 84 23 71 54 6 7 71 7 21 100 99 58 93 35 62 47 36 70 68 9 75 13 35 70 76 36 62 22 52 51 2 87 66 41 54 35 78 62 30 35 65 44 74 93 78 37 96 70 26 32 71 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOf course our child likes walking in a zoo. The zoo has n areas, that are numbered from 1 to n. The i-th area contains ai animals in it. Also there are m roads in the zoo, and each road connects two distinct areas. Natura...
[{"type": "stdin_stdout", "input": "10 19\n13637 26970 19043 3616 12880 19387 12539 25190 2452 1261\n1 2\n1 3\n1 4\n2 5\n3 6\n6 7\n3 8\n5 9\n3 10\n4 10\n9 3\n2 8\n4 3\n2 3\n7 10\n7 8\n5 10\n5 6\n7 4\n", "output": "8241.4222222222\n"}, {"type": "stdin_stdout", "input": "10 19\n15704 19758 26631 25050 22778 15041 8487 26...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Kitayuta has kindly given you a string s consisting of lowercase English letters. You are asked to insert exactly n lowercase English letters into s to make it a palindrome. (A palindrome is a string that reads the sa...
[{"type": "stdin_stdout", "input": "ccxsecrxosqsrsoolxzcoolqllexxssxqoqeqkocerchlxckqschxxczlxscoxhszsoxzxrzohsccsclocxxzshrhzoexxhrohqrrqhorhxxeozhrhszxxcolcsccshozrxzxoszshxocsxlzcxxhcsqkcxlhcrecokqeqoqxssxxellqlooczxloosrsqsoxrcesxcc\n536870712\n", "output": "ccxsecrxosqsrsoolxzcoolqllexxssxqoqeqkocerchlxckqschxxczl...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAndrewid the Android is a galaxy-famous detective. In his free time he likes to think about strings containing zeros and ones.\n\nOnce he thought about a string of length n consisting of zeroes and ones. Consider the foll...
[{"type": "stdin_stdout", "input": "9\n011111111\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "9\n011101111\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "9\n011101101\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "9\n001101101\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "9\n0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMotorist Kojiro spent 10 years saving up for his favorite car brand, Furrari. Finally Kojiro's dream came true! Kojiro now wants to get to his girlfriend Johanna to show off his car to her.\n\nKojiro wants to get to his g...
[{"type": "stdin_stdout", "input": "386 20 29 30\n1 349\n2 482\n1 112\n1 93\n2 189\n1 207\n2 35\n2 -5\n1 422\n1 442\n1 402\n2 238\n3 258\n3 54\n2 369\n2 290\n2 329\n3 74\n3 -62\n2 170\n1 462\n2 15\n2 222\n1 309\n3 150\n1 -25\n3 130\n1 271\n1 -43\n351 250 91 102 0 286 123 93 100 205 328 269 188 83 73 35 188 223 73 215 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCatherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions: \n\n * take any two (not necessarily adjacent) cards with differe...
[{"type": "stdin_stdout", "input": "200\nBBRBGGRGBRBRRRBRGRGBGRRBBRBGGGBGGGRBBBGRGRGGRRRRRRGBGBBBGRRGGGRRBRGBRBBBGGBGRRRBRRGBGBBBGBGGBBBBGRGRBGBGGBBRBRRRBRRRRBGGBGBGRGGRRRGGRBGGBBBBBBBRBGBGBGRBBGGRRRGRRGBGRGBBRRGRGBRGRGRGRRGBGBGBGGGRBBRRGRBB\n", "output": "BGR\n"}, {"type": "stdin_stdout", "input": "200\nBBRBGGRGBRBRRR...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n banks in the city where Vasya lives, they are located in a circle, such that any two banks are neighbouring if their indices differ by no more than 1. Also, bank 1 and bank n are neighbours if n > 1. No bank i...
[{"type": "stdin_stdout", "input": "50\n108431864 128274949 -554057370 -384620666 -202862975 -803855410 -482167063 -55139054 -215901009 0 0 0 0 0 94325701 730397219 358214459 -673647271 -131397668 -377892440 0 0 0 0 0 -487994257 -360271553 639988328 489338210 -281060728 250208758 0 993242346 -213071841 -59752620 -86435...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKostya likes Codeforces contests very much. However, he is very disappointed that his solutions are frequently hacked. That's why he decided to obfuscate (intentionally make less readable) his code before upcoming contest...
[{"type": "stdin_stdout", "input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA prime number is a number which has exactly two distinct divisors: one and itself. For example, numbers 2, 7, 3 are prime, and 1, 6, 4 are not.\n\nThe next prime number after x is the smallest prime number greater than x...
[{"type": "stdin_stdout", "input": "13 17\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "23 29\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "43 47\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "17 19\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "11 13\n", "output": "YES...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n<image>\n\nSome time ago Slastyona the Sweetmaid decided to open her own bakery! She bought required ingredients and a wonder-oven which can bake several types of cakes, and opened the bakery.\n\nSoon the expenses started...
[{"type": "stdin_stdout", "input": "50 5\n2 39 16 20 32 36 29 42 14 23 9 4 28 17 45 16 46 1 39 33 47 15 34 43 6 6 12 15 46 11 32 16 31 12 41 33 47 35 22 3 10 4 15 36 22 24 17 33 15 46\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "50 5\n2 39 16 20 32 36 29 42 14 23 9 4 28 17 45 16 46 1 39 33 47 15 34 43 6 6 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProfessor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he i...
[{"type": "stdin_stdout", "input": "43 959134961 -868367850 142426380\n921743429 63959718 -797293233 122041422 -407576197 700139744 299598010 168207043 362252658 591926075 941946099 812263640 -76679927 -824267725 89529990 -73303355 83596189 -982699817 -235197848 654773327 125211479 -497091570 -2301804 203486596 -126652...
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": "1 1 100\n100 99\n", "output": "9901\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nHEAL\nH...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle town Nsk consists of n junctions connected by m bidirectional roads. Each road connects two distinct junctions and no two roads connect the same pair of junctions. It is possible to get from any junction to any oth...
[{"type": "stdin_stdout", "input": "5 6 1 5\n1 2\n1 3\n1 4\n4 5\n3 5\n2 5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5 6 1 5\n1 2\n1 3\n1 4\n4 5\n3 5\n1 5\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "5 6 1 5\n1 2\n1 3\n2 4\n4 5\n3 5\n2 5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProfessor Ibrahim has prepared the final homework for his algorithm’s class. He asked his students to implement the Posterization Image Filter.\n\nTheir algorithm will be tested on an array of integers, where the i-th int...
[{"type": "stdin_stdout", "input": "100 10\n39 242 238 155 95 30 129 132 72 59 22 91 203 113 99 81 253 204 160 109 92 187 11 227 145 211 100 42 78 14 113 91 140 197 123 182 4 185 208 27 182 207 63 146 102 39 159 195 26 100 72 127 157 159 152 53 0 117 101 125 19 188 179 145 240 50 205 207 113 246 42 56 161 13 188 244 15...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the memory of his not less mean sister Hexadecimal. He loaded there a huge amount of n different natural numbe...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "512\n"}, {"type": "stdin_stdout", "input": "999999999\n", "output": "511\n"}, {"type": "stdin_stdout", "input": "121212121\n", "output": "511\n"}, {"type": "stdin_stdout", "input": "101010101\n", "output": "341\n"}, {"type": "stdin_stdout", "input": "9015561...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a square matrix of size n. Rows are indexed 1 to n from top to\nbottom and columns are indexed 1 to n\nform left to right. Matrix consists of only '*' and '.'.\nYou need to check whether matrix is symmetric ...
[{"type": "stdin_stdout", "input": "500\n12\n.***.**.***.\n.*.**.*..*.*\n*...*..***.*\n***.*..*..**\n*..**...*...\n..**.*.**.*.\n..*....**...\n..**.**...*.\n..**..*...**\n**..**.****.\n*..**.**....\n.*.***.....*\n5\n**..*\n*.*.*\n**.**\n.*.*.\n*****\n10\n.***..*.**\n*.*..***.*\n*.***...*.\n.*.*..*.*.\n*.....**..\n**......
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the Kingdom of AtCoder, people use a language called Taknese, which uses lowercase English letters.\n\nIn Taknese, the plural form of a noun is spelled based on the following rules:\n\n* If a noun's singular form does ...
[{"type": "stdin_stdout", "input": "aeplp", "output": "aeplps\n"}, {"type": "stdin_stdout", "input": "eaplp", "output": "eaplps\n"}, {"type": "stdin_stdout", "input": "daplp", "output": "daplps\n"}, {"type": "stdin_stdout", "input": "d`plp", "output": "d`plps\n"}, {"type": "stdin_stdout", "input": "c`plp", "output": "c...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConsider an analog clock whose hour and minute hands are A and B centimeters long, respectively.\n\nAn endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotat...
[{"type": "stdin_stdout", "input": "3 4 10 40", "output": "4.56425719433005567605"}, {"type": "stdin_stdout", "input": "3 4 9 0", "output": "5.00000000000000000000"}, {"type": "stdin_stdout", "input": "4 4 1 269", "output": "0.662465660098\n"}, {"type": "stdin_stdout", "input": "8 1 -1 312", "output": "7.45623470415\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are N points (x_i, y_i) in a two-dimensional plane.\n\nFind the minimum radius of a circle such that all the points are inside or on it.\n\nConstraints\n\n* 2 \\leq N \\leq 50\n* 0 \\leq x_i \\leq 1000\n* 0 \\leq y_...
[{"type": "stdin_stdout", "input": "10\n10 9\n5 9\n2 0\n0 0\n2 7\n3 3\n2 5\n10 0\n3 7\n1 9", "output": "6.726812023536805158"}, {"type": "stdin_stdout", "input": "10\n21 1\n10 7\n-1 -1\n-2 0\n1 10\n3 3\n1 4\n20 1\n6 7\n4 5", "output": "11.6109530324\n"}, {"type": "stdin_stdout", "input": "10\n21 2\n10 7\n-1 0\n-2 0\n0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follow...
[{"type": "stdin_stdout", "input": "10 10 10 42\n3471439818 7125082499 52097 2843504496 3381970101 14107954240 249131806 9465078905 6690322794 2898542789\n1873977926 4407421270 764181049 1379118507 9014541718 4925540914 3902539811 5851891101 178325203 2877436338\n8482502021 8974383988 2882263257 4734915691 95905874 859...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn \"Takahashi-ya\", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions).\n\nA customer ordered a bowl of ramen and told...
[{"type": "stdin_stdout", "input": "ooo", "output": "1000"}, {"type": "stdin_stdout", "input": "pxo", "output": "800\n"}, {"type": "stdin_stdout", "input": "yxx", "output": "700\n"}, {"type": "stdin_stdout", "input": "opo", "output": "900\n"}, {"type": "stdin_stdout", "input": "oxp", "output": "800\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJoisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).\n\nA...
[{"type": "stdin_stdout", "input": "5\n7 5 1 10 5\n3\n4 3\n1 11\n3 12", "output": "21\n32\n39\n"}, {"type": "stdin_stdout", "input": "5\n7 5 1 10 5\n3\n4 3\n2 11\n3 12", "output": "21\n34\n39\n"}, {"type": "stdin_stdout", "input": "5\n7 8 1 10 11\n3\n4 3\n0 11\n3 7", "output": "30\n37\n43\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied:\n\n* Each lowercase letter of the English alphabet occurs even number of times in w.\n\n\n\nYou are give...
[{"type": "stdin_stdout", "input": "ab`cc`ba", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "abaccaba", "output": "Yes"}, {"type": "stdin_stdout", "input": "ab`ccaba", "output": "No\n"}, {"type": "stdin_stdout", "input": "`b`cc`ba", "output": "No\n"}, {"type": "stdin_stdout", "input": "ab`cc`b`", "output": "No...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMatrix of given integers\n\n\na1,1 a1,2 ... a1, n\na2,1 a2,2 ... a2, n\n::\nan, 1 an, 2 ... an, n\n\n\nThen, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the v...
[{"type": "stdin_stdout", "input": "4\n1 3 -9 2\n2 7 -1 5\n-8 3 2 -1\n5 -1 -3 1", "output": "15\n"}, {"type": "stdin_stdout", "input": "4\n1 3 -9 0\n2 7 -1 5\n-8 3 2 -2\n3 -1 -3 1", "output": "14\n"}, {"type": "stdin_stdout", "input": "4\n1 3 -9 2\n2 4 -1 5\n-8 3 2 -1\n5 -1 -6 1", "output": "12\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNinja Atsushi guards the town from the roof of the Ninja Building from early morning to late night every day. This Ninja Building is two adjacent buildings of the same floor, and Atsushi's daily routine is to jump between...
[{"type": "stdin_stdout", "input": "8\n0 0 0 2 3 1 0 -1\n1 2 -1 2 1 0 -1 0\n2\n1 1 2 2\n0 -1 2 2\n-1", "output": "4\n0\n"}, {"type": "stdin_stdout", "input": "8\n0 0 -1 2 2 2 0 -1\n1 1 1 1 1 1 -1 0\n2\n1 1 2 2\n0 -1 4 2\n0", "output": "1\n0\n"}, {"type": "stdin_stdout", "input": "8\n0 0 0 2 3 1 0 -1\n1 2 0 2 1 0 -1 0\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are now examining a unique method to sort a sequence of numbers in increasing order. The method only allows swapping of two numbers that have a common prime factor. For example, a sequence [6, 4, 2, 3, 7] can be sorte...
[{"type": "stdin_stdout", "input": "7\n4 7 6 5 6 12 5", "output": "0\n"}, {"type": "stdin_stdout", "input": "7\n4 7 6 4 6 13 5", "output": "0\n"}, {"type": "stdin_stdout", "input": "7\n2 9 6 5 6 7 5", "output": "0\n"}, {"type": "stdin_stdout", "input": "7\n4 9 6 5 6 7 5", "output": "0\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPeter is a senior manager of Agile Change Management (ACM) Inc., where each employee is a member of one or more task groups. Since ACM is agile, task groups are often reorganized and their members frequently change, so me...
[{"type": "stdin_stdout", "input": "2\ndevelopment:alice,bob,design,eve.\ndesign:carol,alice.\n3\none:another.\nanother:yetanother.\nxetanother:dave.\n3\nfriends:alice,bob,bestfriends,carol,fran,badcompany.\nbestfriends:eve,alice.\nbadcompany:dave,carol.\n5\na:b,c,d,e.\nb:c,d,e,f.\nc:d,e,f,g.\nd:e,f,g,h.\ne:f,g,h,i.\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem statement\n\n2D, who is good at cooking, is trying to make lunch. Cooking requires all N ingredients a_ {0}, a_ {1},…, a_ {Nβˆ’1}.\n\nNow, 2D's refrigerator doesn't contain any ingredients, so I have to go to the su...
[{"type": "stdin_stdout", "input": "2\npaks 0\naxii -1\n-1\nnkua hx`j", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2\ntako -1\njiay -1\n0\npuja yakh", "output": "-2\n"}, {"type": "stdin_stdout", "input": "2\npaks -2\nayhi -1\n0\nmauk j`xh", "output": "-3\n"}, {"type": "stdin_stdout", "input": "2\npaks 1\naxi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nproblem\n\nPrepare the Othello board. The upper left is $ (1,1) $ and the lower right is $ (8,8) $. The board to be prepared here is $ (5,4) as follows. ) There is no $ black stone.\n\n\n........\n........\n........\n... ...
[{"type": "stdin_stdout", "input": "3\n1 1 10 1\n2 4 6 8\n6 3 8 8", "output": "10\n19\n15\n"}, {"type": "stdin_stdout", "input": "3\n1 1 10 1\n2 4 6 8\n8 3 8 8", "output": "10\n19\n6\n"}, {"type": "stdin_stdout", "input": "3\n1 1 10 1\n2 4 6 8\n8 3 8 4", "output": "10\n19\n2\n"}, {"type": "stdin_stdout", "input": "3\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given $N$ points in the 2D Euclidean plane, find the distance of the shortest tour that meets the following criteria:\n\n* Visit the points according to the following steps:\n1. It starts from the leftmost point (star...
[{"type": "stdin_stdout", "input": "5\n-1 0\n1 2\n2 1\n3 2\n4 0", "output": "12.462840740\n"}, {"type": "stdin_stdout", "input": "5\n0 0\n1 2\n2 1\n3 2\n4 0", "output": "10.94427191"}, {"type": "stdin_stdout", "input": "3\n-13 -1\n0 -1\n10 -2", "output": "46.071604488\n"}, {"type": "stdin_stdout", "input": "3\n-10 -1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor given integer n, count the totatives of n, that is, the positive integers less than or equal to n that are relatively prime to n.\n\n\n\nInput\n\n\nn\n\n\nAn integer n (1 ≀ n ≀ 1000000000).\n\nOutput\n\nThe number of ...
[{"type": "stdin_stdout", "input": "1101011", "output": "1084512\n"}, {"type": "stdin_stdout", "input": "1100111", "output": "1097712\n"}, {"type": "stdin_stdout", "input": "1010111", "output": "1003752\n"}, {"type": "stdin_stdout", "input": "1111111", "output": "1106224\n"}, {"type": "stdin_stdout", "input": "1011001"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChef Jessie has a lot of recipes with her (N). She often remembered the starting few characters of the recipe and forgot the rest. As all the great chefs do, Jessie also numbered the recipes depending on the priority. So,...
[{"type": "stdin_stdout", "input": "4\nflour-with-eggs 100\nchicken-ham -10\nflour-without-eggs 200\nfish-with-pepper 1100\n6\nf\nflour-with\nflour-with-\nc\nfl\nchik", "output": "fish-with-pepper\nflour-without-eggs\nflour-with-eggs\nchicken-ham\nflour-without-eggs\nNO\n"}, {"type": "stdin_stdout", "input": "4\nflour-...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs you know, majority of students and teachers of Summer Informatics School live in Berland for the most part of the year. Since corruption there is quite widespread, the following story is not uncommon.\n\nElections are ...
[{"type": "stdin_stdout", "input": "10 10\n5 81\n7 68\n7 48\n1 10\n5 37\n7 97\n8 54\n7 41\n7 56\n5 21\n", "output": "110\n"}, {"type": "stdin_stdout", "input": "10 10\n7 29\n10 31\n9 40\n5 17\n5 30\n6 85\n2 53\n7 23\n4 57\n10 9\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "10 10\n7 29\n10 31\n9 32\n5 17\n5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a tube which is reflective inside represented as two non-coinciding, but parallel to Ox lines. Each line has some special integer points β€” positions of sensors on sides of the tube.\n\nYou are going to emit ...
[{"type": "stdin_stdout", "input": "13 968288\n0 67108864 134217728 201326592 268435456 335544320 402653184 469762048 536870912 603979776 671088640 738197504 805306368\n13 986214\n33554432 100663296 167772160 234881024 301989888 369098752 436207616 503316480 570425344 637534208 704643072 771751936 838860800\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLunar New Year is approaching, and Bob is struggling with his homework – a number division problem.\n\nThere are n positive integers a_1, a_2, …, a_n on Bob's homework paper, where n is always an even number. Bob is asked...
[{"type": "stdin_stdout", "input": "100\n28 27 23 6 23 11 25 20 28 15 29 23 20 2 8 24 8 9 30 8 8 1 11 7 6 17 17 27 26 30 12 22 17 22 9 25 4 26 9 26 10 30 13 4 16 12 23 19 10 22 12 20 3 16 10 4 29 11 15 4 5 7 29 16 3 1 7 16 26 14 28 1 15 19 30 28 5 22 14 28 13 12 11 30 3 4 7 10 22 8 4 10 22 12 17 27 23 11 18 7\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two arrays a and b, each contains n integers.\n\nYou want to create a new array c as follows: choose some real (i.e. not necessarily integer) number d, and then for every i ∈ [1, n] let c_i := d β‹… a_i + b_i....
[{"type": "stdin_stdout", "input": "5\n-999999999 999999999 1252085585 999999998 -414067761\n-1011239935 -1000000000 -1000000000 -1397885361 1010000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n-999999999 999999999 1252085585 999999998 -421666581\n-1011239935 -1000000000 -1000000000 -1397885361 101000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have an array a_1, a_2, ..., a_n. \n\nLet's call some subarray a_l, a_{l + 1}, ... , a_r of this array a subpermutation if it contains all integers from 1 to r-l+1 exactly once. For example, array a = [2, 2, 1, 3, 2, ...
[{"type": "stdin_stdout", "input": "99\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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 9...
code_stdio