




'''simple docstring'''


from collections.abc import Callable

class     A					:







							def __init__(						self :						List[Any]							,    lowerCAmelCase_ :						Callable | None = None      )    ->							None:


														"""simple docstring"""


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







							def      __lowerCAmelCase    (						self :						Tuple							,    lowerCAmelCase_ :						int      )    ->							int | None:


														"""simple docstring"""


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







							def      __lowerCAmelCase    (						self :						Tuple							,    lowerCAmelCase_ :						int      )    ->							int | None:


														"""simple docstring"""


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







							def      __lowerCAmelCase    (						self :						List[str]							,    lowerCAmelCase_ :						int      )    ->							int | None:


														"""simple docstring"""


														_a			  =       int(2 * i + 2      )
														return right if 0 < right < self.size else None







							def      __lowerCAmelCase    (						self :						List[str]							,    lowerCAmelCase_ :						int							,    lowerCAmelCase_ :						int      )    ->							None:


														"""simple docstring"""


														_a  ,							_a			  =       (
														    self.pos_map[self.arr[j][0]],
														    self.pos_map[self.arr[i][0]],
														)
														# Then swap the items in the list.
														_a  ,							_a			  =       self.arr[j], self.arr[i]







							def      __lowerCAmelCase    (						self :						str							,    lowerCAmelCase_ :						int							,    lowerCAmelCase_ :						int      )    ->							bool:


														"""simple docstring"""


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







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


														"""simple docstring"""


														_a			  =       self._left(lowerCAmelCase_      )
														_a			  =       self._right(lowerCAmelCase_      )
														_a			  =       i

														if left is not None and not self._cmp(lowerCAmelCase_							,    lowerCAmelCase_      ):
																					_a			  =       left
														if right is not None and not self._cmp(lowerCAmelCase_							,    lowerCAmelCase_      ):
																					_a			  =       right

														return valid_parent







							def      __lowerCAmelCase    (						self :						str							,    lowerCAmelCase_ :						int      )    ->							None:


														"""simple docstring"""


														_a			  =       self._parent(lowerCAmelCase_      )
														while parent is not None and not self._cmp(lowerCAmelCase_							,    lowerCAmelCase_      ):
																					self._swap(lowerCAmelCase_							,    lowerCAmelCase_      )
																					_a  ,							_a			  =       parent, self._parent(lowerCAmelCase_      )







							def      __lowerCAmelCase    (						self :						Union[str, Any]							,    lowerCAmelCase_ :						int      )    ->							None:


														"""simple docstring"""


														_a			  =       self._get_valid_parent(lowerCAmelCase_      )
														while valid_parent != index:
																					self._swap(lowerCAmelCase_							,    lowerCAmelCase_      )
																					_a  ,							_a			  =       valid_parent, self._get_valid_parent(lowerCAmelCase_      )







							def      __lowerCAmelCase    (						self :						List[str]							,    lowerCAmelCase_ :						int							,    lowerCAmelCase_ :						int      )    ->							None:


														"""simple docstring"""


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







							def      __lowerCAmelCase    (						self :						Any							,    lowerCAmelCase_ :						int      )    ->							None:


														"""simple docstring"""


														if item not in self.pos_map:
																					return
														_a			  =       self.pos_map[item]
														del self.pos_map[item]
														_a			  =       self.arr[self.size - 1]
														_a			  =       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(lowerCAmelCase_      )
																					self._heapify_down(lowerCAmelCase_      )







							def      __lowerCAmelCase    (						self :						Any							,    lowerCAmelCase_ :						int							,    lowerCAmelCase_ :						int      )    ->							None:


														"""simple docstring"""


														_a			  =       len(self.arr      )
														if arr_len == self.size:
																					self.arr.append([item, self.key(lowerCAmelCase_      )]      )
														else:
																					_a			  =       [item, self.key(lowerCAmelCase_      )]
														_a			  =       self.size
														self.size += 1
														self._heapify_up(self.size - 1      )







							def      __lowerCAmelCase    (						self :						int      )    ->							tuple | None:


														"""simple docstring"""


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







							def      __lowerCAmelCase    (						self :						Union[str, Any]      )    ->							tuple | None:


														"""simple docstring"""


														_a			  =       self.get_top()
														if top_item_tuple:
																					self.delete_item(top_item_tuple[0]      )
														return top_item_tuple



def 	snake_case_					():





							'''simple docstring'''




if __name__ == "__main__":
				import doctest

				doctest.testmod()







'''simple docstring'''


import math
import unittest
def 	snake_case_					(UpperCamelCase :						int   ):





							'''simple docstring'''


							assert isinstance(UpperCamelCase				,		UpperCamelCase   ) and (
							    number >= 0
							), "'number' must been an int and positive"

							if 1 < number < 4:
														# 2 and 3 are primes
														return True
							elif number < 2 or number % 2 == 0 or number % 3 == 0:
														# Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
														return False

							# All primes number are in format of 6k +/- 1
							for i in range(5				,		int(math.sqrt(UpperCamelCase   ) + 1   )				,		6   ):
														if number % i == 0 or number % (i + 2) == 0:
																					return False
							return True

class     A					(	unittest.TestCase					):







							def      __lowerCAmelCase    (						self :						Union[str, Any]      )    ->							Optional[Any]:


														"""simple docstring"""


														self.assertTrue(is_prime(2      )      )
														self.assertTrue(is_prime(3      )      )
														self.assertTrue(is_prime(5      )      )
														self.assertTrue(is_prime(7      )      )
														self.assertTrue(is_prime(11      )      )
														self.assertTrue(is_prime(13      )      )
														self.assertTrue(is_prime(17      )      )
														self.assertTrue(is_prime(19      )      )
														self.assertTrue(is_prime(23      )      )
														self.assertTrue(is_prime(29      )      )







							def      __lowerCAmelCase    (						self :						Any      )    ->							Dict:


														"""simple docstring"""


														with self.assertRaises(lowerCAmelCase_      ):
																					is_prime(-19      )
														self.assertFalse(
														    is_prime(0      )							,    '''Zero doesn\'t have any positive factors, primes must have exactly two.'''							,    )
														self.assertFalse(
														    is_prime(1      )							,    '''One only has 1 positive factor, primes must have exactly two.'''							,    )
														self.assertFalse(is_prime(2 * 2      )      )
														self.assertFalse(is_prime(2 * 3      )      )
														self.assertFalse(is_prime(3 * 3      )      )
														self.assertFalse(is_prime(3 * 5      )      )
														self.assertFalse(is_prime(3 * 5 * 7      )      )


if __name__ == "__main__":
				unittest.main()

