# 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_			(   _SCREAMING_SNAKE_CASE     :				int		, _SCREAMING_SNAKE_CASE     :				Any		, _SCREAMING_SNAKE_CASE     :				Tuple		, _SCREAMING_SNAKE_CASE     :				Any			):
						UpperCamelCase_		:							str  =		multiprocessing.Manager()
						UpperCamelCase_		:							List[Any]  =		manager.list()

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

												UpperCamelCase_		:							Union[str, Any]  =		shutil.rmtree
												UpperCamelCase_		:							List[Any]  =		os.rmdir
												UpperCamelCase_		:							str  =		os.chdir

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

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

												# Needed for cleaning up.
												UpperCamelCase_		:							List[Any]  =		rmtree
												UpperCamelCase_		:							str  =		rmdir
												UpperCamelCase_		:							str  =		chdir






@contextlib.contextmanager
def     lowerCAmelCase_			(   _SCREAMING_SNAKE_CASE     :				int			):
						def signal_handler(_SCREAMING_SNAKE_CASE     :				str		, _SCREAMING_SNAKE_CASE     :				Tuple			):
												raise TimeoutException("""Timed out!"""			)

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






@contextlib.contextmanager
def     lowerCAmelCase_			(   ):
						UpperCamelCase_		:							Optional[int]  =		WriteOnlyStringIO()
						with contextlib.redirect_stdout(_SCREAMING_SNAKE_CASE			):
												with contextlib.redirect_stderr(_SCREAMING_SNAKE_CASE			):
																		with redirect_stdin(_SCREAMING_SNAKE_CASE			):
																								yield






@contextlib.contextmanager
def     lowerCAmelCase_			(   ):
						with tempfile.TemporaryDirectory() as dirname:
												with chdir(_SCREAMING_SNAKE_CASE			):
																		yield dirname

class        UpperCamelCase						(				__a				):
						pass


class        UpperCamelCase						(				io.StringIO				):





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





						def        A_							(self			,     *__UpperCamelCase			,     **__UpperCamelCase						)				->				str:
												raise OSError





						def        A_							(self			,     *__UpperCamelCase			,     **__UpperCamelCase						)				->				Dict:
												raise OSError





						def        A_							(self			,     *__UpperCamelCase			,     **__UpperCamelCase						)				->				Tuple:
												return False


class        UpperCamelCase						(				contextlib._RedirectStream				):  # type: ignore
						a__		:Tuple      =			'''stdin'''






@contextlib.contextmanager
def     lowerCAmelCase_			(   _SCREAMING_SNAKE_CASE     :				int			):
						if root == ".":
												yield
												return
						UpperCamelCase_		:							List[Any]  =		os.getcwd()
						os.chdir(_SCREAMING_SNAKE_CASE			)
						try:
												yield
						except BaseException as exc:
												raise exc
						finally:
												os.chdir(_SCREAMING_SNAKE_CASE			)







