



class     _A       :



       def __init__(		self							:     str     ,		__SCREAMING_SNAKE_CASE							:     List[str]     ,		__SCREAMING_SNAKE_CASE							:     Dict     ,		__SCREAMING_SNAKE_CASE							:     int):


           '''simple docstring'''

           __a						       =				None
           __a						       =				None
           __a						       =				graph

           self._normalize_graph(lowerCamelCase__     ,		lowerCamelCase__)
           __a						       =				len(lowerCamelCase__)
           __a						       =				None



       def 		_lowerCamelCase			(		self							:     List[str]     ,		__SCREAMING_SNAKE_CASE							:     int     ,		__SCREAMING_SNAKE_CASE							:     Optional[Any]):


           '''simple docstring'''

           if sources is int:
               __a						       =				[sources]
           if sinks is int:
               __a						       =				[sinks]

           if len(lowerCamelCase__) == 0 or len(lowerCamelCase__) == 0:
               return

           __a						       =				sources[0]
           __a						       =				sinks[0]

           # make fake vertex if there are more
           # than one source or sink
           if len(lowerCamelCase__) > 1 or len(lowerCamelCase__) > 1:
               __a						       =				0
               for i in sources:
                   max_input_flow += sum(self.graph[i])

               __a						       =				len(self.graph) + 1
               for room in self.graph:
                   room.insert(0     ,		0)
               self.graph.insert(0     ,		[0] * size)
               for i in sources:
                   __a						       =				max_input_flow
               __a						       =				0

               __a						       =				len(self.graph) + 1
               for room in self.graph:
                   room.append(0)
               self.graph.append([0] * size)
               for i in sinks:
                   __a						       =				max_input_flow
               __a						       =				size - 1



       def 		_lowerCamelCase			(		self							:     List[str]):


           '''simple docstring'''

           if self.maximum_flow_algorithm is None:
               raise Exception('''You need to set maximum flow algorithm before.''')
           if self.source_index is None or self.sink_index is None:
               return 0

           self.maximum_flow_algorithm.execute()
           return self.maximum_flow_algorithm.getMaximumFlow()





       def 		_lowerCamelCase			(		self							:     Dict     ,		__SCREAMING_SNAKE_CASE							:     Any):


           '''simple docstring'''

           __a						       =				algorithm(self)


class     _A       :



       def __init__(		self							:     str     ,		__SCREAMING_SNAKE_CASE							:     Tuple):


           '''simple docstring'''

           __a						       =				flow_network
           __a						       =				flow_network.verticesCount
           __a						       =				flow_network.sourceIndex
           __a						       =				flow_network.sinkIndex
           # it's just a reference, so you shouldn't change
           # it in your algorithms, use deep copy before doing that
           __a						       =				flow_network.graph
           __a						       =				False



       def 		_lowerCamelCase			(		self							:     str):


           '''simple docstring'''

           if not self.executed:
               self._algorithm()
               __a						       =				True





       def 		_lowerCamelCase			(		self							:     Optional[Any]):


           '''simple docstring'''

           pass


class     _A       (	UpperCAmelCase__    ):



       def __init__(		self							:     str     ,		__SCREAMING_SNAKE_CASE							:     Dict):


           '''simple docstring'''

           super().__init__(lowerCamelCase__)
           # use this to save your result
           __a						       =				-1





       def 		_lowerCamelCase			(		self							:     Optional[Any]):


           '''simple docstring'''

           if not self.executed:
               raise Exception('''You should execute algorithm before using its result!''')

           return self.maximum_flow


class     _A       (	UpperCAmelCase__    ):



       def __init__(		self							:     Optional[Any]     ,		__SCREAMING_SNAKE_CASE							:     Optional[Any]):


           '''simple docstring'''

           super().__init__(lowerCamelCase__)

           __a						       =				[[0] * self.verticies_count for i in range(self.verticies_count)]

           __a						       =				[0] * self.verticies_count
           __a						       =				[0] * self.verticies_count



       def 		_lowerCamelCase			(		self							:     str):


           '''simple docstring'''

           __a						       =				self.verticies_count

           # push some substance to graph
           for nextvertex_index, bandwidth in enumerate(self.graph[self.source_index]):
               self.preflow[self.source_index][nextvertex_index] += bandwidth
               self.preflow[nextvertex_index][self.source_index] -= bandwidth
               self.excesses[nextvertex_index] += bandwidth

           # Relabel-to-front selection rule
           __a						       =				[
               i
               for i in range(self.verticies_count)
               if i != self.source_index and i != self.sink_index
           ]

           # move through list
           __a						       =				0
           while i < len(lowerCamelCase__):
               __a						       =				vertices_list[i]
               __a						       =				self.heights[vertex_index]
               self.process_vertex(lowerCamelCase__)
               if self.heights[vertex_index] > previous_height:
                   # if it was relabeled, swap elements
                   # and start from 0 index
                   vertices_list.insert(0     ,		vertices_list.pop(lowerCamelCase__))
                   __a						       =				0
               else:
                   i += 1

           __a						       =				sum(self.preflow[self.source_index])



       def 		_lowerCamelCase			(		self							:     str     ,		__SCREAMING_SNAKE_CASE							:     int):


           '''simple docstring'''

           while self.excesses[vertex_index] > 0:
               for neighbour_index in range(self.verticies_count):
                   # if it's neighbour and current vertex is higher
                   if (
                       self.graph[vertex_index][neighbour_index]
                       - self.preflow[vertex_index][neighbour_index]
                       > 0
                       and self.heights[vertex_index] > self.heights[neighbour_index]
                   ):
                       self.push(lowerCamelCase__     ,		lowerCamelCase__)

               self.relabel(lowerCamelCase__)



       def 		_lowerCamelCase			(		self							:     List[Any]     ,		__SCREAMING_SNAKE_CASE							:     int     ,		__SCREAMING_SNAKE_CASE							:     Dict):


           '''simple docstring'''

           __a						       =				min(
               self.excesses[from_index]     ,		self.graph[from_index][to_index] - self.preflow[from_index][to_index]     ,		)
           self.preflow[from_index][to_index] += preflow_delta
           self.preflow[to_index][from_index] -= preflow_delta
           self.excesses[from_index] -= preflow_delta
           self.excesses[to_index] += preflow_delta





       def 		_lowerCamelCase			(		self							:     List[str]     ,		__SCREAMING_SNAKE_CASE							:     List[str]):


           '''simple docstring'''

           __a						       =				None
           for to_index in range(self.verticies_count):
               if (
                   self.graph[vertex_index][to_index]
                   - self.preflow[vertex_index][to_index]
                   > 0
               ) and (min_height is None or self.heights[to_index] < min_height):
                   __a						       =				self.heights[to_index]

           if min_height is not None:
               __a						       =				min_height + 1


