





def 	A_       (  _lowerCAmelCase  )		->				str:



 for i in range(len(A__  ) - 1							,     0							,     -1  ):
  UpperCamelCase			:      Dict 			=     False

  for j in range(A__							,     0							,     -1  ):
   if unsorted[j] < unsorted[j - 1]:
    UpperCamelCase			,					UpperCamelCase			:      int 			=     unsorted[j - 1], unsorted[j]
    UpperCamelCase			:      List[Any] 			=     True

  for j in range(A__  ):
   if unsorted[j] > unsorted[j + 1]:
    UpperCamelCase			,					UpperCamelCase			:      List[Any] 			=     unsorted[j + 1], unsorted[j]
    UpperCamelCase			:      List[Any] 			=     True

  if not swapped:
   break
 return unsorted


if __name__ == "__main__":
    import doctest

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







from PIL import Image



def 	A_       (  _lowerCAmelCase  )		->				Image:
 UpperCamelCase			,					UpperCamelCase			:      List[Any] 			=     image.size
 UpperCamelCase			:      Union[str, Any] 			=     0
 UpperCamelCase			:      List[str] 			=     image.load()
 for i in range(_lowerCAmelCase  ):
  for j in range(_lowerCAmelCase  ):
   UpperCamelCase			:      List[Any] 			=     pixels[j, i]
   mean += pixel
 mean //= width * height

 for j in range(_lowerCAmelCase  ):
  for i in range(_lowerCAmelCase  ):
   UpperCamelCase			:      Union[str, Any] 			=     255 if pixels[i, j] > mean else 0
 return image


if __name__ == "__main__":
    __lowerCamelCase :  Union[str, Any]										=  mean_threshold(Image.open("""path_to_image""").convert("""L"""))
    image.save("""output_image_path""")
