



"""simple docstring"""






import logging
import os

from .state import PartialState



class 			A__   (  logging.LoggerAdapter							):




	'''simple docstring'''





	@staticmethod
	def 							_SCREAMING_SNAKE_CASE   (     _SCREAMING_SNAKE_CASE:		Any)				->       Optional[Any]:

				"""simple docstring"""

				__lowerCAmelCase      :  Tuple												=       PartialState()
				return not main_process_only or (main_process_only and state.is_main_process)







	def 							_SCREAMING_SNAKE_CASE   (     self:		str       ,			_SCREAMING_SNAKE_CASE:		List[Any]       ,			_SCREAMING_SNAKE_CASE:		Union[str, Any]       ,			*_SCREAMING_SNAKE_CASE:		Tuple       ,			**_SCREAMING_SNAKE_CASE:		Optional[int])				->       Dict:

				"""simple docstring"""

				if PartialState._shared_state == {}:
							raise RuntimeError(
							    "You must initialize the accelerate state by calling either `PartialState()` or `Accelerator()` before using the logging utility.")
				__lowerCAmelCase      :  int												=       kwargs.pop("main_process_only"       ,			_SCREAMING_SNAKE_CASE)
				__lowerCAmelCase      :  str												=       kwargs.pop("in_order"       ,			_SCREAMING_SNAKE_CASE)

				if self.isEnabledFor(_SCREAMING_SNAKE_CASE):
							if self._should_log(_SCREAMING_SNAKE_CASE):
										__lowerCAmelCase						,	__lowerCAmelCase      :  Tuple												=       self.process(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE)
										self.logger.log(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			*_SCREAMING_SNAKE_CASE       ,			**_SCREAMING_SNAKE_CASE)

							elif in_order:
										__lowerCAmelCase      :  List[Any]												=       PartialState()
										for i in range(state.num_processes):
													if i == state.process_index:
																__lowerCAmelCase						,	__lowerCAmelCase      :  str												=       self.process(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE)
																self.logger.log(_SCREAMING_SNAKE_CASE       ,			_SCREAMING_SNAKE_CASE       ,			*_SCREAMING_SNAKE_CASE       ,			**_SCREAMING_SNAKE_CASE)
													state.wait_for_everyone()






def 			_lowercase				(  __snake_case					,__snake_case = None	)						->   Tuple:
			if log_level is None:
						__lowerCAmelCase      :  Optional[Any]												=       os.environ.get("ACCELERATE_LOG_LEVEL"					,__snake_case	)
			__lowerCAmelCase      :  Tuple												=       logging.getLogger(__snake_case	)
			if log_level is not None:
						logger.setLevel(log_level.upper()	)
						logger.root.setLevel(log_level.upper()	)
			return MultiProcessAdapter(__snake_case					,{}	)




"""simple docstring"""






from __future__ import annotations


def 			_lowercase				(  __snake_case					,__snake_case					,__snake_case					,__snake_case	)						->   list:
			__lowerCAmelCase      :  Dict												=       []
			__lowerCAmelCase						,	__lowerCAmelCase      :  Any												=       input_list[low:mid], input_list[mid : high + 1]
			while left and right:
						result.append((left if left[0] <= right[0] else right).pop(0	)	)
			__lowerCAmelCase      :  int												=       result + left + right
			return input_list


def 			_lowercase				(  __snake_case	)						->   list:
			if len(__snake_case	) <= 1:
						return input_list
			__lowerCAmelCase      :  int												=       list(__snake_case	)

			# iteration for two-way merging
			__lowerCAmelCase      :  Optional[int]												=       2
			while p <= len(__snake_case	):
						# getting low, high and middle value for merge-sort of single list
						for i in range(0					,len(__snake_case	)					,__snake_case	):
									__lowerCAmelCase      :  Union[str, Any]												=       i
									__lowerCAmelCase      :  Tuple												=       i + p - 1
									__lowerCAmelCase      :  Optional[Any]												=       (low + high + 1) // 2
									__lowerCAmelCase      :  Any												=       merge(__snake_case					,__snake_case					,__snake_case					,__snake_case	)
						# final merge of last two parts
						if p * 2 >= len(__snake_case	):
									__lowerCAmelCase      :  Optional[Any]												=       i
									__lowerCAmelCase      :  Union[str, Any]												=       merge(__snake_case					,0					,__snake_case					,len(__snake_case	) - 1	)
									break
						p *= 2

			return input_list


if __name__ == "__main__":
	__snake_case							:   Union[str, Any]      =    input('Enter numbers separated by a comma:\n').strip()
	if user_input == "":
		__snake_case							:   Optional[int]      =    []
	else:
		__snake_case							:   int      =    [int(item.strip()) for item in user_input.split(',')]
	print(iter_merge_sort(unsorted))