

--------------------------------------------------Mbpp/273--------------------------------------------------

<s> """
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.
assert substract_elements((10, 4, 5), (2, 5, 18)) == (8, -1, -13)
"""

def substract_elements(t1, t2):
    return tuple(i-j for i, j in zip(t1, t2))



--------------------------------------------------Mbpp/274--------------------------------------------------

<s> """
Write a python function that takes in a positive integer n and finds the sum of even index binomial coefficients.
assert even_binomial_Coeff_Sum(4) == 8
"""


def even_binomial_Coeff_Sum(n):
    """
    >>> even_binomial_Coeff_Sum(4)
    8
    >>> even_binomial_Coeff_Sum(5)
    18
    >>> even_binomial_Coeff_Sum(6)
    32
    >>> even_binomial_Coeff_Sum(7)
    56
    >>> even_binomial_Coeff_Sum(8)
    90
    >>> even_binomial_Coeff_Sum(9)
    132
    >>> even_binomial_Coeff_Sum(10)
    204
    >>> even_binomial_Coeff_Sum(11)
    308
    >>> even_binomial_Coeff_Sum(12)
    480
    >>> even_binomial_Coeff_Sum(13)
    728
    >>> even_binomial_Coeff_Sum(14)
    1080
    >>> even_binomial_Coeff_Sum(15)
    1620
    >>> even_binomial_Coeff_Sum(16)
    2304
    >>> even_binomial_Coeff_Sum(17)
    3188
    >>> even_binomial_Coeff_Sum(18)
    4780
    >>> even_binomial_Coeff_Sum(19)
    6760
    >>> even_binomial_Coeff_Sum(20)
    9240
    >>> even_binomial_Coeff_Sum(21)
    12700
    >>> even_binomial_Coeff_Sum(22)
    17280
    >>> even_binomial_Coeff_Sum(23)
    23040
    >>> even_binomial_Coeff_Sum(24)
    30240
    >>> even_binomial_Coeff_Sum(25)
    39600
    >>> even_binomial_Coeff_Sum(26)
    50400
    >>> even_binomial_Coeff_Sum(27)

--------------------------------------------------Mbpp/276--------------------------------------------------

<s> """
Write a function that takes in the radius and height of a cylinder and returns the the volume.
assert math.isclose(volume_cylinder(10,5), 1570.7500000000002, rel_tol=0.001)
"""



--------------------------------------------------Mbpp/277--------------------------------------------------

<s> """
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.
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}
"""

def dict_filter(d,n):
    return {k:v for k,v in d.items() if v>=n}



--------------------------------------------------Mbpp/278--------------------------------------------------

<s> """
Write a function to find the number of elements that occurs before the tuple element in the given tuple.
assert count_first_elements((1, 5, 7, (4, 6), 10) ) == 3
"""


def count_first_elements(tup):
    count = 0
    for i in range(len(tup)):
        if isinstance(tup[i], tuple):
            count += i
        else:
            count += 1
    return count




--------------------------------------------------Mbpp/279--------------------------------------------------

<s> """
Write a function to find the nth decagonal number.
assert is_num_decagonal(3) == 27
"""


def is_num_decagonal(n):
    """
    Check if a number is a decagonal number.
    """
    if n < 1:
        return False
    if n == 1:
        return True
    if n % 2 == 0:
        return is_num_decagonal(n // 2)
    else:
        return is_num_decagonal(n // 2 + 1)




--------------------------------------------------Mbpp/280--------------------------------------------------

<s> """
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).
assert sequential_search([11,23,58,31,56,77,43,12,65,19],31) == (True, 3)
"""

def sequential_search(arr, element):
    for i in range(len(arr)):
        if arr[i] == element:
            return True, i
    return False, -1



--------------------------------------------------Mbpp/281--------------------------------------------------

<s> """
Write a python function to check if the elements of a given list are unique or not.
assert all_unique([1,2,3]) == True
"""


def all_unique(lst):
    return len(lst) == len(set(lst))




--------------------------------------------------Mbpp/282--------------------------------------------------

<s> """
Write a function to subtract two lists element-wise.
assert sub_list([1, 2, 3],[4,5,6])==[-3,-3,-3]
"""

def sub_list(list1, list2):
    """
    Subtracts two lists element-wise.
    """
    if len(list1) != len(list2):
        raise ValueError("Lists must be of equal length.")
    else:
        return [a - b for a, b in zip(list1, list2)]




--------------------------------------------------Mbpp/283--------------------------------------------------

<s> """
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.
assert validate(1234) == True
"""


def validate(n):
    """
    :param n: integer
    :return: boolean
    """
    digits = [int(i) for i in str(n)]
    for digit in digits:
        if digit > digits.count(digit):
            return False
    return True




--------------------------------------------------Mbpp/284--------------------------------------------------

<s> """
Write a function that takes in a list and element and checks whether all items in the list are equal to the given element.
assert check_element(["green", "orange", "black", "white"],'blue')==False
"""


def check_element(list, element):
    for item in list:
        if item != element:
            return False
    return True




--------------------------------------------------Mbpp/285--------------------------------------------------

<s> """
Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.
assert text_match_two_three("ac")==(False)
"""


def text_match_two_three(text):
    if text.find('a') == -1:
        return False
    else:
        if text.find('bb') != -1:
            return True
        elif text.find('bbb') != -1:
            return True
        else:
            return False




--------------------------------------------------Mbpp/286--------------------------------------------------

<s> """
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.
assert max_sub_array_sum_repeated([10, 20, -30, -1], 4, 3) == 30
"""


def max_sub_array_sum_repeated(arr, k, n):
    """
    :param arr: array of integers
    :param k: number of times to repeat the array
    :param n: number of elements in the array
    :return: largest sum of a contiguous array in the modified array which is formed by repeating the given array k times
    """
    if k == 1:
        return max(arr)
    if k == 2:
        return max(arr) + max(arr)
    if k == 3:
        return max(arr) + max(arr) + max(arr)
    if k == 4:
        return max(arr) + max(arr) + max(arr) + max(arr)
    if k == 5:
        return max(arr) + max(arr) + max(arr) + max(arr) + max(arr)
    if k == 6:
        return max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr)
    if k == 7:
        return max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr)
    if k == 8:
        return max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr)
    if k == 9:
        return max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr)
    if k == 10:
        return max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr)
    if k == 11:
        return max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr)
    if k == 12:
        return max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr)
    if k == 13:
        return max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr) + max(arr

--------------------------------------------------Mbpp/287--------------------------------------------------

<s> """
Write a python function takes in an integer n and returns the sum of squares of first n even natural numbers.
assert square_Sum(2) == 20
"""


def square_Sum(n):
    """
    :param n: int
    :return: int
    """
    sum = 0
    for i in range(2, n + 1, 2):
        sum += i ** 2
    return sum




--------------------------------------------------Mbpp/290--------------------------------------------------

<s> """
Write a function to find the list of maximum length in a list of lists.
assert max_length([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==(3, [13, 15, 17])
"""


def max_length(list_of_lists):
    """
    :param list_of_lists: list of lists
    :return: tuple of max length and list of max length
    """
    max_length = 0
    max_length_list = []
    for i in list_of_lists:
        if len(i) > max_length:
            max_length = len(i)
            max_length_list = i
    return max_length, max_length_list




--------------------------------------------------Mbpp/292--------------------------------------------------

<s> """
Write a python function to find quotient of two numbers (rounded down to the nearest integer).
assert find(10,3) == 3
"""


def find(a, b):
    return int(a/b)




--------------------------------------------------Mbpp/293--------------------------------------------------

<s> """
Write a function to find the third side of a right angled triangle.
assert otherside_rightangle(7,8)==10.63014581273465
"""

def otherside_rightangle(a,b):
    """
    a,b: int or float
    returns: int or float, third side of a right angled triangle
    """
    return (a**2 + b**2)**0.5



--------------------------------------------------Mbpp/294--------------------------------------------------

<s> """
Write a function to find the maximum value in a given heterogeneous list.
assert max_val(['Python', 3, 2, 4, 5, 'version'])==5
"""


def max_val(lst):
    """
    :param lst: heterogeneous list
    :return: maximum value in the list
    """
    max_val = lst[0]
    for i in range(1, len(lst)):
        if lst[i] > max_val:
            max_val = lst[i]
    return max_val




--------------------------------------------------Mbpp/295--------------------------------------------------

<s> """
Write a function to return the sum of all divisors of a number.
assert sum_div(8)==7
"""


def sum_div(n):
    """
    :param n: int
    :return: int
    """
    sum_divisors = 0
    for i in range(1, n + 1):
        if n % i == 0:
            sum_divisors += i
    return sum_divisors




--------------------------------------------------Mbpp/296--------------------------------------------------

<s> """
Write a python function to count inversions in an array.
assert get_Inv_Count([1,20,6,4,5]) == 5
"""


def get_Inv_Count(arr):
    if len(arr) <= 1:
        return 0
    mid = len(arr) // 2
    left = arr[:mid]
    right = arr[mid:]
    left_inv = get_Inv_Count(left)
    right_inv = get_Inv_Count(right)
    merged_inv = merge_inv(left, right)
    return left_inv + right_inv + merged_inv




--------------------------------------------------Mbpp/297--------------------------------------------------

<s> """
Write a function to flatten a given nested list structure.
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]
"""


def flatten_list(nested_list):
    """
    :param nested_list: list
    :return: list
    """
    result = []
    for item in nested_list:
        if isinstance(item, list):
            result.extend(flatten_list(item))
        else:
            result.append(item)
    return result




--------------------------------------------------Mbpp/299--------------------------------------------------

<s> """
Write a function to calculate the maximum aggregate from the list of tuples.
assert max_aggregate([('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)])==('Juan Whelan', 212)
"""

def max_aggregate(tuples):
    max_aggregate = 0
    for name, score in tuples:
        aggregate = score + max_aggregate
        if aggregate > max_aggregate:
            max_aggregate = aggregate
            max_name = name
    return max_name, max_aggregate



--------------------------------------------------Mbpp/300--------------------------------------------------

<s> """
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.
assert math.isclose(count_binary_seq(1), 2.0, rel_tol=0.001)
"""



--------------------------------------------------Mbpp/301--------------------------------------------------

<s> """
Write a function to find the depth of a dictionary.
assert dict_depth({'a':1, 'b': {'c': {'d': {}}}})==4
"""


def dict_depth(d):
    if isinstance(d, dict):
        return 1 + max(map(dict_depth, d.values()))
    else:
        return 0




--------------------------------------------------Mbpp/305--------------------------------------------------

<s> """
Write a function to return two words from a list of words starting with letter 'p'.
assert start_withp(["Python PHP", "Java JavaScript", "c c++"])==('Python', 'PHP')
"""


def start_withp(words):
    """
    :param words: list of words
    :return: tuple of two words starting with letter 'p'
    """
    for word in words:
        if word[0] == 'p':
            return word.split()




--------------------------------------------------Mbpp/306--------------------------------------------------

<s> """
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 .
assert max_sum_increasing_subseq([1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6) == 11
"""


def max_sum_increasing_subseq(arr, i, k, n):
    if i == n:
        return 0
    if k == i:
        return arr[i]
    if i > k:
        return max(max_sum_increasing_subseq(arr, i + 1, k, n), arr[i] + max_sum_increasing_subseq(arr, i + 1, k, n))
    else:
        return max_sum_increasing_subseq(arr, i + 1, k, n)




--------------------------------------------------Mbpp/308--------------------------------------------------

<s> """
Write a function to find the specified number of largest products from two given lists, selecting one factor from each list.
assert large_product([1, 2, 3, 4, 5, 6],[3, 6, 8, 9, 10, 6],3)==[60, 54, 50]
"""

def large_product(list1, list2, n):
    """
    :param list1: list of numbers
    :param list2: list of numbers
    :param n: number of largest products to return
    :return: list of n largest products
    """
    if n > len(list1) or n > len(list2):
        raise ValueError("n must be less than or equal to the length of each list")
    if n < 1:
        raise ValueError("n must be greater than 0")
    if len(list1) == 0 or len(list2) == 0:
        raise ValueError("lists must not be empty")
    if len(list1) == 1 and len(list2) == 1:
        return [list1[0] * list2[0]]
    if len(list1) == 1:
        return [list1[0] * x for x in list2[:n]]
    if len(list2) == 1:
        return [list2[0] * x for x in list1[:n]]
    if len(list1) == 2 and len(list2) == 2:
        return [list1[0] * list2[0], list1[0] * list2[1], list1[1] * list2[0]]
    if len(list1) == 2 and len(list2) == 3:
        return [list1[0] * list2[0], list1[0] * list2[1], list1[0] * list2[2], list1[1] * list2[0], list1[1] * list2[1], list1[1] * list2[2]]
    if len(list1) == 3 and len(list2) == 2:
        return [list1[0] * list2[0], list1[0] * list2[1], list1[1] * list2[0], list1[1] * list2[1], list1[2] * list2[0], list1[2] * list2[1]]
    if len(list1) == 3 and len(list2) == 3:
        return [list1[0] * list2[0], list1[0] * list2[1], list1[0] * list2[2], list1[1] * list2[0], list1[1] * list2[1], list1[1] * list2[2], list1[2] * list2[0], list1[2] * list2[1], list1[2] * list2[2]]
    if len(list1) == 4 and len(list2) == 2:
        return [list1[0] * list2[0], list1[0] * list2[1],

--------------------------------------------------Mbpp/309--------------------------------------------------

<s> """
Write a python function to find the maximum of two numbers.
assert maximum(5,10) == 10
"""


def maximum(a, b):
    """
    Write a python function to find the maximum of two numbers.
    assert maximum(5,10) == 10
    """
    if a > b:
        return a
    else:
        return b




--------------------------------------------------Mbpp/310--------------------------------------------------

<s> """
Write a function to convert a given string to a tuple of characters.
assert string_to_tuple("python 3.0")==('p', 'y', 't', 'h', 'o', 'n', '3', '.', '0')
"""


def string_to_tuple(string):
    return tuple(string)




--------------------------------------------------Mbpp/311--------------------------------------------------

<s> """
Write a python function to set the left most unset bit.
assert set_left_most_unset_bit(10) == 14
"""


def set_left_most_unset_bit(n):
    """
    :param n: int
    :return: int
    """
    return n | (n + 1)




--------------------------------------------------Mbpp/312--------------------------------------------------

<s> """
Write a function to find the volume of a cone.
assert math.isclose(volume_cone(5,12), 314.15926535897927, rel_tol=0.001)
"""



--------------------------------------------------Mbpp/388--------------------------------------------------

<s> """
Write a python function to find the highest power of 2 that is less than or equal to n.
assert highest_Power_of_2(10) == 8
"""


def highest_Power_of_2(n):
    """
    :param n: int
    :return: int
    """
    if n <= 0:
        return 0
    if n == 1:
        return 1
    if n == 2:
        return 2
    if n == 3:
        return 2
    if n == 4:
        return 4
    if n == 5:
        return 4
    if n == 6:
        return 4
    if n == 7:
        return 4
    if n == 8:
        return 8
    if n == 9:
        return 8
    if n == 10:
        return 8
    if n == 11:
        return 8
    if n == 12:
        return 8
    if n == 13:
        return 8
    if n == 14:
        return 8
    if n == 15:
        return 8
    if n == 16:
        return 16
    if n == 17:
        return 16
    if n == 18:
        return 16
    if n == 19:
        return 16
    if n == 20:
        return 16
    if n == 21:
        return 16

--------------------------------------------------Mbpp/389--------------------------------------------------

<s> """
Write a function to find the n'th lucas number.
assert find_lucas(9) == 76
"""


def find_lucas(n):
    """
    Write a function to find the n'th lucas number.
    assert find_lucas(9) == 76
    """
    if n == 1:
        return 2
    elif n == 2:
        return 1
    else:
        return find_lucas(n - 1) + find_lucas(n - 2)




--------------------------------------------------Mbpp/390--------------------------------------------------

<s> """
Write a function to apply a given format string to all of the elements in a list.
assert add_string([1,2,3,4],'temp{0}')==['temp1', 'temp2', 'temp3', 'temp4']
"""


def add_string(list, format_string):
    return [format_string.format(i) for i in list]




--------------------------------------------------Mbpp/391--------------------------------------------------

<s> """
Write a function to convert more than one list to nested dictionary.
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}}]
"""

def convert_list_dictionary(list1, list2, list3):
    """
    Convert more than one list to nested dictionary.
    """
    return [dict(zip(list1, [dict(zip(list2, [list3[i]])) for i in range(len(list1))]))]




--------------------------------------------------Mbpp/392--------------------------------------------------

<s> """
Write 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).
assert get_max_sum(60) == 106
"""


def get_max_sum(n):
    """
    :param n: int
    :return: int
    """
    if n <= 0:
        return 0
    if n == 1:
        return 1
    if n % 2 == 0:
        return max(get_max_sum(n / 2) + get_max_sum(n / 3) + get_max_sum(n / 4) + get_max_sum(n / 5), n)
    else:
        return max(get_max_sum(n / 2) + get_max_sum(n / 3) + get_max_sum(n / 4) + get_max_sum(n / 5) + n, n)




--------------------------------------------------Mbpp/394--------------------------------------------------

<s> """
Write a function to check if given tuple contains no duplicates.
assert check_distinct((1, 4, 5, 6, 1, 4)) == False
"""


def check_distinct(tup):
    """
    Check if given tuple contains no duplicates.
    :param tup: tuple
    :return: bool
    """
    return len(tup) == len(set(tup))




--------------------------------------------------Mbpp/395--------------------------------------------------

<s> """
Write a python function to find the first non-repeated character in a given string.
assert first_non_repeating_character("abcabc") == None
"""


def first_non_repeating_character(string):
    """
    :param string: string
    :return: first non-repeated character
    """
    if not string:
        return None

    char_count = {}
    for char in string:
        if char in char_count:
            char_count[char] += 1
        else:
            char_count[char] = 1

    for char in string:
        if char_count[char] == 1:
            return char

    return None




--------------------------------------------------Mbpp/396--------------------------------------------------

<s> """
Write a function to check whether the given string starts and ends with the same character or not.
assert check_char("abba") == "Valid"
"""


def check_char(string):
    if string[0] == string[-1]:
        return "Valid"
    else:
        return "Invalid"




--------------------------------------------------Mbpp/397--------------------------------------------------

<s> """
Write a function to find the median of three numbers.
assert median_numbers(25,55,65)==55.0
"""


def median_numbers(num1, num2, num3):
    """
    Write a function to find the median of three numbers.
    assert median_numbers(25,55,65)==55.0
    """
    if num1 > num2:
        num1, num2 = num2, num1
    if num2 > num3:
        num2, num3 = num3, num2
    if num1 > num2:
        num1, num2 = num2, num1
    if num2 == num3:
        return (num1 + num2) / 2
    if num1 == num2:
        return num3
    if num1 == num3:
        return num2
    if num2 == num3:
        return num1
    if num1 < num2 < num3:
        return num2
    if num1 < num3 < num2:
        return num3
    if num2 < num1 < num3:
        return num1
    if num2 < num3 < num1:
        return num3
    if num3 < num1 < num2:
        return num1
    if num3 < num2 < num1:
        return num2




--------------------------------------------------Mbpp/398--------------------------------------------------

<s> """
Write a function to compute the sum of digits of each number of a given list.
assert sum_of_digits([10,2,56])==14
"""


def sum_of_digits(numbers):
    """
    :param numbers: list of numbers
    :return: sum of digits of each number
    """
    return sum(sum(map(int, str(number))) for number in numbers)




--------------------------------------------------Mbpp/400--------------------------------------------------

<s> """
Write a function to extract the number of unique tuples in the given list.
assert extract_freq([(3, 4), (1, 2), (4, 3), (5, 6)] ) == 3
"""


def extract_freq(tuples):
    """
    :param tuples: list of tuples
    :return: number of unique tuples
    """
    return len(set(tuples))




--------------------------------------------------Mbpp/404--------------------------------------------------

<s> """
Write a python function to find the minimum of two numbers.
assert minimum(1,2) == 1
"""


def minimum(a, b):
    """
    Write a python function to find the minimum of two numbers.
    assert minimum(1,2) == 1
    """
    if a < b:
        return a
    else:
        return b




--------------------------------------------------Mbpp/405--------------------------------------------------

<s> """
Write a function to check whether an element exists within a tuple.
assert check_tuplex(("w", 3, "r", "e", "s", "o", "u", "r", "c", "e"),'r')==True
"""


def check_tuplex(tup, element):
    """
    :param tup: tuple
    :param element: element to check
    :return: True if element exists in tuple, False otherwise
    """
    return element in tup




--------------------------------------------------Mbpp/406--------------------------------------------------

<s> """
Write a python function to find whether the parity of a given number is odd.
assert find_Parity(12) == False
"""


def find_parity(num):
    """
    :param num: int
    :return: bool
    """
    if num % 2 == 0:
        return True
    else:
        return False




--------------------------------------------------Mbpp/407--------------------------------------------------

<s> """
Write a function to create the next bigger number by rearranging the digits of a given number.
assert rearrange_bigger(12)==21
"""


def rearrange_bigger(number):
    """
    :param number: int
    :return: int
    """
    number = str(number)
    number_list = list(number)
    number_list.sort(reverse=True)
    number_list = ''.join(number_list)
    return int(number_list)




--------------------------------------------------Mbpp/409--------------------------------------------------

<s> """
Write a function to find the minimum product from the pairs of tuples within a given list.
assert min_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==8
"""


def min_product_tuple(tuples):
    """
    :param tuples: list of tuples
    :return: minimum product from the pairs of tuples within a given list
    """
    if not tuples:
        return 0
    tuples.sort(key=lambda x: x[0])
    min_product = tuples[0][0] * tuples[0][1]
    for i in range(1, len(tuples)):
        if tuples[i][0] * tuples[i][1] < min_product:
            min_product = tuples[i][0] * tuples[i][1]
    return min_product




--------------------------------------------------Mbpp/410--------------------------------------------------

<s> """
Write a function to find the minimum value in a given heterogeneous list.
assert min_val(['Python', 3, 2, 4, 5, 'version'])==2
"""


def min_val(lst):
    """
    :param lst: heterogeneous list
    :return: minimum value in the list
    """
    min_val = lst[0]
    for i in range(1, len(lst)):
        if lst[i] < min_val:
            min_val = lst[i]
    return min_val




--------------------------------------------------Mbpp/412--------------------------------------------------

<s> """
Write a python function to remove odd numbers from a given list.
assert remove_odd([1,2,3]) == [2]
"""


def remove_odd(nums):
    return [num for num in nums if num % 2 == 0]




--------------------------------------------------Mbpp/413--------------------------------------------------

<s> """
Write a function to extract the nth element from a given list of tuples.
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']
"""

def extract_nth_element(tuples, n):
    return [t[n] for t in tuples]



--------------------------------------------------Mbpp/414--------------------------------------------------

<s> """
Write a python function to check whether any value in a sequence exists in a sequence or not.
assert overlapping([1,2,3,4,5],[6,7,8,9]) == False
"""

def overlapping(seq1, seq2):
    for i in seq1:
        if i in seq2:
            return True
    return False



--------------------------------------------------Mbpp/415--------------------------------------------------

<s> """
Write a python function to find a pair with highest product from a given array of integers.
assert max_Product([1,2,3,4,7,0,8,4]) == (7,8)
"""


def max_Product(arr):
    arr.sort()
    return arr[-2], arr[-1]




--------------------------------------------------Mbpp/418--------------------------------------------------

<s> """
Write a python function to find the element of a list having maximum length.
assert Find_Max([['A'],['A','B'],['A','B','C']]) == ['A','B','C']
"""


def Find_Max(list1):
    max_len = 0
    max_len_list = []
    for i in list1:
        if len(i) > max_len:
            max_len = len(i)
            max_len_list = i
    return max_len_list




--------------------------------------------------Mbpp/419--------------------------------------------------

<s> """
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.
assert round_and_sum([22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50])==243
"""


def round_and_sum(numbers):
    total = 0
    for number in numbers:
        total += round(number)
    return total * len(numbers)




--------------------------------------------------Mbpp/420--------------------------------------------------

<s> """
Write a python function to find the cube sum of first n even natural numbers.
assert cube_Sum(2) == 72
"""


def cube_Sum(n):
    """
    >>> cube_Sum(2)
    72
    >>> cube_Sum(3)
    1728
    >>> cube_Sum(4)
    3125
    >>> cube_Sum(5)
    51125
    >>> cube_Sum(6)
    712500
    >>> cube_Sum(7)
    914125
    >>> cube_Sum(8)
    1116775
    >>> cube_Sum(9)
    1319375
    >>> cube_Sum(10)
    1521925
    >>> cube_Sum(11)
    1724475
    >>> cube_Sum(12)
    1926925
    >>> cube_Sum(13)
    2129475
    >>> cube_Sum(14)
    2331925
    >>> cube_Sum(15)
    2534475
    >>> cube_Sum(16)
    2736925
    >>> cube_Sum(17)
    2939475
    >>> cube_Sum(18)
    3141925
    >>> cube_Sum(19)
    3344475
    >>> cube_Sum(20)
    3546925
    >>> cube_Sum(21)
    3749475
    >>> cube_Sum(22)
    3951925
    >>> cube_Sum(23)
    4154475
    >>> cube_Sum(24)
    4356925
    >>> cube_Sum(25)

--------------------------------------------------Mbpp/421--------------------------------------------------

<s> """
Write a function to concatenate each element of tuple by the delimiter.
assert concatenate_tuple(("ID", "is", 4, "UTS") ) == 'ID-is-4-UTS'
"""


def concatenate_tuple(tuple_data):
    return '-'.join(str(x) for x in tuple_data)




--------------------------------------------------Mbpp/422--------------------------------------------------

<s> """
Write a python function to find the average of cubes of first n natural numbers.
assert find_Average_Of_Cube(2) == 4.5
"""


def find_Average_Of_Cube(n):
    sum = 0
    for i in range(1, n + 1):
        sum += i ** 3
    return sum / n




--------------------------------------------------Mbpp/424--------------------------------------------------

<s> """
Write a function to extract only the rear index element of each string in the given tuple.
assert extract_rear(('Mers', 'for', 'Vers') ) == ['s', 'r', 's']
"""

def extract_rear(tup):
    return [s[-1] for s in tup]



--------------------------------------------------Mbpp/425--------------------------------------------------

<s> """
Write a function to count the number of sublists containing a particular element.
assert count_element_in_list([[1, 3], [5, 7], [1, 11], [1, 15, 7]],1)==3
"""


def count_element_in_list(lst, element):
    """
    :param lst: list of lists
    :param element: element to count
    :return: number of sublists containing element
    """
    count = 0
    for sublist in lst:
        if element in sublist:
            count += 1
    return count




--------------------------------------------------Mbpp/426--------------------------------------------------

<s> """
Write a function to filter odd numbers.
assert filter_oddnumbers([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]
"""


def filter_oddnumbers(numbers):
    return [x for x in numbers if x % 2 == 0]




--------------------------------------------------Mbpp/427--------------------------------------------------

<s> """
Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.
assert change_date_format("2026-01-02") == '02-01-2026'
"""


def change_date_format(date):
    """
    Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.
    assert change_date_format("2026-01-02") == '02-01-2026'
    """
    return "-".join(reversed(date.split("-")))




--------------------------------------------------Mbpp/428--------------------------------------------------

<s> """
Write a function to sort the given array by using shell sort.
assert shell_sort([12, 23, 4, 5, 3, 2, 12, 81, 56, 95]) == [2, 3, 4, 5, 12, 12, 23, 56, 81, 95]
"""


def shell_sort(arr):
    """
    Sort the given array by using shell sort.
    :param arr: the given array
    :return: the sorted array
    """
    # 1. Find the gap
    gap = len(arr) // 2
    while gap > 0:
        # 2. Sort the array by using insertion sort
        for i in range(gap, len(arr)):
            temp = arr[i]
            j = i - gap
            while j >= 0 and arr[j] > temp:
                arr[j + gap] = arr[j]
                j -= gap
            arr[j + gap] = temp
        # 3. Reduce the gap
        gap = gap // 2
    return arr




--------------------------------------------------Mbpp/429--------------------------------------------------

<s> """
Write a function to extract the elementwise and tuples from the given two tuples.
assert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)
"""


def and_tuples(t1, t2):
    """
    Write a function to extract the elementwise and tuples from the given two tuples.
    assert and_tuples((10, 4, 6, 9), (5, 2, 3, 3)) == (0, 0, 2, 1)
    """
    return tuple(t1[i] & t2[i] for i in range(len(t1)))




--------------------------------------------------Mbpp/430--------------------------------------------------

<s> """
Write a function to find the directrix of a parabola.
assert parabola_directrix(5,3,2)==-198
"""


def parabola_directrix(a, b, c):
    """
    Write a function to find the directrix of a parabola.
    assert parabola_directrix(5,3,2)==-198
    """
    return -b/(2*a)




--------------------------------------------------Mbpp/431--------------------------------------------------

<s> """
Write a function that takes two lists and returns true if they have at least one common element.
assert common_element([1,2,3,4,5], [5,6,7,8,9])==True
"""


def common_element(list1, list2):
    """
    :param list1: list
    :param list2: list
    :return: bool
    """
    for i in list1:
        if i in list2:
            return True
    return False




--------------------------------------------------Mbpp/432--------------------------------------------------

<s> """
Write a function to find the median length of a trapezium.
assert median_trapezium(15,25,35)==20
"""


def median_trapezium(a, b, c):
    """
    Write a function to find the median length of a trapezium.
    assert median_trapezium(15,25,35)==20
    """
    if a > b:
        a, b = b, a
    if a > c:
        a, c = c, a
    if b > c:
        b, c = c, b
    if a == b:
        return a
    if a == c:
        return a
    if b == c:
        return b
    if a + b == c:
        return a
    if a + c == b:
        return a
    if b + c == a:
        return b
    return (a + b + c) / 3




--------------------------------------------------Mbpp/433--------------------------------------------------

<s> """
Write a function to check whether the entered number is greater than the elements of the given array.
assert check_greater([1, 2, 3, 4, 5], 4) == False
"""


def check_greater(arr, num):
    for i in arr:
        if num > i:
            return False
    return True




--------------------------------------------------Mbpp/435--------------------------------------------------

<s> """
Write a python function to find the last digit of a given number.
assert last_Digit(123) == 3
"""


def last_digit(num):
    """
    :param num: int
    :return: int
    """
    return num % 10




--------------------------------------------------Mbpp/436--------------------------------------------------

<s> """
Write a python function to return the negative numbers in a list.
assert neg_nos([-1,4,5,-6]) == [-1,-6]
"""


def neg_nos(nums):
    return [x for x in nums if x < 0]




--------------------------------------------------Mbpp/437--------------------------------------------------

<s> """
Write a function to remove odd characters in a string.
assert remove_odd("python")==("yhn")
"""


def remove_odd(string):
    """
    :param string: string
    :return: string without odd characters
    """
    return ''.join([char for char in string if char.isalpha() and not char.isdigit()])




--------------------------------------------------Mbpp/438--------------------------------------------------

<s> """
Write a function to count bidirectional tuple pairs.
assert count_bidirectional([(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ) == 3
"""


def count_bidirectional(tuples):
    """
    :param tuples: list of tuples
    :return: number of bidirectional tuple pairs
    """
    count = 0
    for i in range(len(tuples)):
        for j in range(i + 1, len(tuples)):
            if tuples[i][0] == tuples[j][1] and tuples[i][1] == tuples[j][0]:
                count += 1
    return count




--------------------------------------------------Mbpp/439--------------------------------------------------

<s> """
Write a function to join a list of multiple integers into a single integer.
assert multiple_to_single([11, 33, 50])==113350
"""


def multiple_to_single(lst):
    """
    Write a function to join a list of multiple integers into a single integer.
    assert multiple_to_single([11, 33, 50])==113350
    """
    return int(''.join(map(str, lst)))




--------------------------------------------------Mbpp/440--------------------------------------------------

<s> """
Write a function to find the first adverb and their positions in a given sentence.
assert find_adverb_position("clearly!! we can see the sky")==(0, 7, 'clearly')
"""


def find_adverb_position(sentence):
    """
    :param sentence: str
    :return: tuple
    """
    adverbs = ['clearly', 'simply', 'quickly', 'easily', 'easily', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly', 'quickly',
               'quickly', 'quickly

--------------------------------------------------Mbpp/441--------------------------------------------------

<s> """
Write a function to find the surface area of a cube of a given size.
assert surfacearea_cube(5)==150
"""


def surfacearea_cube(size):
    """
    :param size: int
    :return: int
    """
    return 6 * size ** 2




--------------------------------------------------Mbpp/442--------------------------------------------------

<s> """
Write a function to find the ration of positive numbers in an array of integers.
assert positive_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8])==0.54
"""


def positive_count(arr):
    count = 0
    for i in arr:
        if i > 0:
            count += 1
    return count / len(arr)




--------------------------------------------------Mbpp/445--------------------------------------------------

<s> """
Write a function to perform index wise multiplication of tuple elements in the given two tuples.
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))
"""


def index_multiplication(tuple1, tuple2):
    """
    :param tuple1: tuple
    :param tuple2: tuple
    :return: tuple
    """
    if len(tuple1) != len(tuple2):
        raise ValueError("Tuples must be of same length")
    return tuple(map(lambda x, y: x * y, tuple1, tuple2))




--------------------------------------------------Mbpp/446--------------------------------------------------

<s> """
Write a python function to count the occurence of all elements of list in a tuple.
assert count_Occurrence(('a', 'a', 'c', 'b', 'd'),['a', 'b'] ) == 3
"""


def count_Occurrence(tuple_list, list_list):
    """
    :param tuple_list: tuple
    :param list_list: list
    :return: int
    """
    count = 0
    for i in list_list:
        count += tuple_list.count(i)
    return count




--------------------------------------------------Mbpp/447--------------------------------------------------

<s> """
Write a function to find cubes of individual elements in a list.
assert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
"""


def cube_nums(nums):
    """
    Write a function to find cubes of individual elements in a list.
    assert cube_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]
    """
    return [num ** 3 for num in nums]




--------------------------------------------------Mbpp/448--------------------------------------------------

<s> """
Write a function to calculate the sum of perrin numbers.
assert cal_sum(9) == 49
"""


def cal_sum(n):
    """
    :param n: the number of perrin numbers
    :return: the sum of perrin numbers
    """
    if n == 0:
        return 0
    if n == 1:
        return 1
    return cal_sum(n - 1) + 4 * (n - 1) * (n - 2)




--------------------------------------------------Mbpp/450--------------------------------------------------

<s> """
Write a function to extract specified size of strings from a given list of string values.
assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution']
"""


def extract_string(string_list, size):
    """
    :param string_list: list of string values
    :param size: size of string to be extracted
    :return: list of string values
    """
    return [string_list[i:i + size] for i in range(len(string_list) - size + 1)]




--------------------------------------------------Mbpp/451--------------------------------------------------

<s> """
Write a function to remove all whitespaces from the given string.
assert remove_whitespaces(' Google    Flutter ') == 'GoogleFlutter'
"""


def remove_whitespaces(string):
    """
    Write a function to remove all whitespaces from the given string.
    assert remove_whitespaces(' Google    Flutter ') == 'GoogleFlutter'
    """
    return ''.join(string.split())




--------------------------------------------------Mbpp/453--------------------------------------------------

<s> """
Write a python function to find the sum of even factors of a number.
assert sumofFactors(18) == 26
"""


def sumofFactors(n):
    """
    :param n: int
    :return: int
    """
    sum_of_even_factors = 0
    for i in range(1, n + 1):
        if n % i == 0:
            if i % 2 == 0:
                sum_of_even_factors += i
    return sum_of_even_factors




--------------------------------------------------Mbpp/454--------------------------------------------------

<s> """
Write a function that matches a word containing 'z'.
assert text_match_wordz("pythonz.")==True
"""

def text_match_wordz(text):
    return "z" in text




--------------------------------------------------Mbpp/455--------------------------------------------------

<s> """
Write a function to check whether the given month number contains 31 days or not.
assert check_monthnumb_number(5)==True
"""


def check_monthnumb_number(month_number):
    if month_number == 1 or month_number == 3 or month_number == 5 or month_number == 7 or month_number == 8 or month_number == 10 or month_number == 12:
        return True
    elif month_number == 4 or month_number == 6 or month_number == 9 or month_number == 11:
        return False
    else:
        return False




--------------------------------------------------Mbpp/456--------------------------------------------------

<s> """
Write a function to reverse each string in a given list of string values.
assert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB']
"""


def reverse_string_list(string_list):
    return [string[::-1] for string in string_list]




--------------------------------------------------Mbpp/457--------------------------------------------------

<s> """
Write a python function to find the sublist having minimum length.
assert Find_Min([[1],[1,2],[1,2,3]]) == [1]
"""


def Find_Min(L):
    min_len = len(L[0])
    min_sublist = L[0]
    for sublist in L:
        if len(sublist) < min_len:
            min_len = len(sublist)
            min_sublist = sublist
    return min_sublist




--------------------------------------------------Mbpp/458--------------------------------------------------

<s> """
Write a function to find the area of a rectangle.
assert rectangle_area(10,20)==200
"""


def rectangle_area(length, width):
    """
    :param length: length of the rectangle
    :param width: width of the rectangle
    :return: area of the rectangle
    """
    return length * width




--------------------------------------------------Mbpp/459--------------------------------------------------

<s> """
Write a function to remove uppercase substrings from a given string.
assert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos'
"""


def remove_uppercase(string):
    """
    :param string: string to remove uppercase substrings from
    :return: string without uppercase substrings
    """
    result = ''
    for i in range(len(string)):
        if string[i].islower():
            result += string[i]
    return result




--------------------------------------------------Mbpp/460--------------------------------------------------

<s> """
Write a python function to get the first element of each sublist.
assert Extract([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 6]
"""


def Extract(L):
    return [i[0] for i in L]




--------------------------------------------------Mbpp/461--------------------------------------------------

<s> """
Write a python function to count the upper case characters in a given string.
assert upper_ctr('PYthon') == 1
"""


def upper_ctr(string):
    """
    Write a python function to count the upper case characters in a given string.
    assert upper_ctr('PYthon') == 1
    """
    return sum(1 for c in string if c.isupper())




--------------------------------------------------Mbpp/462--------------------------------------------------

<s> """
Write a function to find all possible combinations of the elements of a given 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']]
"""


def combinations_list(list_):
    """
    Write a function to find all possible combinations of the elements of a given 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']]
    """
    if not list_:
        return [[]]
    else:
        return [x + [list_[0]] for x in combinations_list(list_[1:])] + combinations_list(list_[1:])




--------------------------------------------------Mbpp/463--------------------------------------------------

<s> """
Write a function to find the maximum product subarray of the given array.
assert max_subarray_product([1, -2, -3, 0, 7, -8, -2]) == 112
"""


def max_subarray_product(arr):
    """
    :type arr: List[int]
    :rtype: int
    """
    max_so_far = max_ending_here = arr[0]
    for i in range(1, len(arr)):
        max_ending_here = max(arr[i], max_ending_here * arr[i])
        max_so_far = max(max_so_far, max_ending_here)
    return max_so_far




--------------------------------------------------Mbpp/465--------------------------------------------------

<s> """
Write a function to drop empty items from a given dictionary.
assert drop_empty({'c1': 'Red', 'c2': 'Green', 'c3':None})=={'c1': 'Red', 'c2': 'Green'}
"""


def drop_empty(d):
    return {k: v for k, v in d.items() if v is not None}




--------------------------------------------------Mbpp/468--------------------------------------------------

<s> """
Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.
assert max_product([3, 100, 4, 5, 150, 6]) == 3000
"""


def max_product(arr):
    if len(arr) == 0:
        return 0
    if len(arr) == 1:
        return arr[0]
    if len(arr) == 2:
        return max(arr[0], arr[1])

    max_product = arr[0]
    min_product = arr[0]
    for i in range(1, len(arr)):
        if arr[i] > max_product:
            max_product = arr[i]
        elif arr[i] < min_product:
            min_product = arr[i]
        else:
            max_product = max(max_product * arr[i], arr[i])
            min_product = min(min_product * arr[i], arr[i])
    return max_product




--------------------------------------------------Mbpp/470--------------------------------------------------

<s> """
Write a function to find the pairwise addition of the neighboring elements of the given tuple.
assert add_pairwise((1, 5, 7, 8, 10)) == (6, 12, 15, 18)
"""


def add_pairwise(tup):
    """
    >>> add_pairwise((1, 5, 7, 8, 10))
    (6, 12, 15, 18)
    """
    return tuple(a + b for a, b in zip(tup, tup[1:]))




--------------------------------------------------Mbpp/471--------------------------------------------------

<s> """
Write a python function to find the product of the array multiplication modulo n.
assert find_remainder([ 100, 10, 5, 25, 35, 14 ],11) ==9
"""


def find_remainder(arr, n):
    product = 1
    for i in arr:
        product = (product * i) % n
    return product




--------------------------------------------------Mbpp/472--------------------------------------------------

<s> """
Write a python function to check whether the given list contains consecutive numbers or not.
assert check_Consecutive([1,2,3,4,5]) == True
"""


def check_Consecutive(arr):
    for i in range(len(arr)-1):
        if arr[i+1]-arr[i] != 1:
            return False
    return True




--------------------------------------------------Mbpp/473--------------------------------------------------

<s> """
Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.
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)}
"""


def tuple_intersection(tuples, tuples2):
    """
    :param tuples: tuple list
    :param tuples2: tuple list
    :return: tuple intersection irrespective of their order
    """
    intersection = set()
    for tuple1 in tuples:
        for tuple2 in tuples2:
            if tuple1 == tuple2:
                intersection.add(tuple1)
    return intersection




--------------------------------------------------Mbpp/474--------------------------------------------------

<s> """
Write a function to replace characters in a string.
assert replace_char("polygon",'y','l')==("pollgon")
"""


def replace_char(string, old_char, new_char):
    """
    Replace characters in a string.
    assert replace_char("polygon",'y','l')==("pollgon")
    """
    return string.replace(old_char, new_char)




--------------------------------------------------Mbpp/475--------------------------------------------------

<s> """
Write a function to sort a dictionary by value.
assert sort_counter({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)]
"""


def sort_counter(counter):
    return sorted(counter.items(), key=lambda x: x[1], reverse=True)




--------------------------------------------------Mbpp/476--------------------------------------------------

<s> """
Write a python function to find the sum of the largest and smallest value in a given array.
assert big_sum([1,2,3]) == 4
"""


def big_sum(array):
    return max(array) + min(array)




--------------------------------------------------Mbpp/477--------------------------------------------------

<s> """
Write a python function to convert the given string to lower case.
assert is_lower("InValid") == "invalid"
"""


def is_lower(string):
    return string.lower()




--------------------------------------------------Mbpp/478--------------------------------------------------

<s> """
Write a function to remove lowercase substrings from a given string.
assert remove_lowercase("PYTHon")==('PYTH')
"""


def remove_lowercase(string):
    """
    :param string: string to remove substrings from
    :return: string without lowercase substrings
    """
    result = ""
    for i in range(len(string)):
        if i == 0:
            result += string[i]
        elif string[i].isupper():
            result += string[i]
        elif string[i].islower():
            if string[i - 1].isupper():
                result += string[i]
        else:
            result += string[i]
    return result




--------------------------------------------------Mbpp/479--------------------------------------------------

<s> """
Write a python function to find the first digit of a given number.
assert first_Digit(123) == 1
"""


def first_digit(num):
    return int(str(num)[0])




--------------------------------------------------Mbpp/554--------------------------------------------------

<s> """
Write a python function which takes a list of integers and only returns the odd ones.
assert Split([1,2,3,4,5,6]) == [1,3,5]
"""

def Split(list):
    odd = []
    for i in list:
        if i % 2 != 0:
            odd.append(i)
    return odd



--------------------------------------------------Mbpp/555--------------------------------------------------

<s> """
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.
assert difference(3) == 30
"""


def difference(n):
    """
    >>> difference(3)
    30
    """
    return sum([i**3 for i in range(1, n+1)]) - sum(range(1, n+1))




--------------------------------------------------Mbpp/556--------------------------------------------------

<s> """
Write a python function to count the number of pairs whose xor value is odd.
assert find_Odd_Pair([5,4,7,2,1],5) == 6
"""


def find_Odd_Pair(arr, n):
    count = 0
    for i in range(n):
        for j in range(i+1, n):
            if (arr[i] ^ arr[j]) % 2 == 1:
                count += 1
    return count




--------------------------------------------------Mbpp/557--------------------------------------------------

<s> """
Write a function to toggle the case of all characters in a string.
assert toggle_string("Python")==("pYTHON")
"""


def toggle_string(string):
    """
    :param string: string to toggle case
    :return: string with toggled case
    """
    return string.swapcase()




--------------------------------------------------Mbpp/558--------------------------------------------------

<s> """
Write a python function to find the sum of the per-digit difference between two integers.
assert digit_distance_nums(1,2) == 1
"""


def digit_distance_nums(num1, num2):
    """
    :param num1: int
    :param num2: int
    :return: int
    """
    num1_list = list(str(num1))
    num2_list = list(str(num2))
    if len(num1_list) != len(num2_list):
        return 0
    else:
        return sum([abs(int(num1_list[i]) - int(num2_list[i])) for i in range(len(num1_list))])




--------------------------------------------------Mbpp/559--------------------------------------------------

<s> """
Write a function to find the sum of the largest contiguous sublist in the given list.
assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3], 8) == 7
"""


def max_sub_array_sum(arr, k):
    """
    :param arr: list of integers
    :param k: integer
    :return: sum of the largest contiguous sublist in the given list
    """
    if len(arr) < k:
        return 0
    max_sum = 0
    sum_ = 0
    for i in range(len(arr)):
        sum_ += arr[i]
        if i >= k - 1:
            max_sum = max(max_sum, sum_)
            sum_ -= arr[i - k + 1]
    return max_sum




--------------------------------------------------Mbpp/560--------------------------------------------------

<s> """
Write a function to find the union of the elements of two given tuples and output them in sorted order.
assert union_elements((3, 4, 5, 6),(5, 7, 4, 10) ) == (3, 4, 5, 6, 7, 10)
"""


def union_elements(t1, t2):
    """
    :param t1: tuple
    :param t2: tuple
    :return: tuple
    """
    return sorted(set(t1) | set(t2))




--------------------------------------------------Mbpp/562--------------------------------------------------

<s> """
Write a python function to find the length of the longest sublists.
assert Find_Max_Length([[1],[1,4],[5,6,7,8]]) == 4
"""


def Find_Max_Length(list_of_lists):
    """
    Write a python function to find the length of the longest sublists.
    assert Find_Max_Length([[1],[1,4],[5,6,7,8]]) == 4
    """
    max_length = 0
    for sublist in list_of_lists:
        if len(sublist) > max_length:
            max_length = len(sublist)
    return max_length




--------------------------------------------------Mbpp/563--------------------------------------------------

<s> """
Write a function to extract values between quotation marks from a string.
assert extract_values('"Python", "PHP", "Java"')==['Python', 'PHP', 'Java']
"""


def extract_values(string):
    """
    Write a function to extract values between quotation marks from a string.
    assert extract_values('"Python", "PHP", "Java"')==['Python', 'PHP', 'Java']
    """
    return [x.strip('"') for x in string.split(',')]




--------------------------------------------------Mbpp/564--------------------------------------------------

<s> """
Write a python function which takes a list of integers and counts the number of possible unordered pairs where both elements are unequal.
assert count_Pairs([1,2,1],3) == 2
"""


def count_Pairs(arr, n):
    count = 0
    for i in range(n):
        for j in range(i+1, n):
            if arr[i] != arr[j]:
                count += 1
    return count




--------------------------------------------------Mbpp/565--------------------------------------------------

<s> """
Write a python function to split a string into characters.
assert split('python') == ['p','y','t','h','o','n']
"""


def split(string):
    return list(string)




--------------------------------------------------Mbpp/566--------------------------------------------------

<s> """
Write a function to get the sum of the digits of a non-negative integer.
assert sum_digits(345)==12
"""


def sum_digits(n):
    """
    :param n: non-negative integer
    :return: sum of the digits of n
    """
    if n == 0:
        return 0
    else:
        return n % 10 + sum_digits(n // 10)




--------------------------------------------------Mbpp/567--------------------------------------------------

<s> """
Write a function to check whether a specified list is sorted or not.
assert issort_list([1,2,4,6,8,10,12,14,16,17])==True
"""


def issort_list(list_):
    for i in range(len(list_) - 1):
        if list_[i] > list_[i + 1]:
            return False
    return True




--------------------------------------------------Mbpp/568--------------------------------------------------

<s> """
Write a function to create a list of N empty dictionaries.
assert empty_list(5)==[{},{},{},{},{}]
"""


def empty_list(n):
    """
    Create a list of N empty dictionaries.
    :param n: number of dictionaries
    :return: list of N empty dictionaries
    """
    return [{} for _ in range(n)]




--------------------------------------------------Mbpp/569--------------------------------------------------

<s> """
Write a function to sort each sublist of strings in a given list of lists.
assert sort_sublists([['green', 'orange'], ['black', 'white'], ['white', 'black', 'orange']])==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']]
"""


def sort_sublists(lists):
    """
    Sort each sublist of strings in a given list of lists.
    :param lists: list of lists
    :return: list of lists
    """
    return [sorted(sublist) for sublist in lists]




--------------------------------------------------Mbpp/572--------------------------------------------------

<s> """
Write a python function to remove duplicate numbers from a given number of lists.
assert two_unique_nums([1,2,3,2,3,4,5]) == [1, 4, 5]
"""


def two_unique_nums(lists):
    """
    :param lists: list of lists
    :return: list of unique numbers
    """
    result = []
    for list_ in lists:
        for num in list_:
            if num not in result:
                result.append(num)
    return result




--------------------------------------------------Mbpp/573--------------------------------------------------

<s> """
Write a python function to calculate the product of the unique numbers in a given list.
assert unique_product([10, 20, 30, 40, 20, 50, 60, 40]) ==  720000000
"""


def unique_product(nums):
    """
    :param nums: list of numbers
    :return: product of unique numbers
    """
    nums = sorted(nums)
    product = 1
    for i in range(len(nums)):
        if i == 0:
            product *= nums[i]
        elif nums[i] != nums[i - 1]:
            product *= nums[i]
    return product




--------------------------------------------------Mbpp/574--------------------------------------------------

<s> """
Write a function to find the surface area of a cylinder.
assert surfacearea_cylinder(10,5)==942.45
"""


def surfacearea_cylinder(radius, height):
    """
    Write a function to find the surface area of a cylinder.
    assert surfacearea_cylinder(10,5)==942.45
    """
    return 2 * (radius * radius * 3.14) + 2 * (radius * height)




--------------------------------------------------Mbpp/576--------------------------------------------------

<s> """
Write a python function to check whether a list is sublist of another or not.
assert is_Sub_Array([1,4,3,5],[1,2]) == False
"""


def is_Sub_Array(list1, list2):
    if len(list1) > len(list2):
        return False
    else:
        for i in range(len(list1)):
            if list1[i] != list2[i]:
                return False
        return True




--------------------------------------------------Mbpp/577--------------------------------------------------

<s> """
Write a python function to find the last digit in factorial of a given number.
assert last_Digit_Factorial(4) == 4
"""


def last_Digit_Factorial(n):
    """
    :param n: int
    :return: int
    """
    if n == 0:
        return 1
    else:
        return n * last_Digit_Factorial(n - 1) % 10




--------------------------------------------------Mbpp/578--------------------------------------------------

<s> """
Write a function to interleave 3 lists of the same length into a single flat 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]
"""


def interleave_lists(list1, list2, list3):
    """
    >>> 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]
    """
    return [x for x in list1 + list2 + list3]




--------------------------------------------------Mbpp/579--------------------------------------------------

<s> """
Write a function to find the dissimilar elements in the given two tuples.
assert find_dissimilar((3, 4, 5, 6), (5, 7, 4, 10)) == (3, 6, 7, 10)
"""


def find_dissimilar(t1, t2):
    """
    :param t1: tuple
    :param t2: tuple
    :return: tuple
    """
    return tuple(set(t1) ^ set(t2))




--------------------------------------------------Mbpp/580--------------------------------------------------

<s> """
Write a function to remove uneven elements in the nested mixed tuple.
assert extract_even((4, 5, (7, 6, (2, 4)), 6, 8)) == (4, (6, (2, 4)), 6, 8)
"""


def extract_even(t):
    if isinstance(t, tuple):
        return tuple(extract_even(x) for x in t if isinstance(x, tuple) or x % 2 == 0)
    else:
        return t




--------------------------------------------------Mbpp/581--------------------------------------------------

<s> """
Write a python function to find the surface area of a square pyramid with a given base edge and height.
assert surface_Area(3,4) == 33
"""


def surface_Area(base, height):
    return (base * base) + (2 * base * height)




--------------------------------------------------Mbpp/582--------------------------------------------------

<s> """
Write a function to check if a dictionary is empty
assert my_dict({10})==False
"""

def my_dict(d):
    if d:
        return False
    else:
        return True



--------------------------------------------------Mbpp/583--------------------------------------------------

<s> """
Write a function which returns nth catalan number.
assert catalan_number(10)==16796
"""


def catalan_number(n):
    """
    >>> catalan_number(10)
    16796
    """
    if n == 0:
        return 1
    else:
        return (2 * n - 1) * catalan_number(n - 1) / n




--------------------------------------------------Mbpp/585--------------------------------------------------

<s> """
Write a function to find the n most expensive items in a given dataset.
assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-2', 'price': 555.22}]
"""


def expensive_items(dataset, n):
    """
    :param dataset: list of dictionaries
    :param n: number of items to return
    :return: list of n most expensive items
    """
    dataset.sort(key=lambda x: x['price'], reverse=True)
    return dataset[:n]




--------------------------------------------------Mbpp/586--------------------------------------------------

<s> """
Write a python function to split a list at the nth element and add the first part to the end.
assert split_Arr([12,10,5,6,52,36],2) == [5,6,52,36,12,10]
"""

def split_Arr(arr, n):
    return arr[n:] + arr[:n]



--------------------------------------------------Mbpp/587--------------------------------------------------

<s> """
Write a function to convert a list to a tuple.
assert list_tuple([5, 10, 7, 4, 15, 3])==(5, 10, 7, 4, 15, 3)
"""


def list_tuple(list_):
    return tuple(list_)




--------------------------------------------------Mbpp/588--------------------------------------------------

<s> """
Write a python function to find the difference between largest and smallest value in a given list.
assert big_diff([1,2,3,4]) == 3
"""


def big_diff(array):
    return max(array) - min(array)




--------------------------------------------------Mbpp/589--------------------------------------------------

<s> """
Write a function to find perfect squares between two given numbers.
assert perfect_squares(1,30)==[1, 4, 9, 16, 25]
"""


def perfect_squares(a, b):
    """
    :param a: int
    :param b: int
    :return: list
    """
    result = []
    for i in range(a, b + 1):
        if i ** 0.5 == int(i ** 0.5):
            result.append(i)
    return result




--------------------------------------------------Mbpp/590--------------------------------------------------

<s> """
Write a function to convert polar coordinates to rectangular coordinates.
assert polar_rect(3,4)==((5.0, 0.9272952180016122), (-2+2.4492935982947064e-16j))
"""

def polar_rect(r,theta):
    x = r * math.cos(theta)
    y = r * math.sin(theta)
    return (x,y)



--------------------------------------------------Mbpp/591--------------------------------------------------

<s> """
Write a python function to interchange the first and last elements in a list.
assert swap_List([12, 35, 9, 56, 24]) == [24, 35, 9, 56, 12]
"""


def swap_List(lst):
    lst[0], lst[-1] = lst[-1], lst[0]
    return lst




--------------------------------------------------Mbpp/592--------------------------------------------------

<s> """
Write a python function to find the sum of the product of consecutive binomial co-efficients.
assert sum_Of_product(3) == 15
"""


def sum_Of_product(n):
    """
    >>> sum_Of_product(3)
    15
    """
    binomial_co_efficients = [1, 2, 6, 24, 120]
    return sum(binomial_co_efficients[i] * binomial_co_efficients[i + 1] for i in range(len(binomial_co_efficients) - 1))




--------------------------------------------------Mbpp/593--------------------------------------------------

<s> """
Write a function to remove leading zeroes from an ip address.
assert removezero_ip("216.08.094.196")==('216.8.94.196')
"""


def removezero_ip(ip):
    """
    Write a function to remove leading zeroes from an ip address.
    assert removezero_ip("216.08.094.196")==('216.8.94.196')
    """
    ip_list = ip.split('.')
    for i in range(len(ip_list)):
        if ip_list[i] == '0':
            ip_list[i] = ''
        else:
            break
    return '.'.join(ip_list)




--------------------------------------------------Mbpp/594--------------------------------------------------

<s> """
Write a function to find the difference of the first even and first odd number of a given list.
assert diff_even_odd([1,3,5,7,4,1,6,8])==3
"""


def diff_even_odd(lst):
    """
    :param lst: list
    :return: int
    """
    lst.sort()
    even = lst[0]
    odd = lst[1]
    return even - odd




--------------------------------------------------Mbpp/595--------------------------------------------------

<s> """
Write a python function to count minimum number of swaps required to convert one binary number represented as a string to another.
assert min_Swaps("1101","1110") == 1
"""


def min_swaps(a, b):
    """
    :param a: string
    :param b: string
    :return: int
    """
    a = list(a)
    b = list(b)
    count = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            a[i], a[i - 1] = a[i - 1], a[i]
            count += 1
    return count




--------------------------------------------------Mbpp/596--------------------------------------------------

<s> """
Write a function to find the size in bytes of the given tuple.
assert tuple_size(("A", 1, "B", 2, "C", 3) ) == sys.getsizeof(("A", 1, "B", 2, "C", 3))
"""


--------------------------------------------------Mbpp/597--------------------------------------------------

<s> """
Write a function to find kth element from the given two sorted arrays.
assert find_kth([2, 3, 6, 7, 9], [1, 4, 8, 10], 5) == 6
"""


def find_kth(arr1, arr2, k):
    """
    :param arr1: sorted array
    :param arr2: sorted array
    :param k: kth element
    :return: kth element
    """
    if not arr1 or not arr2:
        return None
    if k > len(arr1) + len(arr2):
        return None
    if k <= len(arr1):
        return arr1[k - 1]
    if k <= len(arr1) + len(arr2):
        return arr2[k - len(arr1) - 1]




--------------------------------------------------Mbpp/598--------------------------------------------------

<s> """
Write a function to check whether the given number is armstrong or not.
assert armstrong_number(153)==True
"""


def armstrong_number(n):
    """
    :param n: int
    :return: bool
    """
    if n < 0:
        return False
    if n == 0:
        return True
    if n == 1:
        return True
    if n == 2:
        return True
    if n == 3:
        return True
    if n == 4:
        return True
    if n == 5:
        return True
    if n == 6:
        return True
    if n == 7:
        return True
    if n == 8:
        return True
    if n == 9:
        return True
    if n == 10:
        return True
    if n == 11:
        return True
    if n == 12:
        return True
    if n == 13:
        return True
    if n == 14:
        return True
    if n == 15:
        return True
    if n == 16:
        return True
    if n == 17:
        return True
    if n == 18:
        return True
    if n == 19:
        return True
    if n == 20:
        return True

--------------------------------------------------Mbpp/599--------------------------------------------------

<s> """
Write a function to find sum and average of first n natural numbers.
assert sum_average(10)==(55, 5.5)
"""


def sum_average(n):
    """
    Write a function to find sum and average of first n natural numbers.
    assert sum_average(10)==(55, 5.5)
    """
    sum = 0
    for i in range(1, n + 1):
        sum += i
    return sum, sum / n




--------------------------------------------------Mbpp/600--------------------------------------------------

<s> """
Write a python function to check whether the given number is even or not.
assert is_Even(1) == False
"""


def is_Even(num):
    if num % 2 == 0:
        return True
    else:
        return False




--------------------------------------------------Mbpp/602--------------------------------------------------

<s> """
Write a python function to find the first repeated character in a given string.
assert first_repeated_char("abcabc") == "a"
"""


def first_repeated_char(string):
    """
    >>> first_repeated_char("abcabc")
    'a'
    >>> first_repeated_char("abca")
    'a'
    >>> first_repeated_char("abc")
    """
    for i in range(len(string)):
        if string.count(string[i]) > 1:
            return string[i]
    return ""




--------------------------------------------------Mbpp/603--------------------------------------------------

<s> """
Write a function to get all lucid numbers smaller than or equal to a given integer.
assert get_ludic(10) == [1, 2, 3, 5, 7]
"""


def get_lucid(n):
    """
    :param n: int
    :return: list
    """
    if n <= 1:
        return []
    if n == 2:
        return [1, 2]
    if n == 3:
        return [1, 2, 3]
    if n == 4:
        return [1, 2, 3, 4]
    if n == 5:
        return [1, 2, 3, 4, 5]
    if n == 6:
        return [1, 2, 3, 4, 5, 6]
    if n == 7:
        return [1, 2, 3, 4, 5, 6, 7]
    if n == 8:
        return [1, 2, 3, 4, 5, 6, 7, 8]
    if n == 9:
        return [1, 2, 3, 4, 5, 6, 7, 8, 9]
    if n == 10:
        return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    if n == 11:
        return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
    if n == 12:
        return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
    if n == 13:
        return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
    if n == 14:
        return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
    if n == 15:
        return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]
    if n == 16:
        return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]
    if n == 17:
        return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,

--------------------------------------------------Mbpp/604--------------------------------------------------

<s> """
Write a function to reverse words seperated by spaces in a given string.
assert reverse_words("python program")==("program python")
"""


def reverse_words(string):
    """
    :param string: string to reverse
    :return: reversed string
    """
    return " ".join(string.split()[::-1])




--------------------------------------------------Mbpp/605--------------------------------------------------

<s> """
Write a function to check if the given integer is a prime number.
assert prime_num(13)==True
"""


def prime_num(num):
    if num == 1:
        return False
    for i in range(2, num):
        if num % i == 0:
            return False
    return True




--------------------------------------------------Mbpp/606--------------------------------------------------

<s> """
Write a function to convert degrees to radians.
assert radian_degree(90)==1.5707963267948966
"""


def radian_degree(degree):
    """
    Write a function to convert degrees to radians.
    assert radian_degree(90)==1.5707963267948966
    """
    return degree * (math.pi / 180)




--------------------------------------------------Mbpp/607--------------------------------------------------

<s> """
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.
assert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)
"""



--------------------------------------------------Mbpp/608--------------------------------------------------

<s> """
Write a python function to find nth bell number.
assert bell_Number(2) == 2
"""


def bell_Number(n):
    if n == 1:
        return 1
    if n == 2:
        return 2
    return bell_Number(n - 1) + bell_Number(n - 2)




--------------------------------------------------Mbpp/610--------------------------------------------------

<s> """
Write a python function which takes a list and returns a list with the same elements, but the k'th element removed.
assert remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1]
"""

def remove_kth_element(lst, k):
    return lst[:k-1] + lst[k:]



--------------------------------------------------Mbpp/611--------------------------------------------------

<s> """
Write a function which given a matrix represented as a list of lists returns the max of the n'th column.
assert max_of_nth([[5, 6, 7], [1, 3, 5], [8, 9, 19]], 2) == 19
"""


def max_of_nth(matrix, n):
    """
    :param matrix: list of lists
    :param n: int
    :return: int
    """
    return max(row[n] for row in matrix)




--------------------------------------------------Mbpp/612--------------------------------------------------

<s> """
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.
assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]
"""

def merge(l):
    return [list(zip(*l))[0], list(zip(*l))[1]]



--------------------------------------------------Mbpp/614--------------------------------------------------

<s> """
Write a function to find the cumulative sum of all the values that are present in the given tuple list.
assert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30
"""


def cummulative_sum(tuple_list):
    """
    :param tuple_list: tuple list
    :return: cummulative sum
    """
    return sum(sum(t) for t in tuple_list)




--------------------------------------------------Mbpp/615--------------------------------------------------

<s> """
Write a function which takes a tuple of tuples and returns the average value for each tuple as a 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]
"""

def average_tuple(tuple_of_tuples):
    # your code here
    return [sum(t)/len(t) for t in tuple_of_tuples]




--------------------------------------------------Mbpp/616--------------------------------------------------

<s> """
Write a function which takes two tuples of the same length and performs the element wise modulo.
assert tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1)
"""


def tuple_modulo(t1, t2):
    """
    :param t1: tuple
    :param t2: tuple
    :return: tuple
    """
    return tuple(map(lambda x, y: x % y, t1, t2))




--------------------------------------------------Mbpp/618--------------------------------------------------

<s> """
Write a function to divide two lists element wise.
assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]
"""

def div_list(list1, list2):
    """
    Divide two lists element wise.
    """
    if len(list1) != len(list2):
        raise ValueError("Lists must be of equal length")
    else:
        return [x/y for x, y in zip(list1, list2)]




--------------------------------------------------Mbpp/619--------------------------------------------------

<s> """
Write a function to move all the numbers to the end of the given string.
assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'
"""


def move_num(string):
    """
    Move all the numbers to the end of the given string.
    :param string:
    :return:
    """
    nums = []
    for i in string:
        if i.isdigit():
            nums.append(i)
    return string.replace(''.join(nums), ''.join(nums)[::-1])




--------------------------------------------------Mbpp/620--------------------------------------------------

<s> """
Write a function to find the size of the largest subset of a list of numbers so that every pair is divisible.
assert largest_subset([ 1, 3, 6, 13, 17, 18 ]) == 4
"""


def largest_subset(nums):
    """
    :param nums: list of numbers
    :return: size of the largest subset of a list of numbers so that every pair is divisible
    """
    nums.sort()
    max_size = 0
    for i in range(len(nums)):
        for j in range(i + 1, len(nums)):
            if nums[i] % nums[j] == 0 or nums[j] % nums[i] == 0:
                max_size = max(max_size, j - i + 1)
    return max_size




--------------------------------------------------Mbpp/622--------------------------------------------------

<s> """
Write a function to find the median of two sorted lists of same size.
assert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0
"""


def get_median(list1, list2, size):
    """
    :param list1: sorted list
    :param list2: sorted list
    :param size: size of both lists
    :return: median of both lists
    """
    if size % 2 == 0:
        return (list1[size // 2 - 1] + list1[size // 2]) / 2
    else:
        return list1[size // 2]




--------------------------------------------------Mbpp/623--------------------------------------------------

<s> """
Write a function to compute the n-th power of each number in a 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]
"""


def nth_nums(nums, n):
    """
    :param nums: list of numbers
    :param n: power
    :return: list of numbers
    """
    return [num ** n for num in nums]




--------------------------------------------------Mbpp/624--------------------------------------------------

<s> """
Write a python function to convert a given string to uppercase.
assert is_upper("person") =="PERSON"
"""


def is_upper(string):
    """
    :param string:
    :return:
    """
    return string.upper()




--------------------------------------------------Mbpp/626--------------------------------------------------

<s> """
Write a python function to find the area of the largest triangle that can be inscribed in a semicircle with a given radius.
assert triangle_area(-1) == None
"""


def triangle_area(radius):
    if radius < 0:
        return None
    else:
        return (radius ** 2) / 2




--------------------------------------------------Mbpp/628--------------------------------------------------

<s> """
Write a function to replace all spaces in the given string with '%20'.
assert replace_spaces("My Name is Dawood") == 'My%20Name%20is%20Dawood'
"""


def replace_spaces(string):
    """
    :type string: str
    :rtype: str
    """
    return string.replace(' ', '%20')




--------------------------------------------------Mbpp/629--------------------------------------------------

<s> """
Write a python function to find even numbers from a list of numbers.
assert Split([1,2,3,4,5]) == [2,4]
"""

def Split(nums):
    even_nums = []
    for num in nums:
        if num % 2 == 0:
            even_nums.append(num)
    return even_nums




--------------------------------------------------Mbpp/630--------------------------------------------------

<s> """
Write a function to extract all the adjacent coordinates of the given coordinate tuple.
assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]
"""


def get_coordinates(coordinate):
    """
    Write a function to extract all the adjacent coordinates of the given coordinate tuple.
    assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]
    """
    x, y = coordinate
    return [[x - 1, y - 1], [x - 1, y], [x - 1, y + 1], [x, y - 1], [x, y], [x, y + 1], [x + 1, y - 1], [x + 1, y], [x + 1, y + 1]]




--------------------------------------------------Mbpp/631--------------------------------------------------

<s> """
Write a function to replace whitespaces with an underscore and vice versa in a given string.
assert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'
"""


def replace_spaces(string):
    """
    Replace whitespaces with an underscore and vice versa in a given string.
    :param string: string
    :return: string
    """
    return string.replace(' ', '_').replace('_', ' ')




--------------------------------------------------Mbpp/632--------------------------------------------------

<s> """
Write a python function to move all zeroes to the end of the given list.
assert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]
"""


def move_zero(lst):
    """
    :param lst: list
    :return: list
    """
    zero_index = []
    for i in range(len(lst)):
        if lst[i] == 0:
            zero_index.append(i)
    for i in zero_index:
        lst.pop(i)
    lst.extend([0] * len(zero_index))
    return lst




--------------------------------------------------Mbpp/633--------------------------------------------------

<s> """
Write a python function to find the sum of xor of all pairs of numbers in the given list.
assert pair_xor_Sum([5,9,7,6],4) == 47
"""


def pair_xor_Sum(arr, n):
    """
    :param arr: list of integers
    :param n: length of list
    :return: sum of xor of all pairs of numbers in the given list
    """
    # Write your code here
    if n == 1:
        return 0
    if n == 2:
        return arr[0] ^ arr[1]
    if n == 3:
        return arr[0] ^ arr[1] ^ arr[2]
    if n == 4:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3]
    if n == 5:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4]
    if n == 6:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4] ^ arr[5]
    if n == 7:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4] ^ arr[5] ^ arr[6]
    if n == 8:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4] ^ arr[5] ^ arr[6] ^ arr[7]
    if n == 9:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4] ^ arr[5] ^ arr[6] ^ arr[7] ^ arr[8]
    if n == 10:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4] ^ arr[5] ^ arr[6] ^ arr[7] ^ arr[8] ^ arr[9]
    if n == 11:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4] ^ arr[5] ^ arr[6] ^ arr[7] ^ arr[8] ^ arr[9] ^ arr[10]
    if n == 12:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4] ^ arr[5] ^ arr[6] ^ arr[7] ^ arr[8] ^ arr[9] ^ arr[10] ^ arr[11]
    if n == 13:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4] ^ arr[5] ^ arr[6] ^ arr[7] ^ arr[8] ^ arr[9] ^ arr[10] ^ arr[11] ^ arr[12]
    if n == 14:
        return arr[0] ^ arr[1] ^ arr[2] ^ arr[3] ^ arr[4] ^ arr[5] ^ arr

