Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# Problem E - Red and Green Apples

from collections import deque

# input
X, Y, A, B, C = map(int, input().split())
red_list = list(map(int, input().split())) # red apple
green_list = list(map(int, input().split())) # green apple
transparent_list = list(map(int, input().split())) # transparent apple

# initialization
red_list = deque(sorted(red_list, reverse=True))
green_list = deque(sorted(green_list, reverse=True))
transparent_list = deque(sorted(transparent_list, reverse=True))
ans_list = deque([])

# count
while X>0 or Y>0:
    red = -1
    green = -1
    toumei = -1
    if C>=0:
        toumei = transparent_list[0]
    max_v = 0

    if X>0:
        red = red_list[0]

    if Y>0:
        green = green_list[0]

    # max value check
    if red>=green and red>=toumei:
        max_v = red_list.popleft()
        X -= 1
    elif green>=red and green>=toumei:
        max_v = green_list.popleft()
        Y -= 1
    else:
        # min value check
        if X>0 and Y>0:
            if red<=green:
                max_v = transparent_list.popleft()
                X -= 1
                C -= 1
                red_list.popleft()
            else:
                max_v = transparent_list.popleft()
                Y -= 1
                C -= 1
                green_list.popleft()
        elif X>0:
            max_v = transparent_list.popleft()
            X -= 1
            C -= 1
            red_list.popleft()
        else:
            max_v = transparent_list.popleft()
            Y -= 1
            C -= 1
            green_list.popleft()

    # list insert
    ans_list.append(max_v)

# output
ans = sum(ans_list)
print(ans)


Fixed submission:
# Problem E - Red and Green Apples

from collections import deque

# input
X, Y, A, B, C = map(int, input().split())
red_apples = sorted(list(map(int, input().split())), reverse=True)
green_apples = sorted(list(map(int, input().split())), reverse=True)
mushoku_apples = sorted(list(map(int, input().split())), reverse=True)

# initialization
red_apples = red_apples[:X]
green_apples = green_apples[:Y]
ans_list = deque([])
for r in red_apples:
    ans_list.append(r)
for g in green_apples:
    ans_list.append(g)
for m in mushoku_apples:
    ans_list.append(m)
ans_list = sorted(ans_list, reverse=True)

