Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
"""
9 5
-4 -3 -2 -1 0 1 2 3
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Am = []
Ap = []
for a in A:
    if a < 0:
        Am.append(a)
    else:
        Ap.append(a)

mod = 10**9 + 7

ans = 1

if N == K:
    for a in A:
        ans *= a
        ans %= mod

elif A[-1] < 0:
    if K % 2 = 1
        for i in range(K):
            ans *= Am[-1-i]
            ans %= mod
    else:
        for i in range(K):
            ans *= Am[i]
            ans %= mod

else:
    if K%2 == 1:
        ans *= Ap[-1]
        ans %= mod
        K -= 1
        del Ap[-1]
    Amd = []     
    Apd = []
    for i in range(len(Ap)//2):
        Apd.append(Ap[-1-(2*i)]*Ap[-1-(2*i+1)])
    for i in range(len(Am)//2):
        Amd.append(Am[2*i]*Am[2*i+1])
    Apd.append(-1)
    Amd.append(-1)
    
    ip = 0
    im = 0
    while K > 0:
        if Apd[ip] >= Amd[im]:
            ans *= Apd[ip]
            ip += 1
        else:
            ans *= Amd[im]
            im += 1
        ans %= mod
        K -= 2


ans %= mod
print(ans)




Fixed submission:
"""
9 5
-4 -3 -2 -1 0 1 2 3
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Am = []
Ap = []
for a in A:
    if a < 0:
        Am.append(a)
    else:
        Ap.append(a)

mod = 10**9 + 7

ans = 1

if N == K:
    for a in A:
        ans *= a
        ans %= mod

elif A[-1] < 0:
    if K % 2 == 1:
        for i in range(K):
            ans *= Am[-1-i]
            ans %= mod
    else:
        for i in range(K):
            ans *= Am[i]
            ans %= mod

