def mono_comb(n: int, r: int, mod: int = 10**9 + 7) -> int:
    """Binomial coefficient

    python 3.8 or later

    Parameters
    ----------
    n
        n
    r
        r
    mod, optional
        mod, by default 10**9+7

    Returns
    -------
        nCr

    Notes
    -----
    Time complexity

    O(min(r, n - r))

    Examples
    --------
    Examples
    --------
    >>> print(mono_comb(5, 3))
    10
    """
    r = min(r, n - r)
    numer = 1
    denom = 1
    for i in range(r):
        numer *= n - i
        denom *= r - i

        numer %= mod
        denom %= mod

    denom_mod = pow(denom, -1, mod)
    return (numer * denom_mod) % mod