'''simple docstring'''

from __future__ import annotations

from collections.abc import Iterable
from dataclasses import dataclass
from typing import Any




class    lowerCamelCase__  :
   __UpperCAmelCase           =						("""_front""", """_back""", """_len""")




   @dataclass
   class    lowerCamelCase__  :
      __UpperCAmelCase           =						None
      __UpperCAmelCase           =						None
      __UpperCAmelCase           =						None




   class    lowerCamelCase__  :
      __UpperCAmelCase           =						("""_cur""",)



      def __init__(    self					,      lowerCAmelCase__     )				->     None:
           """simple docstring"""





           _UpperCamelCase  :List[str]       =cur



      def __iter__(    self     )				->     Deque._Iterator:
           """simple docstring"""





           return self




      def  _UpperCamelCase		(    self     )				->     Any:
           """simple docstring"""





           if self._cur is None:
                # finished iterating
                raise StopIteration
           _UpperCamelCase  :Any       =self._cur.val
           _UpperCamelCase  :Tuple       =self._cur.next_node

           return val




   def __init__(    self					,      lowerCAmelCase__ = None     )				->     None:
        """simple docstring"""





        _UpperCamelCase  :str       =None
        _UpperCamelCase  :List[Any]       =None
        _UpperCamelCase  :Tuple       =0

        if iterable is not None:
             # append every value to the deque
             for val in iterable:
                  self.append(lowerCAmelCase__     )



   def  _UpperCamelCase		(    self					,      lowerCAmelCase__     )				->     None:
        """simple docstring"""





        _UpperCamelCase  :List[str]       =self._Node(lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__     )
        if self.is_empty():
             # front = back
             _UpperCamelCase  :Any       =node
             _UpperCamelCase  :Optional[Any]       =1
        else:
             # connect nodes
             _UpperCamelCase  :int       =node
             _UpperCamelCase  :Optional[Any]       =self._back
             _UpperCamelCase  :Dict       =node  # assign new back to the new node

             self._len += 1

             # make sure there were no errors
             assert not self.is_empty(), "Error on appending value."



   def  _UpperCamelCase		(    self					,      lowerCAmelCase__     )				->     None:
        """simple docstring"""





        _UpperCamelCase  :List[Any]       =self._Node(lowerCAmelCase__					,      lowerCAmelCase__					,      lowerCAmelCase__     )
        if self.is_empty():
             # front = back
             _UpperCamelCase  :Union[str, Any]       =node
             _UpperCamelCase  :List[Any]       =1
        else:
             # connect nodes
             _UpperCamelCase  :Any       =self._front
             _UpperCamelCase  :Dict       =node
             _UpperCamelCase  :str       =node  # assign new front to the new node

             self._len += 1

             # make sure there were no errors
             assert not self.is_empty(), "Error on appending value."



   def  _UpperCamelCase		(    self					,      lowerCAmelCase__     )				->     None:
        """simple docstring"""





        for val in iterable:
             self.append(lowerCAmelCase__     )



   def  _UpperCamelCase		(    self					,      lowerCAmelCase__     )				->     None:
        """simple docstring"""





        for val in iterable:
             self.appendleft(lowerCAmelCase__     )



   def  _UpperCamelCase		(    self     )				->     Any:
        """simple docstring"""





        assert not self.is_empty(), "Deque is empty."

        _UpperCamelCase  :List[str]       =self._back
        _UpperCamelCase  :Tuple       =self._back.prev_node  # set new back
        # drop the last node - python will deallocate memory automatically
        _UpperCamelCase  :Union[str, Any]       =None

        self._len -= 1

        return topop.val



   def  _UpperCamelCase		(    self     )				->     Any:
        """simple docstring"""





        assert not self.is_empty(), "Deque is empty."

        _UpperCamelCase  :Optional[Any]       =self._front
        _UpperCamelCase  :Tuple       =self._front.next_node  # set new front and drop the first node
        _UpperCamelCase  :Optional[Any]       =None

        self._len -= 1

        return topop.val



   def  _UpperCamelCase		(    self     )				->     bool:
        """simple docstring"""





        return self._front is None



   def __len__(    self     )				->     int:
        """simple docstring"""





        return self._len



   def __eq__(    self					,      lowerCAmelCase__     )				->     bool:
        """simple docstring"""





        if not isinstance(lowerCAmelCase__					,      lowerCAmelCase__     ):
             return NotImplemented

        _UpperCamelCase  :str       =self._front
        _UpperCamelCase  :Any       =other._front

        # if the length of the dequeues are not the same, they are not equal
        if len(self     ) != len(lowerCAmelCase__     ):
             return False

        while me is not None and oth is not None:
             # compare every value
             if me.val != oth.val:
                  return False
             _UpperCamelCase  :Union[str, Any]       =me.next_node
             _UpperCamelCase  :str       =oth.next_node

        return True



   def __iter__(    self     )				->     Deque._Iterator:
        """simple docstring"""





        return Deque._Iterator(self._front     )




   def __repr__(    self     )				->     str:
        """simple docstring"""





        _UpperCamelCase  :Dict       =[]
        _UpperCamelCase  :str       =self._front
        while aux is not None:
             # append the values in a list to display
             values_list.append(aux.val     )
             _UpperCamelCase  :int       =aux.next_node

        return f'''[{', '.join(repr(lowerCAmelCase__     ) for val in values_list     )}]'''


if __name__ == "__main__":
      import doctest

      doctest.testmod()



'''simple docstring'''






import math
from decimal import Decimal, getcontext






def 						_A					(lowerCAmelCase__	:int = 4_00_00_00		) ->	int:




     '''simple docstring'''



     try:
          _a         =				int(lowerCAmelCase__		)
     except (TypeError, ValueError):
          raise TypeError('Parameter n must be int or castable to int.'		)
     if n <= 0:
          raise ValueError('Parameter n must be greater than or equal to one.'		)
     _a         =				1_00
     _a         =				(Decimal(5		) ** Decimal(0.5		) + 1) / Decimal(2		)

     _a         =				(math.floor(math.log(n * (phi + 2)					,    lowerCAmelCase__		) - 1		) // 3) * 3 + 2
     _a         =				Decimal(round(phi ** Decimal(index + 1		)		)		) / (phi + 2)
     _a         =				num // 2
     return int(lowerCAmelCase__		)


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

