






'''simple docstring'''




from abc import ABC, abstractmethod
from typing import List, Optional







class       __lowercase					(UpperCamelCase__    ):

	def __init__(      self   :						List[str]):
			# test for the above condition
			self.test()

	def      __UpperCamelCase							(      self   :						Dict):
			UpperCamelCase__				:					Union[str, Any]					=					0
			UpperCamelCase__				:					Tuple					=					False
			while not completed:
					if counter == 1:
							self.reset()
					UpperCamelCase__				:					str					=					self.advance()
					if not self.does_advance(UpperCAmelCase_):
							raise Exception(
							    'Custom Constraint is not defined correctly. self.does_advance(self.advance()) must be true.')

					UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__				:					Any					=					self.update(UpperCAmelCase_)
					counter += 1

					if counter > 10_000:
							raise Exception('update() does not fulfill the constraint.')

			if self.remaining() != 0:
					raise Exception('Custom Constraint is not defined correctly.')

	@abstractmethod
	def      __UpperCamelCase							(      self   :						Tuple):
			raise NotImplementedError(
			    F'{self.__class__} is an abstract class. Only classes inheriting this class can be called.')

	@abstractmethod
	def      __UpperCamelCase							(      self   :						Union[str, Any]  ,					UpperCAmelCase_   :						Dict):
			raise NotImplementedError(
			    F'{self.__class__} is an abstract class. Only classes inheriting this class can be called.')

	@abstractmethod
	def      __UpperCamelCase							(      self   :						Optional[Any]  ,					UpperCAmelCase_   :						Optional[int]):
			raise NotImplementedError(
			    F'{self.__class__} is an abstract class. Only classes inheriting this class can be called.')

	@abstractmethod
	def      __UpperCamelCase							(      self   :						Optional[Any]):
			raise NotImplementedError(
			    F'{self.__class__} is an abstract class. Only classes inheriting this class can be called.')

	@abstractmethod
	def      __UpperCamelCase							(      self   :						Union[str, Any]):
			raise NotImplementedError(
			    F'{self.__class__} is an abstract class. Only classes inheriting this class can be called.')





	@abstractmethod
	def      __UpperCamelCase							(      self   :						List[str]  ,					UpperCAmelCase_   :						Optional[Any]=False):
			raise NotImplementedError(
			    F'{self.__class__} is an abstract class. Only classes inheriting this class can be called.')







class       __lowercase					(UpperCamelCase__    ):

	def __init__(      self   :						List[str]  ,					UpperCAmelCase_   :						Optional[int]):
			super(UpperCAmelCase_  ,					self).__init__()

			if not isinstance(UpperCAmelCase_  ,					UpperCAmelCase_) or len(UpperCAmelCase_) == 0:
					raise ValueError(F'`token_ids` has to be a non-empty list, but is {token_ids}.')
			if any((not isinstance(UpperCAmelCase_  ,					UpperCAmelCase_) or token_id < 0) for token_id in token_ids):
					raise ValueError(F'Each list in `token_ids` has to be a list of positive integers, but is {token_ids}.')

			UpperCamelCase__				:					str					=					token_ids

			UpperCamelCase__				:					Union[str, Any]					=					len(self.token_ids)
			UpperCamelCase__				:					str					=					-1  # the index of the currently fulfilled step
			UpperCamelCase__				:					Optional[int]					=					False

	def      __UpperCamelCase							(      self   :						Optional[int]):
			if self.completed:
					return None
			return self.token_ids[self.fulfilled_idx + 1]

	def      __UpperCamelCase							(      self   :						Dict  ,					UpperCAmelCase_   :						Optional[Any]):
			if not isinstance(UpperCAmelCase_  ,					UpperCAmelCase_):
					raise ValueError(F'`token_id` has to be an `int`, but is {token_id} of type {type(UpperCAmelCase_)}')

			if self.completed:
					return False

			return token_id == self.token_ids[self.fulfilled_idx + 1]

	def      __UpperCamelCase							(      self   :						Optional[Any]  ,					UpperCAmelCase_   :						Union[str, Any]):
			if not isinstance(UpperCAmelCase_  ,					UpperCAmelCase_):
					raise ValueError(F'`token_id` has to be an `int`, but is {token_id} of type {type(UpperCAmelCase_)}')

			UpperCamelCase__				:					int					=					False
			UpperCamelCase__				:					Optional[Any]					=					False
			UpperCamelCase__				:					List[Any]					=					False

			if self.does_advance(UpperCAmelCase_):
					self.fulfilled_idx += 1
					UpperCamelCase__				:					Tuple					=					True
					if self.fulfilled_idx == (self.seqlen - 1):
							UpperCamelCase__				:					Tuple					=					True
					UpperCamelCase__				:					List[str]					=					completed
			else:
					# failed to make progress.
					UpperCamelCase__				:					Union[str, Any]					=					True
					self.reset()
			return stepped, completed, reset

	def      __UpperCamelCase							(      self   :						Optional[Any]):
			UpperCamelCase__				:					str					=					False
			UpperCamelCase__				:					Optional[int]					=					0

	def      __UpperCamelCase							(      self   :						str):
			return self.seqlen - (self.fulfilled_idx + 1)





	def      __UpperCamelCase							(      self   :						Dict  ,					UpperCAmelCase_   :						Dict=False):
			UpperCamelCase__				:					Optional[Any]					=					PhrasalConstraint(self.token_ids)

			if stateful:
					UpperCamelCase__				:					Tuple					=					self.seqlen
					UpperCamelCase__				:					Dict					=					self.fulfilled_idx
					UpperCamelCase__				:					List[Any]					=					self.completed

			return new_constraint







