

--------------------------------------------------Mbpp/2--------------------------------------------------

"""
Write a function to find the shared elements from the given two lists.
assert set(similar_elements((3, 4, 5, 6),(5, 7, 4, 10))) == set((4, 5))
"""

def similar_elements(l1, l2):
    """
    :param l1: list of numbers
    :param l2: list of numbers
    :return: set of numbers
    """
    return set(l1) & set(l2)



--------------------------------------------------Mbpp/3--------------------------------------------------

"""
Write a python function to identify non-prime numbers.
assert is_not_prime(2) == False
"""

def is_not_prime(num):
    """
    Assert that num is not prime.
    """
    assert num > 0, "num must be positive"
    assert num % 2 == 0, "num must be even"
    assert num > 1, "num must be greater than 1"
    for i in range(3, int(num**0.5) + 1, 2):
        if num % i == 0:
            return False
    return True



--------------------------------------------------Mbpp/4--------------------------------------------------

"""
Write a function to find the n largest integers from a given list of numbers, returned in descending order.
assert heap_queue_largest( [25, 35, 22, 85, 14, 65, 75, 22, 58],3)==[85, 75, 65]
"""

def heap_queue_largest(nums, n):
    heap = []
    for i in range(n):
        heapq.heappush(heap, nums[i])
    for i in range(n-1, -1, -1):
        heapq.heappop(heap)
    return heap



--------------------------------------------------Mbpp/6--------------------------------------------------

"""
Write a python function to check whether the two numbers differ at one bit position only or not.
assert differ_At_One_Bit_Pos(13,9) == True
"""

def differ_At_One_Bit_Pos(num1, num2):
    if num1 == num2:
        return False
    if num1 > num2:
        return True
    else:
        return False



--------------------------------------------------Mbpp/7--------------------------------------------------

"""
Write a function to find all words which are at least 4 characters long in a string.
assert set(find_char_long('Please move back to stream')) == set(['Please','move', 'back','stream'])
"""

def find_char_long(string):
    """
    :type string: str
    :rtype: set
    """
    char_long = set()
    for word in string.split():
        if len(word) >= 4:
            char_long.add(word)
    return char_long



--------------------------------------------------Mbpp/8--------------------------------------------------

"""
Write a function to find squares of individual elements in a list.
assert square_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
"""

def square_nums(nums):
    """
    :param nums: list of numbers
    :return: list of squares of individual elements in nums
    """
    squares = []
    for num in nums:
        squares.append(num**2)
    return squares



--------------------------------------------------Mbpp/9--------------------------------------------------

"""
Write a python function to find the minimum number of rotations (greater than 0) required to get the same string.
assert find_Rotations("aaaa") == 1
"""

def find_Rotations(str):
    count = 0
    for i in range(len(str)):
        if str[i] == str[i+1]:
            count += 1
        else:
            count = 0
            break
    return count



--------------------------------------------------Mbpp/11--------------------------------------------------

"""
Write a python function to remove first and last occurrence of a given character from the string.
assert remove_Occ("hello","l") == "heo"
"""
def remove_Occ(str,ch):
    if ch in str:
        str = str.replace(ch,"")
    return str



--------------------------------------------------Mbpp/12--------------------------------------------------

"""
Write a function to sort a given matrix in ascending order according to the sum of its rows.
assert sort_matrix([[1, 2, 3], [2, 4, 5], [1, 1, 1]])==[[1, 1, 1], [1, 2, 3], [2, 4, 5]]
"""

def sort_matrix(matrix):
    sum_rows = 0
    for row in matrix:
        sum_rows += sum(row)
    for row in matrix:
        row.sort(reverse=True)
    return matrix



--------------------------------------------------Mbpp/14--------------------------------------------------

"""
Write a python function to find the volume of a triangular prism.
assert find_Volume(10,8,6) == 240
"""



--------------------------------------------------Mbpp/16--------------------------------------------------

"""
Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise.
assert text_lowercase_underscore("aab_cbbbc")==(True)
"""
def text_lowercase_underscore(text):
    if len(text) == 0:
        return False
    if len(text) == 1:
        return True
    if text[0] == '_':
        return True
    else:
        return False



--------------------------------------------------Mbpp/17--------------------------------------------------

"""
Write a function that returns the perimeter of a square given its side length as input.
assert square_perimeter(10)==40
"""

def square_perimeter(side):
    return side * 4



--------------------------------------------------Mbpp/18--------------------------------------------------

"""
Write a function to remove characters from the first string which are present in the second string.
assert remove_dirty_chars("probasscurve", "pros") == 'bacuve'
"""
def remove_dirty_chars(first, second):
    for i in range(len(second)):
        if second[i] in first:
            first = first.replace(second[i], "")
    return first



--------------------------------------------------Mbpp/19--------------------------------------------------

"""
Write a function to find whether a given array of integers contains any duplicate element.
assert test_duplicate(([1,2,3,4,5]))==False
"""
def test_duplicate(arr):
    for i in arr:
        if arr.count(i) > 1:
            return True
    return False



--------------------------------------------------Mbpp/20--------------------------------------------------

"""
Write a function to check if the given number is woodball or not.
assert is_woodall(383) == True
"""

def is_woodball(number):
    if number % 2 == 0:
        return True
    else:
        return False



--------------------------------------------------Mbpp/56--------------------------------------------------

"""
Write a python function to check if a given number is one less than twice its reverse.
assert check(70) == False
"""

def check(n):
    rev = n[::-1]
    if n == rev:
        return True
    else:
        return False



--------------------------------------------------Mbpp/57--------------------------------------------------

"""
Write a python function to find the largest number that can be formed with the given list of digits.
assert find_Max_Num([1,2,3]) == 321
"""
def find_Max_Num(lst):
    max_num = lst[0]
    for i in range(len(lst)):
        if lst[i] > max_num:
            max_num = lst[i]
    return max_num



--------------------------------------------------Mbpp/58--------------------------------------------------

"""
Write a python function to check whether the given two integers have opposite sign or not.
assert opposite_Signs(1,-2) == True
"""
def opposite_Signs(a,b):
    if a < 0 and b < 0:
        return True
    elif a > 0 and b > 0:
        return True
    else:
        return False



--------------------------------------------------Mbpp/59--------------------------------------------------

"""
Write a function to find the nth octagonal number.
assert is_octagonal(5) == 65
"""

def is_octagonal(n):
    if n == 1:
        return True
    elif n == 2:
        return True
    elif n == 3:
        return True
    elif n == 4:
        return True
    elif n == 5:
        return True
    elif n == 6:
        return True
    elif n == 7:
        return True
    elif n == 8:
        return True
    elif n == 9:
        return True
    elif n == 10:
        return True
    elif n == 11:
        return True
    elif n == 12:
        return True
    elif n == 13:
        return True
    elif n == 14:
        return True
    elif n == 15:
        return True
    elif n == 16:
        return True
    elif n == 17:
        return True
    elif n == 18:
        return True
    elif n == 19:
        return True
    elif n == 20:
        return True
    elif n == 21:
        return True
    elif n == 22:
        return True
    elif n == 23:
        return True
    elif n == 24:
        return True
    elif n == 25:

--------------------------------------------------Mbpp/61--------------------------------------------------

"""
Write a python function to count the number of substrings with the sum of digits equal to their length.
assert count_Substrings('112112') == 6
"""

def count_Substrings(str):
    count = 0
    for i in range(len(str)):
        for j in range(i+1, len(str)):
            if int(str[i:j]) == int(str[i:j][::-1]):
                count += 1
    return count



--------------------------------------------------Mbpp/62--------------------------------------------------

"""
Write a python function to find smallest number in a list.
assert smallest_num([10, 20, 1, 45, 99]) == 1
"""

def smallest_num(lst):
    smallest = lst[0]
    for i in lst:
        if i < smallest:
            smallest = i
    return smallest



--------------------------------------------------Mbpp/63--------------------------------------------------

"""
Write a function to find the maximum difference between available pairs in the given tuple list.
assert max_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 7
"""

def max_difference(tuple_list):
    """
    :param tuple_list: tuple of tuples
    :return: maximum difference between available pairs
    """
    max_difference = 0
    for i in range(len(tuple_list) - 1):
        for j in range(i + 1, len(tuple_list)):
            difference = tuple_list[i][1] - tuple_list[j][1]
            if difference > max_difference:
                max_difference = difference
    return max_difference



--------------------------------------------------Mbpp/64--------------------------------------------------

"""
Write a function to sort a list of tuples using the second value of each tuple.
assert subject_marks([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])==[('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]
"""
def sort_tuples(subject_marks):
    subject_marks.sort(key=lambda x: x[1])
    return subject_marks



--------------------------------------------------Mbpp/65--------------------------------------------------

"""
Write a function to flatten a list and sum all of its elements.
assert recursive_list_sum(([1, 2, [3,4],[5,6]]))==21
"""
def recursive_list_sum(lst):
    if len(lst) == 0:
        return 0
    else:
        return recursive_list_sum(lst[1:]) + lst[0]



--------------------------------------------------Mbpp/66--------------------------------------------------

"""
Write a python function to count the number of positive numbers in a list.
assert pos_count([1,-2,3,-4]) == 2
"""
def pos_count(list):
    count = 0
    for i in list:
        if i > 0:
            count += 1
    return count



--------------------------------------------------Mbpp/67--------------------------------------------------

"""
Write a function to find the number of ways to partition a set of Bell numbers.
assert bell_number(2)==2
"""
def bell_number(n):
    if n==1:
        return 1
    if n==2:
        return 2
    if n==3:
        return 4
    if n==4:
        return 8
    if n==5:
        return 16
    if n==6:
        return 32
    if n==7:
        return 64
    if n==8:
        return 128
    if n==9:
        return 256
    if n==10:
        return 512
    if n==11:
        return 1024
    if n==12:
        return 2048
    if n==13:
        return 4096
    if n==14:
        return 8192
    if n==15:
        return 16384
    if n==16:
        return 32768
    if n==17:
        return 65536
    if n==18:
        return 131072
    if n==19:
        return 262144
    if n==20:
        return 524288
    if n==21:
        return 1048576
    if n==22:
        return 2097152
    if n==23:
        return 4194304
    if n==24:
        return 8388608
    if n==25:
        return 16777216

--------------------------------------------------Mbpp/68--------------------------------------------------

"""
Write a python function to check whether the given array is monotonic or not.
assert is_Monotonic([6, 5, 4, 4]) == True
"""

def is_Monotonic(arr):
    if len(arr) == 1:
        return True
    if arr[0] < arr[1]:
        return False
    if arr[0] > arr[1]:
        return False
    for i in range(1, len(arr)):
        if arr[i] < arr[i - 1]:
            return False
    return True



--------------------------------------------------Mbpp/69--------------------------------------------------

"""
Write a function to check whether a list contains the given sublist or not.
assert is_sublist([2,4,3,5,7],[3,7])==False
"""
def is_sublist(lst, sublist):
    for i in range(len(lst)):
        if lst[i] not in sublist:
            return False
    return True



--------------------------------------------------Mbpp/70--------------------------------------------------

"""
Write a function to find whether all the given tuples have equal length or not.
assert get_equal([(11, 22, 33), (44, 55, 66)]) == True
"""

def get_equal(tuples):
    for i in range(len(tuples)):
        if len(tuples[i])!= len(set(tuples[i])):
            return False
    return True



--------------------------------------------------Mbpp/71--------------------------------------------------

"""
Write a function to sort a list of elements.
assert comb_sort([5, 15, 37, 25, 79]) == [5, 15, 25, 37, 79]
"""

def comb_sort(elements):
    """
    Sort the elements of a list using the Comb Sort algorithm.
    """
    # Create a new list to store the sorted elements
    sorted_list = []

    # Create a variable to store the number of elements
    n = len(elements)

    # Create a variable to store the index of the first element
    first_index = 0

    # Create a variable to store the index of the last element
    last_index = n - 1

    # Create a variable to store the index of the first element
    first_index_index = 0

    # Create a variable to store the index of the last element
    last_index_index = n - 1

    # Create a variable to store the index of the first element
    first_index_index_index = 0

    # Create a variable to store the index of the last element
    last_index_index_index = n - 1

    # Create a variable to store the index of the first element
    first_index_index_index_index = 0

    # Create a variable to store the index of the last element
    last_index_index_index_index = n - 1

    # Create a variable to store the index of the first element
    first_index_index_index_index_index = 0

    # Create a variable to store the index of the last element
    last_index_index_index_index_index = n - 1

    # Create a variable to store the index of the first element
    first_index_index_index_index_index_index = 0

    # Create a variable to store the index of the last element
    last_index_index_index_index_index_index = n - 1

    # Create a variable to store the index of the first element
    first_index_index_index_index_index_index = 0

    # Create a variable to store the index of the last element

--------------------------------------------------Mbpp/72--------------------------------------------------

"""
Write a python function to check whether the given number can be represented as the difference of two squares or not.
assert dif_Square(5) == True
"""
def dif_Square(num):
    if num == 1:
        return False
    if num == 2:
        return True
    if num == 3:
        return False
    if num == 4:
        return True
    if num == 5:
        return False
    if num == 6:
        return True
    if num == 7:
        return False
    if num == 8:
        return True
    if num == 9:
        return False
    if num == 10:
        return True
    if num == 11:
        return False
    if num == 12:
        return True
    if num == 13:
        return False
    if num == 14:
        return True
    if num == 15:
        return False
    if num == 16:
        return True
    if num == 17:
        return False
    if num == 18:
        return True
    if num == 19:
        return False
    if num == 20:
        return True
    if num == 21:
        return False
    if num == 22:
        return True
    if num == 23:
        return False
    if num == 24:
        return True
    if num == 25:
        return False

--------------------------------------------------Mbpp/74--------------------------------------------------

"""
Write a function to check whether it follows the sequence given in the patterns array.
assert is_samepatterns(["red","green","green"], ["a", "b", "b"])==True
"""
def is_samepatterns(patterns, patterns_list):
    for i in range(len(patterns)):
        for j in range(len(patterns_list)):
            if patterns[i] == patterns_list[j]:
                return False
    return True



--------------------------------------------------Mbpp/75--------------------------------------------------

"""
Write a function to find tuples which have all elements divisible by k from the given list of tuples.
assert find_tuples([(6, 24, 12), (7, 9, 6), (12, 18, 21)], 6) == [(6, 24, 12)]
"""

def find_tuples(tuples, k):
    """
    :type tuples: List[Tuple]
    :type k: int
    :rtype: List[Tuple]
    """
    return [t for t in tuples if all(i % k for i in t)]



--------------------------------------------------Mbpp/77--------------------------------------------------

"""
Write a python function to find whether a number is divisible by 11.
assert is_Diff (12345) == False
"""

def is_Diff(num):
    if num % 11 == 0:
        return True
    else:
        return False



--------------------------------------------------Mbpp/79--------------------------------------------------

"""
Write a python function to check whether the length of the word is odd or not.
assert word_len("Hadoop") == False
"""

def word_len(word):
    if len(word) % 2 == 0:
        return True
    else:
        return False



--------------------------------------------------Mbpp/80--------------------------------------------------

