Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

import copy

pp = p[:]
qq = q[:]
rr = r[:]

count = 0
another_count = 0

check_r = []
check_g = []
# 赤く塗り替える
# 赤いりんごX
for i in range(X):
    max_red = 0
    if max(p)>=max(r):
        max_red = max(p)
        p.remove(max_red)
    else:
        max_red = max(r)
        check_r.append(max_red)
        r.remove(max_red)

    count += max_red


# 緑のりんごY
for i in range(Y):
    max_green = 0
    if max(q)>=max(r):
        max_green = max(q)
        q.remove(max_green)
    else:
        max_green = max(r)
        r.remove(max_green)
    count += max_green

#
# # 緑に塗り替える
# # 緑のりんごY
# for i in range(Y):
#     max_green = 0
#     if max(qq)>=max(rr):
#         max_green = max(qq)
#         qq.remove(max_green)
#     else:
#         max_green = max(rr)
#
#         rr.remove(max_green)
#
#     another_count += max_green
#
#
# # 赤いりんごX
# for i in range(X):
#     max_red = 0
#     if max(pp)>=max(rr):
#         max_red = max(pp)
#         pp.remove(max_red)
#     else:
#         max_red = max(rr)
#         check_g.append(max_red)
#         rr.remove(max_red)
#     another_count += max_red

print(count)
# print(another_count)


Fixed submission:
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p_sort = sorted(p, reverse=True)
q_sort = sorted(q, reverse=True)
r_sort = sorted(r, reverse=True)

del p_sort[X:]
del q_sort[Y:]

total_list = p_sort + q_sort + r_sort
total_list_sort = sorted(total_list, reverse=True)
del total_list_sort[(X+Y):]
print(sum(total_list_sort))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
check = [0]*N

for k in range(N):
    check[A[k]-1] += 1

for k in range(N):
    list = []
    list = check[:]
    list[A[k]-1] -= 1
    ans = 0
    for l in list:
        if l>=2:
            ans += l*(l-1)//2
    print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

import collections
c= collections.Counter(A)

counter = 0
for j in c.keys():
    if c[j]>=2:
        counter += c[j]*(c[j]-1)/2


for i in A:
    c[i]
    print(int(counter-c[i]+1))
Buggy python submission (verdict: Time Limit Exceeded):
A, B, M = map(int, input().split())
a_price = list(map(int, input().split()))
b_price = list(map(int, input().split()))
coupon = [list(map(int, input().split())) for i in range(M)]
min = a_price[0] + b_price[0]
for i in a_price:
    for j in b_price:
        if min > i+j:
            min = i+j

for cpn in coupon:
    idx_a = cpn[0]-1
    idx_b = cpn[1]-1
    total = a_price[idx_a] + b_price[idx_b] - cpn[2]
    if min > total:
        min = total

print(min)


Fixed submission:
A, B, M = map(int, input().split())
a_price = list(map(int, input().split()))
b_price = list(map(int, input().split()))
coupon = [list(map(int, input().split())) for i in range(M)]



min = min(a_price) + min(b_price)


for cpn in coupon:
    idx_a = cpn[0]-1
    idx_b = cpn[1]-1
    total = a_price[idx_a] + b_price[idx_b] - cpn[2]
    if min > total:
        min = total

print(min)
Buggy python submission (verdict: Runtime Error):

N, A,B = map(int, input().split())
str = []
for j in range(N//(A+B)+1):
    for i in range(A):
        if i==N+1:
            break
        str.append('b')

    for i in range(B):
        if i==N+1:
            break
        str.append('r')
print(str)
count = 0
for k in range(N):
    if str[k] == 'b':
        count+=1
print(count)


Fixed submission:
s = input()
if s[0]=='A' and s[1]=='A' and s[2]=='A':
    print("No")
elif s[0]=='B' and s[1]=='B' and s[2]=='B':
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())


condition = [list(map(str, input().split())) for i in range(Q)]

front = True

for i in condition:

    if i[0] == '1':
        front = not front

    elif i[0] == '2':
        if i[1] == '1':
            if front:
                S = i[2] + S
            else:
                S = S + i[2]
        elif i[1] == '2':
            if front:
                S = S + i[2]
            else:
                S = i[2] + S

if not front:
    S = ''.join(list(reversed(S)))

print(S)


Fixed submission:
from collections import deque
d = deque()

S = input()
Q = int(input())
d.extend(S)




front = True

for i in range(Q):
    inp = input().split()
    if inp[0] == '1':
        front = not front
    else:
        F = int(inp[1])
        C = inp[2]
        if F == 1:
            if front:
                d.appendleft(C)
            else:
                d.append(C)
        elif F == 2:
            if front:
                d.append(C)
            else:
                d.appendleft(C)