else:
    if K%2 == 1:
        ans *= Ap[-1]
        ans %= mod
        K -= 1
        del Ap[-1]
    Amd = []     
    Apd = []
    for i in range(len(Ap)//2):
        Apd.append(Ap[-1-(2*i)]*Ap[-1-(2*i+1)])
    for i in range(len(Am)//2):
        Amd.append(Am[2*i]*Am[2*i+1])
    Apd.append(-1)
    Amd.append(-1)
    
    ip = 0
    im = 0
    while K > 0:
        if Apd[ip] >= Amd[im]:
            ans *= Apd[ip]
            ip += 1
        else:
            ans *= Amd[im]
            im += 1
        ans %= mod
        K -= 2


ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
K = int(input())
S = input()
N = len(S)

mod = 10**9+7

power25 = [1]*(K+1)
power26 = [1]*(K+1)

def mod_factorial(n, m):
    mod_factorials = [1] * (n + 1)
    for i in range(1, n+1):
        mod_factorials[i] = mod_factorials[i-1]*i
        mod_factorials[i] %= m
    return mod_factorials

# 1!,2!,3!,...,n! の逆元 (mod m)
def mod_inv_factorials2(n, m):
    mod_invs = [1] * (n + 1)
    invs = [1] * (n + 1)
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m

    for i in range(1, n+1):
        mod_invs[i] = invs[i]*mod_invs[i-1]
        mod_invs[i] %= m
    return mod_invs

factrials = mod_factorial(K+N,mod)
inv_factrials = mod_inv_factorials2(K+1,mod)

for i in range(1,K+1):
    power25[i] = (power25[i-1]*25)%mod
for i in range(1,K+1):
    power26[i] = (power26[i-1]*26)%mod

ans = 0
for i in range(K+1):
    rk = K-i
    ans += power25[rk]*factrials[rk+N-1]*inv_factrials[N-1]*inv_factrials[rk]*power26[i]
    ans %= mod

print(ans)



Fixed submission:
K = int(input())
S = input()
N = len(S)

mod = 10**9+7

power25 = [1]*(K+1)
power26 = [1]*(K+1)

def mod_factorial(n, m):
    mod_factorials = [1] * (n + 1)
    for i in range(1, n+1):
        mod_factorials[i] = mod_factorials[i-1]*i
        mod_factorials[i] %= m
    return mod_factorials

# 1!,2!,3!,...,n! の逆元 (mod m)
def mod_inv_factorials2(n, m):
    mod_invs = [1] * (n + 1)
    invs = [1] * (n + 1)
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m

    for i in range(1, n+1):
        mod_invs[i] = invs[i]*mod_invs[i-1]
        mod_invs[i] %= m
    return mod_invs

factrials = mod_factorial(K+N,mod)
inv_factrials = mod_inv_factorials2(max(N,K+1),mod)

for i in range(1,K+1):
    power25[i] = (power25[i-1]*25)%mod
for i in range(1,K+1):
    power26[i] = (power26[i-1]*26)%mod

ans = 0
for i in range(K+1):
    rk = K-i
    ans += power25[rk]*factrials[rk+N-1]*inv_factrials[N-1]*inv_factrials[rk]*power26[i]
    ans %= mod

print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect as bc
 
N = int(input())
A = list(map(int,input().split()))
A.sort()
 
dp = [True for _ in range(A[-1]+1)]
 
for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        dp[ai*j] = False
 
ans = 0
for i in range(N):
    if dp[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False
 
print(ans)

Fixed submission:
x = list(map(int,input().split()))
print(x.index(0)+1)
Buggy python submission (verdict: Runtime Error):
import bisect as bc
 
N = int(input())
A = list(map(int,input().split()))
A.sort()
 
dp = [True for _ in range(A[-1]+1)]
 
for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        dp[ai*j] = False
 
ans = 0
for i in range(N):
    if dp[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False
 
print(ans)

Fixed submission:
import bisect as bc

N = int(input())
A = list(map(int,input().split()))
A.sort()

dp = [True for _ in range(A[-1]+1)]

for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        if dp[ai*j]:
            dp[ai*j] = False

ans = 0
finish = [True for _ in range(A[-1]+1)]
for i in range(N):
    if dp[A[i]] and finish[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect as bc
from collections import defaultdict
from collections import deque
N = int(input())
A = list(map(int,input().split()))
A.sort()
q = set([i for i in range(N)])
 
for i in range(N):
    ai = A[i]
    itr = list(q)
    for j in itr:
        if j == i:
            continue
        if A[j] % ai == 0:
            q.remove(j)
 
print(len(q))
 
 

Fixed submission:
import bisect as bc

N = int(input())
A = list(map(int,input().split()))
A.sort()

dp = [True for _ in range(A[-1]+1)]

for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        if dp[ai*j]:
            dp[ai*j] = False

ans = 0
finish = [True for _ in range(A[-1]+1)]
for i in range(N):
    if dp[A[i]] and finish[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect as bc
from collections import defaultdict
from collections import deque
N = int(input())
A = list(map(int,input().split()))
A.sort()
q = deque([i for i in range(N)])
 
for i in range(N):
    ai = A[i]
    itr = list(q)
    for j in itr:
        if j == i:
            continue
        if A[j] % ai == 0:
            del q[bc.bisect_left(q,j)]
 
print(len(q))
 
 

Fixed submission:
import bisect as bc

N = int(input())
A = list(map(int,input().split()))
A.sort()

dp = [True for _ in range(A[-1]+1)]

for i in range(N):
    ai = A[i]
    for j in range(2,A[-1]+1):
        if ai*j > A[-1]:
            break
        if dp[ai*j]:
            dp[ai*j] = False

ans = 0
finish = [True for _ in range(A[-1]+1)]
for i in range(N):
    if dp[A[i]] and finish[A[i]]:
        if bc.bisect_right(A,A[i]) - bc.bisect_left(A,A[i]) == 1:
            ans += 1
            finish[A[i]] = False

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N,M = map(int,input().split())
C = [[] for _ in range(N+1)]
for _ in range(M):
    tmp = list(map(int,input().split()))
    C[tmp[0]].append(tmp[1])
    C[tmp[1]].append(tmp[0])
d = [1000000000]*(N+1)
d[1] = 0
visited = [False]*(N+1)
q = deque()
q.append(1)

while q:
    node = q.popleft()
    visited[node] = True
    for adj in C[node]:
        if visited[adj] == False:
            d[adj] = min(d[node]+1,d[adj])
            q.append(adj)

sirube = [0]*(N+1)
for i in range(2,N+1):
    min_d = 10000000000
    for adj in C[i]:
        if d[adj] < min_d:
            sirube[i] = adj
            min_d = d[adj]


print("Yes")
for i in range(2,N+1):
    print(sirube[i])



Fixed submission:
from collections import deque

N,M = map(int,input().split())
C = [[] for _ in range(N+1)]
for _ in range(M):
    tmp = list(map(int,input().split()))
    C[tmp[0]].append(tmp[1])
    C[tmp[1]].append(tmp[0])
d = [1000000000]*(N+1)
d[1] = 0
visited = [False]*(N+1)
q = deque()
q.append(1)

sirube = [0]*(N+1)
while q:
    node = q.popleft()
    for adj in C[node]:
        if visited[adj] == False:
            sirube[adj] = node
            q.append(adj)
            visited[adj] = True



print("Yes")
for i in range(2,N+1):
    print(sirube[i])
Buggy python submission (verdict: Time Limit Exceeded):
mod = 998244353
N,M,K = map(int,input().split())
ans = 0
def color(n,m):
    return m*(pow_k(m-1, n-1))

def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x
            x = x ** 2
            x %= mod
            n = (n - 1) // 2
        else:
            x = x ** 2
            x %= mod
            n = n // 2

    return (K * x)%mod
invs = [0] * (N + 1)
invs[1] = 1
for i in range(2, N + 1):
    invs[i] = mod - invs[mod % i] * (mod//i) % mod

def mod_inv_factorial2(n1, n2, m):
    n = max(n1, n2)
    r1 = r2 = 1
    for i in range(1, n+1):
        r1 *= invs[i]
        r1 %= m
        if i == min(n1, n2):
            r2 = r1
    return r1, r2

def mod_factorial(n, m):
    r = 1
    for i in range(1, n+1):
        r *= i
        r %= m
    return r

upper = mod_factorial(N-1,mod)

for i in range(K+1):
    tmp = color(N-i,M)
    lower1,lower2 = mod_inv_factorial2(i,N-1-i,mod)
    ansk = (upper*lower1*lower2*tmp)%mod
    ans += ansk
    ans %= mod
print(ans)

    


Fixed submission:
mod = 998244353
N,M,K = map(int,input().split())
ans = 0
def color(n,m):
    return m*(pow_k(m-1, n-1))

def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x
            x = x ** 2
            x %= mod
            n = (n - 1) // 2
        else:
            x = x ** 2
            x %= mod
            n = n // 2

    return (K * x)%mod
invs = [0] * (N + 1)
invs[1] = 1
for i in range(2, N + 1):
    invs[i] = mod - invs[mod % i] * (mod//i) % mod
mod_inv_factorials=[1]*(N+1)

for i in range(2,N+1):
    mod_inv_factorials[i] = mod_inv_factorials[i-1]*invs[i]
    mod_inv_factorials[i] %= mod

def mod_factorial(n, m):
    r = 1
    for i in range(1, n+1):
        r *= i
        r %= m
    return r

upper = mod_factorial(N-1,mod)

for i in range(K+1):
    tmp = color(N-i,M)
    ansk = (upper*mod_inv_factorials[i]*mod_inv_factorials[N-1-i]*tmp)%mod
    ans += ansk
    ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S=list(input())
S.reverse()
N=len(S)
R=[0]*N
m=2019
K=0

for i in range(N):
    K+=int(S[i])*10**i
    R[i]=K%m
d={}
for i in range(2019):
    d[i]=0

for i in range(N):
    d[R[i]]+=1
ans=0
for i in range(2019):
    if i == 0:
        ans += d[i]
        ans +=d[i]*(d[i]-1)//2
    else:
        ans +=d[i]*(d[i]-1)//2
print(ans)



Fixed submission:
S=list(input())
S.reverse()
N=len(S)
R=[0]*N
R10=[0]*N
m=2019
K=0

R10[0]=1
R[0]=int(S[0])%m
for i in range(1,N):
    R10[i]=(R10[i-1]*10)%m
    R[i]=(R[i-1]+int(S[i])*R10[i])%m
d={}
for i in range(2019):
    d[i]=0

for i in range(N):
    d[R[i]]+=1
ans=0
for i in range(2019):
    if i == 0:
        ans += d[i]
        ans +=d[i]*(d[i]-1)//2
    else:
        ans +=d[i]*(d[i]-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
R=int(input())
print(2*R*3.1415926535

Fixed submission:
R=int(input())
print(2*R*3.1415926535)

Buggy python submission (verdict: Runtime Error):
R=int(input())
print(2*R*3.1415926535

Fixed submission:
R=int(input())
print(2*R*3.1415926535)
Buggy python submission (verdict: Runtime Error):
N=int(input()[:-1])
ans=0
for i in range(1,N+1):
    if i%3==0 or i%5==0:
        pass
    else:
        ans+=1
print(ans)


Fixed submission:
N=int(input())
S=0

for i in range(1,N+1):
    if i%3!=0 and i%5!=0:
        S += i
print(S)
Buggy python submission (verdict: Runtime Error):
import sys
A=[a.rstrip() for a in sys.stdin.readlines(3)]
N=int(A[0])
S="".join(["A",A[1]])

a=0
ans=S.count("R")*S.count("G")*S.count("B")

for i in range(1,N+1):
    for j in range(1,N+1):
        k=2*j-i
        if 1 <= k <= N and i < j < k:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
print(ans)



Fixed submission:
N=int(input())
S=input()
R=[0]*N
G=[0]*N
B=[0]*N

for i in range(N):
    if S[i]=="R":
        R[i]=1
    elif S[i]=="G":
        G[i]=1
    else:
        B[i]=1
R_S=[0]*N
G_S=[0]*N
B_S=[0]*N
R_S[0] = R[0]
G_S[0] = G[0]
B_S[0] = B[0]
for i in range(1,N):
    R_S[i]=R_S[i-1]+R[i]
    G_S[i]=G_S[i-1]+G[i]
    B_S[i]=B_S[i-1]+B[i]

ans=0
for j in range(1,N-1):
    char=S[j]
    if char=="G":
        ans += R_S[j-1]*(B_S[N-1]-B_S[j])
        ans += B_S[j-1]*(R_S[N-1]-R_S[j])
        min_len=min(j,N-1-j)
        for i in range(1,min_len+1):
            if (S[j-i]=="R" and S[j+i]=="B") or (S[j-i]=="B" and S[j+i]=="R"):
                ans -= 1
    if char=="R":
        ans += G_S[j-1]*(B_S[N-1]-B_S[j])
        ans += B_S[j-1]*(G_S[N-1]-G_S[j])
        min_len=min(j,N-1-j)
        for i in range(1,min_len+1):
            if (S[j-i]=="G" and S[j+i]=="B") or (S[j-i]=="B" and S[j+i]=="G"):
                ans -= 1
    if char=="B":
        ans += G_S[j-1]*(R_S[N-1]-R_S[j])
        ans += R_S[j-1]*(G_S[N-1]-G_S[j])
        min_len=min(j,N-1-j)
        for i in range(1,min_len+1):
            if (S[j-i]=="G" and S[j+i]=="R") or (S[j-i]=="R" and S[j+i]=="G"):
                ans -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, X, Y = map(int, input().split())

print(N)

for k in range(2, N):
    cnt = 0
    for i in range(1, N + 1):
        if X < i and i + k <= N:
            cnt += 1
        if i <= X and X - i + 1 == k:
            cnt += 2
        if i <= X and X - i + 2 <= k:
            if Y - (k - (X - i + 1)) > i + k:
                cnt += 2
            if Y - (k - (X - i + 1)) == i + k:
                cnt += 1
            if Y + (k - (X - i + 1)) <= N:
                cnt += 1
        if i + k <= X:
            cnt += 1
        if X < i and i+k < Y and:
            if i + k > Y-(k-(i-X+1)) and k-(i-X+1) >= 0:
                cnt += 1
                if Y+(k-(i-X+1)) <= N:
                    cnt += 1
    print(cnt)

Fixed submission:
N, X, Y = map(int, input().split())
dis_comb = [0]*N

for i in range(1, N):
    for j in range(i+1, N+1):
        dis_comb[min(abs(i-j), abs(X-i)+1+abs(Y-j))] += 1

for i in range(1, N):
    print(dis_comb[i])
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = ["a"] * N


def next_chr(ch):
    res = []
    for i in range(-1, 2):
        if ord(ch) + i >= ord("a") and ord(ch) + i <= ord("z"):
            res.append(chr(ord(ch)+i))
    return res


def answer(s, i):
    if i == N:
        ch = next_chr(s[-1])
        for m in ch:
            print("".join([s, m]))
    else:
        i += 1
        ch = next_chr(s[-1])
        for m in ch:
            answer("".join([s, m]), i)


answer("a", 2)


Fixed submission:
N = int(input())
ans = []


def next_chr(ch):
    res = []
    g = ord(ch) - ord("a") + 2
    for i in range(g):
        res.append(chr(ord("a")+i))
    return res


def answer(s, i):
    if i == N:
        ch = next_chr(max(s))
        for m in ch:
            ans.append("".join([s, m]))
    else:
        i += 1
        ch = next_chr(max(s))
        for m in ch:
            answer("".join([s, m]), i)


if N == 1:
    print("a")
else:
    answer("a", 2)
    ans = sorted(ans)
    for c in ans:
        print(c)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N, P = map(int, input().split())
S = [int(s) for s in input()]
S.reverse()

ans = 0

if P != 2 and P != 5:
    S = [(s * 10**n) % P for n, s in enumerate(S)]
    for n in range(1, N):
        S[n] = (S[n-1] + S[n]) % P

    S = Counter(S)
    for p in range(P):
        if p == 0:
            ans += S[p]
        ans += (S[p] * (S[p]-1)) // 2

else:
    for n in range(N):
        if S[n] % P == 0:
            ans += N - n

print(ans)

Fixed submission:
from collections import Counter

N, P = map(int, input().split())
S = [int(s) for s in input()]
S.reverse()

ans = 0

if P != 2 and P != 5:
    prime10 = [1] * N
    for n in range(1, N):
        prime10[n] = (prime10[n-1] * 10) % P
    S = [(s * prime10[n]) % P for n, s in enumerate(S)]
    for n in range(1, N):
        S[n] = (S[n-1] + S[n]) % P

    S = Counter(S)
    for p in range(P):
        if p == 0:
            ans += S[p]
        ans += (S[p] * (S[p]-1)) // 2

else:
    for n in range(N):
        if S[n] % P == 0:
            ans += N - n

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = ["*"]*(N+1)
S[1:] = list(input())
Q = int(input())
q1,q2,q3 = [0]*Q,[0]*Q,[0]*Q
for i in range(Q):
    tmp = input().split()
    q1[i],q2[i] = map(int,tmp[:2])
    if q1[i] == 2:
        q3[i] = int(tmp[2])
    else:
        q3[i] = tmp[2]

class BIT:
    def __init__(self, n, init_list):
        self.num = n + 1
        self.tree = [0] * self.num
        for i, e in enumerate(init_list):
            self.update(i, e)

    #a_kにxを加算
    def update(self, k, x):
        k = k + 1
        while k < self.num:
            self.tree[k] += x
            k += (k & (-k))
        return

    def query1(self, r):
        ret = 0
        while r > 0:
            ret += self.tree[r]
            r -= r & (-r)
        return ret

    #通常のスライスと同じ。lは含み、rは含まない
    def query2(self, l, r):
        return self.query1(r) - self.query1(l)

s_pos = [BIT(N+1,[0]*(N+1)) for _ in range(26)]

for i in range(1,N+1):
    s_pos[ord(S[i]) - ord("a")].update(i,1)

alphabets = [chr(ord("a") + i) for i in range(26)]

for i in range(Q):
    if q1[i] == 1:
        s_pos[ord(S[q2[i]]) - ord("a")].update(q2[i],-1)
        S[i] = q3[i]
        s_pos[ord(q3[i]) - ord("a")].update(q2[i],1)
    else:
        ans = 0
        for c in alphabets:
            if s_pos[ord(c) - ord("a")].query2(q2[i],q3[i]+1) > 0:
                ans += 1
        print(ans)











Fixed submission:
N = int(input())
S = ["*"]*(N+1)
S[1:] = list(input())
Q = int(input())
q1,q2,q3 = [0]*Q,[0]*Q,[0]*Q
for i in range(Q):
    tmp = input().split()
    q1[i],q2[i] = map(int,tmp[:2])
    if q1[i] == 2:
        q3[i] = int(tmp[2])
    else:
        q3[i] = tmp[2]

class BIT:
    def __init__(self, n, init_list):
        self.num = n + 1
        self.tree = [0] * self.num
        for i, e in enumerate(init_list):
            self.update(i, e)

    #a_kにxを加算
    def update(self, k, x):
        k = k + 1
        while k < self.num:
            self.tree[k] += x
            k += (k & (-k))
        return

    def query1(self, r):
        ret = 0
        while r > 0:
            ret += self.tree[r]
            r -= r & (-r)
        return ret

    #通常のスライスと同じ。lは含み、rは含まない
    def query2(self, l, r):
        return self.query1(r) - self.query1(l)

s_pos = [BIT(N+1,[0]*(N+1)) for _ in range(26)]

for i in range(1,N+1):
    s_pos[ord(S[i]) - ord("a")].update(i,1)

alphabets = [chr(ord("a") + i) for i in range(26)]

for i in range(Q):
    if q1[i] == 1:
        s_pos[ord(S[q2[i]]) - ord("a")].update(q2[i],-1)
        S[q2[i]] = q3[i]
        s_pos[ord(q3[i]) - ord("a")].update(q2[i],1)
    else:
        ans = 0
        for c in alphabets:
            if s_pos[ord(c) - ord("a")].query2(q2[i],q3[i]+1) > 0:
                ans += 1
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, a, b = map(int, input().split())

mod = 10 **9 +7
kinds = 0

def mod_factorial(n, m):
    r = 1
    for i in range(1, n+1):
        r *= i
        r %= m
    return r

def mod_inv_factorial(n, m):
    invs = [0] * (n + 1)
    invs[1] = 1
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m

    R = [1] * (n+1)

    for i in range(1, n+1):
        if i > 1:
            R[i] = R[i-1]*invs[i]
            R[i] %= m
        else:
            R[i] = invs[i]
    return R


fact_n = mod_factorial(n, mod)
Rs = mod_inv_factorial(n, mod)


for i in range(1, n+1):
    if i != a and i != b:
        kinds += fact_n * Rs[i] * Rs[n-i]
        kinds %= mod

print(kinds % mod)

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

mod = 10 **9 +7
kinds = 0

def mod_factorial(nr, nl, m):
    r = 1
    for i in range(nl+1, nr+1):
        r *= i
        r %= m
    return r

def mod_inv_factorial(n1, n2, m):
    n = max(n1, n2)
    invs = [0] * (n + 1)
    invs[1] = 1
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m
        
    r1 = 1
    r2 = 1
    for i in range(1, n1+1):
        r1 *= invs[i]
        r1 %= m
    for i in range(1, n2+1):
        r2 *= invs[i]
        r2 %= m
    return r1, r2
        
        



kinds = 2 ** n -1

la = max(a, n-a)
sa = min(a, n-a)
lb = max(b, n-b)
sb = min(b, n-b)

upper1 = mod_factorial(n, la, mod)
upper2 = mod_factorial(n, lb, mod)

r1, r2 = mod_inv_factorial(sa, sb, mod)

print((kinds - upper1 * r1 - upper2 * r2)% mod)
t = 0
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = [int(a) for a in input().split()]

B = [0]*(N-K+1)
for i in range(N-K+1):
    B[i] = sum(p[i:i+K])

max_ind = B.index(max(B))

ep = 0
for i in range(K):
    ep += (p[max_ind+i]*(p[max_ind+i]+1))/(2*p[max_ind+i])

print(ep)

Fixed submission:
N, K = map(int, input().split())
p = [int(a) for a in input().split()]

B = [0]*(N-K+1)
B[0] = sum(p[0:K])
for i in range(1, N-K+1):
    B[i] = B[i-1] - p[i-1] + p[i+K-1]
    
max_ind = B.index(max(B))

ep = 0
for i in range(K):
    ep += (p[max_ind+i]*(p[max_ind+i]+1))/(2*p[max_ind+i])

print(ep)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
p = [int(a) for a in input().split()]

B = [0]*(N-K+1)
for i in range(N-K+1):
    B[i] = sum(p[i:i+K])

max_ind = B.index(max(B))

ep = 0
for i in range(K):
    ep += (p[max_ind+i]*(p[max_ind+i]+1))/(2*p[max_ind+i])

print(ep)


Fixed submission:
N, K = map(int, input().split())
p = [int(a) for a in input().split()]

B = [0]*(N-K+1)
B[0] = sum(p[0:K])
for i in range(1, N-K+1):
    B[i] = B[i-1] - p[i-1] + p[i+K-1]
    
max_ind = B.index(max(B))

ep = 0
for i in range(K):
    ep += (p[max_ind+i]*(p[max_ind+i]+1))/(2*p[max_ind+i])

print(ep)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K = map(int, input().split())
H = [int(i) for i in input().split()]

for i in range(K):
    H[np.argmax(H)] = 0
print(sum(H))

Fixed submission:
N, K = map(int, input().split())
H = [int(i) for i in input().split()]

H.sort()

if N-K >= 0:
    H[N-K:N] = [0]*K
else:
    H[:] = [0]*N
print(sum(H))