Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    if r==1:return n
    elif r==0:return 1
    else:
        num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
        den=reduce(lambda x,y:x*y%mod,range(1,r+1))
        return num*pow(den,mod-2,mod)%mod
def main():
    x,y=map(int,input().split())
    mod=10**9+7
    if (2*x-y)%3>0 or (2*y-x)%3>0:
        print(0)
    else:
        n=(2*x-y)//3
        m=(2*y-x)//3
        print(mod_comb4(n+m,n,mod)%mod)


if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    if r==1:return n
    elif r==0:return 1
    else:
        num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
        den=reduce(lambda x,y:x*y%mod,range(1,r+1))
        return num*pow(den,mod-2,mod)%mod
def main():
    x,y=map(int,input().split())
    mod=10**9+7
    n=2*x-y
    m=2*y-x
    if n%3==0 and m%3==0 and n>=0 and m>=0:
        print(mod_comb4(n//3+m//3,n//3,mod))
    else:
        print(0)


if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
    den=reduce(lambda x,y:x*y%mod,range(1,r+1))
    return num*pow(den,mod-2,mod)%mod
def main():
    x,y=map(int,input().split())
    mod=10**9+7
    if (2*x-y)%3>0 or (2*y-x)%3>0:
        print(0)
    else:
        n=(2*x-y)//3
        m=(2*y-x)//3
        print(mod_comb4(n+m,n,mod)%mod)


if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
from functools import reduce
def mod_comb4(n,r,mod=10**9+7):
    if r==1:return n
    elif r==0:return 1
    else:
        num=reduce(lambda x,y:x*y%mod,range(n,n-r,-1))
        den=reduce(lambda x,y:x*y%mod,range(1,r+1))
        return num*pow(den,mod-2,mod)%mod
def main():
    x,y=map(int,input().split())
    mod=10**9+7
    n=2*x-y
    m=2*y-x
    if n%3==0 and m%3==0 and n>=0 and m>=0:
        print(mod_comb4(n//3+m//3,n//3,mod))
    else:
        print(0)


if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
import math
def main():
    a,b,x=map(int,input().split())
    if x==a**2/b:
        print(90)
        sys.exit()
    if x<=a**2*b/2:
        print(90.0-math.degrees(math.atan((2*x)/(a*b**2))))
    else:
        z=2*x/a**2-b
        print(90.0-math.degrees(math.atan(a/(b-z))))

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
import math
def main():
    a,b,x=map(int,input().split())
    if x==a**2*b:
        print(0)
        sys.exit()
    if x<=a**2*b/2:
        print(90.0-math.degrees(math.atan((2*x)/(a*b**2))))
    else:
        z=2*x/a**2-b
        print(90.0-math.degrees(math.atan(a/(b-z))))

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
import math
def main():
    a,b,x=map(int,input().split())
    if x<=a**2*b/2:
        #x=y*b*a/2
        #y=2*x/(a*b)
        print(90.0-math.degrees(math.atan((2*x)/(a*b**2))))
    else:
        #x-a^**2*b/2=a**2*z/2
        z=2*x/a**2-b
        print(90.0-math.degrees(math.atan(a/(b-z))))

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
import math
def main():
    a,b,x=map(int,input().split())
    if x==a**2*b:
        print(0)
        sys.exit()
    if x<=a**2*b/2:
        print(90.0-math.degrees(math.atan((2*x)/(a*b**2))))
    else:
        z=2*x/a**2-b
        print(90.0-math.degrees(math.atan(a/(b-z))))

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    F=list(map(int,input().split()))
    F.sort(reverse=True)
    A.sort()
    right=10**12
    left=-1
    while right-left>1:#区間(left,right]に解Xがある
        x=(right+left)//2
        k_sum=0
        for i in range(n):
            k_sum+=max(0,A[i]-x//F[i])
        if k_sum<=k:
            right=x
        else:
            left=x
    print(right)
    

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    F=list(map(int,input().split()))
    F.sort(reverse=True)
    A.sort()
    right=10**12
    left=-1
    while right-left>1:#区間(left,right]に解Xがある
        x=(right+left)//2
        k_sum=0
        for i in range(n):
            k_sum+=max(0,A[i]-x//F[i])
        if k_sum<=k:
            right=x
        else:
            left=x
    print(right)
    

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    L=[int(_) for _ in input().split()]
    L.sort()
    ans=0
    for a in range(n-2):
        for b in range(a+1,n-1):
            flag=L[a]+L[b]
            for c in range(b+1,n):
                if L[c]>=flag:
                    break
                ans+=1
    print(ans)


if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect_left
def main():
    n=int(input())
    L=[int(_) for _ in input().split()]
    L.sort()
    ans=0
    for a in range(n-2):
        for b in range(a+1,n-1):
            ans+=bisect_left(L,L[a]+L[b])-b-1
    print(ans)


if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from subprocess import *
call(('pypy3','-c'."""
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n,q=map(int,input().split())
    P=[[] for _ in range(n)]
    for i in range(n-1):
        a,b=map(int,input().split())
        P[a-1].append(b-1)
        P[b-1].append(a-1)
    X=[0]*n
    for i in range(q):
        p,x=map(int,input().split())
        X[p-1]+=x
    deq=deque([0])
    visited=[False]*n 
    while deq:
        node=deq.popleft()
        if not(visited[node]):
            visited[node]=True
            for p in P[node]:
                if not(visited[p]):
                    X[p]+=X[node]
                    deq.append(p)
    print(*X)

if __name__=='__main__':
    main()
"""))

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n,q=map(int,input().split())
    P=[[] for _ in range(n)]
    for i in range(n-1):
        a,b=map(int,input().split())
        P[a-1].append(b-1)
        P[b-1].append(a-1)
    X=[0]*n
    for i in range(q):
        p,x=map(int,input().split())
        X[p-1]+=x
    deq=deque([0])
    visited=[False]*n 
    while deq:
        node=deq.popleft()
        if not(visited[node]):
            visited[node]=True
            for p in P[node]:
                if not(visited[p]):
                    X[p]+=X[node]
                    deq.append(p)
    print(*X)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    len_s=len(s)
    mod=10**9+7
    dp=[[0]*13 for _ in range(len_s+1)] #i(1-)桁目までについて，13で割った余り
    dp[0][0]=1
    for i in range(len_s):
        if s[i]=="?":
            for j in range(13):
                for k in range(10):
                    dp[i+1][(10*j+k)%13]+=dp[i][j]%mod
        else:
            c=int(s[i])
            for j in range(13):
                dp[i+1][(10*j+c)%13]=dp[i][j]
        for j in range(13):
            dp[i+1][j]%=mod
    print(dp[len_s][5])

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    len_s=len(s)
    mod=10**9+7
    dp=[[0]*13 for _ in range(len_s+1)] #i(1-)桁目までについて，13で割った余り
    dp[0][0]=1
    for i in range(len_s):
        if s[i]=="?":
            for j in range(13):
                for k in range(10):
                    dp[i+1][(10*j+k)%13]+=dp[i][j]%mod
        else:
            c=int(s[i])
            for j in range(13):
                dp[i+1][(10*j+c)%13]=dp[i][j]
        for j in range(13):
            dp[i+1][j]%=mod
    print(dp[len_s][5])

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=list(map(int,input().split()))
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(*B)
    
if __name__=='__main__':
    main()

Fixed submission:
n,a,b=map(int,input().split())
print(min(n*a,b))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
import numpy as np
def main():
    n=int(input())
    A=np.array([int(_) for _ in input().split()])
    B=np.zeros(n,dtype=int)
    while True:
        for i in range(1,n):
            B[i]=A[i-1]-B[i-1]
        B[1::]=A[:-1:]-B[:-1:]
        if B[0]==A[-1]-B[-1]:
            print(*[2*x for x in B])
            break
        B[0]+=1
    

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(*B)
    
if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[0]*n
    while True:
        for i in range(1,n):
            B[i]=A[i-1]-B[i-1]
        if B[0]==A[-1]-B[-1]:
            print(*[2*x for x in B])
            break
        B[0]+=1
    

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(*B)
    
if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[0]*n
    while True:
        for i in range(1,n):
            B[i]=A[i-1]-B[i-1]
        if B[0]==A[-1]-B[-1]:
            print(*[2*x for x in B])
            break
        B[0]+=1
    

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[0]*n
    B[0]=sum(A)-sum(A[1::2])*2
    for i in range(1,n):
        B[i]=(A[i-1]-B[i-1]//2)*2
    print(*B)
    
if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import combinations
from collections import Counter
def main():
    n=int(input())
    if n==1:
        print(1)
    XY=[tuple(map(int,input().split())) for i in range(n)]
    lis=list(combinations(XY,2))
    PQ=[]
    for l in lis:
        if l[0][0]<l[1][0]:
            PQ.append((l[1][0]-l[0][0],l[1][1]-l[0][1]))
        else:
            PQ.append((l[0][0]-l[1][0],l[0][1]-l[1][1])) 
    x=Counter(PQ).most_common(1)[0][1]
    print(n-x)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import combinations
from collections import Counter
def main():
    n=int(input())
    if n==1:
        print(1)
        sys.exit()
    XY=[tuple(map(int,input().split())) for i in range(n)]
    XY.sort()
    lis=list(combinations(XY,2))
    PQ=[]
    for l in lis:
        PQ.append((l[1][0]-l[0][0],l[1][1]-l[0][1]))
    x=Counter(PQ).most_common(1)[0][1]
    print(n-x)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import combinations
from collections import Counter
def main():
    n=int(input())
    XY=[tuple(map(int,input().split())) for i in range(n)]
    lis=list(combinations(XY,2))
    PQ=[]
    for l in lis:
        if l[0][0]<l[1][0]:
            PQ.append((l[1][0]-l[0][0],l[1][1]-l[0][1]))
        else:
            PQ.append((l[0][0]-l[1][0],l[0][1]-l[1][1])) 
    x=Counter(PQ).most_common(1)[0][1]
    print(n-x)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import combinations
from collections import Counter
def main():
    n=int(input())
    if n==1:
        print(1)
        sys.exit()
    XY=[tuple(map(int,input().split())) for i in range(n)]
    XY.sort()
    lis=list(combinations(XY,2))
    PQ=[]
    for l in lis:
        PQ.append((l[1][0]-l[0][0],l[1][1]-l[0][1]))
    x=Counter(PQ).most_common(1)[0][1]
    print(n-x)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    Large=deque(A)
    Small=deque()
    while len(Large)>=2:
        if Large[-1]>=0:break
        Small.append(Large.pop())
    if not Small:Small.append(Large.pop())
    ans=[]
    while len(Large)>=2:
        a=Large.pop()
        b=Small.pop()
        ans.append((b,a))
        Small.append(b-a)  
    large=Large.pop()
    while len(Small)>=2:
        b=Small.popleft()
        ans.append((b,a))
        large+=-b
    small=Small.pop()
    ans.append((large,small))
    print(large-small)
    for a,b in ans:
        print(a,b)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort(reverse=True)
    Large=deque([a for a in A if a>=0])
    Small=deque([a for a in A if a<0])
    if not Large:Large.append(Small.popleft())
    if not Small:Small.append(Large.pop())
    ans=[]
    while len(Small)>=2:
        a,b=Large.pop(),Small.pop()
        ans.append((a,b))
        Large.append(a-b)
    small=Small.pop()
    while len(Large)>=2:
        a=Large.pop()
        ans.append((small,a))
        small-=a
    large=Large.pop()
    ans.append((large,small))
    print(large-small)
    for a,b in ans:
        print(a,b)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
    
def main():
    n,m=map(int,input().split())
    A=[int(input())for _ in range(m)]
    flag=[True]
    for a in A:
        flag[a]=False
    mod=10**9+7
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(n):
        if flag[i+1]:
            dp[i+1]+=dp[i]%mod
        if flag[i+2] and i<n-1:
            dp[i+2]+=dp[i]%mod
    print(dp[n]%mod)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
    
def main():
    n,m=map(int,input().split())
    A=[int(input())for _ in range(m)]
    flag=[True]*(n+2)
    for a in A:
        flag[a]=False
    mod=10**9+7
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(n):
        if flag[i+1]:
            dp[i+1]+=dp[i]%mod
        if flag[i+2] and i<n-1:
            dp[i+2]+=dp[i]%mod
    print(dp[n]%mod)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
    
def main():
    n,m=map(int,input().split())
    A=[int(input())for _ in range(m)]
    mod=10**9+7
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(n):
        if not(i+1 in A):
            dp[i+1]+=dp[i]%mod
        if not(i+2 in A) and i<n-1:
            dp[i+2]+=dp[i]%mod
    print(dp[n]%mod)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
    
def main():
    n,m=map(int,input().split())
    A=[int(input())for _ in range(m)]
    flag=[True]*(n+2)
    for a in A:
        flag[a]=False
    mod=10**9+7
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(n):
        if flag[i+1]:
            dp[i+1]+=dp[i]%mod
        if flag[i+2] and i<n-1:
            dp[i+2]+=dp[i]%mod
    print(dp[n]%mod)

if __name__=='__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
    
def main():
    n,m=map(int,input().split())
    A=[int(input())for _ in range(m)]
    mod=10**9+7
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(n):
        if not(i+1 in A):
            dp[i+1]+=dp[i]%mod
        if not(i+2 in A) and i<n-1:
            dp[i+2]+=dp[i]%mod
    print(dp[n]%mod)

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
    
def main():
    n,m=map(int,input().split())
    A=[int(input())for _ in range(m)]
    flag=[True]*(n+2)
    for a in A:
        flag[a]=False
    mod=10**9+7
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(n):
        if flag[i+1]:
            dp[i+1]+=dp[i]%mod
        if flag[i+2] and i<n-1:
            dp[i+2]+=dp[i]%mod
    print(dp[n]%mod)

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
CARD=[0]*n
for i in range(m):
    L,R=map(int,input().split())
    for j in range(L-1,R):
        CARD[j]+=1
ans=0
for i in range(n):
    if CARD[i]==m:ans+=1
print(ans)

Fixed submission:
n,m=map(int,input().split())
CARD=[0]*(n+1)
for i in range(m):
    L,R=map(int,input().split())
    CARD[L-1]+=1
    CARD[R]-=1
ans=0
for i in range(n):
    if CARD[i]==m:ans+=1
    CARD[i+1]=CARD[i+1]+CARD[i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    h,w=map(int,input().split())
    B=[[-1]*w for _ in range(h)]
    ans=0
    que=deque()
    for i in range(h):
        s=input()
        for j,ss in enumerate(s):
            if ss=="#":
                que.append((i,j))
                B[i][j]=0
    while que:
        qr,qc=que.popleft()
        for r,c in ((qr+1,qc),(qr-1,qc),(qr,qc+1),(qr,qc-1)):
            if r>=0 and r<=h-1 and c>=0 and c<=w-1 and B[r][c]==-1:
                B[r][c]=B[qr][qc]+1
                que.append((r,c))
    print(max([max(b) for b in B]))

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    h,w=map(int,input().split())
    B=[[-1]*w for _ in range(h)]
    ans=0
    que=deque()
    for i in range(h):
        s=input()
        for j,ss in enumerate(s):
            if ss=="#":
                que.append((i,j))
                B[i][j]=0
    while que:
        qr,qc=que.popleft()
        for r,c in ((qr+1,qc),(qr-1,qc),(qr,qc+1),(qr,qc-1)):
            if r>=0 and r<=h-1 and c>=0 and c<=w-1 and B[r][c]==-1:
                B[r][c]=B[qr][qc]+1
                que.append((r,c))
    print(max([max(b) for b in B]))

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    mod=10**9+7
    C=[int(input())for _ in range(n)]
    places=[[] for _ in range(2*10**5+1)]
    for i in range(n):
        places[C[i]].append(i)
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(1,n+1):
        dp[i]=(dp[i]+dp[i-1])%mod
        color=C[i-1]
        it=places[color].index(i-1)
        if it>0:
            j=places[color][it-1]
            if i-1-j>1:
                dp[i]=(dp[i]+dp[j+1])%mod
    print(dp[-1])


if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    mod=10**9+7
    stone=[0]*(2*10**5+1)
    stone_last_pos=[-1]*(2*10**5+1)
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(1,n+1):
        c=int(input())
        place=stone_last_pos[c]
        if place==i-1 or place==-1:
            dp[i]=dp[i-1]
        else:
            dp[i]=(dp[i-1]+dp[place])%mod
        stone_last_pos[c]=i
    print(dp[n])


if __name__=='__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    mod=10**9+7
    C=[int(input())for _ in range(n)]
    places=[[] for _ in range(n)]
    for i in range(n):
        places[C[i]].append(i)
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(1,n+1):
        dp[i]=(dp[i]+dp[i-1])%mod
        color=C[i-1]
        it=places[color].index(i-1)
        if it>0:
            j=places[color][it-1]
            if i-1-j>1:
                dp[i]=(dp[i]+dp[j+1])%mod
    print(dp[-1])


if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    mod=10**9+7
    stone=[0]*(2*10**5+1)
    stone_last_pos=[-1]*(2*10**5+1)
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(1,n+1):
        c=int(input())
        place=stone_last_pos[c]
        if place==i-1 or place==-1:
            dp[i]=dp[i-1]
        else:
            dp[i]=(dp[i-1]+dp[place])%mod
        stone_last_pos[c]=i
    print(dp[n])


if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
count=k
for i in range(100):
    if a%(i+1)==0 and b%(i+1)==0:
        count+=1
        if count==K:
            print(i+1)
            break

Fixed submission:
a,b,k=map(int,input().split())
N=[]
for i in range(100):
    if a%(i+1)==0 and b%(i+1)==0:
        N.append(i+1)
N.sort(reverse=True)
print(N[k-1])
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    N=[]
    for _ in range(3):
        a,b=map(int,input().split())
        N.append(a)
        N.append(b)
    N=Counter(N)
    NN=N.most_common(1)
    if NN[0][1]==3:
        print("NO")
    else:
        print("YES")


if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,k=map(int,input().split())
    if n>=2*k-1:print("YES")
    else:print("NO")

if __name__=='__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    ke="keyence"
    cunt=0
    cunt_str=0
    flag=False
    for i in range(len(s)):
        if s[i]==ke[cunt]:
            cunt+=1
            flag=False
        elif cunt_str==0 and flag==False:
            flag=True
            cunt_str+=1
        elif flag==False and cunt_str==1:
            print("NO")
            break
        print(i,s[i],flag)
    else:
        if cunt==7:print("YES")
        else:print("NO")

if __name__=='__main__':
    main()

Fixed submission:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    s=input()
    n=len(s)
    target="keyence"
    if s==target:
        print("YES")
        sys.exit()
    for i in range(n):#文字列開始
        for j in range(n):#文字列終了
            for k in range(i,j+1):
                #区間[i,j]が予想
                s_exp=s[:i]+s[j+1:]
                if s_exp==target:
                    print("YES")
                    sys.exit()
    print("NO")



if __name__=='__main__':
    main()