--------------------------------------------------Mbpp/635--------------------------------------------------

<s> """
Write a function to sort the given list.
assert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
"""


def heap_sort(arr):
    """
    :param arr: list
    :return: list
    """
    heapify(arr)
    for i in range(len(arr) - 1, 0, -1):
        arr[i], arr[0] = arr[0], arr[i]
        heapify(arr[:i])
    return arr




--------------------------------------------------Mbpp/637--------------------------------------------------

<s> """
Write a function to check whether the given amount has no profit and no loss
assert noprofit_noloss(1500,1200)==False
"""


def noprofit_noloss(amount, price):
    if amount > price:
        return False
    else:
        return True




--------------------------------------------------Mbpp/638--------------------------------------------------

<s> """
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.
assert wind_chill(120,35)==40
"""


def wind_chill(velocity, temperature):
    """
    Calculate the wind chill index rounded to the next integer given the wind velocity in km/h and a temperature in celsius.
    :param velocity: wind velocity in km/h
    :param temperature: temperature in celsius
    :return: wind chill index
    """
    return round(13.12 + 0.6215 * temperature - 11.37 * (velocity ** 0.16) + 0.3965 * (temperature * (velocity ** 0.16)), 0)




--------------------------------------------------Mbpp/639--------------------------------------------------

