import copy
import os

import cva
import numpy as np
from matplotlib import pyplot as plt






class      __lowercase					:

						def __init__(	self				:      int   )							->		int:


									'''simple docstring'''

									lowercase							=		''''''
									lowercase							=		''''''
									lowercase							=		[]
									lowercase							=		0
									lowercase							=		2_56
									lowercase							=		0
									lowercase							=		0
									lowercase							=		0
									lowercase							=		0

						def        __a		(	self				:      int							,							__lowerCamelCase				:      Optional[int]   )							->		List[str]:


									'''simple docstring'''

									lowercase							=		cva.imread(__lowerCamelCase							,							0   )
									lowercase							=		copy.deepcopy(self.img   )
									lowercase		,lowercase		,lowercase							=		plt.hist(self.img.ravel()							,							2_56							,							[0, 2_56]							,							label='''x'''   )
									lowercase							=		np.sum(__lowerCamelCase   )
									for i in range(len(__lowerCamelCase   )   ):
												lowercase							=		x[i] / self.k
												self.sk += prk
												lowercase							=		(self.L - 1) * self.sk
												if self.rem != 0:
															lowercase							=		int(last % last   )
												lowercase							=		int(last + 1 if self.rem >= 0.5 else last   )
												self.last_list.append(__lowerCamelCase   )
												lowercase							=		int(np.ma.count(self.img   ) / self.img[1].size   )
												lowercase							=		self.img[1].size
									for i in range(self.number_of_cols   ):
												for j in range(self.number_of_rows   ):
															lowercase							=		self.img[j][i]
															if num != self.last_list[num]:
																		lowercase							=		self.last_list[num]
									cva.imwrite('''output_data/output.jpg'''							,							self.img   )

						def        __a		(	self				:      Any   )							->		str:


									'''simple docstring'''

									plt.hist(self.img.ravel()							,							2_56							,							[0, 2_56]   )



						def        __a		(	self				:      Union[str, Any]   )							->		str:


									'''simple docstring'''

									cva.imshow('''Output-Image'''							,							self.img   )
									cva.imshow('''Input-Image'''							,							self.original_image   )
									cva.waitKey(50_00   )
									cva.destroyAllWindows()


if __name__ == "__main__":
						A_      =      os.path.join(os.path.basename(__file__), "image_data/input.jpg")
						A_      =      ConstantStretch()
						stretcher.stretch(file_path)
						stretcher.plot_histogram()
						stretcher.show_image()






from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt






def        __UpperCAmelCase    (       UpperCAmelCase       )->       bool:



			"""simple docstring"""







			lowercase							=		int(number**0.5       )
			return number == sq * sq






def        __UpperCAmelCase    (       UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase       )->       tuple[int, int]:



			"""simple docstring"""







			lowercase							=		x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
			lowercase							=		x_den * y_den * z_den
			lowercase							=		gcd(UpperCAmelCase,		UpperCAmelCase       )
			top //= hcf
			bottom //= hcf
			return top, bottom






def        __UpperCAmelCase    (       UpperCAmelCase = 35       )->       int:



			"""simple docstring"""







			lowercase							=		set()
			lowercase							=		42
			lowercase							=		Fraction(0       )
			lowercase							=		42

			for x_num in range(1,		order + 1       ):
						for x_den in range(x_num + 1,		order + 1       ):
									for y_num in range(1,		order + 1       ):
												for y_den in range(y_num + 1,		order + 1       ):
															# n=1
															lowercase							=		x_num * y_den + x_den * y_num
															lowercase							=		x_den * y_den
															lowercase							=		gcd(UpperCAmelCase,		UpperCAmelCase       )
															z_num //= hcf
															z_den //= hcf
															if 0 < z_num < z_den <= order:
																		lowercase							=		add_three(
																		    UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase       )
																		unique_s.add(UpperCAmelCase       )

															# n=2
															lowercase							=		(
															    x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
															)
															lowercase							=		x_den * x_den * y_den * y_den
															if is_sq(UpperCAmelCase       ) and is_sq(UpperCAmelCase       ):
																		lowercase							=		int(sqrt(UpperCAmelCase       )       )
																		lowercase							=		int(sqrt(UpperCAmelCase       )       )
																		lowercase							=		gcd(UpperCAmelCase,		UpperCAmelCase       )
																		z_num //= hcf
																		z_den //= hcf
																		if 0 < z_num < z_den <= order:
																					lowercase							=		add_three(
																					    UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase       )
																					unique_s.add(UpperCAmelCase       )

                    # n=-1
															lowercase							=		x_num * y_num
															lowercase							=		x_den * y_num + x_num * y_den
															lowercase							=		gcd(UpperCAmelCase,		UpperCAmelCase       )
															z_num //= hcf
															z_den //= hcf
															if 0 < z_num < z_den <= order:
																		lowercase							=		add_three(
																		    UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase       )
																		unique_s.add(UpperCAmelCase       )

															# n=2
															lowercase							=		x_num * x_num * y_num * y_num
															lowercase							=		(
															    x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
															)
															if is_sq(UpperCAmelCase       ) and is_sq(UpperCAmelCase       ):
																		lowercase							=		int(sqrt(UpperCAmelCase       )       )
																		lowercase							=		int(sqrt(UpperCAmelCase       )       )
																		lowercase							=		gcd(UpperCAmelCase,		UpperCAmelCase       )
																		z_num //= hcf
																		z_den //= hcf
																		if 0 < z_num < z_den <= order:
																					lowercase							=		add_three(
																					    UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase,		UpperCAmelCase       )
																					unique_s.add(UpperCAmelCase       )

			for num, den in unique_s:
						total += Fraction(UpperCAmelCase,		UpperCAmelCase       )

			return total.denominator + total.numerator


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





