'''simple docstring'''




from typing import List, Optional, TypeVar

from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .info import DatasetInfo
from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _interleave_iterable_datasets
from .splits import NamedSplit
from .utils import logging
from .utils.py_utils import Literal


__SCREAMING_SNAKE_CASE       :     Union[str, Any]     =  logging.get_logger(__name__)


__SCREAMING_SNAKE_CASE       :     Tuple     =  TypeVar("""DatasetType""", Dataset, IterableDataset)

def 	UpperCamelCase_							(					_UpperCAmelCase  :      List[DatasetType]			,	_UpperCAmelCase  :      Optional[List[float]] = None			,	_UpperCAmelCase  :      Optional[int] = None			,	_UpperCAmelCase  :      Optional[DatasetInfo] = None			,	_UpperCAmelCase  :      Optional[NamedSplit] = None			,	_UpperCAmelCase  :      Literal["first_exhausted", "all_exhausted"] = "first_exhausted"			,	)    ->    DatasetType:


       """simple docstring"""







       from .arrow_dataset import Dataset
       from .iterable_dataset import IterableDataset

       if not datasets:
              raise ValueError("Unable to interleave an empty list of datasets."    )
       for i, dataset in enumerate(_UpperCAmelCase    ):
              if not isinstance(_UpperCAmelCase			,	(Dataset, IterableDataset)    ):
                     if isinstance(_UpperCAmelCase			,	(DatasetDict, IterableDatasetDict)    ):
                            if not dataset:
                                   raise ValueError(
                                       F"""Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} """
                                       "is an empty dataset dictionary."    )
                            raise ValueError(
                                F"""Dataset at position {i} has at least one split: {list(_UpperCAmelCase    )}\n"""
                                F"""Please pick one to interleave with the other datasets, for example: dataset['{next(iter(_UpperCAmelCase    )    )}']"""    )
                     raise ValueError(
                         F"""Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(_UpperCAmelCase    ).__name__}."""    )
              if i == 0:
                     _UpperCAmelCase      ,  _UpperCAmelCase     :  Dict							      =    (
                         (Dataset, IterableDataset) if isinstance(_UpperCAmelCase			,	_UpperCAmelCase    ) else (IterableDataset, Dataset)
                     )
              elif not isinstance(_UpperCAmelCase			,	_UpperCAmelCase    ):
                     raise ValueError(
                         F"""Unable to interleave a {dataset_type.__name__} (at position 0) with a {other_type.__name__} (at position {i}). Expected a list of Dataset objects or a list of IterableDataset objects."""    )
       if stopping_strategy not in ["first_exhausted", "all_exhausted"]:
              raise ValueError(F"""{stopping_strategy} is not supported. Please enter a valid stopping_strategy."""    )
       if dataset_type is Dataset:
              return _interleave_map_style_datasets(
                  _UpperCAmelCase			,	_UpperCAmelCase			,	_UpperCAmelCase			,	info=_UpperCAmelCase			,	split=_UpperCAmelCase			,	stopping_strategy=_UpperCAmelCase    )
       else:
              return _interleave_iterable_datasets(
                  _UpperCAmelCase			,	_UpperCAmelCase			,	_UpperCAmelCase			,	info=_UpperCAmelCase			,	split=_UpperCAmelCase			,	stopping_strategy=_UpperCAmelCase    )


def 	UpperCamelCase_							(					_UpperCAmelCase  :      List[DatasetType]			,	_UpperCAmelCase  :      Optional[DatasetInfo] = None			,	_UpperCAmelCase  :      Optional[NamedSplit] = None			,	_UpperCAmelCase  :      int = 0			,	)    ->    DatasetType:


       """simple docstring"""







       if not dsets:
              raise ValueError("Unable to concatenate an empty list of datasets."    )
       for i, dataset in enumerate(_UpperCAmelCase    ):
              if not isinstance(_UpperCAmelCase			,	(Dataset, IterableDataset)    ):
                     if isinstance(_UpperCAmelCase			,	(DatasetDict, IterableDatasetDict)    ):
                            if not dataset:
                                   raise ValueError(
                                       F"""Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} """
                                       "is an empty dataset dictionary."    )
                            raise ValueError(
                                F"""Dataset at position {i} has at least one split: {list(_UpperCAmelCase    )}\n"""
                                F"""Please pick one to interleave with the other datasets, for example: dataset['{next(iter(_UpperCAmelCase    )    )}']"""    )
                     raise ValueError(
                         F"""Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(_UpperCAmelCase    ).__name__}."""    )
              if i == 0:
                     _UpperCAmelCase      ,  _UpperCAmelCase     :  Dict							      =    (
                         (Dataset, IterableDataset) if isinstance(_UpperCAmelCase			,	_UpperCAmelCase    ) else (IterableDataset, Dataset)
                     )
              elif not isinstance(_UpperCAmelCase			,	_UpperCAmelCase    ):
                     raise ValueError(
                         F"""Unable to interleave a {dataset_type.__name__} (at position 0) with a {other_type.__name__} (at position {i}). Expected a list of Dataset objects or a list of IterableDataset objects."""    )
       if dataset_type is Dataset:
              return _concatenate_map_style_datasets(_UpperCAmelCase			,	info=_UpperCAmelCase			,	split=_UpperCAmelCase			,	axis=_UpperCAmelCase    )
       else:
              return _concatenate_iterable_datasets(_UpperCAmelCase			,	info=_UpperCAmelCase			,	split=_UpperCAmelCase			,	axis=_UpperCAmelCase    )


'''simple docstring'''




def 	UpperCamelCase_							(					_UpperCAmelCase  :      int			,	_UpperCAmelCase  :      int    )    ->    int:


       """simple docstring"""







       _UpperCAmelCase     :  List[str]							      =    1  # To kept the Calculated Value
       # Since C(n, k) = C(n, n-k)
       if k > (n - k):
              _UpperCAmelCase     :  Any							      =    n - k
       # Calculate C(n,k)
       for i in range(_UpperCAmelCase    ):
              result *= n - i
              result //= i + 1
       return result

def 	UpperCamelCase_							(					_UpperCAmelCase  :      int    )    ->    int:


       """simple docstring"""







       return binomial_coefficient(2 * node_count			,	_UpperCAmelCase    ) // (node_count + 1)

def 	UpperCamelCase_							(					_UpperCAmelCase  :      int    )    ->    int:


       """simple docstring"""







       if n < 0:
              raise ValueError("factorial() not defined for negative values"    )
       _UpperCAmelCase     :  List[str]							      =    1
       for i in range(1			,	n + 1    ):
              result *= i
       return result

def 	UpperCamelCase_							(					_UpperCAmelCase  :      int    )    ->    int:


       """simple docstring"""







       return catalan_number(_UpperCAmelCase    ) * factorial(_UpperCAmelCase    )


if __name__ == "__main__":
  __SCREAMING_SNAKE_CASE       :     Dict     =  int(input("""Enter the number of nodes: """).strip() or 0)
  if node_count <= 0:
    raise ValueError("""We need some nodes to work with.""")
  print(
      F'Given {node_count} nodes, there are {binary_tree_count(node_count)} '
      F'binary trees and {catalan_number(node_count)} binary search trees.'
  )

