



'''simple docstring'''
from __future__ import annotations






def A__   (					UpperCAmelCase_  ,  UpperCAmelCase_							):
						if b == 0:
												return (1, 0)
						(_UpperCamelCase) :		Dict			    =       extended_euclid(UpperCAmelCase_  ,  a % b							)
						_UpperCamelCase :		List[Any]			    =       a // b
						return (y, x - k * y)






def A__   (					UpperCAmelCase_  ,  UpperCAmelCase_  ,  UpperCAmelCase_  ,  UpperCAmelCase_							):
						(_UpperCamelCase) :		Optional[int]			    =       extended_euclid(UpperCAmelCase_  ,  UpperCAmelCase_							)
						_UpperCamelCase :		Optional[Any]			    =       na * na
						_UpperCamelCase :		Optional[int]			    =       ra * x * na + ra * y * na
						return (n % m + m) % m






def A__   (					UpperCAmelCase_  ,  UpperCAmelCase_							):
						(_UpperCamelCase) :		int			    =       extended_euclid(UpperCAmelCase_  ,  UpperCAmelCase_							)
						if b < 0:
												_UpperCamelCase :		str			    =       (b % n + n) % n
						return b






def A__   (					UpperCAmelCase_  ,  UpperCAmelCase_  ,  UpperCAmelCase_  ,  UpperCAmelCase_							):
						_UpperCamelCase :		List[str]			    =       invert_modulo(UpperCAmelCase_  ,  UpperCAmelCase_							), invert_modulo(UpperCAmelCase_  ,  UpperCAmelCase_							)
						_UpperCamelCase :		Any			    =       na * na
						_UpperCamelCase :		List[str]			    =       ra * x * na + ra * y * na
						return (n % m + m) % m


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

					testmod(name='chinese_remainder_theorem', verbose=True)
					testmod(name='chinese_remainder_theorem2', verbose=True)
					testmod(name='invert_modulo', verbose=True)
					testmod(name='extended_euclid', verbose=True)










'''simple docstring'''
from __future__ import annotations

import numpy as np






def A__   (					UpperCAmelCase_							):
						_UpperCamelCase    ,      _UpperCamelCase :		Optional[int]			    =       np.shape(UpperCAmelCase_							)
						if rows != columns:
												_UpperCamelCase :		Union[str, Any]			    =       (
												    '\'table\' has to be of square shaped array but got a '
												    f'{rows}x{columns} array:\n{table}'
												)
												raise ValueError(UpperCAmelCase_							)

						_UpperCamelCase :		Optional[Any]			    =       np.zeros((rows, columns)							)
						_UpperCamelCase :		Tuple			    =       np.zeros((rows, columns)							)
						for i in range(UpperCAmelCase_							):
												for j in range(UpperCAmelCase_							):
																		_UpperCamelCase :		Optional[Any]			    =       sum(lower[i][k] * upper[k][j] for k in range(UpperCAmelCase_							)							)
																		if upper[j][j] == 0:
																								raise ArithmeticError('No LU decomposition exists'							)
																		_UpperCamelCase :		Optional[Any]			    =       (table[i][j] - total) / upper[j][j]
												_UpperCamelCase :		int			    =       1
												for j in range(UpperCAmelCase_  ,  UpperCAmelCase_							):
																		_UpperCamelCase :		Optional[int]			    =       sum(lower[i][k] * upper[k][j] for k in range(UpperCAmelCase_							)							)
																		_UpperCamelCase :		Tuple			    =       table[i][j] - total
						return lower, upper


if __name__ == "__main__":
					import doctest

					doctest.testmod()


