




def        __UpperCAmelCase						(							lowerCamelCase_ :     list  )       ->  list:







			"""simple docstring"""





			if len(lowerCamelCase_  ) <= 1:
						return [tuple(lowerCamelCase_  )]

			SCREAMING_SNAKE_CASE_   : Optional[int]					  =      []

			def generate(lowerCamelCase_ :     int  ,							lowerCamelCase_ :     list  ):
						SCREAMING_SNAKE_CASE_   : Any					  =      [0] * n
						res.append(tuple(lowerCamelCase_  )  )

						SCREAMING_SNAKE_CASE_   : Dict					  =      0
						while i < n:
									if c[i] < i:
												if i % 2 == 0:
															SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : List[str]					  =      arr[i], arr[0]
												else:
															SCREAMING_SNAKE_CASE_  ,    SCREAMING_SNAKE_CASE_   : List[Any]					  =      arr[i], arr[c[i]]
												res.append(tuple(lowerCamelCase_  )  )
												c[i] += 1
												SCREAMING_SNAKE_CASE_   : int					  =      0
									else:
												SCREAMING_SNAKE_CASE_   : str					  =      0
												i += 1

			generate(len(lowerCamelCase_  )  ,							lowerCamelCase_  )
			return res


if __name__ == "__main__":
						UpperCamelCase__ :   Any						=							input('''Enter numbers separated by a comma:\n''').strip()
						UpperCamelCase__ :   List[Any]						=							[int(item) for item in user_input.split(''',''')]
						print(heaps(arr))









from __future__ import annotations

import math

import numpy as np
from numpy.linalg import norm





def        __UpperCAmelCase						(							lowerCamelCase_ :     np.ndarray  ,							lowerCamelCase_ :     np.ndarray  )       ->  float:







			"""simple docstring"""





			return math.sqrt(sum(pow(a - b  ,							2  ) for a, b in zip(lowerCamelCase_  ,							lowerCamelCase_  )  )  )





def        __UpperCAmelCase						(							lowerCamelCase_ :     np.ndarray  ,							lowerCamelCase_ :     np.ndarray  )       ->  list[list[list[float] | float]]:







			"""simple docstring"""





			if dataset.ndim != value_array.ndim:
						SCREAMING_SNAKE_CASE_   : Optional[int]					  =      (
						    'Wrong input data\'s dimensions... '
						    F'dataset : {dataset.ndim}, value_array : {value_array.ndim}'
						)
						raise ValueError(lowerCamelCase_  )

			try:
						if dataset.shape[1] != value_array.shape[1]:
									SCREAMING_SNAKE_CASE_   : List[Any]					  =      (
									    'Wrong input data\'s shape... '
									    F'dataset : {dataset.shape[1]}, value_array : {value_array.shape[1]}'
									)
									raise ValueError(lowerCamelCase_  )
			except IndexError:
						if dataset.ndim != value_array.ndim:
									raise TypeError('Wrong shape'  )

			if dataset.dtype != value_array.dtype:
						SCREAMING_SNAKE_CASE_   : Tuple					  =      (
						    'Input data have different datatype... '
						    F'dataset : {dataset.dtype}, value_array : {value_array.dtype}'
						)
						raise TypeError(lowerCamelCase_  )

			SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      []

			for value in value_array:
						SCREAMING_SNAKE_CASE_   : str					  =      euclidean(lowerCamelCase_  ,							dataset[0]  )
						SCREAMING_SNAKE_CASE_   : List[Any]					  =      dataset[0].tolist()

						for dataset_value in dataset[1:]:
									SCREAMING_SNAKE_CASE_   : Optional[Any]					  =      euclidean(lowerCamelCase_  ,							lowerCamelCase_  )

									if dist > temp_dist:
												SCREAMING_SNAKE_CASE_   : Optional[int]					  =      temp_dist
												SCREAMING_SNAKE_CASE_   : Union[str, Any]					  =      dataset_value.tolist()

						answer.append([vector, dist]  )

			return answer





def        __UpperCAmelCase						(							lowerCamelCase_ :     np.ndarray  ,							lowerCamelCase_ :     np.ndarray  )       ->  float:







			"""simple docstring"""





			return np.dot(lowerCamelCase_  ,							lowerCamelCase_  ) / (norm(lowerCamelCase_  ) * norm(lowerCamelCase_  ))


if __name__ == "__main__":
						import doctest

						doctest.testmod()



