



"""simple docstring"""






from __future__ import annotations

from typing import Generic, TypeVar

__UpperCAmelCase      :      Optional[Any]   					=					TypeVar('T')

class 	__lowerCAmelCase							(__UpperCamelCase  ):


					'''simple docstring'''


					pass



class 	__lowerCAmelCase							(__UpperCamelCase  ):


					'''simple docstring'''


					pass



class 	__lowerCAmelCase							(Generic[T]  ):


					'''simple docstring'''


					def __init__(      self    ,       a = 10   ):




										"""simple docstring"""





										snake_case_						:list[T]								=						[]
										snake_case_						:List[Any]								=						limit







					def __bool__(      self   ):




										"""simple docstring"""





										return bool(self.stack   )







					def __str__(      self   ):




										"""simple docstring"""





										return str(self.stack   )







					def 		_a (      self    ,       a   ):




										"""simple docstring"""





										if len(self.stack   ) >= self.limit:
															raise StackOverflowError
										self.stack.append(a   )







					def 		_a (      self   ):




										"""simple docstring"""





										if not self.stack:
															raise StackUnderflowError
										return self.stack.pop()







					def 		_a (      self   ):




										"""simple docstring"""





										if not self.stack:
															raise StackUnderflowError
										return self.stack[-1]







					def 		_a (      self   ):




										"""simple docstring"""





										return not bool(self.stack   )







					def 		_a (      self   ):




										"""simple docstring"""





										return self.size() == self.limit







					def 		_a (      self   ):




										"""simple docstring"""





										return len(self.stack   )







					def __contains__(      self    ,       a   ):




										"""simple docstring"""





										return item in self.stack



def      A      (			):




					"""simple docstring"""
					snake_case_						:Stack[int]								=						Stack(10							)
					assert bool(_A							) is False
					assert stack.is_empty() is True
					assert stack.is_full() is False
					assert str(_A							) == "[]"

					try:
										snake_case_						:Dict								=						stack.pop()
										raise AssertionError  # This should not happen
					except StackUnderflowError:
										assert True  # This should happen

					try:
										snake_case_						:Optional[int]								=						stack.peek()
										raise AssertionError  # This should not happen
					except StackUnderflowError:
										assert True  # This should happen

					for i in range(10							):
										assert stack.size() == i
										stack.push(_A							)

					assert bool(_A							)
					assert not stack.is_empty()
					assert stack.is_full()
					assert str(_A							) == str(list(range(10							)							)							)
					assert stack.pop() == 9
					assert stack.peek() == 8

					stack.push(100							)
					assert str(_A							) == str([0, 1, 2, 3, 4, 5, 6, 7, 8, 100]							)

					try:
										stack.push(200							)
										raise AssertionError  # This should not happen
					except StackOverflowError:
										assert True  # This should happen

					assert not stack.is_empty()
					assert stack.size() == 10

					assert 5 in stack
					assert 55 not in stack


if __name__ == "__main__":
				test_stack()






"""simple docstring"""






def      A      (			_A,     _A = 1_000							):




					"""simple docstring"""
					if (not isinstance(_A,     _A							)) or (digit_position <= 0):
										raise ValueError("Digit position must be a positive integer"							)
					elif (not isinstance(_A,     _A							)) or (precision < 0):
										raise ValueError("Precision must be a nonnegative integer"							)

					# compute an approximation of (16 ** (n - 1)) * pi whose fractional part is mostly
					# accurate
					snake_case_						:List[Any]								=						(
					    4 * _subsum(_A,     1,     _A							)
					    - 2 * _subsum(_A,     4,     _A							)
					    - _subsum(_A,     5,     _A							)
					    - _subsum(_A,     6,     _A							)
					)

					# return the first hex digit of the fractional part of the result
					return hex(int((sum_result % 1) * 16							)							)[2:]
def      A      (			_A,     _A,     _A							):




					"""simple docstring"""
					snake_case_						:int								=						0.0
					for sum_index in range(digit_pos_to_extract + precision							):
										snake_case_						:Optional[Any]								=						8 * sum_index + denominator_addend
										if sum_index < digit_pos_to_extract:
															# if the exponential term is an integer and we mod it by the denominator
															# before dividing, only the integer part of the sum will change;
															# the fractional part will not
															snake_case_						:List[Any]								=						pow(
															    16,     digit_pos_to_extract - 1 - sum_index,     _A							)
										else:
															snake_case_						:Optional[Any]								=						pow(16,     digit_pos_to_extract - 1 - sum_index							)
										total += exponential_term / denominator
					return total


if __name__ == "__main__":
				import doctest

				doctest.testmod()