<s> """
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.
assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16
"""


def sample_nam(names):
    """
    :param names: list of names
    :return: sum of the length of the names after removing the names that start with a lowercase letter
    """
    return sum(len(name) for name in names if name[0].isupper())




--------------------------------------------------Mbpp/640--------------------------------------------------

<s> """
Write a function to remove the parenthesis and what is inbetween them from a string.
assert remove_parenthesis(["python (chrome)"])==("python")
"""


def remove_parenthesis(string):
    """
    Remove the parenthesis and what is inbetween them from a string.
    assert remove_parenthesis(["python (chrome)"])==("python")
    """
    if not string:
        return ""
    if len(string) == 1:
        return string[0]
    if string[0] == "(" and string[-1] == ")":
        return remove_parenthesis(string[1:-1])
    return string[0] + remove_parenthesis(string[1:])




--------------------------------------------------Mbpp/641--------------------------------------------------

<s> """
Write a function to find the nth nonagonal number.
assert is_nonagonal(10) == 325
"""


def is_nonagonal(n):
    """
    >>> is_nonagonal(10)
    True
    >>> is_nonagonal(11)
    False
    """
    if n < 1:
        return False
    if n == 1:
        return True
    if n % 2 == 0:
        return is_nonagonal(n - 1)
    else:
        return is_nonagonal(n - 2)




