



"""simple docstring"""







import unittest

import numpy as np

def     UpperCamelCase_   (   lowerCAmelCase__				:    List[str]   ,       lowerCAmelCase__				:    Dict   ,       lowerCAmelCase__				:    List[Any]   ,       lowerCAmelCase__				:    Optional[int] = None   ,       )						->       np.ndarray:

  """simple docstring"""




  lowerCAmelCase_       :    int								=			np.shape(lowerCamelCase_						)
  lowerCAmelCase_       :    List[Any]								=			np.shape(lowerCamelCase_						)
  lowerCAmelCase_       :    Dict								=			np.shape(lowerCamelCase_						)

  if shape_a[0] != shape_b[0]:
    lowerCAmelCase_       :    Union[str, Any]								=			(
        'Expected the same number of rows for A and B. '
        f"Instead found A of size {shape_a} and B of size {shape_b}"
    )
    raise ValueError(lowerCamelCase_						)

  if shape_b[1] != shape_c[1]:
    lowerCAmelCase_       :    str								=			(
        'Expected the same number of columns for B and C. '
        f"Instead found B of size {shape_b} and C of size {shape_c}"
    )
    raise ValueError(lowerCamelCase_						)

  lowerCAmelCase_       :    int								=			pseudo_inv
  if a_inv is None:
    try:
      lowerCAmelCase_       :    int								=			np.linalg.inv(lowerCamelCase_						)
    except np.linalg.LinAlgError:
      raise ValueError(
          'Input matrix A is not invertible. Cannot compute Schur complement.'						)

  return mat_c - mat_b.T @ a_inv @ mat_b







class 				UpperCamelCase__       (     unittest.TestCase  ):




      """simple docstring"""




      def 					SCREAMING_SNAKE_CASE__			(				self    :				Any	):
        lowerCAmelCase_       :    Dict								=			np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]	)
        lowerCAmelCase_       :    int								=			np.array([[0, 3], [3, 0], [2, 3]]	)
        lowerCAmelCase_       :    Optional[Any]								=			np.array([[2, 1], [6, 3]]	)

        lowerCAmelCase_       :    Dict								=			schur_complement(SCREAMING_SNAKE_CASE_   ,      SCREAMING_SNAKE_CASE_   ,      SCREAMING_SNAKE_CASE_	)

        lowerCAmelCase_       :    List[str]								=			np.block([[a, b], [b.T, c]]	)

        lowerCAmelCase_       :    str								=			np.linalg.det(SCREAMING_SNAKE_CASE_	)
        lowerCAmelCase_       :    Any								=			np.linalg.det(SCREAMING_SNAKE_CASE_	)
        lowerCAmelCase_       :    Union[str, Any]								=			np.linalg.det(SCREAMING_SNAKE_CASE_	)

        self.assertAlmostEqual(SCREAMING_SNAKE_CASE_   ,      det_a * det_s	)



      def 					SCREAMING_SNAKE_CASE__			(				self    :				Union[str, Any]	):
        lowerCAmelCase_       :    Union[str, Any]								=			np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]	)
        lowerCAmelCase_       :    Tuple								=			np.array([[0, 3], [3, 0], [2, 3]]	)
        lowerCAmelCase_       :    List[str]								=			np.array([[2, 1], [6, 3]]	)

        with self.assertRaises(SCREAMING_SNAKE_CASE_	):
          schur_complement(SCREAMING_SNAKE_CASE_   ,      SCREAMING_SNAKE_CASE_   ,      SCREAMING_SNAKE_CASE_	)





      def 					SCREAMING_SNAKE_CASE__			(				self    :				List[Any]	):
        lowerCAmelCase_       :    Optional[Any]								=			np.array([[1, 2, 1], [2, 1, 2], [3, 2, 4]]	)
        lowerCAmelCase_       :    str								=			np.array([[0, 3], [3, 0], [2, 3]]	)
        lowerCAmelCase_       :    List[str]								=			np.array([[2, 1, 3], [6, 3, 5]]	)

        with self.assertRaises(SCREAMING_SNAKE_CASE_	):
          schur_complement(SCREAMING_SNAKE_CASE_   ,      SCREAMING_SNAKE_CASE_   ,      SCREAMING_SNAKE_CASE_	)


if __name__ == "__main__":
     import doctest

     doctest.testmod()
     unittest.main()










"""simple docstring"""







from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt

