

'''simple docstring'''

import logging
import os
import threading
import time


try:
    import warnings
except ImportError:
    A_       						=							None

try:
    import msvcrt
except ImportError:
    A_       						=							None

try:
    import fcntl
except ImportError:
    A_       						=							None


# Backward compatibility
# ------------------------------------------------
try:
    TimeoutError
except NameError:
    A_       						=							OSError


# Data
# ------------------------------------------------
A_       						=							[
    '''Timeout''',
    '''BaseFileLock''',
    '''WindowsFileLock''',
    '''UnixFileLock''',
    '''SoftFileLock''',
    '''FileLock''',
]

A_       						=							'''3.0.12'''


A_       						=							None





def    A_  ( ):
  global _logger
  SCREAMING_SNAKE_CASE:int						      =					_logger or logging.getLogger(__name__ )
  return _logger





class 							_snake_case (       _UpperCAmelCase						):
   def __init__( self			:      Any     ,SCREAMING_SNAKE_CASE__			:      Dict							):
     SCREAMING_SNAKE_CASE:List[str]						      =					lock_file
     return None







   def __str__( self			:      List[str]							):
     SCREAMING_SNAKE_CASE:int						      =					F'''The file lock \'{self.lock_file}\' could not be acquired.'''
     return temp





class 							_snake_case :
   def __init__( self			:      Tuple     ,SCREAMING_SNAKE_CASE__			:      Any							):
     SCREAMING_SNAKE_CASE:Dict						      =					lock
     return None
   def __enter__( self			:      Any							):
     return self.lock







   def __exit__( self			:      List[Any]     ,SCREAMING_SNAKE_CASE__			:      int     ,SCREAMING_SNAKE_CASE__			:      List[str]     ,SCREAMING_SNAKE_CASE__			:      Optional[int]							):
     self.lock.release()
     return None





