






class 		SCREAMING_SNAKE_CASE__	:

  '''simple docstring'''







  def __init__(      self		:			Dict       ,				lowerCamelCase		:			Optional[int]       ,				lowerCamelCase		:			Dict							)						->	List[str]:


         """simple docstring"""
         _UpperCAmelCase							=    name
         _UpperCAmelCase							=    val


  def __str__(      self		:			Tuple							)						->	Optional[int]:


         """simple docstring"""
         return f"""{self.__class__.__name__}({self.name}, {self.val})"""





  def __lt__(      self		:			Optional[int]       ,				lowerCamelCase		:			Union[str, Any]							)						->	Any:


         """simple docstring"""
         return self.val < other.val



class 		SCREAMING_SNAKE_CASE__	:

  '''simple docstring'''







  def __init__(      self		:			int       ,				lowerCamelCase		:			Optional[int]							)						->	int:


         """simple docstring"""
         _UpperCAmelCase							=    {}
         _UpperCAmelCase							=    {}
         _UpperCAmelCase							=    self.build_heap(lowerCamelCase							)


  def __getitem__(      self		:			Any       ,				lowerCamelCase		:			Union[str, Any]							)						->	Any:


         """simple docstring"""
         return self.get_value(lowerCamelCase							)


  def  lowerCamelCase       (      self		:			int       ,				lowerCamelCase		:			Optional[Any]							)						->	Dict:


         """simple docstring"""
         return (idx - 1) // 2


  def  lowerCamelCase       (      self		:			int       ,				lowerCamelCase		:			Optional[int]							)						->	int:


         """simple docstring"""
         return idx * 2 + 1


  def  lowerCamelCase       (      self		:			int       ,				lowerCamelCase		:			Optional[Any]							)						->	Optional[int]:


         """simple docstring"""
         return idx * 2 + 2


  def  lowerCamelCase       (      self		:			Dict       ,				lowerCamelCase		:			Union[str, Any]							)						->	List[Any]:


         """simple docstring"""
         return self.heap_dict[key]


  def  lowerCamelCase       (      self		:			Any       ,				lowerCamelCase		:			Any							)						->	Optional[Any]:


         """simple docstring"""
         _UpperCAmelCase							=    len(lowerCamelCase							) - 1
         _UpperCAmelCase							=    self.get_parent_idx(lowerCamelCase							)

         for idx, i in enumerate(lowerCamelCase							):
                _UpperCAmelCase							=    idx
                _UpperCAmelCase							=    i.val

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


  def  lowerCamelCase       (      self		:			str       ,				lowerCamelCase		:			List[str]       ,				lowerCamelCase		:			int							)						->	List[str]:


         """simple docstring"""
         while True:
                _UpperCAmelCase							=    self.get_left_child_idx(lowerCamelCase							)  # noqa: E741
                _UpperCAmelCase							=    self.get_right_child_idx(lowerCamelCase							)

                _UpperCAmelCase							=    idx
                if l < len(lowerCamelCase							) and array[l] < array[idx]:
                       _UpperCAmelCase							=    l
                if r < len(lowerCamelCase							) and array[r] < array[smallest]:
                       _UpperCAmelCase							=    r

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


  def  lowerCamelCase       (      self		:			Tuple       ,				lowerCamelCase		:			Optional[int]							)						->	Any:


         """simple docstring"""
         _UpperCAmelCase							=    self.get_parent_idx(lowerCamelCase							)
         while p >= 0 and self.heap[p] > self.heap[idx]:
                _UpperCAmelCase	,			_UpperCAmelCase							=    self.heap[idx], self.heap[p]
                _UpperCAmelCase	,			_UpperCAmelCase							=    (
                    self.idx_of_element[self.heap[idx]],
                    self.idx_of_element[self.heap[p]],
                )
                _UpperCAmelCase							=    p
                _UpperCAmelCase							=    self.get_parent_idx(lowerCamelCase							)


  def  lowerCamelCase       (      self		:			List[Any]							)						->	List[Any]:


         """simple docstring"""
         return self.heap[0]


  def  lowerCamelCase       (      self		:			List[Any]							)						->	List[str]:


         """simple docstring"""
         _UpperCAmelCase	,			_UpperCAmelCase							=    self.heap[-1], self.heap[0]
         _UpperCAmelCase	,			_UpperCAmelCase							=    (
             self.idx_of_element[self.heap[-1]],
             self.idx_of_element[self.heap[0]],
         )

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


  def  lowerCamelCase       (      self		:			Union[str, Any]       ,				lowerCamelCase		:			List[str]							)						->	List[Any]:


         """simple docstring"""
         self.heap.append(lowerCamelCase							)
         _UpperCAmelCase							=    len(self.heap							) - 1
         _UpperCAmelCase							=    node.val
         self.sift_up(len(self.heap							) - 1							)


  def  lowerCamelCase       (      self		:			List[Any]							)						->	int:


         """simple docstring"""
         return len(self.heap							) == 0





  def  lowerCamelCase       (      self		:			Any       ,				lowerCamelCase		:			Union[str, Any]       ,				lowerCamelCase		:			List[Any]							)						->	List[str]:


         """simple docstring"""
         assert (
             self.heap[self.idx_of_element[node]].val > new_value
         ), "newValue must be less that current value"
         _UpperCAmelCase							=    new_value
         _UpperCAmelCase							=    new_value
         self.sift_up(self.idx_of_element[node]							)



__a:     str   					=					Node('''R''', -1)
__a:     List[Any]   					=					Node('''B''', 6)
__a:     List[str]   					=					Node('''A''', 3)
__a:     Optional[Any]   					=					Node('''X''', 1)
__a:     Tuple   					=					Node('''E''', 4)

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

# Generating Min-Heap from array
__a:     List[Any]   					=					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'''




import qiskit


def    lowerCamelCase__		(    SCREAMING_SNAKE_CASE   : int							, SCREAMING_SNAKE_CASE   : int    ):
  UpperCAmelCase    				=						qiskit.Aer.get_backend('aer_simulator'    )

  # Create a Quantum Circuit acting on the q register
  UpperCAmelCase    				=						qiskit.QuantumCircuit(SCREAMING_SNAKE_CASE							, SCREAMING_SNAKE_CASE    )

  # Map the quantum measurement to the classical bits
  circuit.measure([0]							, [0]    )

  # Execute the circuit on the simulator
  UpperCAmelCase    				=						qiskit.execute(SCREAMING_SNAKE_CASE							, SCREAMING_SNAKE_CASE							, shots=1000    )

  # Return the histogram data of the results of the experiment.
  return job.result().get_counts(SCREAMING_SNAKE_CASE    )


if __name__ == "__main__":
  print(F'''Total count for various states are: {single_qubit_measure(1, 1)}''')


