

"""simple docstring"""





# 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     __SCREAMING_SNAKE_CASE    ( A_		,	A_		,	A_		,	A_					):
	lowerCAmelCase__      :		Tuple    							=      multiprocessing.Manager()
	lowerCAmelCase__      :		Dict    							=      manager.list()

	lowerCAmelCase__      :		Union[str, Any]    							=      multiprocessing.Process(target=A_		,	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     __SCREAMING_SNAKE_CASE    ( A_		,	A_		,	A_					):
	with create_tempdir():
		# These system calls are needed when cleaning up tempdir.
		import os
		import shutil

		lowerCAmelCase__      :		List[str]    							=      shutil.rmtree
		lowerCAmelCase__      :		int    							=      os.rmdir
		lowerCAmelCase__      :		int    							=      os.chdir

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

		# Run program.
		try:
			lowerCAmelCase__      :		Union[str, Any]    							=      {}
			with swallow_io():
				with time_limit(A_					):
					exec(A_		,	A_					)
			result.append('''passed'''					)
		except TimeoutException:
			result.append('''timed out'''					)
		except BaseException as e:
			result.append(f'failed: {e}'					)

		# Needed for cleaning up.
		lowerCAmelCase__      :		Dict    							=      rmtree
		lowerCAmelCase__      :		Union[str, Any]    							=      rmdir
		lowerCAmelCase__      :		int    							=      chdir

@contextlib.contextmanager
def     __SCREAMING_SNAKE_CASE    ( A_					):
	def signal_handler(A_		,	A_					):
		raise TimeoutException('''Timed out!'''					)

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

@contextlib.contextmanager
def     __SCREAMING_SNAKE_CASE    ( ):
	lowerCAmelCase__      :		str    							=      WriteOnlyStringIO()
	with contextlib.redirect_stdout(A_					):
		with contextlib.redirect_stderr(A_					):
			with redirect_stdin(A_					):
				yield

@contextlib.contextmanager
def     __SCREAMING_SNAKE_CASE    ( ):
	with tempfile.TemporaryDirectory() as dirname:
		with chdir(A_					):
			yield dirname







class 							SCREAMING_SNAKE_CASE   (						a_			):






					"""simple docstring"""



					pass







class 							SCREAMING_SNAKE_CASE   (						io.StringIO			):






					"""simple docstring"""



					def 			__lowerCAmelCase					(			self     :							List[str]  ,*lowercase_     :							Optional[int]  ,**lowercase_     :							Optional[Any]						):
						raise OSError







					def 			__lowerCAmelCase					(			self     :							int  ,*lowercase_     :							Union[str, Any]  ,**lowercase_     :							List[Any]						):
						raise OSError







					def 			__lowerCAmelCase					(			self     :							int  ,*lowercase_     :							Union[str, Any]  ,**lowercase_     :							Optional[Any]						):
						raise OSError







					def 			__lowerCAmelCase					(			self     :							List[Any]  ,*lowercase_     :							Optional[int]  ,**lowercase_     :							List[Any]						):
						return False







class 							SCREAMING_SNAKE_CASE   (						contextlib._RedirectStream			):  # type: ignore






					"""simple docstring"""



					lowercase__												=			"stdin"

@contextlib.contextmanager
def     __SCREAMING_SNAKE_CASE    ( A_					):
	if root == ".":
		yield
		return
	lowerCAmelCase__      :		Optional[int]    							=      os.getcwd()
	os.chdir(A_					)
	try:
		yield
	except BaseException as exc:
		raise exc
	finally:
		os.chdir(A_					)





def     __SCREAMING_SNAKE_CASE    ( A_=None					):

	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

	lowerCAmelCase__      :		Optional[Any]    							=      None
	lowerCAmelCase__      :		Union[str, Any]    							=      None

	import os

	lowerCAmelCase__      :		str    							=      '''1'''

	lowerCAmelCase__      :		int    							=      None
	lowerCAmelCase__      :		Union[str, Any]    							=      None
	lowerCAmelCase__      :		Optional[int]    							=      None
	lowerCAmelCase__      :		List[Any]    							=      None
	lowerCAmelCase__      :		Dict    							=      None
	lowerCAmelCase__      :		List[str]    							=      None
	lowerCAmelCase__      :		Dict    							=      None
	lowerCAmelCase__      :		Any    							=      None
	lowerCAmelCase__      :		Optional[int]    							=      None
	lowerCAmelCase__      :		Optional[int]    							=      None
	lowerCAmelCase__      :		List[Any]    							=      None
	lowerCAmelCase__      :		Dict    							=      None
	lowerCAmelCase__      :		Any    							=      None
	lowerCAmelCase__      :		Union[str, Any]    							=      None
	lowerCAmelCase__      :		Optional[int]    							=      None
	lowerCAmelCase__      :		Tuple    							=      None
	lowerCAmelCase__      :		Optional[int]    							=      None
	lowerCAmelCase__      :		List[Any]    							=      None
	lowerCAmelCase__      :		Dict    							=      None
	lowerCAmelCase__      :		List[Any]    							=      None
	lowerCAmelCase__      :		str    							=      None
	lowerCAmelCase__      :		Tuple    							=      None
	lowerCAmelCase__      :		Any    							=      None
	lowerCAmelCase__      :		int    							=      None
	lowerCAmelCase__      :		str    							=      None
	lowerCAmelCase__      :		Optional[int]    							=      None
	lowerCAmelCase__      :		Optional[int]    							=      None

	import shutil

	lowerCAmelCase__      :		Tuple    							=      None
	lowerCAmelCase__      :		List[Any]    							=      None
	lowerCAmelCase__      :		Optional[Any]    							=      None

	import subprocess

	lowerCAmelCase__      :		Any    							=      None  # type: ignore

	lowerCAmelCase__      :		Optional[int]    							=      None

	import sys

	lowerCAmelCase__      :		Any    							=      None
	lowerCAmelCase__      :		List[str]    							=      None
	lowerCAmelCase__      :		List[Any]    							=      None
	lowerCAmelCase__      :		str    							=      None
	lowerCAmelCase__      :		int    							=      None







"""simple docstring"""





def     __SCREAMING_SNAKE_CASE    ( A_					):
	for i in range(len(A_					) - 1		,	0		,	-1					):
		lowerCAmelCase__      :		Optional[Any]    							=      False

		for j in range(A_		,	0		,	-1					):
			if unsorted[j] < unsorted[j - 1]:
				lowerCAmelCase__							,lowerCAmelCase__      :		Union[str, Any]    							=      unsorted[j - 1], unsorted[j]
				lowerCAmelCase__      :		Dict    							=      True

		for j in range(A_					):
			if unsorted[j] > unsorted[j + 1]:
				lowerCAmelCase__							,lowerCAmelCase__      :		Union[str, Any]    							=      unsorted[j + 1], unsorted[j]
				lowerCAmelCase__      :		Any    							=      True

		if not swapped:
			break
	return unsorted


if __name__ == "__main__":
							import doctest

							doctest.testmod()
							__UpperCamelCase    : int				 =						input('''Enter numbers separated by a comma:\n''').strip()
							__UpperCamelCase    : Optional[Any]				 =						[int(item) for item in user_input.split(''',''')]
							print(F'''{cocktail_shaker_sort(unsorted) = }''')




