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

		UpperCamelCase          =					generate_pascal_triangle(lowercase			)
		for row_idx in range(lowercase			):
				# Print left spaces
				for _ in range(num_rows - row_idx - 1			):
						print(end=' '			)
				# Print row values
				for col_idx in range(row_idx + 1			):
						if col_idx != row_idx:
								print(triangle[row_idx][col_idx]   ,	end=' '			)
						else:
								print(triangle[row_idx][col_idx]   ,	end=''			)
				print()


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

		if not isinstance(lowercase   ,	lowercase			):
				raise TypeError('The input value of \'num_rows\' should be \'int\''			)

		if num_rows == 0:
				return []
		elif num_rows < 0:
				raise ValueError(
				    'The input value of \'num_rows\' should be greater than or equal to 0'			)

		UpperCamelCase          =					[]
		for current_row_idx in range(lowercase			):
				UpperCamelCase          =					populate_current_row(lowercase   ,	lowercase			)
				triangle.append(lowercase			)
		return triangle


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

		UpperCamelCase          =					[-1] * (current_row_idx + 1)
		# first and last elements of current row are equal to 1
		UpperCamelCase     ,  UpperCamelCase          =					1, 1
		for current_col_idx in range(1   ,	lowercase			):
				calculate_current_element(
				    lowercase   ,	lowercase   ,	lowercase   ,	lowercase			)
		return current_row


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

		UpperCamelCase          =					triangle[current_row_idx - 1][current_col_idx - 1]
		UpperCamelCase          =					triangle[current_row_idx - 1][current_col_idx]
		UpperCamelCase          =					above_to_left_elt + above_to_right_elt


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

		if not isinstance(lowercase   ,	lowercase			):
				raise TypeError('The input value of \'num_rows\' should be \'int\''			)

		if num_rows == 0:
				return []
		elif num_rows < 0:
				raise ValueError(
				    'The input value of \'num_rows\' should be greater than or equal to 0'			)

		UpperCamelCase          =					[[1]]

		for row_index in range(1   ,	lowercase			):
				UpperCamelCase          =					[0] + result[-1] + [0]
				UpperCamelCase          =					row_index + 1
				# Calculate the number of distinct elements in a row
				UpperCamelCase          =					sum(divmod(lowercase   ,	2			)			)
				UpperCamelCase          =					[
				    temp_row[i - 1] + temp_row[i] for i in range(1   ,	distinct_elements + 1			)
				]
				UpperCamelCase          =					row_first_half[: (row_index + 1) // 2]
				row_second_half.reverse()
				UpperCamelCase          =					row_first_half + row_second_half
				result.append(lowercase			)

		return result


def 				A	( )       ->  None:
		'''simple docstring'''

		from collections.abc import Callable
		from timeit import timeit

		def benchmark_a_function(lowercase   ,	lowercase			) -> None:
				UpperCamelCase          =					f'''{func.__name__}({value})'''
				UpperCamelCase          =					timeit(f'''__main__.{call}'''   ,	setup='import __main__'			)
				# print(f"{call:38} = {func(value)} -- {timing:.4f} seconds")
				print(f'''{call:38} -- {timing:.4f} seconds'''			)

		for value in range(15			):  # (1, 7, 14):
				for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):
						benchmark_a_function(lowercase   ,	lowercase			)
				print()


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					benchmark()


from __future__ import annotations


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   ,	lowercase   ,	lowercase			)       ->  int:
		'''simple docstring'''

		((UpperCamelCase)     ,  (UpperCamelCase))          =					extended_euclid(lowercase   ,	lowercase			)
		UpperCamelCase          =					na * na
		UpperCamelCase          =					ra * x * na + ra * y * na
		return (n % m + m) % m


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

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


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

		UpperCamelCase     ,  UpperCamelCase          =					invert_modulo(lowercase   ,	lowercase			), invert_modulo(lowercase   ,	lowercase			)
		UpperCamelCase          =					na * na
		UpperCamelCase          =					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)