class 							_snake_case :
   def __init__( self			:      Optional[Any]     ,SCREAMING_SNAKE_CASE__			:      Optional[int]     ,SCREAMING_SNAKE_CASE__			:      Dict=-1     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]=None							):
     SCREAMING_SNAKE_CASE:int						      =					max_filename_length if max_filename_length is not None else 255
     # Hash the filename if it's too long
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					self.hash_filename_if_too_long(__UpperCamelCase     ,__UpperCamelCase							)
     # The path to the lock file.
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					lock_file

     # The file descriptor for the *_lock_file* as it is returned by the
     # os.open() function.
     # This file lock is only NOT None, if the object currently holds the
     # lock.
     SCREAMING_SNAKE_CASE:str						      =					None

     # The default timeout value.
     SCREAMING_SNAKE_CASE:Optional[int]						      =					timeout

     # We use this lock primarily for the lock counter.
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					threading.Lock()

     # The lock counter is used for implementing the nested locking
     # mechanism. Whenever the lock is acquired, the counter is increased and
     # the lock is only released, when this value is 0 again.
     SCREAMING_SNAKE_CASE:Optional[int]						      =					0
     return None
   @property
   def     __UpperCamelCase						( self			:      Union[str, Any]							):
     return self._lock_file
   @property
   def     __UpperCamelCase						( self			:      Tuple							):
     return self._timeout
   @timeout.setter
   def     __UpperCamelCase						( self			:      Union[str, Any]     ,SCREAMING_SNAKE_CASE__			:      Any							):
     SCREAMING_SNAKE_CASE:List[str]						      =					float(__UpperCamelCase							)
     return None
   def     __UpperCamelCase						( self			:      Optional[int]							):
     raise NotImplementedError()
   def     __UpperCamelCase						( self			:      str							):
     raise NotImplementedError()
   @property
   def     __UpperCamelCase						( self			:      Optional[int]							):
     return self._lock_file_fd is not None
   def     __UpperCamelCase						( self			:      Any     ,SCREAMING_SNAKE_CASE__			:      List[Any]=None     ,SCREAMING_SNAKE_CASE__			:      int=0.05							):






     if timeout is None:
       SCREAMING_SNAKE_CASE:Dict						      =					self.timeout

     # Increment the number right at the beginning.
     # We can still undo it, if something fails.
     with self._thread_lock:
       self._lock_counter += 1

     SCREAMING_SNAKE_CASE:Any						      =					id(self							)
     SCREAMING_SNAKE_CASE:str						      =					self._lock_file
     SCREAMING_SNAKE_CASE:Any						      =					time.time()
     try:
       while True:
         with self._thread_lock:
           if not self.is_locked:
             logger().debug(F'''Attempting to acquire lock {lock_id} on {lock_filename}'''							)
             self._acquire()

         if self.is_locked:
           logger().debug(F'''Lock {lock_id} acquired on {lock_filename}'''							)
           break
         elif timeout >= 0 and time.time() - start_time > timeout:
           logger().debug(F'''Timeout on acquiring lock {lock_id} on {lock_filename}'''							)
           raise Timeout(self._lock_file							)
         else:
           logger().debug(
               F'''Lock {lock_id} not acquired on {lock_filename}, waiting {poll_intervall} seconds ...'''							)
           time.sleep(__UpperCamelCase							)
     except:  # noqa
       # Something did go wrong, so decrement the counter.
       with self._thread_lock:
         SCREAMING_SNAKE_CASE:List[Any]						      =					max(0     ,self._lock_counter - 1							)

       raise
     return _Acquire_ReturnProxy(lock=self							)
   def     __UpperCamelCase						( self			:      str     ,SCREAMING_SNAKE_CASE__			:      Tuple=False							):






     with self._thread_lock:
       if self.is_locked:
         self._lock_counter -= 1

         if self._lock_counter == 0 or force:
           SCREAMING_SNAKE_CASE:Optional[Any]						      =					id(self							)
           SCREAMING_SNAKE_CASE:Dict						      =					self._lock_file

           logger().debug(F'''Attempting to release lock {lock_id} on {lock_filename}'''							)
           self._release()
           SCREAMING_SNAKE_CASE:List[Any]						      =					0
           logger().debug(F'''Lock {lock_id} released on {lock_filename}'''							)

     return None
   def __enter__( self			:      str							):
     self.acquire()
     return self
   def __exit__( self			:      int     ,SCREAMING_SNAKE_CASE__			:      Dict     ,SCREAMING_SNAKE_CASE__			:      Dict     ,SCREAMING_SNAKE_CASE__			:      Optional[int]							):
     self.release()
     return None
   def __del__( self			:      Any							):
     self.release(force=__UpperCamelCase							)
     return None







   def     __UpperCamelCase						( self			:      int     ,SCREAMING_SNAKE_CASE__			:      str     ,SCREAMING_SNAKE_CASE__			:      int							):
     SCREAMING_SNAKE_CASE:Any						      =					os.path.basename(__UpperCamelCase							)
     if len(__UpperCamelCase							) > max_length and max_length > 0:
       SCREAMING_SNAKE_CASE:Optional[Any]						      =					os.path.dirname(__UpperCamelCase							)
       SCREAMING_SNAKE_CASE:List[Any]						      =					str(hash(__UpperCamelCase							)							)
       SCREAMING_SNAKE_CASE:Optional[Any]						      =					filename[: max_length - len(__UpperCamelCase							) - 8] + "..." + hashed_filename + ".lock"
       return os.path.join(__UpperCamelCase     ,__UpperCamelCase							)
     else:
       return path





class 							_snake_case (       _UpperCAmelCase						):
   def __init__( self			:      Optional[Any]     ,SCREAMING_SNAKE_CASE__			:      Optional[Any]     ,SCREAMING_SNAKE_CASE__			:      Tuple=-1     ,SCREAMING_SNAKE_CASE__			:      Dict=None							):
     from .file_utils import relative_to_absolute_path

     super().__init__(__UpperCamelCase     ,timeout=__UpperCamelCase     ,max_filename_length=__UpperCamelCase							)
     SCREAMING_SNAKE_CASE:Any						      =					"\\\\?\\" + relative_to_absolute_path(self.lock_file							)
   def     __UpperCamelCase						( self			:      List[str]							):
     SCREAMING_SNAKE_CASE:List[str]						      =					os.O_RDWR | os.O_CREAT | os.O_TRUNC

     try:
       SCREAMING_SNAKE_CASE:Tuple						      =					os.open(self._lock_file     ,__UpperCamelCase							)
     except OSError:
       pass
     else:
       try:
         msvcrt.locking(__UpperCamelCase     ,msvcrt.LK_NBLCK     ,1							)
       except OSError:
         os.close(__UpperCamelCase							)
       else:
         SCREAMING_SNAKE_CASE:str						      =					fd
     return None







   def     __UpperCamelCase						( self			:      Tuple							):
     SCREAMING_SNAKE_CASE:List[Any]						      =					self._lock_file_fd
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					None
     msvcrt.locking(__UpperCamelCase     ,msvcrt.LK_UNLCK     ,1							)
     os.close(__UpperCamelCase							)

     try:
       os.remove(self._lock_file							)
     # Probably another instance of the application
     # that acquired the file lock.
     except OSError:
       pass
     return None





