messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
2 values
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Santa asks all the great programmers of the world to solve a trivial problem. He gives them an integer m and asks for the number of positive integers n, such that the factorial of n ends with exactly m zeroes. Are you...
[{"type": "stdin_stdout", "input": "100000\n", "output": "5\n400005 400006 400007 400008 400009 "}, {"type": "stdin_stdout", "input": "100000\n", "output": "5\n400005 400006 400007 400008 400009 "}, {"type": "stdin_stdout", "input": "26151\n", "output": "5\n104620 104621 104622 104623 104624 "}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nChouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.\n\nYou are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vert...
[{"type": "stdin_stdout", "input": "4 4 2\n3 4\n1 2 1000000000\n2 3 1000000000\n3 1 1000000000\n3 4 1\n", "output": "1 1 \n"}, {"type": "stdin_stdout", "input": "5 7 4\n1 2 3 4\n1 2 3\n5 1 4\n3 1 1\n4 2 5\n2 5 6\n2 3 3\n3 4 6\n", "output": "5 5 5 5 \n"}, {"type": "stdin_stdout", "input": "6 5 4\n1 2 3 4\n1 2 1\n2 3 1\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball ...
[{"type": "stdin_stdout", "input": "2000000000\n0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1999999995\n0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1999999995\n1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1999999995\n2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given n rectangles. The corners of rectangles have integer coordinates and their edges are parallel to the Ox and Oy axes. The rectangles may touch each other, but they do not overlap (that is, there are no points...
[{"type": "stdin_stdout", "input": "5\n20421 5189 23141 12511\n16414 10436 17880 12511\n17880 10436 20421 12511\n15819 10436 16414 12511\n15819 5189 20421 10436\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\n10359 859 28918 4384\n2895 26520 28918 26882\n2895 26424 28918 26520\n2895 859 10359 4384\n2895 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks that a positive integer number x is really big if the difference between x and the sum of its digits (...
[{"type": "stdin_stdout", "input": "1000000000000000000 100000000000000000\n", "output": "899999999999999991\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 200000000000000000\n", "output": "799999999999999991\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 10000000000000000\n", "output": "98999...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMemory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, both Memory and Lexa get some integer in the range [ - ...
[{"type": "stdin_stdout", "input": "100 100 1000 100\n", "output": "922257788\n"}, {"type": "stdin_stdout", "input": "1 100 1000 100\n", "output": "542673827\n"}, {"type": "stdin_stdout", "input": "100 1 1000 100\n", "output": "603336175\n"}, {"type": "stdin_stdout", "input": "10 10 1000 100\n", "output": "922257788\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler! \n\nHowever, there is no reason for disappointment, as Valery has found anot...
[{"type": "stdin_stdout", "input": "112 1867 1261 1606\n0 7 17 43 67 70 87 112 129 141 148 162 179 180 189 202 211 220 231 247 250 277 308 311 327 376 400 406 409 417 418 444 480 512 514 515 518 547 572 575 578 587 612 617 654 684 701 742 757 761 788 821 825 835 841 843 850 858 869 872 881 936 939 969 970 971 997 1026 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs you know, every birthday party has a cake! This time, Babaei is going to prepare the very special birthday party's cake.\n\nSimple cake is a cylinder of some radius and height. The volume of the simple cake is equal to...
[{"type": "stdin_stdout", "input": "24\n14 3600\n105 64\n40 441\n15 3136\n24 1225\n42 400\n84 100\n12 4900\n120 49\n56 225\n140 36\n70 144\n168 25\n60 196\n30 784\n280 9\n10 7056\n21 1600\n28 900\n210 16\n420 4\n840 1\n35 576\n20 1764\n", "output": "2216707.776373104\n"}, {"type": "stdin_stdout", "input": "18\n3 6400\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a toy building consisting of $n$ towers. Each tower consists of several cubes standing on each other. The $i$-th tower consists of $h_i$ cubes, so it has height $h_i$.\n\nLet's define operation slice on some heig...
[{"type": "stdin_stdout", "input": "10 10\n1 1 1 1 1 1 1 1 1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "10 10\n3 3 3 3 3 3 3 3 3 3\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 3\n1 200000 200000\n", "output": "199999\n"}, {"type": "stdin_stdout", "input": "2 25584\n13182 19648\n", "output"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMishka is decorating the Christmas tree. He has got three garlands, and all of them will be put on the tree. After that Mishka will switch these garlands on.\n\nWhen a garland is switched on, it periodically changes its s...
[{"type": "stdin_stdout", "input": "1499 1498 1500\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1500 1500 1500\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1493 1489 1487\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "2 998 1000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$ of length $n$ consisting of lowercase Latin letters. You may apply some operations to this string: in one operation you can delete some contiguous substring of this string, if all letters in the...
[{"type": "stdin_stdout", "input": "500\nbbababaabaabaabbbbbbaabbabbabbaabababababbbbabaaabbbbaaabbbbbbbabababaaaaabbbbabaababbababbaaaaaabbaaabbaabaaababbbbbabbaabaabaabbbaaabaabbaaabbaabababbaaabaaabaaaaabbbababaabbbbabbbbbababbbaabaabbabaabbabbababbbbbaababbaabbbbbbbbaabbabbbabababaaaaaaaaaabababaaabbaabbbabbabbbbab...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Berland State University is hosting a ballroom dance in celebration of its 100500-th anniversary! n boys and m girls are already busy rehearsing waltz, minuet, polonaise and quadrille moves.\n\nWe know that several bo...
[{"type": "stdin_stdout", "input": "100\n4 1 1 1 3 3 2 5 1 2 1 2 1 1 1 6 1 3 1 1 1 1 2 4 1 1 4 2 2 8 2 2 1 8 2 4 3 3 8 1 3 2 3 2 1 3 8 2 2 3 1 1 2 2 5 1 4 3 1 1 3 1 3 1 7 1 1 1 3 2 1 2 2 3 7 2 1 4 3 2 1 1 3 4 1 1 3 5 1 8 4 1 1 1 3 10 2 2 1 2\n100\n1 1 5 2 13 2 2 3 6 12 1 13 8 1 1 16 1 1 5 6 2 4 6 4 2 7 4 1 7 3 3 9 5 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKicker (table football) is a board game based on football, in which players control the footballers' figures mounted on rods by using bars to get the ball into the opponent's goal. When playing two on two, one player of e...
[{"type": "stdin_stdout", "input": "1 100\n100 1\n99 99\n99 99\n", "output": "Team 1\n"}, {"type": "stdin_stdout", "input": "80 79\n79 30\n80 81\n40 80\n", "output": "Team 2\n"}, {"type": "stdin_stdout", "input": "48 41\n15 47\n11 38\n19 31\n", "output": "Team 1\n"}, {"type": "stdin_stdout", "input": "51 54\n95 28\n42 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi wants to grill N pieces of meat on a grilling net, which can be seen as a two-dimensional plane. The coordinates of the i-th piece of meat are \\left(x_i, y_i\\right), and its hardness is c_i.\nTakahashi can use...
[{"type": "stdin_stdout", "input": "60 60\n1000 1000 80\n1000 -1000 17\n-1000 1000 38\n-1000 -1000 76\n1000 316 83\n1000 25 65\n1000 547 40\n1000 290 41\n1000 -523 55\n1000 951 3\n1000 -685 16\n1000 -172 56\n1000 -564 13\n1000 449 11\n1000 330 74\n1000 -264 31\n1000 -620 24\n-1000 -998 9\n-1000 763 76\n-1000 -923 4\n-1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read: \"Find such positive integer n, that among numbers n + 1, n + 2, ..., 2·n there are exactly m n...
[{"type": "stdin_stdout", "input": "101628400788615604 30\n", "output": "999999999999995905\n"}, {"type": "stdin_stdout", "input": "101628400798615604 31\n", "output": "981546175132942729\n"}, {"type": "stdin_stdout", "input": "10000000000000000 35\n", "output": "247948501945678280\n"}, {"type": "stdin_stdout", "input"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this problem you will meet the simplified model of game King of Thieves.\n\nIn a new ZeptoLab game called \"King of Thieves\" your aim is to reach a chest with gold by controlling your character, avoiding traps and obs...
[{"type": "stdin_stdout", "input": "100\n****************************************************************************************************\n", "output": "yes"}, {"type": "stdin_stdout", "input": "100\n*****...............................................................................................\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nZS the Coder and Chris the Baboon arrived at the entrance of Udayland. There is a n × n magic grid on the entrance which is filled with integers. Chris noticed that exactly one of the cells in the grid is empty, and to en...
[{"type": "stdin_stdout", "input": "9\n1 1000000000 1 1000000000 1 1000000000 1 1000000000 1\n1000000000 1 1000000000 1 1 1 1000000000 1 1000000000\n1 1000000000 1 1000000000 1 1000000000 1 1000000000 1\n1000000000 1 1000000000 1 1 1 1000000000 1 1000000000\n1 1 1 1 0 1 1 1 1\n1000000000 1 1000000000 1 1 1 1000000000 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ benches in the Berland Central park. It is known that $a_i$ people are currently sitting on the $i$-th bench. Another $m$ people are coming to the park and each of them is going to have a seat on some bench ...
[{"type": "stdin_stdout", "input": "100\n3241\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100\n100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA company of $n$ friends wants to order exactly two pizzas. It is known that in total there are $9$ pizza ingredients in nature, which are denoted by integers from $1$ to $9$.\n\nEach of the $n$ friends has one or more fa...
[{"type": "stdin_stdout", "input": "5 5\n8 5 3 8 4 1 9 7 6\n4 6 7 8 2\n4 8 4 1 3\n1 7\n9 9 4 7 6 5 8 3 1 2\n1 5 8 2 4 5 3\n1 9 2 6 9 5 8 4 3 1 7\n1 8 1 6 2 7 9 5 4 3\n1 3 7 9 6\n1 7 6 9 2 1 5 8 7\n", "output": "1 2\n"}, {"type": "stdin_stdout", "input": "5 5\n9 7 3 2 9 4 6 1 5 8\n3 1 9 8\n4 1 3 8 9\n5 7 5 6 9 3\n8 5 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have a positive integer m and a non-negative integer s. Your task is to find the smallest and the largest of the numbers that have length m and sum of digits s. The required numbers should be non-negative integers wri...
[{"type": "stdin_stdout", "input": "100 100\n", "output": "1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000099999999999 9999999999910000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n"}, {"type": "stdin_stdout", "input": "100 296\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers $l$ and $r$ ($l \\le r$). Your task is to calculate the sum of numbers from $l$ to $r$ (including $l$ and $r$) such that each number contains at most $k$ different digits, and print this sum mod...
[{"type": "stdin_stdout", "input": "299877849271027626 687486864689028806 10\n", "output": "285886436\n"}, {"type": "stdin_stdout", "input": "996517375802030519 996517375802227037 10\n", "output": "795592963\n"}, {"type": "stdin_stdout", "input": "999999999999999999 999999999999999999 10\n", "output": "716070897\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.\n\nNow he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs fo...
[{"type": "stdin_stdout", "input": "!Y!!!Y!!G!!!G!!B!!R!!!!B!!!!!Y!!G!R!!!!!!!!!!!!B!!!!GY!B!!!!!YR!G!!!!!!B!Y!B!!!!!!R!G!!!!!!!G!R!!!!B\n", "output": "20 18 19 18"}, {"type": "stdin_stdout", "input": "!!!!!!!!!!!!!!!!!!Y!!!!!!!!!!!!!!!!!!B!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!G!!R!!!!!!!!!!!!\n", "output": "24...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a cave consisting of N rooms and M one-directional passages. The rooms are numbered 1 through N.\nTakahashi is now in Room 1, and Room N has the exit. The i-th passage connects Room s_i and Room t_i (s_i < t_i) a...
[{"type": "stdin_stdout", "input": "600 6251\n421 424\n422 488\n346 422\n556 565\n162 425\n500 595\n155 570\n391 405\n572 598\n287 416\n534 564\n452 513\n361 465\n31 420\n531 533\n45 458\n170 310\n176 284\n445 477\n319 415\n106 343\n405 428\n401 478\n178 456\n433 534\n532 584\n351 392\n252 319\n435 496\n341 521\n553 56...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded.\n\nFor example, if n = 4722 answer is 4720. If n = 5 Vasy...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "999999999\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "999999998\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "999999994\n", "output": "999999990\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSanta Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of keys took each other's place! That is, Santa suspects that each key is either on it...
[{"type": "stdin_stdout", "input": "dofbgdppdvmwjwtdyphhmqliydxyjfxoopxiscevowleccmhwybsxitvujkfliamvqinlrpytyaqdlbywccprukoisyaseibuqbfqjcabkieimsggsakpnqliwhehnemewhychqrfiuyaecoydnromrh\ndofbgdppdvmwjwtdyphhmqliydxyjfxoopxiscevowleccmhwybsxitvujkfliamvqinlrpytyaqdlbywccprukoisyaseibuqbfqjcabkieimsggsakpnqliwhehnemew...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe preferred way to generate user login in Polygon is to concatenate a prefix of the user's first name and a prefix of their last name, in that order. Each prefix must be non-empty, and any of the prefixes can be the ful...
[{"type": "stdin_stdout", "input": "asdfghjkli ware\n", "output": "asdfghjkliw\n"}, {"type": "stdin_stdout", "input": "aaaaaaaaaz york\n", "output": "aaaaaaaaay\n"}, {"type": "stdin_stdout", "input": "wixjzniiub ssdfodfgap\n", "output": "wis\n"}, {"type": "stdin_stdout", "input": "bgopsdfji uaps\n", "output": "bgopsdfj...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA sequence of square brackets is regular if by inserting symbols \"+\" and \"1\" into it, you can get a regular mathematical expression from it. For example, sequences \"[[]][]\", \"[]\" and \"[[][[]]]\" — are regular, at...
[{"type": "stdin_stdout", "input": "30\n[[[[][]][]]][][[[][[]]][[]][]]\n", "output": "+- -++- -++- -+\n|+- -+|| ||+- -++- -++- -+|\n||+- -++- -+||| |||+- -++- -+||+- -+|| ||\n|||+- -++- -+|| |||| |||| ||+- -+|||| ||| ||\n|||| || ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou took a peek on Thanos wearing Infinity Gauntlet. In the Gauntlet there is a place for six Infinity Gems: the Power Gem of purple color, the Time Gem of green color, the Space Gem of blue color, the Soul Gem of ora...
[{"type": "stdin_stdout", "input": "4\ngreen\nyellow\norange\npurple\n", "output": "2\nReality\nSpace\n"}, {"type": "stdin_stdout", "input": "3\nyellow\npurple\norange\n", "output": "3\nSpace\nTime\nReality\n"}, {"type": "stdin_stdout", "input": "3\norange\nyellow\ngreen\n", "output": "3\nPower\nSpace\nReality\n"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe last stage of Football World Cup is played using the play-off system.\n\nThere are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in ...
[{"type": "stdin_stdout", "input": "256 128 256\n", "output": "Final!\n"}, {"type": "stdin_stdout", "input": "256 128 129\n", "output": "Final!\n"}, {"type": "stdin_stdout", "input": "256 255 128\n", "output": "Final!\n"}, {"type": "stdin_stdout", "input": "128 30 98\n", "output": "Final!\n"}, {"type": "stdin_stdout", ...
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\nThe on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v_1 meters per second, and in the end it is v_2 meters per second. We know that this section of the r...
[{"type": "stdin_stdout", "input": "100 100\n100 10\n", "output": "34500"}, {"type": "stdin_stdout", "input": "100 100\n100 0\n", "output": "10000"}, {"type": "stdin_stdout", "input": "100 100\n100 1\n", "output": "12450"}, {"type": "stdin_stdout", "input": "1 100\n100 10\n", "output": "29305"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEven if the world is full of counterfeits, I still regard it as wonderful.\n\nPile up herbs and incense, and arise again from the flames and ashes of its predecessor — as is known to many, the phoenix does it like this.\n...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "999999999000000000 1000000000000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "500000000000000000 1000000000000000000\n", "output": "0\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolandBall is a young, clever Ball. He is interested in prime numbers. He has stated a following hypothesis: \"There exists such a positive integer n that for each positive integer m number n·m + 1 is a prime number\".\n\...
[{"type": "stdin_stdout", "input": "1000\n", "output": "1"}, {"type": "stdin_stdout", "input": "153\n", "output": "1"}, {"type": "stdin_stdout", "input": "998\n", "output": "1"}, {"type": "stdin_stdout", "input": "996\n", "output": "3"}, {"type": "stdin_stdout", "input": "210\n", "output": "4"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKolya is developing an economy simulator game. His most favourite part of the development process is in-game testing. Once he was entertained by the testing so much, that he found out his game-coin score become equal to 0...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "YES"}, {"type": "stdin_stdout", "input": "438734347\n", "output": "YES"}, {"type": "stdin_stdout", "input": "999999987\n", "output": "YES"}, {"type": "stdin_stdout", "input": "999999999\n", "output": "YES"}, {"type": "stdin_stdout", "input": "999999244\n", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's define a split of $n$ as a nonincreasing sequence of positive integers, the sum of which is $n$. \n\nFor example, the following sequences are splits of $8$: $[4, 4]$, $[3, 3, 2]$, $[2, 2, 1, 1, 1, 1]$, $[5, 2, 1]$.\...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "500000001\n"}, {"type": "stdin_stdout", "input": "574128507\n", "output": "287064254\n"}, {"type": "stdin_stdout", "input": "648476655\n", "output": "324238328\n"}, {"type": "stdin_stdout", "input": "716489761\n", "output": "358244881\n"}, {"type": "stdin_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFamous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will follow knockout rules from the very first game. ...
[{"type": "stdin_stdout", "input": "1000000000000000000\n", "output": "85\n"}, {"type": "stdin_stdout", "input": "123456789123456789\n", "output": "81\n"}, {"type": "stdin_stdout", "input": "679891637638612257\n", "output": "84\n"}, {"type": "stdin_stdout", "input": "679891637638612258\n", "output": "85\n"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTonio has a keyboard with only two letters, \"V\" and \"K\".\n\nOne day, he has typed out a string s with only these two letters. He really likes it when the string \"VK\" appears, so he wishes to change at most one lette...
[{"type": "stdin_stdout", "input": "VVKKVKKVVKKVKKVKVVKKVKKVVKKVKVVKKVKKVKVVKKVVKKVKVVKKVKVVKKVVKVVKKVKKVKKVKKVKKVKVVKKVKKVKKVKKVKKVVKVK\n", "output": "32\n"}, {"type": "stdin_stdout", "input": "VVVVVKKVKVKVKVVKVVKKVVKVKKKKKKKVKKKVVVVVVKKVVVKVKVVKVKKVVKVVVKKKKKVVVVVKVVVVKVVVKKVKKVKKKVKKVKKVVKKV\n", "output": "25\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Sofia is in fourth grade. Today in the geometry lesson she learned about segments and squares. On the way home, she decided to draw $n$ squares in the snow with a side length of $1$. For simplicity, we assume that ...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "63246\n"}, {"type": "stdin_stdout", "input": "423353776\n", "output": "41152\n"}, {"type": "stdin_stdout", "input": "999950884\n", "output": "63244\n"}, {"type": "stdin_stdout", "input": "605551861\n", "output": "49216\n"}, {"type": "stdin_stdout", "input": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBear Limak wants to become the largest of bears, or at least to become larger than his brother Bob.\n\nRight now, Limak and Bob weigh a and b respectively. It's guaranteed that Limak's weight is smaller than or equal to h...
[{"type": "stdin_stdout", "input": "10 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 10\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "1 10\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "2 10\n", "output": "4\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSpongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly x distinct squares in the table consisting of n rows and m c...
[{"type": "stdin_stdout", "input": "90006000426440\n", "output": "30\n1 90006000426440\n2 30002000142147\n3 15001000071074\n4 9000600042645\n7 3214500015232\n16 661808826670\n20 428600002037\n34 151270588963\n48 76535714664\n84 25211764853\n111 14479729835\n119 12605882452\n147 8274131362\n628 455712949\n784 292493438\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEverybody in Russia uses Gregorian calendar. In this calendar there are 31 days in January, 28 or 29 days in February (depending on whether the year is leap or not), 31 days in March, 30 days in April, 31 days in May, 30 ...
[{"type": "stdin_stdout", "input": "24\n31 28 31 30 31 30 31 31 30 31 30 31 31 29 31 30 31 30 31 31 30 31 30 31\n", "output": "Yes\n\n"}, {"type": "stdin_stdout", "input": "24\n31 28 31 30 31 30 31 31 30 31 30 31 31 28 31 30 31 30 31 31 30 31 30 31\n", "output": "Yes\n\n"}, {"type": "stdin_stdout", "input": "24\n28 31 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a positive integer $n$.\n\nFind a sequence of fractions $\\frac{a_i}{b_i}$, $i = 1 \\ldots k$ (where $a_i$ and $b_i$ are positive integers) for some $k$ such that:\n\n$$ \\begin{cases} \\text{$b_i$ divides $...
[{"type": "stdin_stdout", "input": "792852058\n", "output": "YES\n2\n1 2\n198213014 396426029\n"}, {"type": "stdin_stdout", "input": "672783194\n", "output": "YES\n2\n1 2\n168195798 336391597\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "YES\n2\n403 512\n415802 1953125\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya should paint a fence in front of his own cottage. The fence is a sequence of n wooden boards arranged in a single row. Each board is a 1 centimeter wide rectangle. Let's number the board fence using numbers 1, 2, .....
[{"type": "stdin_stdout", "input": "118\n8850 1770\n97 19 137 20 92 16 145 35 2 86 4 83 147 135 125 7 145 84 142 124 14 91 169 132 149 117 67 41 137 132 91 34 162 70 92 75 73 24 6 143 24 12 149 48 107 82 146 119 107 174 166 103 42 31 70 142 156 25 153 159 116 108 151 21 156 43 38 85 68 2 107 16 163 179 92 150 48 52 85 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has got three integers $n$, $m$ and $k$. He'd like to find three integer points $(x_1, y_1)$, $(x_2, y_2)$, $(x_3, y_3)$, such that $0 \\le x_1, x_2, x_3 \\le n$, $0 \\le y_1, y_2, y_3 \\le m$ and the area of the tr...
[{"type": "stdin_stdout", "input": "1000000000 1000000000 2\n", "output": "YES\n0 0\n0 1000000000\n1000000000 0\n"}, {"type": "stdin_stdout", "input": "1000000000 999999937 1024\n", "output": "YES\n0 0\n0 999999937\n1953125 0\n"}, {"type": "stdin_stdout", "input": "236887699 1000000000 2\n", "output": "YES\n0 0\n0 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.\n\nToday he invented one simple game to play with Lena, with w...
[{"type": "stdin_stdout", "input": "251656215122324104 164397544865601257\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "669038685745448997 501718093668307460\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "255787422422806632 146884995820359999\n", "output": "YES\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTranslator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.\n\nThe term is comin...
[{"type": "stdin_stdout", "input": "100\n3 2 4 3 3 3 4 2 3 5 5 2 5 2 3 2 4 4 4 5 5 4 2 5 4 3 2 5 3 4 3 4 2 4 5 4 2 4 3 4 5 2 5 3 3 4 2 2 4 4 4 5 4 3 3 3 2 5 2 2 2 3 5 4 3 2 4 5 5 5 2 2 4 2 3 3 3 5 3 2 2 4 5 5 4 5 5 4 2 3 2 2 2 2 5 3 5 2 3 4\n", "output": "40\n"}, {"type": "stdin_stdout", "input": "100\n2 2 2 2 2 2 2 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven 2 integers $u$ and $v$, find the shortest array such that bitwise-xor of its elements is $u$, and the sum of its elements is $v$.\n\n\n-----Input-----\n\nThe only line contains 2 integers $u$ and $v$ $(0 \\le u,v \\...
[{"type": "stdin_stdout", "input": "293341698588646512 496573494755010944\n", "output": "3\n293341698588646512 101615898083182216 101615898083182216"}, {"type": "stdin_stdout", "input": "247970080241541989 808225497994435575\n", "output": "3\n247970080241541989 280127708876446793 280127708876446793"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProf. Vasechkin wants to represent positive integer n as a sum of addends, where each addends is an integer number containing only 1s. For example, he can represent 121 as 121=111+11+–1. Help him to find the least number ...
[{"type": "stdin_stdout", "input": "973546235465729\n", "output": "263\n"}, {"type": "stdin_stdout", "input": "842369588365127\n", "output": "330\n"}, {"type": "stdin_stdout", "input": "768617061415848\n", "output": "390\n"}, {"type": "stdin_stdout", "input": "694855944531976\n", "output": "348\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCaptain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of teleportation and said that only this potion might help them to reach the treasure. \n\nBottle wi...
[{"type": "stdin_stdout", "input": "-100000 -100000 100000 100000\n100000 100000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "100000 100000 99999 99999\n100000 100000\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "-84870 -42042 94570 98028\n8972 23345\n", "output": "YES\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the lo...
[{"type": "stdin_stdout", "input": "987654320023456789\n", "output": "29340299842560\n"}, {"type": "stdin_stdout", "input": "987654321123456789\n", "output": "33007837322880\n"}, {"type": "stdin_stdout", "input": "987654321123456780\n", "output": "55657759288320\n"}, {"type": "stdin_stdout", "input": "23490681737975942...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA new delivery of clothing has arrived today to the clothing store. This delivery consists of $a$ ties, $b$ scarves, $c$ vests and $d$ jackets.\n\nThe store does not sell single clothing items — instead, it sells suits of...
[{"type": "stdin_stdout", "input": "100000\n100000\n100000\n100000\n1000\n1000\n", "output": "100000000\n"}, {"type": "stdin_stdout", "input": "100000\n100000\n100000\n100000\n1000\n1\n", "output": "100000000\n"}, {"type": "stdin_stdout", "input": "100000\n100000\n100000\n100000\n1\n1000\n", "output": "100000000\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an integer $x$. Your task is to find out how many positive integers $n$ ($1 \\leq n \\leq x$) satisfy $$n \\cdot a^n \\equiv b \\quad (\\textrm{mod}\\;p),$$ where $a, b, p$ are all known constants.\n\n\n-----Input--...
[{"type": "stdin_stdout", "input": "1000002 1000002 1000003 1000000000000\n", "output": "999998\n"}, {"type": "stdin_stdout", "input": "693528 398514 1000003 1000000000000\n", "output": "999995\n"}, {"type": "stdin_stdout", "input": "299973 381004 1000003 140225320941\n", "output": "140481\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Anton found a box with digits in his room. There are k_2 digits 2, k_3 digits 3, k_5 digits 5 and k_6 digits 6.\n\nAnton's favorite integers are 32 and 256. He decided to compose this integers from digits he has....
[{"type": "stdin_stdout", "input": "5000000 5000000 5000000 5000000\n", "output": "1280000000\n"}, {"type": "stdin_stdout", "input": "4759823 3520376 4743363 4743363\n", "output": "1214827648\n"}, {"type": "stdin_stdout", "input": "1480320 1969946 1158387 3940412\n", "output": "306848928\n"}, {"type": "stdin_stdout", "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMr. Bender has a digital table of size n × n, each cell can be switched on or off. He wants the field to have at least c switched on squares. When this condition is fulfilled, Mr Bender will be happy.\n\nWe'll consider th...
[{"type": "stdin_stdout", "input": "1000000000 504951981 646612086 602763371\n", "output": "17360\n"}, {"type": "stdin_stdout", "input": "1000000000 999999946 999999941 715189365\n", "output": "37707\n"}, {"type": "stdin_stdout", "input": "1000000000 999999916 999999940 857945620\n", "output": "41279\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of $2n+1$ integer points on a Cartesian plane. Points are numbered from $0$ to $2n$ inclusive. Let $P_i$ be the $i$-th point. The $x$-coordinate of the point $P_i$ equals $i$. The $y$-coordinate of the...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1000000000000000000\n", "output": "1000000000000000000\n"}, {"type": "stdin_stdout", "input": "1000000001 1000000000000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMasha lives in a multi-storey building, where floors are numbered with positive integers. Two floors are called adjacent if their numbers differ by one. Masha decided to visit Egor. Masha lives on the floor $x$, Egor on t...
[{"type": "stdin_stdout", "input": "1000 999 1000 1000 1000 1000\n", "output": "NO"}, {"type": "stdin_stdout", "input": "837 544 703 808 549 694\n", "output": "YES"}, {"type": "stdin_stdout", "input": "602 375 551 580 466 704\n", "output": "YES"}, {"type": "stdin_stdout", "input": "723 971 992 711 336 872\n", "output":...
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"}, {"type": "stdin_stdout", "input": "1000000000 100000000\n", "output": "100000001"}, {"type": "stdin_stdout", "input": "1000000000 500000000\n", "output": "500000001"}, {"type": "stdin_stdout", "input": "262833325 131416663\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlena has successfully passed the entrance exams to the university and is now looking forward to start studying.\n\nOne two-hour lesson at the Russian university is traditionally called a pair, it lasts for two academic h...
[{"type": "stdin_stdout", "input": "100\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100\n0 1 1 0 1 1 0 0...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBran and his older sister Arya are from the same house. Bran like candies so much, so Arya is going to give him some Candies.\n\nAt first, Arya and Bran have 0 Candies. There are n days, at the i-th day, Arya finds a_{i} ...
[{"type": "stdin_stdout", "input": "100 456\n100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently a dog was bought for Polycarp. The dog's name is Cormen. Now Polycarp has a lot of troubles. For example, Cormen likes going for a walk. \n\nEmpirically Polycarp learned that the dog needs at least k walks for an...
[{"type": "stdin_stdout", "input": "100 500\n64 140 15 221 24 106 73 30 275 97 296 55 5 30 47 199 130 44 72 170 7 204 359 40 128 117 45 192 344 112 0 11 196 78 73 53 222 93 88 151 99 283 60 71 4 87 226 46 66 74 23 89 77 60 397 181 0 101 358 54 124 155 19 218 9 140 161 130 308 85 103 85 300 128 19 108 225 136 100 54 30 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhile playing with geometric figures Alex has accidentally invented a concept of a $n$-th order rhombus in a cell grid.\n\nA $1$-st order rhombus is just a square $1 \\times 1$ (i.e just a cell).\n\nA $n$-th order rhombus...
[{"type": "stdin_stdout", "input": "100\n", "output": "19801"}, {"type": "stdin_stdout", "input": "78\n", "output": "12013"}, {"type": "stdin_stdout", "input": "87\n", "output": "14965"}, {"type": "stdin_stdout", "input": "94\n", "output": "17485"}, {"type": "stdin_stdout", "input": "90\n", "output": "16021"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devi...
[{"type": "stdin_stdout", "input": "100\nmKtsiDRJypUieHIkvJaMFkwaKxcCIbBszZQLIyPpCDCjhNpAnYFngLjRpnKWpKWtGnwoSteeZXuFHWQxxxOpFlNeYTwKocsXuCoa\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "66\nBovdMlDzTaqKllZILFVfxbLGsRnzmtVVTmqiIDTYrossLEPlmsPrkUYtWEsGHVOnFj\n", "output": "NO\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given the current time in 24-hour format hh:mm. Find and print the time after a minutes.\n\nNote that you should find only the time after a minutes, see the examples to clarify the problem statement.\n\nYou can re...
[{"type": "stdin_stdout", "input": "12:34\n10000\n", "output": "11:14\n"}, {"type": "stdin_stdout", "input": "00:00\n10000\n", "output": "22:40\n"}, {"type": "stdin_stdout", "input": "00:00\n1440\n", "output": "00:00\n"}, {"type": "stdin_stdout", "input": "23:59\n8640\n", "output": "23:59\n"}, {"type": "stdin_stdout", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice has a lovely piece of cloth. It has the shape of a square with a side of length $a$ centimeters. Bob also wants such piece of cloth. He would prefer a square with a side of length $b$ centimeters (where $b < a$). Al...
[{"type": "stdin_stdout", "input": "5\n35838040099 35838040098\n26612022790 26612022789\n23649629085 23649629084\n17783940691 17783940690\n31547284201 31547284200\n", "output": "YES\nYES\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "5\n17406961899 17406961898\n21570966087 21570966086\n31354673689 31354673688\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis.\n\n\n-----Input-----\n\nThe first line co...
[{"type": "stdin_stdout", "input": "23\n-1 1\n-1 2\n-2 4\n-7 -8\n-3 3\n-9 -14\n-5 3\n-6 2\n-7 11\n-4 4\n-8 5\n1 1\n-1 -1\n-1 -2\n-2 -4\n-7 8\n-3 -3\n-9 14\n-5 -3\n-6 -2\n-7 -11\n-4 -4\n-8 -5\n", "output": "Yes"}, {"type": "stdin_stdout", "input": "4\n-1000000000 -1000000000\n1000000000 1000000000\n-1000000000 100000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHolidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory f...
[{"type": "stdin_stdout", "input": "12 1000000000\n", "output": "479001600\n"}, {"type": "stdin_stdout", "input": "1000000000 12\n", "output": "479001600\n"}, {"type": "stdin_stdout", "input": "11 562314608\n", "output": "39916800\n"}, {"type": "stdin_stdout", "input": "11 859155400\n", "output": "39916800\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call a positive integer composite if it has at least one divisor other than $1$ and itself. For example:\n\n the following numbers are composite: $1024$, $4$, $6$, $9$; the following numbers are not composite: $13...
[{"type": "stdin_stdout", "input": "10000000\n", "output": "90000000 80000000\n"}, {"type": "stdin_stdout", "input": "8958020\n", "output": "80622180 71664160\n"}, {"type": "stdin_stdout", "input": "3194897\n", "output": "28754073 25559176\n"}, {"type": "stdin_stdout", "input": "6767476\n", "output": "60907284 54139808...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a directed graph with N vertices numbered 1 to N and M edges.\nThe i-th edge is directed from Vertex A_i to Vertex B_i, and there are C_i coins placed along that edge.\nAdditionally, there is a button on Vertex N...
[{"type": "stdin_stdout", "input": "2500 5000 0\n1206 2272 100000\n315 2399 100000\n1186 1435 100000\n303 1569 100000\n2364 581 100000\n1683 1969 100000\n700 1088 100000\n717 410 100000\n1412 1595 100000\n2066 813 100000\n1190 949 100000\n258 2307 100000\n423 2263 100000\n671 425 100000\n1712 1110 100000\n787 1469 1000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSince Grisha behaved well last year, at New Year's Eve he was visited by Ded Moroz who brought an enormous bag of gifts with him! The bag contains n sweet candies from the good ol' bakery, each labeled from 1 to n corresp...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "1152921504606846975\n"}, {"type": "stdin_stdout", "input": "815936580997298686 684083143940282566\n", "output": "1152921504606846975\n"}, {"type": "stdin_stdout", "input": "816762824175382110 752185261508428780\n", "output": "115...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are $n$ points on the plane, $(x_1,y_1), (x_2,y_2), \\ldots, (x_n,y_n)$.\n\nYou need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the...
[{"type": "stdin_stdout", "input": "10\n100 34\n27 17\n17 73\n12 60\n53 25\n46 31\n61 86\n22 91\n82 91\n8 41\n", "output": "173"}, {"type": "stdin_stdout", "input": "2\n1 100000000\n3 99999999\n", "output": "100000002"}, {"type": "stdin_stdout", "input": "5\n7 7\n5 8\n8 5\n4 9\n9 4\n", "output": "14"}, {"type": "stdin_...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice likes word \"nineteen\" very much. She has a string s and wants the string to contain as many such words as possible. For that reason she can rearrange the letters of the string.\n\nFor example, if she has string \"...
[{"type": "stdin_stdout", "input": "nnnnnnnnnneeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiiiiiiiiiiiiiiiiiiiitttttttttttttttttttt\n", "output": "4"}, {"type": "stdin_stdout", "input": "eihstiirnmteejeehimttrijittjsntjejmessstsemmtristjrhenithrrsssihnthheehhrnmimssjmejjreimjiemrmiis\n", "output": "2"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nZane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us.\n\n [Image] \n\nThe girl lives in house m of a village. There are n houses in that village, lining in a s...
[{"type": "stdin_stdout", "input": "100 1 100\n0 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNastya came to her informatics lesson, and her teacher who is, by the way, a little bit famous here gave her the following task.\n\nTwo matrices $A$ and $B$ are given, each of them has size $n \\times m$. Nastya can perfo...
[{"type": "stdin_stdout", "input": "4 9\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1\n", "output": "YES"}, {"type": "stdin_stdout", "input": "6 6\n1 1 1 1 2 3\n1 1 1 2 3 1\n1 1 2 3 1 1\n1 3 2 1 1 1\n3 2 1 1 1 1\n2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhile Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.\n\nGiven two strings a and b, find the...
[{"type": "stdin_stdout", "input": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA monster is chasing after Rick and Morty on another planet. They're so frightened that sometimes they scream. More accurately, Rick screams at times b, b + a, b + 2a, b + 3a, ... and Morty screams at times d, d + c, d + ...
[{"type": "stdin_stdout", "input": "100 100\n100 100\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "39 52\n88 78\n", "output": "1222\n"}, {"type": "stdin_stdout", "input": "59 96\n34 48\n", "output": "1748\n"}, {"type": "stdin_stdout", "input": "39 21\n95 89\n", "output": "3414\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle C loves number «3» very much. He loves all things about it.\n\nNow he has a positive integer $n$. He wants to split $n$ into $3$ positive integers $a,b,c$, such that $a+b+c=n$ and none of the $3$ integers is a mult...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "1 1 999999998"}, {"type": "stdin_stdout", "input": "387420489\n", "output": "1 1 387420487"}, {"type": "stdin_stdout", "input": "701041167\n", "output": "1 1 701041165"}, {"type": "stdin_stdout", "input": "175744383\n", "output": "1 1 175744381"}, {"type": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya works as a watchman in the gallery. Unfortunately, one of the most expensive paintings was stolen while he was on duty. He doesn't want to be fired, so he has to quickly restore the painting. He remembers some facts...
[{"type": "stdin_stdout", "input": "100000 100000 100000 100000 100000\n", "output": "10000000000\n"}, {"type": "stdin_stdout", "input": "100000 80015 84290 50777 30497\n", "output": "1696900000\n"}, {"type": "stdin_stdout", "input": "100000 64022 49026 55956 88430\n", "output": "6866200000\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nToday's morning was exceptionally snowy. Meshanya decided to go outside and noticed a huge snowball rolling down the mountain! Luckily, there are two stones on that mountain.\n\nInitially, snowball is at height $h$ and it...
[{"type": "stdin_stdout", "input": "29 100\n30 51\n28 92\n", "output": "5021"}, {"type": "stdin_stdout", "input": "71 100\n56 44\n12 85\n", "output": "5053"}, {"type": "stdin_stdout", "input": "93 80\n13 49\n100 21\n", "output": "3220"}, {"type": "stdin_stdout", "input": "46 100\n36 81\n99 28\n", "output": "4961"}, {"t...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt the beginning of the school year Berland State University starts two city school programming groups, for beginners and for intermediate coders. The children were tested in order to sort them into groups. According to t...
[{"type": "stdin_stdout", "input": "100\n78 43 41 93 12 76 62 54 85 5 42 61 93 37 22 6 50 80 63 53 66 47 0 60 43 93 90 8 97 64 80 22 23 47 30 100 80 75 84 95 35 69 36 20 58 99 78 88 1 100 10 69 57 77 68 61 62 85 4 45 24 4 24 74 65 73 91 47 100 35 25 53 27 66 62 55 38 83 56 20 62 10 71 90 41 5 75 83 36 75 15 97 79 52 88...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJATC's math teacher always gives the class some interesting math problems so that they don't get bored. Today the problem is as follows. Given an integer $n$, you can perform the following operations zero or more times: ...
[{"type": "stdin_stdout", "input": "999979\n", "output": "999979 0"}, {"type": "stdin_stdout", "input": "999983\n", "output": "999983 0"}, {"type": "stdin_stdout", "input": "499979\n", "output": "499979 0"}, {"type": "stdin_stdout", "input": "999958\n", "output": "999958 0"}, {"type": "stdin_stdout", "input": "162401\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt an arcade, Takahashi is playing a game called RPS Battle, which is played as follows:\n - The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A d...
[{"type": "stdin_stdout", "input": "99901 2\n3193 1797 2772\nssrprrspsrprsrpsrprsssprrsrssrrprppprrrrrrrsprrrrsprsprsspsspprrrrpprsrprrrrpsspprrrspspsprprprprrpprppsrspprrsssssprsrrsrrsssppsprsrprpprpspppsprrspsspsppsrpspprpprsrsrssrrrrprspprpprrspssprsrrsppsrsrpssprsssprspppspspssrrpsrprpsrpprsrpppsprssssprsrrrrpsrprr...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Vova studies programming in an elite school. Vova and his classmates are supposed to write n progress tests, for each test they will get a mark from 1 to p. Vova is very smart and he can write every test for any ma...
[{"type": "stdin_stdout", "input": "997 100 3 1102 2\n1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 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 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 2 1 1 1 1 1 1 3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "11 10 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are \"a\", \"o\", \"u\", \"i\", and \"e\". Other letters are consonant.\n\nIn Berlanese, there has to b...
[{"type": "stdin_stdout", "input": "auuaoonntanonnuewannnnpuuinniwoonennyolonnnvienonpoujinndinunnenannmuveoiuuhikucuziuhunnnmunzancenen\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "eonwonojannonnufimiiniewuqaienokacevecinfuqihatenhunliquuyebayiaenifuexuanenuaounnboancaeowonu\n", "output": "YES\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every $a$ and $b$ such that $1 \\leq a \\leq b \\leq 6$, there is exactly one domino with $a$ dots on one half and $b$ dots on...
[{"type": "stdin_stdout", "input": "7 21\n1 2\n1 3\n1 4\n1 5\n1 6\n1 7\n2 3\n2 4\n2 5\n2 6\n2 7\n3 4\n3 5\n3 6\n3 7\n4 5\n4 6\n4 7\n5 6\n5 7\n6 7\n", "output": "16\n"}, {"type": "stdin_stdout", "input": "7 21\n3 5\n7 2\n2 3\n6 5\n5 2\n4 7\n2 6\n2 4\n6 7\n5 1\n1 4\n4 5\n5 7\n4 6\n3 1\n1 2\n3 4\n7 1\n3 7\n6 1\n3 6\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n'Jeopardy!' is an intellectual game where players answer questions and earn points. Company Q conducts a simplified 'Jeopardy!' tournament among the best IT companies. By a lucky coincidence, the old rivals made it to the...
[{"type": "stdin_stdout", "input": "50 30\n6015200 8643865 4116771 6555197 304415 8580071 8414182 3089212 5684567 7595481 1272699 7127763 3309618 1410297 4349070 2027355 136702 6863504 1800751 5585842 5924142 5188269 4805201 9313209 8941399 5137060 4983630 8467668 1646260 7804684 8646497 7067118 6896291 9109696 6197162...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maximum point values of 500, 1000, 1500, 2000, and 2500, respectively. Despite the challenging...
[{"type": "stdin_stdout", "input": "119 119 119 119 119\n10 10 10 10 10\n0 20\n", "output": "1310\n"}, {"type": "stdin_stdout", "input": "119 119 119 119 119\n0 0 0 0 0\n10 0\n", "output": "4930\n"}, {"type": "stdin_stdout", "input": "113 107 59 50 56\n3 7 10 6 3\n10 12\n", "output": "4586\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two $n \\times m$ matrices containing integers. A sequence of integers is strictly increasing if each next number is greater than the previous one. A row is strictly increasing if all numbers from left to ri...
[{"type": "stdin_stdout", "input": "20 1\n66723051\n192052119\n224590623\n285234278\n167627491\n337383819\n374082795\n457862809\n434684264\n480651568\n509016946\n512760752\n577998249\n647547233\n737914492\n753247062\n687137696\n799938346\n957366563\n986223900\n47472129\n101178650\n145468869\n145519928\n311820460\n20856...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMakes solves problems on Decoforces and lots of other different online judges. Each problem is denoted by its difficulty — a positive integer number. Difficulties are measured the same across all the judges (the problem w...
[{"type": "stdin_stdout", "input": "100 10\n246 286 693 607 87 612 909 312 621 37 801 558 504 914 416 762 187 974 976 123 635 488 416 659 988 998 93 662 92 749 889 78 214 786 735 625 921 372 713 617 975 119 402 411 878 138 548 905 802 762 940 336 529 373 745 835 805 880 816 94 166 114 475 699 974 462 61 337 555 805 968...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSoon a school Olympiad in Informatics will be held in Berland, n schoolchildren will participate there.\n\nAt a meeting of the jury of the Olympiad it was decided that each of the n participants, depending on the results,...
[{"type": "stdin_stdout", "input": "3000000\n1000000 1000000\n1000000 1000000\n1000000 1000000\n", "output": "1000000 1000000 1000000 \n"}, {"type": "stdin_stdout", "input": "1629279\n267360 999930\n183077 674527\n202618 786988\n", "output": "999930 426731 202618 \n"}, {"type": "stdin_stdout", "input": "2174477\n276494...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEvery summer Vitya comes to visit his grandmother in the countryside. This summer, he got a huge wart. Every grandma knows that one should treat warts when the moon goes down. Thus, Vitya has to catch the moment when the ...
[{"type": "stdin_stdout", "input": "92\n13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 14 13 12\n", "output": "DOWN\n"}, {"type": "stdin_stdout", "input": "9...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWe all know that a superhero can transform to certain other superheroes. But not all Superheroes can transform to any other superhero. A superhero with name $s$ can transform to another superhero with name $t$ if $s$ can ...
[{"type": "stdin_stdout", "input": "eieoiiieaiuiiauieeuoueeoudljpjrpxdtqkrdfmhktpqrnkmyggywglpfpfmhrbaiioeuaieaouaoioaiuoiuueuaoouaeeoaaaueauueeiuaueuaeouiaaaieeaeiuouoiooauuoeauaiaoouuauuuuocqschpcxrxrgrcsjmwcbyfvtdxqtwha\naoeaoaoueieeioooiaooeoeoitvplxwkprykbhvxylcnxrhpgqclyjgfpzdpqwlcvouooeueoouieioeuouieoaaueuiiiae...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGalois is one of the strongest chess players of Byteforces. He has even invented a new variant of chess, which he named «PawnChess».\n\nThis new game is played on a board consisting of 8 rows and 8 columns. At the beginni...
[{"type": "stdin_stdout", "input": "........\n........\n.B....B.\n....W...\n........\n..W.....\n........\n........\n", "output": "A\n"}, {"type": "stdin_stdout", "input": "..B.....\n..W.....\n......B.\n........\n.....W..\n......B.\n........\n........\n", "output": "B\n"}, {"type": "stdin_stdout", "input": ".BB.B.B.\nB....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has two arrays $A$ and $B$ of lengths $n$ and $m$, respectively.\n\nHe can perform the following operation arbitrary number of times (possibly zero): he takes some consecutive subsegment of the array and replaces it...
[{"type": "stdin_stdout", "input": "49\n18 1 7 2 1 1 50 22 8 2 2 1 30 2 46 10 1 4 5 18 25 21 38 11 2 15 29 8 7 2 45 12 14 16 16 23 11 1 1 4 48 18 3 1 1 23 4 10 7\n50\n5 25 34 22 19 4 4 2 40 52 1 4 1 3 47 9 4 1 8 47 4 5 1 1 9 22 9 2 2 1 1 48 7 2 8 16 4 2 41 12 3 30 21 10 2 2 5 1 31 13\n", "output": "14\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems.\n\nBut there are too many problems, to do i...
[{"type": "stdin_stdout", "input": "____________________________________________________________________________________________________\n", "output": "NO"}, {"type": "stdin_stdout", "input": "AnnNikitaNikitaNikitaNikita__good_luck\n", "output": "NO"}, {"type": "stdin_stdout", "input": "I_dont_know_what_to_write_here\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors.\n\nConsider positive integers a, a ...
[{"type": "stdin_stdout", "input": "100000 1000000 7821\n", "output": "108426\n"}, {"type": "stdin_stdout", "input": "10000 1000000 60000\n", "output": "793662\n"}, {"type": "stdin_stdout", "input": "1000 900000 50000\n", "output": "659334\n"}, {"type": "stdin_stdout", "input": "20 1000000 40000\n", "output": "539580\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArkadiy has lots square photos with size a × a. He wants to put some of them on a rectangular wall with size h × w. \n\nThe photos which Arkadiy will put on the wall must form a rectangular grid and the distances between ...
[{"type": "stdin_stdout", "input": "452081307 790635695 790635695\n", "output": "169277194.00000000000000000000\n"}, {"type": "stdin_stdout", "input": "469568633 681052815 681052815\n", "output": "105742091.00000000000000000000\n"}, {"type": "stdin_stdout", "input": "338084774 564168943 564168943\n", "output": "1130420...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter lessons Nastya decided to read a book. The book contains $n$ chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page.\n\nYesterday e...
[{"type": "stdin_stdout", "input": "49\n1 17\n18 115\n116 211\n212 269\n270 345\n346 404\n405 441\n442 467\n468 526\n527 583\n584 664\n665 757\n758 794\n795 802\n803 882\n883 920\n921 960\n961 962\n963 1006\n1007 1081\n1082 1112\n1113 1149\n1150 1217\n1218 1282\n1283 1287\n1288 1365\n1366 1374\n1375 1379\n1380 1478\n14...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA large banner with word CODEFORCES was ordered for the 1000-th onsite round of Codeforces^{ω} that takes place on the Miami beach. Unfortunately, the company that made the banner mixed up two orders and delivered somebod...
[{"type": "stdin_stdout", "input": "CODEFOGSIUZMZCMWAVQHNYFEKIEZQMAZOVEMDRMOEDBHAXPLBLDYYXCVTOOSJZVSQAKFXTBTZFWAYRZEMDEMVDJTDRXXAQBURCES\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "EDYKHVZCNTLJUUOQGHPTIOETQNFLLWEKZOHIUAXELGECABVSBIBGQODQXVYFKBYJWTGBYHVSSNTINKWSINWSMALUSIWNJMTCOOVF\n", "output": "NO\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a regular polygon with $n$ vertices labeled from $1$ to $n$ in counter-clockwise order. The triangulation of a given polygon is a set of triangles such that each vertex of each triangle is a vertex of the in...
[{"type": "stdin_stdout", "input": "500\n", "output": "41666498\n"}, {"type": "stdin_stdout", "input": "497\n", "output": "40920990\n"}, {"type": "stdin_stdout", "input": "494\n", "output": "40184428\n"}, {"type": "stdin_stdout", "input": "491\n", "output": "39456758\n"}, {"type": "stdin_stdout", "input": "488\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVanya got an important task — he should enumerate books in the library and label each book with its number. Each of the n books should be assigned with a number from 1 to n. Naturally, distinct books should be assigned di...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "8888888899\n"}, {"type": "stdin_stdout", "input": "222222222\n", "output": "1888888896\n"}, {"type": "stdin_stdout", "input": "943006819\n", "output": "8375950269\n"}, {"type": "stdin_stdout", "input": "986747865\n", "output": "8769619683\n"}, {"type": "stdi...
code_stdio