





# 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   ):
	snake_case_		:			Union[str, Any]											=	multiprocessing.Manager()
	snake_case_		:			Any											=	manager.list()

	snake_case_		:			Dict											=	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

		snake_case_		:			int											=	shutil.rmtree
		snake_case_		:			Union[str, Any]											=	os.rmdir
		snake_case_		:			Dict											=	os.chdir

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

		# Run program.
		try:
			snake_case_		:			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.
		snake_case_		:			Union[str, Any]											=	rmtree
		snake_case_		:			str											=	rmdir
		snake_case_		:			Tuple											=	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__						(    ):
	snake_case_		:			Any											=	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_						(					snake_case_					):
						pass
class SCREAMING_SNAKE_CASE_						(					io.StringIO					):






						def UpperCAmelCase_				(      self      :      str		,   *_A      :      List[Any]		,   **_A      :      str	)							->    Tuple:







							"""simple docstring"""


							raise OSError






						def UpperCAmelCase_				(      self      :      Tuple		,   *_A      :      Optional[int]		,   **_A      :      List[Any]	)							->    Any:







							"""simple docstring"""


							raise OSError






						def UpperCAmelCase_				(      self      :      str		,   *_A      :      Optional[int]		,   **_A      :      Optional[Any]	)							->    List[str]:







							"""simple docstring"""


							raise OSError






						def UpperCAmelCase_				(      self      :      Optional[Any]		,   *_A      :      Union[str, Any]		,   **_A      :      Optional[Any]	)							->    List[Any]:







							"""simple docstring"""


							return False
class SCREAMING_SNAKE_CASE_						(					contextlib._RedirectStream					):  # type: ignore
						__magic_name__:			Union[str, Any]       =       "stdin"


@contextlib.contextmanager
def 							SCREAMING_SNAKE_CASE__						(    __a   ):
	if root == ".":
		yield
		return
	snake_case_		:			List[Any]											=	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

	snake_case_		:			int											=	None
	snake_case_		:			Optional[Any]											=	None

	import os

	snake_case_		:			int											=	'1'

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

	import shutil

	snake_case_		:			Any											=	None
	snake_case_		:			str											=	None
	snake_case_		:			int											=	None

	import subprocess

	snake_case_		:			Dict											=	None  # type: ignore

	snake_case_		:			Tuple											=	None

	import sys

	snake_case_		:			Tuple											=	None
	snake_case_		:			Optional[Any]											=	None
	snake_case_		:			str											=	None
	snake_case_		:			Optional[int]											=	None
	snake_case_		:			Optional[Any]											=	None








import webbrowser
from sys import argv
from urllib.parse import parse_qs, quote

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

if __name__ == "__main__":
						_SCREAMING_SNAKE_CASE      	=		"""%20""".join(argv[1:]) if len(argv) > 1 else quote(str(input("""Search: """)))

						print("""Googling.....""")

						_SCREAMING_SNAKE_CASE      	=		F'''https://www.google.com/search?q={query}&num=100'''

						_SCREAMING_SNAKE_CASE      	=		requests.get(
						    url,
						    headers={"""User-Agent""": str(UserAgent().random)},
						)

						try:
												_SCREAMING_SNAKE_CASE      	=		(
												    BeautifulSoup(res.text, """html.parser""")
												    .find("""div""", attrs={"""class""": """yuRUbf"""})
												    .find("""a""")
												    .get("""href""")
												)

						except AttributeError:
												_SCREAMING_SNAKE_CASE      	=		parse_qs(
												    BeautifulSoup(res.text, """html.parser""")
												    .find("""div""", attrs={"""class""": """kCrYT"""})
												    .find("""a""")
												    .get("""href""")
												)["""url"""][0]

						webbrowser.open(link)

