
"""simple docstring"""







from collections.abc import Callable



class 		UpperCAmelCase_						:
 """simple docstring"""




 def __init__(			self							:			Dict  , a_							:			Callable | None = None			)->       None:



      """simple docstring"""

      UpperCAmelCase_    :     list            =	[]
      # Stores indexes of each item for supporting updates and deletion.
      UpperCAmelCase_    :     dict            =	{}
      # Stores current size of heap.
      UpperCAmelCase_    :     Optional[int]            =	0
      # Stores function used to evaluate the score of an item on which basis ordering
      # will be done.
      UpperCAmelCase_    :     Dict            =	key or (lambda a_			: x)




 def 	a   (			self							:			Any  , a_							:			int			)->       int | None:



      """simple docstring"""

      return int((i - 1) / 2			) if i > 0 else None




 def 	a   (			self							:			Optional[int]  , a_							:			int			)->       int | None:



      """simple docstring"""

      UpperCAmelCase_    :     str            =	int(2 * i + 1			)
      return left if 0 < left < self.size else None




 def 	a   (			self							:			Tuple  , a_							:			int			)->       int | None:



      """simple docstring"""

      UpperCAmelCase_    :     Optional[Any]            =	int(2 * i + 2			)
      return right if 0 < right < self.size else None




 def 	a   (			self							:			List[str]  , a_							:			int  , a_							:			int			)->       None:



      """simple docstring"""

      UpperCAmelCase_       ,UpperCAmelCase_    :     Optional[Any]            =	(
          self.pos_map[self.arr[j][0]],
          self.pos_map[self.arr[i][0]],
      )
      # Then swap the items in the list.
      UpperCAmelCase_       ,UpperCAmelCase_    :     Tuple            =	self.arr[j], self.arr[i]




 def 	a   (			self							:			Union[str, Any]  , a_							:			int  , a_							:			int			)->       bool:



      """simple docstring"""

      return self.arr[i][1] < self.arr[j][1]




 def 	a   (			self							:			int  , a_							:			int			)->       int:



      """simple docstring"""

      UpperCAmelCase_    :     Optional[int]            =	self._left(a_			)
      UpperCAmelCase_    :     str            =	self._right(a_			)
      UpperCAmelCase_    :     Optional[Any]            =	i

      if left is not None and not self._cmp(a_  , a_			):
           UpperCAmelCase_    :     List[Any]            =	left
      if right is not None and not self._cmp(a_  , a_			):
           UpperCAmelCase_    :     Optional[int]            =	right

      return valid_parent




 def 	a   (			self							:			Union[str, Any]  , a_							:			int			)->       None:



      """simple docstring"""

      UpperCAmelCase_    :     Tuple            =	self._parent(a_			)
      while parent is not None and not self._cmp(a_  , a_			):
           self._swap(a_  , a_			)
           UpperCAmelCase_       ,UpperCAmelCase_    :     Tuple            =	parent, self._parent(a_			)




 def 	a   (			self							:			Any  , a_							:			int			)->       None:



      """simple docstring"""

      UpperCAmelCase_    :     Dict            =	self._get_valid_parent(a_			)
      while valid_parent != index:
           self._swap(a_  , a_			)
           UpperCAmelCase_       ,UpperCAmelCase_    :     Any            =	valid_parent, self._get_valid_parent(a_			)




 def 	a   (			self							:			Tuple  , a_							:			int  , a_							:			int			)->       None:



      """simple docstring"""

      if item not in self.pos_map:
           return
      UpperCAmelCase_    :     str            =	self.pos_map[item]
      UpperCAmelCase_    :     Union[str, Any]            =	[item, self.key(a_			)]
      # Make sure heap is right in both up and down direction.
      # Ideally only one of them will make any change.
      self._heapify_up(a_			)
      self._heapify_down(a_			)




 def 	a   (			self							:			List[Any]  , a_							:			int			)->       None:



      """simple docstring"""

      if item not in self.pos_map:
           return
      UpperCAmelCase_    :     Dict            =	self.pos_map[item]
      del self.pos_map[item]
      UpperCAmelCase_    :     List[str]            =	self.arr[self.size - 1]
      UpperCAmelCase_    :     List[Any]            =	index
      self.size -= 1
      # Make sure heap is right in both up and down direction. Ideally only one
      # of them will make any change- so no performance loss in calling both.
      if self.size > index:
           self._heapify_up(a_			)
           self._heapify_down(a_			)




 def 	a   (			self							:			str  , a_							:			int  , a_							:			int			)->       None:



      """simple docstring"""

      UpperCAmelCase_    :     Dict            =	len(self.arr			)
      if arr_len == self.size:
           self.arr.append([item, self.key(a_			)]			)
      else:
           UpperCAmelCase_    :     int            =	[item, self.key(a_			)]
      UpperCAmelCase_    :     List[Any]            =	self.size
      self.size += 1
      self._heapify_up(self.size - 1			)




 def 	a   (			self							:			Optional[Any]			)->       tuple | None:



      """simple docstring"""

      return self.arr[0] if self.size else None






 def 	a   (			self							:			Dict			)->       tuple | None:



      """simple docstring"""

      UpperCAmelCase_    :     List[str]            =	self.get_top()
      if top_item_tuple:
           self.delete_item(top_item_tuple[0]			)
      return top_item_tuple




def       A_      (       )  ->				None:


     """simple docstring"""









if __name__ == "__main__":
       import doctest

       doctest.testmod()



"""simple docstring"""







from string import ascii_lowercase, ascii_uppercase




def       A_      (       lowercase   )  ->				str:


     """simple docstring"""







     if not sentence:
          return ""
     UpperCAmelCase_    :     Any            =	dict(zip(lowercase    ,			lowercase   )   )
     return lower_to_upper.get(sentence[0]    ,			sentence[0]   ) + sentence[1:]


if __name__ == "__main__":
       from doctest import testmod

       testmod()

