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

Fixed submission:
N=int(input())
ans =1
A = list(map(int,input().split()))
for i in A:
        if i == 0:

               print(0)
               exit()
for i in A:
      
       ans *=i
       if ans >10**18:
               print(-1)
               exit()
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans =1
A = list(map(int,input().split()))
for i in A:
        if i =0:

               print(0)
               exit()
for i in A:
      
       ans *=i
       if ans >10**18:
               print(-1)
               exit()
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans =1
A = list(map(int,input().split()))
if i in A:
        i =0
        print(0)
        exit()
for i in A:
      
       ans *=i
       if ans >10**18:
               print(-1)
               exit()
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans =1
A = list(map(int,input().split()))
for i in A
      
       ans *=A
if ans <=10**18:
        print(ans)
else:
        print(-1)
Problem p02675 (python)

Fixed submission:
N=(input())
x = int(N[-1])
A =[2,4,5,7,9]
if x in A:
    print('hon')
elif x == 3:
    print('bon')
else:
    print('pon')

Buggy submission (verdict: Runtime Error):
K=int(input())
s =input()
x = len(s)

if x<=K:
    print(s)
else:
    print(s[:K]+'...')
Problem p02677 (python)

Fixed submission:
import math
a,b,h,m=map(int,input().split())
x =(math.pi)*h/6 - (math.pi)*m/30 + (math.pi)*m/360
c = math.sqrt(a**2+b**2-2*a*b*(math.cos(x)))
print(c)

Buggy submission (verdict: Runtime Error):
import math
a,b,h,m=map(int,input().split())
x =(math.pi)*h/6 - (math.pi)*m/30) + (math.pi)*m/360
c =a**2+b**2-2*a*b*(math.cos(x))
c = math.sqrt(c)
print(c)
Problem p02802 (python)

Fixed submission:
n,m=map(int,input().split())
l1 = [0]*n
l2 = [0]*n
for i in range(m):
        p,s=map(str,input().split())
        p= int(p)
        if s == 'AC':
                l2[p-1] +=1
        else:
                if l2[p-1] == 0:
                        l1[p-1] +=1
cntac = 0
cntwa = 0
for i in range(n):
        if l2[i] != 0:
                cntac +=1
                cntwa += l1[i]

                
                
print(cntac,cntwa)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l1 = [0]*n
l2 = [0]*n
for i in range(m):
        p,s=map(str,input().split())
        p= int(p)
        if s == 'AC':
                if l2[p-1] == 0:
                        l2[p-1] +=1
                else:
                        pass 
        else:
                if l2[p-1] == 0:
                        l1[p-1] +=1
                else:
                        pass
for i in range(n):
        if l2[i] == 0:
                l1[i] == 0:
                
print(sum(l2),sum(l1))
Problem p02813 (python)

Fixed submission:
from itertools import permutations
n=int(input())
p,q = tuple(map(int, input().split())), tuple(map(int, input().split()))
l = list(range(1,n+1))
x = [i for i in permutations(l,n)]
print(abs(x.index(p) - x.index(q)))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
n=int(input())
p,q = = tuple(map(int, input().split())), tuple(map(int, input().split()))
l = list(range(1,n+1))
x = [i for i in permutations(l,n)]
print(abs(x.index(p) - x.index(q)))
Problem p02969 (python)

Fixed submission:
n=int(input())
print(3*n**2)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = [int(input()) for _ in range(n)]
b = max(a)
c = a.index(b)
for i in range(n):
        if i == c:
                print(max(sorted(a)[:n-1]))
        else:
                print(b)
Problem p02971 (python)

Fixed submission:
n=int(input())
a = [int(input()) for _ in range(n)]
b = max(a)
c = a.index(b)
for i in range(n):
        if i == c:
                print(max(sorted(a)[:n-1]))
        else:
                print(b)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = [int(input()) for _ in range(n)]
b = max(l)
c = a.index(b)
for i in range(n):
        if i == c:
                print(max(sorted(a)[:n-1]))
        else:
                print(b)
Problem p02982 (python)

Fixed submission:
n,d =map(int,input().split())
l= [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n):
    for j in range(i+1,n):
        a = 0
        for k in range(d):
            a += (l[i][k] - l[j][k])**2
        a **=0.5
        if a.is_integer():
            ans +=1
print(ans)

