






'''simple docstring'''
def  _a(  UpperCamelCase__				:						int							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__     :				List[str]									=generate_pascal_triangle(UpperCamelCase__							)
      for row_idx in range(UpperCamelCase__							):
            # Print left spaces
            for _ in range(num_rows - row_idx - 1							):
                  print(end=''' '''							)
            # Print row values
            for col_idx in range(row_idx + 1							):
                  if col_idx != row_idx:
                        print(triangle[row_idx][col_idx],	end=''' '''							)
                  else:
                        print(triangle[row_idx][col_idx],	end=''''''							)
            print()





def  _a(  UpperCamelCase__				:						int							):




      '''simple docstring'''






      if not isinstance(UpperCamelCase__,	UpperCamelCase__							):
            raise TypeError('''The input value of \'num_rows\' should be \'int\''''							)

      if num_rows == 0:
            return []
      elif num_rows < 0:
            raise ValueError(
                '''The input value of \'num_rows\' should be greater than or equal to 0'''							)

      SCREAMING_SNAKE_CASE__     :				list[list[int]]									=[]
      for current_row_idx in range(UpperCamelCase__							):
            SCREAMING_SNAKE_CASE__     :				Optional[Any]									=populate_current_row(UpperCamelCase__,	UpperCamelCase__							)
            triangle.append(UpperCamelCase__							)
      return triangle





def  _a(  UpperCamelCase__				:						list[list[int]],	UpperCamelCase__				:						int							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__     :				Optional[Any]									=[-1] * (current_row_idx + 1)
      # first and last elements of current row are equal to 1
      SCREAMING_SNAKE_CASE__		,	SCREAMING_SNAKE_CASE__     :				List[str]									=1, 1
      for current_col_idx in range(1,	UpperCamelCase__							):
            calculate_current_element(
                UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__							)
      return current_row





def  _a(  UpperCamelCase__				:						list[list[int]],	UpperCamelCase__				:						list[int],	UpperCamelCase__				:						int,	UpperCamelCase__				:						int,	):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__     :				Dict									=triangle[current_row_idx - 1][current_col_idx - 1]
      SCREAMING_SNAKE_CASE__     :				str									=triangle[current_row_idx - 1][current_col_idx]
      SCREAMING_SNAKE_CASE__     :				str									=above_to_left_elt + above_to_right_elt





def  _a(  UpperCamelCase__				:						int							):




      '''simple docstring'''






      if not isinstance(UpperCamelCase__,	UpperCamelCase__							):
            raise TypeError('''The input value of \'num_rows\' should be \'int\''''							)

      if num_rows == 0:
            return []
      elif num_rows < 0:
            raise ValueError(
                '''The input value of \'num_rows\' should be greater than or equal to 0'''							)

      SCREAMING_SNAKE_CASE__     :				list[list[int]]									=[[1]]

      for row_index in range(1,	UpperCamelCase__							):
            SCREAMING_SNAKE_CASE__     :				Tuple									=[0] + result[-1] + [0]
            SCREAMING_SNAKE_CASE__     :				List[Any]									=row_index + 1
            # Calculate the number of distinct elements in a row
            SCREAMING_SNAKE_CASE__     :				int									=sum(divmod(UpperCamelCase__,	2							)							)
            SCREAMING_SNAKE_CASE__     :				str									=[
                temp_row[i - 1] + temp_row[i] for i in range(1,	distinct_elements + 1							)
            ]
            SCREAMING_SNAKE_CASE__     :				int									=row_first_half[: (row_index + 1) // 2]
            row_second_half.reverse()
            SCREAMING_SNAKE_CASE__     :				Optional[int]									=row_first_half + row_second_half
            result.append(UpperCamelCase__							)

      return result





def  _a(  ):




      '''simple docstring'''






      from collections.abc import Callable
      from timeit import timeit

      def benchmark_a_function(UpperCamelCase__				:						Callable,	UpperCamelCase__				:						int							) -> None:
            SCREAMING_SNAKE_CASE__     :				List[Any]									=f"{func.__name__}({value})"
            SCREAMING_SNAKE_CASE__     :				Optional[int]									=timeit(f"__main__.{call}",	setup='''import __main__'''							)
            # print(f"{call:38} = {func(value)} -- {timing:.4f} seconds")
            print(f"{call:38} -- {timing:.4f} seconds"							)

      for value in range(1_5							):  # (1, 7, 14):
            for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):
                  benchmark_a_function(UpperCamelCase__,	UpperCamelCase__							)
            print()


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  benchmark()







'''simple docstring'''
def  _a(  UpperCamelCase__				:						Optional[int],	UpperCamelCase__				:						int							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__     :				Optional[int]									=0
      SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=len(UpperCamelCase__							) - 1

      while left <= right:
            # avoid divided by 0 during interpolation
            if sorted_collection[left] == sorted_collection[right]:
                  if sorted_collection[left] == item:
                        return left
                  else:
                        return None

            SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=left + ((item - sorted_collection[left]) * (right - left)) // (
                sorted_collection[right] - sorted_collection[left]
            )

            # out of range check
            if point < 0 or point >= len(UpperCamelCase__							):
                  return None

            SCREAMING_SNAKE_CASE__     :				Optional[int]									=sorted_collection[point]
            if current_item == item:
                  return point
            else:
                  if point < left:
                        SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=left
                        SCREAMING_SNAKE_CASE__     :				Optional[Any]									=point
                  elif point > right:
                        SCREAMING_SNAKE_CASE__     :				Optional[int]									=right
                        SCREAMING_SNAKE_CASE__     :				Tuple									=point
                  else:
                        if item < current_item:
                              SCREAMING_SNAKE_CASE__     :				str									=point - 1
                        else:
                              SCREAMING_SNAKE_CASE__     :				Tuple									=point + 1
      return None





def  _a(  UpperCamelCase__				:						List[str],	UpperCamelCase__				:						Optional[Any],	UpperCamelCase__				:						Union[str, Any],	UpperCamelCase__				:						Union[str, Any]							):




      '''simple docstring'''






      if sorted_collection[left] == sorted_collection[right]:
            if sorted_collection[left] == item:
                  return left
            else:
                  return None

      SCREAMING_SNAKE_CASE__     :				Dict									=left + ((item - sorted_collection[left]) * (right - left)) // (
          sorted_collection[right] - sorted_collection[left]
      )

      # out of range check
      if point < 0 or point >= len(UpperCamelCase__							):
            return None

      if sorted_collection[point] == item:
            return point
      elif point < left:
            return interpolation_search_by_recursion(UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__							)
      elif point > right:
            return interpolation_search_by_recursion(UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__							)
      else:
            if sorted_collection[point] > item:
                  return interpolation_search_by_recursion(
                      UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__,	point - 1							)
            else:
                  return interpolation_search_by_recursion(
                      UpperCamelCase__,	UpperCamelCase__,	point + 1,	UpperCamelCase__							)





def  _a(  UpperCamelCase__				:						Dict							):




      '''simple docstring'''






      if collection != sorted(UpperCamelCase__							):
            raise ValueError('''Collection must be ascending sorted'''							)
      return True


if __name__ == "__main__":
  import sys
  a_					= 0
  if debug == 1:
    a_					= [1_0, 3_0, 4_0, 4_5, 5_0, 6_6, 7_7, 9_3]
    try:
      __assert_sorted(collection)
    except ValueError:
      sys.exit('Sequence must be ascending sorted to apply interpolation search')
    a_					= 6_7

  a_					= interpolation_search(collection, target)
  if result is not None:
    print(F'''{target} found at positions: {result}''')
  else:
    print('Not found')