messages
listlengths
1
1
ground_truth
stringlengths
156
726k
dataset
stringclasses
2 values
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThis problem is a complicated version of D1, but it has significant differences, so read the whole statement....
[{"input": "10\n10\n-30 45 -37 -11 25 61 97 7 7 35\n10\n48 -2 13 88 97 -27 40 88 41 -67\n10\n-13 -31 94 -43 19 95 -35 5 41 10\n10\n-28 -88 17 17 2 -43 -73 -73 -13 2\n10\n46 -73 47 54 -13 67 7 -33 1 -33\n10\n60 92 -100 -76 -12 -52 4 84 -38 36\n10\n50 62 56 -58 -10 87 29 52 14 -22\n10\n-78 50 -52 -28 -6 -28 17 51 40 -30\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nHo ho! So you think you know integers, do you? Well then, young wizard, tell us what the Nth digit of the [Ch...
[{"input": "501337501337101", "output": "[3]", "fn_name": "champernowneDigit"}, {"input": "77199254740991", "output": "[7]", "fn_name": "champernowneDigit"}, {"input": "101800813569", "output": "[6]", "fn_name": "champernowneDigit"}, {"input": "1000599563", "output": "[1]", "fn_name": "champernowneDigit"}, {"input": "1...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe phantom thief \"Lupin IV\" is told by the beautiful \"Fujiko Mine\", a descendant of the Aizu clan, that ...
[{"input": "5\n13 199 1\n93 1000 1\n37 350 10\n27 300 2\n123 200 1100", "output": "93 37 27 13 123\n"}, {"input": "5\n11 199 0\n93 1000 1\n37 350 10\n27 300 2\n123 200 1100", "output": "93 37 27 11 123\n"}, {"input": "5\n11 91 0\n124 1000 1\n37 350 3\n12 300 2\n123 200 1111", "output": "124 37 12 11 123\n"}, {"input": ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nVasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its addre...
[{"input": "ftpprutpfrutrutptpfrutpfrutfrutrfrutpfrutprutruruu\n", "output": "ftp://p.ru/tpfrutrutptpfrutpfrutfrutrfrutpfrutprutruruu\n"}, {"input": "ftpprutufrutrutptpfrutpfrutfrutrfrutpfrptprutruruu\n", "output": "ftp://p.ru/tufrutrutptpfrutpfrutfrutrfrutpfrptprutruruu"}, {"input": "ftpprutufrutrutptpfrutpfrutfrutrfr...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nConsider the infinite sequence of integers: 1, 1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5.... The sequence is b...
[{"input": "100000000000000\n", "output": "1749820\n"}, {"input": "99999998250180\n", "output": "14142135\n"}, {"input": "99999998250180\n", "output": "14142135\n"}, {"input": "100000000000000\n", "output": "1749820\n"}, {"input": "1001000000000\n", "output": "1404260\n"}, {"input": "1001000001000\n", "output": "140526...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nMonocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space ...
[{"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000\n", "output": "1000000000000000000\n"}, {"input": "1000000000000000000 1000000000000000000 999999...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nGuy-Manuel and Thomas are going to build a polygon spaceship.\n\nYou're given a strictly convex (i. e. no thr...
[{"input": "8\n-440365664 -897818514\n107345267 -994221803\n248590739 -968608613\n473576011 -880752952\n105203574 994450706\n-164464580 1061907476\n-522092561 852888831\n-874210729 485546704\n", "output": "NO\n"}, {"input": "8\n-845415846 -897818514\n107345267 -994221803\n248590739 -968608613\n473576011 -880752952\n105...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nFind the union of two sets $A = \\\\{a_0, a_1, ..., a_{n-1}\\\\}$ and $B = \\\\{b_0, b_1, ..., b_{m-1}\\\\}$....
[{"input": "3\n2 4 15\n2\n11 64", "output": "2\n4\n11\n15\n64\n"}, {"input": "3\n-1 5 10\n2\n3 16", "output": "-1\n3\n5\n10\n16\n"}, {"input": "3\n-1 4 10\n2\n3 16", "output": "-1\n3\n4\n10\n16\n"}, {"input": "3\n-1 4 10\n2\n5 16", "output": "-1\n4\n5\n10\n16\n"}, {"input": "3\n2 9 15\n2\n7 11", "output": "2\n7\n9\n11\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLunar New Year is approaching, and you bought a matrix with lots of \"crosses\".\n\nThis matrix $M$ of size $...
[{"input": "14\nXXX.XXXXX..X.X\nX..XX..X...X..\n.....X.XX..XXX\n.X..X..XXX.XX.\n...XXXX.XX..XX\n.X..XX...XXX..\nXX.XX.XX..XXX.\n.X..X.....X.XX\n...XXX...XX.XX\nXXX.XX.XX.X.XX\nX.XXXX..XX.XX.\n.X.XX....X....\nX..XX..X.XX.X.\n..X...XX....XX\n", "output": "2\n"}, {"input": "14\nXXX.XXXXX..X.X\nX..XX..X...X..\n.....X.XX..X...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nPetya has an array of integers a_1, a_2, …, a_n. He only likes sorted arrays. Unfortunately, the given array ...
[{"input": "7\n1\n1\n2\n2 2\n2\n2 2\n3\n1 2 3\n3\n1 1 1\n3\n3 1 2\n4\n2 1 4 3\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "7\n1\n1\n2\n1 2\n2\n1 1\n3\n1 2 3\n3\n2 1 1\n3\n3 1 1\n4\n4 1 4 3\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nYES\n"}, {"input": "7\n1\n1\n2\n1 2\n2\n1 1\n3\n1 3 3\n3\n2 1 1\n3...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given a picture consisting of $n$ rows and $m$ columns. Rows are numbered from $1$ to $n$ from the to...
[{"input": "9\n5 5\n..*..\n..*..\n*****\n..*..\n..*..\n3 4\n****\n.*..\n.*..\n4 3\n***\n*..\n*..\n*..\n5 5\n*****\n*.*.*\n*****\n..*.*\n..***\n1 4\n****\n5 5\n.....\n..*..\n.***.\n..*..\n.....\n5 3\n...\n.*.\n.*.\n***\n.*.\n3 3\n.*.\n*.*\n.*.\n4 4\n*.**\n....\n*.**\n*.**\n", "output": "0\n0\n0\n0\n0\n4\n1\n1\n2\n"}, {"...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nFor two permutations p and q of the integers from 1 through N, let f(p,q) be the permutation that satisfies t...
[{"input": "10 1000001000\n7 10 6 5 4 2 9 1 3 8\n4 1 9 2 3 7 8 10 6 5", "output": "8 4 6 5 2 7 9 10 1 3"}, {"input": "10 1001000001\n7 10 6 5 4 2 9 1 3 8\n4 1 9 2 3 7 8 10 6 5", "output": "4 8 10 6 9 2 1 3 5 7"}, {"input": "10 1000000001\n7 10 6 5 4 2 9 1 3 8\n4 1 9 2 3 7 8 10 6 5", "output": "10 3 7 6 4 8 2 1 5 9"}, {...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nProblem\n\nThere are coins with front and back sides and dice with rolls from $ 1 $ to $ N $. Gacho decided t...
[{"input": "12 110 467", "output": "469611202\n"}, {"input": "12 100 467", "output": "732809678\n"}, {"input": "12 13 187", "output": "455459798\n"}, {"input": "12 60 467", "output": "654858060\n"}, {"input": "13 31 187", "output": "681077066\n"}, {"input": "10 31 187", "output": "611384855\n"}, {"input": "6 13 187", "...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\n# Task\n\nThe game starts with `n` people standing in a circle. The presenter counts `m` people starting with...
[{"input": "75\n34", "output": "[[35, 4238]]", "fn_name": "find_last"}, {"input": "82\n49", "output": "[[48, 5091]]", "fn_name": "find_last"}, {"input": "73\n38", "output": "[[61, 3996]]", "fn_name": "find_last"}, {"input": "86\n71", "output": "[[10, 6275]]", "fn_name": "find_last"}, {"input": "61\n17", "output": "[[26...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nMad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he use...
[{"input": "115\n10\n10\n10\n10\n01\n01\n10\n10\n10\n01\n01\n10\n01\n01\n10\n10\n10\n01\n10\n01\n10\n10\n01\n01\n10\n10\n10\n10\n01\n10\n01\n01\n10\n10\n10\n10\n01\n10\n10\n10\n01\n10\n01\n10\n10\n10\n10\n01\n01\n01\n10\n10\n01\n01\n01\n10\n10\n01\n10\n01\n01\n01\n01\n10\n10\n01\n10\n01\n01\n01\n01\n01\n10\n01\n10\n10\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLet's introduce some definitions that will be needed later.\n\nLet $prime(x)$ be the set of prime divisors of...
[{"input": "1000000000 1000000000000000000\n", "output": "997440007\n"}, {"input": "1000000000 1000000000000000000\n", "output": "997440007\n"}, {"input": "1000000000 1000000000010000000\n", "output": "778038345\n"}, {"input": "1000001001 1000000000010000000\n", "output": "141474221\n"}, {"input": "732253291 1106035102...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAlice has just learned addition. However, she hasn't learned the concept of \"carrying\" fully — instead of c...
[{"input": "2\n352942581\n1100110000\n", "output": "192407906\n102030199\n"}, {"input": "2\n178886702\n1100110000\n", "output": "148360651\n102030199\n"}, {"input": "2\n139544809\n1100110000\n", "output": "69014088\n102030199\n"}, {"input": "2\n217736582\n1100110000\n", "output": "48387455\n102030199\n"}, {"input": "2\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nA: Union Ball\n\nProblem Statement\n\nThere are N balls in a box. The i-th ball is labeled with a positive in...
[{"input": "3\n17 1 12", "output": "1\n"}, {"input": "3\n17 0 12", "output": "2\n"}, {"input": "3\n12 2 2", "output": "0\n"}, {"input": "3\n12 1 2", "output": "2\n"}, {"input": "3\n10 2 2", "output": "0\n"}, {"input": "3\n19 2 2", "output": "2\n"}, {"input": "3\n17 1 4", "output": "1\n"}, {"input": "3\n17 0 4", "output...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are standing at the point $0$ on a coordinate line. Your goal is to reach the point $n$. In one minute, y...
[{"input": "10\n999999999\n999999990\n999999995\n999999951\n999999999\n999999990\n999999999\n999999992\n999999997\n999999999\n", "output": "333333333\n333333330\n333333332\n333333317\n333333333\n333333330\n333333333\n333333331\n333333333\n333333333\n"}, {"input": "1\n84123456\n", "output": "28041152\n"}, {"input": "1\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou can't possibly imagine how cold our friends are this winter in Nvodsk! Two of them play the following gam...
[{"input": "7938986881993\n", "output": "1\n378028993"}, {"input": "1477562914357\n", "output": "1\n41161181\n"}, {"input": "472670214391\n", "output": "1\n23020027"}, {"input": "1468526771489\n", "output": "1\n613783"}, {"input": "1245373417369\n", "output": "1\n908209"}, {"input": "365292057641\n", "output": "1\n1260...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nOn the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. O...
[{"input": "100 20\n.....G.#.#..................#.........##....#...................#.#..........#...#.#.T..#.......#...\n", "output": "YES\n"}, {"input": "100 33\nG..................................................................................................T\n", "output": "YES\n"}, {"input": "100 33\nG..............
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are preparing for an exam on scheduling theory. The exam will last for exactly T milliseconds and will co...
[{"input": "10 481\n6 25\n0 85\n8 96\n6 7\n1 16\n4 32\n2 5\n3 42\n9 126\n7 70\n", "output": "5\n5\n4 1 10 3 9"}, {"input": "10 481\n6 25\n0 85\n8 96\n6 7\n1 16\n4 32\n2 9\n3 42\n9 126\n7 70\n", "output": "5\n5\n4 1 10 3 9"}, {"input": "10 481\n6 25\n0 85\n8 96\n6 7\n1 16\n4 32\n2 0\n3 42\n9 126\n7 70\n", "output": "5\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nGiven time in 24-hour format, convert it to words. \n\n```\nFor example:\n13:00 = one o'clock \n13:09 = nine ...
[{"input": "\"23:31\"", "output": "[\"twenty nine minutes to midnight\"]", "fn_name": "solve"}, {"input": "\"11:31\"", "output": "[\"twenty nine minutes to twelve\"]", "fn_name": "solve"}, {"input": "\"13:29\"", "output": "[\"twenty nine minutes past one\"]", "fn_name": "solve"}, {"input": "\"00:08\"", "output": "[\"ei...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have ...
[{"input": "5\n99999997 999999998 999999998 999999999\n99999996 999999997 999999997 999999999\n99999997 999999998 999999998 999999999\n99999996 999999997 999999997 999999999\n99999997 999999998 999999998 999999999\n", "output": "899999999100000001\n449999999550000002\n899999999100000001\n449999999550000002\n89999999910...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nStudent A and student B are giving each other test answers during a test. \nThey don't want to be caught so ...
[{"input": "\"8 d9dx0962x8067d x 760x272690 d852757d59 d552820d52dx767d 0dxxxd995x0676x59d6x7760x0d7 02dd7558770x2d0760x85d8x709d0x590\"", "output": "[\"88x256960x8 027275x22xd6758dx7dd797272 07d00dd6d0066779x 95dd7056d0x095x6x5009 2xx08xx67d dx5d785268dxd97759x05579d 0d0\"]", "fn_name": "decipher_message"}, {"input...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given a forest with N vertices and M edges. The vertices are numbered 0 through N-1. The edges are gi...
[{"input": "7 -1\n1 2 3 4 5 6 0\n3 0\n4 0\n1 2\n1 3\n5 6", "output": "Impossible\n"}, {"input": "7 -1\n1 2 3 4 5 6 0\n3 0\n4 0\n1 2\n2 3\n5 6", "output": "Impossible\n"}, {"input": "7 -1\n1 2 3 4 5 6 0\n0 0\n4 0\n1 2\n2 3\n5 6", "output": "Impossible\n"}, {"input": "7 -1\n1 4 3 4 5 6 0\n0 0\n4 0\n1 2\n2 3\n5 6", "outpu...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nVasya is sitting on an extremely boring math class. To have fun, he took a piece of paper and wrote out n num...
[{"input": "200 100\n56988719755815575893282254081467698462485803782142631369385180999746639622554559884281193367342283559238834106917388166048020056852911293394377949964185368886333934084399980368238188117302968424219707\n", "output": "295455656\n"}, {"input": "200 100\n655255749193583406396355747768874383520958452063...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAn eviternity number is a number which:\n* contains only digits 8, 5 and 3, and \n* the count of the digit `8...
[{"input": "0\n100000", "output": "[103]", "fn_name": "solve"}, {"input": "0\n500000", "output": "[148]", "fn_name": "solve"}, {"input": "90\n139701", "output": "[99]", "fn_name": "solve"}, {"input": "61\n56976", "output": "[53]", "fn_name": "solve"}, {"input": "0\n10000", "output": "[37]", "fn_name": "solve"}, {"input...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nConnect the countless points with lines, till we reach the faraway yonder.\n\nThere are n points on a coordin...
[{"input": "20\n-975467170 758268840 -975467171 758268839 -975467172 758268838 -975467173 758268837 -975467174 1015089897 -975467175 758268835 -975467176 758268834 -975467177 967684266 -975467178 758268832 -975467179 1082851919\n", "output": "No\n"}, {"input": "20\n-975467170 758268840 -975467171 758268839 -975467172 7...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given a permutation $a$ consisting of $n$ numbers $1$, $2$, ..., $n$ (a permutation is an array in wh...
[{"input": "3\n4\n1 3 2 10\n3\n1 2 3\n5\n3 1 4 0 0\n", "output": "1\n0\n2\n"}, {"input": "3\n4\n1 3 2 7\n3\n1 2 3\n5\n2 1 4 5 -1\n", "output": "1\n0\n2\n"}, {"input": "3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3\n", "output": "\n1\n0\n2\n"}, {"input": "3\n4\n1 3 2 4\n3\n1 2 3\n5\n2 1 4 5 3\n", "output": "1\n0\n2\n"}, {"input...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAfter a successful field test, Heidi is considering deploying a trap along some Corridor, possibly not the fi...
[{"input": "10 26\n9 5 277429172\n10 8 789225932\n5 2 992601916\n9 8 277294258\n8 6 245446241\n6 2 439001127\n7 1 447891377\n10 6 699661758\n1 9 865851152\n2 8 299785854\n7 10 756200111\n8 3 431547893\n5 6 465205287\n7 4 957301499\n3 4 308491540\n3 7 252157788\n10 5 282875145\n1 8 262659451\n5 4 981921705\n2 4 16048245...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nОсновой любой социальной сети является отношение дружбы между двумя пользователями в том или ином смысле. В о...
[{"input": "10 50\n946010975 207263044\n923545573 749203275\n862015642 426425906\n749203275 839134958\n910721783 289091881\n827003531 333726912\n49704846 538788252\n382891592 207263044\n333726912 438209022\n974360048 49704846\n", "output": "49704846: 0\n207263044: 0\n289091881: 0\n333726912: 0\n382891592: 1 946010975\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nPolycarp has come up with a new game to play with you. He calls it \"A missing bigram\".\n\nA bigram of a wor...
[{"input": "4\n7\nab bb ba aa ba\n7\nab ba aa ab ba\n3\naa\n5\nbb ab bb\n", "output": "abbaaba\nabaabaa\naaa\nbbabb\n"}, {"input": "4\n7\nab bb ba aa ba\n7\nab ba aa ab ba\n3\naa\n5\nbb ab bb\n", "output": "abbaaba\nabaabaa\naaa\nbbabb\n"}, {"input": "4\n7\nab bb ba aa ba\n7\nab ba aa ab ab\n3\naa\n5\nbb ab bb\n", "out...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nChallenge:\nGiven two null-terminated strings in the arguments \"string\" and \"prefix\", determine if \"stri...
[{"input": "\"hello world!\"\n\"HELLO\"", "output": "[false]", "fn_name": "starts_with"}, {"input": "\"hello world!\"\n\"hello\"", "output": "[true]", "fn_name": "starts_with"}, {"input": "\"nowai\"\n\"nowaisir\"", "output": "[false]", "fn_name": "starts_with"}, {"input": "\"\"\n\"abc\"", "output": "[false]", "fn_name"...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAbsent-minded Masha got set of n cubes for her birthday.\n\nAt each of 6 faces of each cube, there is exactly...
[{"input": "3\n5 1 2 9 6 4\n9 0 6 4 2 8\n4 6 2 8 3 7\n", "output": "10\n"}, {"input": "3\n1 1 1 0 2 3\n4 5 6 7 8 9\n0 0 0 0 0 0\n", "output": "10\n"}, {"input": "3\n1 1 1 1 1 1\n0 2 3 4 5 6\n7 8 9 2 3 4\n", "output": "10\n"}, {"input": "3\n0 1 1 2 2 3\n4 5 6 7 8 9\n3 4 5 6 7 1\n", "output": "19\n"}, {"input": "3\n3 4 5...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nMeikyokan University is very famous for its research and education in the area of computer science. This univ...
[{"input": "8\n2\nomura\ntoshio\nraku\ntanaka\ninura\nyoshoi\nhayashi\nmiura\n3\n1\ntasaka\nnakata\ntanaka\n1\n1\nfoo\n5\n2\npsqt\nabcdef\nabzdefa\npqrst\nabdxcef\n0", "output": "inura,miura\ninura,omura\nmiura,omura\ntoshio,yoshoi\n4\ntanaka,tasaka\n1\n0\nabcdef,abdxcef\nabcdef,abzdefa\npqrst,psqt\n3\n"}, {"input": "8...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere are $n$ cities and $m$ roads in Berland. Each road connects a pair of cities. The roads in Berland are ...
[{"input": "39 40 38\n4 8\n24 28\n16 17\n7 25\n4 29\n34 35\n16 24\n21 10\n23 36\n36 14\n28 16\n34 19\n15 21\n22 38\n22 37\n37 27\n28 33\n3 29\n32 22\n12 30\n9 15\n5 19\n23 27\n19 17\n25 17\n24 11\n39 10\n6 20\n16 6\n3 18\n34 21\n15 38\n11 19\n11 3\n32 4\n15 13\n16 11\n11 7\n33 7\n3 33\n", "output": "12\n"}, {"input": "...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nIn 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important r...
[{"input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 6\n5 6\n6 3\n5 8\n1 16\n1 8\n2 14\n7 0\n11 9\n9 2\n0 0\n1 3\n3 4\n5 5\n4 2\n0 0", "output": "NG\nOK\n"}, {"input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 6\n5 6\n6 3\n5 8\n1 16\n3 8\n6 14\n7 0\n8 9\n9 2\n0 0\n1 3\n3 4\n5 5\n4 2\n0 0", "output": "NG\nOK\n"}, {"input": "1 3\n3 4\n3 5...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given two strings $s$ and $t$, each of length $n$ and consisting of lowercase Latin alphabets. You wa...
[{"input": "16\n3\naaa\naaa\n3\nabb\naab\n3\naab\nbaa\n3\naab\naba\n3\naca\naba\n3\naba\nbaa\n3\naba\naab\n3\nabb\nabb\n3\nabb\nbab\n3\nabb\nbba\n3\nabc\nabc\n3\ncba\nbad\n3\nabc\ndab\n3\nabc\nacb\n3\ncba\ncba\n3\nabc\nbca\n", "output": "0\n-1\n1\n1\n-1\n1\n1\n0\n1\n2\n0\n-1\n-1\n1\n0\n2\n"}, {"input": "16\n3\naaa\naaa...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nIn this kata, you should calculate type of triangle with three given sides ``a``, ``b`` and ``c`` (given in a...
[{"input": "100000\n100005\n111111", "output": "[1]", "fn_name": "triangle_type"}, {"input": "68000\n285000\n293000", "output": "[2]", "fn_name": "triangle_type"}, {"input": "122.14\n222.11\n250", "output": "[1]", "fn_name": "triangle_type"}, {"input": "8.625\n33.625\n32.5", "output": "[2]", "fn_name": "triangle_type"}...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nIn Math, an improper fraction is a fraction where the numerator (the top number) is greater than or equal to ...
[{"input": "\"-21511/21\"", "output": "[\"-1024 7/21\"]", "fn_name": "convert_to_mixed_numeral"}, {"input": "\"9999/24\"", "output": "[\"416 15/24\"]", "fn_name": "convert_to_mixed_numeral"}, {"input": "\"-504/26\"", "output": "[\"-19 10/26\"]", "fn_name": "convert_to_mixed_numeral"}, {"input": "\"74/30\"", "output": "...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nLittle Petya loves playing with squares. Mum bought him a square 2n × 2n in size. Petya marked a cell inside ...
[{"input": "100 100 100\n", "output": "YES\n"}, {"input": "100 110 100\n", "output": "YES\n"}, {"input": "110 110 100\n", "output": "YES\n"}, {"input": "110 110 110\n", "output": "YES\n"}, {"input": "110 110 101\n", "output": "YES\n"}, {"input": "110 111 101\n", "output": "YES\n"}, {"input": "010 111 101\n", "output": ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nA simple recommendation system would recommend a user things liked by a certain number of their friends. In t...
[{"input": "10 10 10\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\n", "output": "10\n"}, {"input": "10 10 10\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\nYYYYYYYYYY\n", "output": "1...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nDolphin loves programming contests. Today, he will take part in a contest in AtCoder.\n\nIn this country, 24-...
[{"input": "23 23\n", "output": "22\n"}, {"input": "405 14", "output": "11\n"}, {"input": "9 12\n", "output": "21\n"}, {"input": "19 0\n", "output": "19\n"}, {"input": "22 1\n", "output": "23\n"}, {"input": "3 12\n", "output": "15\n"}, {"input": "0 15\n", "output": "15\n"}, {"input": "17 -1", "output": "16\n"}, {"input...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nInput\n\nThe input contains two integers N, M (1 ≤ N ≤ 1024, 2 ≤ M ≤ 16), separated by a single space.\n\nOut...
[{"input": "33 16\n", "output": "\nYES\n"}, {"input": "11 11\n", "output": "YES\n"}, {"input": "12 16\n", "output": "YES\n"}, {"input": "11 20\n", "output": "YES\n"}, {"input": "15 11\n", "output": "YES\n"}, {"input": "26 11\n", "output": "YES\n"}, {"input": "12 26\n", "output": "YES\n"}, {"input": "13 11\n", "output":...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nDid you ever hear about 'crossing the bridge noodle' ? Let me tell you that it's not some kind of bridge made...
[{"input": "2\nQ 0\nP 14\n\n2\nO -1\nM -16\n\n0", "output": "13\n15\n"}, {"input": "2\nQ -1\nP 14\n\n2\nN -1\nM -3\n\n0", "output": "13\n2\n"}, {"input": "2\nQ -1\nP 8\n\n2\nM -1\nM -14\n\n0", "output": "7\n13\n"}, {"input": "2\nQ -1\nP 8\n\n2\nM -1\nM -13\n\n0", "output": "7\n12\n"}, {"input": "2\nQ 1\nP 7\n\n2\nO 0\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nIn computing, there are two primary byte order formats: big-endian and little-endian. Big-endian is used prim...
[{"input": "859983475894789589772983457982345896389458937589738945435\n1024", "output": "[10935879118170253467575045997837531765542549198363770264806105328514144954155675005294370560789173602325403413189569286370255297035043193807918631267898110032789194315444561922202783069416581989858234400991054570729329260875447493...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nTakahashi has two integers X and Y.\nHe computed X + Y and X - Y, and the results were A and B, respectively....
[{"input": "-100 -100\n", "output": "-100 0\n"}, {"input": "-100 100\n", "output": "0 -100\n"}, {"input": "-39 -69\n", "output": "-54 15\n"}, {"input": "100 -100\n", "output": "0 100\n"}, {"input": "-98 4\n", "output": "-47 -51\n"}, {"input": "-23 71\n", "output": "24 -47\n"}, {"input": "17 -95\n", "output": "-39 56\n"...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\n# The die is cast!\n\nYour task in this kata is to write a \"dice roller\" that interprets a subset of [dice ...
[{"input": "\"2d6+3 abc\"", "output": "[false]", "fn_name": "roll"}, {"input": "\"abc 2d6+3\"", "output": "[false]", "fn_name": "roll"}, {"input": "\"2d6++4\"", "output": "[false]", "fn_name": "roll"}, {"input": "\"abc\"", "output": "[false]", "fn_name": "roll"}, {"input": "\"\"", "output": "[false]", "fn_name": "roll"...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given an integer N. Find the number of strings of length N that satisfy the following conditions, mod...
[{"input": "100\n", "output": "388130742\n"}, {"input": "18\n", "output": "261943303\n"}, {"input": "26\n", "output": "858533109\n"}, {"input": "50\n", "output": "113468411\n"}, {"input": "90\n", "output": "252858375\n"}, {"input": "97\n", "output": "329869205\n"}, {"input": "98\n", "output": "616680192\n"}, {"input": ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nHarry is a bright student. To prepare thoroughly for exams, he completes all the exercises in his book! Now t...
[{"input": "6\n14 hrilgne\n6 mathematics\n-1 geography\n-1\n3 grcphias\n-1", "output": "0 mathematics\n0 hrilgne\n0 grcphias\n"}, {"input": "6\n9 english\n7 nathematics\n-1 geography\n-1\n3 gchpsias\n-1", "output": "0 nathematics\n0 english\n0 gchpsias\n"}, {"input": "6\n1 hsilgne\n-1 lathematics\n14 georgaphy\n-1\n2 s...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nArkady invited Anna for a dinner to a sushi restaurant. The restaurant is a bit unusual: it offers $n$ pieces...
[{"input": "100\n2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "54\n"}, {"input": "100\n1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2 2 2 2 2 1 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given three integers $a \\le b \\le c$.\n\nIn one move, you can add $+1$ or $-1$ to any of these inte...
[{"input": "10\n3351 6383 6479\n7051 9793 9929\n1 1061 9572\n5401 5401 5865\n9777 9987 9987\n3393 7229 9665\n8014 8533 8665\n9549 9917 9998\n3336 6686 9962\n5351 8201 9241\n", "output": "208\n3239 6478 6478\n2223\n4964 9928 9928\n7\n1 1063 9567\n464\n5401 5401 5401\n210\n9987 9987 9987\n2608\n3221 9663 9663\n651\n8533 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nFind the minimum area of a square land on which you can place two identical rectangular $a \\times b$ houses....
[{"input": "8\n3 2\n4 2\n1 1\n3 1\n4 13\n1 3\n12 4\n100 100\n", "output": "16\n16\n4\n9\n169\n9\n144\n40000\n"}, {"input": "8\n3 2\n2 2\n1 1\n4 2\n2 11\n1 4\n7 4\n100 101\n", "output": "16\n16\n4\n16\n121\n16\n64\n40000\n"}, {"input": "8\n3 2\n4 2\n1 1\n3 1\n12 7\n1 3\n12 4\n100 001\n", "output": "16\n16\n4\n9\n196\n9\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nDefine a \"prime prime\" number to be a rational number written as one prime number over another prime number...
[{"input": "1000", "output": "[[14028, 6266]]", "fn_name": "prime_primes"}, {"input": "666", "output": "[[7260, 3213]]", "fn_name": "prime_primes"}, {"input": "65", "output": "[[153, 63]]", "fn_name": "prime_primes"}, {"input": "10", "output": "[[6, 3]]", "fn_name": "prime_primes"}, {"input": "6", "output": "[[3, 1]]",...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere are N integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi will repeatedly perform t...
[{"input": "5\n1 18 1 14 0", "output": "YES\n"}, {"input": "5\n2 18 0 14 0", "output": "YES\n"}, {"input": "5\n4 3 -1 16 4", "output": "YES\n"}, {"input": "5\n2 3 -1 16 4", "output": "YES\n"}, {"input": "5\n2 3 -1 16 2", "output": "YES\n"}, {"input": "5\n4 3 -1 16 2", "output": "YES\n"}, {"input": "5\n6 3 -1 16 2", "ou...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nproblem\n\nAt IOI Confectionery, rice crackers are baked using the traditional method since the company was f...
[{"input": "2 5\n0 1 1 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0", "output": "10\n15\n"}, {"input": "2 5\n1 1 1 1 0\n0 0 0 0 1\n3 6\n1 0 0 0 0 1\n0 1 1 0 1 0\n1 0 1 1 0 1\n0 0", "output": "10\n16\n"}, {"input": "2 5\n1 1 1 1 0\n0 0 0 0 1\n3 6\n1 0 0 0 1 0\n0 1 1 0 1 1\n1 0 1 1 0 1\n0 0", "output":...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAlice is visiting New York City. To make the trip fun, Alice will take photos of the city skyline and give th...
[{"input": "50\n5 42 16 13 20 2 39 49 33 1 11 4 46 3 48 44 12 7 27 41 35 38 26 6 31 37 10 50 24 9 32 15 47 30 17 28 22 29 23 34 8 18 40 21 19 36 25 43 45 14\n427 -3 -165 -161 302 -337 285 -418 227 -78 -453 -122 -162 -249 -194 119 -127 322 -238 467 -236 254 263 -57 225 391 270 -96 -173 329 -45 133 -36 449 -3 168 -490 15...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\n# Summary:\nGiven a number, `num`, return the shortest amount of `steps` it would take from 1, to land exactl...
[{"input": "10000", "output": "[17]", "fn_name": "shortest_steps_to_num"}, {"input": "1500", "output": "[16]", "fn_name": "shortest_steps_to_num"}, {"input": "1534", "output": "[18]", "fn_name": "shortest_steps_to_num"}, {"input": "1978", "output": "[17]", "fn_name": "shortest_steps_to_num"}, {"input": "2763", "output"...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nGiven is an integer S.\nFind how many sequences there are whose terms are all integers greater than or equal ...
[{"input": "1729\n", "output": "294867501\n"}, {"input": "2000\n", "output": "883312678\n"}, {"input": "1445\n", "output": "157799856\n"}, {"input": "1447\n", "output": "185357934\n"}, {"input": "1497\n", "output": "661810862\n"}, {"input": "1202\n", "output": "751905815\n"}, {"input": "522\n", "output": "272885863\n"}...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nA variation of determining leap years, assuming only integers are used and years can be negative and positive...
[{"input": "2016", "output": "[\"2016 has 366 days\"]", "fn_name": "year_days"}, {"input": "1974", "output": "[\"1974 has 365 days\"]", "fn_name": "year_days"}, {"input": "1857", "output": "[\"1857 has 365 days\"]", "fn_name": "year_days"}, {"input": "2000", "output": "[\"2000 has 366 days\"]", "fn_name": "year_days"},...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere is a building with 2N floors, numbered 1, 2, \\ldots, 2N from bottom to top.\nThe elevator in this buil...
[{"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 130\n14 114\n90 190\n66 16...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nMr. Square is going on a holiday. He wants to bring 2 of his favorite squares with him, so he put them in his...
[{"input": "10\n10\n11\n11", "output": "[false]", "fn_name": "fit_in"}, {"input": "1\n2\n2\n1", "output": "[false]", "fn_name": "fit_in"}, {"input": "3\n2\n3\n2", "output": "[false]", "fn_name": "fit_in"}, {"input": "1\n2\n1\n2", "output": "[false]", "fn_name": "fit_in"}, {"input": "6\n5\n8\n7", "output": "[false]", "f...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere are N cities on a 2D plane. The coordinate of the i-th city is (x_i, y_i). Here (x_1, x_2, \\dots, x_N)...
[{"input": "7\n6 4\n4 2\n3 5\n7 1\n2 7\n5 3\n1 6", "output": "3\n3\n1\n1\n2\n3\n2\n"}, {"input": "7\n6 4\n4 3\n3 5\n7 1\n2 6\n5 2\n1 7", "output": "3\n3\n1\n1\n1\n3\n1\n"}, {"input": "7\n6 4\n4 3\n3 5\n7 1\n2 7\n5 2\n1 6", "output": "3\n3\n1\n1\n2\n3\n2"}, {"input": "4\n2 4\n1 3\n3 1\n4 2", "output": "2\n2\n2\n2\n"}, {...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nContest T-shirts\n\nSegtree has $ M $ contest T-shirts.\n\nHe decided to spend $ N $ days on the contest T-sh...
[{"input": "11 0\n2 2 -1", "output": "0\n"}, {"input": "-1 0\n3 0 -1", "output": "0\n"}, {"input": "0 1\n2 -1 -2", "output": "0\n"}, {"input": "0 0\n-1 3 -2", "output": "0\n"}, {"input": "-1 0\n2 3 -1", "output": "0\n"}, {"input": "11 0\n2 0 -2", "output": "0\n"}, {"input": "-1 0\n-1 0 0", "output": "0\n"}, {"input": "...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nVasya has recently got a job as a cashier at a local store. His day at work is $L$ minutes long. Vasya has al...
[{"input": "1 1000000000 1\n0 1000000000\n", "output": "0\n"}, {"input": "1 1000000000 1\n0 1000000000\n", "output": "0"}, {"input": "0 1000000000 1\n", "output": "1000000000\n"}, {"input": "0 1000000000 1000000000\n", "output": "1\n"}, {"input": "0 1000000000 1000000010\n", "output": "0\n"}, {"input": "0 1000010000 10...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThere is a directed graph with N vertices and M edges.\nThe i-th edge (1≤i≤M) points from vertex a_i to verte...
[{"input": "6 5\n1 2 -1000000000\n2 3 -1000000000\n3 4 -1000000000\n4 5 -1000000000\n5 6 -1000000000\n", "output": "-5000000000\n"}, {"input": "6 5\n1 2 -1000000000\n2 3 -1000000000\n3 5 -1000000000\n4 5 -1000000000\n5 6 -1000000000", "output": "-4000000000\n"}, {"input": "6 5\n1 2 -1000000000\n2 3 -1000000000\n3 5 -12...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nBridge Removal\n\nICPC islands once had been a popular tourist destination. For nature preservation, however,...
[{"input": "4\n1 2 3\n10 37 30\n10\n1 2 2 1 1 5 1 10 8\n10 2 1 20 2 1 30 1 1\n3\n1 1\n1 1\n0", "output": "114\n139\n2\n"}, {"input": "4\n1 2 3\n10 37 52\n10\n1 2 2 1 1 5 1 10 8\n10 2 1 20 2 1 30 1 1\n3\n1 1\n1 1\n0", "output": "136\n139\n2\n"}, {"input": "4\n1 2 3\n10 30 30\n10\n1 2 2 1 1 5 1 8 8\n10 1 1 20 2 1 30 1 1\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nPolycarpus has a sequence, consisting of n non-negative integers: a1, a2, ..., an.\n\nLet's define function f...
[{"input": "10\n375813 659427 484038 348181 432640 368050 271089 721588 345312 630771\n", "output": "29\n"}, {"input": "10\n1 1 3 4 5 12 1 2 9 10\n", "output": "12\n"}, {"input": "10\n6 8 11 5 1 9 10 2 4 7\n", "output": "13\n"}, {"input": "10\n1 1 3 1 5 12 1 2 9 10\n", "output": "11\n"}, {"input": "10\n1 1 3 1 5 12 1 2...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nRead problems statements in Mandarin Chinese, Russian and Vietnamese as well. \n\nChef likes problems involvi...
[{"input": "3\n3\n3 0 0\n4\n3 2 0 1\n6\n1 0 -1 0 1 0", "output": "4\n4\n12\n"}, {"input": "3\n3\n1 0 0\n4\n3 2 0 1\n6\n0 0 -1 0 1 0", "output": "4\n4\n13\n"}, {"input": "3\n3\n1 3 2\n4\n4 2 6 -1\n6\n2 1 2 -1 2 1", "output": "4\n4\n6\n"}, {"input": "3\n3\n1 0 2\n4\n4 1 2 1\n6\n1 3 2 2 2 2", "output": "3\n5\n10\n"}, {"in...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nWe have a sequence p = {p_1,\\ p_2,\\ ...,\\ p_N} which is a permutation of {1,\\ 2,\\ ...,\\ N}.\nYou can pe...
[{"input": "50\n43 20 27 29 33 34 2 15 50 18 23 3 13 19 12 1 11 7 32 48 35 36 41 44 22 24 6 30 45 46 5 25 37 16 26 4 47 39 28 8 42 9 31 21 10 49 40 17 14 38\n", "output": "NO\n"}, {"input": "44\n1 2 3 4 5 6 7 8 9 10 22 12 13 14 15 16 17 18 19 20 21 11 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44\n"...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou get a \"text\" and have to shift the vowels by \"n\" positions to the right.\n(Negative value for n shoul...
[{"input": "\"This is a test!\"\n-1", "output": "[\"This as e tist!\"]", "fn_name": "vowel_shift"}, {"input": "\"This is a test!\"\n-5", "output": "[\"This as e tist!\"]", "fn_name": "vowel_shift"}, {"input": "\"This is a test!\"\n0", "output": "[\"This is a test!\"]", "fn_name": "vowel_shift"}, {"input": "\"This is a ...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nMahmoud and Ehab play a game called the even-odd game. Ehab chooses his favorite integer n and then they take...
[{"input": "1001000000\n", "output": "Mahmoud\n"}, {"input": "1011000000\n", "output": "Mahmoud\n"}, {"input": "1165278070\n", "output": "Mahmoud\n"}, {"input": "1425124860\n", "output": "Mahmoud\n"}, {"input": "1000000000\n", "output": "Mahmoud"}, {"input": "1000000000\n", "output": "Mahmoud"}, {"input": "691838234\n"...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nAri the monster is not an ordinary monster. She is the hidden identity of Super M, the Byteforces’ superhero....
[{"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\n57 9\n30 61\n31 4\n58 13...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nTakahashi recorded his daily life for the last few days as a integer sequence of length 2N, as follows:\n\n* ...
[{"input": "10\n43196 57600\n4800 9600\n6000 1200\n600 600\n300 600\n5400 600\n6000 5760\n6760 2880\n6000 12000\n9000 600", "output": "5\n"}, {"input": "10\n43196 57600\n4800 9600\n6000 1200\n600 600\n300 600\n5400 600\n6000 5760\n6760 2880\n6000 12000\n9000 794", "output": "5\n"}, {"input": "10\n43196 21072\n8364 1124...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given a string s of length n consisting of lowercase English letters.\n\nFor two given strings s and ...
[{"input": "10 30\naccbaaccac\n6 8 3\n2 9 1\n6 8 3\n10 5 1\n6 2 2\n1 4 7\n3 10 1\n6 9 1\n7 7 3\n7 3 2\n8 4 1\n4 9 1\n7 6 4\n6 8 2\n10 2 1\n1 3 5\n5 10 1\n7 10 1\n4 1 2\n8 5 3\n9 8 1\n8 6 2\n6 9 2\n10 3 1\n3 9 1\n5 5 5\n1 5 6\n4 2 6\n10 7 1\n9 8 2\n", "output": "NO\nYES\nNO\nYES\nNO\nNO\nYES\nYES\nYES\nNO\nYES\nYES\nNO\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given an array $a$ of length $n$ that has a special condition: every element in this array has at mos...
[{"input": "8\n6 15 35 129 143 221 34 26\n", "output": "3\n"}, {"input": "8\n6 15 35 129 143 221 3 26\n", "output": "-1\n"}, {"input": "8\n6 15 35 129 143 221 3 51\n", "output": "-1\n"}, {"input": "8\n6 11 35 129 143 221 3 51\n", "output": "5\n"}, {"input": "8\n6 15 35 77 143 221 34 26\n", "output": "3"}, {"input": "8\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nTaro and Jiro will play the following game against each other.\n\nInitially, they are given a sequence a = (a...
[{"input": "10\n1000000000 0 1000000000 1 1000000000 1 1000000000 1 1000000000 1", "output": "4999999996\n"}, {"input": "10\n1000000000 1 1000000000 1 1000000000 2 1000000000 1 1000000000 1", "output": "4999999994\n"}, {"input": "10\n1000000000 0 1000000000 1 1000000000 1 1010000000 1 1000000000 1", "output": "50099999...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nFour-digit palindromes start with `[1001,1111,1221,1331,1441,1551,1551,...]` and the number at position `2` i...
[{"input": "6\n20", "output": "[119911]", "fn_name": "palin"}, {"input": "7\n3", "output": "[1002001]", "fn_name": "palin"}, {"input": "5\n19", "output": "[11811]", "fn_name": "palin"}, {"input": "6\n3", "output": "[102201]", "fn_name": "palin"}, {"input": "3\n10", "output": "[191]", "fn_name": "palin"}, {"input": "4\n...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nGiven are three positive integers A, B, and C. Compute the following value modulo 998244353:\n\\sum_{a=1}^{A}...
[{"input": "1000000000 987654321 123456789\n", "output": "951633476\n"}, {"input": "192279221 156648747 154396385\n", "output": "152138957\n"}, {"input": "264704198 120999147 136987925\n", "output": "24444247\n"}, {"input": "682152024 451794315 2028038\n", "output": "579633067\n"}, {"input": "693 299 737\n", "output": ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe only difference between easy and hard versions is the constraints.\n\nVova likes pictures with kittens. T...
[{"input": "25 4 15\n172043124 384297369 650214870 426077944 587045971 576701397 865475689 261462255 763837593 285228401 629011531 611623799 456424430 820020943 166915939 903479811 357808031 561107351 177427070 14589838 994169358 1227795556 193684940 439658261 237500762\n", "output": "10512644504\n"}, {"input": "25 4 1...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nProblem statement\n\nAOR Ika got a cabbage with $ N $ leaves. The leaves of this cabbage are numbered $ 1, \\...
[{"input": "16 6 10 -1\n24 1 4 -1 0", "output": "1\n"}, {"input": "16 6 10 -1\n24 1 5 -1 0", "output": "1\n"}, {"input": "21 10 0 4\n5 2 13 -1 0", "output": "3\n"}, {"input": "16 6 10 -1\n24 1 4 0 1", "output": "1\n"}, {"input": "16 6 10 -1\n24 1 4 0 0", "output": "1\n"}, {"input": "16 6 10 0\n24 1 5 -1 0", "output": "...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nMost languages have a `split` function that lets you turn a string like `“hello world”` into an array like`[“...
[{"input": "\"hello world! hello world!\"\n\"hello wo|rld!\"", "output": "[[\"hello wo\", \"rld! hello wo\", \"rld!\"]]", "fn_name": "split_without_loss"}, {"input": "\"hello world! hello world!\"\n\" |\"", "output": "[[\"hello \", \"world! \", \"hello \", \"world!\"]]", "fn_name": "split_without_loss"}, {"input": "\"h...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous on...
[{"input": "2000000000000000000\n", "output": "25\n"}, {"input": "1000000000000000000\n", "output": "25\n"}, {"input": "1000001000000000000\n", "output": "25\n"}, {"input": "1440563777463828705\n", "output": "25\n"}, {"input": "1000001000000010000\n", "output": "25\n"}, {"input": "1000001000000000100\n", "output": "25\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nRecently a serious bug has been found in the FOS code. The head of the F company wants to find the culprit an...
[{"input": "10 2\n10 2\n9 3\n9 4\n7 2\n4 6\n10 1\n9 2\n3 10\n7 1\n5 1\n", "output": "43\n"}, {"input": "10 3\n6 3\n6 10\n2 5\n5 7\n6 2\n9 2\n8 1\n10 5\n5 10\n7 6\n", "output": "34\n"}, {"input": "10 2\n10 2\n9 3\n9 4\n7 2\n4 6\n10 1\n9 2\n3 10\n7 1\n5 1\n", "output": "43\n"}, {"input": "10 3\n6 3\n6 10\n2 5\n5 7\n6 2\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nA `Nice array` is defined to be an array where for every value `n` in the array, there is also an element `n-...
[{"input": "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]", "output": "[true]", "fn_name": "is_nice"}, {"input": "[1, -1, 2, -2, 3, -3, 6]", "output": "[false]", "fn_name": "is_nice"}, {"input": "[3, 2, 10, 4, 1, 6]", "output": "[false]", "fn_name": "is_nice"}, {"input": "[0, 1, 3, -2, 5, 4]", "output": "[false]", "fn_name": "is_nice...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe only difference between the easy and the hard versions is constraints.\n\nA subsequence is a string that ...
[{"input": "100 1000000000000\ndjgykfqaywhkhpocyxcpvbiiouyielmighclnuopadzuvrirbecucwnzwahahagvfstbxxaednajfauscxwttiglbbxtomnnalcl\n", "output": "8854753825335\n"}, {"input": "100 1000000000000\ndjgykfqaywhkhpocyxcpvbiiouyielmighclnuopadzuvrirbecucwnzwahahagvfstbxxaednajfauscxwttiglbbxtomnnalcl\n", "output": "88547538...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nC: Only one subsequence --Unique Subsequence-\n\nproblem\n\nOne day Ebi-chan noticed that a text string T of ...
[{"input": "aziucamp\nazu", "output": "yes\n"}, {"input": "azjucamp\nazu", "output": "yes\n"}, {"input": "aizucamp\nuza", "output": "no\n"}, {"input": "azjucamp\nazt", "output": "no\n"}, {"input": "azjucamp\nzat", "output": "no\n"}, {"input": "pmacujza\nzat", "output": "no\n"}, {"input": "pmacuiza\nzat", "output": "no\...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nSuppose you are given a string $s$ of length $n$ consisting of lowercase English letters. You need to compres...
[{"input": "255 3880 4590\nwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwkwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwawgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwkwgwzwgwuwgwzwgwxwgwzwgwuwgwzwgwewgwzwgwuwgwzwgwxwgwzwgwuwgwzwgw\n", "output": "62460\n"}, {"input": "...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nPetya is preparing for IQ test and he has noticed that there many problems like: you are given a sequence, fi...
[{"input": "64 160 400 1000\n", "output": "2500\n"}, {"input": "992 994 1419 1000\n", "output": "42\n"}, {"input": "1000 980 1495 906\n", "output": "42\n"}, {"input": "992 429 1419 1000\n", "output": "42\n"}, {"input": "836 624 412 200\n", "output": "-12\n"}, {"input": "1 334 667 1000\n", "output": "1333\n"}, {"input":...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nHappy traveller [Part 1]\n\nThere is a play grid NxN; Always square! \n\n 0 1 2 3\n0 [o, o, o, X]\n1 [o,...
[{"input": "6\n[5, 0]", "output": "[252]", "fn_name": "count_paths"}, {"input": "7\n[6, 0]", "output": "[924]", "fn_name": "count_paths"}, {"input": "5\n[4, 0]", "output": "[70]", "fn_name": "count_paths"}, {"input": "1\n[0, 0]", "output": "[0]", "fn_name": "count_paths"}, {"input": "2\n[1, 0]", "output": "[2]", "fn_na...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nYou are given an array a consisting of n integers.\n\nLet min(l, r) be the minimum value among a_l, a_{l + 1}...
[{"input": "8\n3\n1000000000 1000000000 1000000000\n3\n1 1000000000 1000000000\n3\n1000000000 1 1000000000\n3\n1 1 1000000000\n3\n1000000000 1000000000 1\n3\n1 1000000000 1\n3\n1000000000 1 1\n3\n1 1 1\n", "output": "YES\n1 1 1\nNO\nNO\nNO\nNO\nNO\nNO\nYES\n1 1 1\n"}, {"input": "8\n3\n1000000000 1000000000 1000000000\n...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nBear Limak prepares problems for a programming competition. Of course, it would be unprofessional to mention ...
[{"input": "75\nVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\n", "output": "1406\n"}, {"input": "75\nVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\n", "output": "1406\n"}, {"input": "75\nVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVKVK...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nIt can be shown that any positive integer x can be uniquely represented as x = 1 + 2 + 4 + ... + 2k - 1 + r, ...
[{"input": "100\n1 1 1 1 1 1 1 2 2 2 2 2 2 2 4 4 4 4 4 4 4 6 8 8 8 8 8 8 8 10 16 16 16 16 16 16 16 17 22 24 24 30 32 32 32 46 32 32 48 62 64 108 65 65 67 70 74 88 89 98 99 101 101 109 121 127 128 128 137 143 152 153 155 156 160 161 114 183 186 196 196 214 220 226 228 230 238 240 241 245 249 249 250 253 254 256 256 512 ...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nThe central dogma of molecular biology is that DNA is transcribed into RNA, which is then tranlsated into pro...
[{"input": "\"AUGUAUCCUUCCAUCAAGGAAACCAUGCGCGUUCAGCUUUCUAUGGAGGGUAGUGUUAACUACCACGCCUUCAAGUGCACUGGAAAAGGAGAGGGAAAACCAUACGAAGGCACCCAAAGCCUGAAUAUUACAAUAACUGAAGGAGGUCCUCUGCCAUUUGCUUUUGACAUUCUGUCACACGCCUUUCAGUAUGGCAUCAAGGUCUUCGCCAAGUACCCCAAAGAAAUUCCUGACUUCUUUAAGCAGUCUCUACCUGGUGGUUUUUCUUGGGAAAGAGUAAGCACCUAUGAAGAUGGAGGAGUGCUU...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nFor any positive integer, we define a digit rotation as either moving the first digit\nto the end of the numb...
[{"input": "6\n12345\n43634\n21427\n211011\n7\n166", "output": "51234\n63443\n72142\n211011\n7\n661\n"}, {"input": "6\n23325\n43634\n21427\n211011\n7\n166", "output": "52332\n63443\n72142\n211011\n7\n661\n"}, {"input": "6\n23325\n43634\n21427\n211011\n1\n166", "output": "52332\n63443\n72142\n211011\n1\n661\n"}, {"input...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nWe have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the to...
[{"input": "155776 1 112696\n", "output": "837491985\n"}, {"input": "200000 1 134405\n", "output": "945631888\n"}, {"input": "491 405 148903\n", "output": "206234613\n"}, {"input": "435 448 126173\n", "output": "779238467\n"}, {"input": "454 424 168618\n", "output": "804548732\n"}, {"input": "488 405 176503\n", "output...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nGiven two integers `a` and `b`, which can be positive or negative, find the sum of all the numbers between in...
[{"input": "-321\n123", "output": "[-44055]", "fn_name": "get_sum"}, {"input": "-505\n4", "output": "[-127755]", "fn_name": "get_sum"}, {"input": "321\n123", "output": "[44178]", "fn_name": "get_sum"}, {"input": "505\n4", "output": "[127759]", "fn_name": "get_sum"}, {"input": "-50\n0", "output": "[-1275]", "fn_name": "...
code_functional
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nBeing a programmer, you like arrays a lot. For your birthday, your friends have given you an array a consisti...
[{"input": "40\n22993199 75843013 76710455 99749069 105296587 122559115 125881005 153961749 163646706 175409222 185819807 214465092 264449243 278246513 295514446 322935239 370349154 375773209 390474983 775646826 767329655 740310077 718820037 708508595 693119912 680958422 669537382 629123011 607511013 546574974 54657213...
code_stdio
[ { "content": "You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests.\n\nGiven a number, write a function to output its reverse digits. (e.g. given 123 the answer is 321)\n\n\nNumbe...
[{"input": "98989898", "output": "[89898989]", "fn_name": "reverse_number"}, {"input": "4321234", "output": "[4321234]", "fn_name": "reverse_number"}, {"input": "-123", "output": "[-321]", "fn_name": "reverse_number"}, {"input": "123", "output": "[321]", "fn_name": "reverse_number"}, {"input": "1000", "output": "[1]", ...
code_functional