{"problem_id":"mbpp_train_00602","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the first repeated character in a given string.\n\nTests:\nassert first_repeated_char(\"abcabc\") == \"a\"\nassert first_repeated_char(\"abc\") == None\nassert first_repeated_char(\"123123\") == \"1\"","canonical_answer":"def first_repeated_char(str1):\n for index,c in enumerate(str1):\n if str1[:index+1].count(c) > 1:\n return c","verification_metadata":{"test_list":["assert first_repeated_char(\"abcabc\") == \"a\"","assert first_repeated_char(\"abc\") == None","assert first_repeated_char(\"123123\") == \"1\""],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":602,"text":"Write a python function to find the first repeated character in a given string.","code":"def first_repeated_char(str1):\n for index,c in enumerate(str1):\n if str1[:index+1].count(c) > 1:\n return c","test_list":["assert first_repeated_char(\"abcabc\") == \"a\"","assert first_repeated_char(\"abc\") == None","assert first_repeated_char(\"123123\") == \"1\""],"test_imports":[]}} {"problem_id":"mbpp_train_00603","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to get all lucid numbers smaller than or equal to a given integer.\n\nTests:\nassert get_ludic(10) == [1, 2, 3, 5, 7]\nassert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]\nassert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]","canonical_answer":"def get_ludic(n):\n\tludics = []\n\tfor i in range(1, n + 1):\n\t\tludics.append(i)\n\tindex = 1\n\twhile(index != len(ludics)):\n\t\tfirst_ludic = ludics[index]\n\t\tremove_index = index + first_ludic\n\t\twhile(remove_index < len(ludics)):\n\t\t\tludics.remove(ludics[remove_index])\n\t\t\tremove_index = remove_index + first_ludic - 1\n\t\tindex += 1\n\treturn ludics","verification_metadata":{"test_list":["assert get_ludic(10) == [1, 2, 3, 5, 7]","assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]","assert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":603,"text":"Write a function to get all lucid numbers smaller than or equal to a given integer.","code":"def get_ludic(n):\n\tludics = []\n\tfor i in range(1, n + 1):\n\t\tludics.append(i)\n\tindex = 1\n\twhile(index != len(ludics)):\n\t\tfirst_ludic = ludics[index]\n\t\tremove_index = index + first_ludic\n\t\twhile(remove_index < len(ludics)):\n\t\t\tludics.remove(ludics[remove_index])\n\t\t\tremove_index = remove_index + first_ludic - 1\n\t\tindex += 1\n\treturn ludics","test_list":["assert get_ludic(10) == [1, 2, 3, 5, 7]","assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]","assert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]"],"test_imports":[]}} {"problem_id":"mbpp_train_00604","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to reverse words seperated by spaces in a given string.\n\nTests:\nassert reverse_words(\"python program\")==(\"program python\")\nassert reverse_words(\"java language\")==(\"language java\")\nassert reverse_words(\"indian man\")==(\"man indian\")","canonical_answer":"def reverse_words(s):\n return ' '.join(reversed(s.split()))","verification_metadata":{"test_list":["assert reverse_words(\"python program\")==(\"program python\")","assert reverse_words(\"java language\")==(\"language java\")","assert reverse_words(\"indian man\")==(\"man indian\")"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":604,"text":"Write a function to reverse words seperated by spaces in a given string.","code":"def reverse_words(s):\n return ' '.join(reversed(s.split()))","test_list":["assert reverse_words(\"python program\")==(\"program python\")","assert reverse_words(\"java language\")==(\"language java\")","assert reverse_words(\"indian man\")==(\"man indian\")"],"test_imports":[]}} {"problem_id":"mbpp_train_00605","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if the given integer is a prime number.\n\nTests:\nassert prime_num(13)==True\nassert prime_num(7)==True\nassert prime_num(-1010)==False","canonical_answer":"def prime_num(num):\n if num >=1:\n for i in range(2, num//2):\n if (num % i) == 0:\n return False\n else:\n return True\n else:\n return False","verification_metadata":{"test_list":["assert prime_num(13)==True","assert prime_num(7)==True","assert prime_num(-1010)==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":605,"text":"Write a function to check if the given integer is a prime number.","code":"def prime_num(num):\n if num >=1:\n for i in range(2, num//2):\n if (num % i) == 0:\n return False\n else:\n return True\n else:\n return False","test_list":["assert prime_num(13)==True","assert prime_num(7)==True","assert prime_num(-1010)==False"],"test_imports":[]}} {"problem_id":"mbpp_train_00606","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert degrees to radians.\n\nTests:\nassert radian_degree(90)==1.5707963267948966\nassert radian_degree(60)==1.0471975511965976\nassert radian_degree(120)==2.0943951023931953","canonical_answer":"import math\ndef radian_degree(degree):\n radian = degree*(math.pi/180)\n return radian","verification_metadata":{"test_list":["assert radian_degree(90)==1.5707963267948966","assert radian_degree(60)==1.0471975511965976","assert radian_degree(120)==2.0943951023931953"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":606,"text":"Write a function to convert degrees to radians.","code":"import math\ndef radian_degree(degree):\n radian = degree*(math.pi/180)\n return radian","test_list":["assert radian_degree(90)==1.5707963267948966","assert radian_degree(60)==1.0471975511965976","assert radian_degree(120)==2.0943951023931953"],"test_imports":[]}} {"problem_id":"mbpp_train_00607","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to search a string for a regex pattern. The function should return the matching subtring, a start index and an end index.\n\nTests:\nassert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)\nassert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)\nassert find_literals('Hardest choices required strongest will', 'will') == ('will', 35, 39)","canonical_answer":"import re\n\ndef find_literals(text, pattern):\n match = re.search(pattern, text)\n s = match.start()\n e = match.end()\n return (match.re.pattern, s, e)","verification_metadata":{"test_list":["assert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)","assert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)","assert find_literals('Hardest choices required strongest will', 'will') == ('will', 35, 39)"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":607,"text":"Write a function to search a string for a regex pattern. The function should return the matching subtring, a start index and an end index.","code":"import re\n\ndef find_literals(text, pattern):\n match = re.search(pattern, text)\n s = match.start()\n e = match.end()\n return (match.re.pattern, s, e)","test_list":["assert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)","assert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)","assert find_literals('Hardest choices required strongest will', 'will') == ('will', 35, 39)"],"test_imports":[]}} {"problem_id":"mbpp_train_00608","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find nth bell number.\n\nTests:\nassert bell_Number(2) == 2\nassert bell_Number(3) == 5\nassert bell_Number(4) == 15","canonical_answer":"def bell_Number(n): \n bell = [[0 for i in range(n+1)] for j in range(n+1)] \n bell[0][0] = 1\n for i in range(1, n+1):\n bell[i][0] = bell[i-1][i-1]\n for j in range(1, i+1): \n bell[i][j] = bell[i-1][j-1] + bell[i][j-1] \n return bell[n][0]","verification_metadata":{"test_list":["assert bell_Number(2) == 2","assert bell_Number(3) == 5","assert bell_Number(4) == 15"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":608,"text":"Write a python function to find nth bell number.","code":"def bell_Number(n): \n bell = [[0 for i in range(n+1)] for j in range(n+1)] \n bell[0][0] = 1\n for i in range(1, n+1):\n bell[i][0] = bell[i-1][i-1]\n for j in range(1, i+1): \n bell[i][j] = bell[i-1][j-1] + bell[i][j-1] \n return bell[n][0]","test_list":["assert bell_Number(2) == 2","assert bell_Number(3) == 5","assert bell_Number(4) == 15"],"test_imports":[]}} {"problem_id":"mbpp_train_00610","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function which takes a list and returns a list with the same elements, but the k'th element removed.\n\nTests:\nassert remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1]\nassert remove_kth_element([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4],4)==[0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]\nassert remove_kth_element([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10],5)==[10,10,15,19, 18, 17, 26, 26, 17, 18, 10]","canonical_answer":"def remove_kth_element(list1, L):\n return list1[:L-1] + list1[L:]","verification_metadata":{"test_list":["assert remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1]","assert remove_kth_element([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4],4)==[0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]","assert remove_kth_element([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10],5)==[10,10,15,19, 18, 17, 26, 26, 17, 18, 10]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":610,"text":"Write a python function which takes a list and returns a list with the same elements, but the k'th element removed.","code":"def remove_kth_element(list1, L):\n return list1[:L-1] + list1[L:]","test_list":["assert remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1]","assert remove_kth_element([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4],4)==[0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]","assert remove_kth_element([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10],5)==[10,10,15,19, 18, 17, 26, 26, 17, 18, 10]"],"test_imports":[]}} {"problem_id":"mbpp_train_00611","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function which given a matrix represented as a list of lists returns the max of the n'th column.\n\nTests:\nassert max_of_nth([[5, 6, 7], [1, 3, 5], [8, 9, 19]], 2) == 19\nassert max_of_nth([[6, 7, 8], [2, 4, 6], [9, 10, 20]], 1) == 10\nassert max_of_nth([[7, 8, 9], [3, 5, 7], [10, 11, 21]], 1) == 11","canonical_answer":"def max_of_nth(test_list, N):\n res = max([sub[N] for sub in test_list])\n return (res)","verification_metadata":{"test_list":["assert max_of_nth([[5, 6, 7], [1, 3, 5], [8, 9, 19]], 2) == 19","assert max_of_nth([[6, 7, 8], [2, 4, 6], [9, 10, 20]], 1) == 10","assert max_of_nth([[7, 8, 9], [3, 5, 7], [10, 11, 21]], 1) == 11"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":611,"text":"Write a function which given a matrix represented as a list of lists returns the max of the n'th column.","code":"def max_of_nth(test_list, N):\n res = max([sub[N] for sub in test_list])\n return (res)","test_list":["assert max_of_nth([[5, 6, 7], [1, 3, 5], [8, 9, 19]], 2) == 19","assert max_of_nth([[6, 7, 8], [2, 4, 6], [9, 10, 20]], 1) == 10","assert max_of_nth([[7, 8, 9], [3, 5, 7], [10, 11, 21]], 1) == 11"],"test_imports":[]}} {"problem_id":"mbpp_train_00612","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function which takes a list of lists, where each sublist has two elements, and returns a list of two lists where the first list has the first element of each sublist and the second one has the second.\n\nTests:\nassert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]\nassert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]\nassert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]","canonical_answer":"def merge(lst): \n return [list(ele) for ele in list(zip(*lst))]","verification_metadata":{"test_list":["assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]","assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]","assert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":612,"text":"Write a python function which takes a list of lists, where each sublist has two elements, and returns a list of two lists where the first list has the first element of each sublist and the second one has the second.","code":"def merge(lst): \n return [list(ele) for ele in list(zip(*lst))]","test_list":["assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]","assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]","assert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]"],"test_imports":[]}} {"problem_id":"mbpp_train_00614","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the cumulative sum of all the values that are present in the given tuple list.\n\nTests:\nassert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30\nassert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37\nassert cummulative_sum([(3, 5), (7, 8, 9), (4, 8)]) == 44","canonical_answer":"def cummulative_sum(test_list):\n res = sum(map(sum, test_list))\n return (res)","verification_metadata":{"test_list":["assert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30","assert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37","assert cummulative_sum([(3, 5), (7, 8, 9), (4, 8)]) == 44"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":614,"text":"Write a function to find the cumulative sum of all the values that are present in the given tuple list.","code":"def cummulative_sum(test_list):\n res = sum(map(sum, test_list))\n return (res)","test_list":["assert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30","assert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37","assert cummulative_sum([(3, 5), (7, 8, 9), (4, 8)]) == 44"],"test_imports":[]}} {"problem_id":"mbpp_train_00615","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function which takes a tuple of tuples and returns the average value for each tuple as a list.\n\nTests:\nassert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]\nassert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]\nassert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 320), (10, 20, 30, 40)))==[305.0, 342.5, 270.0, 232.5]","canonical_answer":"def average_tuple(nums):\n result = [sum(x) / len(x) for x in zip(*nums)]\n return result","verification_metadata":{"test_list":["assert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]","assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]","assert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 320), (10, 20, 30, 40)))==[305.0, 342.5, 270.0, 232.5]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":615,"text":"Write a function which takes a tuple of tuples and returns the average value for each tuple as a list.","code":"def average_tuple(nums):\n result = [sum(x) / len(x) for x in zip(*nums)]\n return result","test_list":["assert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]","assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]","assert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 320), (10, 20, 30, 40)))==[305.0, 342.5, 270.0, 232.5]"],"test_imports":[]}} {"problem_id":"mbpp_train_00616","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function which takes two tuples of the same length and performs the element wise modulo.\n\nTests:\nassert tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1)\nassert tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6)) == (5, 5, 6, 1)\nassert tuple_modulo((12, 6, 7, 8), (7, 8, 9, 7)) == (5, 6, 7, 1)","canonical_answer":"def tuple_modulo(test_tup1, test_tup2):\n res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) \n return (res)","verification_metadata":{"test_list":["assert tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1)","assert tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6)) == (5, 5, 6, 1)","assert tuple_modulo((12, 6, 7, 8), (7, 8, 9, 7)) == (5, 6, 7, 1)"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":616,"text":"Write a function which takes two tuples of the same length and performs the element wise modulo.","code":"def tuple_modulo(test_tup1, test_tup2):\n res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) \n return (res)","test_list":["assert tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1)","assert tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6)) == (5, 5, 6, 1)","assert tuple_modulo((12, 6, 7, 8), (7, 8, 9, 7)) == (5, 6, 7, 1)"],"test_imports":[]}} {"problem_id":"mbpp_train_00617","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.\n\nTests:\nassert min_Jumps((3,4),11)==3.5\nassert min_Jumps((3,4),0)==0\nassert min_Jumps((11,14),11)==1","canonical_answer":"def min_Jumps(steps, d): \n (a, b) = steps\n temp = a \n a = min(a, b) \n b = max(temp, b) \n if (d >= b): \n return (d + b - 1) / b \n if (d == 0): \n return 0\n if (d == a): \n return 1\n else:\n return 2","verification_metadata":{"test_list":["assert min_Jumps((3,4),11)==3.5","assert min_Jumps((3,4),0)==0","assert min_Jumps((11,14),11)==1"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":617,"text":"Write a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.","code":"def min_Jumps(steps, d): \n (a, b) = steps\n temp = a \n a = min(a, b) \n b = max(temp, b) \n if (d >= b): \n return (d + b - 1) / b \n if (d == 0): \n return 0\n if (d == a): \n return 1\n else:\n return 2","test_list":["assert min_Jumps((3,4),11)==3.5","assert min_Jumps((3,4),0)==0","assert min_Jumps((11,14),11)==1"],"test_imports":[]}} {"problem_id":"mbpp_train_00618","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to divide two lists element wise.\n\nTests:\nassert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]\nassert div_list([3,2],[1,4])==[3.0, 0.5]\nassert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]","canonical_answer":"def div_list(nums1,nums2):\n result = map(lambda x, y: x / y, nums1, nums2)\n return list(result)","verification_metadata":{"test_list":["assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]","assert div_list([3,2],[1,4])==[3.0, 0.5]","assert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":618,"text":"Write a function to divide two lists element wise.","code":"def div_list(nums1,nums2):\n result = map(lambda x, y: x / y, nums1, nums2)\n return list(result)","test_list":["assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]","assert div_list([3,2],[1,4])==[3.0, 0.5]","assert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]"],"test_imports":[]}} {"problem_id":"mbpp_train_00619","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to move all the numbers to the end of the given string.\n\nTests:\nassert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'\nassert move_num('Avengers124Assemble') == 'AvengersAssemble124'\nassert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'","canonical_answer":"def move_num(test_str):\n res = ''\n dig = ''\n for ele in test_str:\n if ele.isdigit():\n dig += ele\n else:\n res += ele\n res += dig\n return (res)","verification_metadata":{"test_list":["assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'","assert move_num('Avengers124Assemble') == 'AvengersAssemble124'","assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":619,"text":"Write a function to move all the numbers to the end of the given string.","code":"def move_num(test_str):\n res = ''\n dig = ''\n for ele in test_str:\n if ele.isdigit():\n dig += ele\n else:\n res += ele\n res += dig\n return (res)","test_list":["assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'","assert move_num('Avengers124Assemble') == 'AvengersAssemble124'","assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'"],"test_imports":[]}} {"problem_id":"mbpp_train_00620","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the size of the largest subset of a list of numbers so that every pair is divisible.\n\nTests:\nassert largest_subset([ 1, 3, 6, 13, 17, 18 ]) == 4\nassert largest_subset([10, 5, 3, 15, 20]) == 3\nassert largest_subset([18, 1, 3, 6, 13, 17]) == 4","canonical_answer":"def largest_subset(a):\n\tn = len(a)\n\tdp = [0 for i in range(n)]\n\tdp[n - 1] = 1; \n\tfor i in range(n - 2, -1, -1):\n\t\tmxm = 0;\n\t\tfor j in range(i + 1, n):\n\t\t\tif a[j] % a[i] == 0 or a[i] % a[j] == 0:\n\t\t\t\tmxm = max(mxm, dp[j])\n\t\tdp[i] = 1 + mxm\n\treturn max(dp)","verification_metadata":{"test_list":["assert largest_subset([ 1, 3, 6, 13, 17, 18 ]) == 4","assert largest_subset([10, 5, 3, 15, 20]) == 3","assert largest_subset([18, 1, 3, 6, 13, 17]) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":620,"text":"Write a function to find the size of the largest subset of a list of numbers so that every pair is divisible.","code":"def largest_subset(a):\n\tn = len(a)\n\tdp = [0 for i in range(n)]\n\tdp[n - 1] = 1; \n\tfor i in range(n - 2, -1, -1):\n\t\tmxm = 0;\n\t\tfor j in range(i + 1, n):\n\t\t\tif a[j] % a[i] == 0 or a[i] % a[j] == 0:\n\t\t\t\tmxm = max(mxm, dp[j])\n\t\tdp[i] = 1 + mxm\n\treturn max(dp)","test_list":["assert largest_subset([ 1, 3, 6, 13, 17, 18 ]) == 4","assert largest_subset([10, 5, 3, 15, 20]) == 3","assert largest_subset([18, 1, 3, 6, 13, 17]) == 4"],"test_imports":[]}} {"problem_id":"mbpp_train_00622","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the median of two sorted lists of same size.\n\nTests:\nassert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0\nassert get_median([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5\nassert get_median([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6) == 25.0","canonical_answer":"def get_median(arr1, arr2, n):\n i = 0\n j = 0\n m1 = -1\n m2 = -1\n count = 0\n while count < n + 1:\n count += 1\n if i == n:\n m1 = m2\n m2 = arr2[0]\n break\n elif j == n:\n m1 = m2\n m2 = arr1[0]\n break\n if arr1[i] <= arr2[j]:\n m1 = m2\n m2 = arr1[i]\n i += 1\n else:\n m1 = m2\n m2 = arr2[j]\n j += 1\n return (m1 + m2)/2","verification_metadata":{"test_list":["assert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0","assert get_median([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5","assert get_median([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6) == 25.0"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":622,"text":"Write a function to find the median of two sorted lists of same size.","code":"def get_median(arr1, arr2, n):\n i = 0\n j = 0\n m1 = -1\n m2 = -1\n count = 0\n while count < n + 1:\n count += 1\n if i == n:\n m1 = m2\n m2 = arr2[0]\n break\n elif j == n:\n m1 = m2\n m2 = arr1[0]\n break\n if arr1[i] <= arr2[j]:\n m1 = m2\n m2 = arr1[i]\n i += 1\n else:\n m1 = m2\n m2 = arr2[j]\n j += 1\n return (m1 + m2)/2","test_list":["assert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0","assert get_median([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5","assert get_median([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6) == 25.0"],"test_imports":[]}} {"problem_id":"mbpp_train_00623","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to compute the n-th power of each number in a list.\n\nTests:\nassert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\nassert nth_nums([10,20,30],3)==([1000, 8000, 27000])\nassert nth_nums([12,15],5)==([248832, 759375])","canonical_answer":"def nth_nums(nums,n):\n nth_nums = list(map(lambda x: x ** n, nums))\n return nth_nums","verification_metadata":{"test_list":["assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]","assert nth_nums([10,20,30],3)==([1000, 8000, 27000])","assert nth_nums([12,15],5)==([248832, 759375])"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":623,"text":"Write a function to compute the n-th power of each number in a list.","code":"def nth_nums(nums,n):\n nth_nums = list(map(lambda x: x ** n, nums))\n return nth_nums","test_list":["assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]","assert nth_nums([10,20,30],3)==([1000, 8000, 27000])","assert nth_nums([12,15],5)==([248832, 759375])"],"test_imports":[]}} {"problem_id":"mbpp_train_00624","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to convert a given string to uppercase.\n\nTests:\nassert is_upper(\"person\") ==\"PERSON\"\nassert is_upper(\"final\") == \"FINAL\"\nassert is_upper(\"Valid\") == \"VALID\"","canonical_answer":"def is_upper(string):\n return (string.upper())","verification_metadata":{"test_list":["assert is_upper(\"person\") ==\"PERSON\"","assert is_upper(\"final\") == \"FINAL\"","assert is_upper(\"Valid\") == \"VALID\""],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":624,"text":"Write a python function to convert a given string to uppercase.","code":"def is_upper(string):\n return (string.upper())","test_list":["assert is_upper(\"person\") ==\"PERSON\"","assert is_upper(\"final\") == \"FINAL\"","assert is_upper(\"Valid\") == \"VALID\""],"test_imports":[]}} {"problem_id":"mbpp_train_00625","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to interchange the first and last element in a given list.\n\nTests:\nassert swap_List([1,2,3]) == [3,2,1]\nassert swap_List([1,2,3,4,4]) == [4,2,3,4,1]\nassert swap_List([4,5,6]) == [6,5,4]","canonical_answer":"def swap_List(newList): \n size = len(newList) \n temp = newList[0] \n newList[0] = newList[size - 1] \n newList[size - 1] = temp \n return newList","verification_metadata":{"test_list":["assert swap_List([1,2,3]) == [3,2,1]","assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]","assert swap_List([4,5,6]) == [6,5,4]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":625,"text":"Write a python function to interchange the first and last element in a given list.","code":"def swap_List(newList): \n size = len(newList) \n temp = newList[0] \n newList[0] = newList[size - 1] \n newList[size - 1] = temp \n return newList","test_list":["assert swap_List([1,2,3]) == [3,2,1]","assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]","assert swap_List([4,5,6]) == [6,5,4]"],"test_imports":[]}} {"problem_id":"mbpp_train_00626","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the area of the largest triangle that can be inscribed in a semicircle with a given radius.\n\nTests:\nassert triangle_area(-1) == None\nassert triangle_area(0) == 0\nassert triangle_area(2) == 4","canonical_answer":"def triangle_area(r) : \n if r < 0 : \n return None\n return r * r","verification_metadata":{"test_list":["assert triangle_area(-1) == None","assert triangle_area(0) == 0","assert triangle_area(2) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":626,"text":"Write a python function to find the area of the largest triangle that can be inscribed in a semicircle with a given radius.","code":"def triangle_area(r) : \n if r < 0 : \n return None\n return r * r","test_list":["assert triangle_area(-1) == None","assert triangle_area(0) == 0","assert triangle_area(2) == 4"],"test_imports":[]}} {"problem_id":"mbpp_train_00627","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the smallest missing number from a sorted list of natural numbers.\n\nTests:\nassert find_First_Missing([0,1,2,3]) == 4\nassert find_First_Missing([0,1,2,6,9]) == 3\nassert find_First_Missing([2,3,5,8,9]) == 0","canonical_answer":"def find_First_Missing(array,start=0,end=None):\n if end is None:\n end = len(array) - 1 \n if (start > end): \n return end + 1\n if (start != array[start]): \n return start; \n mid = int((start + end) / 2) \n if (array[mid] == mid): \n return find_First_Missing(array,mid+1,end) \n return find_First_Missing(array,start,mid)","verification_metadata":{"test_list":["assert find_First_Missing([0,1,2,3]) == 4","assert find_First_Missing([0,1,2,6,9]) == 3","assert find_First_Missing([2,3,5,8,9]) == 0"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":627,"text":"Write a python function to find the smallest missing number from a sorted list of natural numbers.","code":"def find_First_Missing(array,start=0,end=None):\n if end is None:\n end = len(array) - 1 \n if (start > end): \n return end + 1\n if (start != array[start]): \n return start; \n mid = int((start + end) / 2) \n if (array[mid] == mid): \n return find_First_Missing(array,mid+1,end) \n return find_First_Missing(array,start,mid)","test_list":["assert find_First_Missing([0,1,2,3]) == 4","assert find_First_Missing([0,1,2,6,9]) == 3","assert find_First_Missing([2,3,5,8,9]) == 0"],"test_imports":[]}} {"problem_id":"mbpp_train_00628","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to replace all spaces in the given string with '%20'.\n\nTests:\nassert replace_spaces(\"My Name is Dawood\") == 'My%20Name%20is%20Dawood'\nassert replace_spaces(\"I am a Programmer\") == 'I%20am%20a%20Programmer'\nassert replace_spaces(\"I love Coding\") == 'I%20love%20Coding'","canonical_answer":"def replace_spaces(string):\n return string.replace(\" \", \"%20\")","verification_metadata":{"test_list":["assert replace_spaces(\"My Name is Dawood\") == 'My%20Name%20is%20Dawood'","assert replace_spaces(\"I am a Programmer\") == 'I%20am%20a%20Programmer'","assert replace_spaces(\"I love Coding\") == 'I%20love%20Coding'"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":628,"text":"Write a function to replace all spaces in the given string with '%20'.","code":"def replace_spaces(string):\n return string.replace(\" \", \"%20\")","test_list":["assert replace_spaces(\"My Name is Dawood\") == 'My%20Name%20is%20Dawood'","assert replace_spaces(\"I am a Programmer\") == 'I%20am%20a%20Programmer'","assert replace_spaces(\"I love Coding\") == 'I%20love%20Coding'"],"test_imports":[]}} {"problem_id":"mbpp_train_00629","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find even numbers from a list of numbers.\n\nTests:\nassert Split([1,2,3,4,5]) == [2,4]\nassert Split([4,5,6,7,8,0,1]) == [4,6,8,0]\nassert Split ([8,12,15,19]) == [8,12]","canonical_answer":"def Split(list): \n return [num for num in list if num % 2 == 0]","verification_metadata":{"test_list":["assert Split([1,2,3,4,5]) == [2,4]","assert Split([4,5,6,7,8,0,1]) == [4,6,8,0]","assert Split ([8,12,15,19]) == [8,12]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":629,"text":"Write a python function to find even numbers from a list of numbers.","code":"def Split(list): \n return [num for num in list if num % 2 == 0]","test_list":["assert Split([1,2,3,4,5]) == [2,4]","assert Split([4,5,6,7,8,0,1]) == [4,6,8,0]","assert Split ([8,12,15,19]) == [8,12]"],"test_imports":[]}} {"problem_id":"mbpp_train_00630","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to extract all the adjacent coordinates of the given coordinate tuple.\n\nTests:\nassert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]\nassert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]\nassert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7]]","canonical_answer":"def adjac(ele, sub = []): \n if not ele: \n yield sub \n else: \n yield from [idx for j in range(ele[0] - 1, ele[0] + 2) \n for idx in adjac(ele[1:], sub + [j])] \ndef get_coordinates(test_tup):\n return list(adjac(test_tup))","verification_metadata":{"test_list":["assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]","assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]","assert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7]]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":630,"text":"Write a function to extract all the adjacent coordinates of the given coordinate tuple.","code":"def adjac(ele, sub = []): \n if not ele: \n yield sub \n else: \n yield from [idx for j in range(ele[0] - 1, ele[0] + 2) \n for idx in adjac(ele[1:], sub + [j])] \ndef get_coordinates(test_tup):\n return list(adjac(test_tup))","test_list":["assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]","assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]","assert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7]]"],"test_imports":[]}} {"problem_id":"mbpp_train_00631","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to replace whitespaces with an underscore and vice versa in a given string.\n\nTests:\nassert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'\nassert replace_spaces('The_Avengers') == 'The Avengers'\nassert replace_spaces('Fast and Furious') == 'Fast_and_Furious'","canonical_answer":"def replace_spaces(text):\n return \"\".join(\" \" if c == \"_\" else (\"_\" if c == \" \" else c) for c in text)","verification_metadata":{"test_list":["assert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'","assert replace_spaces('The_Avengers') == 'The Avengers'","assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":631,"text":"Write a function to replace whitespaces with an underscore and vice versa in a given string.","code":"def replace_spaces(text):\n return \"\".join(\" \" if c == \"_\" else (\"_\" if c == \" \" else c) for c in text)","test_list":["assert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'","assert replace_spaces('The_Avengers') == 'The Avengers'","assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'"],"test_imports":[]}} {"problem_id":"mbpp_train_00632","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to move all zeroes to the end of the given list.\n\nTests:\nassert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]\nassert move_zero([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0]\nassert move_zero([0,1,0,1,1]) == [1,1,1,0,0]","canonical_answer":"def move_zero(num_list):\n a = [0 for i in range(num_list.count(0))]\n x = [i for i in num_list if i != 0]\n return x + a","verification_metadata":{"test_list":["assert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]","assert move_zero([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0]","assert move_zero([0,1,0,1,1]) == [1,1,1,0,0]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":632,"text":"Write a python function to move all zeroes to the end of the given list.","code":"def move_zero(num_list):\n a = [0 for i in range(num_list.count(0))]\n x = [i for i in num_list if i != 0]\n return x + a","test_list":["assert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]","assert move_zero([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0]","assert move_zero([0,1,0,1,1]) == [1,1,1,0,0]"],"test_imports":[]}} {"problem_id":"mbpp_train_00633","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of xor of all pairs of numbers in the given list.\n\nTests:\nassert pair_xor_Sum([5,9,7,6],4) == 47\nassert pair_xor_Sum([7,3,5],3) == 12\nassert pair_xor_Sum([7,3],2) == 4","canonical_answer":"def pair_xor_Sum(arr,n) : \n ans = 0 \n for i in range(0,n) : \n for j in range(i + 1,n) : \n ans = ans + (arr[i] ^ arr[j]) \n return ans","verification_metadata":{"test_list":["assert pair_xor_Sum([5,9,7,6],4) == 47","assert pair_xor_Sum([7,3,5],3) == 12","assert pair_xor_Sum([7,3],2) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":633,"text":"Write a python function to find the sum of xor of all pairs of numbers in the given list.","code":"def pair_xor_Sum(arr,n) : \n ans = 0 \n for i in range(0,n) : \n for j in range(i + 1,n) : \n ans = ans + (arr[i] ^ arr[j]) \n return ans","test_list":["assert pair_xor_Sum([5,9,7,6],4) == 47","assert pair_xor_Sum([7,3,5],3) == 12","assert pair_xor_Sum([7,3],2) == 4"],"test_imports":[]}} {"problem_id":"mbpp_train_00635","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sort the given list.\n\nTests:\nassert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\nassert heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]\nassert heap_sort( [7, 1, 9, 5])==[1,5,7,9]","canonical_answer":"import heapq as hq\ndef heap_sort(iterable):\n h = []\n for value in iterable:\n hq.heappush(h, value)\n return [hq.heappop(h) for i in range(len(h))]","verification_metadata":{"test_list":["assert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]","assert heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]","assert heap_sort( [7, 1, 9, 5])==[1,5,7,9]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":635,"text":"Write a function to sort the given list.","code":"import heapq as hq\ndef heap_sort(iterable):\n h = []\n for value in iterable:\n hq.heappush(h, value)\n return [hq.heappop(h) for i in range(len(h))]","test_list":["assert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]","assert heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]","assert heap_sort( [7, 1, 9, 5])==[1,5,7,9]"],"test_imports":[]}} {"problem_id":"mbpp_train_00637","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether the given amount has no profit and no loss\n\nTests:\nassert noprofit_noloss(1500,1200)==False\nassert noprofit_noloss(100,100)==True\nassert noprofit_noloss(2000,5000)==False","canonical_answer":"def noprofit_noloss(actual_cost,sale_amount): \n if(sale_amount == actual_cost):\n return True\n else:\n return False","verification_metadata":{"test_list":["assert noprofit_noloss(1500,1200)==False","assert noprofit_noloss(100,100)==True","assert noprofit_noloss(2000,5000)==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":637,"text":"Write a function to check whether the given amount has no profit and no loss","code":"def noprofit_noloss(actual_cost,sale_amount): \n if(sale_amount == actual_cost):\n return True\n else:\n return False","test_list":["assert noprofit_noloss(1500,1200)==False","assert noprofit_noloss(100,100)==True","assert noprofit_noloss(2000,5000)==False"],"test_imports":[]}} {"problem_id":"mbpp_train_00638","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to calculate the wind chill index rounded to the next integer given the wind velocity in km/h and a temperature in celsius.\n\nTests:\nassert wind_chill(120,35)==40\nassert wind_chill(40,20)==19\nassert wind_chill(10,8)==6","canonical_answer":"import math\ndef wind_chill(v,t):\n windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16)\n return int(round(windchill, 0))","verification_metadata":{"test_list":["assert wind_chill(120,35)==40","assert wind_chill(40,20)==19","assert wind_chill(10,8)==6"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":638,"text":"Write a function to calculate the wind chill index rounded to the next integer given the wind velocity in km/h and a temperature in celsius.","code":"import math\ndef wind_chill(v,t):\n windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16)\n return int(round(windchill, 0))","test_list":["assert wind_chill(120,35)==40","assert wind_chill(40,20)==19","assert wind_chill(10,8)==6"],"test_imports":[]}} {"problem_id":"mbpp_train_00639","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter.\n\nTests:\nassert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16\nassert sample_nam([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==10\nassert sample_nam([\"abcd\", \"Python\", \"abba\", \"aba\"])==6","canonical_answer":"def sample_nam(sample_names):\n sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names))\n return len(''.join(sample_names))","verification_metadata":{"test_list":["assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16","assert sample_nam([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==10","assert sample_nam([\"abcd\", \"Python\", \"abba\", \"aba\"])==6"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":639,"text":"Write a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter.","code":"def sample_nam(sample_names):\n sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names))\n return len(''.join(sample_names))","test_list":["assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16","assert sample_nam([\"php\", \"res\", \"Python\", \"abcd\", \"Java\", \"aaa\"])==10","assert sample_nam([\"abcd\", \"Python\", \"abba\", \"aba\"])==6"],"test_imports":[]}} {"problem_id":"mbpp_train_00640","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove the parenthesis and what is inbetween them from a string.\n\nTests:\nassert remove_parenthesis([\"python (chrome)\"])==(\"python\")\nassert remove_parenthesis([\"string(.abc)\"])==(\"string\")\nassert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")","canonical_answer":"import re\ndef remove_parenthesis(items):\n for item in items:\n return (re.sub(r\" ?\\([^)]+\\)\", \"\", item))","verification_metadata":{"test_list":["assert remove_parenthesis([\"python (chrome)\"])==(\"python\")","assert remove_parenthesis([\"string(.abc)\"])==(\"string\")","assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":640,"text":"Write a function to remove the parenthesis and what is inbetween them from a string.","code":"import re\ndef remove_parenthesis(items):\n for item in items:\n return (re.sub(r\" ?\\([^)]+\\)\", \"\", item))","test_list":["assert remove_parenthesis([\"python (chrome)\"])==(\"python\")","assert remove_parenthesis([\"string(.abc)\"])==(\"string\")","assert remove_parenthesis([\"alpha(num)\"])==(\"alpha\")"],"test_imports":[]}} {"problem_id":"mbpp_train_00641","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the nth nonagonal number.\n\nTests:\nassert is_nonagonal(10) == 325\nassert is_nonagonal(15) == 750\nassert is_nonagonal(18) == 1089","canonical_answer":"def is_nonagonal(n): \n\treturn int(n * (7 * n - 5) / 2)","verification_metadata":{"test_list":["assert is_nonagonal(10) == 325","assert is_nonagonal(15) == 750","assert is_nonagonal(18) == 1089"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":641,"text":"Write a function to find the nth nonagonal number.","code":"def is_nonagonal(n): \n\treturn int(n * (7 * n - 5) / 2)","test_list":["assert is_nonagonal(10) == 325","assert is_nonagonal(15) == 750","assert is_nonagonal(18) == 1089"],"test_imports":[]}} {"problem_id":"mbpp_train_00643","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that checks if a strings contains 'z', except at the start and end of the word.\n\nTests:\nassert text_match_wordz_middle(\"pythonzabc.\")==True\nassert text_match_wordz_middle(\"zxyabc.\")==False\nassert text_match_wordz_middle(\" lang .\")==False","canonical_answer":"import re\ndef text_match_wordz_middle(text):\n return bool(re.search(r'\\Bz\\B', text))","verification_metadata":{"test_list":["assert text_match_wordz_middle(\"pythonzabc.\")==True","assert text_match_wordz_middle(\"zxyabc.\")==False","assert text_match_wordz_middle(\" lang .\")==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":643,"text":"Write a function that checks if a strings contains 'z', except at the start and end of the word.","code":"import re\ndef text_match_wordz_middle(text):\n return bool(re.search(r'\\Bz\\B', text))","test_list":["assert text_match_wordz_middle(\"pythonzabc.\")==True","assert text_match_wordz_middle(\"zxyabc.\")==False","assert text_match_wordz_middle(\" lang .\")==False"],"test_imports":[]}} {"problem_id":"mbpp_train_00644","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to reverse an array upto a given position.\n\nTests:\nassert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]\nassert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]\nassert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]","canonical_answer":"def reverse_Array_Upto_K(input, k): \n return (input[k-1::-1] + input[k:])","verification_metadata":{"test_list":["assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]","assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]","assert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":644,"text":"Write a python function to reverse an array upto a given position.","code":"def reverse_Array_Upto_K(input, k): \n return (input[k-1::-1] + input[k:])","test_list":["assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]","assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]","assert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]"],"test_imports":[]}} {"problem_id":"mbpp_train_00720","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to add a dictionary to the tuple. The output should be a tuple.\n\nTests:\nassert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})\nassert add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})\nassert add_dict_to_tuple((8, 9, 10), {\"POS\" : 3, \"is\" : 4, \"Okay\" : 5} ) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})","canonical_answer":"def add_dict_to_tuple(test_tup, test_dict):\n test_tup = list(test_tup)\n test_tup.append(test_dict)\n test_tup = tuple(test_tup)\n return (test_tup)","verification_metadata":{"test_list":["assert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})","assert add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})","assert add_dict_to_tuple((8, 9, 10), {\"POS\" : 3, \"is\" : 4, \"Okay\" : 5} ) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":720,"text":"Write a function to add a dictionary to the tuple. The output should be a tuple.","code":"def add_dict_to_tuple(test_tup, test_dict):\n test_tup = list(test_tup)\n test_tup.append(test_dict)\n test_tup = tuple(test_tup)\n return (test_tup)","test_list":["assert add_dict_to_tuple((4, 5, 6), {\"MSAM\" : 1, \"is\" : 2, \"best\" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})","assert add_dict_to_tuple((1, 2, 3), {\"UTS\" : 2, \"is\" : 3, \"Worst\" : 4} ) == (1, 2, 3, {'UTS': 2, 'is': 3, 'Worst': 4})","assert add_dict_to_tuple((8, 9, 10), {\"POS\" : 3, \"is\" : 4, \"Okay\" : 5} ) == (8, 9, 10, {'POS': 3, 'is': 4, 'Okay': 5})"],"test_imports":[]}} {"problem_id":"mbpp_train_00721","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nGiven a square matrix of size N*N given as a list of lists, where each cell is associated with a specific cost. A path is defined as a specific sequence of cells that starts from the top-left cell move only right or down and ends on bottom right cell. We want to find a path with the maximum average over all existing paths. Average is computed as total cost divided by the number of cells visited in the path.\n\nTests:\nassert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]]) == 5.2\nassert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]]) == 6.2\nassert maxAverageOfPath([[3, 4, 5], [8, 7, 6], [9, 5, 11]]) == 7.2\nassert maxAverageOfPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 5.8","canonical_answer":"def maxAverageOfPath(cost):\n N = len(cost)\n dp = [[0 for i in range(N + 1)] for j in range(N + 1)]\n dp[0][0] = cost[0][0]\n for i in range(1, N):\n dp[i][0] = dp[i - 1][0] + cost[i][0]\n for j in range(1, N):\n dp[0][j] = dp[0][j - 1] + cost[0][j]\n for i in range(1, N):\n for j in range(1, N):\n dp[i][j] = max(dp[i - 1][j],\n dp[i][j - 1]) + cost[i][j]\n return dp[N - 1][N - 1] / (2 * N - 1)","verification_metadata":{"test_list":["assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]]) == 5.2","assert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]]) == 6.2","assert maxAverageOfPath([[3, 4, 5], [8, 7, 6], [9, 5, 11]]) == 7.2","assert maxAverageOfPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 5.8"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":721,"text":"Given a square matrix of size N*N given as a list of lists, where each cell is associated with a specific cost. A path is defined as a specific sequence of cells that starts from the top-left cell move only right or down and ends on bottom right cell. We want to find a path with the maximum average over all existing paths. Average is computed as total cost divided by the number of cells visited in the path.","code":"def maxAverageOfPath(cost):\n N = len(cost)\n dp = [[0 for i in range(N + 1)] for j in range(N + 1)]\n dp[0][0] = cost[0][0]\n for i in range(1, N):\n dp[i][0] = dp[i - 1][0] + cost[i][0]\n for j in range(1, N):\n dp[0][j] = dp[0][j - 1] + cost[0][j]\n for i in range(1, N):\n for j in range(1, N):\n dp[i][j] = max(dp[i - 1][j],\n dp[i][j - 1]) + cost[i][j]\n return dp[N - 1][N - 1] / (2 * N - 1)","test_list":["assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]]) == 5.2","assert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]]) == 6.2","assert maxAverageOfPath([[3, 4, 5], [8, 7, 6], [9, 5, 11]]) == 7.2","assert maxAverageOfPath([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 5.8"],"test_imports":[]}} {"problem_id":"mbpp_train_00722","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nThe input is given as - a dictionary with a student name as a key and a tuple of float (student_height, student_weight) as a value, - minimal height, - minimal weight. Write a function to filter students that have height and weight above the minimum.\n\nTests:\nassert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)}\nassert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.9,67)=={'Cierra Vega': (6.2, 70),'Kierra Gentry': (6.0, 68)}\nassert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.7,64)=={'Cierra Vega': (6.2, 70),'Alden Cantrell': (5.9, 65),'Kierra Gentry': (6.0, 68),'Pierre Cox': (5.8, 66)}","canonical_answer":"def filter_data(students,h,w):\n result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w}\n return result","verification_metadata":{"test_list":["assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)}","assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.9,67)=={'Cierra Vega': (6.2, 70),'Kierra Gentry': (6.0, 68)}","assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.7,64)=={'Cierra Vega': (6.2, 70),'Alden Cantrell': (5.9, 65),'Kierra Gentry': (6.0, 68),'Pierre Cox': (5.8, 66)}"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":722,"text":"The input is given as - a dictionary with a student name as a key and a tuple of float (student_height, student_weight) as a value, - minimal height, - minimal weight. Write a function to filter students that have height and weight above the minimum.","code":"def filter_data(students,h,w):\n result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w}\n return result","test_list":["assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)}","assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.9,67)=={'Cierra Vega': (6.2, 70),'Kierra Gentry': (6.0, 68)}","assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.7,64)=={'Cierra Vega': (6.2, 70),'Alden Cantrell': (5.9, 65),'Kierra Gentry': (6.0, 68),'Pierre Cox': (5.8, 66)}"],"test_imports":[]}} {"problem_id":"mbpp_train_00723","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nThe input is defined as two lists of the same length. Write a function to count indices where the lists have the same values.\n\nTests:\nassert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4\nassert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==11\nassert count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==1\nassert count_same_pair([0, 1, 1, 2],[0, 1, 2, 2])==3","canonical_answer":"from operator import eq\ndef count_same_pair(nums1, nums2):\n result = sum(map(eq, nums1, nums2))\n return result","verification_metadata":{"test_list":["assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4","assert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==11","assert count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==1","assert count_same_pair([0, 1, 1, 2],[0, 1, 2, 2])==3"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":723,"text":"The input is defined as two lists of the same length. Write a function to count indices where the lists have the same values.","code":"from operator import eq\ndef count_same_pair(nums1, nums2):\n result = sum(map(eq, nums1, nums2))\n return result","test_list":["assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4","assert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==11","assert count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==1","assert count_same_pair([0, 1, 1, 2],[0, 1, 2, 2])==3"],"test_imports":[]}} {"problem_id":"mbpp_train_00724","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes base and power as arguments and calculate the sum of all digits of the base to the specified power.\n\nTests:\nassert power_base_sum(2,100)==115\nassert power_base_sum(8,10)==37\nassert power_base_sum(8,15)==62\nassert power_base_sum(3,3)==9","canonical_answer":"def power_base_sum(base, power):\n return sum([int(i) for i in str(pow(base, power))])","verification_metadata":{"test_list":["assert power_base_sum(2,100)==115","assert power_base_sum(8,10)==37","assert power_base_sum(8,15)==62","assert power_base_sum(3,3)==9"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":724,"text":"Write a function that takes base and power as arguments and calculate the sum of all digits of the base to the specified power.","code":"def power_base_sum(base, power):\n return sum([int(i) for i in str(pow(base, power))])","test_list":["assert power_base_sum(2,100)==115","assert power_base_sum(8,10)==37","assert power_base_sum(8,15)==62","assert power_base_sum(3,3)==9"],"test_imports":[]}} {"problem_id":"mbpp_train_00725","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to extract values between quotation marks \" \" of the given string.\n\nTests:\nassert extract_quotation('Cortex \"A53\" Based \"multi\" tasking \"Processor\"') == ['A53', 'multi', 'Processor']\nassert extract_quotation('Cast your \"favorite\" entertainment \"apps\"') == ['favorite', 'apps']\nassert extract_quotation('Watch content \"4k Ultra HD\" resolution with \"HDR 10\" Support') == ['4k Ultra HD', 'HDR 10']\nassert extract_quotation(\"Watch content '4k Ultra HD' resolution with 'HDR 10' Support\") == []","canonical_answer":"import re\ndef extract_quotation(text1):\n return (re.findall(r'\"(.*?)\"', text1))","verification_metadata":{"test_list":["assert extract_quotation('Cortex \"A53\" Based \"multi\" tasking \"Processor\"') == ['A53', 'multi', 'Processor']","assert extract_quotation('Cast your \"favorite\" entertainment \"apps\"') == ['favorite', 'apps']","assert extract_quotation('Watch content \"4k Ultra HD\" resolution with \"HDR 10\" Support') == ['4k Ultra HD', 'HDR 10']","assert extract_quotation(\"Watch content '4k Ultra HD' resolution with 'HDR 10' Support\") == []"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":725,"text":"Write a function to extract values between quotation marks \" \" of the given string.","code":"import re\ndef extract_quotation(text1):\n return (re.findall(r'\"(.*?)\"', text1))","test_list":["assert extract_quotation('Cortex \"A53\" Based \"multi\" tasking \"Processor\"') == ['A53', 'multi', 'Processor']","assert extract_quotation('Cast your \"favorite\" entertainment \"apps\"') == ['favorite', 'apps']","assert extract_quotation('Watch content \"4k Ultra HD\" resolution with \"HDR 10\" Support') == ['4k Ultra HD', 'HDR 10']","assert extract_quotation(\"Watch content '4k Ultra HD' resolution with 'HDR 10' Support\") == []"],"test_imports":[]}} {"problem_id":"mbpp_train_00726","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes as input a tuple of numbers (t_1,...,t_{N+1}) and returns a tuple of length N where the i-th element of the tuple is equal to t_i * t_{i+1}.\n\nTests:\nassert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)\nassert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42)\nassert multiply_elements((12, 13, 14, 9, 15)) == (156, 182, 126, 135)\nassert multiply_elements((12,)) == ()","canonical_answer":"def multiply_elements(test_tup):\n res = tuple(i * j for i, j in zip(test_tup, test_tup[1:]))\n return (res)","verification_metadata":{"test_list":["assert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)","assert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42)","assert multiply_elements((12, 13, 14, 9, 15)) == (156, 182, 126, 135)","assert multiply_elements((12,)) == ()"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":726,"text":"Write a function that takes as input a tuple of numbers (t_1,...,t_{N+1}) and returns a tuple of length N where the i-th element of the tuple is equal to t_i * t_{i+1}.","code":"def multiply_elements(test_tup):\n res = tuple(i * j for i, j in zip(test_tup, test_tup[1:]))\n return (res)","test_list":["assert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)","assert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42)","assert multiply_elements((12, 13, 14, 9, 15)) == (156, 182, 126, 135)","assert multiply_elements((12,)) == ()"],"test_imports":[]}} {"problem_id":"mbpp_train_00728","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function takes as input two lists [a_1,...,a_n], [b_1,...,b_n] and returns [a_1+b_1,...,a_n+b_n].\n\nTests:\nassert sum_list([10,20,30],[15,25,35])==[25,45,65]\nassert sum_list([1,2,3],[5,6,7])==[6,8,10]\nassert sum_list([15,20,30],[15,45,75])==[30,65,105]","canonical_answer":"def sum_list(lst1,lst2):\n res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] \n return res_list","verification_metadata":{"test_list":["assert sum_list([10,20,30],[15,25,35])==[25,45,65]","assert sum_list([1,2,3],[5,6,7])==[6,8,10]","assert sum_list([15,20,30],[15,45,75])==[30,65,105]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":728,"text":"Write a function takes as input two lists [a_1,...,a_n], [b_1,...,b_n] and returns [a_1+b_1,...,a_n+b_n].","code":"def sum_list(lst1,lst2):\n res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] \n return res_list","test_list":["assert sum_list([10,20,30],[15,25,35])==[25,45,65]","assert sum_list([1,2,3],[5,6,7])==[6,8,10]","assert sum_list([15,20,30],[15,45,75])==[30,65,105]"],"test_imports":[]}} {"problem_id":"mbpp_train_00730","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove consecutive duplicates of a given list.\n\nTests:\nassert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]\nassert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10]\nassert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==['a', 'b', 'c', 'd']\nassert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd', 'a', 'a'])==['a', 'b', 'c', 'd', 'a']","canonical_answer":"from itertools import groupby\ndef consecutive_duplicates(nums):\n return [key for key, group in groupby(nums)]","verification_metadata":{"test_list":["assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]","assert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10]","assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==['a', 'b', 'c', 'd']","assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd', 'a', 'a'])==['a', 'b', 'c', 'd', 'a']"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":730,"text":"Write a function to remove consecutive duplicates of a given list.","code":"from itertools import groupby\ndef consecutive_duplicates(nums):\n return [key for key, group in groupby(nums)]","test_list":["assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]","assert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10]","assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==['a', 'b', 'c', 'd']","assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd', 'a', 'a'])==['a', 'b', 'c', 'd', 'a']"],"test_imports":[]}} {"problem_id":"mbpp_train_00731","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the lateral surface area of a cone given radius r and the height h.\n\nTests:\nassert lateralsurface_cone(5,12)==204.20352248333654\nassert lateralsurface_cone(10,15)==566.3586699569488\nassert lateralsurface_cone(19,17)==1521.8090132193388","canonical_answer":"import math\ndef lateralsurface_cone(r,h):\n l = math.sqrt(r * r + h * h)\n LSA = math.pi * r * l\n return LSA","verification_metadata":{"test_list":["assert lateralsurface_cone(5,12)==204.20352248333654","assert lateralsurface_cone(10,15)==566.3586699569488","assert lateralsurface_cone(19,17)==1521.8090132193388"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":731,"text":"Write a function to find the lateral surface area of a cone given radius r and the height h.","code":"import math\ndef lateralsurface_cone(r,h):\n l = math.sqrt(r * r + h * h)\n LSA = math.pi * r * l\n return LSA","test_list":["assert lateralsurface_cone(5,12)==204.20352248333654","assert lateralsurface_cone(10,15)==566.3586699569488","assert lateralsurface_cone(19,17)==1521.8090132193388"],"test_imports":[]}} {"problem_id":"mbpp_train_00732","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to replace all occurrences of spaces, commas, or dots with a colon.\n\nTests:\nassert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')\nassert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')\nassert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')","canonical_answer":"import re\ndef replace_specialchar(text):\n return (re.sub(\"[ ,.]\", \":\", text))","verification_metadata":{"test_list":["assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')","assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')","assert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":732,"text":"Write a function to replace all occurrences of spaces, commas, or dots with a colon.","code":"import re\ndef replace_specialchar(text):\n return (re.sub(\"[ ,.]\", \":\", text))","test_list":["assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')","assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')","assert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')"],"test_imports":[]}} {"problem_id":"mbpp_train_00733","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the index of the first occurrence of a given number in a sorted array.\n\nTests:\nassert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1\nassert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2\nassert find_first_occurrence([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6) == 4","canonical_answer":"def find_first_occurrence(A, x):\n (left, right) = (0, len(A) - 1)\n result = -1\n while left <= right:\n mid = (left + right) // 2\n if x == A[mid]:\n result = mid\n right = mid - 1\n elif x < A[mid]:\n right = mid - 1\n else:\n left = mid + 1\n return result","verification_metadata":{"test_list":["assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1","assert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2","assert find_first_occurrence([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":733,"text":"Write a function to find the index of the first occurrence of a given number in a sorted array.","code":"def find_first_occurrence(A, x):\n (left, right) = (0, len(A) - 1)\n result = -1\n while left <= right:\n mid = (left + right) // 2\n if x == A[mid]:\n result = mid\n right = mid - 1\n elif x < A[mid]:\n right = mid - 1\n else:\n left = mid + 1\n return result","test_list":["assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1","assert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2","assert find_first_occurrence([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6) == 4"],"test_imports":[]}} {"problem_id":"mbpp_train_00734","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find sum of products of all possible sublists of a given list. https://www.geeksforgeeks.org/sum-of-products-of-all-possible-subarrays/\n\nTests:\nassert sum_Of_Subarray_Prod([1,2,3]) == 20\nassert sum_Of_Subarray_Prod([1,2]) == 5\nassert sum_Of_Subarray_Prod([1,2,3,4]) == 84","canonical_answer":"def sum_Of_Subarray_Prod(arr):\n ans = 0\n res = 0\n i = len(arr) - 1\n while (i >= 0):\n incr = arr[i]*(1 + res)\n ans += incr\n res = incr\n i -= 1\n return (ans)","verification_metadata":{"test_list":["assert sum_Of_Subarray_Prod([1,2,3]) == 20","assert sum_Of_Subarray_Prod([1,2]) == 5","assert sum_Of_Subarray_Prod([1,2,3,4]) == 84"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":734,"text":"Write a python function to find sum of products of all possible sublists of a given list. https://www.geeksforgeeks.org/sum-of-products-of-all-possible-subarrays/","code":"def sum_Of_Subarray_Prod(arr):\n ans = 0\n res = 0\n i = len(arr) - 1\n while (i >= 0):\n incr = arr[i]*(1 + res)\n ans += incr\n res = incr\n i -= 1\n return (ans)","test_list":["assert sum_Of_Subarray_Prod([1,2,3]) == 20","assert sum_Of_Subarray_Prod([1,2]) == 5","assert sum_Of_Subarray_Prod([1,2,3,4]) == 84"],"test_imports":[]}} {"problem_id":"mbpp_train_00735","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to toggle bits of the number except the first and the last bit. https://www.geeksforgeeks.org/toggle-bits-number-expect-first-last-bits/\n\nTests:\nassert toggle_middle_bits(9) == 15\nassert toggle_middle_bits(10) == 12\nassert toggle_middle_bits(11) == 13\nassert toggle_middle_bits(0b1000001) == 0b1111111\nassert toggle_middle_bits(0b1001101) == 0b1110011","canonical_answer":"def set_middle_bits(n): \n n |= n >> 1; \n n |= n >> 2; \n n |= n >> 4; \n n |= n >> 8; \n n |= n >> 16; \n return (n >> 1) ^ 1\ndef toggle_middle_bits(n): \n if (n == 1): \n return 1\n return n ^ set_middle_bits(n)","verification_metadata":{"test_list":["assert toggle_middle_bits(9) == 15","assert toggle_middle_bits(10) == 12","assert toggle_middle_bits(11) == 13","assert toggle_middle_bits(0b1000001) == 0b1111111","assert toggle_middle_bits(0b1001101) == 0b1110011"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":735,"text":"Write a python function to toggle bits of the number except the first and the last bit. https://www.geeksforgeeks.org/toggle-bits-number-expect-first-last-bits/","code":"def set_middle_bits(n): \n n |= n >> 1; \n n |= n >> 2; \n n |= n >> 4; \n n |= n >> 8; \n n |= n >> 16; \n return (n >> 1) ^ 1\ndef toggle_middle_bits(n): \n if (n == 1): \n return 1\n return n ^ set_middle_bits(n)","test_list":["assert toggle_middle_bits(9) == 15","assert toggle_middle_bits(10) == 12","assert toggle_middle_bits(11) == 13","assert toggle_middle_bits(0b1000001) == 0b1111111","assert toggle_middle_bits(0b1001101) == 0b1110011"],"test_imports":[]}} {"problem_id":"mbpp_train_00736","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to locate the left insertion point for a specified value in sorted order. https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-data-structure-exercise-24.php\n\nTests:\nassert left_insertion([1,2,4,5],6)==4\nassert left_insertion([1,2,4,5],3)==2\nassert left_insertion([1,2,4,5],7)==4","canonical_answer":"import bisect\ndef left_insertion(a, x):\n i = bisect.bisect_left(a, x)\n return i","verification_metadata":{"test_list":["assert left_insertion([1,2,4,5],6)==4","assert left_insertion([1,2,4,5],3)==2","assert left_insertion([1,2,4,5],7)==4"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":736,"text":"Write a function to locate the left insertion point for a specified value in sorted order. https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-data-structure-exercise-24.php","code":"import bisect\ndef left_insertion(a, x):\n i = bisect.bisect_left(a, x)\n return i","test_list":["assert left_insertion([1,2,4,5],6)==4","assert left_insertion([1,2,4,5],3)==2","assert left_insertion([1,2,4,5],7)==4"],"test_imports":[]}} {"problem_id":"mbpp_train_00737","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether the given string is starting with a vowel or not using regex.\n\nTests:\nassert check_str(\"annie\")\nassert not check_str(\"dawood\")\nassert check_str(\"Else\")","canonical_answer":"import re \nregex = '^[aeiouAEIOU][A-Za-z0-9_]*'\ndef check_str(string): \n\treturn re.search(regex, string)","verification_metadata":{"test_list":["assert check_str(\"annie\")","assert not check_str(\"dawood\")","assert check_str(\"Else\")"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":737,"text":"Write a function to check whether the given string is starting with a vowel or not using regex.","code":"import re \nregex = '^[aeiouAEIOU][A-Za-z0-9_]*'\ndef check_str(string): \n\treturn re.search(regex, string)","test_list":["assert check_str(\"annie\")","assert not check_str(\"dawood\")","assert check_str(\"Else\")"],"test_imports":[]}} {"problem_id":"mbpp_train_00738","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to calculate the geometric sum of n-1. https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-recursion-exercise-9.php\n\nTests:\nassert geometric_sum(7) == 1.9921875\nassert geometric_sum(4) == 1.9375\nassert geometric_sum(8) == 1.99609375","canonical_answer":"def geometric_sum(n):\n if n < 0:\n return 0\n else:\n return 1 / (pow(2, n)) + geometric_sum(n - 1)","verification_metadata":{"test_list":["assert geometric_sum(7) == 1.9921875","assert geometric_sum(4) == 1.9375","assert geometric_sum(8) == 1.99609375"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":738,"text":"Write a function to calculate the geometric sum of n-1. https://www.w3resource.com/python-exercises/data-structures-and-algorithms/python-recursion-exercise-9.php","code":"def geometric_sum(n):\n if n < 0:\n return 0\n else:\n return 1 / (pow(2, n)) + geometric_sum(n - 1)","test_list":["assert geometric_sum(7) == 1.9921875","assert geometric_sum(4) == 1.9375","assert geometric_sum(8) == 1.99609375"],"test_imports":[]}} {"problem_id":"mbpp_train_00739","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the index of smallest triangular number with n digits. https://www.geeksforgeeks.org/index-of-smallest-triangular-number-with-n-digits/\n\nTests:\nassert find_Index(2) == 4\nassert find_Index(3) == 14\nassert find_Index(4) == 45","canonical_answer":"import math \ndef find_Index(n): \n x = math.sqrt(2 * math.pow(10,(n - 1)))\n return round(x)","verification_metadata":{"test_list":["assert find_Index(2) == 4","assert find_Index(3) == 14","assert find_Index(4) == 45"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":739,"text":"Write a python function to find the index of smallest triangular number with n digits. https://www.geeksforgeeks.org/index-of-smallest-triangular-number-with-n-digits/","code":"import math \ndef find_Index(n): \n x = math.sqrt(2 * math.pow(10,(n - 1)))\n return round(x)","test_list":["assert find_Index(2) == 4","assert find_Index(3) == 14","assert find_Index(4) == 45"],"test_imports":[]}} {"problem_id":"mbpp_train_00740","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert the given tuple to a key-value dictionary using adjacent elements. https://www.geeksforgeeks.org/python-convert-tuple-to-adjacent-pair-dictionary/\n\nTests:\nassert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}\nassert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}\nassert tuple_to_dict((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}","canonical_answer":"def tuple_to_dict(test_tup):\n res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))\n return (res)","verification_metadata":{"test_list":["assert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}","assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}","assert tuple_to_dict((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":740,"text":"Write a function to convert the given tuple to a key-value dictionary using adjacent elements. https://www.geeksforgeeks.org/python-convert-tuple-to-adjacent-pair-dictionary/","code":"def tuple_to_dict(test_tup):\n res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))\n return (res)","test_list":["assert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}","assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}","assert tuple_to_dict((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}"],"test_imports":[]}} {"problem_id":"mbpp_train_00741","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether all the characters are same or not.\n\nTests:\nassert all_Characters_Same(\"python\") == False\nassert all_Characters_Same(\"aaa\") == True\nassert all_Characters_Same(\"data\") == False","canonical_answer":"def all_Characters_Same(s) :\n n = len(s)\n for i in range(1,n) :\n if s[i] != s[0] :\n return False\n return True","verification_metadata":{"test_list":["assert all_Characters_Same(\"python\") == False","assert all_Characters_Same(\"aaa\") == True","assert all_Characters_Same(\"data\") == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":741,"text":"Write a python function to check whether all the characters are same or not.","code":"def all_Characters_Same(s) :\n n = len(s)\n for i in range(1,n) :\n if s[i] != s[0] :\n return False\n return True","test_list":["assert all_Characters_Same(\"python\") == False","assert all_Characters_Same(\"aaa\") == True","assert all_Characters_Same(\"data\") == False"],"test_imports":[]}} {"problem_id":"mbpp_train_00742","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to caluclate the area of a tetrahedron.\n\nTests:\nassert area_tetrahedron(3)==15.588457268119894\nassert area_tetrahedron(20)==692.8203230275509\nassert area_tetrahedron(10)==173.20508075688772","canonical_answer":"import math\ndef area_tetrahedron(side):\n area = math.sqrt(3)*(side*side)\n return area","verification_metadata":{"test_list":["assert area_tetrahedron(3)==15.588457268119894","assert area_tetrahedron(20)==692.8203230275509","assert area_tetrahedron(10)==173.20508075688772"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":742,"text":"Write a function to caluclate the area of a tetrahedron.","code":"import math\ndef area_tetrahedron(side):\n area = math.sqrt(3)*(side*side)\n return area","test_list":["assert area_tetrahedron(3)==15.588457268119894","assert area_tetrahedron(20)==692.8203230275509","assert area_tetrahedron(10)==173.20508075688772"],"test_imports":[]}} {"problem_id":"mbpp_train_00743","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to rotate a given list by specified number of items to the right direction. https://www.geeksforgeeks.org/python-program-right-rotate-list-n/\n\nTests:\nassert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3)==[8, 9, 10, 1, 2, 3, 4, 5, 6, 7]\nassert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]\nassert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5]","canonical_answer":"def rotate_right(list, m):\n result = list[-m:] + list[:-m]\n return result","verification_metadata":{"test_list":["assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3)==[8, 9, 10, 1, 2, 3, 4, 5, 6, 7]","assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]","assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":743,"text":"Write a function to rotate a given list by specified number of items to the right direction. https://www.geeksforgeeks.org/python-program-right-rotate-list-n/","code":"def rotate_right(list, m):\n result = list[-m:] + list[:-m]\n return result","test_list":["assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3)==[8, 9, 10, 1, 2, 3, 4, 5, 6, 7]","assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]","assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5]"],"test_imports":[]}} {"problem_id":"mbpp_train_00744","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if the given tuple has any none value or not.\n\nTests:\nassert check_none((10, 4, 5, 6, None)) == True\nassert check_none((7, 8, 9, 11, 14)) == False\nassert check_none((1, 2, 3, 4, None)) == True","canonical_answer":"def check_none(test_tup):\n res = any(map(lambda ele: ele is None, test_tup))\n return res","verification_metadata":{"test_list":["assert check_none((10, 4, 5, 6, None)) == True","assert check_none((7, 8, 9, 11, 14)) == False","assert check_none((1, 2, 3, 4, None)) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":744,"text":"Write a function to check if the given tuple has any none value or not.","code":"def check_none(test_tup):\n res = any(map(lambda ele: ele is None, test_tup))\n return res","test_list":["assert check_none((10, 4, 5, 6, None)) == True","assert check_none((7, 8, 9, 11, 14)) == False","assert check_none((1, 2, 3, 4, None)) == True"],"test_imports":[]}} {"problem_id":"mbpp_train_00745","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find numbers within a given range from startnum ti endnum where every number is divisible by every digit it contains. https://www.w3resource.com/python-exercises/lambda/python-lambda-exercise-24.php\n\nTests:\nassert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]\nassert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]\nassert divisible_by_digits(20,25)==[22, 24]","canonical_answer":"def divisible_by_digits(startnum, endnum):\n return [n for n in range(startnum, endnum+1) \\\n if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]","verification_metadata":{"test_list":["assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]","assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]","assert divisible_by_digits(20,25)==[22, 24]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":745,"text":"Write a function to find numbers within a given range from startnum ti endnum where every number is divisible by every digit it contains. https://www.w3resource.com/python-exercises/lambda/python-lambda-exercise-24.php","code":"def divisible_by_digits(startnum, endnum):\n return [n for n in range(startnum, endnum+1) \\\n if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]","test_list":["assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]","assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]","assert divisible_by_digits(20,25)==[22, 24]"],"test_imports":[]}} {"problem_id":"mbpp_train_00746","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find area of a sector. The function takes the radius and angle as inputs. Function should return None if the angle is larger than 360 degrees.\n\nTests:\nassert sector_area(4,45)==6.283185307179586\nassert sector_area(9,45)==31.808625617596654\nassert sector_area(9,361)==None","canonical_answer":"import math\ndef sector_area(r,a):\n if a > 360:\n return None\n return (math.pi*r**2) * (a/360)","verification_metadata":{"test_list":["assert sector_area(4,45)==6.283185307179586","assert sector_area(9,45)==31.808625617596654","assert sector_area(9,361)==None"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":746,"text":"Write a function to find area of a sector. The function takes the radius and angle as inputs. Function should return None if the angle is larger than 360 degrees.","code":"import math\ndef sector_area(r,a):\n if a > 360:\n return None\n return (math.pi*r**2) * (a/360)","test_list":["assert sector_area(4,45)==6.283185307179586","assert sector_area(9,45)==31.808625617596654","assert sector_area(9,361)==None"],"test_imports":[]}} {"problem_id":"mbpp_train_00747","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the longest common subsequence for the given three string sequence. https://www.geeksforgeeks.org/lcs-longest-common-subsequence-three-strings/\n\nTests:\nassert lcs_of_three('AGGT12', '12TXAYB', '12XBA') == 2\nassert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels') == 5\nassert lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea') == 3","canonical_answer":"def lcs_of_three(X, Y, Z): \n m = len(X)\n n = len(Y)\n o = len(Z)\n L = [[[0 for i in range(o+1)] for j in range(n+1)] for k in range(m+1)]\n for i in range(m+1): \n\t for j in range(n+1): \n\t\t for k in range(o+1): \n\t\t\t if (i == 0 or j == 0 or k == 0): \n\t\t\t\t L[i][j][k] = 0\n\t\t\t elif (X[i-1] == Y[j-1] and X[i-1] == Z[k-1]): \n\t\t\t\t L[i][j][k] = L[i-1][j-1][k-1] + 1\n\t\t\t else: \n\t\t\t\t L[i][j][k] = max(max(L[i-1][j][k], L[i][j-1][k]), L[i][j][k-1]) \n return L[m][n][o]","verification_metadata":{"test_list":["assert lcs_of_three('AGGT12', '12TXAYB', '12XBA') == 2","assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels') == 5","assert lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea') == 3"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":747,"text":"Write a function to find the longest common subsequence for the given three string sequence. https://www.geeksforgeeks.org/lcs-longest-common-subsequence-three-strings/","code":"def lcs_of_three(X, Y, Z): \n m = len(X)\n n = len(Y)\n o = len(Z)\n L = [[[0 for i in range(o+1)] for j in range(n+1)] for k in range(m+1)]\n for i in range(m+1): \n\t for j in range(n+1): \n\t\t for k in range(o+1): \n\t\t\t if (i == 0 or j == 0 or k == 0): \n\t\t\t\t L[i][j][k] = 0\n\t\t\t elif (X[i-1] == Y[j-1] and X[i-1] == Z[k-1]): \n\t\t\t\t L[i][j][k] = L[i-1][j-1][k-1] + 1\n\t\t\t else: \n\t\t\t\t L[i][j][k] = max(max(L[i-1][j][k], L[i][j-1][k]), L[i][j][k-1]) \n return L[m][n][o]","test_list":["assert lcs_of_three('AGGT12', '12TXAYB', '12XBA') == 2","assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels') == 5","assert lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea') == 3"],"test_imports":[]}} {"problem_id":"mbpp_train_00748","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to put spaces between words starting with capital letters in a given string.\n\nTests:\nassert capital_words_spaces(\"Python\") == 'Python'\nassert capital_words_spaces(\"PythonProgrammingExamples\") == 'Python Programming Examples'\nassert capital_words_spaces(\"GetReadyToBeCodingFreak\") == 'Get Ready To Be Coding Freak'","canonical_answer":"import re\ndef capital_words_spaces(str1):\n return re.sub(r\"(\\w)([A-Z])\", r\"\\1 \\2\", str1)","verification_metadata":{"test_list":["assert capital_words_spaces(\"Python\") == 'Python'","assert capital_words_spaces(\"PythonProgrammingExamples\") == 'Python Programming Examples'","assert capital_words_spaces(\"GetReadyToBeCodingFreak\") == 'Get Ready To Be Coding Freak'"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":748,"text":"Write a function to put spaces between words starting with capital letters in a given string.","code":"import re\ndef capital_words_spaces(str1):\n return re.sub(r\"(\\w)([A-Z])\", r\"\\1 \\2\", str1)","test_list":["assert capital_words_spaces(\"Python\") == 'Python'","assert capital_words_spaces(\"PythonProgrammingExamples\") == 'Python Programming Examples'","assert capital_words_spaces(\"GetReadyToBeCodingFreak\") == 'Get Ready To Be Coding Freak'"],"test_imports":[]}} {"problem_id":"mbpp_train_00749","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sort a given list of strings of numbers numerically. https://www.geeksforgeeks.org/python-sort-numeric-strings-in-a-list/\n\nTests:\nassert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]\nassert sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])==[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]\nassert sort_numeric_strings(['1','3','5','7','1', '3','13', '15', '17','5', '7 ','9','1', '11'])==[1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17]","canonical_answer":"def sort_numeric_strings(nums_str):\n result = [int(x) for x in nums_str]\n result.sort()\n return result","verification_metadata":{"test_list":["assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]","assert sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])==[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]","assert sort_numeric_strings(['1','3','5','7','1', '3','13', '15', '17','5', '7 ','9','1', '11'])==[1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":749,"text":"Write a function to sort a given list of strings of numbers numerically. https://www.geeksforgeeks.org/python-sort-numeric-strings-in-a-list/","code":"def sort_numeric_strings(nums_str):\n result = [int(x) for x in nums_str]\n result.sort()\n return result","test_list":["assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]","assert sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])==[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]","assert sort_numeric_strings(['1','3','5','7','1', '3','13', '15', '17','5', '7 ','9','1', '11'])==[1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17]"],"test_imports":[]}} {"problem_id":"mbpp_train_00750","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to add the given tuple to the given list.\n\nTests:\nassert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]\nassert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]\nassert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]","canonical_answer":"def add_tuple(test_list, test_tup):\n test_list += test_tup\n return test_list","verification_metadata":{"test_list":["assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]","assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]","assert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":750,"text":"Write a function to add the given tuple to the given list.","code":"def add_tuple(test_list, test_tup):\n test_list += test_tup\n return test_list","test_list":["assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]","assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]","assert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]"],"test_imports":[]}} {"problem_id":"mbpp_train_00751","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if the given array represents min heap or not. https://www.geeksforgeeks.org/how-to-check-if-a-given-array-represents-a-binary-heap/\n\nTests:\nassert check_min_heap([1, 2, 3, 4, 5, 6]) == True\nassert check_min_heap([2, 3, 4, 5, 10, 15]) == True\nassert check_min_heap([2, 10, 4, 5, 3, 15]) == False","canonical_answer":"def check_min_heap_helper(arr, i):\n if 2 * i + 2 > len(arr):\n return True\n left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap_helper(arr, 2 * i + 1)\n right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2] \n and check_min_heap_helper(arr, 2 * i + 2))\n return left_child and right_child\n\ndef check_min_heap(arr):\n return check_min_heap_helper(arr, 0)","verification_metadata":{"test_list":["assert check_min_heap([1, 2, 3, 4, 5, 6]) == True","assert check_min_heap([2, 3, 4, 5, 10, 15]) == True","assert check_min_heap([2, 10, 4, 5, 3, 15]) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":751,"text":"Write a function to check if the given array represents min heap or not. https://www.geeksforgeeks.org/how-to-check-if-a-given-array-represents-a-binary-heap/","code":"def check_min_heap_helper(arr, i):\n if 2 * i + 2 > len(arr):\n return True\n left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap_helper(arr, 2 * i + 1)\n right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2] \n and check_min_heap_helper(arr, 2 * i + 2))\n return left_child and right_child\n\ndef check_min_heap(arr):\n return check_min_heap_helper(arr, 0)","test_list":["assert check_min_heap([1, 2, 3, 4, 5, 6]) == True","assert check_min_heap([2, 3, 4, 5, 10, 15]) == True","assert check_min_heap([2, 10, 4, 5, 3, 15]) == False"],"test_imports":[]}} {"problem_id":"mbpp_train_00752","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the nth jacobsthal number. https://www.geeksforgeeks.org/jacobsthal-and-jacobsthal-lucas-numbers/ 0, 1, 1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, 2731, ...\n\nTests:\nassert jacobsthal_num(5) == 11\nassert jacobsthal_num(2) == 1\nassert jacobsthal_num(4) == 5\nassert jacobsthal_num(13) == 2731","canonical_answer":"def jacobsthal_num(n): \n\tdp = [0] * (n + 1) \n\tdp[0] = 0\n\tdp[1] = 1\n\tfor i in range(2, n+1): \n\t\tdp[i] = dp[i - 1] + 2 * dp[i - 2] \n\treturn dp[n]","verification_metadata":{"test_list":["assert jacobsthal_num(5) == 11","assert jacobsthal_num(2) == 1","assert jacobsthal_num(4) == 5","assert jacobsthal_num(13) == 2731"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":752,"text":"Write a function to find the nth jacobsthal number. https://www.geeksforgeeks.org/jacobsthal-and-jacobsthal-lucas-numbers/ 0, 1, 1, 3, 5, 11, 21, 43, 85, 171, 341, 683, 1365, 2731, ...","code":"def jacobsthal_num(n): \n\tdp = [0] * (n + 1) \n\tdp[0] = 0\n\tdp[1] = 1\n\tfor i in range(2, n+1): \n\t\tdp[i] = dp[i - 1] + 2 * dp[i - 2] \n\treturn dp[n]","test_list":["assert jacobsthal_num(5) == 11","assert jacobsthal_num(2) == 1","assert jacobsthal_num(4) == 5","assert jacobsthal_num(13) == 2731"],"test_imports":[]}} {"problem_id":"mbpp_train_00753","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find minimum k records from tuple list. https://www.geeksforgeeks.org/python-find-minimum-k-records-from-tuple-list/ - in this case a verbatim copy of test cases\n\nTests:\nassert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]\nassert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]\nassert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1) == [('Ayesha', 9)]","canonical_answer":"def min_k(test_list, K):\n res = sorted(test_list, key = lambda x: x[1])[:K]\n return (res)","verification_metadata":{"test_list":["assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]","assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]","assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1) == [('Ayesha', 9)]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":753,"text":"Write a function to find minimum k records from tuple list. https://www.geeksforgeeks.org/python-find-minimum-k-records-from-tuple-list/ - in this case a verbatim copy of test cases","code":"def min_k(test_list, K):\n res = sorted(test_list, key = lambda x: x[1])[:K]\n return (res)","test_list":["assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]","assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]","assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1) == [('Ayesha', 9)]"],"test_imports":[]}} {"problem_id":"mbpp_train_00754","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWe say that an element is common for lists l1, l2, l3 if it appears in all three lists under the same index. Write a function to find common elements from three lists. The function should return a list.\n\nTests:\nassert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]\nassert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6]\nassert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5]\nassert extract_index_list([1, 2, 3, 4, 6, 6, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[]","canonical_answer":"def extract_index_list(l1, l2, l3):\n result = []\n for m, n, o in zip(l1, l2, l3):\n if (m == n == o):\n result.append(m)\n return result","verification_metadata":{"test_list":["assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]","assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6]","assert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5]","assert extract_index_list([1, 2, 3, 4, 6, 6, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":754,"text":"We say that an element is common for lists l1, l2, l3 if it appears in all three lists under the same index. Write a function to find common elements from three lists. The function should return a list.","code":"def extract_index_list(l1, l2, l3):\n result = []\n for m, n, o in zip(l1, l2, l3):\n if (m == n == o):\n result.append(m)\n return result","test_list":["assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]","assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6]","assert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5]","assert extract_index_list([1, 2, 3, 4, 6, 6, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[]"],"test_imports":[]}} {"problem_id":"mbpp_train_00755","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the second smallest number in a list.\n\nTests:\nassert second_smallest([1, 2, -8, -2, 0, -2])==-2\nassert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5\nassert second_smallest([2,2])==None\nassert second_smallest([2,2,2])==None","canonical_answer":"def second_smallest(numbers):\n unique_numbers = list(set(numbers))\n unique_numbers.sort()\n if len(unique_numbers) < 2:\n return None\n else:\n return unique_numbers[1]","verification_metadata":{"test_list":["assert second_smallest([1, 2, -8, -2, 0, -2])==-2","assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5","assert second_smallest([2,2])==None","assert second_smallest([2,2,2])==None"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":755,"text":"Write a function to find the second smallest number in a list.","code":"def second_smallest(numbers):\n unique_numbers = list(set(numbers))\n unique_numbers.sort()\n if len(unique_numbers) < 2:\n return None\n else:\n return unique_numbers[1]","test_list":["assert second_smallest([1, 2, -8, -2, 0, -2])==-2","assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5","assert second_smallest([2,2])==None","assert second_smallest([2,2,2])==None"],"test_imports":[]}} {"problem_id":"mbpp_train_00756","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that matches a string that has an 'a' followed by one or more 'b's. https://www.w3resource.com/python-exercises/re/python-re-exercise-3.php\n\nTests:\nassert text_match_zero_one(\"ac\")==False\nassert text_match_zero_one(\"dc\")==False\nassert text_match_zero_one(\"abbbba\")==True\nassert text_match_zero_one(\"dsabbbba\")==True\nassert text_match_zero_one(\"asbbbba\")==False\nassert text_match_zero_one(\"abaaa\")==True","canonical_answer":"import re\ndef text_match_zero_one(text):\n patterns = 'ab+?'\n if re.search(patterns, text):\n return True\n else:\n return False","verification_metadata":{"test_list":["assert text_match_zero_one(\"ac\")==False","assert text_match_zero_one(\"dc\")==False","assert text_match_zero_one(\"abbbba\")==True","assert text_match_zero_one(\"dsabbbba\")==True","assert text_match_zero_one(\"asbbbba\")==False","assert text_match_zero_one(\"abaaa\")==True"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":756,"text":"Write a function that matches a string that has an 'a' followed by one or more 'b's. https://www.w3resource.com/python-exercises/re/python-re-exercise-3.php","code":"import re\ndef text_match_zero_one(text):\n patterns = 'ab+?'\n if re.search(patterns, text):\n return True\n else:\n return False","test_list":["assert text_match_zero_one(\"ac\")==False","assert text_match_zero_one(\"dc\")==False","assert text_match_zero_one(\"abbbba\")==True","assert text_match_zero_one(\"dsabbbba\")==True","assert text_match_zero_one(\"asbbbba\")==False","assert text_match_zero_one(\"abaaa\")==True"],"test_imports":[]}} {"problem_id":"mbpp_train_00757","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to count the pairs of reverse strings in the given string list. https://www.geeksforgeeks.org/python-program-to-count-the-pairs-of-reverse-strings/\n\nTests:\nassert count_reverse_pairs([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"])== 2\nassert count_reverse_pairs([\"geeks\", \"best\", \"for\", \"skeeg\"]) == 1\nassert count_reverse_pairs([\"makes\", \"best\", \"sekam\", \"for\", \"rof\"]) == 2","canonical_answer":"def count_reverse_pairs(test_list):\n res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len( \n\ttest_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))]) \n return res","verification_metadata":{"test_list":["assert count_reverse_pairs([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"])== 2","assert count_reverse_pairs([\"geeks\", \"best\", \"for\", \"skeeg\"]) == 1","assert count_reverse_pairs([\"makes\", \"best\", \"sekam\", \"for\", \"rof\"]) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":757,"text":"Write a function to count the pairs of reverse strings in the given string list. https://www.geeksforgeeks.org/python-program-to-count-the-pairs-of-reverse-strings/","code":"def count_reverse_pairs(test_list):\n res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len( \n\ttest_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))]) \n return res","test_list":["assert count_reverse_pairs([\"julia\", \"best\", \"tseb\", \"for\", \"ailuj\"])== 2","assert count_reverse_pairs([\"geeks\", \"best\", \"for\", \"skeeg\"]) == 1","assert count_reverse_pairs([\"makes\", \"best\", \"sekam\", \"for\", \"rof\"]) == 2"],"test_imports":[]}} {"problem_id":"mbpp_train_00758","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to count lists within a list. The function should return a dictionary where every list is converted to a tuple and the value of such tuple is the number of its occurencies in the original list.\n\nTests:\nassert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}\nassert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}\nassert unique_sublists([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]])=={(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1}\nassert unique_sublists([['john']])=={('john',): 1}","canonical_answer":"def unique_sublists(list1):\n result ={}\n for l in list1: \n result.setdefault(tuple(l), list()).append(1) \n for a, b in result.items(): \n result[a] = sum(b)\n return result","verification_metadata":{"test_list":["assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}","assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}","assert unique_sublists([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]])=={(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1}","assert unique_sublists([['john']])=={('john',): 1}"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":758,"text":"Write a function to count lists within a list. The function should return a dictionary where every list is converted to a tuple and the value of such tuple is the number of its occurencies in the original list.","code":"def unique_sublists(list1):\n result ={}\n for l in list1: \n result.setdefault(tuple(l), list()).append(1) \n for a, b in result.items(): \n result[a] = sum(b)\n return result","test_list":["assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}","assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}","assert unique_sublists([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]])=={(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1}","assert unique_sublists([['john']])=={('john',): 1}"],"test_imports":[]}} {"problem_id":"mbpp_train_00759","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether a given string is a decimal number with a precision of 2.\n\nTests:\nassert is_decimal('123.11')==True\nassert is_decimal('e666.86')==False\nassert is_decimal('3.124587')==False\nassert is_decimal('1.11')==True\nassert is_decimal('1.1.11')==False","canonical_answer":"def is_decimal(num):\n import re\n dnumre = re.compile(r\"\"\"^[0-9]+(\\.[0-9]{1,2})?$\"\"\")\n result = dnumre.search(num)\n return bool(result)","verification_metadata":{"test_list":["assert is_decimal('123.11')==True","assert is_decimal('e666.86')==False","assert is_decimal('3.124587')==False","assert is_decimal('1.11')==True","assert is_decimal('1.1.11')==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":759,"text":"Write a function to check whether a given string is a decimal number with a precision of 2.","code":"def is_decimal(num):\n import re\n dnumre = re.compile(r\"\"\"^[0-9]+(\\.[0-9]{1,2})?$\"\"\")\n result = dnumre.search(num)\n return bool(result)","test_list":["assert is_decimal('123.11')==True","assert is_decimal('e666.86')==False","assert is_decimal('3.124587')==False","assert is_decimal('1.11')==True","assert is_decimal('1.1.11')==False"],"test_imports":[]}} {"problem_id":"mbpp_train_00760","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether a list of numbers contains only one distinct element or not.\n\nTests:\nassert unique_Element([1,1,1]) == True\nassert unique_Element([1,2,1,2]) == False\nassert unique_Element([1,2,3,4,5]) == False","canonical_answer":"def unique_Element(arr):\n s = set(arr)\n return len(s) == 1","verification_metadata":{"test_list":["assert unique_Element([1,1,1]) == True","assert unique_Element([1,2,1,2]) == False","assert unique_Element([1,2,3,4,5]) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":760,"text":"Write a python function to check whether a list of numbers contains only one distinct element or not.","code":"def unique_Element(arr):\n s = set(arr)\n return len(s) == 1","test_list":["assert unique_Element([1,1,1]) == True","assert unique_Element([1,2,1,2]) == False","assert unique_Element([1,2,3,4,5]) == False"],"test_imports":[]}} {"problem_id":"mbpp_train_00762","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether the given month number contains 30 days or not. Months are given as number from 1 to 12.\n\nTests:\nassert check_monthnumber_number(6)==True\nassert check_monthnumber_number(2)==False\nassert check_monthnumber_number(12)==False","canonical_answer":"def check_monthnumber_number(monthnum3):\n return monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11","verification_metadata":{"test_list":["assert check_monthnumber_number(6)==True","assert check_monthnumber_number(2)==False","assert check_monthnumber_number(12)==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":762,"text":"Write a function to check whether the given month number contains 30 days or not. Months are given as number from 1 to 12.","code":"def check_monthnumber_number(monthnum3):\n return monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11","test_list":["assert check_monthnumber_number(6)==True","assert check_monthnumber_number(2)==False","assert check_monthnumber_number(12)==False"],"test_imports":[]}} {"problem_id":"mbpp_train_00763","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the minimum difference between any two elements in a given array. https://www.geeksforgeeks.org/find-minimum-difference-pair/\n\nTests:\nassert find_min_diff((1,5,3,19,18,25),6) == 1\nassert find_min_diff((4,3,2,6),4) == 1\nassert find_min_diff((30,5,20,9),4) == 4","canonical_answer":"def find_min_diff(arr,n): \n arr = sorted(arr) \n diff = 10**20 \n for i in range(n-1): \n if arr[i+1] - arr[i] < diff: \n diff = arr[i+1] - arr[i] \n return diff","verification_metadata":{"test_list":["assert find_min_diff((1,5,3,19,18,25),6) == 1","assert find_min_diff((4,3,2,6),4) == 1","assert find_min_diff((30,5,20,9),4) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":763,"text":"Write a python function to find the minimum difference between any two elements in a given array. https://www.geeksforgeeks.org/find-minimum-difference-pair/","code":"def find_min_diff(arr,n): \n arr = sorted(arr) \n diff = 10**20 \n for i in range(n-1): \n if arr[i+1] - arr[i] < diff: \n diff = arr[i+1] - arr[i] \n return diff","test_list":["assert find_min_diff((1,5,3,19,18,25),6) == 1","assert find_min_diff((4,3,2,6),4) == 1","assert find_min_diff((30,5,20,9),4) == 4"],"test_imports":[]}} {"problem_id":"mbpp_train_00764","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count number of digits in a given string.\n\nTests:\nassert number_ctr('program2bedone') == 1\nassert number_ctr('3wonders') == 1\nassert number_ctr('123') == 3\nassert number_ctr('3wond-1ers2') == 3","canonical_answer":"def number_ctr(str):\n number_ctr= 0\n for i in range(len(str)):\n if str[i] >= '0' and str[i] <= '9': number_ctr += 1 \n return number_ctr","verification_metadata":{"test_list":["assert number_ctr('program2bedone') == 1","assert number_ctr('3wonders') == 1","assert number_ctr('123') == 3","assert number_ctr('3wond-1ers2') == 3"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":764,"text":"Write a python function to count number of digits in a given string.","code":"def number_ctr(str):\n number_ctr= 0\n for i in range(len(str)):\n if str[i] >= '0' and str[i] <= '9': number_ctr += 1 \n return number_ctr","test_list":["assert number_ctr('program2bedone') == 1","assert number_ctr('3wonders') == 1","assert number_ctr('123') == 3","assert number_ctr('3wond-1ers2') == 3"],"test_imports":[]}} {"problem_id":"mbpp_train_00765","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find nth polite number. geeksforgeeks.org/n-th-polite-number/\n\nTests:\nassert is_polite(7) == 11\nassert is_polite(4) == 7\nassert is_polite(9) == 13","canonical_answer":"import math \ndef is_polite(n): \n\tn = n + 1\n\treturn (int)(n+(math.log((n + math.log(n, 2)), 2)))","verification_metadata":{"test_list":["assert is_polite(7) == 11","assert is_polite(4) == 7","assert is_polite(9) == 13"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":765,"text":"Write a function to find nth polite number. geeksforgeeks.org/n-th-polite-number/","code":"import math \ndef is_polite(n): \n\tn = n + 1\n\treturn (int)(n+(math.log((n + math.log(n, 2)), 2)))","test_list":["assert is_polite(7) == 11","assert is_polite(4) == 7","assert is_polite(9) == 13"],"test_imports":[]}} {"problem_id":"mbpp_train_00766","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to return a list of all pairs of consecutive items in a given list.\n\nTests:\nassert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]\nassert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]\nassert pair_wise([5,1,9,7,10])==[(5, 1), (1, 9), (9, 7), (7, 10)]\nassert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]","canonical_answer":"def pair_wise(l1):\n temp = []\n for i in range(len(l1) - 1):\n current_element, next_element = l1[i], l1[i + 1]\n x = (current_element, next_element)\n temp.append(x)\n return temp","verification_metadata":{"test_list":["assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]","assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]","assert pair_wise([5,1,9,7,10])==[(5, 1), (1, 9), (9, 7), (7, 10)]","assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":766,"text":"Write a function to return a list of all pairs of consecutive items in a given list.","code":"def pair_wise(l1):\n temp = []\n for i in range(len(l1) - 1):\n current_element, next_element = l1[i], l1[i + 1]\n x = (current_element, next_element)\n temp.append(x)\n return temp","test_list":["assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]","assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]","assert pair_wise([5,1,9,7,10])==[(5, 1), (1, 9), (9, 7), (7, 10)]","assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]"],"test_imports":[]}} {"problem_id":"mbpp_train_00767","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the number of pairs whose sum is equal to ‘sum’. The funtion gets as input a list of numbers and the sum,\n\nTests:\nassert get_pairs_count([1,1,1,1],2) == 6\nassert get_pairs_count([1,5,7,-1,5],6) == 3\nassert get_pairs_count([1,-2,3],1) == 1\nassert get_pairs_count([-1,-2,3],-3) == 1","canonical_answer":"def get_pairs_count(arr, sum):\n count = 0 \n for i in range(len(arr)):\n for j in range(i + 1,len(arr)):\n if arr[i] + arr[j] == sum:\n count += 1\n return count","verification_metadata":{"test_list":["assert get_pairs_count([1,1,1,1],2) == 6","assert get_pairs_count([1,5,7,-1,5],6) == 3","assert get_pairs_count([1,-2,3],1) == 1","assert get_pairs_count([-1,-2,3],-3) == 1"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":767,"text":"Write a python function to count the number of pairs whose sum is equal to ‘sum’. The funtion gets as input a list of numbers and the sum,","code":"def get_pairs_count(arr, sum):\n count = 0 \n for i in range(len(arr)):\n for j in range(i + 1,len(arr)):\n if arr[i] + arr[j] == sum:\n count += 1\n return count","test_list":["assert get_pairs_count([1,1,1,1],2) == 6","assert get_pairs_count([1,5,7,-1,5],6) == 3","assert get_pairs_count([1,-2,3],1) == 1","assert get_pairs_count([-1,-2,3],-3) == 1"],"test_imports":[]}} {"problem_id":"mbpp_train_00769","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to get the difference between two lists.\n\nTests:\nassert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]\nassert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7]\nassert (Diff([1,2,3], [6,7,1])) == [2,3,6,7]","canonical_answer":"def Diff(li1,li2):\n return list(set(li1)-set(li2)) + list(set(li2)-set(li1))","verification_metadata":{"test_list":["assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]","assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7]","assert (Diff([1,2,3], [6,7,1])) == [2,3,6,7]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":769,"text":"Write a python function to get the difference between two lists.","code":"def Diff(li1,li2):\n return list(set(li1)-set(li2)) + list(set(li2)-set(li1))","test_list":["assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]","assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7]","assert (Diff([1,2,3], [6,7,1])) == [2,3,6,7]"],"test_imports":[]}} {"problem_id":"mbpp_train_00770","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of fourth power of first n odd natural numbers.\n\nTests:\nassert odd_num_sum(2) == 82\nassert odd_num_sum(3) == 707\nassert odd_num_sum(4) == 3108","canonical_answer":"def odd_num_sum(n) : \n j = 0\n sm = 0\n for i in range(1,n + 1) : \n j = (2*i-1) \n sm = sm + (j*j*j*j) \n return sm","verification_metadata":{"test_list":["assert odd_num_sum(2) == 82","assert odd_num_sum(3) == 707","assert odd_num_sum(4) == 3108"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":770,"text":"Write a python function to find the sum of fourth power of first n odd natural numbers.","code":"def odd_num_sum(n) : \n j = 0\n sm = 0\n for i in range(1,n + 1) : \n j = (2*i-1) \n sm = sm + (j*j*j*j) \n return sm","test_list":["assert odd_num_sum(2) == 82","assert odd_num_sum(3) == 707","assert odd_num_sum(4) == 3108"],"test_imports":[]}} {"problem_id":"mbpp_train_00771","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if the given expression is balanced or not. https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/\n\nTests:\nassert check_expression(\"{()}[{}]\") == True\nassert check_expression(\"{()}[{]\") == False\nassert check_expression(\"{()}[{}][]({})\") == True","canonical_answer":"from collections import deque\ndef check_expression(exp):\n if len(exp) & 1:\n return False\n stack = deque()\n for ch in exp:\n if ch == '(' or ch == '{' or ch == '[':\n stack.append(ch)\n if ch == ')' or ch == '}' or ch == ']':\n if not stack:\n return False\n top = stack.pop()\n if (top == '(' and ch != ')') or (top == '{' and ch != '}' or (top == '[' and ch != ']')):\n return False\n return not stack","verification_metadata":{"test_list":["assert check_expression(\"{()}[{}]\") == True","assert check_expression(\"{()}[{]\") == False","assert check_expression(\"{()}[{}][]({})\") == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":771,"text":"Write a function to check if the given expression is balanced or not. https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/","code":"from collections import deque\ndef check_expression(exp):\n if len(exp) & 1:\n return False\n stack = deque()\n for ch in exp:\n if ch == '(' or ch == '{' or ch == '[':\n stack.append(ch)\n if ch == ')' or ch == '}' or ch == ']':\n if not stack:\n return False\n top = stack.pop()\n if (top == '(' and ch != ')') or (top == '{' and ch != '}' or (top == '[' and ch != ']')):\n return False\n return not stack","test_list":["assert check_expression(\"{()}[{}]\") == True","assert check_expression(\"{()}[{]\") == False","assert check_expression(\"{()}[{}][]({})\") == True"],"test_imports":[]}} {"problem_id":"mbpp_train_00772","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove all the words with k length in the given string.\n\nTests:\nassert remove_length('The person is most value tet', 3) == 'person is most value'\nassert remove_length('If you told me about this ok', 4) == 'If you me about ok'\nassert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'","canonical_answer":"def remove_length(test_str, K):\n temp = test_str.split()\n res = [ele for ele in temp if len(ele) != K]\n res = ' '.join(res)\n return (res)","verification_metadata":{"test_list":["assert remove_length('The person is most value tet', 3) == 'person is most value'","assert remove_length('If you told me about this ok', 4) == 'If you me about ok'","assert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":772,"text":"Write a function to remove all the words with k length in the given string.","code":"def remove_length(test_str, K):\n temp = test_str.split()\n res = [ele for ele in temp if len(ele) != K]\n res = ' '.join(res)\n return (res)","test_list":["assert remove_length('The person is most value tet', 3) == 'person is most value'","assert remove_length('If you told me about this ok', 4) == 'If you me about ok'","assert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'"],"test_imports":[]}} {"problem_id":"mbpp_train_00773","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the occurrence and position of the substrings within a string. Return None if there is no match.\n\nTests:\nassert occurance_substring('python programming, python language','python')==('python', 0, 6)\nassert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)\nassert occurance_substring('python programming,programming language','language')==('language', 31, 39)\nassert occurance_substring('c++ programming, c++ language','python')==None","canonical_answer":"import re\ndef occurance_substring(text,pattern):\n for match in re.finditer(pattern, text):\n s = match.start()\n e = match.end()\n return (text[s:e], s, e)","verification_metadata":{"test_list":["assert occurance_substring('python programming, python language','python')==('python', 0, 6)","assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)","assert occurance_substring('python programming,programming language','language')==('language', 31, 39)","assert occurance_substring('c++ programming, c++ language','python')==None"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":773,"text":"Write a function to find the occurrence and position of the substrings within a string. Return None if there is no match.","code":"import re\ndef occurance_substring(text,pattern):\n for match in re.finditer(pattern, text):\n s = match.start()\n e = match.end()\n return (text[s:e], s, e)","test_list":["assert occurance_substring('python programming, python language','python')==('python', 0, 6)","assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)","assert occurance_substring('python programming,programming language','language')==('language', 31, 39)","assert occurance_substring('c++ programming, c++ language','python')==None"],"test_imports":[]}} {"problem_id":"mbpp_train_00775","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether every odd index contains odd numbers of a given list.\n\nTests:\nassert odd_position([2,1,4,3,6,7,6,3]) == True\nassert odd_position([4,1,2]) == True\nassert odd_position([1,2,3]) == False","canonical_answer":"def odd_position(nums):\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))","verification_metadata":{"test_list":["assert odd_position([2,1,4,3,6,7,6,3]) == True","assert odd_position([4,1,2]) == True","assert odd_position([1,2,3]) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":775,"text":"Write a python function to check whether every odd index contains odd numbers of a given list.","code":"def odd_position(nums):\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))","test_list":["assert odd_position([2,1,4,3,6,7,6,3]) == True","assert odd_position([4,1,2]) == True","assert odd_position([1,2,3]) == False"],"test_imports":[]}} {"problem_id":"mbpp_train_00776","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to count those characters which have vowels as their neighbors in the given string.\n\nTests:\nassert count_vowels('bestinstareels') == 7\nassert count_vowels('partofthejourneyistheend') == 12\nassert count_vowels('amazonprime') == 5","canonical_answer":"def count_vowels(test_str):\n res = 0\n vow_list = ['a', 'e', 'i', 'o', 'u']\n for idx in range(1, len(test_str) - 1):\n if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):\n res += 1\n if test_str[0] not in vow_list and test_str[1] in vow_list:\n res += 1\n if test_str[-1] not in vow_list and test_str[-2] in vow_list:\n res += 1\n return (res)","verification_metadata":{"test_list":["assert count_vowels('bestinstareels') == 7","assert count_vowels('partofthejourneyistheend') == 12","assert count_vowels('amazonprime') == 5"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":776,"text":"Write a function to count those characters which have vowels as their neighbors in the given string.","code":"def count_vowels(test_str):\n res = 0\n vow_list = ['a', 'e', 'i', 'o', 'u']\n for idx in range(1, len(test_str) - 1):\n if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):\n res += 1\n if test_str[0] not in vow_list and test_str[1] in vow_list:\n res += 1\n if test_str[-1] not in vow_list and test_str[-2] in vow_list:\n res += 1\n return (res)","test_list":["assert count_vowels('bestinstareels') == 7","assert count_vowels('partofthejourneyistheend') == 12","assert count_vowels('amazonprime') == 5"],"test_imports":[]}} {"problem_id":"mbpp_train_00777","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of non-repeated elements in a given list.\n\nTests:\nassert find_sum([1,2,3,1,1,4,5,6]) == 21\nassert find_sum([1,10,9,4,2,10,10,45,4]) == 71\nassert find_sum([12,10,9,45,2,10,10,45,10]) == 78","canonical_answer":"def find_sum(arr): \n arr.sort() \n sum = arr[0] \n for i in range(len(arr)-1): \n if (arr[i] != arr[i+1]): \n sum = sum + arr[i+1] \n return sum","verification_metadata":{"test_list":["assert find_sum([1,2,3,1,1,4,5,6]) == 21","assert find_sum([1,10,9,4,2,10,10,45,4]) == 71","assert find_sum([12,10,9,45,2,10,10,45,10]) == 78"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":777,"text":"Write a python function to find the sum of non-repeated elements in a given list.","code":"def find_sum(arr): \n arr.sort() \n sum = arr[0] \n for i in range(len(arr)-1): \n if (arr[i] != arr[i+1]): \n sum = sum + arr[i+1] \n return sum","test_list":["assert find_sum([1,2,3,1,1,4,5,6]) == 21","assert find_sum([1,10,9,4,2,10,10,45,4]) == 71","assert find_sum([12,10,9,45,2,10,10,45,10]) == 78"],"test_imports":[]}} {"problem_id":"mbpp_train_00778","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to pack consecutive duplicates of a given list elements into sublists.\n\nTests:\nassert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]\nassert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]\nassert pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==[['a', 'a'], ['b'], ['c'], ['d', 'd']]","canonical_answer":"from itertools import groupby\ndef pack_consecutive_duplicates(list1):\n return [list(group) for key, group in groupby(list1)]","verification_metadata":{"test_list":["assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]","assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]","assert pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==[['a', 'a'], ['b'], ['c'], ['d', 'd']]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":778,"text":"Write a function to pack consecutive duplicates of a given list elements into sublists.","code":"from itertools import groupby\ndef pack_consecutive_duplicates(list1):\n return [list(group) for key, group in groupby(list1)]","test_list":["assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7], [8], [9], [4, 4]]","assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]","assert pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==[['a', 'a'], ['b'], ['c'], ['d', 'd']]"],"test_imports":[]}} {"problem_id":"mbpp_train_00779","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to count the number of lists within a list. The function should return a dictionary, where every list is turned to a tuple, and the value of the tuple is the number of its occurrences.\n\nTests:\nassert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}\nassert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}\nassert unique_sublists([[1, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}","canonical_answer":"def unique_sublists(list1):\n result ={}\n for l in list1: \n result.setdefault(tuple(l), list()).append(1) \n for a, b in result.items(): \n result[a] = sum(b)\n return result","verification_metadata":{"test_list":["assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}","assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}","assert unique_sublists([[1, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":779,"text":"Write a function to count the number of lists within a list. The function should return a dictionary, where every list is turned to a tuple, and the value of the tuple is the number of its occurrences.","code":"def unique_sublists(list1):\n result ={}\n for l in list1: \n result.setdefault(tuple(l), list()).append(1) \n for a, b in result.items(): \n result[a] = sum(b)\n return result","test_list":["assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}","assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}","assert unique_sublists([[1, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}"],"test_imports":[]}} {"problem_id":"mbpp_train_00780","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the combinations of sums with tuples in the given tuple list. https://www.geeksforgeeks.org/python-combinations-of-sum-with-tuples-in-tuple-list/\n\nTests:\nassert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]\nassert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]\nassert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [(12, 15), (11, 9), (12, 18), (15, 12), (16, 21), (15, 15)]","canonical_answer":"from itertools import combinations \ndef find_combinations(test_list):\n res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)]\n return (res)","verification_metadata":{"test_list":["assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]","assert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]","assert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [(12, 15), (11, 9), (12, 18), (15, 12), (16, 21), (15, 15)]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":780,"text":"Write a function to find the combinations of sums with tuples in the given tuple list. https://www.geeksforgeeks.org/python-combinations-of-sum-with-tuples-in-tuple-list/","code":"from itertools import combinations \ndef find_combinations(test_list):\n res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)]\n return (res)","test_list":["assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]","assert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]","assert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [(12, 15), (11, 9), (12, 18), (15, 12), (16, 21), (15, 15)]"],"test_imports":[]}} {"problem_id":"mbpp_train_00781","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether the count of divisors is even. https://www.w3resource.com/python-exercises/basic/python-basic-1-exercise-24.php\n\nTests:\nassert count_divisors(10)\nassert not count_divisors(100)\nassert count_divisors(125)","canonical_answer":"import math \ndef count_divisors(n) : \n count = 0\n for i in range(1, (int)(math.sqrt(n)) + 2) : \n if (n % i == 0) : \n if( n // i == i) : \n count = count + 1\n else : \n count = count + 2\n return count % 2 == 0","verification_metadata":{"test_list":["assert count_divisors(10)","assert not count_divisors(100)","assert count_divisors(125)"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":781,"text":"Write a python function to check whether the count of divisors is even. https://www.w3resource.com/python-exercises/basic/python-basic-1-exercise-24.php","code":"import math \ndef count_divisors(n) : \n count = 0\n for i in range(1, (int)(math.sqrt(n)) + 2) : \n if (n % i == 0) : \n if( n // i == i) : \n count = count + 1\n else : \n count = count + 2\n return count % 2 == 0","test_list":["assert count_divisors(10)","assert not count_divisors(100)","assert count_divisors(125)"],"test_imports":[]}} {"problem_id":"mbpp_train_00782","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of all odd length subarrays. https://www.geeksforgeeks.org/sum-of-all-odd-length-subarrays/\n\nTests:\nassert odd_length_sum([1,2,4]) == 14\nassert odd_length_sum([1,2,1,2]) == 15\nassert odd_length_sum([1,7]) == 8","canonical_answer":"def odd_length_sum(arr):\n Sum = 0\n l = len(arr)\n for i in range(l):\n Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])\n return Sum","verification_metadata":{"test_list":["assert odd_length_sum([1,2,4]) == 14","assert odd_length_sum([1,2,1,2]) == 15","assert odd_length_sum([1,7]) == 8"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":782,"text":"Write a python function to find the sum of all odd length subarrays. https://www.geeksforgeeks.org/sum-of-all-odd-length-subarrays/","code":"def odd_length_sum(arr):\n Sum = 0\n l = len(arr)\n for i in range(l):\n Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])\n return Sum","test_list":["assert odd_length_sum([1,2,4]) == 14","assert odd_length_sum([1,2,1,2]) == 15","assert odd_length_sum([1,7]) == 8"],"test_imports":[]}} {"problem_id":"mbpp_train_00783","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert rgb color to hsv color. https://www.geeksforgeeks.org/program-change-rgb-color-model-hsv-color-model/\n\nTests:\nassert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0)\nassert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608)\nassert rgb_to_hsv(10, 215, 110)==(149.26829268292684, 95.34883720930233, 84.31372549019608)","canonical_answer":"def rgb_to_hsv(r, g, b):\n r, g, b = r/255.0, g/255.0, b/255.0\n mx = max(r, g, b)\n mn = min(r, g, b)\n df = mx-mn\n if mx == mn:\n h = 0\n elif mx == r:\n h = (60 * ((g-b)/df) + 360) % 360\n elif mx == g:\n h = (60 * ((b-r)/df) + 120) % 360\n elif mx == b:\n h = (60 * ((r-g)/df) + 240) % 360\n if mx == 0:\n s = 0\n else:\n s = (df/mx)*100\n v = mx*100\n return h, s, v","verification_metadata":{"test_list":["assert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0)","assert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608)","assert rgb_to_hsv(10, 215, 110)==(149.26829268292684, 95.34883720930233, 84.31372549019608)"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":783,"text":"Write a function to convert rgb color to hsv color. https://www.geeksforgeeks.org/program-change-rgb-color-model-hsv-color-model/","code":"def rgb_to_hsv(r, g, b):\n r, g, b = r/255.0, g/255.0, b/255.0\n mx = max(r, g, b)\n mn = min(r, g, b)\n df = mx-mn\n if mx == mn:\n h = 0\n elif mx == r:\n h = (60 * ((g-b)/df) + 360) % 360\n elif mx == g:\n h = (60 * ((b-r)/df) + 120) % 360\n elif mx == b:\n h = (60 * ((r-g)/df) + 240) % 360\n if mx == 0:\n s = 0\n else:\n s = (df/mx)*100\n v = mx*100\n return h, s, v","test_list":["assert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0)","assert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608)","assert rgb_to_hsv(10, 215, 110)==(149.26829268292684, 95.34883720930233, 84.31372549019608)"],"test_imports":[]}} {"problem_id":"mbpp_train_00784","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the product of first even and odd number of a given list.\n\nTests:\nassert mul_even_odd([1,3,5,7,4,1,6,8])==4\nassert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2\nassert mul_even_odd([1,5,7,9,10])==10","canonical_answer":"def mul_even_odd(list1):\n first_even = next((el for el in list1 if el%2==0),-1)\n first_odd = next((el for el in list1 if el%2!=0),-1)\n return (first_even*first_odd)","verification_metadata":{"test_list":["assert mul_even_odd([1,3,5,7,4,1,6,8])==4","assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2","assert mul_even_odd([1,5,7,9,10])==10"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":784,"text":"Write a function to find the product of first even and odd number of a given list.","code":"def mul_even_odd(list1):\n first_even = next((el for el in list1 if el%2==0),-1)\n first_odd = next((el for el in list1 if el%2!=0),-1)\n return (first_even*first_odd)","test_list":["assert mul_even_odd([1,3,5,7,4,1,6,8])==4","assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2","assert mul_even_odd([1,5,7,9,10])==10"],"test_imports":[]}} {"problem_id":"mbpp_train_00785","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert tuple string to integer tuple.\n\nTests:\nassert tuple_str_int(\"(7, 8, 9)\") == (7, 8, 9)\nassert tuple_str_int(\"(1, 2, 3)\") == (1, 2, 3)\nassert tuple_str_int(\"(4, 5, 6)\") == (4, 5, 6)\nassert tuple_str_int(\"(7, 81, 19)\") == (7, 81, 19)","canonical_answer":"def tuple_str_int(test_str):\n res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', '))\n return (res)","verification_metadata":{"test_list":["assert tuple_str_int(\"(7, 8, 9)\") == (7, 8, 9)","assert tuple_str_int(\"(1, 2, 3)\") == (1, 2, 3)","assert tuple_str_int(\"(4, 5, 6)\") == (4, 5, 6)","assert tuple_str_int(\"(7, 81, 19)\") == (7, 81, 19)"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":785,"text":"Write a function to convert tuple string to integer tuple.","code":"def tuple_str_int(test_str):\n res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', '))\n return (res)","test_list":["assert tuple_str_int(\"(7, 8, 9)\") == (7, 8, 9)","assert tuple_str_int(\"(1, 2, 3)\") == (1, 2, 3)","assert tuple_str_int(\"(4, 5, 6)\") == (4, 5, 6)","assert tuple_str_int(\"(7, 81, 19)\") == (7, 81, 19)"],"test_imports":[]}} {"problem_id":"mbpp_train_00786","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to locate the right insertion point for a specified value in sorted order.\n\nTests:\nassert right_insertion([1,2,4,5],6)==4\nassert right_insertion([1,2,4,5],3)==2\nassert right_insertion([1,2,4,5],7)==4","canonical_answer":"import bisect\ndef right_insertion(a, x):\n return bisect.bisect_right(a, x)","verification_metadata":{"test_list":["assert right_insertion([1,2,4,5],6)==4","assert right_insertion([1,2,4,5],3)==2","assert right_insertion([1,2,4,5],7)==4"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":786,"text":"Write a function to locate the right insertion point for a specified value in sorted order.","code":"import bisect\ndef right_insertion(a, x):\n return bisect.bisect_right(a, x)","test_list":["assert right_insertion([1,2,4,5],6)==4","assert right_insertion([1,2,4,5],3)==2","assert right_insertion([1,2,4,5],7)==4"],"test_imports":[]}} {"problem_id":"mbpp_train_00787","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that matches a string that has an a followed by three 'b'.\n\nTests:\nassert not text_match_three(\"ac\")\nassert not text_match_three(\"dc\")\nassert text_match_three(\"abbbba\")\nassert text_match_three(\"caacabbbba\")","canonical_answer":"import re\ndef text_match_three(text):\n patterns = 'ab{3}?'\n return re.search(patterns, text)","verification_metadata":{"test_list":["assert not text_match_three(\"ac\")","assert not text_match_three(\"dc\")","assert text_match_three(\"abbbba\")","assert text_match_three(\"caacabbbba\")"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":787,"text":"Write a function that matches a string that has an a followed by three 'b'.","code":"import re\ndef text_match_three(text):\n patterns = 'ab{3}?'\n return re.search(patterns, text)","test_list":["assert not text_match_three(\"ac\")","assert not text_match_three(\"dc\")","assert text_match_three(\"abbbba\")","assert text_match_three(\"caacabbbba\")"],"test_imports":[]}} {"problem_id":"mbpp_train_00788","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to create a new tuple from the given string and list.\n\nTests:\nassert new_tuple([\"WEB\", \"is\"], \"best\") == ('WEB', 'is', 'best')\nassert new_tuple([\"We\", \"are\"], \"Developers\") == ('We', 'are', 'Developers')\nassert new_tuple([\"Part\", \"is\"], \"Wrong\") == ('Part', 'is', 'Wrong')","canonical_answer":"def new_tuple(test_list, test_str):\n return tuple(test_list + [test_str])","verification_metadata":{"test_list":["assert new_tuple([\"WEB\", \"is\"], \"best\") == ('WEB', 'is', 'best')","assert new_tuple([\"We\", \"are\"], \"Developers\") == ('We', 'are', 'Developers')","assert new_tuple([\"Part\", \"is\"], \"Wrong\") == ('Part', 'is', 'Wrong')"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":788,"text":"Write a function to create a new tuple from the given string and list.","code":"def new_tuple(test_list, test_str):\n return tuple(test_list + [test_str])","test_list":["assert new_tuple([\"WEB\", \"is\"], \"best\") == ('WEB', 'is', 'best')","assert new_tuple([\"We\", \"are\"], \"Developers\") == ('We', 'are', 'Developers')","assert new_tuple([\"Part\", \"is\"], \"Wrong\") == ('Part', 'is', 'Wrong')"],"test_imports":[]}} {"problem_id":"mbpp_train_00790","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether every even index contains even numbers of a given list.\n\nTests:\nassert even_position([3,2,1]) == False\nassert even_position([1,2,3]) == False\nassert even_position([2,1,4]) == True","canonical_answer":"def even_position(nums):\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))","verification_metadata":{"test_list":["assert even_position([3,2,1]) == False","assert even_position([1,2,3]) == False","assert even_position([2,1,4]) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":790,"text":"Write a python function to check whether every even index contains even numbers of a given list.","code":"def even_position(nums):\n\treturn all(nums[i]%2==i%2 for i in range(len(nums)))","test_list":["assert even_position([3,2,1]) == False","assert even_position([1,2,3]) == False","assert even_position([2,1,4]) == True"],"test_imports":[]}} {"problem_id":"mbpp_train_00791","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove tuples from the given tuple.\n\nTests:\nassert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)\nassert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)\nassert remove_nested((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12)\nassert remove_nested((3, 7, 9, (6, 8), (5,12), 12)) == (3, 7, 9, 12)","canonical_answer":"def remove_nested(test_tup):\n res = tuple()\n for count, ele in enumerate(test_tup):\n if not isinstance(ele, tuple):\n res = res + (ele, )\n return (res)","verification_metadata":{"test_list":["assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)","assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)","assert remove_nested((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12)","assert remove_nested((3, 7, 9, (6, 8), (5,12), 12)) == (3, 7, 9, 12)"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":791,"text":"Write a function to remove tuples from the given tuple.","code":"def remove_nested(test_tup):\n res = tuple()\n for count, ele in enumerate(test_tup):\n if not isinstance(ele, tuple):\n res = res + (ele, )\n return (res)","test_list":["assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)","assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11)","assert remove_nested((3, 7, 9, (6, 8), 12)) == (3, 7, 9, 12)","assert remove_nested((3, 7, 9, (6, 8), (5,12), 12)) == (3, 7, 9, 12)"],"test_imports":[]}} {"problem_id":"mbpp_train_00792","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the number of lists in a given number of lists.\n\nTests:\nassert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4\nassert count_list([[1,2],[2,3],[4,5]]) == 3\nassert count_list([[1,0],[2,0]]) == 2","canonical_answer":"def count_list(input_list): \n return len(input_list)","verification_metadata":{"test_list":["assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4","assert count_list([[1,2],[2,3],[4,5]]) == 3","assert count_list([[1,0],[2,0]]) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":792,"text":"Write a python function to count the number of lists in a given number of lists.","code":"def count_list(input_list): \n return len(input_list)","test_list":["assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4","assert count_list([[1,2],[2,3],[4,5]]) == 3","assert count_list([[1,0],[2,0]]) == 2"],"test_imports":[]}} {"problem_id":"mbpp_train_00793","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the last position of an element in a sorted array.\n\nTests:\nassert last([1,2,3],1) == 0\nassert last([1,1,1,2,3,4],1) == 2\nassert last([2,3,2,3,6,8,9],3) == 3","canonical_answer":"def last(arr,x):\n n = len(arr)\n low = 0\n high = n - 1\n res = -1 \n while (low <= high):\n mid = (low + high) // 2 \n if arr[mid] > x:\n high = mid - 1\n elif arr[mid] < x:\n low = mid + 1\n else:\n res = mid\n low = mid + 1\n return res","verification_metadata":{"test_list":["assert last([1,2,3],1) == 0","assert last([1,1,1,2,3,4],1) == 2","assert last([2,3,2,3,6,8,9],3) == 3"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":793,"text":"Write a python function to find the last position of an element in a sorted array.","code":"def last(arr,x):\n n = len(arr)\n low = 0\n high = n - 1\n res = -1 \n while (low <= high):\n mid = (low + high) // 2 \n if arr[mid] > x:\n high = mid - 1\n elif arr[mid] < x:\n low = mid + 1\n else:\n res = mid\n low = mid + 1\n return res","test_list":["assert last([1,2,3],1) == 0","assert last([1,1,1,2,3,4],1) == 2","assert last([2,3,2,3,6,8,9],3) == 3"],"test_imports":[]}} {"problem_id":"mbpp_train_00794","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that matches a string that has an 'a' followed by anything, ending in 'b'.\n\nTests:\nassert text_starta_endb(\"aabbbb\")\nassert not text_starta_endb(\"aabAbbbc\")\nassert not text_starta_endb(\"accddbbjjj\")","canonical_answer":"import re\ndef text_starta_endb(text):\n patterns = 'a.*?b$'\n return re.search(patterns, text)","verification_metadata":{"test_list":["assert text_starta_endb(\"aabbbb\")","assert not text_starta_endb(\"aabAbbbc\")","assert not text_starta_endb(\"accddbbjjj\")"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":794,"text":"Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.","code":"import re\ndef text_starta_endb(text):\n patterns = 'a.*?b$'\n return re.search(patterns, text)","test_list":["assert text_starta_endb(\"aabbbb\")","assert not text_starta_endb(\"aabAbbbc\")","assert not text_starta_endb(\"accddbbjjj\")"],"test_imports":[]}} {"problem_id":"mbpp_train_00796","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite function to find the sum of all items in the given dictionary.\n\nTests:\nassert return_sum({'a': 100, 'b':200, 'c':300}) == 600\nassert return_sum({'a': 25, 'b':18, 'c':45}) == 88\nassert return_sum({'a': 36, 'b':39, 'c':49}) == 124","canonical_answer":"def return_sum(dict):\n sum = 0\n for i in dict.values():\n sum = sum + i\n return sum","verification_metadata":{"test_list":["assert return_sum({'a': 100, 'b':200, 'c':300}) == 600","assert return_sum({'a': 25, 'b':18, 'c':45}) == 88","assert return_sum({'a': 36, 'b':39, 'c':49}) == 124"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":796,"text":"Write function to find the sum of all items in the given dictionary.","code":"def return_sum(dict):\n sum = 0\n for i in dict.values():\n sum = sum + i\n return sum","test_list":["assert return_sum({'a': 100, 'b':200, 'c':300}) == 600","assert return_sum({'a': 25, 'b':18, 'c':45}) == 88","assert return_sum({'a': 36, 'b':39, 'c':49}) == 124"],"test_imports":[]}} {"problem_id":"mbpp_train_00797","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of all odd natural numbers within the range l and r.\n\nTests:\nassert sum_in_range(2,5) == 8\nassert sum_in_range(5,7) == 12\nassert sum_in_range(7,13) == 40","canonical_answer":"def sum_odd(n): \n terms = (n + 1)//2\n sum1 = terms * terms \n return sum1 \ndef sum_in_range(l,r): \n return sum_odd(r) - sum_odd(l - 1)","verification_metadata":{"test_list":["assert sum_in_range(2,5) == 8","assert sum_in_range(5,7) == 12","assert sum_in_range(7,13) == 40"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":797,"text":"Write a python function to find the sum of all odd natural numbers within the range l and r.","code":"def sum_odd(n): \n terms = (n + 1)//2\n sum1 = terms * terms \n return sum1 \ndef sum_in_range(l,r): \n return sum_odd(r) - sum_odd(l - 1)","test_list":["assert sum_in_range(2,5) == 8","assert sum_in_range(5,7) == 12","assert sum_in_range(7,13) == 40"],"test_imports":[]}} {"problem_id":"mbpp_train_00798","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of an array.\n\nTests:\nassert _sum([1, 2, 3]) == 6\nassert _sum([15, 12, 13, 10]) == 50\nassert _sum([0, 1, 2]) == 3","canonical_answer":"def _sum(arr): \n sum=0\n for i in arr: \n sum = sum + i \n return(sum)","verification_metadata":{"test_list":["assert _sum([1, 2, 3]) == 6","assert _sum([15, 12, 13, 10]) == 50","assert _sum([0, 1, 2]) == 3"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":798,"text":"Write a python function to find the sum of an array.","code":"def _sum(arr): \n sum=0\n for i in arr: \n sum = sum + i \n return(sum)","test_list":["assert _sum([1, 2, 3]) == 6","assert _sum([15, 12, 13, 10]) == 50","assert _sum([0, 1, 2]) == 3"],"test_imports":[]}} {"problem_id":"mbpp_train_00799","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to that rotate left bits by d bits a given number. We assume that the number is 32 bit.\n\nTests:\nassert left_rotate(16,2) == 64\nassert left_rotate(10,2) == 40\nassert left_rotate(99,3) == 792\nassert left_rotate(99,3) == 792\nassert left_rotate(0b0001,3) == 0b1000\nassert left_rotate(0b0101,3) == 0b101000\nassert left_rotate(0b11101,3) == 0b11101000","canonical_answer":"def left_rotate(n,d): \n INT_BITS = 32\n return (n << d)|(n >> (INT_BITS - d))","verification_metadata":{"test_list":["assert left_rotate(16,2) == 64","assert left_rotate(10,2) == 40","assert left_rotate(99,3) == 792","assert left_rotate(99,3) == 792","assert left_rotate(0b0001,3) == 0b1000","assert left_rotate(0b0101,3) == 0b101000","assert left_rotate(0b11101,3) == 0b11101000"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":799,"text":"Write a function to that rotate left bits by d bits a given number. We assume that the number is 32 bit.","code":"def left_rotate(n,d): \n INT_BITS = 32\n return (n << d)|(n >> (INT_BITS - d))","test_list":["assert left_rotate(16,2) == 64","assert left_rotate(10,2) == 40","assert left_rotate(99,3) == 792","assert left_rotate(99,3) == 792","assert left_rotate(0b0001,3) == 0b1000","assert left_rotate(0b0101,3) == 0b101000","assert left_rotate(0b11101,3) == 0b11101000"],"test_imports":[]}} {"problem_id":"mbpp_train_00800","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove all whitespaces from a string.\n\nTests:\nassert remove_all_spaces('python program')==('pythonprogram')\nassert remove_all_spaces('python programming language')==('pythonprogramminglanguage')\nassert remove_all_spaces('python program')==('pythonprogram')\nassert remove_all_spaces(' python program')=='pythonprogram'","canonical_answer":"import re\ndef remove_all_spaces(text):\n return (re.sub(r'\\s+', '',text))","verification_metadata":{"test_list":["assert remove_all_spaces('python program')==('pythonprogram')","assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')","assert remove_all_spaces('python program')==('pythonprogram')","assert remove_all_spaces(' python program')=='pythonprogram'"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":800,"text":"Write a function to remove all whitespaces from a string.","code":"import re\ndef remove_all_spaces(text):\n return (re.sub(r'\\s+', '',text))","test_list":["assert remove_all_spaces('python program')==('pythonprogram')","assert remove_all_spaces('python programming language')==('pythonprogramminglanguage')","assert remove_all_spaces('python program')==('pythonprogram')","assert remove_all_spaces(' python program')=='pythonprogram'"],"test_imports":[]}} {"problem_id":"mbpp_train_00801","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the number of equal numbers from three given integers.\n\nTests:\nassert test_three_equal(1,1,1) == 3\nassert test_three_equal(-1,-2,-3) == 0\nassert test_three_equal(1,2,2) == 2","canonical_answer":"def test_three_equal(x,y,z):\n result = set([x,y,z])\n if len(result)==3:\n return 0\n else:\n return 4-len(result)","verification_metadata":{"test_list":["assert test_three_equal(1,1,1) == 3","assert test_three_equal(-1,-2,-3) == 0","assert test_three_equal(1,2,2) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":801,"text":"Write a python function to count the number of equal numbers from three given integers.","code":"def test_three_equal(x,y,z):\n result = set([x,y,z])\n if len(result)==3:\n return 0\n else:\n return 4-len(result)","test_list":["assert test_three_equal(1,1,1) == 3","assert test_three_equal(-1,-2,-3) == 0","assert test_three_equal(1,2,2) == 2"],"test_imports":[]}} {"problem_id":"mbpp_train_00802","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the number of rotations required to generate a sorted array. https://www.geeksforgeeks.org/count-of-rotations-required-to-generate-a-sorted-array/\n\nTests:\nassert count_rotation([3,2,1]) == 1\nassert count_rotation([4,5,1,2,3]) == 2\nassert count_rotation([7,8,9,1,2,3]) == 3\nassert count_rotation([1,2,3]) == 0\nassert count_rotation([1,3,2]) == 2","canonical_answer":"def count_rotation(arr): \n for i in range (1,len(arr)): \n if (arr[i] < arr[i - 1]): \n return i \n return 0","verification_metadata":{"test_list":["assert count_rotation([3,2,1]) == 1","assert count_rotation([4,5,1,2,3]) == 2","assert count_rotation([7,8,9,1,2,3]) == 3","assert count_rotation([1,2,3]) == 0","assert count_rotation([1,3,2]) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":802,"text":"Write a python function to count the number of rotations required to generate a sorted array. https://www.geeksforgeeks.org/count-of-rotations-required-to-generate-a-sorted-array/","code":"def count_rotation(arr): \n for i in range (1,len(arr)): \n if (arr[i] < arr[i - 1]): \n return i \n return 0","test_list":["assert count_rotation([3,2,1]) == 1","assert count_rotation([4,5,1,2,3]) == 2","assert count_rotation([7,8,9,1,2,3]) == 3","assert count_rotation([1,2,3]) == 0","assert count_rotation([1,3,2]) == 2"],"test_imports":[]}} {"problem_id":"mbpp_train_00803","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether the given number is a perfect square or not. https://www.geeksforgeeks.org/check-if-given-number-is-perfect-square-in-cpp/\n\nTests:\nassert not is_perfect_square(10)\nassert is_perfect_square(36)\nassert not is_perfect_square(14)\nassert is_perfect_square(14*14)\nassert not is_perfect_square(125)\nassert is_perfect_square(125*125)","canonical_answer":"def is_perfect_square(n) :\n i = 1\n while (i * i<= n):\n if ((n % i == 0) and (n / i == i)):\n return True \n i = i + 1\n return False","verification_metadata":{"test_list":["assert not is_perfect_square(10)","assert is_perfect_square(36)","assert not is_perfect_square(14)","assert is_perfect_square(14*14)","assert not is_perfect_square(125)","assert is_perfect_square(125*125)"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":803,"text":"Write a function to check whether the given number is a perfect square or not. https://www.geeksforgeeks.org/check-if-given-number-is-perfect-square-in-cpp/","code":"def is_perfect_square(n) :\n i = 1\n while (i * i<= n):\n if ((n % i == 0) and (n / i == i)):\n return True \n i = i + 1\n return False","test_list":["assert not is_perfect_square(10)","assert is_perfect_square(36)","assert not is_perfect_square(14)","assert is_perfect_square(14*14)","assert not is_perfect_square(125)","assert is_perfect_square(125*125)"],"test_imports":[]}} {"problem_id":"mbpp_train_00804","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether the product of numbers in a list is even or not.\n\nTests:\nassert is_product_even([1,2,3])\nassert is_product_even([1,2,1,4])\nassert not is_product_even([1,1])","canonical_answer":"def is_product_even(arr): \n for i in range(len(arr)): \n if (arr[i] & 1) == 0: \n return True\n return False","verification_metadata":{"test_list":["assert is_product_even([1,2,3])","assert is_product_even([1,2,1,4])","assert not is_product_even([1,1])"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":804,"text":"Write a function to check whether the product of numbers in a list is even or not.","code":"def is_product_even(arr): \n for i in range(len(arr)): \n if (arr[i] & 1) == 0: \n return True\n return False","test_list":["assert is_product_even([1,2,3])","assert is_product_even([1,2,1,4])","assert not is_product_even([1,1])"],"test_imports":[]}} {"problem_id":"mbpp_train_00805","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that returns the list in a list of lists whose sum of elements is the highest.\n\nTests:\nassert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12]\nassert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10]\nassert max_sum_list([[2,3,1]])==[2,3,1]","canonical_answer":"def max_sum_list(lists):\n return max(lists, key=sum)","verification_metadata":{"test_list":["assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12]","assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10]","assert max_sum_list([[2,3,1]])==[2,3,1]"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":805,"text":"Write a function that returns the list in a list of lists whose sum of elements is the highest.","code":"def max_sum_list(lists):\n return max(lists, key=sum)","test_list":["assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12]","assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10]","assert max_sum_list([[2,3,1]])==[2,3,1]"],"test_imports":[]}} {"problem_id":"mbpp_train_00806","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find maximum run of uppercase characters in the given string.\n\nTests:\nassert max_run_uppercase('GeMKSForGERksISBESt') == 5\nassert max_run_uppercase('PrECIOusMOVemENTSYT') == 6\nassert max_run_uppercase('GooGLEFluTTER') == 4","canonical_answer":"def max_run_uppercase(test_str):\n cnt = 0\n res = 0\n for idx in range(0, len(test_str)):\n if test_str[idx].isupper():\n cnt += 1\n else:\n res = cnt\n cnt = 0\n if test_str[len(test_str) - 1].isupper():\n res = cnt\n return (res)","verification_metadata":{"test_list":["assert max_run_uppercase('GeMKSForGERksISBESt') == 5","assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6","assert max_run_uppercase('GooGLEFluTTER') == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":806,"text":"Write a function to find maximum run of uppercase characters in the given string.","code":"def max_run_uppercase(test_str):\n cnt = 0\n res = 0\n for idx in range(0, len(test_str)):\n if test_str[idx].isupper():\n cnt += 1\n else:\n res = cnt\n cnt = 0\n if test_str[len(test_str) - 1].isupper():\n res = cnt\n return (res)","test_list":["assert max_run_uppercase('GeMKSForGERksISBESt') == 5","assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6","assert max_run_uppercase('GooGLEFluTTER') == 4"],"test_imports":[]}} {"problem_id":"mbpp_train_00807","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the first odd number in a given list of numbers.\n\nTests:\nassert first_odd([1,3,5]) == 1\nassert first_odd([2,4,1,3]) == 1\nassert first_odd ([8,9,1]) == 9","canonical_answer":"def first_odd(nums):\n first_odd = next((el for el in nums if el%2!=0),-1)\n return first_odd","verification_metadata":{"test_list":["assert first_odd([1,3,5]) == 1","assert first_odd([2,4,1,3]) == 1","assert first_odd ([8,9,1]) == 9"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":807,"text":"Write a python function to find the first odd number in a given list of numbers.","code":"def first_odd(nums):\n first_odd = next((el for el in nums if el%2!=0),-1)\n return first_odd","test_list":["assert first_odd([1,3,5]) == 1","assert first_odd([2,4,1,3]) == 1","assert first_odd ([8,9,1]) == 9"],"test_imports":[]}} {"problem_id":"mbpp_train_00808","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if the given tuples contain the k or not.\n\nTests:\nassert check_K((10, 4, 5, 6, 8), 6) == True\nassert check_K((1, 2, 3, 4, 5, 6), 7) == False\nassert check_K((7, 8, 9, 44, 11, 12), 11) == True","canonical_answer":"def check_K(test_tup, K):\n res = False\n for ele in test_tup:\n if ele == K:\n res = True\n break\n return res","verification_metadata":{"test_list":["assert check_K((10, 4, 5, 6, 8), 6) == True","assert check_K((1, 2, 3, 4, 5, 6), 7) == False","assert check_K((7, 8, 9, 44, 11, 12), 11) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":808,"text":"Write a function to check if the given tuples contain the k or not.","code":"def check_K(test_tup, K):\n res = False\n for ele in test_tup:\n if ele == K:\n res = True\n break\n return res","test_list":["assert check_K((10, 4, 5, 6, 8), 6) == True","assert check_K((1, 2, 3, 4, 5, 6), 7) == False","assert check_K((7, 8, 9, 44, 11, 12), 11) == True"],"test_imports":[]}} {"problem_id":"mbpp_train_00809","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if each element of second tuple is smaller than its corresponding element in the first tuple.\n\nTests:\nassert check_smaller((1, 2, 3), (2, 3, 4)) == False\nassert check_smaller((4, 5, 6), (3, 4, 5)) == True\nassert check_smaller((11, 12, 13), (10, 11, 12)) == True","canonical_answer":"def check_smaller(test_tup1, test_tup2):\n return all(x > y for x, y in zip(test_tup1, test_tup2))","verification_metadata":{"test_list":["assert check_smaller((1, 2, 3), (2, 3, 4)) == False","assert check_smaller((4, 5, 6), (3, 4, 5)) == True","assert check_smaller((11, 12, 13), (10, 11, 12)) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"train"},"raw_source_entry":{"task_id":809,"text":"Write a function to check if each element of second tuple is smaller than its corresponding element in the first tuple.","code":"def check_smaller(test_tup1, test_tup2):\n return all(x > y for x, y in zip(test_tup1, test_tup2))","test_list":["assert check_smaller((1, 2, 3), (2, 3, 4)) == False","assert check_smaller((4, 5, 6), (3, 4, 5)) == True","assert check_smaller((11, 12, 13), (10, 11, 12)) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00011","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to remove first and last occurrence of a given character from the string.\n\nTests:\nassert remove_Occ(\"hello\",\"l\") == \"heo\"\nassert remove_Occ(\"abcda\",\"a\") == \"bcd\"\nassert remove_Occ(\"PHP\",\"P\") == \"H\"","canonical_answer":"def remove_Occ(s,ch): \n for i in range(len(s)): \n if (s[i] == ch): \n s = s[0 : i] + s[i + 1:] \n break\n for i in range(len(s) - 1,-1,-1): \n if (s[i] == ch): \n s = s[0 : i] + s[i + 1:] \n break\n return s","verification_metadata":{"test_list":["assert remove_Occ(\"hello\",\"l\") == \"heo\"","assert remove_Occ(\"abcda\",\"a\") == \"bcd\"","assert remove_Occ(\"PHP\",\"P\") == \"H\""],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":11,"text":"Write a python function to remove first and last occurrence of a given character from the string.","code":"def remove_Occ(s,ch): \n for i in range(len(s)): \n if (s[i] == ch): \n s = s[0 : i] + s[i + 1:] \n break\n for i in range(len(s) - 1,-1,-1): \n if (s[i] == ch): \n s = s[0 : i] + s[i + 1:] \n break\n return s","test_list":["assert remove_Occ(\"hello\",\"l\") == \"heo\"","assert remove_Occ(\"abcda\",\"a\") == \"bcd\"","assert remove_Occ(\"PHP\",\"P\") == \"H\""],"test_imports":[]}} {"problem_id":"mbpp_test_00012","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sort a given matrix in ascending order according to the sum of its rows.\n\nTests:\nassert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]\nassert sort_matrix([[1, 2, 3], [-2, 4, -5], [1, -1, 1]])==[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]\nassert sort_matrix([[5,8,9],[6,4,3],[2,1,4]])==[[2, 1, 4], [6, 4, 3], [5, 8, 9]]","canonical_answer":"def sort_matrix(M):\n result = sorted(M, key=sum)\n return result","verification_metadata":{"test_list":["assert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]","assert sort_matrix([[1, 2, 3], [-2, 4, -5], [1, -1, 1]])==[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]","assert sort_matrix([[5,8,9],[6,4,3],[2,1,4]])==[[2, 1, 4], [6, 4, 3], [5, 8, 9]]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":12,"text":"Write a function to sort a given matrix in ascending order according to the sum of its rows.","code":"def sort_matrix(M):\n result = sorted(M, key=sum)\n return result","test_list":["assert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]","assert sort_matrix([[1, 2, 3], [-2, 4, -5], [1, -1, 1]])==[[-2, 4, -5], [1, -1, 1], [1, 2, 3]]","assert sort_matrix([[5,8,9],[6,4,3],[2,1,4]])==[[2, 1, 4], [6, 4, 3], [5, 8, 9]]"],"test_imports":[]}} {"problem_id":"mbpp_test_00014","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the volume of a triangular prism.\n\nTests:\nassert find_Volume(10,8,6) == 240\nassert find_Volume(3,2,2) == 6\nassert find_Volume(1,2,1) == 1","canonical_answer":"def find_Volume(l,b,h) : \n return ((l * b * h) / 2)","verification_metadata":{"test_list":["assert find_Volume(10,8,6) == 240","assert find_Volume(3,2,2) == 6","assert find_Volume(1,2,1) == 1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":14,"text":"Write a python function to find the volume of a triangular prism.","code":"def find_Volume(l,b,h) : \n return ((l * b * h) / 2)","test_list":["assert find_Volume(10,8,6) == 240","assert find_Volume(3,2,2) == 6","assert find_Volume(1,2,1) == 1"],"test_imports":[]}} {"problem_id":"mbpp_test_00016","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise.\n\nTests:\nassert text_lowercase_underscore(\"aab_cbbbc\")==(True)\nassert text_lowercase_underscore(\"aab_Abbbc\")==(False)\nassert text_lowercase_underscore(\"Aaab_abbbc\")==(False)","canonical_answer":"import re\ndef text_lowercase_underscore(text):\n patterns = '^[a-z]+_[a-z]+$'\n if re.search(patterns, text):\n return True\n else:\n return False","verification_metadata":{"test_list":["assert text_lowercase_underscore(\"aab_cbbbc\")==(True)","assert text_lowercase_underscore(\"aab_Abbbc\")==(False)","assert text_lowercase_underscore(\"Aaab_abbbc\")==(False)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":16,"text":"Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise.","code":"import re\ndef text_lowercase_underscore(text):\n patterns = '^[a-z]+_[a-z]+$'\n if re.search(patterns, text):\n return True\n else:\n return False","test_list":["assert text_lowercase_underscore(\"aab_cbbbc\")==(True)","assert text_lowercase_underscore(\"aab_Abbbc\")==(False)","assert text_lowercase_underscore(\"Aaab_abbbc\")==(False)"],"test_imports":[]}} {"problem_id":"mbpp_test_00017","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that returns the perimeter of a square given its side length as input.\n\nTests:\nassert square_perimeter(10)==40\nassert square_perimeter(5)==20\nassert square_perimeter(4)==16","canonical_answer":"def square_perimeter(a):\n perimeter=4*a\n return perimeter","verification_metadata":{"test_list":["assert square_perimeter(10)==40","assert square_perimeter(5)==20","assert square_perimeter(4)==16"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":17,"text":"Write a function that returns the perimeter of a square given its side length as input.","code":"def square_perimeter(a):\n perimeter=4*a\n return perimeter","test_list":["assert square_perimeter(10)==40","assert square_perimeter(5)==20","assert square_perimeter(4)==16"],"test_imports":[]}} {"problem_id":"mbpp_test_00018","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove characters from the first string which are present in the second string.\n\nTests:\nassert remove_dirty_chars(\"probasscurve\", \"pros\") == 'bacuve'\nassert remove_dirty_chars(\"digitalindia\", \"talent\") == 'digiidi'\nassert remove_dirty_chars(\"exoticmiles\", \"toxic\") == 'emles'","canonical_answer":"NO_OF_CHARS = 256\ndef str_to_list(string): \n\ttemp = [] \n\tfor x in string: \n\t\ttemp.append(x) \n\treturn temp \ndef lst_to_string(List): \n\treturn ''.join(List) \ndef get_char_count_array(string): \n\tcount = [0] * NO_OF_CHARS \n\tfor i in string: \n\t\tcount[ord(i)] += 1\n\treturn count \ndef remove_dirty_chars(string, second_string): \n\tcount = get_char_count_array(second_string) \n\tip_ind = 0\n\tres_ind = 0\n\ttemp = '' \n\tstr_list = str_to_list(string) \n\twhile ip_ind != len(str_list): \n\t\ttemp = str_list[ip_ind] \n\t\tif count[ord(temp)] == 0: \n\t\t\tstr_list[res_ind] = str_list[ip_ind] \n\t\t\tres_ind += 1\n\t\tip_ind+=1\n\treturn lst_to_string(str_list[0:res_ind])","verification_metadata":{"test_list":["assert remove_dirty_chars(\"probasscurve\", \"pros\") == 'bacuve'","assert remove_dirty_chars(\"digitalindia\", \"talent\") == 'digiidi'","assert remove_dirty_chars(\"exoticmiles\", \"toxic\") == 'emles'"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":18,"text":"Write a function to remove characters from the first string which are present in the second string.","code":"NO_OF_CHARS = 256\ndef str_to_list(string): \n\ttemp = [] \n\tfor x in string: \n\t\ttemp.append(x) \n\treturn temp \ndef lst_to_string(List): \n\treturn ''.join(List) \ndef get_char_count_array(string): \n\tcount = [0] * NO_OF_CHARS \n\tfor i in string: \n\t\tcount[ord(i)] += 1\n\treturn count \ndef remove_dirty_chars(string, second_string): \n\tcount = get_char_count_array(second_string) \n\tip_ind = 0\n\tres_ind = 0\n\ttemp = '' \n\tstr_list = str_to_list(string) \n\twhile ip_ind != len(str_list): \n\t\ttemp = str_list[ip_ind] \n\t\tif count[ord(temp)] == 0: \n\t\t\tstr_list[res_ind] = str_list[ip_ind] \n\t\t\tres_ind += 1\n\t\tip_ind+=1\n\treturn lst_to_string(str_list[0:res_ind])","test_list":["assert remove_dirty_chars(\"probasscurve\", \"pros\") == 'bacuve'","assert remove_dirty_chars(\"digitalindia\", \"talent\") == 'digiidi'","assert remove_dirty_chars(\"exoticmiles\", \"toxic\") == 'emles'"],"test_imports":[]}} {"problem_id":"mbpp_test_00019","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find whether a given array of integers contains any duplicate element.\n\nTests:\nassert test_duplicate(([1,2,3,4,5]))==False\nassert test_duplicate(([1,2,3,4, 4]))==True\nassert test_duplicate([1,1,2,2,3,3,4,4,5])==True","canonical_answer":"def test_duplicate(arraynums):\n nums_set = set(arraynums) \n return len(arraynums) != len(nums_set)","verification_metadata":{"test_list":["assert test_duplicate(([1,2,3,4,5]))==False","assert test_duplicate(([1,2,3,4, 4]))==True","assert test_duplicate([1,1,2,2,3,3,4,4,5])==True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":19,"text":"Write a function to find whether a given array of integers contains any duplicate element.","code":"def test_duplicate(arraynums):\n nums_set = set(arraynums) \n return len(arraynums) != len(nums_set)","test_list":["assert test_duplicate(([1,2,3,4,5]))==False","assert test_duplicate(([1,2,3,4, 4]))==True","assert test_duplicate([1,1,2,2,3,3,4,4,5])==True"],"test_imports":[]}} {"problem_id":"mbpp_test_00020","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if the given number is woodball or not.\n\nTests:\nassert is_woodall(383) == True\nassert is_woodall(254) == False\nassert is_woodall(200) == False","canonical_answer":"def is_woodall(x): \n\tif (x % 2 == 0): \n\t\treturn False\n\tif (x == 1): \n\t\treturn True\n\tx = x + 1 \n\tp = 0\n\twhile (x % 2 == 0): \n\t\tx = x/2\n\t\tp = p + 1\n\t\tif (p == x): \n\t\t\treturn True\n\treturn False","verification_metadata":{"test_list":["assert is_woodall(383) == True","assert is_woodall(254) == False","assert is_woodall(200) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":20,"text":"Write a function to check if the given number is woodball or not.","code":"def is_woodall(x): \n\tif (x % 2 == 0): \n\t\treturn False\n\tif (x == 1): \n\t\treturn True\n\tx = x + 1 \n\tp = 0\n\twhile (x % 2 == 0): \n\t\tx = x/2\n\t\tp = p + 1\n\t\tif (p == x): \n\t\t\treturn True\n\treturn False","test_list":["assert is_woodall(383) == True","assert is_woodall(254) == False","assert is_woodall(200) == False"],"test_imports":[]}} {"problem_id":"mbpp_test_00056","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check if a given number is one less than twice its reverse.\n\nTests:\nassert check(70) == False\nassert check(23) == False\nassert check(73) == True","canonical_answer":"def rev(num): \n rev_num = 0\n while (num > 0): \n rev_num = (rev_num * 10 + num % 10) \n num = num // 10 \n return rev_num \ndef check(n): \n return (2 * rev(n) == n + 1)","verification_metadata":{"test_list":["assert check(70) == False","assert check(23) == False","assert check(73) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":56,"text":"Write a python function to check if a given number is one less than twice its reverse.","code":"def rev(num): \n rev_num = 0\n while (num > 0): \n rev_num = (rev_num * 10 + num % 10) \n num = num // 10 \n return rev_num \ndef check(n): \n return (2 * rev(n) == n + 1)","test_list":["assert check(70) == False","assert check(23) == False","assert check(73) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00057","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the largest number that can be formed with the given list of digits.\n\nTests:\nassert find_Max_Num([1,2,3]) == 321\nassert find_Max_Num([4,5,6,1]) == 6541\nassert find_Max_Num([1,2,3,9]) == 9321","canonical_answer":"def find_Max_Num(arr) : \n n = len(arr)\n arr.sort(reverse = True) \n num = arr[0] \n for i in range(1,n) : \n num = num * 10 + arr[i] \n return num","verification_metadata":{"test_list":["assert find_Max_Num([1,2,3]) == 321","assert find_Max_Num([4,5,6,1]) == 6541","assert find_Max_Num([1,2,3,9]) == 9321"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":57,"text":"Write a python function to find the largest number that can be formed with the given list of digits.","code":"def find_Max_Num(arr) : \n n = len(arr)\n arr.sort(reverse = True) \n num = arr[0] \n for i in range(1,n) : \n num = num * 10 + arr[i] \n return num","test_list":["assert find_Max_Num([1,2,3]) == 321","assert find_Max_Num([4,5,6,1]) == 6541","assert find_Max_Num([1,2,3,9]) == 9321"],"test_imports":[]}} {"problem_id":"mbpp_test_00058","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether the given two integers have opposite sign or not.\n\nTests:\nassert opposite_Signs(1,-2) == True\nassert opposite_Signs(3,2) == False\nassert opposite_Signs(-10,-10) == False\nassert opposite_Signs(-2,2) == True","canonical_answer":"def opposite_Signs(x,y): \n return ((x ^ y) < 0);","verification_metadata":{"test_list":["assert opposite_Signs(1,-2) == True","assert opposite_Signs(3,2) == False","assert opposite_Signs(-10,-10) == False","assert opposite_Signs(-2,2) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":58,"text":"Write a python function to check whether the given two integers have opposite sign or not.","code":"def opposite_Signs(x,y): \n return ((x ^ y) < 0);","test_list":["assert opposite_Signs(1,-2) == True","assert opposite_Signs(3,2) == False","assert opposite_Signs(-10,-10) == False","assert opposite_Signs(-2,2) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00059","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the nth octagonal number.\n\nTests:\nassert is_octagonal(5) == 65\nassert is_octagonal(10) == 280\nassert is_octagonal(15) == 645","canonical_answer":"def is_octagonal(n): \n\treturn 3 * n * n - 2 * n","verification_metadata":{"test_list":["assert is_octagonal(5) == 65","assert is_octagonal(10) == 280","assert is_octagonal(15) == 645"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":59,"text":"Write a function to find the nth octagonal number.","code":"def is_octagonal(n): \n\treturn 3 * n * n - 2 * n","test_list":["assert is_octagonal(5) == 65","assert is_octagonal(10) == 280","assert is_octagonal(15) == 645"],"test_imports":[]}} {"problem_id":"mbpp_test_00061","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the number of substrings with the sum of digits equal to their length.\n\nTests:\nassert count_Substrings('112112') == 6\nassert count_Substrings('111') == 6\nassert count_Substrings('1101112') == 12","canonical_answer":"from collections import defaultdict\ndef count_Substrings(s):\n n = len(s)\n count,sum = 0,0\n mp = defaultdict(lambda : 0)\n mp[0] += 1\n for i in range(n):\n sum += ord(s[i]) - ord('0')\n count += mp[sum - (i + 1)]\n mp[sum - (i + 1)] += 1\n return count","verification_metadata":{"test_list":["assert count_Substrings('112112') == 6","assert count_Substrings('111') == 6","assert count_Substrings('1101112') == 12"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":61,"text":"Write a python function to count the number of substrings with the sum of digits equal to their length.","code":"from collections import defaultdict\ndef count_Substrings(s):\n n = len(s)\n count,sum = 0,0\n mp = defaultdict(lambda : 0)\n mp[0] += 1\n for i in range(n):\n sum += ord(s[i]) - ord('0')\n count += mp[sum - (i + 1)]\n mp[sum - (i + 1)] += 1\n return count","test_list":["assert count_Substrings('112112') == 6","assert count_Substrings('111') == 6","assert count_Substrings('1101112') == 12"],"test_imports":[]}} {"problem_id":"mbpp_test_00062","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find smallest number in a list.\n\nTests:\nassert smallest_num([10, 20, 1, 45, 99]) == 1\nassert smallest_num([1, 2, 3]) == 1\nassert smallest_num([45, 46, 50, 60]) == 45","canonical_answer":"def smallest_num(xs):\n return min(xs)","verification_metadata":{"test_list":["assert smallest_num([10, 20, 1, 45, 99]) == 1","assert smallest_num([1, 2, 3]) == 1","assert smallest_num([45, 46, 50, 60]) == 45"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":62,"text":"Write a python function to find smallest number in a list.","code":"def smallest_num(xs):\n return min(xs)","test_list":["assert smallest_num([10, 20, 1, 45, 99]) == 1","assert smallest_num([1, 2, 3]) == 1","assert smallest_num([45, 46, 50, 60]) == 45"],"test_imports":[]}} {"problem_id":"mbpp_test_00063","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the maximum difference between available pairs in the given tuple list.\n\nTests:\nassert max_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 7\nassert max_difference([(4, 6), (2, 17), (9, 13), (11, 12)]) == 15\nassert max_difference([(12, 35), (21, 27), (13, 23), (41, 22)]) == 23","canonical_answer":"def max_difference(test_list):\n temp = [abs(b - a) for a, b in test_list]\n res = max(temp)\n return (res)","verification_metadata":{"test_list":["assert max_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 7","assert max_difference([(4, 6), (2, 17), (9, 13), (11, 12)]) == 15","assert max_difference([(12, 35), (21, 27), (13, 23), (41, 22)]) == 23"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":63,"text":"Write a function to find the maximum difference between available pairs in the given tuple list.","code":"def max_difference(test_list):\n temp = [abs(b - a) for a, b in test_list]\n res = max(temp)\n return (res)","test_list":["assert max_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 7","assert max_difference([(4, 6), (2, 17), (9, 13), (11, 12)]) == 15","assert max_difference([(12, 35), (21, 27), (13, 23), (41, 22)]) == 23"],"test_imports":[]}} {"problem_id":"mbpp_test_00064","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sort a list of tuples using the second value of each tuple.\n\nTests:\nassert subject_marks([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])==[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]\nassert subject_marks([('Telugu',49),('Hindhi',54),('Social',33)])==([('Social',33),('Telugu',49),('Hindhi',54)])\nassert subject_marks([('Physics',96),('Chemistry',97),('Biology',45)])==([('Biology',45),('Physics',96),('Chemistry',97)])","canonical_answer":"def subject_marks(subjectmarks):\n#subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])\n subjectmarks.sort(key = lambda x: x[1])\n return subjectmarks","verification_metadata":{"test_list":["assert subject_marks([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])==[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]","assert subject_marks([('Telugu',49),('Hindhi',54),('Social',33)])==([('Social',33),('Telugu',49),('Hindhi',54)])","assert subject_marks([('Physics',96),('Chemistry',97),('Biology',45)])==([('Biology',45),('Physics',96),('Chemistry',97)])"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":64,"text":"Write a function to sort a list of tuples using the second value of each tuple.","code":"def subject_marks(subjectmarks):\n#subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])\n subjectmarks.sort(key = lambda x: x[1])\n return subjectmarks","test_list":["assert subject_marks([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])==[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]","assert subject_marks([('Telugu',49),('Hindhi',54),('Social',33)])==([('Social',33),('Telugu',49),('Hindhi',54)])","assert subject_marks([('Physics',96),('Chemistry',97),('Biology',45)])==([('Biology',45),('Physics',96),('Chemistry',97)])"],"test_imports":[]}} {"problem_id":"mbpp_test_00065","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to flatten a list and sum all of its elements.\n\nTests:\nassert recursive_list_sum(([1, 2, [3,4],[5,6]]))==21\nassert recursive_list_sum(([7, 10, [15,14],[19,41]]))==106\nassert recursive_list_sum(([10, 20, [30,40],[50,60]]))==210","canonical_answer":"def recursive_list_sum(data_list):\n\ttotal = 0\n\tfor element in data_list:\n\t\tif type(element) == type([]):\n\t\t\ttotal = total + recursive_list_sum(element)\n\t\telse:\n\t\t\ttotal = total + element\n\treturn total","verification_metadata":{"test_list":["assert recursive_list_sum(([1, 2, [3,4],[5,6]]))==21","assert recursive_list_sum(([7, 10, [15,14],[19,41]]))==106","assert recursive_list_sum(([10, 20, [30,40],[50,60]]))==210"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":65,"text":"Write a function to flatten a list and sum all of its elements.","code":"def recursive_list_sum(data_list):\n\ttotal = 0\n\tfor element in data_list:\n\t\tif type(element) == type([]):\n\t\t\ttotal = total + recursive_list_sum(element)\n\t\telse:\n\t\t\ttotal = total + element\n\treturn total","test_list":["assert recursive_list_sum(([1, 2, [3,4],[5,6]]))==21","assert recursive_list_sum(([7, 10, [15,14],[19,41]]))==106","assert recursive_list_sum(([10, 20, [30,40],[50,60]]))==210"],"test_imports":[]}} {"problem_id":"mbpp_test_00066","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the number of positive numbers in a list.\n\nTests:\nassert pos_count([1,-2,3,-4]) == 2\nassert pos_count([3,4,5,-1]) == 3\nassert pos_count([1,2,3,4]) == 4","canonical_answer":"def pos_count(list):\n pos_count= 0\n for num in list: \n if num >= 0: \n pos_count += 1\n return pos_count","verification_metadata":{"test_list":["assert pos_count([1,-2,3,-4]) == 2","assert pos_count([3,4,5,-1]) == 3","assert pos_count([1,2,3,4]) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":66,"text":"Write a python function to count the number of positive numbers in a list.","code":"def pos_count(list):\n pos_count= 0\n for num in list: \n if num >= 0: \n pos_count += 1\n return pos_count","test_list":["assert pos_count([1,-2,3,-4]) == 2","assert pos_count([3,4,5,-1]) == 3","assert pos_count([1,2,3,4]) == 4"],"test_imports":[]}} {"problem_id":"mbpp_test_00067","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the number of ways to partition a set of Bell numbers.\n\nTests:\nassert bell_number(2)==2\nassert bell_number(10)==115975\nassert bell_number(56)==6775685320645824322581483068371419745979053216268760300","canonical_answer":"def bell_number(n): \n bell = [[0 for i in range(n+1)] for j in range(n+1)] \n bell[0][0] = 1\n for i in range(1, n+1): \n bell[i][0] = bell[i-1][i-1] \n for j in range(1, i+1): \n bell[i][j] = bell[i-1][j-1] + bell[i][j-1] \n return bell[n][0]","verification_metadata":{"test_list":["assert bell_number(2)==2","assert bell_number(10)==115975","assert bell_number(56)==6775685320645824322581483068371419745979053216268760300"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":67,"text":"Write a function to find the number of ways to partition a set of Bell numbers.","code":"def bell_number(n): \n bell = [[0 for i in range(n+1)] for j in range(n+1)] \n bell[0][0] = 1\n for i in range(1, n+1): \n bell[i][0] = bell[i-1][i-1] \n for j in range(1, i+1): \n bell[i][j] = bell[i-1][j-1] + bell[i][j-1] \n return bell[n][0]","test_list":["assert bell_number(2)==2","assert bell_number(10)==115975","assert bell_number(56)==6775685320645824322581483068371419745979053216268760300"],"test_imports":[]}} {"problem_id":"mbpp_test_00068","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether the given array is monotonic or not.\n\nTests:\nassert is_Monotonic([6, 5, 4, 4]) == True\nassert is_Monotonic([1, 2, 2, 3]) == True\nassert is_Monotonic([1, 3, 2]) == False","canonical_answer":"def is_Monotonic(A): \n return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or\n all(A[i] >= A[i + 1] for i in range(len(A) - 1)))","verification_metadata":{"test_list":["assert is_Monotonic([6, 5, 4, 4]) == True","assert is_Monotonic([1, 2, 2, 3]) == True","assert is_Monotonic([1, 3, 2]) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":68,"text":"Write a python function to check whether the given array is monotonic or not.","code":"def is_Monotonic(A): \n return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or\n all(A[i] >= A[i + 1] for i in range(len(A) - 1)))","test_list":["assert is_Monotonic([6, 5, 4, 4]) == True","assert is_Monotonic([1, 2, 2, 3]) == True","assert is_Monotonic([1, 3, 2]) == False"],"test_imports":[]}} {"problem_id":"mbpp_test_00069","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether a list contains the given sublist or not.\n\nTests:\nassert is_sublist([2,4,3,5,7],[3,7])==False\nassert is_sublist([2,4,3,5,7],[4,3])==True\nassert is_sublist([2,4,3,5,7],[1,6])==False","canonical_answer":"def is_sublist(l, s):\n\tsub_set = False\n\tif s == []:\n\t\tsub_set = True\n\telif s == l:\n\t\tsub_set = True\n\telif len(s) > len(l):\n\t\tsub_set = False\n\telse:\n\t\tfor i in range(len(l)):\n\t\t\tif l[i] == s[0]:\n\t\t\t\tn = 1\n\t\t\t\twhile (n < len(s)) and (l[i+n] == s[n]):\n\t\t\t\t\tn += 1\t\t\t\t\n\t\t\t\tif n == len(s):\n\t\t\t\t\tsub_set = True\n\treturn sub_set","verification_metadata":{"test_list":["assert is_sublist([2,4,3,5,7],[3,7])==False","assert is_sublist([2,4,3,5,7],[4,3])==True","assert is_sublist([2,4,3,5,7],[1,6])==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":69,"text":"Write a function to check whether a list contains the given sublist or not.","code":"def is_sublist(l, s):\n\tsub_set = False\n\tif s == []:\n\t\tsub_set = True\n\telif s == l:\n\t\tsub_set = True\n\telif len(s) > len(l):\n\t\tsub_set = False\n\telse:\n\t\tfor i in range(len(l)):\n\t\t\tif l[i] == s[0]:\n\t\t\t\tn = 1\n\t\t\t\twhile (n < len(s)) and (l[i+n] == s[n]):\n\t\t\t\t\tn += 1\t\t\t\t\n\t\t\t\tif n == len(s):\n\t\t\t\t\tsub_set = True\n\treturn sub_set","test_list":["assert is_sublist([2,4,3,5,7],[3,7])==False","assert is_sublist([2,4,3,5,7],[4,3])==True","assert is_sublist([2,4,3,5,7],[1,6])==False"],"test_imports":[]}} {"problem_id":"mbpp_test_00070","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find whether all the given tuples have equal length or not.\n\nTests:\nassert get_equal([(11, 22, 33), (44, 55, 66)]) == True\nassert get_equal([(1, 2, 3), (4, 5, 6, 7)]) == False\nassert get_equal([(1, 2), (3, 4)]) == True","canonical_answer":"def find_equal_tuple(Input):\n k = 0 if not Input else len(Input[0])\n flag = 1\n for tuple in Input:\n if len(tuple) != k:\n flag = 0\n break\n return flag\ndef get_equal(Input):\n return find_equal_tuple(Input) == 1","verification_metadata":{"test_list":["assert get_equal([(11, 22, 33), (44, 55, 66)]) == True","assert get_equal([(1, 2, 3), (4, 5, 6, 7)]) == False","assert get_equal([(1, 2), (3, 4)]) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":70,"text":"Write a function to find whether all the given tuples have equal length or not.","code":"def find_equal_tuple(Input):\n k = 0 if not Input else len(Input[0])\n flag = 1\n for tuple in Input:\n if len(tuple) != k:\n flag = 0\n break\n return flag\ndef get_equal(Input):\n return find_equal_tuple(Input) == 1","test_list":["assert get_equal([(11, 22, 33), (44, 55, 66)]) == True","assert get_equal([(1, 2, 3), (4, 5, 6, 7)]) == False","assert get_equal([(1, 2), (3, 4)]) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00071","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sort a list of elements.\n\nTests:\nassert comb_sort([5, 15, 37, 25, 79]) == [5, 15, 25, 37, 79]\nassert comb_sort([41, 32, 15, 19, 22]) == [15, 19, 22, 32, 41]\nassert comb_sort([99, 15, 13, 47]) == [13, 15, 47, 99]","canonical_answer":"def comb_sort(nums):\n shrink_fact = 1.3\n gaps = len(nums)\n swapped = True\n i = 0\n while gaps > 1 or swapped:\n gaps = int(float(gaps) / shrink_fact)\n swapped = False\n i = 0\n while gaps + i < len(nums):\n if nums[i] > nums[i+gaps]:\n nums[i], nums[i+gaps] = nums[i+gaps], nums[i]\n swapped = True\n i += 1\n return nums","verification_metadata":{"test_list":["assert comb_sort([5, 15, 37, 25, 79]) == [5, 15, 25, 37, 79]","assert comb_sort([41, 32, 15, 19, 22]) == [15, 19, 22, 32, 41]","assert comb_sort([99, 15, 13, 47]) == [13, 15, 47, 99]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":71,"text":"Write a function to sort a list of elements.","code":"def comb_sort(nums):\n shrink_fact = 1.3\n gaps = len(nums)\n swapped = True\n i = 0\n while gaps > 1 or swapped:\n gaps = int(float(gaps) / shrink_fact)\n swapped = False\n i = 0\n while gaps + i < len(nums):\n if nums[i] > nums[i+gaps]:\n nums[i], nums[i+gaps] = nums[i+gaps], nums[i]\n swapped = True\n i += 1\n return nums","test_list":["assert comb_sort([5, 15, 37, 25, 79]) == [5, 15, 25, 37, 79]","assert comb_sort([41, 32, 15, 19, 22]) == [15, 19, 22, 32, 41]","assert comb_sort([99, 15, 13, 47]) == [13, 15, 47, 99]"],"test_imports":[]}} {"problem_id":"mbpp_test_00072","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether the given number can be represented as the difference of two squares or not.\n\nTests:\nassert dif_Square(5) == True\nassert dif_Square(10) == False\nassert dif_Square(15) == True","canonical_answer":"def dif_Square(n): \n if (n % 4 != 2): \n return True\n return False","verification_metadata":{"test_list":["assert dif_Square(5) == True","assert dif_Square(10) == False","assert dif_Square(15) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":72,"text":"Write a python function to check whether the given number can be represented as the difference of two squares or not.","code":"def dif_Square(n): \n if (n % 4 != 2): \n return True\n return False","test_list":["assert dif_Square(5) == True","assert dif_Square(10) == False","assert dif_Square(15) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00074","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether it follows the sequence given in the patterns array.\n\nTests:\nassert is_samepatterns([\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"])==True\nassert is_samepatterns([\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"])==False\nassert is_samepatterns([\"red\",\"green\",\"greenn\"], [\"a\",\"b\"])==False","canonical_answer":"def is_samepatterns(colors, patterns): \n if len(colors) != len(patterns):\n return False \n sdict = {}\n pset = set()\n sset = set() \n for i in range(len(patterns)):\n pset.add(patterns[i])\n sset.add(colors[i])\n if patterns[i] not in sdict.keys():\n sdict[patterns[i]] = []\n\n keys = sdict[patterns[i]]\n keys.append(colors[i])\n sdict[patterns[i]] = keys\n\n if len(pset) != len(sset):\n return False \n\n for values in sdict.values():\n\n for i in range(len(values) - 1):\n if values[i] != values[i+1]:\n return False\n\n return True","verification_metadata":{"test_list":["assert is_samepatterns([\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"])==True","assert is_samepatterns([\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"])==False","assert is_samepatterns([\"red\",\"green\",\"greenn\"], [\"a\",\"b\"])==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":74,"text":"Write a function to check whether it follows the sequence given in the patterns array.","code":"def is_samepatterns(colors, patterns): \n if len(colors) != len(patterns):\n return False \n sdict = {}\n pset = set()\n sset = set() \n for i in range(len(patterns)):\n pset.add(patterns[i])\n sset.add(colors[i])\n if patterns[i] not in sdict.keys():\n sdict[patterns[i]] = []\n\n keys = sdict[patterns[i]]\n keys.append(colors[i])\n sdict[patterns[i]] = keys\n\n if len(pset) != len(sset):\n return False \n\n for values in sdict.values():\n\n for i in range(len(values) - 1):\n if values[i] != values[i+1]:\n return False\n\n return True","test_list":["assert is_samepatterns([\"red\",\"green\",\"green\"], [\"a\", \"b\", \"b\"])==True","assert is_samepatterns([\"red\",\"green\",\"greenn\"], [\"a\",\"b\",\"b\"])==False","assert is_samepatterns([\"red\",\"green\",\"greenn\"], [\"a\",\"b\"])==False"],"test_imports":[]}} {"problem_id":"mbpp_test_00075","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find tuples which have all elements divisible by k from the given list of tuples.\n\nTests:\nassert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == [(6, 24, 12)]\nassert find_tuples([(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5) == [(5, 25, 30)]\nassert find_tuples([(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4) == [(8, 16, 4)]","canonical_answer":"def find_tuples(test_list, K):\n res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)]\n return res","verification_metadata":{"test_list":["assert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == [(6, 24, 12)]","assert find_tuples([(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5) == [(5, 25, 30)]","assert find_tuples([(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4) == [(8, 16, 4)]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":75,"text":"Write a function to find tuples which have all elements divisible by k from the given list of tuples.","code":"def find_tuples(test_list, K):\n res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)]\n return res","test_list":["assert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == [(6, 24, 12)]","assert find_tuples([(5, 25, 30), (4, 2, 3), (7, 8, 9)], 5) == [(5, 25, 30)]","assert find_tuples([(7, 9, 16), (8, 16, 4), (19, 17, 18)], 4) == [(8, 16, 4)]"],"test_imports":[]}} {"problem_id":"mbpp_test_00077","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find whether a number is divisible by 11.\n\nTests:\nassert is_Diff (12345) == False\nassert is_Diff(1212112) == True\nassert is_Diff(1212) == False","canonical_answer":"def is_Diff(n): \n return (n % 11 == 0)","verification_metadata":{"test_list":["assert is_Diff (12345) == False","assert is_Diff(1212112) == True","assert is_Diff(1212) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":77,"text":"Write a python function to find whether a number is divisible by 11.","code":"def is_Diff(n): \n return (n % 11 == 0)","test_list":["assert is_Diff (12345) == False","assert is_Diff(1212112) == True","assert is_Diff(1212) == False"],"test_imports":[]}} {"problem_id":"mbpp_test_00079","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether the length of the word is odd or not.\n\nTests:\nassert word_len(\"Hadoop\") == False\nassert word_len(\"great\") == True\nassert word_len(\"structure\") == True","canonical_answer":"def word_len(s): \n s = s.split(' ') \n for word in s: \n if len(word)%2!=0: \n return True \n else:\n return False","verification_metadata":{"test_list":["assert word_len(\"Hadoop\") == False","assert word_len(\"great\") == True","assert word_len(\"structure\") == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":79,"text":"Write a python function to check whether the length of the word is odd or not.","code":"def word_len(s): \n s = s.split(' ') \n for word in s: \n if len(word)%2!=0: \n return True \n else:\n return False","test_list":["assert word_len(\"Hadoop\") == False","assert word_len(\"great\") == True","assert word_len(\"structure\") == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00080","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the nth tetrahedral number.\n\nTests:\nassert tetrahedral_number(5) == 35\nassert tetrahedral_number(6) == 56\nassert tetrahedral_number(7) == 84","canonical_answer":"def tetrahedral_number(n): \n\treturn (n * (n + 1) * (n + 2)) / 6","verification_metadata":{"test_list":["assert tetrahedral_number(5) == 35","assert tetrahedral_number(6) == 56","assert tetrahedral_number(7) == 84"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":80,"text":"Write a function to find the nth tetrahedral number.","code":"def tetrahedral_number(n): \n\treturn (n * (n + 1) * (n + 2)) / 6","test_list":["assert tetrahedral_number(5) == 35","assert tetrahedral_number(6) == 56","assert tetrahedral_number(7) == 84"],"test_imports":[]}} {"problem_id":"mbpp_test_00082","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the volume of a sphere.\n\nTests:\nassert math.isclose(volume_sphere(10), 4188.790204786391, rel_tol=0.001)\nassert math.isclose(volume_sphere(25), 65449.84694978735, rel_tol=0.001)\nassert math.isclose(volume_sphere(20), 33510.32163829113, rel_tol=0.001)","canonical_answer":"import math\ndef volume_sphere(r):\n volume=(4/3)*math.pi*r*r*r\n return volume","verification_metadata":{"test_list":["assert math.isclose(volume_sphere(10), 4188.790204786391, rel_tol=0.001)","assert math.isclose(volume_sphere(25), 65449.84694978735, rel_tol=0.001)","assert math.isclose(volume_sphere(20), 33510.32163829113, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":82,"text":"Write a function to find the volume of a sphere.","code":"import math\ndef volume_sphere(r):\n volume=(4/3)*math.pi*r*r*r\n return volume","test_list":["assert math.isclose(volume_sphere(10), 4188.790204786391, rel_tol=0.001)","assert math.isclose(volume_sphere(25), 65449.84694978735, rel_tol=0.001)","assert math.isclose(volume_sphere(20), 33510.32163829113, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00083","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.\n\nTests:\nassert get_Char(\"abc\") == \"f\"\nassert get_Char(\"gfg\") == \"t\"\nassert get_Char(\"ab\") == \"c\"","canonical_answer":"def get_Char(strr): \n summ = 0\n for i in range(len(strr)): \n summ += (ord(strr[i]) - ord('a') + 1) \n if (summ % 26 == 0): \n return ord('z') \n else: \n summ = summ % 26\n return chr(ord('a') + summ - 1)","verification_metadata":{"test_list":["assert get_Char(\"abc\") == \"f\"","assert get_Char(\"gfg\") == \"t\"","assert get_Char(\"ab\") == \"c\""],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":83,"text":"Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.","code":"def get_Char(strr): \n summ = 0\n for i in range(len(strr)): \n summ += (ord(strr[i]) - ord('a') + 1) \n if (summ % 26 == 0): \n return ord('z') \n else: \n summ = summ % 26\n return chr(ord('a') + summ - 1)","test_list":["assert get_Char(\"abc\") == \"f\"","assert get_Char(\"gfg\") == \"t\"","assert get_Char(\"ab\") == \"c\""],"test_imports":[]}} {"problem_id":"mbpp_test_00084","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the nth number in the newman conway sequence.\n\nTests:\nassert sequence(10) == 6\nassert sequence(2) == 1\nassert sequence(3) == 2","canonical_answer":"def sequence(n): \n\tif n == 1 or n == 2: \n\t\treturn 1\n\telse: \n\t\treturn sequence(sequence(n-1)) + sequence(n-sequence(n-1))","verification_metadata":{"test_list":["assert sequence(10) == 6","assert sequence(2) == 1","assert sequence(3) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":84,"text":"Write a function to find the nth number in the newman conway sequence.","code":"def sequence(n): \n\tif n == 1 or n == 2: \n\t\treturn 1\n\telse: \n\t\treturn sequence(sequence(n-1)) + sequence(n-sequence(n-1))","test_list":["assert sequence(10) == 6","assert sequence(2) == 1","assert sequence(3) == 2"],"test_imports":[]}} {"problem_id":"mbpp_test_00085","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the surface area of a sphere.\n\nTests:\nassert math.isclose(surfacearea_sphere(10), 1256.6370614359173, rel_tol=0.001)\nassert math.isclose(surfacearea_sphere(15), 2827.4333882308138, rel_tol=0.001)\nassert math.isclose(surfacearea_sphere(20), 5026.548245743669, rel_tol=0.001)","canonical_answer":"import math\ndef surfacearea_sphere(r):\n surfacearea=4*math.pi*r*r\n return surfacearea","verification_metadata":{"test_list":["assert math.isclose(surfacearea_sphere(10), 1256.6370614359173, rel_tol=0.001)","assert math.isclose(surfacearea_sphere(15), 2827.4333882308138, rel_tol=0.001)","assert math.isclose(surfacearea_sphere(20), 5026.548245743669, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":85,"text":"Write a function to find the surface area of a sphere.","code":"import math\ndef surfacearea_sphere(r):\n surfacearea=4*math.pi*r*r\n return surfacearea","test_list":["assert math.isclose(surfacearea_sphere(10), 1256.6370614359173, rel_tol=0.001)","assert math.isclose(surfacearea_sphere(15), 2827.4333882308138, rel_tol=0.001)","assert math.isclose(surfacearea_sphere(20), 5026.548245743669, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00086","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find nth centered hexagonal number.\n\nTests:\nassert centered_hexagonal_number(10) == 271\nassert centered_hexagonal_number(2) == 7\nassert centered_hexagonal_number(9) == 217","canonical_answer":"def centered_hexagonal_number(n):\n return 3 * n * (n - 1) + 1","verification_metadata":{"test_list":["assert centered_hexagonal_number(10) == 271","assert centered_hexagonal_number(2) == 7","assert centered_hexagonal_number(9) == 217"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":86,"text":"Write a function to find nth centered hexagonal number.","code":"def centered_hexagonal_number(n):\n return 3 * n * (n - 1) + 1","test_list":["assert centered_hexagonal_number(10) == 271","assert centered_hexagonal_number(2) == 7","assert centered_hexagonal_number(9) == 217"],"test_imports":[]}} {"problem_id":"mbpp_test_00087","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to merge three dictionaries into a single dictionary.\n\nTests:\nassert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}\nassert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{\"L\":\"lavender\",\"B\":\"Blue\"})=={'W': 'White', 'P': 'Pink', 'B': 'Black', 'R': 'Red', 'G': 'Green', 'L': 'lavender'}\nassert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{\"L\":\"lavender\",\"B\":\"Blue\"},{ \"G\": \"Green\", \"W\": \"White\" })=={'B': 'Black', 'P': 'Pink', 'R': 'Red', 'G': 'Green', 'L': 'lavender', 'W': 'White'}","canonical_answer":"import collections as ct\ndef merge_dictionaries_three(dict1,dict2, dict3):\n merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3))\n return merged_dict","verification_metadata":{"test_list":["assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}","assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{\"L\":\"lavender\",\"B\":\"Blue\"})=={'W': 'White', 'P': 'Pink', 'B': 'Black', 'R': 'Red', 'G': 'Green', 'L': 'lavender'}","assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{\"L\":\"lavender\",\"B\":\"Blue\"},{ \"G\": \"Green\", \"W\": \"White\" })=={'B': 'Black', 'P': 'Pink', 'R': 'Red', 'G': 'Green', 'L': 'lavender', 'W': 'White'}"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":87,"text":"Write a function to merge three dictionaries into a single dictionary.","code":"import collections as ct\ndef merge_dictionaries_three(dict1,dict2, dict3):\n merged_dict = dict(ct.ChainMap({},dict1,dict2,dict3))\n return merged_dict","test_list":["assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{ \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}","assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }, { \"G\": \"Green\", \"W\": \"White\" },{\"L\":\"lavender\",\"B\":\"Blue\"})=={'W': 'White', 'P': 'Pink', 'B': 'Black', 'R': 'Red', 'G': 'Green', 'L': 'lavender'}","assert merge_dictionaries_three({ \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" },{\"L\":\"lavender\",\"B\":\"Blue\"},{ \"G\": \"Green\", \"W\": \"White\" })=={'B': 'Black', 'P': 'Pink', 'R': 'Red', 'G': 'Green', 'L': 'lavender', 'W': 'White'}"],"test_imports":[]}} {"problem_id":"mbpp_test_00088","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to get the frequency of all the elements in a list, returned as a dictionary.\n\nTests:\nassert freq_count([10,10,10,10,20,20,20,20,40,40,50,50,30])==({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})\nassert freq_count([1,2,3,4,3,2,4,1,3,1,4])==({1:3, 2:2,3:3,4:3})\nassert freq_count([5,6,7,4,9,10,4,5,6,7,9,5])==({10:1,5:3,6:2,7:2,4:2,9:2})","canonical_answer":"import collections\ndef freq_count(list1):\n freq_count= collections.Counter(list1)\n return freq_count","verification_metadata":{"test_list":["assert freq_count([10,10,10,10,20,20,20,20,40,40,50,50,30])==({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})","assert freq_count([1,2,3,4,3,2,4,1,3,1,4])==({1:3, 2:2,3:3,4:3})","assert freq_count([5,6,7,4,9,10,4,5,6,7,9,5])==({10:1,5:3,6:2,7:2,4:2,9:2})"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":88,"text":"Write a function to get the frequency of all the elements in a list, returned as a dictionary.","code":"import collections\ndef freq_count(list1):\n freq_count= collections.Counter(list1)\n return freq_count","test_list":["assert freq_count([10,10,10,10,20,20,20,20,40,40,50,50,30])==({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})","assert freq_count([1,2,3,4,3,2,4,1,3,1,4])==({1:3, 2:2,3:3,4:3})","assert freq_count([5,6,7,4,9,10,4,5,6,7,9,5])==({10:1,5:3,6:2,7:2,4:2,9:2})"],"test_imports":[]}} {"problem_id":"mbpp_test_00089","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the closest smaller number than n.\n\nTests:\nassert closest_num(11) == 10\nassert closest_num(7) == 6\nassert closest_num(12) == 11","canonical_answer":"def closest_num(N):\n return (N - 1)","verification_metadata":{"test_list":["assert closest_num(11) == 10","assert closest_num(7) == 6","assert closest_num(12) == 11"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":89,"text":"Write a function to find the closest smaller number than n.","code":"def closest_num(N):\n return (N - 1)","test_list":["assert closest_num(11) == 10","assert closest_num(7) == 6","assert closest_num(12) == 11"],"test_imports":[]}} {"problem_id":"mbpp_test_00090","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the length of the longest word.\n\nTests:\nassert len_log([\"python\",\"PHP\",\"bigdata\"]) == 7\nassert len_log([\"a\",\"ab\",\"abc\"]) == 3\nassert len_log([\"small\",\"big\",\"tall\"]) == 5","canonical_answer":"def len_log(list1):\n max=len(list1[0])\n for i in list1:\n if len(i)>max:\n max=len(i)\n return max","verification_metadata":{"test_list":["assert len_log([\"python\",\"PHP\",\"bigdata\"]) == 7","assert len_log([\"a\",\"ab\",\"abc\"]) == 3","assert len_log([\"small\",\"big\",\"tall\"]) == 5"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":90,"text":"Write a python function to find the length of the longest word.","code":"def len_log(list1):\n max=len(list1[0])\n for i in list1:\n if len(i)>max:\n max=len(i)\n return max","test_list":["assert len_log([\"python\",\"PHP\",\"bigdata\"]) == 7","assert len_log([\"a\",\"ab\",\"abc\"]) == 3","assert len_log([\"small\",\"big\",\"tall\"]) == 5"],"test_imports":[]}} {"problem_id":"mbpp_test_00091","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if a string is present as a substring in a given list of string values.\n\nTests:\nassert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\")==True\nassert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"abc\")==False\nassert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ange\")==True","canonical_answer":"def find_substring(str1, sub_str):\n if any(sub_str in s for s in str1):\n return True\n return False","verification_metadata":{"test_list":["assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\")==True","assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"abc\")==False","assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ange\")==True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":91,"text":"Write a function to check if a string is present as a substring in a given list of string values.","code":"def find_substring(str1, sub_str):\n if any(sub_str in s for s in str1):\n return True\n return False","test_list":["assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ack\")==True","assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"abc\")==False","assert find_substring([\"red\", \"black\", \"white\", \"green\", \"orange\"],\"ange\")==True"],"test_imports":[]}} {"problem_id":"mbpp_test_00092","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether the given number is undulating or not.\n\nTests:\nassert is_undulating(1212121) == True\nassert is_undulating(1991) == False\nassert is_undulating(121) == True","canonical_answer":"def is_undulating(n): \n\tn = str(n)\n\tif (len(n) <= 2): \n\t\treturn False\n\tfor i in range(2, len(n)): \n\t\tif (n[i - 2] != n[i]): \n\t\t\treturn False\n\treturn True","verification_metadata":{"test_list":["assert is_undulating(1212121) == True","assert is_undulating(1991) == False","assert is_undulating(121) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":92,"text":"Write a function to check whether the given number is undulating or not.","code":"def is_undulating(n): \n\tn = str(n)\n\tif (len(n) <= 2): \n\t\treturn False\n\tfor i in range(2, len(n)): \n\t\tif (n[i - 2] != n[i]): \n\t\t\treturn False\n\treturn True","test_list":["assert is_undulating(1212121) == True","assert is_undulating(1991) == False","assert is_undulating(121) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00093","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to calculate the value of 'a' to the power 'b'.\n\nTests:\nassert power(3,4) == 81\nassert power(2,3) == 8\nassert power(5,5) == 3125","canonical_answer":"def power(a,b):\n\tif b==0:\n\t\treturn 1\n\telif a==0:\n\t\treturn 0\n\telif b==1:\n\t\treturn a\n\telse:\n\t\treturn a*power(a,b-1)","verification_metadata":{"test_list":["assert power(3,4) == 81","assert power(2,3) == 8","assert power(5,5) == 3125"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":93,"text":"Write a function to calculate the value of 'a' to the power 'b'.","code":"def power(a,b):\n\tif b==0:\n\t\treturn 1\n\telif a==0:\n\t\treturn 0\n\telif b==1:\n\t\treturn a\n\telse:\n\t\treturn a*power(a,b-1)","test_list":["assert power(3,4) == 81","assert power(2,3) == 8","assert power(5,5) == 3125"],"test_imports":[]}} {"problem_id":"mbpp_test_00094","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nGiven a list of tuples, write a function that returns the first value of the tuple with the smallest second value.\n\nTests:\nassert index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]) == 'Varsha'\nassert index_minimum([('Yash', 185), ('Dawood', 125), ('Sanya', 175)]) == 'Dawood'\nassert index_minimum([('Sai', 345), ('Salman', 145), ('Ayesha', 96)]) == 'Ayesha'","canonical_answer":"from operator import itemgetter \ndef index_minimum(test_list):\n res = min(test_list, key = itemgetter(1))[0]\n return (res)","verification_metadata":{"test_list":["assert index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]) == 'Varsha'","assert index_minimum([('Yash', 185), ('Dawood', 125), ('Sanya', 175)]) == 'Dawood'","assert index_minimum([('Sai', 345), ('Salman', 145), ('Ayesha', 96)]) == 'Ayesha'"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":94,"text":"Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value.","code":"from operator import itemgetter \ndef index_minimum(test_list):\n res = min(test_list, key = itemgetter(1))[0]\n return (res)","test_list":["assert index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]) == 'Varsha'","assert index_minimum([('Yash', 185), ('Dawood', 125), ('Sanya', 175)]) == 'Dawood'","assert index_minimum([('Sai', 345), ('Salman', 145), ('Ayesha', 96)]) == 'Ayesha'"],"test_imports":[]}} {"problem_id":"mbpp_test_00095","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the length of the smallest list in a list of lists.\n\nTests:\nassert Find_Min_Length([[1],[1,2]]) == 1\nassert Find_Min_Length([[1,2],[1,2,3],[1,2,3,4]]) == 2\nassert Find_Min_Length([[3,3,3],[4,4,4,4]]) == 3","canonical_answer":"def Find_Min_Length(lst): \n minLength = min(len(x) for x in lst )\n return minLength","verification_metadata":{"test_list":["assert Find_Min_Length([[1],[1,2]]) == 1","assert Find_Min_Length([[1,2],[1,2,3],[1,2,3,4]]) == 2","assert Find_Min_Length([[3,3,3],[4,4,4,4]]) == 3"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":95,"text":"Write a python function to find the length of the smallest list in a list of lists.","code":"def Find_Min_Length(lst): \n minLength = min(len(x) for x in lst )\n return minLength","test_list":["assert Find_Min_Length([[1],[1,2]]) == 1","assert Find_Min_Length([[1,2],[1,2,3],[1,2,3,4]]) == 2","assert Find_Min_Length([[3,3,3],[4,4,4,4]]) == 3"],"test_imports":[]}} {"problem_id":"mbpp_test_00096","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the number of divisors of a given integer.\n\nTests:\nassert divisor(15) == 4\nassert divisor(12) == 6\nassert divisor(9) == 3","canonical_answer":"def divisor(n):\n for i in range(n):\n x = len([i for i in range(1,n+1) if not n % i])\n return x","verification_metadata":{"test_list":["assert divisor(15) == 4","assert divisor(12) == 6","assert divisor(9) == 3"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":96,"text":"Write a python function to find the number of divisors of a given integer.","code":"def divisor(n):\n for i in range(n):\n x = len([i for i in range(1,n+1) if not n % i])\n return x","test_list":["assert divisor(15) == 4","assert divisor(12) == 6","assert divisor(9) == 3"],"test_imports":[]}} {"problem_id":"mbpp_test_00097","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find frequency of each element in a flattened list of lists, returned in a dictionary.\n\nTests:\nassert frequency_lists([[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]])=={1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}\nassert frequency_lists([[1,2,3,4],[5,6,7,8],[9,10,11,12]])=={1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}\nassert frequency_lists([[20,30,40,17],[18,16,14,13],[10,20,30,40]])=={20:2,30:2,40:2,17: 1,18:1, 16: 1,14: 1,13: 1, 10: 1}","canonical_answer":"def frequency_lists(list1):\n list1 = [item for sublist in list1 for item in sublist]\n dic_data = {}\n for num in list1:\n if num in dic_data.keys():\n dic_data[num] += 1\n else:\n key = num\n value = 1\n dic_data[key] = value\n return dic_data","verification_metadata":{"test_list":["assert frequency_lists([[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]])=={1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}","assert frequency_lists([[1,2,3,4],[5,6,7,8],[9,10,11,12]])=={1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}","assert frequency_lists([[20,30,40,17],[18,16,14,13],[10,20,30,40]])=={20:2,30:2,40:2,17: 1,18:1, 16: 1,14: 1,13: 1, 10: 1}"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":97,"text":"Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary.","code":"def frequency_lists(list1):\n list1 = [item for sublist in list1 for item in sublist]\n dic_data = {}\n for num in list1:\n if num in dic_data.keys():\n dic_data[num] += 1\n else:\n key = num\n value = 1\n dic_data[key] = value\n return dic_data","test_list":["assert frequency_lists([[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]])=={1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}","assert frequency_lists([[1,2,3,4],[5,6,7,8],[9,10,11,12]])=={1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}","assert frequency_lists([[20,30,40,17],[18,16,14,13],[10,20,30,40]])=={20:2,30:2,40:2,17: 1,18:1, 16: 1,14: 1,13: 1, 10: 1}"],"test_imports":[]}} {"problem_id":"mbpp_test_00098","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to multiply all the numbers in a list and divide with the length of the list.\n\nTests:\nassert math.isclose(multiply_num((8, 2, 3, -1, 7)), -67.2, rel_tol=0.001)\nassert math.isclose(multiply_num((-10,-20,-30)), -2000.0, rel_tol=0.001)\nassert math.isclose(multiply_num((19,15,18)), 1710.0, rel_tol=0.001)","canonical_answer":"def multiply_num(numbers): \n total = 1\n for x in numbers:\n total *= x \n return total/len(numbers)","verification_metadata":{"test_list":["assert math.isclose(multiply_num((8, 2, 3, -1, 7)), -67.2, rel_tol=0.001)","assert math.isclose(multiply_num((-10,-20,-30)), -2000.0, rel_tol=0.001)","assert math.isclose(multiply_num((19,15,18)), 1710.0, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":98,"text":"Write a function to multiply all the numbers in a list and divide with the length of the list.","code":"def multiply_num(numbers): \n total = 1\n for x in numbers:\n total *= x \n return total/len(numbers)","test_list":["assert math.isclose(multiply_num((8, 2, 3, -1, 7)), -67.2, rel_tol=0.001)","assert math.isclose(multiply_num((-10,-20,-30)), -2000.0, rel_tol=0.001)","assert math.isclose(multiply_num((19,15,18)), 1710.0, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00099","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros.\n\nTests:\nassert decimal_to_binary(8) == '1000'\nassert decimal_to_binary(18) == '10010'\nassert decimal_to_binary(7) == '111'","canonical_answer":"def decimal_to_binary(n): \n return bin(n).replace(\"0b\",\"\")","verification_metadata":{"test_list":["assert decimal_to_binary(8) == '1000'","assert decimal_to_binary(18) == '10010'","assert decimal_to_binary(7) == '111'"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":99,"text":"Write a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros.","code":"def decimal_to_binary(n): \n return bin(n).replace(\"0b\",\"\")","test_list":["assert decimal_to_binary(8) == '1000'","assert decimal_to_binary(18) == '10010'","assert decimal_to_binary(7) == '111'"],"test_imports":[]}} {"problem_id":"mbpp_test_00100","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the next smallest palindrome of a specified integer, returned as an integer.\n\nTests:\nassert next_smallest_palindrome(99)==101\nassert next_smallest_palindrome(1221)==1331\nassert next_smallest_palindrome(120)==121","canonical_answer":"import sys\ndef next_smallest_palindrome(num):\n numstr = str(num)\n for i in range(num+1,sys.maxsize):\n if str(i) == str(i)[::-1]:\n return i","verification_metadata":{"test_list":["assert next_smallest_palindrome(99)==101","assert next_smallest_palindrome(1221)==1331","assert next_smallest_palindrome(120)==121"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":100,"text":"Write a function to find the next smallest palindrome of a specified integer, returned as an integer.","code":"import sys\ndef next_smallest_palindrome(num):\n numstr = str(num)\n for i in range(num+1,sys.maxsize):\n if str(i) == str(i)[::-1]:\n return i","test_list":["assert next_smallest_palindrome(99)==101","assert next_smallest_palindrome(1221)==1331","assert next_smallest_palindrome(120)==121"],"test_imports":[]}} {"problem_id":"mbpp_test_00101","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the kth element in the given array using 1-based indexing.\n\nTests:\nassert kth_element([12,3,5,7,19], 2) == 3\nassert kth_element([17,24,8,23], 3) == 8\nassert kth_element([16,21,25,36,4], 4) == 36","canonical_answer":"def kth_element(arr, k):\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] == arr[j+1], arr[j]\n return arr[k-1]","verification_metadata":{"test_list":["assert kth_element([12,3,5,7,19], 2) == 3","assert kth_element([17,24,8,23], 3) == 8","assert kth_element([16,21,25,36,4], 4) == 36"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":101,"text":"Write a function to find the kth element in the given array using 1-based indexing.","code":"def kth_element(arr, k):\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] == arr[j+1], arr[j]\n return arr[k-1]","test_list":["assert kth_element([12,3,5,7,19], 2) == 3","assert kth_element([17,24,8,23], 3) == 8","assert kth_element([16,21,25,36,4], 4) == 36"],"test_imports":[]}} {"problem_id":"mbpp_test_00102","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert a snake case string to camel case string.\n\nTests:\nassert snake_to_camel('python_program')=='PythonProgram'\nassert snake_to_camel('python_language')==('PythonLanguage')\nassert snake_to_camel('programming_language')==('ProgrammingLanguage')","canonical_answer":"def snake_to_camel(word):\n import re\n return ''.join(x.capitalize() or '_' for x in word.split('_'))","verification_metadata":{"test_list":["assert snake_to_camel('python_program')=='PythonProgram'","assert snake_to_camel('python_language')==('PythonLanguage')","assert snake_to_camel('programming_language')==('ProgrammingLanguage')"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":102,"text":"Write a function to convert a snake case string to camel case string.","code":"def snake_to_camel(word):\n import re\n return ''.join(x.capitalize() or '_' for x in word.split('_'))","test_list":["assert snake_to_camel('python_program')=='PythonProgram'","assert snake_to_camel('python_language')==('PythonLanguage')","assert snake_to_camel('programming_language')==('ProgrammingLanguage')"],"test_imports":[]}} {"problem_id":"mbpp_test_00103","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the Eulerian number a(n, m).\n\nTests:\nassert eulerian_num(3, 1) == 4\nassert eulerian_num(4, 1) == 11\nassert eulerian_num(5, 3) == 26","canonical_answer":"def eulerian_num(n, m): \n\tif (m >= n or n == 0): \n\t\treturn 0 \n\tif (m == 0): \n\t\treturn 1 \n\treturn ((n - m) * eulerian_num(n - 1, m - 1) +(m + 1) * eulerian_num(n - 1, m))","verification_metadata":{"test_list":["assert eulerian_num(3, 1) == 4","assert eulerian_num(4, 1) == 11","assert eulerian_num(5, 3) == 26"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":103,"text":"Write a function to find the Eulerian number a(n, m).","code":"def eulerian_num(n, m): \n\tif (m >= n or n == 0): \n\t\treturn 0 \n\tif (m == 0): \n\t\treturn 1 \n\treturn ((n - m) * eulerian_num(n - 1, m - 1) +(m + 1) * eulerian_num(n - 1, m))","test_list":["assert eulerian_num(3, 1) == 4","assert eulerian_num(4, 1) == 11","assert eulerian_num(5, 3) == 26"],"test_imports":[]}} {"problem_id":"mbpp_test_00104","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sort each sublist of strings in a given list of lists.\n\nTests:\nassert sort_sublists(([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"]))==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]\nassert sort_sublists(([\" red \",\"green\" ],[\"blue \",\" black\"],[\" orange\",\"brown\"]))==[[' red ', 'green'], [' black', 'blue '], [' orange', 'brown']]\nassert sort_sublists(([\"zilver\",\"gold\"], [\"magnesium\",\"aluminium\"], [\"steel\", \"bronze\"]))==[['gold', 'zilver'],['aluminium', 'magnesium'], ['bronze', 'steel']]","canonical_answer":"def sort_sublists(input_list):\n result = [sorted(x, key = lambda x:x[0]) for x in input_list] \n return result","verification_metadata":{"test_list":["assert sort_sublists(([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"]))==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]","assert sort_sublists(([\" red \",\"green\" ],[\"blue \",\" black\"],[\" orange\",\"brown\"]))==[[' red ', 'green'], [' black', 'blue '], [' orange', 'brown']]","assert sort_sublists(([\"zilver\",\"gold\"], [\"magnesium\",\"aluminium\"], [\"steel\", \"bronze\"]))==[['gold', 'zilver'],['aluminium', 'magnesium'], ['bronze', 'steel']]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":104,"text":"Write a function to sort each sublist of strings in a given list of lists.","code":"def sort_sublists(input_list):\n result = [sorted(x, key = lambda x:x[0]) for x in input_list] \n return result","test_list":["assert sort_sublists(([\"green\", \"orange\"], [\"black\", \"white\"], [\"white\", \"black\", \"orange\"]))==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]","assert sort_sublists(([\" red \",\"green\" ],[\"blue \",\" black\"],[\" orange\",\"brown\"]))==[[' red ', 'green'], [' black', 'blue '], [' orange', 'brown']]","assert sort_sublists(([\"zilver\",\"gold\"], [\"magnesium\",\"aluminium\"], [\"steel\", \"bronze\"]))==[['gold', 'zilver'],['aluminium', 'magnesium'], ['bronze', 'steel']]"],"test_imports":[]}} {"problem_id":"mbpp_test_00105","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count true booleans in the given list.\n\nTests:\nassert count([True,False,True]) == 2\nassert count([False,False]) == 0\nassert count([True,True,True]) == 3","canonical_answer":"def count(lst): \n return sum(lst)","verification_metadata":{"test_list":["assert count([True,False,True]) == 2","assert count([False,False]) == 0","assert count([True,True,True]) == 3"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":105,"text":"Write a python function to count true booleans in the given list.","code":"def count(lst): \n return sum(lst)","test_list":["assert count([True,False,True]) == 2","assert count([False,False]) == 0","assert count([True,True,True]) == 3"],"test_imports":[]}} {"problem_id":"mbpp_test_00106","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to append the given list to the given tuples.\n\nTests:\nassert add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)\nassert add_lists([6, 7, 8], (10, 11)) == (10, 11, 6, 7, 8)\nassert add_lists([7, 8, 9], (11, 12)) == (11, 12, 7, 8, 9)","canonical_answer":"def add_lists(test_list, test_tup):\n res = tuple(list(test_tup) + test_list)\n return (res)","verification_metadata":{"test_list":["assert add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)","assert add_lists([6, 7, 8], (10, 11)) == (10, 11, 6, 7, 8)","assert add_lists([7, 8, 9], (11, 12)) == (11, 12, 7, 8, 9)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":106,"text":"Write a function to append the given list to the given tuples.","code":"def add_lists(test_list, test_tup):\n res = tuple(list(test_tup) + test_list)\n return (res)","test_list":["assert add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)","assert add_lists([6, 7, 8], (10, 11)) == (10, 11, 6, 7, 8)","assert add_lists([7, 8, 9], (11, 12)) == (11, 12, 7, 8, 9)"],"test_imports":[]}} {"problem_id":"mbpp_test_00108","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to merge three lists into a single sorted list.\n\nTests:\nassert merge_sorted_list([25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48])==[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]\nassert merge_sorted_list([1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12])==[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]\nassert merge_sorted_list([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1],[25, 35, 22, 85, 14, 65, 75, 25, 58],[12, 74, 9, 50, 61, 41])==[1, 2, 3, 4, 7, 8, 9, 9, 9, 10, 12, 14, 14, 18, 22, 25, 25, 35, 41, 50, 58, 61, 65, 74, 75, 85]","canonical_answer":"import heapq\ndef merge_sorted_list(num1,num2,num3):\n num1=sorted(num1)\n num2=sorted(num2)\n num3=sorted(num3)\n result = heapq.merge(num1,num2,num3)\n return list(result)","verification_metadata":{"test_list":["assert merge_sorted_list([25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48])==[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]","assert merge_sorted_list([1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12])==[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]","assert merge_sorted_list([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1],[25, 35, 22, 85, 14, 65, 75, 25, 58],[12, 74, 9, 50, 61, 41])==[1, 2, 3, 4, 7, 8, 9, 9, 9, 10, 12, 14, 14, 18, 22, 25, 25, 35, 41, 50, 58, 61, 65, 74, 75, 85]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":108,"text":"Write a function to merge three lists into a single sorted list.","code":"import heapq\ndef merge_sorted_list(num1,num2,num3):\n num1=sorted(num1)\n num2=sorted(num2)\n num3=sorted(num3)\n result = heapq.merge(num1,num2,num3)\n return list(result)","test_list":["assert merge_sorted_list([25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48])==[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]","assert merge_sorted_list([1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12])==[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]","assert merge_sorted_list([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1],[25, 35, 22, 85, 14, 65, 75, 25, 58],[12, 74, 9, 50, 61, 41])==[1, 2, 3, 4, 7, 8, 9, 9, 9, 10, 12, 14, 14, 18, 22, 25, 25, 35, 41, 50, 58, 61, 65, 74, 75, 85]"],"test_imports":[]}} {"problem_id":"mbpp_test_00109","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the number of numbers with an odd value when rotating a binary string the given number of times.\n\nTests:\nassert odd_Equivalent(\"011001\",6) == 3\nassert odd_Equivalent(\"11011\",5) == 4\nassert odd_Equivalent(\"1010\",4) == 2","canonical_answer":"def odd_Equivalent(s,n): \n count=0\n for i in range(0,n): \n if (s[i] == '1'): \n count = count + 1\n return count","verification_metadata":{"test_list":["assert odd_Equivalent(\"011001\",6) == 3","assert odd_Equivalent(\"11011\",5) == 4","assert odd_Equivalent(\"1010\",4) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":109,"text":"Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times.","code":"def odd_Equivalent(s,n): \n count=0\n for i in range(0,n): \n if (s[i] == '1'): \n count = count + 1\n return count","test_list":["assert odd_Equivalent(\"011001\",6) == 3","assert odd_Equivalent(\"11011\",5) == 4","assert odd_Equivalent(\"1010\",4) == 2"],"test_imports":[]}} {"problem_id":"mbpp_test_00111","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the common elements in given nested lists.\n\nTests:\nassert set(common_in_nested_lists([[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]))==set([18, 12])\nassert set(common_in_nested_lists([[12, 5, 23, 25, 45], [7, 11, 5, 23, 28], [1, 5, 8, 18, 23, 16]]))==set([5,23])\nassert set(common_in_nested_lists([[2, 3,4, 1], [4, 5], [6,4, 8],[4, 5], [6, 8,4]]))==set([4])","canonical_answer":"def common_in_nested_lists(nestedlist):\n result = list(set.intersection(*map(set, nestedlist)))\n return result","verification_metadata":{"test_list":["assert set(common_in_nested_lists([[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]))==set([18, 12])","assert set(common_in_nested_lists([[12, 5, 23, 25, 45], [7, 11, 5, 23, 28], [1, 5, 8, 18, 23, 16]]))==set([5,23])","assert set(common_in_nested_lists([[2, 3,4, 1], [4, 5], [6,4, 8],[4, 5], [6, 8,4]]))==set([4])"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":111,"text":"Write a function to find the common elements in given nested lists.","code":"def common_in_nested_lists(nestedlist):\n result = list(set.intersection(*map(set, nestedlist)))\n return result","test_list":["assert set(common_in_nested_lists([[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]))==set([18, 12])","assert set(common_in_nested_lists([[12, 5, 23, 25, 45], [7, 11, 5, 23, 28], [1, 5, 8, 18, 23, 16]]))==set([5,23])","assert set(common_in_nested_lists([[2, 3,4, 1], [4, 5], [6,4, 8],[4, 5], [6, 8,4]]))==set([4])"],"test_imports":[]}} {"problem_id":"mbpp_test_00113","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if a string represents an integer or not.\n\nTests:\nassert check_integer(\"python\")==False\nassert check_integer(\"1\")==True\nassert check_integer(\"12345\")==True","canonical_answer":"def check_integer(text):\n text = text.strip()\n if len(text) < 1:\n return None\n else:\n if all(text[i] in \"0123456789\" for i in range(len(text))):\n return True\n elif (text[0] in \"+-\") and \\\n all(text[i] in \"0123456789\" for i in range(1,len(text))):\n return True\n else:\n return False","verification_metadata":{"test_list":["assert check_integer(\"python\")==False","assert check_integer(\"1\")==True","assert check_integer(\"12345\")==True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":113,"text":"Write a function to check if a string represents an integer or not.","code":"def check_integer(text):\n text = text.strip()\n if len(text) < 1:\n return None\n else:\n if all(text[i] in \"0123456789\" for i in range(len(text))):\n return True\n elif (text[0] in \"+-\") and \\\n all(text[i] in \"0123456789\" for i in range(1,len(text))):\n return True\n else:\n return False","test_list":["assert check_integer(\"python\")==False","assert check_integer(\"1\")==True","assert check_integer(\"12345\")==True"],"test_imports":[]}} {"problem_id":"mbpp_test_00115","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether all dictionaries in a list are empty or not.\n\nTests:\nassert empty_dit([{},{},{}])==True\nassert empty_dit([{1,2},{},{}])==False\nassert empty_dit({})==True","canonical_answer":"def empty_dit(list1):\n empty_dit=all(not d for d in list1)\n return empty_dit","verification_metadata":{"test_list":["assert empty_dit([{},{},{}])==True","assert empty_dit([{1,2},{},{}])==False","assert empty_dit({})==True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":115,"text":"Write a function to check whether all dictionaries in a list are empty or not.","code":"def empty_dit(list1):\n empty_dit=all(not d for d in list1)\n return empty_dit","test_list":["assert empty_dit([{},{},{}])==True","assert empty_dit([{1,2},{},{}])==False","assert empty_dit({})==True"],"test_imports":[]}} {"problem_id":"mbpp_test_00116","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert a given tuple of positive integers into a single integer.\n\nTests:\nassert tuple_to_int((1,2,3))==123\nassert tuple_to_int((4,5,6))==456\nassert tuple_to_int((5,6,7))==567","canonical_answer":"def tuple_to_int(nums):\n result = int(''.join(map(str,nums)))\n return result","verification_metadata":{"test_list":["assert tuple_to_int((1,2,3))==123","assert tuple_to_int((4,5,6))==456","assert tuple_to_int((5,6,7))==567"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":116,"text":"Write a function to convert a given tuple of positive integers into a single integer.","code":"def tuple_to_int(nums):\n result = int(''.join(map(str,nums)))\n return result","test_list":["assert tuple_to_int((1,2,3))==123","assert tuple_to_int((4,5,6))==456","assert tuple_to_int((5,6,7))==567"],"test_imports":[]}} {"problem_id":"mbpp_test_00117","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert all possible convertible elements in a list of lists to floats.\n\nTests:\nassert list_to_float( [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ) == [(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]\nassert list_to_float( [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ) == [(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]\nassert list_to_float( [(\"6\", \"78\"), (\"5\", \"26.45\"), (\"1.33\", \"4\"), (\"82\", \"13\")] ) == [(6.0, 78.0), (5.0, 26.45), (1.33, 4.0), (82.0, 13.0)]","canonical_answer":"def list_to_float(test_list):\n res = []\n for tup in test_list:\n temp = []\n for ele in tup:\n if ele.isalpha():\n temp.append(ele)\n else:\n temp.append(float(ele))\n res.append((temp[0],temp[1])) \n return res","verification_metadata":{"test_list":["assert list_to_float( [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ) == [(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]","assert list_to_float( [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ) == [(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]","assert list_to_float( [(\"6\", \"78\"), (\"5\", \"26.45\"), (\"1.33\", \"4\"), (\"82\", \"13\")] ) == [(6.0, 78.0), (5.0, 26.45), (1.33, 4.0), (82.0, 13.0)]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":117,"text":"Write a function to convert all possible convertible elements in a list of lists to floats.","code":"def list_to_float(test_list):\n res = []\n for tup in test_list:\n temp = []\n for ele in tup:\n if ele.isalpha():\n temp.append(ele)\n else:\n temp.append(float(ele))\n res.append((temp[0],temp[1])) \n return res","test_list":["assert list_to_float( [(\"3\", \"4\"), (\"1\", \"26.45\"), (\"7.32\", \"8\"), (\"4\", \"8\")] ) == [(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]","assert list_to_float( [(\"4\", \"4\"), (\"2\", \"27\"), (\"4.12\", \"9\"), (\"7\", \"11\")] ) == [(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]","assert list_to_float( [(\"6\", \"78\"), (\"5\", \"26.45\"), (\"1.33\", \"4\"), (\"82\", \"13\")] ) == [(6.0, 78.0), (5.0, 26.45), (1.33, 4.0), (82.0, 13.0)]"],"test_imports":[]}} {"problem_id":"mbpp_test_00118","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert a string to a list of strings split on the space character.\n\nTests:\nassert string_to_list(\"python programming\")==['python','programming']\nassert string_to_list(\"lists tuples strings\")==['lists','tuples','strings']\nassert string_to_list(\"write a program\")==['write','a','program']","canonical_answer":"def string_to_list(string): \n lst = list(string.split(\" \")) \n return lst","verification_metadata":{"test_list":["assert string_to_list(\"python programming\")==['python','programming']","assert string_to_list(\"lists tuples strings\")==['lists','tuples','strings']","assert string_to_list(\"write a program\")==['write','a','program']"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":118,"text":"Write a function to convert a string to a list of strings split on the space character.","code":"def string_to_list(string): \n lst = list(string.split(\" \")) \n return lst","test_list":["assert string_to_list(\"python programming\")==['python','programming']","assert string_to_list(\"lists tuples strings\")==['lists','tuples','strings']","assert string_to_list(\"write a program\")==['write','a','program']"],"test_imports":[]}} {"problem_id":"mbpp_test_00119","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the element that appears only once in a sorted array.\n\nTests:\nassert search([1,1,2,2,3]) == 3\nassert search([1,1,3,3,4,4,5,5,7,7,8]) == 8\nassert search([1,2,2,3,3,4,4]) == 1","canonical_answer":"def search(arr):\n n = len(arr)\n XOR = 0\n for i in range(n) :\n XOR = XOR ^ arr[i]\n return (XOR)","verification_metadata":{"test_list":["assert search([1,1,2,2,3]) == 3","assert search([1,1,3,3,4,4,5,5,7,7,8]) == 8","assert search([1,2,2,3,3,4,4]) == 1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":119,"text":"Write a python function to find the element that appears only once in a sorted array.","code":"def search(arr):\n n = len(arr)\n XOR = 0\n for i in range(n) :\n XOR = XOR ^ arr[i]\n return (XOR)","test_list":["assert search([1,1,2,2,3]) == 3","assert search([1,1,3,3,4,4,5,5,7,7,8]) == 8","assert search([1,2,2,3,3,4,4]) == 1"],"test_imports":[]}} {"problem_id":"mbpp_test_00120","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the maximum absolute product between numbers in pairs of tuples within a given list.\n\nTests:\nassert max_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==36\nassert max_product_tuple([(10,20), (15,2), (5,10)] )==200\nassert max_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==484","canonical_answer":"def max_product_tuple(list1):\n result_max = max([abs(x * y) for x, y in list1] )\n return result_max","verification_metadata":{"test_list":["assert max_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==36","assert max_product_tuple([(10,20), (15,2), (5,10)] )==200","assert max_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==484"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":120,"text":"Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list.","code":"def max_product_tuple(list1):\n result_max = max([abs(x * y) for x, y in list1] )\n return result_max","test_list":["assert max_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==36","assert max_product_tuple([(10,20), (15,2), (5,10)] )==200","assert max_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==484"],"test_imports":[]}} {"problem_id":"mbpp_test_00123","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sum all amicable numbers from 1 to a specified number.\n\nTests:\nassert amicable_numbers_sum(999)==504\nassert amicable_numbers_sum(9999)==31626\nassert amicable_numbers_sum(99)==0","canonical_answer":"def amicable_numbers_sum(limit):\n if not isinstance(limit, int):\n return \"Input is not an integer!\"\n if limit < 1:\n return \"Input must be bigger than 0!\"\n amicables = set()\n for num in range(2, limit+1):\n if num in amicables:\n continue\n sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])\n sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])\n if num == sum_fact2 and num != sum_fact:\n amicables.add(num)\n amicables.add(sum_fact2)\n return sum(amicables)","verification_metadata":{"test_list":["assert amicable_numbers_sum(999)==504","assert amicable_numbers_sum(9999)==31626","assert amicable_numbers_sum(99)==0"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":123,"text":"Write a function to sum all amicable numbers from 1 to a specified number.","code":"def amicable_numbers_sum(limit):\n if not isinstance(limit, int):\n return \"Input is not an integer!\"\n if limit < 1:\n return \"Input must be bigger than 0!\"\n amicables = set()\n for num in range(2, limit+1):\n if num in amicables:\n continue\n sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])\n sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])\n if num == sum_fact2 and num != sum_fact:\n amicables.add(num)\n amicables.add(sum_fact2)\n return sum(amicables)","test_list":["assert amicable_numbers_sum(999)==504","assert amicable_numbers_sum(9999)==31626","assert amicable_numbers_sum(99)==0"],"test_imports":[]}} {"problem_id":"mbpp_test_00124","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to get the angle of a complex number.\n\nTests:\nassert math.isclose(angle_complex(0,1j), 1.5707963267948966, rel_tol=0.001)\nassert math.isclose(angle_complex(2,1j), 0.4636476090008061, rel_tol=0.001)\nassert math.isclose(angle_complex(0,2j), 1.5707963267948966, rel_tol=0.001)","canonical_answer":"import cmath\ndef angle_complex(a,b):\n cn=complex(a,b)\n angle=cmath.phase(a+b)\n return angle","verification_metadata":{"test_list":["assert math.isclose(angle_complex(0,1j), 1.5707963267948966, rel_tol=0.001)","assert math.isclose(angle_complex(2,1j), 0.4636476090008061, rel_tol=0.001)","assert math.isclose(angle_complex(0,2j), 1.5707963267948966, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":124,"text":"Write a function to get the angle of a complex number.","code":"import cmath\ndef angle_complex(a,b):\n cn=complex(a,b)\n angle=cmath.phase(a+b)\n return angle","test_list":["assert math.isclose(angle_complex(0,1j), 1.5707963267948966, rel_tol=0.001)","assert math.isclose(angle_complex(2,1j), 0.4636476090008061, rel_tol=0.001)","assert math.isclose(angle_complex(0,2j), 1.5707963267948966, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00125","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.\n\nTests:\nassert find_length(\"11000010001\") == 6\nassert find_length(\"10111\") == 1\nassert find_length(\"11011101100101\") == 2","canonical_answer":"def find_length(string): \n\tn = len(string)\n\tcurrent_sum = 0\n\tmax_sum = 0\n\tfor i in range(n): \n\t\tcurrent_sum += (1 if string[i] == '0' else -1) \n\t\tif current_sum < 0: \n\t\t\tcurrent_sum = 0\n\t\tmax_sum = max(current_sum, max_sum) \n\treturn max_sum if max_sum else 0","verification_metadata":{"test_list":["assert find_length(\"11000010001\") == 6","assert find_length(\"10111\") == 1","assert find_length(\"11011101100101\") == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":125,"text":"Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.","code":"def find_length(string): \n\tn = len(string)\n\tcurrent_sum = 0\n\tmax_sum = 0\n\tfor i in range(n): \n\t\tcurrent_sum += (1 if string[i] == '0' else -1) \n\t\tif current_sum < 0: \n\t\t\tcurrent_sum = 0\n\t\tmax_sum = max(current_sum, max_sum) \n\treturn max_sum if max_sum else 0","test_list":["assert find_length(\"11000010001\") == 6","assert find_length(\"10111\") == 1","assert find_length(\"11011101100101\") == 2"],"test_imports":[]}} {"problem_id":"mbpp_test_00126","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of common divisors of two given numbers.\n\nTests:\nassert sum(10,15) == 6\nassert sum(100,150) == 93\nassert sum(4,6) == 3","canonical_answer":"def sum(a,b): \n sum = 0\n for i in range (1,min(a,b)): \n if (a % i == 0 and b % i == 0): \n sum += i \n return sum","verification_metadata":{"test_list":["assert sum(10,15) == 6","assert sum(100,150) == 93","assert sum(4,6) == 3"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":126,"text":"Write a python function to find the sum of common divisors of two given numbers.","code":"def sum(a,b): \n sum = 0\n for i in range (1,min(a,b)): \n if (a % i == 0 and b % i == 0): \n sum += i \n return sum","test_list":["assert sum(10,15) == 6","assert sum(100,150) == 93","assert sum(4,6) == 3"],"test_imports":[]}} {"problem_id":"mbpp_test_00127","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to multiply two integers.\n\nTests:\nassert multiply_int(10,20)==200\nassert multiply_int(5,10)==50\nassert multiply_int(4,8)==32","canonical_answer":"def multiply_int(x, y):\n if y < 0:\n return -multiply_int(x, -y)\n elif y == 0:\n return 0\n elif y == 1:\n return x\n else:\n return x + multiply_int(x, y - 1)","verification_metadata":{"test_list":["assert multiply_int(10,20)==200","assert multiply_int(5,10)==50","assert multiply_int(4,8)==32"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":127,"text":"Write a function to multiply two integers.","code":"def multiply_int(x, y):\n if y < 0:\n return -multiply_int(x, -y)\n elif y == 0:\n return 0\n elif y == 1:\n return x\n else:\n return x + multiply_int(x, y - 1)","test_list":["assert multiply_int(10,20)==200","assert multiply_int(5,10)==50","assert multiply_int(4,8)==32"],"test_imports":[]}} {"problem_id":"mbpp_test_00128","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find words that are longer than n characters from a given list of words.\n\nTests:\nassert long_words(3,\"python is a programming language\")==['python','programming','language']\nassert long_words(2,\"writing a program\")==['writing','program']\nassert long_words(5,\"sorting list\")==['sorting']","canonical_answer":"def long_words(n, str):\n word_len = []\n txt = str.split(\" \")\n for x in txt:\n if len(x) > n:\n word_len.append(x)\n return word_len","verification_metadata":{"test_list":["assert long_words(3,\"python is a programming language\")==['python','programming','language']","assert long_words(2,\"writing a program\")==['writing','program']","assert long_words(5,\"sorting list\")==['sorting']"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":128,"text":"Write a function to find words that are longer than n characters from a given list of words.","code":"def long_words(n, str):\n word_len = []\n txt = str.split(\" \")\n for x in txt:\n if len(x) > n:\n word_len.append(x)\n return word_len","test_list":["assert long_words(3,\"python is a programming language\")==['python','programming','language']","assert long_words(2,\"writing a program\")==['writing','program']","assert long_words(5,\"sorting list\")==['sorting']"],"test_imports":[]}} {"problem_id":"mbpp_test_00129","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to calculate whether the matrix is a magic square.\n\nTests:\nassert magic_square_test([[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]])==True\nassert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 8]])==True\nassert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 7]])==False","canonical_answer":"def magic_square_test(my_matrix):\n iSize = len(my_matrix[0])\n sum_list = []\n sum_list.extend([sum (lines) for lines in my_matrix]) \n for col in range(iSize):\n sum_list.append(sum(row[col] for row in my_matrix))\n result1 = 0\n for i in range(0,iSize):\n result1 +=my_matrix[i][i]\n sum_list.append(result1) \n result2 = 0\n for i in range(iSize-1,-1,-1):\n result2 +=my_matrix[i][i]\n sum_list.append(result2)\n if len(set(sum_list))>1:\n return False\n return True","verification_metadata":{"test_list":["assert magic_square_test([[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]])==True","assert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 8]])==True","assert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 7]])==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":129,"text":"Write a function to calculate whether the matrix is a magic square.","code":"def magic_square_test(my_matrix):\n iSize = len(my_matrix[0])\n sum_list = []\n sum_list.extend([sum (lines) for lines in my_matrix]) \n for col in range(iSize):\n sum_list.append(sum(row[col] for row in my_matrix))\n result1 = 0\n for i in range(0,iSize):\n result1 +=my_matrix[i][i]\n sum_list.append(result1) \n result2 = 0\n for i in range(iSize-1,-1,-1):\n result2 +=my_matrix[i][i]\n sum_list.append(result2)\n if len(set(sum_list))>1:\n return False\n return True","test_list":["assert magic_square_test([[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]])==True","assert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 8]])==True","assert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 7]])==False"],"test_imports":[]}} {"problem_id":"mbpp_test_00130","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the item with maximum frequency in a given list.\n\nTests:\nassert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2])==2\nassert max_occurrences([2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18])==8\nassert max_occurrences([10,20,20,30,40,90,80,50,30,20,50,10])==20","canonical_answer":"from collections import defaultdict\ndef max_occurrences(nums):\n dict = defaultdict(int)\n for i in nums:\n dict[i] += 1\n result = max(dict.items(), key=lambda x: x[1]) \n return result[0]","verification_metadata":{"test_list":["assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2])==2","assert max_occurrences([2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18])==8","assert max_occurrences([10,20,20,30,40,90,80,50,30,20,50,10])==20"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":130,"text":"Write a function to find the item with maximum frequency in a given list.","code":"from collections import defaultdict\ndef max_occurrences(nums):\n dict = defaultdict(int)\n for i in nums:\n dict[i] += 1\n result = max(dict.items(), key=lambda x: x[1]) \n return result[0]","test_list":["assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2])==2","assert max_occurrences([2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18])==8","assert max_occurrences([10,20,20,30,40,90,80,50,30,20,50,10])==20"],"test_imports":[]}} {"problem_id":"mbpp_test_00131","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to reverse only the vowels of a given string (where y is not a vowel).\n\nTests:\nassert reverse_vowels(\"Python\") == \"Python\"\nassert reverse_vowels(\"USA\") == \"ASU\"\nassert reverse_vowels(\"ab\") == \"ab\"","canonical_answer":"def reverse_vowels(str1):\n\tvowels = \"\"\n\tfor char in str1:\n\t\tif char in \"aeiouAEIOU\":\n\t\t\tvowels += char\n\tresult_string = \"\"\n\tfor char in str1:\n\t\tif char in \"aeiouAEIOU\":\n\t\t\tresult_string += vowels[-1]\n\t\t\tvowels = vowels[:-1]\n\t\telse:\n\t\t\tresult_string += char\n\treturn result_string","verification_metadata":{"test_list":["assert reverse_vowels(\"Python\") == \"Python\"","assert reverse_vowels(\"USA\") == \"ASU\"","assert reverse_vowels(\"ab\") == \"ab\""],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":131,"text":"Write a python function to reverse only the vowels of a given string (where y is not a vowel).","code":"def reverse_vowels(str1):\n\tvowels = \"\"\n\tfor char in str1:\n\t\tif char in \"aeiouAEIOU\":\n\t\t\tvowels += char\n\tresult_string = \"\"\n\tfor char in str1:\n\t\tif char in \"aeiouAEIOU\":\n\t\t\tresult_string += vowels[-1]\n\t\t\tvowels = vowels[:-1]\n\t\telse:\n\t\t\tresult_string += char\n\treturn result_string","test_list":["assert reverse_vowels(\"Python\") == \"Python\"","assert reverse_vowels(\"USA\") == \"ASU\"","assert reverse_vowels(\"ab\") == \"ab\""],"test_imports":[]}} {"problem_id":"mbpp_test_00132","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert a tuple to a string.\n\nTests:\nassert tup_string(('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's'))==(\"exercises\")\nassert tup_string(('p','y','t','h','o','n'))==(\"python\")\nassert tup_string(('p','r','o','g','r','a','m'))==(\"program\")","canonical_answer":"def tup_string(tup1):\n str = ''.join(tup1)\n return str","verification_metadata":{"test_list":["assert tup_string(('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's'))==(\"exercises\")","assert tup_string(('p','y','t','h','o','n'))==(\"python\")","assert tup_string(('p','r','o','g','r','a','m'))==(\"program\")"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":132,"text":"Write a function to convert a tuple to a string.","code":"def tup_string(tup1):\n str = ''.join(tup1)\n return str","test_list":["assert tup_string(('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's'))==(\"exercises\")","assert tup_string(('p','y','t','h','o','n'))==(\"python\")","assert tup_string(('p','r','o','g','r','a','m'))==(\"program\")"],"test_imports":[]}} {"problem_id":"mbpp_test_00133","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to calculate the sum of the negative numbers of a given list of numbers.\n\nTests:\nassert sum_negativenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==-32\nassert sum_negativenum([10,15,-14,13,-18,12,-20])==-52\nassert sum_negativenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==-894","canonical_answer":"def sum_negativenum(nums):\n sum_negativenum = list(filter(lambda nums:nums<0,nums))\n return sum(sum_negativenum)","verification_metadata":{"test_list":["assert sum_negativenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==-32","assert sum_negativenum([10,15,-14,13,-18,12,-20])==-52","assert sum_negativenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==-894"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":133,"text":"Write a function to calculate the sum of the negative numbers of a given list of numbers.","code":"def sum_negativenum(nums):\n sum_negativenum = list(filter(lambda nums:nums<0,nums))\n return sum(sum_negativenum)","test_list":["assert sum_negativenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==-32","assert sum_negativenum([10,15,-14,13,-18,12,-20])==-52","assert sum_negativenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==-894"],"test_imports":[]}} {"problem_id":"mbpp_test_00135","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the nth hexagonal number.\n\nTests:\nassert hexagonal_num(10) == 190\nassert hexagonal_num(5) == 45\nassert hexagonal_num(7) == 91","canonical_answer":"def hexagonal_num(n): \n\treturn n*(2*n - 1)","verification_metadata":{"test_list":["assert hexagonal_num(10) == 190","assert hexagonal_num(5) == 45","assert hexagonal_num(7) == 91"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":135,"text":"Write a function to find the nth hexagonal number.","code":"def hexagonal_num(n): \n\treturn n*(2*n - 1)","test_list":["assert hexagonal_num(10) == 190","assert hexagonal_num(5) == 45","assert hexagonal_num(7) == 91"],"test_imports":[]}} {"problem_id":"mbpp_test_00137","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the ratio of zeroes to non-zeroes in an array of integers.\n\nTests:\nassert math.isclose(zero_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]), 0.181818, rel_tol=0.001)\nassert math.isclose(zero_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]), 0.00, rel_tol=0.001)\nassert math.isclose(zero_count([2, 4, -6, -9, 11, -12, 14, -5, 17]), 0.00, rel_tol=0.001)","canonical_answer":"from array import array\ndef zero_count(nums):\n n = len(nums)\n n1 = 0\n for x in nums:\n if x == 0:\n n1 += 1\n else:\n None\n return n1/(n-n1)","verification_metadata":{"test_list":["assert math.isclose(zero_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]), 0.181818, rel_tol=0.001)","assert math.isclose(zero_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]), 0.00, rel_tol=0.001)","assert math.isclose(zero_count([2, 4, -6, -9, 11, -12, 14, -5, 17]), 0.00, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":137,"text":"Write a function to find the ratio of zeroes to non-zeroes in an array of integers.","code":"from array import array\ndef zero_count(nums):\n n = len(nums)\n n1 = 0\n for x in nums:\n if x == 0:\n n1 += 1\n else:\n None\n return n1/(n-n1)","test_list":["assert math.isclose(zero_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]), 0.181818, rel_tol=0.001)","assert math.isclose(zero_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]), 0.00, rel_tol=0.001)","assert math.isclose(zero_count([2, 4, -6, -9, 11, -12, 14, -5, 17]), 0.00, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00138","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.\n\nTests:\nassert is_Sum_Of_Powers_Of_Two(10) == True\nassert is_Sum_Of_Powers_Of_Two(7) == False\nassert is_Sum_Of_Powers_Of_Two(14) == True","canonical_answer":"def is_Sum_Of_Powers_Of_Two(n): \n if (n % 2 == 1): \n return False\n else: \n return True","verification_metadata":{"test_list":["assert is_Sum_Of_Powers_Of_Two(10) == True","assert is_Sum_Of_Powers_Of_Two(7) == False","assert is_Sum_Of_Powers_Of_Two(14) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":138,"text":"Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.","code":"def is_Sum_Of_Powers_Of_Two(n): \n if (n % 2 == 1): \n return False\n else: \n return True","test_list":["assert is_Sum_Of_Powers_Of_Two(10) == True","assert is_Sum_Of_Powers_Of_Two(7) == False","assert is_Sum_Of_Powers_Of_Two(14) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00139","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the circumference of a circle.\n\nTests:\nassert math.isclose(circle_circumference(10), 62.830000000000005, rel_tol=0.001)\nassert math.isclose(circle_circumference(5), 31.415000000000003, rel_tol=0.001)\nassert math.isclose(circle_circumference(4), 25.132, rel_tol=0.001)","canonical_answer":"def circle_circumference(r):\n perimeter=2*3.1415*r\n return perimeter","verification_metadata":{"test_list":["assert math.isclose(circle_circumference(10), 62.830000000000005, rel_tol=0.001)","assert math.isclose(circle_circumference(5), 31.415000000000003, rel_tol=0.001)","assert math.isclose(circle_circumference(4), 25.132, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":139,"text":"Write a function to find the circumference of a circle.","code":"def circle_circumference(r):\n perimeter=2*3.1415*r\n return perimeter","test_list":["assert math.isclose(circle_circumference(10), 62.830000000000005, rel_tol=0.001)","assert math.isclose(circle_circumference(5), 31.415000000000003, rel_tol=0.001)","assert math.isclose(circle_circumference(4), 25.132, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00140","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to flatten the list of lists into a single set of numbers.\n\nTests:\nassert set(extract_singly([(3, 4, 5), (4, 5, 7), (1, 4)])) == set([3, 4, 5, 7, 1])\nassert set(extract_singly([(1, 2, 3), (4, 2, 3), (7, 8)])) == set([1, 2, 3, 4, 7, 8])\nassert set(extract_singly([(7, 8, 9), (10, 11, 12), (10, 11)])) == set([7, 8, 9, 10, 11, 12])","canonical_answer":"def extract_singly(test_list):\n res = []\n temp = set()\n for inner in test_list:\n for ele in inner:\n if not ele in temp:\n temp.add(ele)\n res.append(ele)\n return (res)","verification_metadata":{"test_list":["assert set(extract_singly([(3, 4, 5), (4, 5, 7), (1, 4)])) == set([3, 4, 5, 7, 1])","assert set(extract_singly([(1, 2, 3), (4, 2, 3), (7, 8)])) == set([1, 2, 3, 4, 7, 8])","assert set(extract_singly([(7, 8, 9), (10, 11, 12), (10, 11)])) == set([7, 8, 9, 10, 11, 12])"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":140,"text":"Write a function to flatten the list of lists into a single set of numbers.","code":"def extract_singly(test_list):\n res = []\n temp = set()\n for inner in test_list:\n for ele in inner:\n if not ele in temp:\n temp.add(ele)\n res.append(ele)\n return (res)","test_list":["assert set(extract_singly([(3, 4, 5), (4, 5, 7), (1, 4)])) == set([3, 4, 5, 7, 1])","assert set(extract_singly([(1, 2, 3), (4, 2, 3), (7, 8)])) == set([1, 2, 3, 4, 7, 8])","assert set(extract_singly([(7, 8, 9), (10, 11, 12), (10, 11)])) == set([7, 8, 9, 10, 11, 12])"],"test_imports":[]}} {"problem_id":"mbpp_test_00141","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sort a list of elements.\n\nTests:\nassert pancake_sort([15, 79, 25, 38, 69]) == [15, 25, 38, 69, 79]\nassert pancake_sort([98, 12, 54, 36, 85]) == [12, 36, 54, 85, 98]\nassert pancake_sort([41, 42, 32, 12, 23]) == [12, 23, 32, 41, 42]","canonical_answer":"def pancake_sort(nums):\n arr_len = len(nums)\n while arr_len > 1:\n mi = nums.index(max(nums[0:arr_len]))\n nums = nums[mi::-1] + nums[mi+1:len(nums)]\n nums = nums[arr_len-1::-1] + nums[arr_len:len(nums)]\n arr_len -= 1\n return nums","verification_metadata":{"test_list":["assert pancake_sort([15, 79, 25, 38, 69]) == [15, 25, 38, 69, 79]","assert pancake_sort([98, 12, 54, 36, 85]) == [12, 36, 54, 85, 98]","assert pancake_sort([41, 42, 32, 12, 23]) == [12, 23, 32, 41, 42]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":141,"text":"Write a function to sort a list of elements.","code":"def pancake_sort(nums):\n arr_len = len(nums)\n while arr_len > 1:\n mi = nums.index(max(nums[0:arr_len]))\n nums = nums[mi::-1] + nums[mi+1:len(nums)]\n nums = nums[arr_len-1::-1] + nums[arr_len:len(nums)]\n arr_len -= 1\n return nums","test_list":["assert pancake_sort([15, 79, 25, 38, 69]) == [15, 25, 38, 69, 79]","assert pancake_sort([98, 12, 54, 36, 85]) == [12, 36, 54, 85, 98]","assert pancake_sort([41, 42, 32, 12, 23]) == [12, 23, 32, 41, 42]"],"test_imports":[]}} {"problem_id":"mbpp_test_00142","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to count number items that are identical in the same position of three given lists.\n\nTests:\nassert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9])==3\nassert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==4\nassert count_samepair([1,2,3,4,2,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==5","canonical_answer":"def count_samepair(list1,list2,list3):\n result = sum(m == n == o for m, n, o in zip(list1,list2,list3))\n return result","verification_metadata":{"test_list":["assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9])==3","assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==4","assert count_samepair([1,2,3,4,2,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==5"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":142,"text":"Write a function to count number items that are identical in the same position of three given lists.","code":"def count_samepair(list1,list2,list3):\n result = sum(m == n == o for m, n, o in zip(list1,list2,list3))\n return result","test_list":["assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9])==3","assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==4","assert count_samepair([1,2,3,4,2,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==5"],"test_imports":[]}} {"problem_id":"mbpp_test_00143","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find number of lists present in the given tuple.\n\nTests:\nassert find_lists(([1, 2, 3, 4], [5, 6, 7, 8])) == 2\nassert find_lists(([1, 2], [3, 4], [5, 6])) == 3\nassert find_lists(([9, 8, 7, 6, 5, 4, 3, 2, 1])) == 1","canonical_answer":"def find_lists(Input): \n\tif isinstance(Input, list): \n\t\treturn 1\n\telse: \n\t\treturn len(Input)","verification_metadata":{"test_list":["assert find_lists(([1, 2, 3, 4], [5, 6, 7, 8])) == 2","assert find_lists(([1, 2], [3, 4], [5, 6])) == 3","assert find_lists(([9, 8, 7, 6, 5, 4, 3, 2, 1])) == 1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":143,"text":"Write a function to find number of lists present in the given tuple.","code":"def find_lists(Input): \n\tif isinstance(Input, list): \n\t\treturn 1\n\telse: \n\t\treturn len(Input)","test_list":["assert find_lists(([1, 2, 3, 4], [5, 6, 7, 8])) == 2","assert find_lists(([1, 2], [3, 4], [5, 6])) == 3","assert find_lists(([9, 8, 7, 6, 5, 4, 3, 2, 1])) == 1"],"test_imports":[]}} {"problem_id":"mbpp_test_00145","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the maximum difference between any two elements in a given array.\n\nTests:\nassert max_Abs_Diff((2,1,5,3)) == 4\nassert max_Abs_Diff((9,3,2,5,1)) == 8\nassert max_Abs_Diff((3,2,1)) == 2","canonical_answer":"def max_Abs_Diff(arr): \n n = len(arr)\n minEle = arr[0] \n maxEle = arr[0] \n for i in range(1, n): \n minEle = min(minEle,arr[i]) \n maxEle = max(maxEle,arr[i]) \n return (maxEle - minEle)","verification_metadata":{"test_list":["assert max_Abs_Diff((2,1,5,3)) == 4","assert max_Abs_Diff((9,3,2,5,1)) == 8","assert max_Abs_Diff((3,2,1)) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":145,"text":"Write a python function to find the maximum difference between any two elements in a given array.","code":"def max_Abs_Diff(arr): \n n = len(arr)\n minEle = arr[0] \n maxEle = arr[0] \n for i in range(1, n): \n minEle = min(minEle,arr[i]) \n maxEle = max(maxEle,arr[i]) \n return (maxEle - minEle)","test_list":["assert max_Abs_Diff((2,1,5,3)) == 4","assert max_Abs_Diff((9,3,2,5,1)) == 8","assert max_Abs_Diff((3,2,1)) == 2"],"test_imports":[]}} {"problem_id":"mbpp_test_00160","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists.\n\nTests:\nassert find_solution(2, 3, 7) == (2, 1)\nassert find_solution(4, 2, 7) == None\nassert find_solution(1, 13, 17) == (4, 1)","canonical_answer":"def find_solution(a, b, n):\n\ti = 0\n\twhile i * a <= n:\n\t\tif (n - (i * a)) % b == 0: \n\t\t\treturn (i, (n - (i * a)) // b)\n\t\ti = i + 1\n\treturn None","verification_metadata":{"test_list":["assert find_solution(2, 3, 7) == (2, 1)","assert find_solution(4, 2, 7) == None","assert find_solution(1, 13, 17) == (4, 1)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":160,"text":"Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists.","code":"def find_solution(a, b, n):\n\ti = 0\n\twhile i * a <= n:\n\t\tif (n - (i * a)) % b == 0: \n\t\t\treturn (i, (n - (i * a)) // b)\n\t\ti = i + 1\n\treturn None","test_list":["assert find_solution(2, 3, 7) == (2, 1)","assert find_solution(4, 2, 7) == None","assert find_solution(1, 13, 17) == (4, 1)"],"test_imports":[]}} {"problem_id":"mbpp_test_00161","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove all elements from a given list present in another list.\n\nTests:\nassert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8]) == [1, 3, 5, 7, 9, 10]\nassert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7]) == [2, 4, 6, 8, 9, 10]\nassert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [5, 7]) == [1, 2, 3, 4, 6, 8, 9, 10]","canonical_answer":"def remove_elements(list1, list2):\n result = [x for x in list1 if x not in list2]\n return result","verification_metadata":{"test_list":["assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8]) == [1, 3, 5, 7, 9, 10]","assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7]) == [2, 4, 6, 8, 9, 10]","assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [5, 7]) == [1, 2, 3, 4, 6, 8, 9, 10]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":161,"text":"Write a function to remove all elements from a given list present in another list.","code":"def remove_elements(list1, list2):\n result = [x for x in list1 if x not in list2]\n return result","test_list":["assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8]) == [1, 3, 5, 7, 9, 10]","assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7]) == [2, 4, 6, 8, 9, 10]","assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [5, 7]) == [1, 2, 3, 4, 6, 8, 9, 10]"],"test_imports":[]}} {"problem_id":"mbpp_test_00162","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0).\n\nTests:\nassert sum_series(6) == 12\nassert sum_series(10) == 30\nassert sum_series(9) == 25","canonical_answer":"def sum_series(n):\n if n < 1:\n return 0\n else:\n return n + sum_series(n - 2)","verification_metadata":{"test_list":["assert sum_series(6) == 12","assert sum_series(10) == 30","assert sum_series(9) == 25"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":162,"text":"Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0).","code":"def sum_series(n):\n if n < 1:\n return 0\n else:\n return n + sum_series(n - 2)","test_list":["assert sum_series(6) == 12","assert sum_series(10) == 30","assert sum_series(9) == 25"],"test_imports":[]}} {"problem_id":"mbpp_test_00163","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to calculate the area of a regular polygon given the length and number of its sides.\n\nTests:\nassert math.isclose(area_polygon(4, 20), 400., rel_tol=0.001)\nassert math.isclose(area_polygon(10, 15), 1731.197, rel_tol=0.001)\nassert math.isclose(area_polygon(9, 7), 302.909, rel_tol=0.001)","canonical_answer":"from math import tan, pi\ndef area_polygon(s, l):\n area = s * (l ** 2) / (4 * tan(pi / s))\n return area","verification_metadata":{"test_list":["assert math.isclose(area_polygon(4, 20), 400., rel_tol=0.001)","assert math.isclose(area_polygon(10, 15), 1731.197, rel_tol=0.001)","assert math.isclose(area_polygon(9, 7), 302.909, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":163,"text":"Write a function to calculate the area of a regular polygon given the length and number of its sides.","code":"from math import tan, pi\ndef area_polygon(s, l):\n area = s * (l ** 2) / (4 * tan(pi / s))\n return area","test_list":["assert math.isclose(area_polygon(4, 20), 400., rel_tol=0.001)","assert math.isclose(area_polygon(10, 15), 1731.197, rel_tol=0.001)","assert math.isclose(area_polygon(9, 7), 302.909, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00164","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to determine if the sum of the divisors of two integers are the same.\n\nTests:\nassert are_equivalent(36, 57) == False\nassert are_equivalent(2, 4) == False\nassert are_equivalent(23, 47) == True","canonical_answer":"import math \ndef div_sum(n): \n total = 1\n i = 2\n\n while i * i <= n:\n if (n % i == 0):\n total = (total + i + math.floor(n / i))\n i += 1\n\n return total\n\ndef are_equivalent(num1, num2): \n return div_sum(num1) == div_sum(num2);","verification_metadata":{"test_list":["assert are_equivalent(36, 57) == False","assert are_equivalent(2, 4) == False","assert are_equivalent(23, 47) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":164,"text":"Write a function to determine if the sum of the divisors of two integers are the same.","code":"import math \ndef div_sum(n): \n total = 1\n i = 2\n\n while i * i <= n:\n if (n % i == 0):\n total = (total + i + math.floor(n / i))\n i += 1\n\n return total\n\ndef are_equivalent(num1, num2): \n return div_sum(num1) == div_sum(num2);","test_list":["assert are_equivalent(36, 57) == False","assert are_equivalent(2, 4) == False","assert are_equivalent(23, 47) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00165","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive).\n\nTests:\nassert count_char_position(\"xbcefg\") == 2\nassert count_char_position(\"ABcED\") == 3\nassert count_char_position(\"AbgdeF\") == 5","canonical_answer":"def count_char_position(str1): \n count_chars = 0\n for i in range(len(str1)):\n if ((i == ord(str1[i]) - ord('A')) or \n (i == ord(str1[i]) - ord('a'))): \n count_chars += 1\n return count_chars","verification_metadata":{"test_list":["assert count_char_position(\"xbcefg\") == 2","assert count_char_position(\"ABcED\") == 3","assert count_char_position(\"AbgdeF\") == 5"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":165,"text":"Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive).","code":"def count_char_position(str1): \n count_chars = 0\n for i in range(len(str1)):\n if ((i == ord(str1[i]) - ord('A')) or \n (i == ord(str1[i]) - ord('a'))): \n count_chars += 1\n return count_chars","test_list":["assert count_char_position(\"xbcefg\") == 2","assert count_char_position(\"ABcED\") == 3","assert count_char_position(\"AbgdeF\") == 5"],"test_imports":[]}} {"problem_id":"mbpp_test_00166","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that counts the number of pairs of integers in a list that xor to an even number.\n\nTests:\nassert find_even_pair([5, 4, 7, 2, 1]) == 4\nassert find_even_pair([7, 2, 8, 1, 0, 5, 11]) == 9\nassert find_even_pair([1, 2, 3]) == 1","canonical_answer":"def find_even_pair(A): \n count = 0\n for i in range(0, len(A)): \n for j in range(i+1, len(A)): \n if ((A[i] ^ A[j]) % 2 == 0): \n count += 1\n\n return count","verification_metadata":{"test_list":["assert find_even_pair([5, 4, 7, 2, 1]) == 4","assert find_even_pair([7, 2, 8, 1, 0, 5, 11]) == 9","assert find_even_pair([1, 2, 3]) == 1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":166,"text":"Write a function that counts the number of pairs of integers in a list that xor to an even number.","code":"def find_even_pair(A): \n count = 0\n for i in range(0, len(A)): \n for j in range(i+1, len(A)): \n if ((A[i] ^ A[j]) % 2 == 0): \n count += 1\n\n return count","test_list":["assert find_even_pair([5, 4, 7, 2, 1]) == 4","assert find_even_pair([7, 2, 8, 1, 0, 5, 11]) == 9","assert find_even_pair([1, 2, 3]) == 1"],"test_imports":[]}} {"problem_id":"mbpp_test_00167","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the smallest power of 2 greater than or equal to n.\n\nTests:\nassert next_power_of_2(0) == 1\nassert next_power_of_2(5) == 8\nassert next_power_of_2(17) == 32","canonical_answer":"def next_power_of_2(n): \n if n and not n & (n - 1):\n return n\n\n count = 0\n while n != 0: \n n >>= 1\n count += 1\n\n return 1 << count;","verification_metadata":{"test_list":["assert next_power_of_2(0) == 1","assert next_power_of_2(5) == 8","assert next_power_of_2(17) == 32"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":167,"text":"Write a python function to find the smallest power of 2 greater than or equal to n.","code":"def next_power_of_2(n): \n if n and not n & (n - 1):\n return n\n\n count = 0\n while n != 0: \n n >>= 1\n count += 1\n\n return 1 << count;","test_list":["assert next_power_of_2(0) == 1","assert next_power_of_2(5) == 8","assert next_power_of_2(17) == 32"],"test_imports":[]}} {"problem_id":"mbpp_test_00168","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to count the number of occurrences of a number in a given list.\n\nTests:\nassert frequency([1,2,3], 4) == 0\nassert frequency([1,2,2,3,3,3,4], 3) == 3\nassert frequency([0,1,2,3,1,2], 1) == 2","canonical_answer":"def frequency(a,x): \n count = 0 \n for i in a: \n if i == x: \n count += 1\n\n return count","verification_metadata":{"test_list":["assert frequency([1,2,3], 4) == 0","assert frequency([1,2,2,3,3,3,4], 3) == 3","assert frequency([0,1,2,3,1,2], 1) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":168,"text":"Write a function to count the number of occurrences of a number in a given list.","code":"def frequency(a,x): \n count = 0 \n for i in a: \n if i == x: \n count += 1\n\n return count","test_list":["assert frequency([1,2,3], 4) == 0","assert frequency([1,2,2,3,3,3,4], 3) == 3","assert frequency([0,1,2,3,1,2], 1) == 2"],"test_imports":[]}} {"problem_id":"mbpp_test_00170","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the sum of numbers in a list within a range specified by two indices.\n\nTests:\nassert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 8, 10) == 29\nassert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 5, 7) == 16\nassert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 7, 10) == 38","canonical_answer":"def sum_range_list(list1, m, n): \n sum_range = 0 \n for i in range(m, n+1, 1): \n sum_range += list1[i] \n return sum_range","verification_metadata":{"test_list":["assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 8, 10) == 29","assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 5, 7) == 16","assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 7, 10) == 38"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":170,"text":"Write a function to find the sum of numbers in a list within a range specified by two indices.","code":"def sum_range_list(list1, m, n): \n sum_range = 0 \n for i in range(m, n+1, 1): \n sum_range += list1[i] \n return sum_range","test_list":["assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 8, 10) == 29","assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 5, 7) == 16","assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 7, 10) == 38"],"test_imports":[]}} {"problem_id":"mbpp_test_00171","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the perimeter of a regular pentagon from the length of its sides.\n\nTests:\nassert perimeter_pentagon(5) == 25\nassert perimeter_pentagon(10) == 50\nassert perimeter_pentagon(15) == 75","canonical_answer":"import math\ndef perimeter_pentagon(a):\n perimeter=(5*a)\n return perimeter","verification_metadata":{"test_list":["assert perimeter_pentagon(5) == 25","assert perimeter_pentagon(10) == 50","assert perimeter_pentagon(15) == 75"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":171,"text":"Write a function to find the perimeter of a regular pentagon from the length of its sides.","code":"import math\ndef perimeter_pentagon(a):\n perimeter=(5*a)\n return perimeter","test_list":["assert perimeter_pentagon(5) == 25","assert perimeter_pentagon(10) == 50","assert perimeter_pentagon(15) == 75"],"test_imports":[]}} {"problem_id":"mbpp_test_00172","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to count the number of occurence of the string 'std' in a given string.\n\nTests:\nassert count_occurance(\"letstdlenstdporstd\") == 3\nassert count_occurance(\"truststdsolensporsd\") == 1\nassert count_occurance(\"makestdsostdworthit\") == 2\nassert count_occurance(\"stds\") == 1\nassert count_occurance(\"\") == 0","canonical_answer":"def count_occurance(s):\n count = 0\n for i in range(len(s) - 2):\n if (s[i] == 's' and s[i+1] == 't' and s[i+2] == 'd'):\n count = count + 1\n return count","verification_metadata":{"test_list":["assert count_occurance(\"letstdlenstdporstd\") == 3","assert count_occurance(\"truststdsolensporsd\") == 1","assert count_occurance(\"makestdsostdworthit\") == 2","assert count_occurance(\"stds\") == 1","assert count_occurance(\"\") == 0"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":172,"text":"Write a function to count the number of occurence of the string 'std' in a given string.","code":"def count_occurance(s):\n count = 0\n for i in range(len(s) - 2):\n if (s[i] == 's' and s[i+1] == 't' and s[i+2] == 'd'):\n count = count + 1\n return count","test_list":["assert count_occurance(\"letstdlenstdporstd\") == 3","assert count_occurance(\"truststdsolensporsd\") == 1","assert count_occurance(\"makestdsostdworthit\") == 2","assert count_occurance(\"stds\") == 1","assert count_occurance(\"\") == 0"],"test_imports":[]}} {"problem_id":"mbpp_test_00222","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if all the elements in tuple have same data type or not.\n\nTests:\nassert check_type((5, 6, 7, 3, 5, 6) ) == True\nassert check_type((1, 2, \"4\") ) == False\nassert check_type((3, 2, 1, 4, 5) ) == True","canonical_answer":"def check_type(test_tuple):\n res = True\n for ele in test_tuple:\n if not isinstance(ele, type(test_tuple[0])):\n res = False\n break\n return (res)","verification_metadata":{"test_list":["assert check_type((5, 6, 7, 3, 5, 6) ) == True","assert check_type((1, 2, \"4\") ) == False","assert check_type((3, 2, 1, 4, 5) ) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":222,"text":"Write a function to check if all the elements in tuple have same data type or not.","code":"def check_type(test_tuple):\n res = True\n for ele in test_tuple:\n if not isinstance(ele, type(test_tuple[0])):\n res = False\n break\n return (res)","test_list":["assert check_type((5, 6, 7, 3, 5, 6) ) == True","assert check_type((1, 2, \"4\") ) == False","assert check_type((3, 2, 1, 4, 5) ) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00223","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)\n\nTests:\nassert is_majority([1, 2, 3, 3, 3, 3, 10], 7, 3) == True\nassert is_majority([1, 1, 2, 4, 4, 4, 6, 6], 8, 4) == False\nassert is_majority([1, 1, 1, 2, 2], 5, 1) == True\nassert is_majority([1, 1, 2, 2], 5, 1) == False","canonical_answer":"def is_majority(arr, n, x):\n\ti = binary_search(arr, 0, n-1, x)\n\tif i == -1:\n\t\treturn False\n\tif ((i + n//2) <= (n -1)) and arr[i + n//2] == x:\n\t\treturn True\n\telse:\n\t\treturn False\ndef binary_search(arr, low, high, x):\n\tif high >= low:\n\t\tmid = (low + high)//2 \n\t\tif (mid == 0 or x > arr[mid-1]) and (arr[mid] == x):\n\t\t\treturn mid\n\t\telif x > arr[mid]:\n\t\t\treturn binary_search(arr, (mid + 1), high, x)\n\t\telse:\n\t\t\treturn binary_search(arr, low, (mid -1), x)\n\treturn -1","verification_metadata":{"test_list":["assert is_majority([1, 2, 3, 3, 3, 3, 10], 7, 3) == True","assert is_majority([1, 1, 2, 4, 4, 4, 6, 6], 8, 4) == False","assert is_majority([1, 1, 1, 2, 2], 5, 1) == True","assert is_majority([1, 1, 2, 2], 5, 1) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":223,"text":"Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)","code":"def is_majority(arr, n, x):\n\ti = binary_search(arr, 0, n-1, x)\n\tif i == -1:\n\t\treturn False\n\tif ((i + n//2) <= (n -1)) and arr[i + n//2] == x:\n\t\treturn True\n\telse:\n\t\treturn False\ndef binary_search(arr, low, high, x):\n\tif high >= low:\n\t\tmid = (low + high)//2 \n\t\tif (mid == 0 or x > arr[mid-1]) and (arr[mid] == x):\n\t\t\treturn mid\n\t\telif x > arr[mid]:\n\t\t\treturn binary_search(arr, (mid + 1), high, x)\n\t\telse:\n\t\t\treturn binary_search(arr, low, (mid -1), x)\n\treturn -1","test_list":["assert is_majority([1, 2, 3, 3, 3, 3, 10], 7, 3) == True","assert is_majority([1, 1, 2, 4, 4, 4, 6, 6], 8, 4) == False","assert is_majority([1, 1, 1, 2, 2], 5, 1) == True","assert is_majority([1, 1, 2, 2], 5, 1) == False"],"test_imports":[]}} {"problem_id":"mbpp_test_00224","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the number of set bits (binary digits with value 1) in a given number.\n\nTests:\nassert count_Set_Bits(2) == 1\nassert count_Set_Bits(4) == 1\nassert count_Set_Bits(6) == 2","canonical_answer":"def count_Set_Bits(n): \n count = 0\n while (n): \n count += n & 1\n n >>= 1\n return count","verification_metadata":{"test_list":["assert count_Set_Bits(2) == 1","assert count_Set_Bits(4) == 1","assert count_Set_Bits(6) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":224,"text":"Write a python function to count the number of set bits (binary digits with value 1) in a given number.","code":"def count_Set_Bits(n): \n count = 0\n while (n): \n count += n & 1\n n >>= 1\n return count","test_list":["assert count_Set_Bits(2) == 1","assert count_Set_Bits(4) == 1","assert count_Set_Bits(6) == 2"],"test_imports":[]}} {"problem_id":"mbpp_test_00226","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to remove the characters which have odd index values of a given string.\n\nTests:\nassert odd_values_string('abcdef') == 'ace'\nassert odd_values_string('python') == 'pto'\nassert odd_values_string('data') == 'dt'\nassert odd_values_string('lambs') == 'lms'","canonical_answer":"def odd_values_string(str):\n result = \"\" \n for i in range(len(str)):\n if i % 2 == 0:\n result = result + str[i]\n return result","verification_metadata":{"test_list":["assert odd_values_string('abcdef') == 'ace'","assert odd_values_string('python') == 'pto'","assert odd_values_string('data') == 'dt'","assert odd_values_string('lambs') == 'lms'"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":226,"text":"Write a python function to remove the characters which have odd index values of a given string.","code":"def odd_values_string(str):\n result = \"\" \n for i in range(len(str)):\n if i % 2 == 0:\n result = result + str[i]\n return result","test_list":["assert odd_values_string('abcdef') == 'ace'","assert odd_values_string('python') == 'pto'","assert odd_values_string('data') == 'dt'","assert odd_values_string('lambs') == 'lms'"],"test_imports":[]}} {"problem_id":"mbpp_test_00227","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find minimum of three numbers.\n\nTests:\nassert min_of_three(10,20,0)==0\nassert min_of_three(19,15,18)==15\nassert min_of_three(-10,-20,-30)==-30","canonical_answer":"def min_of_three(a,b,c): \n if (a <= b) and (a <= c): \n smallest = a \n elif (b <= a) and (b <= c): \n smallest = b \n else: \n smallest = c \n return smallest","verification_metadata":{"test_list":["assert min_of_three(10,20,0)==0","assert min_of_three(19,15,18)==15","assert min_of_three(-10,-20,-30)==-30"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":227,"text":"Write a function to find minimum of three numbers.","code":"def min_of_three(a,b,c): \n if (a <= b) and (a <= c): \n smallest = a \n elif (b <= a) and (b <= c): \n smallest = b \n else: \n smallest = c \n return smallest","test_list":["assert min_of_three(10,20,0)==0","assert min_of_three(19,15,18)==15","assert min_of_three(-10,-20,-30)==-30"],"test_imports":[]}} {"problem_id":"mbpp_test_00228","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether all the bits are unset in the given range or not.\n\nTests:\nassert all_Bits_Set_In_The_Given_Range(4,1,2) == True\nassert all_Bits_Set_In_The_Given_Range(17,2,4) == True\nassert all_Bits_Set_In_The_Given_Range(39,4,6) == False","canonical_answer":"def all_Bits_Set_In_The_Given_Range(n,l,r): \n num = (((1 << r) - 1) ^ ((1 << (l - 1)) - 1)) \n new_num = n & num\n if (new_num == 0): \n return True\n return False","verification_metadata":{"test_list":["assert all_Bits_Set_In_The_Given_Range(4,1,2) == True","assert all_Bits_Set_In_The_Given_Range(17,2,4) == True","assert all_Bits_Set_In_The_Given_Range(39,4,6) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":228,"text":"Write a python function to check whether all the bits are unset in the given range or not.","code":"def all_Bits_Set_In_The_Given_Range(n,l,r): \n num = (((1 << r) - 1) ^ ((1 << (l - 1)) - 1)) \n new_num = n & num\n if (new_num == 0): \n return True\n return False","test_list":["assert all_Bits_Set_In_The_Given_Range(4,1,2) == True","assert all_Bits_Set_In_The_Given_Range(17,2,4) == True","assert all_Bits_Set_In_The_Given_Range(39,4,6) == False"],"test_imports":[]}} {"problem_id":"mbpp_test_00229","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in an array and an integer n, and re-arranges the first n elements of the given array so that all negative elements appear before positive ones, and where the relative order among negative and positive elements is preserved.\n\nTests:\nassert re_arrange_array([-1, 2, -3, 4, 5, 6, -7, 8, 9], 9) == [-1, -3, -7, 4, 5, 6, 2, 8, 9]\nassert re_arrange_array([12, -14, -26, 13, 15], 5) == [-14, -26, 12, 13, 15]\nassert re_arrange_array([10, 24, 36, -42, -39, -78, 85], 7) == [-42, -39, -78, 10, 24, 36, 85]","canonical_answer":"def re_arrange_array(arr, n):\n j=0\n for i in range(0, n):\n if (arr[i] < 0):\n temp = arr[i]\n arr[i] = arr[j]\n arr[j] = temp\n j = j + 1\n return arr","verification_metadata":{"test_list":["assert re_arrange_array([-1, 2, -3, 4, 5, 6, -7, 8, 9], 9) == [-1, -3, -7, 4, 5, 6, 2, 8, 9]","assert re_arrange_array([12, -14, -26, 13, 15], 5) == [-14, -26, 12, 13, 15]","assert re_arrange_array([10, 24, 36, -42, -39, -78, 85], 7) == [-42, -39, -78, 10, 24, 36, 85]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":229,"text":"Write a function that takes in an array and an integer n, and re-arranges the first n elements of the given array so that all negative elements appear before positive ones, and where the relative order among negative and positive elements is preserved.","code":"def re_arrange_array(arr, n):\n j=0\n for i in range(0, n):\n if (arr[i] < 0):\n temp = arr[i]\n arr[i] = arr[j]\n arr[j] = temp\n j = j + 1\n return arr","test_list":["assert re_arrange_array([-1, 2, -3, 4, 5, 6, -7, 8, 9], 9) == [-1, -3, -7, 4, 5, 6, 2, 8, 9]","assert re_arrange_array([12, -14, -26, 13, 15], 5) == [-14, -26, 12, 13, 15]","assert re_arrange_array([10, 24, 36, -42, -39, -78, 85], 7) == [-42, -39, -78, 10, 24, 36, 85]"],"test_imports":[]}} {"problem_id":"mbpp_test_00230","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a string and character, replaces blank spaces in the string with the character, and returns the string.\n\nTests:\nassert replace_blank(\"hello people\",'@')==(\"hello@people\")\nassert replace_blank(\"python program language\",'$')==(\"python$program$language\")\nassert replace_blank(\"blank space\",\"-\")==(\"blank-space\")","canonical_answer":"def replace_blank(str1,char):\n str2 = str1.replace(' ', char)\n return str2","verification_metadata":{"test_list":["assert replace_blank(\"hello people\",'@')==(\"hello@people\")","assert replace_blank(\"python program language\",'$')==(\"python$program$language\")","assert replace_blank(\"blank space\",\"-\")==(\"blank-space\")"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":230,"text":"Write a function that takes in a string and character, replaces blank spaces in the string with the character, and returns the string.","code":"def replace_blank(str1,char):\n str2 = str1.replace(' ', char)\n return str2","test_list":["assert replace_blank(\"hello people\",'@')==(\"hello@people\")","assert replace_blank(\"python program language\",'$')==(\"python$program$language\")","assert replace_blank(\"blank space\",\"-\")==(\"blank-space\")"],"test_imports":[]}} {"problem_id":"mbpp_test_00232","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a list and an integer n and returns a list containing the n largest items from the list.\n\nTests:\nassert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2))==set([100,90])\nassert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],5))==set([100,90,80,70,60])\nassert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],3))==set([100,90,80])","canonical_answer":"import heapq\ndef larg_nnum(list1,n):\n largest=heapq.nlargest(n,list1)\n return largest","verification_metadata":{"test_list":["assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2))==set([100,90])","assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],5))==set([100,90,80,70,60])","assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],3))==set([100,90,80])"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":232,"text":"Write a function that takes in a list and an integer n and returns a list containing the n largest items from the list.","code":"import heapq\ndef larg_nnum(list1,n):\n largest=heapq.nlargest(n,list1)\n return largest","test_list":["assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2))==set([100,90])","assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],5))==set([100,90,80,70,60])","assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],3))==set([100,90,80])"],"test_imports":[]}} {"problem_id":"mbpp_test_00233","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the lateral surface area of a cylinder.\n\nTests:\nassert math.isclose(lateralsuface_cylinder(10,5), 314.15000000000003, rel_tol=0.001)\nassert math.isclose(lateralsuface_cylinder(4,5), 125.66000000000001, rel_tol=0.001)\nassert math.isclose(lateralsuface_cylinder(4,10), 251.32000000000002, rel_tol=0.001)","canonical_answer":"def lateralsuface_cylinder(r,h):\n lateralsurface= 2*3.1415*r*h\n return lateralsurface","verification_metadata":{"test_list":["assert math.isclose(lateralsuface_cylinder(10,5), 314.15000000000003, rel_tol=0.001)","assert math.isclose(lateralsuface_cylinder(4,5), 125.66000000000001, rel_tol=0.001)","assert math.isclose(lateralsuface_cylinder(4,10), 251.32000000000002, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":233,"text":"Write a function to find the lateral surface area of a cylinder.","code":"def lateralsuface_cylinder(r,h):\n lateralsurface= 2*3.1415*r*h\n return lateralsurface","test_list":["assert math.isclose(lateralsuface_cylinder(10,5), 314.15000000000003, rel_tol=0.001)","assert math.isclose(lateralsuface_cylinder(4,5), 125.66000000000001, rel_tol=0.001)","assert math.isclose(lateralsuface_cylinder(4,10), 251.32000000000002, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00234","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the volume of a cube given its side length.\n\nTests:\nassert volume_cube(3)==27\nassert volume_cube(2)==8\nassert volume_cube(5)==125","canonical_answer":"def volume_cube(l):\n volume = l * l * l\n return volume","verification_metadata":{"test_list":["assert volume_cube(3)==27","assert volume_cube(2)==8","assert volume_cube(5)==125"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":234,"text":"Write a function to find the volume of a cube given its side length.","code":"def volume_cube(l):\n volume = l * l * l\n return volume","test_list":["assert volume_cube(3)==27","assert volume_cube(2)==8","assert volume_cube(5)==125"],"test_imports":[]}} {"problem_id":"mbpp_test_00235","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to set all even bits of a given number.\n\nTests:\nassert even_bit_set_number(10) == 10\nassert even_bit_set_number(20) == 30\nassert even_bit_set_number(30) == 30","canonical_answer":"def even_bit_set_number(n): \n count = 0;res = 0;temp = n \n while(temp > 0): \n if (count % 2 == 1): \n res |= (1 << count)\n count+=1\n temp >>= 1\n return (n | res)","verification_metadata":{"test_list":["assert even_bit_set_number(10) == 10","assert even_bit_set_number(20) == 30","assert even_bit_set_number(30) == 30"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":235,"text":"Write a python function to set all even bits of a given number.","code":"def even_bit_set_number(n): \n count = 0;res = 0;temp = n \n while(temp > 0): \n if (count % 2 == 1): \n res |= (1 << count)\n count+=1\n temp >>= 1\n return (n | res)","test_list":["assert even_bit_set_number(10) == 10","assert even_bit_set_number(20) == 30","assert even_bit_set_number(30) == 30"],"test_imports":[]}} {"problem_id":"mbpp_test_00237","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a list of tuples and returns a dictionary mapping each unique tuple to the number of times it occurs in the list.\n\nTests:\nassert check_occurences([(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)] ) == {(1, 3): 2, (2, 5): 2, (3, 6): 1}\nassert check_occurences([(4, 2), (2, 4), (3, 6), (6, 3), (7, 4)] ) == {(2, 4): 2, (3, 6): 2, (4, 7): 1}\nassert check_occurences([(13, 2), (11, 23), (12, 25), (25, 12), (16, 23)] ) == {(2, 13): 1, (11, 23): 1, (12, 25): 2, (16, 23): 1}","canonical_answer":"from collections import Counter \ndef check_occurences(test_list):\n res = dict(Counter(tuple(ele) for ele in map(sorted, test_list)))\n return (res)","verification_metadata":{"test_list":["assert check_occurences([(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)] ) == {(1, 3): 2, (2, 5): 2, (3, 6): 1}","assert check_occurences([(4, 2), (2, 4), (3, 6), (6, 3), (7, 4)] ) == {(2, 4): 2, (3, 6): 2, (4, 7): 1}","assert check_occurences([(13, 2), (11, 23), (12, 25), (25, 12), (16, 23)] ) == {(2, 13): 1, (11, 23): 1, (12, 25): 2, (16, 23): 1}"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":237,"text":"Write a function that takes in a list of tuples and returns a dictionary mapping each unique tuple to the number of times it occurs in the list.","code":"from collections import Counter \ndef check_occurences(test_list):\n res = dict(Counter(tuple(ele) for ele in map(sorted, test_list)))\n return (res)","test_list":["assert check_occurences([(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)] ) == {(1, 3): 2, (2, 5): 2, (3, 6): 1}","assert check_occurences([(4, 2), (2, 4), (3, 6), (6, 3), (7, 4)] ) == {(2, 4): 2, (3, 6): 2, (4, 7): 1}","assert check_occurences([(13, 2), (11, 23), (12, 25), (25, 12), (16, 23)] ) == {(2, 13): 1, (11, 23): 1, (12, 25): 2, (16, 23): 1}"],"test_imports":[]}} {"problem_id":"mbpp_test_00238","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the number of non-empty substrings of a given string.\n\nTests:\nassert number_of_substrings(\"abc\") == 6\nassert number_of_substrings(\"abcd\") == 10\nassert number_of_substrings(\"abcde\") == 15","canonical_answer":"def number_of_substrings(str): \n\tstr_len = len(str); \n\treturn int(str_len * (str_len + 1) / 2);","verification_metadata":{"test_list":["assert number_of_substrings(\"abc\") == 6","assert number_of_substrings(\"abcd\") == 10","assert number_of_substrings(\"abcde\") == 15"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":238,"text":"Write a python function to count the number of non-empty substrings of a given string.","code":"def number_of_substrings(str): \n\tstr_len = len(str); \n\treturn int(str_len * (str_len + 1) / 2);","test_list":["assert number_of_substrings(\"abc\") == 6","assert number_of_substrings(\"abcd\") == 10","assert number_of_substrings(\"abcde\") == 15"],"test_imports":[]}} {"problem_id":"mbpp_test_00239","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in positive integers m and n and finds the number of possible sequences of length n, such that each element is a positive integer and is greater than or equal to twice the previous element but less than or equal to m.\n\nTests:\nassert get_total_number_of_sequences(10, 4) == 4\nassert get_total_number_of_sequences(5, 2) == 6\nassert get_total_number_of_sequences(16, 3) == 84","canonical_answer":"def get_total_number_of_sequences(m,n): \n\tT=[[0 for i in range(n+1)] for i in range(m+1)] \n\tfor i in range(m+1): \n\t\tfor j in range(n+1): \n\t\t\tif i==0 or j==0: \n\t\t\t\tT[i][j]=0\n\t\t\telif i arr[j] and MSIBS[i] < MSIBS[j] + arr[i]: \n\t\t\t\tMSIBS[i] = MSIBS[j] + arr[i] \n\tMSDBS = arr[:] \n\tfor i in range(1, len(arr) + 1): \n\t\tfor j in range(1, i): \n\t\t\tif arr[-i] > arr[-j] and MSDBS[-i] < MSDBS[-j] + arr[-i]: \n\t\t\t\tMSDBS[-i] = MSDBS[-j] + arr[-i] \n\tmax_sum = float(\"-Inf\") \n\tfor i, j, k in zip(MSIBS, MSDBS, arr): \n\t\tmax_sum = max(max_sum, i + j - k) \n\treturn max_sum","verification_metadata":{"test_list":["assert max_sum([1, 15, 51, 45, 33, 100, 12, 18, 9]) == 194","assert max_sum([80, 60, 30, 40, 20, 10]) == 210","assert max_sum([2, 3 ,14, 16, 21, 23, 29, 30]) == 138"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":245,"text":"Write a function that takes an array and finds the maximum sum of a bitonic subsequence for the given array, where a sequence is bitonic if it is first increasing and then decreasing.","code":"def max_sum(arr): \n\tMSIBS = arr[:] \n\tfor i in range(len(arr)): \n\t\tfor j in range(0, i): \n\t\t\tif arr[i] > arr[j] and MSIBS[i] < MSIBS[j] + arr[i]: \n\t\t\t\tMSIBS[i] = MSIBS[j] + arr[i] \n\tMSDBS = arr[:] \n\tfor i in range(1, len(arr) + 1): \n\t\tfor j in range(1, i): \n\t\t\tif arr[-i] > arr[-j] and MSDBS[-i] < MSDBS[-j] + arr[-i]: \n\t\t\t\tMSDBS[-i] = MSDBS[-j] + arr[-i] \n\tmax_sum = float(\"-Inf\") \n\tfor i, j, k in zip(MSIBS, MSDBS, arr): \n\t\tmax_sum = max(max_sum, i + j - k) \n\treturn max_sum","test_list":["assert max_sum([1, 15, 51, 45, 33, 100, 12, 18, 9]) == 194","assert max_sum([80, 60, 30, 40, 20, 10]) == 210","assert max_sum([2, 3 ,14, 16, 21, 23, 29, 30]) == 138"],"test_imports":[]}} {"problem_id":"mbpp_test_00246","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function for computing square roots using the babylonian method.\n\nTests:\nassert math.isclose(babylonian_squareroot(10), 3.162277660168379, rel_tol=0.001)\nassert math.isclose(babylonian_squareroot(2), 1.414213562373095, rel_tol=0.001)\nassert math.isclose(babylonian_squareroot(9), 3.0, rel_tol=0.001)","canonical_answer":"def babylonian_squareroot(number):\n if(number == 0):\n return 0;\n g = number/2.0;\n g2 = g + 1;\n while(g != g2):\n n = number/ g;\n g2 = g;\n g = (g + n)/2;\n return g;","verification_metadata":{"test_list":["assert math.isclose(babylonian_squareroot(10), 3.162277660168379, rel_tol=0.001)","assert math.isclose(babylonian_squareroot(2), 1.414213562373095, rel_tol=0.001)","assert math.isclose(babylonian_squareroot(9), 3.0, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":246,"text":"Write a function for computing square roots using the babylonian method.","code":"def babylonian_squareroot(number):\n if(number == 0):\n return 0;\n g = number/2.0;\n g2 = g + 1;\n while(g != g2):\n n = number/ g;\n g2 = g;\n g = (g + n)/2;\n return g;","test_list":["assert math.isclose(babylonian_squareroot(10), 3.162277660168379, rel_tol=0.001)","assert math.isclose(babylonian_squareroot(2), 1.414213562373095, rel_tol=0.001)","assert math.isclose(babylonian_squareroot(9), 3.0, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00247","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the length of the longest palindromic subsequence in the given string.\n\nTests:\nassert lps(\"TENS FOR TENS\") == 5\nassert lps(\"CARDIO FOR CARDS\") == 7\nassert lps(\"PART OF THE JOURNEY IS PART\") == 9","canonical_answer":"def lps(str): \n\tn = len(str) \n\tL = [[0 for x in range(n)] for x in range(n)] \n\tfor i in range(n): \n\t\tL[i][i] = 1\n\tfor cl in range(2, n+1): \n\t\tfor i in range(n-cl+1): \n\t\t\tj = i+cl-1\n\t\t\tif str[i] == str[j] and cl == 2: \n\t\t\t\tL[i][j] = 2\n\t\t\telif str[i] == str[j]: \n\t\t\t\tL[i][j] = L[i+1][j-1] + 2\n\t\t\telse: \n\t\t\t\tL[i][j] = max(L[i][j-1], L[i+1][j]); \n\treturn L[0][n-1]","verification_metadata":{"test_list":["assert lps(\"TENS FOR TENS\") == 5","assert lps(\"CARDIO FOR CARDS\") == 7","assert lps(\"PART OF THE JOURNEY IS PART\") == 9"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":247,"text":"Write a function to find the length of the longest palindromic subsequence in the given string.","code":"def lps(str): \n\tn = len(str) \n\tL = [[0 for x in range(n)] for x in range(n)] \n\tfor i in range(n): \n\t\tL[i][i] = 1\n\tfor cl in range(2, n+1): \n\t\tfor i in range(n-cl+1): \n\t\t\tj = i+cl-1\n\t\t\tif str[i] == str[j] and cl == 2: \n\t\t\t\tL[i][j] = 2\n\t\t\telif str[i] == str[j]: \n\t\t\t\tL[i][j] = L[i+1][j-1] + 2\n\t\t\telse: \n\t\t\t\tL[i][j] = max(L[i][j-1], L[i+1][j]); \n\treturn L[0][n-1]","test_list":["assert lps(\"TENS FOR TENS\") == 5","assert lps(\"CARDIO FOR CARDS\") == 7","assert lps(\"PART OF THE JOURNEY IS PART\") == 9"],"test_imports":[]}} {"problem_id":"mbpp_test_00248","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in an integer n and calculates the harmonic sum of n-1.\n\nTests:\nassert math.isclose(harmonic_sum(7), 2.5928571428571425, rel_tol=0.001)\nassert math.isclose(harmonic_sum(4), 2.083333333333333, rel_tol=0.001)\nassert math.isclose(harmonic_sum(19), 3.547739657143682, rel_tol=0.001)","canonical_answer":"def harmonic_sum(n):\n if n < 2:\n return 1\n else:\n return 1 / n + (harmonic_sum(n - 1))","verification_metadata":{"test_list":["assert math.isclose(harmonic_sum(7), 2.5928571428571425, rel_tol=0.001)","assert math.isclose(harmonic_sum(4), 2.083333333333333, rel_tol=0.001)","assert math.isclose(harmonic_sum(19), 3.547739657143682, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":248,"text":"Write a function that takes in an integer n and calculates the harmonic sum of n-1.","code":"def harmonic_sum(n):\n if n < 2:\n return 1\n else:\n return 1 / n + (harmonic_sum(n - 1))","test_list":["assert math.isclose(harmonic_sum(7), 2.5928571428571425, rel_tol=0.001)","assert math.isclose(harmonic_sum(4), 2.083333333333333, rel_tol=0.001)","assert math.isclose(harmonic_sum(19), 3.547739657143682, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00249","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the intersection of two arrays.\n\nTests:\nassert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]\nassert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[3,5,7,9])==[3,5,7,9]\nassert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[10,20,30,40])==[10]","canonical_answer":"def intersection_array(array_nums1,array_nums2):\n result = list(filter(lambda x: x in array_nums1, array_nums2)) \n return result","verification_metadata":{"test_list":["assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]","assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[3,5,7,9])==[3,5,7,9]","assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[10,20,30,40])==[10]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":249,"text":"Write a function to find the intersection of two arrays.","code":"def intersection_array(array_nums1,array_nums2):\n result = list(filter(lambda x: x in array_nums1, array_nums2)) \n return result","test_list":["assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]","assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[3,5,7,9])==[3,5,7,9]","assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[10,20,30,40])==[10]"],"test_imports":[]}} {"problem_id":"mbpp_test_00250","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple.\n\nTests:\nassert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0\nassert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10) == 3\nassert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8) == 4","canonical_answer":"def count_X(tup, x): \n count = 0\n for ele in tup: \n if (ele == x): \n count = count + 1\n return count","verification_metadata":{"test_list":["assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0","assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10) == 3","assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":250,"text":"Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple.","code":"def count_X(tup, x): \n count = 0\n for ele in tup: \n if (ele == x): \n count = count + 1\n return count","test_list":["assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0","assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10) == 3","assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8) == 4"],"test_imports":[]}} {"problem_id":"mbpp_test_00251","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a list and an element and inserts the element before each element in the list, and returns the resulting list.\n\nTests:\nassert insert_element(['Red', 'Green', 'Black'] ,'c')==['c', 'Red', 'c', 'Green', 'c', 'Black']\nassert insert_element(['python', 'java'] ,'program')==['program', 'python', 'program', 'java']\nassert insert_element(['happy', 'sad'] ,'laugh')==['laugh', 'happy', 'laugh', 'sad']","canonical_answer":"def insert_element(list,element):\n list = [v for elt in list for v in (element, elt)]\n return list","verification_metadata":{"test_list":["assert insert_element(['Red', 'Green', 'Black'] ,'c')==['c', 'Red', 'c', 'Green', 'c', 'Black']","assert insert_element(['python', 'java'] ,'program')==['program', 'python', 'program', 'java']","assert insert_element(['happy', 'sad'] ,'laugh')==['laugh', 'happy', 'laugh', 'sad']"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":251,"text":"Write a function that takes in a list and an element and inserts the element before each element in the list, and returns the resulting list.","code":"def insert_element(list,element):\n list = [v for elt in list for v in (element, elt)]\n return list","test_list":["assert insert_element(['Red', 'Green', 'Black'] ,'c')==['c', 'Red', 'c', 'Green', 'c', 'Black']","assert insert_element(['python', 'java'] ,'program')==['program', 'python', 'program', 'java']","assert insert_element(['happy', 'sad'] ,'laugh')==['laugh', 'happy', 'laugh', 'sad']"],"test_imports":[]}} {"problem_id":"mbpp_test_00252","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to convert complex numbers to polar coordinates.\n\nTests:\nassert convert(1) == (1.0, 0.0)\nassert convert(4) == (4.0,0.0)\nassert convert(5) == (5.0,0.0)","canonical_answer":"import cmath \ndef convert(numbers): \n num = cmath.polar(numbers) \n return (num)","verification_metadata":{"test_list":["assert convert(1) == (1.0, 0.0)","assert convert(4) == (4.0,0.0)","assert convert(5) == (5.0,0.0)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":252,"text":"Write a python function to convert complex numbers to polar coordinates.","code":"import cmath \ndef convert(numbers): \n num = cmath.polar(numbers) \n return (num)","test_list":["assert convert(1) == (1.0, 0.0)","assert convert(4) == (4.0,0.0)","assert convert(5) == (5.0,0.0)"],"test_imports":[]}} {"problem_id":"mbpp_test_00253","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function that returns the number of integer elements in a given list.\n\nTests:\nassert count_integer([1,2,'abc',1.2]) == 2\nassert count_integer([1,2,3]) == 3\nassert count_integer([1,1.2,4,5.1]) == 2","canonical_answer":"def count_integer(list1):\n ctr = 0\n for i in list1:\n if isinstance(i, int):\n ctr = ctr + 1\n return ctr","verification_metadata":{"test_list":["assert count_integer([1,2,'abc',1.2]) == 2","assert count_integer([1,2,3]) == 3","assert count_integer([1,1.2,4,5.1]) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":253,"text":"Write a python function that returns the number of integer elements in a given list.","code":"def count_integer(list1):\n ctr = 0\n for i in list1:\n if isinstance(i, int):\n ctr = ctr + 1\n return ctr","test_list":["assert count_integer([1,2,'abc',1.2]) == 2","assert count_integer([1,2,3]) == 3","assert count_integer([1,1.2,4,5.1]) == 2"],"test_imports":[]}} {"problem_id":"mbpp_test_00255","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a list and length n, and generates all combinations (with repetition) of the elements of the list and returns a list with a tuple for each combination.\n\nTests:\nassert combinations_colors( [\"Red\",\"Green\",\"Blue\"],1)==[('Red',), ('Green',), ('Blue',)]\nassert combinations_colors( [\"Red\",\"Green\",\"Blue\"],2)==[('Red', 'Red'), ('Red', 'Green'), ('Red', 'Blue'), ('Green', 'Green'), ('Green', 'Blue'), ('Blue', 'Blue')]\nassert combinations_colors( [\"Red\",\"Green\",\"Blue\"],3)==[('Red', 'Red', 'Red'), ('Red', 'Red', 'Green'), ('Red', 'Red', 'Blue'), ('Red', 'Green', 'Green'), ('Red', 'Green', 'Blue'), ('Red', 'Blue', 'Blue'), ('Green', 'Green', 'Green'), ('Green', 'Green', 'Blue'), ('Green', 'Blue', 'Blue'), ('Blue', 'Blue', 'Blue')]","canonical_answer":"from itertools import combinations_with_replacement \ndef combinations_colors(l, n):\n return list(combinations_with_replacement(l,n))","verification_metadata":{"test_list":["assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],1)==[('Red',), ('Green',), ('Blue',)]","assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],2)==[('Red', 'Red'), ('Red', 'Green'), ('Red', 'Blue'), ('Green', 'Green'), ('Green', 'Blue'), ('Blue', 'Blue')]","assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],3)==[('Red', 'Red', 'Red'), ('Red', 'Red', 'Green'), ('Red', 'Red', 'Blue'), ('Red', 'Green', 'Green'), ('Red', 'Green', 'Blue'), ('Red', 'Blue', 'Blue'), ('Green', 'Green', 'Green'), ('Green', 'Green', 'Blue'), ('Green', 'Blue', 'Blue'), ('Blue', 'Blue', 'Blue')]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":255,"text":"Write a function that takes in a list and length n, and generates all combinations (with repetition) of the elements of the list and returns a list with a tuple for each combination.","code":"from itertools import combinations_with_replacement \ndef combinations_colors(l, n):\n return list(combinations_with_replacement(l,n))","test_list":["assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],1)==[('Red',), ('Green',), ('Blue',)]","assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],2)==[('Red', 'Red'), ('Red', 'Green'), ('Red', 'Blue'), ('Green', 'Green'), ('Green', 'Blue'), ('Blue', 'Blue')]","assert combinations_colors( [\"Red\",\"Green\",\"Blue\"],3)==[('Red', 'Red', 'Red'), ('Red', 'Red', 'Green'), ('Red', 'Red', 'Blue'), ('Red', 'Green', 'Green'), ('Red', 'Green', 'Blue'), ('Red', 'Blue', 'Blue'), ('Green', 'Green', 'Green'), ('Green', 'Green', 'Blue'), ('Green', 'Blue', 'Blue'), ('Blue', 'Blue', 'Blue')]"],"test_imports":[]}} {"problem_id":"mbpp_test_00256","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.\n\nTests:\nassert count_Primes_nums(5) == 2\nassert count_Primes_nums(10) == 4\nassert count_Primes_nums(100) == 25","canonical_answer":"def count_Primes_nums(n):\n ctr = 0\n for num in range(n):\n if num <= 1:\n continue\n for i in range(2,num):\n if (num % i) == 0:\n break\n else:\n ctr += 1\n return ctr","verification_metadata":{"test_list":["assert count_Primes_nums(5) == 2","assert count_Primes_nums(10) == 4","assert count_Primes_nums(100) == 25"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":256,"text":"Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.","code":"def count_Primes_nums(n):\n ctr = 0\n for num in range(n):\n if num <= 1:\n continue\n for i in range(2,num):\n if (num % i) == 0:\n break\n else:\n ctr += 1\n return ctr","test_list":["assert count_Primes_nums(5) == 2","assert count_Primes_nums(10) == 4","assert count_Primes_nums(100) == 25"],"test_imports":[]}} {"problem_id":"mbpp_test_00257","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in two numbers and returns a tuple with the second number and then the first number.\n\nTests:\nassert swap_numbers(10,20)==(20,10)\nassert swap_numbers(15,17)==(17,15)\nassert swap_numbers(100,200)==(200,100)","canonical_answer":"def swap_numbers(a,b):\n temp = a\n a = b\n b = temp\n return (a,b)","verification_metadata":{"test_list":["assert swap_numbers(10,20)==(20,10)","assert swap_numbers(15,17)==(17,15)","assert swap_numbers(100,200)==(200,100)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":257,"text":"Write a function that takes in two numbers and returns a tuple with the second number and then the first number.","code":"def swap_numbers(a,b):\n temp = a\n a = b\n b = temp\n return (a,b)","test_list":["assert swap_numbers(10,20)==(20,10)","assert swap_numbers(15,17)==(17,15)","assert swap_numbers(100,200)==(200,100)"],"test_imports":[]}} {"problem_id":"mbpp_test_00259","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to maximize the given two tuples.\n\nTests:\nassert maximize_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((6, 7), (4, 9), (2, 9), (7, 10))\nassert maximize_elements(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((7, 8), (5, 10), (3, 10), (8, 11))\nassert maximize_elements(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((8, 9), (6, 11), (4, 11), (9, 12))","canonical_answer":"def maximize_elements(test_tup1, test_tup2):\n res = tuple(tuple(max(a, b) for a, b in zip(tup1, tup2))\n for tup1, tup2 in zip(test_tup1, test_tup2))\n return (res)","verification_metadata":{"test_list":["assert maximize_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((6, 7), (4, 9), (2, 9), (7, 10))","assert maximize_elements(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((7, 8), (5, 10), (3, 10), (8, 11))","assert maximize_elements(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((8, 9), (6, 11), (4, 11), (9, 12))"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":259,"text":"Write a function to maximize the given two tuples.","code":"def maximize_elements(test_tup1, test_tup2):\n res = tuple(tuple(max(a, b) for a, b in zip(tup1, tup2))\n for tup1, tup2 in zip(test_tup1, test_tup2))\n return (res)","test_list":["assert maximize_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((6, 7), (4, 9), (2, 9), (7, 10))","assert maximize_elements(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((7, 8), (5, 10), (3, 10), (8, 11))","assert maximize_elements(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((8, 9), (6, 11), (4, 11), (9, 12))"],"test_imports":[]}} {"problem_id":"mbpp_test_00260","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the nth newman–shanks–williams prime number.\n\nTests:\nassert newman_prime(3) == 7\nassert newman_prime(4) == 17\nassert newman_prime(5) == 41","canonical_answer":"def newman_prime(n): \n\tif n == 0 or n == 1: \n\t\treturn 1\n\treturn 2 * newman_prime(n - 1) + newman_prime(n - 2)","verification_metadata":{"test_list":["assert newman_prime(3) == 7","assert newman_prime(4) == 17","assert newman_prime(5) == 41"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":260,"text":"Write a function to find the nth newman–shanks–williams prime number.","code":"def newman_prime(n): \n\tif n == 0 or n == 1: \n\t\treturn 1\n\treturn 2 * newman_prime(n - 1) + newman_prime(n - 2)","test_list":["assert newman_prime(3) == 7","assert newman_prime(4) == 17","assert newman_prime(5) == 41"],"test_imports":[]}} {"problem_id":"mbpp_test_00261","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples.\n\nTests:\nassert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)\nassert division_elements((12, 6, 8, 16),(6, 3, 4, 4)) == (2, 2, 2, 4)\nassert division_elements((20, 14, 36, 18),(5, 7, 6, 9)) == (4, 2, 6, 2)","canonical_answer":"def division_elements(test_tup1, test_tup2):\n res = tuple(ele1 // ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\n return (res)","verification_metadata":{"test_list":["assert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)","assert division_elements((12, 6, 8, 16),(6, 3, 4, 4)) == (2, 2, 2, 4)","assert division_elements((20, 14, 36, 18),(5, 7, 6, 9)) == (4, 2, 6, 2)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":261,"text":"Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples.","code":"def division_elements(test_tup1, test_tup2):\n res = tuple(ele1 // ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\n return (res)","test_list":["assert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)","assert division_elements((12, 6, 8, 16),(6, 3, 4, 4)) == (2, 2, 2, 4)","assert division_elements((20, 14, 36, 18),(5, 7, 6, 9)) == (4, 2, 6, 2)"],"test_imports":[]}} {"problem_id":"mbpp_test_00262","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a list and an integer L and splits the given list into two parts where the length of the first part of the list is L, and returns the resulting lists in a tuple.\n\nTests:\nassert split_two_parts([1,1,2,3,4,4,5,1],3)==([1, 1, 2], [3, 4, 4, 5, 1])\nassert split_two_parts(['a', 'b', 'c', 'd'],2)==(['a', 'b'], ['c', 'd'])\nassert split_two_parts(['p', 'y', 't', 'h', 'o', 'n'],4)==(['p', 'y', 't', 'h'], ['o', 'n'])","canonical_answer":"def split_two_parts(list1, L):\n return list1[:L], list1[L:]","verification_metadata":{"test_list":["assert split_two_parts([1,1,2,3,4,4,5,1],3)==([1, 1, 2], [3, 4, 4, 5, 1])","assert split_two_parts(['a', 'b', 'c', 'd'],2)==(['a', 'b'], ['c', 'd'])","assert split_two_parts(['p', 'y', 't', 'h', 'o', 'n'],4)==(['p', 'y', 't', 'h'], ['o', 'n'])"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":262,"text":"Write a function that takes in a list and an integer L and splits the given list into two parts where the length of the first part of the list is L, and returns the resulting lists in a tuple.","code":"def split_two_parts(list1, L):\n return list1[:L], list1[L:]","test_list":["assert split_two_parts([1,1,2,3,4,4,5,1],3)==([1, 1, 2], [3, 4, 4, 5, 1])","assert split_two_parts(['a', 'b', 'c', 'd'],2)==(['a', 'b'], ['c', 'd'])","assert split_two_parts(['p', 'y', 't', 'h', 'o', 'n'],4)==(['p', 'y', 't', 'h'], ['o', 'n'])"],"test_imports":[]}} {"problem_id":"mbpp_test_00264","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to calculate a dog's age in dog's years.\n\nTests:\nassert dog_age(12)==61\nassert dog_age(15)==73\nassert dog_age(24)==109","canonical_answer":"def dog_age(h_age):\n if h_age < 0:\n \texit()\n elif h_age <= 2:\n\t d_age = h_age * 10.5\n else:\n\t d_age = 21 + (h_age - 2)*4\n return d_age","verification_metadata":{"test_list":["assert dog_age(12)==61","assert dog_age(15)==73","assert dog_age(24)==109"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":264,"text":"Write a function to calculate a dog's age in dog's years.","code":"def dog_age(h_age):\n if h_age < 0:\n \texit()\n elif h_age <= 2:\n\t d_age = h_age * 10.5\n else:\n\t d_age = 21 + (h_age - 2)*4\n return d_age","test_list":["assert dog_age(12)==61","assert dog_age(15)==73","assert dog_age(24)==109"],"test_imports":[]}} {"problem_id":"mbpp_test_00265","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a list and an integer n and splits a list for every nth element, returning a list of the resulting lists.\n\nTests:\nassert list_split(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],3)==[['a', 'd', 'g', 'j', 'm'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']]\nassert list_split([1,2,3,4,5,6,7,8,9,10,11,12,13,14],3)==[[1,4,7,10,13], [2,5,8,11,14], [3,6,9,12]]\nassert list_split(['python','java','C','C++','DBMS','SQL'],2)==[['python', 'C', 'DBMS'], ['java', 'C++', 'SQL']]","canonical_answer":"def list_split(S, step):\n return [S[i::step] for i in range(step)]","verification_metadata":{"test_list":["assert list_split(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],3)==[['a', 'd', 'g', 'j', 'm'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']]","assert list_split([1,2,3,4,5,6,7,8,9,10,11,12,13,14],3)==[[1,4,7,10,13], [2,5,8,11,14], [3,6,9,12]]","assert list_split(['python','java','C','C++','DBMS','SQL'],2)==[['python', 'C', 'DBMS'], ['java', 'C++', 'SQL']]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":265,"text":"Write a function that takes in a list and an integer n and splits a list for every nth element, returning a list of the resulting lists.","code":"def list_split(S, step):\n return [S[i::step] for i in range(step)]","test_list":["assert list_split(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],3)==[['a', 'd', 'g', 'j', 'm'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']]","assert list_split([1,2,3,4,5,6,7,8,9,10,11,12,13,14],3)==[[1,4,7,10,13], [2,5,8,11,14], [3,6,9,12]]","assert list_split(['python','java','C','C++','DBMS','SQL'],2)==[['python', 'C', 'DBMS'], ['java', 'C++', 'SQL']]"],"test_imports":[]}} {"problem_id":"mbpp_test_00266","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the lateral surface area of a cube given its side length.\n\nTests:\nassert lateralsurface_cube(5)==100\nassert lateralsurface_cube(9)==324\nassert lateralsurface_cube(10)==400","canonical_answer":"def lateralsurface_cube(l):\n LSA = 4 * (l * l)\n return LSA","verification_metadata":{"test_list":["assert lateralsurface_cube(5)==100","assert lateralsurface_cube(9)==324","assert lateralsurface_cube(10)==400"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":266,"text":"Write a function to find the lateral surface area of a cube given its side length.","code":"def lateralsurface_cube(l):\n LSA = 4 * (l * l)\n return LSA","test_list":["assert lateralsurface_cube(5)==100","assert lateralsurface_cube(9)==324","assert lateralsurface_cube(10)==400"],"test_imports":[]}} {"problem_id":"mbpp_test_00267","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function that takes in an integer n and returns the sum of the squares of the first n odd natural numbers.\n\nTests:\nassert square_Sum(2) == 10\nassert square_Sum(3) == 35\nassert square_Sum(4) == 84","canonical_answer":"def square_Sum(n): \n return int(n*(4*n*n-1)/3)","verification_metadata":{"test_list":["assert square_Sum(2) == 10","assert square_Sum(3) == 35","assert square_Sum(4) == 84"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":267,"text":"Write a python function that takes in an integer n and returns the sum of the squares of the first n odd natural numbers.","code":"def square_Sum(n): \n return int(n*(4*n*n-1)/3)","test_list":["assert square_Sum(2) == 10","assert square_Sum(3) == 35","assert square_Sum(4) == 84"],"test_imports":[]}} {"problem_id":"mbpp_test_00268","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the n'th star number.\n\nTests:\nassert find_star_num(3) == 37\nassert find_star_num(4) == 73\nassert find_star_num(5) == 121","canonical_answer":"def find_star_num(n): \n\treturn (6 * n * (n - 1) + 1)","verification_metadata":{"test_list":["assert find_star_num(3) == 37","assert find_star_num(4) == 73","assert find_star_num(5) == 121"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":268,"text":"Write a function to find the n'th star number.","code":"def find_star_num(n): \n\treturn (6 * n * (n - 1) + 1)","test_list":["assert find_star_num(3) == 37","assert find_star_num(4) == 73","assert find_star_num(5) == 121"],"test_imports":[]}} {"problem_id":"mbpp_test_00269","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the ascii value of a character.\n\nTests:\nassert ascii_value('A')==65\nassert ascii_value('R')==82\nassert ascii_value('S')==83","canonical_answer":"def ascii_value(k):\n ch=k\n return ord(ch)","verification_metadata":{"test_list":["assert ascii_value('A')==65","assert ascii_value('R')==82","assert ascii_value('S')==83"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":269,"text":"Write a function to find the ascii value of a character.","code":"def ascii_value(k):\n ch=k\n return ord(ch)","test_list":["assert ascii_value('A')==65","assert ascii_value('R')==82","assert ascii_value('S')==83"],"test_imports":[]}} {"problem_id":"mbpp_test_00270","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of even numbers at even positions of a list.\n\nTests:\nassert sum_even_and_even_index([5, 6, 12, 1, 18, 8]) == 30\nassert sum_even_and_even_index([3, 20, 17, 9, 2, 10, 18, 13, 6, 18]) == 26\nassert sum_even_and_even_index([5, 6, 12, 1]) == 12","canonical_answer":"def sum_even_and_even_index(arr): \n i = 0\n sum = 0\n for i in range(0, len(arr),2): \n if (arr[i] % 2 == 0) : \n sum += arr[i] \n return sum","verification_metadata":{"test_list":["assert sum_even_and_even_index([5, 6, 12, 1, 18, 8]) == 30","assert sum_even_and_even_index([3, 20, 17, 9, 2, 10, 18, 13, 6, 18]) == 26","assert sum_even_and_even_index([5, 6, 12, 1]) == 12"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":270,"text":"Write a python function to find the sum of even numbers at even positions of a list.","code":"def sum_even_and_even_index(arr): \n i = 0\n sum = 0\n for i in range(0, len(arr),2): \n if (arr[i] % 2 == 0) : \n sum += arr[i] \n return sum","test_list":["assert sum_even_and_even_index([5, 6, 12, 1, 18, 8]) == 30","assert sum_even_and_even_index([3, 20, 17, 9, 2, 10, 18, 13, 6, 18]) == 26","assert sum_even_and_even_index([5, 6, 12, 1]) == 12"],"test_imports":[]}} {"problem_id":"mbpp_test_00271","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.\n\nTests:\nassert even_Power_Sum(2) == 1056\nassert even_Power_Sum(3) == 8832\nassert even_Power_Sum(1) == 32","canonical_answer":"def even_Power_Sum(n): \n sum = 0; \n for i in range(1,n+1): \n j = 2*i; \n sum = sum + (j*j*j*j*j); \n return sum;","verification_metadata":{"test_list":["assert even_Power_Sum(2) == 1056","assert even_Power_Sum(3) == 8832","assert even_Power_Sum(1) == 32"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":271,"text":"Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.","code":"def even_Power_Sum(n): \n sum = 0; \n for i in range(1,n+1): \n j = 2*i; \n sum = sum + (j*j*j*j*j); \n return sum;","test_list":["assert even_Power_Sum(2) == 1056","assert even_Power_Sum(3) == 8832","assert even_Power_Sum(1) == 32"],"test_imports":[]}} {"problem_id":"mbpp_test_00272","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a list of tuples and returns a list containing the rear element of each tuple.\n\nTests:\nassert rear_extract([(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]) == [21, 20, 19]\nassert rear_extract([(1, 'Sai', 36), (2, 'Ayesha', 25), (3, 'Salman', 45)]) == [36, 25, 45]\nassert rear_extract([(1, 'Sudeep', 14), (2, 'Vandana', 36), (3, 'Dawood', 56)]) == [14, 36, 56]","canonical_answer":"def rear_extract(test_list):\n res = [lis[-1] for lis in test_list]\n return (res)","verification_metadata":{"test_list":["assert rear_extract([(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]) == [21, 20, 19]","assert rear_extract([(1, 'Sai', 36), (2, 'Ayesha', 25), (3, 'Salman', 45)]) == [36, 25, 45]","assert rear_extract([(1, 'Sudeep', 14), (2, 'Vandana', 36), (3, 'Dawood', 56)]) == [14, 36, 56]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":272,"text":"Write a function that takes in a list of tuples and returns a list containing the rear element of each tuple.","code":"def rear_extract(test_list):\n res = [lis[-1] for lis in test_list]\n return (res)","test_list":["assert rear_extract([(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]) == [21, 20, 19]","assert rear_extract([(1, 'Sai', 36), (2, 'Ayesha', 25), (3, 'Salman', 45)]) == [36, 25, 45]","assert rear_extract([(1, 'Sudeep', 14), (2, 'Vandana', 36), (3, 'Dawood', 56)]) == [14, 36, 56]"],"test_imports":[]}} {"problem_id":"mbpp_test_00273","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index.\n\nTests:\nassert substract_elements((10, 4, 5), (2, 5, 18)) == (8, -1, -13)\nassert substract_elements((11, 2, 3), (24, 45 ,16)) == (-13, -43, -13)\nassert substract_elements((7, 18, 9), (10, 11, 12)) == (-3, 7, -3)","canonical_answer":"def substract_elements(test_tup1, test_tup2):\n res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))\n return (res)","verification_metadata":{"test_list":["assert substract_elements((10, 4, 5), (2, 5, 18)) == (8, -1, -13)","assert substract_elements((11, 2, 3), (24, 45 ,16)) == (-13, -43, -13)","assert substract_elements((7, 18, 9), (10, 11, 12)) == (-3, 7, -3)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":273,"text":"Write a function that takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index.","code":"def substract_elements(test_tup1, test_tup2):\n res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))\n return (res)","test_list":["assert substract_elements((10, 4, 5), (2, 5, 18)) == (8, -1, -13)","assert substract_elements((11, 2, 3), (24, 45 ,16)) == (-13, -43, -13)","assert substract_elements((7, 18, 9), (10, 11, 12)) == (-3, 7, -3)"],"test_imports":[]}} {"problem_id":"mbpp_test_00274","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function that takes in a positive integer n and finds the sum of even index binomial coefficients.\n\nTests:\nassert even_binomial_Coeff_Sum(4) == 8\nassert even_binomial_Coeff_Sum(6) == 32\nassert even_binomial_Coeff_Sum(2) == 2","canonical_answer":"import math \ndef even_binomial_Coeff_Sum( n): \n return (1 << (n - 1))","verification_metadata":{"test_list":["assert even_binomial_Coeff_Sum(4) == 8","assert even_binomial_Coeff_Sum(6) == 32","assert even_binomial_Coeff_Sum(2) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":274,"text":"Write a python function that takes in a positive integer n and finds the sum of even index binomial coefficients.","code":"import math \ndef even_binomial_Coeff_Sum( n): \n return (1 << (n - 1))","test_list":["assert even_binomial_Coeff_Sum(4) == 8","assert even_binomial_Coeff_Sum(6) == 32","assert even_binomial_Coeff_Sum(2) == 2"],"test_imports":[]}} {"problem_id":"mbpp_test_00276","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in the radius and height of a cylinder and returns the the volume.\n\nTests:\nassert math.isclose(volume_cylinder(10,5), 1570.7500000000002, rel_tol=0.001)\nassert math.isclose(volume_cylinder(4,5), 251.32000000000002, rel_tol=0.001)\nassert math.isclose(volume_cylinder(4,10), 502.64000000000004, rel_tol=0.001)","canonical_answer":"def volume_cylinder(r,h):\n volume=3.1415*r*r*h\n return volume","verification_metadata":{"test_list":["assert math.isclose(volume_cylinder(10,5), 1570.7500000000002, rel_tol=0.001)","assert math.isclose(volume_cylinder(4,5), 251.32000000000002, rel_tol=0.001)","assert math.isclose(volume_cylinder(4,10), 502.64000000000004, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":276,"text":"Write a function that takes in the radius and height of a cylinder and returns the the volume.","code":"def volume_cylinder(r,h):\n volume=3.1415*r*r*h\n return volume","test_list":["assert math.isclose(volume_cylinder(10,5), 1570.7500000000002, rel_tol=0.001)","assert math.isclose(volume_cylinder(4,5), 251.32000000000002, rel_tol=0.001)","assert math.isclose(volume_cylinder(4,10), 502.64000000000004, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00277","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a dictionary and integer n and filters the dictionary to only include entries with values greater than or equal to n.\n\nTests:\nassert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170)=={'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}\nassert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},180)=={ 'Alden Cantrell': 180, 'Pierre Cox': 190}\nassert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},190)=={ 'Pierre Cox': 190}","canonical_answer":"def dict_filter(dict,n):\n result = {key:value for (key, value) in dict.items() if value >=n}\n return result","verification_metadata":{"test_list":["assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170)=={'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}","assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},180)=={ 'Alden Cantrell': 180, 'Pierre Cox': 190}","assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},190)=={ 'Pierre Cox': 190}"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":277,"text":"Write a function that takes in a dictionary and integer n and filters the dictionary to only include entries with values greater than or equal to n.","code":"def dict_filter(dict,n):\n result = {key:value for (key, value) in dict.items() if value >=n}\n return result","test_list":["assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170)=={'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}","assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},180)=={ 'Alden Cantrell': 180, 'Pierre Cox': 190}","assert dict_filter({'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},190)=={ 'Pierre Cox': 190}"],"test_imports":[]}} {"problem_id":"mbpp_test_00278","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the number of elements that occurs before the tuple element in the given tuple.\n\nTests:\nassert count_first_elements((1, 5, 7, (4, 6), 10) ) == 3\nassert count_first_elements((2, 9, (5, 7), 11) ) == 2\nassert count_first_elements((11, 15, 5, 8, (2, 3), 8) ) == 4","canonical_answer":"def count_first_elements(test_tup):\n for count, ele in enumerate(test_tup):\n if isinstance(ele, tuple):\n break\n return (count)","verification_metadata":{"test_list":["assert count_first_elements((1, 5, 7, (4, 6), 10) ) == 3","assert count_first_elements((2, 9, (5, 7), 11) ) == 2","assert count_first_elements((11, 15, 5, 8, (2, 3), 8) ) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":278,"text":"Write a function to find the number of elements that occurs before the tuple element in the given tuple.","code":"def count_first_elements(test_tup):\n for count, ele in enumerate(test_tup):\n if isinstance(ele, tuple):\n break\n return (count)","test_list":["assert count_first_elements((1, 5, 7, (4, 6), 10) ) == 3","assert count_first_elements((2, 9, (5, 7), 11) ) == 2","assert count_first_elements((11, 15, 5, 8, (2, 3), 8) ) == 4"],"test_imports":[]}} {"problem_id":"mbpp_test_00279","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the nth decagonal number.\n\nTests:\nassert is_num_decagonal(3) == 27\nassert is_num_decagonal(7) == 175\nassert is_num_decagonal(10) == 370","canonical_answer":"def is_num_decagonal(n): \n\treturn 4 * n * n - 3 * n","verification_metadata":{"test_list":["assert is_num_decagonal(3) == 27","assert is_num_decagonal(7) == 175","assert is_num_decagonal(10) == 370"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":279,"text":"Write a function to find the nth decagonal number.","code":"def is_num_decagonal(n): \n\treturn 4 * n * n - 3 * n","test_list":["assert is_num_decagonal(3) == 27","assert is_num_decagonal(7) == 175","assert is_num_decagonal(10) == 370"],"test_imports":[]}} {"problem_id":"mbpp_test_00280","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).\n\nTests:\nassert sequential_search([11,23,58,31,56,77,43,12,65,19],31) == (True, 3)\nassert sequential_search([12, 32, 45, 62, 35, 47, 44, 61],61) == (True, 7)\nassert sequential_search([9, 10, 17, 19, 22, 39, 48, 56],48) == (True, 6)","canonical_answer":"def sequential_search(dlist, item):\n pos = 0\n found = False\n while pos < len(dlist) and not found:\n if dlist[pos] == item:\n found = True\n else:\n pos = pos + 1\n return found, pos","verification_metadata":{"test_list":["assert sequential_search([11,23,58,31,56,77,43,12,65,19],31) == (True, 3)","assert sequential_search([12, 32, 45, 62, 35, 47, 44, 61],61) == (True, 7)","assert sequential_search([9, 10, 17, 19, 22, 39, 48, 56],48) == (True, 6)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":280,"text":"Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).","code":"def sequential_search(dlist, item):\n pos = 0\n found = False\n while pos < len(dlist) and not found:\n if dlist[pos] == item:\n found = True\n else:\n pos = pos + 1\n return found, pos","test_list":["assert sequential_search([11,23,58,31,56,77,43,12,65,19],31) == (True, 3)","assert sequential_search([12, 32, 45, 62, 35, 47, 44, 61],61) == (True, 7)","assert sequential_search([9, 10, 17, 19, 22, 39, 48, 56],48) == (True, 6)"],"test_imports":[]}} {"problem_id":"mbpp_test_00281","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check if the elements of a given list are unique or not.\n\nTests:\nassert all_unique([1,2,3]) == True\nassert all_unique([1,2,1,2]) == False\nassert all_unique([1,2,3,4,5]) == True","canonical_answer":"def all_unique(test_list):\n if len(test_list) > len(set(test_list)):\n return False\n return True","verification_metadata":{"test_list":["assert all_unique([1,2,3]) == True","assert all_unique([1,2,1,2]) == False","assert all_unique([1,2,3,4,5]) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":281,"text":"Write a python function to check if the elements of a given list are unique or not.","code":"def all_unique(test_list):\n if len(test_list) > len(set(test_list)):\n return False\n return True","test_list":["assert all_unique([1,2,3]) == True","assert all_unique([1,2,1,2]) == False","assert all_unique([1,2,3,4,5]) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00282","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to subtract two lists element-wise.\n\nTests:\nassert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]\nassert sub_list([1,2],[3,4])==[-2,-2]\nassert sub_list([90,120],[50,70])==[40,50]","canonical_answer":"def sub_list(nums1,nums2):\n result = map(lambda x, y: x - y, nums1, nums2)\n return list(result)","verification_metadata":{"test_list":["assert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]","assert sub_list([1,2],[3,4])==[-2,-2]","assert sub_list([90,120],[50,70])==[40,50]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":282,"text":"Write a function to subtract two lists element-wise.","code":"def sub_list(nums1,nums2):\n result = map(lambda x, y: x - y, nums1, nums2)\n return list(result)","test_list":["assert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]","assert sub_list([1,2],[3,4])==[-2,-2]","assert sub_list([90,120],[50,70])==[40,50]"],"test_imports":[]}} {"problem_id":"mbpp_test_00283","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.\n\nTests:\nassert validate(1234) == True\nassert validate(51241) == False\nassert validate(321) == True","canonical_answer":"def validate(n): \n for i in range(10): \n temp = n; \n count = 0; \n while (temp): \n if (temp % 10 == i): \n count+=1; \n if (count > i): \n return False\n temp //= 10; \n return True","verification_metadata":{"test_list":["assert validate(1234) == True","assert validate(51241) == False","assert validate(321) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":283,"text":"Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.","code":"def validate(n): \n for i in range(10): \n temp = n; \n count = 0; \n while (temp): \n if (temp % 10 == i): \n count+=1; \n if (count > i): \n return False\n temp //= 10; \n return True","test_list":["assert validate(1234) == True","assert validate(51241) == False","assert validate(321) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00284","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes in a list and element and checks whether all items in the list are equal to the given element.\n\nTests:\nassert check_element([\"green\", \"orange\", \"black\", \"white\"],'blue')==False\nassert check_element([1,2,3,4],7)==False\nassert check_element([\"green\", \"green\", \"green\", \"green\"],'green')==True","canonical_answer":"def check_element(list,element):\n check_element=all(v== element for v in list)\n return check_element","verification_metadata":{"test_list":["assert check_element([\"green\", \"orange\", \"black\", \"white\"],'blue')==False","assert check_element([1,2,3,4],7)==False","assert check_element([\"green\", \"green\", \"green\", \"green\"],'green')==True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":284,"text":"Write a function that takes in a list and element and checks whether all items in the list are equal to the given element.","code":"def check_element(list,element):\n check_element=all(v== element for v in list)\n return check_element","test_list":["assert check_element([\"green\", \"orange\", \"black\", \"white\"],'blue')==False","assert check_element([1,2,3,4],7)==False","assert check_element([\"green\", \"green\", \"green\", \"green\"],'green')==True"],"test_imports":[]}} {"problem_id":"mbpp_test_00285","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.\n\nTests:\nassert text_match_two_three(\"ac\")==(False)\nassert text_match_two_three(\"dc\")==(False)\nassert text_match_two_three(\"abbbba\")==(True)","canonical_answer":"import re\ndef text_match_two_three(text):\n patterns = 'ab{2,3}'\n if re.search(patterns, text):\n return True\n else:\n return False","verification_metadata":{"test_list":["assert text_match_two_three(\"ac\")==(False)","assert text_match_two_three(\"dc\")==(False)","assert text_match_two_three(\"abbbba\")==(True)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":285,"text":"Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.","code":"import re\ndef text_match_two_three(text):\n patterns = 'ab{2,3}'\n if re.search(patterns, text):\n return True\n else:\n return False","test_list":["assert text_match_two_three(\"ac\")==(False)","assert text_match_two_three(\"dc\")==(False)","assert text_match_two_three(\"abbbba\")==(True)"],"test_imports":[]}} {"problem_id":"mbpp_test_00286","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.\n\nTests:\nassert max_sub_array_sum_repeated([10, 20, -30, -1], 4, 3) == 30\nassert max_sub_array_sum_repeated([-1, 10, 20], 3, 2) == 59\nassert max_sub_array_sum_repeated([-1, -2, -3], 3, 3) == -1","canonical_answer":"def max_sub_array_sum_repeated(a, n, k): \n\tmax_so_far = -2147483648\n\tmax_ending_here = 0\n\tfor i in range(n*k): \n\t\tmax_ending_here = max_ending_here + a[i%n] \n\t\tif (max_so_far < max_ending_here): \n\t\t\tmax_so_far = max_ending_here \n\t\tif (max_ending_here < 0): \n\t\t\tmax_ending_here = 0\n\treturn max_so_far","verification_metadata":{"test_list":["assert max_sub_array_sum_repeated([10, 20, -30, -1], 4, 3) == 30","assert max_sub_array_sum_repeated([-1, 10, 20], 3, 2) == 59","assert max_sub_array_sum_repeated([-1, -2, -3], 3, 3) == -1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":286,"text":"Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.","code":"def max_sub_array_sum_repeated(a, n, k): \n\tmax_so_far = -2147483648\n\tmax_ending_here = 0\n\tfor i in range(n*k): \n\t\tmax_ending_here = max_ending_here + a[i%n] \n\t\tif (max_so_far < max_ending_here): \n\t\t\tmax_so_far = max_ending_here \n\t\tif (max_ending_here < 0): \n\t\t\tmax_ending_here = 0\n\treturn max_so_far","test_list":["assert max_sub_array_sum_repeated([10, 20, -30, -1], 4, 3) == 30","assert max_sub_array_sum_repeated([-1, 10, 20], 3, 2) == 59","assert max_sub_array_sum_repeated([-1, -2, -3], 3, 3) == -1"],"test_imports":[]}} {"problem_id":"mbpp_test_00287","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function takes in an integer n and returns the sum of squares of first n even natural numbers.\n\nTests:\nassert square_Sum(2) == 20\nassert square_Sum(3) == 56\nassert square_Sum(4) == 120","canonical_answer":"def square_Sum(n): \n return int(2*n*(n+1)*(2*n+1)/3)","verification_metadata":{"test_list":["assert square_Sum(2) == 20","assert square_Sum(3) == 56","assert square_Sum(4) == 120"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":287,"text":"Write a python function takes in an integer n and returns the sum of squares of first n even natural numbers.","code":"def square_Sum(n): \n return int(2*n*(n+1)*(2*n+1)/3)","test_list":["assert square_Sum(2) == 20","assert square_Sum(3) == 56","assert square_Sum(4) == 120"],"test_imports":[]}} {"problem_id":"mbpp_test_00290","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the list of maximum length in a list of lists.\n\nTests:\nassert max_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])\nassert max_length([[1], [5, 7], [10, 12, 14,15]])==(4, [10, 12, 14,15])\nassert max_length([[5], [15,20,25]])==(3, [15,20,25])","canonical_answer":"def max_length(list1):\n max_length = max(len(x) for x in list1 ) \n max_list = max((x) for x in list1)\n return(max_length, max_list)","verification_metadata":{"test_list":["assert max_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])","assert max_length([[1], [5, 7], [10, 12, 14,15]])==(4, [10, 12, 14,15])","assert max_length([[5], [15,20,25]])==(3, [15,20,25])"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":290,"text":"Write a function to find the list of maximum length in a list of lists.","code":"def max_length(list1):\n max_length = max(len(x) for x in list1 ) \n max_list = max((x) for x in list1)\n return(max_length, max_list)","test_list":["assert max_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])","assert max_length([[1], [5, 7], [10, 12, 14,15]])==(4, [10, 12, 14,15])","assert max_length([[5], [15,20,25]])==(3, [15,20,25])"],"test_imports":[]}} {"problem_id":"mbpp_test_00291","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.\n\nTests:\nassert count_no_of_ways(2, 4) == 16\nassert count_no_of_ways(3, 2) == 6\nassert count_no_of_ways(4, 4) == 228","canonical_answer":"def count_no_of_ways(n, k): \n\tdp = [0] * (n + 1) \n\ttotal = k \n\tmod = 1000000007\n\tdp[1] = k \n\tdp[2] = k * k\t \n\tfor i in range(3,n+1): \n\t\tdp[i] = ((k - 1) * (dp[i - 1] + dp[i - 2])) % mod \n\treturn dp[n]","verification_metadata":{"test_list":["assert count_no_of_ways(2, 4) == 16","assert count_no_of_ways(3, 2) == 6","assert count_no_of_ways(4, 4) == 228"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":291,"text":"Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.","code":"def count_no_of_ways(n, k): \n\tdp = [0] * (n + 1) \n\ttotal = k \n\tmod = 1000000007\n\tdp[1] = k \n\tdp[2] = k * k\t \n\tfor i in range(3,n+1): \n\t\tdp[i] = ((k - 1) * (dp[i - 1] + dp[i - 2])) % mod \n\treturn dp[n]","test_list":["assert count_no_of_ways(2, 4) == 16","assert count_no_of_ways(3, 2) == 6","assert count_no_of_ways(4, 4) == 228"],"test_imports":[]}} {"problem_id":"mbpp_test_00292","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find quotient of two numbers (rounded down to the nearest integer).\n\nTests:\nassert find(10,3) == 3\nassert find(4,2) == 2\nassert find(20,5) == 4","canonical_answer":"def find(n,m): \n q = n//m \n return (q)","verification_metadata":{"test_list":["assert find(10,3) == 3","assert find(4,2) == 2","assert find(20,5) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":292,"text":"Write a python function to find quotient of two numbers (rounded down to the nearest integer).","code":"def find(n,m): \n q = n//m \n return (q)","test_list":["assert find(10,3) == 3","assert find(4,2) == 2","assert find(20,5) == 4"],"test_imports":[]}} {"problem_id":"mbpp_test_00293","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the third side of a right angled triangle.\n\nTests:\nassert otherside_rightangle(7,8)==10.63014581273465\nassert otherside_rightangle(3,4)==5\nassert otherside_rightangle(7,15)==16.55294535724685","canonical_answer":"import math\ndef otherside_rightangle(w,h):\n s=math.sqrt((w*w)+(h*h))\n return s","verification_metadata":{"test_list":["assert otherside_rightangle(7,8)==10.63014581273465","assert otherside_rightangle(3,4)==5","assert otherside_rightangle(7,15)==16.55294535724685"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":293,"text":"Write a function to find the third side of a right angled triangle.","code":"import math\ndef otherside_rightangle(w,h):\n s=math.sqrt((w*w)+(h*h))\n return s","test_list":["assert otherside_rightangle(7,8)==10.63014581273465","assert otherside_rightangle(3,4)==5","assert otherside_rightangle(7,15)==16.55294535724685"],"test_imports":[]}} {"problem_id":"mbpp_test_00294","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the maximum value in a given heterogeneous list.\n\nTests:\nassert max_val(['Python', 3, 2, 4, 5, 'version'])==5\nassert max_val(['Python', 15, 20, 25])==25\nassert max_val(['Python', 30, 20, 40, 50, 'version'])==50","canonical_answer":"def max_val(listval):\n max_val = max(i for i in listval if isinstance(i, int)) \n return(max_val)","verification_metadata":{"test_list":["assert max_val(['Python', 3, 2, 4, 5, 'version'])==5","assert max_val(['Python', 15, 20, 25])==25","assert max_val(['Python', 30, 20, 40, 50, 'version'])==50"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":294,"text":"Write a function to find the maximum value in a given heterogeneous list.","code":"def max_val(listval):\n max_val = max(i for i in listval if isinstance(i, int)) \n return(max_val)","test_list":["assert max_val(['Python', 3, 2, 4, 5, 'version'])==5","assert max_val(['Python', 15, 20, 25])==25","assert max_val(['Python', 30, 20, 40, 50, 'version'])==50"],"test_imports":[]}} {"problem_id":"mbpp_test_00295","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to return the sum of all divisors of a number.\n\nTests:\nassert sum_div(8)==7\nassert sum_div(12)==16\nassert sum_div(7)==1","canonical_answer":"def sum_div(number):\n divisors = [1]\n for i in range(2, number):\n if (number % i)==0:\n divisors.append(i)\n return sum(divisors)","verification_metadata":{"test_list":["assert sum_div(8)==7","assert sum_div(12)==16","assert sum_div(7)==1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":295,"text":"Write a function to return the sum of all divisors of a number.","code":"def sum_div(number):\n divisors = [1]\n for i in range(2, number):\n if (number % i)==0:\n divisors.append(i)\n return sum(divisors)","test_list":["assert sum_div(8)==7","assert sum_div(12)==16","assert sum_div(7)==1"],"test_imports":[]}} {"problem_id":"mbpp_test_00296","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count inversions in an array.\n\nTests:\nassert get_Inv_Count([1,20,6,4,5]) == 5\nassert get_Inv_Count([1,2,1]) == 1\nassert get_Inv_Count([1,2,5,6,1]) == 3","canonical_answer":"def get_Inv_Count(arr): \n inv_count = 0\n for i in range(len(arr)): \n for j in range(i + 1, len(arr)): \n if (arr[i] > arr[j]): \n inv_count += 1\n return inv_count","verification_metadata":{"test_list":["assert get_Inv_Count([1,20,6,4,5]) == 5","assert get_Inv_Count([1,2,1]) == 1","assert get_Inv_Count([1,2,5,6,1]) == 3"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":296,"text":"Write a python function to count inversions in an array.","code":"def get_Inv_Count(arr): \n inv_count = 0\n for i in range(len(arr)): \n for j in range(i + 1, len(arr)): \n if (arr[i] > arr[j]): \n inv_count += 1\n return inv_count","test_list":["assert get_Inv_Count([1,20,6,4,5]) == 5","assert get_Inv_Count([1,2,1]) == 1","assert get_Inv_Count([1,2,5,6,1]) == 3"],"test_imports":[]}} {"problem_id":"mbpp_test_00297","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to flatten a given nested list structure.\n\nTests:\nassert flatten_list([0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]])==[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]\nassert flatten_list([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]\nassert flatten_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]","canonical_answer":"def flatten_list(list1):\n result_list = []\n if not list1: return result_list\n stack = [list(list1)]\n while stack:\n c_num = stack.pop()\n next = c_num.pop()\n if c_num: stack.append(c_num)\n if isinstance(next, list):\n if next: stack.append(list(next))\n else: result_list.append(next)\n result_list.reverse()\n return result_list","verification_metadata":{"test_list":["assert flatten_list([0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]])==[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]","assert flatten_list([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]","assert flatten_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":297,"text":"Write a function to flatten a given nested list structure.","code":"def flatten_list(list1):\n result_list = []\n if not list1: return result_list\n stack = [list(list1)]\n while stack:\n c_num = stack.pop()\n next = c_num.pop()\n if c_num: stack.append(c_num)\n if isinstance(next, list):\n if next: stack.append(list(next))\n else: result_list.append(next)\n result_list.reverse()\n return result_list","test_list":["assert flatten_list([0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]])==[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]","assert flatten_list([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]","assert flatten_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]"],"test_imports":[]}} {"problem_id":"mbpp_test_00299","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to calculate the maximum aggregate from the list of tuples.\n\nTests:\nassert max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)])==('Juan Whelan', 212)\nassert max_aggregate([('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)])==('Juan Whelan', 72)\nassert max_aggregate([('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)])==('Sabah Colley', 70)","canonical_answer":"from collections import defaultdict\ndef max_aggregate(stdata):\n temp = defaultdict(int)\n for name, marks in stdata:\n temp[name] += marks\n return max(temp.items(), key=lambda x: x[1])","verification_metadata":{"test_list":["assert max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)])==('Juan Whelan', 212)","assert max_aggregate([('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)])==('Juan Whelan', 72)","assert max_aggregate([('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)])==('Sabah Colley', 70)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":299,"text":"Write a function to calculate the maximum aggregate from the list of tuples.","code":"from collections import defaultdict\ndef max_aggregate(stdata):\n temp = defaultdict(int)\n for name, marks in stdata:\n temp[name] += marks\n return max(temp.items(), key=lambda x: x[1])","test_list":["assert max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)])==('Juan Whelan', 212)","assert max_aggregate([('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)])==('Juan Whelan', 72)","assert max_aggregate([('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)])==('Sabah Colley', 70)"],"test_imports":[]}} {"problem_id":"mbpp_test_00300","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.\n\nTests:\nassert math.isclose(count_binary_seq(1), 2.0, rel_tol=0.001)\nassert math.isclose(count_binary_seq(2), 6.0, rel_tol=0.001)\nassert math.isclose(count_binary_seq(3), 20.0, rel_tol=0.001)","canonical_answer":"def count_binary_seq(n): \n\tnCr = 1\n\tres = 1\n\tfor r in range(1, n + 1): \n\t\tnCr = (nCr * (n + 1 - r)) / r \n\t\tres += nCr * nCr \n\treturn res","verification_metadata":{"test_list":["assert math.isclose(count_binary_seq(1), 2.0, rel_tol=0.001)","assert math.isclose(count_binary_seq(2), 6.0, rel_tol=0.001)","assert math.isclose(count_binary_seq(3), 20.0, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":300,"text":"Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.","code":"def count_binary_seq(n): \n\tnCr = 1\n\tres = 1\n\tfor r in range(1, n + 1): \n\t\tnCr = (nCr * (n + 1 - r)) / r \n\t\tres += nCr * nCr \n\treturn res","test_list":["assert math.isclose(count_binary_seq(1), 2.0, rel_tol=0.001)","assert math.isclose(count_binary_seq(2), 6.0, rel_tol=0.001)","assert math.isclose(count_binary_seq(3), 20.0, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00301","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the depth of a dictionary.\n\nTests:\nassert dict_depth({'a':1, 'b': {'c': {'d': {}}}})==4\nassert dict_depth({'a':1, 'b': {'c':'python'}})==2\nassert dict_depth({1: 'Sun', 2: {3: {4:'Mon'}}})==3","canonical_answer":"def dict_depth(d):\n if isinstance(d, dict):\n return 1 + (max(map(dict_depth, d.values())) if d else 0)\n return 0","verification_metadata":{"test_list":["assert dict_depth({'a':1, 'b': {'c': {'d': {}}}})==4","assert dict_depth({'a':1, 'b': {'c':'python'}})==2","assert dict_depth({1: 'Sun', 2: {3: {4:'Mon'}}})==3"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":301,"text":"Write a function to find the depth of a dictionary.","code":"def dict_depth(d):\n if isinstance(d, dict):\n return 1 + (max(map(dict_depth, d.values())) if d else 0)\n return 0","test_list":["assert dict_depth({'a':1, 'b': {'c': {'d': {}}}})==4","assert dict_depth({'a':1, 'b': {'c':'python'}})==2","assert dict_depth({1: 'Sun', 2: {3: {4:'Mon'}}})==3"],"test_imports":[]}} {"problem_id":"mbpp_test_00304","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find element at a given index after number of rotations.\n\nTests:\nassert find_Element([1,2,3,4,5],[[0,2],[0,3]],2,1) == 3\nassert find_Element([1,2,3,4],[[0,1],[0,2]],1,2) == 3\nassert find_Element([1,2,3,4,5,6],[[0,1],[0,2]],1,1) == 1","canonical_answer":"def find_Element(arr,ranges,rotations,index) : \n for i in range(rotations - 1,-1,-1 ) : \n left = ranges[i][0] \n right = ranges[i][1] \n if (left <= index and right >= index) : \n if (index == left) : \n index = right \n else : \n index = index - 1 \n return arr[index]","verification_metadata":{"test_list":["assert find_Element([1,2,3,4,5],[[0,2],[0,3]],2,1) == 3","assert find_Element([1,2,3,4],[[0,1],[0,2]],1,2) == 3","assert find_Element([1,2,3,4,5,6],[[0,1],[0,2]],1,1) == 1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":304,"text":"Write a python function to find element at a given index after number of rotations.","code":"def find_Element(arr,ranges,rotations,index) : \n for i in range(rotations - 1,-1,-1 ) : \n left = ranges[i][0] \n right = ranges[i][1] \n if (left <= index and right >= index) : \n if (index == left) : \n index = right \n else : \n index = index - 1 \n return arr[index]","test_list":["assert find_Element([1,2,3,4,5],[[0,2],[0,3]],2,1) == 3","assert find_Element([1,2,3,4],[[0,1],[0,2]],1,2) == 3","assert find_Element([1,2,3,4,5,6],[[0,1],[0,2]],1,1) == 1"],"test_imports":[]}} {"problem_id":"mbpp_test_00305","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to return two words from a list of words starting with letter 'p'.\n\nTests:\nassert start_withp([\"Python PHP\", \"Java JavaScript\", \"c c++\"])==('Python', 'PHP')\nassert start_withp([\"Python Programming\",\"Java Programming\"])==('Python','Programming')\nassert start_withp([\"Pqrst Pqr\",\"qrstuv\"])==('Pqrst','Pqr')","canonical_answer":"import re\ndef start_withp(words):\n for w in words:\n m = re.match(\"(P\\w+)\\W(P\\w+)\", w)\n if m:\n return m.groups()","verification_metadata":{"test_list":["assert start_withp([\"Python PHP\", \"Java JavaScript\", \"c c++\"])==('Python', 'PHP')","assert start_withp([\"Python Programming\",\"Java Programming\"])==('Python','Programming')","assert start_withp([\"Pqrst Pqr\",\"qrstuv\"])==('Pqrst','Pqr')"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":305,"text":"Write a function to return two words from a list of words starting with letter 'p'.","code":"import re\ndef start_withp(words):\n for w in words:\n m = re.match(\"(P\\w+)\\W(P\\w+)\", w)\n if m:\n return m.groups()","test_list":["assert start_withp([\"Python PHP\", \"Java JavaScript\", \"c c++\"])==('Python', 'PHP')","assert start_withp([\"Python Programming\",\"Java Programming\"])==('Python','Programming')","assert start_withp([\"Pqrst Pqr\",\"qrstuv\"])==('Pqrst','Pqr')"],"test_imports":[]}} {"problem_id":"mbpp_test_00306","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .\n\nTests:\nassert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6) == 11\nassert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5) == 7\nassert max_sum_increasing_subseq([11, 15, 19, 21, 26, 28, 31], 7, 2, 4) == 71","canonical_answer":"def max_sum_increasing_subseq(a, n, index, k):\n\tdp = [[0 for i in range(n)] \n\t\t\tfor i in range(n)]\n\tfor i in range(n):\n\t\tif a[i] > a[0]:\n\t\t\tdp[0][i] = a[i] + a[0]\n\t\telse:\n\t\t\tdp[0][i] = a[i]\n\tfor i in range(1, n):\n\t\tfor j in range(n):\n\t\t\tif a[j] > a[i] and j > i:\n\t\t\t\tif dp[i - 1][i] + a[j] > dp[i - 1][j]:\n\t\t\t\t\tdp[i][j] = dp[i - 1][i] + a[j]\n\t\t\t\telse:\n\t\t\t\t\tdp[i][j] = dp[i - 1][j]\n\t\t\telse:\n\t\t\t\tdp[i][j] = dp[i - 1][j]\n\treturn dp[index][k]","verification_metadata":{"test_list":["assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6) == 11","assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5) == 7","assert max_sum_increasing_subseq([11, 15, 19, 21, 26, 28, 31], 7, 2, 4) == 71"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":306,"text":"Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .","code":"def max_sum_increasing_subseq(a, n, index, k):\n\tdp = [[0 for i in range(n)] \n\t\t\tfor i in range(n)]\n\tfor i in range(n):\n\t\tif a[i] > a[0]:\n\t\t\tdp[0][i] = a[i] + a[0]\n\t\telse:\n\t\t\tdp[0][i] = a[i]\n\tfor i in range(1, n):\n\t\tfor j in range(n):\n\t\t\tif a[j] > a[i] and j > i:\n\t\t\t\tif dp[i - 1][i] + a[j] > dp[i - 1][j]:\n\t\t\t\t\tdp[i][j] = dp[i - 1][i] + a[j]\n\t\t\t\telse:\n\t\t\t\t\tdp[i][j] = dp[i - 1][j]\n\t\t\telse:\n\t\t\t\tdp[i][j] = dp[i - 1][j]\n\treturn dp[index][k]","test_list":["assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6) == 11","assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5) == 7","assert max_sum_increasing_subseq([11, 15, 19, 21, 26, 28, 31], 7, 2, 4) == 71"],"test_imports":[]}} {"problem_id":"mbpp_test_00307","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to get a colon of a tuple.\n\nTests:\nassert colon_tuplex((\"HELLO\", 5, [], True) ,2,50)==(\"HELLO\", 5, [50], True)\nassert colon_tuplex((\"HELLO\", 5, [], True) ,2,100)==((\"HELLO\", 5, [100],True))\nassert colon_tuplex((\"HELLO\", 5, [], True) ,2,500)==(\"HELLO\", 5, [500], True)","canonical_answer":"from copy import deepcopy\ndef colon_tuplex(tuplex,m,n):\n tuplex_colon = deepcopy(tuplex)\n tuplex_colon[m].append(n)\n return tuplex_colon","verification_metadata":{"test_list":["assert colon_tuplex((\"HELLO\", 5, [], True) ,2,50)==(\"HELLO\", 5, [50], True)","assert colon_tuplex((\"HELLO\", 5, [], True) ,2,100)==((\"HELLO\", 5, [100],True))","assert colon_tuplex((\"HELLO\", 5, [], True) ,2,500)==(\"HELLO\", 5, [500], True)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":307,"text":"Write a function to get a colon of a tuple.","code":"from copy import deepcopy\ndef colon_tuplex(tuplex,m,n):\n tuplex_colon = deepcopy(tuplex)\n tuplex_colon[m].append(n)\n return tuplex_colon","test_list":["assert colon_tuplex((\"HELLO\", 5, [], True) ,2,50)==(\"HELLO\", 5, [50], True)","assert colon_tuplex((\"HELLO\", 5, [], True) ,2,100)==((\"HELLO\", 5, [100],True))","assert colon_tuplex((\"HELLO\", 5, [], True) ,2,500)==(\"HELLO\", 5, [500], True)"],"test_imports":[]}} {"problem_id":"mbpp_test_00308","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the specified number of largest products from two given lists, selecting one factor from each list.\n\nTests:\nassert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)==[60, 54, 50]\nassert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],4)==[60, 54, 50, 48]\nassert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],5)==[60, 54, 50, 48, 45]","canonical_answer":"def large_product(nums1, nums2, N):\n result = sorted([x*y for x in nums1 for y in nums2], reverse=True)[:N]\n return result","verification_metadata":{"test_list":["assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)==[60, 54, 50]","assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],4)==[60, 54, 50, 48]","assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],5)==[60, 54, 50, 48, 45]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":308,"text":"Write a function to find the specified number of largest products from two given lists, selecting one factor from each list.","code":"def large_product(nums1, nums2, N):\n result = sorted([x*y for x in nums1 for y in nums2], reverse=True)[:N]\n return result","test_list":["assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)==[60, 54, 50]","assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],4)==[60, 54, 50, 48]","assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],5)==[60, 54, 50, 48, 45]"],"test_imports":[]}} {"problem_id":"mbpp_test_00309","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the maximum of two numbers.\n\nTests:\nassert maximum(5,10) == 10\nassert maximum(-1,-2) == -1\nassert maximum(9,7) == 9","canonical_answer":"def maximum(a,b): \n if a >= b: \n return a \n else: \n return b","verification_metadata":{"test_list":["assert maximum(5,10) == 10","assert maximum(-1,-2) == -1","assert maximum(9,7) == 9"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":309,"text":"Write a python function to find the maximum of two numbers.","code":"def maximum(a,b): \n if a >= b: \n return a \n else: \n return b","test_list":["assert maximum(5,10) == 10","assert maximum(-1,-2) == -1","assert maximum(9,7) == 9"],"test_imports":[]}} {"problem_id":"mbpp_test_00310","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert a given string to a tuple of characters.\n\nTests:\nassert string_to_tuple(\"python 3.0\")==('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')\nassert string_to_tuple(\"item1\")==('i', 't', 'e', 'm', '1')\nassert string_to_tuple(\"15.10\")==('1', '5', '.', '1', '0')","canonical_answer":"def string_to_tuple(str1):\n result = tuple(x for x in str1 if not x.isspace()) \n return result","verification_metadata":{"test_list":["assert string_to_tuple(\"python 3.0\")==('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')","assert string_to_tuple(\"item1\")==('i', 't', 'e', 'm', '1')","assert string_to_tuple(\"15.10\")==('1', '5', '.', '1', '0')"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":310,"text":"Write a function to convert a given string to a tuple of characters.","code":"def string_to_tuple(str1):\n result = tuple(x for x in str1 if not x.isspace()) \n return result","test_list":["assert string_to_tuple(\"python 3.0\")==('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')","assert string_to_tuple(\"item1\")==('i', 't', 'e', 'm', '1')","assert string_to_tuple(\"15.10\")==('1', '5', '.', '1', '0')"],"test_imports":[]}} {"problem_id":"mbpp_test_00311","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to set the left most unset bit.\n\nTests:\nassert set_left_most_unset_bit(10) == 14\nassert set_left_most_unset_bit(12) == 14\nassert set_left_most_unset_bit(15) == 15","canonical_answer":"def set_left_most_unset_bit(n): \n if not (n & (n + 1)): \n return n \n pos, temp, count = 0, n, 0 \n while temp: \n if not (temp & 1): \n pos = count \n count += 1; temp>>=1\n return (n | (1 << (pos)))","verification_metadata":{"test_list":["assert set_left_most_unset_bit(10) == 14","assert set_left_most_unset_bit(12) == 14","assert set_left_most_unset_bit(15) == 15"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":311,"text":"Write a python function to set the left most unset bit.","code":"def set_left_most_unset_bit(n): \n if not (n & (n + 1)): \n return n \n pos, temp, count = 0, n, 0 \n while temp: \n if not (temp & 1): \n pos = count \n count += 1; temp>>=1\n return (n | (1 << (pos)))","test_list":["assert set_left_most_unset_bit(10) == 14","assert set_left_most_unset_bit(12) == 14","assert set_left_most_unset_bit(15) == 15"],"test_imports":[]}} {"problem_id":"mbpp_test_00312","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the volume of a cone.\n\nTests:\nassert math.isclose(volume_cone(5,12), 314.15926535897927, rel_tol=0.001)\nassert math.isclose(volume_cone(10,15), 1570.7963267948965, rel_tol=0.001)\nassert math.isclose(volume_cone(19,17), 6426.651371693521, rel_tol=0.001)","canonical_answer":"import math\ndef volume_cone(r,h):\n volume = (1.0/3) * math.pi * r * r * h\n return volume","verification_metadata":{"test_list":["assert math.isclose(volume_cone(5,12), 314.15926535897927, rel_tol=0.001)","assert math.isclose(volume_cone(10,15), 1570.7963267948965, rel_tol=0.001)","assert math.isclose(volume_cone(19,17), 6426.651371693521, rel_tol=0.001)"],"test_imports":["import math"],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":312,"text":"Write a function to find the volume of a cone.","code":"import math\ndef volume_cone(r,h):\n volume = (1.0/3) * math.pi * r * r * h\n return volume","test_list":["assert math.isclose(volume_cone(5,12), 314.15926535897927, rel_tol=0.001)","assert math.isclose(volume_cone(10,15), 1570.7963267948965, rel_tol=0.001)","assert math.isclose(volume_cone(19,17), 6426.651371693521, rel_tol=0.001)"],"test_imports":["import math"]}} {"problem_id":"mbpp_test_00388","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the highest power of 2 that is less than or equal to n.\n\nTests:\nassert highest_Power_of_2(10) == 8\nassert highest_Power_of_2(19) == 16\nassert highest_Power_of_2(32) == 32","canonical_answer":"def highest_Power_of_2(n): \n res = 0 \n for i in range(n, 0, -1): \n if ((i & (i - 1)) == 0): \n res = i \n break \n return res","verification_metadata":{"test_list":["assert highest_Power_of_2(10) == 8","assert highest_Power_of_2(19) == 16","assert highest_Power_of_2(32) == 32"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":388,"text":"Write a python function to find the highest power of 2 that is less than or equal to n.","code":"def highest_Power_of_2(n): \n res = 0 \n for i in range(n, 0, -1): \n if ((i & (i - 1)) == 0): \n res = i \n break \n return res","test_list":["assert highest_Power_of_2(10) == 8","assert highest_Power_of_2(19) == 16","assert highest_Power_of_2(32) == 32"],"test_imports":[]}} {"problem_id":"mbpp_test_00389","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the n'th lucas number.\n\nTests:\nassert find_lucas(9) == 76\nassert find_lucas(4) == 7\nassert find_lucas(3) == 4","canonical_answer":"def find_lucas(n): \n\tif (n == 0): \n\t\treturn 2\n\tif (n == 1): \n\t\treturn 1\n\treturn find_lucas(n - 1) + find_lucas(n - 2)","verification_metadata":{"test_list":["assert find_lucas(9) == 76","assert find_lucas(4) == 7","assert find_lucas(3) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":389,"text":"Write a function to find the n'th lucas number.","code":"def find_lucas(n): \n\tif (n == 0): \n\t\treturn 2\n\tif (n == 1): \n\t\treturn 1\n\treturn find_lucas(n - 1) + find_lucas(n - 2)","test_list":["assert find_lucas(9) == 76","assert find_lucas(4) == 7","assert find_lucas(3) == 4"],"test_imports":[]}} {"problem_id":"mbpp_test_00390","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to apply a given format string to all of the elements in a list.\n\nTests:\nassert add_string([1,2,3,4],'temp{0}')==['temp1', 'temp2', 'temp3', 'temp4']\nassert add_string(['a','b','c','d'], 'python{0}')==[ 'pythona', 'pythonb', 'pythonc', 'pythond']\nassert add_string([5,6,7,8],'string{0}')==['string5', 'string6', 'string7', 'string8']","canonical_answer":"def add_string(list_, string):\n add_string=[string.format(i) for i in list_]\n return add_string","verification_metadata":{"test_list":["assert add_string([1,2,3,4],'temp{0}')==['temp1', 'temp2', 'temp3', 'temp4']","assert add_string(['a','b','c','d'], 'python{0}')==[ 'pythona', 'pythonb', 'pythonc', 'pythond']","assert add_string([5,6,7,8],'string{0}')==['string5', 'string6', 'string7', 'string8']"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":390,"text":"Write a function to apply a given format string to all of the elements in a list.","code":"def add_string(list_, string):\n add_string=[string.format(i) for i in list_]\n return add_string","test_list":["assert add_string([1,2,3,4],'temp{0}')==['temp1', 'temp2', 'temp3', 'temp4']","assert add_string(['a','b','c','d'], 'python{0}')==[ 'pythona', 'pythonb', 'pythonc', 'pythond']","assert add_string([5,6,7,8],'string{0}')==['string5', 'string6', 'string7', 'string8']"],"test_imports":[]}} {"problem_id":"mbpp_test_00391","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert more than one list to nested dictionary.\n\nTests:\nassert convert_list_dictionary([\"S001\", \"S002\", \"S003\", \"S004\"],[\"Adina Park\", \"Leyton Marsh\", \"Duncan Boyle\", \"Saim Richards\"] ,[85, 98, 89, 92])==[{'S001': {'Adina Park': 85}}, {'S002': {'Leyton Marsh': 98}}, {'S003': {'Duncan Boyle': 89}}, {'S004': {'Saim Richards': 92}}]\nassert convert_list_dictionary([\"abc\",\"def\",\"ghi\",\"jkl\"],[\"python\",\"program\",\"language\",\"programs\"],[100,200,300,400])==[{'abc':{'python':100}},{'def':{'program':200}},{'ghi':{'language':300}},{'jkl':{'programs':400}}]\nassert convert_list_dictionary([\"A1\",\"A2\",\"A3\",\"A4\"],[\"java\",\"C\",\"C++\",\"DBMS\"],[10,20,30,40])==[{'A1':{'java':10}},{'A2':{'C':20}},{'A3':{'C++':30}},{'A4':{'DBMS':40}}]","canonical_answer":"def convert_list_dictionary(l1, l2, l3):\n result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]\n return result","verification_metadata":{"test_list":["assert convert_list_dictionary([\"S001\", \"S002\", \"S003\", \"S004\"],[\"Adina Park\", \"Leyton Marsh\", \"Duncan Boyle\", \"Saim Richards\"] ,[85, 98, 89, 92])==[{'S001': {'Adina Park': 85}}, {'S002': {'Leyton Marsh': 98}}, {'S003': {'Duncan Boyle': 89}}, {'S004': {'Saim Richards': 92}}]","assert convert_list_dictionary([\"abc\",\"def\",\"ghi\",\"jkl\"],[\"python\",\"program\",\"language\",\"programs\"],[100,200,300,400])==[{'abc':{'python':100}},{'def':{'program':200}},{'ghi':{'language':300}},{'jkl':{'programs':400}}]","assert convert_list_dictionary([\"A1\",\"A2\",\"A3\",\"A4\"],[\"java\",\"C\",\"C++\",\"DBMS\"],[10,20,30,40])==[{'A1':{'java':10}},{'A2':{'C':20}},{'A3':{'C++':30}},{'A4':{'DBMS':40}}]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":391,"text":"Write a function to convert more than one list to nested dictionary.","code":"def convert_list_dictionary(l1, l2, l3):\n result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]\n return result","test_list":["assert convert_list_dictionary([\"S001\", \"S002\", \"S003\", \"S004\"],[\"Adina Park\", \"Leyton Marsh\", \"Duncan Boyle\", \"Saim Richards\"] ,[85, 98, 89, 92])==[{'S001': {'Adina Park': 85}}, {'S002': {'Leyton Marsh': 98}}, {'S003': {'Duncan Boyle': 89}}, {'S004': {'Saim Richards': 92}}]","assert convert_list_dictionary([\"abc\",\"def\",\"ghi\",\"jkl\"],[\"python\",\"program\",\"language\",\"programs\"],[100,200,300,400])==[{'abc':{'python':100}},{'def':{'program':200}},{'ghi':{'language':300}},{'jkl':{'programs':400}}]","assert convert_list_dictionary([\"A1\",\"A2\",\"A3\",\"A4\"],[\"java\",\"C\",\"C++\",\"DBMS\"],[10,20,30,40])==[{'A1':{'java':10}},{'A2':{'C':20}},{'A3':{'C++':30}},{'A4':{'DBMS':40}}]"],"test_imports":[]}} {"problem_id":"mbpp_test_00392","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).\n\nTests:\nassert get_max_sum(60) == 106\nassert get_max_sum(10) == 12\nassert get_max_sum(2) == 2","canonical_answer":"def get_max_sum (n):\n\tres = list()\n\tres.append(0)\n\tres.append(1)\n\ti = 2\n\twhile i b:\n if a < c:\n median = a\n elif b > c:\n median = b\n else:\n median = c\n else:\n if a > c:\n median = a\n elif b < c:\n median = b\n else:\n median = c\n return median","verification_metadata":{"test_list":["assert median_numbers(25,55,65)==55.0","assert median_numbers(20,10,30)==20.0","assert median_numbers(15,45,75)==45.0"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":397,"text":"Write a function to find the median of three numbers.","code":"def median_numbers(a,b,c):\n if a > b:\n if a < c:\n median = a\n elif b > c:\n median = b\n else:\n median = c\n else:\n if a > c:\n median = a\n elif b < c:\n median = b\n else:\n median = c\n return median","test_list":["assert median_numbers(25,55,65)==55.0","assert median_numbers(20,10,30)==20.0","assert median_numbers(15,45,75)==45.0"],"test_imports":[]}} {"problem_id":"mbpp_test_00398","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to compute the sum of digits of each number of a given list.\n\nTests:\nassert sum_of_digits([10,2,56])==14\nassert sum_of_digits([[10,20,4,5,'b',70,'a']])==19\nassert sum_of_digits([10,20,-4,5,-70])==19","canonical_answer":"def sum_of_digits(nums):\n return sum(int(el) for n in nums for el in str(n) if el.isdigit())","verification_metadata":{"test_list":["assert sum_of_digits([10,2,56])==14","assert sum_of_digits([[10,20,4,5,'b',70,'a']])==19","assert sum_of_digits([10,20,-4,5,-70])==19"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":398,"text":"Write a function to compute the sum of digits of each number of a given list.","code":"def sum_of_digits(nums):\n return sum(int(el) for n in nums for el in str(n) if el.isdigit())","test_list":["assert sum_of_digits([10,2,56])==14","assert sum_of_digits([[10,20,4,5,'b',70,'a']])==19","assert sum_of_digits([10,20,-4,5,-70])==19"],"test_imports":[]}} {"problem_id":"mbpp_test_00399","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to perform the mathematical bitwise xor operation across the given tuples.\n\nTests:\nassert bitwise_xor((10, 4, 6, 9), (5, 2, 3, 3)) == (15, 6, 5, 10)\nassert bitwise_xor((11, 5, 7, 10), (6, 3, 4, 4)) == (13, 6, 3, 14)\nassert bitwise_xor((12, 6, 8, 11), (7, 4, 5, 6)) == (11, 2, 13, 13)","canonical_answer":"def bitwise_xor(test_tup1, test_tup2):\n res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\n return (res)","verification_metadata":{"test_list":["assert bitwise_xor((10, 4, 6, 9), (5, 2, 3, 3)) == (15, 6, 5, 10)","assert bitwise_xor((11, 5, 7, 10), (6, 3, 4, 4)) == (13, 6, 3, 14)","assert bitwise_xor((12, 6, 8, 11), (7, 4, 5, 6)) == (11, 2, 13, 13)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":399,"text":"Write a function to perform the mathematical bitwise xor operation across the given tuples.","code":"def bitwise_xor(test_tup1, test_tup2):\n res = tuple(ele1 ^ ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\n return (res)","test_list":["assert bitwise_xor((10, 4, 6, 9), (5, 2, 3, 3)) == (15, 6, 5, 10)","assert bitwise_xor((11, 5, 7, 10), (6, 3, 4, 4)) == (13, 6, 3, 14)","assert bitwise_xor((12, 6, 8, 11), (7, 4, 5, 6)) == (11, 2, 13, 13)"],"test_imports":[]}} {"problem_id":"mbpp_test_00400","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to extract the number of unique tuples in the given list.\n\nTests:\nassert extract_freq([(3, 4), (1, 2), (4, 3), (5, 6)] ) == 3\nassert extract_freq([(4, 15), (2, 3), (5, 4), (6, 7)] ) == 4\nassert extract_freq([(5, 16), (2, 3), (6, 5), (6, 9)] ) == 4","canonical_answer":"def extract_freq(test_list):\n res = len(list(set(tuple(sorted(sub)) for sub in test_list)))\n return (res)","verification_metadata":{"test_list":["assert extract_freq([(3, 4), (1, 2), (4, 3), (5, 6)] ) == 3","assert extract_freq([(4, 15), (2, 3), (5, 4), (6, 7)] ) == 4","assert extract_freq([(5, 16), (2, 3), (6, 5), (6, 9)] ) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":400,"text":"Write a function to extract the number of unique tuples in the given list.","code":"def extract_freq(test_list):\n res = len(list(set(tuple(sorted(sub)) for sub in test_list)))\n return (res)","test_list":["assert extract_freq([(3, 4), (1, 2), (4, 3), (5, 6)] ) == 3","assert extract_freq([(4, 15), (2, 3), (5, 4), (6, 7)] ) == 4","assert extract_freq([(5, 16), (2, 3), (6, 5), (6, 9)] ) == 4"],"test_imports":[]}} {"problem_id":"mbpp_test_00401","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to perform index wise addition of tuple elements in the given two nested tuples.\n\nTests:\nassert add_nested_tuples(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((7, 10), (7, 14), (3, 10), (8, 13))\nassert add_nested_tuples(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((9, 12), (9, 16), (5, 12), (10, 15))\nassert add_nested_tuples(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((11, 14), (11, 18), (7, 14), (12, 17))","canonical_answer":"def add_nested_tuples(test_tup1, test_tup2):\n res = tuple(tuple(a + b for a, b in zip(tup1, tup2))\n for tup1, tup2 in zip(test_tup1, test_tup2))\n return (res)","verification_metadata":{"test_list":["assert add_nested_tuples(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((7, 10), (7, 14), (3, 10), (8, 13))","assert add_nested_tuples(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((9, 12), (9, 16), (5, 12), (10, 15))","assert add_nested_tuples(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((11, 14), (11, 18), (7, 14), (12, 17))"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":401,"text":"Write a function to perform index wise addition of tuple elements in the given two nested tuples.","code":"def add_nested_tuples(test_tup1, test_tup2):\n res = tuple(tuple(a + b for a, b in zip(tup1, tup2))\n for tup1, tup2 in zip(test_tup1, test_tup2))\n return (res)","test_list":["assert add_nested_tuples(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((7, 10), (7, 14), (3, 10), (8, 13))","assert add_nested_tuples(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((9, 12), (9, 16), (5, 12), (10, 15))","assert add_nested_tuples(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((11, 14), (11, 18), (7, 14), (12, 17))"],"test_imports":[]}} {"problem_id":"mbpp_test_00404","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the minimum of two numbers.\n\nTests:\nassert minimum(1,2) == 1\nassert minimum(-5,-4) == -5\nassert minimum(0,0) == 0","canonical_answer":"def minimum(a,b): \n if a <= b: \n return a \n else: \n return b","verification_metadata":{"test_list":["assert minimum(1,2) == 1","assert minimum(-5,-4) == -5","assert minimum(0,0) == 0"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":404,"text":"Write a python function to find the minimum of two numbers.","code":"def minimum(a,b): \n if a <= b: \n return a \n else: \n return b","test_list":["assert minimum(1,2) == 1","assert minimum(-5,-4) == -5","assert minimum(0,0) == 0"],"test_imports":[]}} {"problem_id":"mbpp_test_00405","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether an element exists within a tuple.\n\nTests:\nassert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'r')==True\nassert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'5')==False\nassert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\",\"e\"),3)==True","canonical_answer":"def check_tuplex(tuplex,tuple1): \n if tuple1 in tuplex:\n return True\n else:\n return False","verification_metadata":{"test_list":["assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'r')==True","assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'5')==False","assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\",\"e\"),3)==True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":405,"text":"Write a function to check whether an element exists within a tuple.","code":"def check_tuplex(tuplex,tuple1): \n if tuple1 in tuplex:\n return True\n else:\n return False","test_list":["assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'r')==True","assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\", \"e\"),'5')==False","assert check_tuplex((\"w\", 3, \"r\", \"e\", \"s\", \"o\", \"u\", \"r\", \"c\",\"e\"),3)==True"],"test_imports":[]}} {"problem_id":"mbpp_test_00406","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find whether the parity of a given number is odd.\n\nTests:\nassert find_Parity(12) == False\nassert find_Parity(7) == True\nassert find_Parity(10) == False","canonical_answer":"def find_Parity(x): \n y = x ^ (x >> 1); \n y = y ^ (y >> 2); \n y = y ^ (y >> 4); \n y = y ^ (y >> 8); \n y = y ^ (y >> 16); \n if (y & 1): \n return True\n return False","verification_metadata":{"test_list":["assert find_Parity(12) == False","assert find_Parity(7) == True","assert find_Parity(10) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":406,"text":"Write a python function to find whether the parity of a given number is odd.","code":"def find_Parity(x): \n y = x ^ (x >> 1); \n y = y ^ (y >> 2); \n y = y ^ (y >> 4); \n y = y ^ (y >> 8); \n y = y ^ (y >> 16); \n if (y & 1): \n return True\n return False","test_list":["assert find_Parity(12) == False","assert find_Parity(7) == True","assert find_Parity(10) == False"],"test_imports":[]}} {"problem_id":"mbpp_test_00407","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to create the next bigger number by rearranging the digits of a given number.\n\nTests:\nassert rearrange_bigger(12)==21\nassert rearrange_bigger(10)==False\nassert rearrange_bigger(102)==120","canonical_answer":"def rearrange_bigger(n):\n nums = list(str(n))\n for i in range(len(nums)-2,-1,-1):\n if nums[i] < nums[i+1]:\n z = nums[i:]\n y = min(filter(lambda x: x > z[0], z))\n z.remove(y)\n z.sort()\n nums[i:] = [y] + z\n return int(\"\".join(nums))\n return False","verification_metadata":{"test_list":["assert rearrange_bigger(12)==21","assert rearrange_bigger(10)==False","assert rearrange_bigger(102)==120"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":407,"text":"Write a function to create the next bigger number by rearranging the digits of a given number.","code":"def rearrange_bigger(n):\n nums = list(str(n))\n for i in range(len(nums)-2,-1,-1):\n if nums[i] < nums[i+1]:\n z = nums[i:]\n y = min(filter(lambda x: x > z[0], z))\n z.remove(y)\n z.sort()\n nums[i:] = [y] + z\n return int(\"\".join(nums))\n return False","test_list":["assert rearrange_bigger(12)==21","assert rearrange_bigger(10)==False","assert rearrange_bigger(102)==120"],"test_imports":[]}} {"problem_id":"mbpp_test_00408","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array.\n\nTests:\nassert k_smallest_pairs([1,3,7],[2,4,6],2)==[[1, 2], [1, 4]]\nassert k_smallest_pairs([1,3,7],[2,4,6],1)==[[1, 2]]\nassert k_smallest_pairs([1,3,7],[2,4,6],7)==[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]","canonical_answer":"import heapq\ndef k_smallest_pairs(nums1, nums2, k):\n queue = []\n def push(i, j):\n if i < len(nums1) and j < len(nums2):\n heapq.heappush(queue, [nums1[i] + nums2[j], i, j])\n push(0, 0)\n pairs = []\n while queue and len(pairs) < k:\n _, i, j = heapq.heappop(queue)\n pairs.append([nums1[i], nums2[j]])\n push(i, j + 1)\n if j == 0:\n push(i + 1, 0)\n return pairs","verification_metadata":{"test_list":["assert k_smallest_pairs([1,3,7],[2,4,6],2)==[[1, 2], [1, 4]]","assert k_smallest_pairs([1,3,7],[2,4,6],1)==[[1, 2]]","assert k_smallest_pairs([1,3,7],[2,4,6],7)==[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":408,"text":"Write a function to find k number of smallest pairs which consist of one element from the first array and one element from the second array.","code":"import heapq\ndef k_smallest_pairs(nums1, nums2, k):\n queue = []\n def push(i, j):\n if i < len(nums1) and j < len(nums2):\n heapq.heappush(queue, [nums1[i] + nums2[j], i, j])\n push(0, 0)\n pairs = []\n while queue and len(pairs) < k:\n _, i, j = heapq.heappop(queue)\n pairs.append([nums1[i], nums2[j]])\n push(i, j + 1)\n if j == 0:\n push(i + 1, 0)\n return pairs","test_list":["assert k_smallest_pairs([1,3,7],[2,4,6],2)==[[1, 2], [1, 4]]","assert k_smallest_pairs([1,3,7],[2,4,6],1)==[[1, 2]]","assert k_smallest_pairs([1,3,7],[2,4,6],7)==[[1, 2], [1, 4], [3, 2], [1, 6], [3, 4], [3, 6], [7, 2]]"],"test_imports":[]}} {"problem_id":"mbpp_test_00409","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the minimum product from the pairs of tuples within a given list.\n\nTests:\nassert min_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==8\nassert min_product_tuple([(10,20), (15,2), (5,10)] )==30\nassert min_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==100","canonical_answer":"def min_product_tuple(list1):\n result_min = min([abs(x * y) for x, y in list1] )\n return result_min","verification_metadata":{"test_list":["assert min_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==8","assert min_product_tuple([(10,20), (15,2), (5,10)] )==30","assert min_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==100"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":409,"text":"Write a function to find the minimum product from the pairs of tuples within a given list.","code":"def min_product_tuple(list1):\n result_min = min([abs(x * y) for x, y in list1] )\n return result_min","test_list":["assert min_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==8","assert min_product_tuple([(10,20), (15,2), (5,10)] )==30","assert min_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==100"],"test_imports":[]}} {"problem_id":"mbpp_test_00410","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the minimum value in a given heterogeneous list.\n\nTests:\nassert min_val(['Python', 3, 2, 4, 5, 'version'])==2\nassert min_val(['Python', 15, 20, 25])==15\nassert min_val(['Python', 30, 20, 40, 50, 'version'])==20","canonical_answer":"def min_val(listval):\n min_val = min(i for i in listval if isinstance(i, int))\n return min_val","verification_metadata":{"test_list":["assert min_val(['Python', 3, 2, 4, 5, 'version'])==2","assert min_val(['Python', 15, 20, 25])==15","assert min_val(['Python', 30, 20, 40, 50, 'version'])==20"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":410,"text":"Write a function to find the minimum value in a given heterogeneous list.","code":"def min_val(listval):\n min_val = min(i for i in listval if isinstance(i, int))\n return min_val","test_list":["assert min_val(['Python', 3, 2, 4, 5, 'version'])==2","assert min_val(['Python', 15, 20, 25])==15","assert min_val(['Python', 30, 20, 40, 50, 'version'])==20"],"test_imports":[]}} {"problem_id":"mbpp_test_00411","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert the given snake case string to camel case string.\n\nTests:\nassert snake_to_camel('android_tv') == 'AndroidTv'\nassert snake_to_camel('google_pixel') == 'GooglePixel'\nassert snake_to_camel('apple_watch') == 'AppleWatch'","canonical_answer":"import re\ndef snake_to_camel(word):\n return ''.join(x.capitalize() or '_' for x in word.split('_'))","verification_metadata":{"test_list":["assert snake_to_camel('android_tv') == 'AndroidTv'","assert snake_to_camel('google_pixel') == 'GooglePixel'","assert snake_to_camel('apple_watch') == 'AppleWatch'"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":411,"text":"Write a function to convert the given snake case string to camel case string.","code":"import re\ndef snake_to_camel(word):\n return ''.join(x.capitalize() or '_' for x in word.split('_'))","test_list":["assert snake_to_camel('android_tv') == 'AndroidTv'","assert snake_to_camel('google_pixel') == 'GooglePixel'","assert snake_to_camel('apple_watch') == 'AppleWatch'"],"test_imports":[]}} {"problem_id":"mbpp_test_00412","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to remove odd numbers from a given list.\n\nTests:\nassert remove_odd([1,2,3]) == [2]\nassert remove_odd([2,4,6]) == [2,4,6]\nassert remove_odd([10,20,3]) == [10,20]","canonical_answer":"def remove_odd(l):\n for i in l:\n if i % 2 != 0:\n l.remove(i)\n return l","verification_metadata":{"test_list":["assert remove_odd([1,2,3]) == [2]","assert remove_odd([2,4,6]) == [2,4,6]","assert remove_odd([10,20,3]) == [10,20]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":412,"text":"Write a python function to remove odd numbers from a given list.","code":"def remove_odd(l):\n for i in l:\n if i % 2 != 0:\n l.remove(i)\n return l","test_list":["assert remove_odd([1,2,3]) == [2]","assert remove_odd([2,4,6]) == [2,4,6]","assert remove_odd([10,20,3]) == [10,20]"],"test_imports":[]}} {"problem_id":"mbpp_test_00413","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to extract the nth element from a given list of tuples.\n\nTests:\nassert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0)==['Greyson Fulton', 'Brady Kent', 'Wyatt Knott', 'Beau Turnbull']\nassert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2)==[99, 96, 94, 98]\nassert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)],1)==[98, 97, 91, 94]","canonical_answer":"def extract_nth_element(list1, n):\n result = [x[n] for x in list1]\n return result","verification_metadata":{"test_list":["assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0)==['Greyson Fulton', 'Brady Kent', 'Wyatt Knott', 'Beau Turnbull']","assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2)==[99, 96, 94, 98]","assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)],1)==[98, 97, 91, 94]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":413,"text":"Write a function to extract the nth element from a given list of tuples.","code":"def extract_nth_element(list1, n):\n result = [x[n] for x in list1]\n return result","test_list":["assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,0)==['Greyson Fulton', 'Brady Kent', 'Wyatt Knott', 'Beau Turnbull']","assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)] ,2)==[99, 96, 94, 98]","assert extract_nth_element([('Greyson Fulton', 98, 99), ('Brady Kent', 97, 96), ('Wyatt Knott', 91, 94), ('Beau Turnbull', 94, 98)],1)==[98, 97, 91, 94]"],"test_imports":[]}} {"problem_id":"mbpp_test_00414","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether any value in a sequence exists in a sequence or not.\n\nTests:\nassert overlapping([1,2,3,4,5],[6,7,8,9]) == False\nassert overlapping([1,2,3],[4,5,6]) == False\nassert overlapping([1,4,5],[1,4,5]) == True","canonical_answer":"def overlapping(list1,list2): \n for i in range(len(list1)): \n for j in range(len(list2)): \n if(list1[i]==list2[j]): \n return True\n return False","verification_metadata":{"test_list":["assert overlapping([1,2,3,4,5],[6,7,8,9]) == False","assert overlapping([1,2,3],[4,5,6]) == False","assert overlapping([1,4,5],[1,4,5]) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":414,"text":"Write a python function to check whether any value in a sequence exists in a sequence or not.","code":"def overlapping(list1,list2): \n for i in range(len(list1)): \n for j in range(len(list2)): \n if(list1[i]==list2[j]): \n return True\n return False","test_list":["assert overlapping([1,2,3,4,5],[6,7,8,9]) == False","assert overlapping([1,2,3],[4,5,6]) == False","assert overlapping([1,4,5],[1,4,5]) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00415","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find a pair with highest product from a given array of integers.\n\nTests:\nassert max_Product([1,2,3,4,7,0,8,4]) == (7,8)\nassert max_Product([0,-1,-2,-4,5,0,-6]) == (-4,-6)\nassert max_Product([1,2,3]) == (2,3)","canonical_answer":"def max_Product(arr): \n arr_len = len(arr) \n if (arr_len < 2): \n return (\"No pairs exists\") \n x = arr[0]; y = arr[1] \n for i in range(0,arr_len): \n for j in range(i + 1,arr_len): \n if (arr[i] * arr[j] > x * y): \n x = arr[i]; y = arr[j] \n return x,y","verification_metadata":{"test_list":["assert max_Product([1,2,3,4,7,0,8,4]) == (7,8)","assert max_Product([0,-1,-2,-4,5,0,-6]) == (-4,-6)","assert max_Product([1,2,3]) == (2,3)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":415,"text":"Write a python function to find a pair with highest product from a given array of integers.","code":"def max_Product(arr): \n arr_len = len(arr) \n if (arr_len < 2): \n return (\"No pairs exists\") \n x = arr[0]; y = arr[1] \n for i in range(0,arr_len): \n for j in range(i + 1,arr_len): \n if (arr[i] * arr[j] > x * y): \n x = arr[i]; y = arr[j] \n return x,y","test_list":["assert max_Product([1,2,3,4,7,0,8,4]) == (7,8)","assert max_Product([0,-1,-2,-4,5,0,-6]) == (-4,-6)","assert max_Product([1,2,3]) == (2,3)"],"test_imports":[]}} {"problem_id":"mbpp_test_00417","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find common first element in given list of tuple.\n\nTests:\nassert group_tuples([('x', 'y'), ('x', 'z'), ('w', 't')]) == [('x', 'y', 'z'), ('w', 't')]\nassert group_tuples([('a', 'b'), ('a', 'c'), ('d', 'e')]) == [('a', 'b', 'c'), ('d', 'e')]\nassert group_tuples([('f', 'g'), ('f', 'g'), ('h', 'i')]) == [('f', 'g', 'g'), ('h', 'i')]","canonical_answer":"def group_tuples(Input): \n\tout = {} \n\tfor elem in Input: \n\t\ttry: \n\t\t\tout[elem[0]].extend(elem[1:]) \n\t\texcept KeyError: \n\t\t\tout[elem[0]] = list(elem) \n\treturn [tuple(values) for values in out.values()]","verification_metadata":{"test_list":["assert group_tuples([('x', 'y'), ('x', 'z'), ('w', 't')]) == [('x', 'y', 'z'), ('w', 't')]","assert group_tuples([('a', 'b'), ('a', 'c'), ('d', 'e')]) == [('a', 'b', 'c'), ('d', 'e')]","assert group_tuples([('f', 'g'), ('f', 'g'), ('h', 'i')]) == [('f', 'g', 'g'), ('h', 'i')]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":417,"text":"Write a function to find common first element in given list of tuple.","code":"def group_tuples(Input): \n\tout = {} \n\tfor elem in Input: \n\t\ttry: \n\t\t\tout[elem[0]].extend(elem[1:]) \n\t\texcept KeyError: \n\t\t\tout[elem[0]] = list(elem) \n\treturn [tuple(values) for values in out.values()]","test_list":["assert group_tuples([('x', 'y'), ('x', 'z'), ('w', 't')]) == [('x', 'y', 'z'), ('w', 't')]","assert group_tuples([('a', 'b'), ('a', 'c'), ('d', 'e')]) == [('a', 'b', 'c'), ('d', 'e')]","assert group_tuples([('f', 'g'), ('f', 'g'), ('h', 'i')]) == [('f', 'g', 'g'), ('h', 'i')]"],"test_imports":[]}} {"problem_id":"mbpp_test_00418","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the element of a list having maximum length.\n\nTests:\nassert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']\nassert Find_Max([[1],[1,2],[1,2,3]]) == [1,2,3]\nassert Find_Max([[1,1],[1,2,3],[1,5,6,1]]) == [1,5,6,1]","canonical_answer":"def Find_Max(lst): \n maxList = max((x) for x in lst) \n return maxList","verification_metadata":{"test_list":["assert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']","assert Find_Max([[1],[1,2],[1,2,3]]) == [1,2,3]","assert Find_Max([[1,1],[1,2,3],[1,5,6,1]]) == [1,5,6,1]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":418,"text":"Write a python function to find the element of a list having maximum length.","code":"def Find_Max(lst): \n maxList = max((x) for x in lst) \n return maxList","test_list":["assert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']","assert Find_Max([[1],[1,2],[1,2,3]]) == [1,2,3]","assert Find_Max([[1,1],[1,2,3],[1,5,6,1]]) == [1,5,6,1]"],"test_imports":[]}} {"problem_id":"mbpp_test_00419","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.\n\nTests:\nassert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243\nassert round_and_sum([5,2,9,24.3,29])==345\nassert round_and_sum([25.0,56.7,89.2])==513","canonical_answer":"def round_and_sum(list1):\n lenght=len(list1)\n round_and_sum=sum(list(map(round,list1))* lenght)\n return round_and_sum","verification_metadata":{"test_list":["assert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243","assert round_and_sum([5,2,9,24.3,29])==345","assert round_and_sum([25.0,56.7,89.2])==513"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":419,"text":"Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.","code":"def round_and_sum(list1):\n lenght=len(list1)\n round_and_sum=sum(list(map(round,list1))* lenght)\n return round_and_sum","test_list":["assert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243","assert round_and_sum([5,2,9,24.3,29])==345","assert round_and_sum([25.0,56.7,89.2])==513"],"test_imports":[]}} {"problem_id":"mbpp_test_00420","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the cube sum of first n even natural numbers.\n\nTests:\nassert cube_Sum(2) == 72\nassert cube_Sum(3) == 288\nassert cube_Sum(4) == 800","canonical_answer":"def cube_Sum(n): \n sum = 0\n for i in range(1,n + 1): \n sum += (2*i)*(2*i)*(2*i) \n return sum","verification_metadata":{"test_list":["assert cube_Sum(2) == 72","assert cube_Sum(3) == 288","assert cube_Sum(4) == 800"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":420,"text":"Write a python function to find the cube sum of first n even natural numbers.","code":"def cube_Sum(n): \n sum = 0\n for i in range(1,n + 1): \n sum += (2*i)*(2*i)*(2*i) \n return sum","test_list":["assert cube_Sum(2) == 72","assert cube_Sum(3) == 288","assert cube_Sum(4) == 800"],"test_imports":[]}} {"problem_id":"mbpp_test_00421","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to concatenate each element of tuple by the delimiter.\n\nTests:\nassert concatenate_tuple((\"ID\", \"is\", 4, \"UTS\") ) == 'ID-is-4-UTS'\nassert concatenate_tuple((\"QWE\", \"is\", 4, \"RTY\") ) == 'QWE-is-4-RTY'\nassert concatenate_tuple((\"ZEN\", \"is\", 4, \"OP\") ) == 'ZEN-is-4-OP'","canonical_answer":"def concatenate_tuple(test_tup):\n delim = \"-\"\n res = ''.join([str(ele) + delim for ele in test_tup])\n res = res[ : len(res) - len(delim)]\n return (str(res))","verification_metadata":{"test_list":["assert concatenate_tuple((\"ID\", \"is\", 4, \"UTS\") ) == 'ID-is-4-UTS'","assert concatenate_tuple((\"QWE\", \"is\", 4, \"RTY\") ) == 'QWE-is-4-RTY'","assert concatenate_tuple((\"ZEN\", \"is\", 4, \"OP\") ) == 'ZEN-is-4-OP'"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":421,"text":"Write a function to concatenate each element of tuple by the delimiter.","code":"def concatenate_tuple(test_tup):\n delim = \"-\"\n res = ''.join([str(ele) + delim for ele in test_tup])\n res = res[ : len(res) - len(delim)]\n return (str(res))","test_list":["assert concatenate_tuple((\"ID\", \"is\", 4, \"UTS\") ) == 'ID-is-4-UTS'","assert concatenate_tuple((\"QWE\", \"is\", 4, \"RTY\") ) == 'QWE-is-4-RTY'","assert concatenate_tuple((\"ZEN\", \"is\", 4, \"OP\") ) == 'ZEN-is-4-OP'"],"test_imports":[]}} {"problem_id":"mbpp_test_00422","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the average of cubes of first n natural numbers.\n\nTests:\nassert find_Average_Of_Cube(2) == 4.5\nassert find_Average_Of_Cube(3) == 12\nassert find_Average_Of_Cube(1) == 1","canonical_answer":"def find_Average_Of_Cube(n): \n sum = 0\n for i in range(1, n + 1): \n sum += i * i * i \n return round(sum / n, 6)","verification_metadata":{"test_list":["assert find_Average_Of_Cube(2) == 4.5","assert find_Average_Of_Cube(3) == 12","assert find_Average_Of_Cube(1) == 1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":422,"text":"Write a python function to find the average of cubes of first n natural numbers.","code":"def find_Average_Of_Cube(n): \n sum = 0\n for i in range(1, n + 1): \n sum += i * i * i \n return round(sum / n, 6)","test_list":["assert find_Average_Of_Cube(2) == 4.5","assert find_Average_Of_Cube(3) == 12","assert find_Average_Of_Cube(1) == 1"],"test_imports":[]}} {"problem_id":"mbpp_test_00424","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to extract only the rear index element of each string in the given tuple.\n\nTests:\nassert extract_rear(('Mers', 'for', 'Vers') ) == ['s', 'r', 's']\nassert extract_rear(('Avenge', 'for', 'People') ) == ['e', 'r', 'e']\nassert extract_rear(('Gotta', 'get', 'go') ) == ['a', 't', 'o']","canonical_answer":"def extract_rear(test_tuple):\n res = list(sub[len(sub) - 1] for sub in test_tuple)\n return (res)","verification_metadata":{"test_list":["assert extract_rear(('Mers', 'for', 'Vers') ) == ['s', 'r', 's']","assert extract_rear(('Avenge', 'for', 'People') ) == ['e', 'r', 'e']","assert extract_rear(('Gotta', 'get', 'go') ) == ['a', 't', 'o']"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":424,"text":"Write a function to extract only the rear index element of each string in the given tuple.","code":"def extract_rear(test_tuple):\n res = list(sub[len(sub) - 1] for sub in test_tuple)\n return (res)","test_list":["assert extract_rear(('Mers', 'for', 'Vers') ) == ['s', 'r', 's']","assert extract_rear(('Avenge', 'for', 'People') ) == ['e', 'r', 'e']","assert extract_rear(('Gotta', 'get', 'go') ) == ['a', 't', 'o']"],"test_imports":[]}} {"problem_id":"mbpp_test_00425","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to count the number of sublists containing a particular element.\n\nTests:\nassert count_element_in_list([[1, 3], [5, 7], [1, 11], [1, 15, 7]],1)==3\nassert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A')==3\nassert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E')==1","canonical_answer":"def count_element_in_list(list1, x): \n ctr = 0\n for i in range(len(list1)): \n if x in list1[i]: \n ctr+= 1 \n return ctr","verification_metadata":{"test_list":["assert count_element_in_list([[1, 3], [5, 7], [1, 11], [1, 15, 7]],1)==3","assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A')==3","assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E')==1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":425,"text":"Write a function to count the number of sublists containing a particular element.","code":"def count_element_in_list(list1, x): \n ctr = 0\n for i in range(len(list1)): \n if x in list1[i]: \n ctr+= 1 \n return ctr","test_list":["assert count_element_in_list([[1, 3], [5, 7], [1, 11], [1, 15, 7]],1)==3","assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A')==3","assert count_element_in_list([['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E')==1"],"test_imports":[]}} {"problem_id":"mbpp_test_00426","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to filter odd numbers.\n\nTests:\nassert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]\nassert filter_oddnumbers([10,20,45,67,84,93])==[45,67,93]\nassert filter_oddnumbers([5,7,9,8,6,4,3])==[5,7,9,3]","canonical_answer":"def filter_oddnumbers(nums):\n odd_nums = list(filter(lambda x: x%2 != 0, nums))\n return odd_nums","verification_metadata":{"test_list":["assert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]","assert filter_oddnumbers([10,20,45,67,84,93])==[45,67,93]","assert filter_oddnumbers([5,7,9,8,6,4,3])==[5,7,9,3]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":426,"text":"Write a function to filter odd numbers.","code":"def filter_oddnumbers(nums):\n odd_nums = list(filter(lambda x: x%2 != 0, nums))\n return odd_nums","test_list":["assert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]","assert filter_oddnumbers([10,20,45,67,84,93])==[45,67,93]","assert filter_oddnumbers([5,7,9,8,6,4,3])==[5,7,9,3]"],"test_imports":[]}} {"problem_id":"mbpp_test_00427","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.\n\nTests:\nassert change_date_format(\"2026-01-02\") == '02-01-2026'\nassert change_date_format(\"2020-11-13\") == '13-11-2020'\nassert change_date_format(\"2021-04-26\") == '26-04-2021'","canonical_answer":"import re\ndef change_date_format(dt):\n return re.sub(r'(\\d{4})-(\\d{1,2})-(\\d{1,2})', '\\\\3-\\\\2-\\\\1', dt)","verification_metadata":{"test_list":["assert change_date_format(\"2026-01-02\") == '02-01-2026'","assert change_date_format(\"2020-11-13\") == '13-11-2020'","assert change_date_format(\"2021-04-26\") == '26-04-2021'"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":427,"text":"Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.","code":"import re\ndef change_date_format(dt):\n return re.sub(r'(\\d{4})-(\\d{1,2})-(\\d{1,2})', '\\\\3-\\\\2-\\\\1', dt)","test_list":["assert change_date_format(\"2026-01-02\") == '02-01-2026'","assert change_date_format(\"2020-11-13\") == '13-11-2020'","assert change_date_format(\"2021-04-26\") == '26-04-2021'"],"test_imports":[]}} {"problem_id":"mbpp_test_00428","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sort the given array by using shell sort.\n\nTests:\nassert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]\nassert shell_sort([24, 22, 39, 34, 87, 73, 68]) == [22, 24, 34, 39, 68, 73, 87]\nassert shell_sort([32, 30, 16, 96, 82, 83, 74]) == [16, 30, 32, 74, 82, 83, 96]","canonical_answer":"def shell_sort(my_list):\n gap = len(my_list) // 2\n while gap > 0:\n for i in range(gap, len(my_list)):\n current_item = my_list[i]\n j = i\n while j >= gap and my_list[j - gap] > current_item:\n my_list[j] = my_list[j - gap]\n j -= gap\n my_list[j] = current_item\n gap //= 2\n\n return my_list","verification_metadata":{"test_list":["assert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]","assert shell_sort([24, 22, 39, 34, 87, 73, 68]) == [22, 24, 34, 39, 68, 73, 87]","assert shell_sort([32, 30, 16, 96, 82, 83, 74]) == [16, 30, 32, 74, 82, 83, 96]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":428,"text":"Write a function to sort the given array by using shell sort.","code":"def shell_sort(my_list):\n gap = len(my_list) // 2\n while gap > 0:\n for i in range(gap, len(my_list)):\n current_item = my_list[i]\n j = i\n while j >= gap and my_list[j - gap] > current_item:\n my_list[j] = my_list[j - gap]\n j -= gap\n my_list[j] = current_item\n gap //= 2\n\n return my_list","test_list":["assert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]","assert shell_sort([24, 22, 39, 34, 87, 73, 68]) == [22, 24, 34, 39, 68, 73, 87]","assert shell_sort([32, 30, 16, 96, 82, 83, 74]) == [16, 30, 32, 74, 82, 83, 96]"],"test_imports":[]}} {"problem_id":"mbpp_test_00429","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to extract the elementwise and tuples from the given two tuples.\n\nTests:\nassert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)\nassert and_tuples((1, 2, 3, 4), (5, 6, 7, 8)) == (1, 2, 3, 0)\nassert and_tuples((8, 9, 11, 12), (7, 13, 14, 17)) == (0, 9, 10, 0)","canonical_answer":"def and_tuples(test_tup1, test_tup2):\n res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\n return (res)","verification_metadata":{"test_list":["assert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)","assert and_tuples((1, 2, 3, 4), (5, 6, 7, 8)) == (1, 2, 3, 0)","assert and_tuples((8, 9, 11, 12), (7, 13, 14, 17)) == (0, 9, 10, 0)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":429,"text":"Write a function to extract the elementwise and tuples from the given two tuples.","code":"def and_tuples(test_tup1, test_tup2):\n res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))\n return (res)","test_list":["assert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)","assert and_tuples((1, 2, 3, 4), (5, 6, 7, 8)) == (1, 2, 3, 0)","assert and_tuples((8, 9, 11, 12), (7, 13, 14, 17)) == (0, 9, 10, 0)"],"test_imports":[]}} {"problem_id":"mbpp_test_00430","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the directrix of a parabola.\n\nTests:\nassert parabola_directrix(5,3,2)==-198\nassert parabola_directrix(9,8,4)==-2336\nassert parabola_directrix(2,4,6)==-130","canonical_answer":"def parabola_directrix(a, b, c): \n directrix=((int)(c - ((b * b) + 1) * 4 * a ))\n return directrix","verification_metadata":{"test_list":["assert parabola_directrix(5,3,2)==-198","assert parabola_directrix(9,8,4)==-2336","assert parabola_directrix(2,4,6)==-130"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":430,"text":"Write a function to find the directrix of a parabola.","code":"def parabola_directrix(a, b, c): \n directrix=((int)(c - ((b * b) + 1) * 4 * a ))\n return directrix","test_list":["assert parabola_directrix(5,3,2)==-198","assert parabola_directrix(9,8,4)==-2336","assert parabola_directrix(2,4,6)==-130"],"test_imports":[]}} {"problem_id":"mbpp_test_00431","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that takes two lists and returns true if they have at least one common element.\n\nTests:\nassert common_element([1,2,3,4,5], [5,6,7,8,9])==True\nassert common_element([1,2,3,4,5], [6,7,8,9])==None\nassert common_element(['a','b','c'], ['d','b','e'])==True","canonical_answer":"def common_element(list1, list2):\n result = False\n for x in list1:\n for y in list2:\n if x == y:\n result = True\n return result","verification_metadata":{"test_list":["assert common_element([1,2,3,4,5], [5,6,7,8,9])==True","assert common_element([1,2,3,4,5], [6,7,8,9])==None","assert common_element(['a','b','c'], ['d','b','e'])==True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":431,"text":"Write a function that takes two lists and returns true if they have at least one common element.","code":"def common_element(list1, list2):\n result = False\n for x in list1:\n for y in list2:\n if x == y:\n result = True\n return result","test_list":["assert common_element([1,2,3,4,5], [5,6,7,8,9])==True","assert common_element([1,2,3,4,5], [6,7,8,9])==None","assert common_element(['a','b','c'], ['d','b','e'])==True"],"test_imports":[]}} {"problem_id":"mbpp_test_00432","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the median length of a trapezium.\n\nTests:\nassert median_trapezium(15,25,35)==20\nassert median_trapezium(10,20,30)==15\nassert median_trapezium(6,9,4)==7.5","canonical_answer":"def median_trapezium(base1,base2,height):\n median = 0.5 * (base1+ base2)\n return median","verification_metadata":{"test_list":["assert median_trapezium(15,25,35)==20","assert median_trapezium(10,20,30)==15","assert median_trapezium(6,9,4)==7.5"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":432,"text":"Write a function to find the median length of a trapezium.","code":"def median_trapezium(base1,base2,height):\n median = 0.5 * (base1+ base2)\n return median","test_list":["assert median_trapezium(15,25,35)==20","assert median_trapezium(10,20,30)==15","assert median_trapezium(6,9,4)==7.5"],"test_imports":[]}} {"problem_id":"mbpp_test_00433","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether the entered number is greater than the elements of the given array.\n\nTests:\nassert check_greater([1, 2, 3, 4, 5], 4) == False\nassert check_greater([2, 3, 4, 5, 6], 8) == True\nassert check_greater([9, 7, 4, 8, 6, 1], 11) == True","canonical_answer":"def check_greater(arr, number):\n arr.sort()\n return number > arr[-1]","verification_metadata":{"test_list":["assert check_greater([1, 2, 3, 4, 5], 4) == False","assert check_greater([2, 3, 4, 5, 6], 8) == True","assert check_greater([9, 7, 4, 8, 6, 1], 11) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":433,"text":"Write a function to check whether the entered number is greater than the elements of the given array.","code":"def check_greater(arr, number):\n arr.sort()\n return number > arr[-1]","test_list":["assert check_greater([1, 2, 3, 4, 5], 4) == False","assert check_greater([2, 3, 4, 5, 6], 8) == True","assert check_greater([9, 7, 4, 8, 6, 1], 11) == True"],"test_imports":[]}} {"problem_id":"mbpp_test_00434","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that matches a string that has an a followed by one or more b's.\n\nTests:\nassert text_match_one(\"ac\")==False\nassert text_match_one(\"dc\")==False\nassert text_match_one(\"abba\")==True","canonical_answer":"import re\ndef text_match_one(text):\n patterns = 'ab+?'\n if re.search(patterns, text):\n return True\n else:\n return False","verification_metadata":{"test_list":["assert text_match_one(\"ac\")==False","assert text_match_one(\"dc\")==False","assert text_match_one(\"abba\")==True"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":434,"text":"Write a function that matches a string that has an a followed by one or more b's.","code":"import re\ndef text_match_one(text):\n patterns = 'ab+?'\n if re.search(patterns, text):\n return True\n else:\n return False","test_list":["assert text_match_one(\"ac\")==False","assert text_match_one(\"dc\")==False","assert text_match_one(\"abba\")==True"],"test_imports":[]}} {"problem_id":"mbpp_test_00435","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the last digit of a given number.\n\nTests:\nassert last_Digit(123) == 3\nassert last_Digit(25) == 5\nassert last_Digit(30) == 0","canonical_answer":"def last_Digit(n) :\n return (n % 10)","verification_metadata":{"test_list":["assert last_Digit(123) == 3","assert last_Digit(25) == 5","assert last_Digit(30) == 0"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":435,"text":"Write a python function to find the last digit of a given number.","code":"def last_Digit(n) :\n return (n % 10)","test_list":["assert last_Digit(123) == 3","assert last_Digit(25) == 5","assert last_Digit(30) == 0"],"test_imports":[]}} {"problem_id":"mbpp_test_00436","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to return the negative numbers in a list.\n\nTests:\nassert neg_nos([-1,4,5,-6]) == [-1,-6]\nassert neg_nos([-1,-2,3,4]) == [-1,-2]\nassert neg_nos([-7,-6,8,9]) == [-7,-6]","canonical_answer":"def neg_nos(list1):\n out = []\n for num in list1: \n if num < 0: \n out.append(num)\n return out","verification_metadata":{"test_list":["assert neg_nos([-1,4,5,-6]) == [-1,-6]","assert neg_nos([-1,-2,3,4]) == [-1,-2]","assert neg_nos([-7,-6,8,9]) == [-7,-6]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":436,"text":"Write a python function to return the negative numbers in a list.","code":"def neg_nos(list1):\n out = []\n for num in list1: \n if num < 0: \n out.append(num)\n return out","test_list":["assert neg_nos([-1,4,5,-6]) == [-1,-6]","assert neg_nos([-1,-2,3,4]) == [-1,-2]","assert neg_nos([-7,-6,8,9]) == [-7,-6]"],"test_imports":[]}} {"problem_id":"mbpp_test_00437","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove odd characters in a string.\n\nTests:\nassert remove_odd(\"python\")==(\"yhn\")\nassert remove_odd(\"program\")==(\"rga\")\nassert remove_odd(\"language\")==(\"agae\")","canonical_answer":"def remove_odd(str1):\n str2 = ''\n for i in range(1, len(str1) + 1):\n if(i % 2 == 0):\n str2 = str2 + str1[i - 1]\n return str2","verification_metadata":{"test_list":["assert remove_odd(\"python\")==(\"yhn\")","assert remove_odd(\"program\")==(\"rga\")","assert remove_odd(\"language\")==(\"agae\")"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":437,"text":"Write a function to remove odd characters in a string.","code":"def remove_odd(str1):\n str2 = ''\n for i in range(1, len(str1) + 1):\n if(i % 2 == 0):\n str2 = str2 + str1[i - 1]\n return str2","test_list":["assert remove_odd(\"python\")==(\"yhn\")","assert remove_odd(\"program\")==(\"rga\")","assert remove_odd(\"language\")==(\"agae\")"],"test_imports":[]}} {"problem_id":"mbpp_test_00438","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to count bidirectional tuple pairs.\n\nTests:\nassert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 3\nassert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 2\nassert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ) == 4","canonical_answer":"def count_bidirectional(test_list):\n res = 0\n for idx in range(0, len(test_list)):\n for iidx in range(idx + 1, len(test_list)):\n if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:\n res += 1\n return res","verification_metadata":{"test_list":["assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 3","assert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 2","assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ) == 4"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":438,"text":"Write a function to count bidirectional tuple pairs.","code":"def count_bidirectional(test_list):\n res = 0\n for idx in range(0, len(test_list)):\n for iidx in range(idx + 1, len(test_list)):\n if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:\n res += 1\n return res","test_list":["assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 3","assert count_bidirectional([(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 2","assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ) == 4"],"test_imports":[]}} {"problem_id":"mbpp_test_00439","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to join a list of multiple integers into a single integer.\n\nTests:\nassert multiple_to_single([11, 33, 50])==113350\nassert multiple_to_single([-1,2,3,4,5,6])==-123456\nassert multiple_to_single([10,15,20,25])==10152025","canonical_answer":"def multiple_to_single(L):\n x = int(\"\".join(map(str, L)))\n return x","verification_metadata":{"test_list":["assert multiple_to_single([11, 33, 50])==113350","assert multiple_to_single([-1,2,3,4,5,6])==-123456","assert multiple_to_single([10,15,20,25])==10152025"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":439,"text":"Write a function to join a list of multiple integers into a single integer.","code":"def multiple_to_single(L):\n x = int(\"\".join(map(str, L)))\n return x","test_list":["assert multiple_to_single([11, 33, 50])==113350","assert multiple_to_single([-1,2,3,4,5,6])==-123456","assert multiple_to_single([10,15,20,25])==10152025"],"test_imports":[]}} {"problem_id":"mbpp_test_00440","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the first adverb and their positions in a given sentence.\n\nTests:\nassert find_adverb_position(\"clearly!! we can see the sky\")==(0, 7, 'clearly')\nassert find_adverb_position(\"seriously!! there are many roses\")==(0, 9, 'seriously')\nassert find_adverb_position(\"unfortunately!! sita is going to home\")==(0, 13, 'unfortunately')","canonical_answer":"import re\ndef find_adverb_position(text):\n for m in re.finditer(r\"\\w+ly\", text):\n return (m.start(), m.end(), m.group(0))","verification_metadata":{"test_list":["assert find_adverb_position(\"clearly!! we can see the sky\")==(0, 7, 'clearly')","assert find_adverb_position(\"seriously!! there are many roses\")==(0, 9, 'seriously')","assert find_adverb_position(\"unfortunately!! sita is going to home\")==(0, 13, 'unfortunately')"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":440,"text":"Write a function to find the first adverb and their positions in a given sentence.","code":"import re\ndef find_adverb_position(text):\n for m in re.finditer(r\"\\w+ly\", text):\n return (m.start(), m.end(), m.group(0))","test_list":["assert find_adverb_position(\"clearly!! we can see the sky\")==(0, 7, 'clearly')","assert find_adverb_position(\"seriously!! there are many roses\")==(0, 9, 'seriously')","assert find_adverb_position(\"unfortunately!! sita is going to home\")==(0, 13, 'unfortunately')"],"test_imports":[]}} {"problem_id":"mbpp_test_00441","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the surface area of a cube of a given size.\n\nTests:\nassert surfacearea_cube(5)==150\nassert surfacearea_cube(3)==54\nassert surfacearea_cube(10)==600","canonical_answer":"def surfacearea_cube(l):\n surfacearea= 6*l*l\n return surfacearea","verification_metadata":{"test_list":["assert surfacearea_cube(5)==150","assert surfacearea_cube(3)==54","assert surfacearea_cube(10)==600"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":441,"text":"Write a function to find the surface area of a cube of a given size.","code":"def surfacearea_cube(l):\n surfacearea= 6*l*l\n return surfacearea","test_list":["assert surfacearea_cube(5)==150","assert surfacearea_cube(3)==54","assert surfacearea_cube(10)==600"],"test_imports":[]}} {"problem_id":"mbpp_test_00442","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the ration of positive numbers in an array of integers.\n\nTests:\nassert positive_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.54\nassert positive_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==0.69\nassert positive_count([2, 4, -6, -9, 11, -12, 14, -5, 17])==0.56","canonical_answer":"from array import array\ndef positive_count(nums):\n n = len(nums)\n n1 = 0\n for x in nums:\n if x > 0:\n n1 += 1\n else:\n None\n return round(n1/n,2)","verification_metadata":{"test_list":["assert positive_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.54","assert positive_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==0.69","assert positive_count([2, 4, -6, -9, 11, -12, 14, -5, 17])==0.56"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":442,"text":"Write a function to find the ration of positive numbers in an array of integers.","code":"from array import array\ndef positive_count(nums):\n n = len(nums)\n n1 = 0\n for x in nums:\n if x > 0:\n n1 += 1\n else:\n None\n return round(n1/n,2)","test_list":["assert positive_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.54","assert positive_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==0.69","assert positive_count([2, 4, -6, -9, 11, -12, 14, -5, 17])==0.56"],"test_imports":[]}} {"problem_id":"mbpp_test_00443","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the largest negative number from the given list.\n\nTests:\nassert largest_neg([1,2,3,-4,-6]) == -6\nassert largest_neg([1,2,3,-8,-9]) == -9\nassert largest_neg([1,2,3,4,-1]) == -1","canonical_answer":"def largest_neg(list1): \n max = list1[0] \n for x in list1: \n if x < max : \n max = x \n return max","verification_metadata":{"test_list":["assert largest_neg([1,2,3,-4,-6]) == -6","assert largest_neg([1,2,3,-8,-9]) == -9","assert largest_neg([1,2,3,4,-1]) == -1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":443,"text":"Write a python function to find the largest negative number from the given list.","code":"def largest_neg(list1): \n max = list1[0] \n for x in list1: \n if x < max : \n max = x \n return max","test_list":["assert largest_neg([1,2,3,-4,-6]) == -6","assert largest_neg([1,2,3,-8,-9]) == -9","assert largest_neg([1,2,3,4,-1]) == -1"],"test_imports":[]}} {"problem_id":"mbpp_test_00444","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to trim each tuple by k in the given tuple list.\n\nTests:\nassert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2) == '[(2,), (9,), (2,), (2,)]'\nassert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1) == '[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'\nassert trim_tuple([(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1) == '[(8, 4), (8, 12), (1, 7), (6, 9)]'","canonical_answer":"def trim_tuple(test_list, K):\n res = []\n for ele in test_list:\n N = len(ele)\n res.append(tuple(list(ele)[K: N - K]))\n return (str(res))","verification_metadata":{"test_list":["assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2) == '[(2,), (9,), (2,), (2,)]'","assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1) == '[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'","assert trim_tuple([(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1) == '[(8, 4), (8, 12), (1, 7), (6, 9)]'"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":444,"text":"Write a function to trim each tuple by k in the given tuple list.","code":"def trim_tuple(test_list, K):\n res = []\n for ele in test_list:\n N = len(ele)\n res.append(tuple(list(ele)[K: N - K]))\n return (str(res))","test_list":["assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2) == '[(2,), (9,), (2,), (2,)]'","assert trim_tuple([(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1) == '[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'","assert trim_tuple([(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1) == '[(8, 4), (8, 12), (1, 7), (6, 9)]'"],"test_imports":[]}} {"problem_id":"mbpp_test_00445","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to perform index wise multiplication of tuple elements in the given two tuples.\n\nTests:\nassert index_multiplication(((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ) == ((6, 21), (12, 45), (2, 9), (7, 30))\nassert index_multiplication(((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ) == ((14, 32), (20, 60), (6, 20), (16, 44))\nassert index_multiplication(((3, 5), (6, 7), (4, 11), (3, 12)),((8, 9), (5, 11), (3, 3), (9, 5)) ) == ((24, 45), (30, 77), (12, 33), (27, 60))","canonical_answer":"def index_multiplication(test_tup1, test_tup2):\n res = tuple(tuple(a * b for a, b in zip(tup1, tup2))\n for tup1, tup2 in zip(test_tup1, test_tup2))\n return (res)","verification_metadata":{"test_list":["assert index_multiplication(((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ) == ((6, 21), (12, 45), (2, 9), (7, 30))","assert index_multiplication(((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ) == ((14, 32), (20, 60), (6, 20), (16, 44))","assert index_multiplication(((3, 5), (6, 7), (4, 11), (3, 12)),((8, 9), (5, 11), (3, 3), (9, 5)) ) == ((24, 45), (30, 77), (12, 33), (27, 60))"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":445,"text":"Write a function to perform index wise multiplication of tuple elements in the given two tuples.","code":"def index_multiplication(test_tup1, test_tup2):\n res = tuple(tuple(a * b for a, b in zip(tup1, tup2))\n for tup1, tup2 in zip(test_tup1, test_tup2))\n return (res)","test_list":["assert index_multiplication(((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ) == ((6, 21), (12, 45), (2, 9), (7, 30))","assert index_multiplication(((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ) == ((14, 32), (20, 60), (6, 20), (16, 44))","assert index_multiplication(((3, 5), (6, 7), (4, 11), (3, 12)),((8, 9), (5, 11), (3, 3), (9, 5)) ) == ((24, 45), (30, 77), (12, 33), (27, 60))"],"test_imports":[]}} {"problem_id":"mbpp_test_00446","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the occurence of all elements of list in a tuple.\n\nTests:\nassert count_Occurrence(('a', 'a', 'c', 'b', 'd'),['a', 'b'] ) == 3\nassert count_Occurrence((1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]) == 6\nassert count_Occurrence((1,2,3,4,5,6),[1,2]) == 2","canonical_answer":"from collections import Counter \ndef count_Occurrence(tup, lst): \n count = 0\n for item in tup: \n if item in lst: \n count+= 1 \n return count","verification_metadata":{"test_list":["assert count_Occurrence(('a', 'a', 'c', 'b', 'd'),['a', 'b'] ) == 3","assert count_Occurrence((1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]) == 6","assert count_Occurrence((1,2,3,4,5,6),[1,2]) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":446,"text":"Write a python function to count the occurence of all elements of list in a tuple.","code":"from collections import Counter \ndef count_Occurrence(tup, lst): \n count = 0\n for item in tup: \n if item in lst: \n count+= 1 \n return count","test_list":["assert count_Occurrence(('a', 'a', 'c', 'b', 'd'),['a', 'b'] ) == 3","assert count_Occurrence((1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]) == 6","assert count_Occurrence((1,2,3,4,5,6),[1,2]) == 2"],"test_imports":[]}} {"problem_id":"mbpp_test_00447","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find cubes of individual elements in a list.\n\nTests:\nassert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]\nassert cube_nums([10,20,30])==([1000, 8000, 27000])\nassert cube_nums([12,15])==([1728, 3375])","canonical_answer":"def cube_nums(nums):\n cube_nums = list(map(lambda x: x ** 3, nums))\n return cube_nums","verification_metadata":{"test_list":["assert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]","assert cube_nums([10,20,30])==([1000, 8000, 27000])","assert cube_nums([12,15])==([1728, 3375])"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":447,"text":"Write a function to find cubes of individual elements in a list.","code":"def cube_nums(nums):\n cube_nums = list(map(lambda x: x ** 3, nums))\n return cube_nums","test_list":["assert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]","assert cube_nums([10,20,30])==([1000, 8000, 27000])","assert cube_nums([12,15])==([1728, 3375])"],"test_imports":[]}} {"problem_id":"mbpp_test_00448","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to calculate the sum of perrin numbers.\n\nTests:\nassert cal_sum(9) == 49\nassert cal_sum(10) == 66\nassert cal_sum(11) == 88","canonical_answer":"def cal_sum(n): \n\ta = 3\n\tb = 0\n\tc = 2\n\tif (n == 0): \n\t\treturn 3\n\tif (n == 1): \n\t\treturn 3\n\tif (n == 2): \n\t\treturn 5\n\tsum = 5\n\twhile (n > 2): \n\t\td = a + b \n\t\tsum = sum + d \n\t\ta = b \n\t\tb = c \n\t\tc = d \n\t\tn = n-1\n\treturn sum","verification_metadata":{"test_list":["assert cal_sum(9) == 49","assert cal_sum(10) == 66","assert cal_sum(11) == 88"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":448,"text":"Write a function to calculate the sum of perrin numbers.","code":"def cal_sum(n): \n\ta = 3\n\tb = 0\n\tc = 2\n\tif (n == 0): \n\t\treturn 3\n\tif (n == 1): \n\t\treturn 3\n\tif (n == 2): \n\t\treturn 5\n\tsum = 5\n\twhile (n > 2): \n\t\td = a + b \n\t\tsum = sum + d \n\t\ta = b \n\t\tb = c \n\t\tc = d \n\t\tn = n-1\n\treturn sum","test_list":["assert cal_sum(9) == 49","assert cal_sum(10) == 66","assert cal_sum(11) == 88"],"test_imports":[]}} {"problem_id":"mbpp_test_00450","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to extract specified size of strings from a given list of string values.\n\nTests:\nassert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']\nassert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python']\nassert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,9)==['exercises']","canonical_answer":"def extract_string(str, l):\n result = [e for e in str if len(e) == l] \n return result","verification_metadata":{"test_list":["assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']","assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python']","assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,9)==['exercises']"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":450,"text":"Write a function to extract specified size of strings from a given list of string values.","code":"def extract_string(str, l):\n result = [e for e in str if len(e) == l] \n return result","test_list":["assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']","assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python']","assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,9)==['exercises']"],"test_imports":[]}} {"problem_id":"mbpp_test_00451","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove all whitespaces from the given string.\n\nTests:\nassert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'\nassert remove_whitespaces(' Google Dart ') == 'GoogleDart'\nassert remove_whitespaces(' iOS Swift ') == 'iOSSwift'","canonical_answer":"import re\ndef remove_whitespaces(text1):\n return (re.sub(r'\\s+', '',text1))","verification_metadata":{"test_list":["assert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'","assert remove_whitespaces(' Google Dart ') == 'GoogleDart'","assert remove_whitespaces(' iOS Swift ') == 'iOSSwift'"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":451,"text":"Write a function to remove all whitespaces from the given string.","code":"import re\ndef remove_whitespaces(text1):\n return (re.sub(r'\\s+', '',text1))","test_list":["assert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter'","assert remove_whitespaces(' Google Dart ') == 'GoogleDart'","assert remove_whitespaces(' iOS Swift ') == 'iOSSwift'"],"test_imports":[]}} {"problem_id":"mbpp_test_00452","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that gives loss amount on a sale if the given amount has loss else return 0.\n\nTests:\nassert loss_amount(1500,1200)==0\nassert loss_amount(100,200)==100\nassert loss_amount(2000,5000)==3000","canonical_answer":"def loss_amount(actual_cost,sale_amount): \n if(sale_amount > actual_cost):\n amount = sale_amount - actual_cost\n return amount\n else:\n return 0","verification_metadata":{"test_list":["assert loss_amount(1500,1200)==0","assert loss_amount(100,200)==100","assert loss_amount(2000,5000)==3000"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":452,"text":"Write a function that gives loss amount on a sale if the given amount has loss else return 0.","code":"def loss_amount(actual_cost,sale_amount): \n if(sale_amount > actual_cost):\n amount = sale_amount - actual_cost\n return amount\n else:\n return 0","test_list":["assert loss_amount(1500,1200)==0","assert loss_amount(100,200)==100","assert loss_amount(2000,5000)==3000"],"test_imports":[]}} {"problem_id":"mbpp_test_00453","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of even factors of a number.\n\nTests:\nassert sumofFactors(18) == 26\nassert sumofFactors(30) == 48\nassert sumofFactors(6) == 8","canonical_answer":"import math \ndef sumofFactors(n) : \n if (n % 2 != 0) : \n return 0\n res = 1\n for i in range(2, (int)(math.sqrt(n)) + 1) : \n count = 0\n curr_sum = 1\n curr_term = 1\n while (n % i == 0) : \n count= count + 1\n n = n // i \n if (i == 2 and count == 1) : \n curr_sum = 0\n curr_term = curr_term * i \n curr_sum = curr_sum + curr_term \n res = res * curr_sum \n if (n >= 2) : \n res = res * (1 + n) \n return res","verification_metadata":{"test_list":["assert sumofFactors(18) == 26","assert sumofFactors(30) == 48","assert sumofFactors(6) == 8"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":453,"text":"Write a python function to find the sum of even factors of a number.","code":"import math \ndef sumofFactors(n) : \n if (n % 2 != 0) : \n return 0\n res = 1\n for i in range(2, (int)(math.sqrt(n)) + 1) : \n count = 0\n curr_sum = 1\n curr_term = 1\n while (n % i == 0) : \n count= count + 1\n n = n // i \n if (i == 2 and count == 1) : \n curr_sum = 0\n curr_term = curr_term * i \n curr_sum = curr_sum + curr_term \n res = res * curr_sum \n if (n >= 2) : \n res = res * (1 + n) \n return res","test_list":["assert sumofFactors(18) == 26","assert sumofFactors(30) == 48","assert sumofFactors(6) == 8"],"test_imports":[]}} {"problem_id":"mbpp_test_00454","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function that matches a word containing 'z'.\n\nTests:\nassert text_match_wordz(\"pythonz.\")==True\nassert text_match_wordz(\"xyz.\")==True\nassert text_match_wordz(\" lang .\")==False","canonical_answer":"import re\ndef text_match_wordz(text):\n patterns = '\\w*z.\\w*'\n if re.search(patterns, text):\n return True\n else:\n return False","verification_metadata":{"test_list":["assert text_match_wordz(\"pythonz.\")==True","assert text_match_wordz(\"xyz.\")==True","assert text_match_wordz(\" lang .\")==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":454,"text":"Write a function that matches a word containing 'z'.","code":"import re\ndef text_match_wordz(text):\n patterns = '\\w*z.\\w*'\n if re.search(patterns, text):\n return True\n else:\n return False","test_list":["assert text_match_wordz(\"pythonz.\")==True","assert text_match_wordz(\"xyz.\")==True","assert text_match_wordz(\" lang .\")==False"],"test_imports":[]}} {"problem_id":"mbpp_test_00455","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether the given month number contains 31 days or not.\n\nTests:\nassert check_monthnumb_number(5)==True\nassert check_monthnumb_number(2)==False\nassert check_monthnumb_number(6)==False","canonical_answer":"def check_monthnumb_number(monthnum2):\n if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):\n return True\n else:\n return False","verification_metadata":{"test_list":["assert check_monthnumb_number(5)==True","assert check_monthnumb_number(2)==False","assert check_monthnumb_number(6)==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":455,"text":"Write a function to check whether the given month number contains 31 days or not.","code":"def check_monthnumb_number(monthnum2):\n if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):\n return True\n else:\n return False","test_list":["assert check_monthnumb_number(5)==True","assert check_monthnumb_number(2)==False","assert check_monthnumb_number(6)==False"],"test_imports":[]}} {"problem_id":"mbpp_test_00456","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to reverse each string in a given list of string values.\n\nTests:\nassert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB']\nassert reverse_string_list(['john','amal','joel','george'])==['nhoj','lama','leoj','egroeg']\nassert reverse_string_list(['jack','john','mary'])==['kcaj','nhoj','yram']","canonical_answer":"def reverse_string_list(stringlist):\n result = [x[::-1] for x in stringlist]\n return result","verification_metadata":{"test_list":["assert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB']","assert reverse_string_list(['john','amal','joel','george'])==['nhoj','lama','leoj','egroeg']","assert reverse_string_list(['jack','john','mary'])==['kcaj','nhoj','yram']"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":456,"text":"Write a function to reverse each string in a given list of string values.","code":"def reverse_string_list(stringlist):\n result = [x[::-1] for x in stringlist]\n return result","test_list":["assert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB']","assert reverse_string_list(['john','amal','joel','george'])==['nhoj','lama','leoj','egroeg']","assert reverse_string_list(['jack','john','mary'])==['kcaj','nhoj','yram']"],"test_imports":[]}} {"problem_id":"mbpp_test_00457","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sublist having minimum length.\n\nTests:\nassert Find_Min([[1],[1,2],[1,2,3]]) == [1]\nassert Find_Min([[1,1],[1,1,1],[1,2,7,8]]) == [1,1]\nassert Find_Min([['x'],['x','y'],['x','y','z']]) == ['x']","canonical_answer":"def Find_Min(lst): \n return min(lst, key=len)","verification_metadata":{"test_list":["assert Find_Min([[1],[1,2],[1,2,3]]) == [1]","assert Find_Min([[1,1],[1,1,1],[1,2,7,8]]) == [1,1]","assert Find_Min([['x'],['x','y'],['x','y','z']]) == ['x']"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":457,"text":"Write a python function to find the sublist having minimum length.","code":"def Find_Min(lst): \n return min(lst, key=len)","test_list":["assert Find_Min([[1],[1,2],[1,2,3]]) == [1]","assert Find_Min([[1,1],[1,1,1],[1,2,7,8]]) == [1,1]","assert Find_Min([['x'],['x','y'],['x','y','z']]) == ['x']"],"test_imports":[]}} {"problem_id":"mbpp_test_00458","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the area of a rectangle.\n\nTests:\nassert rectangle_area(10,20)==200\nassert rectangle_area(10,5)==50\nassert rectangle_area(4,2)==8","canonical_answer":"def rectangle_area(l,b):\n area=l*b\n return area","verification_metadata":{"test_list":["assert rectangle_area(10,20)==200","assert rectangle_area(10,5)==50","assert rectangle_area(4,2)==8"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":458,"text":"Write a function to find the area of a rectangle.","code":"def rectangle_area(l,b):\n area=l*b\n return area","test_list":["assert rectangle_area(10,20)==200","assert rectangle_area(10,5)==50","assert rectangle_area(4,2)==8"],"test_imports":[]}} {"problem_id":"mbpp_test_00459","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove uppercase substrings from a given string.\n\nTests:\nassert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos'\nassert remove_uppercase('wAtchTheinTernEtrAdIo') == 'wtchheinerntrdo'\nassert remove_uppercase('VoicESeaRchAndreComMendaTionS') == 'oiceachndreomendaion'","canonical_answer":"import re\ndef remove_uppercase(str1):\n return re.sub('[A-Z]', '', str1)","verification_metadata":{"test_list":["assert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos'","assert remove_uppercase('wAtchTheinTernEtrAdIo') == 'wtchheinerntrdo'","assert remove_uppercase('VoicESeaRchAndreComMendaTionS') == 'oiceachndreomendaion'"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":459,"text":"Write a function to remove uppercase substrings from a given string.","code":"import re\ndef remove_uppercase(str1):\n return re.sub('[A-Z]', '', str1)","test_list":["assert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos'","assert remove_uppercase('wAtchTheinTernEtrAdIo') == 'wtchheinerntrdo'","assert remove_uppercase('VoicESeaRchAndreComMendaTionS') == 'oiceachndreomendaion'"],"test_imports":[]}} {"problem_id":"mbpp_test_00460","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to get the first element of each sublist.\n\nTests:\nassert Extract([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 6]\nassert Extract([[1,2,3],[4, 5]]) == [1,4]\nassert Extract([[9,8,1],[1,2]]) == [9,1]","canonical_answer":"def Extract(lst): \n return [item[0] for item in lst]","verification_metadata":{"test_list":["assert Extract([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 6]","assert Extract([[1,2,3],[4, 5]]) == [1,4]","assert Extract([[9,8,1],[1,2]]) == [9,1]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":460,"text":"Write a python function to get the first element of each sublist.","code":"def Extract(lst): \n return [item[0] for item in lst]","test_list":["assert Extract([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 6]","assert Extract([[1,2,3],[4, 5]]) == [1,4]","assert Extract([[9,8,1],[1,2]]) == [9,1]"],"test_imports":[]}} {"problem_id":"mbpp_test_00461","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the upper case characters in a given string.\n\nTests:\nassert upper_ctr('PYthon') == 1\nassert upper_ctr('BigData') == 1\nassert upper_ctr('program') == 0","canonical_answer":"def upper_ctr(str):\n upper_ctr = 0\n for i in range(len(str)):\n if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1\n return upper_ctr","verification_metadata":{"test_list":["assert upper_ctr('PYthon') == 1","assert upper_ctr('BigData') == 1","assert upper_ctr('program') == 0"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":461,"text":"Write a python function to count the upper case characters in a given string.","code":"def upper_ctr(str):\n upper_ctr = 0\n for i in range(len(str)):\n if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1\n return upper_ctr","test_list":["assert upper_ctr('PYthon') == 1","assert upper_ctr('BigData') == 1","assert upper_ctr('program') == 0"],"test_imports":[]}} {"problem_id":"mbpp_test_00462","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find all possible combinations of the elements of a given list.\n\nTests:\nassert combinations_list(['orange', 'red', 'green', 'blue'])==[[], ['orange'], ['red'], ['red', 'orange'], ['green'], ['green', 'orange'], ['green', 'red'], ['green', 'red', 'orange'], ['blue'], ['blue', 'orange'], ['blue', 'red'], ['blue', 'red', 'orange'], ['blue', 'green'], ['blue', 'green', 'orange'], ['blue', 'green', 'red'], ['blue', 'green', 'red', 'orange']]\nassert combinations_list(['red', 'green', 'blue', 'white', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['blue'], ['blue', 'red'], ['blue', 'green'], ['blue', 'green', 'red'], ['white'], ['white', 'red'], ['white', 'green'], ['white', 'green', 'red'], ['white', 'blue'], ['white', 'blue', 'red'], ['white', 'blue', 'green'], ['white', 'blue', 'green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['black', 'blue'], ['black', 'blue', 'red'], ['black', 'blue', 'green'], ['black', 'blue', 'green', 'red'], ['black', 'white'], ['black', 'white', 'red'], ['black', 'white', 'green'], ['black', 'white', 'green', 'red'], ['black', 'white', 'blue'], ['black', 'white', 'blue', 'red'], ['black', 'white', 'blue', 'green'], ['black', 'white', 'blue', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'blue'], ['orange', 'blue', 'red'], ['orange', 'blue', 'green'], ['orange', 'blue', 'green', 'red'], ['orange', 'white'], ['orange', 'white', 'red'], ['orange', 'white', 'green'], ['orange', 'white', 'green', 'red'], ['orange', 'white', 'blue'], ['orange', 'white', 'blue', 'red'], ['orange', 'white', 'blue', 'green'], ['orange', 'white', 'blue', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red'], ['orange', 'black', 'blue'], ['orange', 'black', 'blue', 'red'], ['orange', 'black', 'blue', 'green'], ['orange', 'black', 'blue', 'green', 'red'], ['orange', 'black', 'white'], ['orange', 'black', 'white', 'red'], ['orange', 'black', 'white', 'green'], ['orange', 'black', 'white', 'green', 'red'], ['orange', 'black', 'white', 'blue'], ['orange', 'black', 'white', 'blue', 'red'], ['orange', 'black', 'white', 'blue', 'green'], ['orange', 'black', 'white', 'blue', 'green', 'red']]\nassert combinations_list(['red', 'green', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red']]","canonical_answer":"def combinations_list(list1):\n if len(list1) == 0:\n return [[]]\n result = []\n for el in combinations_list(list1[1:]):\n result += [el, el+[list1[0]]]\n return result","verification_metadata":{"test_list":["assert combinations_list(['orange', 'red', 'green', 'blue'])==[[], ['orange'], ['red'], ['red', 'orange'], ['green'], ['green', 'orange'], ['green', 'red'], ['green', 'red', 'orange'], ['blue'], ['blue', 'orange'], ['blue', 'red'], ['blue', 'red', 'orange'], ['blue', 'green'], ['blue', 'green', 'orange'], ['blue', 'green', 'red'], ['blue', 'green', 'red', 'orange']]","assert combinations_list(['red', 'green', 'blue', 'white', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['blue'], ['blue', 'red'], ['blue', 'green'], ['blue', 'green', 'red'], ['white'], ['white', 'red'], ['white', 'green'], ['white', 'green', 'red'], ['white', 'blue'], ['white', 'blue', 'red'], ['white', 'blue', 'green'], ['white', 'blue', 'green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['black', 'blue'], ['black', 'blue', 'red'], ['black', 'blue', 'green'], ['black', 'blue', 'green', 'red'], ['black', 'white'], ['black', 'white', 'red'], ['black', 'white', 'green'], ['black', 'white', 'green', 'red'], ['black', 'white', 'blue'], ['black', 'white', 'blue', 'red'], ['black', 'white', 'blue', 'green'], ['black', 'white', 'blue', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'blue'], ['orange', 'blue', 'red'], ['orange', 'blue', 'green'], ['orange', 'blue', 'green', 'red'], ['orange', 'white'], ['orange', 'white', 'red'], ['orange', 'white', 'green'], ['orange', 'white', 'green', 'red'], ['orange', 'white', 'blue'], ['orange', 'white', 'blue', 'red'], ['orange', 'white', 'blue', 'green'], ['orange', 'white', 'blue', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red'], ['orange', 'black', 'blue'], ['orange', 'black', 'blue', 'red'], ['orange', 'black', 'blue', 'green'], ['orange', 'black', 'blue', 'green', 'red'], ['orange', 'black', 'white'], ['orange', 'black', 'white', 'red'], ['orange', 'black', 'white', 'green'], ['orange', 'black', 'white', 'green', 'red'], ['orange', 'black', 'white', 'blue'], ['orange', 'black', 'white', 'blue', 'red'], ['orange', 'black', 'white', 'blue', 'green'], ['orange', 'black', 'white', 'blue', 'green', 'red']]","assert combinations_list(['red', 'green', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red']]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":462,"text":"Write a function to find all possible combinations of the elements of a given list.","code":"def combinations_list(list1):\n if len(list1) == 0:\n return [[]]\n result = []\n for el in combinations_list(list1[1:]):\n result += [el, el+[list1[0]]]\n return result","test_list":["assert combinations_list(['orange', 'red', 'green', 'blue'])==[[], ['orange'], ['red'], ['red', 'orange'], ['green'], ['green', 'orange'], ['green', 'red'], ['green', 'red', 'orange'], ['blue'], ['blue', 'orange'], ['blue', 'red'], ['blue', 'red', 'orange'], ['blue', 'green'], ['blue', 'green', 'orange'], ['blue', 'green', 'red'], ['blue', 'green', 'red', 'orange']]","assert combinations_list(['red', 'green', 'blue', 'white', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['blue'], ['blue', 'red'], ['blue', 'green'], ['blue', 'green', 'red'], ['white'], ['white', 'red'], ['white', 'green'], ['white', 'green', 'red'], ['white', 'blue'], ['white', 'blue', 'red'], ['white', 'blue', 'green'], ['white', 'blue', 'green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['black', 'blue'], ['black', 'blue', 'red'], ['black', 'blue', 'green'], ['black', 'blue', 'green', 'red'], ['black', 'white'], ['black', 'white', 'red'], ['black', 'white', 'green'], ['black', 'white', 'green', 'red'], ['black', 'white', 'blue'], ['black', 'white', 'blue', 'red'], ['black', 'white', 'blue', 'green'], ['black', 'white', 'blue', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'blue'], ['orange', 'blue', 'red'], ['orange', 'blue', 'green'], ['orange', 'blue', 'green', 'red'], ['orange', 'white'], ['orange', 'white', 'red'], ['orange', 'white', 'green'], ['orange', 'white', 'green', 'red'], ['orange', 'white', 'blue'], ['orange', 'white', 'blue', 'red'], ['orange', 'white', 'blue', 'green'], ['orange', 'white', 'blue', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red'], ['orange', 'black', 'blue'], ['orange', 'black', 'blue', 'red'], ['orange', 'black', 'blue', 'green'], ['orange', 'black', 'blue', 'green', 'red'], ['orange', 'black', 'white'], ['orange', 'black', 'white', 'red'], ['orange', 'black', 'white', 'green'], ['orange', 'black', 'white', 'green', 'red'], ['orange', 'black', 'white', 'blue'], ['orange', 'black', 'white', 'blue', 'red'], ['orange', 'black', 'white', 'blue', 'green'], ['orange', 'black', 'white', 'blue', 'green', 'red']]","assert combinations_list(['red', 'green', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red']]"],"test_imports":[]}} {"problem_id":"mbpp_test_00463","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the maximum product subarray of the given array.\n\nTests:\nassert max_subarray_product([1, -2, -3, 0, 7, -8, -2]) == 112\nassert max_subarray_product([6, -3, -10, 0, 2]) == 180\nassert max_subarray_product([-2, -40, 0, -2, -3]) == 80","canonical_answer":"def max_subarray_product(arr):\n\tn = len(arr)\n\tmax_ending_here = 1\n\tmin_ending_here = 1\n\tmax_so_far = 0\n\tflag = 0\n\tfor i in range(0, n):\n\t\tif arr[i] > 0:\n\t\t\tmax_ending_here = max_ending_here * arr[i]\n\t\t\tmin_ending_here = min (min_ending_here * arr[i], 1)\n\t\t\tflag = 1\n\t\telif arr[i] == 0:\n\t\t\tmax_ending_here = 1\n\t\t\tmin_ending_here = 1\n\t\telse:\n\t\t\ttemp = max_ending_here\n\t\t\tmax_ending_here = max (min_ending_here * arr[i], 1)\n\t\t\tmin_ending_here = temp * arr[i]\n\t\tif (max_so_far < max_ending_here):\n\t\t\tmax_so_far = max_ending_here\n\tif flag == 0 and max_so_far == 0:\n\t\treturn 0\n\treturn max_so_far","verification_metadata":{"test_list":["assert max_subarray_product([1, -2, -3, 0, 7, -8, -2]) == 112","assert max_subarray_product([6, -3, -10, 0, 2]) == 180","assert max_subarray_product([-2, -40, 0, -2, -3]) == 80"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":463,"text":"Write a function to find the maximum product subarray of the given array.","code":"def max_subarray_product(arr):\n\tn = len(arr)\n\tmax_ending_here = 1\n\tmin_ending_here = 1\n\tmax_so_far = 0\n\tflag = 0\n\tfor i in range(0, n):\n\t\tif arr[i] > 0:\n\t\t\tmax_ending_here = max_ending_here * arr[i]\n\t\t\tmin_ending_here = min (min_ending_here * arr[i], 1)\n\t\t\tflag = 1\n\t\telif arr[i] == 0:\n\t\t\tmax_ending_here = 1\n\t\t\tmin_ending_here = 1\n\t\telse:\n\t\t\ttemp = max_ending_here\n\t\t\tmax_ending_here = max (min_ending_here * arr[i], 1)\n\t\t\tmin_ending_here = temp * arr[i]\n\t\tif (max_so_far < max_ending_here):\n\t\t\tmax_so_far = max_ending_here\n\tif flag == 0 and max_so_far == 0:\n\t\treturn 0\n\treturn max_so_far","test_list":["assert max_subarray_product([1, -2, -3, 0, 7, -8, -2]) == 112","assert max_subarray_product([6, -3, -10, 0, 2]) == 180","assert max_subarray_product([-2, -40, 0, -2, -3]) == 80"],"test_imports":[]}} {"problem_id":"mbpp_test_00464","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if all values are same in a dictionary.\n\nTests:\nassert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},10)==False\nassert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},12)==True\nassert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},5)==False","canonical_answer":"def check_value(dict, n):\n result = all(x == n for x in dict.values()) \n return result","verification_metadata":{"test_list":["assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},10)==False","assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},12)==True","assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},5)==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":464,"text":"Write a function to check if all values are same in a dictionary.","code":"def check_value(dict, n):\n result = all(x == n for x in dict.values()) \n return result","test_list":["assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},10)==False","assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},12)==True","assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},5)==False"],"test_imports":[]}} {"problem_id":"mbpp_test_00465","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to drop empty items from a given dictionary.\n\nTests:\nassert drop_empty({'c1': 'Red', 'c2': 'Green', 'c3':None})=={'c1': 'Red', 'c2': 'Green'}\nassert drop_empty({'c1': 'Red', 'c2': None, 'c3':None})=={'c1': 'Red'}\nassert drop_empty({'c1': None, 'c2': 'Green', 'c3':None})=={ 'c2': 'Green'}","canonical_answer":"def drop_empty(dict1):\n dict1 = {key:value for (key, value) in dict1.items() if value is not None}\n return dict1","verification_metadata":{"test_list":["assert drop_empty({'c1': 'Red', 'c2': 'Green', 'c3':None})=={'c1': 'Red', 'c2': 'Green'}","assert drop_empty({'c1': 'Red', 'c2': None, 'c3':None})=={'c1': 'Red'}","assert drop_empty({'c1': None, 'c2': 'Green', 'c3':None})=={ 'c2': 'Green'}"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":465,"text":"Write a function to drop empty items from a given dictionary.","code":"def drop_empty(dict1):\n dict1 = {key:value for (key, value) in dict1.items() if value is not None}\n return dict1","test_list":["assert drop_empty({'c1': 'Red', 'c2': 'Green', 'c3':None})=={'c1': 'Red', 'c2': 'Green'}","assert drop_empty({'c1': 'Red', 'c2': None, 'c3':None})=={'c1': 'Red'}","assert drop_empty({'c1': None, 'c2': 'Green', 'c3':None})=={ 'c2': 'Green'}"],"test_imports":[]}} {"problem_id":"mbpp_test_00468","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.\n\nTests:\nassert max_product([3, 100, 4, 5, 150, 6]) == 3000\nassert max_product([4, 42, 55, 68, 80]) == 50265600\nassert max_product([10, 22, 9, 33, 21, 50, 41, 60]) == 2460","canonical_answer":"def max_product(arr): \n n = len(arr)\n mpis = arr[:]\n for i in range(n): \n current_prod = arr[i]\n j = i + 1\n while j < n:\n if arr[j-1] > arr[j]: \n break\n current_prod *= arr[j]\n if current_prod > mpis[j]:\n mpis[j] = current_prod \n j = j + 1\n return max(mpis)","verification_metadata":{"test_list":["assert max_product([3, 100, 4, 5, 150, 6]) == 3000","assert max_product([4, 42, 55, 68, 80]) == 50265600","assert max_product([10, 22, 9, 33, 21, 50, 41, 60]) == 2460"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":468,"text":"Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.","code":"def max_product(arr): \n n = len(arr)\n mpis = arr[:]\n for i in range(n): \n current_prod = arr[i]\n j = i + 1\n while j < n:\n if arr[j-1] > arr[j]: \n break\n current_prod *= arr[j]\n if current_prod > mpis[j]:\n mpis[j] = current_prod \n j = j + 1\n return max(mpis)","test_list":["assert max_product([3, 100, 4, 5, 150, 6]) == 3000","assert max_product([4, 42, 55, 68, 80]) == 50265600","assert max_product([10, 22, 9, 33, 21, 50, 41, 60]) == 2460"],"test_imports":[]}} {"problem_id":"mbpp_test_00470","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the pairwise addition of the neighboring elements of the given tuple.\n\nTests:\nassert add_pairwise((1, 5, 7, 8, 10)) == (6, 12, 15, 18)\nassert add_pairwise((2, 6, 8, 9, 11)) == (8, 14, 17, 20)\nassert add_pairwise((3, 7, 9, 10, 12)) == (10, 16, 19, 22)","canonical_answer":"def add_pairwise(test_tup):\n res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))\n return (res)","verification_metadata":{"test_list":["assert add_pairwise((1, 5, 7, 8, 10)) == (6, 12, 15, 18)","assert add_pairwise((2, 6, 8, 9, 11)) == (8, 14, 17, 20)","assert add_pairwise((3, 7, 9, 10, 12)) == (10, 16, 19, 22)"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":470,"text":"Write a function to find the pairwise addition of the neighboring elements of the given tuple.","code":"def add_pairwise(test_tup):\n res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))\n return (res)","test_list":["assert add_pairwise((1, 5, 7, 8, 10)) == (6, 12, 15, 18)","assert add_pairwise((2, 6, 8, 9, 11)) == (8, 14, 17, 20)","assert add_pairwise((3, 7, 9, 10, 12)) == (10, 16, 19, 22)"],"test_imports":[]}} {"problem_id":"mbpp_test_00471","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the product of the array multiplication modulo n.\n\nTests:\nassert find_remainder([ 100, 10, 5, 25, 35, 14 ],11) ==9\nassert find_remainder([1,1,1],1) == 0\nassert find_remainder([1,2,1],2) == 0","canonical_answer":"def find_remainder(arr, n): \n mul = 1\n for i in range(len(arr)): \n mul = (mul * (arr[i] % n)) % n \n return mul % n","verification_metadata":{"test_list":["assert find_remainder([ 100, 10, 5, 25, 35, 14 ],11) ==9","assert find_remainder([1,1,1],1) == 0","assert find_remainder([1,2,1],2) == 0"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":471,"text":"Write a python function to find the product of the array multiplication modulo n.","code":"def find_remainder(arr, n): \n mul = 1\n for i in range(len(arr)): \n mul = (mul * (arr[i] % n)) % n \n return mul % n","test_list":["assert find_remainder([ 100, 10, 5, 25, 35, 14 ],11) ==9","assert find_remainder([1,1,1],1) == 0","assert find_remainder([1,2,1],2) == 0"],"test_imports":[]}} {"problem_id":"mbpp_test_00472","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether the given list contains consecutive numbers or not.\n\nTests:\nassert check_Consecutive([1,2,3,4,5]) == True\nassert check_Consecutive([1,2,3,5,6]) == False\nassert check_Consecutive([1,2,1]) == False","canonical_answer":"def check_Consecutive(l): \n return sorted(l) == list(range(min(l),max(l)+1))","verification_metadata":{"test_list":["assert check_Consecutive([1,2,3,4,5]) == True","assert check_Consecutive([1,2,3,5,6]) == False","assert check_Consecutive([1,2,1]) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":472,"text":"Write a python function to check whether the given list contains consecutive numbers or not.","code":"def check_Consecutive(l): \n return sorted(l) == list(range(min(l),max(l)+1))","test_list":["assert check_Consecutive([1,2,3,4,5]) == True","assert check_Consecutive([1,2,3,5,6]) == False","assert check_Consecutive([1,2,1]) == False"],"test_imports":[]}} {"problem_id":"mbpp_test_00473","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the tuple intersection of elements in the given tuple list irrespective of their order.\n\nTests:\nassert tuple_intersection([(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]) == {(4, 5), (3, 4), (5, 6)}\nassert tuple_intersection([(4, 1), (7, 4), (11, 13), (17, 14)] , [(1, 4), (7, 4), (16, 12), (10, 13)]) == {(4, 7), (1, 4)}\nassert tuple_intersection([(2, 1), (3, 2), (1, 3), (1, 4)] , [(11, 2), (2, 3), (6, 2), (1, 3)]) == {(1, 3), (2, 3)}","canonical_answer":"def tuple_intersection(test_list1, test_list2):\n res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2])\n return (res)","verification_metadata":{"test_list":["assert tuple_intersection([(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]) == {(4, 5), (3, 4), (5, 6)}","assert tuple_intersection([(4, 1), (7, 4), (11, 13), (17, 14)] , [(1, 4), (7, 4), (16, 12), (10, 13)]) == {(4, 7), (1, 4)}","assert tuple_intersection([(2, 1), (3, 2), (1, 3), (1, 4)] , [(11, 2), (2, 3), (6, 2), (1, 3)]) == {(1, 3), (2, 3)}"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":473,"text":"Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.","code":"def tuple_intersection(test_list1, test_list2):\n res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2])\n return (res)","test_list":["assert tuple_intersection([(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]) == {(4, 5), (3, 4), (5, 6)}","assert tuple_intersection([(4, 1), (7, 4), (11, 13), (17, 14)] , [(1, 4), (7, 4), (16, 12), (10, 13)]) == {(4, 7), (1, 4)}","assert tuple_intersection([(2, 1), (3, 2), (1, 3), (1, 4)] , [(11, 2), (2, 3), (6, 2), (1, 3)]) == {(1, 3), (2, 3)}"],"test_imports":[]}} {"problem_id":"mbpp_test_00474","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to replace characters in a string.\n\nTests:\nassert replace_char(\"polygon\",'y','l')==(\"pollgon\")\nassert replace_char(\"character\",'c','a')==(\"aharaater\")\nassert replace_char(\"python\",'l','a')==(\"python\")","canonical_answer":"def replace_char(str1,ch,newch):\n str2 = str1.replace(ch, newch)\n return str2","verification_metadata":{"test_list":["assert replace_char(\"polygon\",'y','l')==(\"pollgon\")","assert replace_char(\"character\",'c','a')==(\"aharaater\")","assert replace_char(\"python\",'l','a')==(\"python\")"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":474,"text":"Write a function to replace characters in a string.","code":"def replace_char(str1,ch,newch):\n str2 = str1.replace(ch, newch)\n return str2","test_list":["assert replace_char(\"polygon\",'y','l')==(\"pollgon\")","assert replace_char(\"character\",'c','a')==(\"aharaater\")","assert replace_char(\"python\",'l','a')==(\"python\")"],"test_imports":[]}} {"problem_id":"mbpp_test_00475","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sort a dictionary by value.\n\nTests:\nassert sort_counter({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)]\nassert sort_counter({'Math':400, 'Physics':300, 'Chemistry':250})==[('Math', 400), ('Physics', 300), ('Chemistry', 250)]\nassert sort_counter({'Math':900, 'Physics':1000, 'Chemistry':1250})==[('Chemistry', 1250), ('Physics', 1000), ('Math', 900)]","canonical_answer":"from collections import Counter\ndef sort_counter(dict1):\n x = Counter(dict1)\n sort_counter=x.most_common()\n return sort_counter","verification_metadata":{"test_list":["assert sort_counter({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)]","assert sort_counter({'Math':400, 'Physics':300, 'Chemistry':250})==[('Math', 400), ('Physics', 300), ('Chemistry', 250)]","assert sort_counter({'Math':900, 'Physics':1000, 'Chemistry':1250})==[('Chemistry', 1250), ('Physics', 1000), ('Math', 900)]"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":475,"text":"Write a function to sort a dictionary by value.","code":"from collections import Counter\ndef sort_counter(dict1):\n x = Counter(dict1)\n sort_counter=x.most_common()\n return sort_counter","test_list":["assert sort_counter({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)]","assert sort_counter({'Math':400, 'Physics':300, 'Chemistry':250})==[('Math', 400), ('Physics', 300), ('Chemistry', 250)]","assert sort_counter({'Math':900, 'Physics':1000, 'Chemistry':1250})==[('Chemistry', 1250), ('Physics', 1000), ('Math', 900)]"],"test_imports":[]}} {"problem_id":"mbpp_test_00476","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of the largest and smallest value in a given array.\n\nTests:\nassert big_sum([1,2,3]) == 4\nassert big_sum([-1,2,3,4]) == 3\nassert big_sum([2,3,6]) == 8","canonical_answer":"def big_sum(nums):\n sum= max(nums)+min(nums)\n return sum","verification_metadata":{"test_list":["assert big_sum([1,2,3]) == 4","assert big_sum([-1,2,3,4]) == 3","assert big_sum([2,3,6]) == 8"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":476,"text":"Write a python function to find the sum of the largest and smallest value in a given array.","code":"def big_sum(nums):\n sum= max(nums)+min(nums)\n return sum","test_list":["assert big_sum([1,2,3]) == 4","assert big_sum([-1,2,3,4]) == 3","assert big_sum([2,3,6]) == 8"],"test_imports":[]}} {"problem_id":"mbpp_test_00477","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to convert the given string to lower case.\n\nTests:\nassert is_lower(\"InValid\") == \"invalid\"\nassert is_lower(\"TruE\") == \"true\"\nassert is_lower(\"SenTenCE\") == \"sentence\"","canonical_answer":"def is_lower(string):\n return (string.lower())","verification_metadata":{"test_list":["assert is_lower(\"InValid\") == \"invalid\"","assert is_lower(\"TruE\") == \"true\"","assert is_lower(\"SenTenCE\") == \"sentence\""],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":477,"text":"Write a python function to convert the given string to lower case.","code":"def is_lower(string):\n return (string.lower())","test_list":["assert is_lower(\"InValid\") == \"invalid\"","assert is_lower(\"TruE\") == \"true\"","assert is_lower(\"SenTenCE\") == \"sentence\""],"test_imports":[]}} {"problem_id":"mbpp_test_00478","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove lowercase substrings from a given string.\n\nTests:\nassert remove_lowercase(\"PYTHon\")==('PYTH')\nassert remove_lowercase(\"FInD\")==('FID')\nassert remove_lowercase(\"STRinG\")==('STRG')","canonical_answer":"import re\ndef remove_lowercase(str1):\n return re.sub('[a-z]', '', str1)","verification_metadata":{"test_list":["assert remove_lowercase(\"PYTHon\")==('PYTH')","assert remove_lowercase(\"FInD\")==('FID')","assert remove_lowercase(\"STRinG\")==('STRG')"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":478,"text":"Write a function to remove lowercase substrings from a given string.","code":"import re\ndef remove_lowercase(str1):\n return re.sub('[a-z]', '', str1)","test_list":["assert remove_lowercase(\"PYTHon\")==('PYTH')","assert remove_lowercase(\"FInD\")==('FID')","assert remove_lowercase(\"STRinG\")==('STRG')"],"test_imports":[]}} {"problem_id":"mbpp_test_00479","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the first digit of a given number.\n\nTests:\nassert first_Digit(123) == 1\nassert first_Digit(456) == 4\nassert first_Digit(12) == 1","canonical_answer":"def first_Digit(n) : \n while n >= 10: \n n = n / 10 \n return int(n)","verification_metadata":{"test_list":["assert first_Digit(123) == 1","assert first_Digit(456) == 4","assert first_Digit(12) == 1"],"test_imports":[],"verification_type":"execute_and_assert","split":"test"},"raw_source_entry":{"task_id":479,"text":"Write a python function to find the first digit of a given number.","code":"def first_Digit(n) : \n while n >= 10: \n n = n / 10 \n return int(n)","test_list":["assert first_Digit(123) == 1","assert first_Digit(456) == 4","assert first_Digit(12) == 1"],"test_imports":[]}} {"problem_id":"mbpp_validation_00554","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function which takes a list of integers and only returns the odd ones.\n\nTests:\nassert Split([1,2,3,4,5,6]) == [1,3,5]\nassert Split([10,11,12,13]) == [11,13]\nassert Split([7,8,9,1]) == [7,9,1]","canonical_answer":"def Split(list): \n od_li = [] \n for i in list: \n if (i % 2 != 0): \n od_li.append(i) \n return od_li","verification_metadata":{"test_list":["assert Split([1,2,3,4,5,6]) == [1,3,5]","assert Split([10,11,12,13]) == [11,13]","assert Split([7,8,9,1]) == [7,9,1]"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":554,"text":"Write a python function which takes a list of integers and only returns the odd ones.","code":"def Split(list): \n od_li = [] \n for i in list: \n if (i % 2 != 0): \n od_li.append(i) \n return od_li","test_list":["assert Split([1,2,3,4,5,6]) == [1,3,5]","assert Split([10,11,12,13]) == [11,13]","assert Split([7,8,9,1]) == [7,9,1]"],"test_imports":[]}} {"problem_id":"mbpp_validation_00555","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the difference between the sum of cubes of the first n natural numbers and the sum of the first n natural numbers.\n\nTests:\nassert difference(3) == 30\nassert difference(5) == 210\nassert difference(2) == 6","canonical_answer":"def difference(n) : \n S = (n*(n + 1))//2; \n res = S*(S-1); \n return res;","verification_metadata":{"test_list":["assert difference(3) == 30","assert difference(5) == 210","assert difference(2) == 6"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":555,"text":"Write a python function to find the difference between the sum of cubes of the first n natural numbers and the sum of the first n natural numbers.","code":"def difference(n) : \n S = (n*(n + 1))//2; \n res = S*(S-1); \n return res;","test_list":["assert difference(3) == 30","assert difference(5) == 210","assert difference(2) == 6"],"test_imports":[]}} {"problem_id":"mbpp_validation_00556","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count the number of pairs whose xor value is odd.\n\nTests:\nassert find_Odd_Pair([5,4,7,2,1],5) == 6\nassert find_Odd_Pair([7,2,8,1,0,5,11],7) == 12\nassert find_Odd_Pair([1,2,3],3) == 2","canonical_answer":"def find_Odd_Pair(A,N) : \n oddPair = 0\n for i in range(0,N) : \n for j in range(i+1,N) : \n if ((A[i] ^ A[j]) % 2 != 0): \n oddPair+=1 \n return oddPair","verification_metadata":{"test_list":["assert find_Odd_Pair([5,4,7,2,1],5) == 6","assert find_Odd_Pair([7,2,8,1,0,5,11],7) == 12","assert find_Odd_Pair([1,2,3],3) == 2"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":556,"text":"Write a python function to count the number of pairs whose xor value is odd.","code":"def find_Odd_Pair(A,N) : \n oddPair = 0\n for i in range(0,N) : \n for j in range(i+1,N) : \n if ((A[i] ^ A[j]) % 2 != 0): \n oddPair+=1 \n return oddPair","test_list":["assert find_Odd_Pair([5,4,7,2,1],5) == 6","assert find_Odd_Pair([7,2,8,1,0,5,11],7) == 12","assert find_Odd_Pair([1,2,3],3) == 2"],"test_imports":[]}} {"problem_id":"mbpp_validation_00557","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to toggle the case of all characters in a string.\n\nTests:\nassert toggle_string(\"Python\")==(\"pYTHON\")\nassert toggle_string(\"Pangram\")==(\"pANGRAM\")\nassert toggle_string(\"LIttLE\")==(\"liTTle\")","canonical_answer":"def toggle_string(string):\n string1 = string.swapcase()\n return string1","verification_metadata":{"test_list":["assert toggle_string(\"Python\")==(\"pYTHON\")","assert toggle_string(\"Pangram\")==(\"pANGRAM\")","assert toggle_string(\"LIttLE\")==(\"liTTle\")"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":557,"text":"Write a function to toggle the case of all characters in a string.","code":"def toggle_string(string):\n string1 = string.swapcase()\n return string1","test_list":["assert toggle_string(\"Python\")==(\"pYTHON\")","assert toggle_string(\"Pangram\")==(\"pANGRAM\")","assert toggle_string(\"LIttLE\")==(\"liTTle\")"],"test_imports":[]}} {"problem_id":"mbpp_validation_00558","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of the per-digit difference between two integers.\n\nTests:\nassert digit_distance_nums(1,2) == 1\nassert digit_distance_nums(23,56) == 6\nassert digit_distance_nums(123,256) == 7","canonical_answer":"def digit_distance_nums(n1, n2):\n return sum(map(int,str(abs(n1-n2))))","verification_metadata":{"test_list":["assert digit_distance_nums(1,2) == 1","assert digit_distance_nums(23,56) == 6","assert digit_distance_nums(123,256) == 7"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":558,"text":"Write a python function to find the sum of the per-digit difference between two integers.","code":"def digit_distance_nums(n1, n2):\n return sum(map(int,str(abs(n1-n2))))","test_list":["assert digit_distance_nums(1,2) == 1","assert digit_distance_nums(23,56) == 6","assert digit_distance_nums(123,256) == 7"],"test_imports":[]}} {"problem_id":"mbpp_validation_00559","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the sum of the largest contiguous sublist in the given list.\n\nTests:\nassert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3], 8) == 7\nassert max_sub_array_sum([-3, -4, 5, -2, -3, 2, 6, -4], 8) == 8\nassert max_sub_array_sum([-4, -5, 6, -3, -4, 3, 7, -5], 8) == 10","canonical_answer":"def max_sub_array_sum(a, size):\n max_so_far = 0\n max_ending_here = 0\n for i in range(0, size):\n max_ending_here = max_ending_here + a[i]\n if max_ending_here < 0:\n max_ending_here = 0\n elif (max_so_far < max_ending_here):\n max_so_far = max_ending_here\n return max_so_far","verification_metadata":{"test_list":["assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3], 8) == 7","assert max_sub_array_sum([-3, -4, 5, -2, -3, 2, 6, -4], 8) == 8","assert max_sub_array_sum([-4, -5, 6, -3, -4, 3, 7, -5], 8) == 10"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":559,"text":"Write a function to find the sum of the largest contiguous sublist in the given list.","code":"def max_sub_array_sum(a, size):\n max_so_far = 0\n max_ending_here = 0\n for i in range(0, size):\n max_ending_here = max_ending_here + a[i]\n if max_ending_here < 0:\n max_ending_here = 0\n elif (max_so_far < max_ending_here):\n max_so_far = max_ending_here\n return max_so_far","test_list":["assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3], 8) == 7","assert max_sub_array_sum([-3, -4, 5, -2, -3, 2, 6, -4], 8) == 8","assert max_sub_array_sum([-4, -5, 6, -3, -4, 3, 7, -5], 8) == 10"],"test_imports":[]}} {"problem_id":"mbpp_validation_00560","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the union of the elements of two given tuples and output them in sorted order.\n\nTests:\nassert union_elements((3, 4, 5, 6),(5, 7, 4, 10) ) == (3, 4, 5, 6, 7, 10)\nassert union_elements((1, 2, 3, 4),(3, 4, 5, 6) ) == (1, 2, 3, 4, 5, 6)\nassert union_elements((11, 12, 13, 14),(13, 15, 16, 17) ) == (11, 12, 13, 14, 15, 16, 17)","canonical_answer":"def union_elements(test_tup1, test_tup2):\n res = tuple(set(test_tup1 + test_tup2))\n return (res)","verification_metadata":{"test_list":["assert union_elements((3, 4, 5, 6),(5, 7, 4, 10) ) == (3, 4, 5, 6, 7, 10)","assert union_elements((1, 2, 3, 4),(3, 4, 5, 6) ) == (1, 2, 3, 4, 5, 6)","assert union_elements((11, 12, 13, 14),(13, 15, 16, 17) ) == (11, 12, 13, 14, 15, 16, 17)"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":560,"text":"Write a function to find the union of the elements of two given tuples and output them in sorted order.","code":"def union_elements(test_tup1, test_tup2):\n res = tuple(set(test_tup1 + test_tup2))\n return (res)","test_list":["assert union_elements((3, 4, 5, 6),(5, 7, 4, 10) ) == (3, 4, 5, 6, 7, 10)","assert union_elements((1, 2, 3, 4),(3, 4, 5, 6) ) == (1, 2, 3, 4, 5, 6)","assert union_elements((11, 12, 13, 14),(13, 15, 16, 17) ) == (11, 12, 13, 14, 15, 16, 17)"],"test_imports":[]}} {"problem_id":"mbpp_validation_00562","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the length of the longest sublists.\n\nTests:\nassert Find_Max_Length([[1],[1,4],[5,6,7,8]]) == 4\nassert Find_Max_Length([[0,1],[2,2,],[3,2,1]]) == 3\nassert Find_Max_Length([[7],[22,23],[13,14,15],[10,20,30,40,50]]) == 5","canonical_answer":"def Find_Max_Length(lst): \n maxLength = max(len(x) for x in lst )\n return maxLength","verification_metadata":{"test_list":["assert Find_Max_Length([[1],[1,4],[5,6,7,8]]) == 4","assert Find_Max_Length([[0,1],[2,2,],[3,2,1]]) == 3","assert Find_Max_Length([[7],[22,23],[13,14,15],[10,20,30,40,50]]) == 5"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":562,"text":"Write a python function to find the length of the longest sublists.","code":"def Find_Max_Length(lst): \n maxLength = max(len(x) for x in lst )\n return maxLength","test_list":["assert Find_Max_Length([[1],[1,4],[5,6,7,8]]) == 4","assert Find_Max_Length([[0,1],[2,2,],[3,2,1]]) == 3","assert Find_Max_Length([[7],[22,23],[13,14,15],[10,20,30,40,50]]) == 5"],"test_imports":[]}} {"problem_id":"mbpp_validation_00563","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to extract values between quotation marks from a string.\n\nTests:\nassert extract_values('\"Python\", \"PHP\", \"Java\"')==['Python', 'PHP', 'Java']\nassert extract_values('\"python\",\"program\",\"language\"')==['python','program','language']\nassert extract_values('\"red\",\"blue\",\"green\",\"yellow\"')==['red','blue','green','yellow']","canonical_answer":"import re\ndef extract_values(text):\n return (re.findall(r'\"(.*?)\"', text))","verification_metadata":{"test_list":["assert extract_values('\"Python\", \"PHP\", \"Java\"')==['Python', 'PHP', 'Java']","assert extract_values('\"python\",\"program\",\"language\"')==['python','program','language']","assert extract_values('\"red\",\"blue\",\"green\",\"yellow\"')==['red','blue','green','yellow']"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":563,"text":"Write a function to extract values between quotation marks from a string.","code":"import re\ndef extract_values(text):\n return (re.findall(r'\"(.*?)\"', text))","test_list":["assert extract_values('\"Python\", \"PHP\", \"Java\"')==['Python', 'PHP', 'Java']","assert extract_values('\"python\",\"program\",\"language\"')==['python','program','language']","assert extract_values('\"red\",\"blue\",\"green\",\"yellow\"')==['red','blue','green','yellow']"],"test_imports":[]}} {"problem_id":"mbpp_validation_00564","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function which takes a list of integers and counts the number of possible unordered pairs where both elements are unequal.\n\nTests:\nassert count_Pairs([1,2,1],3) == 2\nassert count_Pairs([1,1,1,1],4) == 0\nassert count_Pairs([1,2,3,4,5],5) == 10","canonical_answer":"def count_Pairs(arr,n): \n cnt = 0; \n for i in range(n): \n for j in range(i + 1,n): \n if (arr[i] != arr[j]): \n cnt += 1; \n return cnt;","verification_metadata":{"test_list":["assert count_Pairs([1,2,1],3) == 2","assert count_Pairs([1,1,1,1],4) == 0","assert count_Pairs([1,2,3,4,5],5) == 10"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":564,"text":"Write a python function which takes a list of integers and counts the number of possible unordered pairs where both elements are unequal.","code":"def count_Pairs(arr,n): \n cnt = 0; \n for i in range(n): \n for j in range(i + 1,n): \n if (arr[i] != arr[j]): \n cnt += 1; \n return cnt;","test_list":["assert count_Pairs([1,2,1],3) == 2","assert count_Pairs([1,1,1,1],4) == 0","assert count_Pairs([1,2,3,4,5],5) == 10"],"test_imports":[]}} {"problem_id":"mbpp_validation_00565","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to split a string into characters.\n\nTests:\nassert split('python') == ['p','y','t','h','o','n']\nassert split('Name') == ['N','a','m','e']\nassert split('program') == ['p','r','o','g','r','a','m']","canonical_answer":"def split(word): \n return [char for char in word]","verification_metadata":{"test_list":["assert split('python') == ['p','y','t','h','o','n']","assert split('Name') == ['N','a','m','e']","assert split('program') == ['p','r','o','g','r','a','m']"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":565,"text":"Write a python function to split a string into characters.","code":"def split(word): \n return [char for char in word]","test_list":["assert split('python') == ['p','y','t','h','o','n']","assert split('Name') == ['N','a','m','e']","assert split('program') == ['p','r','o','g','r','a','m']"],"test_imports":[]}} {"problem_id":"mbpp_validation_00566","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to get the sum of the digits of a non-negative integer.\n\nTests:\nassert sum_digits(345)==12\nassert sum_digits(12)==3\nassert sum_digits(97)==16","canonical_answer":"def sum_digits(n):\n if n == 0:\n return 0\n else:\n return n % 10 + sum_digits(int(n / 10))","verification_metadata":{"test_list":["assert sum_digits(345)==12","assert sum_digits(12)==3","assert sum_digits(97)==16"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":566,"text":"Write a function to get the sum of the digits of a non-negative integer.","code":"def sum_digits(n):\n if n == 0:\n return 0\n else:\n return n % 10 + sum_digits(int(n / 10))","test_list":["assert sum_digits(345)==12","assert sum_digits(12)==3","assert sum_digits(97)==16"],"test_imports":[]}} {"problem_id":"mbpp_validation_00567","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether a specified list is sorted or not.\n\nTests:\nassert issort_list([1,2,4,6,8,10,12,14,16,17])==True\nassert issort_list([1, 2, 4, 6, 8, 10, 12, 14, 20, 17])==False\nassert issort_list([1, 2, 4, 6, 8, 10,15,14,20])==False","canonical_answer":"def issort_list(list1):\n result = all(list1[i] <= list1[i+1] for i in range(len(list1)-1))\n return result","verification_metadata":{"test_list":["assert issort_list([1,2,4,6,8,10,12,14,16,17])==True","assert issort_list([1, 2, 4, 6, 8, 10, 12, 14, 20, 17])==False","assert issort_list([1, 2, 4, 6, 8, 10,15,14,20])==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":567,"text":"Write a function to check whether a specified list is sorted or not.","code":"def issort_list(list1):\n result = all(list1[i] <= list1[i+1] for i in range(len(list1)-1))\n return result","test_list":["assert issort_list([1,2,4,6,8,10,12,14,16,17])==True","assert issort_list([1, 2, 4, 6, 8, 10, 12, 14, 20, 17])==False","assert issort_list([1, 2, 4, 6, 8, 10,15,14,20])==False"],"test_imports":[]}} {"problem_id":"mbpp_validation_00568","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to create a list of N empty dictionaries.\n\nTests:\nassert empty_list(5)==[{},{},{},{},{}]\nassert empty_list(6)==[{},{},{},{},{},{}]\nassert empty_list(7)==[{},{},{},{},{},{},{}]","canonical_answer":"def empty_list(length):\n empty_list = [{} for _ in range(length)]\n return empty_list","verification_metadata":{"test_list":["assert empty_list(5)==[{},{},{},{},{}]","assert empty_list(6)==[{},{},{},{},{},{}]","assert empty_list(7)==[{},{},{},{},{},{},{}]"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":568,"text":"Write a function to create a list of N empty dictionaries.","code":"def empty_list(length):\n empty_list = [{} for _ in range(length)]\n return empty_list","test_list":["assert empty_list(5)==[{},{},{},{},{}]","assert empty_list(6)==[{},{},{},{},{},{}]","assert empty_list(7)==[{},{},{},{},{},{},{}]"],"test_imports":[]}} {"problem_id":"mbpp_validation_00569","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to sort each sublist of strings in a given list of lists.\n\nTests:\nassert sort_sublists([['green', 'orange'], ['black', 'white'], ['white', 'black', 'orange']])==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]\nassert sort_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])==[['green', 'orange'], ['black'], ['green', 'orange'], ['white']]\nassert sort_sublists([['a','b'],['d','c'],['g','h'] , ['f','e']])==[['a', 'b'], ['c', 'd'], ['g', 'h'], ['e', 'f']]","canonical_answer":"def sort_sublists(list1):\n result = list(map(sorted,list1)) \n return result","verification_metadata":{"test_list":["assert sort_sublists([['green', 'orange'], ['black', 'white'], ['white', 'black', 'orange']])==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]","assert sort_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])==[['green', 'orange'], ['black'], ['green', 'orange'], ['white']]","assert sort_sublists([['a','b'],['d','c'],['g','h'] , ['f','e']])==[['a', 'b'], ['c', 'd'], ['g', 'h'], ['e', 'f']]"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":569,"text":"Write a function to sort each sublist of strings in a given list of lists.","code":"def sort_sublists(list1):\n result = list(map(sorted,list1)) \n return result","test_list":["assert sort_sublists([['green', 'orange'], ['black', 'white'], ['white', 'black', 'orange']])==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]","assert sort_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])==[['green', 'orange'], ['black'], ['green', 'orange'], ['white']]","assert sort_sublists([['a','b'],['d','c'],['g','h'] , ['f','e']])==[['a', 'b'], ['c', 'd'], ['g', 'h'], ['e', 'f']]"],"test_imports":[]}} {"problem_id":"mbpp_validation_00572","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to remove duplicate numbers from a given number of lists.\n\nTests:\nassert two_unique_nums([1,2,3,2,3,4,5]) == [1, 4, 5]\nassert two_unique_nums([1,2,3,2,4,5]) == [1, 3, 4, 5]\nassert two_unique_nums([1,2,3,4,5]) == [1, 2, 3, 4, 5]","canonical_answer":"def two_unique_nums(nums):\n return [i for i in nums if nums.count(i)==1]","verification_metadata":{"test_list":["assert two_unique_nums([1,2,3,2,3,4,5]) == [1, 4, 5]","assert two_unique_nums([1,2,3,2,4,5]) == [1, 3, 4, 5]","assert two_unique_nums([1,2,3,4,5]) == [1, 2, 3, 4, 5]"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":572,"text":"Write a python function to remove duplicate numbers from a given number of lists.","code":"def two_unique_nums(nums):\n return [i for i in nums if nums.count(i)==1]","test_list":["assert two_unique_nums([1,2,3,2,3,4,5]) == [1, 4, 5]","assert two_unique_nums([1,2,3,2,4,5]) == [1, 3, 4, 5]","assert two_unique_nums([1,2,3,4,5]) == [1, 2, 3, 4, 5]"],"test_imports":[]}} {"problem_id":"mbpp_validation_00573","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to calculate the product of the unique numbers in a given list.\n\nTests:\nassert unique_product([10, 20, 30, 40, 20, 50, 60, 40]) == 720000000\nassert unique_product([1, 2, 3, 1,]) == 6\nassert unique_product([7, 8, 9, 0, 1, 1]) == 0","canonical_answer":"def unique_product(list_data):\n temp = list(set(list_data))\n p = 1\n for i in temp:\n p *= i\n return p","verification_metadata":{"test_list":["assert unique_product([10, 20, 30, 40, 20, 50, 60, 40]) == 720000000","assert unique_product([1, 2, 3, 1,]) == 6","assert unique_product([7, 8, 9, 0, 1, 1]) == 0"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":573,"text":"Write a python function to calculate the product of the unique numbers in a given list.","code":"def unique_product(list_data):\n temp = list(set(list_data))\n p = 1\n for i in temp:\n p *= i\n return p","test_list":["assert unique_product([10, 20, 30, 40, 20, 50, 60, 40]) == 720000000","assert unique_product([1, 2, 3, 1,]) == 6","assert unique_product([7, 8, 9, 0, 1, 1]) == 0"],"test_imports":[]}} {"problem_id":"mbpp_validation_00574","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the surface area of a cylinder.\n\nTests:\nassert surfacearea_cylinder(10,5)==942.45\nassert surfacearea_cylinder(4,5)==226.18800000000002\nassert surfacearea_cylinder(4,10)==351.848","canonical_answer":"def surfacearea_cylinder(r,h):\n surfacearea=((2*3.1415*r*r) +(2*3.1415*r*h))\n return surfacearea","verification_metadata":{"test_list":["assert surfacearea_cylinder(10,5)==942.45","assert surfacearea_cylinder(4,5)==226.18800000000002","assert surfacearea_cylinder(4,10)==351.848"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":574,"text":"Write a function to find the surface area of a cylinder.","code":"def surfacearea_cylinder(r,h):\n surfacearea=((2*3.1415*r*r) +(2*3.1415*r*h))\n return surfacearea","test_list":["assert surfacearea_cylinder(10,5)==942.45","assert surfacearea_cylinder(4,5)==226.18800000000002","assert surfacearea_cylinder(4,10)==351.848"],"test_imports":[]}} {"problem_id":"mbpp_validation_00576","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether a list is sublist of another or not.\n\nTests:\nassert is_Sub_Array([1,4,3,5],[1,2]) == False\nassert is_Sub_Array([1,2,1],[1,2,1]) == True\nassert is_Sub_Array([1,0,2,2],[2,2,0]) ==False","canonical_answer":"def is_Sub_Array(A,B): \n n = len(A)\n m = len(B)\n i = 0; j = 0; \n while (i < n and j < m): \n if (A[i] == B[j]): \n i += 1; \n j += 1; \n if (j == m): \n return True; \n else: \n i = i - j + 1; \n j = 0; \n return False;","verification_metadata":{"test_list":["assert is_Sub_Array([1,4,3,5],[1,2]) == False","assert is_Sub_Array([1,2,1],[1,2,1]) == True","assert is_Sub_Array([1,0,2,2],[2,2,0]) ==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":576,"text":"Write a python function to check whether a list is sublist of another or not.","code":"def is_Sub_Array(A,B): \n n = len(A)\n m = len(B)\n i = 0; j = 0; \n while (i < n and j < m): \n if (A[i] == B[j]): \n i += 1; \n j += 1; \n if (j == m): \n return True; \n else: \n i = i - j + 1; \n j = 0; \n return False;","test_list":["assert is_Sub_Array([1,4,3,5],[1,2]) == False","assert is_Sub_Array([1,2,1],[1,2,1]) == True","assert is_Sub_Array([1,0,2,2],[2,2,0]) ==False"],"test_imports":[]}} {"problem_id":"mbpp_validation_00577","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the last digit in factorial of a given number.\n\nTests:\nassert last_Digit_Factorial(4) == 4\nassert last_Digit_Factorial(21) == 0\nassert last_Digit_Factorial(30) == 0","canonical_answer":"def last_Digit_Factorial(n): \n if (n == 0): return 1\n elif (n <= 2): return n \n elif (n == 3): return 6\n elif (n == 4): return 4 \n else: \n return 0","verification_metadata":{"test_list":["assert last_Digit_Factorial(4) == 4","assert last_Digit_Factorial(21) == 0","assert last_Digit_Factorial(30) == 0"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":577,"text":"Write a python function to find the last digit in factorial of a given number.","code":"def last_Digit_Factorial(n): \n if (n == 0): return 1\n elif (n <= 2): return n \n elif (n == 3): return 6\n elif (n == 4): return 4 \n else: \n return 0","test_list":["assert last_Digit_Factorial(4) == 4","assert last_Digit_Factorial(21) == 0","assert last_Digit_Factorial(30) == 0"],"test_imports":[]}} {"problem_id":"mbpp_validation_00578","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to interleave 3 lists of the same length into a single flat list.\n\nTests:\nassert interleave_lists([1,2,3,4,5,6,7],[10,20,30,40,50,60,70],[100,200,300,400,500,600,700])==[1, 10, 100, 2, 20, 200, 3, 30, 300, 4, 40, 400, 5, 50, 500, 6, 60, 600, 7, 70, 700]\nassert interleave_lists([10,20],[15,2],[5,10])==[10,15,5,20,2,10]\nassert interleave_lists([11,44], [10,15], [20,5])==[11,10,20,44,15,5]","canonical_answer":"def interleave_lists(list1,list2,list3):\n result = [el for pair in zip(list1, list2, list3) for el in pair]\n return result","verification_metadata":{"test_list":["assert interleave_lists([1,2,3,4,5,6,7],[10,20,30,40,50,60,70],[100,200,300,400,500,600,700])==[1, 10, 100, 2, 20, 200, 3, 30, 300, 4, 40, 400, 5, 50, 500, 6, 60, 600, 7, 70, 700]","assert interleave_lists([10,20],[15,2],[5,10])==[10,15,5,20,2,10]","assert interleave_lists([11,44], [10,15], [20,5])==[11,10,20,44,15,5]"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":578,"text":"Write a function to interleave 3 lists of the same length into a single flat list.","code":"def interleave_lists(list1,list2,list3):\n result = [el for pair in zip(list1, list2, list3) for el in pair]\n return result","test_list":["assert interleave_lists([1,2,3,4,5,6,7],[10,20,30,40,50,60,70],[100,200,300,400,500,600,700])==[1, 10, 100, 2, 20, 200, 3, 30, 300, 4, 40, 400, 5, 50, 500, 6, 60, 600, 7, 70, 700]","assert interleave_lists([10,20],[15,2],[5,10])==[10,15,5,20,2,10]","assert interleave_lists([11,44], [10,15], [20,5])==[11,10,20,44,15,5]"],"test_imports":[]}} {"problem_id":"mbpp_validation_00579","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the dissimilar elements in the given two tuples.\n\nTests:\nassert find_dissimilar((3, 4, 5, 6), (5, 7, 4, 10)) == (3, 6, 7, 10)\nassert find_dissimilar((1, 2, 3, 4), (7, 2, 3, 9)) == (1, 4, 7, 9)\nassert find_dissimilar((21, 11, 25, 26), (26, 34, 21, 36)) == (34, 36, 11, 25)","canonical_answer":"def find_dissimilar(test_tup1, test_tup2):\n res = tuple(set(test_tup1) ^ set(test_tup2))\n return (res)","verification_metadata":{"test_list":["assert find_dissimilar((3, 4, 5, 6), (5, 7, 4, 10)) == (3, 6, 7, 10)","assert find_dissimilar((1, 2, 3, 4), (7, 2, 3, 9)) == (1, 4, 7, 9)","assert find_dissimilar((21, 11, 25, 26), (26, 34, 21, 36)) == (34, 36, 11, 25)"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":579,"text":"Write a function to find the dissimilar elements in the given two tuples.","code":"def find_dissimilar(test_tup1, test_tup2):\n res = tuple(set(test_tup1) ^ set(test_tup2))\n return (res)","test_list":["assert find_dissimilar((3, 4, 5, 6), (5, 7, 4, 10)) == (3, 6, 7, 10)","assert find_dissimilar((1, 2, 3, 4), (7, 2, 3, 9)) == (1, 4, 7, 9)","assert find_dissimilar((21, 11, 25, 26), (26, 34, 21, 36)) == (34, 36, 11, 25)"],"test_imports":[]}} {"problem_id":"mbpp_validation_00580","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove uneven elements in the nested mixed tuple.\n\nTests:\nassert extract_even((4, 5, (7, 6, (2, 4)), 6, 8)) == (4, (6, (2, 4)), 6, 8)\nassert extract_even((5, 6, (8, 7, (4, 8)), 7, 9)) == (6, (8, (4, 8)))\nassert extract_even((5, 6, (9, 8, (4, 6)), 8, 10)) == (6, (8, (4, 6)), 8, 10)","canonical_answer":"def even_ele(test_tuple, even_fnc): \n\tres = tuple() \n\tfor ele in test_tuple: \n\t\tif isinstance(ele, tuple): \n\t\t\tres += (even_ele(ele, even_fnc), ) \n\t\telif even_fnc(ele): \n\t\t\tres += (ele, ) \n\treturn res \ndef extract_even(test_tuple):\n res = even_ele(test_tuple, lambda x: x % 2 == 0)\n return (res)","verification_metadata":{"test_list":["assert extract_even((4, 5, (7, 6, (2, 4)), 6, 8)) == (4, (6, (2, 4)), 6, 8)","assert extract_even((5, 6, (8, 7, (4, 8)), 7, 9)) == (6, (8, (4, 8)))","assert extract_even((5, 6, (9, 8, (4, 6)), 8, 10)) == (6, (8, (4, 6)), 8, 10)"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":580,"text":"Write a function to remove uneven elements in the nested mixed tuple.","code":"def even_ele(test_tuple, even_fnc): \n\tres = tuple() \n\tfor ele in test_tuple: \n\t\tif isinstance(ele, tuple): \n\t\t\tres += (even_ele(ele, even_fnc), ) \n\t\telif even_fnc(ele): \n\t\t\tres += (ele, ) \n\treturn res \ndef extract_even(test_tuple):\n res = even_ele(test_tuple, lambda x: x % 2 == 0)\n return (res)","test_list":["assert extract_even((4, 5, (7, 6, (2, 4)), 6, 8)) == (4, (6, (2, 4)), 6, 8)","assert extract_even((5, 6, (8, 7, (4, 8)), 7, 9)) == (6, (8, (4, 8)))","assert extract_even((5, 6, (9, 8, (4, 6)), 8, 10)) == (6, (8, (4, 6)), 8, 10)"],"test_imports":[]}} {"problem_id":"mbpp_validation_00581","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the surface area of a square pyramid with a given base edge and height.\n\nTests:\nassert surface_Area(3,4) == 33\nassert surface_Area(4,5) == 56\nassert surface_Area(1,2) == 5","canonical_answer":"def surface_Area(b,s): \n return 2 * b * s + pow(b,2)","verification_metadata":{"test_list":["assert surface_Area(3,4) == 33","assert surface_Area(4,5) == 56","assert surface_Area(1,2) == 5"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":581,"text":"Write a python function to find the surface area of a square pyramid with a given base edge and height.","code":"def surface_Area(b,s): \n return 2 * b * s + pow(b,2)","test_list":["assert surface_Area(3,4) == 33","assert surface_Area(4,5) == 56","assert surface_Area(1,2) == 5"],"test_imports":[]}} {"problem_id":"mbpp_validation_00582","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check if a dictionary is empty\n\nTests:\nassert my_dict({10})==False\nassert my_dict({11})==False\nassert my_dict({})==True","canonical_answer":"def my_dict(dict1):\n if bool(dict1):\n return False\n else:\n return True","verification_metadata":{"test_list":["assert my_dict({10})==False","assert my_dict({11})==False","assert my_dict({})==True"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":582,"text":"Write a function to check if a dictionary is empty","code":"def my_dict(dict1):\n if bool(dict1):\n return False\n else:\n return True","test_list":["assert my_dict({10})==False","assert my_dict({11})==False","assert my_dict({})==True"],"test_imports":[]}} {"problem_id":"mbpp_validation_00583","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function which returns nth catalan number.\n\nTests:\nassert catalan_number(10)==16796\nassert catalan_number(9)==4862\nassert catalan_number(7)==429","canonical_answer":"def catalan_number(num):\n if num <=1:\n return 1 \n res_num = 0\n for i in range(num):\n res_num += catalan_number(i) * catalan_number(num-i-1)\n return res_num","verification_metadata":{"test_list":["assert catalan_number(10)==16796","assert catalan_number(9)==4862","assert catalan_number(7)==429"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":583,"text":"Write a function which returns nth catalan number.","code":"def catalan_number(num):\n if num <=1:\n return 1 \n res_num = 0\n for i in range(num):\n res_num += catalan_number(i) * catalan_number(num-i-1)\n return res_num","test_list":["assert catalan_number(10)==16796","assert catalan_number(9)==4862","assert catalan_number(7)==429"],"test_imports":[]}} {"problem_id":"mbpp_validation_00584","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the first adverb ending with ly and its positions in a given string.\n\nTests:\nassert find_adverbs(\"Clearly, he has no excuse for such behavior.\") == '0-7: Clearly'\nassert find_adverbs(\"Please handle the situation carefuly\") == '28-36: carefuly'\nassert find_adverbs(\"Complete the task quickly\") == '18-25: quickly'","canonical_answer":"import re\ndef find_adverbs(text):\n for m in re.finditer(r\"\\w+ly\", text):\n return ('%d-%d: %s' % (m.start(), m.end(), m.group(0)))","verification_metadata":{"test_list":["assert find_adverbs(\"Clearly, he has no excuse for such behavior.\") == '0-7: Clearly'","assert find_adverbs(\"Please handle the situation carefuly\") == '28-36: carefuly'","assert find_adverbs(\"Complete the task quickly\") == '18-25: quickly'"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":584,"text":"Write a function to find the first adverb ending with ly and its positions in a given string.","code":"import re\ndef find_adverbs(text):\n for m in re.finditer(r\"\\w+ly\", text):\n return ('%d-%d: %s' % (m.start(), m.end(), m.group(0)))","test_list":["assert find_adverbs(\"Clearly, he has no excuse for such behavior.\") == '0-7: Clearly'","assert find_adverbs(\"Please handle the situation carefuly\") == '28-36: carefuly'","assert find_adverbs(\"Complete the task quickly\") == '18-25: quickly'"],"test_imports":[]}} {"problem_id":"mbpp_validation_00585","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the n most expensive items in a given dataset.\n\nTests:\nassert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-2', 'price': 555.22}]\nassert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09}],2)==[{'name': 'Item-2', 'price': 555.22},{'name': 'Item-1', 'price': 101.1}]\nassert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09},{'name': 'Item-4', 'price': 22.75}],1)==[{'name': 'Item-2', 'price': 555.22}]","canonical_answer":"import heapq\ndef expensive_items(items,n):\n expensive_items = heapq.nlargest(n, items, key=lambda s: s['price'])\n return expensive_items","verification_metadata":{"test_list":["assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-2', 'price': 555.22}]","assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09}],2)==[{'name': 'Item-2', 'price': 555.22},{'name': 'Item-1', 'price': 101.1}]","assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09},{'name': 'Item-4', 'price': 22.75}],1)==[{'name': 'Item-2', 'price': 555.22}]"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":585,"text":"Write a function to find the n most expensive items in a given dataset.","code":"import heapq\ndef expensive_items(items,n):\n expensive_items = heapq.nlargest(n, items, key=lambda s: s['price'])\n return expensive_items","test_list":["assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-2', 'price': 555.22}]","assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09}],2)==[{'name': 'Item-2', 'price': 555.22},{'name': 'Item-1', 'price': 101.1}]","assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09},{'name': 'Item-4', 'price': 22.75}],1)==[{'name': 'Item-2', 'price': 555.22}]"],"test_imports":[]}} {"problem_id":"mbpp_validation_00586","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to split a list at the nth eelment and add the first part to the end.\n\nTests:\nassert split_Arr([12,10,5,6,52,36],2) == [5,6,52,36,12,10]\nassert split_Arr([1,2,3,4],1) == [2,3,4,1]\nassert split_Arr([0,1,2,3,4,5,6,7],3) == [3,4,5,6,7,0,1,2]","canonical_answer":"def split_Arr(l, n):\n return l[n:] + l[:n]","verification_metadata":{"test_list":["assert split_Arr([12,10,5,6,52,36],2) == [5,6,52,36,12,10]","assert split_Arr([1,2,3,4],1) == [2,3,4,1]","assert split_Arr([0,1,2,3,4,5,6,7],3) == [3,4,5,6,7,0,1,2]"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":586,"text":"Write a python function to split a list at the nth eelment and add the first part to the end.","code":"def split_Arr(l, n):\n return l[n:] + l[:n]","test_list":["assert split_Arr([12,10,5,6,52,36],2) == [5,6,52,36,12,10]","assert split_Arr([1,2,3,4],1) == [2,3,4,1]","assert split_Arr([0,1,2,3,4,5,6,7],3) == [3,4,5,6,7,0,1,2]"],"test_imports":[]}} {"problem_id":"mbpp_validation_00587","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert a list to a tuple.\n\nTests:\nassert list_tuple([5, 10, 7, 4, 15, 3])==(5, 10, 7, 4, 15, 3)\nassert list_tuple([2, 4, 5, 6, 2, 3, 4, 4, 7])==(2, 4, 5, 6, 2, 3, 4, 4, 7)\nassert list_tuple([58,44,56])==(58,44,56)","canonical_answer":"def list_tuple(listx):\n tuplex = tuple(listx)\n return tuplex","verification_metadata":{"test_list":["assert list_tuple([5, 10, 7, 4, 15, 3])==(5, 10, 7, 4, 15, 3)","assert list_tuple([2, 4, 5, 6, 2, 3, 4, 4, 7])==(2, 4, 5, 6, 2, 3, 4, 4, 7)","assert list_tuple([58,44,56])==(58,44,56)"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":587,"text":"Write a function to convert a list to a tuple.","code":"def list_tuple(listx):\n tuplex = tuple(listx)\n return tuplex","test_list":["assert list_tuple([5, 10, 7, 4, 15, 3])==(5, 10, 7, 4, 15, 3)","assert list_tuple([2, 4, 5, 6, 2, 3, 4, 4, 7])==(2, 4, 5, 6, 2, 3, 4, 4, 7)","assert list_tuple([58,44,56])==(58,44,56)"],"test_imports":[]}} {"problem_id":"mbpp_validation_00588","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the difference between largest and smallest value in a given list.\n\nTests:\nassert big_diff([1,2,3,4]) == 3\nassert big_diff([4,5,12]) == 8\nassert big_diff([9,2,3]) == 7","canonical_answer":"def big_diff(nums):\n diff= max(nums)-min(nums)\n return diff","verification_metadata":{"test_list":["assert big_diff([1,2,3,4]) == 3","assert big_diff([4,5,12]) == 8","assert big_diff([9,2,3]) == 7"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":588,"text":"Write a python function to find the difference between largest and smallest value in a given list.","code":"def big_diff(nums):\n diff= max(nums)-min(nums)\n return diff","test_list":["assert big_diff([1,2,3,4]) == 3","assert big_diff([4,5,12]) == 8","assert big_diff([9,2,3]) == 7"],"test_imports":[]}} {"problem_id":"mbpp_validation_00589","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find perfect squares between two given numbers.\n\nTests:\nassert perfect_squares(1,30)==[1, 4, 9, 16, 25]\nassert perfect_squares(50,100)==[64, 81, 100]\nassert perfect_squares(100,200)==[100, 121, 144, 169, 196]","canonical_answer":"def perfect_squares(a, b):\n lists=[]\n for i in range (a,b+1):\n j = 1;\n while j*j <= i:\n if j*j == i:\n lists.append(i) \n j = j+1\n i = i+1\n return lists","verification_metadata":{"test_list":["assert perfect_squares(1,30)==[1, 4, 9, 16, 25]","assert perfect_squares(50,100)==[64, 81, 100]","assert perfect_squares(100,200)==[100, 121, 144, 169, 196]"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":589,"text":"Write a function to find perfect squares between two given numbers.","code":"def perfect_squares(a, b):\n lists=[]\n for i in range (a,b+1):\n j = 1;\n while j*j <= i:\n if j*j == i:\n lists.append(i) \n j = j+1\n i = i+1\n return lists","test_list":["assert perfect_squares(1,30)==[1, 4, 9, 16, 25]","assert perfect_squares(50,100)==[64, 81, 100]","assert perfect_squares(100,200)==[100, 121, 144, 169, 196]"],"test_imports":[]}} {"problem_id":"mbpp_validation_00590","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to convert polar coordinates to rectangular coordinates.\n\nTests:\nassert polar_rect(3,4)==((5.0, 0.9272952180016122), (-2+2.4492935982947064e-16j))\nassert polar_rect(4,7)==((8.06225774829855, 1.0516502125483738), (-2+2.4492935982947064e-16j))\nassert polar_rect(15,17)==((22.67156809750927, 0.8478169733934057), (-2+2.4492935982947064e-16j))","canonical_answer":"import cmath\ndef polar_rect(x,y):\n cn = complex(x,y)\n cn=cmath.polar(cn)\n cn1 = cmath.rect(2, cmath.pi)\n return (cn,cn1)","verification_metadata":{"test_list":["assert polar_rect(3,4)==((5.0, 0.9272952180016122), (-2+2.4492935982947064e-16j))","assert polar_rect(4,7)==((8.06225774829855, 1.0516502125483738), (-2+2.4492935982947064e-16j))","assert polar_rect(15,17)==((22.67156809750927, 0.8478169733934057), (-2+2.4492935982947064e-16j))"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":590,"text":"Write a function to convert polar coordinates to rectangular coordinates.","code":"import cmath\ndef polar_rect(x,y):\n cn = complex(x,y)\n cn=cmath.polar(cn)\n cn1 = cmath.rect(2, cmath.pi)\n return (cn,cn1)","test_list":["assert polar_rect(3,4)==((5.0, 0.9272952180016122), (-2+2.4492935982947064e-16j))","assert polar_rect(4,7)==((8.06225774829855, 1.0516502125483738), (-2+2.4492935982947064e-16j))","assert polar_rect(15,17)==((22.67156809750927, 0.8478169733934057), (-2+2.4492935982947064e-16j))"],"test_imports":[]}} {"problem_id":"mbpp_validation_00591","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to interchange the first and last elements in a list.\n\nTests:\nassert swap_List([12, 35, 9, 56, 24]) == [24, 35, 9, 56, 12]\nassert swap_List([1, 2, 3]) == [3, 2, 1]\nassert swap_List([4, 5, 6]) == [6, 5, 4]","canonical_answer":"def swap_List(newList): \n size = len(newList) \n temp = newList[0] \n newList[0] = newList[size - 1] \n newList[size - 1] = temp \n return newList","verification_metadata":{"test_list":["assert swap_List([12, 35, 9, 56, 24]) == [24, 35, 9, 56, 12]","assert swap_List([1, 2, 3]) == [3, 2, 1]","assert swap_List([4, 5, 6]) == [6, 5, 4]"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":591,"text":"Write a python function to interchange the first and last elements in a list.","code":"def swap_List(newList): \n size = len(newList) \n temp = newList[0] \n newList[0] = newList[size - 1] \n newList[size - 1] = temp \n return newList","test_list":["assert swap_List([12, 35, 9, 56, 24]) == [24, 35, 9, 56, 12]","assert swap_List([1, 2, 3]) == [3, 2, 1]","assert swap_List([4, 5, 6]) == [6, 5, 4]"],"test_imports":[]}} {"problem_id":"mbpp_validation_00592","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the sum of the product of consecutive binomial co-efficients.\n\nTests:\nassert sum_Of_product(3) == 15\nassert sum_Of_product(4) == 56\nassert sum_Of_product(1) == 1","canonical_answer":"def binomial_Coeff(n,k): \n C = [0] * (k + 1); \n C[0] = 1; # nC0 is 1 \n for i in range(1,n + 1): \n for j in range(min(i, k),0,-1): \n C[j] = C[j] + C[j - 1]; \n return C[k]; \ndef sum_Of_product(n): \n return binomial_Coeff(2 * n,n - 1);","verification_metadata":{"test_list":["assert sum_Of_product(3) == 15","assert sum_Of_product(4) == 56","assert sum_Of_product(1) == 1"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":592,"text":"Write a python function to find the sum of the product of consecutive binomial co-efficients.","code":"def binomial_Coeff(n,k): \n C = [0] * (k + 1); \n C[0] = 1; # nC0 is 1 \n for i in range(1,n + 1): \n for j in range(min(i, k),0,-1): \n C[j] = C[j] + C[j - 1]; \n return C[k]; \ndef sum_Of_product(n): \n return binomial_Coeff(2 * n,n - 1);","test_list":["assert sum_Of_product(3) == 15","assert sum_Of_product(4) == 56","assert sum_Of_product(1) == 1"],"test_imports":[]}} {"problem_id":"mbpp_validation_00593","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to remove leading zeroes from an ip address.\n\nTests:\nassert removezero_ip(\"216.08.094.196\")==('216.8.94.196')\nassert removezero_ip(\"12.01.024\")==('12.1.24')\nassert removezero_ip(\"216.08.094.0196\")==('216.8.94.196')","canonical_answer":"import re\ndef removezero_ip(ip):\n string = re.sub('\\.[0]*', '.', ip)\n return string","verification_metadata":{"test_list":["assert removezero_ip(\"216.08.094.196\")==('216.8.94.196')","assert removezero_ip(\"12.01.024\")==('12.1.24')","assert removezero_ip(\"216.08.094.0196\")==('216.8.94.196')"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":593,"text":"Write a function to remove leading zeroes from an ip address.","code":"import re\ndef removezero_ip(ip):\n string = re.sub('\\.[0]*', '.', ip)\n return string","test_list":["assert removezero_ip(\"216.08.094.196\")==('216.8.94.196')","assert removezero_ip(\"12.01.024\")==('12.1.24')","assert removezero_ip(\"216.08.094.0196\")==('216.8.94.196')"],"test_imports":[]}} {"problem_id":"mbpp_validation_00594","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the difference of the first even and first odd number of a given list.\n\nTests:\nassert diff_even_odd([1,3,5,7,4,1,6,8])==3\nassert diff_even_odd([1,2,3,4,5,6,7,8,9,10])==1\nassert diff_even_odd([1,5,7,9,10])==9","canonical_answer":"def diff_even_odd(list1):\n first_even = next((el for el in list1 if el%2==0),-1)\n first_odd = next((el for el in list1 if el%2!=0),-1)\n return (first_even-first_odd)","verification_metadata":{"test_list":["assert diff_even_odd([1,3,5,7,4,1,6,8])==3","assert diff_even_odd([1,2,3,4,5,6,7,8,9,10])==1","assert diff_even_odd([1,5,7,9,10])==9"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":594,"text":"Write a function to find the difference of the first even and first odd number of a given list.","code":"def diff_even_odd(list1):\n first_even = next((el for el in list1 if el%2==0),-1)\n first_odd = next((el for el in list1 if el%2!=0),-1)\n return (first_even-first_odd)","test_list":["assert diff_even_odd([1,3,5,7,4,1,6,8])==3","assert diff_even_odd([1,2,3,4,5,6,7,8,9,10])==1","assert diff_even_odd([1,5,7,9,10])==9"],"test_imports":[]}} {"problem_id":"mbpp_validation_00595","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to count minimum number of swaps required to convert one binary number represented as a string to another.\n\nTests:\nassert min_Swaps(\"1101\",\"1110\") == 1\nassert min_Swaps(\"111\",\"000\") == \"Not Possible\"\nassert min_Swaps(\"111\",\"110\") == \"Not Possible\"","canonical_answer":"def min_Swaps(str1,str2) : \n count = 0\n for i in range(len(str1)) : \n if str1[i] != str2[i] : \n count += 1\n if count % 2 == 0 : \n return (count // 2) \n else : \n return (\"Not Possible\")","verification_metadata":{"test_list":["assert min_Swaps(\"1101\",\"1110\") == 1","assert min_Swaps(\"111\",\"000\") == \"Not Possible\"","assert min_Swaps(\"111\",\"110\") == \"Not Possible\""],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":595,"text":"Write a python function to count minimum number of swaps required to convert one binary number represented as a string to another.","code":"def min_Swaps(str1,str2) : \n count = 0\n for i in range(len(str1)) : \n if str1[i] != str2[i] : \n count += 1\n if count % 2 == 0 : \n return (count // 2) \n else : \n return (\"Not Possible\")","test_list":["assert min_Swaps(\"1101\",\"1110\") == 1","assert min_Swaps(\"111\",\"000\") == \"Not Possible\"","assert min_Swaps(\"111\",\"110\") == \"Not Possible\""],"test_imports":[]}} {"problem_id":"mbpp_validation_00596","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the size in bytes of the given tuple.\n\nTests:\nassert tuple_size((\"A\", 1, \"B\", 2, \"C\", 3) ) == sys.getsizeof((\"A\", 1, \"B\", 2, \"C\", 3))\nassert tuple_size((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\") ) == sys.getsizeof((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\"))\nassert tuple_size(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")) ) == sys.getsizeof(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")))","canonical_answer":"import sys \ndef tuple_size(tuple_list):\n return (sys.getsizeof(tuple_list))","verification_metadata":{"test_list":["assert tuple_size((\"A\", 1, \"B\", 2, \"C\", 3) ) == sys.getsizeof((\"A\", 1, \"B\", 2, \"C\", 3))","assert tuple_size((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\") ) == sys.getsizeof((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\"))","assert tuple_size(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")) ) == sys.getsizeof(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")))"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":596,"text":"Write a function to find the size in bytes of the given tuple.","code":"import sys \ndef tuple_size(tuple_list):\n return (sys.getsizeof(tuple_list))","test_list":["assert tuple_size((\"A\", 1, \"B\", 2, \"C\", 3) ) == sys.getsizeof((\"A\", 1, \"B\", 2, \"C\", 3))","assert tuple_size((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\") ) == sys.getsizeof((1, \"Raju\", 2, \"Nikhil\", 3, \"Deepanshu\"))","assert tuple_size(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")) ) == sys.getsizeof(((1, \"Lion\"), ( 2, \"Tiger\"), (3, \"Fox\"), (4, \"Wolf\")))"],"test_imports":[]}} {"problem_id":"mbpp_validation_00597","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find kth element from the given two sorted arrays.\n\nTests:\nassert find_kth([2, 3, 6, 7, 9], [1, 4, 8, 10], 5) == 6\nassert find_kth([100, 112, 256, 349, 770], [72, 86, 113, 119, 265, 445, 892], 7) == 256\nassert find_kth([3, 4, 7, 8, 10], [2, 5, 9, 11], 6) == 8","canonical_answer":"def find_kth(arr1, arr2, k):\n\tm = len(arr1)\n\tn = len(arr2)\n\tsorted1 = [0] * (m + n)\n\ti = 0\n\tj = 0\n\td = 0\n\twhile (i < m and j < n):\n\t\tif (arr1[i] < arr2[j]):\n\t\t\tsorted1[d] = arr1[i]\n\t\t\ti += 1\n\t\telse:\n\t\t\tsorted1[d] = arr2[j]\n\t\t\tj += 1\n\t\td += 1\n\twhile (i < m):\n\t\tsorted1[d] = arr1[i]\n\t\td += 1\n\t\ti += 1\n\twhile (j < n):\n\t\tsorted1[d] = arr2[j]\n\t\td += 1\n\t\tj += 1\n\treturn sorted1[k - 1]","verification_metadata":{"test_list":["assert find_kth([2, 3, 6, 7, 9], [1, 4, 8, 10], 5) == 6","assert find_kth([100, 112, 256, 349, 770], [72, 86, 113, 119, 265, 445, 892], 7) == 256","assert find_kth([3, 4, 7, 8, 10], [2, 5, 9, 11], 6) == 8"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":597,"text":"Write a function to find kth element from the given two sorted arrays.","code":"def find_kth(arr1, arr2, k):\n\tm = len(arr1)\n\tn = len(arr2)\n\tsorted1 = [0] * (m + n)\n\ti = 0\n\tj = 0\n\td = 0\n\twhile (i < m and j < n):\n\t\tif (arr1[i] < arr2[j]):\n\t\t\tsorted1[d] = arr1[i]\n\t\t\ti += 1\n\t\telse:\n\t\t\tsorted1[d] = arr2[j]\n\t\t\tj += 1\n\t\td += 1\n\twhile (i < m):\n\t\tsorted1[d] = arr1[i]\n\t\td += 1\n\t\ti += 1\n\twhile (j < n):\n\t\tsorted1[d] = arr2[j]\n\t\td += 1\n\t\tj += 1\n\treturn sorted1[k - 1]","test_list":["assert find_kth([2, 3, 6, 7, 9], [1, 4, 8, 10], 5) == 6","assert find_kth([100, 112, 256, 349, 770], [72, 86, 113, 119, 265, 445, 892], 7) == 256","assert find_kth([3, 4, 7, 8, 10], [2, 5, 9, 11], 6) == 8"],"test_imports":[]}} {"problem_id":"mbpp_validation_00598","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to check whether the given number is armstrong or not.\n\nTests:\nassert armstrong_number(153)==True\nassert armstrong_number(259)==False\nassert armstrong_number(4458)==False","canonical_answer":"def armstrong_number(number):\n sum = 0\n times = 0\n temp = number\n while temp > 0:\n times = times + 1\n temp = temp // 10\n temp = number\n while temp > 0:\n reminder = temp % 10\n sum = sum + (reminder ** times)\n temp //= 10\n if number == sum:\n return True\n else:\n return False","verification_metadata":{"test_list":["assert armstrong_number(153)==True","assert armstrong_number(259)==False","assert armstrong_number(4458)==False"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":598,"text":"Write a function to check whether the given number is armstrong or not.","code":"def armstrong_number(number):\n sum = 0\n times = 0\n temp = number\n while temp > 0:\n times = times + 1\n temp = temp // 10\n temp = number\n while temp > 0:\n reminder = temp % 10\n sum = sum + (reminder ** times)\n temp //= 10\n if number == sum:\n return True\n else:\n return False","test_list":["assert armstrong_number(153)==True","assert armstrong_number(259)==False","assert armstrong_number(4458)==False"],"test_imports":[]}} {"problem_id":"mbpp_validation_00599","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find sum and average of first n natural numbers.\n\nTests:\nassert sum_average(10)==(55, 5.5)\nassert sum_average(15)==(120, 8.0)\nassert sum_average(20)==(210, 10.5)","canonical_answer":"def sum_average(number):\n total = 0\n for value in range(1, number + 1):\n total = total + value\n average = total / number\n return (total,average)","verification_metadata":{"test_list":["assert sum_average(10)==(55, 5.5)","assert sum_average(15)==(120, 8.0)","assert sum_average(20)==(210, 10.5)"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":599,"text":"Write a function to find sum and average of first n natural numbers.","code":"def sum_average(number):\n total = 0\n for value in range(1, number + 1):\n total = total + value\n average = total / number\n return (total,average)","test_list":["assert sum_average(10)==(55, 5.5)","assert sum_average(15)==(120, 8.0)","assert sum_average(20)==(210, 10.5)"],"test_imports":[]}} {"problem_id":"mbpp_validation_00600","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether the given number is even or not.\n\nTests:\nassert is_Even(1) == False\nassert is_Even(2) == True\nassert is_Even(3) == False","canonical_answer":"def is_Even(n) : \n if (n^1 == n+1) :\n return True; \n else :\n return False;","verification_metadata":{"test_list":["assert is_Even(1) == False","assert is_Even(2) == True","assert is_Even(3) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"validation"},"raw_source_entry":{"task_id":600,"text":"Write a python function to check whether the given number is even or not.","code":"def is_Even(n) : \n if (n^1 == n+1) :\n return True; \n else :\n return False;","test_list":["assert is_Even(1) == False","assert is_Even(2) == True","assert is_Even(3) == False"],"test_imports":[]}} {"problem_id":"mbpp_prompt_00002","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the shared elements from the given two lists.\n\nTests:\nassert set(similar_elements((3, 4, 5, 6),(5, 7, 4, 10))) == set((4, 5))\nassert set(similar_elements((1, 2, 3, 4),(5, 4, 3, 7))) == set((3, 4))\nassert set(similar_elements((11, 12, 14, 13),(17, 15, 14, 13))) == set((13, 14))","canonical_answer":"def similar_elements(test_tup1, test_tup2):\n res = tuple(set(test_tup1) & set(test_tup2))\n return (res)","verification_metadata":{"test_list":["assert set(similar_elements((3, 4, 5, 6),(5, 7, 4, 10))) == set((4, 5))","assert set(similar_elements((1, 2, 3, 4),(5, 4, 3, 7))) == set((3, 4))","assert set(similar_elements((11, 12, 14, 13),(17, 15, 14, 13))) == set((13, 14))"],"test_imports":[],"verification_type":"execute_and_assert","split":"prompt"},"raw_source_entry":{"task_id":2,"text":"Write a function to find the shared elements from the given two lists.","code":"def similar_elements(test_tup1, test_tup2):\n res = tuple(set(test_tup1) & set(test_tup2))\n return (res)","test_list":["assert set(similar_elements((3, 4, 5, 6),(5, 7, 4, 10))) == set((4, 5))","assert set(similar_elements((1, 2, 3, 4),(5, 4, 3, 7))) == set((3, 4))","assert set(similar_elements((11, 12, 14, 13),(17, 15, 14, 13))) == set((13, 14))"],"test_imports":[]}} {"problem_id":"mbpp_prompt_00003","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to identify non-prime numbers.\n\nTests:\nassert is_not_prime(2) == False\nassert is_not_prime(10) == True\nassert is_not_prime(35) == True\nassert is_not_prime(37) == False","canonical_answer":"import math\ndef is_not_prime(n):\n result = False\n for i in range(2,int(math.sqrt(n)) + 1):\n if n % i == 0:\n result = True\n return result","verification_metadata":{"test_list":["assert is_not_prime(2) == False","assert is_not_prime(10) == True","assert is_not_prime(35) == True","assert is_not_prime(37) == False"],"test_imports":[],"verification_type":"execute_and_assert","split":"prompt"},"raw_source_entry":{"task_id":3,"text":"Write a python function to identify non-prime numbers.","code":"import math\ndef is_not_prime(n):\n result = False\n for i in range(2,int(math.sqrt(n)) + 1):\n if n % i == 0:\n result = True\n return result","test_list":["assert is_not_prime(2) == False","assert is_not_prime(10) == True","assert is_not_prime(35) == True","assert is_not_prime(37) == False"],"test_imports":[]}} {"problem_id":"mbpp_prompt_00004","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find the n largest integers from a given list of numbers, returned in descending order.\n\nTests:\nassert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],3)==[85, 75, 65]\nassert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],2)==[85, 75]\nassert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],5)==[85, 75, 65, 58, 35]","canonical_answer":"import heapq as hq\ndef heap_queue_largest(nums,n):\n largest_nums = hq.nlargest(n, nums)\n return largest_nums","verification_metadata":{"test_list":["assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],3)==[85, 75, 65]","assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],2)==[85, 75]","assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],5)==[85, 75, 65, 58, 35]"],"test_imports":[],"verification_type":"execute_and_assert","split":"prompt"},"raw_source_entry":{"task_id":4,"text":"Write a function to find the n largest integers from a given list of numbers, returned in descending order.","code":"import heapq as hq\ndef heap_queue_largest(nums,n):\n largest_nums = hq.nlargest(n, nums)\n return largest_nums","test_list":["assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],3)==[85, 75, 65]","assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],2)==[85, 75]","assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],5)==[85, 75, 65, 58, 35]"],"test_imports":[]}} {"problem_id":"mbpp_prompt_00006","domain":"code","difficulty":2,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to check whether the two numbers differ at one bit position only or not.\n\nTests:\nassert differ_At_One_Bit_Pos(13,9) == True\nassert differ_At_One_Bit_Pos(15,8) == False\nassert differ_At_One_Bit_Pos(2,4) == False\nassert differ_At_One_Bit_Pos(2, 3) == True\nassert differ_At_One_Bit_Pos(5, 1) == True\nassert differ_At_One_Bit_Pos(1, 5) == True","canonical_answer":"def is_Power_Of_Two (x): \n return x and (not(x & (x - 1))) \ndef differ_At_One_Bit_Pos(a,b): \n return is_Power_Of_Two(a ^ b)","verification_metadata":{"test_list":["assert differ_At_One_Bit_Pos(13,9) == True","assert differ_At_One_Bit_Pos(15,8) == False","assert differ_At_One_Bit_Pos(2,4) == False","assert differ_At_One_Bit_Pos(2, 3) == True","assert differ_At_One_Bit_Pos(5, 1) == True","assert differ_At_One_Bit_Pos(1, 5) == True"],"test_imports":[],"verification_type":"execute_and_assert","split":"prompt"},"raw_source_entry":{"task_id":6,"text":"Write a python function to check whether the two numbers differ at one bit position only or not.","code":"def is_Power_Of_Two (x): \n return x and (not(x & (x - 1))) \ndef differ_At_One_Bit_Pos(a,b): \n return is_Power_Of_Two(a ^ b)","test_list":["assert differ_At_One_Bit_Pos(13,9) == True","assert differ_At_One_Bit_Pos(15,8) == False","assert differ_At_One_Bit_Pos(2,4) == False","assert differ_At_One_Bit_Pos(2, 3) == True","assert differ_At_One_Bit_Pos(5, 1) == True","assert differ_At_One_Bit_Pos(1, 5) == True"],"test_imports":[]}} {"problem_id":"mbpp_prompt_00007","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find all words which are at least 4 characters long in a string.\n\nTests:\nassert set(find_char_long('Please move back to stream')) == set(['Please', 'move', 'back', 'stream'])\nassert set(find_char_long('Jing Eco and Tech')) == set(['Jing', 'Tech'])\nassert set(find_char_long('Jhingai wulu road Zone 3')) == set(['Jhingai', 'wulu', 'road', 'Zone'])","canonical_answer":"import re\ndef find_char_long(text):\n return (re.findall(r\"\\b\\w{4,}\\b\", text))","verification_metadata":{"test_list":["assert set(find_char_long('Please move back to stream')) == set(['Please', 'move', 'back', 'stream'])","assert set(find_char_long('Jing Eco and Tech')) == set(['Jing', 'Tech'])","assert set(find_char_long('Jhingai wulu road Zone 3')) == set(['Jhingai', 'wulu', 'road', 'Zone'])"],"test_imports":[],"verification_type":"execute_and_assert","split":"prompt"},"raw_source_entry":{"task_id":7,"text":"Write a function to find all words which are at least 4 characters long in a string.","code":"import re\ndef find_char_long(text):\n return (re.findall(r\"\\b\\w{4,}\\b\", text))","test_list":["assert set(find_char_long('Please move back to stream')) == set(['Please', 'move', 'back', 'stream'])","assert set(find_char_long('Jing Eco and Tech')) == set(['Jing', 'Tech'])","assert set(find_char_long('Jhingai wulu road Zone 3')) == set(['Jhingai', 'wulu', 'road', 'Zone'])"],"test_imports":[]}} {"problem_id":"mbpp_prompt_00008","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a function to find squares of individual elements in a list.\n\nTests:\nassert square_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\nassert square_nums([10,20,30])==([100,400,900])\nassert square_nums([12,15])==([144,225])","canonical_answer":"def square_nums(nums):\n square_nums = list(map(lambda x: x ** 2, nums))\n return square_nums","verification_metadata":{"test_list":["assert square_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]","assert square_nums([10,20,30])==([100,400,900])","assert square_nums([12,15])==([144,225])"],"test_imports":[],"verification_type":"execute_and_assert","split":"prompt"},"raw_source_entry":{"task_id":8,"text":"Write a function to find squares of individual elements in a list.","code":"def square_nums(nums):\n square_nums = list(map(lambda x: x ** 2, nums))\n return square_nums","test_list":["assert square_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]","assert square_nums([10,20,30])==([100,400,900])","assert square_nums([12,15])==([144,225])"],"test_imports":[]}} {"problem_id":"mbpp_prompt_00009","domain":"code","difficulty":1,"source":"mbpp","question":"Write a Python function that satisfies the following description. Return only the function definition(s); the function name and signature must match the tests below.\n\nDescription:\nWrite a python function to find the minimum number of rotations (greater than 0) required to get the same string.\n\nTests:\nassert find_Rotations(\"aaaa\") == 1\nassert find_Rotations(\"ab\") == 2\nassert find_Rotations(\"abc\") == 3","canonical_answer":"def find_Rotations(str): \n tmp = str + str\n n = len(str) \n for i in range(1,n + 1): \n substring = tmp[i: i+n] \n if (str == substring): \n return i \n return n","verification_metadata":{"test_list":["assert find_Rotations(\"aaaa\") == 1","assert find_Rotations(\"ab\") == 2","assert find_Rotations(\"abc\") == 3"],"test_imports":[],"verification_type":"execute_and_assert","split":"prompt"},"raw_source_entry":{"task_id":9,"text":"Write a python function to find the minimum number of rotations (greater than 0) required to get the same string.","code":"def find_Rotations(str): \n tmp = str + str\n n = len(str) \n for i in range(1,n + 1): \n substring = tmp[i: i+n] \n if (str == substring): \n return i \n return n","test_list":["assert find_Rotations(\"aaaa\") == 1","assert find_Rotations(\"ab\") == 2","assert find_Rotations(\"abc\") == 3"],"test_imports":[]}}