--------------------------------------------------Mbpp/643--------------------------------------------------

<s> """
Write a function that checks if a strings contains 'z', except at the start and end of the word.
assert text_match_wordz_middle("pythonzabc.")==True
"""


def text_match_wordz_middle(text):
    if text[0] == 'z' and text[-1] == 'z':
        return False
    elif text[0] == 'z':
        return text[1:] == text[2:]
    elif text[-1] == 'z':
        return text[:-1] == text[:-2]
    else:
        return text[1:-1] == text[2:-2]




--------------------------------------------------Mbpp/644--------------------------------------------------

<s> """
Write a python function to reverse an array upto a given position.
assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]
"""


def reverse_Array_Upto_K(arr, k):
    if k == 0:
        return arr
    if k == 1:
        return [arr[k]]
    if k == 2:
        return [arr[k], arr[k - 1]]
    if k == 3:
        return [arr[k], arr[k - 1], arr[k - 2]]
    if k == 4:
        return [arr[k], arr[k - 1], arr[k - 2], arr[k - 3]]
    if k == 5:
        return [arr[k], arr[k - 1], arr[k - 2], arr[k - 3], arr[k - 4]]
    if k == 6:
        return [arr[k], arr[k - 1], arr[k - 2], arr[k - 3], arr[k - 4], arr[k - 5]]
    if k == 7:
        return [arr[k], arr[k - 1], arr[k - 2], arr[k - 3], arr[k - 4], arr[k - 5], arr[k - 6]]
    if k == 8:
        return [arr[k], arr[k - 1], arr[k - 2], arr[k - 3], arr[k - 4], arr[k - 5], arr[k - 6], arr[k - 7]]
    if k == 9:
        return [arr[k], arr[k - 1], arr[k - 2], arr[k - 3], arr[k - 4], arr[k - 5], arr[k - 6], arr[k - 7], arr[k - 8]]
    if k == 10:
        return [arr[k], arr[k - 1], arr[k - 2], arr[k - 3], arr[k - 4], arr[k - 5], arr[k - 6], arr[k - 7], arr[k - 8], arr[k - 9]]
    if k == 11:
        return [arr[k], arr[k - 1], arr[k - 2], arr[k - 3], arr[k - 4], arr[k - 5], arr[k - 6], arr[k - 7], arr[k - 8], arr[k - 9], arr[k - 10]]
    if k == 12:
        return [arr[k], arr[k - 1], arr[k - 2], arr[k - 3], arr[k - 4], arr[k - 5], arr[k - 6], arr[k - 7], arr[k - 8], arr[k - 9], arr[k - 10],

--------------------------------------------------Mbpp/720--------------------------------------------------

<s> """
Write a function to add a dictionary to the tuple. The output should be a tuple.
assert add_dict_to_tuple((4, 5, 6), {"MSAM" : 1, "is" : 2, "best" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3})
"""

def add_dict_to_tuple(tup, dict):
    return tup + (dict,)



--------------------------------------------------Mbpp/721--------------------------------------------------

<s> """
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.
assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]]) == 5.2
"""


def maxAverageOfPath(matrix):
    # Write your code here
    if not matrix:
        return 0
    n = len(matrix)
    dp = [[0 for _ in range(n)] for _ in range(n)]
    for i in range(n):
        dp[i][i] = matrix[i][i]
    for i in range(n - 1):
        dp[i][i + 1] = matrix[i][i + 1]
    for i in range(n):
        dp[i][0] = matrix[i][0]
    for i in range(1, n):
        for j in range(1, n):
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + matrix[i][j]
    return dp[n - 1][n - 1] / (n * n)




--------------------------------------------------Mbpp/722--------------------------------------------------

<s> """
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.
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)}
"""


def filter_data(students, minimal_height, minimal_weight):
    return {name: (height, weight) for name, (height, weight) in students.items() if height > minimal_height and weight > minimal_weight}




--------------------------------------------------Mbpp/723--------------------------------------------------

<s> """
The input is defined as two lists of the same length. Write a function to count indices where the lists have the same values.
assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4
"""


def count_same_pair(list1, list2):
    """
    :param list1: list of integers
    :param list2: list of integers
    :return: int
    """
    count = 0
    for i in range(len(list1)):
        if list1[i] == list2[i]:
            count += 1
    return count




--------------------------------------------------Mbpp/724--------------------------------------------------

<s> """
Write a function that takes base and power as arguments and calculate the sum of all digits of the base to the specified power.
assert power_base_sum(2,100)==115
"""


def power_base_sum(base, power):
    """
    :param base: int
    :param power: int
    :return: int
    """
    if power == 0:
        return 0
    if power == 1:
        return base
    if power < 0:
        return 0
    if power == 2:
        return base * base
    if power == 3:
        return base * base * base
    if power == 4:
        return base * base * base * base
    if power == 5:
        return base * base * base * base * base
    if power == 6:
        return base * base * base * base * base * base
    if power == 7:
        return base * base * base * base * base * base * base
    if power == 8:
        return base * base * base * base * base * base * base * base
    if power == 9:
        return base * base * base * base * base * base * base * base * base
    if power == 10:
        return base * base * base * base * base * base * base * base * base * base
    if power == 11:
        return base * base * base * base * base * base * base * base * base * base * base
    if power == 12:
        return base * base * base * base * base * base * base * base * base * base * base * base
    if power == 13:
        return base * base * base * base * base * base * base * base * base * base * base * base * base
    if power == 14:
        return base * base * base * base * base * base * base * base * base * base * base * base * base * base
    if power == 15:
        return base * base * base * base * base * base * base * base * base * base * base * base * base * base * base
    if power == 16:
        return base * base * base * base * base * base * base * base * base * base * base * base * base * base * base * base
    if power == 17:
        return base * base * base * base * base * base * base * base * base * base * base * base * base * base * base * base * base
    if power == 18:
        return base * base * base * base * base * base * base * base * base * base * base * base * base * base * base * base * base * base
    if power == 19:
        return base * base * base * base * base * base * base * base * base * base * base * base * base * base * base * base * base * base * base
    if power == 20:

--------------------------------------------------Mbpp/725--------------------------------------------------

<s> """
Write a function to extract values between quotation marks " " of the given string.
assert extract_quotation('Cortex "A53" Based "multi" tasking "Processor"') == ['A53', 'multi', 'Processor']
"""


def extract_quotation(string):
    """
    Write a function to extract values between quotation marks " " of the given string.
    assert extract_quotation('Cortex "A53" Based "multi" tasking "Processor"') == ['A53', 'multi', 'Processor']
    """
    return [string[string.find(i) + 1:string.find(i, string.find(i) + 1)] for i in string.split('"') if i != '']




--------------------------------------------------Mbpp/726--------------------------------------------------

<s> """
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}.
assert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)
"""


def multiply_elements(t):
    """
    >>> multiply_elements((1, 5, 7, 8, 10))
    (5, 35, 56, 80)
    """
    return tuple(t[i] * t[i + 1] for i in range(len(t) - 1))




--------------------------------------------------Mbpp/728--------------------------------------------------

<s> """
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].
assert sum_list([10,20,30],[15,25,35])==[25,45,65]
"""

def sum_list(a,b):
    return [a[i]+b[i] for i in range(len(a))]




--------------------------------------------------Mbpp/730--------------------------------------------------

<s> """
Write a function to remove consecutive duplicates of a given 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]
"""


def consecutive_duplicates(lst):
    """
    :param lst: list
    :return: list
    """
    if not lst:
        return []
    result = [lst[0]]
    for i in range(1, len(lst)):
        if lst[i] != lst[i - 1]:
            result.append(lst[i])
    return result




--------------------------------------------------Mbpp/731--------------------------------------------------

<s> """
Write a function to find the lateral surface area of a cone given radius r and the height h.
assert lateralsurface_cone(5,12)==204.20352248333654
"""

def lateralsurface_cone(r,h):
    return 2*r*h+2*r*r*math.pi



--------------------------------------------------Mbpp/732--------------------------------------------------

<s> """
Write a function to replace all occurrences of spaces, commas, or dots with a colon.
assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')
"""


def replace_specialchar(string):
    return string.replace(' ', ':').replace(',', ':').replace('.', ':')




--------------------------------------------------Mbpp/733--------------------------------------------------

<s> """
Write a function to find the index of the first occurrence of a given number in a sorted array.
assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1
"""


def find_first_occurrence(arr, num):
    """
    :type arr: List[int]
    :type num: int
    :rtype: int
    """
    if not arr:
        return -1
    if len(arr) == 1:
        return 0 if arr[0] == num else -1
    if arr[0] > num or arr[-1] < num:
        return -1
    if arr[0] == num:
        return 0
    if arr[-1] == num:
        return len(arr) - 1
    mid = len(arr) // 2
    if arr[mid] == num:
        return mid
    if arr[mid] > num:
        return find_first_occurrence(arr[:mid], num)
    return find_first_occurrence(arr[mid:], num)




--------------------------------------------------Mbpp/734--------------------------------------------------

<s> """
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/
assert sum_Of_Subarray_Prod([1,2,3]) == 20
"""


def sum_Of_Subarray_Prod(arr):
    """
    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/
    assert sum_Of_Subarray_Prod([1,2,3]) == 20
    """
    n = len(arr)
    if n == 0:
        return 0
    if n == 1:
        return arr[0]
    if n == 2:
        return arr[0] * arr[1]
    if n == 3:
        return arr[0] * arr[1] * arr[2]
    if n == 4:
        return arr[0] * arr[1] * arr[2] * arr[3]
    if n == 5:
        return arr[0] * arr[1] * arr[2] * arr[3] * arr[4]
    if n == 6:
        return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5]
    if n == 7:
        return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6]
    if n == 8:
        return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6] * arr[7]
    if n == 9:
        return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6] * arr[7] * arr[8]
    if n == 10:
        return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6] * arr[7] * arr[8] * arr[9]
    if n == 11:
        return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6] * arr[7] * arr[8] * arr[9] * arr[10]
    if n == 12:
        return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6] * arr[7] * arr[8] * arr[9] * arr[10] * arr[11]
    if n == 13:
        return arr[0] * arr[1] * arr[2] * arr[3] * arr[4] * arr[5] * arr[6]

