





'''simple docstring'''


import random
def 							UpperCAmelCase_  (						__lowerCamelCase : int     ,__lowerCamelCase : str     ,__lowerCamelCase : Any			):
   lowercase_      :List[Any]         =			a[left_index]
   lowercase_      :Union[str, Any]         =			left_index + 1
   for j in range(left_index + 1     ,__lowerCamelCase			):
      if a[j] < pivot:
         lowercase_      ,							lowercase_      :Dict         =			a[i], a[j]
         i += 1
   lowercase_      ,							lowercase_      :Tuple         =			a[i - 1], a[left_index]
   return i - 1
def 							UpperCAmelCase_  (						__lowerCamelCase : int     ,__lowerCamelCase : List[Any]     ,__lowerCamelCase : List[str]			):
   if left < right:
      lowercase_      :Tuple         =			random.randint(__lowerCamelCase     ,right - 1			)
      lowercase_      ,							lowercase_      :Any         =			(
          a[left],
          a[pivot],
      )  # switches the pivot with the left most bound
      lowercase_      :Optional[int]         =			partition(__lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase			)
      quick_sort_random(
          __lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase			)  # recursive quicksort to the left of the pivot point
      quick_sort_random(
          __lowerCamelCase     ,pivot_index + 1     ,__lowerCamelCase			)  # recursive quicksort to the right of the pivot point
def 							UpperCAmelCase_  (						):
   lowercase_      :Optional[Any]         =			input("Enter numbers separated by a comma:\n"			).strip()
   lowercase_      :List[str]         =			[int(__lowerCamelCase			) for item in user_input.split(","			)]

   quick_sort_random(__lowerCamelCase     ,0     ,len(__lowerCamelCase			)			)

   print(__lowerCamelCase			)


if __name__ == "__main__":
 main()









'''simple docstring'''


def 							UpperCAmelCase_  (						__lowerCamelCase : dict			):
   lowercase_      :set[int]         =			set()
   # To detect a back edge, keep track of vertices currently in the recursion stack
   lowercase_      :set[int]         =			set()
   return any(
       node not in visited and depth_first_search(__lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase			)
       for node in graph			)
def 							UpperCAmelCase_  (						__lowerCamelCase : dict     ,__lowerCamelCase : int     ,__lowerCamelCase : set     ,__lowerCamelCase : set			):
   visited.add(__lowerCamelCase			)
   rec_stk.add(__lowerCamelCase			)

   for node in graph[vertex]:
      if node not in visited:
         if depth_first_search(__lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase     ,__lowerCamelCase			):
            return True
      elif node in rec_stk:
         return True

    # The node needs to be removed from recursion stack before function ends
   rec_stk.remove(__lowerCamelCase			)
   return False


if __name__ == "__main__":
 from doctest import testmod

 testmod()


