



"""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_								=			1000







class  A_     :



						"""simple docstring"""






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

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

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






						def       UpperCAmelCase__	(   self					:Tuple  ,    lowercase_					:Tuple  ,    lowercase_					:Optional[int]=None   )							->     Dict:
												if color is None:
																		UpperCAmelCase			 =					self.edgecolor
												((UpperCAmelCase) ,       (UpperCAmelCase) ,       (UpperCAmelCase) ,       (UpperCAmelCase))			 =					box
												UpperCAmelCase			 =					xa - xa
												UpperCAmelCase			 =					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       UpperCAmelCase__	(   self					:Dict  ,    lowercase_					:Tuple  ,    lowercase_					:Optional[int]=None  ,    lowercase_					:Any=None  ,    lowercase_					:Optional[int]=None  ,    lowercase_					:Optional[int]=None   )							->     int:
												if len(boxes.shape   ) > 2:
																		UpperCAmelCase			 =					boxes[0]
												if len(obj_ids.shape   ) > 1:
																		UpperCAmelCase			 =					obj_ids[0]
												if len(obj_scores.shape   ) > 1:
																		UpperCAmelCase			 =					obj_scores[0]
												if len(attr_ids.shape   ) > 1:
																		UpperCAmelCase			 =					attr_ids[0]
												if len(attr_scores.shape   ) > 1:
																		UpperCAmelCase			 =					attr_scores[0]
												if isinstance(lowercase_  ,    torch.Tensor   ):
																		UpperCAmelCase			 =					boxes.numpy()
												if isinstance(lowercase_  ,    lowercase_   ):
																		UpperCAmelCase			 =					np.array(lowercase_   )
												assert isinstance(lowercase_  ,    np.ndarray   )
												UpperCAmelCase			 =					np.prod(boxes[:, 2:] - boxes[:, :2]  ,    axis=1   )
												UpperCAmelCase			 =					np.argsort(-areas   ).tolist()
												UpperCAmelCase			 =					boxes[sorted_idxs] if boxes is not None else None
												UpperCAmelCase			 =					obj_ids[sorted_idxs] if obj_ids is not None else None
												UpperCAmelCase			 =					obj_scores[sorted_idxs] if obj_scores is not None else None
												UpperCAmelCase			 =					attr_ids[sorted_idxs] if attr_ids is not None else None
												UpperCAmelCase			 =					attr_scores[sorted_idxs] if attr_scores is not None else None

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






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

												UpperCAmelCase			 =					(ya - ya) / np.sqrt(self.height * self.width   )
												UpperCAmelCase			 =					self._change_color_brightness(lowercase_  ,    brightness_factor=0.7   )
												UpperCAmelCase			 =					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       UpperCAmelCase__	(   self					:List[str]  ,    lowercase_					:Optional[int]  ,    lowercase_					:Dict  ,    lowercase_					:List[Any]="g"  ,    lowercase_					:List[Any]="left"  ,    )							->     Any:
												UpperCAmelCase			 =					0
												UpperCAmelCase			 =					self.font_size
												UpperCAmelCase			 =					np.maximum(list(mplc.to_rgb(lowercase_   )   )  ,    0.2   )
												UpperCAmelCase			 =					max(0.8  ,    np.max(lowercase_   )   )
												UpperCAmelCase			 =					{
												    'facecolor': 'black',
												    'alpha': self.alpha,
												    'pad': self.pad,
												    'edgecolor': 'none',
												}
												UpperCAmelCase ,       UpperCAmelCase			 =					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       UpperCAmelCase__	(   self					:Any  ,    lowercase_					:Tuple=None   )							->     Tuple:
												if saveas is None:
																		UpperCAmelCase			 =					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       UpperCAmelCase__	(   self					:Any  ,    lowercase_					:str  ,    lowercase_					:str  ,    lowercase_					:Optional[int]  ,    lowercase_					:Optional[Any]   )							->     Tuple:
												UpperCAmelCase			 =					[self.idaobj[i] for i in classes]
												UpperCAmelCase			 =					[self.idaattr[i] for i in attr_classes]
												UpperCAmelCase			 =					[
												    f"""{label} {score:.2f} {attr} {attr_score:.2f}"""
												    for label, score, attr, attr_score in zip(lowercase_  ,    lowercase_  ,    lowercase_  ,    lowercase_   )
												]
												return labels






						def       UpperCAmelCase__	(   self					:List[Any]  ,    lowercase_					:str  ,    lowercase_					:List[str]   )							->     int:
												UpperCAmelCase			 =					[self.idaobj[i] for i in classes]
												if scores is not None:
																		if labels is None:
																								UpperCAmelCase			 =					['{:.0f}%'.format(s * 1_00   ) for s in scores]
																		else:
																								UpperCAmelCase			 =					['{} {:.0f}%'.format(lowercase_  ,    s * 1_00   ) for li, s in zip(lowercase_  ,    lowercase_   )]
												return labels






						def       UpperCAmelCase__	(   self					:List[str]  ,    lowercase_					:int=2_55   )							->     Any:
												UpperCAmelCase			 =					np.random.randint(0  ,    len(_COLORS   )   )
												UpperCAmelCase			 =					_COLORS[idx] * maximum
												if not self.rgb:
																		UpperCAmelCase			 =					ret[::-1]
												return ret






						def       UpperCAmelCase__	(   self					:Any   )							->     Tuple:
												if not self.pynb:
																		UpperCAmelCase ,       UpperCAmelCase			 =					self.canvas.print_to_buffer()
																		if (width, height) != (self.width, self.height):
																								UpperCAmelCase			 =					cva.resize(self.img  ,    (width, height)   )
																		else:
																								UpperCAmelCase			 =					self.img
												else:
																		UpperCAmelCase			 =					io.BytesIO()  # works for cairo backend
																		self.canvas.print_rgba(lowercase_   )
																		UpperCAmelCase ,       UpperCAmelCase			 =					self.width, self.height
																		UpperCAmelCase			 =					buf.getvalue()
																		UpperCAmelCase			 =					self.img

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

												try:
																		import numexpr as ne  # fuse them with numexpr

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

												return visualized_image.astype('uint8'   )






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


snake_case_								=			(
    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"""






def    A_ ( _lowerCAmelCase  :       str,  _lowerCAmelCase  :       str							):






     """simple docstring"""

     if len(_lowerCAmelCase							) < len(_lowerCAmelCase							):
          return levenshtein_distance(_lowerCAmelCase,  _lowerCAmelCase							)

     if len(_lowerCAmelCase							) == 0:
          return len(_lowerCAmelCase							)

     _a     						=					list(range(len(_lowerCAmelCase							) + 1							)							)

     for i, ca in enumerate(_lowerCAmelCase							):
          _a     						=					[i + 1]

          for j, ca in enumerate(_lowerCAmelCase							):
               # Calculate insertions, deletions and substitutions
               _a     						=					previous_row[j + 1] + 1
               _a     						=					current_row[j] + 1
               _a     						=					previous_row[j] + (ca != ca)

               # Get the minimum to append to the current row
               current_row.append(min(_lowerCAmelCase,  _lowerCAmelCase,  _lowerCAmelCase							)							)

          # Store the previous row
          _a     						=					current_row

     # Returns the last element (distance)
     return previous_row[-1]


if __name__ == "__main__":
   __snake_case												=							input('''Enter the first word:\n''').strip()
   __snake_case												=							input('''Enter the second word:\n''').strip()

   __snake_case												=							levenshtein_distance(first_word, second_word)
   print(f'Levenshtein distance between {first_word} and {second_word} is {result}')