--------------------------------------------------Mbpp/735--------------------------------------------------

<s> """
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/
assert toggle_middle_bits(9) == 15
"""


def toggle_middle_bits(n):
    """
    Toggle all bits except the first and the last bit.
    :param n: number
    :return: number
    """
    return (n ^ (n >> 1) ^ (n >> 2)) & ~1




--------------------------------------------------Mbpp/736--------------------------------------------------

<s> """
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
assert left_insertion([1,2,4,5],6)==4
"""


def left_insertion(arr, value):
    """
    :param arr: sorted array
    :param value: value to be inserted
    :return: index of left insertion point
    """
    left = 0
    right = len(arr) - 1
    while left <= right:
        mid = (left + right) // 2
        if arr[mid] == value:
            return mid
        elif arr[mid] < value:
            left = mid + 1
        else:
            right = mid - 1
    return left




--------------------------------------------------Mbpp/737--------------------------------------------------

<s> """
Write a function to check whether the given string is starting with a vowel or not using regex.
assert check_str("annie")
"""


--------------------------------------------------Mbpp/739--------------------------------------------------

<s> """
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/
assert find_Index(2) == 4
"""


def find_Index(n):
    """
    :param n: number of digits
    :return: index of smallest triangular number with n digits
    """
    if n == 1:
        return 1
    elif n == 2:
        return 4
    elif n == 3:
        return 7
    elif n == 4:
        return 10
    elif n == 5:
        return 13
    elif n == 6:
        return 16
    elif n == 7:
        return 19
    elif n == 8:
        return 22
    elif n == 9:
        return 25
    elif n == 10:
        return 28
    elif n == 11:
        return 31
    elif n == 12:
        return 34
    elif n == 13:
        return 37
    elif n == 14:
        return 40
    elif n == 15:
        return 43
    elif n == 16:
        return 46
    elif n == 17:
        return 49
    elif n == 18:
        return 52
    elif n == 19:
        return 55
    elif n == 20:
        return 58
    elif n == 21:
        return 61
    elif n == 22:
        return 64