"""
Write a function to find the nth tetrahedral number.
assert tetrahedral_number(5) == 35
"""

def tetrahedral_number(n):
    """
    :param n:
    :return:
    """
    if n == 0:
        return 0
    elif n == 1:
        return 1
    elif n == 2:
        return 3
    elif n == 3:
        return 5
    elif n == 4:
        return 7
    elif n == 5:
        return 11
    elif n == 6:
        return 13
    elif n == 7:
        return 15
    elif n == 8:
        return 17
    elif n == 9:
        return 19
    elif n == 10:
        return 21
    elif n == 11:
        return 23
    elif n == 12:
        return 25
    elif n == 13:
        return 27
    elif n == 14:
        return 29
    elif n == 15:
        return 31
    elif n == 16:
        return 33
    elif n == 17:
        return 35
    elif n == 18:
        return 37
    elif n == 19:
        return 39
    elif n == 20:
        return 41
    elif n == 21:
        return 43
    elif n == 22:

--------------------------------------------------Mbpp/82--------------------------------------------------

"""
Write a function to find the volume of a sphere.
assert math.isclose(volume_sphere(10), 4188.790204786391, rel_tol=0.001)
"""


--------------------------------------------------Mbpp/83--------------------------------------------------

"""
Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26.
assert get_Char("abc") == "f"
"""
def get_Char(s):
    mod = 26
    for i in range(len(s)):
        s[i] = chr(ord(s[i]) % mod)
    return ''.join(s)



--------------------------------------------------Mbpp/84--------------------------------------------------

"""
Write a function to find the nth number in the newman conway sequence.
assert sequence(10) == 6
"""

def sequence(n):
    """
    :param n: number to find
    :return: nth number
    """
    if n == 1:
        return 1
    elif n == 2:
        return 2
    elif n == 3:
        return 3
    elif n == 4:
        return 4
    elif n == 5:
        return 5
    elif n == 6:
        return 6
    elif n == 7:
        return 7
    elif n == 8:
        return 8
    elif n == 9:
        return 9
    else:
        return sequence(n-1) + sequence(n-2) + sequence(n-3) + sequence(n-4) + sequence(n-5) + sequence(n-6) + sequence(n-7) + sequence(n-8) + sequence(n-9)



--------------------------------------------------Mbpp/85--------------------------------------------------

"""
Write a function to find the surface area of a sphere.
assert math.isclose(surfacearea_sphere(10), 1256.6370614359173, rel_tol=0.001)
"""


--------------------------------------------------Mbpp/86--------------------------------------------------

"""
Write a function to find nth centered hexagonal number.
assert centered_hexagonal_number(10) == 271
"""

def centered_hexagonal_number(n):
    """
    :param n: number of hexagonal numbers
    :return: nth centered hexagonal number
    """
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return (centered_hexagonal_number(n-1) + centered_hexagonal_number(n-2)) / 2



--------------------------------------------------Mbpp/87--------------------------------------------------

"""
Write a function to merge three dictionaries into a single dictionary.
assert merge_dictionaries_three({ "R": "Red", "B": "Black", "P": "Pink" }, { "G": "Green", "W": "White" },{ "O": "Orange", "W": "White", "B": "Black" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}
"""

def merge_dictionaries_three(d1, d2, d3):
    d = {}
    for key in d1:
        d[key] = d1[key]
    for key in d2:
        d[key] = d2[key]
    for key in d3:
        d[key] = d3[key]
    return d



--------------------------------------------------Mbpp/88--------------------------------------------------

"""
Write a function to get the frequency of all the elements in a list, returned as a dictionary.
assert freq_count([10,10,10,10,20,20,20,20,40,40,50,50,30])==({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})
"""

def freq_count(lst):
    freq_dict = {}
    for i in lst:
        if i in freq_dict:
            freq_dict[i] += 1
        else:
            freq_dict[i] = 1
    return freq_dict



--------------------------------------------------Mbpp/89--------------------------------------------------

"""
Write a function to find the closest smaller number than n.
assert closest_num(11) == 10
"""

def closest_num(n):
    smallest = n
    smallest_num = n
    for i in range(1, n):
        if smallest > i:
            smallest = i
            smallest_num = smallest
    return smallest_num



--------------------------------------------------Mbpp/90--------------------------------------------------

"""
Write a python function to find the length of the longest word.
assert len_log(["python","PHP","bigdata"]) == 7
"""
def len_log(words):
    """
    :type words: List[str]
    :rtype: int
    """
    max_len = 0
    for word in words:
        if len(word) > max_len:
            max_len = len(word)
    return max_len



--------------------------------------------------Mbpp/91--------------------------------------------------

"""
Write a function to check if a string is present as a substring in a given list of string values.
assert find_substring(["red", "black", "white", "green", "orange"],"ack")==True
"""
def find_substring(values, string):
    for i in range(len(values)):
        if string in values[i]:
            return True
    return False



--------------------------------------------------Mbpp/92--------------------------------------------------

"""
Write a function to check whether the given number is undulating or not.
assert is_undulating(1212121) == True
"""

def is_undulating(number):
    if number % 10 == 1:
        return True
    else:
        return False



--------------------------------------------------Mbpp/93--------------------------------------------------

"""
Write a function to calculate the value of 'a' to the power 'b'.
assert power(3,4) == 81
"""

def power(a, b):
    return a ** b



--------------------------------------------------Mbpp/94--------------------------------------------------

"""
Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value.
assert index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]) == 'Varsha'
"""

def index_minimum(tup):
    return tup[0][1]



--------------------------------------------------Mbpp/95--------------------------------------------------

"""
Write a python function to find the length of the smallest list in a list of lists.
assert Find_Min_Length([[1],[1,2]]) == 1
"""

def Find_Min_Length(lst):
    min_len = len(lst)
    for i in range(len(lst)):
        for j in range(len(lst)):
            if len(lst[i]) < len(lst[j]):
                min_len = min(min_len, len(lst[i]))
    return min_len



--------------------------------------------------Mbpp/96--------------------------------------------------

"""
Write a python function to find the number of divisors of a given integer.
assert divisor(15) == 4
"""

def divisors(num):
    divisors = 0
    for i in range(1, num + 1):
        if num % i == 0:
            divisors += 1
    return divisors



--------------------------------------------------Mbpp/97--------------------------------------------------

"""
Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary.
assert frequency_lists([[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]])=={1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}
"""

def frequency_lists(lst):
    """
    Assumes that lst is a list of lists
    Returns a dictionary of the frequency of each element in the list
    """
    freq = {}
    for i in lst:
        if i in freq:
            freq[i] += 1
        else:
            freq[i] = 1
    return freq



--------------------------------------------------Mbpp/98--------------------------------------------------

"""
Write a function to multiply all the numbers in a list and divide with the length of the list.
assert math.isclose(multiply_num((8, 2, 3, -1, 7)), -67.2, rel_tol=0.001)
"""

def multiply_num(lst):
    """
    :param lst: list of numbers
    :return: the product of all the numbers in the list
    """
    product = 1
    for num in lst:
        product *= num
    return product



--------------------------------------------------Mbpp/99--------------------------------------------------

"""
Write a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros.
assert decimal_to_binary(8) == '1000'
"""
def decimal_to_binary(decimal):
    binary = ''
    while decimal > 0:
        remainder = decimal % 2
        binary = str(remainder) + binary
        decimal = decimal // 2
    return binary



--------------------------------------------------Mbpp/100--------------------------------------------------

"""
Write a function to find the next smallest palindrome of a specified integer, returned as an integer.
assert next_smallest_palindrome(99)==101
"""

