'''simple docstring'''




class 	__UpperCAmelCase				:





       '''simple docstring'''



       def __init__(      self )		->     None:
           # numbermap keys are the number and its values are lists of indexes sorted
           # in ascending order
           A_     =   {}
           # indexmap keys are an index and it's values are the number at that index
           A_     =   {}

       def 					__A       (      self    ,     _SCREAMING_SNAKE_CASE    ,     _SCREAMING_SNAKE_CASE )		->     list[int]:
           if isinstance(_SCREAMING_SNAKE_CASE    ,     (range, str) ):
               A_     =   list(_SCREAMING_SNAKE_CASE )
           elif not isinstance(_SCREAMING_SNAKE_CASE    ,     _SCREAMING_SNAKE_CASE ):
               raise TypeError(
                   '''binary_search_delete() only accepts either a list, range or str''' )

           A_     =   0
           A_     =   len(_SCREAMING_SNAKE_CASE ) - 1

           while low <= high:
               A_     =   (low + high) // 2
               if array[mid] == item:
                   array.pop(_SCREAMING_SNAKE_CASE )
                   return array
               elif array[mid] < item:
                   A_     =   mid + 1
               else:
                   A_     =   mid - 1
           raise ValueError(
               '''Either the item is not in the array or the array was unsorted''' )

       def 					__A       (      self    ,     _SCREAMING_SNAKE_CASE    ,     _SCREAMING_SNAKE_CASE )		->     list[int]:
           if isinstance(_SCREAMING_SNAKE_CASE    ,     (range, str) ):
               A_     =   list(_SCREAMING_SNAKE_CASE )
           elif not isinstance(_SCREAMING_SNAKE_CASE    ,     _SCREAMING_SNAKE_CASE ):
               raise TypeError(
                   '''binary_search_insert() only accepts either a list, range or str''' )

           A_     =   0
           A_     =   len(_SCREAMING_SNAKE_CASE ) - 1

           while low <= high:
               A_     =   (low + high) // 2
               if array[mid] == index:
                   # If the item already exists in the array,
                   # insert it after the existing item
                   array.insert(mid + 1    ,     _SCREAMING_SNAKE_CASE )
                   return array
               elif array[mid] < index:
                   A_     =   mid + 1
               else:
                   A_     =   mid - 1

        # If the item doesn't exist in the array, insert it at the appropriate position
           array.insert(_SCREAMING_SNAKE_CASE    ,     _SCREAMING_SNAKE_CASE )
           return array

       def 					__A       (      self    ,     _SCREAMING_SNAKE_CASE    ,     _SCREAMING_SNAKE_CASE )		->     None:
           # Remove previous index
           if index in self.indexmap:
               A_     =   self.indexmap[index]
               if len(self.numbermap[n] ) == 1:
                   del self.numbermap[n]
               else:
                   A_     =   self.binary_search_delete(self.numbermap[n]    ,     _SCREAMING_SNAKE_CASE )

        # Set new index
           A_     =   number

           # Number not seen before or empty so insert number value
           if number not in self.numbermap:
               A_     =   [index]

           # Here we need to perform a binary search insertion in order to insert
           # The item in the correct place
           else:
               A_     =   self.binary_search_insert(
                   self.numbermap[number]    ,     _SCREAMING_SNAKE_CASE )

       def 					__A       (      self    ,     _SCREAMING_SNAKE_CASE )		->     int:
           return self.numbermap.get(_SCREAMING_SNAKE_CASE    ,     [-1] )[0]


if __name__ == "__main__":
  import doctest

  doctest.testmod()












def  lowerCAmelCase  (	UpperCAmelCase       )  ->int:






					"""simple docstring"""






					return n * (2 * n - 1)







def  lowerCAmelCase  (	UpperCAmelCase       )  ->bool:






					"""simple docstring"""






					__magic_name__					:							Any		   =							(1 + 24 * n) ** 0.5
					return ((1 + root) / 6) % 1 == 0







def  lowerCAmelCase  (	UpperCAmelCase = 144       )  ->int:






					"""simple docstring"""






					__magic_name__					:							Optional[int]		   =							start
					__magic_name__					:							int		   =							hexagonal_num(UpperCAmelCase       )
					while not is_pentagonal(UpperCAmelCase       ):
										n += 1
										__magic_name__					:							Optional[int]		   =							hexagonal_num(UpperCAmelCase       )
					return num


if __name__ == "__main__":
				print(f"{solution()} = ")