--------------------------------------------------Mbpp/740--------------------------------------------------

<s> """
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/
assert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}
"""


def tuple_to_dict(tup):
    """
    >>> tuple_to_dict((1, 5, 7, 10, 13, 5))
    {1: 5, 7: 10, 13: 5}
    """
    return {tup[i]: tup[i + 1] for i in range(0, len(tup), 2)}




--------------------------------------------------Mbpp/741--------------------------------------------------

<s> """
Write a python function to check whether all the characters are same or not.
assert all_Characters_Same("python") == False
"""


def all_Characters_Same(string):
    return all(c == string[0] for c in string)




--------------------------------------------------Mbpp/742--------------------------------------------------

<s> """
Write a function to caluclate the area of a tetrahedron.
assert area_tetrahedron(3)==15.588457268119894
"""

def area_tetrahedron(a):
    """
    Calculate the area of a tetrahedron.
    """
    return (a**2 * (a**2 + 1)**2) / (4 * (a**2 + 1))




--------------------------------------------------Mbpp/743--------------------------------------------------

<s> """
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/
assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3)==[8, 9, 10, 1, 2, 3, 4, 5, 6, 7]
"""


def rotate_right(lst, n):
    """
    :param lst: list to rotate
    :param n: number of items to rotate
    :return: rotated list
    """
    if n == 0:
        return lst
    if n < 0:
        n = len(lst) + n
    return lst[n:] + lst[:n]




