



"""simple docstring"""







import math







class 				UpperCamelCase__       :




      """simple docstring"""




      def 					SCREAMING_SNAKE_CASE__			(				self    :				List[Any]   ,      SCREAMING_SNAKE_CASE_    :				list[list[float]]   ,      SCREAMING_SNAKE_CASE_    :				list[int]	):
        lowerCAmelCase_       :    Tuple								=			0.0
        lowerCAmelCase_       :    Union[str, Any]								=			0.0
        for i in range(len(SCREAMING_SNAKE_CASE_	)	):
          da += math.pow((sample[i] - weights[0][i])   ,      2	)
          da += math.pow((sample[i] - weights[1][i])   ,      2	)
          return 0 if da > da else 1
        return 0





      def 					SCREAMING_SNAKE_CASE__			(				self    :				List[str]   ,      SCREAMING_SNAKE_CASE_    :				list[list[int | float]]   ,      SCREAMING_SNAKE_CASE_    :				list[int]   ,      SCREAMING_SNAKE_CASE_    :				int   ,      SCREAMING_SNAKE_CASE_    :				float	):
        for i in range(len(SCREAMING_SNAKE_CASE_	)	):
          weights[j][i] += alpha * (sample[i] - weights[j][i])
        return weights




def     UpperCamelCase_   (   )						->       None:

  """simple docstring"""




  lowerCAmelCase_       :    Any								=			[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

  # weight initialization ( n, C )
  lowerCAmelCase_       :    List[Any]								=			[[0.2, 0.6, 0.5, 0.9], [0.8, 0.4, 0.7, 0.3]]

  # training
  lowerCAmelCase_       :    List[Any]								=			SelfOrganizingMap()
  lowerCAmelCase_       :    Tuple								=			3
  lowerCAmelCase_       :    Dict								=			0.5

  for _ in range(lowerCAmelCase__						):
    for j in range(len(lowerCAmelCase__						)						):
      # training sample
      lowerCAmelCase_       :    List[str]								=			training_samples[j]

      # Compute the winning vector
      lowerCAmelCase_       :    List[Any]								=			self_organizing_map.get_winner(lowerCAmelCase__   ,       lowerCAmelCase__						)

      # Update the winning vector
      lowerCAmelCase_       :    int								=			self_organizing_map.update(lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__   ,       lowerCAmelCase__						)

    # classify test sample
  lowerCAmelCase_       :    Union[str, Any]								=			[0, 0, 0, 1]
  lowerCAmelCase_       :    List[str]								=			self_organizing_map.get_winner(lowerCAmelCase__   ,       lowerCAmelCase__						)

  # results
  print(f"Clusters that the test sample belongs to : {winner}"						)
  print(f"Weights that have been trained : {weights}"						)


# running the main() function
if __name__ == "__main__":
     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() = }')





