


"""simple docstring"""





from __future__ import annotations

from typing import Generic, TypeVar

snake_case__		:  Tuple     					=					TypeVar('''T''')



class 		snake_case_(							Generic[T]      ):






     def __init__(						self	:       Optional[Any]       ,					UpperCamelCase_	:       T					):
           lowerCAmelCase       :						Tuple							= data  # Assign data
           lowerCAmelCase       :						Node[T] | None							= None  # Initialize next as null
           lowerCAmelCase       :						Node[T] | None							= None  # Initialize prev as null



class 		snake_case_(							Generic[T]      ):






     def __init__(						self	:       Optional[int]					):
           lowerCAmelCase       :						Node[T] | None							= None






     def   lowerCamelCase__  (						self	:       List[Any]       ,					UpperCamelCase_	:       T					):
           if self.head is None:
                 lowerCAmelCase       :						Any							= Node(UpperCamelCase_					)
           else:
                 lowerCAmelCase       :						Union[str, Any]							= Node(UpperCamelCase_					)
                 lowerCAmelCase       :						Optional[int]							= new_node
                 lowerCAmelCase       :						Any							= self.head
                 lowerCAmelCase       :						Optional[int]							= None
                 lowerCAmelCase       :						Tuple							= new_node






     def   lowerCamelCase__  (						self	:       Any					):
           if self.head is None:
                 return None
           else:
                 assert self.head is not None
                 lowerCAmelCase       :						List[str]							= self.head.data
                 lowerCAmelCase       :						Any							= self.head.next
                 if self.head is not None:
                       lowerCAmelCase       :						Tuple							= None
                 return temp






     def   lowerCamelCase__  (						self	:       Optional[Any]					):
           return self.head.data if self.head is not None else None






     def __len__(						self	:       List[Any]					):
           lowerCAmelCase       :						List[str]							= self.head
           lowerCAmelCase       :						str							= 0
           while temp is not None:
                 count += 1
                 lowerCAmelCase       :						Optional[int]							= temp.next
           return count






     def   lowerCamelCase__  (						self	:       Tuple					):
           return self.head is None






     def   lowerCamelCase__  (						self	:       Dict					):
           print('''stack elements are:'''					)
           lowerCAmelCase       :						str							= self.head
           while temp is not None:
                 print(temp.data       ,					end='''->'''					)
                 lowerCAmelCase       :						Dict							= temp.next


# Code execution starts here
if __name__ == "__main__":
 # Start with the empty stack
 snake_case__		:  Stack[int]     					=					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())






"""simple docstring"""





def   _snake_case    (    _snake_case					:      int      ):
      if not isinstance(_snake_case			, _snake_case      ):
            lowerCAmelCase       :						int							= f'''Input value of [number={number}] must be an integer'''
            raise TypeError(_snake_case      )
      if number < 0 or number % 2 == 1:
            return False
      lowerCAmelCase       :						int							= int(number**0.5      )
      return number == number_sqrt * (number_sqrt + 1)


if __name__ == "__main__":
 import doctest

 doctest.testmod()