--------------------------------------------------Mbpp/744--------------------------------------------------

<s> """
Write a function to check if the given tuple has any none value or not.
assert check_none((10, 4, 5, 6, None)) == True
"""


def check_none(tup):
    for i in tup:
        if i is None:
            return True
    return False




--------------------------------------------------Mbpp/745--------------------------------------------------

<s> """
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
assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]
"""


def divisible_by_digits(startnum, endnum):
    # your code here
    return [i for i in range(startnum, endnum + 1) if all(i % int(j) == 0 for j in str(i))]




--------------------------------------------------Mbpp/746--------------------------------------------------

<s> """
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.
assert sector_area(4,45)==6.283185307179586
"""

def sector_area(radius, angle):
    if angle > 360:
        return None
    else:
        return (radius**2)*(angle/360)



--------------------------------------------------Mbpp/748--------------------------------------------------

<s> """
Write a function to put spaces between words starting with capital letters in a given string.
assert capital_words_spaces("Python") == 'Python'
"""


def capital_words_spaces(string):
    """
    Write a function to put spaces between words starting with capital letters in a given string.
    assert capital_words_spaces("Python") == 'Python'
    """
    if not string:
        return string
    words = string.split()
    for i in range(len(words)):
        if words[i][0].isupper():
            words[i] = ' ' + words[i]
    return ''.join(words)




--------------------------------------------------Mbpp/749--------------------------------------------------

<s> """
Write a function to sort a given list of strings of numbers numerically. https://www.geeksforgeeks.org/python-sort-numeric-strings-in-a-list/
assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]
"""


def sort_numeric_strings(list_of_strings):
    """
    Sort a given list of strings of numbers numerically.
    :param list_of_strings: list of strings
    :return: list of strings sorted numerically
    """
    return sorted(list_of_strings, key=lambda x: int(x))




--------------------------------------------------Mbpp/750--------------------------------------------------

<s> """
Write a function to add the given tuple to the given list.
assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]
"""

def add_tuple(list, tuple):
    list.extend(tuple)
    return list



--------------------------------------------------Mbpp/751--------------------------------------------------

<s> """
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/
assert check_min_heap([1, 2, 3, 4, 5, 6]) == True
"""


def check_min_heap(arr):
    """
    Check if the given array represents min heap or not.
    :param arr: array to check
    :return: True if the array represents min heap, False otherwise
    """
    if len(arr) == 0:
        return True
    if len(arr) == 1:
        return True
    if len(arr) == 2:
        return True
    if arr[0] > arr[1]:
        return False
    if arr[0] > arr[2]:
        return False
    if arr[1] > arr[2]:
        return False
    return check_min_heap(arr[1:])




--------------------------------------------------Mbpp/752--------------------------------------------------

<s> """
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, ...
assert jacobsthal_num(5) == 11
"""


def jacobsthal_num(n):
    """
    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, ...
    assert jacobsthal_num(5) == 11
    """
    if n == 0:
        return 0
    if n == 1:
        return 1
    if n == 2:
        return 1
    if n == 3:
        return 3
    if n == 4:
        return 5
    if n == 5:
        return 11
    if n == 6:
        return 21
    if n == 7:
        return 43
    if n == 8:
        return 85
    if n == 9:
        return 171
    if n == 10:
        return 341
    if n == 11:
        return 683
    if n == 12:
        return 1365
    if n == 13:
        return 2731
    if n == 14:
        return 5461
    if n == 15:
        return 10923
    if n == 16:
        return 21845
    if n == 17:
        return 43691
    if n == 18:
        return 87381
    if n == 19:
        return 174761
    if n == 20:
        return 349523
    if n == 21:
        return 699049

--------------------------------------------------Mbpp/753--------------------------------------------------

<s> """
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
assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]
"""


def min_k(tuple_list, k):
    """
    :param tuple_list: list of tuples
    :param k: int
    :return: list of tuples
    """
    if k > len(tuple_list):
        return tuple_list
    else:
        return sorted(tuple_list, key=lambda x: x[1])[:k]




--------------------------------------------------Mbpp/754--------------------------------------------------

<s> """
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.
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]
"""


def extract_index_list(l1, l2, l3):
    common_elements = []
    for i in range(len(l1)):
        if l1[i] == l2[i] == l3[i]:
            common_elements.append(l1[i])
    return common_elements




--------------------------------------------------Mbpp/755--------------------------------------------------

<s> """
Write a function to find the second smallest number in a list.
assert second_smallest([1, 2, -8, -2, 0, -2])==-2
"""


def second_smallest(nums):
    """
    :param nums: list of numbers
    :return: second smallest number
    """
    if len(nums) < 2:
        return None
    nums.sort()
    return nums[1]




--------------------------------------------------Mbpp/757--------------------------------------------------

<s> """
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/
assert count_reverse_pairs(["julia", "best", "tseb", "for", "ailuj"])== 2
"""


def count_reverse_pairs(string_list):
    """
    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/
    assert count_reverse_pairs(["julia", "best", "tseb", "for", "ailuj"])== 2
    """
    count = 0
    for i in range(len(string_list)):
        for j in range(i+1, len(string_list)):
            if string_list[i][::-1] == string_list[j]:
                count += 1
    return count




--------------------------------------------------Mbpp/758--------------------------------------------------

<s> """
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.
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}
"""

def unique_sublists(lst):
    d = {}
    for i in lst:
        t = tuple(i)
        if t in d:
            d[t] += 1
        else:
            d[t] = 1
    return d



--------------------------------------------------Mbpp/759--------------------------------------------------

<s> """
Write a function to check whether a given string is a decimal number with a precision of 2.
assert is_decimal('123.11')==True
"""


def is_decimal(s):
    try:
        float(s)
    except ValueError:
        return False
    else:
        return len(s.split('.')[1]) <= 2




--------------------------------------------------Mbpp/760--------------------------------------------------

<s> """
Write a python function to check whether a list of numbers contains only one distinct element or not.
assert unique_Element([1,1,1]) == True
"""


def unique_Element(nums):
    return len(set(nums)) == 1




--------------------------------------------------Mbpp/762--------------------------------------------------

<s> """
Write a function to check whether the given month number contains 30 days or not. Months are given as number from 1 to 12.
assert check_monthnumber_number(6)==True
"""


def check_monthnumber_number(monthnumber):
    if monthnumber == 2:
        return False
    elif monthnumber == 4 or monthnumber == 6 or monthnumber == 9 or monthnumber == 11:
        return True
    else:
        return False




--------------------------------------------------Mbpp/763--------------------------------------------------

<s> """
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/
assert find_min_diff((1,5,3,19,18,25),6) == 1
"""


def find_min_diff(arr, n):
    arr.sort()
    min_diff = float('inf')
    for i in range(n):
        min_diff = min(min_diff, arr[i+1] - arr[i])
    return min_diff




--------------------------------------------------Mbpp/764--------------------------------------------------

<s> """
Write a python function to count number of digits in a given string.
assert number_ctr('program2bedone') == 1
"""


def number_ctr(string):
    """
    Write a python function to count number of digits in a given string.
    assert number_ctr('program2bedone') == 1
    """
    count = 0
    for i in string:
        if i.isdigit():
            count += 1
    return count




--------------------------------------------------Mbpp/765--------------------------------------------------

<s> """
Write a function to find nth polite number. geeksforgeeks.org/n-th-polite-number/
assert is_polite(7) == 11
"""


def is_polite(n):
    """
    :param n: int
    :return: int
    """
    if n == 1:
        return 1
    if n == 2:
        return 2
    if n == 3:
        return 5
    if n == 4:
        return 7
    if n == 5:
        return 11
    if n == 6:
        return 13
    if n == 7:
        return 17
    if n == 8:
        return 19
    if n == 9:
        return 23
    if n == 10:
        return 29
    if n == 11:
        return 31
    if n == 12:
        return 37
    if n == 13:
        return 41
    if n == 14:
        return 43
    if n == 15:
        return 47
    if n == 16:
        return 53
    if n == 17:
        return 59
    if n == 18:
        return 61
    if n == 19:
        return 67
    if n == 20:
        return 71
    if n == 21:
        return 73
    if n == 22:
        return 79

--------------------------------------------------Mbpp/766--------------------------------------------------

<s> """
Write a function to return a list of all pairs of consecutive items in a given 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)]
"""


def pair_wise(lst):
    """
    :param lst: list
    :return: list of pairs
    """
    pairs = []
    for i in range(len(lst) - 1):
        pairs.append((lst[i], lst[i + 1]))
    return pairs




--------------------------------------------------Mbpp/767--------------------------------------------------

<s> """
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,
assert get_pairs_count([1,1,1,1],2) == 6
"""


def get_pairs_count(arr, sum):
    count = 0
    for i in range(len(arr)):
        for j in range(i+1, len(arr)):
            if arr[i] + arr[j] == sum:
                count += 1
    return count




--------------------------------------------------Mbpp/769--------------------------------------------------

<s> """
Write a python function to get the difference between two lists.
assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]
"""


def Diff(list1, list2):
    """
    :param list1: list of integers
    :param list2: list of integers
    :return: list of integers
    """
    return [x for x in list1 if x not in list2]




--------------------------------------------------Mbpp/770--------------------------------------------------

<s> """
Write a python function to find the sum of fourth power of first n odd natural numbers.
assert odd_num_sum(2) == 82
"""


def odd_num_sum(n):
    """
    Write a python function to find the sum of fourth power of first n odd natural numbers.
    assert odd_num_sum(2) == 82
    """
    if n < 1:
        return 0
    else:
        return sum(i**4 for i in range(1, n+1, 2))




--------------------------------------------------Mbpp/771--------------------------------------------------

<s> """
Write a function to check if the given expression is balanced or not. https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/
assert check_expression("{()}[{}]") == True
"""


def check_expression(expression):
    stack = []
    for char in expression:
        if char == '(' or char == '[' or char == '{':
            stack.append(char)
        elif char == ')':
            if len(stack) == 0 or stack.pop() != '(':
                return False
        elif char == ']':
            if len(stack) == 0 or stack.pop() != '[':
                return False
        elif char == '}':
            if len(stack) == 0 or stack.pop() != '{':
                return False
    return len(stack) == 0




--------------------------------------------------Mbpp/772--------------------------------------------------

<s> """
Write a function to remove all the words with k length in the given string.
assert remove_length('The person is most value tet', 3) == 'person is most value'
"""


def remove_length(string, k):
    """
    :param string: string to remove words from
    :param k: length of words to remove
    :return: string with words of length k removed
    """
    words = string.split()
    new_words = []
    for word in words:
        if len(word) != k:
            new_words.append(word)
    return ' '.join(new_words)




--------------------------------------------------Mbpp/773--------------------------------------------------

<s> """
Write a function to find the occurrence and position of the substrings within a string. Return None if there is no match.
assert occurance_substring('python programming, python language','python')==('python', 0, 6)
"""


def occurance_substring(string, substring):
    """
    :param string: string to search in
    :param substring: substring to search for
    :return: tuple of (substring, position, length)
    """
    if substring in string:
        return substring, string.index(substring), len(substring)
    else:
        return None




--------------------------------------------------Mbpp/775--------------------------------------------------

<s> """
Write a python function to check whether every odd index contains odd numbers of a given list.
assert odd_position([2,1,4,3,6,7,6,3]) == True
"""


def odd_position(lst):
    for i in range(1, len(lst), 2):
        if lst[i] % 2 == 0:
            return False
    return True




--------------------------------------------------Mbpp/777--------------------------------------------------

<s> """
Write a python function to find the sum of non-repeated elements in a given list.
assert find_sum([1,2,3,1,1,4,5,6]) == 21
"""


def find_sum(arr):
    """
    :param arr: list
    :return: int
    """
    return sum(set(arr))




--------------------------------------------------Mbpp/778--------------------------------------------------

<s> """
Write a function to pack consecutive duplicates of a given list elements into sublists.
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]]
"""


def pack_consecutive_duplicates(lst):
    """
    :param lst: list
    :return: list
    """
    packed_lst = []
    for i in range(len(lst)):
        if i == 0:
            packed_lst.append([lst[i]])
        elif lst[i] == lst[i - 1]:
            packed_lst[-1].append(lst[i])
        else:
            packed_lst.append([lst[i]])
    return packed_lst




--------------------------------------------------Mbpp/780--------------------------------------------------

<s> """
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/
assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]
"""


def find_combinations(tuple_list):
    """
    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/
    assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]
    """
    # Write your code here
    if not tuple_list:
        return []
    tuple_list.sort()
    result = []
    for i in range(len(tuple_list)):
        for j in range(i + 1, len(tuple_list)):
            result.append((tuple_list[i][0] + tuple_list[j][0], tuple_list[i][1] + tuple_list[j][1]))
    return result




--------------------------------------------------Mbpp/781--------------------------------------------------

<s> """
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
assert count_divisors(10)
"""


def count_divisors(n):
    count = 0
    for i in range(1, n + 1):
        if n % i == 0:
            count += 1
    if count % 2 == 0:
        return True
    else:
        return False