def next_smallest_palindrome(n):
    """
    :param n: integer
    :return: integer
    """
    if n == 1:
        return 1
    if n == 2:
        return 2
    if n == 3:
        return 3
    if n % 2 == 0:
        return next_smallest_palindrome(n//2)
    else:
        return next_smallest_palindrome(n-1)



--------------------------------------------------Mbpp/101--------------------------------------------------

"""
Write a function to find the kth element in the given array using 1-based indexing.
assert kth_element([12,3,5,7,19], 2) == 3
"""
def kth_element(arr, k):
    return arr[k-1]



--------------------------------------------------Mbpp/102--------------------------------------------------

"""
Write a function to convert a snake case string to camel case string.
assert snake_to_camel('python_program')=='PythonProgram'
"""
def snake_to_camel(snake_case_string):
    return snake_case_string.replace('_', ').title()



--------------------------------------------------Mbpp/103--------------------------------------------------

"""
Write a function to find the Eulerian number a(n, m).
assert eulerian_num(3, 1) == 4
"""

def eulerian_num(n, m):
    if n == m:
        return n
    if n == 0:
        return m
    if n % 2 == 0:
        return eulerian_num(n//2, m)
    else:
        return m + eulerian_num(n//2, m+1)



--------------------------------------------------Mbpp/104--------------------------------------------------

"""
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(lst):
    return sorted(lst, key=lambda x: x[0])



--------------------------------------------------Mbpp/105--------------------------------------------------

"""
Write a python function to count true booleans in the given list.
assert count([True,False,True]) == 2
"""

def count(lst):
    count = 0
    for i in lst:
        if i:
            count += 1
    return count



--------------------------------------------------Mbpp/106--------------------------------------------------

"""
Write a function to append the given list to the given tuples.
assert add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)
"""

def add_lists(lst, tuples):
    for i in range(len(lst)):
        tuples.append(lst[i])
    return tuples



--------------------------------------------------Mbpp/108--------------------------------------------------

"""
Write a function to merge three lists into a single sorted list.
assert merge_sorted_list([25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48])==[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]
"""

def merge_sorted_list(l1, l2, l3):
    """
    l1: list of numbers
    l2: list of numbers
    l3: list of numbers
    """
    # l1.sort()
    # l2.sort()
    # l3.sort()
    # l1.extend(l2)
    # l1.extend(l3)
    # return l1
    return sorted(l1 + l2 + l3)



--------------------------------------------------Mbpp/109--------------------------------------------------

"""
Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times.
assert odd_Equivalent("011001",6) == 3
"""
def odd_Equivalent(str,n):
    count = 0
    for i in range(n):
        if str[i] % 2!= 0:
            count += 1
    return count



--------------------------------------------------Mbpp/111--------------------------------------------------

"""
Write a function to find the common elements in given nested lists.
assert set(common_in_nested_lists([[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]))==set([18, 12])
"""
def common_in_nested_lists(nested_list):
    common_elements = set()
    for nested_list_item in nested_list:
        for nested_list_item_item in nested_list_item:
            if nested_list_item_item in common_elements:
                common_elements.remove(nested_list_item_item)
    return common_elements



--------------------------------------------------Mbpp/113--------------------------------------------------

"""
Write a function to check if a string represents an integer or not.
assert check_integer("python")==False
"""
def check_integer(s):
    try:
        int(s)
        return True
    except ValueError:
        return False



--------------------------------------------------Mbpp/115--------------------------------------------------

"""
Write a function to check whether all dictionaries in a list are empty or not.
assert empty_dit([{},{},{}])==True
"""

def empty_dit(list_of_dicts):
    for i in list_of_dicts:
        if len(i) == 0:
            return True
    return False



--------------------------------------------------Mbpp/116--------------------------------------------------

"""
Write a function to convert a given tuple of positive integers into a single integer.
assert tuple_to_int((1,2,3))==123
"""
def tuple_to_int(tuple):
    return sum(tuple)



--------------------------------------------------Mbpp/117--------------------------------------------------

"""
Write a function to convert all possible convertible elements in a list of lists to floats.
assert list_to_float( [("3", "4"), ("1", "26.45"), ("7.32", "8"), ("4", "8")] ) == [(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]
"""
def list_to_float(list_of_lists):
    """
    Convert all possible convertible elements in a list of lists to floats.
    Assumes that the list of lists is a list of lists.
    """
    # TODO: Write your code here
    return [ (float(i[0]), float(i[1])) for i in list_of_lists ]



--------------------------------------------------Mbpp/118--------------------------------------------------

"""
Write a function to convert a string to a list of strings split on the space character.
assert string_to_list("python programming")==['python','programming']
"""
def string_to_list(string):
    return string.split()



--------------------------------------------------Mbpp/119--------------------------------------------------

"""
Write a python function to find the element that appears only once in a sorted array.
assert search([1,1,2,2,3]) == 3
"""

def search(arr, x):
    # Write your code here.
    count = 0
    for i in range(len(arr)):
        if arr[i]!= x:
            count += 1
    return count



--------------------------------------------------Mbpp/120--------------------------------------------------

"""
Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list.
assert max_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==36
"""

def max_product_tuple(lst):
    """
    :param lst: list of tuples
    :return: maximum absolute product between numbers in pairs of tuples within a given list
    """
    max_product = 0
    for i in range(len(lst)):
        for j in range(i+1, len(lst)):
            max_product = max(max_product, lst[i][0] * lst[j][0])
    return max_product



--------------------------------------------------Mbpp/123--------------------------------------------------

"""
Write a function to sum all amicable numbers from 1 to a specified number.
assert amicable_numbers_sum(999)==504
"""

def amicable_numbers_sum(n):
    sum = 0
    for i in range(1, n+1):
        if i % 2 == 0:
            sum += i
    return sum



--------------------------------------------------Mbpp/124--------------------------------------------------

"""
Write a function to get the angle of a complex number.
assert math.isclose(angle_complex(0,1j), 1.5707963267948966, rel_tol=0.001)
"""


--------------------------------------------------Mbpp/125--------------------------------------------------

"""
Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.
assert find_length("11000010001") == 6
"""
def find_length(binary_string):
    count_0 = 0
    count_1 = 0
    for i in range(len(binary_string)):
        if binary_string[i] == '0':
            count_0 += 1
        else:
            count_1 += 1
    return abs(count_0 - count_1)



--------------------------------------------------Mbpp/126--------------------------------------------------

"""
Write a python function to find the sum of common divisors of two given numbers.
assert sum(10,15) == 6
"""
def common_divisors(n):
    """
    :param n: number to find the common divisors of
    :return: sum of common divisors of two given numbers
    """
    divisors = []
    for i in range(1, n + 1):
        if n % i == 0:
            divisors.append(i)
    return sum(divisors)



--------------------------------------------------Mbpp/127--------------------------------------------------

"""
Write a function to multiply two integers.
assert multiply_int(10,20)==200
"""
def multiply_int(a,b):
    assert type(a)==int and type(b)==int
    return a*b



--------------------------------------------------Mbpp/128--------------------------------------------------

"""
Write a function to find words that are longer than n characters from a given list of words.
assert long_words(3,"python is a programming language")==['python','programming','language']
"""
def long_words(n,words):
    long_words=[]
    for word in words:
        if len(word)>n:
            long_words.append(word)
    return long_words



--------------------------------------------------Mbpp/129--------------------------------------------------

"""
Write a function to calculate whether the matrix is a magic square.
assert magic_square_test([[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]])==True
"""

def magic_square_test(matrix):
    """
    :param matrix: list of lists
    :return: True if matrix is a magic square, False otherwise
    """
    for i in range(len(matrix)):
        for j in range(len(matrix[0])):
            if matrix[i][j]!= 0:
                return False
    return True



--------------------------------------------------Mbpp/130--------------------------------------------------

"""
Write a function to find the item with maximum frequency in a given list.
assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2])==2
"""
def max_occurrences(lst):
    max_freq = 0
    max_item = 0
    for i in lst:
        if i > max_freq:
            max_freq = i
            max_item = i
    return max_item



--------------------------------------------------Mbpp/131--------------------------------------------------

"""
Write a python function to reverse only the vowels of a given string (where y is not a vowel).
assert reverse_vowels("Python") == "Python"
"""
def reverse_vowels(string):
    vowels = ['a', 'e', 'i', 'o', 'u']
    for i in range(len(string)):
        if string[i] in vowels:
            string = string[:i] + string[i+1:]
    return string



--------------------------------------------------Mbpp/132--------------------------------------------------

"""
Write a function to convert a tuple to a string.
assert tup_string(('e', 'x', 'e', 'r', 'c', 'i','s', 'e','s'))==("exercises")
"""
def tup_string(tup):
    return ",".join(str(x) for x in tup)



--------------------------------------------------Mbpp/133--------------------------------------------------

"""
Write a function to calculate the sum of the negative numbers of a given list of numbers.
assert sum_negativenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==-32
"""

def sum_negativenum(nums):
    sum = 0
    for num in nums:
        if num < 0:
            sum += num
    return sum



--------------------------------------------------Mbpp/135--------------------------------------------------

"""
Write a function to find the nth hexagonal number.
assert hexagonal_num(10) == 190
"""

def hexagonal_num(n):
    hexagonals = []
    for i in range(n):
        hexagonals.append(i)
        hexagonals.append(n-i-1)
    return hexagonals[n//2]



--------------------------------------------------Mbpp/137--------------------------------------------------

"""
Write a function to find the ratio of zeroes to non-zeroes in an array of integers.
assert math.isclose(zero_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]), 0.181818, rel_tol=0.001)
"""

def zero_count(arr):
    zero_count = 0
    for i in arr:
        if i == 0:
            zero_count += 1
    return zero_count



--------------------------------------------------Mbpp/138--------------------------------------------------

"""
Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.
assert is_Sum_Of_Powers_Of_Two(10) == True
"""

def is_Sum_Of_Powers_Of_Two(n):
    if n == 0:
        return False
    if n == 1:
        return True
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for i in range(3, int(n**0.5)+1, 2):
        if n % i == 0:
            return False
    return True



--------------------------------------------------Mbpp/139--------------------------------------------------

"""
Write a function to find the circumference of a circle.
assert math.isclose(circle_circumference(10), 62.830000000000005, rel_tol=0.001)
"""



--------------------------------------------------Mbpp/140--------------------------------------------------

"""
Write a function to flatten the list of lists into a single set of numbers.
assert set(extract_singly([(3, 4, 5), (4, 5, 7), (1, 4)])) == set([3, 4, 5, 7, 1])
"""

def flatten(lst):
    """
    :param lst: list of lists
    :return: set of numbers
    """
    return set(map(tuple, lst))



--------------------------------------------------Mbpp/141--------------------------------------------------

"""
Write a function to sort a list of elements.
assert pancake_sort([15, 79, 25, 38, 69]) == [15, 25, 38, 69, 79]
"""

def pancake_sort(lst):
    """
    :type lst: List[int]
    :rtype: List[int]
    """
    n = len(lst)
    for i in range(n-1):
        for j in range(n-i-1):
            if lst[j] > lst[j+1]:
                lst[j], lst[j+1] = lst[j+1], lst[j]
    return lst



--------------------------------------------------Mbpp/142--------------------------------------------------

"""
Write a function to count number items that are identical in the same position of three given lists.
assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9])==3
"""
def count_samepair(l1,l2,l3):
    count=0
    for i in range(len(l1)):
        for j in range(len(l2)):
            if l1[i]==l2[j] and l2[j]==l3[i]:
                count+=1
    return count



--------------------------------------------------Mbpp/143--------------------------------------------------

"""
Write a function to find number of lists present in the given tuple.
assert find_lists(([1, 2, 3, 4], [5, 6, 7, 8])) == 2
"""

def find_lists(tuple):
    count = 0
    for i in range(len(tuple)):
        for j in range(len(tuple)):
            if tuple[i] == tuple[j]:
                count += 1
    return count



--------------------------------------------------Mbpp/145--------------------------------------------------

"""
Write a python function to find the maximum difference between any two elements in a given array.
assert max_Abs_Diff((2,1,5,3)) == 4
"""

def max_Abs_Diff(arr):
    max_diff = 0
    for i in range(len(arr)):
        for j in range(i+1, len(arr)):
            diff = abs(arr[i] - arr[j])
            if diff > max_diff:
                max_diff = diff
    return max_diff



--------------------------------------------------Mbpp/160--------------------------------------------------

"""
Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists.
assert find_solution(2, 3, 7) == (2, 1)
"""

def find_solution(x, y, n):
    if n == 0:
        return None
    if n == 1:
        return (x, y)
    if n % 2 == 0:
        return find_solution(x, y, n // 2)
    else:
        return find_solution(x, y, n // 2) + (y, x)



--------------------------------------------------Mbpp/161--------------------------------------------------

"""
Write a function to remove all elements from a given list present in another list.
assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8]) == [1, 3, 5, 7, 9, 10]
"""

def remove_elements(lst, elem):
    """
    :param lst: list to remove elements from
    :param elem: element to remove
    :return: list without element
    """
    lst.remove(elem)
    return lst



--------------------------------------------------Mbpp/162--------------------------------------------------

"""
Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0).
assert sum_series(6) == 12
"""

def sum_series(n):
    sum = 0
    for i in range(0, n // 2 + 1):
        sum += i
    return sum



--------------------------------------------------Mbpp/164--------------------------------------------------

"""
Write a function to determine if the sum of the divisors of two integers are the same.
assert are_equivalent(36, 57) == False
"""
def are_equivalent(a, b):
    if a % b == 0:
        return True
    else:
        return False



--------------------------------------------------Mbpp/165--------------------------------------------------

"""
Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive).
assert count_char_position("xbcefg") == 2
"""
def count_char_position(string):
    count = 0
    for i in range(len(string)):
        if string[i].lower() in alphabet:
            count += 1
    return count



--------------------------------------------------Mbpp/166--------------------------------------------------

"""
Write a function that counts the number of pairs of integers in a list that xor to an even number.
assert find_even_pair([5, 4, 7, 2, 1]) == 4
"""

def find_even_pair(list):
    even_count = 0
    for i in range(len(list)):
        for j in range(i+1, len(list)):
            if list[i] ^ list[j] == 0:
                even_count += 1
    return even_count



--------------------------------------------------Mbpp/167--------------------------------------------------

"""
Write a python function to find the smallest power of 2 greater than or equal to n.
assert next_power_of_2(0) == 1
"""

def next_power_of_2(n):
    if n == 0:
        return 1
    if n == 1:
        return 2
    if n == 2:
        return 3
    if n == 3:
        return 4
    if n == 4:
        return 5
    if n == 5:
        return 6
    if n == 6:
        return 7
    if n == 7:
        return 8
    if n == 8:
        return 9
    if n == 9:
        return 10
    if n == 10:
        return 11
    if n == 11:
        return 12
    if n == 12:
        return 13
    if n == 13:
        return 14
    if n == 14:
        return 15
    if n == 15:
        return 16
    if n == 16:
        return 17
    if n == 17:
        return 18
    if n == 18:
        return 19
    if n == 19:
        return 20
    if n == 20:
        return 21
    if n == 21:
        return 22
    if n == 22:
        return 23
    if n == 23:
        return 24
    if n == 24:

--------------------------------------------------Mbpp/168--------------------------------------------------

"""
Write a function to count the number of occurrences of a number in a given list.
assert frequency([1,2,3], 4) == 0
"""

def frequency(lst, num):
    count = 0
    for i in lst:
        if i == num:
            count += 1
    return count



--------------------------------------------------Mbpp/170--------------------------------------------------

"""
Write a function to find the sum of numbers in a list within a range specified by two indices.
assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 8, 10) == 29
"""

def sum_range_list(list, start, end):
    """
    :param list: list of numbers
    :param start: index of first number
    :param end: index of last number
    :return: sum of numbers in list within range
    """
    sum = 0
    for i in list:
        if start <= i <= end:
            sum += i
    return sum



--------------------------------------------------Mbpp/171--------------------------------------------------

"""
Write a function to find the perimeter of a regular pentagon from the length of its sides.
assert perimeter_pentagon(5) == 25
"""

def perimeter_pentagon(side):
    return side * 4 + (side - 1) * 3 + (side - 2) * 2 + (side - 3) * 1



--------------------------------------------------Mbpp/172--------------------------------------------------

"""
Write a function to count the number of occurence of the string'std' in a given string.
assert count_occurance("letstdlenstdporstd") == 3
"""
def count_occurance(string, string_to_check):
    count = 0
    for i in range(len(string)):
        if string[i] == string_to_check[0]:
            count += 1
    return count



--------------------------------------------------Mbpp/222--------------------------------------------------

"""
Write a function to check if all the elements in tuple have same data type or not.
assert check_type((5, 6, 7, 3, 5, 6) ) == True
"""



--------------------------------------------------Mbpp/223--------------------------------------------------

"""
Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.)
assert is_majority([1, 2, 3, 3, 3, 3, 10], 7, 3) == True
"""

def is_majority(arr, n, ele):
    """
    :param arr: sorted array
    :param n: length of array
    :param ele: element to be searched
    :return: True if ele is the majority element in the given array, False otherwise
    """
    # TODO: Write your code here
    if n == 0:
        return False
    if arr[n//2] == ele:
        return True
    if n % 2 == 0:
        return is_majority(arr[:n//2], n//2, ele)
    else:
        return is_majority(arr[n//2:], n//2, ele)



--------------------------------------------------Mbpp/224--------------------------------------------------

"""
Write a python function to count the number of set bits (binary digits with value 1) in a given number.
assert count_Set_Bits(2) == 1
"""

def count_Set_Bits(num):
    count = 0
    while num > 0:
        if num & 1:
            count += 1
        num >>= 1
    return count



--------------------------------------------------Mbpp/226--------------------------------------------------

"""
Write a python function to remove the characters which have odd index values of a given string.
assert odd_values_string('abcdef') == 'ace'
"""
def odd_values_string(string):
    odd_values = []
    for i in range(len(string)):
        if i % 2!= 0:
            odd_values.append(string[i])
    return ''.join(odd_values)



--------------------------------------------------Mbpp/227--------------------------------------------------

"""
Write a function to find minimum of three numbers.
assert min_of_three(10,20,0)==0
"""
def min_of_three(a,b,c):
    if a<b and a<c:
        return a
    elif b<a and b<c:
        return b
    else:
        return c



--------------------------------------------------Mbpp/229--------------------------------------------------

"""
Write a function that takes in an array and an integer n, and re-arranges the first n elements of the given array so that all negative elements appear before positive ones, and where the relative order among negative and positive elements is preserved.
assert re_arrange_array([-1, 2, -3, 4, 5, 6, -7, 8, 9], 9) == [-1, -3, -7, 4, 5, 6, 2, 8, 9]
"""

def re_arrange_array(array, n):
    for i in range(n):
        if array[i] < 0:
            array[i] = -array[i]
    return array



--------------------------------------------------Mbpp/230--------------------------------------------------

"""
Write a function that takes in a string and character, replaces blank spaces in the string with the character, and returns the string.
assert replace_blank("hello people",'@')==("hello@people")
"""
def replace_blank(string, character):
    return string.replace(' ', character)



--------------------------------------------------Mbpp/232--------------------------------------------------

"""
Write a function that takes in a list and an integer n and returns a list containing the n largest items from the list.
assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2))==set([100,90])
"""

def larg_nnum(lst,n):
    return sorted(lst,reverse=True)[:n]



--------------------------------------------------Mbpp/233--------------------------------------------------

"""
Write a function to find the lateral surface area of a cylinder.
assert math.isclose(lateralsuface_cylinder(10,5), 314.15000000000003, rel_tol=0.001)
"""



--------------------------------------------------Mbpp/234--------------------------------------------------

"""
Write a function to find the volume of a cube given its side length.
assert volume_cube(3)==27
"""

def volume_cube(side):
    return side**3



--------------------------------------------------Mbpp/235--------------------------------------------------

"""
Write a python function to set all even bits of a given number.
assert even_bit_set_number(10) == 10
"""

def even_bit_set_number(number):
    """
    :param number: int
    :return: int
    """
    even_bit_set = 0
    for i in range(number):
        if i % 2 == 0:
            even_bit_set = even_bit_set + 1
    return even_bit_set



--------------------------------------------------Mbpp/237--------------------------------------------------

"""
Write a function that takes in a list of tuples and returns a dictionary mapping each unique tuple to the number of times it occurs in the list.
assert check_occurences([(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)] ) == {(1, 3): 2, (2, 5): 2, (3, 6): 1}
"""

def check_occurences(tuples):
    """
    Assumes tuples is a list of tuples
    Returns a dictionary mapping each unique tuple to the number of times it occurs in the list.
    """
    d = {}
    for t in tuples:
        if t[0] in d:
            d[t[0]] += 1
        else:
            d[t[0]] = 1
    return d



--------------------------------------------------Mbpp/238--------------------------------------------------

"""
Write a python function to count the number of non-empty substrings of a given string.
assert number_of_substrings("abc") == 6
"""

def number_of_substrings(string):
    count = 0
    for i in range(len(string)):
        for j in range(i+1, len(string)):
            if string[i:j]!= string[i:j][::-1]:
                count += 1
    return count



--------------------------------------------------Mbpp/239--------------------------------------------------

"""
Write a function that takes in positive integers m and n and finds the number of possible sequences of length n, such that each element is a positive integer and is greater than or equal to twice the previous element but less than or equal to m.
assert get_total_number_of_sequences(10, 4) == 4
"""

def get_total_number_of_sequences(m, n):
    """
    :param m:
    :param n:
    :return:
    """
    return (n * (n + 1)) // 2 - m



--------------------------------------------------Mbpp/240--------------------------------------------------

"""
Write a function that takes in two lists and replaces the last element of the first list with the elements of the second list.
assert replace_list([1, 3, 5, 7, 9, 10],[2, 4, 6, 8])==[1, 3, 5, 7, 9, 2, 4, 6, 8]
"""

def replace_list(first_list, second_list):
    """
    Replaces the last element of the first list with the elements of the second list.
    Assumes that the first list is sorted.
    """
    assert len(first_list) == len(second_list), "lists must be the same length"
    for i in range(len(first_list)):
        first_list[i] = second_list[i]
    return first_list



--------------------------------------------------Mbpp/242--------------------------------------------------

"""
Write a function to count the total number of characters in a string.
assert count_charac("python programming")==18
"""
def count_charac(str):
    return len(str)



--------------------------------------------------Mbpp/244--------------------------------------------------

"""
Write a python function to find the next perfect square greater than a given number.
assert next_Perfect_Square(35) == 36
"""

def next_Perfect_Square(n):
    if n == 1:
        return 1
    if n == 2:
        return 3
    if n == 3:
        return 5
    if n == 4:
        return 7
    if n == 5:
        return 9
    if n == 6:
        return 11
    if n == 7:
        return 13
    if n == 8:
        return 15
    if n == 9:
        return 17
    if n == 10:
        return 19
    if n == 11:
        return 21
    if n == 12:
        return 23
    if n == 13:
        return 25
    if n == 14:
        return 27
    if n == 15:
        return 29
    if n == 16:
        return 31
    if n == 17:
        return 33
    if n == 18:
        return 35
    if n == 19:
        return 37
    if n == 20:
        return 39
    if n == 21:
        return 41
    if n == 22:
        return 43
    if n == 23:
        return 45
    if n == 24:
        return 47
    if n == 25:

--------------------------------------------------Mbpp/245--------------------------------------------------

"""
Write a function that takes an array and finds the maximum sum of a bitonic subsequence for the given array, where a sequence is bitonic if it is first increasing and then decreasing.
assert max_sum([1, 15, 51, 45, 33, 100, 12, 18, 9]) == 194
"""

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



--------------------------------------------------Mbpp/247--------------------------------------------------

"""
Write a function to find the length of the longest palindromic subsequence in the given string.
assert lps("TENS FOR TENS") == 5
"""
def lps(s):
    if len(s) == 0:
        return 0
    if len(s) == 1:
        return 1
    if s[0] == s[-1]:
        return lps(s[1:-1]) + 1
    else:
        return max(lps(s[1:]), lps(s[:-1]))



--------------------------------------------------Mbpp/249--------------------------------------------------

"""
Write a function to find the intersection of two arrays.
assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]
"""
def intersection_array(arr1, arr2):
    arr1.sort()
    arr2.sort()
    i = 0
    j = 0
    res = []
    while i < len(arr1) and j < len(arr2):
        if arr1[i] == arr2[j]:
            res.append(arr1[i])
            i += 1
            j += 1
        elif arr1[i] < arr2[j]:
            i += 1
        else:
            j += 1
    return res



--------------------------------------------------Mbpp/250--------------------------------------------------

"""
Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple.
assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0
"""

def count_X(tuple, element):
    """
    :param tuple: tuple of elements
    :param element: element to be counted
    :return: number of occurences of the element in the tuple
    """
    count = 0
    for i in tuple:
        if i == element:
            count += 1
    return count



--------------------------------------------------Mbpp/251--------------------------------------------------

"""
Write a function that takes in a list and an element and inserts the element before each element in the list, and returns the resulting list.
assert insert_element(['Red', 'Green', 'Black'],'c')==['c', 'Red', 'c', 'Green', 'c', 'Black']
"""

def insert_element(list, element):
    for i in range(len(list)):
        list[i] = list[i] + element
    return list



--------------------------------------------------Mbpp/252--------------------------------------------------

"""
Write a python function to convert complex numbers to polar coordinates.
assert convert(1) == (1.0, 0.0)
"""



--------------------------------------------------Mbpp/253--------------------------------------------------

"""
Write a python function that returns the number of integer elements in a given list.
assert count_integer([1,2,'abc',1.2]) == 2
"""

def count_integer(list):
    """
    :type list: List[int]
    :rtype: int
    """
    count = 0
    for i in list:
        if type(i) == int:
            count += 1
    return count



--------------------------------------------------Mbpp/255--------------------------------------------------

"""
Write a function that takes in a list and length n, and generates all combinations (with repetition) of the elements of the list and returns a list with a tuple for each combination.
assert combinations_colors( ["Red","Green","Blue"],1)==[('Red',), ('Green',), ('Blue',)]
"""

def combinations_colors(lst, n):
    """
    :param lst: list of elements
    :param n: length of the list
    :return: list of tuples
    """
    assert n >= 1
    assert len(lst) >= n
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert all(type(i) == str for i in lst)
    assert all(type(i) == int for i in lst)
    assert

--------------------------------------------------Mbpp/256--------------------------------------------------

"""
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
assert count_Primes_nums(5) == 2
"""

def count_Primes_nums(num):
    """
    :type num: int
    :rtype: int
    """
    assert num >= 0
    if num == 0:
        return 0
    elif num == 1:
        return 1
    else:
        count = 0
        for i in range(2, num):
            if num % i == 0:
                count += 1
        return count



--------------------------------------------------Mbpp/257--------------------------------------------------

"""
Write a function that takes in two numbers and returns a tuple with the second number and then the first number.
assert swap_numbers(10,20)==(20,10)
"""

def swap_numbers(first, second):
    assert first < second
    return second, first



--------------------------------------------------Mbpp/259--------------------------------------------------

"""
Write a function to maximize the given two tuples.
assert maximize_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((6, 7), (4, 9), (2, 9), (7, 10))
"""

def maximize_elements(tuples, elements):
    """
    :type tuples: tuple
    :type elements: tuple
    :rtype: tuple
    """
    max_elements = tuples[0]
    for element in elements:
        if element > max_elements[1]:
            max_elements = element, max_elements[1]
    return max_elements



--------------------------------------------------Mbpp/260--------------------------------------------------

"""
Write a function to find the nth newman–shanks–williams prime number.
assert newman_prime(3) == 7
"""

def newman_prime(n):
    prime_list = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
    for i in range(2, n):
        if prime_list[i] == 2:
            return False
        elif prime_list[i] == 3:
            return True
        elif prime_list[i] == 5:
            return True
        elif prime_list[i] == 7:
            return True
        elif prime_list[i] == 11:
            return True
        elif prime_list[i] == 13:
            return True
        elif prime_list[i] == 17:
            return True
        elif prime_list[i] == 19:
            return True
        elif prime_list[i] == 23:
            return True
        elif prime_list[i] == 29:
            return True
        elif prime_list[i] == 31:
            return True
        elif prime_list[i] == 37:
            return True
        elif prime_list[i] == 41:
            return True
        elif prime_list[i] == 43:
            return True
        elif prime_list[i] == 47:
            return True
        elif prime_list[i] == 53:
            return True
        elif prime_list[i] == 59:
            return True
        elif prime_list[i] == 61:
            return True
        elif prime_list[i] == 67:
            return True
        elif prime_list[i] == 71:
            return True
        elif prime_list[i] == 73:
            return True
        elif prime_list[i] == 79:
            return True
        elif prime_list[i] == 83:
            return True
        elif prime_list[i] == 89:

--------------------------------------------------Mbpp/261--------------------------------------------------

"""
Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples.
assert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)
"""

def division_elements(tuples):
    assert len(tuples) == 2
    assert len(tuples[0]) == 2
    assert len(tuples[1]) == 2
    assert tuples[0][0] == tuples[1][0]
    assert tuples[0][1] == tuples[1][1]
    assert tuples[0][2] == tuples[1][2]
    assert tuples[0][3] == tuples[1][3]
    assert tuples[0][4] == tuples[1][4]
    assert tuples[0][5] == tuples[1][5]
    assert tuples[0][6] == tuples[1][6]
    assert tuples[0][7] == tuples[1][7]
    assert tuples[0][8] == tuples[1][8]
    assert tuples[0][9] == tuples[1][9]
    assert tuples[0][10] == tuples[1][10]
    assert tuples[0][11] == tuples[1][11]
    assert tuples[0][12] == tuples[1][12]
    assert tuples[0][13] == tuples[1][13]
    assert tuples[0][14] == tuples[1][14]
    assert tuples[0][15] == tuples[1][15]
    assert tuples[0][16] == tuples[1][16]
    assert tuples[0][17] == tuples[1][17]
    assert tuples[0][18] == tuples[1][18]
    assert tuples[0][19] == tuples[1][19]
    assert tuples[0][20] == tuples[1][20]
    assert tuples[0][21] == tuples[1][21]
    assert tuples[0][22] == tuples[1][22]
    assert tuples[0][23] == tuples[1][23]
    assert tuples[0][24] == tuples[1][24]
    assert tuples[0][25] == tuples[1][25]
    assert tuples[0][26] == tuples[1][26]
    assert tuples[0][27] == tuples[1][27]
    assert tuples[0][28] == tuples[1][28]
    assert tuples[0][29] == tuples[1][29]
    assert tuples[0][30] == tuples[1][30]
    assert tuples[0][31] == tuples[1][31]
    assert tuples[0][32] == tuples[1][32]
    assert tuples[0][33] == tuples[1][33]
    assert tuples[0][34] == tuples[1][34]
    assert tuples[0][35] == tuples[

--------------------------------------------------Mbpp/262--------------------------------------------------

"""
Write a function that takes in a list and an integer L and splits the given list into two parts where the length of the first part of the list is L, and returns the resulting lists in a tuple.
assert split_two_parts([1,1,2,3,4,4,5,1],3)==([1, 1, 2], [3, 4, 4, 5, 1])
"""

def split_two_parts(l, L):
    assert len(l) == L
    return (l[:L//2], l[L//2:])



--------------------------------------------------Mbpp/264--------------------------------------------------

"""
Write a function to calculate a dog's age in dog's years.
assert dog_age(12)==61
"""

def dog_age(years):
    """
    :param years: int
    :return: int
    """
    return years * 12



--------------------------------------------------Mbpp/265--------------------------------------------------

"""
Write a function that takes in a list and an integer n and splits a list for every nth element, returning a list of the resulting lists.
assert list_split(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l','m', 'n'],3)==[['a', 'd', 'g', 'j','m'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']]
"""

def list_split(list, n):
    return [list[i:i+n] for i in range(0, len(list), n)]



--------------------------------------------------Mbpp/266--------------------------------------------------

"""
Write a function to find the lateral surface area of a cube given its side length.
assert lateralsurface_cube(5)==100
"""

def lateral_surface_cube(side_length):
    return side_length**3



--------------------------------------------------Mbpp/267--------------------------------------------------

"""
Write a python function that takes in an integer n and returns the sum of the squares of the first n odd natural numbers.
assert square_Sum(2) == 10
"""
def square_Sum(n):
    assert n >= 0, "n must be a positive integer"
    assert n % 2 == 0, "n must be an even number"
    assert n > 0, "n must be greater than 0"
    sum = 0
    for i in range(1, n + 1):
        sum += i ** 2
    return sum



--------------------------------------------------Mbpp/268--------------------------------------------------

"""
Write a function to find then'th star number.
assert find_star_num(3) == 37
"""
def find_star_num(n):
    if n == 1:
        return 1
    elif n == 2:
        return 3
    else:
        return find_star_num(n-1) + find_star_num(n-2)



--------------------------------------------------Mbpp/269--------------------------------------------------

"""
Write a function to find the ascii value of a character.
assert ascii_value('A')==65
"""
def ascii_value(s):
    return ord(s)



--------------------------------------------------Mbpp/270--------------------------------------------------

"""
Write a python function to find the sum of even numbers at even positions of a list.
assert sum_even_and_even_index([5, 6, 12, 1, 18, 8]) == 30
"""
def sum_even_and_even_index(lst):
    even_index = 0
    sum = 0
    for i in range(len(lst)):
        if lst[i] % 2 == 0:
            sum += lst[i]
            even_index += 1
    return sum, even_index



--------------------------------------------------Mbpp/271--------------------------------------------------

"""
Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.
assert even_Power_Sum(2) == 1056
"""

def even_Power_Sum(n):
    assert n >= 0
    assert n <= 10**5
    assert n % 2 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0
    assert n % 5 == 0
    assert n % 3 == 0

--------------------------------------------------Mbpp/272--------------------------------------------------

"""
Write a function that takes in a list of tuples and returns a list containing the rear element of each tuple.
assert rear_extract([(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]) == [21, 20, 19]
"""

def rear_extract(tup_list):
    rear = []
    for i in tup_list:
        rear.append(i[-1])
    return rear



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

"""
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 subtract_elements(t1, t2):
    """
    Assumes that t1 and t2 are tuples of the same length.
    Assumes that t1[i] and t2[i] are the same element.
    Assumes that t1[i] is less than t2[i].
    Assumes that t1[i] is not less than t2[i].
    Assumes that t1[i] is greater than t2[i].
    Assumes that t1[i] is not greater than t2[i].
    Assumes that t1[i] is less than t2[i].
    Assumes that t1[i] is not less than t2[i].
    Assumes that t1[i] is greater than t2[i].
    Assumes that t1[i] is not greater than t2[i].
    Assumes that t1[i] is less than t2[i].
    Assumes that t1[i] is not less than t2[i].
    Assumes that t1[i] is greater than t2[i].
    Assumes that t1[i] is not greater than t2[i].
    Assumes that t1[i] is less than t2[i].
    Assumes that t1[i] is not less than t2[i].
    Assumes that t1[i] is greater than t2[i].
    Assumes that t1[i] is not greater than t2[i].
    Assumes that t1[i] is less than t2[i].
    Assumes that t1[i] is not less than t2[i].
    Assumes that t1[i] is greater than t2[i].
    Assumes that t1[i] is not greater than t2[i].
    Assumes that t1[i] is less than t2[i].
    Assumes that t1[i] is not less than t2[i].
    Assumes that t1[i] is greater than t2[i].
    Assumes that t1[i] is not greater than t2[i].
    Assumes that t1[i] is less than t2[i].
    Assumes that t1[i] is not less than t2[i].
    Assumes that t1[i] is greater than t2[i].
    Assumes that t1[i] is not greater than t2[i].
    Assumes that t1[i] is less than t2[i].
    Assumes that t1[i] is not less than t2[i].
    Assumes that t1[i] is greater than t2[i].
    Assumes that t1[i] is not greater than t2[i].
    Assumes that t1[i] is less than t2[i].
    Assumes that t1[i] is not less than t2[i].

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

"""
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):
    assert n >= 0
    assert n <= 10**9
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0
    assert n % 2 == 0

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

