


'''simple docstring'''



from __future__ import annotations

import time
from collections.abc import Sequence
from random import randint

from matplotlib import pyplot as plt



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				Sequence[float]      ,    UpperCAmelCase_    :				int      ,    UpperCAmelCase_    :				int							)     ->		tuple[int | None, int | None, float]:
     if not arr:
          return None, None, 0
     if low == high:
          return low, high, arr[low]

     __lowerCamelCase   :	Any								=		(low + high) // 2
     __lowerCamelCase				,       __lowerCamelCase				,       __lowerCamelCase   :	str								=		max_subarray(UpperCAmelCase_      ,    UpperCAmelCase_      ,    UpperCAmelCase_							)
     __lowerCamelCase				,       __lowerCamelCase				,       __lowerCamelCase   :	int								=		max_subarray(UpperCAmelCase_      ,    mid + 1      ,    UpperCAmelCase_							)
     __lowerCamelCase				,       __lowerCamelCase				,       __lowerCamelCase   :	Optional[int]								=		max_cross_sum(UpperCAmelCase_      ,    UpperCAmelCase_      ,    UpperCAmelCase_      ,    UpperCAmelCase_							)
     if left_sum >= right_sum and left_sum >= cross_sum:
          return left_low, left_high, left_sum
     elif right_sum >= left_sum and right_sum >= cross_sum:
          return right_low, right_high, right_sum
     return cross_left, cross_right, cross_sum



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				Sequence[float]      ,    UpperCAmelCase_    :				int      ,    UpperCAmelCase_    :				int      ,    UpperCAmelCase_    :				int							)     ->		tuple[int, int, float]:
     __lowerCamelCase				,       __lowerCamelCase   :	str								=		float('-inf'							), -1
     __lowerCamelCase				,       __lowerCamelCase   :	Dict								=		float('-inf'							), -1

     __lowerCamelCase   :	int | float								=		0
     for i in range(UpperCAmelCase_      ,    low - 1      ,    -1							):
          summ += arr[i]
          if summ > left_sum:
               __lowerCamelCase   :	Dict								=		summ
               __lowerCamelCase   :	Tuple								=		i

     __lowerCamelCase   :	str								=		0
     for i in range(mid + 1      ,    high + 1							):
          summ += arr[i]
          if summ > right_sum:
               __lowerCamelCase   :	Dict								=		summ
               __lowerCamelCase   :	Tuple								=		i

     return max_left, max_right, (left_sum + right_sum)



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				int							)     ->		float:
     __lowerCamelCase   :	Optional[Any]								=		[randint(1      ,    UpperCAmelCase_							) for _ in range(UpperCAmelCase_							)]
     __lowerCamelCase   :	Dict								=		time.time()
     max_subarray(UpperCAmelCase_      ,    0      ,    input_size - 1							)
     __lowerCamelCase   :	Tuple								=		time.time()
     return end - start



def 			UpperCAmelCase__					(	)     ->		None:
     __lowerCamelCase   :	Any								=		[10, 1_00, 10_00, 1_00_00, 5_00_00, 10_00_00, 20_00_00, 30_00_00, 40_00_00, 50_00_00]
     __lowerCamelCase   :	Any								=		[time_max_subarray(UpperCAmelCase_							) for input_size in input_sizes]
     print('No of Inputs\t\tTime Taken'							)
     for input_size, runtime in zip(UpperCAmelCase_      ,    UpperCAmelCase_							):
          print(UpperCAmelCase_      ,    '\t\t'      ,    UpperCAmelCase_							)
     plt.plot(UpperCAmelCase_      ,    UpperCAmelCase_							)
     plt.xlabel('Number of Inputs'							)
     plt.ylabel('Time taken in seconds'							)
     plt.show()


if __name__ == "__main__":
      from doctest import testmod

      testmod()










'''simple docstring'''



import numpy as np
from cva import destroyAllWindows, imread, imshow, waitKey





class    UpperCAmelCase_  :





    """simple docstring"""






    def __init__(							self			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_			,     SCREAMING_SNAKE_CASE_	)				->     int:
         if dst_width < 0 or dst_height < 0:
              raise ValueError('Destination width/height should be > 0'	)

         __lowerCamelCase   :	Dict								=		img
         __lowerCamelCase   :	Any								=		img.shape[1]
         __lowerCamelCase   :	Optional[int]								=		img.shape[0]
         __lowerCamelCase   :	Dict								=		dst_width
         __lowerCamelCase   :	str								=		dst_height

         __lowerCamelCase   :	Dict								=		self.src_w / self.dst_w
         __lowerCamelCase   :	List[Any]								=		self.src_h / self.dst_h

         __lowerCamelCase   :	Optional[int]								=		(
             np.ones((self.dst_h, self.dst_w, 3)			,     np.uinta	) * 2_55
         )







    def       lowercase_				(							self	)				->     List[Any]:
         for i in range(self.dst_h	):
              for j in range(self.dst_w	):
                   __lowerCamelCase   :	Union[str, Any]								=		self.img[self.get_y(SCREAMING_SNAKE_CASE_	)][self.get_x(SCREAMING_SNAKE_CASE_	)]







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_	)				->     int:
         return int(self.ratio_x * x	)







    def       lowercase_				(							self			,     SCREAMING_SNAKE_CASE_	)				->     int:
         return int(self.ratio_y * y	)


if __name__ == "__main__":
      A__						,					A__		:					Optional[Any]												=  800, 600
      A__		:					List[str]												=  imread("""image_data/lena.jpg""", 1)
      A__		:					List[Any]												=  NearestNeighbour(im, dst_w, dst_h)
      n.process()

      imshow(
          f'''Image resized from: {im.shape[1]}x{im.shape[0]} to {dst_w}x{dst_h}''', n.output
      )
      waitKey(0)
      destroyAllWindows()






