



from __future__ import annotations


def 						_UpperCAmelCase							( snake_case      ,		snake_case      ,		snake_case     ):





					"""simple docstring"""

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


def 						_UpperCAmelCase							( snake_case      ,		snake_case     ):





					"""simple docstring"""

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


def 						_UpperCAmelCase							( snake_case      ,		snake_case      ,		snake_case     ):





					"""simple docstring"""

					_lowerCAmelCase         =       invert_modulo(snake_case      ,		snake_case     )
					_lowerCAmelCase         =       (b * s) % n
					return x


def 						_UpperCAmelCase							( snake_case      ,		snake_case     ):





					"""simple docstring"""

					assert a >= 0 and b >= 0

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


def 						_UpperCAmelCase							( snake_case      ,		snake_case     ):





					"""simple docstring"""

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


def 						_UpperCAmelCase							( snake_case      ,		snake_case     ):





					"""simple docstring"""

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

					while a % b != 0:
										_lowerCAmelCase      ,      _lowerCAmelCase         =       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'''

		barcode //= 10  # exclude the last digit
		UpperCamelCase            =	False
		UpperCamelCase            =	0

		# extract and check each digit
		while barcode != 0:
				UpperCamelCase            =	1 if checker else 3
				s += mult * (barcode % 10)
				barcode //= 10
				UpperCamelCase            =	not checker

		return (10 - (s % 10)) % 10


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

		return len(str(lowercase					)					) == 13 and get_check_digit(lowercase					) == barcode % 10


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

		if str(lowercase					).isalpha():
				UpperCamelCase            =	f'''Barcode \'{barcode}\' has alphabetic characters.'''
				raise ValueError(lowercase					)
		elif int(lowercase					) < 0:
				raise ValueError('The entered barcode has a negative value. Try again.'					)
		else:
				return int(lowercase					)


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					_UpperCAmelCase   :					List[str]    =			get_barcode(input("Barcode: ").strip())

					if is_valid(barcode):
										print(F'''\'{barcode}\' is a valid barcode.''')
					else:
										print(F'''\'{barcode}\' is NOT a valid barcode.''')