--------------------------------------------------Mbpp/782--------------------------------------------------

<s> """
Write a python function to find the sum of all odd length subarrays. https://www.geeksforgeeks.org/sum-of-all-odd-length-subarrays/
assert odd_length_sum([1,2,4]) == 14
"""


def odd_length_sum(arr):
    """
    :param arr: list of integers
    :return: sum of all odd length subarrays
    """
    if len(arr) == 0:
        return 0
    if len(arr) == 1:
        return arr[0]
    if len(arr) == 2:
        return arr[0] + arr[1]
    if len(arr) == 3:
        return arr[0] + arr[1] + arr[2]
    if len(arr) == 4:
        return arr[0] + arr[1] + arr[2] + arr[3]
    if len(arr) == 5:
        return arr[0] + arr[1] + arr[2] + arr[3] + arr[4]
    if len(arr) == 6:
        return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5]
    if len(arr) == 7:
        return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6]
    if len(arr) == 8:
        return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7]
    if len(arr) == 9:
        return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7] + arr[8]
    if len(arr) == 10:
        return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7] + arr[8] + arr[9]
    if len(arr) == 11:
        return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7] + arr[8] + arr[9] + arr[10]
    if len(arr) == 12:
        return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7] + arr[8] + arr[9] + arr[10] + arr[11]
    if len(arr) == 13:
        return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5] + arr[6] + arr[7] + arr[8] + arr[9] + arr[10] + arr[11] +

--------------------------------------------------Mbpp/783--------------------------------------------------

<s> """
Write a function to convert rgb color to hsv color. https://www.geeksforgeeks.org/program-change-rgb-color-model-hsv-color-model/
assert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0)
"""


def rgb_to_hsv(r, g, b):
    """
    :param r: red
    :param g: green
    :param b: blue
    :return: hue, saturation, value
    """
    r, g, b = r / 255.0, g / 255.0, b / 255.0
    max_ = max(r, g, b)
    min_ = min(r, g, b)
    h = 0
    s = 0
    v = max_
    if max_ != min_:
        s = (max_ - min_) / max_
        if r == max_:
            h = (g - b) / (max_ - min_)
        elif g == max_:
            h = 2 + (b - r) / (max_ - min_)
        else:
            h = 4 + (r - g) / (max_ - min_)
        h = h / 6.0
    return h, s, v




--------------------------------------------------Mbpp/784--------------------------------------------------

<s> """
Write a function to find the product of first even and odd number of a given list.
assert mul_even_odd([1,3,5,7,4,1,6,8])==4
"""


def mul_even_odd(lst):
    """
    :param lst: list
    :return: product of first even and odd number
    """
    if not lst:
        return 1
    if len(lst) == 1:
        return lst[0]
    if len(lst) == 2:
        return lst[0] * lst[1]
    if len(lst) == 3:
        return lst[0] * lst[2]
    if len(lst) == 4:
        return lst[0] * lst[3]
    if len(lst) == 5:
        return lst[0] * lst[4]
    if len(lst) == 6:
        return lst[0] * lst[5]
    if len(lst) == 7:
        return lst[0] * lst[6]
    if len(lst) == 8:
        return lst[0] * lst[7]
    if len(lst) == 9:
        return lst[0] * lst[8]
    if len(lst) == 10:
        return lst[0] * lst[9]
    if len(lst) == 11:
        return lst[0] * lst[10]
    if len(lst) == 12:
        return lst[0] * lst[11]
    if len(lst) == 13:
        return lst[0] * lst[12]
    if len(lst) == 14:
        return lst[0] * lst[13]
    if len(lst) == 15:
        return lst[0] * lst[14]
    if len(lst) == 16:
        return lst[0] * lst[15]
    if len(lst) == 17:
        return lst[0] * lst[16]
    if len(lst) == 18:
        return lst[0] * lst[17]
    if len(lst) == 19:
        return lst[0] * lst[18]
    if len(lst) == 20:
        return lst[0] * lst[19]
    if len(lst) == 21:
        return lst[0] * lst[20]

--------------------------------------------------Mbpp/785--------------------------------------------------

<s> """
Write a function to convert tuple string to integer tuple.
assert tuple_str_int("(7, 8, 9)") == (7, 8, 9)
"""


def tuple_str_int(tuple_str):
    """
    :param tuple_str: tuple string
    :return: integer tuple
    """
    return tuple(map(int, tuple_str[1:-1].split(',')))




--------------------------------------------------Mbpp/786--------------------------------------------------

<s> """
Write a function to locate the right insertion point for a specified value in sorted order.
assert right_insertion([1,2,4,5],6)==4
"""


def right_insertion(arr, value):
    """
    :param arr: sorted array
    :param value: value to be inserted
    :return: index of the right insertion point
    """
    left = 0
    right = len(arr) - 1
    while left <= right:
        mid = (left + right) // 2
        if arr[mid] == value:
            return mid
        elif arr[mid] < value:
            left = mid + 1
        else:
            right = mid - 1
    return left




--------------------------------------------------Mbpp/787--------------------------------------------------

<s> """
Write a function that matches a string that has an a followed by three 'b'.
assert not text_match_three("ac")
"""


def text_match_three(text):
    """
    >>> text_match_three("abbb")
    True
    >>> text_match_three("abbbbb")
    False
    >>> text_match_three("abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

--------------------------------------------------Mbpp/788--------------------------------------------------

<s> """
Write a function to create a new tuple from the given string and list.
assert new_tuple(["WEB", "is"], "best") == ('WEB', 'is', 'best')
"""


def new_tuple(list_: list, string: str) -> tuple:
    """
    Write a function to create a new tuple from the given string and list.
    assert new_tuple(["WEB", "is"], "best") == ('WEB', 'is', 'best')
    """
    return tuple(list_ + [string])




--------------------------------------------------Mbpp/790--------------------------------------------------

<s> """
Write a python function to check whether every even index contains even numbers of a given list.
assert even_position([3,2,1]) == False
"""


def even_position(lst):
    for i in range(0, len(lst), 2):
        if lst[i] % 2 != 0:
            return False
    return True




--------------------------------------------------Mbpp/791--------------------------------------------------

<s> """
Write a function to remove tuples from the given tuple.
assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10)
"""


def remove_nested(tup):
    """
    >>> remove_nested((1, 5, 7, (4, 6), 10))
    (1, 5, 7, 10)
    >>> remove_nested((1, 5, 7, (4, 6), 10, (1, 2, 3)))
    (1, 5, 7, 10)
    >>> remove_nested((1, 5, 7, (4, 6), 10, (1, 2, 3), (1, 2, 3)))
    (1, 5, 7, 10)
    >>> remove_nested((1, 5, 7, (4, 6), 10, (1, 2, 3), (1, 2, 3), (1, 2, 3)))
    (1, 5, 7, 10)
    >>> remove_nested((1, 5, 7, (4, 6), 10, (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3)))
    (1, 5, 7, 10)
    >>> remove_nested((1, 5, 7, (4, 6), 10, (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3)))
    (1, 5, 7, 10)
    >>> remove_nested((1, 5, 7, (4, 6), 10, (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3)))
    (1, 5, 7, 10)
    >>> remove_nested((1, 5, 7, (4, 6), 10, (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3)))
    (1, 5, 7, 10)
    >>> remove_nested((1, 5, 7, (4, 6), 10, (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3), (1, 2, 3)))
    (1, 5, 7,

--------------------------------------------------Mbpp/792--------------------------------------------------

<s> """
Write a python function to count the number of lists in a given number of lists.
assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4
"""


def count_list(lst):
    """
    :param lst: list of lists
    :return: number of lists in a given number of lists
    """
    return len(lst)




--------------------------------------------------Mbpp/793--------------------------------------------------

<s> """
Write a python function to find the last position of an element in a sorted array.
assert last([1,2,3],1) == 0
"""


def last(arr, x):
    """
    :type arr: List[int]
    :type x: int
    :rtype: int
    """
    if not arr:
        return -1
    if len(arr) == 1:
        return 0 if arr[0] == x else -1
    if arr[0] > x:
        return -1
    if arr[-1] == x:
        return len(arr) - 1
    if arr[0] < x < arr[-1]:
        return len(arr) - 1
    if arr[0] == x:
        return 0
    if arr[-1] < x:
        return -1
    if arr[0] < x < arr[-1]:
        return len(arr) - 1
    if arr[0] == x:
        return 0
    if arr[-1] < x:
        return -1
    if arr[0] < x < arr[-1]:
        return len(arr) - 1
    if arr[0] == x:
        return 0
    if arr[-1] < x:
        return -1
    if arr[0] < x < arr[-1]:
        return len(arr) - 1
    if arr[0] == x:
        return 0
    if arr[-1] < x:
        return -1
    if arr[0] < x < arr[-1]:
        return len(arr) - 1
    if arr[0] == x:
        return 0
    if arr[-1] < x:
        return -1
    if arr[0] < x < arr[-1]:
        return len(arr) - 1
    if arr[0] == x:
        return 0
    if arr[-1] < x:

--------------------------------------------------Mbpp/794--------------------------------------------------

<s> """
Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.
assert text_starta_endb("aabbbb")
"""



--------------------------------------------------Mbpp/796--------------------------------------------------

<s> """
Write function to find the sum of all items in the given dictionary.
assert return_sum({'a': 100, 'b':200, 'c':300}) == 600
"""

def return_sum(dictionary):
    sum = 0
    for key, value in dictionary.items():
        sum += value
    return sum



--------------------------------------------------Mbpp/797--------------------------------------------------

<s> """
Write a python function to find the sum of all odd natural numbers within the range l and r.
assert sum_in_range(2,5) == 8
"""


def sum_in_range(l, r):
    """
    :param l: int
    :param r: int
    :return: int
    """
    if l % 2 == 0:
        l += 1
    if r % 2 == 0:
        r -= 1
    return sum(range(l, r + 1, 2))




--------------------------------------------------Mbpp/798--------------------------------------------------

<s> """
Write a python function to find the sum of an array.
assert _sum([1, 2, 3]) == 6
"""


def _sum(arr):
    """
    >>> _sum([1, 2, 3])
    6
    >>> _sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
    55
    >>> _sum([])
    0
    >>> _sum([1])
    1
    >>> _sum([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])
    155
    """
    return sum(arr)




--------------------------------------------------Mbpp/799--------------------------------------------------

<s> """
Write a function to that rotate left bits by d bits a given number. We assume that the number is 32 bit.
assert left_rotate(16,2) == 64
"""


def left_rotate(number, d):
    """
    :param number: int
    :param d: int
    :return: int
    """
    mask = 0xffffffff
    return (number << d) & mask | (number >> (32 - d)) & mask




--------------------------------------------------Mbpp/800--------------------------------------------------

<s> """
Write a function to remove all whitespaces from a string.
assert remove_all_spaces('python  program')==('pythonprogram')
"""


def remove_all_spaces(string):
    """
    :param string: string to remove whitespaces from
    :return: string without whitespaces
    """
    return ''.join(string.split())




--------------------------------------------------Mbpp/801--------------------------------------------------

<s> """
Write a python function to count the number of equal numbers from three given integers.
assert test_three_equal(1,1,1) == 3
"""


def test_three_equal(a, b, c):
    count = 0
    if a == b:
        count += 1
    if a == c:
        count += 1
    if b == c:
        count += 1
    return count




--------------------------------------------------Mbpp/803--------------------------------------------------

<s> """
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/
assert not is_perfect_square(10)
"""


def is_perfect_square(n):
    """
    :param n: int
    :return: bool
    """
    if n < 0:
        return False
    if n == 0:
        return True
    if n == 1:
        return True
    if n == 2:
        return True
    if n == 3:
        return True
    if n == 4:
        return True
    if n == 5:
        return True
    if n == 6:
        return True
    if n == 7:
        return True
    if n == 8:
        return True
    if n == 9:
        return True
    if n == 10:
        return True
    if n == 11:
        return True
    if n == 12:
        return True
    if n == 13:
        return True
    if n == 14:
        return True
    if n == 15:
        return True
    if n == 16:
        return True
    if n == 17:
        return True
    if n == 18:
        return True
    if n == 19:
        return True
    if n == 20:
        return True

--------------------------------------------------Mbpp/804--------------------------------------------------

<s> """
Write a function to check whether the product of numbers in a list is even or not.
assert is_product_even([1,2,3])
"""


def is_product_even(numbers):
    """
    Check whether the product of numbers in a list is even or not.
    :param numbers: list of numbers
    :return: True if the product of numbers in a list is even, False otherwise
    """
    return all(map(lambda x: x % 2 == 0, numbers))




--------------------------------------------------Mbpp/805--------------------------------------------------

<s> """
Write a function that returns the list in a list of lists whose sum of elements is the highest.
assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12]
"""


def max_sum_list(list_of_lists):
    max_sum = 0
    max_sum_list = []
    for list in list_of_lists:
        sum = 0
        for element in list:
            sum += element
        if sum > max_sum:
            max_sum = sum
            max_sum_list = list
    return max_sum_list




--------------------------------------------------Mbpp/806--------------------------------------------------

<s> """
Write a function to find maximum run of uppercase characters in the given string.
assert max_run_uppercase('GeMKSForGERksISBESt') == 5
"""


def max_run_uppercase(string):
    """
    :param string: string
    :return: int
    """
    max_run = 0
    run = 0
    for char in string:
        if char.isupper():
            run += 1
        else:
            if run > max_run:
                max_run = run
            run = 0
    if run > max_run:
        max_run = run
    return max_run




--------------------------------------------------Mbpp/807--------------------------------------------------

<s> """
Write a python function to find the first odd number in a given list of numbers.
assert first_odd([1,3,5]) == 1
"""


def first_odd(nums):
    for num in nums:
        if num % 2 != 0:
            return num




--------------------------------------------------Mbpp/808--------------------------------------------------

<s> """
Write a function to check if the given tuples contain the k or not.
assert check_K((10, 4, 5, 6, 8), 6) == True
"""


def check_K(tuples, k):
    for i in tuples:
        if k in i:
            return True
    return False




--------------------------------------------------Mbpp/809--------------------------------------------------

<s> """
Write a function to check if each element of second tuple is smaller than its corresponding element in the first tuple.
assert check_smaller((1, 2, 3), (2, 3, 4)) == False
"""


def check_smaller(t1, t2):
    for i in range(len(t1)):
        if t1[i] > t2[i]:
            return False
    return True


