




'''simple docstring'''






from math import factorial






class        lowercase_      :





     def __init__(     self     :					Union[str, Any]     ,							__lowerCamelCase     :					Union[str, Any]     ,							__lowerCamelCase     :					Union[str, Any]			):
           snake_case__       :   str	      =    real
           if isinstance(__lowerCamelCase     ,							__lowerCamelCase			):
                 snake_case__       :   Any	      =    [1] * rank
           else:
                 snake_case__       :   Dict	      =    rank





     def __repr__(     self     :					List[Any]			):
           return (
               F"{self.real}+"
               F"{'+'.join(str(__lowerCamelCase			)+'E'+str(n+1			)for n,dual in enumerate(self.duals			)			)}"
           )





     def 			_lowerCAmelCase      (     self     :					Optional[Any]			):
           snake_case__       :   List[str]	      =    self.duals.copy()
           while cur[-1] == 0:
                 cur.pop(-1			)
           return Dual(self.real     ,							__lowerCamelCase			)





     def __add__(     self     :					Tuple     ,							__lowerCamelCase     :					List[str]			):
           if not isinstance(__lowerCamelCase     ,							__lowerCamelCase			):
                 return Dual(self.real + other     ,							self.duals			)
           snake_case__       :   Optional[int]	      =    self.duals.copy()
           snake_case__       :   Any	      =    other.duals.copy()
           if len(__lowerCamelCase			) > len(__lowerCamelCase			):
                 o_dual.extend([1] * (len(__lowerCamelCase			) - len(__lowerCamelCase			))			)
           elif len(__lowerCamelCase			) < len(__lowerCamelCase			):
                 s_dual.extend([1] * (len(__lowerCamelCase			) - len(__lowerCamelCase			))			)
           snake_case__       :   Dict	      =    []
           for i in range(len(__lowerCamelCase			)			):
                 new_duals.append(s_dual[i] + o_dual[i]			)
           return Dual(self.real + other.real     ,							__lowerCamelCase			)

     A_											=			__add__





     def __sub__(     self     :					Dict     ,							__lowerCamelCase     :					Optional[Any]			):
           return self + other * -1





     def __mul__(     self     :					str     ,							__lowerCamelCase     :					Dict			):
           if not isinstance(__lowerCamelCase     ,							__lowerCamelCase			):
                 snake_case__       :   int	      =    []
                 for i in self.duals:
                       new_duals.append(i * other			)
                 return Dual(self.real * other     ,							__lowerCamelCase			)
           snake_case__       :   Optional[Any]	      =    [0] * (len(self.duals			) + len(other.duals			) + 1)
           for i, item in enumerate(self.duals			):
                 for j, jtem in enumerate(other.duals			):
                       new_duals[i + j + 1] += item * jtem
           for k in range(len(self.duals			)			):
                 new_duals[k] += self.duals[k] * other.real
           for index in range(len(other.duals			)			):
                 new_duals[index] += other.duals[index] * self.real
           return Dual(self.real * other.real     ,							__lowerCamelCase			)

     A_											=			__mul__





     def __truediv__(     self     :					str     ,							__lowerCamelCase     :					Optional[int]			):
           if not isinstance(__lowerCamelCase     ,							__lowerCamelCase			):
                 snake_case__       :   Optional[int]	      =    []
                 for i in self.duals:
                       new_duals.append(i / other			)
                 return Dual(self.real / other     ,							__lowerCamelCase			)
           raise ValueError





     def __floordiv__(     self     :					Dict     ,							__lowerCamelCase     :					Any			):
           if not isinstance(__lowerCamelCase     ,							__lowerCamelCase			):
                 snake_case__       :   str	      =    []
                 for i in self.duals:
                       new_duals.append(i // other			)
                 return Dual(self.real // other     ,							__lowerCamelCase			)
           raise ValueError





     def __pow__(     self     :					Tuple     ,							__lowerCamelCase     :					List[str]			):
           if n < 0 or isinstance(__lowerCamelCase     ,							__lowerCamelCase			):
                 raise ValueError('power must be a positive integer'			)
           if n == 0:
                 return 1
           if n == 1:
                 return self
           snake_case__       :   str	      =    self
           for _ in range(n - 1			):
                 x *= self
           return x






def 		UpperCamelCase__      (		__SCREAMING_SNAKE_CASE				,      __SCREAMING_SNAKE_CASE				,      __SCREAMING_SNAKE_CASE		)    ->   Optional[int]:
      if not callable(__SCREAMING_SNAKE_CASE		):
            raise ValueError('differentiate() requires a function as input for func'		)
      if not isinstance(__SCREAMING_SNAKE_CASE				,      (float, int)		):
            raise ValueError('differentiate() requires a float as input for position'		)
      if not isinstance(__SCREAMING_SNAKE_CASE				,      __SCREAMING_SNAKE_CASE		):
            raise ValueError('differentiate() requires an int as input for order'		)
      snake_case__       :   int	      =    Dual(__SCREAMING_SNAKE_CASE				,      1		)
      snake_case__       :   List[Any]	      =    func(__SCREAMING_SNAKE_CASE		)
      if order == 0:
            return result.real
      return result.duals[order - 1] * factorial(__SCREAMING_SNAKE_CASE		)


if __name__ == "__main__":
      import doctest

      doctest.testmod()






      def 		UpperCamelCase__      (		__SCREAMING_SNAKE_CASE		)    ->   Optional[int]:
            return y**2 * y**4




      print(differentiate(f, 9, 2))






'''simple docstring'''






from typing import Any






class        lowercase_      :





     def __init__(     self     :					Dict     ,							__lowerCamelCase     :					Any			):
           snake_case__       :   str	      =    data
           snake_case__       :   Dict	      =    None






class        lowercase_      :





     def __init__(     self     :					int			):
           snake_case__       :   List[Any]	      =    None





     def 			_lowerCAmelCase      (     self     :					str			):
           snake_case__       :   Any	      =    self.head
           while temp is not None:
                 print(temp.data     ,							end=' '			)
                 snake_case__       :   int	      =    temp.next
           print()





     def 			_lowerCAmelCase      (     self     :					Optional[Any]     ,							__lowerCamelCase     :					Any			):
           snake_case__       :   Union[str, Any]	      =    Node(__lowerCamelCase			)
           snake_case__       :   List[str]	      =    self.head
           snake_case__       :   Any	      =    new_node





     def 			_lowerCAmelCase      (     self     :					Dict     ,							__lowerCamelCase     :					int     ,							__lowerCamelCase     :					Tuple			):
           if node_data_a == node_data_a:
                 return
           else:
                 snake_case__       :   List[Any]	      =    self.head
                 while node_a is not None and node_a.data != node_data_a:
                       snake_case__       :   List[str]	      =    node_a.next

                 snake_case__       :   Union[str, Any]	      =    self.head
                 while node_a is not None and node_a.data != node_data_a:
                       snake_case__       :   str	      =    node_a.next

                 if node_a is None or node_a is None:
                       return

                 snake_case__      ,							snake_case__       :   Dict	      =    node_a.data, node_a.data


if __name__ == "__main__":
      A_			      =		LinkedList()
      for i in range(5, 0, -1):
            ll.push(i)

      ll.print_list()

      ll.swap_nodes(1, 4)
      print("After swapping")
      ll.print_list()
