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\nYou are given two non-empty strings $s$ and $t$, consisting of Latin letters.\n\nIn one move, you can choose ...
[{"input": "10\nakhvjuejwrazexjkmzfersbjnvdvdbrdvuexbdloltpllcnvqtdoooftuhphtdfcveomexsbn\ni\ndgkrbariruzn\njwa\nttbbvxlxjsksrziizcmhhxpntxvmkqvhtqqedhqprzdidcvgfgrbqyhlrpwpisajpwmbszyjntqgaoskvc\nmk\ntwakxsrktfktpkrmrxsruzjvivionieksdngxrhcifxcyzuqfaciojwifrusfrlvikfcqeextlfcudoahqqm\na\nb\nwr\nds\na\npwrawcwzympnqwbq...
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 had record hot temperatures this summer. To avoid heat stroke, you decided to buy a quantity of drink...
[{"input": "467 101 10577", "output": "2222\n"}, {"input": "467 100 16500", "output": "3300\n"}, {"input": "467 100 12758", "output": "2600\n"}, {"input": "467 101 12758", "output": "2626\n"}, {"input": "467 111 12758", "output": "2886\n"}, {"input": "467 111 18557", "output": "4218\n"}, {"input": "467 111 18051", "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\nC*++ language is quite similar to C++. The similarity manifests itself in the fact that the programs written ...
[{"input": "399\n469*++a-935*++a-838*++a-468*++a+79*++a-89*++a-863*++a+531*a++-523*a++-583*++a-411*++a+301*++a+201*a++-108*a+++581*a+++938*++a-16*a++-632*a+++146*a++-230*++a+151*++a-618*a+++593*a+++320*++a+750*++a+185*a++-68*++a+839*a++-853*a+++761*a++-442*a++-385*a++-487*a++-573*a++-820*a++-123*a+++792*++a+95*++a+228*...
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$ warriors in a row. The power of the $i$-th warrior is $a_i$. All powers are pairwise distinct.\...
[{"input": "23 5\n10 3 3\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22\n4 6 3 18 23\n", "output": "56\n"}, {"input": "23 5\n10 3 4\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22\n4 6 3 18 23\n", "output": "64\n"}, {"input": "23 5\n10 3 4\n2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 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\nAlice and Bob are studying for their class test together. The topic of the test is Prime Numbers. The prepara...
[{"input": "4\n3 0 1\n2 12 2\n22 12 2\n2 20 1", "output": "-1\n3\n-5\n12\n"}, {"input": "4\n3 0 1\n2 19 2\n22 12 2\n2 20 1", "output": "-1\n6\n-5\n12\n"}, {"input": "4\n3 0 1\n2 12 4\n22 12 2\n2 20 1", "output": "-1\n0\n-5\n12\n"}, {"input": "4\n2 2 1\n3 12 2\n1 15 2\n0 20 5", "output": "1\n3\n5\n-1816\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\nYou drop a ball from a given height. After each bounce, the ball returns to some fixed proportion of its prev...
[{"input": "100\n0.1", "output": "[2]", "fn_name": "bouncing_ball"}, {"input": "10\n0.1", "output": "[1]", "fn_name": "bouncing_ball"}, {"input": "30\n0.3", "output": "[3]", "fn_name": "bouncing_ball"}, {"input": "2\n0.5", "output": "[1]", "fn_name": "bouncing_ball"}, {"input": "4\n0.5", "output": "[2]", "fn_name": "bo...
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\nÆsir - CHAOS Æsir - V.\n\n\"Everything has been planned out. No more hidden concerns. The condition of Cytus ...
[{"input": "87\n1120 1120 1120 872 1120 731 3583 2815 4019 1291 4568 973 1120 1705 1120 822 203 1120 1120 1120 1120 4196 3166 4589 3030 1120 1120 1120 711 1120 500 1120 1120 3551 1120 1120 1120 1700 1120 1120 2319 4554 1120 1312 1120 1120 4176 1120 1120 3661 1120 1120 1120 1120 142 63 4125 1120 4698 3469 1829 567 1120 ...
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 integers written on a blackboard. The i-th integer is A_i.\n\nTakahashi and Aoki will arrange the...
[{"input": "5\n1 12 6 0 5", "output": "1 0 6 12 5 "}, {"input": "5\n1 12 2 0 5", "output": "1 0 5 2 12 "}, {"input": "5\n1 12 3 0 5", "output": "1 0 5 3 12 "}, {"input": "5\n1 17 3 0 5", "output": "1 0 17 5 3 "}, {"input": "5\n1 4 10 0 5", "output": "1 0 4 10 5 "}, {"input": "5\n1 13 6 0 5", "output": "1 0 13 6 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\nPolycarp found under the Christmas tree an array $a$ of $n$ elements and instructions for playing with it:\n\...
[{"input": "4\n5\n6 5 2 2 8\n3\n2 1 12\n6\n2 1111 2 3 995 1\n5\n1 1 1 1 4\n", "output": "10\n14\n1111\n8\n"}, {"input": "4\n5\n6 5 2 2 8\n3\n2 1 15\n6\n2 1111 2 3 995 1\n5\n1 1 1 1 4\n", "output": "10\n17\n1111\n8\n"}, {"input": "4\n5\n12 3 1 2 3\n3\n2 1 4\n6\n5 1101 2 5 613 1\n5\n2 1 1 1 1\n", "output": "12\n6\n1101\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 are given an array a with n elements. Each element of a is either 0 or 1.\n\nLet's denote the length of t...
[{"input": "10 5\n0 0 1 0 0 1 1 0 1 1\n", "output": "10\n1 1 1 1 1 1 1 1 1 1 "}, {"input": "10 2\n1 0 0 1 0 1 0 1 0 1\n", "output": "5\n1 0 0 1 1 1 1 1 0 1\n"}, {"input": "10 3\n0 0 1 0 0 1 0 0 1 1\n", "output": "6\n0 0 1 0 1 1 1 1 1 1\n"}, {"input": "10 3\n0 0 1 0 0 1 0 0 1 1\n", "output": "6\n0 0 1 0 1 1 1 1 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\nYou are given n positive integers a_1, …, a_n, and an integer k ≥ 2. Count the number of pairs i, j such that...
[{"input": "100 4\n94 94 83 27 80 73 61 38 34 95 72 96 59 36 52 15 122 78 39 22 21 57 54 59 9 32 81 64 51 90 67 41 18 58 93 76 44 62 77 61 31 70 39 73 111 57 43 31 27 85 36 26 58 48 35 23 124 53 3 14 40 67 53 19 70 81 98 12 91 15 92 90 89 86 58 30 67 73 72 69 68 47 30 7 89 41 17 97 45 6 4 23 13 36 10 35 73 74 45 52\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\nBearland has n cities, numbered 1 through n. Cities are connected via bidirectional roads. Each road connects...
[{"input": "1000 1577\n698 459 326 404\n", "output": "698 326 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 ...
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\nThis problem takes its name by arguably the most important event in the life of the ancient historian Josephu...
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n11", "output": "[[11, 22, 33, 44, 5, 17, 29, 41, 3, 16, 30, 43, 7, 21, 36, 50, 15, 32, 48, 14, 34, 1, 20, 39, 9, 28...
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 $n$ blocks, each of them is of the form [color$_1$|value|color$_2$], where the block can also b...
[{"input": "40\n2 99891 4\n1 29593 4\n4 12318 1\n1 40460 3\n1 84340 2\n3 33349 4\n3 2121 4\n3 50068 3\n2 72029 4\n4 52319 3\n4 60726 2\n1 30229 1\n3 1887 2\n2 56145 4\n3 53121 1\n2 54227 4\n2 70016 3\n1 93754 4\n4 68567 3\n1 70373 2\n4 52983 3\n2 27467 2\n4 56860 2\n2 12665 2\n3 11282 3\n2 18731 4\n1 69767 4\n2 51820 4...
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$ both of length $n$ and both consisting of lowercase Latin letters.\n\nI...
[{"input": "4\n4\nabcd\nabdc\n5\nababa\nbaaba\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "output": "NO\nYES\nNO\nYES\n"}, {"input": "4\n4\nabcd\nabdc\n5\nababa\nabaab\n4\nasdf\nasdg\n4\nabcd\nbadc\n", "output": "NO\nYES\nNO\nYES\n"}, {"input": "4\n4\ndabb\nabdb\n5\nababa\nababa\n4\nasdf\nasdg\n4\nabdd\nbadc\n", "output": "YES\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\nOnce Vasya played bricks. All the bricks in the set had regular cubical shape. Vasya vas a talented architect...
[{"input": "20\n-10 17 -4 11\n1 22 -15 6\n-5 12 -9 16\n-9 16 -5 12\n-2 19 -12 9\n-10 17 -4 11\n-8 13 -6 15\n-5 12 -9 16\n-3 18 -11 10\n-1 20 -13 8\n29 9 -12 50\n29 50 -11 10\n29 9 -12 50\n29 50 -10 11\n-14 50 29 7\n-9 12 29 50\n-14 7 29 50\n29 9 -12 50\n-11 10 29 50\n-11 50 29 10\n", "output": "10"}, {"input": "20\n-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\nAt the annual family gathering, the family likes to find the oldest living family member’s age and the younge...
[{"input": "[46, 86, 33, 29, 87, 47, 28, 12, 1, 4, 78, 92]", "output": "[[1, 92, 91]]", "fn_name": "difference_in_ages"}, {"input": "[12, 76, 49, 37, 29, 17, 3, 65, 84, 38]", "output": "[[3, 84, 81]]", "fn_name": "difference_in_ages"}, {"input": "[62, 0, 3, 77, 88, 102, 26, 44, 55]", "output": "[[0, 102, 102]]", "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\nFor a positive integer n let's define a function f:\n\nf(n) = - 1 + 2 - 3 + .. + ( - 1)^{n}n \n\nYour task i...
[{"input": "1000000000000000\n", "output": "500000000000000\n"}, {"input": "999999999999999\n", "output": "-500000000000000\n"}, {"input": "1000000000000000\n", "output": "500000000000000\n"}, {"input": "999999999999999\n", "output": "-500000000000000\n"}, {"input": "1000000000000100\n", "output": "500000000000050\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\nLimak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and w...
[{"input": "10 135\n", "output": "6\n"}, {"input": "10 136\n", "output": "5\n"}, {"input": "10 240\n", "output": "0\n"}, {"input": "10 165\n", "output": "5\n"}, {"input": "10 166\n", "output": "4\n"}, {"input": "10 164\n", "output": "5\n"}, {"input": "10 240\n", "output": "0\n"}, {"input": "10 235\n", "output": "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\nYour friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan sha...
[{"input": "291", "output": "158467928000\n"}, {"input": "188", "output": "1040975000\n"}, {"input": "214", "output": "3701387000\n"}, {"input": "190", "output": "1147676000\n"}, {"input": "143", "output": "115848000\n"}, {"input": "170", "output": "432541000\n"}, {"input": "149", "output": "155251000\n"}, {"input": "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\nPasha is participating in a contest on one well-known website. This time he wants to win the contest and will...
[{"input": "44\n750 672 846 969 981 698 380 587 813 587 156 28 446 917 1550 449 142 764 226 1406 349 622 236 782 416 689 113 325 452 265 585 217 707 50 520 712 1869 275 423 123 175 160 415 528\n4\n869 1568\n1353 1354\n1683 1685\n2532 2540\n", "output": "-1\n"}, {"input": "44\n750 672 846 969 981 698 380 587 813 587 156...
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\nKaren has just arrived at school, and she has a math test today! [Image] \n\nThe test is about basic addition...
[{"input": "19\n519879446 764655030 680293934 914539062 744988123 317088317 653721289 239862203 605157354 943428394 261437390 821695238 312192823 432992892 547139308 408916833 829654733 223751525 672158759\n", "output": "\n265109293\n"}, {"input": "19\n519879446 764655030 680293934 914539062 744988123 317088317 6537212...
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$ rectangles in a row. You can either turn each rectangle by $90$ degrees or leave it as it is. I...
[{"input": "10\n706794178 103578427\n431808055 641644550\n715688799 406274173\n767234853 345348548\n241724251 408945969\n808703176 213953908\n185314264 16672343\n1017427585 152702033\n105991807 76314740\n61409204 244301685\n", "output": "YES\n"}, {"input": "10\n706794178 103578427\n431808055 641644550\n715688799 406274...
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 two rival donut shops.\n\nThe first shop sells donuts at retail: each donut costs a dollars.\n\nThe...
[{"input": "20\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 1000000000 1000000000\n2 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\nThe Smart Beaver from ABBYY got hooked on square matrices. Now he is busy studying an n × n size matrix, wher...
[{"input": "15\n0 2 1 2 1 0 2 0 2 2 2 2 2 0 2\n2 0 1 0 1 1 2 2 0 2 2 0 3 0 1\n3 3 2 2 2 1 2 3 2 3 1 2 3 3 2\n0 3 0 3 3 3 2 1 0 2 3 2 3 3 2\n3 0 0 2 1 2 3 1 1 1 2 2 2 1 0\n1 3 2 3 3 0 3 2 0 3 1 2 3 0 3\n2 2 3 2 0 0 2 3 0 1 2 1 1 2 1\n2 1 3 2 3 3 2 2 2 0 3 3 1 1 3\n0 2 1 3 1 2 0 0 1 0 0 2 0 0 0\n3 1 2 1 2 3 2 3 2 1 0 2 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\nRecently Luba bought a very interesting book. She knows that it will take t seconds to read the book. Luba wa...
[{"input": "100 1000000\n0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 1 0 0 1 -1 -1 0 0 0 0 0 0 0 1 0 0 0 0 0 -1 -1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 1 1 0 1 1 0 0 1 0 0 0 0 -1 0 0 0\n", "output": "12\n"}, {"input": "100 1000000\n0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 ...
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 You are given a regular array `arr`. Let's call a `step` the difference between two adjacent element...
[{"input": "[54, 70, 86, 1, -2, -5, 0, 5, 78, 145, 212, 15]", "output": "[639]", "fn_name": "sum_of_regular_numbers"}, {"input": "[-1, 7000, 1, -6998, -13997]", "output": "[-13994]", "fn_name": "sum_of_regular_numbers"}, {"input": "[7, 2, 3, 2, -2, 400, 802]", "output": "[1200]", "fn_name": "sum_of_regular_numbers"}, {...
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\n## Welcome to my (amazing) kata!\n\nYou are given a gigantic number to decode. Each number is a code that al...
[{"input": "10910111310211511810510411911510910111310711510911410712011512012511610511810111410411511311210512012010511811998100000010010101001010101010101981021121011081011121191041101111061011121041191111061101011191041081071011191121041081071011191211121091041071089810001010010119810111910411110810711210411210111111...
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\nOne day Alice was cleaning up her basement when she noticed something very curious: an infinite set of wooden...
[{"input": "21\n##.######.###.#####.#\n#...##.#.......#.#...\n##..#...#.....#.....#\n#....#..###.###.....#\n....#....####....#.##\n#..#....##.#....#.###\n#...#.###...#.##....#\n#..#.##.##.##.##.....\n..........##......#.#\n#.##.#......#.#..##.#\n#.##.............#...\n..........#.....##..#\n#.#..###..###.##....#\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\nRJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Haz...
[{"input": "4\n_e\na`ba\nebbf\neddea", "output": "2\n12\n12\n13\n"}, {"input": "4\ne]\na`ba\nebbf\needea", "output": "2\n12\n12\n14\n"}, {"input": "4\n_f\n`db_\nfecf\nhaefg", "output": "2\n12\n12\n18\n"}, {"input": "4\naa\ndc^b\neagb\nbfghh", "output": "1\n12\n12\n14\n"}, {"input": "4\nab\nd^ca\neagb\n_fhhh", "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\nValera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to...
[{"input": "15\nrxeeeeeeeeeeeer\nereeeeeeeeeeere\needeeeeeeeeeoee\neeereeeeeeeewee\neeeereeeeebeeee\nqeeeereeejedyee\neeeeeerereeeeee\neeeeeeereeeeeee\neeeeeerereeeeze\neeeeereeereeeee\neeeereeeeegeeee\neeereeeeeeereee\neereeeeeeqeeved\ncreeeeeeceeeere\nreeerneeeeeeeer\n", "output": "NO\n"}, {"input": "15\nrxeeeeeeeeee...
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\nChef has recently learnt some new facts about the famous number π. For example, he was surprised that ordinar...
[{"input": "3\n3\n6\n82", "output": "3.141\n3.141592\n3.1415926530119026040722614947737296840070086399613316415926530119026040722614947737\n"}, {"input": "3\n3\n5\n82", "output": "3.141\n3.14159\n3.1415926530119026040722614947737296840070086399613316415926530119026040722614947737\n"}, {"input": "3\n2\n53\n4", "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\nAlthough Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, ...
[{"input": "10\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000\n10 3\n7 4\n2 6\n9 2\n5 10\n1 8\n7 8\n7 2\n10 6\n", "output": "-999999998\n"}, {"input": "10\n-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -10000...
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 the beginning of the new year Keivan decided to reverse his name. He doesn't like palindromes, so he chang...
[{"input": "89946\n", "output": "aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaab...
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 some perfect squares with a particular property.\nFor example the number ```n = 256``` is a perfect...
[{"input": "100000\n4", "output": "[298116]", "fn_name": "next_perfectsq_perm"}, {"input": "100\n4", "output": "[81796]", "fn_name": "next_perfectsq_perm"}, {"input": "1000\n3", "output": "[9216]", "fn_name": "next_perfectsq_perm"}, {"input": "100\n2", "output": "[441]", "fn_name": "next_perfectsq_perm"}, {"input": "10...
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 AtCoder Kingdom, Gregorian calendar is used, and dates are written in the \"year-month-day\" order, or the...
[{"input": "-13 438", "output": "-13\n"}, {"input": "-18 766", "output": "-18\n"}, {"input": "-143 0", "output": "-143\n"}, {"input": "-212 0", "output": "-212\n"}, {"input": "-106 5", "output": "-106\n"}, {"input": "148 -1", "output": "147\n"}, {"input": "146 -1", "output": "145\n"}, {"input": "-12 -2", "output": "-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\nYou are given a set of strings S. Each string consists of lowercase Latin letters.\n\nFor each string in this...
[{"input": "10\n0 i\n1 q\n2 g\n0 k\n1 e\n5 r\n4 m\n5 h\n3 o\n3 e\n5\n8 9 1 10 6\n", "output": "2 4 1 3 3\n"}, {"input": "10\n0 i\n1 q\n2 g\n0 k\n1 e\n5 r\n4 m\n4 g\n3 o\n3 e\n5\n8 9 1 10 6\n", "output": "2 4 1 3 2\n"}, {"input": "10\n0 i\n1 q\n2 g\n1 k\n1 e\n5 r\n4 m\n4 g\n3 o\n3 e\n5\n8 9 1 10 6\n", "output": "3 4 1 3...
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\nLittle Susie, thanks to her older brother, likes to play with cars. Today she decided to set up a tournament ...
[{"input": "4\n-1 3 3 3\n6 -1 3 -1\n2 3 -1 3\n3 3 3 -1\n", "output": "0\n\n"}, {"input": "4\n-1 3 3 3\n6 -1 3 -1\n2 1 -1 3\n3 3 3 -1\n", "output": "0\n\n"}, {"input": "4\n-1 3 3 3\n6 -1 3 -1\n2 3 -1 2\n3 3 3 -1\n", "output": "0\n\n"}, {"input": "4\n-1 3 3 3\n6 -1 3 -1\n0 3 -1 3\n3 3 3 -1\n", "output": "0\n\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\nYou are given a string and a number k. You are suggested to generate new strings by swapping any adjacent pai...
[{"input": "pckoshien\n16", "output": "cehikposn\n"}, {"input": "pckoshien\n30", "output": "cehiknops\n"}, {"input": "pckosiien\n26", "output": "ceiiknops\n"}, {"input": "pckoshien\n14", "output": "cehkopisn\n"}, {"input": "kcposhien\n3", "output": "ckophsien\n"}, {"input": "pckoshien\n9", "output": "cekopshin\n"}, {"i...
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\nArtem has an array of n positive integers. Artem decided to play with it. The game consists of n moves. Each ...
[{"input": "10\n96 106 8 18 36 48 34 11 37 42\n", "output": "305\n"}, {"input": "10\n96 106 8 18 58 48 34 11 37 42\n", "output": "337\n"}, {"input": "10\n96 66 8 18 30 48 34 11 37 42\n", "output": "299\n"}, {"input": "10\n96 66 8 18 58 48 34 11 37 42\n", "output": "337\n"}, {"input": "10\n96 66 8 18 30 48 34 11 37 42\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 this kata you will create a function to check a non-negative input to see if it is a prime number.\n\nThe ...
[{"input": "573", "output": "[false]", "fn_name": "is_prime"}, {"input": "12", "output": "[false]", "fn_name": "is_prime"}, {"input": "571", "output": "[true]", "fn_name": "is_prime"}, {"input": "25", "output": "[false]", "fn_name": "is_prime"}, {"input": "0", "output": "[false]", "fn_name": "is_prime"}, {"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 statement of this problem shares a lot with problem A. The differences are that in this problem, the prob...
[{"input": "10\n44317 2 42112 2 19660 2 49\n48930 2 47499 1 27225 2 43\n48392 2 28544 2 34152 2 97\n43473 2 185 2 4950 1 94\n41685 2 38469 1 6333 1 18\n45137 2 29286 1 28293 2 34\n43584 2 41743 1 28092 2 83\n47658 2 33552 2 8862 1 27\n46379 2 4528 2 2818 2 58\n46926 2 14781 1 7952 1 59\n", "output": "795918375\n7827068...
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 is an array of n positive integers, all of which are not greater than n.\n\nYou have to process q queries t...
[{"input": "50\n49 21 50 31 3 19 10 40 20 5 47 12 12 30 5 4 5 2 11 23 5 39 3 30 19 3 23 40 4 14 39 50 45 14 33 37 1 15 43 30 45 23 32 3 9 17 9 5 14 12\n50\n36 29\n44 24\n38 22\n30 43\n15 19\n39 2\n13 8\n29 50\n37 18\n32 19\n42 39\n20 41\n14 11\n4 25\n14 35\n17 23\n1 29\n3 19\n8 6\n26 31\n9 46\n36 31\n21 49\n17 38\n47 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\nJOI has a stove in your room. JOI himself is resistant to the cold, so he doesn't need to put on the stove wh...
[{"input": "2 1\n-10\n31\n0", "output": "42\n"}, {"input": "3 1\n-1\n4\n11", "output": "13\n"}, {"input": "3 1\n-1\n0\n23", "output": "25\n"}, {"input": "3 2\n-2\n6\n21", "output": "10\n"}, {"input": "3 1\n-1\n1\n20", "output": "22\n"}, {"input": "3 2\n1\n14\n1", "output": "-11\n"}, {"input": "3 1\n-1\n1\n28", "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\nOri and Sein have overcome many difficult challenges. They finally lit the Shrouded Lantern and found Gumon S...
[{"input": "20 7\n18525 35038\n15816 31586\n18641 46864\n35863 38632\n13563 35915\n41614 98684\n13573 35863\n25851 35985\n41687 55831\n31583 80871\n18525 35038\n15816 31586\n18641 46864\n35863 38632\n13563 35915\n41614 98684\n13573 35863\n25851 35985\n41687 55831\n31583 80871\n", "output": "4112\n"}, {"input": "20 7\n1...
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 is the easy version of the problem. The difference is that in this version, there are no nodes with alread...
[{"input": "010\n", "output": "153616455\n"}, {"input": "011\n", "output": "217549120\n"}, {"input": "60\n", "output": "937481864\n"}, {"input": "50\n", "output": "902552662\n"}, {"input": "59\n", "output": "950618124\n"}, {"input": "58\n", "output": "166788441\n"}, {"input": "10\n", "output": "153616455\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\nYou are given a positive integer x. Find any such 2 positive integers a and b such that GCD(a,b)+LCM(a,b)=x.\...
[{"input": "100\n3\n4\n5\n6\n7\n10\n9\n10\n11\n12\n13\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n28\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n111\n69\n70\n71\n72\n117\n74\n75\n76\n77\n78\n79\n80\...
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\nWhat are you doing at the end of the world? Are you busy? Will you save us?\n\n\n\n[Image]\n\nNephren is play...
[{"input": "10\n100000 873326525630182716\n100000 620513733919162415\n100000 482953375281256917\n100000 485328193417229962\n100000 353549227094721271\n100000 367447590857326107\n100000 627193846053528323\n100000 243833127760837417\n100000 287297493528203749\n100000 70867563577617188\n", "output": "o W rlot\n"}, {"inp...
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 string that includes alphanumeric characters ('3a4B2d') return the expansion of that string: The nume...
[{"input": "\"123p9cdbjs\"", "output": "[\"pppcccccccccdddddddddbbbbbbbbbjjjjjjjjjsssssssss\"]", "fn_name": "string_expansion"}, {"input": "\"cvyb239bved2dv\"", "output": "[\"cvybbbbbbbbbbvvvvvvvvveeeeeeeeedddddddddddvv\"]", "fn_name": "string_expansion"}, {"input": "\"239vbsac\"", "output": "[\"vvvvvvvvvbbbbbbbbbsssss...
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\n[Generala](https://en.wikipedia.org/wiki/Generala) is a dice game popular in South America. It's very similar...
[{"input": "\"55555\"", "output": "[50]", "fn_name": "points"}, {"input": "\"44444\"", "output": "[50]", "fn_name": "points"}, {"input": "\"44441\"", "output": "[40]", "fn_name": "points"}, {"input": "\"33233\"", "output": "[40]", "fn_name": "points"}, {"input": "\"22262\"", "output": "[40]", "fn_name": "points"}, {"in...
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\nArtem has an array of n positive integers. Artem decided to play with it. The game consists of n moves. Each ...
[{"input": "10\n96 66 8 18 30 48 34 11 37 42\n", "output": " 299\n"}, {"input": "9\n72 49 39 50 68 35 75 94 56\n", "output": " 435\n"}, {"input": "8\n77 84 26 34 17 56 76 3\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\nAlice and Brown are brothers in a family and each receives pocket money in celebration of the coming year. Th...
[{"input": "1001 20263", "output": "10632\n"}, {"input": "1011 20263", "output": "10637\n"}, {"input": "0010 12073", "output": "6041\n"}, {"input": "0000 12073", "output": "6036\n"}, {"input": "0001 12073", "output": "6037\n"}, {"input": "0011 12073", "output": "6042\n"}, {"input": "0111 12073", "output": "6092\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\nAn online contest will soon be held on ForceCoders, a large competitive programming platform. The authors hav...
[{"input": "50\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\n48 100\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# Task\n You are given a car odometer which displays the miles traveled as an integer. \n \n The odometer has...
[{"input": "165826622", "output": "[69517865]", "fn_name": "faulty_odometer"}, {"input": "999999", "output": "[531440]", "fn_name": "faulty_odometer"}, {"input": "2005", "output": "[1462]", "fn_name": "faulty_odometer"}, {"input": "1500", "output": "[1053]", "fn_name": "faulty_odometer"}, {"input": "13", "output": "[12...
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\nOne very important person has a piece of paper in the form of a rectangle a × b.\n\nAlso, he has n seals. Eac...
[{"input": "30 100 101\n60 34\n29 82\n89 77\n39 1\n100 100\n82 12\n57 87\n93 43\n78 50\n38 55\n37 9\n67 5\n100 100\n100 100\n82 47\n3 71\n100 100\n19 26\n25 94\n89 5\n100 100\n32 1\n100 100\n34 3\n40 99\n100 100\n36 12\n100 100\n100 100\n100 100\n", "output": "10039\n"}, {"input": "30 100 101\n60 34\n29 82\n89 77\n39 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\nIt's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents...
[{"input": "251656215122324104 164397544865601257\n", "output": "YES\n"}, {"input": "669038685745448997 501718093668307460\n", "output": "YES\n"}, {"input": "255787422422806632 146884995820359999\n", "output": "YES\n"}, {"input": "545668929424440387 508692735816921376\n", "output": "YES\n"}, {"input": "5481476546637233...
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 will be given a string and your task is to return the most valuable character. The value of...
[{"input": "\"acefacefacef\"", "output": "[\"a\"]", "fn_name": "solve"}, {"input": "\"efghijefghi\"", "output": "[\"e\"]", "fn_name": "solve"}, {"input": "\"dcbadcba\"", "output": "[\"a\"]", "fn_name": "solve"}, {"input": "\"acefacef\"", "output": "[\"a\"]", "fn_name": "solve"}, {"input": "\"axyzxyz\"", "output": "[\"x...
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\nHow many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?\n\n-----Constrain...
[{"input": "182", "output": "-134\n"}, {"input": "339", "output": "-291\n"}, {"input": "-117", "output": "165\n"}, {"input": "467", "output": "-419\n"}, {"input": "-155", "output": "203\n"}, {"input": "324", "output": "-276\n"}, {"input": "-263", "output": "311\n"}, {"input": "349", "output": "-301\n"}, {"input": "-414...
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\nProgrammers' kids solve this riddle in 5-10 minutes. How fast can you do it?\n\n\n-----Input-----\n\nThe inpu...
[{"input": "1215860145\n", "output": "10\n"}, {"input": "2000000000\n", "output": "4\n"}, {"input": "143165576\n", "output": "14\n"}, {"input": "1919020031\n", "output": "3\n"}, {"input": "1795248373\n", "output": "5\n"}, {"input": "1818960378\n", "output": "5\n"}, {"input": "1285316221\n", "output": "3\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\nOn a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the...
[{"input": "6 5\n-1330303216 -293179180 212428642 418379342 586260100 802780784\n-116893124 193944314 556319375 1032972003 1322749268", "output": "988916105\n"}, {"input": "6 5\n-1330303216 -293179180 122359065 418379342 586260100 802780784\n-116893124 193944314 556319375 1032972003 1322749268", "output": "494088334\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 are given a tree consisting of $n$ vertices. A tree is an undirected connected acyclic graph. [Image] Exa...
[{"input": "15\n10 34 69 39 82 49 57 22 50 25 82 37 33 62 69\n35 14 68 31 26 8 33 98 33 95 19 22 89 18 67\n80 24 10 5 26 85 69 21 29 38 89 24 78 68 88\n13 1\n6 12\n8 4\n11 9\n14 11\n15 5\n3 15\n1 10\n13 9\n7 12\n14 6\n3 2\n2 7\n4 5\n", "output": "620\n2 3 2 2 3 3 1 1 3 3 2 2 1 1 1 \n"}, {"input": "15\n10 34 69 39 82 49...
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 and Aoki will play a game using a grid with H rows and W columns of square cells. There are N obsta...
[{"input": "10 10 14\n4 3\n2 2\n9 4\n9 10\n7 7\n10 2\n10 10\n5 4\n3 4\n2 8\n6 4\n5 4\n5 8\n9 0", "output": "8\n"}, {"input": "10 10 14\n4 3\n2 1\n7 3\n9 10\n7 7\n8 1\n10 10\n5 4\n2 4\n2 8\n6 4\n4 4\n9 6\n9 -1", "output": "1\n"}, {"input": "10 10 14\n6 3\n2 2\n9 10\n9 10\n7 7\n8 2\n10 10\n5 6\n2 5\n2 8\n6 4\n5 4\n5 8\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\nWhile swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry a...
[{"input": "9\n123456789\n", "output": "YES\n"}, {"input": "9\n103481226\n", "output": "YES\n"}, {"input": "9\n246112056\n", "output": "YES\n"}, {"input": "9\n289887167\n", "output": "YES\n"}, {"input": "9\n722403540\n", "output": "YES\n"}, {"input": "9\n722403540\n", "output": "YES\n"}, {"input": "9\n246112056\n", "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\nGerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are ...
[{"input": "1000 1000 1000 1000 1000 1000\n", "output": "6000000\n"}, {"input": "718 466 729 470 714 481\n", "output": "2102808\n"}, {"input": "677 303 685 288 692 296\n", "output": "1365807\n"}, {"input": "1000 1000 1 1000 1000 1\n", "output": "2004000\n"}, {"input": "888 888 888 887 889 887\n", "output": "4729487\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\nThe objective is to disambiguate two given names: the original with another\n\nLet's start simple, and just w...
[{"input": "\"Carlos Ray Norris\"\n\"carlos Ray Norris\"", "output": "[false]", "fn_name": "could_be"}, {"input": "\"Carlos Ray Norris\"\n\"Carlos-Ray Norris\"", "output": "[false]", "fn_name": "could_be"}, {"input": "\"Carlos Ray Norris\"\n\"Carlos Ray Norris\"", "output": "[true]", "fn_name": "could_be"}, {"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\nLimak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive in...
[{"input": "1000000000000000\n", "output": "18 999999993541753\n"}, {"input": "1000000000000000\n", "output": "18 999999993541753\n"}, {"input": "1000000000000000\n", "output": "18 999999993541753\n"}, {"input": "999999993700000\n", "output": "18 999999993541753\n"}, {"input": "385925923480002\n", "output": "17 3859259...
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 constraints.\n\nYou are given a sequence $a$ consisting...
[{"input": "6\n8\n1 1 2 10 3 2 1 1\n3\n2 4 3\n4\n2 10 11 1\n1\n26\n2\n1 1\n3\n2 1 1\n", "output": "6\n1\n1\n1\n2\n2\n"}, {"input": "6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 1\n3\n1 1 1\n", "output": "7\n2\n4\n1\n1\n3\n"}, {"input": "6\n8\n1 1 2 2 3 3 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 1\n3\n1 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\nWe'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For ex...
[{"input": "10000000000000000 10000000000000000 1\n", "output": "588235294117647\n"}, {"input": "10000000000000000 10000000000000000 1000000000\n", "output": "588235\n"}, {"input": "10000000000000000 10000000000000000 1\n", "output": "588235294117647\n"}, {"input": "10000000000000000 10000000000000000 1000000000\n", "o...
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. \n3:33\nIt's possible for all t...
[{"input": "6\n24 60\n34 50\n10 11\n10 12\n11 11\n1 2", "output": "19\n20\n10\n11\n10\n1\n"}, {"input": "6\n24 60\n34 50\n10 11\n10 12\n13 11\n1 2", "output": "19\n20\n10\n11\n11\n1\n"}, {"input": "6\n24 60\n34 50\n10 11\n15 12\n11 11\n1 1", "output": "19\n20\n10\n13\n10\n1\n"}, {"input": "6\n24 60\n34 88\n10 11\n10 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\nLittle Elephant likes lemonade.\n\nWhen Little Elephant visits any room, he finds the bottle of the lemonade ...
[{"input": "2\n3 3\n0 2 0\n3 1 2 3\n1 11\n2 4 13\n4 7\n0 2 2 0 1 0 0\n1 14\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 2", "output": "18\n36\n"}, {"input": "2\n3 3\n0 2 0\n3 1 2 3\n1 11\n2 4 13\n4 7\n0 2 2 0 1 0 0\n1 19\n3 9 4 5\n7 1 2 3 4 5 6 7\n1 2", "output": "18\n41\n"}, {"input": "2\n3 3\n0 2 1\n3 1 2 3\n1 11\n2 4 7\n4 7\n0 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\nB: Twice as own\n\nproblem\n\nYou will be given Q queries. Since one positive integer N is given for each que...
[{"input": "3\n3\n2233\n2", "output": "0\n1254\n0\n"}, {"input": "3\n3\n3148\n2", "output": "0\n1810\n0\n"}, {"input": "3\n2\n1144\n1", "output": "0\n614\n0\n"}, {"input": "3\n2\n1079\n1", "output": "0\n576\n0\n"}, {"input": "3\n2\n1651\n0", "output": "0\n911\n0\n"}, {"input": "3\n2\n1215\n1", "output": "0\n653\n0\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\nThis Christmas Santa gave Masha a magic picture and a pencil. The picture consists of n points connected by m...
[{"input": "100 50\n66 3\n92 79\n9 44\n84 45\n30 63\n30 20\n33 86\n8 83\n40 75\n7 36\n91 4\n76 88\n77 76\n28 27\n6 52\n41 57\n8 23\n34 75\n50 15\n86 68\n36 98\n30 84\n37 62\n22 4\n6 45\n72 80\n98 74\n78 84\n1 54\n99 27\n84 91\n78 7\n80 61\n67 48\n51 52\n36 72\n97 87\n25 17\n20 80\n20 39\n72 5\n21 77\n48 1\n63 21\n92 45...
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 ABC number of a string T is the number of triples of integers (i, j, k) that satisfy all of the following...
[{"input": "BACAB?BABBACBBCAC??AABA?BAA??BA?AAA?A??A?AACC?C??A??B?A?CABC?CA?BB??BBAABB?C??AA??A??AABBAC??B?B?ABA?BAB???AAB?A??BAACA?BAAA?ACCCA?C?BA?AAABABAA?BCCC?BAAB??ABBACCBAACCAACBCBA?CA?CC?????ABBCA?BAB?BC?ACABBA??????CCA?ACCBABA???AACBBBBA?BACAAA?BBABACC?CACA?BBCC?A?ABBCAAAAC?BCBBBCA?ABB?BCABACA??A?A?AA?BACC??AA?A...
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\nGerald has n younger brothers and their number happens to be even. One day he bought n^2 candy bags. One bag ...
[{"input": "100\n", "output": "1 10000 2 9999 3 9998 4 9997 5 9996 6 9995 7 9994 8 9993 9 9992 10 9991 11 9990 12 9989 13 9988 14 9987 15 9986 16 9985 17 9984 18 9983 19 9982 20 9981 21 9980 22 9979 23 9978 24 9977 25 9976 26 9975 27 9974 28 9973 29 9972 30 9971 31 9970 32 9969 33 9968 34 9967 35 9966 36 9965 37 9964 3...
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 positive integers $n$ and $s$. Find the maximum possible median of an array of $n$ non-nega...
[{"input": "8\n1 1\n1 10\n3 5\n2 2\n14 33\n4 23\n1 1010001000\n1000100000 1\n", "output": "1\n10\n2\n1\n4\n7\n1010001000\n0\n"}, {"input": "8\n1 1\n1 10\n3 5\n2 1\n14 33\n4 23\n1 1010001000\n1000100000 1\n", "output": "1\n10\n2\n0\n4\n7\n1010001000\n0\n"}, {"input": "8\n1 1\n1 10\n3 5\n2 1\n14 33\n4 44\n2 1010001000\n1...
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 n × n square matrix is special, if: it is binary, that is, each cell contains either a 0, or a 1; the nu...
[{"input": "7 4 100501\n0100010\n0000101\n0100100\n0000011\n", "output": "6\n"}, {"input": "7 4 100501\n0100010\n0000101\n0100100\n0000011\n", "output": "6\n"}, {"input": "6 4 100501\n100010\n100100\n010100\n000011\n", "output": "2\n"}, {"input": "6 4 100501\n100010\n100100\n010100\n000011\n", "output": "2\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\nTwo integer sequences existed initially, one of them was strictly increasing, and another one — strictly decr...
[{"input": "12\n12 8 1 3 7 5 9 6 4 10 11 2\n", "output": "YES\n1 1 0 0 1 0 0 1 1 0 0 1 \n"}, {"input": "12\n12 8 1 3 7 5 9 6 4 10 11 2\n", "output": "YES\n1 1 0 0 1 0 0 1 1 0 0 1 \n"}, {"input": "12\n12 10 1 3 7 5 9 6 4 10 11 2\n", "output": "YES\n1 1 0 0 1 0 0 1 1 0 0 1\n"}, {"input": "12\n12 10 1 3 7 5 9 6 4 10 22 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\nMaxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discount system...
[{"input": "48\n14 2 5 3 10 10 5 6 14 8 19 13 4 4 3 13 18 19 9 16 3 1 14 9 13 10 13 4 12 11 8 2 18 20 14 11 3 11 18 11 4 2 7 2 18 19 2 8\n70\n9497 5103 1001 2399 5701 4053 3557 8481 1736 4139 5829 1107 6461 4089 5936 7961 6017 1416 1191 4635 4288 5605 8857 1822 71 1435 2837 5523 6993 2404 2840 8251 765 5678 7834 8595 3...
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're given an integer N. Write a program to calculate the sum of all the digits of N. \n\n-----Input-----\n...
[{"input": "3 \n36926\n147301\n1688", "output": "26\n16\n23\n"}, {"input": "3 \n36926\n168223\n1688", "output": "26\n22\n23\n"}, {"input": "3 \n36926\n168223\n2811", "output": "26\n22\n12\n"}, {"input": "3 \n17364\n141737\n8146", "output": "21\n23\n19\n"}, {"input": "3 \n36926\n213494\n1688", "output": "26\n23\n23\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\nThere are n knights sitting at the Round Table at an equal distance from each other. Each of them is either i...
[{"input": "113\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n", "output": "YES\n"}, {"input": "100\n1 0 1 1 1 1 0 1 1 1 0 0 0 0 0 0 0 1 0...
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 Snukes lining up in a row. You are given a string S of length N. The i-th Snuke from the front ha...
[{"input": "12001021211100201020", "output": "543589959"}, {"input": "2100", "output": "21\n"}, {"input": "101", "output": "14\n"}, {"input": "111", "output": "20\n"}, {"input": "011", "output": "10\n"}, {"input": "110", "output": "15\n"}, {"input": "102", "output": "16\n"}, {"input": "202", "output": "10\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\nYou are given a string $s$ of length $n$ consisting of lowercase Latin letters. You may apply some operations...
[{"input": "500\nbbababaabaabaabbbbbbaabbabbabbaabababababbbbabaaabbbbaaabbbbbbbabababaaaaabbbbabaababbababbaaaaaabbaaabbaabaaababbbbbabbaabaabaabbbaaabaabbaaabbaabababbaaabaaabaaaaabbbababaabbbbabbbbbababbbaabaabbabaabbabbababbbbbaababbaabbbbbbbbaabbabbbabababaaaaaaaaaabababaaabbaabbbabbabbbbabbbaabaaabbbaabbabbbbbbba...
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\nOne day Greg and his friends were walking in the forest. Overall there were n people walking, including Greg....
[{"input": "50 207\n50 100 100 100 100 50 100 100 100 50 100 100 100 50 100 100 50 100 50 100 50 100 100 100 50 100 50 50 100 50 100 100 50 100 100 100 100 50 100 100 100 100 50 50 50 100 100 50 100 100\n", "output": "55\n833060250"}, {"input": "50 125\n50 50 50 100 100 50 100 100 50 50 100 100 100 100 100 100 50 50 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\nFox Ciel studies number theory.\n\nShe thinks a non-empty set S contains non-negative integers is perfect if ...
[{"input": "1000000000\n", "output": "866215044\n"}, {"input": "1000000000\n", "output": "866215044\n"}, {"input": "1059916422\n", "output": "691290739\n"}, {"input": "1000001000\n", "output": "214567917\n"}, {"input": "1001707390\n", "output": "183716036\n"}, {"input": "1063854616\n", "output": "710920454\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\nYou are given a rooted tree of $2^n - 1$ vertices. Every vertex of this tree has either $0$ children, or $2$ ...
[{"input": "8\nABBBAAABBBAABABAAAABAABAABBABABBABABBBBBAABBAABBBAABBBBAAABBABAABBBBBAAABBABAABAABBBBBAABBBABAAAAAAABBAAABBAABBABABABABBAABBAAABBBBBAAAABBBBAAAABAABABAABBBAABBBAABBAAABBABAABAAABBBAAAABBAAABABBBABAAAAABBABBABAABBBBBAAABBBBBBAABABBAAABBABBABABAAABBABBABABA\n", "output": "479173089\n"}, {"input": "8\nAAAAB...
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\nJohnny has just found the new, great tutorial: \"How to become a grandmaster?\". The tutorial tells many stra...
[{"input": "1\n71 4\n100 99 98 97 96 95 94 93 92 91 90 87 86 82 79 78 76 71 70 69 68 66 64 63 62 56 55 53 52 51 50 46 43 42 39 38 37 35 33 31 30 29 22 20 19 18 11 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "862166308\n"}, {"input": "1\n71 2\n100 99 98 97 96 95 94 93 92 91 90 87 86 82 79 78 76 71 70 ...
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\nScientists working internationally use metric units almost exclusively. Unless that is, they wish to crash mu...
[{"input": "9000000000000000.0", "output": "[\"9Pm\"]", "fn_name": "meters"}, {"input": "9000000000000.0", "output": "[\"9Tm\"]", "fn_name": "meters"}, {"input": "123456", "output": "[\"123.456km\"]", "fn_name": "meters"}, {"input": "9000000000.0", "output": "[\"9Gm\"]", "fn_name": "meters"}, {"input": "12300000", "out...
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\nVasya plays Robot Bicorn Attack.\n\nThe game consists of three rounds. For each one a non-negative integer am...
[{"input": "123456789123456789123456789123\n", "output": "-1\n"}, {"input": "111111111111111111111111111111\n", "output": "-1\n"}, {"input": "349967407479541078587181768161\n", "output": "-1\n"}, {"input": "429496729742949672974294967297\n", "output": "-1\n"}, {"input": "999999999999999999999999999999\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\nProfessor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows.\n\nThere...
[{"input": "45\n45 44 40 43 27 29 41 39 30 34 28 26 25 42 38 19 32 24 9 37 23 21 20 18 33 36 16 22 35 17 7 4 15 31 13 11 2 3 10 12 14 6 8 5 1\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45\n", "output": "22\n"}, {"input": "40\n40 27 29 39 3...
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 integers $n$ and $m$. Calculate the number of pairs of arrays $(a, b)$ such that:\n\n the ...
[{"input": "1000 10\n", "output": "414070642\n"}, {"input": "1000 10\n", "output": "414070642\n"}, {"input": "1000 2\n", "output": "917124963\n"}, {"input": "1000 2\n", "output": "917124963\n"}, {"input": "379 10\n", "output": "181813681\n"}, {"input": "723 9\n", "output": "157557417\n"}, {"input": "678 7\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\nThere are $n$ points on the plane, $(x_1,y_1), (x_2,y_2), \\ldots, (x_n,y_n)$.\n\nYou need to place an isosce...
[{"input": "10\n100 34\n27 17\n17 73\n12 60\n53 25\n46 31\n61 86\n22 91\n82 91\n8 41\n", "output": "173\n"}, {"input": "10\n100 34\n27 17\n17 73\n12 60\n53 25\n46 31\n51 86\n22 91\n82 91\n8 41\n", "output": "173\n"}, {"input": "10\n110 34\n27 17\n17 73\n12 60\n53 25\n46 31\n51 86\n22 91\n82 91\n8 41\n", "output": "173\...
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 super computer has been built in the Turtle Academy of Sciences. The computer consists of n·m·k CPUs. The a...
[{"input": "100 1 1\n0\n\n1\n\n1\n\n1\n\n0\n\n0\n\n0\n\n1\n\n1\n\n0\n\n0\n\n1\n\n0\n\n1\n\n1\n\n1\n\n1\n\n0\n\n0\n\n1\n\n1\n\n1\n\n0\n\n0\n\n0\n\n0\n\n0\n\n1\n\n1\n\n0\n\n1\n\n1\n\n1\n\n0\n\n1\n\n0\n\n0\n\n1\n\n0\n\n1\n\n1\n\n0\n\n0\n\n0\n\n0\n\n1\n\n0\n\n1\n\n0\n\n0\n\n1\n\n1\n\n1\n\n0\n\n1\n\n1\n\n0\n\n1\n\n1\n\n1\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\nOnce upon a time there were several little pigs and several wolves on a two-dimensional grid of size n × m. E...
[{"input": "10 10\n..P..WWP.W\nPP.WPPPPPP\nWWPP.PPWPP\nPPPPW..PPW\nPP.PW.P.PW\nWW..PPWWP.\n..PW...PP.\n.PPPP.PPPW\nPP.PWP..P.\nPWPPP..WWP\n", "output": "20\n"}, {"input": "10 10\nWPPPPWPPWP\nPPPWPPPPPP\nPWPPPPWPPP\nPPPPWPPPWP\nWPPPPPPPPP\nPPPWPPWPPP\nPWPPPPPPWP\nPPPPWPPPPP\nWPPPPPWPPP\nPPPWPPPPWP\n", "output": "18\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 late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifi...
[{"input": "4 6\n5 1000000000 1790978867 12\n", "output": "1790978867\n"}, {"input": "4 9\n5 1000000000 1766326397 19\n", "output": "1766326397\n"}, {"input": "4 9\n5 1000000000 1204240164 12\n", "output": "1204240164\n"}, {"input": "4 6\n6 1000000000 1790978867 12\n", "output": "1790978867\n"}, {"input": "4 9\n5 10001...
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\nCheck if given chord is minor or major.\n\n_____________________________________________________________\nRul...
[{"input": "\"D F A C#\"", "output": "[\"Not a chord\"]", "fn_name": "minor_or_major"}, {"input": "\"Bb Gb Eb\"", "output": "[\"Not a chord\"]", "fn_name": "minor_or_major"}, {"input": "\"A C# D#\"", "output": "[\"Not a chord\"]", "fn_name": "minor_or_major"}, {"input": "\"D F A G\"", "output": "[\"Not a chord\"]", "fn...
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\nPolycarp has n dice d_1, d_2, ..., d_{n}. The i-th dice shows numbers from 1 to d_{i}. Polycarp rolled all th...
[{"input": "10 20\n1 1 1 1 5 100 1 1 1 1\n", "output": "0 0 0 0 0 95 0 0 0 0 "}, {"input": "10 20\n1 1 1 1 5 100 1 1 1 1\n", "output": "0 0 0 0 0 95 0 0 0 0\n"}, {"input": "10 20\n1 1 1 1 10 100 1 1 1 1\n", "output": "0 0 0 0 0 90 0 0 0 0"}, {"input": "10 20\n1 1 1 1 11 100 1 1 1 1\n", "output": "0 0 0 0 0 89 0 0 0 0"}...
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 factory that inputs the data of the side and diagonal lengths to the machine and cuts out the plas...
[{"input": "3,4,5\n5,5,8\n4,5,4\n5,4,3", "output": "1\n1\n"}, {"input": "3,3,5\n5,5,8\n4,4,4\n5,4,3", "output": "0\n3\n"}, {"input": "3,4,5\n5,5,8\n4,5,4\n3,4,5", "output": "2\n1\n"}, {"input": "3,4,5\n8,5,5\n4,5,4\n3,4,5", "output": "2\n0\n"}, {"input": "3,5,5\n6,5,8\n4,4,5\n5,4,3", "output": "0\n1\n"}, {"input": "3,3...
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\nAs usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:\n\n...
[{"input": "116 10\n477 -765 -756 376 -48 -75 768 -658 263 -207 362 -535 96 -960 630 -686 609 -830 889 57 -239 346 -298 -18 -107 853 -607 -443 -517 371 657 105 479 498 -47 432 503 -917 -656 610 -466 216 -747 -587 -163 -174 493 -882 853 -582 -774 -477 -386 610 -58 557 968 196 69 610 -38 366 -79 574 170 317 332 189 158 -...
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 have N bamboos. The lengths (in centimeters) of these are l_1, l_2, ..., l_N, respectively.\nYour objecti...
[{"input": "8 1000 800 100\n300\n333\n400\n444\n500\n555\n600\n666\n", "output": "243\n"}, {"input": "8 1000 898 567\n737\n433\n926\n825\n780\n516\n964\n299\n", "output": "115\n"}, {"input": "8 1000 328 262\n854\n364\n362\n544\n270\n235\n209\n353\n", "output": "65\n"}, {"input": "8 1100 800 100\n300\n333\n400\n444\n500...
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\nAyrat has number n, represented as it's prime factorization p_{i} of size m, i.e. n = p_1·p_2·...·p_{m}. Ayra...
[{"input": "67\n98929 19079 160079 181891 17599 91807 19079 98929 182233 92647 77477 98929 98639 182233 181891 182233 160079 98929 19079 98639 114941 98929 161341 91807 160079 22777 132361 92647 98929 77477 182233 103913 160079 77477 55711 77477 77477 182233 114941 91807 98929 19079 104393 182233 182233 131009 132361 1...
code_stdio