Buggy submission (verdict: Runtime Error):
n,d =map(int,input().split())
l= [list(map(int, input().split())) for i in range(N)]
a = 0
ans +=1
for i in range(n):
    for j in range(i+1,n):
        for k in range(d):
            a += l[i][k]**2 - l[j][k]**2
            a **=0.5
            if a.is_integer:
                ans +=1
print(ans)
Problem p03037 (python)

Fixed submission:
n,m =map(int,input().split())
a =[]*m
b =[]*m
for i in range(m):
        l,r =map(int,input().split())
        a.append(l)
        b.append(r)

if max(a) <=min(b):
        print(min(b)-max(a)+1)
else:
        print(0)

Buggy submission (verdict: Runtime Error):
n,m =map(int,input().split())
a =[]*m
b =[]*m
for i in range(n):
        l,r =map(int,input().split())
        a.append(l)
        b.append(r)

if max(a) <=min(b):
        print(min(b)-max(a)+1)
else:
        print(0)
Problem p03086 (python)

Fixed submission:
s=input()
l = [0]
cnt = 0
for i in s:
    if i =='A'or i == 'C' or i == 'G' or i == 'T':
        cnt +=1
        l.append(cnt)
    else:
        cnt = 0
print(max(l))

Buggy submission (verdict: Runtime Error):
s=input()
l = []
cnt = 0
for i in s:
    if i =='A'or i == 'C' or i == 'G' or i == 'T':
        cnt +=1
        l.append(cnt)
    else:
        cnt = 0
print(max(l))

Buggy submission (verdict: Runtime Error):
s=input()
l = []
cnt = 0
for i in s:
    if i =='A'or i == 'C' or i == 'G' or i == 'T':
        cnt +=1
    else:
        l.append(cnt)
        cnt = 0
print(max(l))
Problem p03103 (python)

Fixed submission:
n,m = map(int,input().split())
a = [list(map(int, input().split())) for _ in range(n)]
ans = 0
cnt = 0
a = sorted(a, key=lambda x:x[0])
for i in range(n):
    if cnt + a[i][1] <m:
        ans += a[i][0]*a[i][1]
        cnt +=a[i][1]
    else:
        ans += a[i][0]*(m-cnt)
        break
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
d = {}
cnt = 0
ans = 0
for i in range(n):
    a,b =map(int,input().split())
    d[a] = b
while cnt <m:
    if cnt+d[min(d)] <m:
        ans += min(d)*d[min(d)]
        cnt +=d[min(d)]
        del d[min(d)]
    else:
        ans += min(d)*(m-cnt)
        break
print(ans)
Problem p03261 (python)

Fixed submission:
n=int(input())
w = [(input()) for _ in range(n)]
l = set(w)
if len(w) != len(l):
        print('No')
        exit()
for i in range(n-1):
        if w[i][len(w[i])-1] != w[i+1][0]:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
n=int(input())
w = [(input()) for _ in range(n)]
l = set(w)
if len(w) != len(l):
        print('No')
        exit()
for i in range(n-1):
        if w[i][len(w[i]-1)] != w[i+1][0]:
                print('No')
                exit()
print('Yes')
Problem p03294 (python)

Fixed submission:
n=int(input())
l = list(map(int, input().split()))
print(sum(l) - n)

Buggy submission (verdict: Runtime Error):
n=int(input())
l = list(map(int, input().split()))
print(sum(l) = n)
Problem p03361 (python)

Fixed submission:
h,w=map(int,input().split()) 
l = [input() for _ in range(h)]
dx = [1,-1,0,0]
dy = [0,0,1,-1]
for i in range(h):
    for j in range(w):
        if l[i][j] =='#':
            cnt = 0
            for di in range(4):
                y = i+dx[di]
                x = j+dy[di]
                if x<0 or y<0 or x>w-1 or y>h-1:
                    continue
                else:
                    if l[y][x] =='#':
                        cnt +=1
            if cnt == 0:
                print('No')
                exit()

print('Yes')

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split()) 
l = [input() for _ in range(h)]
dx = [1,-1,0,0]
dy = [0,0,1,-1]
ans = 'No'
for i in range(w):
    for j in range(h):
        if l[j][i] =='#':
            for di in range(4):
                x = i+dx[di]
                y = j+dy[di]
                if x<0 or y<0 or x>w-1 or y>h-1:
                    continue
                else:
                    if l[x][y] =='#':
                        ans = 'Yes'
print(ans)

