



'''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  :						Union[str, Any]     ,_snake_case  :						Any     ,_snake_case  :						List[Any]     ,_snake_case  :						List[Any]       ):





    '''simple docstring'''


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

    lowercase__		       =						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  :						List[str]     ,_snake_case  :						str     ,_snake_case  :						Union[str, Any]       ):





    '''simple docstring'''


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

        lowercase__		       =						shutil.rmtree
        lowercase__		       =						os.rmdir
        lowercase__		       =						os.chdir

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

        # Run program.
        try:
            lowercase__		       =						{}
            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.
        lowercase__		       =						rmtree
        lowercase__		       =						rmdir
        lowercase__		       =						chdir




@contextlib.contextmanager
def        lowerCamelCase  (				_snake_case  :						str       ):





    '''simple docstring'''


    def signal_handler(_snake_case  :						Tuple     ,_snake_case  :						int       ):
        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  (				):





    '''simple docstring'''


    lowercase__		       =						WriteOnlyStringIO()
    with contextlib.redirect_stdout(_snake_case       ):
        with contextlib.redirect_stderr(_snake_case       ):
            with redirect_stdin(_snake_case       ):
                yield




@contextlib.contextmanager
def        lowerCamelCase  (				):





    '''simple docstring'''


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


class 				snake_case (UpperCamelCase   ):
       pass





class 				snake_case (io.StringIO   ):



       def 							_a      (				self     ,*UpperCAmelCase_     ,**UpperCAmelCase_      )  ->							Union[str, Any]:
           raise OSError



       def 							_a      (				self     ,*UpperCAmelCase_     ,**UpperCAmelCase_      )  ->							Optional[Any]:
           raise OSError



       def 							_a      (				self     ,*UpperCAmelCase_     ,**UpperCAmelCase_      )  ->							Optional[Any]:
           raise OSError







       def 							_a      (				self     ,*UpperCAmelCase_     ,**UpperCAmelCase_      )  ->							Union[str, Any]:
           return False





class 				snake_case (contextlib._RedirectStream   ):  # type: ignore
       lowerCAmelCase__  :Optional[int]						   =					"stdin"





@contextlib.contextmanager
def        lowerCamelCase  (				_snake_case  :						Dict       ):





    '''simple docstring'''


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




def        lowerCamelCase  (				_snake_case  :						int=None       ):





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

    lowercase__		       =						None
    lowercase__		       =						None

    import os

    lowercase__		       =						"1"

    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None

    import shutil

    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None

    import subprocess

    lowercase__		       =						None  # type: ignore

    lowercase__		       =						None

    import sys

    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None
    lowercase__		       =						None









'''simple docstring'''





print((lambda quine: quine % quine)("print((lambda quine: quine %% quine)(%r))"))