def     UpperCamelCase_   (   lowerCAmelCase__				:    int						)						->       bool:

  """simple docstring"""




  lowerCAmelCase_       :    int								=			int(number**0.5						)
  return number == sq * sq

def     UpperCamelCase_   (   lowerCAmelCase__				:    int   ,       lowerCAmelCase__				:    int   ,       lowerCAmelCase__				:    int   ,       lowerCAmelCase__				:    int   ,       lowerCAmelCase__				:    int   ,       lowerCAmelCase__				:    int						)						->       tuple[int, int]:

  """simple docstring"""




  lowerCAmelCase_       :    int								=			x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
  lowerCAmelCase_       :    int								=			x_den * y_den * z_den
  lowerCAmelCase_       :    int								=			gcd(lowerCAmelCase__   ,       lowerCAmelCase__						)
  top //= hcf
  bottom //= hcf
  return top, bottom

def     UpperCamelCase_   (   lowerCAmelCase__				:    int = 35						)						->       int:

  """simple docstring"""




  lowerCAmelCase_       :    set								=			set()
  lowerCAmelCase_       :    int
  lowerCAmelCase_       :    Fraction								=			Fraction(0						)
  lowerCAmelCase_       :    tuple[int, int]

  for x_num in range(1   ,       order + 1						):
    for x_den in range(x_num + 1   ,       order + 1						):
      for y_num in range(1   ,       order + 1						):
        for y_den in range(y_num + 1   ,       order + 1						):
          # n=1
          lowerCAmelCase_       :    str								=			x_num * y_den + x_den * y_num
          lowerCAmelCase_       :    int								=			x_den * y_den
          lowerCAmelCase_       :    int								=			gcd(lowerCAmelCase__   ,       lowerCAmelCase__						)
          z_num //= hcf
          z_den //= hcf
          if 0 < z_num < z_den <= order:
            lowerCAmelCase_       :    List[str]								=			add_three(
                lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__						)
            unique_s.add(lowerCAmelCase__						)

          # n=2
          lowerCAmelCase_       :    Optional[int]								=			(
              x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
          )
          lowerCAmelCase_       :    Dict								=			x_den * x_den * y_den * y_den
          if is_sq(lowerCAmelCase__						) and is_sq(lowerCAmelCase__						):
            lowerCAmelCase_       :    Optional[int]								=			int(sqrt(lowerCAmelCase__						)						)
            lowerCAmelCase_       :    List[str]								=			int(sqrt(lowerCAmelCase__						)						)
            lowerCAmelCase_       :    Union[str, Any]								=			gcd(lowerCAmelCase__   ,       lowerCAmelCase__						)
            z_num //= hcf
            z_den //= hcf
            if 0 < z_num < z_den <= order:
              lowerCAmelCase_       :    Union[str, Any]								=			add_three(
                  lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__						)
              unique_s.add(lowerCAmelCase__						)

                    # n=-1
          lowerCAmelCase_       :    Dict								=			x_num * y_num
          lowerCAmelCase_       :    Optional[int]								=			x_den * y_num + x_num * y_den
          lowerCAmelCase_       :    Any								=			gcd(lowerCAmelCase__   ,       lowerCAmelCase__						)
          z_num //= hcf
          z_den //= hcf
          if 0 < z_num < z_den <= order:
            lowerCAmelCase_       :    Tuple								=			add_three(
                lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__						)
            unique_s.add(lowerCAmelCase__						)

          # n=2
          lowerCAmelCase_       :    List[str]								=			x_num * x_num * y_num * y_num
          lowerCAmelCase_       :    Optional[Any]								=			(
              x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
          )
          if is_sq(lowerCAmelCase__						) and is_sq(lowerCAmelCase__						):
            lowerCAmelCase_       :    Tuple								=			int(sqrt(lowerCAmelCase__						)						)
            lowerCAmelCase_       :    Optional[Any]								=			int(sqrt(lowerCAmelCase__						)						)
            lowerCAmelCase_       :    Optional[int]								=			gcd(lowerCAmelCase__   ,       lowerCAmelCase__						)
            z_num //= hcf
            z_den //= hcf
            if 0 < z_num < z_den <= order:
              lowerCAmelCase_       :    Any								=			add_three(
                  lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__						)
              unique_s.add(lowerCAmelCase__						)

  for num, den in unique_s:
    total += Fraction(lowerCAmelCase__   ,       lowerCAmelCase__						)

  return total.denominator + total.numerator


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





