
"""simple docstring"""


class 					lowerCAmelCase_					:



						'''simple docstring'''


						def __init__(			self  :   Union[str, Any]	,A_  :   Union[str, Any]	,A_  :   List[Any]   )  -> Union[str, Any]:
							A     = name
							A     = val


						def __str__(			self  :   Dict   )  -> Tuple:
							return F'{self.__class__.__name__}({self.name}, {self.val})'




						def __lt__(			self  :   Union[str, Any]	,A_  :   List[str]   )  -> str:
							return self.val < other.val







class 					lowerCAmelCase_					:



						'''simple docstring'''


						def __init__(			self  :   Optional[int]	,A_  :   Union[str, Any]   )  -> List[str]:
							A     = {}
							A     = {}
							A     = self.build_heap(A_   )


						def __getitem__(			self  :   str	,A_  :   Dict   )  -> Tuple:
							return self.get_value(A_   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   int	,A_  :   Optional[int]   )  -> List[Any]:
							return (idx - 1) // 2


						def     _SCREAMING_SNAKE_CASE   (			self  :   int	,A_  :   Tuple   )  -> Union[str, Any]:
							return idx * 2 + 1


						def     _SCREAMING_SNAKE_CASE   (			self  :   int	,A_  :   Any   )  -> Tuple:
							return idx * 2 + 2


						def     _SCREAMING_SNAKE_CASE   (			self  :   int	,A_  :   Tuple   )  -> Any:
							return self.heap_dict[key]


						def     _SCREAMING_SNAKE_CASE   (			self  :   Tuple	,A_  :   Any   )  -> int:
							A     = len(A_   ) - 1
							A     = self.get_parent_idx(A_   )

							for idx, i in enumerate(A_   ):
								A     = idx
								A     = i.val

							for i in range(A_	,-1	,-1   ):
								self.sift_down(A_	,A_   )
							return array


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[str]	,A_  :   Union[str, Any]	,A_  :   Tuple   )  -> int:
							while True:
								A     = self.get_left_child_idx(A_   )  # noqa: E741
								A     = self.get_right_child_idx(A_   )

								A     = idx
								if l < len(A_   ) and array[l] < array[idx]:
									A     = l
								if r < len(A_   ) and array[r] < array[smallest]:
									A     = r

								if smallest != idx:
									A ,   A     = array[smallest], array[idx]
									(
									    (
									    A
									) ,   (
									    A
									) ,   
									)     = (
									    self.idx_of_element[array[smallest]],
									    self.idx_of_element[array[idx]],
									)
									A     = smallest
								else:
									break


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[Any]	,A_  :   Any   )  -> Tuple:
							A     = self.get_parent_idx(A_   )
							while p >= 0 and self.heap[p] > self.heap[idx]:
								A ,   A     = self.heap[idx], self.heap[p]
								A ,   A     = (
								    self.idx_of_element[self.heap[idx]],
								    self.idx_of_element[self.heap[p]],
								)
								A     = p
								A     = self.get_parent_idx(A_   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Optional[Any]   )  -> Tuple:
							return self.heap[0]


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[str]   )  -> int:
							A ,   A     = self.heap[-1], self.heap[0]
							A ,   A     = (
							    self.idx_of_element[self.heap[-1]],
							    self.idx_of_element[self.heap[0]],
							)

							A     = self.heap.pop()
							del self.idx_of_element[x]
							self.sift_down(0	,self.heap   )
							return x


						def     _SCREAMING_SNAKE_CASE   (			self  :   List[Any]	,A_  :   Optional[int]   )  -> Optional[int]:
							self.heap.append(A_   )
							A     = len(self.heap   ) - 1
							A     = node.val
							self.sift_up(len(self.heap   ) - 1   )


						def     _SCREAMING_SNAKE_CASE   (			self  :   Union[str, Any]   )  -> List[str]:
							return len(self.heap   ) == 0




						def     _SCREAMING_SNAKE_CASE   (			self  :   int	,A_  :   Union[str, Any]	,A_  :   Optional[int]   )  -> List[Any]:
							assert (
							    self.heap[self.idx_of_element[node]].val > new_value
							), "newValue must be less that current value"
							A     = new_value
							A     = new_value
							self.sift_up(self.idx_of_element[node]   )

_lowercase				 =					Node('''R''', -1)
_lowercase				 =					Node('''B''', 6)
_lowercase				 =					Node('''A''', 3)
_lowercase				 =					Node('''X''', 1)
_lowercase				 =					Node('''E''', 4)

# Use one of these two ways to generate Min-Heap

# Generating Min-Heap from array
_lowercase				 =					MinHeap([r, b, a, x, e])

# Generating Min-Heap by Insert method
# myMinHeap.insert(a)
# myMinHeap.insert(b)
# myMinHeap.insert(x)
# myMinHeap.insert(r)
# myMinHeap.insert(e)

# Before
print('''Min Heap - before decrease key''')
for i in my_min_heap.heap:
		print(i)

print('''Min Heap - After decrease key of node [B -> -17]''')
my_min_heap.decrease_key(b, -17)

# After
for i in my_min_heap.heap:
		print(i)

if __name__ == "__main__":
		import doctest

		doctest.testmod()



'''simple docstring'''
from math import factorial

UpperCAmelCase_			:  List[str]										=   {str(d): factorial(d) for d in range(1_0)}


def       _lowercase							(					UpperCamelCase__							:       int      ):
 return sum(DIGIT_FACTORIAL[d] for d in str(UpperCamelCase__      )      )


def       _lowercase							(					):
 __A	:		Union[str, Any]	  =      7 * factorial(9      ) + 1
 return sum(i for i in range(3,					UpperCamelCase__      ) if sum_of_digit_factorial(UpperCamelCase__      ) == i      )


if __name__ == "__main__":
 print(f'''{solution() = }''')






