


'''simple docstring'''
import math


def 			_lowercase       (				UpperCamelCase__       :					List[Any],				UpperCamelCase__       :					int = 0,				UpperCamelCase__       :					Tuple = 0			):
 __A  :		int       =			end or len(lowercase__			)
 for i in range(lowercase__,				lowercase__			):
  __A  :		int       =			i
  __A  :		str       =			array[i]
  while temp_index != start and temp_index_value < array[temp_index - 1]:
   __A  :		List[Any]       =			array[temp_index - 1]
   temp_index -= 1
  __A  :		Any       =			temp_index_value
 return array


def 			_lowercase       (				UpperCamelCase__       :					str,				UpperCamelCase__       :					int,				UpperCamelCase__       :					Dict			):  # Max Heap
 __A  :		Any       =			index
 __A  :		List[str]       =			2 * index + 1  # Left Node
 __A  :		int       =			2 * index + 2  # Right Node

 if left_index < heap_size and array[largest] < array[left_index]:
  __A  :		Optional[int]       =			left_index

 if right_index < heap_size and array[largest] < array[right_index]:
  __A  :		Optional[Any]       =			right_index

 if largest != index:
  __A     ,__A  :		int       =			array[largest], array[index]
  heapify(lowercase__,				lowercase__,				lowercase__			)


def 			_lowercase       (				UpperCamelCase__       :					List[Any]			):
 __A  :		Any       =			len(lowercase__			)

 for i in range(n // 2,				-1,				-1			):
  heapify(lowercase__,				lowercase__,				lowercase__			)

 for i in range(n - 1,				0,				-1			):
  __A     ,__A  :		Optional[Any]       =			array[0], array[i]
  heapify(lowercase__,				0,				lowercase__			)

 return array


def 			_lowercase       (				UpperCamelCase__       :					List[str],				UpperCamelCase__       :					Tuple,				UpperCamelCase__       :					List[Any],				UpperCamelCase__       :					Any			):







 if (array[first_index] > array[middle_index]) != (
     array[first_index] > array[last_index]
 ):
  return array[first_index]
 elif (array[middle_index] > array[first_index]) != (
     array[middle_index] > array[last_index]
 ):
  return array[middle_index]
 else:
  return array[last_index]


def 			_lowercase       (				UpperCamelCase__       :					List[str],				UpperCamelCase__       :					Optional[int],				UpperCamelCase__       :					int,				UpperCamelCase__       :					Optional[Any]			):
 __A  :		Union[str, Any]       =			low
 __A  :		Tuple       =			high
 while True:
  while array[i] < pivot:
   i += 1
  j -= 1
  while pivot < array[j]:
   j -= 1
  if i >= j:
   return i
  __A     ,__A  :		int       =			array[j], array[i]
  i += 1


def 			_lowercase       (				UpperCamelCase__       :					List[Any]			):







 if len(lowercase__			) == 0:
  return array
 __A  :		Optional[Any]       =			2 * math.ceil(math.loga(len(lowercase__			)			)			)
 __A  :		Union[str, Any]       =			16
 return intro_sort(lowercase__,				0,				len(lowercase__			),				lowercase__,				lowercase__			)


def 			_lowercase       (				UpperCamelCase__       :					int,				UpperCamelCase__       :					int,				UpperCamelCase__       :					Optional[int],				UpperCamelCase__       :					Any,				UpperCamelCase__       :					str			):







 while end - start > size_threshold:
  if max_depth == 0:
   return heap_sort(lowercase__			)
  max_depth -= 1
  __A  :		int       =			median_of_a(lowercase__,				lowercase__,				start + ((end - start) // 2) + 1,				end - 1			)
  __A  :		List[Any]       =			partition(lowercase__,				lowercase__,				lowercase__,				lowercase__			)
  intro_sort(lowercase__,				lowercase__,				lowercase__,				lowercase__,				lowercase__			)
  __A  :		List[Any]       =			p
 return insertion_sort(lowercase__,				lowercase__,				lowercase__			)


if __name__ == "__main__":
 import doctest

 doctest.testmod()

 UpperCAmelCase_ :     Tuple								=      input('Enter numbers separated by a comma : ').strip()
 UpperCAmelCase_ :     int								=      [float(item) for item in user_input.split(',')]
 print(sort(unsorted))










'''simple docstring'''
import math

class 						_lowerCamelCase					:




 '''simple docstring'''


 def  snake_case__   (      self      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  __A  :		List[str]       =			0.0
  __A  :		Optional[int]       =			0.0
  for i in range(len(__lowercase						)						):
   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  snake_case__   (      self      ,      __lowercase      ,      __lowercase      ,      __lowercase      ,      __lowercase						):

  """simple docstring"""







  for i in range(len(__lowercase						)						):
   weights[j][i] += alpha * (sample[i] - weights[j][i])
  return weights


def 			_lowercase       (				):
 # Training Examples ( m, n )
 __A  :		Union[str, Any]       =			[[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 1]]

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

 # training
 __A  :		Optional[int]       =			SelfOrganizingMap()
 __A  :		int       =			3
 __A  :		Optional[Any]       =			0.5

 for _ in range(UpperCamelCase__			):
  for j in range(len(UpperCamelCase__			)			):
   # training sample
   __A  :		Dict       =			training_samples[j]

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

   # Update the winning vector
   __A  :		Union[str, Any]       =			self_organizing_map.update(UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__,				UpperCamelCase__			)

    # classify test sample
 __A  :		int       =			[0, 0, 0, 1]
 __A  :		List[Any]       =			self_organizing_map.get_winner(UpperCamelCase__,				UpperCamelCase__			)

 # 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()






