import logging
import os
import threading
import time


try:
 import warnings
except ImportError:
 lowerCamelCase     :							Optional[int]    =None

try:
 import msvcrt
except ImportError:
 lowerCamelCase     :							Optional[Any]    =None

try:
 import fcntl
except ImportError:
 lowerCamelCase     :							Dict    =None


# Backward compatibility
# ------------------------------------------------
try:
 TimeoutError
except NameError:
 lowerCamelCase     :							int    =OSError


# Data
# ------------------------------------------------
lowerCamelCase     :							Dict    =[
    "Timeout",
    "BaseFileLock",
    "WindowsFileLock",
    "UnixFileLock",
    "SoftFileLock",
    "FileLock",
]

lowerCamelCase     :							Dict    ="3.0.12"


lowerCamelCase     :							Union[str, Any]    =None







def 		SCREAMING_SNAKE_CASE							( )			->     str:
     global _logger
     UpperCamelCase__      :       str	    =  _logger or logging.getLogger(__name__      )
     return _logger





class       __a  (   SCREAMING_SNAKE_CASE__	):







 def __init__(		self :       Optional[int]							,       SCREAMING_SNAKE_CASE :       Dict						):


      '''simple docstring'''






      UpperCamelCase__      :       Any	    =  lock_file
      return None







 def __str__(		self :       str						):


      '''simple docstring'''






      UpperCamelCase__      :       Optional[int]	    =  F'The file lock \'{self.lock_file}\' could not be acquired.'
      return temp







class       __a  :







 def __init__(		self :       Union[str, Any]							,       SCREAMING_SNAKE_CASE :       List[str]						):


      '''simple docstring'''






      UpperCamelCase__      :       int	    =  lock
      return None







 def __enter__(		self :       Optional[int]						):


      '''simple docstring'''






      return self.lock







 def __exit__(		self :       List[str]							,       SCREAMING_SNAKE_CASE :       str							,       SCREAMING_SNAKE_CASE :       Union[str, Any]							,       SCREAMING_SNAKE_CASE :       Optional[int]						):


      '''simple docstring'''






      self.lock.release()
      return None







