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\nThere will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or...
[{"type": "stdin_stdout", "input": "30\nRLLRLRLLRRRLRRRLLLLLLRRRLRRLRL\n128 610 1680 2436 2896 2994 3008 3358 3392 4020 4298 4582 4712 4728 5136 5900 6088 6232 6282 6858 6934 7186 7224 7256 7614 8802 8872 9170 9384 9794\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "28\nRRLRLRRRRRRLLLRRLRRLLLRRLLLR\n156 172 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Cybermen and the Daleks have long been the Doctor's main enemies. Everyone knows that both these species enjoy destroying everything they encounter. However, a little-known fact about them is that they both also love ...
[{"type": "stdin_stdout", "input": "10\n11 11\n11 12\n11 15\n11 17\n11 18\n11 19\n11 28\n11 33\n11 38\n11 40\n12 11\n15 46\n17 11\n17 46\n18 46\n19 11\n19 46\n20 11\n20 46\n24 46\n25 46\n26 11\n32 11\n32 46\n33 11\n34 46\n36 11\n39 11\n40 46\n43 11\n44 0\n46 14\n46 15\n46 17\n46 22\n46 26\n46 28\n46 32\n46 43\n46 45\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKurt reaches nirvana when he finds the product of all the digits of some positive integer. Greater value of the product makes the nirvana deeper.\n\nHelp Kurt find the maximum possible product of digits among all integers...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "387420489\n"}, {"type": "stdin_stdout", "input": "2000000000\n", "output": "387420489\n"}, {"type": "stdin_stdout", "input": "1382011913\n", "output": "387420489\n"}, {"type": "stdin_stdout", "input": "1999999999\n", "output": "387420489\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAwruk is taking part in elections in his school. It is the final round. He has only one opponent — Elodreip. The are $n$ students in the school. Each student has exactly $k$ votes and is obligated to use all of them. So A...
[{"type": "stdin_stdout", "input": "100\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 100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a set of points on a straight line. Each point has a color assigned to it. For point a, its neighbors are the points which don't have any other points between them and a. Each point has at most two neighbors...
[{"type": "stdin_stdout", "input": "aaaaaaaaabbbbbaaaabaaaaaaaaaaaaaaaaabaaaaaabbbbbbbaaabbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "bbbbbbbbbbbbbbbbbbbbbbddddddddddddddddaaaaaaaaaaaaaccccccccbbbbbbbaaaaaaaaaabbbbbbbbaaaaaaaaaacccccc\n", "output": "11\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter returning from the army Makes received a gift — an array a consisting of n positive integer numbers. He hadn't been solving problems for a long time, so he became interested to answer a particular question: how many...
[{"type": "stdin_stdout", "input": "4\n33554432 33554432 67108864 33554432\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "3\n1000000000 1000000000 1000000000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "11\n1 2 2 2 2 2 2 2 2 2 2\n", "output": "45\n"}, {"type": "stdin_stdout", "input": "10\n1 2 2 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKatie, Kuro and Shiro are best friends. They have known each other since kindergarten. That's why they often share everything with each other and work together on some very hard problems.\n\nToday is Shiro's birthday. She...
[{"type": "stdin_stdout", "input": "1000000000000000000\n", "output": "1000000000000000001"}, {"type": "stdin_stdout", "input": "822981260158260519\n", "output": "411490630079130260"}, {"type": "stdin_stdout", "input": "779547116602436424\n", "output": "779547116602436425"}, {"type": "stdin_stdout", "input": "578223540...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIlya is a very clever lion, he lives in an unusual city ZooVille. In this city all the animals have their rights and obligations. Moreover, they even have their own bank accounts. The state of a bank account is an integer...
[{"type": "stdin_stdout", "input": "-1000000000\n", "output": "-100000000\n"}, {"type": "stdin_stdout", "input": "1000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "-847251738\n", "output": "-84725173\n"}, {"type": "stdin_stdout", "input": "-623563697\n", "output": "-62356367\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n[Image] \n\nWalking through the streets of Marshmallow City, Slastyona have spotted some merchants selling a kind of useless toy which is very popular nowadays – caramel spinner! Wanting to join the craze, she has immedia...
[{"type": "stdin_stdout", "input": "> >\n1000000000\n", "output": "undefined\n"}, {"type": "stdin_stdout", "input": "v ^\n571728018\n", "output": "undefined\n"}, {"type": "stdin_stdout", "input": "v v\n927162384\n", "output": "undefined\n"}, {"type": "stdin_stdout", "input": "v ^\n571728018\n", "output": "undefined\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Chris knows there's no fun in playing dominoes, he thinks it's too random and doesn't require skill. Instead, he decided to play with the dominoes and make a \"domino show\".\n\nChris arranges n dominoes in a line,...
[{"type": "stdin_stdout", "input": "400\n.L.R.LR.LRL.R.LR.LR..L....RLR.L..R..LRLRLR.LRL..RLR.LRLRLRLR.LR..LRL.RLR...LRLR.LRL.R.LR..LR.LRLR...LRLRL.R.L.....RL..RL.RLRL.RL.RL...RL..R.LRLRL..R.LRL...R..LRL.RLRL...RL..RLRLRLRL.R..LRL.R..LRLRL.R.L.R.L.RL.RLRLRL....R.LR..L..RL.RL.RLRLR.L..RLRL.RLR..LRLR.L.R..L.R.LR.LRL.....R...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it larger. Unfortunately, the only operation Pasha can do is to swap two adjacent decimal digits of t...
[{"type": "stdin_stdout", "input": "219810011901120912 100\n", "output": "999822211111110000\n"}, {"type": "stdin_stdout", "input": "191919191919119911 100\n", "output": "999999991111111111\n"}, {"type": "stdin_stdout", "input": "123456789123456789 100\n", "output": "998877665544213123\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIlya lives in a beautiful city of Chordalsk.\n\nThere are $n$ houses on the street Ilya lives, they are numerated from $1$ to $n$ from left to right; the distance between every two neighboring houses is equal to $1$ unit....
[{"type": "stdin_stdout", "input": "41\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1\n", "output": "39\n"}, {"type": "stdin_stdout", "input": "20\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "20\n1 1 1 1 1 1 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSanta Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are n lanes of m desks each, and there are two working places at each of the...
[{"type": "stdin_stdout", "input": "10000 10000 199999999\n", "output": "10000 10000 L\n"}, {"type": "stdin_stdout", "input": "10000 10000 200000000\n", "output": "10000 10000 R\n"}, {"type": "stdin_stdout", "input": "10000 10000 160845880\n", "output": "8043 2940 R\n"}, {"type": "stdin_stdout", "input": "10000 9999 18...
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: take any two (not necessarily adjacent) cards with different col...
[{"type": "stdin_stdout", "input": "200\nBBRGRRBBRGGGBGBGBGRRGRGRGRBGRGRRBBGRGBGRRGRRRGGBBRGBGBGBRBBBBBBBGGBRGGRRRGGRGBGBGGBRRRRBRRRBRBBGGBGBRGRGBBBBGGBGBBBGBGRRBRRRGBGGBBBRBGRBRRGGGRRGBBBGBGRRRRRRGGRGRGBBBRGGGBGGGBRBBRRGBGRGRBRRRBRBGRGGBRBB\n", "output": "BGR\n"}, {"type": "stdin_stdout", "input": "200\nRGRGRRRRRGRRGR...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDasha decided to have a rest after solving the problem. She had been ready to start her favourite activity — origami, but remembered the puzzle that she could not solve. [Image] \n\nThe tree is a non-oriented connected g...
[{"type": "stdin_stdout", "input": "25\n1 2\n1 3\n1 4\n2 5\n5 6\n6 7\n7 8\n2 9\n9 10\n11 2\n12 11\n13 12\n3 14\n14 15\n14 16\n16 17\n14 18\n18 19\n20 4\n20 21\n20 22\n22 23\n20 24\n24 25\n", "output": "YES\n0 0\n0 1073741824\n1073741824 0\n0 -1073741824\n0 1610612736\n0 1879048192\n0 2013265920\n0 2080374784\n536870912...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNazar, a student of the scientific lyceum of the Kingdom of Kremland, is known for his outstanding mathematical abilities. Today a math teacher gave him a very difficult task.\n\nConsider two infinite sets of numbers. The...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000\n", "output": "975735772"}, {"type": "stdin_stdout", "input": "110132820763723554 347999721032847655\n", "output": "416849587"}, {"type": "stdin_stdout", "input": "344719938937955218 881301645881541177\n", "output": "901594724"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nArpa is taking a geometry exam. Here is the last problem of the exam.\n\nYou are given three points a, b, c.\n\nFind a point and an angle such that if we rotate the page around the point by the angle, the new position of ...
[{"type": "stdin_stdout", "input": "-947393823 -495674431 211535284 -877153626 -522763219 -778236665\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "-357531221 381512519 -761132895 -224448284 328888775 -237692564\n", "output": "No\n"}, {"type": "stdin_stdout", "input": "-706921242 -758563024 -588592101 -44344...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp loves geometric progressions very much. Since he was only three years old, he loves only the progressions of length three. He also has a favorite integer k and a sequence a, consisting of n integers.\n\nHe wants ...
[{"type": "stdin_stdout", "input": "18 10\n10000000 100000000 1000000000 -10000000 -100000000 -1000000000 -10000000 -100000000 -1000000000 -10000000 -100000000 -1000000000 10000000 100000000 1000000000 10000000 100000000 1000000000\n", "output": "20"}, {"type": "stdin_stdout", "input": "30 4096\n1 2 4 8 16 32 64 128 25...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently Max has got himself into popular CCG \"BrainStone\". As \"BrainStone\" is a pretty intellectual game, Max has to solve numerous hard problems during the gameplay. Here is one of them:\n\nMax owns n creatures, i-t...
[{"type": "stdin_stdout", "input": "10 9 0\n620118469 704168608\n528098892 341451371\n15150469 449838744\n960504540 722185004\n271837337 344050133\n940943201 419522619\n85569623 788965215\n161962866 563795701\n943389281 445744350\n610994199 473866838\n", "output": "5253588583\n"}, {"type": "stdin_stdout", "input": "12 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day Vasya was sitting on a not so interesting Maths lesson and making an origami from a rectangular a mm × b mm sheet of paper (a > b). Usually the first step in making an origami is making a square piece of paper f...
[{"type": "stdin_stdout", "input": "1000000000000 999999999999\n", "output": "1000000000000\n"}, {"type": "stdin_stdout", "input": "1000000000000 999999999998\n", "output": "500000000000\n"}, {"type": "stdin_stdout", "input": "1000000000000 1\n", "output": "1000000000000\n"}, {"type": "stdin_stdout", "input": "62862524...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSengoku still remembers the mysterious \"colourful meteoroids\" she discovered with Lala-chan when they were little. In particular, one of the nights impressed her deeply, giving her the illusion that all her fancies woul...
[{"type": "stdin_stdout", "input": "11\n1 2 3 4 5 6 7 8 9 10 10\n1 2 3 4 5 6 7 8 9 10 3\n", "output": "1 2 3 4 5 6 7 8 9 10 11\n"}, {"type": "stdin_stdout", "input": "10\n1 2 3 4 7 6 7 8 9 10\n1 2 3 4 5 6 5 8 9 10\n", "output": "1 2 3 4 5 6 7 8 9 10\n"}, {"type": "stdin_stdout", "input": "10\n1 2 3 4 5 6 7 8 4 10\n1 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOn one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular conv...
[{"type": "stdin_stdout", "input": "100000 180\n", "output": "2 1 100000\n"}, {"type": "stdin_stdout", "input": "100000 123\n", "output": "2 1 68335\n"}, {"type": "stdin_stdout", "input": "100000 101\n", "output": "2 1 56113\n"}, {"type": "stdin_stdout", "input": "100000 109\n", "output": "2 1 60558\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetr has just bought a new car. He's just arrived at the most known Petersburg's petrol station to refuel it when he suddenly discovered that the petrol tank is secured with a combination lock! The lock has a scale of $36...
[{"type": "stdin_stdout", "input": "15\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n168\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "15\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n180\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "14\n180\n18...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp decided to relax on his weekend and visited to the performance of famous ropewalkers: Agafon, Boniface and Konrad.\n\nThe rope is straight and infinite in both directions. At the beginning of the performance, Aga...
[{"type": "stdin_stdout", "input": "1000000000 1000000000 1000000000 1000000000\n", "output": "2000000000\n"}, {"type": "stdin_stdout", "input": "500000000 250000000 750000000 1000000000\n", "output": "1500000000\n"}, {"type": "stdin_stdout", "input": "716270982 22102638 553198855 1000000000\n", "output": "1305831656\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) = 0; f(a, b) = 1 + f(a, b - gcd(a, b)), where gcd(a, b) is the greatest common divisor of a and b. \n\nVasya has two numbers x and y,...
[{"type": "stdin_stdout", "input": "999999999989 999999999988\n", "output": "999999999988\n"}, {"type": "stdin_stdout", "input": "414654652183 366894205623\n", "output": "366894205623\n"}, {"type": "stdin_stdout", "input": "999999999958 999999999957\n", "output": "499999999979\n"}, {"type": "stdin_stdout", "input": "19...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is a building with 2N floors, numbered 1, 2, \\ldots, 2N from bottom to top.\nThe elevator in this building moved from Floor 1 to Floor 2N just once.\nOn the way, N persons got on and off the elevator. Each person i...
[{"type": "stdin_stdout", "input": "100\n65 165\n6 106\n41 141\n1 101\n4 104\n33 133\n5 105\n57 157\n98 198\n15 115\n52 152\n53 153\n46 146\n29 129\n42 142\n8 108\n12 112\n69 169\n47 147\n87 187\n79 179\n88 188\n67 167\n26 126\n55 155\n73 173\n72 172\n74 174\n95 195\n36 136\n61 161\n10 110\n17 117\n7 107\n23 123\n30 13...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal s...
[{"type": "stdin_stdout", "input": "1000000 1000000\n1000000 999999\n1000000 999998\n999999 1000000\n999999 999998\n999998 1000000\n999998 999999\n999998 999998\n", "output": "respectable\n"}, {"type": "stdin_stdout", "input": "642921 597358\n922979 597358\n127181 616833\n642921 828316\n922979 828316\n127181 597358\n92...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAdilbek was assigned to a special project. For Adilbek it means that he has $n$ days to run a special program and provide its results. But there is a problem: the program needs to run for $d$ days to calculate the results...
[{"type": "stdin_stdout", "input": "50\n1000000000 1000000000\n999999999 1000000000\n999999998 1000000000\n999999997 1000000000\n999999996 1000000000\n999999995 1000000000\n999999994 1000000000\n999999900 1000000000\n1 11\n2 11\n3 11\n4 11\n5 11\n6 11\n7 11\n8 11\n9 11\n10 11\n11 11\n4 18\n4 20\n3 19\n3 18\n3 167\n3 15...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nApart from Nian, there is a daemon named Sui, which terrifies children and causes them to become sick. Parents give their children money wrapped in red packets and put them under the pillow, so that when Sui tries to appr...
[{"type": "stdin_stdout", "input": "35\n", "output": "888888888888888886\n"}, {"type": "stdin_stdout", "input": "36\n", "output": "888888888888888888\n"}, {"type": "stdin_stdout", "input": "33\n", "output": "88888888888888886\n"}, {"type": "stdin_stdout", "input": "34\n", "output": "88888888888888888\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nErelong Leha was bored by calculating of the greatest common divisor of two factorials. Therefore he decided to solve some crosswords. It's well known that it is a very interesting occupation though it can be very difficu...
[{"type": "stdin_stdout", "input": "26 26\nabcdefghijklmnopqrstuvwxyz\nffffffffffffffffffffffffff\n", "output": "25\n1 2 3 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 \n"}, {"type": "stdin_stdout", "input": "10 100\nmpmmpmmmpm\nmppppppmppmmpmpppmpppmmpppmpppppmpppmmmppmpmpmmmpmmpmppmmpppppmpmppppmmppmp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA tree is a connected undirected graph consisting of n vertices and n - 1 edges. Vertices are numbered 1 through n.\n\nLimak is a little polar bear and Radewoosh is his evil enemy. Limak once had a tree but Radewoosh st...
[{"type": "stdin_stdout", "input": "33 5 3\n", "output": "1 2\n2 3\n3 4\n1 5\n5 6\n7 1\n8 1\n9 1\n10 1\n11 1\n12 1\n13 1\n14 1\n15 1\n16 1\n17 1\n18 1\n19 1\n20 1\n21 1\n22 1\n23 1\n24 1\n25 1\n26 1\n27 1\n28 1\n29 1\n30 1\n31 1\n32 1\n33 1\n"}, {"type": "stdin_stdout", "input": "30 14 14\n", "output": "1 2\n2 3\n3 4\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNN is an experienced internet user and that means he spends a lot of time on the social media. Once he found the following image on the Net, which asked him to compare the sizes of inner circles: [Image] \n\nIt turned out...
[{"type": "stdin_stdout", "input": "100 100\n", "output": "3.2429391\n"}, {"type": "stdin_stdout", "input": "5 100\n", "output": "142.5919998\n"}, {"type": "stdin_stdout", "input": "3 32\n", "output": "206.8512517\n"}, {"type": "stdin_stdout", "input": "10 25\n", "output": "11.1803399\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHarry Potter and He-Who-Must-Not-Be-Named engaged in a fight to the death once again. This time they are located at opposite ends of the corridor of length l. Two opponents simultaneously charge a deadly spell in the enem...
[{"type": "stdin_stdout", "input": "538\n479\n416\n", "output": "287.9351955\n"}, {"type": "stdin_stdout", "input": "583\n112\n248\n", "output": "181.3777778\n"}, {"type": "stdin_stdout", "input": "978\n467\n371\n", "output": "545.0190931\n"}, {"type": "stdin_stdout", "input": "980\n322\n193\n", "output": "612.7378641\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere is the faculty of Computer Science in Berland. In the social net \"TheContact!\" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course o...
[{"type": "stdin_stdout", "input": "5\n2043 2042 2041 2044 2040\n", "output": "2042\n"}, {"type": "stdin_stdout", "input": "5\n2012 2013 2014 2015 2016\n", "output": "2014\n"}, {"type": "stdin_stdout", "input": "5\n2011 2014 2012 2013 2010\n", "output": "2012\n"}, {"type": "stdin_stdout", "input": "5\n2014 2013 2011 20...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOverlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.\n\nArkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dime...
[{"type": "stdin_stdout", "input": "100\nC?M?M?M?YM??YMYC?MCYMYM??Y??YC?CYC???YM?YM??MYMY?CYCYMYC?YC?C?CYCMY??CMC?YMCMYCYCYMYM?CYM?M?MCMCMY?Y\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "100\n????????????????????????????????????????????????????????????????????????????????????????????????????\n", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet $f_{x} = c^{2x-6} \\cdot f_{x-1} \\cdot f_{x-2} \\cdot f_{x-3}$ for $x \\ge 4$.\n\nYou have given integers $n$, $f_{1}$, $f_{2}$, $f_{3}$, and $c$. Find $f_{n} \\bmod (10^{9}+7)$.\n\n\n-----Input-----\n\nThe only line...
[{"type": "stdin_stdout", "input": "1000000000000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "607659049\n"}, {"type": "stdin_stdout", "input": "828401532544180275 298741808 401572465 730243936 632306255\n", "output": "808231153\n"}, {"type": "stdin_stdout", "input": "644520543495037719 168164385 42...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nReturning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse. For example, strings \"pop\", \"noon\", \"x\", and \"kkkkkk\" are pal...
[{"type": "stdin_stdout", "input": "24 17\ngdnaevfczjayllndr\nwmuarvqwpbhuznpxz\nlurusjuzrkxmdvfhw\nyckftntrvdatssgbb\nzxpnzuhbpwqvraumw\nwaxuutbtbtbtuuxaw\ndgwjcwilgyrgpohnr\ntrcttthipihtttcrt\ncmbovzvfgdqlfkfqp\nqbgqnzkhixnnvzvqi\nqiursxnedmveeuxdq\nrdnllyajzcfveandg\nbzwxilleapxzcxmde\ncxcfjzlfdtytldtqf\nyhukzlipwdu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's call a list of positive integers $a_0, a_1, ..., a_{n-1}$ a power sequence if there is a positive integer $c$, so that for every $0 \\le i \\le n-1$ then $a_i = c^i$.\n\nGiven a list of $n$ positive integers $a_0, a...
[{"type": "stdin_stdout", "input": "100\n881 479 355 759 257 497 690 598 275 446 439 787 257 326 584 713 322 5 253 781 434 307 164 154 241 381 38 942 680 906 240 11 431 478 628 959 346 74 493 964 455 746 950 41 585 549 892 687 264 41 487 676 63 453 861 980 477 901 80 907 285 506 619 748 773 743 56 925 651 685 845 313 4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLord Omkar has permitted you to enter the Holy Church of Omkar! To test your worthiness, Omkar gives you a password which you must interpret!\n\nA password is an array $a$ of $n$ positive integers. You apply the following...
[{"type": "stdin_stdout", "input": "80\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nStudent Dima from Kremland has a matrix $a$ of size $n \\times m$ filled with non-negative integers.\n\nHe wants to select exactly one integer from each row of the matrix so that the bitwise exclusive OR of the selected i...
[{"type": "stdin_stdout", "input": "1 249\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 67 0 0 0 0 0 0 0 0 0 0 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are two strings s and t consisting of lowercase English letters. Determine if there exists an integer i satisfying the following condition, and find the minimum such i if it exists.\n - Let s' be the concatenation o...
[{"type": "stdin_stdout", "input": "contest\nprogramming\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "contest\nsentence\n", "output": "33\n"}, {"type": "stdin_stdout", "input": "contest\nson\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "s\nsv\n", "output": "-1\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBear Limak examines a social network. Its main functionality is that two members can become friends (then they can talk with each other and share funny pictures).\n\nThere are n members, numbered 1 through n. m pairs of m...
[{"type": "stdin_stdout", "input": "20 80\n17 4\n10 1\n11 10\n17 7\n15 10\n14 15\n13 1\n18 13\n3 13\n12 7\n9 13\n10 12\n14 12\n18 11\n4 7\n10 13\n11 3\n19 8\n14 7\n10 17\n14 3\n7 11\n11 14\n19 5\n10 14\n15 17\n3 1\n9 10\n11 1\n4 1\n11 4\n9 1\n12 3\n13 7\n1 14\n11 12\n7 1\n9 12\n18 15\n17 3\n7 15\n4 10\n7 18\n7 9\n12 17...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n[Image] \n\n\n-----Input-----\n\nThe first line of the input is a string (between 1 and 50 characters long, inclusive). Each character will be a letter of English alphabet, lowercase or uppercase.\n\nThe second line of th...
[{"type": "stdin_stdout", "input": "MDJivQRiOIVRcCdkSuUlNbMEOkIVJRMTAnHbkVaOmOblLfignh\n25\n", "output": "MDJIVQRIOIVRCCDKSUULNBMEOKIVJRMTANHBKVAOMOBLLFIGNH\n"}, {"type": "stdin_stdout", "input": "aaaaaaAAAaaaaAaaAaaAaaaaAAaAAAaaAAaaaAAaaaaaAaaAAa\n2\n", "output": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"}...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYaroslav, Andrey and Roman can play cubes for hours and hours. But the game is for three, so when Roman doesn't show up, Yaroslav and Andrey play another game. \n\nRoman leaves a word for each of them. Each word consists ...
[{"type": "stdin_stdout", "input": "10\n00000000000111111111\n00000000011111111111\n", "output": "Draw\n"}, {"type": "stdin_stdout", "input": "4\n01100000\n10010011\n", "output": "Second\n"}, {"type": "stdin_stdout", "input": "4\n01101010\n11111110\n", "output": "Second\n"}, {"type": "stdin_stdout", "input": "4\n010101...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAnya and Kirill are doing a physics laboratory work. In one of the tasks they have to measure some value n times, and then compute the average value to lower the error.\n\nKirill has already made his measurements, and has...
[{"type": "stdin_stdout", "input": "60\n-86077 -86075 -86076 -86076 -86077 -86077 -86075 -86075 -86075 -86077 -86075 -86076 -86075 -86075 -86075 -86076 -86075 -86076 -86075 -86075 -86076 -86076 -86076 -86075 -86075 -86075 -86075 -86077 -86075 -86076 -86075 -86075 -86075 -86076 -86075 -86076 -86077 -86075 -86075 -86075 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGrigoriy, like the hero of one famous comedy film, found a job as a night security guard at the museum. At first night he received embosser and was to take stock of the whole exposition.\n\nEmbosser is a special devise th...
[{"type": "stdin_stdout", "input": "dqcpcobpcobnznamznamzlykxkxlxlylzmaobnaobpbnanbpcoaobnboaoboanzlymzmykylymylzlylymanboanaocqdqesfrfs\n", "output": "1236\n"}, {"type": "stdin_stdout", "input": "uhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuhuh\n", "output": "1293\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe final match of the Berland Football Cup has been held recently. The referee has shown $n$ yellow cards throughout the match. At the beginning of the match there were $a_1$ players in the first team and $a_2$ players i...
[{"type": "stdin_stdout", "input": "1000\n1000\n1000\n1000\n1999999\n", "output": "1999 1999\n"}, {"type": "stdin_stdout", "input": "1000\n1000\n1000\n1000\n2000000\n", "output": "2000 2000\n"}, {"type": "stdin_stdout", "input": "1000\n1000\n1000\n1000\n1456999\n", "output": "0 1456\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring the break the schoolchildren, boys and girls, formed a queue of n people in the canteen. Initially the children stood in the order they entered the canteen. However, after a while the boys started feeling awkward f...
[{"type": "stdin_stdout", "input": "50 30\nBGGGGGGBGGBGBGGGGBGBBGBBBGGBBBGBGBGGGGGBGBBGBGBGGG\n", "output": "GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGBBBBBBBBBBBBBBBBBBBB\n"}, {"type": "stdin_stdout", "input": "50 10\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n", "output": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMakoto has a big blackboard with a positive integer $n$ written on it. He will perform the following action exactly $k$ times:\n\nSuppose the number currently written on the blackboard is $v$. He will randomly pick one of...
[{"type": "stdin_stdout", "input": "1000000000000000 10000\n", "output": "215514159\n"}, {"type": "stdin_stdout", "input": "671058194037157 8673\n", "output": "298638658\n"}, {"type": "stdin_stdout", "input": "900018062553298 4801\n", "output": "345432320\n"}, {"type": "stdin_stdout", "input": "999999999999993 8123\n",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNow it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best friends ever since primary school and hopefully, that can somehow help them in teamwork.\n\...
[{"type": "stdin_stdout", "input": "74 99\n", "output": "11011011011011011011011011011011011011011011011011011011011011011011011010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\n"}, {"type": "stdin_stdout", "input": "19 30\n", "output": "1101101101101101101101101101...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. \n\nString t is called a palindrome, if it reads the same from left to right and from right t...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "999999999\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "213443120\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "999999998\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "21000000...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nImp is in a magic forest, where xorangles grow (wut?)\n\n [Image] \n\nA xorangle of order n is such a non-degenerate triangle, that lengths of its sides are integers not exceeding n, and the xor-sum of the lengths is equa...
[{"type": "stdin_stdout", "input": "2500\n", "output": "700393\n"}, {"type": "stdin_stdout", "input": "1216\n", "output": "160822\n"}, {"type": "stdin_stdout", "input": "2140\n", "output": "614785\n"}, {"type": "stdin_stdout", "input": "1488\n", "output": "239580\n"}, {"type": "stdin_stdout", "input": "1040\n", "output...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice.\n\nThe level...
[{"type": "stdin_stdout", "input": "21 21\n.....X...X.........X.\n...X...XX......X.....\n..X........X.X...XX..\n.........X....X...X..\nX...X...........XX...\n...X...X....XX...XXX.\n.X............X......\n......X.X............\n.X...X.........X.X...\n......XX......X.X....\n....X.......X.XXX....\n.X.......X..XXX.X..X.\n....
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe programming competition season has already started and it's time to train for ICPC. Sereja coaches his teams for a number of year and he knows that to get ready for the training session it's not enough to prepare only...
[{"type": "stdin_stdout", "input": "100\n56 22 13 79 28 73 16 55 34 0 97 19 22 36 22 80 30 19 36 92 9 38 24 10 61 43 19 12 18 34 21 36 1 17 0 97 72 37 74 70 51 34 33 87 27 33 45 97 38 56 2 32 88 92 64 51 74 94 86 98 57 62 83 3 87 61 9 65 57 13 64 10 50 35 7 75 41 3 70 66 6 55 69 42 91 75 14 22 68 93 2 53 22 98 45 2 78 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$ consisting of $n$ lowercase Latin letters. $n$ is even.\n\nFor each position $i$ ($1 \\le i \\le n$) in string $s$ you are required to change the letter on this position either to the previous l...
[{"type": "stdin_stdout", "input": "50\n6\nbxyxcz\n4\nzzcy\n2\nzb\n2\nyb\n6\nzzbxyx\n4\nbxzb\n4\naaca\n4\nbzyx\n4\nxaac\n2\nbb\n2\nzb\n6\ncabcbb\n6\nyxzbbb\n2\nxz\n2\ncc\n6\nazcaza\n4\nyyaa\n2\nxb\n2\nyb\n6\nzaxxxz\n4\nbyab\n4\naxxz\n2\nay\n2\nyb\n2\ncx\n4\nzyab\n6\nybcyya\n6\nxayzaz\n4\nzacx\n6\nzzyxbz\n2\ncc\n4\nbycx...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMarina loves strings of the same length and Vasya loves when there is a third string, different from them in exactly t characters. Help Vasya find at least one such string.\n\nMore formally, you are given two strings s_1,...
[{"type": "stdin_stdout", "input": "100 85\njknccpmanwhxqnxivdgguahjcuyhdrazmbfwoptatlgytakxsfvdzzcsglhmswfxafxyregdbeiwpawrjgwcqrkbhmrfcscgoszf\nhknccpmanwhxjnxivdggeahjcuyhdrazmbfwoqtatlgytdkxsfvdztcsglhmssfxsfxyrngdbeiwpawrjgwcqrkbhmrfcsckoskf\n", "output": "aknccpmanwhxanxivaaaabaaaaaaaabaaaaaaaabaaaaabaaaaaaaaaaaa...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's hard times now. Today Petya needs to score 100 points on Informatics exam. The tasks seem easy to Petya, but he thinks he lacks time to finish them all, so he asks you to help with one..\n\nThere is a glob pattern in...
[{"type": "stdin_stdout", "input": "k\n*\n89\nb\ncbbbc\ncabac\nbccbb\nccc\ncabaa\nabbaa\nccbaa\nccccb\ncabbb\nbbcbc\nbac\naaac\nabb\nbcbb\ncb\nbacc\nbbaba\nb\nacc\nbaac\naaba\nbcbba\nbaa\nbc\naaccb\nb\nab\nc\nbbbb\nabbcb\nacbb\ncba\nc\nbac\nc\nac\ncc\nb\nbbc\nbaab\nc\nbbc\nab\nb\nc\naa\naab\nab\naccbc\nacbaa\na\nccc\nc...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVanya is managed to enter his favourite site Codehorses. Vanya uses n distinct passwords for sites at all, however he can't remember which one exactly he specified during Codehorses registration.\n\nVanya will enter passw...
[{"type": "stdin_stdout", "input": "20 5\nvSyC787KlIL8kZ2Uv5sw\nWKWOP\n7i8J3E8EByIq\nNW2VyGweL\nmyR2sRNu\nmXusPP0\nf4jgGxra\n4wHRzRhOCpEt\npPz9kybGb\nOtSpePCRoG5nkjZ2VxRy\nwHYsSttWbJkg\nKBOP9\nQfiOiFyHPPsw3GHo8J8\nxB8\nqCpehZEeEhdq\niOLjICK6\nQ91\nHmCsfMGTFKoFFnv238c\nJKjhg\ngkEUh\nKBOP9\n", "output": "3 11\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWhen registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.\n\nLogin is an arbitrary sequence of lower and uppercase l...
[{"type": "stdin_stdout", "input": "ELioO1lOoOIOiLoooi1iolul1O\n7\nOoEIuOIl1ui1010uiooOoi0Oio001L0EoEolO0\nOLIoOEuoE11u1u1iLOI0oO\nuEOuO0uIOOlO01OlEI0E1Oo0IO1LI0uE0LILO0\nEOo0Il11iIOOOIiuOiIiiLOLEOOII001EE\niOoO0LOulioE0OLIIIulli01OoiuOOOoOlEiI0EiiElIIu0\nlE1LOE1Oil\n1u0EOliIiIOl1u110il0l1O0u\n", "output": "Yes\n"}, {"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nConnect the countless points with lines, till we reach the faraway yonder.\n\nThere are n points on a coordinate plane, the i-th of which being (i, y_{i}).\n\nDetermine whether it's possible to draw two parallel and non-o...
[{"type": "stdin_stdout", "input": "20\n-975467170 758268840 -975467171 758268839 -975467172 758268838 -975467173 758268837 -975467174 758268836 -975467175 758268835 -975467176 758268834 -975467177 758268833 -975467178 758268832 -975467179 758268831\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "20\n3194103...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya had three strings $a$, $b$ and $s$, which consist of lowercase English letters. The lengths of strings $a$ and $b$ are equal to $n$, the length of the string $s$ is equal to $m$. \n\nVasya decided to choose a substr...
[{"type": "stdin_stdout", "input": "100 200\ndddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\ndddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd\nddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring a New Year special offer the \"Sudislavl Bars\" offered n promo codes. Each promo code consists of exactly six digits and gives right to one free cocktail at the bar \"Mosquito Shelter\". Of course, all the promoco...
[{"type": "stdin_stdout", "input": "58\n145410\n686144\n766870\n859775\n922809\n470967\n034349\n318920\n019664\n667953\n295078\n908733\n691385\n774622\n325695\n443254\n817406\n984471\n512092\n635832\n303546\n189826\n128551\n720334\n569318\n377719\n281502\n956352\n758447\n207280\n583935\n246631\n160045\n452683\n594100\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Alyona is celebrating Happy Birthday! Her mother has an array of n flowers. Each flower has some mood, the mood of i-th flower is a_{i}. The mood can be positive, zero or negative.\n\nLet's define a subarray as a s...
[{"type": "stdin_stdout", "input": "86 30\n16 -12 11 16 8 14 7 -29 18 30 -32 -10 20 29 -14 -21 23 -19 -15 17 -2 25 -22 2 26 15 -7 -12 -4 -28 21 -4 -2 22 28 -32 9 -20 23 38 -21 21 37 -13 -30 25 31 6 18 29 29 29 27 38 -15 -32 32 -7 -8 -33 -11 24 23 -19 -36 -36 -18 9 -1 32 -34 -26 1 -1 -16 -14 17 -17 15 -24 38 5 -27 -12 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLuke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9 - t. \n\nHelp Chewbacca to transform the initial ...
[{"type": "stdin_stdout", "input": "1000000000000000000\n", "output": "1000000000000000000\n"}, {"type": "stdin_stdout", "input": "164324828731963982\n", "output": "134324121231033012\n"}, {"type": "stdin_stdout", "input": "384979173822804784\n", "output": "314020123122104214\n"}, {"type": "stdin_stdout", "input": "606...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProgrammer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.\n\nUnfortunately, Rostislav is unable to understand ...
[{"type": "stdin_stdout", "input": "1 2576683920000 2\n", "output": "1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 1073741824 2147483648 4294967296 8589934592 17179869184 34359738368 687194...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPig is visiting a friend.\n\nPig's house is located at point 0, and his friend's house is located at point m on an axis.\n\nPig can use teleports to move along the axis.\n\nTo use a teleport, Pig should come to a certain ...
[{"type": "stdin_stdout", "input": "70 100\n0 99\n1 87\n1 94\n1 4\n2 72\n3 39\n3 69\n4 78\n5 85\n7 14\n8 59\n12 69\n14 15\n14 76\n17 17\n19 53\n19 57\n19 21\n21 35\n21 83\n24 52\n24 33\n27 66\n27 97\n30 62\n30 74\n30 64\n32 63\n35 49\n37 60\n40 99\n40 71\n41 83\n42 66\n42 46\n45 83\n51 76\n53 69\n54 82\n54 96\n54 88\n5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N blocks arranged in a row. Let us paint these blocks.\nWe will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways.\nFind the number of ...
[{"type": "stdin_stdout", "input": "200000 200000 199999\n", "output": "703273590\n"}, {"type": "stdin_stdout", "input": "178720 187658 129518\n", "output": "963607179\n"}, {"type": "stdin_stdout", "input": "189770 199455 133747\n", "output": "971381227\n"}, {"type": "stdin_stdout", "input": "189992 49130 122242\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven are a prime number p and a sequence of p integers a_0, \\ldots, a_{p-1} consisting of zeros and ones.\nFind a polynomial of degree at most p-1, f(x) = b_{p-1} x^{p-1} + b_{p-2} x^{p-2} + \\ldots + b_0, satisfying th...
[{"type": "stdin_stdout", "input": "2999\n0 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 1 0 0 1 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 1 1 1 1 0 1 0 0 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 1 0 1 0 1 0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 0 1 1 1 0 1 1 1 1 1 0 0 1 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarp is a great fan of television.\n\nHe wrote down all the TV programs he is interested in for today. His list contains n shows, i-th of them starts at moment l_{i} and ends at moment r_{i}.\n\nPolycarp owns two TVs....
[{"type": "stdin_stdout", "input": "5\n15 18\n23 24\n23 28\n22 24\n15 19\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n19 23\n12 17\n16 21\n20 23\n8 10\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "5\n3 4\n21 26\n12 17\n9 14\n15 16\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSereja showed an interesting game to his friends. The game goes like that. Initially, there is a table with an empty cup and n water mugs on it. Then all players take turns to move. During a move, a player takes a non-emp...
[{"type": "stdin_stdout", "input": "100 1000\n10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob are decorating a Christmas Tree. \n\nAlice wants only $3$ types of ornaments to be used on the Christmas Tree: yellow, blue and red. They have $y$ yellow ornaments, $b$ blue ornaments and $r$ red ornaments.\...
[{"type": "stdin_stdout", "input": "100 100 100\n", "output": "297"}, {"type": "stdin_stdout", "input": "99 100 100\n", "output": "297"}, {"type": "stdin_stdout", "input": "100 98 99\n", "output": "294"}, {"type": "stdin_stdout", "input": "99 100 99\n", "output": "294"}, {"type": "stdin_stdout", "input": "50 80 70\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nKolya loves putting gnomes at the circle table and giving them coins, and Tanya loves studying triplets of gnomes, sitting in the vertexes of an equilateral triangle.\n\nMore formally, there are 3n gnomes sitting in a cir...
[{"type": "stdin_stdout", "input": "100000\n", "output": "192156836"}, {"type": "stdin_stdout", "input": "100000\n", "output": "192156836"}, {"type": "stdin_stdout", "input": "10000\n", "output": "246305722"}, {"type": "stdin_stdout", "input": "10868\n", "output": "118127713"}, {"type": "stdin_stdout", "input": "66115\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA wise man told Kerem \"Different is good\" once, so Kerem wants all things in his life to be different. \n\nKerem recently got a string s consisting of lowercase English letters. Since Kerem likes it when things are diff...
[{"type": "stdin_stdout", "input": "45\naaabbbcccdddeeefffgghhiijjkkkkkkkkkkkkkkkkkkk\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "30\nabcdefghtyabcdefghtyabcdefghty\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "27\naaaaaaaaaaaaaaaaaaaaaaaaaaa\n", "output": "-1\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAt regular competition Vladik and Valera won a and b candies respectively. Vladik offered 1 his candy to Valera. After that Valera gave Vladik 2 his candies, so that no one thought that he was less generous. Vladik for sa...
[{"type": "stdin_stdout", "input": "1000000000 1000000000\n", "output": "Vladik\n"}, {"type": "stdin_stdout", "input": "1000000000 999982505\n", "output": "Valera\n"}, {"type": "stdin_stdout", "input": "999963734 999994456\n", "output": "Vladik\n"}, {"type": "stdin_stdout", "input": "965161805 908862070\n", "output": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nServal soon said goodbye to Japari kindergarten, and began his life in Japari Primary School.\n\nIn his favorite math class, the teacher taught him the following interesting definitions.\n\nA parenthesis sequence is a str...
[{"type": "stdin_stdout", "input": "300\n??????(??????(???)??(???????)??????)((??????(???(??)())?(???????)???????????((??(??(??(?)???)(????)??(??(?(??(????????()?????(????(?(??(?(?????)??(????(????(??(??(????((??)(??(??????????????????(????????(????(?(???????(??(????(???)?(???????)?)??(?????((??(??(??????????()?????(??...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLimak is a little polar bear. He doesn't have many toys and thus he often plays with polynomials.\n\nHe considers a polynomial valid if its degree is n and its coefficients are integers not exceeding k by the absolute val...
[{"type": "stdin_stdout", "input": "100 1000\n-62 57 -27 -67 49 -10 66 -64 -36 -78 62 -75 -39 75 -47 -36 41 -88 62 -43 22 29 -20 58 40 16 71 -2 -87 12 86 -90 -92 67 -12 -48 -10 -26 78 68 22 -3 66 -95 -81 34 14 -76 -27 76 -60 87 -84 3 35 -60 46 -65 29 -29 2 -44 -55 18 -75 91 36 34 -86 53 59 -54 -29 33 -95 66 9 72 67 -44...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDeveloping tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.\n\nA field map consists of hexagonal cells. Since locations sizes are going to be big, a game designe...
[{"type": "stdin_stdout", "input": "-1000000000 -1000000000 1000000000 1000000000\n", "output": "2000000002000000001"}, {"type": "stdin_stdout", "input": "-1000000000 -999999999 1000000000 999999999\n", "output": "2000000000000000000"}, {"type": "stdin_stdout", "input": "-999999999 -1000000000 999999999 1000000000\n", ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAlice and Bob are playing chess on a huge chessboard with dimensions $n \\times n$. Alice has a single piece left — a queen, located at $(a_x, a_y)$, while Bob has only the king standing at $(b_x, b_y)$. Alice thinks that...
[{"type": "stdin_stdout", "input": "1000\n500 200\n350 300\n400 401\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000\n600 600\n700 653\n650 701\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000\n500 500\n893 450\n891 449\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1000\n350 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nGiven an array $a$, consisting of $n$ integers, find:\n\n$$\\max\\limits_{1 \\le i < j \\le n} LCM(a_i,a_j),$$\n\nwhere $LCM(x, y)$ is the smallest positive integer that is divisible by both $x$ and $y$. For example, $LCM...
[{"type": "stdin_stdout", "input": "174\n28 44 12 32 9 27 23 5 23 47 14 49 39 5 10 5 20 9 4 34 18 40 16 4 45 30 32 44 44 30 29 23 21 27 35 13 23 46 5 32 47 45 44 23 12 2 9 28 47 23 22 27 45 27 40 41 22 39 50 14 40 44 20 40 49 23 14 29 27 23 16 40 45 44 15 18 28 9 23 15 21 10 46 29 18 6 15 3 11 34 1 15 35 27 46 36 4 20 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBarney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate. [Image] \n\nBarney asked the bar ...
[{"type": "stdin_stdout", "input": "2.0629094807595491132306264747042243928486303384791951220362096240931158821630792563855724946791054152e85\n", "output": "20629094807595491132306264747042243928486303384791951220362096240931158821630792563855.724946791054152\n"}, {"type": "stdin_stdout", "input": "1.739019376653594888...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBerland has n cities, the capital is located in city s, and the historic home town of the President is in city t (s ≠ t). The cities are connected by one-way roads, the travel time for each of the road is a positive integ...
[{"type": "stdin_stdout", "input": "2 9 1 2\n1 2 1000000\n1 2 1000000\n1 2 1000000\n1 2 1000000\n1 2 2\n1 2 1000000\n1 2 1000000\n1 2 1000000\n1 2 1000000\n", "output": "CAN 999999\nCAN 999999\nCAN 999999\nCAN 999999\nYES\nCAN 999999\nCAN 999999\nCAN 999999\nCAN 999999\n"}, {"type": "stdin_stdout", "input": "10 13 2 10...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an unweighted tree with n vertices. Then n - 1 following operations are applied to the tree. A single operation consists of the following steps: choose two leaves; add the length of the simple path betwee...
[{"type": "stdin_stdout", "input": "10\n8 2\n8 10\n10 3\n2 4\n3 6\n8 1\n2 7\n10 9\n4 5\n", "output": "35\n5 9 9\n6 1 1\n6 7 7\n5 6 6\n5 3 3\n5 10 10\n5 8 8\n5 2 2\n5 4 4\n"}, {"type": "stdin_stdout", "input": "10\n7 10\n10 6\n6 4\n4 5\n5 8\n8 2\n2 1\n1 3\n3 9\n", "output": "45\n7 9 9\n7 3 3\n7 1 1\n7 2 2\n7 8 8\n7 5 5\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVK news recommendation system daily selects interesting publications of one of $n$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $i$ batch algorithm selects $a_i$ p...
[{"type": "stdin_stdout", "input": "40\n19 20 8 13 13 17 1 14 15 20 14 17 2 9 9 10 19 16 6 12 9 7 20 5 12 6 4 4 12 5 4 11 8 1 2 8 11 19 18 4\n52258 5648 46847 9200 63940 79328 64407 54479 1788 60107 8234 64215 15419 84411 50307 78075 92548 17867 43456 7970 1390 99373 97297 90662 82950 678 79356 51351 2794 82477 16508 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is an easier version of the problem. In this version, $n \\le 500$.\n\nVasya is an experienced developer of programming competitions' problems. As all great minds at some time, Vasya faced a creative crisis. To impro...
[{"type": "stdin_stdout", "input": "500\n())()(((())))()()()()()(())()()((()))(((())))()()()()()()()(()())()()((()()))()(((()())))(()()())()()()()(((()))())()()()()()((())())()()(((())))()()()()(())()()()()((()))()()()()()()()((()))()()()((()))(((()())))()((((()))))(((())))(())(())()()()(())()(())(()())()()(()(((()))))...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nModern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.\n\nIn this problem you should implement the simila...
[{"type": "stdin_stdout", "input": "255\nT___J(M_XZJlr_lH___mqJA_p__kW)ko__F_M_Aro__ZA_G_M_P_____j_V(J_Jk_dkR_ta_lbIUhKFfo_y_DluW)IVFj_gouRfMhabn()_e___q_vo__QPEGBI_TpVVI_clPwwb_m_yL_cMVKgi___RJb_J_f____tPCyntLOr_s_x_N_SyqQw_zP_mycsW_o_c_o_Yzb_UVa_ATd(BYH_gl___Y__Uzok_Y_IA_XL_D__bkJ____e__K_quk)\n", "output": "10 25\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two arrays $a_1, a_2, \\dots , a_n$ and $b_1, b_2, \\dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).\n\nYou have to divide the array $a$ into $m$ con...
[{"type": "stdin_stdout", "input": "77 22\n7 2 4 8 10 7 5 7 9 7 5 6 2 9 10 1 5 4 5 8 6 9 3 1 8 1 10 9 6 7 7 1 5 3 6 4 9 10 7 8 2 3 10 10 9 9 2 9 1 9 7 3 2 4 7 7 1 1 10 4 2 2 8 3 2 9 9 9 5 6 7 1 10 8 3 9 1\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nE869120 is initially standing at the origin (0, 0) in a two-dimensional plane.\nHe has N engines, which can be used as follows:\n - When E869120 uses the i-th engine, his X- and Y-coordinate change by x_i and y_i, respect...
[{"type": "stdin_stdout", "input": "100\n-62558 -455059\n-78926 -574123\n-122264 -889372\n-29760 -216480\n-91884 -668382\n-122636 -892078\n-134168 -975964\n-17670 -128535\n-127782 -929511\n-74524 -542102\n-104470 -759935\n-133362 -970101\n-93124 -677402\n-16368 -119064\n-19530 -142065\n-82336 -598928\n-87358 -635459\n-...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIvan has an array consisting of n elements. Each of the elements is an integer from 1 to n.\n\nRecently Ivan learned about permutations and their lexicographical order. Now he wants to change (replace) minimum number of e...
[{"type": "stdin_stdout", "input": "50\n48 37 47 50 46 43 42 46 36 40 45 41 40 50 35 49 37 42 44 45 49 44 31 47 45 49 48 41 45 45 48 20 34 43 43 41 47 50 41 48 38 48 43 48 46 48 32 37 47 45\n", "output": "31\n1 2 3 4 5 6 7 8 36 9 10 11 40 12 35 13 14 42 15 16 17 44 31 18 19 49 21 22 23 24 25 20 34 26 27 28 29 50 41 30 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya is going to the Olympics in the city Ntown by train. The boy wants to read the textbook to prepare for the Olympics. He counted that he needed k hours for this. He also found that the light in the train changes ever...
[{"type": "stdin_stdout", "input": "100 79\n83 83 83 83 83 94 94 83 83 83 83 90 83 99 83 91 83 83 83 83 83 83 83 83 83 83 83 91 83 83 83 83 83 96 83 83 83 91 83 83 92 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 98 83 83 91 97 83 83 83 83 83 83 83 92 83 83 83 83 83 83 83 93 83 83 91 83 83 83 83 83 83 83 83 83 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.\n\nThe electoral system in the country is pretty unu...
[{"type": "stdin_stdout", "input": "100 1\n439 158 619 538 187 153 973 781 610 475 94 947 449 531 220 51 788 118 189 501 54 434 465 902 280 635 688 214 737 327 682 690 683 519 261 923 254 388 529 659 662 276 376 735 976 664 521 285 42 147 187 259 407 977 879 465 522 17 550 701 114 921 577 265 668 812 232 267 135 371 58...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nValera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.\n\nValera has written n correct solutions. For each correct solution, he knows its running time (in se...
[{"type": "stdin_stdout", "input": "68 85\n43 55 2 4 72 45 19 56 53 81 18 90 11 87 47 8 94 88 24 4 67 9 21 70 25 66 65 27 46 13 8 51 65 99 37 43 71 59 71 79 32 56 49 43 57 85 95 81 40 28 60 36 72 81 60 40 16 78 61 37 29 26 15 95 70 27 50 97\n6 6 48 72 54 31 1 50 29 64 93 9 29 93 66 63 25 90 52 1 66 13 70 30 24 87 32 90...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCalendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calen...
[{"type": "stdin_stdout", "input": "1900:01:01\n2038:12:31\n", "output": "50768\n"}, {"type": "stdin_stdout", "input": "1903:09:27\n1988:06:15\n", "output": "30943\n"}, {"type": "stdin_stdout", "input": "1915:01:01\n2007:07:01\n", "output": "33784\n"}, {"type": "stdin_stdout", "input": "1925:07:15\n2010:06:22\n", "outp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAri the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero. Byteforces is a country that consists of n cities, connected by n - 1 bidirectional roads. Every road connects ...
[{"type": "stdin_stdout", "input": "63 20\n35 26\n54 5\n32 56\n56 53\n59 46\n37 31\n46 8\n4 1\n2 47\n59 42\n55 11\n62 6\n30 7\n60 24\n41 36\n34 22\n24 34\n21 2\n12 52\n8 44\n60 21\n24 30\n48 35\n48 25\n32 57\n20 37\n11 54\n11 62\n42 58\n31 43\n12 23\n55 48\n51 55\n41 27\n25 33\n21 18\n42 12\n4 15\n51 60\n62 39\n46 41\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIt's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha.\n\nSo the hacker began to work hard in order to get rid of boredom. It means that Leha began to ha...
[{"type": "stdin_stdout", "input": "15 17\n1 10 8\n5 19 1\n12 14 6\n9 19 8\n6 7 3\n5 11 9\n7 12 5\n17 20 8\n6 12 6\n11 19 4\n3 14 1\n15 19 10\n3 20 5\n5 19 9\n10 18 10\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "15 24\n2 14 5\n7 14 4\n6 11 6\n3 5 6\n4 13 5\n10 11 4\n8 8 6\n5 14 4\n2 2 3\n9 14 5\n2 13 6\n1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwo friends are on the coordinate axis Ox in points with integer coordinates. One of them is in the point x_1 = a, another one is in the point x_2 = b. \n\nEach of the friends can move by one along the line in any directi...
[{"type": "stdin_stdout", "input": "864\n179\n", "output": "117649\n"}, {"type": "stdin_stdout", "input": "1\n1000\n", "output": "250000\n"}, {"type": "stdin_stdout", "input": "1000\n1\n", "output": "250000\n"}, {"type": "stdin_stdout", "input": "2\n1000\n", "output": "249500\n"}, {"type": "stdin_stdout", "input": "100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course.\n\nYou decided to rob a town's blacksmith ...
[{"type": "stdin_stdout", "input": "9\n475033014 267058742\n26843 148652\n850113755 279316120\n871120869 885251487\n51363 15651\n220811492 256297120\n473761699 194406678\n38725 23371\n167395720 333327477\n107541472 19164492\n74340 1113\n654389849 224345301\n663158140 437349008\n332 5052\n971865476 538450184\n959712803 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\n-----Input-----\n\nThe input contains a single integer a (1 ≤ a ≤ 40).\n\n\n-----Output-----\n\nOutput a single string.\n\n\n-----Examples-----\nInput\n2\n\nOutput\nAdams\n\nInput\n8\n\nOutput\nVan Buren\n\nInput\n29\n\nO...
[{"type": "stdin_stdout", "input": "34\n", "output": "Eisenhower\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "Washington\n"}, {"type": "stdin_stdout", "input": "22\n", "output": "Cleveland\n"}, {"type": "stdin_stdout", "input": "24\n", "output": "Cleveland\n"}, {"type": "stdin_stdout", "input": "26\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFox Ciel has some flowers: r red flowers, g green flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:\n\n To make a \"red bouquet\", it needs 3 red flowers....
[{"type": "stdin_stdout", "input": "1000000000 1000000000 1000000000\n", "output": "1000000000\n"}, {"type": "stdin_stdout", "input": "1000000000 999999999 999999998\n", "output": "999999998\n"}, {"type": "stdin_stdout", "input": "123456789 123456789 123456789\n", "output": "123456789\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFifa and Fafa are sharing a flat. Fifa loves video games and wants to download a new soccer game. Unfortunately, Fafa heavily uses the internet which consumes the quota. Fifa can access the internet through his Wi-Fi acce...
[{"type": "stdin_stdout", "input": "519 -92641 -28571 -92540 -28203\n", "output": "-92659.18165738975 -28637.246038806206 450.30421903092184\n"}, {"type": "stdin_stdout", "input": "3930 -76494 -83852 -78181 -81125\n", "output": "-76303.71953677801 -84159.58436467478 3568.316718555632\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecall that the permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2,3,1,5,4]$ is a permutation, but $[1,2,2]$ is not a permutation ($2$ appears twice in the arr...
[{"type": "stdin_stdout", "input": "250000 993244853\n", "output": "872048421\n"}, {"type": "stdin_stdout", "input": "244435 994838543\n", "output": "634651929\n"}, {"type": "stdin_stdout", "input": "234324 994631069\n", "output": "720229385\n"}, {"type": "stdin_stdout", "input": "249996 997202249\n", "output": "633673...
code_stdio