Buggy submission (verdict: Runtime Error):
5 5
#.#.#
.#.#.
#.#.#
.#.#.
#.#.#
Problem p03449 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int, input().split()))
ans = 0
for i in range(n):
        ans = max(ans,sum(a[:i+1])+sum(b[i:n]))
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int, input().split()))
ans = 0
        for i in range(n):
                        ans = max(ans,sum(a[:i+1])+sum(b[i:n]))
Problem p03471 (python)

Fixed submission:
n,y=map(int,input().split())
y //=1000
for i in range(n+1):
    for j in range(n-i+1):
        if n -(i+j) < 0:
            break
        if 9*i+4*j+n == y:
            print(i,j,n-(i+j))
            exit()
print('-1','-1','-1')

Buggy submission (verdict: Runtime Error):
n,y=map(int,input().split())
y //=1000
for i in range(n+1):
    for j in range(n-i+1):
        if n -(i+j) < 0
            break
        if 9*i+4*j+n == y:
            print(i,j,n-(i+j))
            exit()
print('-1','-1','-1')
Problem p03644 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(n):
    if 2**i <=n:
        ans = 2**i
    else:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
    if 2**i <=n:
Problem p03760 (python)

Fixed submission:
o = input()
e = input()
ans = ''
for i in range(len(e)):
    ans +=o[i]+e[i]
if len(o) != len(e):
    ans +=o[-1]
print(ans)

Buggy submission (verdict: Runtime Error):
o = input()
e = input()
ans = ''
for i in range(len(o)):
    ans +=o[i]+e[i]
if len(o) != len(e):
    ans +=e[-1]
print(ans)
Problem p02609 (python)

Fixed submission:
import collections
N=int(input())
X=list(input())
X=list(map(int,X))
#print(X)
ans1=0
ans2=0
c=collections.Counter(X)
div=c[1]
for i in range(N):
    ans1=(ans1+X[i]*pow(2,N-i-1,div+1))%(div+1)
    if div-1!=0:
        ans2=(ans2+X[i]*pow(2,N-i-1,div-1))%(div-1)
    else:
        ans2=None
    #print(ans1)
#print(ans1,div+1)
#print(ans2,div-1)
#ここまででXについてのXのbit数、X%(Xのbit数)がわかる
for i in range(N):
    cnt = 1
    if (X[i]==0):
        num=(ans1+pow(2,N-i-1,div+1))%(div+1)
        #print(num)
    else:
        if (div-1)!=0:
            num=(ans2+div-1-pow(2,N-i-1,div-1))%(div-1)
        else:
            cnt=0
            num=0
        #print(num)
    while num != 0:
        di = 0
        for j in range(18):
            if (num >> j)&1 == 1:
                di = di + 1
        num = num % di
        cnt = cnt + 1
    print(cnt)

Buggy submission (verdict: Runtime Error):
import collections
N=int(input())
X=list(input())
X=list(map(int,X))
#print(X)
ans1=0
ans2=0
c=collections.Counter(X)
div=c[1]
for i in range(N):
    ans1=(ans1+X[i]*pow(2,N-i-1,div+1))%(div+1)
    ans2=(ans2+X[i]*pow(2,N-i-1,div-1))%(div-1)
    #print(ans1)
#print(ans1,div+1)
#print(ans2,div-1)
#ここまででXについてのXのbit数、X%(Xのbit数)がわかる
for i in range(N):
    cnt = 1
    if (X[i]==0):
        num=(ans1+pow(2,N-i-1,div+1))%(div+1)
        #print(num)
    else:
        num=(ans2+div-1-pow(2,N-i-1,div-1))%(div-1)
        #print(num)
    while num != 0:
        di = 0
        for j in range(18):
            if (num >> j)&1 == 1:
                di = di + 1
        num = num % di
        cnt = cnt + 1
    print(cnt)
Problem p02615 (python)

Fixed submission:
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import collections
from heapq import *
import json
l=[]
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
l.sort(key=lambda x:x[0],reverse=True)
ans=0
num=N-1
for i in range(len(l)):
    if i==0:
        ans=ans+l[i][0]*min(2*l[i][1]-1,num)
        num=num-min(2*l[i][1]-1,num)
    else:
        ans=ans+l[i][0]*min(2*l[i][1],num)
        num=num-min(2*l[i][1],num)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import collections
from heapq import *
import json
l=[]
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
for i in range(len(key)):
    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
