


"""simple docstring"""






def __lowercase  (   lowerCamelCase_	:   int    ,       lowerCamelCase_	:   List[Any]    ,       lowerCamelCase_	:   List[str]	):
				SCREAMING_SNAKE_CASE__  				=					index
				SCREAMING_SNAKE_CASE__  				=					2 * index + 1
				SCREAMING_SNAKE_CASE__  				=					2 * index + 2
				if left_index < heap_size and unsorted[left_index] > unsorted[largest]:
								SCREAMING_SNAKE_CASE__  				=					left_index

				if right_index < heap_size and unsorted[right_index] > unsorted[largest]:
								SCREAMING_SNAKE_CASE__  				=					right_index

				if largest != index:
								SCREAMING_SNAKE_CASE__				,   SCREAMING_SNAKE_CASE__  				=					unsorted[index], unsorted[largest]
								heapify(lowerCamelCase_    ,       lowerCamelCase_    ,       lowerCamelCase_	)


def __lowercase  (   lowerCamelCase_	:   str	):
				SCREAMING_SNAKE_CASE__  				=					len(lowerCamelCase_	)
				for i in range(n // 2 - 1    ,       -1    ,       -1	):
								heapify(lowerCamelCase_    ,       lowerCamelCase_    ,       lowerCamelCase_	)
				for i in range(n - 1    ,       0    ,       -1	):
								SCREAMING_SNAKE_CASE__				,   SCREAMING_SNAKE_CASE__  				=					unsorted[i], unsorted[0]
								heapify(lowerCamelCase_    ,       0    ,       lowerCamelCase_	)
				return unsorted


if __name__ == "__main__":
	_lowerCamelCase  =	input('Enter numbers separated by a comma:\n').strip()
	_lowerCamelCase  =	[int(item) for item in user_input.split(',')]
	print(heap_sort(unsorted))




"""simple docstring"""






from __future__ import annotations

from collections.abc import Generator


def __lowercase  (   lowerCamelCase_	:   int	):
				if not isinstance(lowerCamelCase_    ,       lowerCamelCase_	) or n < 1:
								raise Exception("Sequence only defined for positive integers"	)

				yield n
				while n != 1:
								if n % 2 == 0:
												n //= 2
								else:
												SCREAMING_SNAKE_CASE__  				=					3 * n + 1
								yield n


def __lowercase  (   ):
				SCREAMING_SNAKE_CASE__  				=					43
				SCREAMING_SNAKE_CASE__  				=					tuple(collatz_sequence(lowerCamelCase_	)	)
				print(lowerCamelCase_	)
				print(F'''Collatz sequence from {n} took {len(lowerCamelCase_	)} steps.'''	)


if __name__ == "__main__":
	main()