class       __lowercase					:

	def __init__(      self   :						Union[str, Any]  ,					UpperCAmelCase_   :						Optional[Any]  ,					UpperCAmelCase_   :						int=True):
			UpperCamelCase__				:					Optional[Any]					=					max([len(UpperCAmelCase_) for one in nested_token_ids])

			UpperCamelCase__				:					Tuple					=					{}
			for token_ids in nested_token_ids:
					UpperCamelCase__				:					List[Any]					=					root
					for tidx, token_id in enumerate(UpperCAmelCase_):
							if token_id not in level:
									UpperCamelCase__				:					List[str]					=					{}

							UpperCamelCase__				:					List[str]					=					level[token_id]

			if no_subsets and self.has_subsets(UpperCAmelCase_  ,					UpperCAmelCase_):
					raise ValueError(
					    'Each list in `nested_token_ids` can\'t be a complete subset of another list, but is'
					    F' {nested_token_ids}.')

			UpperCamelCase__				:					List[str]					=					root

	def      __UpperCamelCase							(      self   :						Optional[int]  ,					UpperCAmelCase_   :						Optional[int]):
			UpperCamelCase__				:					Union[str, Any]					=					self.trie

			for current_token in current_seq:
					UpperCamelCase__				:					Any					=					start[current_token]

			UpperCamelCase__				:					Optional[int]					=					list(start.keys())

			return next_tokens

	def      __UpperCamelCase							(      self   :						Dict  ,					UpperCAmelCase_   :						Any):
			UpperCamelCase__				:					List[str]					=					self.next_tokens(UpperCAmelCase_)

			return len(UpperCAmelCase_) == 0

	def      __UpperCamelCase							(      self   :						List[Any]  ,					UpperCAmelCase_   :						str):
			UpperCamelCase__				:					Any					=					list(root.values())
			if len(UpperCAmelCase_) == 0:
					return 1
			else:
					return sum([self.count_leaves(UpperCAmelCase_) for nn in next_nodes])





	def      __UpperCamelCase							(      self   :						str  ,					UpperCAmelCase_   :						List[str]  ,					UpperCAmelCase_   :						Any):
			UpperCamelCase__				:					int					=					self.count_leaves(UpperCAmelCase_)
			return len(UpperCAmelCase_) != leaf_count