l.sort(key=lambda x:x[0],reverse=True)
ans=0
num=N-1
for i in range(len(l)):
    if i==0:
        ans=ans+l[i][0]*min(2*l[i][1]-1,num)
        num=num-min(2*l[i][1]-1,num)
    else:
        ans=ans+l[i][0]*min(2*l[i][1],num)
        num=num-xmin(2*l[i][1],num)
print(ans)
Problem p02618 (python)

Fixed submission:
D=int(input())                                          #コンテの日数
c=list(map(int,input().split()))                        #26タイプ(AAC~AZC)のコンテストの満足度低下度
s=[list(map(int,input().split())) for _ in range(D)]    #s[d][i]...d(1<=d<=D)日目にi(1<=i<=26)番目のコンテストを行った時の満足度上昇
#types=[int(input()) for _ in range(D)]                  #コンテタイプ(1~26)
#満足度低下はΣ(1<=i<=26)ci*(d-last(d,i))                  #なおlast(d,i)=d日目以前に最後にタイプiのコンテストをやった日にち(ない場合0)
#よって満足度はs[d][i]-Σ(1<=i<=26)ci*(d-last(d,i))
#i日目のスコアはmax(10^6+s[d][i]-Σ(1<=i<=26)ci*(d-last(d,i)),0)
#last=[0]*26                                             #typeごとに、最後に使われた日にちを記録するよ
typ=0
ans=0
#greedyに最大とりまーす
for i in range(D):
    ma=0
    ind=0
    for j in range(26):
        if ma<=s[i][j]:
            ma=s[i][j]
            ind=j
    print(ind+1)

Buggy submission (verdict: Runtime Error):
import random
D=int(input())                                          #コンテの日数
c=list(map(int,input().split()))                        #26タイプ(AAC~AZC)のコンテストの満足度低下度
s=[list(map(int,input().split())) for _ in range(D)]    #s[d][i]...d(1<=d<=D)日目にi(1<=i<=26)番目のコンテストを行った時の満足度上昇
#types=[int(input()) for _ in range(D)]                  #コンテタイプ(1~26)
#満足度低下はΣ(1<=i<=26)ci*(d-last(d,i))                  #なおlast(d,i)=d日目以前に最後にタイプiのコンテストをやった日にち(ない場合0)
#よって満足度はs[d][i]-Σ(1<=i<=26)ci*(d-last(d,i))
#i日目のスコアはmax(10^6+s[d][i]-Σ(1<=i<=26)ci*(d-last(d,i)),0)
#last=[0]*26                                             #typeごとに、最後に使われた日にちを記録するよ
typ=0
ans=0
#greedyに最大とりまーす
#D=365
types=[(i%26)+1 for i in range(D)]
#print(l)
sc = [0] * D
last=[0]*26
for i in range(D):
    typ = types[i] - 1
    score = s[i][typ]
    dwn = 0
    last[typ] = (i + 1)
    for j in range(26):
        dwn = dwn + c[j] * ((i + 1) - last[j])
    ans = score - dwn
    # print(score,last)
    sc[i] = ans
all = sum(sc)
for _ in range(800):
    types2 = []
    mi=float("inf")
    ind=0
    for i in range(D):
        if mi>sc[i]:
            mi=sc[i]
            ind=i
    l=list(range(1,27))
    lab1=l.pop(types[ind])
    lab2=random.choice(l)
    spans=ind//26
    types2=types
    for i in range(spans*26,min((spans+1)*26,D)):
        if types[i]==lab2:
            types[i]=lab1
            types[ind]=lab2
            break
    sc2=[0]*D
    last=[0]*26
    for i in range(D):
        typ = types[i] - 1
        score = s[i][typ]
        dwn = 0
        last[typ] = (i + 1)
        for j in range(26):
            dwn = dwn + c[j] * ((i + 1) - last[j])
        ans = score - dwn
                # print(score,last)
        sc2[i] = ans
    all2 = sum(sc2)
    if all2<all:
        types=types2
    else:
        sc=sc2
        all=all2
    #print(max(all,all2))
for i in range(D):
    print(types[i])
Problem p02619 (python)