if not front:
    d.reverse()

d_list = list(d)
str = "".join(d_list)

print(str)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())


condition = [list(map(str, input().split())) for i in range(Q)]

for i in condition:
    
    if i[0] == '1':
        S = ''.join(list(reversed(S)))
    elif i[0] == '2':
        if i[1] == '1':
            S = i[2] + S
        elif i[1] == '2':
            S = S + i[2]
print(S)


Fixed submission:
from collections import deque
d = deque()

S = input()
Q = int(input())
d.extend(S)




front = True

for i in range(Q):
    inp = input().split()
    if inp[0] == '1':
        front = not front
    else:
        F = int(inp[1])
        C = inp[2]
        if F == 1:
            if front:
                d.appendleft(C)
            else:
                d.append(C)
        elif F == 2:
            if front:
                d.append(C)
            else:
                d.appendleft(C)

if not front:
    d.reverse()

d_list = list(d)
str = "".join(d_list)

print(str)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())


condition = [list(map(str, input().split())) for i in range(Q)]

for i in range(Q):
    if condition[i][0] == '1':
        S = ''.join(list(reversed(S)))
    elif condition[i][0] == '2':
        if condition[i][1] == '1':
            S = condition[i][2] + S
        elif condition[i][1] == '2':
            S = S + condition[i][2]

print(S)


Fixed submission:
from collections import deque
d = deque()

S = input()
Q = int(input())
d.extend(S)




front = True

for i in range(Q):
    inp = input().split()
    if inp[0] == '1':
        front = not front
    else:
        F = int(inp[1])
        C = inp[2]
        if F == 1:
            if front:
                d.appendleft(C)
            else:
                d.append(C)
        elif F == 2:
            if front:
                d.append(C)
            else:
                d.appendleft(C)

if not front:
    d.reverse()

d_list = list(d)
str = "".join(d_list)

print(str)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
S=[]
C=[]
for i in range(M):
    s,c = map(int,input().split())
    S.append(s)
    C.append(c)

ans = 0
C_check = []
S_check = []
for i in range(M):
    j = (N-S[i])
    if S[i] in S_check:
        index = S_check.index(S[i])
        if C[i]!=C[index]:
            ans = '-1'
            break
        continue
    if S[i] < N:
        if S[i]==1 and C[i]==0:
            ans = '-1'
            break

    ans += 10**j*C[i]
    S_check.append(S[i])

if not 1 in S_check:
    ans += 10**(N-1)





print(ans)


Fixed submission:
N,M = map(int,input().split())
S=[]
C=[]
for i in range(M):
    s,c = map(int,input().split())
    S.append(s)
    C.append(c)
not_ans=0
ans = 0
C_check = []
S_check = []
for i in range(M):
    j = (N-S[i])
    if S[i] in S_check:
        index = S_check.index(S[i])
        if C[i]!=C[index]:
            not_ans = '-1'
            break
        continue
    if S[i] < N:
        if S[i]==1 and C[i]==0:
            not_ans = '-1'
            break
    if N < S[i]:
        not_ans = '-1'

    ans += 10**j*C[i]
    S_check.append(S[i])

if not 1 in S_check:
    ans += 10**(N-1)

if N==1 and M==0:
    ans = 0




if not_ans=='-1':
    print(not_ans)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n , k = map(int, input().split())
A = list(map(int, input().split()))

combi = list(itertools.combinations(A,2))
combi_multi = [a*b for a,b in combi]
combi_multi = sorted(combi_multi)

print(combi_multi[k-1])


Fixed submission:
import numpy as np

N, K = map(int, input().split())
A = np.sort(np.array(input().split(),np.int64))
z = A[A == 0]
p = A[A > 0]
n = A[A < 0]



