





'''simple docstring'''

import baseaa

def 						__magic_name__       (							__UpperCAmelCase      )						->					bytes:

   '''simple docstring'''







   return baseaa.aaaencode(string.encode("""utf-8"""      )      )

def 						__magic_name__       (							__UpperCAmelCase      )						->					str:

   '''simple docstring'''







   return baseaa.aaadecode(_lowercase      ).decode("""utf-8"""      )


if __name__ == "__main__":
    import doctest

    doctest.testmod()












'''simple docstring'''

from __future__ import annotations

from collections.abc import Callable

a        =						list[list[float | int]]

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase      )						->					Matrix:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       len(__UpperCAmelCase      )
   __SCREAMING_SNAKE_CASE      							=       [[0 for _ in range(size + 1      )] for _ in range(__UpperCAmelCase      )]
   __SCREAMING_SNAKE_CASE      							=       42
   __SCREAMING_SNAKE_CASE      							=       42
   __SCREAMING_SNAKE_CASE      							=       42
   __SCREAMING_SNAKE_CASE      							=       42
   __SCREAMING_SNAKE_CASE      							=       42
   __SCREAMING_SNAKE_CASE      							=       42

   for row in range(__UpperCAmelCase      ):
      for col in range(__UpperCAmelCase      ):
         __SCREAMING_SNAKE_CASE      							=       matrix[row][col]

      __SCREAMING_SNAKE_CASE      							=       vector[row][0]

   __SCREAMING_SNAKE_CASE      							=       0
   __SCREAMING_SNAKE_CASE      							=       0
   while row < size and col < size:
      # pivoting
      __SCREAMING_SNAKE_CASE      							=       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      							=       augmented[pivot_row], augmented[row]

      for rowa in range(row + 1							,	__UpperCAmelCase      ):
         __SCREAMING_SNAKE_CASE      							=       augmented[rowa][col] / augmented[row][col]
         __SCREAMING_SNAKE_CASE      							=       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      							=       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]							,	10      )] for row in range(__UpperCAmelCase      )
   ]

def 						__magic_name__       (							__UpperCAmelCase      )						->					Callable[[int], int]:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       len(__UpperCAmelCase      )
   __SCREAMING_SNAKE_CASE      							=       [[0 for _ in range(__UpperCAmelCase      )] for _ in range(__UpperCAmelCase      )]
   __SCREAMING_SNAKE_CASE      							=       [[0] for _ in range(__UpperCAmelCase      )]
   __SCREAMING_SNAKE_CASE      							=       42
   __SCREAMING_SNAKE_CASE      							=       42
   __SCREAMING_SNAKE_CASE      							=       42
   __SCREAMING_SNAKE_CASE      							=       42

   for x_val, y_val in enumerate(__UpperCAmelCase      ):
      for col in range(__UpperCAmelCase      ):
         __SCREAMING_SNAKE_CASE      							=       (x_val + 1) ** (size - col - 1)
      __SCREAMING_SNAKE_CASE      							=       y_val

   __SCREAMING_SNAKE_CASE      							=       solve(__UpperCAmelCase							,	__UpperCAmelCase      )

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

   return interpolated_func

def 						__magic_name__       (							__UpperCAmelCase      )						->					int:

   '''simple docstring'''







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

def 						__magic_name__       (							__UpperCAmelCase = question_function							,	__UpperCAmelCase = 10      )						->					int:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       [func(__UpperCAmelCase      ) for x_val in range(1							,	order + 1      )]

   __SCREAMING_SNAKE_CASE      							=       [
       interpolate(data_points[:max_coeff]      ) for max_coeff in range(1							,	order + 1      )
   ]

   __SCREAMING_SNAKE_CASE      							=       0
   __SCREAMING_SNAKE_CASE      							=       42
   __SCREAMING_SNAKE_CASE      							=       42

   for poly in polynomials:
      __SCREAMING_SNAKE_CASE      							=       1
      while func(__UpperCAmelCase      ) == poly(__UpperCAmelCase      ):
         x_val += 1

      ret += poly(__UpperCAmelCase      )

   return ret


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