# output
i = X+Y
ans = sum(ans_list[:i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# Problem A - Range Flip Find Route

# input
h, w = map(int, input().split())
s_board = [['.']*w for i in range(h)]
c_board = [[100000]*w for i in range(h)]
for i in range(h):
    w_line = list(input())
    for j in range(w):
        s_board[i][j] = w_line[j]

# initialization
visit_queue = []

# count step
visit_queue.append([0, 0])
c_board[0][0] = 0
while len(visit_queue)>0:
    q = visit_queue.pop(0)
    r = q[0]
    c = q[1]
    # right
    if c+1<w:
        if s_board[r][c]=='.' and s_board[r][c+1]=='#':
            c_board[r][c+1] = min(c_board[r][c+1], c_board[r][c]+1)
        else:
            c_board[r][c+1] = min(c_board[r][c+1], c_board[r][c])
        visit_queue.append([r, c+1])
    # down
    if r+1<h:
        if s_board[r][c]=='.' and s_board[r+1][c]=='#':
            c_board[r+1][c] = min(c_board[r+1][c], c_board[r][c]+1)
        else:
            c_board[r+1][c] = min(c_board[r+1][c], c_board[r][c])
        visit_queue.append([r+1, c])

# start adjust
if s_board[0][0]=='#':
    c_board[h-1][w-1] += 1

# output
print(c_board[h-1][w-1])


Fixed submission:
# Problem A - Range Flip Find Route

# input
h, w = map(int, input().split())
s_board = [['']*w for i in range(h)]
for i in range(h):
    s = list(input())
    for j in range(w):
        s_board[i][j] = s[j]

# initialization
INF = 10**5
dp = [[INF]*w for i in range(h)]
if s_board[0][0]=='#':
    dp[0][0] = 1
else:
    dp[0][0] = 0

# count
for i in range(h):
    for j in range(w):
        # skip
        if i==0 and j==0:
            continue

        # left
        if j-1>=0:
            if s_board[i][j]=='#' and s_board[i][j-1]=='.':
                dp[i][j] = min(dp[i][j], dp[i][j-1] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i][j-1])

        # up
        if i-1>=0:
            if s_board[i][j]=='#' and s_board[i-1][j]=='.':
                dp[i][j] = min(dp[i][j], dp[i-1][j] + 1)
            else:
                dp[i][j] = min(dp[i][j], dp[i-1][j])

# output
print(dp[-1][-1])
Buggy python submission (verdict: Runtime Error):
H = int(input())

memo_count = {}
def searchCount(h):
    if h==1: # 脱出条件
        return 1
    elif h in memo_count:
        return memo_count[h]
    else:
        h_half = int(h / 2)
        memo_count[h] = 1 + 2*searchCount(h_half)
        return memo_count[h]

print(searchCount(H))


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

count = 0
while H > 0:
    H = H - A
    count = count + 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
H_list = list(map(int, input().split()))

count = 0

if N<K:
    print(0)
else:
    for i in range(0,K):

        # 最大値を見つける
        H_max = max(H_list)
        # 最大値を１つリストから削除
        H_list.remove(H_max)

    # リスト内の残りの数を合計
    count = sum(H_list)
    print(count)


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

count = 0

if N<K:
    print(0)
else:
    # リストをソートする
    H_list = sorted(H_list, reverse=True)
    # 上位K位をスライスで削除
    H_list = H_list[K:]


    # リスト内の残りの数を合計
    count = sum(H_list)
    print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p_list = list(map(int, input().split()))

count = 0 # p_j > p_i である回数
p_length = len(p_list)
for i in range(p_length):
    p_max = min(p_list[:i+1])
    if p_list[i]==p_max:
        count = count + 1

print(count)


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

count = 0 # p_j > p_i である回数
p_length = len(p_list)
p_min = p_list[0] # 現時点での最小値

for i in range(p_length):
    if p_list[i]<=p_min:
        p_min = p_list[i]
        count = count + 1 # カウントを１つ増やす
    else:
        continue

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p_list = list(map(int, input().split()))

count = 0 # p_j > p_i である回数
for i in range(len(p_list)):
    p_max = min(p_list[:i+1])
    if p_list[i]==p_max:
        count = count + 1

print(count)


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

count = 0 # p_j > p_i である回数
p_length = len(p_list)
p_min = p_list[0] # 現時点での最小値

for i in range(p_length):
    if p_list[i]<=p_min:
        p_min = p_list[i]
        count = count + 1 # カウントを１つ増やす
    else:
        continue

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p_list = list(map(int, input().split()))

count = 0 # p_j > p_i である回数
for i in range(len(p_list)):
    flag = False
    for j in  p_list[:i+1]:
        if p_list[i]<=j:
            flag = True
        else:
          flag = False
          break
    if flag:
        count = count + 1

print(count)


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

count = 0 # p_j > p_i である回数
p_length = len(p_list)
p_min = p_list[0] # 現時点での最小値

for i in range(p_length):
    if p_list[i]<=p_min:
        p_min = p_list[i]
        count = count + 1 # カウントを１つ増やす
    else:
        continue

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
# Handstand 2
# c_ij = {1<=k<=N : 先頭の桁がiで、末尾の桁の数がjであるもの}

N = int(input())
count = 0

# 先頭の桁をi, 末尾の桁をjとする数の数を求める
c_memo = {}
def c(i, j):
    count_num = 0
    key = str(i) + '_' + str(j)
    if key in c_memo:
        return c_memo[key]
    for a in range(1,N+1):
        a_str = str(a)
        a_i, a_j = int(a_str[0]), int(a_str[-1]) # 各数の先頭桁を求める
        if i==a_i and j==a_j:
            count_num = count_num + 1
    c_memo[key] = count_num
    return count_num


for i in range(10):
    for j in range(10):
        count += c(i,j)*c(j,i)

print(count)


Fixed submission:
# Handstand 2

N = int(input())
count = 0

count_list = [[0]*10 for i in range(10)]

# 1~Nまでの先頭iと末尾jの頻度を全て算出する
for a in range(1,N+1):
    a_str = str(a)
    a_i, a_j = int(a_str[0]), int(a_str[-1]) # 各数の先頭桁を求める
    count_list[a_i][a_j] = count_list[a_i][a_j] + 1

# count_listから全ての組み合わせ数を計算
for i in range(1,10):
    for j in range(1,10):
        count = count + count_list[i][j]*count_list[j][i]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
# Handstand 2
# c_ij = {1<=k<=N : 先頭の桁がiで、末尾の桁の数がjであるもの}

N = int(input())
count = 0

# 先頭の桁をi, 末尾の桁をjとする数の数を求める
def c(i, j):
    count_num = 0
    for a in range(1,N+1):
        a_str = str(a)
        a_i, a_j = int(a_str[0]), int(a_str[-1]) # 各数の先頭桁を求める
        if i==a_i and j==a_j:
            count_num = count_num + 1
    return count_num


for i in range(10):
    for j in range(10):
        count += c(i,j)*c(j,i)

print(count)


Fixed submission:
# Handstand 2

N = int(input())
count = 0

count_list = [[0]*10 for i in range(10)]

# 1~Nまでの先頭iと末尾jの頻度を全て算出する
for a in range(1,N+1):
    a_str = str(a)
    a_i, a_j = int(a_str[0]), int(a_str[-1]) # 各数の先頭桁を求める
    count_list[a_i][a_j] = count_list[a_i][a_j] + 1

# count_listから全ての組み合わせ数を計算
for i in range(1,10):
    for j in range(1,10):
        count = count + count_list[i][j]*count_list[j][i]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
# Handstand 2
# c_ij = {1<=k<=N : 先頭の桁がiで、末尾の桁の数がjであるもの}

N = int(input())
count = 0

# 先頭の桁をi, 末尾の桁をjとする数の数を求める
def c(i, j):
    count_num = 0
    for a in range(1,N+1):
        a_str = str(a)
        a_i, a_j = int(a_str[0]), int(a_str[-1]) # 各数の先頭桁を求める
        if i==a_i and j==a_j:
            count_num = count_num + 1
    return count_num


for i in range(10):
    for j in range(10):
        count += c(i,j)*c(j,i)

print(count)


Fixed submission:
# Handstand 2

N = int(input())
count = 0

count_list = [[0]*10 for i in range(10)]

# 1~Nまでの先頭iと末尾jの頻度を全て算出する
for a in range(1,N+1):
    a_str = str(a)
    a_i, a_j = int(a_str[0]), int(a_str[-1]) # 各数の先頭桁を求める
    count_list[a_i][a_j] = count_list[a_i][a_j] + 1

# count_listから全ての組み合わせ数を計算
for i in range(1,10):
    for j in range(1,10):
        count = count + count_list[i][j]*count_list[j][i]

print(count)
Buggy python submission (verdict: Runtime Error):
import fractions

N = int(input())
A_list = list(map(int, input().split()))

mod = 10**9+7

R = 1 # 最小公倍数
# 最小公倍数を求める
for A in A_list:
    R *= A // fractions.gcd(R, A)

# Bの合計を求める
ans = 0
for A in A_list:
    ans = ans + (R / A)

print(int(ans%(mod+7)))


Fixed submission:
import fractions

N = int(input())
A_list = list(map(int, input().split()))

mod = 10**9+7

R = 1 # 最小公倍数
# 最小公倍数を求める
for A in A_list:
    R *= A // fractions.gcd(R, A)

# Bの合計を求める
ans = 0
for A in A_list:
    ans = ans + R // A # 計算は小数として出してはダメだから//を使う

ans %= mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions

N = int(input())
A_list = list(map(int, input().split()))

R = 1 # 最小公倍数
# 最小公倍数を求める
for A in A_list:
    R = R * A // fractions.gcd(R, A)

# Bの合計を求める
ans = 0
for A in A_list:
    ans = ans + (R / A)

print(int(ans%(pow(10,9)+7)))


Fixed submission:
import fractions

N = int(input())
A_list = list(map(int, input().split()))

mod = 10**9+7

R = 1 # 最小公倍数
# 最小公倍数を求める
for A in A_list:
    R *= A // fractions.gcd(R, A)

# Bの合計を求める
ans = 0
for A in A_list:
    ans = ans + R // A # 計算は小数として出してはダメだから//を使う

ans %= mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions

N = int(input())
A_list = list(map(int, input().split()))

R = 1 # 最小公倍数
# 最小公倍数を求める
for A in A_list:
    R = R * A // fractions.gcd(R, A)

# Bの合計を求める
ans = 0
for A in A_list:
    ans = ans + (R / A)

print("%d"%(ans%(pow(10,9)+7)))


Fixed submission:
import fractions

N = int(input())
A_list = list(map(int, input().split()))

mod = 10**9+7

R = 1 # 最小公倍数
# 最小公倍数を求める
for A in A_list:
    R *= A // fractions.gcd(R, A)

# Bの合計を求める
ans = 0
for A in A_list:
    ans = ans + R // A # 計算は小数として出してはダメだから//を使う

ans %= mod

print(ans)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
A_list = list(map(int, input().split()))

R = 1 # 最小公倍数
# 最小公倍数を求める
for A in A_list:
    R = R * A // math.gcd(R, A)

# Bの合計を求める
ans = 0
for A in A_list:
    ans = ans + (R / A)

print("%d"%(ans%(pow(10,9)+7)))


Fixed submission:
import fractions

N = int(input())
A_list = list(map(int, input().split()))

mod = 10**9+7

R = 1 # 最小公倍数
# 最小公倍数を求める
for A in A_list:
    R *= A // fractions.gcd(R, A)

# Bの合計を求める
ans = 0
for A in A_list:
    ans = ans + R // A # 計算は小数として出してはダメだから//を使う

ans %= mod

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# Problem D - Xor Sum 4

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
ans = 0
MOD = 10**9 + 7

# count
two_factor = 1
for i in range(60):
    tmp_count = 0
    one_count = 0
    zero_count = 0
    for j in range(N):
        if (a_nums[j]>>i)&1==1:
            one_count += 1
        else:
            zero_count += 1
    tmp_count = (one_count * zero_count)%MOD
    ans += (tmp_count * two_factor)%MOD
    two_factor = (two_factor * 2)%MOD

# output
print(ans%MOD)


Fixed submission:
# Problem D - Xor Sum 4

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
ans = 0
MOD = 10**9 + 7

# count
two_factor = 1
for i in range(60):
    tmp_count = 0
    one_count = 0
    zero_count = 0
    for j in range(N):
        if (a_nums[j]>>i)&1==1:
            one_count += 1
        else:
            zero_count += 1
    tmp_count = (one_count * zero_count)%MOD
    ans += (tmp_count * two_factor)%MOD
    two_factor = (two_factor * 2)%MOD

# output
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
# Problem D - Xor Sum 4

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
ans = 0
MOD = 10**9 + 7

# count
for i in range(60):
    tmp_count = 0
    one_count = 0
    zero_count = 0
    for a in a_nums:
        if (a>>i)&1==1:
            one_count += 1
        else:
            zero_count += 1
    tmp_count = one_count * zero_count
    ans += (tmp_count * (2**i))%MOD

# output
print(ans%MOD)


Fixed submission:
# Problem D - Xor Sum 4

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
ans = 0
MOD = 10**9 + 7

# count
two_factor = 1
for i in range(60):
    tmp_count = 0
    one_count = 0
    zero_count = 0
    for j in range(N):
        if (a_nums[j]>>i)&1==1:
            one_count += 1
        else:
            zero_count += 1
    tmp_count = (one_count * zero_count)%MOD
    ans += (tmp_count * two_factor)%MOD
    two_factor = (two_factor * 2)%MOD

# output
print(ans%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
# Problem A - ><

# input
S = input()

# initialization
part_str = []
tmp = S
last_i = 0
for i in range(len(S)-1):
    if S[i]=='>' and S[i+1]=='<':
        part_str.append(S[last_i:i+1])
        last_i = i + 1
        tmp = S[last_i:]
if len(tmp)>=1:
    part_str.append(tmp)

ans = 0

# count
for p in part_str:
    left_count = 0
    right_count = 0
    for c in p:
        if c=='<':
            left_count += 1
        elif c=='>':
            right_count += 1
    tmp_max = max(left_count, right_count)
    if left_count-1>0:
        left_count -= 1
        left_count = (left_count * (1 + left_count)) / 2
    else:
        left_count = 0

    if right_count-1>0:
        right_count -= 1
        right_count = (right_count * (1 + right_count)) / 2
    else:
        right_count = 0
    ans += tmp_max + left_count + right_count

# output
print("%d"%(ans))


Fixed submission:
# Problem A - ><

S = input()
N = len(S) + 1

num_list = [0]*N
ans_sum = 0

# < process
for i in range(len(S)):
    s = S[i]
    if s=="<":
        num_list[i+1] = num_list[i] + 1

# > process
for i in range(len(S)-1, -1, -1):
    s = S[i]
    if s==">":
        num_list[i] = max(num_list[i], num_list[i+1]+1)

# sum process
for i in range(N):
    ans_sum = ans_sum + num_list[i]

print(ans_sum)
Buggy python submission (verdict: Time Limit Exceeded):
L, R = map(int, input().split())

count_limit = 0 # count limit is 2019
min_num = 2020
for i in range(L, R+1):
    for j in range(i+1, R+1):
        min_num = min(min_num, (i*j)%2019)

    # limit process
    count_limit = count_limit + 1
    if count_limit>2020:
        break

print(min_num)


Fixed submission:
L, R = map(int, input().split())

count_limit = 0 # count limit is 2019
min_num = 2020
for i in range(L, R+1):

    count_limit_j = 0
    for j in range(i+1, R+1):
        min_num = min(min_num, (i*j)%2019)
        count_limit_j = count_limit_j + 1
        if count_limit_j>2020:
            break

    # limit process
    count_limit = count_limit + 1
    if count_limit>2020:
        break

print(min_num)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()

ans_count = 0
b_count = 0
for i in range(len(S)):
    s = S[i]
    if s=="B":
        b_count = b_count + 1
    if s=="W":
        cut_str = S[:i]
        ans_count = ans_count + b_count

print(ans_count)


Fixed submission:
S = input()

ans_count = 0
b_count = 0
for s in S:
    if s=="B":
        b_count = b_count + 1
    if s=="W":
        ans_count = ans_count + b_count

print(ans_count)

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

ans_count = 0
for i in range(len(S)):
    s = S[i]
    if s=="W":
        cut_str = S[:i]
        b_count = cut_str.count("B")
        ans_count = ans_count + b_count

print(ans_count)


Fixed submission:
S = input()

ans_count = 0
b_count = 0
for s in S:
    if s=="B":
        b_count = b_count + 1
    if s=="W":
        ans_count = ans_count + b_count

print(ans_count)
Buggy python submission (verdict: Runtime Error):
# Problem B - Ringo's Favorite Numbers

# input
D, N = map(int, input().split())

# initialization
ans = 0
tmp_list = []
tmp = 100**D

# calc
i = 1
while not i>N:
    ans = tmp * i
    if not ans%(tmp*100)==0:
        tmp_list.append(ans)
        i = i + 1
    else:
        i = i + 1

#output
ans = tmp_list[N-1]
print(ans)


Fixed submission:
d, n = map(int, input().split())


for i in range(1, 100000000):
    if i % (100 ** d) == 0 and i % (100 * 100 ** d) != 0:
        n -= 1
    if n == 0:
        print(i)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
# Problem B - Small and Large Integers

A, B, K = map(int, input().split())

# initialization
num_list = [i for i in range(A,B+1)]


# output process 1
for i in range(K):
    if len(num_list)<=0:
        break
    n = num_list[0]
    print(n)
    num_list.remove(n)

# output process 2
output2_list = []
for i in range(K):
    if len(num_list)<=0:
        break
    n = num_list[-1]
    output2_list.append(n)
    num_list.remove(n)
output2_list = output2_list[::-1]
for o in output2_list:
    print(o)


Fixed submission:
# Problem B - Small and Large Integers

A, B, K = map(int, input().split())

# initialization

if B-A<=2*K:
    num_list = [i for i in range(A,B+1)]
    # output process 1
    for i in range(K):
        if len(num_list)<=0:
            break
        n = num_list[0]
        print(n)
        num_list.remove(n)

    # output process 2
    output_list = []
    for i in range(K):
        if len(num_list)<=0:
            break
        n = num_list[-1]
        output_list.append(n)
        num_list.remove(n)

    output_list = output_list[::-1]

    for o in output_list:
        print(o)
else:
    num_list_1 = [i for i in range(A, A+K+1)]
    num_list_2 = [i for i in range(B-K+1, B+1)]
    # output process 1
    for i in range(K):
        n = num_list_1[i]
        print(n)

    # output process 2
    for i in range(K):
        n = num_list_2[i]
        print(n)
Buggy python submission (verdict: Time Limit Exceeded):
# Problem B - Training Camp

# input process
N = int(input())

# initialization
frac_num = 1
INF = 10**9 + 7

for i in range(1, N+1):
    frac_num = frac_num * i

print(frac_num%INF)


Fixed submission:
# Problem B - Training Camp

# input process
N = int(input())

# initialization
frac_num = 1
INF = 10**9 + 7

for i in range(1, N+1):
    frac_num = (frac_num * i) % INF

print(frac_num%INF)
Buggy python submission (verdict: Runtime Error):
#156D
p=7+10**9
def comb(n,r):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
n,a,b=map(int,input().split())
s=-1+pow(2,n,p)-comb(n,a)-comb(n,b)
print(s%p)


Fixed submission:
n,m=map(int,input().split())
print(m+max(0,100*(10-n)))
Buggy python submission (verdict: Time Limit Exceeded):
#156D

def comb(n,r,p=7+10**9):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
n,a,b=map(int,input().split())
s=-1+2**n-comb(n,a)-comb(n,b)
print(s%(7+10**9))


Fixed submission:
#156D
p=7+10**9
def comb(n,r):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
n,a,b=map(int,input().split())
s=-1+pow(2,n,p)-comb(n,a)-comb(n,b)
print(s%p)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

Fixed submission:
#156D
p=7+10**9
def comb(n,r):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
n,a,b=map(int,input().split())
s=-1+pow(2,n,p)-comb(n,a)-comb(n,b)
print(s%p)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=list(map(int,input().split())
s=sum(l)
if n<=s:
  print("Yes")
else:
  print("No")

Fixed submission:
n,m=map(int,input().split())
l=list(map(int,input().split()))
s=sum(l)
if n<=s:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import fractions
from functools import reduce
n=int(input())
numbers=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
l=0
x=lcm_list(numbers)
for i in range(n):
    l+=(x//numbers[i])
print(l%(10**9+7))


Fixed submission:
n,m=map(int,input().split())
if n==m:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
n=int(input())
numbers=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
l=0
for i in range(n):
    l+=(lcm_list(numbers)//numbers[i])
print(l%(10**9+7))


Fixed submission:
# -*- coding: utf-8 -*-
import fractions
 
mod = 10**9+7
 
n = int(input())
a = list(map(int, input().split()))
 
div = a[0]
for i in a[1:]:
    div = div*i//fractions.gcd(div, i)

ans = 0
for i in a:
    ans += div//i

print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
from functools import reduce
n=int(input())
numbers=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
l=[]
for i in range(n):
    l.append(lcm_list(numbers)//numbers[i])
print(sum(l)%(10**9+7))

Fixed submission:
# -*- coding: utf-8 -*-
import fractions
 
mod = 10**9+7
 
n = int(input())
a = list(map(int, input().split()))
 
div = a[0]
for i in a[1:]:
    div = div*i//fractions.gcd(div, i)

ans = 0
for i in a:
    ans += div//i

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
import itertools
n=int(input()
a=map(int,input().split())
b=map(int,input().split())
seq=range(n)
list(itertools.permutations(seq))
print(a)
print(list[0])

Fixed submission:
import itertools
n=int(input())
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
seq=range(1,n+1)
l=list(itertools.permutations(seq))
#print(l[0])

a_num=0
b_num=0
for i in range(len(l)):
  if l[i]==a:
    a_num=i
  if l[i]==b:
    b_num=i

print(abs(a_num-b_num))