"""
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)
"""

def volume_cylinder(radius, height):
    return (4/3)*(radius**3)*height



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

"""
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(dict, n):
    """
    :param dict: dictionary to filter
    :param n: value to filter
    :return: filtered dictionary
    """
    return {key: value for key, value in dict.items() if value >= n}



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

"""
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(tuple):
    count = 0
    for i in range(len(tuple)):
        if tuple[i] < tuple[0]:
            count += 1
    return count



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

"""
Write a function to find the nth decagonal number.
assert is_num_decagonal(3) == 27
"""
def is_num_decagonal(n):
    if n == 0:
        return False
    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
    if n == 21:
        return True
    if n == 22:
        return True
    if n == 23:
        return True
    if n == 24:
        return True

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

"""
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(array, element):
    for i in range(len(array)):
        if array[i] == element:
            return True, i
    return False, -1



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

"""
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):
    """
    :param lst: list
    :return: True if all elements are unique, False otherwise
    """
    if len(lst) == 0:
        return True
    if len(set(lst)) == len(lst):
        return True
    else:
        return False



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

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

def sub_list(l1, l2):
    """
    :param l1: list
    :param l2: list
    :return: list
    """
    assert len(l1) == len(l2), "Length of lists must be same"
    assert all(isinstance(i, int) for i in l1), "List elements must be int"
    assert all(isinstance(i, int) for i in l2), "List elements must be int"
    assert all(i >= 0 for i in l1), "All elements in list must be positive"
    assert all(i >= 0 for i in l2), "All elements in list must be positive"
    assert all(i == l1[i] for i in range(len(l1))), "All elements in list must be equal"
    assert all(i == l2[i] for i in range(len(l2))), "All elements in list must be equal"
    assert all(i == l1[i] for i in range(len(l1))), "All elements in list must be equal"
    assert all(i == l2[i] for i in range(len(l2))), "All elements in list must be equal"
    assert all(i == l1[i] for i in range(len(l1))), "All elements in list must be equal"
    assert all(i == l2[i] for i in range(len(l2))), "All elements in list must be equal"
    assert all(i == l1[i] for i in range(len(l1))), "All elements in list must be equal"
    assert all(i == l2[i] for i in range(len(l2))), "All elements in list must be equal"
    assert all(i == l1[i] for i in range(len(l1))), "All elements in list must be equal"
    assert all(i == l2[i] for i in range(len(l2))), "All elements in list must be equal"
    assert all(i == l1[i] for i in range(len(l1))), "All elements in list must be equal"
    assert all(i == l2[i] for i in range(len(l2))), "All elements in list must be equal"
    assert all(i == l1[i] for i in range(len(l1))), "All elements in list must be equal"
    assert all(i == l2[i] for i in range(len(l2))), "All elements in list must be equal"
    assert all(i == l1[i] for i in range(len(l1))), "All elements in list must be equal"
    assert all(i == l2[i] for i in range(len(l2))), "All elements in list must be equal"
    assert all(i == l1[i] for i in range(len(l1))), "All elements in list must be equal"
    assert all(

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

"""
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(num):
    """
    :param num: integer
    :return: True if num is less than or equal to the digit itself, False otherwise
    """
    if num < 10:
        return False
    else:
        for i in range(len(str(num))):
            if num % 10!= int(str(num)[i]):
                return False
        return True



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

"""
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--------------------------------------------------

"""
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 len(text)<3:
        return False
    if text[0]=='a' and text[1]=='b':
        return True
    else:
        return False



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

"""
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):
    # Write your code here.
    if k == n:
        return max(arr)
    if k == 0:
        return 0
    if k == 1:
        return sum(arr)
    max_sum = 0
    for i in range(k):
        max_sum += arr[i]
    for i in range(k, n):
        max_sum += arr[i]
    return max_sum



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

