import functools
import operator


def comb(n: int, k: int) -> int:
    """Compute binomial coefficient n choose k"""
    if not 0 <= k <= n:
        return 0

    k = min(k, n - k)
    numerator = functools.reduce(operator.mul, range(n, n - k, -1), 1)
    denominator = functools.reduce(operator.mul, range(1, k + 1), 1)
    return numerator // denominator