def binomial(n, k):
    """
    Computes n chooses k
    :param n: number of items to choose from
    :param k: number of items chosen
    :return: n chooses k
    """
    if 2 * k > n:
        return binomial(n, n - k)
    if k < 0 or k > n:
        return 0
    r = 1
    for i in range(1, k + 1):
        r = (r * (n - i + 1)) // i
    return r