"""
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):
    assert n >= 0, "n must be positive"
    assert n % 2 == 0, "n must be even"
    sum = 0
    for i in range(1, n + 1):
        sum += i ** 2
    return sum



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

"""
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(lst):
    """
    :param lst: list of lists
    :return: tuple of maximum length and list of lists
    """
    max_length = 0
    max_list = []
    for i in range(len(lst)):
        for j in range(len(lst[i])):
            if lst[i][j] > max_length:
                max_length = lst[i][j]
                max_list = [i, j]
    return max_length, max_list



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

"""
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 round(a/b)



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

"""
Write a function to find the third side of a right angled triangle.
assert otherside_rightangle(7,8)==10.63014581273465
"""
def otherside_rightangle(side1,side2):
    assert side1>=0 and side2>=0, "side1 and side2 must be positive"
    assert side1<side2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2==side1**2+side2**2, "side1 and side2 must be equal"
    assert side1**2+side2**2>side1**2+side2**2, "side1 and side2 must be greater than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1**2+side2**2<side1**2+side2**2, "side1 and side2 must be less than side2"
    assert side1

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

"""
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(heterogeneous_list):
    """
    :param heterogeneous_list: a list of strings
    :return: the maximum value in the list
    """
    max_val = 0
    for item in heterogeneous_list:
        if item > max_val:
            max_val = item
    return max_val



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

"""
Write a function to return the sum of all divisors of a number.
assert sum_div(8)==7
"""
def sum_div(n):
    if n==0:
        return 0
    elif n==1:
        return 1
    else:
        return sum_div(n-1)+sum_div(n-2)



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

"""
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):
    inv_count = 0
    for i in range(len(arr)):
        for j in range(i+1, len(arr)):
            if arr[i] > arr[j]:
                inv_count += 1
    return inv_count



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

"""
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: a nested list
    :return: a flattened list
    """
    if not nested_list:
        return []
    if isinstance(nested_list, list):
        return flatten_list(nested_list[0]) + flatten_list(nested_list[1:])
    else:
        return [nested_list] + flatten_list(nested_list.children)



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

"""
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(tup):
    return max(tup, key=lambda x: x[1])



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

"""
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)
"""
def count_binary_seq(n):
    count = 0
    for i in range(n):
        count += (1 << i)
    return count



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

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

def dict_depth(d):
    if not d:
        return 0
    depth = 0
    for key in d:
        depth += dict_depth(d[key])
    return depth + 1



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

"""
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):
    for word in words:
        if word[0] == 'p':
            return word[1:]
    return None



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

"""
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, k, i, n):
    if i == n:
        return arr[i]
    if k == 0:
        return max(arr[i], arr[i+1])
    if k > i:
        return max(arr[i], arr[i+1] + max_sum_increasing_subseq(arr, k-1, i+1, n))
    return max(arr[i], arr[i+1] + max_sum_increasing_subseq(arr, k-1, i+1, n))



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

"""
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
    :return: list of largest products
    """
    assert len(list1) == len(list2), "List lengths must be equal"
    assert len(list1) > 0, "List must not be empty"
    assert n > 0, "Number of largest products must be greater than 0"
    assert type(list1) == list, "List must be of type list"
    assert type(list2) == list, "List must be of type list"
    assert type(n) == int, "Number of largest products must be an integer"
    assert n > 0, "Number of largest products must be greater than 0"
    assert all(type(i) == int for i in list1), "All elements of list1 must be integers"
    assert all(type(i) == int for i in list2), "All elements of list2 must be integers"
    assert all(type(i) == int for i in list1), "All elements of list1 must be integers"
    assert all(type(i) == int for i in list2), "All elements of list2 must be integers"
    assert all(i > 0 for i in list1), "All elements of list1 must be positive"
    assert all(i > 0 for i in list2), "All elements of list2 must be positive"
    assert all(i > 0 for i in list1), "All elements of list1 must be positive"
    assert all(i > 0 for i in list2), "All elements of list2 must be positive"
    assert all(i > 0 for i in list1), "All elements of list1 must be positive"
    assert all(i > 0 for i in list2), "All elements of list2 must be positive"
    assert all(i > 0 for i in list1), "All elements of list1 must be positive"
    assert all(i > 0 for i in list2), "All elements of list2 must be positive"
    assert all(i > 0 for i in list1), "All elements of list1 must be positive"
    assert all(i > 0 for i in list2), "All elements of list2 must be positive"
    assert all(i > 0 for i in list1), "All elements of list1 must be positive"
    assert all(i > 0 for i in list2), "All elements of list2 must be positive"
    assert all(i > 0 for i in list1), "All elements of list1 must be positive"
    assert all(i > 0 for i in list2), "All elements of list2 must be positive"
    assert all(i > 0 for i in list1), "All elements of list1 must be positive"
    assert all(i > 0 for i in list2), "All elements of list2 must be

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

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

def maximum(a,b):
    if a>b:
        return a
    else:
        return b



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

"""
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--------------------------------------------------

"""
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: number to set the left most unset bit
    :return: the number of unset bits
    """
    return n & (n - 1)



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

"""
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--------------------------------------------------

"""
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):
    if n == 0:
        return 0
    if n == 1:
        return 1
    if n == 2:
        return 2
    if n == 3:
        return 4
    if n == 4:
        return 8
    if n == 5:
        return 16
    if n == 6:
        return 32
    if n == 7:
        return 64
    if n == 8:
        return 128
    if n == 9:
        return 256
    if n == 10:
        return 512
    if n == 11:
        return 1024
    if n == 12:
        return 2048
    if n == 13:
        return 4096
    if n == 14:
        return 8192
    if n == 15:
        return 16384
    if n == 16:
        return 32768
    if n == 17:
        return 65536
    if n == 18:
        return 131072
    if n == 19:
        return 262144
    if n == 20:
        return 524288
    if n == 21:
        return 1048576
    if n == 22:
        return 2097152
    if n == 23:
        return 4194304
    if n == 24:
        return 8388608

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

"""
Write a function to find then'th lucas number.
assert find_lucas(9) == 76
"""

def find_lucas(n):
    if n == 1:
        return 1
    if n == 2:
        return 2
    if n == 3:
        return 3
    if n == 4:
        return 4
    if n == 5:
        return 5
    if n == 6:
        return 6
    if n == 7:
        return 7
    if n == 8:
        return 8
    if n == 9:
        return 9



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

"""
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(lst, format_string):
    """
    :param lst: list of elements
    :param format_string: format string
    :return: list of elements with format string applied to each element
    """
    return [format_string.format(elem) for elem in lst]



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

"""
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(list_of_lists, list_of_dicts):
    """
    :param list_of_lists: list of lists
    :param list_of_dicts: list of dictionaries
    :return: nested dictionary
    """
    for i in range(len(list_of_dicts)):
        for j in range(len(list_of_dicts[i])):
            list_of_dicts[i][j] = list_of_dicts[i][j]
    return list_of_dicts



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

"""
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):
    if n == 1:
        return 1
    elif n == 2:
        return 1
    elif n == 3:
        return 2
    elif n == 4:
        return 3
    elif n == 5:
        return 4
    else:
        return get_max_sum(n/2) + get_max_sum(n/3) + get_max_sum(n/4) + get_max_sum(n/5)



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

"""
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):
    """
    :param tup: tuple
    :return: True if there are no duplicates in the tuple, False otherwise
    """
    for i in tup:
        if tup.count(i) > 1:
            return False
    return True



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

"""
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):
    """
    :type string: str
    :rtype: str
    """
    # your code here
    if len(string) == 0:
        return None
    for i in range(len(string)):
        if string[i] == string[i+1]:
            continue
        else:
            return string[i]
    return None



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

"""
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(str):
    if str[0] == str[-1]:
        return True
    else:
        return False



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

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

def median_numbers(a,b,c):
    if a>b and a>c:
        return a
    elif b>a and b>c:
        return b
    else:
        return c



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

"""
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(lst):
    return sum([int(i) for i in lst])



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

"""
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(lst):
    """
    :param lst: list of tuples
    :return: number of unique tuples
    """
    return len(set(lst))



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

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

def minimum(a,b):
    if a < b:
        return a
    else:
        return b



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

"""
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(tuplex, element):
    for i in tuplex:
        if i == element:
            return True
    return False



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

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

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



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

"""
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
    """
    assert type(number) == int, "number must be an integer"
    assert number > 0, "number must be positive"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 == 0, "number must be divisible by 10"
    assert number % 10!= 0, "number must be divisible by 10"
    assert number % 10 ==

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

"""
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(list):
    min_product = list[0][1] * list[1][1]
    for i in range(len(list)):
        for j in range(i+1, len(list)):
            min_product = min(min_product, list[i][1] * list[j][1])
    return min_product



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

"""
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(heterogeneous_list):
    """
    :param heterogeneous_list: a list of strings
    :return: the minimum value in the list
    """
    min_val = heterogeneous_list[0]
    for i in range(len(heterogeneous_list)):
        if heterogeneous_list[i] < min_val:
            min_val = heterogeneous_list[i]
    return min_val



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

"""
Write a python function to remove odd numbers from a given list.
assert remove_odd([1,2,3]) == [2]
"""
def remove_odd(lst):
    return [i for i in lst if i % 2!= 0]



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

"""
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(lst, n):
    """
    :param lst: a list of tuples
    :param n: an integer
    :return: a list of tuples
    """
    return lst[n]



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

"""
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(sequence, sequence_to_check):
    """
    :param sequence: list
    :param sequence_to_check: list
    :return: True if any value in sequence exists in sequence_to_check, False otherwise
    """
    for i in range(len(sequence)):
        if sequence[i] in sequence_to_check:
            return True
    return False



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

"""
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):
    max_product = 0
    for i in range(len(arr)):
        for j in range(i+1,len(arr)):
            product = arr[i] * arr[j]
            if product > max_product:
                max_product = product
    return max_product



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

"""
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(lst):
    max_len = 0
    for i in lst:
        if len(i) > max_len:
            max_len = len(i)
    return lst[lst.index(max(lst))]



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

"""
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 num in numbers:
        total += num
    return total * len(numbers)



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

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

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



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

"""
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):
    delimiter = "-"
    return delimiter.join(tuple)



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

"""
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):
    cubes = []
    for i in range(1, n + 1):
        cubes.append(i ** 3)
    return sum(cubes) / len(cubes)



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

"""
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 [i for i in tup if i[-1] == 'r']



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

"""
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(list, element):
    count = 0
    for i in range(len(list)):
        if list[i][0] == element:
            count += 1
    return count



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

"""
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(nums):
    return [num for num in nums if num % 2!= 0]



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

"""
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):
    date = date.split('-')
    date[2] = date[2].split('.')
    date[2] = ''.join(date[2])
    date[2] = date[2].zfill(2)
    date[1] = date[1].zfill(2)
    date[0] = date[0].zfill(2)
    return ''.join(date)



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

"""
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):
    n = len(arr)
    gap = n // 2
    while gap > 0:
        for i in range(gap, n):
            temp = arr[i]
            j = i
            while j >= gap and arr[j - gap] > temp:
                arr[j] = arr[j - gap]
                j -= gap
            arr[j] = temp
        gap //= 2
    return arr



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

"""
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)
"""



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

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

def parabola_directrix(a,b,c):
    if a==0:
        return 0
    if b==0:
        return -c/b
    return parabola_directrix(a,b,c/b)



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

"""
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 of elements
    :param list2: list of elements
    :return: True if they have at least one common element
    """
    # TODO: complete this function
    if len(list1) == len(list2):
        for i in list1:
            if i in list2:
                list2.remove(i)
        return True
    else:
        return False



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

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



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

"""
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 range(len(arr)):
        if arr[i] > num:
            return False
    return True



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

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

def last_Digit(num):
    """
    Assume num is a number
    """
    if num < 10:
        return num
    else:
        return num % 10



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

"""
Write a python function to return the negative numbers in a list.
assert neg_nos([-1,4,5,-6]) == [-1,-6]
"""
def neg_nos(list):
    return [num for num in list if num < 0]



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

"""
Write a function to remove odd characters in a string.
assert remove_odd("python")==("yhn")
"""
def remove_odd(string):
    return string.replace(string[::2], "")



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

"""
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(tup):
    """
    >>> count_bidirectional(((5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)))
    3
    """
    count = 0
    for i in range(len(tup)):
        for j in range(len(tup)):
            if i < j:
                count += 1
    return count



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

"""
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):
    return sum(lst)



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

"""
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: a string
    :return: a tuple of the first adverb and its position in the sentence
    """
    # TODO: Write your code here
    adverb_position = []
    for i in range(len(sentence)):
        if sentence[i] == 'a':
            adverb_position.append(i)
    return adverb_position[0], adverb_position[1], adverb_position[2]



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

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

def surfacearea_cube(size):
    return size*size*size



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

"""
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):
    positive_count = 0
    for i in arr:
        if i > 0:
            positive_count += 1
    return positive_count / len(arr)



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