Fixed submission:
D=int(input())                                          #コンテの日数
c=list(map(int,input().split()))                        #26タイプ(AAC~AZC)のコンテストの満足度低下度
s=[list(map(int,input().split())) for _ in range(D)]    #s[d][i]...d(1<=d<=D)日目にi(1<=i<=26)番目のコンテストを行った時の満足度上昇
types=[int(input()) for _ in range(D)]                  #コンテタイプ(1~26)
#満足度低下はΣ(1<=i<=26)ci*(d-last(d,i))                  #なおlast(d,i)=d日目以前に最後にタイプiのコンテストをやった日にち(ない場合0)
#よって満足度はs[d][i]-Σ(1<=i<=26)ci*(d-last(d,i))
#i日目のスコアはmax(10^6+s[d][i]-Σ(1<=i<=26)ci*(d-last(d,i)),0)
last=[0]*26                                             #typeごとに、最後に使われた日にちを記録するよ
typ=0
ans=0
for i in range(D):
    typ=types[i]-1
    score=s[i][typ]
    dwn=0
    last[typ]=(i+1)
    for j in range(26):
        dwn=dwn+c[j]*((i+1)-last[j])
    ans=ans+(score-dwn)
    #print(score,last)
    print(ans)
    #input()

Buggy submission (verdict: Runtime Error):
import random
D=int(input())                                          #コンテの日数
c=list(map(int,input().split()))                        #26タイプ(AAC~AZC)のコンテストの満足度低下度
s=[list(map(int,input().split())) for _ in range(D)]    #s[d][i]...d(1<=d<=D)日目にi(1<=i<=26)番目のコンテストを行った時の満足度上昇
#types=[int(input()) for _ in range(D)]                  #コンテタイプ(1~26)
#満足度低下はΣ(1<=i<=26)ci*(d-last(d,i))                  #なおlast(d,i)=d日目以前に最後にタイプiのコンテストをやった日にち(ない場合0)
#よって満足度はs[d][i]-Σ(1<=i<=26)ci*(d-last(d,i))
#i日目のスコアはmax(10^6+s[d][i]-Σ(1<=i<=26)ci*(d-last(d,i)),0)
#last=[0]*26                                             #typeごとに、最後に使われた日にちを記録するよ
typ=0
ans=0
#greedyに最大とりまーす
#D=365
types=[(i%26)+1 for i in range(D)]
#print(l)
sc = [0] * D
last=[0]*26
for i in range(D):
    typ = types[i] - 1
    score = s[i][typ]
    dwn = 0
    last[typ] = (i + 1)
    for j in range(26):
        dwn = dwn + c[j] * ((i + 1) - last[j])
    ans = score - dwn
    # print(score,last)
    sc[i] = ans
all = sum(sc)
for _ in range(800):
    types2 = []
    mi=float("inf")
    ind=0
    for i in range(D):
        if mi>sc[i]:
            mi=sc[i]
            ind=i
    l=list(range(1,27))
    lab1=l.pop(types[ind])
    lab2=random.choice(l)
    spans=ind//26
    types2=types
    for i in range(spans*26,min((spans+1)*26,D)):
        if types[i]==lab2:
            types[i]=lab1
            types[ind]=lab2
            break
    sc2=[0]*D
    last=[0]*26
    for i in range(D):
        typ = types[i] - 1
        score = s[i][typ]
        dwn = 0
        last[typ] = (i + 1)
        for j in range(26):
            dwn = dwn + c[j] * ((i + 1) - last[j])
        ans = score - dwn
                # print(score,last)
        sc2[i] = ans
    all2 = sum(sc2)
    if all2<all:
        types=types2
    else:
        sc=sc2
        all=all2
    #print(max(all,all2))
for i in range(D):
    print(types[i])
