





"""simple docstring"""




from __future__ import annotations





def 						UpperCAmelCase__		(					_UpperCAmelCase			, _UpperCAmelCase			, _UpperCAmelCase ):






  """simple docstring"""





  assert (
      c % greatest_common_divisor(_UpperCAmelCase			, _UpperCAmelCase ) == 0
  )  # greatest_common_divisor(a,b) function implemented below
  ((A_)						,	(A_)						,	(A_))  :	Dict    						=  extended_gcd(_UpperCAmelCase			, _UpperCAmelCase )  # extended_gcd(a,b) function implemented below
  A_  :	List[str]    						=  c / d
  return (r * x, r * y)





def 						UpperCAmelCase__		(					_UpperCAmelCase			, _UpperCAmelCase			, _UpperCAmelCase			, _UpperCAmelCase = 2 ):






  """simple docstring"""





  ((A_)						,	(A_))  :	List[Any]    						=  diophantine(_UpperCAmelCase			, _UpperCAmelCase			, _UpperCAmelCase )  # Initial value
  A_  :	Any    						=  greatest_common_divisor(_UpperCAmelCase			, _UpperCAmelCase )
  A_  :	Union[str, Any]    						=  a // d
  A_  :	Tuple    						=  b // d

  for i in range(_UpperCAmelCase ):
    A_  :	Optional[int]    						=  xa + i * q
    A_  :	List[Any]    						=  ya - i * p
    print(_UpperCAmelCase			, _UpperCAmelCase )





def 						UpperCAmelCase__		(					_UpperCAmelCase			, _UpperCAmelCase ):






  """simple docstring"""





  if a < b:
    A_						,	A_  :	int    						=  b, a

  while a % b != 0:
    A_						,	A_  :	List[Any]    						=  b, a % b

  return b





def 						UpperCAmelCase__		(					_UpperCAmelCase			, _UpperCAmelCase ):






  """simple docstring"""





  assert a >= 0 and b >= 0

  if b == 0:
    A_						,	A_						,	A_  :	Tuple    						=  a, 1, 0
  else:
    ((A_)						,	(A_)						,	(A_))  :	List[Any]    						=  extended_gcd(_UpperCAmelCase			, a % b )
    A_  :	str    						=  q
    A_  :	Optional[Any]    						=  p - q * (a // b)

  assert a % d == 0 and b % d == 0
  assert d == a * x + b * y

  return (d, x, y)


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

   testmod(name='diophantine', verbose=True)
   testmod(name='diophantine_all_soln', verbose=True)
   testmod(name='extended_gcd', verbose=True)
   testmod(name='greatest_common_divisor', verbose=True)






"""simple docstring"""




def 						UpperCAmelCase__		(					_UpperCAmelCase			, _UpperCAmelCase ):






  """simple docstring"""





  A_  :	Any    						=  len(_UpperCAmelCase )
  # Create a stack and push index of fist element to it
  A_  :	List[Any]    						=  []
  st.append(0 )

  # Span value of first element is always 1
  A_  :	List[str]    						=  1

  # Calculate span values for rest of the elements
  for i in range(1			, _UpperCAmelCase ):
    # Pop elements from stack while stack is not
    # empty and top of stack is smaller than price[i]
    while len(_UpperCAmelCase ) > 0 and price[st[0]] <= price[i]:
      st.pop()

    # If stack becomes empty, then price[i] is greater
    # than all elements on left of it, i.e. price[0],
    # price[1], ..price[i-1]. Else the price[i]  is
    # greater than elements after top of stack
    A_  :	Union[str, Any]    						=  i + 1 if len(_UpperCAmelCase ) <= 0 else (i - st[0])

    # Push this element to stack
    st.append(_UpperCAmelCase )





def 						UpperCAmelCase__		(					_UpperCAmelCase			, _UpperCAmelCase ):






  """simple docstring"""





  for i in range(0			, _UpperCAmelCase ):
    print(arr[i]			, end=' ' )


# Driver program to test above function
lowerCamelCase_					:						List[Any]      = [10, 4, 5, 90, 1_20, 80]
lowerCamelCase_					:						Optional[Any]      = [0 for i in range(len(price) + 1)]

# Fill the span values in array S[]
calculation_span(price, S)





print_array(S, len(price))