



'''simple docstring'''




class 						_UpperCamelCase  :


			'''simple docstring'''

			def __init__(							self					:			Optional[int]						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE	:		Optional[Any]   	=		[0]
					__SCREAMING_SNAKE_CASE	:		str   	=		0

			def UpperCamelCase__ (							self					:			Dict							,					lowerCAmelCase__					:			int						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE	:		str   	=		self.__heap[i]
					while i // 2 > 0:
							if self.__heap[i] > self.__heap[i // 2]:
									__SCREAMING_SNAKE_CASE	:		Dict   	=		self.__heap[i // 2]
									__SCREAMING_SNAKE_CASE	:		Any   	=		temporary
							i //= 2

			def UpperCamelCase__ (							self					:			Tuple							,					lowerCAmelCase__					:			int						):





					"""simple docstring"""






					self.__heap.append(_UpperCamelCase						)
					self.__size += 1
					self.__swap_up(self.__size						)

			def UpperCamelCase__ (							self					:			Tuple							,					lowerCAmelCase__					:			int						):





					"""simple docstring"""






					while self.__size >= 2 * i:
							if 2 * i + 1 > self.__size:
									__SCREAMING_SNAKE_CASE	:		List[str]   	=		2 * i
							else:
									if self.__heap[2 * i] > self.__heap[2 * i + 1]:
											__SCREAMING_SNAKE_CASE	:		Optional[int]   	=		2 * i
									else:
											__SCREAMING_SNAKE_CASE	:		Optional[int]   	=		2 * i + 1
							__SCREAMING_SNAKE_CASE	:		Optional[Any]   	=		self.__heap[i]
							if self.__heap[i] < self.__heap[bigger_child]:
									__SCREAMING_SNAKE_CASE	:		Union[str, Any]   	=		self.__heap[bigger_child]
									__SCREAMING_SNAKE_CASE	:		int   	=		temporary
							__SCREAMING_SNAKE_CASE	:		Dict   	=		bigger_child

			def UpperCamelCase__ (							self					:			Tuple						):





					"""simple docstring"""






					__SCREAMING_SNAKE_CASE	:		int   	=		self.__heap[1]
					__SCREAMING_SNAKE_CASE	:		str   	=		self.__heap[self.__size]
					self.__size -= 1
					self.__heap.pop()
					self.__swap_down(1						)
					return max_value

			@property
			def UpperCamelCase__ (							self					:			int						):





					"""simple docstring"""






					return self.__heap[1:]



			def __len__(							self					:			Optional[Any]						):





					"""simple docstring"""






					return self.__size


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						# create an instance of BinaryHeap
						UpperCamelCase__	:     Tuple		  =			BinaryHeap()
						binary_heap.insert(6)
						binary_heap.insert(10)
						binary_heap.insert(15)
						binary_heap.insert(12)
						# pop root(max-values because it is max heap)
						print(binary_heap.pop())  # 15
						print(binary_heap.pop())  # 12
						# get the list and size after operations
						print(binary_heap.get_list)
						print(len(binary_heap))




'''simple docstring'''




UpperCamelCase__	:     List[Any]    =			10_00


def     lowerCAmelCase_       (     _lowerCamelCase:       float ):
		return x * x


def     lowerCAmelCase_       (     _lowerCamelCase:       Any	,				_lowerCamelCase:       float	,				_lowerCamelCase:       float	,				_lowerCamelCase:       int = 4 ):
		assert callable(
		    _lowerCamelCase ), F"the function(object) passed should be callable your input : {function}"
		assert isinstance(_lowerCamelCase	,				(float, int) ), F"a should be float or integer your input : {a}"
		assert isinstance(function(_lowerCamelCase )	,				(float, int) ), (
		    "the function should return integer or float return type of your function, "
		    F"{type(_lowerCamelCase )}"
		)
		assert isinstance(_lowerCamelCase	,				(float, int) ), F"b should be float or integer your input : {b}"
		assert (
		    isinstance(_lowerCamelCase	,				_lowerCamelCase ) and precision > 0
		), F"precision should be positive integer your input : {precision}"

		# just applying the formula of simpson for approximate integration written in
		# mentioned article in first comment of this file and above this function

		__SCREAMING_SNAKE_CASE	:		List[Any]   	=		(b - a) / N_STEPS
		__SCREAMING_SNAKE_CASE	:		List[Any]   	=		function(_lowerCamelCase ) + function(_lowerCamelCase )

		for i in range(1	,				_lowerCamelCase ):
				__SCREAMING_SNAKE_CASE	:		Union[str, Any]   	=		a + h * i
				result += function(_lowerCamelCase ) * (4 if i % 2 else 2)

		result *= h / 3
		return round(_lowerCamelCase	,				_lowerCamelCase )


if __name__ == "__main__":
						import doctest

						doctest.testmod()