
import math






def 							UpperCAmelCase_		(							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE = 0 ,							__SCREAMING_SNAKE_CASE = 0							):
	lowercase       =    end or len(__SCREAMING_SNAKE_CASE							)
	for i in range(__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							):
		lowercase       =    i
		lowercase       =    array[i]
		while temp_index != start and temp_index_value < array[temp_index - 1]:
			lowercase       =    array[temp_index - 1]
			temp_index -= 1
		lowercase       =    temp_index_value
	return array






def 							UpperCAmelCase_		(							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							):  # Max Heap
	lowercase       =    index
	lowercase       =    2 * index + 1  # Left Node
	lowercase       =    2 * index + 2  # Right Node

	if left_index < heap_size and array[largest] < array[left_index]:
		lowercase       =    left_index

	if right_index < heap_size and array[largest] < array[right_index]:
		lowercase       =    right_index

	if largest != index:
		lowercase  ,					lowercase       =    array[largest], array[index]
		heapify(__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							)






def 							UpperCAmelCase_		(							__SCREAMING_SNAKE_CASE							):
	lowercase       =    len(__SCREAMING_SNAKE_CASE							)

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

	for i in range(n - 1 ,							0 ,							-1							):
		lowercase  ,					lowercase       =    array[0], array[i]
		heapify(__SCREAMING_SNAKE_CASE ,							0 ,							__SCREAMING_SNAKE_CASE							)

	return array






def 							UpperCAmelCase_		(							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							):
	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 							UpperCAmelCase_		(							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							):
	lowercase       =    low
	lowercase       =    high
	while True:
		while array[i] < pivot:
			i += 1
		j -= 1
		while pivot < array[j]:
			j -= 1
		if i >= j:
			return i
		lowercase  ,					lowercase       =    array[j], array[i]
		i += 1






def 							UpperCAmelCase_		(							__SCREAMING_SNAKE_CASE							):
	if len(__SCREAMING_SNAKE_CASE							) == 0:
		return array
	lowercase       =    2 * math.ceil(math.loga(len(__SCREAMING_SNAKE_CASE							)							)							)
	lowercase       =    16
	return intro_sort(__SCREAMING_SNAKE_CASE ,							0 ,							len(__SCREAMING_SNAKE_CASE							) ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							)






def 							UpperCAmelCase_		(							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							):
	while end - start > size_threshold:
		if max_depth == 0:
			return heap_sort(__SCREAMING_SNAKE_CASE							)
		max_depth -= 1
		lowercase       =    median_of_a(__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							start + ((end - start) // 2) + 1 ,							end - 1							)
		lowercase       =    partition(__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							)
		intro_sort(__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							)
		lowercase       =    p
	return insertion_sort(__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE ,							__SCREAMING_SNAKE_CASE							)


if __name__ == "__main__":
	import doctest

	doctest.testmod()

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



import importlib
import sys
from argparse import REMAINDER, ArgumentParser
from pathlib import Path

import torch_xla.distributed.xla_multiprocessing as xmp






def 							UpperCAmelCase_		(							):
	lowercase       =    ArgumentParser(
	    description=(
	        'PyTorch TPU distributed training launch '
	        'helper utility that will spawn up '
	        'multiple distributed processes'
	    )							)

	# Optional arguments for the launch helper
	parser.add_argument('--num_cores' ,							type=__SCREAMING_SNAKE_CASE ,							default=1 ,							help='Number of TPU cores to use (1 or 8).'							)

	# positional
	parser.add_argument(
	    'training_script' ,							type=__SCREAMING_SNAKE_CASE ,							help=(
	        'The full path to the single TPU training '
	        'program/script to be launched in parallel, '
	        'followed by all the arguments for the '
	        'training script'
	    ) ,							)

	# rest from the training program
	parser.add_argument('training_script_args' ,							nargs=__SCREAMING_SNAKE_CASE							)

	return parser.parse_args()






def 							UpperCAmelCase_		(							):
	lowercase       =    parse_args()

	# Import training_script as a module.
	lowercase       =    Path(args.training_script							)
	sys.path.append(str(script_fpath.parent.resolve()							)							)
	lowercase       =    script_fpath.stem
	lowercase       =    importlib.import_module(__SCREAMING_SNAKE_CASE							)

	# Patch sys.argv
	lowercase       =    [args.training_script] + args.training_script_args + ['--tpu_num_cores', str(args.num_cores							)]
	xmp.spawn(mod._mp_fn ,							args=() ,							nprocs=args.num_cores							)


if __name__ == "__main__":
	main()

