






'''simple docstring'''
from __future__ import annotations

from collections.abc import Callable

a_					= list[list[float | int]]





def  _a(  UpperCamelCase__				:						Matrix,	UpperCamelCase__				:						Matrix							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__     :				int									=len(UpperCamelCase__							)
      SCREAMING_SNAKE_CASE__     :				Matrix									=[[0 for _ in range(size + 1							)] for _ in range(UpperCamelCase__							)]
      SCREAMING_SNAKE_CASE__     :				int
      SCREAMING_SNAKE_CASE__     :				int
      SCREAMING_SNAKE_CASE__     :				int
      SCREAMING_SNAKE_CASE__     :				int
      SCREAMING_SNAKE_CASE__     :				int
      SCREAMING_SNAKE_CASE__     :				float

      for row in range(UpperCamelCase__							):
            for col in range(UpperCamelCase__							):
                  SCREAMING_SNAKE_CASE__     :				Tuple									=matrix[row][col]

            SCREAMING_SNAKE_CASE__     :				Optional[int]									=vector[row][0]

      SCREAMING_SNAKE_CASE__     :				Any									=0
      SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=0
      while row < size and col < size:
            # pivoting
            SCREAMING_SNAKE_CASE__     :				Any									=max((abs(augmented[rowa][col]							), rowa) for rowa in range(UpperCamelCase__,	UpperCamelCase__							)							)[
                1
            ]
            if augmented[pivot_row][col] == 0:
                  col += 1
                  continue
            else:
                  SCREAMING_SNAKE_CASE__		,	SCREAMING_SNAKE_CASE__     :				Optional[Any]									=augmented[pivot_row], augmented[row]

            for rowa in range(row + 1,	UpperCamelCase__							):
                  SCREAMING_SNAKE_CASE__     :				Union[str, Any]									=augmented[rowa][col] / augmented[row][col]
                  SCREAMING_SNAKE_CASE__     :				Tuple									=0
                  for cola in range(col + 1,	size + 1							):
                        augmented[rowa][cola] -= augmented[row][cola] * ratio

            row += 1
            col += 1

      # back substitution
      for col in range(1,	UpperCamelCase__							):
            for row in range(UpperCamelCase__							):
                  SCREAMING_SNAKE_CASE__     :				Optional[Any]									=augmented[row][col] / augmented[col][col]
                  for cola in range(UpperCamelCase__,	size + 1							):
                        augmented[row][cola] -= augmented[col][cola] * ratio

    # round to get rid of numbers like 2.000000000000004
      return [
          [round(augmented[row][size] / augmented[row][row],	1_0							)] for row in range(UpperCamelCase__							)
      ]





def  _a(  UpperCamelCase__				:						list[int]							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__     :				int									=len(UpperCamelCase__							)
      SCREAMING_SNAKE_CASE__     :				Matrix									=[[0 for _ in range(UpperCamelCase__							)] for _ in range(UpperCamelCase__							)]
      SCREAMING_SNAKE_CASE__     :				Matrix									=[[0] for _ in range(UpperCamelCase__							)]
      SCREAMING_SNAKE_CASE__     :				Matrix
      SCREAMING_SNAKE_CASE__     :				int
      SCREAMING_SNAKE_CASE__     :				int
      SCREAMING_SNAKE_CASE__     :				int

      for x_val, y_val in enumerate(UpperCamelCase__							):
            for col in range(UpperCamelCase__							):
                  SCREAMING_SNAKE_CASE__     :				Optional[int]									=(x_val + 1) ** (size - col - 1)
            SCREAMING_SNAKE_CASE__     :				Dict									=y_val

      SCREAMING_SNAKE_CASE__     :				Optional[int]									=solve(UpperCamelCase__,	UpperCamelCase__							)

      def interpolated_func(UpperCamelCase__				:						int							) -> int:
            return sum(
                round(coeffs[x_val][0]							) * (var ** (size - x_val - 1))
                for x_val in range(UpperCamelCase__							)							)

      return interpolated_func





def  _a(  UpperCamelCase__				:						int							):




      '''simple docstring'''






      return (
          1
          - variable
          + variable**2
          - variable**3
          + variable**4
          - variable**5
          + variable**6
          - variable**7
          + variable**8
          - variable**9
          + variable**1_0
      )





def  _a(  UpperCamelCase__				:						Callable[[int], int] = question_function,	UpperCamelCase__				:						int = 1_0							):




      '''simple docstring'''






      SCREAMING_SNAKE_CASE__     :				list[int]									=[func(UpperCamelCase__							) for x_val in range(1,	order + 1							)]

      SCREAMING_SNAKE_CASE__     :				list[Callable[[int], int]]									=[
          interpolate(data_points[:max_coeff]							) for max_coeff in range(1,	order + 1							)
      ]

      SCREAMING_SNAKE_CASE__     :				int									=0
      SCREAMING_SNAKE_CASE__     :				Callable[[int], int]
      SCREAMING_SNAKE_CASE__     :				int

      for poly in polynomials:
            SCREAMING_SNAKE_CASE__     :				Any									=1
            while func(UpperCamelCase__							) == poly(UpperCamelCase__							):
                  x_val += 1

            ret += poly(UpperCamelCase__							)

      return ret


if __name__ == "__main__":
  print(F'''{solution() = }''')







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