Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02681 (python)

Fixed submission:
S,T=[input() for i in range(2)]
U=list(S)
W=list(T)
if S in T and len(S)+1==len(T) and U[0]==W[0]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S,T=[input() for i in range(2)]
U=list(S)
W=list(T)
if S in T and len(S)+1==len(T) and U[1]==W[1]:
  print("Yes")
else:
  print("No")
Problem p02718 (python)

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
total=0
for i in range(N):
  total+=A[i]
if A[M-1]>=total/(4*M):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
total=0
for i in range(N):
  total+=A[i]
if A[M]>=total/(4*M):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
total=0
for i in range(M):
  total+=A[i]
if A[M]>=total/(4*M):
  print("Yes")
else:
  print("No")
Problem p02812 (python)

Fixed submission:
N=int(input())
S=list(input())
count=0
for i in range(N-2):
  if S[i]=="A":
    if S[i+1]=="B":
      if S[i+2]=="C":
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N>50:
  N=50
S=list(input())
count=0
for i in range(N):
  if S[i]=="A":
    if S[i+1]=="B":
      if S[i+2]=="C":
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=list(input())
count=0
for i in range(N):
  if S[i]=="A":
    if S[i+1]=="B":
      if S[i+2]=="C":
        count+=1
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=list(input())
count=0
for i in range(N):
  if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
    count+=1
print(count)
Problem p02621 (python)

Fixed submission:
def main():
    a = int(input())

    print(a + (a ** 2) + (a ** 3))
 
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, m, k = map(int, input().split())
    a = [int(x) for x in input().split()]
    b = [int(x) for x in input().split()]

    a_sum = [0 for x in range(n)]
    b_sum = [0 for x in range(m)]

    a_sum[0] = a[0]
    b_sum[0] = b[0]

    max_counter = 0

    for i in range(1, n):
        a_sum[i] = a[i] + a_sum[i - 1]

    for i in range(1, m):
        b_sum[i] = b[i] + b_sum[i - 1]

    for i in range(n):
        for j in range(m):
            if k >= a_sum[i] + b_sum[j] and max_counter < i + j + 2:
                max_counter = i + j + 2
        
    print(max_counter)

if __name__ == '__main__':
    main()
Problem p02609 (python)

Fixed submission:
def f(n):
    if n == 0:
        return 0
    return f(n % bin(n).count("1")) + 1


def solve():
    N = int(input())
    X = input()
    p = X.count("1")
    rem_plus = 0
    rem_minus = 0
    for i in range(N):
        k = N - i - 1
        if X[i] == "0":
            continue
        elif p > 1:
            rem_minus = (rem_minus + pow(2, k, p - 1)) % (p - 1)
        rem_plus = (rem_plus + pow(2, k, p + 1)) % (p + 1)
    for i in range(N):
        k = N - i - 1
        if X[i] == "0":
            print(f((rem_plus + pow(2, k, p + 1)) % (p + 1)) + 1)
        elif p > 1:
            print(f((rem_minus - pow(2, k, p - 1)) % (p - 1)) + 1)
        else:
            print(0)


if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def func(nStep:int, X) -> int:
    nStep += 1
    newX = X % bin(X).count('1')
    if newX == 0:
        return nStep
    else:
        return func(nStep, newX)

def solve():
    N = int(input())
    X = input()
    for i in range(N):
        print(func(0, int(X,2)^(1<<(N-i-1))))

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def func(nStep:int, X) -> int:
    nStep += 1
    newX = X % bin(X).count('1')
    if newX == 0:
        return nStep
    else:
        return func(nStep, newX)

def solve():
    N = int(input())
    X = input()
    for i in range(N):
        print(func(0, int(format(int(X,2)^(1<<(N-i-1)),'b').zfill(N), 2)))

if __name__ == "__main__":
    solve()
Problem p02812 (python)

Fixed submission:
n = int(input())
s = input()
count = 0
for i in range(n - 2):
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
count = 0
for i in range(n):
    if s[i] == "A" and s[i + 1] == "B" and s[i + 2] == "C":count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
