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






def   lowerCamelCase__							(					a      )      ->   Dict:
   return binomial_coefficient(2 * node_count		,		__lowerCamelCase      ) // (node_count + 1)






def   lowerCamelCase__							(					a      )      ->   Optional[Any]:
   if n < 0:
      raise ValueError('''factorial() not defined for negative values'''      )
   _A:  Optional[Any]					=       1
   for i in range(1		,		n + 1      ):
      result *= i
   return result






def   lowerCamelCase__							(					a      )      ->   int:
   return catalan_number(__lowerCamelCase      ) * factorial(__lowerCamelCase      )


if __name__ == "__main__":
   UpperCAmelCase__		:     Tuple     			=      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."""
   )











def 				lowerCamelCase__      (    __lowerCamelCase			:     Tuple  ,		__lowerCamelCase			:     Union[str, Any]		):
  __UpperCAmelCase							:	Tuple           =  [1]
  for i in range(2  ,		__lowerCamelCase		):
    factorials.append(factorials[-1] * i		)
  assert 0 <= k < factorials[-1] * n, "k out of bounds"

  __UpperCAmelCase							:	Optional[Any]           =  []
  __UpperCAmelCase							:	str           =  list(range(__lowerCamelCase		)		)

  # Find permutation
  while factorials:
    __UpperCAmelCase							:	Any           =  factorials.pop()
    __UpperCAmelCase      , __UpperCAmelCase							:	Optional[Any]           =  divmod(__lowerCamelCase  ,		__lowerCamelCase		)
    permutation.append(elements[number]		)
    elements.remove(elements[number]		)
  permutation.append(elements[0]		)

  return permutation


if __name__ == "__main__":
       import doctest

       doctest.testmod()