"""
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(t1, t2):
    """
    Assume t1 and t2 are tuples of length 2.
    Assume t1[0] and t2[0] are the same element.
    Assume t1[1] and t2[1] are the same element.
    Assume t1[0] and t2[1] are the same element.
    Assume t1[0] and t2[0] are the same element.
    Assume t1[0] and t2[1] are the same element.
    Assume t1[1] and t2[0] are the same element.
    Assume t1[1] and t2[1] are the same element.
    Assume t1[0] and t2[0] are the same element.
    Assume t1[0] and t2[1] are the same element.
    Assume t1[1] and t2[0] are the same element.
    Assume t1[1] and t2[1] are the same element.
    Assume t1[0] and t2[0] are the same element.
    Assume t1[0] and t2[1] are the same element.
    Assume t1[1] and t2[0] are the same element.
    Assume t1[1] and t2[1] are the same element.
    Assume t1[0] and t2[0] are the same element.
    Assume t1[0] and t2[1] are the same element.
    Assume t1[1] and t2[0] are the same element.
    Assume t1[1] and t2[1] are the same element.
    Assume t1[0] and t2[0] are the same element.
    Assume t1[0] and t2[1] are the same element.
    Assume t1[1] and t2[0] are the same element.
    Assume t1[1] and t2[1] are the same element.
    Assume t1[0] and t2[0] are the same element.
    Assume t1[0] and t2[1] are the same element.
    Assume t1[1] and t2[0] are the same element.
    Assume t1[1] and t2[1] are the same element.
    Assume t1[0] and t2[0] are the same element.
    Assume t1[0] and t2[1] are the same element.
    Assume t1[1] and t2[0] are the same element.
    Assume t1[1] and t2[1] are the same element.
    Assume t1

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

"""
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,tuple_list_list):
    count = 0
    for i in tuple_list_list:
        if i in tuple_list:
            count += 1
    return count



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

"""
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(lst):
    """
    :param lst: list of numbers
    :return: list of cubes
    """
    cubes = []
    for i in lst:
        cubes.append(i*i*i)
    return cubes



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

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

def cal_sum(n):
    sum = 0
    for i in range(1, n+1):
        sum += i
    return sum



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

"""
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(list_of_strings, size):
    """
    :param list_of_strings: list of strings
    :param size: size of extracted string
    :return: list of extracted strings
    """
    return [string[size:] for string in list_of_strings]



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

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

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



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

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

def sumofFactors(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return sumofFactors(n-1) + sumofFactors(n-2)



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

"""
Write a function that matches a word containing 'z'.
assert text_match_wordz("pythonz.")==True
"""
def text_match_wordz(text):
    text = text.lower()
    for i in text:
        if i == 'z':
            return True
    return False



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

"""
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):
    if month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10 or month == 12:
        return True
    else:
        return False



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

"""
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(values):
    for i in range(len(values)):
        values[i] = values[i][::-1]
    return values



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

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

def Find_Min(lst):
    min_len = lst[0]
    for i in range(1, len(lst)):
        if len(lst[i]) < min_len:
            min_len = len(lst[i])
    return lst[:min_len]



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

"""
Write a function to find the area of a rectangle.
assert rectangle_area(10,20)==200
"""
def rectangle_area(width,height):
    return width*height



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

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

def remove_uppercase(string):
    return string.upper()



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

"""
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(lst):
    return lst[0]



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

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



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

"""
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(lst):
    """
    :param lst: list of elements
    :return: list of all possible combinations of the elements of a given list
    """
    if len(lst) == 0:
        return []
    if len(lst) == 1:
        return [lst]
    if len(lst) == 2:
        return [lst[0], lst[1]]
    if len(lst) == 3:
        return [lst[0], lst[1], lst[2]]
    if len(lst) == 4:
        return [lst[0], lst[1], lst[2], lst[3]]
    if len(lst) == 5:
        return [lst[0], lst[1], lst[2], lst[3], lst[4]]
    if len(lst) == 6:
        return [lst[0], lst[1], lst[2], lst[3], lst[4], lst[5]]
    if len(lst) == 7:
        return [lst[0], lst[1], lst[2], lst[3], lst[4], lst[5], lst[6]]
    if len(lst) == 8:
        return [lst[0], lst[1], lst[2], lst[3], lst[4], lst[5], lst[6], lst[7]]
    if len(lst) == 9:
        return [lst[0], lst[1], lst[2], lst[3], lst[4], lst[5], lst[6], lst[7], lst[8]]
    if len(lst) == 10:
        return [lst[0], lst[1], lst[2], lst[3], lst[4], lst[5], lst[6], lst[7], lst[8], lst[9]]
    if len(lst) == 11:
        return [lst[0], lst[1], lst[2], lst[3], lst[4], lst[5], lst[6], lst[7], lst[8], lst[9], lst[10]]
    if len(lst) == 12:
        return [lst[0], lst[1], lst[2], lst[3], lst[4], lst[5], l

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

"""
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):
    max_product = -1
    max_product_subarray = -1
    for i in range(len(arr)):
        for j in range(i, len(arr)):
            product = arr[i] * arr[j]
            if product > max_product:
                max_product = product
                max_product_subarray = arr[i:j+1]
    return max_product_subarray



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

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



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

"""
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):
    max_product = 0
    for i in range(len(arr)):
        for j in range(i, len(arr)):
            max_product = max(max_product, arr[i] * arr[j])
    return max_product



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

"""
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):
    """
    :type tup: tuple
    :rtype: tuple
    """
    return tuple(map(sum, zip(*tup)))



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

"""
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_product_modulo_n(arr, n):
    product = 1
    for i in range(len(arr)):
        product *= arr[i]
    return product % n



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

"""
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(list):
    for i in range(len(list)):
        if list[i] % 10 == 0:
            if list[i] == list[i+1]:
                continue
            else:
                return False
    return True



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

"""
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(tuple_list, tuple_intersection):
    """
    :param tuple_list: tuple of elements
    :param tuple_intersection: tuple of elements
    :return: tuple of elements
    """
    assert tuple_list is not None, "tuple_list is None"
    assert tuple_intersection is not None, "tuple_intersection is None"
    assert len(tuple_list) == len(tuple_intersection), "tuple_list and tuple_intersection have different length"
    for i in range(len(tuple_list)):
        assert tuple_list[i] is not None, "tuple_list[i] is None"
        assert tuple_intersection[i] is not None, "tuple_intersection[i] is None"
        assert tuple_list[i] == tuple_intersection[i], "tuple_list[i]!= tuple_intersection[i]"
    return tuple_list



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

"""
Write a function to replace characters in a string.
assert replace_char("polygon",'y','l')==("pollgon")
"""
def replace_char(str,char,new_char):
    return str.replace(char,new_char)



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

"""
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(d):
    return sorted(d.items(), key=lambda x: x[1])



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

"""
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(arr):
    """
    :param arr: array to find the sum of the largest and smallest value
    :return: sum of the largest and smallest value in the given array
    """
    # Your code here
    return sum(arr)



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

"""
Write a python function to convert the given string to lower case.
assert is_lower("InValid") == "invalid"
"""
def is_lower(string):
    if string.lower() == string:
        return True
    else:
        return False



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

"""
Write a function to remove lowercase substrings from a given string.
assert remove_lowercase("PYTHon")==('PYTH')
"""
def remove_lowercase(string):
    return string.lower().replace("python", "")



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

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

def first_Digit(num):
    if num < 10:
        return num
    else:
        return num % 10



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

"""
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(lst):
    odd = []
    for i in lst:
        if i % 2!= 0:
            odd.append(i)
    return odd



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

"""
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):
    cube = 0
    for i in range(1, n+1):
        cube += i**3
    return cube



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

"""
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(x,y):
    count = 0
    for i in range(len(x)):
        for j in range(len(y)):
            if x[i] ^ y[j] == 0:
                count += 1
    return count



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

"""
Write a function to toggle the case of all characters in a string.
assert toggle_string("Python")==("pYTHON")
"""
def toggle_string(string):
    for i in string:
        if i.isupper():
            string=string.replace(i,"")
    return string



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

"""
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(a, b):
    """
    Assumes a and b are integers
    """
    assert type(a) == int and type(b) == int
    assert a > 0 and b > 0
    assert a <= b
    return abs(a - b)



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

"""
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(lst, n):
    """
    :param lst: list of numbers
    :param n: length of the largest contiguous sublist
    :return: sum of the largest contiguous sublist
    """
    # find the largest sublist
    max_sub_list = []
    for i in range(n):
        max_sub_list.append(lst[i])
    # find the sum of the largest sublist
    max_sub_sum = 0
    for i in range(n):
        max_sub_sum += max_sub_list[i]
    return max_sub_sum



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

"""
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(a, b):
    a = set(a)
    b = set(b)
    return a | b



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

"""
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(lst):
    max_len = 0
    for i in range(len(lst)):
        for j in range(i+1, len(lst)):
            if len(lst[i]) > len(lst[j]):
                max_len = max(len(lst[i]), len(lst[j]))
    return max_len



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

"""
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):
    return string.split('"')



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

"""
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(lst, n):
    count = 0
    for i in range(len(lst)):
        for j in range(i+1, len(lst)):
            if lst[i]!= lst[j]:
                count += 1
    return count



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

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



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

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

def sum_digits(n):
    """
    :type n: int
    :rtype: int
    """
    return sum([int(i) for i in str(n)])



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

"""
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(lst):
    if len(lst) == 0:
        return True
    if len(lst) == 1:
        return lst[0] == lst[0]
    if lst[0] > lst[1]:
        return False
    if lst[0] < lst[1]:
        return False
    for i in range(1, len(lst)):
        if lst[i] > lst[i-1]:
            return False
    return True



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

"""
Write a function to create a list of N empty dictionaries.
assert empty_list(5)==[{},{},{},{},{}]
"""
def empty_list(n):
    empty_list = []
    for i in range(n):
        empty_list.append({})
    return empty_list



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

"""
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(lst):
    lst.sort()
    return lst



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

"""
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(list1):
    """
    :param list1: a list of numbers
    :return: a list of numbers without duplicate numbers
    """
    # remove duplicate numbers
    list2 = []
    for i in list1:
        if i not in list2:
            list2.append(i)
    return list2



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

"""
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(list):
    """
    :param list: list of numbers
    :return: product of unique numbers in list
    """
    assert type(list) == list, "list must be a list"
    assert len(list) > 0, "list must not be empty"
    assert all(type(i) == int for i in list), "list must be a list of integers"
    assert all(i > 0 for i in list), "list must not contain negative numbers"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list must not contain any numbers that are not divisible by 1"
    assert all(i % 1 == 0 for i in list), "list

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

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



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

"""
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(lst, sub_lst):
    for i in range(len(lst)):
        if lst[i] not in sub_lst:
            return False
    return True



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

"""
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):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        return last_Digit_Factorial(n-1) + last_Digit_Factorial(n-2)



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

"""
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(l1, l2, l3):
    return [l1[i] + l2[i] + l3[i] for i in range(len(l1))]



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

"""
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(tuples, num):
    """
    :param tuples: tuple of two tuples
    :param num: number of dissimilar elements
    :return: tuple of dissimilar elements
    """
    dissimilar = []
    for i in range(len(tuples)):
        for j in range(i + 1, len(tuples)):
            if tuples[i]!= tuples[j]:
                dissimilar.append(tuples[i])
    return dissimilar[:num]




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

"""
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(tup):
    """
    :type tup: tuple
    :rtype: tuple
    """
    even_tup = []
    for i in tup:
        if type(i) is tuple:
            even_tup.append(i)
        else:
            even_tup.append(i)
    return tuple(even_tup)



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

"""
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_edge, height):
    if base_edge < 0 or base_edge > 100:
        raise ValueError("Base edge must be between 0 and 100")
    if height < 0 or height > 100:
        raise ValueError("Height must be between 0 and 100")
    return base_edge * height



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

"""
Write a function to check if a dictionary is empty
assert my_dict({10})==False
"""
def empty_dict(my_dict):
    return len(my_dict)==0



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

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

def catalan_number(n):
    """
    :param n:
    :return:
    """
    if n == 0:
        return 1
    elif n == 1:
        return 1
    else:
        return catalan_number(n-1) + catalan_number(n-2)



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

"""
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):
    """Find the n most expensive items in a given dataset.
    Assumes that the dataset is a list of dictionaries,
    such as the output of the build_frequent_itemsets function.
    >>> frequent_itemsets = build_frequent_itemsets(
    ..     [{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}])
    >>> expensive_items(frequent_itemsets, 1)
    [{'name': 'Item-2', 'price': 555.22}]
    """
    # TODO: Write your code here
    return sorted(dataset, key=lambda item: item['price'], reverse=True)[:n]



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

"""
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[i:i+n] for i in range(0,len(arr),n)]



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

"""
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_tuple):
    """
    Convert a list to a tuple.
    assert list_tuple([5, 10, 7, 4, 15, 3])==(5, 10, 7, 4, 15, 3)
    """
    return tuple(list_tuple)



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

"""
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(list):
    big_diff = list[0] - list[-1]
    return big_diff



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

"""
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: first number
    :param b: second number
    :return: list of perfect squares
    """
    assert a > 0 and b > 0, "a and b must be positive numbers"
    assert a % 2 == 0 and b % 2 == 0, "a and b must be even numbers"
    assert a > b, "a must be greater than b"
    assert a > 0, "a must be positive"
    assert b > 0, "b must be positive"
    assert a < b, "a must be less than b"
    assert a % 2 == 0, "a must be even"
    assert a > 0, "a must be positive"
    assert b > 0, "b must be positive"
    assert a > b, "a must be greater than b"
    assert a % 2 == 0, "a must be even"
    assert a > 0, "a must be positive"
    assert b > 0, "b must be positive"
    assert a > b, "a must be greater than b"
    assert a % 2 == 0, "a must be even"
    assert a > 0, "a must be positive"
    assert b > 0, "b must be positive"
    assert a > b, "a must be greater than b"
    assert a % 2 == 0, "a must be even"
    assert a > 0, "a must be positive"
    assert b > 0, "b must be positive"
    assert a > b, "a must be greater than b"
    assert a % 2 == 0, "a must be even"
    assert a > 0, "a must be positive"
    assert b > 0, "b must be positive"
    assert a > b, "a must be greater than b"
    assert a % 2 == 0, "a must be even"
    assert a > 0, "a must be positive"
    assert b > 0, "b must be positive"
    assert a > b, "a must be greater than b"
    assert a % 2 == 0, "a must be even"
    assert a > 0, "a must be positive"
    assert b > 0, "b must be positive"
    assert a > b, "a must be greater than b"
    assert a % 2 == 0, "a must be even"
    assert a > 0, "a must be positive"
    assert b > 0, "b must be positive"
    assert a > b, "a must be greater than b"
    assert a % 2 == 0, "a must be even"
    assert a > 0, "a must be positive"
    assert b > 0, "b must be positive"
    assert a > b, "a must be greater than b"
    assert a % 2 == 0, "a must be even"
    assert a > 0, "a must be positive"

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

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



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

