

from collections.abc import Sequence







def 						lowerCamelCase__      ( __A    :Sequence[float]	,__A    :bool = False		):


       """simple docstring"""




       if not arr:
              return 0

       __snake_case       	=							0 if allow_empty_subarrays else float("""-inf"""		)
       __snake_case       	=							0.0
       for num in arr:
              __snake_case       	=							max(0 if allow_empty_subarrays else num	,curr_sum + num		)
              __snake_case       	=							max(__A	,__A		)

       return max_sum


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

    testmod()

    UpperCamelCase__		 =     [-2, 1, -3, 4, -1, 2, 1, -5, 4]
    print(F'{max_subarray_sum(nums) = }')




from PIL import Image







def 						lowerCamelCase__      ( __A    :Image		):


       """simple docstring"""




       __snake_case	,    __snake_case       	=							image.size
       __snake_case       	=							0
       __snake_case       	=							image.load()
       for i in range(__A		):
              for j in range(__A		):
                     __snake_case       	=							pixels[j, i]
                     mean += pixel
       mean //= width * height

       for j in range(__A		):
              for i in range(__A		):
                     __snake_case       	=							2_5_5 if pixels[i, j] > mean else 0
       return image


if __name__ == "__main__":
    UpperCamelCase__		 =     mean_threshold(Image.open('''path_to_image''').convert('''L'''))
    image.save('''output_image_path''')

