



from __future__ import annotations

from typing import Generic, TypeVar

a_								=   TypeVar("""T""")



class 	__lowerCAmelCase       (		Generic[T]				):




 def __init__(  self		,			__UpperCAmelCase			):



    '''simple docstring'''
    __lowerCamelCase  							=      data  # Assign data
    __lowerCamelCase  							=      None  # Initialize next as null
    __lowerCamelCase  							=      None  # Initialize prev as null



class 	__lowerCAmelCase       (		Generic[T]				):




 def __init__(  self			):



    '''simple docstring'''
    __lowerCamelCase  							=      None




 def     lowerCamelCase (  self		,			__UpperCAmelCase			):



    '''simple docstring'''
    if self.head is None:
       __lowerCamelCase  							=      Node(__UpperCAmelCase			)
    else:
       __lowerCamelCase  							=      Node(__UpperCAmelCase			)
       __lowerCamelCase  							=      new_node
       __lowerCamelCase  							=      self.head
       __lowerCamelCase  							=      None
       __lowerCamelCase  							=      new_node




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    if self.head is None:
       return None
    else:
       assert self.head is not None
       __lowerCamelCase  							=      self.head.data
       __lowerCamelCase  							=      self.head.next
       if self.head is not None:
          __lowerCamelCase  							=      None
       return temp




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    return self.head.data if self.head is not None else None




 def __len__(  self			):



    '''simple docstring'''
    __lowerCamelCase  							=      self.head
    __lowerCamelCase  							=      0
    while temp is not None:
       count += 1
       __lowerCamelCase  							=      temp.next
    return count




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    return self.head is None




 def     lowerCamelCase (  self			):



    '''simple docstring'''
    print('''stack elements are:'''			)
    __lowerCamelCase  							=      self.head
    while temp is not None:
       print(temp.data		,			end='''->'''			)
       __lowerCamelCase  							=      temp.next


# Code execution starts here
if __name__ == "__main__":
  # Start with the empty stack
  a_								=   Stack()

  # Insert 4 at the beginning. So stack becomes 4->None
  print("""Stack operations using Doubly LinkedList""")
  stack.push(4)

  # Insert 5 at the beginning. So stack becomes 4->5->None
  stack.push(5)

  # Insert 6 at the beginning. So stack becomes 4->5->6->None
  stack.push(6)

  # Insert 7 at the beginning. So stack becomes 4->5->6->7->None
  stack.push(7)

  # Print the stack
  stack.print_stack()

  # Print the top element
  print("""\nTop element is """, stack.top())

  # Print the stack size
  print("""Size of the stack is """, len(stack))

  # pop the top element
  stack.pop()

  # pop the top element
  stack.pop()

  # two elements have now been popped off
  stack.print_stack()

  # Print True if the stack is empty else False
  print("""\nstack is empty:""", stack.is_empty())











def 						a__     (						_UpperCamelCase     :	int							):
   if not isinstance(_UpperCamelCase	,_UpperCamelCase							):
      __lowerCamelCase  							=      (
          '''operation can not be conducted on a object of type '''
          F"""{type(_UpperCamelCase							).__name__}"""
      )
      raise TypeError(_UpperCamelCase							)
   __lowerCamelCase  							=      ''''''
   for _ in range(0	,32							):
      bit_string += str(number % 2							)
      __lowerCamelCase  							=      number >> 1
   return bit_string





def 						a__     (						_UpperCamelCase     :	int							):
   if number < 0:
      raise ValueError('''the value of input must be positive'''							)
   elif isinstance(_UpperCamelCase	,_UpperCamelCase							):
      raise TypeError('''Input value must be a \'int\' type'''							)
   elif isinstance(_UpperCamelCase	,_UpperCamelCase							):
      raise TypeError('''\'<\' not supported between instances of \'str\' and \'int\''''							)
   __lowerCamelCase  							=      0
   # iterator over [1 to 32],since we are dealing with 32 bit integer
   for _ in range(1	,33							):
      # left shift the bits by unity
      __lowerCamelCase  							=      result << 1
      # get the end bit
      __lowerCamelCase  							=      number % 2
      # right shift the bits by unity
      __lowerCamelCase  							=      number >> 1
      # add that bit to our ans
      __lowerCamelCase  							=      result | end_bit
   return get_reverse_bit_string(_UpperCamelCase							)


if __name__ == "__main__":
  import doctest

  doctest.testmod()






