
# This code is adapted from OpenAI's release
# https://github.com/openai/human-eval/blob/master/human_eval/execution.py

import contextlib
import faulthandler
import io
import multiprocessing
import os
import platform
import signal
import tempfile


def 				A	( lowercase   ,	lowercase   ,	lowercase   ,	lowercase			)       ->  Optional[int]:
		'''simple docstring'''

		UpperCamelCase          =					multiprocessing.Manager()
		UpperCamelCase          =					manager.list()

		UpperCamelCase          =					multiprocessing.Process(target=lowercase   ,	args=(check_program, result, timeout)			)
		p.start()
		p.join(timeout=timeout + 1			)
		if p.is_alive():
				p.kill()

		if not result:
				result.append('timed out'			)

		return {
		    "task_id": task_id,
		    "passed": result[0] == "passed",
		    "result": result[0],
		    "completion_id": completion_id,
		}


def 				A	( lowercase   ,	lowercase   ,	lowercase			)       ->  Tuple:
		'''simple docstring'''

		with create_tempdir():
				# These system calls are needed when cleaning up tempdir.
				import os
				import shutil

				UpperCamelCase          =					shutil.rmtree
				UpperCamelCase          =					os.rmdir
				UpperCamelCase          =					os.chdir

				# Disable functionalities that can make destructive changes to the test.
				reliability_guard()

				# Run program.
				try:
						UpperCamelCase          =					{}
						with swallow_io():
								with time_limit(lowercase			):
										exec(lowercase   ,	lowercase			)
						result.append('passed'			)
				except TimeoutException:
						result.append('timed out'			)
				except BaseException as e:
						result.append(f'''failed: {e}'''			)

				# Needed for cleaning up.
				UpperCamelCase          =					rmtree
				UpperCamelCase          =					rmdir
				UpperCamelCase          =					chdir


@contextlib.contextmanager
def 				A	( lowercase			)       ->  str:
		'''simple docstring'''

		def signal_handler(lowercase   ,	lowercase			):
				raise TimeoutException('Timed out!'			)

		signal.setitimer(signal.ITIMER_REAL   ,	lowercase			)
		signal.signal(signal.SIGALRM   ,	lowercase			)
		try:
				yield
		finally:
				signal.setitimer(signal.ITIMER_REAL   ,	0			)


@contextlib.contextmanager
def 				A	( )       ->  List[str]:
		'''simple docstring'''

		UpperCamelCase          =					WriteOnlyStringIO()
		with contextlib.redirect_stdout(lowercase			):
				with contextlib.redirect_stderr(lowercase			):
						with redirect_stdin(lowercase			):
								yield


@contextlib.contextmanager
def 				A	( )       ->  int:
		'''simple docstring'''

		with tempfile.TemporaryDirectory() as dirname:
				with chdir(lowercase			):
						yield dirname


class     lowercase (		_SCREAMING_SNAKE_CASE       ):
		pass






class     lowercase (		io.StringIO       ):



		def __UpperCamelCase			(			self    ,				*A_    ,				**A_	)  -> int:
				"""simple docstring"""
				raise OSError



		def __UpperCamelCase			(			self    ,				*A_    ,				**A_	)  -> Union[str, Any]:
				"""simple docstring"""
				raise OSError



		def __UpperCamelCase			(			self    ,				*A_    ,				**A_	)  -> Tuple:
				"""simple docstring"""
				raise OSError



		def __UpperCamelCase			(			self    ,				*A_    ,				**A_	)  -> Any:
				"""simple docstring"""
				return False






class     lowercase (		contextlib._RedirectStream       ):  # type: ignore
		__lowercase	:	Tuple     					=    "stdin"






@contextlib.contextmanager
def 				A	( lowercase			)       ->  Dict:
		'''simple docstring'''

		if root == ".":
				yield
				return
		UpperCamelCase          =					os.getcwd()
		os.chdir(lowercase			)
		try:
				yield
		except BaseException as exc:
				raise exc
		finally:
				os.chdir(lowercase			)


def 				A	( lowercase=None			)       ->  Union[str, Any]:
		'''simple docstring'''

		if maximum_memory_bytes is not None:
				import resource

				resource.setrlimit(resource.RLIMIT_AS   ,	(maximum_memory_bytes, maximum_memory_bytes)			)
				resource.setrlimit(resource.RLIMIT_DATA   ,	(maximum_memory_bytes, maximum_memory_bytes)			)
				if not platform.uname().system == "Darwin":
						resource.setrlimit(resource.RLIMIT_STACK   ,	(maximum_memory_bytes, maximum_memory_bytes)			)

		faulthandler.disable()

		import builtins

		UpperCamelCase          =					None
		UpperCamelCase          =					None

		import os

		UpperCamelCase          =					'1'

		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None

		import shutil

		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None

		import subprocess

		UpperCamelCase          =					None  # type: ignore

		UpperCamelCase          =					None

		import sys

		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None
		UpperCamelCase          =					None


from __future__ import annotations


def 				A	( lowercase   ,	lowercase   ,	lowercase   ,	lowercase			)       ->  list:
		'''simple docstring'''

		UpperCamelCase          =					[]
		UpperCamelCase     ,  UpperCamelCase          =					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			)			)
		UpperCamelCase          =					result + left + right
		return input_list


def 				A	( lowercase			)       ->  list:
		'''simple docstring'''

		if len(lowercase			) <= 1:
				return input_list
		UpperCamelCase          =					list(lowercase			)

		# iteration for two-way merging
		UpperCamelCase          =					2
		while p <= len(lowercase			):
				# getting low, high and middle value for merge-sort of single list
				for i in range(0   ,	len(lowercase			)   ,	lowercase			):
						UpperCamelCase          =					i
						UpperCamelCase          =					i + p - 1
						UpperCamelCase          =					(low + high + 1) // 2
						UpperCamelCase          =					merge(lowercase   ,	lowercase   ,	lowercase   ,	lowercase			)
				# final merge of last two parts
				if p * 2 >= len(lowercase			):
						UpperCamelCase          =					i
						UpperCamelCase          =					merge(lowercase   ,	0   ,	lowercase   ,	len(lowercase			) - 1			)
						break
				p *= 2

		return input_list


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