messages
listlengths
1
1
ground_truth
stringlengths
88
726k
dataset
stringclasses
1 value
[ { "content": "Solve the following coding problem using the programming language python:\n\nInternational Car Production Company (ICPC), one of the largest automobile manufacturers in the world, is now developing a new vehicle called \"Two-Wheel Buggy\". As its name suggests, the vehicle has only two wheels. Qui...
[{"type": "stdin_stdout", "input": "1 1\n180 253 3\n1 1\n180 180 19\n2 10\n694 -351 7\n-24 360 8\n3 2\n100 60 2\n-72 -72 10\n-59 -413 5\n0 0", "output": "-7.91148452\n5.59128446\n0.00000000\n59.69026042\n-16.09771605\n5.86169674\n-6.89851214\n-10.76376689\n"}, {"type": "stdin_stdout", "input": "1 2\n180 253 2\n1 2\n180...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNadeko's birthday is approaching! As she decorated the room for the party, a long garland of Dianthus-shaped paper pieces was placed on a prominent part of the wall. Brother Koyomi will like it!\n\nStill unsatisfied with ...
[{"type": "stdin_stdout", "input": "100\ndddddccccdddddaaaaabbbbbbbbbbbbbaaacdcabbacccacccccbdbbadddbbddddbdaaccacdddbbbaddddbbbbdcbbbdddddda\n50\n54 b\n48 d\n45 b\n52 c\n52 a\n48 a\n54 b\n45 a\n47 d\n50 d\n53 a\n34 a\n51 b\n48 d\n47 d\n47 a\n48 d\n53 b\n52 d\n54 d\n46 a\n38 a\n52 b\n49 a\n49 b\n46 c\n99 a\n45 b\n35 c\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Dogeforces company has $k$ employees. Each employee, except for lower-level employees, has at least $2$ subordinates. Lower-level employees have no subordinates. Each employee, except for the head of the company, has ...
[{"type": "stdin_stdout", "input": "9\n98 100 100 100 100 100 100 99 100\n100 96 100 100 99 100 100 100 97\n100 100 98 99 100 100 100 100 100\n100 100 99 97 100 100 100 100 100\n100 99 100 100 98 100 100 100 99\n100 100 100 100 100 97 98 100 100\n100 100 100 100 100 98 97 100 100\n99 100 100 100 100 100 100 98 100\n100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs we all know, Max is the best video game player among her friends. Her friends were so jealous of hers, that they created an actual game just to prove that she's not the best at games. The game is played on a directed a...
[{"type": "stdin_stdout", "input": "100 1\n92 93 p\n", "output": "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\nBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAutumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivi...
[{"type": "stdin_stdout", "input": "9 9\n", "output": "13\nAAA.BCCC.\n.ABBB.CD.\n.AE.BFCD.\nEEEFFFDDD\nG.E.HFIII\nGGGJHHHI.\nGK.JHL.IM\n.KJJJLMMM\nKKK.LLL.M\n"}, {"type": "stdin_stdout", "input": "9 8\n", "output": "12\nAAA.BCCC\n.ABBBDC.\nEA.FBDC.\nEEEFDDDG\nEHFFFGGG\n.HHHIIIG\nJHKKKIL.\nJJJK.IL.\nJ..K.LLL\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEmuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes.\n\nFrom the top view each magical box looks like a sq...
[{"type": "stdin_stdout", "input": "15\n999999986 268435456\n999999987 67108864\n999999988 16777216\n999999989 4194304\n999999990 1048576\n999999991 262144\n999999992 65536\n999999993 16384\n999999994 4096\n999999995 1024\n999999996 256\n999999997 64\n999999998 16\n999999999 4\n1000000000 1\n", "output": "1000000001\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMasha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities.\n\nTo bake muffins in her bakery, Masha needs t...
[{"type": "stdin_stdout", "input": "8 57 3\n1 3 15\n2 3 1\n1 7 21\n1 2 11\n2 1 16\n1 6 4\n1 3 2\n3 7 17\n5 8 3\n1 3 18\n1 4 3\n1 2 1\n2 8 14\n1 4 17\n4 5 21\n2 3 6\n3 5 11\n2 8 11\n3 4 1\n1 3 9\n1 4 3\n2 3 12\n1 5 9\n2 3 15\n1 2 14\n1 2 10\n1 4 19\n5 7 7\n5 8 20\n5 8 1\n1 4 3\n4 5 8\n5 7 1\n1 2 14\n4 5 9\n6 7 2\n2 6 9\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has the sequence consisting of n integers. Vasya consider the pair of integers x and y k-interesting, if their binary representation differs from each other exactly in k bits. For example, if k = 2, the pair of inte...
[{"type": "stdin_stdout", "input": "100 14\n8192 8192 8192 8192 8191 8192 8192 8192 8192 8192 8191 8191 8191 8192 8191 8191 8191 8192 8192 8192 8192 8192 8191 8191 8191 8192 8191 8192 8192 8192 8192 8192 8192 8191 8191 8192 8192 8191 8191 8192 8192 8192 8191 8191 8192 8191 8191 8191 8191 8191 8191 8192 8191 8191 8192 8...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMusicians of a popular band \"Flayer\" have announced that they are going to \"make their exit\" with a world tour. Of course, they will visit Berland as well.\n\nThere are n cities in Berland. People can travel between c...
[{"type": "stdin_stdout", "input": "7 7\n1 6 745325\n2 3 3581176\n2 4 19\n3 6 71263060078\n5 4 141198\n7 4 163953\n5 6 15994\n1 297404206755 82096176217 14663411 187389745 21385 704393\n", "output": "1 335807 7498159 335769 53373 21385 663675 \n"}, {"type": "stdin_stdout", "input": "7 7\n1 6 745325\n2 3 3581176\n2 4 19...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAfter battling Shikamaru, Tayuya decided that her flute is too predictable, and replaced it with a guitar. The guitar has 6 strings and an infinite number of frets numbered from 1. Fretting the fret number j on the i-th s...
[{"type": "stdin_stdout", "input": "58260522 77914575 2436426 24979445 61648772 23690081\n10\n582107247 906728404 411434947 673536177 411497300 488012525 561127307 800305059 992325267 112738006\n", "output": "804109112\n"}, {"type": "stdin_stdout", "input": "58260522 77914575 2436426 24979445 61648772 23690081\n10\n582...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are n employees working in company \"X\" (let's number them from 1 to n for convenience). Initially the employees didn't have any relationships among each other. On each of m next days one of the following events to...
[{"type": "stdin_stdout", "input": "2 10\n2 2\n1 2 1\n3 1 1\n3 2 1\n3 1 1\n2 2\n3 1 2\n3 1 1\n3 2 1\n3 1 2\n", "output": "NO\nYES\nNO\nYES\nNO\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "2 10\n2 2\n1 2 1\n3 1 1\n3 1 1\n3 1 1\n2 2\n3 1 2\n3 1 1\n3 2 1\n3 1 2\n", "output": "NO\nNO\nNO\nYES\nNO\nYES\nYES\n"}, {"type...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given four integers $n$, $B$, $x$ and $y$. You should build a sequence $a_0, a_1, a_2, \\dots, a_n$ where $a_0 = 0$ and for each $i \\ge 1$ you can choose:\n\neither $a_i = a_{i - 1} + x$\n\nor $a_i = a_{i - 1} - ...
[{"type": "stdin_stdout", "input": "2\n100000 1000000000 1000000000 1\n100000 1 1000000000 10000\n", "output": "99995000050000\n-50000500000000\n"}, {"type": "stdin_stdout", "input": "7\n1 1 1 1\n2 2 2 2\n3 3 3 3\n4 4 4 4\n5 5 5 5\n6 6 6 6\n7 7 7 7\n", "output": "1\n2\n6\n8\n15\n18\n28\n"}, {"type": "stdin_stdout", "in...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nΠŸΠ°ΠΌΡΡ‚ΡŒ ΠΊΠΎΠΌΠΏΡŒΡŽΡ‚Π΅Ρ€Π° состоит ΠΈΠ· n ячССк, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ выстроСны Π² ряд. ΠŸΡ€ΠΎΠ½ΡƒΠΌΠ΅Ρ€ΡƒΠ΅ΠΌ ячСйки ΠΎΡ‚ 1 Π΄ΠΎ n слСва Π½Π°ΠΏΡ€Π°Π²ΠΎ. ΠŸΡ€ΠΎ ΠΊΠ°ΠΆΠ΄ΡƒΡŽ ячСйку извСстно, свободна ΠΎΠ½Π° ΠΈΠ»ΠΈ ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ‚ ΠΊΠ°ΠΊΠΎΠΌΡƒ-Π»ΠΈΠ±ΠΎ процСссу (Π² Ρ‚Π°ΠΊΠΎΠΌ случаС извСстСн процСсс, ΠΊΠΎ...
[{"type": "stdin_stdout", "input": "24\n0 0 6 6 6 0 22 22 0 23 23 0 19 19 19 19 0 0 17 0 0 3 3 3\n", "output": "14\n"}, {"type": "stdin_stdout", "input": "21\n0 11 11 11 11 0 7 0 12 12 12 12 12 0 19 19 19 0 1 1 1\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "24\n6 6 0 0 0 22 0 0 23 0 0 19 0 0 0 0 17 17 0 3 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's imagine: there is a chess piece billiard ball. Its movements resemble the ones of a bishop chess piece. The only difference is that when a billiard ball hits the board's border, it can reflect from it and continue m...
[{"type": "stdin_stdout", "input": "1000000 1000000\n", "output": "1000000\n"}, {"type": "stdin_stdout", "input": "666667 1000000\n", "output": "333334\n"}, {"type": "stdin_stdout", "input": "871866 348747\n", "output": "174374\n"}, {"type": "stdin_stdout", "input": "863029 287677\n", "output": "287677\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPanic is rising in the committee for doggo standardizationΒ β€” the puppies of the new brood have been born multi-colored! In total there are 26 possible colors of puppies in the nature and they are denoted by letters from '...
[{"type": "stdin_stdout", "input": "27\nmnpsweykjdvaxyiqtgcuzhbfrlo\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "27\nabcdefghijklmnopqrstuvwxyza\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "27\nabcdefghijklmnopqrstuvwxyza\n", "output": "Yes\n"}, {"type": "stdin_stdout", "input": "27\nmnpswey...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves hockey very much. One day, as he was watching a hockey match, he fell asleep. Petya dreamt of being appointed to change a hockey team's name. Thus, Petya was given the original team name w and the collection o...
[{"type": "stdin_stdout", "input": "100\nqn\nBE\nyN\nep\nPq\nXz\nLM\nEZ\ndb\nMn\nbn\nFe\nqA\nzc\nyq\npC\nyA\nWk\nYq\nrs\noD\nvD\nzW\nxZ\nbl\nur\nkf\ndf\nLS\nUW\nMy\nhR\nsh\nNh\nog\nCW\nor\nzo\nrO\nao\nXH\nDq\nKa\nlL\nYQ\nOh\nRZ\nAx\nta\nko\nDn\nNg\nNy\nDB\nYD\njO\nAp\nFT\noB\nNc\nwB\nHO\neW\nAc\nDr\nMt\nDf\nbF\nFP\nRa\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a directed graph consisting of $n$ vertices. Each directed edge (or arc) labeled with a single character. Initially, the graph is empty.\n\nYou should process $m$ queries with it. Each query is one of three ...
[{"type": "stdin_stdout", "input": "3 11\n+ 1 2 a\n+ 1 3 c\n+ 3 2 a\n+ 2 1 a\n? 6\n? 5\n- 2 1\n- 3 2\n+ 2 1 c\n+ 3 2 d\n? 5\n", "output": "YES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "3 11\n+ 1 2 a\n+ 1 3 c\n+ 3 2 a\n+ 2 1 a\n? 6\n? 5\n- 2 1\n- 3 2\n+ 2 1 c\n+ 3 3 d\n? 5\n", "output": "YES\nYES\nYES\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.\n\nLet's consider that all lines in the poems consist of lowercase Latin letter...
[{"type": "stdin_stdout", "input": "7 3\nferwljzwakxedlgwl\noerwljzwakxedlgwl\nhyqombizhuhxedprb\netptjrizhuhxedprb\nurtuckar\ndkartmwramklcmi\nrurtuckar\nnurartmwramklcmi\niraziomsv\nsaziomsv\nbprapiqpayzurgij\nusyemayzurgij\nztstmeecvmkvuu\nquexlecvmkvuu\nrlhwecvmkvuu\nzecvmkvuu\niikymgbncljtub\nqiikymgbncljtub\nbcav...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBerland Football Cup starts really soon! Commentators from all over the world come to the event.\n\nOrganizers have already built $n$ commentary boxes. $m$ regional delegations will come to the Cup. Every delegation shoul...
[{"type": "stdin_stdout", "input": "500000000001 1000000000000 100 100\n", "output": "49999999999900\n"}, {"type": "stdin_stdout", "input": "500000000001 1000000000000 100 100\n", "output": "49999999999900\n"}, {"type": "stdin_stdout", "input": "500000000001 1000000000000 110 100\n", "output": "50000000000100\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFrom the FAQ:\n\nWhat am I allowed to post as a comment for a problem? \n\nDo NOT post code.\nDo NOT post a comment asking why your solution is wrong.\nDo NOT post a comment asking if you can be given the test case your p...
[{"type": "stdin_stdout", "input": "7\n1\n?\n2\n0?\n11\n69259?087\n4\n??\n2\n0?1\n4\n?????\n3\n22", "output": "0\n01\n692591087\n01\nNO\n01012\nNO\n"}, {"type": "stdin_stdout", "input": "7\n1\n?\n2\n0?\n11\n69259?087\n4\n??\n2\n0?1\n4\n?????\n3\n15", "output": "0\n01\n692591087\n01\nNO\n01012\n15\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDaniel is watching a football team playing a game during their training session. They want to improve their passing skills during that session.\n\nThe game involves $n$ players, making multiple passes towards each other. ...
[{"type": "stdin_stdout", "input": "1\n200\n5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHakone Ekiden is one of the Japanese New Year's traditions. In Hakone Ekiden, 10 runners from each team aim for the goal while connecting the sashes at each relay station. In the TV broadcast, the ranking change from the ...
[{"type": "stdin_stdout", "input": "10\nU\nD\nU\nD\nU\nD\nU\nD\nU\nD", "output": "608"}, {"type": "stdin_stdout", "input": "8\nT\nD\nD\nD\nD\nD\nD\nC", "output": "0\n"}, {"type": "stdin_stdout", "input": "8\nT\nD\nD\nD\nD\nD\nC\nC", "output": "0\n"}, {"type": "stdin_stdout", "input": "8\nT\nD\nD\nD\nD\nE\nC\nC", "outpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFor an integer N, we will choose a permutation \\{P_1, P_2, ..., P_N\\} of \\{1, 2, ..., N\\}.\nThen, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.\nFind the maximum possible value of M_1 + M_2 ...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "499999999500000000\n"}, {"type": "stdin_stdout", "input": "999999999\n", "output": "499999998500000001\n"}, {"type": "stdin_stdout", "input": "999999998\n", "output": "499999997500000003\n"}, {"type": "stdin_stdout", "input": "234679769\n", "output": "275372...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\nL...
[{"type": "stdin_stdout", "input": "1000000000\n", "output": "4444477777\n"}, {"type": "stdin_stdout", "input": "1000100000\n", "output": "4444477777\n"}, {"type": "stdin_stdout", "input": "1211766791\n", "output": "4444477777\n"}, {"type": "stdin_stdout", "input": "1101704081\n", "output": "4444477777\n"}, {"type": "s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet S(n) denote the sum of the digits in the decimal notation of n.\nFor example, S(123) = 1 + 2 + 3 = 6.\nWe will call an integer n a Snuke number when, for all positive integers m such that m > n, \\frac{n}{S(n)} \\leq ...
[{"type": "stdin_stdout", "input": "792\n", "output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n19\n29\n39\n49\n59\n69\n79\n89\n99\n199\n299\n399\n499\n599\n699\n799\n899\n999\n1099\n1199\n1299\n1399\n1499\n1599\n1699\n1799\n1899\n1999\n2999\n3999\n4999\n5999\n6999\n7999\n8999\n9999\n10999\n11999\n12999\n13999\n14999\n15999\n16999\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDuring the lunch break all n Berland State University students lined up in the food court. However, it turned out that the food court, too, has a lunch break and it temporarily stopped working.\n\nStanding in a queue that...
[{"type": "stdin_stdout", "input": "10\n419946 201769\n245945 0\n842799 113073\n836998 245945\n0 794376\n692107 836998\n113073 904403\n904403 987165\n201769 692107\n794376 842799\n", "output": "419946 794376 201769 842799 692107 113073 836998 904403 245945 987165 \n"}, {"type": "stdin_stdout", "input": "10\n419946 2017...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an array $a_1, a_2, \\dots , a_n$. Array is good if for each pair of indexes $i < j$ the condition $j - a_j \\ne i - a_i$ holds. Can you shuffle this array so that it becomes good? To shuffle an array means ...
[{"type": "stdin_stdout", "input": "3\n1\n7\n4\n1 1 3 5\n6\n3 2 1 5 6 4\n", "output": "7\n5 3 1 1\n6 5 4 3 2 1\n"}, {"type": "stdin_stdout", "input": "3\n1\n7\n4\n1 1 3 5\n6\n3 2 1 5 6 4\n", "output": "7\n5 3 1 1\n6 5 4 3 2 1\n"}, {"type": "stdin_stdout", "input": "3\n1\n7\n4\n0 1 3 5\n6\n3 2 1 5 6 4\n", "output": "7\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn a coordinate system,There are 3 chocolate which will be placed at three random position (x1,y1),(x2,y2) and (x3,y3).Ramesh loves Chocolates. Ramesh always moves along a straight line. your task is to find out whether h...
[{"type": "stdin_stdout", "input": "10\n44 89 20 54 87 61\n65 25 84 82 78 98\n62 115 111 81 47 101\n73 22 24 111 56 47\n115 38 36 41 102 112\n32 89 58 91 46 67\n31 23 114 55 119 87\n31 61 84 93 53 42\n77 82 64 67 88 73\n98 49 61 43 79 57", "output": "YES\nNO\nNO\nYES\nNO\nNO\nNO\nNO\nNO\nYES"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequency ...
[{"type": "stdin_stdout", "input": "20 6 15\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n", "output": "Both\nBoth\nVova\nVova\nVanya\nVova\nVova\nBoth\nBoth\nVova\nVova\nVanya\nVova\nVova\nBoth\nBoth\nVova\nVova\nVanya\nVova\n"}, {"type": "stdin_stdout", "input": "20 5 15\n20\n21\n22...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn this problem, we will deal with binary strings. Each character of a binary string is either a 0 or a 1. We will also deal with substrings; recall that a substring is a contiguous subsequence of a string. We denote the ...
[{"type": "stdin_stdout", "input": "50\n01110100101100100100011001100001110010010000000101\n50\n27 18 7\n22 35 2\n50 35 1\n41 16 1\n27 5 5\n11 6 33\n7 19 2\n9 12 33\n14 37 4\n1 22 8\n22 3 5\n50 42 1\n50 38 1\n29 20 2\n20 34 17\n20 4 29\n16 21 3\n11 43 3\n15 45 1\n12 28 3\n31 34 13\n43 1 8\n3 41 1\n18 3 13\n29 44 6\n47 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA subsequence of length |x| of string s = s1s2... s|s| (where |s| is the length of string s) is a string x = sk1sk2... sk|x| (1 ≀ k1 < k2 < ... < k|x| ≀ |s|).\n\nYou've got two strings β€” s and t. Let's consider all subseq...
[{"type": "stdin_stdout", "input": "ctkhagrifaztmnxhmqztzibnmzzkojiztvrkfeoqegvwtbxlvvjhebshqaicsovtkcdovytimjggglyxlvglgunbohnkxargymbqvzgsnvjzgxivdgnaesgxqcruaopjuqsyyorrobnelehjnxcetveehlbmeskptivsuhuqupbieumycwczxyqjtwfofehfkpqmjngygwxkaviuyouiippgvlxjgtkxmhcwtzacbllsybgiujyryngapfwjkkyapfgxtcdpc\nctkhagrifaztmnxhm...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive). How many possible candidates of the value of Nukes's integer there are?\n\nConstraints\n\n* 1 ≀ A ≀ B < 2...
[{"type": "stdin_stdout", "input": "271828182845904523\n1128816364578546661", "output": "881093321760942453\n"}, {"type": "stdin_stdout", "input": "271828182845904523\n1080587834201094862", "output": "881093321760942453\n"}, {"type": "stdin_stdout", "input": "271828182845904523\n1104519973481288013", "output": "8810933...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe ancient Berlanders believed that the longer the name, the more important its bearer is. Thus, Berland kings were famous for their long names. But long names are somewhat inconvenient, so the Berlanders started to abbr...
[{"type": "stdin_stdout", "input": "50\nagecd\ncghafi\nfiide\niecc\njbdcfjhgd\ndiee\nhfeg\nehc\ngfijgjh\ngacaifebg\ndicbbddc\nhjgciaei\njjcdh\ng\ngc\ncf\nhfdjhd\nc\nicidbec\nji\neeh\ncgeejggc\nacfd\njjg\najefdj\neghhebiic\nbih\ngbb\njjaa\nidc\ngafi\necg\ndbigbjiehj\ncedif\nahidfaaajg\nhfhhiccbgb\ndgegjgieif\nhgjebhfdc\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou've got a positive integer sequence a_1, a_2, ..., a_{n}. All numbers in the sequence are distinct. Let's fix the set of variables b_1, b_2, ..., b_{m}. Initially each variable b_{i} (1 ≀ i ≀ m) contains the value of z...
[{"type": "stdin_stdout", "input": "23\n26988535 53977070 107954140 161931210 323862420 215908280 431816560 647724840 269885350 242896815 755678980 485793630 863633120 404828025 539770700 134942675 593747770 377839490 917610190 809656050 620736305 971587260 458805095\n", "output": "7\n"}, {"type": "stdin_stdout", "inpu...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe surveyor starship Hakodate-maru is famous for her two fuel containers with unbounded capacities. They hold the same type of atomic fuel balls.\n\nThere, however, is an inconvenience. The shapes of the fuel containers ...
[{"type": "stdin_stdout", "input": "100\n160\n50\n20\n150323\n0", "output": "99\n160\n47\n20\n150303\n"}, {"type": "stdin_stdout", "input": "100\n31\n37\n104\n151200\n0", "output": "99\n31\n37\n99\n151200\n"}, {"type": "stdin_stdout", "input": "100\n84\n50\n20\n151200\n0", "output": "99\n84\n47\n20\n151200\n"}, {"type"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nAs you might remember, the collector of Siruseri had ordered\na complete revision of the Voters List. He knew that constructing\nthe list of voters is a difficult task, prone to errors. Some\nvoters may have been away on ...
[{"type": "stdin_stdout", "input": "5 6 5\n23\n30\n42\n57\n90\n21 \n23 \n35 \n57 \n90 \n92 \n21 \n23 \n30 \n57 \n90 ", "output": "5\n21 \n23 \n30 \n57 \n90"}, {"type": "stdin_stdout", "input": "5 6 5\n23\n30\n37\n57\n90\n21 \n23 \n35 \n57 \n90 \n92 \n21 \n23 \n30 \n57 \n174", "output": "5\n21\n23\n30\n57\n90\n"}, {"typ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nHeading ##There are two integers A and B. You are required to compute the bitwise AND amongst all natural numbers lying between A and B, both inclusive.\nInput Format\n\nFirst line of the input contains T, the number of t...
[{"type": "stdin_stdout", "input": "124\n1476395008 1493172223\n1275068416 1291845631\n4009754624 4026531839\n2516582400 2533359615\n50331648 67108863\n2566914048 2583691263\n2952790016 2969567231\n3892314112 3909091327\n3489660928 3506438143\n33554432 50331647\n1694498816 1711276031\n3623878656 3640655871\n1308622848 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe ACM ICPC judges are very careful about not leaking their problems, and all communications are encrypted. However, one does sometimes make mistakes, like using too weak an encryption scheme. Here is an example of that....
[{"type": "stdin_stdout", "input": "8\n1 1 1 1 1 1 2 1 8\n3 2 3 2 3 2 4 2 10\n6 4 7 13 7 b a 2 2e\ne1 13 ce 28 ca 6 ab 46 a5d\nb08 49e2 6128 f27 8cf2 bc50 7380 7fe1 722b\n4eba eb4 a352 fd14 6ac1 fed1 dd06 bb83 392bc\nef593c08 847e522f c9b20c47 26f3a4e1 e2720a01 6fe66007\n7a4e96ad 6ee5cef6 3853cd88\n8bf20206 757d6d66 9c...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant has got a problem β€” somebody has been touching his sorted by non-decreasing array a of length n and possibly swapped some elements of the array.\n\nThe Little Elephant doesn't want to call the police u...
[{"type": "stdin_stdout", "input": "128\n1 2 4 6 8 17 20 20 23 33 43 49 49 49 52 73 74 75 82 84 85 87 90 91 102 103 104 105 111 111 401 142 142 152 155 160 175 176 178 181 183 184 187 188 191 193 326 202 202 214 224 225 236 239 240 243 246 247 249 249 257 257 261 264 265 271 277 281 284 284 286 289 290 296 297 303 305 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nNote that the memory limit in this problem is lower than in others.\n\nYou have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom.\n\nYou also have a token that is initially placed in ce...
[{"type": "stdin_stdout", "input": "3912472 307193683\n", "output": "149191773\n"}, {"type": "stdin_stdout", "input": "2525447 612881327\n", "output": "368194805\n"}, {"type": "stdin_stdout", "input": "2924225 629135317\n", "output": "498731287\n"}, {"type": "stdin_stdout", "input": "3175292 612881327\n", "output": "60...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\...
[{"type": "stdin_stdout", "input": "485 9554485\n7759121368632736852539182753173468028218114958118158732302477551670775608015153610483175626465946144780731573954182900412248382710280376491925985206156109890139333293746203940442347501294009600230166311978044218247083102712257326301109220002496805123344816427514286225153...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDraw a chessboard which has a height of H cm and a width of W cm. For example, the following figure shows a chessboard which has a height of 6 cm and a width of 10 cm.\n\n\n.#.#.#.#.\n.#.#.#.#.#\n.#.#.#.#.\n.#.#.#.#.#\n.#...
[{"type": "stdin_stdout", "input": "11 21\n10 0\n5 0\n2 4\n2 0\n0 0", "output": "#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#.#.#.#.#.#.#\n.#.#.#.#.#.#.#.#.#.#.\n#.#.#.#.#...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSo the Beautiful Regional Contest (BeRC) has come to an end! n students took part in the contest. The final standings are already known: the participant in the i-th place solved p_i problems. Since the participants are pr...
[{"type": "stdin_stdout", "input": "5\n12\n5 4 4 3 2 2 1 1 1 1 1 1\n4\n4 3 2 0\n1\n1000000\n20\n20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 10 3 2 1\n32\n64 64 63 58 58 58 58 58 37 37 37 37 34 34 28 28 28 28 28 28 24 24 19 17 17 17 17 16 17 16 16 11\n", "output": "1 2 3\n0 0 0\n0 0 0\n1 2 7\n2 6 6\n"}, {"type": "stdin_s...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA widely known among some people Belarusian sport programmer Lesha decided to make some money to buy a one square meter larger flat. To do this, he wants to make and carry out a Super Rated Match (SRM) on the site Torcode...
[{"type": "stdin_stdout", "input": "15\na b c d e f g h i j k l m n o\n1\n221 n g m h n f d a b a m d o n e e c c i a f f f i h m b o l j b d f m f i j c g d k l i b d a h l j e n b d b j o c c b c e c o g n h a b l m m h n a a a n e k m m a e b l i k a g h k k f d j c n g c d k b f k k a k g m b a j b n m f c f f o a ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nRecently Chef bought a bunch of robot-waiters. And now he needs to know how much to pay for the electricity that robots use for their work. All waiters serve ...
[{"type": "stdin_stdout", "input": "2\n-1 -1\n7 -1", "output": "2\n14\n"}, {"type": "stdin_stdout", "input": "2\n-1 -1\n2 11", "output": "2\n21\n"}, {"type": "stdin_stdout", "input": "2\n-1 -2\n4 14", "output": "3\n28\n"}, {"type": "stdin_stdout", "input": "2\n1 -1\n10 14", "output": "2\n28\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nBob is travelling from one city to another. In his way, he sees many other cities pass by. What he does instead of learning the full names of the cities, he learns just the first character of the cities. For example, if h...
[{"type": "stdin_stdout", "input": "100\n84\nlrbbmqb\ncd\nr\nowkk\nhiddqsc\nxrjm\nwfr\nsjyb\ndbef\narcbynecd\nggx\npklore\nlnmpapqfwk\nopkm\noqhnwnkue\nhsqmgbbuq\nljjivswmd\nq\nbx\nxmvtr\nbljptnsn\nwzqf\nmafadrrwso\nsbcnuv\nhffbsaq\nwp\nc\ncehch\nvf\nkmlnozjkpq\nxrjxki\nzyxa\nbhhki\nq\noendtomfg\nwdwf\ngpxiq\nkuytdlcgd...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to n from top to bottom and the columns β€” from 1 to m, from lef...
[{"type": "stdin_stdout", "input": "63 67 18046757 61758841 85367218 68\n22 30\n25 40\n56 58\n29 11\n34 63\n28 66\n51 5\n39 64\n1 23\n24 61\n19 47\n10 31\n55 28\n52 26\n38 7\n28 31\n13 27\n37 42\n10 52\n19 33\n7 36\n13 1\n46 40\n21 41\n1 1\n6 35\n10 4\n46 9\n21 57\n1 49\n34 14\n14 35\n43 4\n1 41\n25 22\n18 25\n27 23\n4...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShohag has an integer sequence $a_1, a_2, \\ldots, a_n$. He can perform the following operation any number of times (possibly, zero):\n\nSelect any positive integer $k$ (it can be different in different operations).\n\nCh...
[{"type": "stdin_stdout", "input": "1\n39\n481199252 336470888 728039650 446497694 740396295 773386884 579721198 396628655 503722503 971207868 202647942 2087506 268792718 46761498 443917727 16843338 125908043 1772709198 717268783 787375312 150414369 693319712 519096230 29277141 856168102 762263554 674936674 407246545 2...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a rectangle grid. That grid's size is n Γ— m. Let's denote the coordinate system on the grid. So, each point on the grid will have coordinates β€” a pair of integers (x, y) (0 ≀ x ≀ n, 0 ≀ y ≀ m).\n\nYour task ...
[{"type": "stdin_stdout", "input": "1000000000 1000001000 286536427 579261823 230782719 1150170645\n", "output": "209608854 195871608 363464000 962652038\n"}, {"type": "stdin_stdout", "input": "1000000000 1000000000 500000000 500000000 500000000 500000001\n", "output": "250000000 249999999 750000000 750000000\n"}, {"ty...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, y...
[{"type": "stdin_stdout", "input": "100 20 100 15061\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwwwhhwhwwhhwhwhwwwhwwwwhwhwwwwhwhhhwhwhwwh\n", "output": "100\n"}, {"type": "stdin_stdout", "input": "100 20 110 15061\nwwwwhhwhhwhhwhhhhhwwwhhhwwwhwwhwhhwwhhwwwhwwhwwwhwhwhwwhhhwwwhhwhwwhhwhwhwwwhwwwwhwhwwww...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one!\n\nWhy not make ...
[{"type": "stdin_stdout", "input": "010\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "011\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "001\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "20\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "15\n", "output": "4\n"}, {"type": "stdin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nProblem Statement\n\nNathan O. Davis is a student at the department of integrated systems.\n\nToday's agenda in the class is audio signal processing. Nathan was given a lot of homework out. One of the homework was to writ...
[{"type": "stdin_stdout", "input": "5\n1 x 0 4 x\n2\nx x\n2\n1 2\n2\n3 0\n2\n1000000000 x\n4\nx 4 1 x\n0", "output": "ambiguous\nnone\nambiguous\nnone\nambiguous\nambiguous\n"}, {"type": "stdin_stdout", "input": "5\n1 x 0 4 x\n2\nx x\n2\n1 2\n2\n3 0\n2\n0000000000 x\n4\nx 4 1 x\n0", "output": "ambiguous\nnone\nambiguou...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYour task is to write a program which reads a date (from 2004/1/1 to 2004/12/31) and prints the day of the date. Jan. 1, 2004, is Thursday. Note that 2004 is a leap year and we have Feb. 29.\n\n\n\nInput\n\nThe input is a...
[{"type": "stdin_stdout", "input": "6 2\n12 8\n0 0", "output": "Wednesday\nWednesday\n"}, {"type": "stdin_stdout", "input": "4 1\n2 18\n0 0", "output": "Thursday\nWednesday\n"}, {"type": "stdin_stdout", "input": "6 2\n7 17\n0 0", "output": "Wednesday\nSaturday\n"}, {"type": "stdin_stdout", "input": "1 1\n5 19\n0 0", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPetya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.\n\...
[{"type": "stdin_stdout", "input": "614586850 1000000000\n", "output": "1110059271353421796\n"}, {"type": "stdin_stdout", "input": "190535551 1000000000\n", "output": "1340487604111893304\n"}, {"type": "stdin_stdout", "input": "614586850 1000001000\n", "output": "1110063715797865796\n"}, {"type": "stdin_stdout", "input...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA: Alphabet block\n\nWakana Nakawa loves palindromes. Because my name is also a palindrome.\n\nWakana got a set with some alphabet blocks. An alphabet block is a block in which one lowercase alphabet is written for each b...
[{"type": "stdin_stdout", "input": "gcpc", "output": "1\n"}, {"type": "stdin_stdout", "input": "bgnc", "output": "2\n"}, {"type": "stdin_stdout", "input": "gcoc", "output": "1\n"}, {"type": "stdin_stdout", "input": "gcnc", "output": "1\n"}, {"type": "stdin_stdout", "input": "cgnc", "output": "1\n"}, {"type": "stdin_std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nWord $s$ of length $n$ is called $k$-complete if $s$ is a palindrome, i.e. $s_i=s_{n+1-i}$ for all $1 \\le i \\le n$; $s$ has a period of $k$, i.e. $s_i=s_{k+i}$ for all $1 \\le i \\le n-k$. \n\nFor example, \"abaaba\"...
[{"type": "stdin_stdout", "input": "4\n6 2\nabaaba\n6 3\nabaaba\n36 9\nhippopotomonstrosesquippedaliophobia\n21 7\nwudixiaoxingxingheclp\n", "output": "2\n0\n23\n16\n"}, {"type": "stdin_stdout", "input": "4\n6 2\nabaaba\n6 3\nabaaba\n36 9\nhippopotononstrosesquippedaliophobia\n21 7\nwudixiaoxingxingheclp\n", "output": ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nThere are N students living in the dormitory of Berland State University. Each of them sometimes wants to use the kitchen, so the head of t...
[{"type": "stdin_stdout", "input": "2\n3\n1 10 16\n1 27 3\n3\n19 20 30\n15 10 20", "output": "2\n1\n"}, {"type": "stdin_stdout", "input": "2\n3\n1 10 15\n1 10 3\n3\n19 20 30\n15 5 20", "output": "2\n1\n"}, {"type": "stdin_stdout", "input": "2\n3\n1 10 29\n1 10 3\n2\n17 39 30\n15 5 20", "output": "2\n2\n"}, {"type": "st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N children, numbered 1, 2, ..., N.\n\nSnuke has decided to distribute x sweets among them. He needs to give out all the x sweets, but some of the children may get zero sweets.\n\nFor each i (1 \\leq i \\leq N), ...
[{"type": "stdin_stdout", "input": "4 1111\n-1 2 110 1000", "output": "4\n"}, {"type": "stdin_stdout", "input": "4 1111\n1 5 100 1000", "output": "3\n"}, {"type": "stdin_stdout", "input": "4 1101\n1 5 100 1000", "output": "3\n"}, {"type": "stdin_stdout", "input": "4 1101\n0 5 100 1000", "output": "3\n"}, {"type": "stdi...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEach day in Berland consists of $n$ hours. Polycarp likes time management. That's why he has a fixed schedule for each day β€” it is a sequence $a_1, a_2, \\dots, a_n$ (each $a_i$ is either $0$ or $1$), where $a_i=0$ if Pol...
[{"type": "stdin_stdout", "input": "23\n1 1 1 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "23\n1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "23\n1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1\n", "output": "2\n"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA prime number is an integer that is greater than 1 and can only be divided by itself or 1. For example, 2 is a prime number because it is divisible only by 2 and 1, but 12 is not a prime number because it is divisible by...
[{"type": "stdin_stdout", "input": "19\n10887", "output": "17 23\n10883 10889\n"}, {"type": "stdin_stdout", "input": "19\n17073", "output": "17 23\n17053 17077\n"}, {"type": "stdin_stdout", "input": "19\n30085", "output": "17 23\n30071 30089\n"}, {"type": "stdin_stdout", "input": "19\n21592", "output": "17 23\n21589 21...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nOne day alice and bob were playing with their old toys , they had moved all the rakes and drawers to in the pursuit of their childhood toys.\nFinally they found bunch of cubes ,with letters and digits written on it ,whic...
[{"type": "stdin_stdout", "input": "cosmoscosmoscosmoscosmoscosmos 30\no 2 h a v e\ng 3 c o o k\ns 3 i e s 5\no 2 h a v e\ng 3 c s o k\ns 3 i e m 5\no 2 h a v e\ng 3 c o o k\ns 3 i e s 5\no 2 h a v e\ng 3 c s o k\ns 3 i e m 5\no 2 h a v e\ng 3 c o o k\ns 3 i e s 5\no 2 h a v e\ng 3 c s o k\ns 3 i e m 5\no 2 h a v e\ng ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nJoisino wants to evaluate the formula \"A op B\".\nHere, A and B are integers, and the binary operator op is either + or -.\nYour task is to evaluate the formula instead of her.\n\n-----Constraints-----\n - 1≦A,B≦10^9\n -...
[{"type": "stdin_stdout", "input": "-1 - 182", "output": "-183\n"}, {"type": "stdin_stdout", "input": "6 - 131", "output": "-125\n"}, {"type": "stdin_stdout", "input": "5 - 118", "output": "-113\n"}, {"type": "stdin_stdout", "input": "-1 + 112", "output": "111\n"}, {"type": "stdin_stdout", "input": "-1 - 15", "output":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are N rabbits on a number line. The rabbits are conveniently numbered 1 through N. The coordinate of the initial position of rabbit i is x_i.\n\nThe rabbits will now take exercise on the number line, by performing s...
[{"type": "stdin_stdout", "input": "5\n0 1 3 6 10\n3 10\n2 3 4", "output": "0.0\n3.0\n7.0\n8.0\n10.0"}, {"type": "stdin_stdout", "input": "5\n-1 1 3 -1 17\n3 10\n4 4 3", "output": "-1\n1\n3\n-1\n17\n"}, {"type": "stdin_stdout", "input": "5\n-1 -1 2 1 10\n3 10\n2 3 4", "output": "-1\n-2\n7\n7\n10\n"}, {"type": "stdin_st...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nFangy the little walrus, as all the modern walruses, loves to communicate via text messaging. One day he faced the following problem: When he sends large texts, they are split into parts each containing n characters (whic...
[{"type": "stdin_stdout", "input": "123\nOjg CVJm qfE RnHislFds nNKKt TCPLWukqNGAsVBplYbTfq? VeYKjfFGTzXWA ydpVZLIImNub yApKnAHv iXQmqv GjQvxrnAgtfTApiQyCKtg. GdmapGwvI udRqxTbnzgnOUNZx slAuEuLGCJycZJvtCczQ vommS xuuT eIK! DOJeFEaubbz HYLGlIIlNKfyaJQKVN eFNnUvKKCQLXvGhwX gjmRscMkedELUlHq? aTbyMGB EofzX wcAEjyRQpxghWvXh...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Petya likes permutations a lot. Recently his mom has presented him permutation q1, q2, ..., qn of length n.\n\nA permutation a of length n is a sequence of integers a1, a2, ..., an (1 ≀ ai ≀ n), all integers there ...
[{"type": "stdin_stdout", "input": "55 28\n35 33 46 8 11 13 14 26 42 38 1 7 34 5 2 21 17 45 54 43 4 18 27 50 25 10 29 48 6 16 22 28 55 53 49 41 39 23 40 47 51 37 36 19 9 32 52 12 24 3 20 15 30 44 31\n5 52 24 16 7 27 48 21 18 8 14 28 29 12 47 53 17 31 54 41 30 55 10 35 25 4 38 46 23 34 33 3 15 6 11 20 9 26 42 37 43 45 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLet's denote correct match equation (we will denote it as CME) an equation $a + b = c$ there all integers $a$, $b$ and $c$ are greater than zero.\n\nFor example, equations $2 + 2 = 4$ (||+||=||||) and $1 + 2 = 3$ (|+||=||...
[{"type": "stdin_stdout", "input": "100\n928\n970\n950\n921\n1007\n974\n353\n999\n964\n920\n926\n942\n934\n918\n930\n901\n977\n961\n978\n962\n951\n909\n994\n953\n946\n993\n982\n922\n1789\n932\n904\n910\n991\n937\n963\n988\n278\n903\n956\n976\n967\n958\n902\n986\n960\n965\n940\n914\n955\n987\n952\n971\n939\n966\n938\n91...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis is the hard version of this problem. The only difference is the constraint on $k$ β€” the number of gifts in the offer. In this version: $2 \\le k \\le n$.\n\nVasya came to the store to buy goods for his friends for th...
[{"type": "stdin_stdout", "input": "8\n5 6 2\n2 4 3 5 12\n5 5 2\n2 4 3 5 10\n3 1 1\n4 2 6\n5 2 5\n10 1 3 9 2\n2 10000 2\n10000 10000\n2 9999 2\n10000 10000\n4 6 4\n3 2 2 2\n5 5 3\n1 2 2 1 2\n", "output": "3\n2\n0\n1\n2\n0\n4\n5\n"}, {"type": "stdin_stdout", "input": "8\n5 6 2\n2 4 3 5 12\n5 5 2\n2 4 1 5 10\n3 1 1\n4 2 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nDetermine whether a text T includes a pattern P. Your program should answer for given queries consisting of P_i.\n\nConstraints\n\n* 1 ≀ length of T ≀ 1000000\n* 1 ≀ length of P_i ≀ 1000\n* 1 ≀ Q ≀ 10000\n* The input cons...
[{"type": "stdin_stdout", "input": "aabaaa\n4\nab\nba\nbb\nxyz", "output": "1\n1\n0\n0\n"}, {"type": "stdin_stdout", "input": "aabaaa\n4\nab\nba\nba\nxyz", "output": "1\n1\n1\n0\n"}, {"type": "stdin_stdout", "input": "aabaaa\n4\nba\nbb\nac\nzyx", "output": "1\n0\n0\n0\n"}, {"type": "stdin_stdout", "input": "aabaaa\n4\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRecently, chef Ciel often hears about lucky numbers.\n\nEverybody knows that lucky numbers are positive integers\nwhose decimal representation contains only the lucky digits 4 and 7.\nFor example, numbers 47, 744, 4 are l...
[{"type": "stdin_stdout", "input": "6\nklin 18\nCiel's Drink 174\nThe curry 2nd edition 677505\necis omelet 85855\nunagi 1\n She firsu amd last letters can eb a space 253", "output": "0\n"}, {"type": "stdin_stdout", "input": "6\nklin 18\nCiel's Drink 133\nThe curry 2nd edition 888888\necir omelet 85855\nunagi 1...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Petya likes to play very much. And most of all he likes to play the following game:\n\nHe is given a sequence of N integer numbers. At each step it is allowed to increase the value of any number by 1 or to decrease...
[{"type": "stdin_stdout", "input": "7\n1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000\n", "output": "6000000000\n"}, {"type": "stdin_stdout", "input": "7\n1000000000 -447358682 1000000000 -1000000000 1000000000 -1000000000 1000000000\n", "output": "5447358682\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLast year Bob earned by selling memory sticks. During each of n days of his work one of the two following events took place: \n\n * A customer came to Bob and asked to sell him a 2x MB memory stick. If Bob had such a sti...
[{"type": "stdin_stdout", "input": "50\nwin 596\nwin 1799\nwin 1462\nsell 460\nwin 731\nwin 723\nwin 731\nwin 329\nwin 838\nsell 728\nwin 728\nwin 460\nwin 723\nwin 1462\nwin 1462\nwin 460\nwin 329\nwin 1462\nwin 460\nwin 460\nwin 723\nwin 731\nwin 723\nwin 596\nwin 731\nwin 596\nwin 329\nwin 728\nwin 715\nwin 329\nwin...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTwilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.\n...
[{"type": "stdin_stdout", "input": "100001 100000\n", "output": "100000.41802404786\n"}, {"type": "stdin_stdout", "input": "50000 100000\n", "output": "49999.843487110797\n"}, {"type": "stdin_stdout", "input": "99999 100000\n", "output": "99998.418042461126\n"}, {"type": "stdin_stdout", "input": "100000 100000\n", "out...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThe Little Elephant from the Zoo of Lviv likes listening to music.\nThere are N songs, numbered from 1 to N, in his MP3-player. The song i is described by a pair of integers B_{i} and L_{i} - the band (represented as inte...
[{"type": "stdin_stdout", "input": "2\n3\n1 1\n2 2\n-1 2\n3\n1 3\n1 3\n4 2", "output": "11\n14\n"}, {"type": "stdin_stdout", "input": "2\n3\n1 1\n2 3\n-1 2\n3\n0 3\n1 3\n4 2", "output": "14\n17\n"}, {"type": "stdin_stdout", "input": "2\n3\n1 3\n2 3\n4 2\n3\n2 1\n1 2\n2 11", "output": "17\n27\n"}, {"type": "stdin_stdout...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus is an amateur programmer. Now he is analyzing a friend's program. He has already found there the function rangeIncrement(l, r), that adds 1 to each element of some array a for all indexes in the segment [l, r]....
[{"type": "stdin_stdout", "input": "20\n5 9 11 12 13 13 13 13 13 13 13 13 13 6 12 11 11 8 6 4\n", "output": "19\n5 13\n4 13\n3 13\n3 13\n2 13\n2 13\n2 13\n15 15\n15 17\n15 17\n15 17\n15 18\n15 18\n2 19\n1 19\n1 20\n1 20\n1 20\n1 20\n"}, {"type": "stdin_stdout", "input": "20\n5 9 11 12 13 13 13 13 13 13 13 13 13 6 12 11...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given an integer $n$. You have to calculate the number of binary (consisting of characters 0 and/or 1) strings $s$ meeting the following constraints.\n\nFor every pair of integers $(i, j)$ such that $1 \\le i \\le...
[{"type": "stdin_stdout", "input": "20\n1 1 2 0 0 2 0 2 2 2 0 0 2 2 2 0 2 0 0 0\n0 0 0 0 0 0 0 0 0 2 0 2 0 0 0 2 0 0 0\n0 1 2 0 2 2 2 2 0 0 2 0 2 2 0 2 2 2\n1 2 2 2 2 2 2 2 0 2 2 2 0 2 2 2 2\n0 2 0 0 2 2 2 0 2 2 0 0 2 0 0 0\n1 1 1 0 2 0 0 0 0 0 2 0 2 0 2\n1 0 1 2 2 2 0 0 2 0 0 0 2 0\n0 1 2 0 0 0 0 0 0 0 0 2 0\n0 0 0 0 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has got a magic matrix a of size n Γ— m. The rows of the matrix are numbered from 1 to n from top to bottom, the columns are numbered from 1 to m from left to right. Let a_{ij} be the element in the intersection of t...
[{"type": "stdin_stdout", "input": "13 8\n3 2 1 4 8 2 5 9\n8 2 10 8 9 3 2 8\n3 6 8 3 11 7 6 4\n4 2 10 5 7 5 1 3\n10 9 3 6 4 10 10 2\n10 3 7 1 4 5 7 10\n5 3 1 6 1 10 3 6\n10 7 6 8 1 8 4 1\n7 8 1 10 8 5 3 6\n3 8 10 6 7 6 5 5\n1 5 9 8 4 8 5 10\n6 9 10 7 5 10 5 4\n3 9 2 4 8 2 5 4\n8 1\n", "output": "140693813\n"}, {"type":...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTo satisfy his love of matching socks, Phoenix has brought his $n$ socks ($n$ is even) to the sock store. Each of his socks has a color $c_i$ and is either a left sock or right sock.\n\nPhoenix can pay one dollar to the s...
[{"type": "stdin_stdout", "input": "4\n6 3 3\n1 2 3 2 2 2\n6 2 4\n1 1 2 2 2 2\n6 5 1\n6 5 4 3 2 1\n4 0 4\n4 4 4 3\n", "output": "\n2\n3\n5\n3\n"}, {"type": "stdin_stdout", "input": "4\n6 3 3\n1 2 3 2 2 2\n6 2 4\n1 1 2 2 2 2\n6 5 1\n6 5 4 3 2 1\n4 0 4\n4 4 4 3\n", "output": "2\n3\n5\n3\n"}, {"type": "stdin_stdout", "inp...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn the good old Hachioji railroad station located in the west of Tokyo, there are several parking lines, and lots of freight trains come and go every day.\n\nAll freight trains travel at night, so these trains containing ...
[{"type": "stdin_stdout", "input": "3 5\n0W 1W\n0W 2W\n0W 2E\n0E 1E\n1E 2E\naabbcdcee\n-\n-\n-\n-\nbbaadeecc\n3 3\n0E 1W\n1E 2W\n2E 0W\naabb\nbbcc\naa\nbbbb\ncc\naaaa\n3 4\n0E 1W\n0E 2E\n1E 2W\n2E 0W\nababab\n-\n-\naaabbb\n-\n-\n0 0", "output": "5\n2\n5\n"}, {"type": "stdin_stdout", "input": "3 5\n0W 1W\n0W 2W\n0W 2E\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nPolycarpus got an internship in one well-known social network. His test task is to count the number of unique users who have visited a social network during the day. Polycarpus was provided with information on all user re...
[{"type": "stdin_stdout", "input": "10 3 30000\n00:06:54\n00:42:06\n03:49:45\n04:38:35\n05:33:30\n05:51:46\n10:46:34\n14:34:59\n14:40:06\n14:53:13\n", "output": "6\n1\n2\n3\n3\n3\n3\n4\n5\n6\n6\n"}, {"type": "stdin_stdout", "input": "10 3 30000\n00:06:54\n00:42:06\n03:49:45\n04:38:35\n05:33:30\n05:51:56\n10:46:34\n14:3...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has decided to make a Christmas Tree for the Christmas party in AtCoder, Inc.\n\nA Christmas Tree is a tree with N vertices numbered 1 through N and N-1 edges, whose i-th edge (1\\leq i\\leq N-1) connects Vertex...
[{"type": "stdin_stdout", "input": "10\n1 2\n1 3\n1 4\n2 5\n6 10\n6 7\n7 8\n4 9\n10 5", "output": "2 6\n"}, {"type": "stdin_stdout", "input": "10\n1 2\n1 3\n3 4\n2 5\n6 5\n6 7\n7 8\n5 9\n10 5", "output": "2 5\n"}, {"type": "stdin_stdout", "input": "10\n1 2\n1 3\n3 4\n2 5\n7 5\n6 7\n7 8\n5 9\n10 5", "output": "3 5\n"}, ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nSasha likes programming. Once, during a very long contest, Sasha decided that he was a bit tired and needed to relax. So he did. But since Sasha isn't an ordinary guy, he prefers to relax unusually. During leisure time Sa...
[{"type": "stdin_stdout", "input": "2\n114243 620721\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n182166 620721\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n182166 383547\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n60202 951227\n", "output": "0\n"}, {"type": "stdin_stdout",...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nInnokenty is a president of a new football league in Byteland. The first task he should do is to assign short names to all clubs to be shown on TV next to the score. Of course, the short names should be distinct, and Inno...
[{"type": "stdin_stdout", "input": "10\nIJGDI KHB\nHBI CKKCG\nFHE GCAA\nEDCGH HHICE\nGFH AIHD\nHED KIK\nDCK BCFIJ\nFFIHE FDB\nJGB AKKI\nIJD CAG\n", "output": "YES\nIJG\nHBI\nFHE\nEDC\nGFH\nHED\nDCK\nFFI\nJGB\nIJD\n"}, {"type": "stdin_stdout", "input": "10\nIJGDI KHB\nHBI CKKCG\nFHE GCAA\nEDCGH HHICE\nGFH AIHD\nHED KIK\...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nShort Phrase\n\nA Short Phrase (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following conditi...
[{"type": "stdin_stdout", "input": "9\ndo\nhte\nbest\nand\nenjoy\ntoday\nat\nacm\nicpc\n14\noh\nyes\nby\nfar\nit\nis\nwow\nso\nbad\nto\nme\nyou\nknow\nhey\n15\nabcde\nfghijkl\nmnopq\nrstuvwx\nyzz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\nabcde\nfghijkl\nmnopq\nrstuvwx\nyz\n0", "output": "1\n2\n6\n"}, {"type": "stdin_stdout"...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou will receive 5 points for solving this problem.\n\nManao has invented a new operation on strings that is called folding. Each fold happens between a pair of consecutive letters and places the second part of the string...
[{"type": "stdin_stdout", "input": "LEHLLLLLLHAFGEGLLHAFDLHHLLLLLDGGEHGGHLLLLLLLLDFLCBLLEFLLCBLLCGLEDLGGLECLDGLEHLLLGELLLEGLLLLGDLLLDALD\n", "output": "49\n"}, {"type": "stdin_stdout", "input": "LEHLLLLLLHAFGEGLLHAFDLHHMLLLLDGGEHGGHLLLLLLLLDFLCBLLEFLLCBLLCGLEDLGGLECLDGLEHLLLGELLLEGLLLLGDLLLDALD\n", "output": "47\n"}, {...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nTakahashi has an N \\times M grid, with N horizontal rows and M vertical columns. Determine if we can place A 1 \\times 2 tiles (1 vertical, 2 horizontal) and B 2 \\times 1 tiles (2 vertical, 1 horizontal) satisfying the ...
[{"type": "stdin_stdout", "input": "44 6 13 3", "output": "YES\n^^^<>.\nvvv<>.\n<><><>\n<><><>\n<><><>\n<><>..\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n......\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a n Γ— m field consisting only of periods ('.') and asterisks ('*'). Your task is to count all right triangles with two sides parallel to the square sides, whose vertices are in the centers of '*'-cells. A ri...
[{"type": "stdin_stdout", "input": "14 29\n**.*************..*.*********\n**..****.*********.**.*.****.\n********.**..*..*...*....**..\n****.**.***.*.***..*..***.*..\n***.****.***..*.***.*.****.*.\n*.*..***.***********.*.*.****\n****.*.***.*..****.**.**..***\n.*******..**...***.*.********\n*...**********...**...*.***.*...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given two integers $a$ and $m$. Calculate the number of integers $x$ such that $0 \\le x < m$ and $\\gcd(a, m) = \\gcd(a + x, m)$.\n\nNote: $\\gcd(a, b)$ is the greatest common divisor of $a$ and $b$.\n\n\n-----In...
[{"type": "stdin_stdout", "input": "10\n164 252\n94 226\n38 254\n196 255\n35 256\n174 257\n251 495\n246 527\n9 260\n149 261\n", "output": "36\n112\n126\n128\n128\n256\n240\n480\n96\n168\n"}, {"type": "stdin_stdout", "input": "10\n164 252\n94 253\n171 254\n196 255\n35 256\n174 257\n251 258\n239 259\n9 260\n98 261\n", "o...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nMelody Pond was stolen from her parents as a newborn baby by Madame Kovarian, to become a weapon of the Silence in their crusade against the Doctor. Madame Kovarian changed Melody's name to River Song, giving her a new id...
[{"type": "stdin_stdout", "input": "1219679533107\n", "output": "1 609839766552\n"}, {"type": "stdin_stdout", "input": "1044191868535\n", "output": "1 522095934266\n"}, {"type": "stdin_stdout", "input": "1041721920937\n", "output": "1 520860960467\n"}, {"type": "stdin_stdout", "input": "1025662663437\n", "output": "1 5...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThis problem is different with hard version only by constraints on total answers length\n\nIt is an interactive problem\n\nVenya joined a tour to the madhouse, in which orderlies play with patients the following game. Ord...
[{"type": "stdin_stdout", "input": "100\noooooooooooooooooooooooooooooooooooooooooooooooooovvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvwvvvvvvvvvvvvvvvv\n", "output": "? 1 100\n? 1 99\n! 8aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"}, {"type": "stdin_stdout", "input": "100...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nEveryone knows that computers become faster and faster. Recently Berland scientists have built a machine that can move itself back in time!\n\nMore specifically, it works as follows. It has an infinite grid and a robot wh...
[{"type": "stdin_stdout", "input": "2\n236675740 1140949963\n555555555 555555555\n", "output": "ds10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdtedslss10utsusdteds...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nA camera you have accidentally left in a desert has taken an interesting photo. The photo has a resolution of n pixels width, and each column of this photo is all white or all black. Thus, we can represent the photo as a ...
[{"type": "stdin_stdout", "input": "100\n1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "100\n1 1 1 1 0 0 0 0...
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\nOn his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It contains n different items numbered from 1 to n. The i-th item has...
[{"type": "stdin_stdout", "input": "90 61394040\n2480 6212 4506 829 8191 797 5336 6722 3178 1007 5849 3061 3588 6684 5983 5452 7654 5321 660 2569 2809 2179 679 4858 6887 2580 6880 6120 4159 5542 4999 8703 2386 8221 7046 1229 1662 4542 7089 3548 4298 1973 1854 2473 5507 241 359 5248 7907 5201 9624 4596 1723 2622 4800 47...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nThere are many anime that are about \"love triangles\": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to...
[{"type": "stdin_stdout", "input": "28567 13\n28079 24675 1\n18409 26720 1\n980 10815 1\n20794 16571 1\n7376 19861 1\n10805 706 1\n4255 16391 1\n27376 18263 1\n10019 28444 1\n6574 28053 1\n5036 16610 1\n3543 7122 1\n512 9554 1\n", "output": "928433852\n"}, {"type": "stdin_stdout", "input": "28567 13\n28079 24675 1\n184...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nLittle Petya loves looking for numbers' divisors. One day Petya came across the following problem:\n\nYou are given n queries in the form \"xi yi\". For each query Petya should count how many divisors of number xi divide ...
[{"type": "stdin_stdout", "input": "20\n68260 0\n819 1\n54174 1\n20460 1\n25696 2\n81647 4\n17736 4\n91307 5\n5210 4\n87730 2\n4653 8\n11044 6\n15776 4\n17068 7\n73738 7\n36004 12\n83183 7\n75700 12\n84270 14\n16120 5\n", "output": "12\n11\n6\n44\n18\n1\n9\n7\n6\n12\n8\n8\n21\n3\n14\n3\n3\n13\n18\n26\n"}, {"type": "std...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nRead problems statements in Mandarin Chinese and Russian. \n\nOnce Chef decided to divide the tangerine into several parts. At first, he numbered tangerine's segments from 1 to n in the clockwise order starting from some...
[{"type": "stdin_stdout", "input": "2\n10 3 2\n1 5\n5 5\n6 10\n1 5\n6 10\n10 3 0\n4 5\n10 1\n12 18\n1 10", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "2\n10 3 2\n1 5\n5 5\n6 10\n1 5\n6 10\n10 3 0\n4 5\n10 1\n12 9\n1 10", "output": "Yes\nYes\n"}, {"type": "stdin_stdout", "input": "2\n10 3 2\n1 4\n10 5\n6...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nVasya has a beautiful garden where wonderful fruit trees grow and yield fantastic harvest every year. But lately thieves started to sneak into the garden at nights and steal the fruit too often. Vasya can’t spend the nigh...
[{"type": "stdin_stdout", "input": "10 10\n1 0 1 1 1 1 1 1 1 1\n1 1 1 0 1 1 0 1 1 1\n1 0 1 0 1 1 1 1 0 1\n1 1 0 1 1 1 0 0 0 1\n0 1 0 1 1 1 0 1 1 1\n1 0 1 0 1 0 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 0 1 1\n1 1 1 1 0 1 1 1 1 1\n0 1 1 1 1 0 1 1 0 1\n10 10\n", "output": "79\n"}, {"type": "stdin_stdout", "input": "10 ...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nYou are given a string $s$ of length $n$, which consists only of the first $k$ letters of the Latin alphabet. All letters in string $s$ are uppercase.\n\nA subsequence of string $s$ is a string that can be derived from $s...
[{"type": "stdin_stdout", "input": "76 26\nABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXY\n", "output": "26\n"}, {"type": "stdin_stdout", "input": "76 26\nABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXY\n", "output": "26"}, {"type": "stdin_stdout", "input": "22...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nIn Morse code, an letter of English alphabet is represented as a string of some length from $1$ to $4$. Moreover, each Morse code representation of an English letter contains only dots and dashes. In this task, we will re...
[{"type": "stdin_stdout", "input": "100\n1\n0\n0\n1\n0\n0\n1\n1\n0\n0\n1\n0\n0\n0\n0\n0\n1\n1\n0\n0\n0\n1\n1\n1\n1\n0\n0\n1\n1\n0\n1\n1\n0\n1\n1\n1\n1\n0\n0\n0\n0\n0\n0\n1\n1\n0\n0\n1\n1\n1\n1\n0\n1\n0\n0\n0\n1\n0\n0\n1\n0\n1\n1\n1\n1\n1\n0\n1\n0\n0\n1\n1\n0\n0\n1\n0\n0\n1\n1\n0\n0\n0\n1\n0\n0\n0\n0\n0\n0\n1\n1\n0\n0\n...
code_stdio
[ { "content": "Solve the following coding problem using the programming language python:\n\nCreate a program that reads the attendance numbers of students in a class and the data that stores the ABO blood group and outputs the number of people for each blood type. There are four types of ABO blood types: A, B, A...
[{"type": "stdin_stdout", "input": "1,B\n2,A\n3,B\n4,AB\n5,B\n5,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A", "output": "5\n4\n3\n2\n"}, {"type": "stdin_stdout", "input": "1,B\n2,B\n3,B\n4,AB\n5,B\n6,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A", "output": "4\n5\n3\n2\n"}, {"type": "stdin_stdout", "input": "1,...
code_stdio