def     lowerCAmelCase_			(   _SCREAMING_SNAKE_CASE     :				List[str]=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

						UpperCamelCase_		:							Optional[int]  =		None
						UpperCamelCase_		:							Tuple  =		None

						import os

						UpperCamelCase_		:							Tuple  =		"""1"""

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

						import shutil

						UpperCamelCase_		:							Dict  =		None
						UpperCamelCase_		:							Any  =		None
						UpperCamelCase_		:							Optional[int]  =		None

						import subprocess

						UpperCamelCase_		:							Dict  =		None  # type: ignore

						UpperCamelCase_		:							Optional[Any]  =		None

						import sys

						UpperCamelCase_		:							Any  =		None
						UpperCamelCase_		:							str  =		None
						UpperCamelCase_		:							Tuple  =		None
						UpperCamelCase_		:							Dict  =		None
						UpperCamelCase_		:							Tuple  =		None







from __future__ import annotations

import json

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

SCREAMING_SNAKE_CASE		:     Union[str, Any]         =	{"UserAgent": UserAgent().random}






def     lowerCAmelCase_			(   _SCREAMING_SNAKE_CASE     :				Dict			):
						UpperCamelCase_		:							Tuple  =		script.contents[0]
						UpperCamelCase_		:							List[Any]  =		json.loads(data[data.find("""{\"config\""""			) : -1]			)
						return info["entry_data"]["ProfilePage"][0]["graphql"]["user"]

class        UpperCamelCase						:





						def __init__(self			,     __UpperCamelCase						)				->				List[str]:
												UpperCamelCase_		:							Union[str, Any]  =		f'''https://www.instagram.com/{username}/'''
												UpperCamelCase_		:							Optional[int]  =		self.get_json()





						def        A_							(self						)				->				dict:
												UpperCamelCase_		:							Optional[Any]  =		requests.get(self.url			,     headers=__UpperCamelCase						).text
												UpperCamelCase_		:							Any  =		BeautifulSoup(__UpperCamelCase			,     """html.parser"""						).find_all("""script"""						)
												try:
																		return extract_user_profile(scripts[4]						)
												except (json.decoder.JSONDecodeError, KeyError):
																		return extract_user_profile(scripts[3]						)





						def __repr__(self						)				->				str:
												return f'''{self.__class__.__name__}(\'{self.username}\')'''





						def __str__(self						)				->				str:
												return f'''{self.fullname} ({self.username}) is {self.biography}'''





						@property
						def        A_							(self						)				->				str:
												return self.user_data["username"]





						@property
						def        A_							(self						)				->				str:
												return self.user_data["full_name"]





						@property
						def        A_							(self						)				->				str:
												return self.user_data["biography"]





						@property
						def        A_							(self						)				->				str:
												return self.user_data["business_email"]





						@property
						def        A_							(self						)				->				str:
												return self.user_data["external_url"]





						@property
						def        A_							(self						)				->				int:
												return self.user_data["edge_followed_by"]["count"]





						@property
						def        A_							(self						)				->				int:
												return self.user_data["edge_follow"]["count"]





						@property
						def        A_							(self						)				->				int:
												return self.user_data["edge_owner_to_timeline_media"]["count"]





						@property
						def        A_							(self						)				->				str:
												return self.user_data["profile_pic_url_hd"]





						@property
						def        A_							(self						)				->				bool:
												return self.user_data["is_verified"]





						@property
						def        A_							(self						)				->				bool:
												return self.user_data["is_private"]






def     lowerCAmelCase_			(   _SCREAMING_SNAKE_CASE     :				str = "github"			):
						import os

						if os.environ.get("""CI"""			):
												return  # test failing on GitHub Actions
						UpperCamelCase_		:							Any  =		InstagramUser(_SCREAMING_SNAKE_CASE			)
						assert instagram_user.user_data
						assert isinstance(instagram_user.user_data		, _SCREAMING_SNAKE_CASE			)
						assert instagram_user.username == username
						if username != "github":
												return
						assert instagram_user.fullname == "GitHub"
						assert instagram_user.biography == "Built for developers."
						assert instagram_user.number_of_posts > 150
						assert instagram_user.number_of_followers > 12_0000
						assert instagram_user.number_of_followings > 15
						assert instagram_user.email == "support@github.com"
						assert instagram_user.website == "https://github.com/readme"
						assert instagram_user.profile_picture_url.startswith("""https://instagram."""			)
						assert instagram_user.is_verified is True
						assert instagram_user.is_private is False


if __name__ == "__main__":
	import doctest

	doctest.testmod()
	SCREAMING_SNAKE_CASE		:     Dict         =	InstagramUser("github")
	print(instagram_user)
	print(F'''{instagram_user.number_of_posts = }''')
	print(F'''{instagram_user.number_of_followers = }''')
	print(F'''{instagram_user.number_of_followings = }''')
	print(F'''{instagram_user.email = }''')
	print(F'''{instagram_user.website = }''')
	print(F'''{instagram_user.profile_picture_url = }''')
	print(F'''{instagram_user.is_verified = }''')
	print(F'''{instagram_user.is_private = }''')






