



from __future__ import annotations

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



def 				snake_case_(_UpperCamelCase					)							->     list[float]:



  """simple docstring"""






  _snake_case						=							[]
  _snake_case						=							len(_UpperCamelCase					)

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



def 				snake_case_(_UpperCamelCase					)							->     list[float]:



  """simple docstring"""






  _snake_case						=							[]
  for i, outer in enumerate(_UpperCamelCase					):
    _snake_case						=							-1
    for inner in arr[i + 1 :]:
      if outer < inner:
        _snake_case						=							inner
        break
    result.append(_UpperCamelCase					)
  return result



def 				snake_case_(_UpperCamelCase					)							->     list[float]:



  """simple docstring"""






  _snake_case						=							len(_UpperCamelCase					)
  _snake_case						=							[]
  _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:
      _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))

 __A      		=     (
     '''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),
 )




import os
import sys
from contextlib import contextmanager


# Windows only
if os.name == "nt":
 import ctypes
 import msvcrt  # noqa



 class   lowercase_   (  ctypes.Structure					):
       # _fields is a specific attr expected by ctypes
       UpperCamelCase_      :		List[Any]										=    [("size", ctypes.c_int), ("visible", ctypes.c_byte)]



def 				snake_case_()							->     int:



  """simple docstring"""






  if os.name == "nt":
    _snake_case						=							CursorInfo()
    _snake_case						=							ctypes.windll.kernelaa.GetStdHandle(-11					)
    ctypes.windll.kernelaa.GetConsoleCursorInfo(_UpperCamelCase			,	ctypes.byref(_UpperCamelCase					)					)
    _snake_case						=							False
    ctypes.windll.kernelaa.SetConsoleCursorInfo(_UpperCamelCase			,	ctypes.byref(_UpperCamelCase					)					)
  elif os.name == "posix":
    sys.stdout.write('''\033[?25l'''					)
    sys.stdout.flush()



def 				snake_case_()							->     Optional[Any]:



  """simple docstring"""






  if os.name == "nt":
    _snake_case						=							CursorInfo()
    _snake_case						=							ctypes.windll.kernelaa.GetStdHandle(-11					)
    ctypes.windll.kernelaa.GetConsoleCursorInfo(_UpperCamelCase			,	ctypes.byref(_UpperCamelCase					)					)
    _snake_case						=							True
    ctypes.windll.kernelaa.SetConsoleCursorInfo(_UpperCamelCase			,	ctypes.byref(_UpperCamelCase					)					)
  elif os.name == "posix":
    sys.stdout.write('''\033[?25h'''					)
    sys.stdout.flush()



@contextmanager
def 				snake_case_()							->     int:



  """simple docstring"""






  try:
    hide_cursor()
    yield
  finally:
    show_cursor()

