
from __future__ import annotations


def  A			(   lowercase       ,			lowercase       ,			lowercase					)  ->    int:
		'''simple docstring'''

		assert n > 1 and a > 0 and greatest_common_divisor(lowercase       ,			lowercase					) == 1
		((UpperCamelCase)      ,    (UpperCamelCase)      ,    (UpperCamelCase))            =	extended_gcd(lowercase       ,			lowercase					)  # Implemented below
		UpperCamelCase            =	(b * s) % n
		return x


def  A			(   lowercase       ,			lowercase					)  ->    int:
		'''simple docstring'''

		((UpperCamelCase)      ,    (UpperCamelCase))            =	extended_euclid(lowercase       ,			lowercase					)  # Implemented below
		if b < 0:
				UpperCamelCase            =	(b % n + n) % n
		return b


def  A			(   lowercase       ,			lowercase       ,			lowercase					)  ->    int:
		'''simple docstring'''

		UpperCamelCase            =	invert_modulo(lowercase       ,			lowercase					)
		UpperCamelCase            =	(b * s) % n
		return x


def  A			(   lowercase       ,			lowercase					)  ->    tuple[int, int, int]:
		'''simple docstring'''

		assert a >= 0 and b >= 0

		if b == 0:
				UpperCamelCase      ,    UpperCamelCase      ,    UpperCamelCase            =	a, 1, 0
		else:
				((UpperCamelCase)      ,    (UpperCamelCase)      ,    (UpperCamelCase))            =	extended_gcd(lowercase       ,			a % b					)
				UpperCamelCase            =	q
				UpperCamelCase            =	p - q * (a // b)

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

		return (d, x, y)


def  A			(   lowercase       ,			lowercase					)  ->    tuple[int, int]:
		'''simple docstring'''

		if b == 0:
				return (1, 0)
		((UpperCamelCase)      ,    (UpperCamelCase))            =	extended_euclid(lowercase       ,			a % b					)
		UpperCamelCase            =	a // b
		return (y, x - k * y)


def  A			(   lowercase       ,			lowercase					)  ->    int:
		'''simple docstring'''

		if a < b:
				UpperCamelCase      ,    UpperCamelCase            =	b, a

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

		return b


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

					testmod(name="modular_division", verbose=True)
					testmod(name="modular_division2", verbose=True)
					testmod(name="invert_modulo", verbose=True)
					testmod(name="extended_gcd", verbose=True)
					testmod(name="extended_euclid", verbose=True)
					testmod(name="greatest_common_divisor", verbose=True)


def  A			(   lowercase					)  ->    int:
		'''simple docstring'''

		return int(lowercase					) if x - int(lowercase					) >= 0 else int(lowercase					) - 1


if __name__ == "__main__":
					import doctest

					doctest.testmod()