class 							_snake_case (       _UpperCAmelCase						):
   def __init__( self			:      Any     ,SCREAMING_SNAKE_CASE__			:      Any     ,SCREAMING_SNAKE_CASE__			:      Tuple=-1     ,SCREAMING_SNAKE_CASE__			:      Union[str, Any]=None							):
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					os.statvfs(os.path.dirname(__UpperCamelCase							)							).f_namemax
     super().__init__(__UpperCamelCase     ,timeout=__UpperCamelCase     ,max_filename_length=__UpperCamelCase							)
   def     __UpperCamelCase						( self			:      Optional[Any]							):
     SCREAMING_SNAKE_CASE:str						      =					os.O_RDWR | os.O_CREAT | os.O_TRUNC
     SCREAMING_SNAKE_CASE:Any						      =					os.open(self._lock_file     ,__UpperCamelCase							)

     try:
       fcntl.flock(__UpperCamelCase     ,fcntl.LOCK_EX | fcntl.LOCK_NB							)
     except OSError:
       os.close(__UpperCamelCase							)
     else:
       SCREAMING_SNAKE_CASE:Dict						      =					fd
     return None







   def     __UpperCamelCase						( self			:      List[str]							):
     SCREAMING_SNAKE_CASE:int						      =					self._lock_file_fd
     SCREAMING_SNAKE_CASE:Tuple						      =					None
     fcntl.flock(__UpperCamelCase     ,fcntl.LOCK_UN							)
     os.close(__UpperCamelCase							)
     return None





class 							_snake_case (       _UpperCAmelCase						):
   def     __UpperCamelCase						( self			:      List[Any]							):
     SCREAMING_SNAKE_CASE:List[str]						      =					os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_TRUNC
     try:
       SCREAMING_SNAKE_CASE:List[str]						      =					os.open(self._lock_file     ,__UpperCamelCase							)
     except OSError:
       pass
     else:
       SCREAMING_SNAKE_CASE:str						      =					fd
     return None







   def     __UpperCamelCase						( self			:      str							):
     os.close(self._lock_file_fd							)
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					None

     try:
       os.remove(self._lock_file							)
     # The file is already deleted and that's what we want.
     except OSError:
       pass
     return None



A_       						=							None

if msvcrt:
    A_       						=							WindowsFileLock
elif fcntl:
    A_       						=							UnixFileLock
else:
    A_       						=							SoftFileLock

    if warnings is not None:
        warnings.warn("only soft file lock is available")



'''simple docstring'''

def    A_  ( snake_case ):
  SCREAMING_SNAKE_CASE:Dict						      =					(1 + 24 * n) ** 0.5
  return ((1 + root) / 6) % 1 == 0





def    A_  ( snake_case = 5000 ):
  SCREAMING_SNAKE_CASE:int						      =					[(i * (3 * i - 1)) // 2 for i in range(1      ,       snake_case )]
  for i, pentagonal_i in enumerate(snake_case ):
    for j in range(snake_case      ,       len(snake_case ) ):
      SCREAMING_SNAKE_CASE:int						      =					pentagonal_nums[j]
      SCREAMING_SNAKE_CASE:Any						      =					pentagonal_i + pentagonal_j
      SCREAMING_SNAKE_CASE:int						      =					pentagonal_j - pentagonal_i
      if is_pentagonal(snake_case ) and is_pentagonal(snake_case ):
        return b

  return -1


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






