"""simple docstring"""


from __future__ import annotations

from collections.abc import Generator







def 					UpperCAmelCase    (		)				->      Generator[int, None, None]:
     snake_case_					       =					{}
     snake_case_					       =					2
     while True:
          snake_case_					       =					factor_map.pop(UpperCAmelCase						,					UpperCAmelCase					)
          if factor:
               snake_case_					       =					factor + prime
               while x in factor_map:
                    x += factor
               snake_case_					       =					factor
          else:
               snake_case_					       =					prime
               yield prime
          prime += 1







def 					UpperCAmelCase    (		UpperCAmelCase = 1e10					)				->      int:
     snake_case_					       =					sieve()

     snake_case_					       =					1
     while True:
          snake_case_					       =					next(UpperCAmelCase					)
          if (2 * prime * n) > limit:
               return n
          # Ignore the next prime as the reminder will be 2.
          next(UpperCAmelCase					)
          n += 2


if __name__ == "__main__":
    print(solution())





"""simple docstring"""







from PIL import Image




def    UpperCAmelCase__       (lowerCAmelCase_   ):




					'''simple docstring'''


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

					for j in range(lowerCAmelCase_   ):
										for i in range(lowerCAmelCase_   ):
															__SCREAMING_SNAKE_CASE						   =				255 if pixels[i, j] > mean else 0
					return image


if __name__ == "__main__":
		a__				:							List[str]						=     mean_threshold(Image.open('''path_to_image''').convert('''L'''))
		image.save('''output_image_path''')
