"""simple docstring"""






from PIL import Image


def     UpperCAmelCase__ (       lowerCAmelCase__  :str	)				->					int:
      '''simple docstring'''


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

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


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




"""simple docstring"""






def     UpperCAmelCase__ (       lowerCAmelCase__  :int	)				->					bool:
      '''simple docstring'''


      lowercase														=			(1 + 2_4 * n) ** 0.5
      return ((1 + root) / 6) % 1 == 0


def     UpperCAmelCase__ (       lowerCAmelCase__  :int = 5_0_0_0	)				->					int:
      '''simple docstring'''


      lowercase														=			[(i * (3 * i - 1)) // 2 for i in range(1      ,	lowerCAmelCase__	)]
      for i, pentagonal_i in enumerate(lowerCAmelCase__	):
            for j in range(lowerCAmelCase__      ,	len(lowerCAmelCase__	)	):
                  lowercase														=			pentagonal_nums[j]
                  lowercase														=			pentagonal_i + pentagonal_j
                  lowercase														=			pentagonal_j - pentagonal_i
                  if is_pentagonal(lowerCAmelCase__	) and is_pentagonal(lowerCAmelCase__	):
                        return b

      return -1


if __name__ == "__main__":
       print(F"""{solution() = }""")



