
'''simple docstring'''







lowerCAmelCase_      =   {
    '0': 1,
    '1': 1,
    '2': 2,
    '3': 6,
    '4': 2_4,
    '5': 1_2_0,
    '6': 7_2_0,
    '7': 5_0_4_0,
    '8': 4_0_3_2_0,
    '9': 3_6_2_8_8_0,
}

lowerCAmelCase_      =   {1_4_5: 1_4_5}

lowerCAmelCase_      =   {
    1_4_5: 0,
    1_6_9: 3,
    3_6_3_0_1: 3,
    1_4_5_4: 3,
    8_7_1: 2,
    4_5_3_6_1: 2,
    8_7_2: 2,
}







def   lowerCAmelCase(  a__    :  Optional[int]      ):







       '''simple docstring'''






       if n in CACHE_SUM_DIGIT_FACTORIALS:
              return CACHE_SUM_DIGIT_FACTORIALS[n]
       lowerCamelCase__				   =      sum(DIGIT_FACTORIALS[let] for let in str(__lowercase      )      )
       lowerCamelCase__				   =      ret
       return ret







def   lowerCAmelCase(  a__    :  int      , a__    :  Optional[Any] = None      ):







       '''simple docstring'''






       lowerCamelCase__				   =      previous or set()
       if n in CHAIN_LENGTH_CACHE:
              return CHAIN_LENGTH_CACHE[n]
       lowerCamelCase__				   =      sum_digit_factorials(__lowercase      )
       if next_number in previous:
              lowerCamelCase__				   =      0
              return 0
       else:
              previous.add(__lowercase      )
              lowerCamelCase__				   =      1 + chain_length(__lowercase      , __lowercase      )
              lowerCamelCase__				   =      ret
              return ret







def   lowerCAmelCase(  a__    :  Optional[Any] = 60      , a__    :  List[Any] = 100_0000      ):







       '''simple docstring'''






       return sum(1 for i in range(1      , __lowercase      ) if chain_length(__lowercase      ) == num_terms      )


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






class 				lowerCAmelCase__	:







					def __init__(							self   :  Union[str, Any]):
											A__						:				Optional[int]         =			[0]
											A__						:				Any         =			0







					def 			_lowercase      (							self   :  Optional[int]      ,		_A   :  int):
											A__						:				Optional[Any]         =			self.__heap[i]
											while i // 2 > 0:
																	if self.__heap[i] > self.__heap[i // 2]:
																							A__						:				Union[str, Any]         =			self.__heap[i // 2]
																							A__						:				List[str]         =			temporary
																	i //= 2







					def 			_lowercase      (							self   :  Union[str, Any]      ,		_A   :  int):
											self.__heap.append(_A)
											self.__size += 1
											self.__swap_up(self.__size)







					def 			_lowercase      (							self   :  Any      ,		_A   :  int):
											while self.__size >= 2 * i:
																	if 2 * i + 1 > self.__size:
																							A__						:				str         =			2 * i
																	else:
																							if self.__heap[2 * i] > self.__heap[2 * i + 1]:
																													A__						:				Tuple         =			2 * i
																							else:
																													A__						:				Tuple         =			2 * i + 1
																	A__						:				Any         =			self.__heap[i]
																	if self.__heap[i] < self.__heap[bigger_child]:
																							A__						:				List[str]         =			self.__heap[bigger_child]
																							A__						:				Tuple         =			temporary
																	A__						:				Tuple         =			bigger_child







					def 			_lowercase      (							self   :  int):
											A__						:				str         =			self.__heap[1]
											A__						:				Tuple         =			self.__heap[self.__size]
											self.__size -= 1
											self.__heap.pop()
											self.__swap_down(1)
											return max_value







					@property
					def 			_lowercase      (							self   :  Any):
											return self.__heap[1:]







					def __len__(							self   :  Union[str, Any]):
											return self.__size


if __name__ == "__main__":
		import doctest

		doctest.testmod()
		# create an instance of BinaryHeap
		snake_case     :    List[Any]						=    BinaryHeap()
		binary_heap.insert(6)
		binary_heap.insert(1_0)
		binary_heap.insert(1_5)
		binary_heap.insert(1_2)
		# 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))