"""
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):
    """
    swap the first and last elements in a list
    :param lst: list
    :return: list
    """
    lst[0], lst[-1] = lst[-1], lst[0]
    return lst



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

"""
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):
    coefficients = []
    for i in range(1, n + 1):
        coefficients.append(i * (i - 1) // 2)
    return sum(coefficients)



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

"""
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):
    if ip[0] == '0':
        return ip[1:]
    else:
        return ip



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

"""
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):
    even = 0
    odd = 0
    for i in lst:
        if i % 2 == 0:
            even += 1
        else:
            odd += 1
    return even - odd



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

"""
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(binary, target):
    count = 0
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")
    binary = binary.replace("0","1")
    binary = binary.replace("1","0")

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

"""
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))
"""

def tuple_size(tup):
    return len(tup) * 8



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

"""
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):
    if len(arr1) < len(arr2):
        return find_kth(arr2, arr1, k)
    if len(arr1) == len(arr2):
        return arr1[k-1]
    return arr2[k-1]



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

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

def armstrong_number(number):
    """
    :param number: number to check
    :return: True if number is armstrong else False
    """
    if number < 10:
        return False
    else:
        sum = 0
        for i in range(1, number + 1):
            sum += i
        if sum == number:
            return True
        else:
            return False



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

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



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

"""
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 False
    else:
        return True



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

"""
Write a python function to find the first repeated character in a given string.
assert first_repeated_char("abcabc") == "a"
"""
def first_repeated_char(str):
    """
    :type str: str
    :rtype: str
    """
    # your code here
    return str[0]



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

"""
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_ludic(n):
    ludic = []
    for i in range(1, n+1):
        if i < n:
            ludic.append(i)
    return ludic



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

"""
Write a function to reverse words seperated by spaces in a given string.
assert reverse_words("python program")==("program python")
"""
def reverse_words(str):
    return str.split()[::-1]



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

"""
Write a function to check if the given integer is a prime number.
assert prime_num(13)==True
"""
def prime_num(num):
    if num == 2 or num == 3:
        return True
    if num < 2 or num % 2 == 0:
        return False
    for i in range(3, int(num**0.5)+1, 2):
        if num % i == 0:
            return False
    return True



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

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

def radian_degree(degree):
    return degree * (3.141592653589793 / 180)



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

"""
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)
"""

def find_literals(pattern, string):
    start = 0
    end = len(string)
    while start < end:
        if string[start:end] == pattern:
            return start, start + len(pattern), end
        start += 1
        end -= 1
    return None, None, None



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

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

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



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

"""
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[i] for i in range(len(lst)) if i!= k]



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

"""
Write a function which given a matrix represented as a list of lists returns the max of then'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: a list of lists
    :param n: the index of the column
    :return: the max of the nth column
    """
    # your code here
    return max(matrix[0][n])



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

"""
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(lst):
    """
    :param lst: a list of lists
    :return: a list of two lists where the first list has the first element of each sublist and the second one has the second.
    """
    assert len(lst) > 0, "List is empty"
    assert len(lst[0]) > 0, "List has no elements"
    assert len(lst) == len(set(lst)), "List has duplicate elements"
    assert all(len(lst[i]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][0]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][1]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][0]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][1]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][0]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][1]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][0]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][1]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][0]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][1]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][0]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][1]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][0]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][1]) == 2 for i in range(len(lst))), "List has no duplicate elements"
    assert all(len(lst[i][0]) == 2 for i in range(len(lst))), "List has no duplicate

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

"""
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):
    cum_sum = 0
    for i in tuple_list:
        cum_sum += i[0]
    return cum_sum



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

"""
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):
    return [sum(i)/len(i) for i in zip(*tuple)]



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

"""
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(tuple_1, tuple_2):
    """
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.
    Assumes that the tuples are of the same length.

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

"""
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(l1, l2):
    assert len(l1) == len(l2)
    assert len(l1) > 0
    assert len(l2) > 0
    assert all(isinstance(i, (int, float)) for i in l1)
    assert all(isinstance(i, (int, float)) for i in l2)
    assert all(i > 0 for i in l1)
    assert all(i > 0 for i in l2)
    assert all(i % 2 == 0 for i in l1)
    assert all(i % 2 == 0 for i in l2)
    assert all(i > 0 for i in l1)
    assert all(i > 0 for i in l2)
    assert all(i % 2 == 0 for i in l1)
    assert all(i % 2 == 0 for i in l2)
    assert all(i > 0 for i in l1)
    assert all(i > 0 for i in l2)
    assert all(i % 2 == 0 for i in l1)
    assert all(i % 2 == 0 for i in l2)
    assert all(i > 0 for i in l1)
    assert all(i > 0 for i in l2)
    assert all(i % 2 == 0 for i in l1)
    assert all(i % 2 == 0 for i in l2)
    assert all(i > 0 for i in l1)
    assert all(i > 0 for i in l2)
    assert all(i % 2 == 0 for i in l1)
    assert all(i % 2 == 0 for i in l2)
    assert all(i > 0 for i in l1)
    assert all(i > 0 for i in l2)
    assert all(i % 2 == 0 for i in l1)
    assert all(i % 2 == 0 for i in l2)
    assert all(i > 0 for i in l1)
    assert all(i > 0 for i in l2)
    assert all(i % 2 == 0 for i in l1)
    assert all(i % 2 == 0 for i in l2)
    assert all(i > 0 for i in l1)
    assert all(i > 0 for i in l2)
    assert all(i % 2 == 0 for i in l1)
    assert all(i % 2 == 0 for i in l2)
    assert all(i > 0 for i in l1)
    assert all(i > 0 for i in l2)
    assert all(i % 2 == 0 for i in l1)
    assert all(i % 2 == 0 for i in l2)
    assert all(i > 0 for i in l1)
    assert all(i > 0 for i in l2)
    assert all(i % 2 == 0 for i in l1)
    assert all(i % 2 == 0 for i in l2)
    assert all(i > 0 for i in l1)
    

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

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

def move_num(str):
    for i in range(len(str)):
        str[i] = str[i].rjust(10, '0')
    return str



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

"""
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):
    """
    :type nums: List[int]
    :rtype: int
    """
    # Time complexity: O(n^2)
    # Space Complexity: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)
    # Space: O(n)
    # Runtime: O(n^2)

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

"""
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(a, b):
    if len(a) == len(b):
        return (a + b) / 2
    else:
        return a[len(a) // 2]



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

"""
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):
    """Compute the n-th power of each number in a list.
    Args:
      nums: list of numbers
      n: int, the nth number
    Returns:
      A list of the nth powers of each number in nums.
    """
    assert n >= 1
    assert n <= len(nums)
    
    result = []
    for i in range(len(nums)):
        result.append(nums[i]**n)
    return result



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

"""
Write a python function to convert a given string to uppercase.
assert is_upper("person") =="PERSON"
"""
def is_upper(string):
    return string.isupper()



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

"""
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
    elif radius == 0:
        return 0
    elif radius == 1:
        return 1
    else:
        return (radius**2) * (4 * (1 + (1/3)**2))



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

"""
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(str):
    return str.replace(' ', '%20')



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

"""
Write a python function to find even numbers from a list of numbers.
assert Split([1,2,3,4,5]) == [2,4]
"""
def even_numbers(list):
    even_numbers = []
    for i in list:
        if i % 2 == 0:
            even_numbers.append(i)
    return even_numbers



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

"""
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):
    """
    :param coordinate: tuple of two ints
    :return: list of tuples of two ints
    """
    return [[coordinate[0] + 1, coordinate[1]], [coordinate[0] - 1, coordinate[1]], [coordinate[0], coordinate[1] + 1], [coordinate[0], coordinate[1] - 1], [coordinate[0] + 1, coordinate[1] + 1], [coordinate[0] - 1, coordinate[1] + 1], [coordinate[0] + 1, coordinate[1] - 1], [coordinate[0] - 1, coordinate[1] - 1]]



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

"""
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):
    return string.replace(' ', '_').replace('_', ')



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

"""
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):
    for i in range(len(lst)):
        if lst[i] == 0:
            lst.append(0)
            lst.pop(len(lst)-1)
    return lst



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

"""
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(lst,n):
    sum = 0
    for i in range(len(lst)):
        for j in range(i+1,len(lst)):
            sum += lst[i] ^ lst[j]
    return sum



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

"""
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(lst):
    heap = []
    for i in range(len(lst)):
        heapq.heappush(heap, lst[i])
    for i in range(len(heap)):
        lst[i] = heapq.heappop(heap)
    return lst



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

"""
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,budget):
    if amount<budget:
        return False
    elif amount>budget:
        return True
    else:
        return False



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

"""
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):
    """
    :param velocity: wind velocity in km/h
    :param temperature: temperature in celsius
    :return: wind chill index rounded to the next integer given the wind velocity in km/h and a temperature in celsius
    """
    assert velocity > 0 and temperature > 0, "Velocity and temperature must be positive"
    assert temperature <= 100, "Temperature must be less than 100"
    assert velocity <= 100, "Velocity must be less than 100"
    assert 0 <= temperature <= 100, "Temperature must be less than 100"
    assert 0 <= wind_chill(velocity, temperature) <= 100, "Wind chill index must be between 0 and 100"
    return round(wind_chill(velocity, temperature), 2)



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

"""
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 sum_length(names):
    return len([name for name in names if name[0].islower()])



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

"""
Write a function to remove the parenthesis and what is inbetween them from a string.
assert remove_parenthesis(["python (chrome)"])==("python")
"""
def remove_parenthesis(s):
    s = s.replace(')', '')
    s = s.replace('(', '')
    return s



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

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

def is_nonagonal(n):
    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
    if n == 21:
        return True
    if n == 22:
        return True
    if n == 23:
        return True
    if n == 24:
        return True
    if n == 25:

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

"""
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':
        return False
    else:
        return True



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

"""
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 len(arr) <= k:
        return arr
    else:
        return reverse_Array_Upto_K(arr[k:], k) + arr[:k]



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

"""
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(tuple_to_add, dictionary):
    for key in dictionary:
        tuple_to_add[key] = dictionary[key]
    return tuple_to_add



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

"""
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.
    n = len(matrix)
    if n == 0:
        return 0
    m = len(matrix[0])
    if m == 0:
        return 0
    total = 0
    visited = []
    for i in range(n):
        for j in range(m):
            if matrix[i][j]!= 0:
                total += matrix[i][j]
                visited.append((i, j))
    if len(visited) == 0:
        return 0
    path = []
    for i in range(n):
        for j in range(m):
            if matrix[i][j]!= 0:
                path.append((i, j))
    path.sort()
    path_len = len(path)
    total_cost = 0
    for i in range(path_len):
        total_cost += matrix[path[i][0]][path[i][1]]
    total_cost /= path_len
    return total_cost / len(visited)



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

"""
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(student_data, min_height, min_weight):
    """
    :param student_data: 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.
    :param min_height: the minimum height of the student.
    :param min_weight: the minimum weight of the student.
    :return: 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.
    """
    filtered_data = {}
    for student in student_data:
        if student_data[student][0] >= min_height and student_data[student][1] >= min_weight:
            filtered_data[student] = student_data[student]
    return filtered_data



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

"""
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: the number of indices where the lists have the same values
    """
    count = 0
    for i in range(len(list1)):
        if list1[i] == list2[i]:
            count += 1
    return count



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

"""
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):
    sum = 0
    while base > 0:
        digit = base % 10
        sum += digit
        base = base // 10
    return sum * power



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

"""
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):
    return string.split('"')[1::2]



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

"""
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_1, t_N):
    """
    Assume t_1 is a tuple of length N and t_N is a tuple of length N.
    Assume t_1[i] * t_{i+1} = t_i * t_{i+1}.
    """
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)
    assert len(t_1) == len(t_N)


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

"""
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_1,b_1):
    return [a_1+b_1 for a_1,b_1 in zip(a_1,b_1)]



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

"""
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 of numbers
    :return: list of numbers without consecutive duplicates
    """
    lst.sort()
    i = 0
    while i < len(lst):
        if lst[i] == lst[i+1]:
            lst.pop(i)
            lst.pop(i)
            i -= 1
        else:
            i += 1
    return lst



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

"""
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 lateral_surface_cone(r,h):
    return (r**2)*(h/2)



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

"""
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(text):
    text = text.replace(' ', ':')
    text = text.replace(',', ':')
    text = text.replace('.', ':')
    return text



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

"""
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):
    low = 0
    high = len(arr) - 1
    while low <= high:
        mid = (low + high) // 2
        if arr[mid] == num:
            return mid
        elif arr[mid] < num:
            low = mid + 1
        else:
            high = mid - 1
    return -1



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

"""
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 your code here.
    sum = 0
    for i in range(len(arr)):
        for j in range(i+1, len(arr)):
            sum += arr[i] * arr[j]
    return sum



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

"""
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):
    """
    :param n: number to toggle
    :return: number with the middle bit turned off
    """
    return n & (n - 1)



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

"""
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: unsorted list
    :param value: value to be inserted
    :return: index of the left insertion point
    """
    # if the value is not in the list
    if value not in arr:
        return -1
    # if the value is in the list
    else:
        # find the index of the value
        index = arr.index(value)
        # if the index is greater than the length of the list
        if index > len(arr) - 1:
            # return the index of the value
            return index
        # if the index is less than the length of the list
        elif index < 0:
            # return the index of the value
            return index
        # if the index is equal to the length of the list
        else:
            # return the index of the value
            return index



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

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


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

"""
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):
    if n == 1:
        return 0
    if n == 2:
        return 1
    if n == 3:
        return 2
    if n == 4:
        return 3
    if n == 5:
        return 4
    if n == 6:
        return 5
    if n == 7:
        return 6
    if n == 8:
        return 7
    if n == 9:
        return 8
    if n == 10:
        return 9
    if n == 11:
        return 10
    if n == 12:
        return 11
    if n == 13:
        return 12
    if n == 14:
        return 13
    if n == 15:
        return 14
    if n == 16:
        return 15
    if n == 17:
        return 16
    if n == 18:
        return 17
    if n == 19:
        return 18
    if n == 20:
        return 19
    if n == 21:
        return 20
    if n == 22:
        return 21
    if n == 23:
        return 22
    if n == 24:
        return 23
    if n == 25:

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

"""
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(tuple):
    """
    Convert the given tuple to a key-value dictionary using adjacent elements.
    Assume that the tuple is a tuple of tuples.
    """
    assert len(tuple) == 2, "tuple must be a tuple of tuples"
    assert tuple[0] == tuple[1], "tuple must be a tuple of tuples"
    assert type(tuple[0]) == tuple, "tuple must be a tuple of tuples"
    assert type(tuple[1]) == tuple, "tuple must be a tuple of tuples"
    assert type(tuple[0][0]) == int, "tuple must be a tuple of tuples"
    assert type(tuple[1][0]) == int, "tuple must be a tuple of tuples"
    assert type(tuple[0][1]) == int, "tuple must be a tuple of tuples"
    assert type(tuple[1][1]) == int, "tuple must be a tuple of tuples"
    assert type(tuple[0][0]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[1][0]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[0][1]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[1][1]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[0][0]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[1][0]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[0][1]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[1][1]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[0][0]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[1][0]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[0][1]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[1][1]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[0][0]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[1][0]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[0][1]) == str, "tuple must be a tuple of tuples"
    assert type(tuple[1][1]) == str, "tuple must be a tuple of tuples"
    assert

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