if __name__ == "__main__":
 __snake_case						:Union[str, Any]      		=     [0]
 __snake_case						:Any      		=     [3]
 # graph = [
 #     [0, 0, 4, 6, 0, 0],
 #     [0, 0, 5, 2, 0, 0],
 #     [0, 0, 0, 0, 4, 4],
 #     [0, 0, 0, 0, 6, 6],
 #     [0, 0, 0, 0, 0, 0],
 #     [0, 0, 0, 0, 0, 0],
 # ]
 __snake_case						:Union[str, Any]      		=     [[0, 7, 0, 0], [0, 0, 6, 0], [0, 0, 0, 8], [9, 0, 0, 0]]

 # prepare our network
 __snake_case						:Optional[Any]      		=     FlowNetwork(graph, entrances, exits)
 # set algorithm
 flow_network.set_maximum_flow_algorithm(PushRelabelExecutor)
 # and calculate
 __snake_case						:Tuple      		=     flow_network.find_maximum_flow()

 print(f'maximum flow is {maximum_flow}')









'''simple docstring'''


from __future__ import annotations

import json

import requests
from bsa import BeautifulSoup
from fake_useragent import UserAgent

lowerCamelCase__					=   {'UserAgent': UserAgent().random}






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






class 		lowerCAmelCase__	:




			def __init__(						self     :   str		,     lowerCamelCase__     :   List[Any]       )      ->List[str]:



					'''simple docstring'''







					_UpperCAmelCase						:				List[Any]	    =					F"""https://www.instagram.com/{username}/"""
					_UpperCAmelCase						:				Dict	    =					self.get_json()




			def 							lowerCAmelCase__			(						self     :   Any       )      ->dict:



					'''simple docstring'''







					_UpperCAmelCase						:				Optional[int]	    =					requests.get(self.url		,     headers=lowerCamelCase__       ).text
					_UpperCAmelCase						:				Any	    =					BeautifulSoup(lowerCamelCase__		,     "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     :   Optional[Any]       )      ->str:



					'''simple docstring'''







					return F"""{self.__class__.__name__}('{self.username}')"""




			def __str__(						self     :   List[Any]       )      ->str:



					'''simple docstring'''







					return F"""{self.fullname} ({self.username}) is {self.biography}"""




			@property
			def 							lowerCAmelCase__			(						self     :   Optional[int]       )      ->str:



					'''simple docstring'''







					return self.user_data["username"]




			@property
			def 							lowerCAmelCase__			(						self     :   Optional[int]       )      ->str:



					'''simple docstring'''







					return self.user_data["full_name"]




			@property
			def 							lowerCAmelCase__			(						self     :   Optional[int]       )      ->str:



					'''simple docstring'''







					return self.user_data["biography"]




			@property
			def 							lowerCAmelCase__			(						self     :   int       )      ->str:



					'''simple docstring'''







					return self.user_data["business_email"]




			@property
			def 							lowerCAmelCase__			(						self     :   str       )      ->str:



					'''simple docstring'''







					return self.user_data["external_url"]




			@property
			def 							lowerCAmelCase__			(						self     :   Tuple       )      ->int:



					'''simple docstring'''







					return self.user_data["edge_followed_by"]["count"]




			@property
			def 							lowerCAmelCase__			(						self     :   str       )      ->int:



					'''simple docstring'''







					return self.user_data["edge_follow"]["count"]




			@property
			def 							lowerCAmelCase__			(						self     :   Any       )      ->int:



					'''simple docstring'''







					return self.user_data["edge_owner_to_timeline_media"]["count"]




			@property
			def 							lowerCAmelCase__			(						self     :   List[Any]       )      ->str:



					'''simple docstring'''







					return self.user_data["profile_pic_url_hd"]




			@property
			def 							lowerCAmelCase__			(						self     :   Optional[Any]       )      ->bool:



					'''simple docstring'''







					return self.user_data["is_verified"]






			@property
			def 							lowerCAmelCase__			(						self     :   int       )      ->bool:



					'''simple docstring'''







					return self.user_data["is_private"]






def        __lowerCAmelCase       (__lowerCAmelCase = "github"      ):
		import os

		if os.environ.get("CI"      ):
				return  # test failing on GitHub Actions
		_UpperCAmelCase						:				Dict	    =					InstagramUser(__lowerCAmelCase      )
		assert instagram_user.user_data
		assert isinstance(instagram_user.user_data					,       __lowerCAmelCase      )
		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 > 120_000
		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__					=   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 = }''')



