




class   A:



 '''simple docstring'''


 def __init__(				self					:  Any						,							A_					:  int						,							A_					:  Optional[Any]=None						,							A_					:  Any=None  )   ->	Dict:

       """simple docstring"""






       lowerCamelCase_		     =    data
       lowerCamelCase_		     =    previous
       lowerCamelCase_		     =    next_node

 def __str__(				self					:  Dict  )   ->	str:

       """simple docstring"""






       return f"""{self.data}"""

 def 				a__ (				self					:  int  )   ->	int:

       """simple docstring"""






       return self.data

 def 				a__ (				self					:  Any  )   ->	Optional[Any]:

       """simple docstring"""






       return self.next





 def 				a__ (				self					:  str  )   ->	List[Any]:

       """simple docstring"""






       return self.previous







class   A:



 '''simple docstring'''


 def __init__(				self					:  Optional[int]						,							A_					:  Any  )   ->	List[Any]:

       """simple docstring"""






       lowerCamelCase_		     =    head

 def __iter__(				self					:  Union[str, Any]  )   ->	Optional[int]:

       """simple docstring"""






       return self





 def 				a__ (				self					:  Union[str, Any]  )   ->	Optional[Any]:

       """simple docstring"""






       if not self.current:
             raise StopIteration
       else:
             lowerCamelCase_		     =    self.current.get_data()
             lowerCamelCase_		     =    self.current.get_next()
             return value







class   A:



 '''simple docstring'''


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

       """simple docstring"""






       lowerCamelCase_		     =    None  # First node in list
       lowerCamelCase_		     =    None  # Last node in list

 def __str__(				self					:  Dict  )   ->	Optional[int]:

       """simple docstring"""






       lowerCamelCase_		     =    self.head
       lowerCamelCase_		     =    []
       while current is not None:
             nodes.append(current.get_data()  )
             lowerCamelCase_		     =    current.get_next()
       return " ".join(str(A_  ) for node in nodes  )

 def __contains__(				self					:  Optional[Any]						,							A_					:  int  )   ->	Any:

       """simple docstring"""






       lowerCamelCase_		     =    self.head
       while current:
             if current.get_data() == value:
                   return True
             lowerCamelCase_		     =    current.get_next()
       return False

 def __iter__(				self					:  Optional[Any]  )   ->	List[Any]:

       """simple docstring"""






       return LinkedListIterator(self.head  )

 def 				a__ (				self					:  Union[str, Any]  )   ->	List[Any]:

       """simple docstring"""






       if self.head:
             return self.head.get_data()
       return None

 def 				a__ (				self					:  Dict  )   ->	Union[str, Any]:

       """simple docstring"""






       if self.tail:
             return self.tail.get_data()
       return None

 def 				a__ (				self					:  List[Any]						,							A_					:  Node  )   ->	None:

       """simple docstring"""






       if self.head is None:
             lowerCamelCase_		     =    node
             lowerCamelCase_		     =    node
       else:
             self.insert_before_node(self.head						,							A_  )

 def 				a__ (				self					:  Tuple						,							A_					:  Node  )   ->	None:

       """simple docstring"""






       if self.head is None:
             self.set_head(A_  )
       else:
             self.insert_after_node(self.tail						,							A_  )

 def 				a__ (				self					:  Optional[int]						,							A_					:  int  )   ->	None:

       """simple docstring"""






       lowerCamelCase_		     =    Node(A_  )
       if self.head is None:
             self.set_head(A_  )
       else:
             self.set_tail(A_  )

 def 				a__ (				self					:  int						,							A_					:  Node						,							A_					:  Node  )   ->	None:

       """simple docstring"""






       lowerCamelCase_		     =    node
       lowerCamelCase_		     =    node.previous

       if node.get_previous() is None:
             lowerCamelCase_		     =    node_to_insert
       else:
             lowerCamelCase_		     =    node_to_insert

       lowerCamelCase_		     =    node_to_insert

 def 				a__ (				self					:  List[str]						,							A_					:  Node						,							A_					:  Node  )   ->	None:

       """simple docstring"""






       lowerCamelCase_		     =    node
       lowerCamelCase_		     =    node.next

       if node.get_next() is None:
             lowerCamelCase_		     =    node_to_insert
       else:
             lowerCamelCase_		     =    node_to_insert

       lowerCamelCase_		     =    node_to_insert

 def 				a__ (				self					:  Any						,							A_					:  int						,							A_					:  int  )   ->	None:

       """simple docstring"""






       lowerCamelCase_		     =    1
       lowerCamelCase_		     =    Node(A_  )
       lowerCamelCase_		     =    self.head
       while node:
             if current_position == position:
                   self.insert_before_node(A_						,							A_  )
                   return
             current_position += 1
             lowerCamelCase_		     =    node.next
       self.insert_after_node(self.tail						,							A_  )

 def 				a__ (				self					:  str						,							A_					:  int  )   ->	Node:

       """simple docstring"""






       lowerCamelCase_		     =    self.head
       while node:
             if node.get_data() == item:
                   return node
             lowerCamelCase_		     =    node.get_next()
       raise Exception('Node not found'  )

 def 				a__ (				self					:  List[Any]						,							A_					:  Optional[Any]  )   ->	int:

       """simple docstring"""






       if (node := self.get_node(A_  )) is not None:
             if node == self.head:
                   lowerCamelCase_		     =    self.head.get_next()

             if node == self.tail:
                   lowerCamelCase_		     =    self.tail.get_previous()

             self.remove_node_pointers(A_  )

 @staticmethod
 def 				a__ (				A_					:  Node  )   ->	None:

       """simple docstring"""






       if node.get_next():
             lowerCamelCase_		     =    node.previous

       if node.get_previous():
             lowerCamelCase_		     =    node.next

       lowerCamelCase_		     =    None
       lowerCamelCase_		     =    None





 def 				a__ (				self					:  Tuple  )   ->	Dict:

       """simple docstring"""






       return self.head is None

def 			_SCREAMING_SNAKE_CASE			(							):


      '''simple docstring'''





if __name__ == "__main__":
 import doctest

 doctest.testmod()









def 			_SCREAMING_SNAKE_CASE			(							lowercase	:       list     ):


      '''simple docstring'''



      for i in range(len(lowercase     ) - 1	,							0	,							-1     ):
            lowerCamelCase_		     =    False

            for j in range(lowercase	,							0	,							-1     ):
                  if unsorted[j] < unsorted[j - 1]:
                        lowerCamelCase_     ,				lowerCamelCase_		     =    unsorted[j - 1], unsorted[j]
                        lowerCamelCase_		     =    True

            for j in range(lowercase     ):
                  if unsorted[j] > unsorted[j + 1]:
                        lowerCamelCase_     ,				lowerCamelCase_		     =    unsorted[j + 1], unsorted[j]
                        lowerCamelCase_		     =    True

            if not swapped:
                  break
      return unsorted


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 lowerCamelCase				:		Any     =   input("Enter numbers separated by a comma:\n").strip()
 lowerCamelCase				:		Dict     =   [int(item) for item in user_input.split(",")]
 print(F"""{cocktail_shaker_sort(unsorted) = }""")