class       __lowercase					(UpperCamelCase__    ):

	def __init__(      self   :						Optional[int]  ,					UpperCAmelCase_   :						Dict):
			super(UpperCAmelCase_  ,					self).__init__()

			if not isinstance(UpperCAmelCase_  ,					UpperCAmelCase_) or len(UpperCAmelCase_) == 0:
					raise ValueError(F'`nested_token_ids` has to be a non-empty list, but is {nested_token_ids}.')
			if any(not isinstance(UpperCAmelCase_  ,					UpperCAmelCase_) for token_ids in nested_token_ids):
					raise ValueError(F'`nested_token_ids` has to be a list of lists, but is {nested_token_ids}.')
			if any(
			    any((not isinstance(UpperCAmelCase_  ,					UpperCAmelCase_) or token_id < 0) for token_id in token_ids)
			    for token_ids in nested_token_ids):
					raise ValueError(
					    F'Each list in `nested_token_ids` has to be a list of positive integers, but is {nested_token_ids}.')

			UpperCamelCase__				:					Optional[int]					=					DisjunctiveTrie(UpperCAmelCase_)
			UpperCamelCase__				:					int					=					nested_token_ids

			UpperCamelCase__				:					List[Any]					=					self.trie.max_height
			UpperCamelCase__				:					str					=					[]
			UpperCamelCase__				:					Optional[Any]					=					False

	def      __UpperCamelCase							(      self   :						Optional[int]):
			UpperCamelCase__				:					Dict					=					self.trie.next_tokens(self.current_seq)

			if len(UpperCAmelCase_) == 0:
					return None
			else:
					return token_list

	def      __UpperCamelCase							(      self   :						Tuple  ,					UpperCAmelCase_   :						int):
			if not isinstance(UpperCAmelCase_  ,					UpperCAmelCase_):
					raise ValueError(F'`token_id` is supposed to be type `int`, but is {token_id} of type {type(UpperCAmelCase_)}')

			UpperCamelCase__				:					Tuple					=					self.trie.next_tokens(self.current_seq)

			return token_id in next_tokens

	def      __UpperCamelCase							(      self   :						Any  ,					UpperCAmelCase_   :						Optional[Any]):
			if not isinstance(UpperCAmelCase_  ,					UpperCAmelCase_):
					raise ValueError(F'`token_id` is supposed to be type `int`, but is {token_id} of type {type(UpperCAmelCase_)}')

			UpperCamelCase__				:					Optional[Any]					=					False
			UpperCamelCase__				:					List[str]					=					False
			UpperCamelCase__				:					Tuple					=					False

			if self.does_advance(UpperCAmelCase_):
					self.current_seq.append(UpperCAmelCase_)
					UpperCamelCase__				:					str					=					True
			else:
					UpperCamelCase__				:					int					=					True
					self.reset()

			UpperCamelCase__				:					str					=					self.trie.reached_leaf(self.current_seq)
			UpperCamelCase__				:					Any					=					completed

			return stepped, completed, reset

	def      __UpperCamelCase							(      self   :						Any):
			UpperCamelCase__				:					List[str]					=					False
			UpperCamelCase__				:					List[str]					=					[]

	def      __UpperCamelCase							(      self   :						List[Any]):
			if self.completed:
					# since this can be completed without reaching max height
					return 0
			else:
					return self.seqlen - len(self.current_seq)





	def      __UpperCamelCase							(      self   :						Union[str, Any]  ,					UpperCAmelCase_   :						int=False):
			UpperCamelCase__				:					int					=					DisjunctiveConstraint(self.token_ids)

			if stateful:
					UpperCamelCase__				:					Dict					=					self.seqlen
					UpperCamelCase__				:					Tuple					=					self.current_seq
					UpperCamelCase__				:					Optional[Any]					=					self.completed

			return new_constraint







