






"""simple docstring"""



class        a     :







    def __init__(			self							,		_lowerCamelCase							,		_lowerCamelCase       ):
      lowercase							    =       name
      lowercase							    =       val







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







    def __lt__(			self							,		_lowerCamelCase       ):
      return self.val < other.val


class        a     :







    def __init__(			self							,		_lowerCamelCase       ):
      lowercase							    =       {}
      lowercase							    =       {}
      lowercase							    =       self.build_heap(UpperCAmelCase__       )







    def __getitem__(			self							,		_lowerCamelCase       ):
      return self.get_value(UpperCAmelCase__       )







    def 			UpperCamelCase_      (			self							,		_lowerCamelCase       ):
      return (idx - 1) // 2







    def 			UpperCamelCase_      (			self							,		_lowerCamelCase       ):
      return idx * 2 + 1







    def 			UpperCamelCase_      (			self							,		_lowerCamelCase       ):
      return idx * 2 + 2







    def 			UpperCamelCase_      (			self							,		_lowerCamelCase       ):
      return self.heap_dict[key]







    def 			UpperCamelCase_      (			self							,		_lowerCamelCase       ):
      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 			UpperCamelCase_      (			self							,		_lowerCamelCase							,		_lowerCamelCase       ):

      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 			UpperCamelCase_      (			self							,		_lowerCamelCase       ):
      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 			UpperCamelCase_      (			self       ):
      return self.heap[0]







    def 			UpperCamelCase_      (			self       ):
      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 			UpperCamelCase_      (			self							,		_lowerCamelCase       ):
      self.heap.append(UpperCAmelCase__       )
      lowercase							    =       len(self.heap       ) - 1
      lowercase							    =       node.val
      self.sift_up(len(self.heap       ) - 1       )







    def 			UpperCamelCase_      (			self       ):
      return len(self.heap       ) == 0







    def 			UpperCamelCase_      (			self							,		_lowerCamelCase							,		_lowerCamelCase       ):
      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]       )


_UpperCamelCase		:  Optional[Any]						=		Node('R', -1)
_UpperCamelCase		:  int						=		Node('B', 6)
_UpperCamelCase		:  Dict						=		Node('A', 3)
_UpperCamelCase		:  Union[str, Any]						=		Node('X', 1)
_UpperCamelCase		:  Any						=		Node('E', 4)

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

# Generating Min-Heap from array
_UpperCamelCase		:  Dict						=		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, -1_7)

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

if __name__ == "__main__":
    import doctest

    doctest.testmod()








from __future__ import annotations

import typing
from collections.abc import Iterable

import numpy as np

_lowerCamelCase	:		str							       =   typing.Union[Iterable[float], Iterable[int], np.ndarray]  # noqa: UP007
_lowerCamelCase	:		Tuple							       =   typing.Union[np.floataa, int, float]  # noqa: UP007







def SCREAMING_SNAKE_CASE				(       lowercase_ ,				lowercase_						)   ->       VectorOut:



       """simple docstring"""

       return np.sqrt(np.sum((np.asarray(lowercase_						) - np.asarray(lowercase_						)) ** 2						)						)







def SCREAMING_SNAKE_CASE				(       lowercase_ ,				lowercase_						)   ->       VectorOut:



       """simple docstring"""

       return sum((va - va) ** 2 for va, va in zip(lowercase_ ,				lowercase_						)						) ** (1 / 2)


if __name__ == "__main__":







  def SCREAMING_SNAKE_CASE				(       )   ->       None:



         """simple docstring"""

         from timeit import timeit

         print('''Without Numpy'''						)
         print(
             timeit(
                 '''euclidean_distance_no_np([1, 2, 3], [4, 5, 6])''' ,				number=10_000 ,				globals=globals() ,				)						)
         print('''With Numpy'''						)
         print(
             timeit(
                 '''euclidean_distance([1, 2, 3], [4, 5, 6])''' ,				number=10_000 ,				globals=globals() ,				)						)
  benchmark()


