


"""simple docstring"""






from PIL import Image







def        lowerCamelCase_(		_lowerCamelCase       )    ->     Image:
   '''simple docstring'''





   _lowerCamelCase,					_lowerCamelCase   :				Optional[Any]							=     image.size
   _lowerCamelCase   :				List[Any]							=     0
   _lowerCamelCase   :				str							=     image.load()
   for i in range(_lowerCamelCase       ):
      for j in range(_lowerCamelCase       ):
         _lowerCamelCase   :				int							=     pixels[j, i]
         mean += pixel
   mean //= width * height

   for j in range(_lowerCamelCase       ):
      for i in range(_lowerCamelCase       ):
         _lowerCamelCase   :				List[str]							=     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''')


'''simple docstring'''

from collections import defaultdict
from math import gcd

def 					__UpperCamelCase				(						lowercase__    :	int = 1_50_00_00			):






     '''simple docstring'''





     __lowercase      		=defaultdict(lowercase__			)
     __lowercase      		=2
     while 2 * euclid_m * (euclid_m + 1) <= limit:
          for euclid_n in range((euclid_m % 2) + 1,       lowercase__,       2			):
               if gcd(lowercase__,       lowercase__			) > 1:
                    continue
               __lowercase      		=2 * euclid_m * (euclid_m + euclid_n)
               for perimeter in range(lowercase__,       limit + 1,       lowercase__			):
                    frequencies[perimeter] += 1
          euclid_m += 1
     return sum(1 for frequency in frequencies.values() if frequency == 1			)


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


