



'''simple docstring'''





class 					snake_case			:



       def __init__(					self  ,UpperCAmelCase_  ,UpperCAmelCase_   )	->				List[str]:
           lowercase__									=    name
           lowercase__									=    val



       def __str__(					self   )	->				List[str]:
           return F'''{self.__class__.__name__}({self.name}, {self.val})'''







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





class 					snake_case			:



       def __init__(					self  ,UpperCAmelCase_   )	->				Optional[Any]:
           lowercase__									=    {}
           lowercase__									=    {}
           lowercase__									=    self.build_heap(UpperCAmelCase_   )



       def __getitem__(					self  ,UpperCAmelCase_   )	->				List[str]:
           return self.get_value(UpperCAmelCase_   )



       def 				_a   (					self  ,UpperCAmelCase_   )	->				Optional[int]:
           return (idx - 1) // 2



       def 				_a   (					self  ,UpperCAmelCase_   )	->				List[Any]:
           return idx * 2 + 1



       def 				_a   (					self  ,UpperCAmelCase_   )	->				Dict:
           return idx * 2 + 2



       def 				_a   (					self  ,UpperCAmelCase_   )	->				Tuple:
           return self.heap_dict[key]



       def 				_a   (					self  ,UpperCAmelCase_   )	->				Union[str, Any]:
           lowercase__									=    len(UpperCAmelCase_   ) - 1
           lowercase__									=    self.get_parent_idx(UpperCAmelCase_   )

           for idx, i in enumerate(UpperCAmelCase_   ):
               lowercase__									=    idx
               lowercase__									=    i.val

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



       def 				_a   (					self  ,UpperCAmelCase_  ,UpperCAmelCase_   )	->				Tuple:
           while True:
               lowercase__									=    self.get_left_child_idx(UpperCAmelCase_   )  # noqa: E741
               lowercase__									=    self.get_right_child_idx(UpperCAmelCase_   )

               lowercase__									=    idx
               if l < len(UpperCAmelCase_   ) and array[l] < array[idx]:
                   lowercase__									=    l
               if r < len(UpperCAmelCase_   ) and array[r] < array[smallest]:
                   lowercase__									=    r

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



       def 				_a   (					self  ,UpperCAmelCase_   )	->				Tuple:
           lowercase__									=    self.get_parent_idx(UpperCAmelCase_   )
           while p >= 0 and self.heap[p] > self.heap[idx]:
               lowercase__							,							lowercase__									=    self.heap[idx], self.heap[p]
               lowercase__							,							lowercase__									=    (
                   self.idx_of_element[self.heap[idx]],
                   self.idx_of_element[self.heap[p]],
               )
               lowercase__									=    p
               lowercase__									=    self.get_parent_idx(UpperCAmelCase_   )



       def 				_a   (					self   )	->				int:
           return self.heap[0]



       def 				_a   (					self   )	->				List[str]:
           lowercase__							,							lowercase__									=    self.heap[-1], self.heap[0]
           lowercase__							,							lowercase__									=    (
               self.idx_of_element[self.heap[-1]],
               self.idx_of_element[self.heap[0]],
           )

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



       def 				_a   (					self  ,UpperCAmelCase_   )	->				Optional[int]:
           self.heap.append(UpperCAmelCase_   )
           lowercase__									=    len(self.heap   ) - 1
           lowercase__									=    node.val
           self.sift_up(len(self.heap   ) - 1   )



       def 				_a   (					self   )	->				Dict:
           return len(self.heap   ) == 0







       def 				_a   (					self  ,UpperCAmelCase_  ,UpperCAmelCase_   )	->				str:
           assert (
               self.heap[self.idx_of_element[node]].val > new_value
           ), "newValue must be less that current value"
           lowercase__									=    new_value
           lowercase__									=    new_value
           self.sift_up(self.idx_of_element[node]   )





SCREAMING_SNAKE_CASE__          =  Node("R", -1)
SCREAMING_SNAKE_CASE__          =  Node("B", 6)
SCREAMING_SNAKE_CASE__          =  Node("A", 3)
SCREAMING_SNAKE_CASE__          =  Node("X", 1)
SCREAMING_SNAKE_CASE__          =  Node("E", 4)

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

# Generating Min-Heap from array
SCREAMING_SNAKE_CASE__          =  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'''





def 							lowerCamelCase	(					_snake_case	:    int  ,_snake_case	:    int							):





    '''simple docstring'''


    return "\n".join(
        f'''{number} * {i} = {number * i}''' for i in range(1  ,number_of_terms + 1							)							)


if __name__ == "__main__":
 print(multiplication_table(number=5, number_of_terms=10))