count = 0
for i in range(n):
    if s[i] == "A":
        if s[i+ 1] == "B":
            if s[i + 2] == "C":
                count += 1
print(count)
Problem p02606 (python)

Fixed submission:
l, r, d = map(int, input().split())
ans = 0
for i in range(l, r + 1):
    if i % d == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i < r + 1; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}
Problem p02675 (python)

Fixed submission:
N = int(input())
n = N % 10

if n == 3:
    print('bon')
elif n in [0, 1, 6, 8]:
    print('pon')
else:
    print('hon')

Buggy submission (verdict: Runtime Error):
import math

a,b,h,m=map(int,input().split())
deg=abs(h*30+m*0.5)-(m*6)
if deg>=180:
 deg=360-deg
c=math.sqrt(a**2+b**2-2*a*b*math.cos(math.pi*deg/180))
print(c)

Buggy submission (verdict: Runtime Error):
import math
a, b, h, m = map(int,input().split())

a_s = (30 * h) % 360 + 0.5 * m
b_s = (6*m)

s = max(a_s,b_s) - min(a_s,b_s)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)

Buggy submission (verdict: Runtime Error):

A, B, H, M = list(map(int, input().split()))

import math
A_x = A * math.cos(2 * math.pi * (H + M / 60.) / 12.)
A_y = A * math.sin(2 * math.pi * (H + M / 60.) / 12.)
B_x = B * math.cos(2 * math.pi * M / 60.)
B_y = B * math.sin(2 * math.pi * M / 60.)

print('{:.15f}'.format(math.sqrt((A_x - B_x) ** 2 + (A_y - B_y) ** 2)))

Buggy submission (verdict: Runtime Error):
import math
A, B, H, M = map(int, input().split())

A_x = A * math.cos(2 * math.pi * (H + M / 60.) / 12.)
A_y =  A * math.sin(2 * math.pi * (H + M / 60.) / 12.)
B_x = B * math.cos(2 * math.pi * M / 60.)
B_y = B * math.sin(2 * math.pi * M / 60.)

print('{:.15f}'.format(math.sqrt((A_x - B_x) ** 2 + (A_y - B_y) ** 2)))

Buggy submission (verdict: Runtime Error):
import math
A, B, H, M = map(int, input().split())

dgree_h = H / 12. * 360.
dgree_m = M / 60. * 360.

ang = math.pi / 180. * abs(dgree_h - dgree_m)
print(ang)


a = '{:.21f}'.format(math.sqrt(A ** 2. + B ** 2. - 2. * A * B * math.cos(ang)))
print((a))
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

if S == T[0:-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S, T = input().split()

if S == T[0:-1]:
    print('Yes')
else:
    print('No')
Problem p02687 (python)

Fixed submission:
S = input()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(m):
 a,b=map(int,input().split())
 g[a].append(b)
 g[b].append(a)
ans=0
for v in range(1,n+1):
 for u in g[v]: #i番目の展望台から1本の道を通っていけるすべての展望台と高さを比較する
   if arr[u]>=arr[v]:
     break
 else: #i番目の展望台の高さが他のすべての展望台の高さより真に大きければ答えを1増やす
   ans+=1
print(ans)
Problem p02696 (python)

Fixed submission:

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

x = min(B - 1, N)
ans = int(A * x / B)
print(ans)

Buggy submission (verdict: Runtime Error):

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

x = min(B - 1, N)
ans = int(a * x / b)
print(ans)
Problem p03494 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
count = 0
while True:
    for i in range(n):
        fin = True
        if a[i] % 2 == 0:
            a[i] = (a[i] / 2)
        else:
            fin = False
            break
    if fin:
        count += 1
    else:
        break
print(count)

Buggy submission (verdict: Runtime Error):
input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for i in A):
    A = [a/2 for a in A]
    count += 1
print(count)
Problem p02789 (python)

Fixed submission:
n , m = input().split()

if n == m:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = input()
m = input()

if n == m:
    print("Yes")
else:
    print("No")
Problem p02608 (python)

