
from __future__ import annotations



def 	_a  (					__SCREAMING_SNAKE_CASE					:  str		,				__SCREAMING_SNAKE_CASE					:  Optional[int]		,				__SCREAMING_SNAKE_CASE					:  int    ):






  """simple docstring"""




  assert (
      c % greatest_common_divisor(__SCREAMING_SNAKE_CASE		,				__SCREAMING_SNAKE_CASE    ) == 0
  )  # greatest_common_divisor(a,b) function implemented below
  ((_lowerCAmelCase)	,       (_lowerCAmelCase)	,       (_lowerCAmelCase))						=		extended_gcd(__SCREAMING_SNAKE_CASE		,				__SCREAMING_SNAKE_CASE    )  # extended_gcd(a,b) function implemented below
  _lowerCAmelCase						=		c / d
  return (r * x, r * y)



def 	_a  (					__SCREAMING_SNAKE_CASE					:  Union[str, Any]		,				__SCREAMING_SNAKE_CASE					:  Optional[Any]		,				__SCREAMING_SNAKE_CASE					:  Union[str, Any]		,				__SCREAMING_SNAKE_CASE					:  Optional[Any] = 2    ):






  """simple docstring"""




  ((_lowerCAmelCase)	,       (_lowerCAmelCase))						=		diophantine(__SCREAMING_SNAKE_CASE		,				__SCREAMING_SNAKE_CASE		,				__SCREAMING_SNAKE_CASE    )  # Initial value
  _lowerCAmelCase						=		greatest_common_divisor(__SCREAMING_SNAKE_CASE		,				__SCREAMING_SNAKE_CASE    )
  _lowerCAmelCase						=		a // d
  _lowerCAmelCase						=		b // d

  for i in range(__SCREAMING_SNAKE_CASE    ):
    _lowerCAmelCase						=		xa + i * q
    _lowerCAmelCase						=		ya - i * p
    print(__SCREAMING_SNAKE_CASE		,				__SCREAMING_SNAKE_CASE    )



def 	_a  (					__SCREAMING_SNAKE_CASE					:  Optional[int]		,				__SCREAMING_SNAKE_CASE					:  Dict    ):






  """simple docstring"""




  if a < b:
    _lowerCAmelCase	,       _lowerCAmelCase						=		b, a

  while a % b != 0:
    _lowerCAmelCase	,       _lowerCAmelCase						=		b, a % b

  return b



def 	_a  (					__SCREAMING_SNAKE_CASE					:  Union[str, Any]		,				__SCREAMING_SNAKE_CASE					:  Dict    ):






  """simple docstring"""




  assert a >= 0 and b >= 0

  if b == 0:
    _lowerCAmelCase	,       _lowerCAmelCase	,       _lowerCAmelCase						=		a, 1, 0
  else:
    ((_lowerCAmelCase)	,       (_lowerCAmelCase)	,       (_lowerCAmelCase))						=		extended_gcd(__SCREAMING_SNAKE_CASE		,				a % b    )
    _lowerCAmelCase						=		q
    _lowerCAmelCase						=		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'''

from __future__ import annotations

import random
from collections.abc import Iterable
from typing import Any, Generic, TypeVar

_UpperCAmelCase					:			Any				     =					TypeVar("""T""", bound=bool)


class    a__					(			Generic[T]   ):







				"""simple docstring"""



				def __init__(self							,      __lowercase		):
										__lowerCAmelCase											=					value
										__lowerCAmelCase											=					None
										__lowerCAmelCase											=					None




				@property
				def        _snake_case	(self		):
										return self._value




				@staticmethod
				def        _snake_case	(__lowercase							,      __lowercase		):
										if not roota:
																return roota

										if not roota:
																return roota

										if roota.value > roota.value:
																__lowerCAmelCase							,       __lowerCAmelCase											=					roota, roota

										if random.choice([True, False]		):
																__lowerCAmelCase							,       __lowerCAmelCase											=					roota.right, roota.left

										__lowerCAmelCase											=					RandomizedHeapNode.merge(roota.left							,      __lowercase		)

										return roota


class    a__					(			Generic[T]   ):







				"""simple docstring"""



				def __init__(self							,      __lowercase = ()		):
										__lowerCAmelCase											=					None

										if data:
																for item in data:
																						self.insert(__lowercase		)




				def        _snake_case	(self							,      __lowercase		):
										__lowerCAmelCase											=					RandomizedHeapNode.merge(self._root							,      RandomizedHeapNode(__lowercase		)		)




				def        _snake_case	(self		):
										__lowerCAmelCase											=					self.top()

										if self._root is None:
																return None

										__lowerCAmelCase											=					RandomizedHeapNode.merge(self._root.left							,      self._root.right		)

										return result




				def        _snake_case	(self		):
										if not self._root:
																raise IndexError('''Can\'t get top element for the empty heap.'''		)
										return self._root.value




				def        _snake_case	(self		):
										__lowerCAmelCase											=					None




				def        _snake_case	(self		):
										__lowerCAmelCase											=					[]
										while self:
																result.append(self.pop()		)

										return result




				def __bool__(self		):
										return self._root is not None


if __name__ == "__main__":
	import doctest

	doctest.testmod()

