Buggy python submission (verdict: Time Limit Exceeded):
def pre_cmb(N, MOD):  # cmbの前準備
    FACT = [1, 1]  # 階乗
    INV = [0, 1]  # 各iの逆元
    FACTINV = [1, 1]  # 階乗の逆元

    for i in range(2, N + 1):
        FACT.append((FACT[-1] * i) % MOD)
        INV.append(pow(i, MOD-2, MOD))
        FACTINV.append((FACTINV[-1] * INV[-1]) % MOD)
    PRELIST = FACT, FACTINV
    return PRELIST


def cmb(N, R, MOD, PRELIST):  # nCr(mod p)
    FACT, FACTINV = PRELIST
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    return FACT[N] * FACTINV[R] * FACTINV[N-R] % MOD


n, a, b = map(int, input().split())
mod = 10**9+7
prelist = pre_cmb(n, mod)
exc = cmb(n, a, mod, prelist) + cmb(n, b, mod, prelist)
print((pow(2, n, mod) - exc - 1) % mod)


Fixed submission:

def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

exc = bigcmb(n, a, mod) + bigcmb(n, b, mod)
print((pow(2, n, mod) - exc - 1) % mod)

Buggy python submission (verdict: Time Limit Exceeded):
def pre_cmb(N, MOD):  # cmbの前準備
    FACT = [1, 1]  # 階乗
    INV = [0, 1]  # 各iの逆元
    FACTINV = [1, 1]  # 階乗の逆元

    for i in range(2, N + 1):
        FACT.append((FACT[-1] * i) % MOD)
        INV.append(pow(i, MOD-2, MOD))
        FACTINV.append((FACTINV[-1] * INV[-1]) % MOD)
    PRELIST = FACT, FACTINV
    return PRELIST


def cmb(N, R, MOD, PRELIST):  # nCr(mod p)
    FACT, FACTINV = PRELIST
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    return FACT[N] * FACTINV[R] * FACTINV[N-R] % MOD



n, a, b = map(int, input().split())
mod = 10**9+7
prelist = pre_cmb(n, mod)
ans = pow(2, n, mod) - cmb(n, a, mod, prelist) - cmb(n, b, mod, prelist)
print(ans % mod - 1)


Fixed submission:

def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

exc = bigcmb(n, a, mod) + bigcmb(n, b, mod)
print((pow(2, n, mod) - exc - 1) % mod)

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

cnt=1
for i in range(1,n + 1):
    cnt*=i
    if i == a:
        af = cnt
    elif i == n-a:
        anf = cnt
    elif i == b:
        bf = cnt
    elif i == n-b:
        bnf = cnt
    elif i == n:
        nf=cnt
        break

ans = 2 ** n - (nf//af//anf) - (nf//bf//bnf)-1
print(int(ans % (10**9+7)))


Fixed submission:

def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

exc = bigcmb(n, a, mod) + bigcmb(n, b, mod)
print((pow(2, n, mod) - exc - 1) % mod)

Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

cnt=1
for i in range(n + 1):
    cnt*=i
    if i == a:
        af = cnt
    elif i == n-a:
        anf = cnt
    elif i == b:
        bf = cnt
    elif i == n-b:
        bnf = cnt
    elif i == n:
        nf=cnt
        break

ans = 2 ** n - (nf//af//anf) - (nf//bf//bnf)-1
print(int(ans % (10**9+7)))


Fixed submission:

def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


n, a, b = map(int, input().split())
mod = 10 ** 9 + 7

exc = bigcmb(n, a, mod) + bigcmb(n, b, mod)
print((pow(2, n, mod) - exc - 1) % mod)