class       __lowercase					:

	def __init__(      self   :						Any  ,					UpperCAmelCase_   :						List[Any]):
			UpperCamelCase__				:					Union[str, Any]					=					constraints

			# max # of steps required to fulfill a given constraint
			UpperCamelCase__				:					Any					=					max([c.seqlen for c in constraints])
			UpperCamelCase__				:					Dict					=					len(UpperCAmelCase_)
			UpperCamelCase__				:					Optional[int]					=					False

			self.init_state()

	def      __UpperCamelCase							(      self   :						int):
			UpperCamelCase__				:					Any					=					[]
			UpperCamelCase__				:					int					=					None
			UpperCamelCase__				:					Optional[int]					=					[constraint.copy(stateful=UpperCAmelCase_) for constraint in self.constraints]

	def      __UpperCamelCase							(      self   :						str):
			UpperCamelCase__				:					Any					=					0
			if self.inprogress_constraint:
					# extra points for having a constraint mid-fulfilled
					add += self.max_seqlen - self.inprogress_constraint.remaining()

			return (len(self.complete_constraints) * self.max_seqlen) + add

	def      __UpperCamelCase							(      self   :						str):
			UpperCamelCase__				:					List[str]					=					[]
			if self.inprogress_constraint is None:
					for constraint in self.pending_constraints:  # "pending" == "unfulfilled yet"
							UpperCamelCase__				:					str					=					constraint.advance()
							if isinstance(UpperCAmelCase_  ,					UpperCAmelCase_):
									token_list.append(UpperCAmelCase_)
							elif isinstance(UpperCAmelCase_  ,					UpperCAmelCase_):
									token_list.extend(UpperCAmelCase_)
			else:
					UpperCamelCase__				:					List[str]					=					self.inprogress_constraint.advance()
					if isinstance(UpperCAmelCase_  ,					UpperCAmelCase_):
							token_list.append(UpperCAmelCase_)
					elif isinstance(UpperCAmelCase_  ,					UpperCAmelCase_):
							token_list.extend(UpperCAmelCase_)

			if len(UpperCAmelCase_) == 0:
					return None
			else:
					return token_list

	def      __UpperCamelCase							(      self   :						List[Any]  ,					UpperCAmelCase_   :						Dict):
			self.init_state()

			if token_ids is not None:
					for token in token_ids:
							# completes or steps **one** constraint
							UpperCamelCase__,	UpperCamelCase__				:					Union[str, Any]					=					self.add(UpperCAmelCase_)

							# the entire list of constraints are fulfilled
							if self.completed:
									break

	def      __UpperCamelCase							(      self   :						Any  ,					UpperCAmelCase_   :						List[Any]):
			if not isinstance(UpperCAmelCase_  ,					UpperCAmelCase_):
					raise ValueError(F'`token_id` should be an `int`, but is `{token_id}`.')

			UpperCamelCase__,	UpperCamelCase__				:					Optional[Any]					=					False, False

			if self.completed:
					UpperCamelCase__				:					List[Any]					=					True
					UpperCamelCase__				:					List[str]					=					False
					return complete, stepped

			if self.inprogress_constraint is not None:
					# In the middle of fulfilling a constraint. If the `token_id` *does* makes an incremental progress to current
					# job, simply update the state

					UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__				:					List[Any]					=					self.inprogress_constraint.update(UpperCAmelCase_)
					if reset:
							# 1. If the next token breaks the progress, then we must restart.
							#     e.g. constraint = "I love pies" and sequence so far is "I love" but `token_id` == "books".

							#     But that doesn't mean we self.init_state(), since we only reset the state for this particular
							#     constraint, not the full list of constraints.

							self.pending_constraints.append(self.inprogress_constraint.copy(stateful=UpperCAmelCase_))
							UpperCamelCase__				:					Optional[int]					=					None

					if complete:
							# 2. If the next token completes the constraint, move it to completed list, set
							#     inprogress to None. If there are no pending constraints either, then this full list of constraints
							#     is complete.

							self.complete_constraints.append(self.inprogress_constraint)
							UpperCamelCase__				:					str					=					None

							if len(self.pending_constraints) == 0:
									# we're done!
									UpperCamelCase__				:					str					=					True

			else:
					# Not in the middle of fulfilling a constraint. So does this `token_id` helps us step towards any of our list
					# of constraints?

					for cidx, pending_constraint in enumerate(self.pending_constraints):
							if pending_constraint.does_advance(UpperCAmelCase_):
									UpperCamelCase__,	UpperCamelCase__,	UpperCamelCase__				:					Tuple					=					pending_constraint.update(UpperCAmelCase_)

									if not stepped:
											raise Exception(
											    '`constraint.update(token_id)` is not yielding incremental progress, '
											    'even though `constraint.does_advance(token_id)` is true.')

									if complete:
											self.complete_constraints.append(UpperCAmelCase_)
											UpperCamelCase__				:					Optional[Any]					=					None

									if not complete and stepped:
											UpperCamelCase__				:					List[str]					=					pending_constraint

									if complete or stepped:
											# If we made any progress at all, then it's at least not a "pending constraint".

											UpperCamelCase__				:					Union[str, Any]					=					(
											    self.pending_constraints[:cidx] + self.pending_constraints[cidx + 1 :]
											)

											if len(self.pending_constraints) == 0 and self.inprogress_constraint is None:
													# If there's no longer any pending after this and no inprogress either, then we must be
													# complete.

													UpperCamelCase__				:					Tuple					=					True

											break  # prevent accidentally stepping through multiple constraints with just one token.

			return complete, stepped





	def      __UpperCamelCase							(      self   :						List[Any]  ,					UpperCAmelCase_   :						Optional[int]=True):
			UpperCamelCase__				:					str					=					ConstraintListState(self.constraints)  # we actually never though self.constraints objects
			# throughout this process. So it's at initialization state.

			if stateful:
					UpperCamelCase__				:					Optional[int]					=					[
					    constraint.copy(stateful=UpperCAmelCase_) for constraint in self.complete_constraints
					]
					if self.inprogress_constraint is not None:
							UpperCamelCase__				:					Tuple					=					self.inprogress_constraint.copy(stateful=UpperCAmelCase_)
					UpperCamelCase__				:					Tuple					=					[constraint.copy() for constraint in self.pending_constraints]

			return new_state












'''simple docstring'''




import requests
from bsa import BeautifulSoup







def       __UpperCAmelCase						(  lowerCamelCase_ = "AAPL")							->     str:
		UpperCamelCase__				:					str					=					f'https://in.finance.yahoo.com/quote/{symbol}?s={symbol}'
		UpperCamelCase__				:					Optional[Any]					=					BeautifulSoup(requests.get(lowerCamelCase_).text     ,      'html.parser')
		UpperCamelCase__				:					Union[str, Any]					=					'My(6px) Pos(r) smartphone_Mt(6px)'
		return soup.find('div'     ,      class_=class_).find('span').text


if __name__ == "__main__":
		for symbol in "AAPL AMZN IBM GOOG MSFT ORCL".split():
				print(f'''Current {symbol:<4} stock price is {stock_price(symbol):>8}''')




