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\n# Definition\n\n**_Jumping number_** is the number that *All adjacent digits in it differ by 1*.\n\n____\n\n#...
[{"input": "987654322", "output": "[\"Not!!\"]", "fn_name": "jumping_number"}, {"input": "23", "output": "[\"Jumping!!\"]", "fn_name": "jumping_number"}, {"input": "32", "output": "[\"Jumping!!\"]", "fn_name": "jumping_number"}, {"input": "98", "output": "[\"Jumping!!\"]", "fn_name": "jumping_number"}, {"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\nCaptain Fint is involved in another treasure hunt, but have found only one strange problem. The problem may b...
[{"input": "10\n-18 -1 2 3 5 -2 -3 -1 2 -11\n-1 -1 2 2 -1 5 5 7 7 9\n", "output": "-17\n3 4 2 9 5 7 10 8 6 1 "}, {"input": "10\n-10 -1 2 1 5 -2 -3 -3 2 -6\n-1 -1 2 2 -1 5 5 10 7 9\n", "output": "-10\n3 4 2 9 5 7 10 8 6 1 "}, {"input": "10\n-10 -1 2 2 5 -2 -3 -4 2 -6\n-1 -1 2 2 -1 5 5 7 7 9\n", "output": "-9\n3 4 2 9 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\nWe have the first value of a certain sequence, we will name it ```initVal```.\nWe define pattern list, ```pa...
[{"input": "1000\n[2, 2, 5, 8]\n25500", "output": "[26]", "fn_name": "sumDig_nthTerm"}, {"input": "1000\n[2, 2, 5, 8]\n2550", "output": "[14]", "fn_name": "sumDig_nthTerm"}, {"input": "100\n[2, 2, 5, 8]\n157", "output": "[16]", "fn_name": "sumDig_nthTerm"}, {"input": "10\n[2, 2, 5, 8]\n157", "output": "[16]", "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\nAlice received a set of Toy Train™ from Bob. It consists of one train and a connected railway network of $n$ ...
[{"input": "5000 1\n4008 1126\n", "output": "6125 6124 6123 6122 6121 6120 6119 6118 6117 6116 6115 6114 6113 6112 6111 6110 6109 6108 6107 6106 6105 6104 6103 6102 6101 6100 6099 6098 6097 6096 6095 6094 6093 6092 6091 6090 6089 6088 6087 6086 6085 6084 6083 6082 6081 6080 6079 6078 6077 6076 6075 6074 6073 6072 6071 ...
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 all know about Roman Numerals, and if not, here's a nice [introduction kata](http://www.codewars.com/kata/...
[{"input": "1632\n2", "output": "[\"MDCXXXII:\"]", "fn_name": "roman_fractions"}, {"input": "5000", "output": "[\"MMMMM\"]", "fn_name": "roman_fractions"}, {"input": "0\n11", "output": "[\"S:.:\"]", "fn_name": "roman_fractions"}, {"input": "0\n-1", "output": "[\"NaR\"]", "fn_name": "roman_fractions"}, {"input": "0\n12"...
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\nWell met with Fibonacci bigger brother, AKA Tribonacci.\n\nAs the name may already reveal, it works basically...
[{"input": "[0.5, 0.5, 0.5]\n30", "output": "[[0.5, 0.5, 0.5, 1.5, 2.5, 4.5, 8.5, 15.5, 28.5, 52.5, 96.5, 177.5, 326.5, 600.5, 1104.5, 2031.5, 3736.5, 6872.5, 12640.5, 23249.5, 42762.5, 78652.5, 144664.5, 266079.5, 489396.5, 900140.5, 1655616.5, 3045153.5, 5600910.5, 10301680.5]]", "fn_name": "tribonacci"}, {"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\nThere is a string s of length 3 or greater.\nNo two neighboring characters in s are equal.\nTakahashi and Aok...
[{"input": "fzezbxdbwzbqzxdlkqpcheqlhlfkohdekflklzxpxodqexwewpfbobcdlxowlqzxkqdobwodoxdhcohfdzhlfzbzhcobhewxzodzqfxfbokxkqexwzdfxwhwfeocxobxkocphcofwlkzkcqpblclblbecbwozldhxfdekpwxocfhbzkxqwhkofcxzqlwhpdzkdcedxwkqpqpfchfeclcxeqxfcbzfkophefxkqclxwfoxdfpbeowxpxfdwpolkczlpcdhkhkhohplbfzkolqlzfbhfzldowfqkqczklkqhdqwzoxzwlp...
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 N integers. The i-th integer is A_i.\nFind \\sum_{i=1}^{N-1}\\sum_{j=i+1}^{N} (A_i \\mbox{ XOR } A_j)...
[{"input": "10\n3 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820\n", "output": "103715602\n"}, {"input": "10\n1 14 159 2653 58979 323846 2643383 27950288 419716939 9375105820", "output": "103715608\n"}, {"input": "10\n1 14 159 2653 58979 376446 2643383 27950288 419716939 9375105820", "output": "10432892...
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 Petya very much likes computers. Recently he has received a new \"Ternatron IV\" as a gift from his mo...
[{"input": "274842194 1000000000\n", "output": "1162261466\n"}, {"input": "274842194 1000100000\n", "output": "1162105233\n"}, {"input": "922263603 387506683\n", "output": "1064907553\n"}, {"input": "1000000000 100000000\n", "output": "650219958\n"}, {"input": "440760623 316634331\n", "output": "1052493562\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\nYash has recently learnt about the Fibonacci sequence and is very excited about it. He calls a sequence Fibon...
[{"input": "11\n-9 -1 -10 9 7 -4 0 -13 -3 3 5\n", "output": "4\n"}, {"input": "11\n-9 -1 -10 9 7 -4 0 -13 -2 3 5\n", "output": "5\n"}, {"input": "11\n-9 -1 -2 9 7 -4 -1 -13 -3 3 5\n", "output": "5\n"}, {"input": "11\n-9 -1 -10 9 7 -4 0 -8 -3 3 5\n", "output": "5\n"}, {"input": "11\n-9 -1 -10 9 7 -4 0 -8 -3 3 5\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\nThere are some ambiguities when one writes Berland names with the letters of the Latin alphabet.\n\nFor examp...
[{"input": "101\nukuu\nh\nouuo\no\nkkuo\nko\nu\nh\nhku\nh\nh\nhuo\nuhoh\nkuu\nhu\nhkko\nuhuk\nkoho\nh\nhukk\noohu\nkk\nkko\nou\noou\nh\nuuu\nuh\nkhuk\nokoo\nouou\nuo\nkk\noo\nhuok\no\nu\nhok\nhu\nhhuu\nkuu\nooho\noku\nhuoh\nhhkh\nuuuh\nouo\nhou\nhhu\nh\no\nokou\nuo\nh\nukk\nu\nhook\nh\noouk\nokuo\nkuuu\nk\nuvk\nu\nukk\...
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 n × m rectangular table consisting of lower case English letters. In one operation you can c...
[{"input": "4 100\ngdgmmejiigzsmlarrnfsypvlbutvoxazcigpcospgztqkowfhhbnnbxxrbmwbxwkvxlxzabjjjdtbebedukdelooqlxnadjwjpnp\ndmtsnsbsfdzqvydxcdcnkkfcbseicxhvclsligbhqlkccwujpirymoshkqcosbtlxdypsdqkqaolrqtiibymavcwmbfryttdckhw\njtdmpdljcpciuuoznvqqmafvoqychzfslmwqouuarxctunlzegxsucrwontjplkkxhgixgdbvnewphnatxnwqxqshcexpxlyj...
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 Bob saw a string. It contained so many different letters, that the letters were marked by numbers, but a...
[{"input": "100\n8 43 55 27 70 81 66 10 49 67 24 61 53 0 2 76 96 16 16 1 78 1 69 69 4 59 6 87 98 14 98 20 12 48 20 41 67 90 20 96 44 8 77 94 84 2 61 27 90 42 66 84 5 19 68 13 5 53 13 87 70 41 48 40 19 61 72 31 4 4 59 100 50 64 84 10 96 16 73 3 63 85 67 91 74 63 22 34 6 96 78 42 61 85 3 95 98 84 66 78\n", "output": "31\...
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\nWrite a program which reads $n$ items and sorts them. Each item has attributes $\\\\{value, weight, type, dat...
[{"input": "5\n105 24 C 1500000000000 white\n100 23 C 1500000000000 blue\n105 23 A 1480000000000 pink\n110 25 B 1500000000000 black\n110 20 A 1484487224415 gree", "output": "100 23 C 1500000000000 blue\n105 23 A 1480000000000 pink\n105 24 C 1500000000000 white\n110 20 A 1484487224415 gree\n110 25 B 1500000000000 black\...
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 arrays $a_1, a_2, \\dots , a_n$ and $b_1, b_2, \\dots , b_m$. Array $b$ is sorted in ascend...
[{"input": "77 22\n3 2 4 8 10 7 5 7 9 7 5 6 2 9 10 1 5 4 5 8 6 9 3 1 8 1 10 9 6 7 7 1 5 3 6 4 9 10 7 8 2 3 10 10 9 9 2 9 1 9 7 3 2 4 7 7 1 1 10 4 2 2 8 3 2 9 11 10 5 6 7 1 10 8 3 9 1\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22\n", "output": "0\n"}, {"input": "77 22\n3 2 4 8 10 7 5 7 9 7 5 6 2 9 10 1 5 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\nAfter making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle...
[{"input": "4\n-474 -894\n-474 -833\n-446 -894\n-446 -833\n", "output": "1708\n"}, {"input": "4\n-474 -894\n-474 -833\n-446 -894\n-446 -833\n", "output": "1708\n"}, {"input": "4\n-414 -891\n-414 896\n346 -891\n346 896\n", "output": "1358120\n"}, {"input": "4\n-796 -330\n-796 758\n171 -330\n171 758\n", "output": "105209...
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\"Teishi-zushi\", a Japanese restaurant, is a plain restaurant with only one round counter. The outer circumf...
[{"input": "15 10000000000\n400000000 1000000000\n800000000 1000000000\n1900000000 1000000000\n2400000000 1000000000\n2900000000 1000000000\n3300000000 1000000000\n3700000000 1000000000\n3800000000 1000000000\n4000000000 1000000000\n4100000000 1000000000\n5200000000 1000000000\n6600000000 1000000000\n8000000000 1000000...
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\nWrite a function `sumTimesTables` which sums the result of the sums of the elements specified in `tables` mul...
[{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n1\n10", "output": "[3025]", "fn_name": "sum_times_tables"}, {"input": "[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n1\n10", "output": "[3025]", "fn_name": "sum_times_tables"}, {"input": "[5, 4, 7, 8, 9, 6, 3, 2, 10, 1]\n1\n10", "output": "[3025]", "fn_name": "sum_times_tables"}, {"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\nGiven an array $a_1, a_2, \\dots, a_n$, you need to handle a total of $q$ updates and queries of two types:\n...
[{"input": "1\n8 35\n14 14 14 14 14 14 14 14\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 2 3\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 6 7\n1 1 8\n2 1\n2 2\n2 3\n2 4\n2 5\n2 6\n2 7\n2 8\n", "output": "5\n5\n5\n5\n5\n5\n5\n5\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\nAfter celebrating the midcourse the students of one of the faculties of the Berland State University decided ...
[{"input": "40\n119631 119631 772776 119631 658661 119631 108862 524470 125132 700668 69196 844949 154577 108862 108862 108862 597344 940938 989698 108862 154577 69196 125132 687080 940938 125132 69196 69196 125132 566152 953083 406319 380068 119631 154577 125132 413984 69196 154577 154577\n", "output": "108862\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\nVasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vaca...
[{"input": "718167999978848233 1000000000000000000 1000000000000000000\n", "output": "281832000021151766\n"}, {"input": "338654687020656675 999999999999999999 1000000000000000000\n", "output": "661345312979343324\n"}, {"input": "643704740517968615 299040014770868475 999999999999999999\n", "output": "1057255244711162906...
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 Martian boy is named s — he has got this name quite recently from his parents for his coming of age birthda...
[{"input": "mars\nsunvenusearthmarsjupitersaturnuranusneptune\n", "output": "0\n"}, {"input": "mars\nsunvenusearthmarsjupitersatuqnuranusneptune\n", "output": "0\n"}, {"input": "mars\nsunvenusearthmarsjupitersatuqnuranusnepttne\n", "output": "0\n"}, {"input": "mars\nsunvenusfarthmarsjupitersaturnuranusneptune\n", "outp...
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\nVector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a ...
[{"input": "5000000000000000000 4999999999999999837 4999999999999999963\n", "output": "1249999999999999959/1250000000000000000\n"}, {"input": "5000000000000000000 4999999999999999837 4999999999999999963\n", "output": "1249999999999999959/1250000000000000000\n"}, {"input": "5000000000000000000 2229502307241477700 499999...
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\nArray of integers is unimodal, if:\n\n it is strictly increasing in the beginning; after that it is constan...
[{"input": "100\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 100...
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 boxes with colored balls on the table. Colors are numbered from 1 to n. i-th box contains a_{i} b...
[{"input": "200\n1 2 4 10 5 8 1 10 9 10 1 9 5 5 3 10 4 7 7 1 5 10 1 6 7 3 9 3 5 8 8 9 7 3 1 5 6 7 3 3 1 4 9 2 8 7 2 10 2 1 10 9 6 1 9 5 3 5 9 3 3 2 4 9 5 9 4 8 5 6 10 1 3 10 8 6 10 10 4 6 8 4 10 7 5 2 6 6 8 8 8 10 3 2 4 5 10 2 2 10 4 5 3 1 8 10 8 5 6 4 9 10 8 10 8 6 3 1 6 4 7 4 10 10 6 7 1 1 2 5 2 6 9 10 1 5 8 3 10 8 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\nA biscuit making machine produces B biscuits at the following moments: A seconds, 2A seconds, 3A seconds and ...
[{"input": "1 20 20\n", "output": "400\n"}, {"input": "1 -7 15", "output": "-105\n"}, {"input": "1 -8 13", "output": "-104\n"}, {"input": "1 -7 21", "output": "-147\n"}, {"input": "1 -8 19", "output": "-152\n"}, {"input": "1 -5 30", "output": "-150\n"}, {"input": "1 -6 30", "output": "-180\n"}, {"input": "2 11 -16", "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\nYou are given an array A of length N. Your task is to divide it into several contiguous subarrays. Here, all ...
[{"input": "7\n-1 -1 1 0 1 31150610 0000000101", "output": "3\n"}, {"input": "7\n1 2 3 2 1 999999999 1000000100", "output": "3\n"}, {"input": "7\n1 4 3 2 1 999999999 1000000100", "output": "3\n"}, {"input": "7\n1 4 3 4 1 999999999 1000000100", "output": "3\n"}, {"input": "7\n1 3 3 4 1 999999999 1000000100", "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\nBy 2312 there were n Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded ...
[{"input": "1 100\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 1\n+ 1\n- 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\n«Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add...
[{"input": "10\n1 7 13 6 10 10 3 8 2 4\n", "output": "5\n"}, {"input": "10\n1 7 13 6 10 10 4 8 2 4\n", "output": "3\n"}, {"input": "10\n1 7 13 6 10 10 4 8 2 8\n", "output": "3\n"}, {"input": "10\n1 7 13 6 5 10 3 8 2 4\n", "output": "9\n"}, {"input": "10\n7 2 3 8 9 6 5 4 1 10\n", "output": "11\n"}, {"input": "10\n1 7 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\nYou're on your way to the market when you hear beautiful music coming from a nearby street performer. The not...
[{"input": "\"Did I ever tell you about my run with that paleolithic beast? He tried all sorts of ways to get at my three dolla and fitty cent? I told him 'this is MY 4 dolla!'. He just wouldn't listen.\"", "output": "[false]", "fn_name": "is_lock_ness_monster"}, {"input": "\"I'm from Scottland. I moved here to be with...
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 fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a huge dragon-like reptile with ...
[{"input": "5\n4 807989196\n770312657 78181451\n624192034 690910298\n754831733 354913874\n519577171 400120478\n4 491297333\n546432637 76258441\n312107971 75446008\n767483254 958677299\n84044330 577526244\n2 177840791\n197738084 143071228\n23274563 597315796\n7 610054060\n858529462 646280969\n644068190 462783596\n820658...
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 board of size $n \\times n$, where $n$ is odd (not divisible by $2$). Initially, each cell of...
[{"input": "3\n11\n11375\n5405\n", "output": "440\n490606116000\n52633933240\n"}, {"input": "3\n11\n22093\n2775\n", "output": "440\n3594535872088\n7123077200\n"}, {"input": "3\n21\n7511\n4623\n", "output": "3080\n141244655440\n32934449248\n"}, {"input": "3\n11\n7017\n9273\n", "output": "440\n115168355632\n265790540048\...
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 points $x_1$, $x_2$, ..., $x_n$ on the number line.\n\nTwo points $i$ and $j$ can be m...
[{"input": "100 13\n11 28 21 7 6 23 26 31 26 32 34 17 19 1 13 1 28 30 28 8 23 36 17 20 5 37 32 23 14 1 20 23 3 39 20 14 2 12 15 3 1 27 7 25 15 39 10 6 8 37 6 22 7 29 6 17 17 9 16 3 39 23 2 34 20 12 28 29 32 2 38 27 36 27 29 18 7 14 27 25 33 18 29 40 22 9 9 6 21 7 23 35 33 26 31 31 39 36 27 27\n", "output": "50\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\n# Description\nWrite a function that checks whether a credit card number is correct or not, using the Luhn al...
[{"input": "\"8895 6238 9323 4311\"", "output": "[false]", "fn_name": "valid_card"}, {"input": "\"5457 6238 5568 4311\"", "output": "[false]", "fn_name": "valid_card"}, {"input": "\"5457 6238 9323 4311\"", "output": "[false]", "fn_name": "valid_card"}, {"input": "\"5457 1125 9323 4311\"", "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\nTeddy and Tracy like to play a game based on strings. The game is as follows. Initially, Tracy writes a long ...
[{"input": "3\ncodeehcf\n2\nbode\nfehd\nqng\n1\nbas\nippissirsim\n-1\njssiss\nmippi\nmi\nqip", "output": "Tracy\nTracy\nTracy\n"}, {"input": "3\ncodechef\n2\ncode\nchef\nfoo\n1\nbar\nmississippi\n4\nssissi\nmippi\nmi\nipp", "output": "Tracy\nTracy\nTracy\n"}, {"input": "3\ncodechef\n2\ncode\ndhef\nfoo\n1\nbar\nmississi...
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 an array a_1, a_2, ..., a_{n} of n integers, find the largest number in the array that is not a perfect...
[{"input": "71\n908209 289 44521 240100 680625 274576 212521 91809 506944 499849 3844 15376 592900 58081 240100 984064 732736 257049 600625 180625 130321 580644 261121 75625 46225 853776 485809 700569 817216 268324 293764 528529 25921 399424 175561 99856 295936 20736 611524 13924 470596 574564 5329 15376 676 431649 145...
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\nWinters are just damn freezing cold in Nvodsk! That's why a group of n friends prefers to take a taxi, order ...
[{"input": "10\n5 eeleGlOFWbcnIPPtnll\n55-55-55\n00-00-00\n98-65-32\n76-43-10\n98-76-54\n2 DMBiqRyQJkFvHPJNJp\n28-97-50\n87-64-10\n4 bAfmtnKHohIX\n61-58-93\n77-77-77\n53-17-51\n96-43-10\n3 cDX\n22-22-22\n77-77-77\n63-30-64\n1 HCeHJ\n44-44-44\n6 HgSpfAolwoaBQ\n96-93-53\n98-53-10\n33-33-33\n66-66-66\n87-54-32\n11-11-11\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 integer n. Find any string s of length n consisting only of English lowercase letters such t...
[{"input": "1\n99561\n", "output": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
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 playing the game \"Arranging The Sheep\". The goal of this game is to make the sheep line up. The lev...
[{"input": "5\n6\n**.*..\n5\n*****\n3\n.*.\n3\n...\n10\n*.*...*.**\n", "output": "\n1\n0\n0\n0\n9\n"}, {"input": "5\n6\n**.*..\n5\n*****\n3\n.*.\n3\n...\n10\n*.*...*.**\n", "output": "1\n0\n0\n0\n9\n"}, {"input": "5\n6\n..*.**\n5\n*****\n3\n.*.\n3\n...\n10\n*.*...*.**\n", "output": "1\n0\n0\n0\n9\n"}, {"input": "5\n6\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 is a stack of N cards, each of which has a non-negative integer written on it. The integer written on t...
[{"input": "10\n1 -2 8 1 1 10 0 -1 0 2", "output": "43\n"}, {"input": "10\n1 -1 1 1 1 10 0 -1 0 2", "output": "21\n"}, {"input": "10\n3 1 4 1 5 9 2 11 5 3", "output": "130\n"}, {"input": "10\n3 1 4 1 5 2 2 11 5 3", "output": "110\n"}, {"input": "10\n3 1 4 1 5 2 2 11 5 4", "output": "111\n"}, {"input": "10\n7 1 4 0 5 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\nWrite a function that solves an algebraic expression given as a string. \n\n* The expression can include only...
[{"input": "\"1.333333333*1.23456789+0.003*0.002\"", "output": "[\"1.64610e+00\"]", "fn_name": "sum_prod"}, {"input": "\"0.5*1.2*56+9.6*5*81+1\"", "output": "[\"3.92260e+03\"]", "fn_name": "sum_prod"}, {"input": "\"5.4*4.0+6.2+8.0\"", "output": "[\"3.58000e+01\"]", "fn_name": "sum_prod"}, {"input": "\"5*8+6*3*2\"", "ou...
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\nChef recently printed directions from his home to a hot new restaurant across the town, but forgot to print t...
[{"input": "2\n4\nBegin on Road A\nRight on Road B\nRight on Road C\nLeft on Road D\n6\nBegin on Old Madras daoR\nLeft on Domlur Flyover\nLeft on 100 Feet Road\nRight on Sarjapur Road\nRight on Hosur Road\nRight on Ganapathi Temple Road", "output": "Begin on Road D\nRight on Road C\nLeft on Road B\nLeft on Road A\nBegi...
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 $A$ and $B$, calculate the number of pairs $(a, b)$ such that $1 \\le a \\le A$, $...
[{"input": "3\n1 14\n4 2\n191 102469002\n", "output": "1\n0\n1528\n"}, {"input": "3\n1 14\n4 2\n131 176163142\n", "output": "1\n0\n1048\n"}, {"input": "3\n1 14\n4 2\n142 128000654\n", "output": "1\n0\n1136\n"}, {"input": "3\n1 14\n4 2\n191 176163142\n", "output": "1\n0\n1528\n"}, {"input": "3\n1 14\n4 2\n131 128000654\...
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 given two sequences $X$ and $Y$, a sequence $Z$ is a common subsequence of $X$ and $Y$ if $Z$ is a subseq...
[{"input": "3\nabcbdab\nbdcaba\nabc\nabc\nacb\nbc", "output": "4\n3\n1\n"}, {"input": "3\nabcbdab\nbdcaba\nabc\nabc\nbcb\nbc", "output": "4\n3\n2\n"}, {"input": "3\nabcbdab\nbdcaba\n`bc\nabc\nbcb\nbc", "output": "4\n2\n2\n"}, {"input": "3\nbadbcba\nbdcaba\n`bc\nabc\nbcb\nbc", "output": "5\n2\n2\n"}, {"input": "3\nbadbd...
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 number theory, Euler's totient is an arithmetic function, introduced in 1763 by Euler, that counts the pos...
[{"input": "\"wow doge\"", "output": "[0]", "fn_name": "totient"}, {"input": "0.0435", "output": "[0]", "fn_name": "totient"}, {"input": "false", "output": "[0]", "fn_name": "totient"}, {"input": "19", "output": "[18]", "fn_name": "totient"}, {"input": "15", "output": "[8]", "fn_name": "totient"}, {"input": "18", "outp...
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\nSuppose I have two vectors: `(a1, a2, a3, ..., aN)` and `(b1, b2, b3, ..., bN)`. The dot product between thes...
[{"input": "[5, 10, 1, 20, 2]\n[-2, -20, -1, 10, 5]", "output": "[false]", "fn_name": "is_orthogonal"}, {"input": "[2, 4, 5, 6, 7]\n[-14, -12, 0, 8, 4]", "output": "[true]", "fn_name": "is_orthogonal"}, {"input": "[1, -2, 3, -4]\n[-4, 3, 2, -1]", "output": "[true]", "fn_name": "is_orthogonal"}, {"input": "[3, -4, -5]\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\nIvan has an array consisting of n elements. Each of the elements is an integer from 1 to n.\n\nRecently Ivan ...
[{"input": "50\n48 37 47 50 46 43 42 46 36 40 45 41 40 50 35 49 37 42 44 45 49 44 31 47 45 49 48 41 45 45 48 20 34 43 43 41 47 50 41 48 38 48 43 48 46 48 32 37 47 45\n", "output": "31\n1 2 3 4 5 6 7 8 36 9 10 11 40 12 35 13 14 42 15 16 17 44 31 18 19 49 21 22 23 24 25 20 34 26 27 28 29 50 41 30 38 33 43 39 46 48 32 37 ...
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 a given array $a$ consisting of $n$ integers and a given integer $m$ find if it is possible to reorder el...
[{"input": "5\n4 10\n5 5 5 5\n3 5\n5 5 5\n3 4\n10 1 1\n4 5\n5 5 1 5\n5 5\n5 5 5 10 5\n", "output": "NO\nNO\nNO\nNO\nNO\n"}, {"input": "5\n4 10\n5 5 5 5\n3 5\n5 5 5\n3 4\n10 1 1\n4 5\n5 5 1 5\n5 5\n5 5 5 15 5\n", "output": "NO\nNO\nNO\nNO\nNO\n"}, {"input": "5\n4 10\n5 5 5 5\n3 5\n5 5 5\n3 4\n10 1 1\n4 5\n5 5 5 5\n5 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\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that ei...
[{"input": "9\n0 2 4\n1 0 3\n2 -1 -1\n3 0 0\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1", "output": "Preorder\n 1 0 2 4 5 6 7 8 3 0 2 4 5 6 7 8 0 2 4 5 6 7 8\nInorder\n 2 0 6 5 7 4 8 1 2 0 6 5 7 4 8 3 2 0 6 5 7 4 8\nPostorder\n 2 6 7 5 8 4 0 2 6 7 5 8 4 0 2 6 7 5 8 4 0 3 1\n"}, {"input": "9\n0 2 4\n1 0 3\n2 -1 -1\n3 -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\nApart from having lots of holidays throughout the year, residents of Berland also have whole lucky years. Yea...
[{"input": "1000000000\n", "output": "1000000000\n"}, {"input": "1000000000\n", "output": "1000000000\n"}, {"input": "100000000\n", "output": "100000000\n"}, {"input": "900000000\n", "output": "100000000\n"}, {"input": "100000000\n", "output": "100000000\n"}, {"input": "900000000\n", "output": "100000000\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\nThe king's birthday dinner was attended by $k$ guests. The dinner was quite a success: every person has eaten...
[{"input": "100 100\n97 64 64 35 35 97 39 83 26 97 92 97 83 11 83 97 97 64 23 97 97 11 39 11 11 39 64 14 23 39 64 26 26 97 39 39 39 64 83 26 83 97 64 11 64 64 64 83 64 92 64 26 83 26 27 64 11 83 92 92 23 11 11 97 92 64 97 64 97 83 64 27 83 23 11 26 11 92 83 64 83 11 11 11 97 83 97 26 26 97 23 23 39 64 64 64 97 27 27 92...
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 21XX, an annual programming contest, Japan Algorithmist GrandPrix (JAG) has become one of the most popular...
[{"input": "[[r-i]-[m-e]]\nd -1\no 0\ng -1\nl 6", "output": "No\n"}, {"input": "[[m-y]-[a-o]]\nn 0\na 1\ny 2\nm 0", "output": "Yes\n"}, {"input": "[[r-i]-[m-e]]\nd -1\nr 1\ng 1\nm 3", "output": "No\n"}, {"input": "[[r-i]-[m-e]]\nf -1\nr 1\ni 2\nm 4", "output": "No\n"}, {"input": "[[r-i]-[m-e]]\nf -1\nr 1\ni 2\nm 5", "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\nThe new \"Die Hard\" movie has just been released! There are n people at the cinema box office standing in a ...
[{"input": "14\n25 25 25 25 25 25 25 50 50 50 100 100 100 100\n", "output": "NO\n"}, {"input": "14\n25 25 25 25 25 25 25 50 50 50 100 100 100 100\n", "output": "NO\n"}, {"input": "10\n100 100 100 100 100 100 100 100 100 100\n", "output": "NO\n"}, {"input": "10\n100 100 100 100 100 100 100 100 100 100\n", "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\nproblem\n\nJOI decided to play a game with his friends. N players participate in this game. The rules for a s...
[{"input": "5\n000 99 22\n100 97 92\n30 53 63\n99 99 99\n89 97 98", "output": "22\n192\n146\n198\n187\n"}, {"input": "5\n000 99 22\n100 97 92\n51 53 63\n99 99 99\n89 97 98", "output": "22\n192\n167\n198\n187\n"}, {"input": "5\n100 99 22\n100 13 92\n56 53 63\n99 99 99\n89 97 98", "output": "22\n105\n172\n198\n284\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 Petya and Gena gathered after another programming competition and decided to play some game....
[{"input": "110\n-256 -149 -136 -33 -253 -141 -170 -253 0 -107 -141 -236 -65 -158 -84 -180 -97 -97 -223 -44 -232 -255 -108 -25 -49 -48 -212 -3 -232 -172 -231 -158 -23 -206 -198 -55 -36 -11 -169 -94 -190 -115 -116 -231 -155 -201 -155 -103 -242 -119 -136 -8 -2 -11 -69 -250 -51 -129 -155 -216 -107 -102 -186 -13 -78 -2 -23...
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\nHave you ever used the chat application QQ? Well, in a chat group of QQ, administrators can muzzle a user for...
[{"input": "100 61 71\n11 18 0 47 33 37 91 13 8 30 73 64 50 97 62 50 2 36 68 32 64 74 32 77 81 41 23 44 40 18 45 33 21 68 57 79 107 23 21 37 99 27 30 56 75 62 75 63 1 15 79 42 18 66 21 25 2 12 89 48 75 7 57 85 80 14 82 29 66 47 29 10 1 84 79 39 33 81 135 26 80 67 52 25 38 68 57 53 38 83 83 3 86 29 50 46 3 68 88 10\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 problem you will meet the simplified model of game King of Thieves.\n\nIn a new ZeptoLab game called ...
[{"input": "100\n*****************************)**********************************************************************\n", "output": "yes\n"}, {"input": "100\n*.....................*.....................*.....................*......../............*...........\n", "output": "yes\n"}, {"input": "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\nYour task is to write a program which reads an expression and evaluates it.\n\n* The expression consists of n...
[{"input": "2\n4-2*3=\n8*(4+4*3)=", "output": "-2\n128\n"}, {"input": "2\n3-4*3=\n4*(8*4+3)=", "output": "-9\n140\n"}, {"input": "2\n4-2*3=\n4*(8*4+3)=", "output": "-2\n140\n"}, {"input": "2\n4-2*4=\n3*(8*4+4)=", "output": "-4\n108\n"}, {"input": "2\n4-2*3=\n8*(4+4+3)=", "output": "-2\n88\n"}, {"input": "2\n4-2*3=\n8*(...
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 N be a positive integer. You are given a string s of length N - 1, consisting of `<` and `>`.\n\nFind the...
[{"input": "20\n>><<>>><>><>>><>>>>", "output": "217136290\n"}, {"input": "20\n>><<>>><>>>>>><>>><", "output": "415929071\n"}, {"input": "20\n>>>><>>>>><<>>><<>>", "output": "784400335\n"}, {"input": "20\n<>>><>>><>>>>>><<>>", "output": "586939232\n"}, {"input": "20\n>><<>>><>>>><>>>>><", "output": "704760317\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\nFor god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you ...
[{"input": "5\n2\n1 1\n2\n1 1000000000\n2\n1000000000 1\n2\n1000000000 1000000000\n2\n228 1337\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"input": "5\n2\n1 1\n2\n1 1000000000\n2\n1000000000 1\n2\n1000000000 1000000000\n2\n228 1337\n", "output": "YES\nYES\nNO\nYES\nYES\n"}, {"input": "5\n2\n1 1\n2\n1 1000000000\n2\n100...
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\nChris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arr...
[{"input": "100000\n", "output": "879367333\n"}, {"input": "99925\n", "output": "414342728\n"}, {"input": "54904\n", "output": "917915735\n"}, {"input": "57500\n", "output": "540890446\n"}, {"input": "87440\n", "output": "926716958\n"}, {"input": "47504\n", "output": "469586508\n"}, {"input": "49948\n", "output": "1884...
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 has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who ap...
[{"input": "aaaaabbbbbb\n", "output": "NO\n"}, {"input": "aaaaabbbbbb\n", "output": "NO\n"}, {"input": "aaaaabbabbb\n", "output": "NO\n"}, {"input": "bbbabbaaaaa\n", "output": "NO\n"}, {"input": "aabbaacccc\n", "output": "NO\n"}, {"input": "aabbaacccc\n", "output": "NO\n"}, {"input": "cabbaaccca\n", "output": "NO\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: A-Z-\n\nproblem\n\nThere is a circular board of 26 squares, each square with one capital letter of the alp...
[{"input": "AIZV", "output": "2\n"}, {"input": "W\\AG", "output": "1\n"}, {"input": "[VIA", "output": "3\n"}, {"input": "BEW]", "output": "0\n"}, {"input": "VZIA", "output": "2\n"}, {"input": "V[IA", "output": "2\n"}, {"input": "W[IA", "output": "2\n"}, {"input": "AI[W", "output": "2\n"}, {"input": "AH[W", "output": "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\nFor an array a of integers let's denote its maximal element as max(a), and minimal as min(a). We will call an...
[{"input": "1\n24\n1 1 1 1 1 1 2 2 2 2 2 2 4 4 4 4 4 4 5 5 5 5 5 5\n", "output": "YES\n12 13\n"}, {"input": "1\n24\n1 1 1 1 1 1 2 2 2 2 2 2 4 4 4 4 4 4 4 5 5 5 5 5\n", "output": "YES\n12 13\n"}, {"input": "1\n24\n1 1 2 1 1 1 2 2 2 2 2 2 4 4 4 4 4 4 4 5 5 5 5 5\n", "output": "YES\n12 13\n"}, {"input": "1\n24\n1 1 2 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\nThe only king stands on the standard chess board. You are given his position in format \"cd\", where c is the...
[{"input": "e4\n", "output": "8\n"}, {"input": "a1\n", "output": "3\n"}, {"input": "h8\n", "output": "3\n"}, {"input": "a4\n", "output": "5\n"}, {"input": "g7\n", "output": "8\n"}, {"input": "e1\n", "output": "5\n"}, {"input": "b2\n", "output": "8\n"}, {"input": "c7\n", "output": "8\n"}, {"input": "h6\n", "output": "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\nThe Collatz conjecture is one of the most famous one. Take any positive integer n, if it is even divide it by...
[{"input": "1000000", "output": "[[837799, 525]]", "fn_name": "max_collatz_length"}, {"input": "1000", "output": "[[871, 179]]", "fn_name": "max_collatz_length"}, {"input": "30", "output": "[[27, 112]]", "fn_name": "max_collatz_length"}, {"input": "1", "output": "[[1, 1]]", "fn_name": "max_collatz_length"}, {"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 three integers $x, y$ and $n$. Your task is to find the maximum integer $k$ such that $0 \\le k...
[{"input": "7\n7 5 12345\n5 0 4\n10 5 15\n17 8 54321\n499999993 9 1000000000\n10 5 187\n2 0 999999999\n", "output": "12339\n0\n15\n54306\n999999995\n185\n999999998\n"}, {"input": "7\n7 5 12345\n5 0 4\n10 5 15\n17 8 54321\n499999993 5 1000000000\n10 5 187\n2 0 999999999\n", "output": "12339\n0\n15\n54306\n999999991\n185...
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\nKarlsson has recently discovered a huge stock of berry jam jars in the basement of the house. More specifical...
[{"input": "4\n6\n1 1 1 1 2 1 2 1 2 1 1 1\n2\n2 2 1 2\n3\n1 1 1 1 1 1\n2\n2 1 2 1\n", "output": "12\n2\n6\n0\n"}, {"input": "4\n6\n2 2 2 1 2 2 2 1 2 2 1 2\n2\n2 2 1 2\n3\n1 1 1 1 2 1\n2\n2 1 1 1\n", "output": "10\n2\n4\n2\n"}, {"input": "4\n6\n1 1 1 1 2 1 2 1 1 1 1 2\n2\n2 2 1 2\n3\n1 1 1 1 2 1\n2\n2 1 1 1\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\nYou are given a string S consisting of lowercase English letters. We will write down this string, starting a ...
[{"input": "dnuoodnuuuhs\n1", "output": "dnuoodnuuuhs\n"}, {"input": "shuuundoound\n1", "output": "shuuundoound\n"}, {"input": "dnuondouuuhs\n1", "output": "dnuondouuuhs\n"}, {"input": "siuuuodnound\n1", "output": "siuuuodnound\n"}, {"input": "dnuondouuuis\n1", "output": "dnuondouuuis\n"}, {"input": "dnuoocnuuuhs\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\nGiven a credit card number we can determine who the issuer/vendor is with a few basic knowns.\n\n```if:python...
[{"input": "5105105105105100", "output": "[\"Mastercard\"]", "fn_name": "get_issuer"}, {"input": "5105105105105106", "output": "[\"Mastercard\"]", "fn_name": "get_issuer"}, {"input": "5205105105105106", "output": "[\"Mastercard\"]", "fn_name": "get_issuer"}, {"input": "5305105105105106", "output": "[\"Mastercard\"]", "...
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\nM-kun has the following three cards:\n\n* A red card with the integer A.\n* A green card with the integer B.\...
[{"input": "13 4 1\n10", "output": "Yes\n"}, {"input": "13 5 1\n10", "output": "Yes\n"}, {"input": "12 3 4\n9", "output": "Yes\n"}, {"input": "12 4 4\n9", "output": "Yes\n"}, {"input": "12 4 2\n9", "output": "Yes\n"}, {"input": "12 2 2\n9", "output": "Yes\n"}, {"input": "21 2 2\n9", "output": "Yes\n"}, {"input": "12 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\nRead problems statements in Russian here \nThe Head Chef has been playing with Fibonacci numbers for long . H...
[{"input": "3\n5\n13\n13", "output": "YES\nYES\nYES\n"}, {"input": "3\n13\n15\n13", "output": "YES\nNO\nYES\n"}, {"input": "3\n13\n18\n21", "output": "YES\nNO\nYES\n"}, {"input": "3\n5\n13\n11", "output": "YES\nYES\nNO\n"}, {"input": "3\n13\n15\n15", "output": "YES\nNO\nNO\n"}, {"input": "3\n13\n18\n15", "output": "YES...
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 start with a permutation a_1, a_2, …, a_n and with an empty array b. We apply the following operation k ti...
[{"input": "6\n2 1\n2 1\n1\n3 2\n1 3 2\n1 3\n4 2\n4 1 3 2\n1 2\n5 3\n4 3 2 5 1\n1 4 5\n6 3\n2 4 5 6 1 3\n2 4 5\n7 3\n7 6 4 3 2 1 5\n1 2 6\n", "output": "1\n0\n2\n0\n0\n4\n"}, {"input": "6\n2 1\n2 1\n1\n3 2\n1 3 2\n1 3\n4 2\n4 1 3 2\n1 2\n5 3\n4 4 2 5 1\n1 4 5\n6 3\n2 4 5 6 1 3\n2 4 5\n7 3\n7 6 4 3 2 1 5\n1 2 6\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\n_Based on [Project Euler problem 35](https://projecteuler.net/problem=35)_\n\nA circular prime is a prime in ...
[{"input": "179", "output": "[false]", "fn_name": "circular_prime"}, {"input": "222", "output": "[false]", "fn_name": "circular_prime"}, {"input": "9377", "output": "[true]", "fn_name": "circular_prime"}, {"input": "213", "output": "[false]", "fn_name": "circular_prime"}, {"input": "197", "output": "[true]", "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\nRead problems statements in Mandarin Chinese and Russian. \n\nChef is playing a game. Currently in the game,...
[{"input": "1\n3 16\n1 4 4\n8 -1 1", "output": "128\n"}, {"input": "1\n3 10\n3 1 5\n4 8 -1", "output": "80\n"}, {"input": "1\n2 10\n10 1 5\n7 -1 0", "output": "7\n"}, {"input": "1\n3 16\n1 4 4\n4 -1 1", "output": "64\n"}, {"input": "1\n1 1\n10 13 4\n6 3 -1", "output": "0\n"}, {"input": "1\n1 1\n10 11 4\n4 3 -5", "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\nIn 20XX AD, a school competition was held. The tournament has finally left only the final competition. You ar...
[{"input": "5 5\n-38 -71 -293 75 1\n-158 -38 -405 66 1\n-236 -303 157 266 1\n316 26 411 190 1\n207 -312 -27 196 1\n-50 292 -375 -401 389 -389\n460 278 409 -329 -303 411\n215 -220 -200 309 -474 300\n310 -494 -87 -300 123 -463\n386 378 486 -443 -64 299", "output": "0\n2\n1\n3\n0\n"}, {"input": "5 5\n-38 -71 -293 75 1\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\nThere are n cows playing poker at a table. For the current betting phase, each player's status is either \"AL...
[{"input": "100\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n", "output": "100\n"}, {"input": "100\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n", "output": "100"}, {"input": "10\nAAAAAAAAAA\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\nFor an array b of length m we define the function f as \n\n f(b) = \\begin{cases} b[1] & if m = 1 \\\\\\ f...
[{"input": "6\n1 2 1 14 16 32\n4\n1 6\n3 5\n1 6\n1 2\n", "output": "63\n30\n63\n3\n"}, {"input": "6\n1 2 4 10 16 32\n4\n1 6\n1 5\n3 6\n1 1\n", "output": "62\n28\n62\n1\n"}, {"input": "6\n1 0 1 14 16 32\n4\n1 6\n3 5\n1 6\n1 2\n", "output": "63\n30\n63\n1\n"}, {"input": "6\n1 0 1 17 16 32\n4\n1 6\n3 5\n1 6\n1 2\n", "outp...
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 deck of $n$ cards. The $i$-th card has a number $a_i$ on the front and a number $b_i$ on the back....
[{"input": "20\n24 12\n37 1\n5 35\n36 19\n22 6\n25 4\n26 17\n15 31\n39 8\n28 16\n11 29\n21 18\n14 34\n30 10\n32 2\n20 27\n33 13\n23 9\n40 7\n3 38\n", "output": "-1\n"}, {"input": "20\n7 29\n4 34\n40 2\n39 10\n33 5\n1 37\n20 23\n14 21\n22 9\n8 28\n19 24\n26 13\n32 6\n30 16\n11 38\n36 3\n35 12\n15 31\n17 27\n18 25\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\n###Instructions\n\nWrite a function that takes a negative or positive integer, which represents the number of...
[{"input": "259180", "output": "[\"Thursday 23:40\"]", "fn_name": "day_and_time"}, {"input": "-349000", "output": "[\"Tuesday 15:20\"]", "fn_name": "day_and_time"}, {"input": "18876", "output": "[\"Saturday 02:36\"]", "fn_name": "day_and_time"}, {"input": "-3", "output": "[\"Saturday 23:57\"]", "fn_name": "day_and_time...
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\nSnuke has a large collection of cards. Each card has an integer between 1 and N, inclusive, written on it. He...
[{"input": "8\n1\n0\n2\n13\n1\n12\n5\n1", "output": "17\n"}, {"input": "8\n1\n0\n2\n18\n1\n12\n5\n1", "output": "19\n"}, {"input": "8\n1\n0\n2\n13\n1\n21\n5\n1", "output": "21\n"}, {"input": "8\n1\n1\n0\n24\n4\n3\n10\n1", "output": "22\n"}, {"input": "8\n1\n0\n2\n16\n1\n21\n5\n1", "output": "23\n"}, {"input": "8\n1\n0\...
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 K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Taka...
[{"input": "2000 849\n", "output": "1152\n562203648\n76583517\n109459402\n109338043\n155329001\n569751853\n393930605\n30668610\n172729191\n403640438\n424478909\n110785606\n354376031\n327302764\n297759221\n904322614\n38970179\n642408789\n12623313\n462072120\n718075856\n776805328\n371215178\n754737053\n296999830\n5315477...
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 function $f : R \\rightarrow R$ is called Lipschitz continuous if there is a real constant K such that the ...
[{"input": "3 6\n48261735 26888803 75904937\n1 2\n1 3\n2 3\n1 2\n2 3\n1 3\n", "output": "21372932\n119405200\n49016134\n21372932\n49016134\n119405200\n"}, {"input": "3 6\n48261735 26888803 75904937\n1 2\n1 3\n2 3\n1 2\n2 3\n1 3\n", "output": "21372932\n119405200\n49016134\n21372932\n49016134\n119405200\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\nRead problems statements in Mandarin Chinese and Russian as well. \n\nYou had an array of integer numbers. Yo...
[{"input": "2\n5\n1 0 1 1 1\n5\n1 2 10 2 2", "output": "2\n3\n"}, {"input": "2\n5\n1 0 1 1 1\n5\n1 2 10 0 2", "output": "2\n4\n"}, {"input": "2\n5\n1 0 1 1 1\n5\n1 2 10 0 4", "output": "2\n5\n"}, {"input": "2\n5\n1 1 1 1 1\n5\n1 2 6 1 2", "output": "1\n3\n"}, {"input": "2\n5\n1 0 1 1 1\n5\n1 3 3 1 2", "output": "2\n3\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 median of an array of integers of length $n$ is the number standing on the $\\lceil {\\frac{n}{2}} \\rceil$...
[{"input": "6\n2 4\n0 24 37 58 62 64 69 78\n2 2\n27 61 81 91\n4 3\n0 4 16 18 21 27 36 53 82 91 92 95\n3 4\n1 11 12 22 33 35 38 67 69 71 94 99\n2 1\n11 41\n3 3\n1 2 1 1 1 1 1 1 -1\n", "output": "168\n108\n145\n234\n11\n3\n"}, {"input": "6\n2 4\n0 24 25 58 62 64 69 78\n2 2\n27 61 81 91\n4 3\n0 4 16 18 21 27 36 53 82 91 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\nA big company decided to launch a new series of rectangular displays, and decided that the display must have ...
[{"input": "1000000\n", "output": "1000 1000\n"}, {"input": "1000000\n", "output": "1000 1000\n"}, {"input": "1100000\n", "output": "1000 1100\n"}, {"input": "1235799\n", "output": "549 2251\n"}, {"input": "1401914\n", "output": "214 6551\n"}, {"input": "1256957\n", "output": "403 3119\n"}, {"input": "1426666\n", "outp...
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 of n integer numbers. Let sum(l, r) be the sum of all numbers on positions from l to r...
[{"input": "100\n2 1 -2 -1 -2 0 -1 -2 1 2 0 1 0 -2 -1 -2 0 2 0 1 -2 -2 2 0 -2 2 -2 0 2 -1 2 0 -1 0 -2 2 -1 -1 -2 -1 0 -2 2 0 -2 -2 -2 -1 1 0 -2 -1 2 -1 -4 0 -1 1 1 2 -2 1 -2 1 2 2 -2 1 -2 0 -1 -1 -2 -2 1 0 -1 -1 2 0 2 0 -1 2 1 -1 2 0 2 1 1 1 -1 -1 1 -2 0 0 -2 0\n", "output": "2 78 92\n"}, {"input": "100\n2 1 -2 -1 -2 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\nValera has got n domino pieces in a row. Each piece consists of two halves — the upper one and the lower one....
[{"input": "100\n2 3\n2 4\n3 3\n1 4\n5 2\n5 4\n6 6\n3 4\n1 1\n4 2\n5 1\n5 5\n5 3\n3 6\n4 1\n1 6\n1 1\n3 2\n4 5\n6 1\n6 4\n1 1\n3 4\n3 3\n2 2\n1 1\n4 4\n6 4\n3 2\n5 2\n6 4\n3 2\n3 5\n4 4\n1 4\n5 2\n3 4\n1 4\n2 2\n5 6\n3 5\n6 1\n5 5\n1 6\n6 3\n1 4\n1 5\n5 5\n4 1\n3 2\n4 1\n5 5\n5 5\n1 5\n1 2\n6 4\n1 3\n3 6\n4 3\n3 5\n6 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 n rectangles. The corners of rectangles have integer coordinates and their edges are parallel t...
[{"input": "5\n20421 5189 23141 12511\n16414 10436 17880 12511\n17880 10436 20421 12511\n15819 10436 16414 12511\n15819 5189 20421 10436\n", "output": "YES\n"}, {"input": "5\n20421 5189 23141 12511\n16414 10436 17880 12511\n17880 10436 20421 12511\n15819 10436 16414 12511\n15819 5189 20421 10436\n", "output": "YES\n"},...
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 N logs of lengths A_1,A_2,\\cdots A_N.\nWe can cut these logs at most K times in total. When a log of...
[{"input": "10 10\n158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202\n", "output": "292638192\n"}, {"input": "10 10\n158260522 877914575 1013896555 24979445 861648772 623690081 433933447 476190629 262703497 374010847", "output": "337965519\n"}, {"input": "10 10\n15826052...
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 an array of $n$ positive integers $a_1, a_2, \\dots, a_n$ ($1 \\le a_i \\le 1000$). Find the maximum va...
[{"input": "9\n19\n146 637 288 867 647 705 297 414 541 951 238 806 73 916 781 371 937 343 985\n6\n289 797 286 446 650 296\n15\n670 558 11 473 388 270 231 981 580 180 834 882 212 233 547\n16\n461 336 815 510 720 169 999 580 367 47 992 786 671 522 25 24\n8\n732 710 651 518 287 789 347 14\n4\n697 206 722 759\n20\n241 854 ...
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# Scenario \n\n*You're saying good-bye your best friend* , **_See you next happy year_** . \n\n**_Happy Year_...
[{"input": "1001", "output": "[1023]", "fn_name": "next_happy_year"}, {"input": "1123", "output": "[1203]", "fn_name": "next_happy_year"}, {"input": "2001", "output": "[2013]", "fn_name": "next_happy_year"}, {"input": "2334", "output": "[2340]", "fn_name": "next_happy_year"}, {"input": "3331", "output": "[3401]", "fn_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\nWe have a grid with N rows and M columns of squares. Initially, all the squares are white.\n\nThere is a butt...
[{"input": "1 13 1", "output": "Yes\n"}, {"input": "1 13 0", "output": "Yes\n"}, {"input": "7 17 0", "output": "Yes\n"}, {"input": "1 20 0", "output": "Yes\n"}, {"input": "1 21 3", "output": "Yes\n"}, {"input": "1 30 0", "output": "Yes\n"}, {"input": "1 34 8", "output": "Yes\n"}, {"input": "4 2 2", "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\nYou are given n points on a plane. All points are different.\n\nFind the number of different groups of three ...
[{"input": "40\n-8 24\n2 -1\n1 -18\n72 -70\n5 -4\n-308 436\n-19 40\n36 -35\n-178 265\n-1 2\n-7 30\n-1 0\n3 -2\n200 -285\n17 -16\n-35 74\n0 -4\n-86 106\n-1 4\n-7 6\n0 1\n-5 4\n-2 3\n6 -5\n-4 5\n181 -262\n76 -118\n0 0\n-7 18\n-58 104\n-5 6\n-6 12\n-3 4\n1 0\n11 -10\n-86 130\n-3 6\n153 -236\n-183 270\n-33 64\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\n# Task\n Mobius function - an important function in number theory. For each given n, it only has 3 values:\n`...
[{"input": "100000000001", "output": "[0]", "fn_name": "mobius"}, {"input": "10", "output": "[1]", "fn_name": "mobius"}, {"input": "7", "output": "[-1]", "fn_name": "mobius"}, {"input": "5", "output": "[-1]", "fn_name": "mobius"}, {"input": "9", "output": "[0]", "fn_name": "mobius"}, {"input": "8", "output": "[0]", "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\n<image>\n\n\nYou know the merry-go-round in the amusement park. Vehicles such as horses and carriages are fix...
[{"input": "0 3 1 1 0 -1 -1 2\n1 1 5 3 -1 3 0 -1", "output": "1 4 1 2 1 2 1 4\n1 2 1 4 1 4 1 2\n"}, {"input": "0 2 0 1 0 -1 -1 2\n1 1 5 3 -1 3 0 -1", "output": "1 2 1 2 1 4 1 4\n1 2 1 4 1 4 1 2\n"}, {"input": "0 2 1 1 0 -1 -1 2\n1 1 5 3 -1 0 0 -1", "output": "1 2 1 2 1 4 1 4\n2 1 4 1 4 1 2 1\n"}, {"input": "4 7 2 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 positive integer number n. You should create such strictly increasing sequence of k positive nu...
[{"input": "10000000000 5000\n", "output": "640 1280 1920 2560 3200 3840 4480 5120 5760 6400 7040 7680 8320 8960 9600 10240 10880 11520 12160 12800 13440 14080 14720 15360 16000 16640 17280 17920 18560 19200 19840 20480 21120 21760 22400 23040 23680 24320 24960 25600 26240 26880 27520 28160 28800 29440 30080 30720 3136...
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 $ N $ streetlights on a two-dimensional square of $ W \\ times H $.\nGaccho wants to sta...
[{"input": "43 16 2\n4 7\n-1 8\n10 0", "output": "48\n"}, {"input": "19 21 2\n0 3\n-1 11\n1 1", "output": "30\n"}, {"input": "12 31 1\n5 2\n-1 1\n14 0", "output": "36\n"}, {"input": "34 50 1\n9 1\n0 1\n-2 -1", "output": "74\n"}, {"input": "12 16 1\n5 9\n-1 5\n5 0", "output": "14\n"}, {"input": "12 31 1\n5 9\n-1 5\n7 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\nWe have a square grid with N rows and M columns. Takahashi will write an integer in each of the squares, as f...
[{"input": "314159 217986", "output": "153191328\n"}, {"input": "180944 374453", "output": "571894029\n"}, {"input": "180944 102049", "output": "764553516\n"}, {"input": "180944 191217", "output": "826993365\n"}, {"input": "180944 138776", "output": "166821642\n"}, {"input": "180944 221497", "output": "413854937\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 sequence of integers $a_1, a_2, \\dots, a_k$ is called a good array if $a_1 = k - 1$ and $a_1 > 0$. For e...
[{"input": "4\n-2 0 4 -1\n", "output": "0\n"}, {"input": "4\n-2 0 1 -1\n", "output": "1\n"}, {"input": "4\n-2 1 5 0\n", "output": "2\n"}, {"input": "4\n-1 0 4 1\n", "output": "0\n"}, {"input": "4\n-2 0 4 1\n", "output": "0\n"}, {"input": "4\n-2 0 4 0\n", "output": "0\n"}, {"input": "4\n-2 0 5 0\n", "output": "0\n"}, {"...
code_stdio