



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


UpperCAmelCase__  =			1000







class      __lowerCAmelCase       :



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



						"""simple docstring"""






						if isinstance(A					,						torch.Tensor):
									_UpperCAmelCase									=  img.numpy().astype('np.uint8')
						if isinstance(A					,						A):
									_UpperCAmelCase									=  img_tensorize(A)
						assert isinstance(A					,						np.ndarray)

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

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



			def        _lowerCamelCase			(		self  :    List[str]					,						A  :    Optional[Any]					,						A  :    Tuple=None)  ->       Optional[int]:



						"""simple docstring"""






						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)					,						A					,						A					,						fill=A					,						edgecolor=A					,						linewidth=self.font_size // 3					,						alpha=self.alpha					,						linestyle=self.linestyle					,						))



			def        _lowerCamelCase			(		self  :    Union[str, Any]					,						A  :    Tuple					,						A  :    Tuple=None					,						A  :    Optional[int]=None					,						A  :    Any=None					,						A  :    List[Any]=None)  ->       int:



						"""simple docstring"""






						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(A					,						torch.Tensor):
									_UpperCAmelCase									=  boxes.numpy()
						if isinstance(A					,						A):
									_UpperCAmelCase									=  np.array(A)
						assert isinstance(A					,						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(A))]
						_UpperCAmelCase									=  [assigned_colors[idx] for idx in sorted_idxs]
						if obj_ids is not None:
									_UpperCAmelCase									=  self._create_text_labels_attr(A					,						A					,						A					,						A)
									for i in range(len(A)):
												_UpperCAmelCase									=  assigned_colors[i]
												self.add_box(boxes[i]					,						A)
												self.draw_labels(labels[i]					,						boxes[i]					,						A)



			def        _lowerCamelCase			(		self  :    Dict					,						A  :    int					,						A  :    int					,						A  :    List[str])  ->       Tuple:



						"""simple docstring"""






						_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(A					,						brightness_factor=0.7)
						_UpperCAmelCase									=  np.clip((height_ratio - 0.0_2) / 0.0_8 + 1					,						1.2					,						2)
						font_size *= 0.7_5 * self.font_size

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



			def        _lowerCamelCase			(		self  :    List[Any]					,						A  :    Optional[int]					,						A  :    Tuple					,						A  :    Union[str, Any]="g"					,						A  :    Union[str, Any]="left"					,						)  ->       Tuple:



						"""simple docstring"""






						_UpperCAmelCase									=  0
						_UpperCAmelCase									=  self.font_size
						_UpperCAmelCase									=  np.maximum(list(mplc.to_rgb(A))					,						0.2)
						_UpperCAmelCase									=  max(0.8					,						np.max(A))
						_UpperCAmelCase									=  {
						    'facecolor': 'black',
						    'alpha': self.alpha,
						    'pad': self.pad,
						    'edgecolor': 'none',
						}
						_UpperCAmelCase			,	_UpperCAmelCase									=  position
						self.ax.text(
						    A					,						A					,						A					,						size=font_size * self.scale					,						family='sans-serif'					,						bbox=A					,						verticalalignment='top'					,						horizontalalignment=A					,						color=A					,						zorder=10					,						rotation=A					,						)



			def        _lowerCamelCase			(		self  :    Any					,						A  :    Optional[Any]=None)  ->       List[str]:



						"""simple docstring"""






						if saveas is None:
									_UpperCAmelCase									=  self.saveas
						if saveas.lower().endswith('.jpg') or saveas.lower().endswith('.png'):
									cva.imwrite(
									    A					,						self._get_buffer()[:, :, ::-1]					,						)
						else:
									self.fig.savefig(A)



			def        _lowerCamelCase			(		self  :    str					,						A  :    Tuple					,						A  :    Any					,						A  :    Tuple					,						A  :    Optional[Any])  ->       Optional[Any]:



						"""simple docstring"""






						_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(A					,						A					,						A					,						A)
						]
						return labels



			def        _lowerCamelCase			(		self  :    List[Any]					,						A  :    List[Any]					,						A  :    int)  ->       Optional[int]:



						"""simple docstring"""






						_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(A					,						s * 1_00) for li, s in zip(A					,						A)]
						return labels



			def        _lowerCamelCase			(		self  :    str					,						A  :    Dict=2_55)  ->       List[str]:



						"""simple docstring"""






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



			def        _lowerCamelCase			(		self  :    Any)  ->       Any:



						"""simple docstring"""






						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(A)
									_UpperCAmelCase			,	_UpperCAmelCase									=  self.width, self.height
									_UpperCAmelCase									=  buf.getvalue()
									_UpperCAmelCase									=  self.img

						_UpperCAmelCase									=  np.frombuffer(A					,						dtype='uint8')
						_UpperCAmelCase									=  buffer.reshape(A					,						A					,						4)
						_UpperCAmelCase			,	_UpperCAmelCase									=  np.split(A					,						[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') / 2_5_5.0
									_UpperCAmelCase									=  img * (1 - alpha) + rgb * alpha

						return visualized_image.astype('uint8')



			def        _lowerCamelCase			(		self  :    Dict					,						A  :    Optional[int]					,						A  :    Optional[Any])  ->       List[Any]:



						"""simple docstring"""






						assert brightness_factor >= -1.0 and brightness_factor <= 1.0
						_UpperCAmelCase									=  mplc.to_rgb(A)
						_UpperCAmelCase									=  colorsys.rgb_to_hls(*mplc.to_rgb(A))
						_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]					,						A					,						polygon_color[2])
						return modified_color





UpperCAmelCase__  =			(
    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)
)





def 				A      (	_UpperCAmelCase							:  List[Any]       )							->					List[Any]:







			'''simple docstring'''
			_UpperCAmelCase									=  len(_UpperCAmelCase       )
			for _ in range(
			    0				,  int(((no_of_elements - 1) / 2) + 1       )       ):  # we don't need to traverse to end of list as
						for j in range(0				,  no_of_elements - 1       ):
									if (
									    lst[j + 1] < lst[j]
									):  # applying bubble sort algorithm from left to right (or forwards)
												_UpperCAmelCase									=  lst[j + 1]
												_UpperCAmelCase									=  lst[j]
												_UpperCAmelCase									=  temp
									if (
									    lst[no_of_elements - 1 - j] < lst[no_of_elements - 2 - j]
									):  # applying bubble sort algorithm from right to left (or backwards)
												_UpperCAmelCase									=  lst[no_of_elements - 1 - j]
												_UpperCAmelCase									=  lst[no_of_elements - 2 - j]
												_UpperCAmelCase									=  temp
			return lst


if __name__ == "__main__":
							print("enter the list to be sorted")
							UpperCAmelCase__  =			[int(x) for x in input().split()]  # inputing elements of the list in one line
							UpperCAmelCase__  =			double_sort(lst)
							print("the sorted list is")
							print(sorted_lst)
