


'''simple docstring'''







def _UpperCamelCase       (     __A    )							->		None:


      '''simple docstring'''



      UpperCamelCase__										=				generate_pascal_triangle(__A    )
      for row_idx in range(__A    ):
            # 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       (     __A    )							->		list[list[int]]:


      '''simple docstring'''



      if not isinstance(__A      ,			__A    ):
            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(__A    ):
            UpperCamelCase__										=				populate_current_row(__A      ,			__A    )
            triangle.append(__A    )
      return triangle







def _UpperCamelCase       (     __A      ,			__A    )							->		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      ,			__A    ):
            calculate_current_element(
                __A      ,			__A      ,			__A      ,			__A    )
      return current_row







def _UpperCamelCase       (     __A      ,			__A      ,			__A      ,			__A      ,			)							->		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 _UpperCamelCase       (     __A    )							->		list[list[int]]:


      '''simple docstring'''



      if not isinstance(__A      ,			__A    ):
            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      ,			__A    ):
            UpperCamelCase__										=				[0] + result[-1] + [0]
            UpperCamelCase__										=				row_index + 1
            # Calculate the number of distinct elements in a row
            UpperCamelCase__										=				sum(divmod(__A      ,			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(__A    )

      return result







def _UpperCamelCase       (     )							->		None:


      '''simple docstring'''



      from collections.abc import Callable
      from timeit import timeit

      def benchmark_a_function(__A      ,			__A    ) -> 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(__A      ,			__A    )
            print()


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  benchmark()












"""simple docstring"""




from copy import deepcopy

class  _UpperCAmelCase  :



      '''simple docstring'''

      def __init__(     self					,      snake_case_ = None					,      snake_case_ = None  ):

        """simple docstring"""

        if arr is None and size is not None:
          A_  :       Union[str, Any]										=  size
          A_  :       List[str]										=  [0] * size
        elif arr is not None:
          self.init(snake_case_  )
        else:
          raise ValueError('Either arr or size must be specified'  )

      def 					lowerCamelCase_			(     self					,      snake_case_  ):

        """simple docstring"""

        A_  :       Union[str, Any]										=  len(snake_case_  )
        A_  :       Optional[int]										=  deepcopy(snake_case_  )
        for i in range(1					,      self.size  ):
          A_  :       Optional[Any]										=  self.next_(snake_case_  )
          if j < self.size:
            self.tree[j] += self.tree[i]

      def 					lowerCamelCase_			(     self  ):

        """simple docstring"""

        A_  :       int										=  self.tree[:]
        for i in range(self.size - 1					,      0					,      -1  ):
          A_  :       Optional[int]										=  self.next_(snake_case_  )
          if j < self.size:
            arr[j] -= arr[i]
        return arr

      @staticmethod
      def 					lowerCamelCase_			(     snake_case_  ):

        """simple docstring"""

        return index + (index & (-index))

      @staticmethod
      def 					lowerCamelCase_			(     snake_case_  ):

        """simple docstring"""

        return index - (index & (-index))

      def 					lowerCamelCase_			(     self					,      snake_case_					,      snake_case_  ):

        """simple docstring"""

        if index == 0:
          self.tree[0] += value
          return
        while index < self.size:
          self.tree[index] += value
          A_  :       List[str]										=  self.next_(snake_case_  )

      def 					lowerCamelCase_			(     self					,      snake_case_					,      snake_case_  ):

        """simple docstring"""

        self.add(snake_case_					,      value - self.get(snake_case_  )  )

      def 					lowerCamelCase_			(     self					,      snake_case_  ):

        """simple docstring"""

        if right == 0:
          return 0
        A_  :       Any										=  self.tree[0]
        right -= 1  # make right inclusive
        while right > 0:
          result += self.tree[right]
          A_  :       Tuple										=  self.prev(snake_case_  )
        return result

      def 					lowerCamelCase_			(     self					,      snake_case_					,      snake_case_  ):

        """simple docstring"""

        return self.prefix(snake_case_  ) - self.prefix(snake_case_  )

      def 					lowerCamelCase_			(     self					,      snake_case_  ):

        """simple docstring"""

        return self.query(snake_case_					,      index + 1  )

      def 					lowerCamelCase_			(     self					,      snake_case_  ):

        """simple docstring"""

        value -= self.tree[0]
        if value < 0:
          return -1

        A_  :       List[Any]										=  1  # Largest power of 2 <= size
        while j * 2 < self.size:
          j *= 2

        A_  :       Tuple										=  0

        while j > 0:
          if i + j < self.size and self.tree[i + j] <= value:
            value -= self.tree[i + j]
            i += j
          j //= 2
        return i


if __name__ == "__main__":
   import doctest

   doctest.testmod()