

'''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 						__lowerCamelCase	(       __snake_case					:		Optional[Any],		__snake_case					:		Optional[Any],		__snake_case					:		int,		__snake_case					:		Tuple	)	->							Optional[int]:






						"""simple docstring"""





						A__					:       Optional[Any]     =multiprocessing.Manager()
						A__					:       Union[str, Any]     =manager.list()

						A__					:       Optional[int]     =multiprocessing.Process(target=__snake_case,		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 						__lowerCamelCase	(       __snake_case					:		int,		__snake_case					:		Optional[Any],		__snake_case					:		Optional[int]	)	->							str:






						"""simple docstring"""





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

												A__					:       Tuple     =shutil.rmtree
												A__					:       str     =os.rmdir
												A__					:       str     =os.chdir

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

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

												# Needed for cleaning up.
												A__					:       str     =rmtree
												A__					:       int     =rmdir
												A__					:       str     =chdir
@contextlib.contextmanager
def 						__lowerCamelCase	(       __snake_case					:		List[str]	)	->							Union[str, Any]:






						"""simple docstring"""





						def signal_handler(__snake_case					:		Dict,		__snake_case					:		Dict	):
												raise TimeoutException("""Timed out!"""	)

						signal.setitimer(signal.ITIMER_REAL,		__snake_case	)
						signal.signal(signal.SIGALRM,		__snake_case	)
						try:
												yield
						finally:
												signal.setitimer(signal.ITIMER_REAL,		0	)
@contextlib.contextmanager
def 						__lowerCamelCase	(       )	->							str:






						"""simple docstring"""





						A__					:       List[Any]     =WriteOnlyStringIO()
						with contextlib.redirect_stdout(__snake_case	):
												with contextlib.redirect_stderr(__snake_case	):
																		with redirect_stdin(__snake_case	):
																								yield
@contextlib.contextmanager
def 						__lowerCamelCase	(       )	->							Any:






						"""simple docstring"""





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



class lowerCamelCase			(  lowercase_						):



			'''simple docstring'''






			pass



class lowerCamelCase			(  io.StringIO						):



			'''simple docstring'''






			def lowercase__						(				self	:						Dict		,      *lowerCAmelCase_	:						List[Any]		,      **lowerCAmelCase_	:						int			)      ->		str:





									'''simple docstring'''
									raise OSError


			def lowercase__						(				self	:						Optional[Any]		,      *lowerCAmelCase_	:						Dict		,      **lowerCAmelCase_	:						Optional[int]			)      ->		str:





									'''simple docstring'''
									raise OSError


			def lowercase__						(				self	:						Any		,      *lowerCAmelCase_	:						Any		,      **lowerCAmelCase_	:						str			)      ->		Dict:





									'''simple docstring'''
									raise OSError



			def lowercase__						(				self	:						List[Any]		,      *lowerCAmelCase_	:						Optional[Any]		,      **lowerCAmelCase_	:						int			)      ->		int:





									'''simple docstring'''
									return False



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



			'''simple docstring'''






			__snake_case        =	'stdin'


@contextlib.contextmanager
def 						__lowerCamelCase	(       __snake_case					:		Optional[int]	)	->							Optional[int]:






						"""simple docstring"""





						if root == ".":
												yield
												return
						A__					:       int     =os.getcwd()
						os.chdir(__snake_case	)
						try:
												yield
						except BaseException as exc:
												raise exc
						finally:
												os.chdir(__snake_case	)
def 						__lowerCamelCase	(       __snake_case					:		List[str]=None	)	->							Optional[int]:






						"""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

						A__					:       Optional[int]     =None
						A__					:       int     =None

						import os

						A__					:       List[Any]     ="""1"""

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

						import shutil

						A__					:       Tuple     =None
						A__					:       Tuple     =None
						A__					:       Optional[Any]     =None

						import subprocess

						A__					:       Optional[int]     =None  # type: ignore

						A__					:       str     =None

						import sys

						A__					:       int     =None
						A__					:       Any     =None
						A__					:       str     =None
						A__					:       Optional[int]     =None
						A__					:       Optional[int]     =None




'''simple docstring'''



from __future__ import annotations
def 						__lowerCamelCase	(       __snake_case					:		list[int]	)	->							bool:






						"""simple docstring"""





						return len(set(__snake_case	)	) == len(__snake_case	)


if __name__ == "__main__":
		import doctest

		doctest.testmod()