Problem p02727 (python)

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(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
l=[]
#print(p,q,r)
delicious=0
for i in range(X):
    l.append(p[i])
for i in range(Y):
    l.append(q[i])
l.sort(reverse=True)
#print(l)
for i in range(len(l)-C):
    #print(l[i])
    delicious=delicious+l[i]
lidx=max(0,len(l)-C)
#print(l,r,lidx)
cidx=0
#print(delicious,lidx,cidx,l,r,l[lidx],r[cidx])
for j in range(min(C,X+Y)):
    if (l[lidx]<=r[cidx])or(lidx>len(l)):
        delicious=delicious+r[cidx]
        cidx=cidx+1
    else:
        delicious = delicious + l[lidx]
        lidx=lidx+1
    #print(delicious)
print(delicious)

Buggy 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()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
l=[]
#print(p,q,r)
delicious=0
for i in range(X):
    l.append(p[i])
for i in range(Y):
    l.append(q[i])
l.sort(reverse=True)
#print(l)
for i in range(len(l)-C):
    #print(l[i])
    delicious=delicious+l[i]
lidx=len(l)-C
cidx=0
#print(delicious,lidx,cidx,l,r,l[lidx],r[cidx])
for j in range(C):
    if l[lidx]<=r[cidx]:
        delicious=delicious+r[cidx]
        cidx=cidx+1
    else:
        delicious = delicious + l[lidx]
        lidx=lidx+1
    #print(delicious)
print(delicious)
Problem p02761 (python)

Fixed submission:
import collections

N,M=map(int,input().split())
#if not(M==0):
s=[list(map(int,input().split())) for _ in range(M)]
flag=1
l=[[i+1,-1] for i in range(N)]
ns=""
#print(l)
"""
if M==0:
    for i in range(M):
        if i==0:
            l[i][1]=1
        else:
            l[i][1]=0
        ns="".join((ns,str(l[i][1])))
    print(ns)
"""
#else:
for i in range(M):
    #print(l)
    if l[s[i][0]-1][1]==-1:
        l[s[i][0]-1][1]=s[i][1]
    else:
        if not(l[s[i][0]-1][1]==s[i][1]):
            flag=0
if (not(N==1) and (l[0][1]==0)):
    flag=0
if flag==1:
    for i in range(N):
        if not(N==1):
            if (l[i][1]==-1):
                if i==0:
                    l[i][1]=1
                else:
                    l[i][1]=0
        else:
            if (l[i][1]==-1):
                l[i][1]=0
        ns="".join((ns,str(l[i][1])))
    print(ns)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
rest=[[] for _ in range(N)]
r2=[]
end=0
flag=0
buf=""
ans=float("inf")
end=0
for i in range(M):
    s,c=map(int,input().split())
    if len(rest[s-1])==0:
        rest[s-1].append(c)
    elif rest[s-1].count(c)==0:
        end=1
        break
#print(rest)

if N == 1:
    l=range(0,10**N,1)
else:
    l=range(10**(N-1),10**N,1)

if end!=1:
    for i in l:
        buf=str(i)
        #print(i)
        for j in range(N):
            if len(rest[j])==1:
                if buf[j]!=str(rest[j][0]):
                    fail=1
                    break
        if fail==0:
            ans=i
            flag=1
            break
        fail=0
if (flag==1):
    print(ans)
else:
    print("-1")
Problem p02768 (python)

Fixed submission:
#pが素数の時、p未満の数の積xについてx^(p-1)=1(mod p) <=> x^(p-2)=1/x(mod p) (オイラの小定理)
#ここでpは素数なので、p以下の数a,b,nにおいてcmb(n,a)≡n!/((n-a)!*a!)≡((n-a+1)*…*n)/(a!)≡((n-a+1)*…*n)(a!)^(p-2) (mod p)
#あとは((n-a+1)*…*n)(a!)^(p-2) (mod p)を繰り返し2乗法でO(log(p))で求められる…らしいが普通にpow(n,r,mod)つよそう

def modcmb(n,r,mod):
    upper=1
    for i in range(n-r+1,n+1,1):
        upper=(upper*i)%mod
    rfrac=1
    for i in range(1,r+1,1):
        rfrac=(rfrac*i)%mod
    pwrfrac=pow(rfrac,mod-2,mod)
    return (upper*pwrfrac)%mod

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

print((pow(2,n,p)-1-modcmb(n,a,p)-modcmb(n,b,p))%p)

Buggy submission (verdict: Runtime Error):
import math
import sys
from functools import lru_cache
#from scipy.special import comb
from operator import mul
from functools import reduce

n,a,b=map(int,input().split())
'''
def memoize(f): #メモ化関数
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func

@memoize
def memFrac(n):
    if ( n==0 ):
        return 1
    else:
        return n*memFrac(n-1)

def perm(n,r):
    return memFrac(n) // (memFrac(n - r)*memFrac(r))

sys.setrecursionlimit(1000000007)
@lru_cache(maxsize=1000)
def frac(n):
    if n<2:
        return n
    else:
        return n*frac(n-1)

def perm(n,r):
    return frac(n) // (frac(n - r)*frac(r))
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


p = 10 ** 9 + 7
N = 10 ** 10  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
'''
p = 10 ** 9 + 7

@lru_cache(maxsize=1000)
def frac(n):
    if n<2:
        return n
    else:
        return n*frac(n-1)

def perm(n,r):
    return frac(n) // (frac(n - r)*frac(r))


a1=perm(n,a)
b1=perm(n,b)

#a1=cmb(n,a)
#b1=cmb(n,b)

print((pow(2,n)-1-a1-b1)%p)