




'''simple docstring'''


import math



def    _SCREAMING_SNAKE_CASE    (			UpperCamelCase__						:				int							):




     """simple docstring"""


     if 1 < number < 4:
          # 2 and 3 are primes
          return True
     elif number < 2 or number % 2 == 0 or number % 3 == 0:
          # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
          return False

     # All primes number are in format of 6k +/- 1
     for i in range(5   ,						int(math.sqrt(UpperCamelCase__							) + 1							)   ,						6							):
          if number % i == 0 or number % (i + 2) == 0:
               return False
     return True



def    _SCREAMING_SNAKE_CASE    (			UpperCamelCase__						:				int = 1000   ,						UpperCamelCase__						:				int = 1000							):




     """simple docstring"""


     a_    :       Optional[Any]    	=     [0, 0, 0]  # length, a, b
     for a in range((a_limit * -1) + 1   ,						UpperCamelCase__							):
          for b in range(2   ,						UpperCamelCase__							):
               if is_prime(UpperCamelCase__							):
                    a_    :       Dict    	=     0
                    a_    :       Tuple    	=     0
                    while is_prime((n**2) + (a * n) + b							):
                         count += 1
                         n += 1
                    if count > longest[0]:
                         a_    :       Optional[Any]    	=     [count, a, b]
     a_    :       str    	=     longest[1] * longest[2]
     return ans


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






'''simple docstring'''


import colorsys
import io

import cva
import matplotlib as mpl
import matplotlib.colors as mplc
import matplotlib.figure as mplfigure
import numpy as np
import torch
from matplotlib.backends.backend_agg import FigureCanvasAgg

from utils import img_tensorize


lowerCAmelCase_			:     Tuple							    =     1000