def check(x):
    # x以下の数がK個以上ある時、Trueを返す
    count = 0 #最後に２で割る
    if x >= 0:
        count += len(z) * N
    count += (np.searchsorted(A, x//p, side='right')).sum()
    count += (N - np.searchsorted(A, (-x-1)//(-n), side='right')).sum()
    count -= np.count_nonzero(A * A <= x) #ペアなので自分自身は駄目
    assert count % 2 == 0
    count //= 2
    return count >= K

left = - 10 ** 19 # NG
right = 10 ** 19 # OK
while right > left + 1:
    mid = (left+right) // 2
    if check(mid):
        right = mid
    else:
        left = mid

print(right)
Buggy python submission (verdict: Runtime Error):
import math
X,Y = map(int,input().split())

n = 2*Y/3 - X/3
m = 2*X/3 - Y/3


def comb(n, r):
    return (math.factorial(n) // (math.factorial(n - r) * math.factorial(r))) % (10**9+7)



if (X+Y)%3 != 0:
    print(0)
else:
    if n<0 or m<0:
        print(0)
    else:
        print(comb(n+m,n))


Fixed submission:
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
 
 
def main():
    X, Y = map(int, input().split())
 
    if (X + Y) % 3 or X > Y*2 or Y > X*2:
        return 0
 
    n = (X + Y) // 3
    r = Y - n
    return(combination(n, r))
 
 
print(main())
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

ans = 1 / sum(1 / a for a in A)
print(ans)



Fixed submission:
a = int(input())
s = input()

if a>=3200:
    print(s)
else:
    print('red')
Buggy python submission (verdict: Runtime Error):

k, x = map(int, input().split())
for i in range(x-k+1 , x+k):
    print(i+' ', end='')


Fixed submission:
k, x = map(int, input().split())
for i in range(x-k+1 , x+k):
    print(str(i)+' ', end='')
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):

        for z in range(k+1):
            if s == x+y+z:
                ans += 1
print(ans)


Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        if (s-x-y) >= 0 and (s-x-y) <= k:
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    d = dict()
    count = 0
    for no in a:
        d[no] = set()
    for i in range(n):
        no = a[i]
        pos = i+1
        # print(d)
        # print("> pos: "+str(pos))
        if no < pos:
            for j in range(no+1,pos,1):
                # print(">> j: "+str(j))
                if d.get(j-no) is not None and len(d.get(j-no)) > 0:
                    if pos - j in d.get(j-no):
                        count += 1
        d[no].add(pos)
    # print(d)
    print(count)






Fixed submission:
if __name__ == '__main__':
    n = int(input())
    a = [int(i) for i in input().split()]
    d = dict()
    count = 0
    ar = [(a[i]+i+1) for i in range(n)]
    br = [(i+1-a[i]) for i in range(n)]
    for i in range(n):
        if d.get(ar[i]) is not None:
            d[ar[i]] += 1
        else:
            d[ar[i]] = 1
    c = dict()
    for i in range(n):
        if c.get(br[i]) is not None:
            c[br[i]] += 1
        else:
            c[br[i]] = 1
    count = 0
    for no in c.keys():
        if d.get(no) is not None:
            count += (c[no]*d[no])
    
    print(count)
Buggy python submission (verdict: Runtime Error):

list = [0]*Q
res = 0


def solve():

    N, M, Q = map(int, input().split())
    e = [list(map(int, input().split())) for i in range(Q)]

    def dfs(x, y):
        global list, res
        if x == N:
            tmp = 0
            for a, b, c, d in e:
                if list[b-1]-list[a-1] == c:
                    tmp += d
            res = max(res, tmp)
            return

        for i in range(y, M+1):
            w[x] = i
            dfs(x+1, i)

    dfs(0, 1)
    print(res)


if __name__ == "__main__":
    solve()


Fixed submission:

lis = []
res = 0


def solve():

    N, M, Q = map(int, input().split())
    e = [list(map(int, input().split())) for i in range(Q)]
    global lis
    lis = [0]*N

    def dfs(x, y):
        global lis, res
        if x == N:
            tmp = 0
            for a, b, c, d in e:
                if lis[b-1]-lis[a-1] == c:
                    tmp += d
            res = max(res, tmp)
            return

        for i in range(y, M+1):
            lis[x] = i
            dfs(x+1, i)

    dfs(0, 1)
    print(res)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):


anslist = []


def solve():

    S = input()

    ans = 0
    for i in range(len(S)-3):
        for j in range(i, len(S)-3):
            if int(S[i:j+4]) % 2019 == 0:
                ans += 1
                i = j+4

    print(ans)


if __name__ == "__main__":
    solve()


Fixed submission:


def solve():

    s = input()
    mod = 2019
    remains = [0]*mod

    ans = 0
    now = 0
    remains[0] = 1
    for i, val in enumerate(s[::-1]):
        now += int(val) * pow(10, i, mod)
        now %= mod
        ans += remains[now]
        remains[now] += 1

    print(ans)


if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):


anslist = []


def solve():

    S = input()

    ans = 0
    for i in range(len(S)-3):
        for j in range(i, len(S)-3):
            if int(S[i:j+4]) % 2019 == 0:
                ans += 1

    print(ans)


if __name__ == "__main__":
    solve()


Fixed submission:


def solve():

    s = input()
    mod = 2019
    remains = [0]*mod

    ans = 0
    now = 0
    remains[0] = 1
    for i, val in enumerate(s[::-1]):
        now += int(val) * pow(10, i, mod)
        now %= mod
        ans += remains[now]
        remains[now] += 1

    print(ans)


if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Runtime Error):


anslist = []


def solve():

    S = input()

    def dfs(s, start, end):
        global anslist
        if end == len(s)+1:
            return

        if int(s[start:end]) % 2019 == 0:
            anslist.append(str(start)+str(end))

        dfs(s, start, end+1)
        dfs(s, start+1, end+1)

    dfs(S, 0, 4)
    print(len(set(anslist)))


if __name__ == "__main__":
    solve()


Fixed submission:


def solve():

    s = input()
    mod = 2019
    remains = [0]*mod

    ans = 0
    now = 0
    remains[0] = 1
    for i, val in enumerate(s[::-1]):
        now += int(val) * pow(10, i, mod)
        now %= mod
        ans += remains[now]
        remains[now] += 1

    print(ans)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
def div_with_mod(x, y, mod):
    # Fermat's little theorem
    return x*pow(y, mod - 2, mod)


def solve():
    N, K = map(int, input().split())
    mod = 10**9+7

    if K == N+1:
        print(1)
        exit()

    nc = N+1
    n = N+1
    r = K

    for rc in range(1, r):
        nc -= 1
        n = n*nc % mod
        r = r*rc % mod

    ans = div_with_mod(n, r, mod) % mod
    rc += 1

    for k in range(rc, N+1):
        rc += 1
        nc -= 1
        n = n*nc % mod
        r = r*rc % mod
        a = div_with_mod(n, r, mod) % mod
        ans += a

    print(ans % mod)


if __name__ == "__main__":
    solve()


Fixed submission:
def div_with_mod(x, y, mod):
    # Fermat's little theorem
    return x*pow(y, mod - 2, mod)


def solve():
    N, K = map(int, input().split())
    mod = 10**9+7

    s = 0
    s_1 = 0
    a = []
    b = 0
    ans = 0
    for i in range(N+1):
        b += i
        a.append(b)

    for i in range(K, N+1):
        s = a[i-1]
        s_1 = a[N]-a[N-i]
        ans += s_1-s + 1
    print(ans % mod + 1)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
def solve():
 
    N = int(input())
 
    ans = 0
    for i in range(N+1):
        if i % 3 == 0 and i % 5 == 0:
            pass
        elif i % 3 == 0:
            pass
        elif i % 5 == 0:
            pass
        else:
            ans += i
 
    print(ans)
 
 
if __name__ == "__main__":
    solve()
def solve():

    N = int(input())

    ans = 0
    for i in range(N):
        if i % 3 == 0 and i % 5 == 0:
            pass
        elif i % 3 == 0:
            pass
        elif i % 5 == 0:
            pass
        else:
            ans += i

    print(ans)


if __name__ == "__main__":
    solve()
提出情報

Fixed submission:
def solve():

    N = int(input())

    ans = 0
    for i in range(N+1):
        if i % 3 == 0 and i % 5 == 0:
            pass
        elif i % 3 == 0:
            pass
        elif i % 5 == 0:
            pass
        else:
            ans += i

    print(ans)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def solve():

    K = int(input())

    rangeK = range(1, K+1)
    ans = 0

    for a in rangeK:
        for b in rangeK:
            for c in rangeK:
                ans += gcd(a, b, c)

    print(ans)


if __name__ == "__main__":
    solve()


Fixed submission:
from math import gcd


def solve():

    K = int(input())

    rangeK = range(1, K+1)
    ans = 0

    for a in rangeK:
        for b in rangeK:
            for c in rangeK:
                ans += gcd(gcd(a, b), c)

    print(ans)


if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def solve():

    K = int(input())

    rangeK = range(1, K+1)
    ans = 0

    for a in rangeK:
        for b in rangeK:
            for c in rangeK:
                ans += gcd(a, b, c)

    print(ans)


if __name__ == "__main__":
    solve()


Fixed submission:
from math import gcd


def solve():

    K = int(input())

    rangeK = range(1, K+1)
    ans = 0

    for a in rangeK:
        for b in rangeK:
            for c in rangeK:
                ans += gcd(gcd(a, b), c)

    print(ans)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
ans = 0


def solve():

    N = int(input())
    S = input()

    def dfs(a, b):
        global ans

        if b == -1:
            for i in range(a, N-1):
                if S[a] != S[i]:
                    dfs(a, i)
        else:
            for i in range(b, N):
                if S[b] != S[i] and S[a] != S[i]:
                    if i - b != b - a:
                        ans += 1

    for i in range(0, N-2):
        dfs(i, -1)

    print(ans)


if __name__ == "__main__":
    solve()

    

Fixed submission:


def solve():

    N = int(input())
    S = input()

    r = S.count('R')
    g = S.count('G')
    b = S.count('B')

    ans = r*g*b

    for i in range(N-2):
        for j in range(i+1, N-1):
            # j - i = k - j
            k = j-i+j
            if k >= N:
                continue
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

    print(ans)


if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
ans = 0


def solve():

    N = int(input())
    S = input()

    def dfs(len, a, b):
        global ans

        if len == 1:
            for i in range(a, N-1):
                if S[a] != S[i]:
                    dfs(2, a, i)
        elif len == 2:
            for i in range(b, N):
                if S[b] != S[i] and S[a] != S[i]:
                    if i - b != b - a:
                        ans += 1

    for i in range(0, N-2):
        dfs(1, i, 0)

    print(ans)


if __name__ == "__main__":
    solve()


Fixed submission:


def solve():

    N = int(input())
    S = input()

    r = S.count('R')
    g = S.count('G')
    b = S.count('B')

    ans = r*g*b

    for i in range(N-2):
        for j in range(i+1, N-1):
            # j - i = k - j
            k = j-i+j
            if k >= N:
                continue
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

    print(ans)


if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
ans = 0


def solve():

    N = int(input())
    S = input()

    def dfs(len, a, b):
        global ans

        if len == 1:
            for i in range(a, N):
                if S[a] != S[i]:
                    dfs(2, a, i)
        elif len == 2:
            for i in range(b, N):
                if S[b] != S[i] and S[a] != S[i]:
                    if i - b != b - a:
                        ans += 1

    for i in range(0, N):
        dfs(1, i, 0)

    print(ans)


if __name__ == "__main__":
    solve()


Fixed submission:


def solve():

    N = int(input())
    S = input()

    r = S.count('R')
    g = S.count('G')
    b = S.count('B')

    ans = r*g*b

    for i in range(N-2):
        for j in range(i+1, N-1):
            # j - i = k - j
            k = j-i+j
            if k >= N:
                continue
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

    print(ans)


if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):

