
'''simple docstring'''
from __future__ import annotations

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

a_           =    TypeVar("T", bound=bool)






class  UpperCAmelCase_					(						Generic[T]       ):





 def __init__(     self			,							lowercase_):
     snake_case_			:     T        =    value
     snake_case_			:     RandomizedHeapNode[T] | None        =    None
     snake_case_			:     RandomizedHeapNode[T] | None        =    None





 @property
 def 							snake_case__		(     self):
     return self._value





 @staticmethod
 def 							snake_case__		(     lowercase_			,							lowercase_):
     if not roota:
         return roota

     if not roota:
         return roota

     if roota.value > roota.value:
         snake_case_      ,			snake_case_			:     Any        =    roota, roota

     if random.choice([True, False]):
         snake_case_      ,			snake_case_			:     Optional[int]        =    roota.right, roota.left

     snake_case_			:     Union[str, Any]        =    RandomizedHeapNode.merge(roota.left			,							lowercase_)

     return roota






class  UpperCAmelCase_					(						Generic[T]       ):





 def __init__(     self			,							lowercase_ = ()):
     snake_case_			:     RandomizedHeapNode[T] | None        =    None

     if data:
         for item in data:
             self.insert(lowercase_)





 def 							snake_case__		(     self			,							lowercase_):
     snake_case_			:     Optional[int]        =    RandomizedHeapNode.merge(self._root			,							RandomizedHeapNode(lowercase_))





 def 							snake_case__		(     self):
     snake_case_			:     List[str]        =    self.top()

     if self._root is None:
         return None

     snake_case_			:     str        =    RandomizedHeapNode.merge(self._root.left			,							self._root.right)

     return result





 def 							snake_case__		(     self):
     if not self._root:
         raise IndexError("Can't get top element for the empty heap.")
     return self._root.value





 def 							snake_case__		(     self):
     snake_case_			:     Union[str, Any]        =    None





 def 							snake_case__		(     self):
     snake_case_			:     List[Any]        =    []
     while self:
         result.append(self.pop())

     return result





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


if __name__ == "__main__":
  import doctest

  doctest.testmod()






'''simple docstring'''
import itertools

def     UpperCamelCase_  (						__SCREAMING_SNAKE_CASE = 1_0_0_0_0_0_0							):
    """simple docstring"""






    snake_case_			:     Optional[int]        =    [1]

    for i in itertools.count(len(__SCREAMING_SNAKE_CASE							)							):
        snake_case_			:     str        =    0
        for j in itertools.count(1							):
            snake_case_			:     List[str]        =    -1 if j % 2 == 0 else +1
            snake_case_			:     str        =    (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(__SCREAMING_SNAKE_CASE							)

    return 0


if __name__ == "__main__":
  import doctest

  doctest.testmod()

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




