






from __future__ import annotations

__UpperCAmelCase								=						[-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0]
__UpperCAmelCase								=						[-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1]




def      lowercase__      (     __snake_case    :							list[float]  ):


					'''simple docstring'''


					UpperCAmelCase_    :      List[str]            =						[]
					UpperCAmelCase_    :      List[str]            =						len(__UpperCAmelCase  )

					for i in range(__UpperCAmelCase  ):
										UpperCAmelCase_    :      int            =						-1
										for j in range(i + 1     ,       __UpperCAmelCase  ):
															if arr[i] < arr[j]:
																				UpperCAmelCase_    :      List[Any]            =						arr[j]
																				break
										result.append(__UpperCAmelCase  )
					return result




def      lowercase__      (     __snake_case    :							list[float]  ):


					'''simple docstring'''


					UpperCAmelCase_    :      List[Any]            =						[]
					for i, outer in enumerate(__UpperCAmelCase  ):
										UpperCAmelCase_    :      Tuple            =						-1
										for inner in arr[i + 1 :]:
															if outer < inner:
																				UpperCAmelCase_    :      Optional[int]            =						inner
																				break
										result.append(__UpperCAmelCase  )
					return result




def      lowercase__      (     __snake_case    :							list[float]  ):


					'''simple docstring'''


					UpperCAmelCase_    :      Any            =						len(__UpperCAmelCase  )
					UpperCAmelCase_    :      List[Any]            =						[]
					UpperCAmelCase_    :      Tuple            =						[-1] * arr_size

					for index in reversed(range(__UpperCAmelCase  )  ):
										if stack:
															while stack[-1] <= arr[index]:
																				stack.pop()
																				if not stack:
																									break
										if stack:
															UpperCAmelCase_    :      Any            =						stack[-1]
										stack.append(arr[index]  )
					return result


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

		testmod()
		print(next_greatest_element_slow(arr))
		print(next_greatest_element_fast(arr))
		print(next_greatest_element(arr))

		__UpperCAmelCase								=						(
		    'from __main__ import arr, next_greatest_element_slow, '
		    'next_greatest_element_fast, next_greatest_element'
		)
		print(
		    'next_greatest_element_slow():',
		    timeit('next_greatest_element_slow(arr)', setup=setup),
		)
		print(
		    'next_greatest_element_fast():',
		    timeit('next_greatest_element_fast(arr)', setup=setup),
		)
		print(
		    '     next_greatest_element():',
		    timeit('next_greatest_element(arr)', setup=setup),
		)












from __future__ import annotations

lowerCamelCase__ :   Optional[int]					=							[-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0]
lowerCamelCase__ :   List[Any]					=							[-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1]

def 					UpperCAmelCase_							(      __UpperCAmelCase						:	list[float]							)					-> list[float]:
      SCREAMING_SNAKE_CASE_							=			[]
      SCREAMING_SNAKE_CASE_							=			len(__UpperCAmelCase							)

      for i in range(__UpperCAmelCase							):
            SCREAMING_SNAKE_CASE_							=			-1
            for j in range(i + 1			,			__UpperCAmelCase							):
                  if arr[i] < arr[j]:
                        SCREAMING_SNAKE_CASE_							=			arr[j]
                        break
            result.append(__UpperCAmelCase							)
      return result

def 					UpperCAmelCase_							(      __UpperCAmelCase						:	list[float]							)					-> list[float]:
      SCREAMING_SNAKE_CASE_							=			[]
      for i, outer in enumerate(__UpperCAmelCase							):
            SCREAMING_SNAKE_CASE_							=			-1
            for inner in arr[i + 1 :]:
                  if outer < inner:
                        SCREAMING_SNAKE_CASE_							=			inner
                        break
            result.append(__UpperCAmelCase							)
      return result

def 					UpperCAmelCase_							(      __UpperCAmelCase						:	list[float]							)					-> list[float]:
      SCREAMING_SNAKE_CASE_							=			len(__UpperCAmelCase							)
      SCREAMING_SNAKE_CASE_							=			[]
      SCREAMING_SNAKE_CASE_							=			[-1] * arr_size

      for index in reversed(range(__UpperCAmelCase							)							):
            if stack:
                  while stack[-1] <= arr[index]:
                        stack.pop()
                        if not stack:
                              break
            if stack:
                  SCREAMING_SNAKE_CASE_							=			stack[-1]
            stack.append(arr[index]							)
      return result


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

   testmod()
   print(next_greatest_element_slow(arr))
   print(next_greatest_element_fast(arr))
   print(next_greatest_element(arr))

   lowerCamelCase__ :   List[str]					=							(
       'from __main__ import arr, next_greatest_element_slow, '
       'next_greatest_element_fast, next_greatest_element'
   )
   print(
       'next_greatest_element_slow():',
       timeit('next_greatest_element_slow(arr)', setup=setup),
   )
   print(
       'next_greatest_element_fast():',
       timeit('next_greatest_element_fast(arr)', setup=setup),
   )
   print(
       '     next_greatest_element():',
       timeit('next_greatest_element(arr)', setup=setup),
   )