






def   snake_case (UpperCAmelCase__  )	->    None:
		UpperCamelCase_: Union[str, Any]   				=    generate_pascal_triangle(UpperCAmelCase__  )
		for row_idx in range(UpperCAmelCase__  ):
				# 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   snake_case (UpperCAmelCase__  )	->    list[list[int]]:

		if not isinstance(UpperCAmelCase__     ,   UpperCAmelCase__  ):
				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_: list[list[int]]   				=    []
		for current_row_idx in range(UpperCAmelCase__  ):
				UpperCamelCase_: str   				=    populate_current_row(UpperCAmelCase__     ,   UpperCAmelCase__  )
				triangle.append(UpperCAmelCase__  )
		return triangle

def   snake_case (UpperCAmelCase__     ,   UpperCAmelCase__  )	->    list[int]:
		UpperCamelCase_: Dict   				=    [-1] * (current_row_idx + 1)
		# first and last elements of current row are equal to 1
		UpperCamelCase_: Optional[Any]   				=    1, 1
		for current_col_idx in range(1     ,   UpperCAmelCase__  ):
				calculate_current_element(
				    UpperCAmelCase__     ,   UpperCAmelCase__     ,   UpperCAmelCase__     ,   UpperCAmelCase__  )
		return current_row

def   snake_case (UpperCAmelCase__     ,   UpperCAmelCase__     ,   UpperCAmelCase__     ,   UpperCAmelCase__     ,   )	->    None:
		UpperCamelCase_: Union[str, Any]   				=    triangle[current_row_idx - 1][current_col_idx - 1]
		UpperCamelCase_: Optional[int]   				=    triangle[current_row_idx - 1][current_col_idx]
		UpperCamelCase_: Tuple   				=    above_to_left_elt + above_to_right_elt

def   snake_case (UpperCAmelCase__  )	->    list[list[int]]:

		if not isinstance(UpperCAmelCase__     ,   UpperCAmelCase__  ):
				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_: list[list[int]]   				=    [[1]]

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

		return result

def   snake_case ()	->    None:
		from collections.abc import Callable
		from timeit import timeit

		def benchmark_a_function(UpperCAmelCase__     ,   UpperCAmelCase__  ) -> None:
				UpperCamelCase_: Tuple   				=    F'''{func.__name__}({value})'''
				UpperCamelCase_: Tuple   				=    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(1_5  ):  # (1, 7, 14):
				for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):
						benchmark_a_function(UpperCAmelCase__     ,   UpperCAmelCase__  )
				print()


if __name__ == "__main__":
			import doctest

			doctest.testmod()
			benchmark()







def   snake_case (UpperCAmelCase__  )	->    int:
  assert isinstance(UpperCAmelCase__     ,   UpperCAmelCase__  ), F'''The input value of [n={number}] is not an integer'''

  if number == 1:
    return 2
  elif number < 1:
    UpperCamelCase_: List[Any]   				=    F'''The input value of [n={number}] has to be > 0'''
    raise ValueError(UpperCAmelCase__  )
  else:
    UpperCamelCase_: str   				=    sylvester(number - 1  )
    UpperCamelCase_: str   				=    num - 1
    UpperCamelCase_: Any   				=    num
    return lower * upper + 1


if __name__ == "__main__":
   print(F'''The 8th number in Sylvester\'s sequence: {sylvester(8)}''')