



"""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


__snake_case	:				Optional[int]  					=			1_000

class       UpperCamelCase  :





     """simple docstring"""






     def __init__(					self :							str	,      _lowerCamelCase :							Dict	,      _lowerCamelCase :							List[str]=1.2	,      _lowerCamelCase :							Union[str, Any]="g"	,      _lowerCamelCase :							Dict=0.5	,      _lowerCamelCase :							Union[str, Any]="-"	,      _lowerCamelCase :							Optional[int]="test_out.jpg"	,      _lowerCamelCase :							Dict=True	,      _lowerCamelCase :							Optional[Any]=False	,      _lowerCamelCase :							List[str]=None	,      _lowerCamelCase :							Tuple=None	,      _lowerCamelCase :							int=0.7	,      ):
          if isinstance(_lowerCamelCase	,      torch.Tensor ):
               A__				=   img.numpy().astype('''np.uint8''' )
          if isinstance(_lowerCamelCase	,      _lowerCamelCase ):
               A__				=   img_tensorize(_lowerCamelCase )
          assert isinstance(_lowerCamelCase	,      np.ndarray )

          A__	,     A__				=   img.shape[1], img.shape[0]
          A__				=   mplfigure.Figure(frameon=_lowerCamelCase )
          A__				=   fig.get_dpi()
          A__				=   (width * scale + 1E-2) / dpi
          A__				=   (height * scale + 1E-2) / dpi
          fig.set_size_inches(_lowerCamelCase	,      _lowerCamelCase )
          A__				=   fig.add_axes([0.0, 0.0, 1.0, 1.0] )
          ax.axis('''off''' )
          ax.set_xlim(0.0	,      _lowerCamelCase )
          ax.set_ylim(_lowerCamelCase )

          A__				=   saveas
          A__				=   rgb
          A__				=   pynb
          A__				=   img
          A__				=   edgecolor
          A__				=   0.5
          A__				=   linestyle
          A__				=   int(np.sqrt(min(_lowerCamelCase	,      _lowerCamelCase ) ) * scale // 3 )
          A__				=   width
          A__				=   height
          A__				=   scale
          A__				=   fig
          A__				=   ax
          A__				=   pad
          A__				=   idaobj
          A__				=   idaattr
          A__				=   FigureCanvasAgg(_lowerCamelCase )





     def 						A__  (					self :							Optional[Any]	,      _lowerCamelCase :							Optional[Any]	,      _lowerCamelCase :							Optional[int]=None ):
          if color is None:
               A__				=   self.edgecolor
          ((A__)	,     (A__)	,     (A__)	,     (A__))				=   box
          A__				=   xa - xa
          A__				=   ya - ya
          self.ax.add_patch(
              mpl.patches.Rectangle(
                  (xa, ya)	,      _lowerCamelCase	,      _lowerCamelCase	,      fill=_lowerCamelCase	,      edgecolor=_lowerCamelCase	,      linewidth=self.font_size // 3	,      alpha=self.alpha	,      linestyle=self.linestyle	,      ) )





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

          A__				=   [self._random_color(maximum=1 ) for _ in range(len(_lowerCamelCase ) )]
          A__				=   [assigned_colors[idx] for idx in sorted_idxs]
          if obj_ids is not None:
               A__				=   self._create_text_labels_attr(_lowerCamelCase	,      _lowerCamelCase	,      _lowerCamelCase	,      _lowerCamelCase )
               for i in range(len(_lowerCamelCase ) ):
                    A__				=   assigned_colors[i]
                    self.add_box(boxes[i]	,      _lowerCamelCase )
                    self.draw_labels(labels[i]	,      boxes[i]	,      _lowerCamelCase )





     def 						A__  (					self :							Optional[Any]	,      _lowerCamelCase :							Any	,      _lowerCamelCase :							int	,      _lowerCamelCase :							int ):
          A__	,     A__	,     A__	,     A__				=   box
          A__				=   (xa, ya)
          A__				=   (ya - ya) * (xa - xa)
          A__				=   _SMALL_OBJ * self.scale
          if instance_area < small or ya - ya < 4_0 * self.scale:
               if ya >= self.height - 5:
                    A__				=   (xa, ya)
               else:
                    A__				=   (xa, ya)

          A__				=   (ya - ya) / np.sqrt(self.height * self.width )
          A__				=   self._change_color_brightness(_lowerCamelCase	,      brightness_factor=0.7 )
          A__				=   np.clip((height_ratio - 0.02) / 0.08 + 1	,      1.2	,      2 )
          font_size *= 0.75 * self.font_size

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





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





     def 						A__  (					self :							List[str]	,      _lowerCamelCase :							int=None ):
          if saveas is None:
               A__				=   self.saveas
          if saveas.lower().endswith('''.jpg''' ) or saveas.lower().endswith('''.png''' ):
               cva.imwrite(
                   _lowerCamelCase	,      self._get_buffer()[:, :, ::-1]	,      )
          else:
               self.fig.savefig(_lowerCamelCase )





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





     def 						A__  (					self :							Any	,      _lowerCamelCase :							str	,      _lowerCamelCase :							int ):
          A__				=   [self.idaobj[i] for i in classes]
          if scores is not None:
               if labels is None:
                    A__				=   ['''{:.0f}%'''.format(s * 1_0_0 ) for s in scores]
               else:
                    A__				=   ['''{} {:.0f}%'''.format(_lowerCamelCase	,      s * 1_0_0 ) for li, s in zip(_lowerCamelCase	,      _lowerCamelCase )]
          return labels





     def 						A__  (					self :							List[Any]	,      _lowerCamelCase :							str=2_5_5 ):
          A__				=   np.random.randint(0	,      len(_COLORS ) )
          A__				=   _COLORS[idx] * maximum
          if not self.rgb:
               A__				=   ret[::-1]
          return ret





     def 						A__  (					self :							Any ):
          if not self.pynb:
               A__	,     A__				=   self.canvas.print_to_buffer()
               if (width, height) != (self.width, self.height):
                    A__				=   cva.resize(self.img	,      (width, height) )
               else:
                    A__				=   self.img
          else:
               A__				=   io.BytesIO()  # works for cairo backend
               self.canvas.print_rgba(_lowerCamelCase )
               A__	,     A__				=   self.width, self.height
               A__				=   buf.getvalue()
               A__				=   self.img

          A__				=   np.frombuffer(_lowerCamelCase	,      dtype='''uint8''' )
          A__				=   buffer.reshape(_lowerCamelCase	,      _lowerCamelCase	,      4 )
          A__	,     A__				=   np.split(_lowerCamelCase	,      [3]	,      axis=2 )

          try:
               import numexpr as ne  # fuse them with numexpr

               A__				=   ne.evaluate('''img * (1 - alpha / 255.0) + rgb * (alpha / 255.0)''' )
          except ImportError:
               A__				=   alpha.astype('''float32''' ) / 255.0
               A__				=   img * (1 - alpha) + rgb * alpha

          return visualized_image.astype('''uint8''' )





     def 						A__  (					self :							Tuple	,      _lowerCamelCase :							int	,      _lowerCamelCase :							str ):
          assert brightness_factor >= -1.0 and brightness_factor <= 1.0
          A__				=   mplc.to_rgb(_lowerCamelCase )
          A__				=   colorsys.rgb_to_hls(*mplc.to_rgb(_lowerCamelCase ) )
          A__				=   polygon_color[1] + (brightness_factor * polygon_color[1])
          A__				=   0.0 if modified_lightness < 0.0 else modified_lightness
          A__				=   1.0 if modified_lightness > 1.0 else modified_lightness
          A__				=   colorsys.hls_to_rgb(polygon_color[0]	,      _lowerCamelCase	,      polygon_color[2] )
          return modified_color


__snake_case	:				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)
)








"""simple docstring"""







from math import factorial



def   a_	(			__a		,							__a      ):
     return factorial(__a      ) / (factorial(__a      ) * factorial(n - r      ))



def   a_	(			):
     A__				=   0

     for i in range(1		,							101      ):
          for j in range(1		,							i + 1      ):
               if combinations(__a		,							__a      ) > 1e6:
                    total += 1
     return total


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



