





def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							int    ):
		SCREAMING_SNAKE_CASE__			=      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 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							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"""    )

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






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






def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							list[list[int]]					,   UpperCamelCase__:							list[int]					,   UpperCamelCase__:							int					,   UpperCamelCase__:							int					,   ):
		SCREAMING_SNAKE_CASE__			=      triangle[current_row_idx - 1][current_col_idx - 1]
		SCREAMING_SNAKE_CASE__			=      triangle[current_row_idx - 1][current_col_idx]
		SCREAMING_SNAKE_CASE__			=      above_to_left_elt + above_to_right_elt






def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							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"""    )

		SCREAMING_SNAKE_CASE__			=      [[1]]

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

		return result






def 				SCREAMING_SNAKE_CASE__							(       ):
		from collections.abc import Callable
		from timeit import timeit

		def benchmark_a_function(UpperCamelCase__:							Callable					,   UpperCamelCase__:							int    ) -> None:
				SCREAMING_SNAKE_CASE__			=      f'''{func.__name__}({value})'''
				SCREAMING_SNAKE_CASE__			=      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()






import os
from pathlib import Path
from unittest.mock import patch

import pytest
import zstandard as zstd

from datasets.download.download_config import DownloadConfig
from datasets.utils.file_utils import (
    OfflineModeIsEnabled,
    cached_path,
    fsspec_get,
    fsspec_head,
    ftp_get,
    ftp_head,
    get_from_cache,
    http_get,
    http_head,
)


_lowerCamelCase   				=			'\\n    Text data.\n    Second line of data.'

_lowerCamelCase   				=			'file'






@pytest.fixture(scope="""session"""    )
def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							Any    ):
		SCREAMING_SNAKE_CASE__			=      tmp_path_factory.mktemp("""data"""    ) / (FILE_PATH + """.zstd""")
		SCREAMING_SNAKE_CASE__			=      bytes(UpperCamelCase__					,   """utf-8"""    )
		with zstd.open(UpperCamelCase__					,   """wb"""    ) as f:
				f.write(UpperCamelCase__    )
		return path






@pytest.fixture
def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							List[str]    ):
		with open(os.path.join(tmpfs.local_root_dir					,   UpperCamelCase__    )					,   """w"""    ) as f:
				f.write(UpperCamelCase__    )
		return FILE_PATH






@pytest.mark.parametrize("""compression_format"""					,   ["""gzip""", """xz""", """zstd"""]    )
def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							int					,   UpperCamelCase__:							Dict					,   UpperCamelCase__:							int					,   UpperCamelCase__:							str					,   UpperCamelCase__:							Optional[int]					,   UpperCamelCase__:							Optional[Any]    ):
		SCREAMING_SNAKE_CASE__			=      {"""gzip""": gz_file, """xz""": xz_file, """zstd""": zstd_path}
		SCREAMING_SNAKE_CASE__			=      input_paths[compression_format]
		SCREAMING_SNAKE_CASE__			=      tmp_path / """cache"""
		SCREAMING_SNAKE_CASE__			=      DownloadConfig(cache_dir=UpperCamelCase__					,   extract_compressed_file=UpperCamelCase__    )
		SCREAMING_SNAKE_CASE__			=      cached_path(UpperCamelCase__					,   download_config=UpperCamelCase__    )
		with open(UpperCamelCase__    ) as f:
				SCREAMING_SNAKE_CASE__			=      f.read()
		with open(UpperCamelCase__    ) as f:
				SCREAMING_SNAKE_CASE__			=      f.read()
		assert extracted_file_content == expected_file_content






