
from __future__ import annotations

def  __lowerCamelCase					( _lowercase			)       ->      list[int]:
     UpperCamelCase						    =					[True] * limit
     UpperCamelCase						    =					False
     UpperCamelCase						    =					False
     UpperCamelCase						    =					True

     for i in range(3						,     int(limit**0.5 + 1			)						,     2			):
          UpperCamelCase						    =					i * 2
          while index < limit:
               UpperCamelCase						    =					False
               UpperCamelCase						    =					index + i

     UpperCamelCase						    =					[2]

     for i in range(3						,     _lowercase						,     2			):
          if is_prime[i]:
               primes.append(_lowercase			)

     return primes

def  __lowerCamelCase					( _lowercase = 1000000			)       ->      int:
     UpperCamelCase						    =					prime_sieve(_lowercase			)
     UpperCamelCase						    =					0
     UpperCamelCase						    =					0

     for i in range(len(_lowercase			)			):
          for j in range(i + length						,     len(_lowercase			)			):
               UpperCamelCase						    =					sum(primes[i:j]			)
               if sol >= ceiling:
                    break

               if sol in primes:
                    UpperCamelCase						    =					j - i
                    UpperCamelCase						    =					sol

     return largest


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




from typing import Dict, List, Optional, Union

import numpy as np

from ...image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from ...image_transforms import rescale, resize, to_channel_dimension_format
from ...image_utils import (
    ChannelDimension,
    ImageInput,
    PILImageResampling,
    make_list_of_images,
    to_numpy_array,
    valid_images,
)
from ...utils import TensorType, is_vision_available, logging


if is_vision_available():
 import PIL


_snake_case      = logging.get_logger(__name__)

def  __lowerCamelCase					( _lowercase						,     _lowercase			)       ->      Optional[Any]:
     UpperCamelCase						    =					b.T
     UpperCamelCase						    =					np.sum(np.square(_lowercase			)						,     axis=1			)
     UpperCamelCase						    =					np.sum(np.square(_lowercase			)						,     axis=0			)
     UpperCamelCase						    =					np.matmul(_lowercase						,     _lowercase			)
     UpperCamelCase						    =					aa[:, None] - 2 * ab + ba[None, :]
     return d

def  __lowerCamelCase					( _lowercase						,     _lowercase			)       ->      List[Any]:
     UpperCamelCase						    =					x.reshape(-1						,     3			)
     UpperCamelCase						    =					squared_euclidean_distance(_lowercase						,     _lowercase			)
     return np.argmin(_lowercase						,     axis=1			)







