


'''simple docstring'''



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				int							)     ->		None:
     __lowerCamelCase   :	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 			UpperCAmelCase__					(	UpperCAmelCase_    :				int							)     ->		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'							)

     __lowerCamelCase   :	list[list[int]]								=		[]
     for current_row_idx in range(UpperCAmelCase_							):
          __lowerCamelCase   :	Dict								=		populate_current_row(UpperCAmelCase_      ,    UpperCAmelCase_							)
          triangle.append(UpperCAmelCase_							)
     return triangle



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



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				list[list[int]]      ,    UpperCAmelCase_    :				list[int]      ,    UpperCAmelCase_    :				int      ,    UpperCAmelCase_    :				int      ,    )     ->		None:
     __lowerCamelCase   :	List[str]								=		triangle[current_row_idx - 1][current_col_idx - 1]
     __lowerCamelCase   :	List[Any]								=		triangle[current_row_idx - 1][current_col_idx]
     __lowerCamelCase   :	Dict								=		above_to_left_elt + above_to_right_elt



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				int							)     ->		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'							)

     __lowerCamelCase   :	list[list[int]]								=		[[1]]

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

     return result



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

     def benchmark_a_function(UpperCAmelCase_    :				Callable      ,    UpperCAmelCase_    :				int							) -> None:
          __lowerCamelCase   :	Dict								=		F'{func.__name__}({value})'
          __lowerCamelCase   :	str								=		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(UpperCAmelCase_      ,    UpperCAmelCase_							)
          print()


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      benchmark()










'''simple docstring'''



A__		:					Optional[int]												=  """ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"""



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				bytes							)     ->		bytes:
     # Make sure the supplied data is a bytes-like object
     if not isinstance(UpperCAmelCase_      ,    UpperCAmelCase_							):
          __lowerCamelCase   :	Dict								=		F'a bytes-like object is required, not \'{data.__class__.__name__}\''
          raise TypeError(UpperCAmelCase_							)

     __lowerCamelCase   :	Optional[int]								=		''.join(bin(UpperCAmelCase_							)[2:].zfill(8							) for byte in data							)

     __lowerCamelCase   :	Any								=		len(UpperCAmelCase_							) % 6 != 0

     if padding_needed:
          # The padding that will be added later
          __lowerCamelCase   :	int								=		B'=' * ((6 - len(UpperCAmelCase_							) % 6) // 2)

          # Append binary_stream with arbitrary binary digits (0's by default) to make its
          # length a multiple of 6.
          binary_stream += "0" * (6 - len(UpperCAmelCase_							) % 6)
     else:
          __lowerCamelCase   :	str								=		B''

     # Encode every 6 binary digits to their corresponding Base64 character
     return (
         "".join(
             B64_CHARSET[int(binary_stream[index : index + 6]      ,    2							)]
             for index in range(0      ,    len(UpperCAmelCase_							)      ,    6							)							).encode()
         + padding
     )



def 			UpperCAmelCase__					(	UpperCAmelCase_    :				str							)     ->		bytes:
     # Make sure encoded_data is either a string or a bytes-like object
     if not isinstance(UpperCAmelCase_      ,    UpperCAmelCase_							) and not isinstance(UpperCAmelCase_      ,    UpperCAmelCase_							):
          __lowerCamelCase   :	Dict								=		(
              'argument should be a bytes-like object or ASCII string, '
              F'not \'{encoded_data.__class__.__name__}\''
          )
          raise TypeError(UpperCAmelCase_							)

     # In case encoded_data is a bytes-like object, make sure it contains only
     # ASCII characters so we convert it to a string object
     if isinstance(UpperCAmelCase_      ,    UpperCAmelCase_							):
          try:
               __lowerCamelCase   :	int								=		encoded_data.decode('utf-8'							)
          except UnicodeDecodeError:
               raise ValueError('base64 encoded data should only contain ASCII characters'							)

     __lowerCamelCase   :	Union[str, Any]								=		encoded_data.count('='							)

     # Check if the encoded string contains non base64 characters
     if padding:
          assert all(
              char in B64_CHARSET for char in encoded_data[:-padding]							), "Invalid base64 character(s) found."
     else:
          assert all(
              char in B64_CHARSET for char in encoded_data							), "Invalid base64 character(s) found."

     # Check the padding
     assert len(UpperCAmelCase_							) % 4 == 0 and padding < 3, "Incorrect padding"

     if padding:
          # Remove padding if there is one
          __lowerCamelCase   :	Any								=		encoded_data[:-padding]

          __lowerCamelCase   :	Optional[Any]								=		''.join(
              bin(B64_CHARSET.index(UpperCAmelCase_							)							)[2:].zfill(6							) for char in encoded_data							)[: -padding * 2]
     else:
          __lowerCamelCase   :	Any								=		''.join(
              bin(B64_CHARSET.index(UpperCAmelCase_							)							)[2:].zfill(6							) for char in encoded_data							)

     __lowerCamelCase   :	str								=		[
         int(binary_stream[index : index + 8]      ,    2							)
         for index in range(0      ,    len(UpperCAmelCase_							)      ,    8							)
     ]

     return bytes(UpperCAmelCase_							)


if __name__ == "__main__":
      import doctest

      doctest.testmod()