@pytest.mark.parametrize("""default_extracted"""					,   [True, False]    )
@pytest.mark.parametrize("""default_cache_dir"""					,   [True, False]    )
def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							Tuple					,   UpperCamelCase__:							List[str]					,   UpperCamelCase__:							Optional[int]					,   UpperCamelCase__:							Any					,   UpperCamelCase__:							Union[str, Any]    ):
		SCREAMING_SNAKE_CASE__			=      """custom_cache"""
		SCREAMING_SNAKE_CASE__			=      """custom_extracted_dir"""
		SCREAMING_SNAKE_CASE__			=      tmp_path / """custom_extracted_path"""
		if default_extracted:
				SCREAMING_SNAKE_CASE__			=      ("""downloads""" if default_cache_dir else custom_cache_dir, """extracted""")
		else:
				monkeypatch.setattr("""datasets.config.EXTRACTED_DATASETS_DIR"""					,   UpperCamelCase__    )
				monkeypatch.setattr("""datasets.config.EXTRACTED_DATASETS_PATH"""					,   str(UpperCamelCase__    )    )
				SCREAMING_SNAKE_CASE__			=      custom_extracted_path.parts[-2:] if default_cache_dir else (custom_cache_dir, custom_extracted_dir)

		SCREAMING_SNAKE_CASE__			=      xz_file
		SCREAMING_SNAKE_CASE__			=      (
		    DownloadConfig(extract_compressed_file=UpperCamelCase__    )
		    if default_cache_dir
		    else DownloadConfig(cache_dir=tmp_path / custom_cache_dir					,   extract_compressed_file=UpperCamelCase__    )
		)
		SCREAMING_SNAKE_CASE__			=      cached_path(UpperCamelCase__					,   download_config=UpperCamelCase__    )
		assert Path(UpperCamelCase__    ).parent.parts[-2:] == expected






def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							Optional[int]    ):
		# absolute path
		SCREAMING_SNAKE_CASE__			=      str(Path(UpperCamelCase__    ).resolve()    )
		assert cached_path(UpperCamelCase__    ) == text_file
		# relative path
		SCREAMING_SNAKE_CASE__			=      str(Path(UpperCamelCase__    ).resolve().relative_to(Path(os.getcwd()    )    )    )
		assert cached_path(UpperCamelCase__    ) == text_file






def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							List[str]    ):
		# absolute path
		SCREAMING_SNAKE_CASE__			=      str(tmp_path.resolve() / """__missing_file__.txt"""    )
		with pytest.raises(UpperCamelCase__    ):
				cached_path(UpperCamelCase__    )
		# relative path
		SCREAMING_SNAKE_CASE__			=      """./__missing_file__.txt"""
		with pytest.raises(UpperCamelCase__    ):
				cached_path(UpperCamelCase__    )






def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							List[str]    ):
		SCREAMING_SNAKE_CASE__			=      get_from_cache(f'''tmp://{tmpfs_file}'''    )
		with open(UpperCamelCase__    ) as f:
				SCREAMING_SNAKE_CASE__			=      f.read()
		assert output_file_content == FILE_CONTENT






@patch("""datasets.config.HF_DATASETS_OFFLINE"""					,   UpperCamelCase__    )
def 				SCREAMING_SNAKE_CASE__							(       ):
		with pytest.raises(UpperCamelCase__    ):
				cached_path("""https://huggingface.co"""    )






@patch("""datasets.config.HF_DATASETS_OFFLINE"""					,   UpperCamelCase__    )
def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							Optional[Any]    ):
		SCREAMING_SNAKE_CASE__			=      tmp_path_factory.mktemp("""data"""    ) / """file.html"""
		with pytest.raises(UpperCamelCase__    ):
				http_get("""https://huggingface.co"""					,   temp_file=UpperCamelCase__    )
		with pytest.raises(UpperCamelCase__    ):
				http_head("""https://huggingface.co"""    )






@patch("""datasets.config.HF_DATASETS_OFFLINE"""					,   UpperCamelCase__    )
def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							List[Any]    ):
		SCREAMING_SNAKE_CASE__			=      tmp_path_factory.mktemp("""data"""    ) / """file.html"""
		with pytest.raises(UpperCamelCase__    ):
				ftp_get("""ftp://huggingface.co"""					,   temp_file=UpperCamelCase__    )
		with pytest.raises(UpperCamelCase__    ):
				ftp_head("""ftp://huggingface.co"""    )






@patch("""datasets.config.HF_DATASETS_OFFLINE"""					,   UpperCamelCase__    )
def 				SCREAMING_SNAKE_CASE__							(       UpperCamelCase__:							int    ):
		SCREAMING_SNAKE_CASE__			=      tmp_path_factory.mktemp("""data"""    ) / """file.html"""
		with pytest.raises(UpperCamelCase__    ):
				fsspec_get("""s3://huggingface.co"""					,   temp_file=UpperCamelCase__    )
		with pytest.raises(UpperCamelCase__    ):
				fsspec_head("""s3://huggingface.co"""    )