


'''simple docstring'''







from __future__ import annotations

from collections.abc import Iterable, Iterator
from typing import Any, Generic, TypeVar

A   :  Any       		=				TypeVar('''T''', bound=bool)


class 				__lowerCamelCase				( Generic[T] ):
    """simple docstring"""


    def __init__(						self    :							int   ,							SCREAMING_SNAKE_CASE    :							T):
           _A  :			T											=      value
           _A  :			SkewNode[T] | None											=      None
           _A  :			SkewNode[T] | None											=      None


    @property
    def      A					(						self    :							Optional[Any]):
           return self._value


    @staticmethod
    def      A					(						SCREAMING_SNAKE_CASE    :							SkewNode[T] | None   ,							SCREAMING_SNAKE_CASE    :							SkewNode[T] | None):
           if not roota:
                  return roota

           if not roota:
                  return roota

           if roota.value > roota.value:
                  _A						,				_A  :			Optional[int]											=      roota, roota

           _A  :			Optional[Any]											=      roota
           _A  :			Optional[Any]											=      roota.right
           _A  :			List[Any]											=      roota.left
           _A  :			Dict											=      SkewNode.merge(SCREAMING_SNAKE_CASE   ,							SCREAMING_SNAKE_CASE)

           return result




class 				__lowerCamelCase				( Generic[T] ):
    """simple docstring"""


    def __init__(						self    :							Dict   ,							SCREAMING_SNAKE_CASE    :							Iterable[T] | None = ()):
           _A  :			SkewNode[T] | None											=      None
           if data:
                  for item in data:
                         self.insert(SCREAMING_SNAKE_CASE)


    def __bool__(						self    :							str):
           return self._root is not None


    def __iter__(						self    :							Optional[Any]):
           _A  :			list[Any]											=      []
           while self:
                  result.append(self.pop())

           # Pushing items back to the heap not to clear it.
           for item in result:
                  self.insert(SCREAMING_SNAKE_CASE)

           return iter(SCREAMING_SNAKE_CASE)


    def      A					(						self    :							Union[str, Any]   ,							SCREAMING_SNAKE_CASE    :							T):
           _A  :			Tuple											=      SkewNode.merge(self._root   ,							SkewNode(SCREAMING_SNAKE_CASE))


    def      A					(						self    :							Union[str, Any]):
           _A  :			str											=      self.top()
           _A  :			int											=      (
               SkewNode.merge(self._root.left   ,							self._root.right) if self._root else None
           )

           return result


    def      A					(						self    :							List[str]):
           if not self._root:
                  raise IndexError('Can\'t get top element for the empty heap.')
           return self._root.value


    def      A					(						self    :							str):
           _A  :			Union[str, Any]											=      None


if __name__ == "__main__":
   import doctest

   doctest.testmod()










'''simple docstring'''







import itertools






def    lowerCAmelCase__ (       lowerCamelCase  :    int = 1000000     ):
       _A  :			str											=      [1]

       for i in itertools.count(len(lowerCamelCase     )     ):
              _A  :			Optional[Any]											=      0
              for j in itertools.count(1     ):
                     _A  :			int											=      -1 if j % 2 == 0 else +1
                     _A  :			Optional[Any]											=      (j * j * 3 - j) // 2
                     if index > i:
                            break
                     item += partitions[i - index] * sign
                     item %= number
                     index += j
                     if index > i:
                            break
                     item += partitions[i - index] * sign
                     item %= number

              if item == 0:
                     return i
              partitions.append(lowerCamelCase     )

       return 0


if __name__ == "__main__":
   import doctest

   doctest.testmod()

   print(f"""{solution() = }""")






