'''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(   _A					:				Sequence[float]  ,			_A					:				int  ,			_A					:				int    ):
   '''simple docstring'''
   if not arr:
      return None, None, 0
   if low == high:
      return low, high, arr[low]

   UpperCAmelCase__							:				List[str]   				=  (low + high) // 2
   UpperCAmelCase__							:				int   				=  max_subarray(_A  ,			_A  ,			_A    )
   UpperCAmelCase__							:				List[Any]   				=  max_subarray(_A  ,			mid + 1  ,			_A    )
   UpperCAmelCase__							:				str   				=  max_cross_sum(_A  ,			_A  ,			_A  ,			_A    )
   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(   _A					:				Sequence[float]  ,			_A					:				int  ,			_A					:				int  ,			_A					:				int    ):
   '''simple docstring'''
   UpperCAmelCase__							:				Any   				=  float('''-inf'''    ), -1
   UpperCAmelCase__							:				Optional[int]   				=  float('''-inf'''    ), -1

   UpperCAmelCase__							:				int | float   				=  0
   for i in range(_A  ,			low - 1  ,			-1    ):
      summ += arr[i]
      if summ > left_sum:
         UpperCAmelCase__							:				Union[str, Any]   				=  summ
         UpperCAmelCase__							:				str   				=  i

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

   return max_left, max_right, (left_sum + right_sum)







def __UpperCamelCase(   _A					:				int    ):
   '''simple docstring'''
   UpperCAmelCase__							:				Optional[Any]   				=  [randint(1  ,			_A    ) for _ in range(_A    )]
   UpperCAmelCase__							:				Union[str, Any]   				=  time.time()
   max_subarray(_A  ,			0  ,			input_size - 1    )
   UpperCAmelCase__							:				Tuple   				=  time.time()
   return end - start







def __UpperCamelCase(   ):
   '''simple docstring'''
   UpperCAmelCase__							:				str   				=  [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]
   UpperCAmelCase__							:				Union[str, Any]   				=  [time_max_subarray(_A    ) for input_size in input_sizes]
   print('''No of Inputs\t\tTime Taken'''    )
   for input_size, runtime in zip(_A  ,			_A    ):
      print(_A  ,			'''\t\t'''  ,			_A    )
   plt.plot(_A  ,			_A    )
   plt.xlabel('''Number of Inputs'''    )
   plt.ylabel('''Time taken in seconds'''    )
   plt.show()


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

      testmod()





'''simple docstring'''

from __future__ import annotations

import sys
from collections import deque
from typing import Generic, TypeVar

UpperCamelCase__     :	Tuple				=			TypeVar('T')


class 				_lowercase	(      Generic[T]   ):
      '''simple docstring'''


      UpperCAmelCase_      :      deque[T]  # Cache store of keys
      UpperCAmelCase_      :      set[T]  # References of the keys in cache
      UpperCAmelCase_      :      int      							=   10  # Maximum capacity of cache




      def __init__(				self					,lowerCamelCase_							)			->			None:



         '''simple docstring'''



         UpperCAmelCase__							:				Any   				=  deque()
         UpperCAmelCase__							:				Optional[int]   				=  set()
         if not n:
            UpperCAmelCase__							:				List[Any]   				=  sys.maxsize
         elif n < 0:
            raise ValueError('''n should be an integer greater than 0.'''							)
         else:
            UpperCAmelCase__							:				Any   				=  n




      def 		lowerCAmelCase__					(				self					,lowerCamelCase_							)			->			None:



         '''simple docstring'''



         if x not in self.key_reference:
            if len(self.dq_store							) == LRUCache._MAX_CAPACITY:
               UpperCAmelCase__							:				int   				=  self.dq_store.pop()
               self.key_reference.remove(lowerCamelCase_							)
         else:
            self.dq_store.remove(lowerCamelCase_							)

         self.dq_store.appendleft(lowerCamelCase_							)
         self.key_reference.add(lowerCamelCase_							)




      def 		lowerCAmelCase__					(				self							)			->			None:



         '''simple docstring'''



         for k in self.dq_store:
            print(lowerCamelCase_							)




      def __repr__(				self							)			->			str:



         '''simple docstring'''



         return f'''LRUCache({self._MAX_CAPACITY}) => {list(self.dq_store							)}'''


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  UpperCamelCase__     :	LRUCache[str | int]				=			LRUCache(4)
  lru_cache.refer('A')
  lru_cache.refer(2)
  lru_cache.refer(3)
  lru_cache.refer('A')
  lru_cache.refer(4)
  lru_cache.refer(5)
  lru_cache.display()

  print(lru_cache)
  assert str(lru_cache) == "LRUCache(4) => [5, 4, 'A', 3]"