class       _lowerCAmelCase  (		__magic_name__							):

 """simple docstring"""
 SCREAMING_SNAKE_CASE_				:					Optional[Any]       						=["pixel_values"]

 def __init__(						self			:			Dict					, SCREAMING_SNAKE_CASE__			:			Optional[Union[List[List[int]], np.ndarray]] = None					, SCREAMING_SNAKE_CASE__			:			bool = True					, SCREAMING_SNAKE_CASE__			:			Dict[str, int] = None					, SCREAMING_SNAKE_CASE__			:			PILImageResampling = PILImageResampling.BILINEAR					, SCREAMING_SNAKE_CASE__			:			bool = True					, SCREAMING_SNAKE_CASE__			:			bool = True					, **SCREAMING_SNAKE_CASE__			:			Optional[int]					, ):






      """simple docstring"""



      super().__init__(**SCREAMING_SNAKE_CASE__   )
      UpperCamelCase						    =					size if size is not None else {'height': 2_56, 'width': 2_56}
      UpperCamelCase						    =					get_size_dict(SCREAMING_SNAKE_CASE__   )
      UpperCamelCase						    =					np.array(SCREAMING_SNAKE_CASE__   ) if clusters is not None else None
      UpperCamelCase						    =					do_resize
      UpperCamelCase						    =					size
      UpperCamelCase						    =					resample
      UpperCamelCase						    =					do_normalize
      UpperCamelCase						    =					do_color_quantize

 def      __lowerCAmelCase  (						self			:			int					, SCREAMING_SNAKE_CASE__			:			np.ndarray					, SCREAMING_SNAKE_CASE__			:			Dict[str, int]					, SCREAMING_SNAKE_CASE__			:			PILImageResampling = PILImageResampling.BILINEAR					, SCREAMING_SNAKE_CASE__			:			Optional[Union[str, ChannelDimension]] = None					, **SCREAMING_SNAKE_CASE__			:			List[str]					, ):






      """simple docstring"""



      UpperCamelCase						    =					get_size_dict(SCREAMING_SNAKE_CASE__   )
      if "height" not in size or "width" not in size:
           raise ValueError(F'Size dictionary must contain both height and width keys. Got {size.keys()}'   )
      return resize(
          SCREAMING_SNAKE_CASE__					, size=(size['height'], size['width'])					, resample=SCREAMING_SNAKE_CASE__					, data_format=SCREAMING_SNAKE_CASE__					, **SCREAMING_SNAKE_CASE__   )

 def      __lowerCAmelCase  (						self			:			Optional[Any]					, SCREAMING_SNAKE_CASE__			:			np.ndarray					, SCREAMING_SNAKE_CASE__			:			Optional[Union[str, ChannelDimension]] = None					, ):






      """simple docstring"""



      UpperCamelCase						    =					rescale(image=SCREAMING_SNAKE_CASE__					, scale=1 / 127.5					, data_format=SCREAMING_SNAKE_CASE__   )
      UpperCamelCase						    =					image - 1
      return image






 def      __lowerCAmelCase  (						self			:			Union[str, Any]					, SCREAMING_SNAKE_CASE__			:			ImageInput					, SCREAMING_SNAKE_CASE__			:			bool = None					, SCREAMING_SNAKE_CASE__			:			Dict[str, int] = None					, SCREAMING_SNAKE_CASE__			:			PILImageResampling = None					, SCREAMING_SNAKE_CASE__			:			bool = None					, SCREAMING_SNAKE_CASE__			:			Optional[bool] = None					, SCREAMING_SNAKE_CASE__			:			Optional[Union[List[List[int]], np.ndarray]] = None					, SCREAMING_SNAKE_CASE__			:			Optional[Union[str, TensorType]] = None					, SCREAMING_SNAKE_CASE__			:			Optional[Union[str, ChannelDimension]] = ChannelDimension.FIRST					, **SCREAMING_SNAKE_CASE__			:			str					, ):






      """simple docstring"""



      UpperCamelCase						    =					do_resize if do_resize is not None else self.do_resize
      UpperCamelCase						    =					size if size is not None else self.size
      UpperCamelCase						    =					get_size_dict(SCREAMING_SNAKE_CASE__   )
      UpperCamelCase						    =					resample if resample is not None else self.resample
      UpperCamelCase						    =					do_normalize if do_normalize is not None else self.do_normalize
      UpperCamelCase						    =					do_color_quantize if do_color_quantize is not None else self.do_color_quantize
      UpperCamelCase						    =					clusters if clusters is not None else self.clusters
      UpperCamelCase						    =					np.array(SCREAMING_SNAKE_CASE__   )

      UpperCamelCase						    =					make_list_of_images(SCREAMING_SNAKE_CASE__   )

      if not valid_images(SCREAMING_SNAKE_CASE__   ):
           raise ValueError(
               'Invalid image type. Must be of type PIL.Image.Image, numpy.ndarray, '
               'torch.Tensor, tf.Tensor or jax.ndarray.'   )

      if do_resize and size is None or resample is None:
           raise ValueError('Size and resample must be specified if do_resize is True.'   )

      if do_color_quantize and clusters is None:
           raise ValueError('Clusters must be specified if do_color_quantize is True.'   )

      # All transformations expect numpy arrays.
      UpperCamelCase						    =					[to_numpy_array(SCREAMING_SNAKE_CASE__   ) for image in images]

      if do_resize:
           UpperCamelCase						    =					[self.resize(image=SCREAMING_SNAKE_CASE__					, size=SCREAMING_SNAKE_CASE__					, resample=SCREAMING_SNAKE_CASE__   ) for image in images]

      if do_normalize:
           UpperCamelCase						    =					[self.normalize(image=SCREAMING_SNAKE_CASE__   ) for image in images]

      if do_color_quantize:
           UpperCamelCase						    =					[to_channel_dimension_format(SCREAMING_SNAKE_CASE__					, ChannelDimension.LAST   ) for image in images]
           # color quantize from (batch_size, height, width, 3) to (batch_size, height, width)
           UpperCamelCase						    =					np.array(SCREAMING_SNAKE_CASE__   )
           UpperCamelCase						    =					color_quantize(SCREAMING_SNAKE_CASE__					, SCREAMING_SNAKE_CASE__   ).reshape(images.shape[:-1]   )

           # flatten to (batch_size, height*width)
           UpperCamelCase						    =					images.shape[0]
           UpperCamelCase						    =					images.reshape(SCREAMING_SNAKE_CASE__					, -1   )

           # We need to convert back to a list of images to keep consistent behaviour across processors.
           UpperCamelCase						    =					list(SCREAMING_SNAKE_CASE__   )
      else:
           UpperCamelCase						    =					[to_channel_dimension_format(SCREAMING_SNAKE_CASE__					, SCREAMING_SNAKE_CASE__   ) for image in images]

      UpperCamelCase						    =					{'input_ids': images}
      return BatchFeature(data=SCREAMING_SNAKE_CASE__					, tensor_type=SCREAMING_SNAKE_CASE__   )


