
from collections.abc import Callable

class __snake_case		:
    def __init__(  self		,snake_case = None      ):



           '''simple docstring'''







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



           '''simple docstring'''







           return int((i - 1) / 2      ) if i > 0 else None
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case      ):



           '''simple docstring'''







           lowercase							:     Union[str, Any]       	=      int(2 * i + 1      )
           return left if 0 < left < self.size else None
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case      ):



           '''simple docstring'''







           lowercase							:     Union[str, Any]       	=      int(2 * i + 2      )
           return right if 0 < right < self.size else None
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case		,snake_case      ):



           '''simple docstring'''







           lowercase							:     str       	=      (
               self.pos_map[self.arr[j][0]],
               self.pos_map[self.arr[i][0]],
           )
           # Then swap the items in the list.
           lowercase							:     List[str]       	=      self.arr[j], self.arr[i]
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case		,snake_case      ):



           '''simple docstring'''







           return self.arr[i][1] < self.arr[j][1]
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case      ):



           '''simple docstring'''







           lowercase							:     Any       	=      self._left(lowerCAmelCase__      )
           lowercase							:     List[Any]       	=      self._right(lowerCAmelCase__      )
           lowercase							:     List[Any]       	=      i

           if left is not None and not self._cmp(lowerCAmelCase__		,lowerCAmelCase__      ):
                  lowercase							:     Optional[int]       	=      left
           if right is not None and not self._cmp(lowerCAmelCase__		,lowerCAmelCase__      ):
                  lowercase							:     Tuple       	=      right

           return valid_parent
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case      ):



           '''simple docstring'''







           lowercase							:     List[Any]       	=      self._parent(lowerCAmelCase__      )
           while parent is not None and not self._cmp(lowerCAmelCase__		,lowerCAmelCase__      ):
                  self._swap(lowerCAmelCase__		,lowerCAmelCase__      )
                  lowercase							:     List[str]       	=      parent, self._parent(lowerCAmelCase__      )
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case      ):



           '''simple docstring'''







           lowercase							:     Optional[int]       	=      self._get_valid_parent(lowerCAmelCase__      )
           while valid_parent != index:
                  self._swap(lowerCAmelCase__		,lowerCAmelCase__      )
                  lowercase							:     Dict       	=      valid_parent, self._get_valid_parent(lowerCAmelCase__      )
    def       _SCREAMING_SNAKE_CASE       (  self		,snake_case		,snake_case      ):



           '''simple docstring'''







           if item not in self.pos_map:
                  return
           lowercase							:     Any       	=      self.pos_map[item]
           lowercase							:     int       	=      [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       _SCREAMING_SNAKE_CASE       (  self		,snake_case      ):



           '''simple docstring'''







           if item not in self.pos_map:
                  return
           lowercase							:     Optional[Any]       	=      self.pos_map[item]
           del self.pos_map[item]
           lowercase							:     List[str]       	=      self.arr[self.size - 1]
           lowercase							:     Tuple       	=      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       _SCREAMING_SNAKE_CASE       (  self		,snake_case		,snake_case      ):



           '''simple docstring'''







           lowercase							:     Optional[int]       	=      len(self.arr      )
           if arr_len == self.size:
                  self.arr.append([item, self.key(lowerCAmelCase__      )]      )
           else:
                  lowercase							:     str       	=      [item, self.key(lowerCAmelCase__      )]
           lowercase							:     List[Any]       	=      self.size
           self.size += 1
           self._heapify_up(self.size - 1      )
    def       _SCREAMING_SNAKE_CASE       (  self      ):



           '''simple docstring'''







           return self.arr[0] if self.size else None
    def       _SCREAMING_SNAKE_CASE       (  self      ):



           '''simple docstring'''







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







def 						_snake_case(  ) ->    int:
       pass


if __name__ == "__main__":
  import doctest

  doctest.testmod()



import math
import sys







def 			A_      (    _UpperCAmelCase    ):
						if number != int(_UpperCAmelCase    ):
												raise ValueError("the value of input must be a natural number"    )
						if number < 0:
												raise ValueError("the value of input must not be a negative number"    )
						if number == 0:
												return 1
						SCREAMING_SNAKE_CASE_: List[str]  		=       [-1] * (number + 1)
						SCREAMING_SNAKE_CASE_: str  		=       0
						for i in range(1				,	number + 1    ):
												SCREAMING_SNAKE_CASE_: str  		=       sys.maxsize
												SCREAMING_SNAKE_CASE_: List[Any]  		=       int(math.sqrt(_UpperCAmelCase    )    )
												for j in range(1				,	root + 1    ):
																		SCREAMING_SNAKE_CASE_: List[str]  		=       1 + answers[i - (j**2)]
																		SCREAMING_SNAKE_CASE_: Optional[Any]  		=       min(_UpperCAmelCase				,	_UpperCAmelCase    )
												SCREAMING_SNAKE_CASE_: Dict  		=       answer
						return answers[number]


if __name__ == "__main__":
						import doctest

						doctest.testmod()






