


'''simple docstring'''




from __future__ import annotations

import json

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

_lowerCAmelCase  :		Tuple		     =	{'UserAgent': UserAgent().random}

def 			__UpperCamelCase    (    _A    :				Tuple				)    ->      dict:




	"""simple docstring"""





	lowerCAmelCase					:    int      							= script.contents[0]
	lowerCAmelCase					:    List[str]      							= json.loads(data[data.find('{\"config\"'				) : -1]				)
	return info["entry_data"]["ProfilePage"][0]["graphql"]["user"]



class  lowerCAmelCase				:



	def __init__(					self ,					snake_case__    ):
		lowerCAmelCase					:    Union[str, Any]      							= f"https://www.instagram.com/{username}/"
		lowerCAmelCase					:    Dict      							= self.get_json()



	def 				lowercase     (					self    ):
		lowerCAmelCase					:    Optional[Any]      							= requests.get(self.url ,					headers=__a    ).text
		lowerCAmelCase					:    str      							= BeautifulSoup(__a ,					'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    ):
		return f"{self.__class__.__name__}(\'{self.username}\')"



	def __str__(					self    ):
		return f"{self.fullname} ({self.username}) is {self.biography}"



	@property
	def 				lowercase     (					self    ):
		return self.user_data["username"]



	@property
	def 				lowercase     (					self    ):
		return self.user_data["full_name"]



	@property
	def 				lowercase     (					self    ):
		return self.user_data["biography"]



	@property
	def 				lowercase     (					self    ):
		return self.user_data["business_email"]



	@property
	def 				lowercase     (					self    ):
		return self.user_data["external_url"]



	@property
	def 				lowercase     (					self    ):
		return self.user_data["edge_followed_by"]["count"]



	@property
	def 				lowercase     (					self    ):
		return self.user_data["edge_follow"]["count"]



	@property
	def 				lowercase     (					self    ):
		return self.user_data["edge_owner_to_timeline_media"]["count"]



	@property
	def 				lowercase     (					self    ):
		return self.user_data["profile_pic_url_hd"]



	@property
	def 				lowercase     (					self    ):
		return self.user_data["is_verified"]



	@property
	def 				lowercase     (					self    ):
		return self.user_data["is_private"]


def 			__UpperCamelCase    (    _A    :				Optional[Any] = "github"				)    ->      None:




	"""simple docstring"""





	import os

	if os.environ.get('CI'				):
		return  # test failing on GitHub Actions
	lowerCAmelCase					:    Optional[Any]      							= InstagramUser(lowercase_				)
	assert instagram_user.user_data
	assert isinstance(instagram_user.user_data					,   lowercase_				)
	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 > 1_50
	assert instagram_user.number_of_followers > 12_00_00
	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()
							_lowerCAmelCase  :		Tuple		     =	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 = }""")




'''simple docstring'''




def 			__UpperCamelCase    (    _A    :				List[str]				)    ->      Optional[Any]:




	"""simple docstring"""





	if not head:
		return True
	# split the list to two parts
	lowerCAmelCase							,   lowerCAmelCase					:    str      							= head.next, head
	while fast and fast.next:
		lowerCAmelCase					:    Optional[int]      							= fast.next.next
		lowerCAmelCase					:    int      							= slow.next
	lowerCAmelCase					:    int      							= slow.next
	lowerCAmelCase					:    Optional[Any]      							= None  # Don't forget here! But forget still works!
	# reverse the second part
	lowerCAmelCase					:    List[Any]      							= None
	while second:
		lowerCAmelCase					:    List[Any]      							= second.next
		lowerCAmelCase					:    Union[str, Any]      							= node
		lowerCAmelCase					:    Optional[Any]      							= second
		lowerCAmelCase					:    Any      							= nxt
	# compare two parts
	# second part has the same or one less node
	while node:
		if node.val != head.val:
			return False
		lowerCAmelCase					:    Optional[Any]      							= node.next
		lowerCAmelCase					:    Tuple      							= head.next
	return True

def 			__UpperCamelCase    (    _A    :				Optional[Any]				)    ->      Optional[int]:




	"""simple docstring"""





	if not head or not head.next:
		return True

	# 1. Get the midpoint (slow)
	lowerCAmelCase					:    Optional[int]      							= head
	while fast and fast.next:
		lowerCAmelCase							,   lowerCAmelCase					:    Optional[Any]      							= fast.next.next, slow.next

	# 2. Push the second half into the stack
	lowerCAmelCase					:    Tuple      							= [slow.val]
	while slow.next:
		lowerCAmelCase					:    Tuple      							= slow.next
		stack.append(slow.val				)

	# 3. Comparison
	while stack:
		if stack.pop() != cur.val:
			return False
		lowerCAmelCase					:    Union[str, Any]      							= cur.next

	return True






def 			__UpperCamelCase    (    _A    :				Tuple				)    ->      Optional[int]:




	"""simple docstring"""





	if not head or not head.next:
		return True
	lowerCAmelCase					:    Optional[int]      							= {}
	lowerCAmelCase					:    int      							= 0
	while head:
		if head.val in d:
			d[head.val].append(_A				)
		else:
			lowerCAmelCase					:    Any      							= [pos]
		lowerCAmelCase					:    int      							= head.next
		pos += 1
	lowerCAmelCase					:    str      							= pos - 1
	lowerCAmelCase					:    Optional[Any]      							= 0
	for v in d.values():
		if len(_A				) % 2 != 0:
			middle += 1
		else:
			lowerCAmelCase					:    Any      							= 0
			for i in range(0					,   len(_A				)				):
				if v[i] + v[len(_A				) - 1 - step] != checksum:
					return False
				step += 1
		if middle > 1:
			return False
	return True
