





'''simple docstring'''






class 			lowerCamelCase					:


					def __init__(					self	:  Any       ,     __snake_case	:  Any       ):





											'''simple docstring'''





											_snake_case:   List[str]  					=		set_counts
											_snake_case:   Any  					=		max(__A       )
											_snake_case:   Optional[Any]  					=		len(__A       )
											_snake_case:   Any  					=		[1] * num_sets
											_snake_case:   Optional[Any]  					=		list(range(__A       )       )


					def    SCREAMING_SNAKE_CASE_		(					self	:  List[str]       ,     __snake_case	:  str       ,     __snake_case	:  int       ):





											'''simple docstring'''





											_snake_case:   str  					=		self.get_parent(__A       )
											_snake_case:   int  					=		self.get_parent(__A       )

											if src_parent == dst_parent:
																	return False

											if self.ranks[dst_parent] >= self.ranks[src_parent]:
																	self.set_counts[dst_parent] += self.set_counts[src_parent]
																	_snake_case:   Dict  					=		0
																	_snake_case:   Dict  					=		dst_parent
																	if self.ranks[dst_parent] == self.ranks[src_parent]:
																							self.ranks[dst_parent] += 1
																	_snake_case:   int  					=		self.set_counts[dst_parent]
											else:
																	self.set_counts[src_parent] += self.set_counts[dst_parent]
																	_snake_case:   int  					=		0
																	_snake_case:   List[Any]  					=		src_parent
																	_snake_case:   Dict  					=		self.set_counts[src_parent]

											_snake_case:   Optional[int]  					=		max(self.max_set       ,     __A       )
											return True




					def    SCREAMING_SNAKE_CASE_		(					self	:  Optional[int]       ,     __snake_case	:  Tuple       ):





											'''simple docstring'''





											if self.parents[disj_set] == disj_set:
																	return disj_set
											_snake_case:   Tuple  					=		self.get_parent(self.parents[disj_set]       )
											return self.parents[disj_set]












'''simple docstring'''






from __future__ import annotations

A   : Union[str, Any]             =			[-10, -5, 0, 5, 5.1, 11, 13, 21, 3, 4, -21, -10, -5, -1, 0]
A   : Optional[int]             =			[-5, 0, 5, 5.1, 11, 13, 21, -1, 4, -1, -10, -5, -1, 0, -1]





def       lowercase_      (		lowercase__						)   ->list[float]:
						_snake_case:   Tuple  					=		[]
						_snake_case:   List[Any]  					=		len(lowercase__						)

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





def       lowercase_      (		lowercase__						)   ->list[float]:
						_snake_case:   Tuple  					=		[]
						for i, outer in enumerate(lowercase__						):
												_snake_case:   float  					=		-1
												for inner in arr[i + 1 :]:
																		if outer < inner:
																								_snake_case:   List[Any]  					=		inner
																								break
												result.append(lowercase__						)
						return result





def       lowercase_      (		lowercase__						)   ->list[float]:
						_snake_case:   int  					=		len(lowercase__						)
						_snake_case:   list[float]  					=		[]
						_snake_case:   list[float]  					=		[-1] * arr_size

						for index in reversed(range(lowercase__						)						):
												if stack:
																		while stack[-1] <= arr[index]:
																								stack.pop()
																								if not stack:
																														break
												if stack:
																		_snake_case:   Dict  					=		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   : Union[str, Any]             =			(
		    '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),
		)