"""
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):
    for i in string:
        if i not in string:
            return False
    return True



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

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

def area_tetrahedron(a):
    return a*a*a



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

"""
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):
    """
    Rotate a list by n items to the right direction.
    :param lst: list to rotate
    :param n: number of items to rotate
    :return: rotated list
    """
    return lst[n:] + lst[:n]



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

"""
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--------------------------------------------------

"""
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):
    """
    :param startnum: start number
    :param endnum: end number
    :return: list of numbers divisible by every digit it contains
    """
    assert startnum > 0 and endnum > 0, "startnum and endnum must be positive"
    assert type(startnum) == int and type(endnum) == int, "startnum and endnum must be int"
    assert startnum % 10 == 0 and endnum % 10 == 0, "startnum and endnum must be divisible by every digit it contains"
    assert startnum > endnum, "startnum must be greater than endnum"
    assert startnum < endnum, "startnum must be less than endnum"
    assert startnum <= endnum, "startnum must be less than endnum"
    assert startnum > 0 and endnum > 0, "startnum and endnum must be positive"
    assert type(startnum) == int and type(endnum) == int, "startnum and endnum must be int"
    assert startnum % 10 == 0 and endnum % 10 == 0, "startnum and endnum must be divisible by every digit it contains"
    assert startnum > endnum, "startnum must be greater than endnum"
    assert startnum < endnum, "startnum must be less than endnum"
    assert startnum > 0 and endnum > 0, "startnum and endnum must be positive"
    assert type(startnum) == int and type(endnum) == int, "startnum and endnum must be int"
    assert startnum > endnum, "startnum must be greater than endnum"
    assert startnum < endnum, "startnum must be less than endnum"
    assert startnum > 0 and endnum > 0, "startnum and endnum must be positive"
    assert type(startnum) == int and type(endnum) == int, "startnum and endnum must be int"
    assert startnum % 10 == 0 and endnum % 10 == 0, "startnum and endnum must be divisible by every digit it contains"
    assert startnum > endnum, "startnum must be greater than endnum"
    assert startnum < endnum, "startnum must be less than endnum"
    assert startnum > 0 and endnum > 0, "startnum and endnum must be positive"
    assert type(startnum) == int and type(endnum) == int, "startnum and endnum must be int"
    assert startnum > endnum, "startnum must be greater than endnum"
    assert startnum < endnum, "startnum must be less than endnum"
    assert startnum > 0 and endnum > 0, "startnum and endnum must be positive"


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

"""
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(r, angle):
    if angle > 360:
        return None
    elif angle == 0:
        return r * r
    elif angle == 90:
        return r * (r * r * r)
    elif angle == 180:
        return r * (r * r * r * r)
    elif angle == 270:
        return r * (r * r * r * r * r)
    elif angle == 360:
        return r * (r * r * r * r * r * r)



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

"""
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):
    return string.title()



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

"""
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(numbers):
    numbers.sort()
    return numbers



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

"""
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(tuple_list, tuple_tuple):
    """
    tuple_list: list of tuples
    tuple_tuple: tuple of tuples
    """
    for i in range(len(tuple_list)):
        tuple_list[i] = tuple_tuple
    return tuple_list



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

"""
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):
    if len(arr) == 1:
        return True
    if arr[0] < arr[1]:
        return False
    if arr[0] < arr[2]:
        return False
    if arr[0] < arr[3]:
        return False
    if arr[0] < arr[4]:
        return False
    if arr[0] < arr[5]:
        return False
    if arr[0] < arr[6]:
        return False
    if arr[0] < arr[7]:
        return False
    if arr[0] < arr[8]:
        return False
    if arr[0] < arr[9]:
        return False
    if arr[0] < arr[10]:
        return False
    if arr[0] < arr[11]:
        return False
    if arr[0] < arr[12]:
        return False
    if arr[0] < arr[13]:
        return False
    if arr[0] < arr[14]:
        return False
    if arr[0] < arr[15]:
        return False
    if arr[0] < arr[16]:
        return False
    if arr[0] < arr[17]:
        return False
    if arr[0] < arr[18]:
        return False
    if arr[0] < arr[19]:
        return False
    if arr[0] < arr[20]:
        return False
    if arr[0] < arr[21]:
        return False
    if arr[0] < arr[22]:
        return False
    if arr[0] < arr[23]:
        return False
    if arr[0] < arr[24]:

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

"""
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):
    if n == 1:
        return 1
    elif n == 2:
        return 2
    elif n == 3:
        return 3
    elif n == 4:
        return 4
    elif n == 5:
        return 5
    elif n == 6:
        return 6
    elif n == 7:
        return 7
    elif n == 8:
        return 8
    elif n == 9:
        return 9
    elif n == 10:
        return 10
    elif n == 11:
        return 11
    elif n == 12:
        return 12
    elif n == 13:
        return 13
    elif n == 14:
        return 14
    elif n == 15:
        return 15
    elif n == 16:
        return 16
    elif n == 17:
        return 17
    elif n == 18:
        return 18
    elif n == 19:
        return 19
    elif n == 20:
        return 20
    elif n == 21:
        return 21
    elif n == 22:
        return 22
    elif n == 23:
        return 23
    elif n == 24:
        return 24
    elif n == 25:

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

"""
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: tuple of tuples
    :param k: minimum number of records
    :return: minimum k records
    """
    if len(tuple_list) < k:
        return None
    else:
        return min(tuple_list, key=lambda x: x[k])



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

"""
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] in l2:
            common_elements.append(l1[i])
        if l2[i] in l3:
            common_elements.append(l2[i])
        if l3[i] in l1:
            common_elements.append(l3[i])
    return common_elements



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

"""
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(lst):
    """
    :param lst: list of numbers
    :return: the second smallest number in the list
    """
    # TODO: Write your code here
    return lst[1]



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

"""
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(list_of_strings):
    count = 0
    for i in range(len(list_of_strings)):
        for j in range(i+1, len(list_of_strings)):
            if list_of_strings[i] == list_of_strings[j]:
                count += 1
    return count



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

"""
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):
    """
    Convert a list to a tuple and count its occurencies.
    """
    d = {}
    for i in lst:
        t = tuple(i)
        if t in d:
            d[t] += 1
        else:
            d[t] = 1
    return d



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

"""
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(number):
    """
    :param number: a string
    :return: True if number is a decimal number with a precision of 2, False otherwise
    """
    try:
        float(number)
        if len(number) == 0:
            return False
        if len(number) == 1:
            return True
        if number[0] == '.':
            return True
        if number[0] == '-' or number[0] == '+':
            return False
        if number[0] == '0':
            return True
        return False
    except ValueError:
        return False



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

"""
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):
    """
    :type nums: List[int]
    :rtype: bool
    """
    if len(set(nums)) == 1:
        return True
    else:
        return False



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

"""
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(month):
    if month == 1 or month == 2 or month == 3 or month == 4 or month == 5 or month == 6 or month == 7 or month == 8 or month == 9 or month == 10 or month == 11 or month == 12:
        return True
    else:
        return False



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

"""
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):
    min_diff = arr[0] - arr[1]
    for i in range(2, n):
        min_diff = min(min_diff, arr[i] - arr[i-1])
    return min_diff



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

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

def number_ctr(str):
    count = 0
    for i in str:
        if i.isdigit():
            count += 1
    return count



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

"""
Write a function to find nth polite number. geeksforgeeks.org/n-th-polite-number/
assert is_polite(7) == 11
"""
def nth_polite(n):
    if n == 1:
        return 1
    else:
        return nth_polite(n-1) + nth_polite(n-2) + nth_polite(n-3)



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

"""
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):
    """
    Assumes lst is a list of integers
    Returns a list of tuples of consecutive integers
    """
    return [(i, i+1) for i in range(len(lst)-1)]



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

"""
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(lst, sum):
    count = 0
    for i in range(len(lst)):
        for j in range(i+1, len(lst)):
            if lst[i] + lst[j] == sum:
                count += 1
    return count



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

"""
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):
    """
    list1: list of numbers
    list2: list of numbers
    return: list of numbers
    """
    assert len(list1) == len(list2), "Length of list1 and list2 should be same"
    diff = []
    for i in range(len(list1)):
        diff.append(list1[i] - list2[i])
    return diff



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

"""
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):
    sum = 0
    for i in range(1, n+1):
        sum += i**4
    return sum



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

"""
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 i in expression:
        if i == '(':
            stack.append(i)
        elif i == ')':
            if len(stack) == 0:
                return False
            else:
                stack.pop()
    if len(stack)!= 0:
        return False
    else:
        return True



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

"""
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):
    words = string.split()
    for word in words:
        if len(word) == k:
            words.remove(word)
    return '.join(words)



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

"""
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):
    """
    :type string: str
    :type substring: str
    :rtype: tuple[int, int]
    """
    if len(string) < len(substring):
        return None
    if len(string) == len(substring):
        return (0, len(string))
    if string[0:len(substring)] == substring:
        return (0, len(string))
    if string[0:len(substring)]!= substring:
        return None
    for i in range(len(string) - len(substring) + 1):
        if string[i:i + len(substring)] == substring:
            return (i, i + len(substring))
    return None



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

"""
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(len(lst)):
        if lst[i] % 2!= 0:
            return True
    return False



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

"""
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(lst):
    """
    :param lst: list of numbers
    :return: sum of non-repeated elements in lst
    """
    return sum(set(lst))



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

"""
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):
    """
    :type lst: List[int]
    :rtype: List[List[int]]
    """
    lst_len = len(lst)
    if lst_len == 0:
        return []
    elif lst_len == 1:
        return [lst]
    else:
        sublists = []
        for i in range(lst_len):
            if i == 0:
                sublists.append([lst[i]])
            elif i == lst_len - 1:
                sublists.append([lst[i]])
            else:
                sublists.append([lst[i], lst[i + 1]])
        return sublists



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

"""
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):
    """
    :param tuple_list: a list of tuples
    :return: a list of tuples
    """
    # TODO: Write your code here
    combinations = []
    for i in range(len(tuple_list)):
        for j in range(i+1, len(tuple_list)):
            combinations.append(tuple_list[i] + tuple_list[j])
    return combinations



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

"""
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):
    divisors = []
    for i in range(1, n + 1):
        if n % i == 0:
            divisors.append(i)
    return len(divisors)



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

"""
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):
    sum = 0
    for i in range(len(arr)):
        if i % 2 == 0:
            sum += arr[i]
    return sum



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

"""
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):
    """
    Convert rgb color to hsv color.
    :param r: Red value
    :param g: Green value
    :param b: Blue value
    :return: tuple of hsv color
    """
    r = int(r)
    g = int(g)
    b = int(b)
    if r == 0:
        return (0, 0, 0)
    elif g == 0:
        return (0, 0, 0)
    elif b == 0:
        return (0, 0, 0)
    elif r > 255:
        r = 255
    elif g > 255:
        g = 255
    elif b > 255:
        b = 255
    elif r < 0:
        r = 0
    elif g < 0:
        g = 0
    elif b < 0:
        b = 0
    elif r > 255:
        r = 255
    elif g > 255:
        g = 255
    elif b > 255:
        b = 255
    elif r < 0:
        r = 0
    elif g < 0:
        g = 0
    elif b < 0:
        b = 0
    elif r > 255:
        r = 255
    elif g > 255:
        g = 255
    elif b > 255:
        b = 255
    elif r < 0:
        r = 0
    elif g < 0:

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

"""
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):
    even = 0
    odd = 0
    for i in lst:
        if i % 2 == 0:
            even += i
        else:
            odd += i
    return even * odd



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

"""
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):
    return tuple(map(int, tuple_str.split(',')))



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

"""
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):
    if len(arr) == 0:
        return -1
    if arr[0] == value:
        return 0
    if arr[0] > value:
        return len(arr)
    if arr[0] < value:
        return len(arr) - 1
    if arr[0] > value:
        return right_insertion(arr[1:], value)
    if arr[0] < value:
        return right_insertion(arr[1:], value)
    return -1



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

"""
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):
    if len(text) < 3:
        return False
    if text[0]!= 'a' or text[-1]!= 'b':
        return False
    return True



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

"""
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(string, list):
    assert type(string) == str and type(list) == list, "string and list must be strings"
    assert len(string) == len(list), "string and list must be of the same length"
    new_tuple = tuple(string)
    for i in range(len(list)):
        new_tuple += (list[i],)
    return new_tuple



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

"""
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(list):
    for i in range(len(list)):
        if list[i] % 2 == 0:
            print(list[i])
            return False
    return True



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

"""
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(tuple):
    return tuple[0], tuple[1], tuple[2], tuple[3], tuple[4]



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

"""
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: a list of lists
    :return: the number of lists in the given number of lists
    """
    return len(lst)



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

"""
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):
    if len(arr) == 0:
        return -1
    if arr[0] == x:
        return 0
    if arr[0] > x:
        return last(arr[1:],x)
    else:
        return last(arr[1:],x) + 1



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

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

def text_starta_endb(text):
    if text[0] == 'a':
        if text[-1] == 'b':
            return True
    return False



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

"""
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(d):
    sum = 0
    for key in d:
        sum += d[key]
    return sum



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

"""
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):
    sum = 0
    for i in range(l,r+1):
        if i % 2!= 0:
            sum += i
    return sum



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

"""
Write a python function to find the sum of an array.
assert _sum([1, 2, 3]) == 6
"""
def _sum(arr):
    """
    :param arr: array to find the sum
    :return: sum of the array
    """
    sum = 0
    for i in arr:
        sum += i
    return sum



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

"""
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(num, d):
    return ((num << d) | (num >> (32 - d))) & 0xFFFFFFFF



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

"""
Write a function to remove all whitespaces from a string.
assert remove_all_spaces('python  program')==('pythonprogram')
"""
def remove_all_spaces(string):
    return string.replace(' ', '')



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

"""
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):
    assert a == b == c



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

"""
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):
    if n == 0:
        return False
    if n == 1:
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    if n % 5 == 0:
        return False
    return is_perfect_square(n - 1)



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

"""
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):
    for i in range(len(numbers)):
        if numbers[i] % 2 == 0:
            return False
    return True



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

"""
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(lst):
    max_sum = 0
    for i in lst:
        sum = 0
        for j in i:
            sum += j
        if sum > max_sum:
            max_sum = sum
    return max_sum



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

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

def max_run_uppercase(str):
    max_run = 0
    for i in range(len(str)):
        if str[i].isupper():
            max_run += 1
    return max_run



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

"""
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(numbers):
    """
    :param numbers: list of numbers
    :return: the first odd number
    """
    assert len(numbers) > 0, "List must not be empty"
    assert all(type(n) == int for n in numbers), "All numbers must be int"
    assert all(n % 2 == 0 for n in numbers), "All numbers must be even"
    assert all(n % 2 == 1 for n in numbers), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 1), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2 == 0 for n in numbers if n % 2 == 0), "All numbers must be odd"
    assert all(n % 2

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

"""
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 i[k] == k:
            return True
    return False



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

"""
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(tup1, tup2):
    for i in range(len(tup1)):
        if tup1[i] < tup2[i]:
            return False
    return True