class     SCREAMING_SNAKE_CASE						:






      def __init__(   self      :     Union[str, Any]	,	lowercase__      :     Optional[int]	,	lowercase__      :     Optional[int]=1.2	,	lowercase__      :     Tuple="g"	,	lowercase__      :     str=0.5	,	lowercase__      :     List[str]="-"	,	lowercase__      :     Union[str, Any]="test_out.jpg"	,	lowercase__      :     Dict=True	,	lowercase__      :     Optional[int]=False	,	lowercase__      :     str=None	,	lowercase__      :     Union[str, Any]=None	,	lowercase__      :     Tuple=0.7	,	):


           '''simple docstring'''

           if isinstance(lowercase__	,	torch.Tensor					):
                a_    :       Union[str, Any]    	=     img.numpy().astype("""np.uint8"""					)
           if isinstance(lowercase__	,	lowercase__					):
                a_    :       List[Any]    	=     img_tensorize(lowercase__					)
           assert isinstance(lowercase__	,	np.ndarray					)

           a_	,    a_    :       int    	=     img.shape[1], img.shape[0]
           a_    :       str    	=     mplfigure.Figure(frameon=lowercase__					)
           a_    :       Optional[int]    	=     fig.get_dpi()
           a_    :       List[Any]    	=     (width * scale + 1e-2) / dpi
           a_    :       Union[str, Any]    	=     (height * scale + 1e-2) / dpi
           fig.set_size_inches(lowercase__	,	lowercase__					)
           a_    :       Optional[Any]    	=     fig.add_axes([0.0, 0.0, 1.0, 1.0]					)
           ax.axis("""off"""					)
           ax.set_xlim(0.0	,	lowercase__					)
           ax.set_ylim(lowercase__					)

           a_    :       Union[str, Any]    	=     saveas
           a_    :       List[Any]    	=     rgb
           a_    :       Optional[int]    	=     pynb
           a_    :       Any    	=     img
           a_    :       List[Any]    	=     edgecolor
           a_    :       str    	=     0.5
           a_    :       Optional[int]    	=     linestyle
           a_    :       int    	=     int(np.sqrt(min(lowercase__	,	lowercase__					)					) * scale // 3					)
           a_    :       Optional[int]    	=     width
           a_    :       Union[str, Any]    	=     height
           a_    :       List[Any]    	=     scale
           a_    :       Any    	=     fig
           a_    :       List[Any]    	=     ax
           a_    :       Union[str, Any]    	=     pad
           a_    :       List[str]    	=     idaobj
           a_    :       List[Any]    	=     idaattr
           a_    :       Union[str, Any]    	=     FigureCanvasAgg(lowercase__					)






      def        lowercase_	(   self      :     Optional[Any]	,	lowercase__      :     Optional[Any]	,	lowercase__      :     str=None					):


           '''simple docstring'''

           if color is None:
                a_    :       int    	=     self.edgecolor
           ((a_)	,    (a_)	,    (a_)	,    (a_))    :       Union[str, Any]    	=     box
           a_    :       Union[str, Any]    	=     xa - xa
           a_    :       List[Any]    	=     ya - ya
           self.ax.add_patch(
               mpl.patches.Rectangle(
                   (xa, ya)	,	lowercase__	,	lowercase__	,	fill=lowercase__	,	edgecolor=lowercase__	,	linewidth=self.font_size // 3	,	alpha=self.alpha	,	linestyle=self.linestyle	,	)					)






      def        lowercase_	(   self      :     int	,	lowercase__      :     List[Any]	,	lowercase__      :     List[str]=None	,	lowercase__      :     Optional[Any]=None	,	lowercase__      :     List[Any]=None	,	lowercase__      :     Union[str, Any]=None					):


           '''simple docstring'''

           if len(boxes.shape					) > 2:
                a_    :       List[Any]    	=     boxes[0]
           if len(obj_ids.shape					) > 1:
                a_    :       List[Any]    	=     obj_ids[0]
           if len(obj_scores.shape					) > 1:
                a_    :       Optional[int]    	=     obj_scores[0]
           if len(attr_ids.shape					) > 1:
                a_    :       int    	=     attr_ids[0]
           if len(attr_scores.shape					) > 1:
                a_    :       Dict    	=     attr_scores[0]
           if isinstance(lowercase__	,	torch.Tensor					):
                a_    :       Optional[Any]    	=     boxes.numpy()
           if isinstance(lowercase__	,	lowercase__					):
                a_    :       List[Any]    	=     np.array(lowercase__					)
           assert isinstance(lowercase__	,	np.ndarray					)
           a_    :       Optional[int]    	=     np.prod(boxes[:, 2:] - boxes[:, :2]	,	axis=1					)
           a_    :       List[str]    	=     np.argsort(-areas					).tolist()
           a_    :       List[Any]    	=     boxes[sorted_idxs] if boxes is not None else None
           a_    :       List[Any]    	=     obj_ids[sorted_idxs] if obj_ids is not None else None
           a_    :       Any    	=     obj_scores[sorted_idxs] if obj_scores is not None else None
           a_    :       List[Any]    	=     attr_ids[sorted_idxs] if attr_ids is not None else None
           a_    :       str    	=     attr_scores[sorted_idxs] if attr_scores is not None else None

           a_    :       Tuple    	=     [self._random_color(maximum=1					) for _ in range(len(lowercase__					)					)]
           a_    :       List[Any]    	=     [assigned_colors[idx] for idx in sorted_idxs]
           if obj_ids is not None:
                a_    :       Dict    	=     self._create_text_labels_attr(lowercase__	,	lowercase__	,	lowercase__	,	lowercase__					)
                for i in range(len(lowercase__					)					):
                     a_    :       Optional[int]    	=     assigned_colors[i]
                     self.add_box(boxes[i]	,	lowercase__					)
                     self.draw_labels(labels[i]	,	boxes[i]	,	lowercase__					)






      def        lowercase_	(   self      :     Optional[Any]	,	lowercase__      :     Any	,	lowercase__      :     Optional[Any]	,	lowercase__      :     Optional[Any]					):


           '''simple docstring'''

           a_	,    a_	,    a_	,    a_    :       int    	=     box
           a_    :       List[str]    	=     (xa, ya)
           a_    :       Optional[int]    	=     (ya - ya) * (xa - xa)
           a_    :       Optional[Any]    	=     _SMALL_OBJ * self.scale
           if instance_area < small or ya - ya < 40 * self.scale:
                if ya >= self.height - 5:
                     a_    :       Dict    	=     (xa, ya)
                else:
                     a_    :       str    	=     (xa, ya)

           a_    :       List[Any]    	=     (ya - ya) / np.sqrt(self.height * self.width					)
           a_    :       Optional[int]    	=     self._change_color_brightness(lowercase__	,	brightness_factor=0.7					)
           a_    :       List[str]    	=     np.clip((height_ratio - 0.02) / 0.08 + 1	,	1.2	,	2					)
           font_size *= 0.75 * self.font_size

           self.draw_text(
               text=lowercase__	,	position=lowercase__	,	color=lowercase__	,	)






      def        lowercase_	(   self      :     Any	,	lowercase__      :     Optional[int]	,	lowercase__      :     Tuple	,	lowercase__      :     str="g"	,	lowercase__      :     Optional[Any]="left"	,	):


           '''simple docstring'''

           a_    :       List[Any]    	=     0
           a_    :       Tuple    	=     self.font_size
           a_    :       Tuple    	=     np.maximum(list(mplc.to_rgb(lowercase__					)					)	,	0.2					)
           a_    :       List[str]    	=     max(0.8	,	np.max(lowercase__					)					)
           a_    :       str    	=     {
               """facecolor""": """black""",
               """alpha""": self.alpha,
               """pad""": self.pad,
               """edgecolor""": """none""",
           }
           a_	,    a_    :       Any    	=     position
           self.ax.text(
               lowercase__	,	lowercase__	,	lowercase__	,	size=font_size * self.scale	,	family="""sans-serif"""	,	bbox=lowercase__	,	verticalalignment="""top"""	,	horizontalalignment=lowercase__	,	color=lowercase__	,	zorder=10	,	rotation=lowercase__	,	)






      def        lowercase_	(   self      :     List[Any]	,	lowercase__      :     Optional[Any]=None					):


           '''simple docstring'''

           if saveas is None:
                a_    :       Dict    	=     self.saveas
           if saveas.lower().endswith(""".jpg"""					) or saveas.lower().endswith(""".png"""					):
                cva.imwrite(
                    lowercase__	,	self._get_buffer()[:, :, ::-1]	,	)
           else:
                self.fig.savefig(lowercase__					)






      def        lowercase_	(   self      :     List[Any]	,	lowercase__      :     int	,	lowercase__      :     Tuple	,	lowercase__      :     Optional[int]	,	lowercase__      :     Tuple					):


           '''simple docstring'''

           a_    :       Optional[int]    	=     [self.idaobj[i] for i in classes]
           a_    :       Any    	=     [self.idaattr[i] for i in attr_classes]
           a_    :       List[str]    	=     [
               F"{label} {score:.2f} {attr} {attr_score:.2f}"
               for label, score, attr, attr_score in zip(lowercase__	,	lowercase__	,	lowercase__	,	lowercase__					)
           ]
           return labels






      def        lowercase_	(   self      :     str	,	lowercase__      :     Optional[Any]	,	lowercase__      :     Optional[Any]					):


           '''simple docstring'''

           a_    :       Optional[int]    	=     [self.idaobj[i] for i in classes]
           if scores is not None:
                if labels is None:
                     a_    :       int    	=     ["""{:.0f}%""".format(s * 100					) for s in scores]
                else:
                     a_    :       Optional[int]    	=     ["""{} {:.0f}%""".format(lowercase__	,	s * 100					) for li, s in zip(lowercase__	,	lowercase__					)]
           return labels






      def        lowercase_	(   self      :     Dict	,	lowercase__      :     Union[str, Any]=255					):


           '''simple docstring'''

           a_    :       int    	=     np.random.randint(0	,	len(_COLORS					)					)
           a_    :       Tuple    	=     _COLORS[idx] * maximum
           if not self.rgb:
                a_    :       str    	=     ret[::-1]
           return ret






      def        lowercase_	(   self      :     Optional[Any]					):


           '''simple docstring'''

           if not self.pynb:
                a_	,    a_    :       int    	=     self.canvas.print_to_buffer()
                if (width, height) != (self.width, self.height):
                     a_    :       Union[str, Any]    	=     cva.resize(self.img	,	(width, height)					)
                else:
                     a_    :       int    	=     self.img
           else:
                a_    :       Optional[Any]    	=     io.BytesIO()  # works for cairo backend
                self.canvas.print_rgba(lowercase__					)
                a_	,    a_    :       List[Any]    	=     self.width, self.height
                a_    :       Tuple    	=     buf.getvalue()
                a_    :       Tuple    	=     self.img

           a_    :       Optional[Any]    	=     np.frombuffer(lowercase__	,	dtype="""uint8"""					)
           a_    :       Union[str, Any]    	=     buffer.reshape(lowercase__	,	lowercase__	,	4					)
           a_	,    a_    :       Optional[Any]    	=     np.split(lowercase__	,	[3]	,	axis=2					)

           try:
                import numexpr as ne  # fuse them with numexpr

                a_    :       Dict    	=     ne.evaluate("""img * (1 - alpha / 255.0) + rgb * (alpha / 255.0)"""					)
           except ImportError:
                a_    :       List[Any]    	=     alpha.astype("""float32"""					) / 255.0
                a_    :       Optional[int]    	=     img * (1 - alpha) + rgb * alpha

           return visualized_image.astype("""uint8"""					)






      def        lowercase_	(   self      :     Optional[Any]	,	lowercase__      :     Union[str, Any]	,	lowercase__      :     Any					):


           '''simple docstring'''

           assert brightness_factor >= -1.0 and brightness_factor <= 1.0
           a_    :       str    	=     mplc.to_rgb(lowercase__					)
           a_    :       Optional[int]    	=     colorsys.rgb_to_hls(*mplc.to_rgb(lowercase__					)					)
           a_    :       Union[str, Any]    	=     polygon_color[1] + (brightness_factor * polygon_color[1])
           a_    :       int    	=     0.0 if modified_lightness < 0.0 else modified_lightness
           a_    :       Any    	=     1.0 if modified_lightness > 1.0 else modified_lightness
           a_    :       Optional[int]    	=     colorsys.hls_to_rgb(polygon_color[0]	,	lowercase__	,	polygon_color[2]					)
           return modified_color

lowerCAmelCase_			:     List[Any]							    =     (
    np.array(
        [
            0.000,
            0.447,
            0.741,
            0.850,
            0.325,
            0.098,
            0.929,
            0.694,
            0.125,
            0.494,
            0.184,
            0.556,
            0.466,
            0.674,
            0.188,
            0.301,
            0.745,
            0.933,
            0.635,
            0.078,
            0.184,
            0.300,
            0.300,
            0.300,
            0.600,
            0.600,
            0.600,
            1.000,
            0.000,
            0.000,
            1.000,
            0.500,
            0.000,
            0.749,
            0.749,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            1.000,
            0.667,
            0.000,
            1.000,
            0.333,
            0.333,
            0.000,
            0.333,
            0.667,
            0.000,
            0.333,
            1.000,
            0.000,
            0.667,
            0.333,
            0.000,
            0.667,
            0.667,
            0.000,
            0.667,
            1.000,
            0.000,
            1.000,
            0.333,
            0.000,
            1.000,
            0.667,
            0.000,
            1.000,
            1.000,
            0.000,
            0.000,
            0.333,
            0.500,
            0.000,
            0.667,
            0.500,
            0.000,
            1.000,
            0.500,
            0.333,
            0.000,
            0.500,
            0.333,
            0.333,
            0.500,
            0.333,
            0.667,
            0.500,
            0.333,
            1.000,
            0.500,
            0.667,
            0.000,
            0.500,
            0.667,
            0.333,
            0.500,
            0.667,
            0.667,
            0.500,
            0.667,
            1.000,
            0.500,
            1.000,
            0.000,
            0.500,
            1.000,
            0.333,
            0.500,
            1.000,
            0.667,
            0.500,
            1.000,
            1.000,
            0.500,
            0.000,
            0.333,
            1.000,
            0.000,
            0.667,
            1.000,
            0.000,
            1.000,
            1.000,
            0.333,
            0.000,
            1.000,
            0.333,
            0.333,
            1.000,
            0.333,
            0.667,
            1.000,
            0.333,
            1.000,
            1.000,
            0.667,
            0.000,
            1.000,
            0.667,
            0.333,
            1.000,
            0.667,
            0.667,
            1.000,
            0.667,
            1.000,
            1.000,
            1.000,
            0.000,
            1.000,
            1.000,
            0.333,
            1.000,
            1.000,
            0.667,
            1.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.167,
            0.000,
            0.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.167,
            0.000,
            0.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.143,
            0.143,
            0.143,
            0.857,
            0.857,
            0.857,
            1.000,
            1.000,
            1.000,
        ]
    )
    .astype(np.floataa)
    .reshape(-1, 3)
)