class       __a  :







 def __init__(		self :       List[str]							,       SCREAMING_SNAKE_CASE :       Tuple							,       SCREAMING_SNAKE_CASE :       Optional[int]=-1							,       SCREAMING_SNAKE_CASE :       int=None						):


      '''simple docstring'''






      UpperCamelCase__      :       Any	    =  max_filename_length if max_filename_length is not None else 2_55
      # Hash the filename if it's too long
      UpperCamelCase__      :       Dict	    =  self.hash_filename_if_too_long(A__							,       A__						)
      # The path to the lock file.
      UpperCamelCase__      :       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.
      UpperCamelCase__      :       List[str]	    =  None

      # The default timeout value.
      UpperCamelCase__      :       Optional[Any]	    =  timeout

      # We use this lock primarily for the lock counter.
      UpperCamelCase__      :       Optional[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.
      UpperCamelCase__      :       Any	    =  0
      return None







 @property
 def  __lowercase (		self :       Dict						):


      '''simple docstring'''






      return self._lock_file







 @property
 def  __lowercase (		self :       str						):


      '''simple docstring'''






      return self._timeout







 @timeout.setter
 def  __lowercase (		self :       Optional[Any]							,       SCREAMING_SNAKE_CASE :       List[str]						):


      '''simple docstring'''






      UpperCamelCase__      :       str	    =  float(A__						)
      return None







 def  __lowercase (		self :       Optional[int]						):


      '''simple docstring'''






      raise NotImplementedError()







 def  __lowercase (		self :       Tuple						):


      '''simple docstring'''






      raise NotImplementedError()







 @property
 def  __lowercase (		self :       int						):


      '''simple docstring'''






      return self._lock_file_fd is not None







 def  __lowercase (		self :       Optional[Any]							,       SCREAMING_SNAKE_CASE :       int=None							,       SCREAMING_SNAKE_CASE :       List[str]=0.0_5						):


      '''simple docstring'''






      if timeout is None:
           UpperCamelCase__      :       Union[str, Any]	    =  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

      UpperCamelCase__      :       Tuple	    =  id(self						)
      UpperCamelCase__      :       Optional[Any]	    =  self._lock_file
      UpperCamelCase__      :       int	    =  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(A__						)
      except:  # noqa
           # Something did go wrong, so decrement the counter.
           with self._thread_lock:
                UpperCamelCase__      :       Optional[Any]	    =  max(0							,       self._lock_counter - 1						)

           raise
      return _Acquire_ReturnProxy(lock=self						)







 def  __lowercase (		self :       str							,       SCREAMING_SNAKE_CASE :       Optional[int]=False						):


      '''simple docstring'''






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

                if self._lock_counter == 0 or force:
                     UpperCamelCase__      :       Union[str, Any]	    =  id(self						)
                     UpperCamelCase__      :       Tuple	    =  self._lock_file

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

      return None







 def __enter__(		self :       Optional[Any]						):


      '''simple docstring'''






      self.acquire()
      return self







 def __exit__(		self :       int							,       SCREAMING_SNAKE_CASE :       Optional[Any]							,       SCREAMING_SNAKE_CASE :       Optional[Any]							,       SCREAMING_SNAKE_CASE :       List[Any]						):


      '''simple docstring'''






      self.release()
      return None







 def __del__(		self :       Tuple						):


      '''simple docstring'''






      self.release(force=A__						)
      return None







 def  __lowercase (		self :       Dict							,       SCREAMING_SNAKE_CASE :       List[str]							,       SCREAMING_SNAKE_CASE :       Union[str, Any]						):


      '''simple docstring'''






      UpperCamelCase__      :       str	    =  os.path.basename(A__						)
      if len(A__						) > max_length and max_length > 0:
           UpperCamelCase__      :       str	    =  os.path.dirname(A__						)
           UpperCamelCase__      :       Any	    =  str(hash(A__						)						)
           UpperCamelCase__      :       str	    =  filename[: max_length - len(A__						) - 8] + "..." + hashed_filename + ".lock"
           return os.path.join(A__							,       A__						)
      else:
           return path







class       __a  (   SCREAMING_SNAKE_CASE__	):







 def __init__(		self :       Any							,       SCREAMING_SNAKE_CASE :       Any							,       SCREAMING_SNAKE_CASE :       Optional[int]=-1							,       SCREAMING_SNAKE_CASE :       Union[str, Any]=None						):


      '''simple docstring'''






      from .file_utils import relative_to_absolute_path

      super().__init__(A__							,       timeout=A__							,       max_filename_length=A__						)
      UpperCamelCase__      :       int	    =  "\\\\?\\" + relative_to_absolute_path(self.lock_file						)







 def  __lowercase (		self :       str						):


      '''simple docstring'''






      UpperCamelCase__      :       Tuple	    =  os.O_RDWR | os.O_CREAT | os.O_TRUNC

      try:
           UpperCamelCase__      :       Tuple	    =  os.open(self._lock_file							,       A__						)
      except OSError:
           pass
      else:
           try:
                msvcrt.locking(A__							,       msvcrt.LK_NBLCK							,       1						)
           except OSError:
                os.close(A__						)
           else:
                UpperCamelCase__      :       Optional[int]	    =  fd
      return None







 def  __lowercase (		self :       Union[str, Any]						):


      '''simple docstring'''






      UpperCamelCase__      :       int	    =  self._lock_file_fd
      UpperCamelCase__      :       int	    =  None
      msvcrt.locking(A__							,       msvcrt.LK_UNLCK							,       1						)
      os.close(A__						)

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







class       __a  (   SCREAMING_SNAKE_CASE__	):







 def __init__(		self :       str							,       SCREAMING_SNAKE_CASE :       Tuple							,       SCREAMING_SNAKE_CASE :       Dict=-1							,       SCREAMING_SNAKE_CASE :       Any=None						):


      '''simple docstring'''






      UpperCamelCase__      :       str	    =  os.statvfs(os.path.dirname(A__						)						).f_namemax
      super().__init__(A__							,       timeout=A__							,       max_filename_length=A__						)







 def  __lowercase (		self :       Dict						):


      '''simple docstring'''






      UpperCamelCase__      :       Tuple	    =  os.O_RDWR | os.O_CREAT | os.O_TRUNC
      UpperCamelCase__      :       Union[str, Any]	    =  os.open(self._lock_file							,       A__						)

      try:
           fcntl.flock(A__							,       fcntl.LOCK_EX | fcntl.LOCK_NB						)
      except OSError:
           os.close(A__						)
      else:
           UpperCamelCase__      :       Union[str, Any]	    =  fd
      return None







 def  __lowercase (		self :       Dict						):


      '''simple docstring'''






      UpperCamelCase__      :       Union[str, Any]	    =  self._lock_file_fd
      UpperCamelCase__      :       List[Any]	    =  None
      fcntl.flock(A__							,       fcntl.LOCK_UN						)
      os.close(A__						)
      return None







class       __a  (   SCREAMING_SNAKE_CASE__	):







 def  __lowercase (		self :       Dict						):


      '''simple docstring'''






      UpperCamelCase__      :       Optional[Any]	    =  os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_TRUNC
      try:
           UpperCamelCase__      :       Union[str, Any]	    =  os.open(self._lock_file							,       A__						)
      except OSError:
           pass
      else:
           UpperCamelCase__      :       Optional[int]	    =  fd
      return None







 def  __lowercase (		self :       str						):


      '''simple docstring'''






      os.close(self._lock_file_fd						)
      UpperCamelCase__      :       Tuple	    =  None

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







lowerCamelCase     :							List[Any]    =None

if msvcrt:
 lowerCamelCase     :							Any    =WindowsFileLock
elif fcntl:
 lowerCamelCase     :							str    =UnixFileLock
else:
 lowerCamelCase     :							Tuple    =SoftFileLock

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







from __future__ import annotations







def 		SCREAMING_SNAKE_CASE							( __lowerCAmelCase ,   __lowerCAmelCase      )			->     bool:
     if len(__lowerCAmelCase      ) == 0:
          return False
     UpperCamelCase__      :       Any	    =  len(__lowerCAmelCase      ) // 2
     if a_list[midpoint] == item:
          return True
     if item < a_list[midpoint]:
          return binary_search(a_list[:midpoint] ,   __lowerCAmelCase      )
     else:
          return binary_search(a_list[midpoint + 1 :] ,   __lowerCAmelCase      )


if __name__ == "__main__":
 lowerCamelCase     :							Any    =input('''Enter numbers separated by comma:\n''').strip()
 lowerCamelCase     :							Dict    =[int(item.strip()) for item in user_input.split(''',''')]
 lowerCamelCase     :							List[str]    =int(input('''Enter the number to be found in the list:\n''').strip())
 lowerCamelCase     :							Union[str, Any]    ='''''' if binary_search(sequence, target) else '''not '''
 print(F"""{target} was {not_str}found in {sequence}""")