Fixed submission:
n = int(input())
memo = [0]*10010

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            z = i**2+j**2+k**2+i*j+j*k+k*i
            if z <= n:
                memo[z] += 1


for i in range(1, n+1):
    print(memo[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
memo = [0]*1010

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            z = i**2+j**2+k**2+i*j+j*k+k*i
            if z <= n:
                memo[z] += 1


for i in range(1, n+1):
    print(memo[i])
Problem p02642 (python)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
A.sort()
c = Counter(A)

if c[1]==1:
    print(1)
elif c[1] > 1:
    print(0)
else:
    mx = 10**6+10
    ok = [True]*mx
    ans = 0
    for a in A:
        if ok[a]:
            if c[a] == 1:
                ans += 1
            for i in range(mx):
                if i*a >= mx:
                    break
                ok[i*a] = False
        else:
            continue
    print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
if 1 in A:
    print(0)
else:
    c = Counter(A)
    lst = []
    for k,v in c.items():
        if v==1:
            lst.append(k)
    lst.sort()
    mx = max(lst)
    ans = 0
    err = [False] + [True]*(mx)
    for l in lst:
        if err[l]:
            ans += 1
            i = 0
            while True:
                err[l*i] = False
                i += 1
                if l*i > mx:
                    break
    print(ans)
Problem p02678 (python)

Fixed submission:
from collections import deque
n,m = map(int,input().split())
visited = [-1 for _ in range(n)]
g = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
pos = 0
que = deque([])
if g[0]:
    visited[0] = 0
    for nx in g[0]:
        que.append((nx, 0))
while que:
    to, now = que.popleft()
    if visited[to] != -1:
        continue
    else:
        visited[to] = now
        for nx in g[to]:
            que.append((nx, to))
visited = visited[1:]
if -1 in visited:
    print('No')
else:
    print('Yes')
    for k in visited:
        print(k+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m = map(int,input().split())
visited = [-1 for _ in range(n)]
g = [[] for _ in range(m)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
pos = 0
que = deque([])
if g[0]:
    visited[0] = 0
    for nx in g[0]:
        que.append((nx, 0))
while que:
    to, now = que.popleft()
    if visited[to] != -1:
        continue
    else:
        visited[to] = now
        for nx in g[to]:
            que.append((nx, to))
visited = visited[1:]
if -1 in visited:
    print('No')
else:
    print('Yes')
    for k in visited:
        print(k+1)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m = map(int,input().split())
visited = [False for _ in range(n)]
label = [-1 for _ in range(n)]
g = [[] for _ in range(m)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

pos = 0
que = deque([])
for nx in g[0]:
    que.append((nx, pos))
while que:
    to, now = que.popleft()
    if visited[to] == True:
        continue
    else:
        visited[to] = True
        label[to] = now
        for nx in g[to]:
            que.append((nx, to))
if -1 in label[1:]:
    print('No')
else:
    print('Yes')
    for l in label[1:]:
        print(l+1)
Problem p02683 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10*7)

def bit_fullsearch(target):
    n = len(target)
    ret = []
    for i in range(2**n):
        tmp = []
        for j in range(n):
            if (i>>j)&1:
                tmp.append(target[j])
        ret.append(tmp)
    return ret

n,m,x = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(n)]
ans = float('inf')

for l in bit_fullsearch(lst):
    tmp = [0 for _ in range(m+1)]
    for k in l:
        for i in range(m+1):
            tmp[i] += k[i]
    if min(tmp[1:]) >= x:
        ans = min(ans, tmp[0])
print(ans if ans!=float('inf') else -1)

Buggy submission (verdict: Runtime Error):
import sys #追加
sys.setrecursionlimit(10*7)
 
def bit_fullsearch(target):
    n = len(target)
    ret = []
    for i in range(2**n):
        tmp = []
        for j in range(n):
            if (i>>j)&1:
                tmp.append(target[j])
        ret.append(tmp)
    return ret

n,m,x = map(int,input().split())
choice = [i for i in range(n)]
l = [list(map(int,input().split())) for _ in range(n)]
ans = float('inf')
for lst in bit_fullsearch(choice):
    tmp = 0
    A = [0 for _ in range(m)]
    if len(lst)==0:
        continue
    elif len(lst)==1:
        tmp = l[0]
        j = lst[0]
        for k in range(m):
            A[k] += l[j][1+k]
    else:
        for j in lst:
            tmp += l[j][0]
            for k in range(m):
                A[k] += l[j][1+k]
    if min(A) >= x:
        ans = min(ans, tmp)
print(ans if ans!=float('inf') else -1)

Buggy submission (verdict: Runtime Error):
def bit_fullsearch(target):
    n = len(target)
    ret = []
    for i in range(2**n):
        tmp = []
        for j in range(n):
            if (i>>j)&1:
                tmp.append(target[j])
        ret.append(tmp)
    return ret

n,m,x = map(int,input().split())
choice = [i for i in range(n)]
l = [list(map(int,input().split())) for _ in range(n)]

ans = float('inf')
for lst in bit_fullsearch(choice):
    tmp = 0
    A = [0 for _ in range(m)]
    if len(lst)==0:
        continue
    elif len(lst)==1:
        tmp = l[0]
        j = lst[0]
        for k in range(m):
            A[k] += l[j][1+k]
    else:
        for j in lst:
            tmp += l[j][0]
            for k in range(m):
                A[k] += l[j][1+k]
    if min(A) >= x:
        ans = min(ans, tmp)
print(ans if ans!=float('inf') else -1)
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
A = [0]+list(map(int,input().split()))
visited = [False for _ in range(n+1)]
pos = 1
x = []
flg = False
for i in range(k):
    if visited[pos] == False:
        x.append(pos)
        visited[pos] = True
        pos = A[pos]
    else:
        flg = True
        pre = x.index(pos)
        loop = x[pre:]
        break
if not flg:
    print(pos)
else:
    print(loop[(k-pre)%len(loop)])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
A = [0]+list(map(int,input().split()))
visited = [False for _ in range(n+1)]
pos = 1
x = []
flg = False
for i in range(k):
    if visited[pos] == False:
        x.append(pos)
        visited[pos] = True
        pos = A[pos]
    else:
        flg = True
        pre = x.index(pos)
        loop = x[pre:]
        break
print(loop[(k-pre)%len(loop)] if flg else x[k])

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
A = list(map(int,input().split()))
visited = [False for _ in range(5)]
nx = A[0] - 1
x = []
p = -1
for e, i in enumerate(range(n)):
    if visited[nx] == False:
        visited[nx] = True
        x.append(nx)
        nx = A[nx] - 1
    else:
        p = x.index(nx)
        q = x[:p]
        r = x[p:]
        break
if p!=-1:
    k = (k-len(q))%len(r)
    print(r[k-1]+1)
else:
    print(x[k-1])
Problem p02696 (python)

Fixed submission:
import math
def f(x,y,z):
    # x,y,z = A,x,B
    return math.floor(x*y/z) - x*math.floor(y/z)
a,b,n = map(int,input().split())
if n<b:
    print(math.floor(a*n/b))
else:
    print(f(a, b-1, b))

Buggy submission (verdict: Runtime Error):
import math
def f(x,y,z):
    # x,y,z = A,x,B
    return math.floor(x*y/z) - x*math.floor(y/z)

a,b,n = map(int,input().split())
if n<b:
    print(math.floor(a*n/b))
else:
    k = n//b
    x = b*k-1
    print(f(a,x,b) - a*f(x,b))

Buggy submission (verdict: Runtime Error):
import math
def f(x,y,z):
    # x,y,z = A,x,B
    return math.floor(x*y/z) - x*math.floor(y/z)

a,b,n = map(int,input().split())
if n<b:
    print(math.floor(a*n/b))
else:
    k = n//b
    x = b*k-1
    print(f(a,x,b) - a*f(x,b))
Problem p02702 (python)

Fixed submission:
s = list(input())
mod = 2019
tot = [0]
ans = 0
dp = [0 for _ in range(2020)]
dp[0] = 1
for i in range(len(s)):
    nx = tot[i] + int(s[i])*(pow(10,(len(s)-i),mod))
    nx %= mod
    if dp[nx] != 0:
        ans += dp[nx]
    dp[nx] += 1
    tot.append(nx)
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
a = []
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        a.append(s[i:j])

l = []
x = 2019
while x<=200000:
    l.append(x)
    x += 2019
ans = 0

for x in l:
    ans += a.count(str(x))
print(ans)
Problem p02720 (python)

Fixed submission:
k = int(input())
ans = [str(i) for i in range(1, 10)]
tmp = [str(i) for i in range(1, 10)]
cnt = 10
if k<=9:
    print(k)
else:
    while cnt<=k:
        ap = []
        for t in tmp:
            if t[-1]=='0':
                ap.append(t+'0')
                ap.append(t+'1')
            elif t[-1]=='9':
                ap.append(t+'8')
                ap.append(t+'9')
            else:
                l = int(t[-1])
                ap.append(t+str(l-1))
                ap.append(t+str(l))
                ap.append(t+str(l+1))
        cnt += len(ap)
        tmp = ap
    print(tmp[k-cnt])

Buggy submission (verdict: Runtime Error):
import copy
n,k,c = map(int,input().split())
dp = [0]*(n+c+2)
s = input()
idx = []
for i in range(n):
    if s[i]=='o':
        idx.append(i+1)
for i in idx:
    dp[i] += 1
    dp[i+c+1] -= 1
for i in range(1,len(dp)):
    dp[i] = dp[i]+dp[i-1]       

for i in idx:
    tmp = copy.deepcopy(dp)
    for j in range(i, i+c+1):
        tmp[j] -= 1
    cnt = 0
    flg = False
    for j in range(len(tmp[1:-1])):
        if tmp[1+j]!=0 and flg==False:
            flg = True
            cnt += 1
        if tmp[1+j]!=0 and flg:
            continue
        if tmp[1+j]==0:
            flg = False
    if cnt<k:
        print(i)
Problem p02721 (python)

Fixed submission:
import bisect
n,k,c = map(int,input().split())
s = input()

lst = []
for i in range(n):
    if s[i]=='o':
        lst.append(i+1)

x,y = [],[]
for i in range(len(lst)):
    if i==0:
        x.append(lst[i])
    else:
        if lst[i]-x[-1]>c:
            x.append(lst[i])
    if len(x)==k:
        break

for i in range(len(lst))[::-1]:
    if i==len(lst)-1:
        y.append(lst[i])
    else:
        if y[-1]-lst[i]>c:
            y.append(lst[i])
    if len(y)==k:
        break

x.sort()
y.sort()

ans = []
for i in range(k):
    if x[i]==y[i]:
        ans.append(x[i])
for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
import numpy as np
import copy
n,k,c = map(int,input().split())
dp = [0]*(n+c+2)
s = input()
idx = []
for i in range(n):
    if s[i]=='o':
        idx.append(i+1)
for i in idx:
    dp[i] += 1
    dp[i+c+1] -= 1
dp = np.cumsum(dp).tolist()

for i in idx:
    tmp = copy.deepcopy(dp)
    for j in range(i, i+c+1):
        tmp[j] -= 1

    cnt = 0
    flg = False
    for j in range(len(tmp[1:-1])):
        if tmp[1+j]!=0 and flg==False:
            flg = True
            cnt += 1
        if tmp[1+j]!=0 and flg:
            continue
        if tmp[1+j]==0:
            flg = False
    if cnt<k:
        print(i)
Problem p02741 (python)

Fixed submission:
lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lst[int(input())-1])

Buggy submission (verdict: Runtime Error):
lst = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(lst[int(input()-1)])
Problem p02756 (python)

Fixed submission:
from collections import deque
s = input()
Q = int(input())
s = deque([s])
rev = 1
for i in range(Q):
    tmp = list(input().split())
    if len(tmp)==1:
        rev *= -1
    else:
        f,c = tmp[1], tmp[2]
        if rev > 0:
            if f=='1':
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if f=='1':
                s.append(c)
            else:
                s.appendleft(c)
s = ''.join(list(s))
print(s if rev > 0 else s[::-1])

Buggy submission (verdict: Runtime Error):
s = input()
Q = int(input())
for i in range(Q):
    tmp = list(input())
    if len(tmp)==1:
        s = s[::-1]
    else:
        f,c = tmp[2], tmp[4]
        if f=='1':
            s = '{}{}'.format(c,s)
        elif f=='2':
            s = '{}{}'.format(s,c)
        print(s)
print(s)
Problem p02768 (python)

Fixed submission:
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1

comb1 = 1
for i in range(n-a+1, n+1):
    comb1 *= i
    comb1 %=  mod
for i in range(1, a+1):
    comb1 *= pow(i, mod-2, mod)
    comb1 %=  mod

comb2 = 1
for i in range(n-b+1, n+1):
    comb2 *= i
    comb2 %=  mod
for i in range(1, b+1):
    comb2 *= pow(i, mod-2, mod)
    comb2 %=  mod
ans -= (comb1 + comb2)
print(ans % mod)

Buggy submission (verdict: Runtime Error):
class Cmb:
    def __init__(self, N=10**5, mod=10**9+7):
        self.fact = [1,1]
        self.fact_inv = [1,1]
        self.inv = [0,1]
        
        """ 階乗を保存する配列を作成 """
        for i in range(2, N+1):
            self.fact.append((self.fact[-1]*i) % mod)
            self.inv.append((-self.inv[mod%i] * (mod//i))%mod)
            self.fact_inv.append((self.fact_inv[-1]*self.inv[i])%mod)
    
    """ 関数として使えるように、callで定義 """
    def __call__(self, n, r, mod=10**9+7):
        if (r<0) or (n<r):
            return 0
        r = min(r, n-r)
        return self.fact[n] * self.fact_inv[r] * self.fact_inv[n-r] % mod

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

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
mod=10**9+7

def sig(n):
    #return 2**n
    if n==1:
        return 2
    elif n%2==0:
        return (sig(n//2)**2)%mod
    else:
        return (2*sig((n-1)//2)**2)%mod
    
s = sig(n) - 1

MAX = 10**5*3

facts = [1 for i in range(n)]
invs = [1 for i in range(n)]

def inv(x):
	return pow(x,mod-2,mod)
 
for i in range(1,MAX):
		facts[i] = (facts[i-1] * i)% mod
		invs[i] = inv(facts[i])

def nCr(n,r):
	return facts[n]*invs[r] * invs[n-r] % mod

x = nCr(n,a)%mod
y = nCr(n,b)%mod

if s-(x+y) < 0:
    print(s-(x+y)+mod)
else:
    print(s-(x+y)%mod)
Problem p02814 (python)

Fixed submission:
import fractions
"""最小公倍数"""
def lcm(a,b):
    f = fractions.gcd(a,b)
    return a*b//f

n,m = map(int,input().split())
A = list(map(int,input().split()))
l = A[0]
for a in A[1:]:
    l = lcm(l, a)

if n==1:
    if l%2!=0:
        print(0)
    else:
        if l/2>m:
            print(0)
        else:
            print(1 + int((m-l//2)/l))

else:
    flg = True
    for a in A:
        if (l//a)%2==0:
            flg = False
    if not flg:
        print(0)
    else:
        minx = l//2
        if minx>m:
            print(0)
        else:
            print(1 + int((m-minx)//l))

Buggy submission (verdict: Runtime Error):
import math

"""最小公倍数"""
def lcm(a,b):
    f = math.gcd(a,b)
    return a*b//f

n,m = map(int,input().split())
A = list(map(int,input().split()))
l = A[0]
for a in A[1:]:
    l = lcm(l, a)
flg = True
for a in A:
    if (l//a)%2==0:
        flg = False
if not flg:
    print(0)
else:
    minx = l//2
    if minx>m:
        print(0)
    else:
        print(1 + m//l)