def solve():
    N = int(input())
    A = list(map(int, input().split()))

    res = [[e, A.count(e)] for e in set(A) if A.count(e) > 1]

    dic = {}

    for i in range(N):
        ans = 0

        if A[i] in dic:
            print(int(dic[A[i]]))
            continue

        for r in res:
            if r[0] == A[i]:
                ans += (r[1]-1)*(r[1]-2)/2
            else:
                ans += (r[1])*(r[1]-1)/2
        dic[A[i]] = ans

        print(int(ans))


# Solve
if __name__ == "__main__":
    solve()


Fixed submission:
import collections


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    counters = collections.Counter(A)
    ans = 0
    for _, c in counters.items():
        ans += c*(c-1)//2

    for K in range(N):
        if A[K] in counters:
            c = counters[A[K]]
            if counters[A[K]] > 2:
                print(ans - (c*(c-1)//2) + ((c-1)*(c-2)//2))
            else:
                print(ans - (c*(c-1)//2))
        else:
            print(ans)


# Solve
if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
import math


def comb(n, r, mod):
    # calculates C(n,r) mod p (assuming mod is prime).
    nc = n
    for rc in range(1, r):
        nc -= 1
        n *= nc % mod
        r *= rc % mod

    nCr = n*pow(r, mod - 2, mod) % mod
    return nCr


def solve():
    n, a, b = list(map(int, input().split()))
    mod = int(math.pow(10, 9) + 7)

    total = pow(2, n, mod) - 1
    ac = comb(n, a, mod)
    bc = comb(n, b, mod)
    ans = int(total - ac - bc) % mod

    print(ans)


# Solve
if __name__ == "__main__":
    solve()


Fixed submission:
import math


def comb(n, r, mod):
    # calculates C(n,r) mod p (assuming mod is prime).
    nc = n
    for rc in range(1, r):
        nc -= 1
        n = n*nc % mod
        r = r*rc % mod

    nCr = n*pow(r, mod - 2, mod)
    return nCr


def solve():
    n, a, b = list(map(int, input().split()))
    mod = int(pow(10, 9) + 7)

    total = pow(2, n, mod) - 1
    ac = comb(n, a, mod)
    bc = comb(n, b, mod)
    ans = int(total - ac - bc) % mod

    print(ans)


# Solve
if __name__ == "__main__":
    solve()