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

Fixed submission:
alphabet = {0:"a",1:"b",2:"c",3:"d",4:"e",5:"f",6:"g",7:"h",8:"i",9:"j",10:"k",11:"l",12:"m",13:"n",14:"o",15:"p",16:"q",17:"r",18:"s",19:"t",20:"u",21:"v",22:"w",23:"x",24:"y",25:"z"}
N = int(input())
name = ""
while N != 0:
     index= int(N%26)
     if index == 0:
         name += alphabet[25]
     else:
         name += alphabet[index-1]
     N = int((N-1)/26)
print(name[::-1])

Buggy submission (verdict: Runtime Error):
alphabet = {0:"a",1:"b",2:"c",3:"d",4:"e",5:"f",6:"g",7:"h",8:"i",9:"j",10:"k",11:"l",12:"m",13:"n",14:"o",15:"p",16:"q",17:"r",18:"s",19:"t",20:"u",21:"v",22:"w",23:"x",24:"y",25:"z"}
N = int(input())
name = ""
while N != 0:
     index= int(N%26)
     name += alphabet[index-1]
     N = int(N/26)
print(name[::-1])
Problem p02819 (python)

Fixed submission:
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

X = int(input())
result = 0
while result == 0:
    if is_prime(X):
        result = X
    else:
        X += 1
print(X)

Buggy submission (verdict: Runtime Error):
import numpy

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(numpy.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

X = int(input())
result = 0
while result == 0:
    if is_prime(X):
        result = X
    else:
        X += 1
print(X)
Problem p02552 (python)

Fixed submission:
import sys
import collections as cc
import math as mt
I=lambda:list(map(int,input().split()))
n,=I()
if n==1:
	print(0)
else:
	print(1)

Buggy submission (verdict: Runtime Error):
import sys
import collections as cc
import math as mt
I=lambda:list(map(int,input().split()))
a,b,c,d=I()
print(max(a*c,a*d,b*d,b*d))
Problem p02572 (python)

Fixed submission:
I=lambda:list(map(int,input().split()))
mod=10**9+7
n,=I()
l=I()
pre=l.copy()
suf=l.copy()
for i in range(n-2,-1,-1):
	suf[i]+=suf[i+1]
ans=0
#print(suf)
for i in range(n-1):
	ans+=(l[i]*suf[i+1])
	ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
34I=lambda:list(map(int,input().split()))
mod=10**9+7
n,=I()
l=I()
pre=l.copy()
suf=l.copy()
for i in range(n-2,-1,-1):
	suf[i]+=suf[i+1]
ans=0
#print(suf)
for i in range(n-1):
	ans+=(l[i]*suf[i+1])
	ans%=mod
print(ans)
Problem p02595 (python)

Fixed submission:
I=lambda:list(map(int,input().split()))
n,d=I()
def ch(a,b):
    return a**2+b**2
ans=0
for i in range(n):
    x,y=I()
    if ch(x,y)<=d*d:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
I=lambda:list(map(int,input().spilt()))
n,d=I()
def ch(a,b):
    return a**2+b**2
ans=0
for i in range(n):
    x,y=I()
    if ch(x,y)<=d:
        ans+=1
print(ans)
Problem p02629 (python)

Fixed submission:
import math as mt
import collections as cc
I=lambda:list(map(int,input().split()))
ans=[]
prev=0
for i in range(1,15):
    ans.append(26**i+prev)
    prev+=26**i
    
n,=I()
p=0
s='abcdefghijklmnopqrstuvwxyz'
f={}
for i in range(1,27):
    f[i]=s[i-1]
for i in range(len(ans)):
    p+=1
    if n<=ans[i]:
        break
an=''
f[0]='z'
for i in range(p):

    an+=f[n%26]
    if n%26:
        n//=26
    else:
        n//=26
        n-=1
    
print(an[::-1])

Buggy submission (verdict: Runtime Error):
import math as mt
import collections as cc
I=lambda:list(map(int,input().split()))
ans=[]
prev=0
for i in range(1,15):
    ans.append(26**i+prev)
    prev+=26**i
    
n,=I()
p=0
s='abcdefghijklmnopqrstuvwxyz'
f={}
for i in range(1,27):
    f[i]=s[i-1]
for i in range(len(ans)):
    p+=1
    if n<=ans[i]:
        break
an=''
for i in range(p):
    an+=f[n%26]
    n//=26
print(an)
Problem p02779 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if len(set(l))==n:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
f=1
for i in range(n-1):
	if l[i]==l[i+1]:
        f=0
        break
if f:
	print("YES")
else:
	print("NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
f=1
for i in range(n-1):
	if l[i]==l[i+1]:
      f=0
      break
if f:
	print("YES")
else:
	print("NO")
Problem p02819 (python)

Fixed submission:
nn=int(input())
n=10**5+100
ar=[0]*(n)
ar[1]=0
ans=0
pre=1
for i in range(2,n):
    if ar[i]==0:

        for j in range(2*i,n,i):
            ar[j]=1
ans=1
if ar[nn]==0:
    print(nn)
else:
        
    for i in range(nn,n):
        if ar[i]==0:
            print(i)
            break

Buggy submission (verdict: Runtime Error):
nn=int(input())
n=10**5+100
ar=[0]*(n)
ar[1]=0
ans=0
pre=1
for i in range(2,(n**0.5)+1):
    if ar[i]==0:

        for j in range(2*i,n,i):
            ar[j]=1
ans=1
if ar[nn]==0:
    print(nn)
else:
        
    for i in range(nn,n):
        if ar[i]==0:
            print(i)
            break

Buggy submission (verdict: Runtime Error):
nn=int(input())
n=10**5+100
ar=[0]*(n)
ar[1]=0
ans=0
pre=1
for i in range(2,(n**0.5)+1):
    if ar[i]==0:

        for j in range(2*i,n,i):
            ar[j]=1
ans=1
if ar[nn]==0:
    print(nn)
else:
        
    for i in range(nn,n):
        if ar[i]==0:
            print(i)
            break
Problem p02832 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
ans=[[]for i in range(n+1)]
for i in range(n):
    ans[l[i]].append(i+1)

    
c=1
tem=[]
ch=0
while 1:
    if c>n:
        break
    else:
        
        if len(ans[c])==0:
            break
        else:
            flag=0
            for i in ans[c]:
                if i>ch:
                    tem.append(i)
                    ch=i
                    flag=1
                    break
            if not flag:
                break
            else:
                c+=1
                    
                
if len(tem)==0:
    print(-1)
else:
    print(n-len(tem))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
ans=[[]for i in range(max(l)+1)]
for i in range(n):
    ans[l[i]].append(i+1)

    
c=1
tem=[]
ch=0
while 1:
    if len(ans[c])==0:
        break
    else:
        flag=0
        for i in ans[c]:
            if i>ch:
                tem.append(i)
                ch=i
                flag=1
                break
        if not flag:
            break
        else:
            c+=1
                
                
if len(tem)==0:
    print(-1)
else:
    print(n-len(tem))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split()))
ans=[[]for i in range(n+1)]
for i in range(n):
    ans[l[i]].append(i+1)

    
c=1
tem=[]
ch=0
while 1:
    if len(ans[c])==0:
        break
    else:
        flag=0
        for i in ans[c]:
            if i>ch:
                tem.append(i)
                ch=i
                flag=1
                break
        if not flag:
            break
        else:
            c+=1
                
                
if len(tem)==0:
    print(-1)
else:
    print(n-len(tem))
Problem p02833 (python)

Fixed submission:
n = int(input())
if n%2:
  print(0)
else:
  p=n//2
  l=0
  while p>0:
    l+=p//5
    p//=5
  print(l)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2:
    print(0)
else:
    l=0
    x=n//2
    while x>0:
        l+=n//5
        x=n//5
print(l)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2:
    print(0)
else:
    l=0
    n=n//2
    while n>0:
        l+=n//5
        n=n//5
print(l)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2:
    print(0)
else:
    l=0
    n=n//2
    while n>0:
        l+=n//5
        n=n//5
print(l)
Problem p02793 (python)

Fixed submission:
import math
from functools import reduce
     
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
     
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
      
N = int(input())
A = list(map(int,input().split()))
ans = 0
     
lcm = lcm_list(A)
     
for i in range(N):
    ans += lcm//A[i]
     
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
    import math
    from functools import reduce
     
    def lcm_base(x, y):
        return (x * y) // math.gcd(x, y)
     
    def lcm_list(numbers):
        return reduce(lcm_base, numbers, 1)
      
    N = int(input())
    A = list(map(int,input().split()))
    ans = 0
     
    lcm = lcm_list(A)
     
    for i in range(N):
      ans += lcm//A[i]
     
    print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
    def gcd(a,b): 
        if a == 0: 
            return b 
        return gcd(b % a, a) 
      
    def lcm(a,b): 
        return (a*b) // gcd(a,b) 
      
    n = int(input())
    arr = input()   # takes the whole line of n numbers
    a = list(map(int,arr.split(' ')))
    l = a[0]
    ans = 0
    for i in range(n):
        l = lcm(l, a[i])
    for i in range(n):
        ans = ans + l//a[i]
    print(ans%1000000007)
Problem p02777 (python)

Fixed submission:
s, t = input().split()
a, b = (int(x) for x in input().split())
u = input()

if s == u:
  a -= 1
else:
  b -= 1

print('{} {}'.format(a, b))

Buggy submission (verdict: Runtime Error):
n, k = (int(x) for x in input().split())
p = list(int(x) for x in input().split())

max_val = 0
for i in range(0, len(p)-k+1):
  tmp = p[i:i+k]
  val = sum([sum([x for x in range(1, t+1)]) / t for t in tmp])

  if max_val < val:
    max_val = val

print('{:.12f}'.format(val))
Problem p02835 (python)

Fixed submission:
a, b, c = input().split()

if int(a) + int(b) + int(c) >= 22:
  print('bust')
else:
  print('win')

Buggy submission (verdict: Runtime Error):
a, b, c = input().split()

if a + b + c >= 22:
  print('bust')
else:
  print('win')
Problem p02580 (python)

Fixed submission:
import sys
import math
import numpy as np

if __name__ == '__main__':
    H, W, M = list(map(lambda x: int(x), sys.stdin.readline().split()))

    dic = {}
    # h = [0 for i in range(H)]
    # w = [0 for i in range(W)]
    h = np.zeros(H, dtype=np.int64)
    w = np.zeros(W, dtype=np.int64)
    for i in range(M):
        # P.append(list(map(lambda x: int(x), sys.stdin.readline().split())))
        x, y = list(map(lambda x: int(x), sys.stdin.readline().split()))
        x -= 1
        y -= 1
        h[x] += 1
        w[y] += 1
        dic[x*H+y] = 1
    
    lh = np.where(h == h.max())
    lw = np.where(w == w.max())

    mx = np.max(h)
    my = np.max(w)
    # print(mx, my)

    # print(lh[0])
    # print(lw[0])


    tmp = mx + my
    for i in lh[0]:
        for j in lw[0]:
            if i*H+j not in dic:
                print(tmp)
                exit()
    print(tmp-1)
    exit()

Buggy submission (verdict: Runtime Error):
import sys
import math
import numpy as np

if __name__ == '__main__':
    H, W, M = list(map(lambda x: int(x), sys.stdin.readline().split()))

    dic = {}
    # h = [0 for i in range(H)]
    # w = [0 for i in range(W)]
    h = np.zeros(H, dtype=np.int64)
    w = np.zeros(W, dtype=np.int64)
    for i in range(M):
        # P.append(list(map(lambda x: int(x), sys.stdin.readline().split())))
        x, y = list(map(lambda x: int(x), sys.stdin.readline().split()))
        x -= 1
        y -= 1
        h[x] += 1
        w[y] += 1
        dic[x*H+y] = 1
    
    lh = np.where(h == h.max())
    lw = np.where(w == w.max())

    mx = np.max(h)
    my = np.max(w)
    # print(mx, my)

    # print(lh[0])
    # print(lw[0])

    max = 0
    for i in lh[0]:
        for j in lw[0]:
            tmp = h[i] + w[j]
            if i*H+j in dic:
                tmp -= 1
            if tmp > max:
                max = tmp
    print(max)


    # for i in lh[0]:
    #     for j in lw[0]:
    #         if i*H+j not in dic:
    #             print(i, j)
    #             break
    # else:
    #     print(mx+my, 'hi')
    #     exit()
    
    # print(mx+my-1)
    # exit()

Buggy submission (verdict: Runtime Error):
import sys
import math
import numpy as np

if __name__ == '__main__':
    H, W, M = list(map(lambda x: int(x), sys.stdin.readline().split()))

    dic = {}
    # h = [0 for i in range(H)]
    # w = [0 for i in range(W)]
    h = np.zeros(H, dtype=np.int64)
    w = np.zeros(W, dtype=np.int64)
    for i in range(M):
        # P.append(list(map(lambda x: int(x), sys.stdin.readline().split())))
        x, y = list(map(lambda x: int(x), sys.stdin.readline().split()))
        x -= 1
        y -= 1
        h[x] += 1
        w[y] += 1
        dic[x*H+y] = 1
    
    lh = np.where(h == h.max())
    lw = np.where(w == w.max())

    mx = np.max(h)
    my = np.max(w)
    # print(mx, my)

    # print(lh[0])
    # print(lw[0])

    max = 0
    for i in lh[0]:
        for j in lw[0]:
            tmp = h[i] + w[j]
            if i*H+j in dic:
                tmp -= 1
            if tmp > max:
                max = tmp
    print(max)
Problem p02729 (python)

Fixed submission:
n, m = map(int, input().split())
frac = [1]
p = 10**9 + 7
for i in range(max(n, m)):
    frac.append(frac[i]*(i+1)%p)

#フェルマーの小定理を用いてcombの計算を行う
def comb(n, k, mod):
    a=frac[n]
    b=frac[k]
    c=frac[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
if n >= 2:
  a = comb(n, 2, p)
else:
  a = 0
if m >= 2:
  b = comb(m, 2, p)
else:
  b = 0
print(a + b)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
frac = [1]
for i in range(max(n, m)):
    frac.append(frac[i]*(i+1)%p)
mod = 10**9 + 7
#フェルマーの小定理を用いてcombの計算を行う
def comb(n, k, mod):
    a=frac[n]
    b=frac[k]
    c=frac[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
print(comb(n, 2, mod) + comb(m, 2, mod))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
frac = [1]
for i in range(max(n, m)):
    frac.append(frac[i]*(i+1)%p)
mod = 10***9 + 7
#フェルマーの小定理を用いてcombの計算を行う
def comb(n, k, mod):
    a=frac[n]
    b=frac[k]
    c=frac[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
print(comb(n, 2, mod) + comb(m, 2, mod))
Problem p02873 (python)

Fixed submission:
S = list(str(input()))

count = 0
count_bef = 0
count_list=[]
count_list2=[]
minus = []
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    count += 1
  elif not S[i] ==S[i+1]:
    count_list.append(int((count+1)*(count+2)/2))
    count_list2.append(count+1)
    count = 0
count_list.append(int((count+1)*(count+2)/2))
count_list2.append(count+1)
if S[0] == "<":
  for i in range(len(count_list2)//2):
    minus.append(min(count_list2[2*i], count_list2[2*i+1]))
elif S[0] == ">":
  try:
    for i in range(len(count_list2)//2):
      minus.append(min(count_list2[2*i+1], count_list2[2*i+2]))
  except IndexError:
    pass
#print(count_list)
#print(count_list2)
#print(minus)
print(sum(count_list)-sum(minus))

Buggy submission (verdict: Runtime Error):
S = list(str(input()))

count = 0
count_bef = 0
count_list=[]
count_list2=[]
minus = []
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    count += 1
  elif not S[i] ==S[i+1]:
    count_list.append(int((count+1)*(count+2)/2))
    count_list2.append(count+1)
    count = 0
count_list.append(int((count+1)*(count+2)/2))
count_list2.append(count+1)
if S[0] == "<":
  for i in range(len(count_list2)//2):
    minus.append(min(count_list2[2*i], count_list2[2*i+1]))
elif S[0] == ">":
  for i in range(len(count_list2)//2):
    minus.append(min(count_list2[2*i+1], count_list2[2*i+2]))
    
#print(count_list)
#print(count_list2)
#print(minus)
print(sum(count_list)-sum(minus))
Problem p02897 (python)

Fixed submission:
N = float(input())
a = N - N//2
print(a / N)

Buggy submission (verdict: Runtime Error):
N = input()
a = N - N//2
print(a / N)

Buggy submission (verdict: Runtime Error):
N = input()
a = N - N//2
print(float(a / N))
Problem p02912 (python)

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

import heapq
a = [-1*i for i in a]
heapq.heapify(a)
for i in range(M):
    b = heapq.heappop(a)
    b = (-1*b)//2
    heapq.heappush(a, -1*b)
print(-1*sum(a))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().solit()))

import heapq
a = [-1*i for i in a]
heapq.heapify(a)
for i in range(M):
    b = heapq.heappop(a)
    b = (-1*b)//2
    heapq.heappush(a, -1*b)
print(-1*sum(a))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().solit()))

import heapq
a = [-1*i for i in a]
a = heapq.haapify(a)
for i in range(M):
  b = heapq.heappop(a)
  b = (-1*b)//2
  heap.heappush(a, -1*b)
print(-1*sum(a))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().solit()))

import heapq
a = [-1*i for i in a]
a = heapq.haapify(a)
for i in range(M):
  b = heapq.heappop(a)
  b = (-1*b)//2
  heap.heap.push(a, -1*b)
print(-1*sum(a))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = list(map(int, input().solit()))

import heapq
a = [-1*i i for i in a]
a = heapq.haapify(a)
for i in range(M):
  b = heapq.heappop(a)
  b = (-1*b)//2
  heap.heap.push(a, -1*b)
print(-1*sum(a))
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
point = 0

for i in range(N):
    point += B[A[i]-1]
    if i>0 and A[i]-1 == A[i-1]:
        point += C[A[i-1]-1]
print(point)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
point = 0

for i in range(N):
  point += B[A[i]]
  if i>0 and A[i] == A[i-1]:
    point += C[A[i-1]]
print(point)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
point = 0

for i in range(N):
  point += B[A[i]]
  if i>0 and A[i] = A[i-1]:
    point += C[A[i-1]]
print(point)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
point = 0

for i in range(N):
  count+= B[A[i]]
  if i>0 and A[i] = A[i-1]:
    count += C[A[i-1]]
print(count)
Problem p02990 (python)

Fixed submission:
from math import factorial
 
def comb(n, k):
  return int(factorial(n))//int(factorial(n-k))//int(factorial(k))
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))

Buggy submission (verdict: Runtime Error):
from math import factorial
 
def comb(n, k):
  return int(factorial(n))/int(factorial(n-k))/int(factorial(k))
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))

Buggy submission (verdict: Runtime Error):
from math import factorial
 
def comb(n, k):
  return factorial(n)/factorial(n-k)/factorial(k)
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))

Buggy submission (verdict: Runtime Error):
from math import factorial

def comb(n, k):
  return factorial(n)/factorial(n-k)/factorial(k)

N, K = map(int, input().split())

for i in range(1, K+1):
  a = comb(N-K+1, i)%(10**9+7)
  b = comb(K-1, i-1)%(10**9+7)
  print(int((a*b)%(10**9+7)))
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
dp = []
dp.append(1)
if a:
  cantuse = a.pop(0)
  if cantuse == 1:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(1)
else:
  cantuse = -1
  dp.append(1)

for i in range(N-1):
  if (i+2) == cantuse:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(dp[-1]+dp[-2])
print(dp[-1]%1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
dp = []
dp.append(1)
if a:
  cantuse = a.pop(0)
  if cantuse == 1:
    dp.append(0)
    cantuse = a.pop(0)
  else:
    dp.append(1)
else:
  cantuse = -1
  dp.append(1)

for i in range(N-1):
  if (i+2) == cantuse:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(dp[-1]+dp[-2])
print(dp[-1]%1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
dp = []
dp.append(1)
if a:
  cantuse = a.pop(0)
  if cantuse == 1:
    dp.append(0)
  cantuse = a.pop(0)
else:
  cantuse = -1
  dp.append(1)

for i in range(N-1):
  if (i+2) == cantuse:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(dp[-1]+dp[-2])
print(dp[-1]%1000000007)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
for i in range(M):
  a.append(int(input()))
dp = []
if a:
  cantuse = a.pop(0)
dp.append(1)
if cantuse == 1:
  dp.append(0)
  cantuse = a.pop(0)
else:
  dp.append(1)

for i in range(N-1):
  if (i+2) == cantuse:
    dp.append(0)
    if a:
      cantuse = a.pop(0)
  else:
    dp.append(dp[-1]+dp[-2])
print(dp[-1]%1000000007)
Problem p03108 (python)

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

def find(x):#xの親を見つける
  if par[x] < 0:
    return x
  else:
    par[x] = find(par[x])
    return par[x]

def unite(x,y):#要素xとｙを併合させる
  x,y=find(x),find(y)#xとyの親の検索
  if x!=y:#親が異なる場合併合させる
    if x>y:
        x,y=y,x#小さい方をxとする. これにより要素の値が小さいものを優先して木の根とする. 
    par[x]+=par[y] #値を無向木の要素数の和にする.
    par[y]=x #枝側は根の位置を格納

def same(x, y):#要素xと要素yが同じ無向木に所属しているかを判定する
  return find(x) == find(y)#同じ値を持つか否か

def size(x):#要素xが所属する無向木の大きさを返す
  return-par[find(x)]

n, m = map(int, input().split()) #要素の数
par = [-1] * n #
path = []
for i in range(m):
  a, b = map(int, input().split())
  path.append([a-1, b-1])
ans_l = [n*(n-1)//2]
for i in range(m-1, 0, -1):
  if same(path[i][0], path[i][1]):
    ans_l.append(ans_l[-1])
    unite(path[i][0], path[i][1])
  else:
    ans_l.append(ans_l[-1] - size(path[i][0])*size(path[i][1]))
    unite(path[i][0], path[i][1])
for i in range(m-1, -1, -1):
  print(ans_l[i])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

def find(x):#xの親を見つける
  if par[x] < 0:
    return x
  else:
    par[x] = find(par[x])
    return par[x]

def unite(x,y):#要素xとｙを併合させる
  x,y=find(x),find(y)#xとyの親の検索
  if x!=y:#親が異なる場合併合させる
    if x>y:
        x,y=y,x#小さい方をxとする. これにより要素の値が小さいものを優先して木の根とする. 
    par[x]+=par[y] #値を無向木の要素数の和にする.
    par[y]=x #枝側は根の位置を格納

def same(x, y):#要素xと要素yが同じ無向木に所属しているかを判定する
  return find(x) == find(y)#同じ値を持つか否か

def size(x):#要素xが所属する無向木の大きさを返す
  return-par[find(x)]

n, m = map(int, input().split()) #要素の数
par = [-1] * n #
import numpy as np
path = []
par = np.array(par)
for i in range(m):
  a, b = map(int, input().split())
  path.append([a-1, b-1])
ans_l = [n*(n-1)//2]
for i in range(m-1, 0, -1):
  unite(path[i][0], path[i][1])
  if len(par[par < 0]) == 0:
    ans_l.append(0)
  ans = np.dot(np.array([par[par < 0]]).T, np.array([par[par < 0]]))
  ans_l.append((np.sum(ans)-np.trace(ans))//2)
for i in range(m-1, -1, -1):
  print(ans_l[i])

Buggy submission (verdict: Runtime Error):
def find(x):#xの親を見つける
  if par[x] < 0:
    return x
  else:
    par[x] = find(par[x])
    return par[x]

def unite(x,y):#要素xとｙを併合させる
  x,y=find(x),find(y)#xとyの親の検索
  if x!=y:#親が異なる場合併合させる
    if x>y:
        x,y=y,x#小さい方をxとする. これにより要素の値が小さいものを優先して木の根とする. 
    par[x]+=par[y] #値を無向木の要素数の和にする.
    par[y]=x #枝側は根の位置を格納

def same(x, y):#要素xと要素yが同じ無向木に所属しているかを判定する
  return find(x) == find(y)#同じ値を持つか否か

def size(x):#要素xが所属する無向木の大きさを返す
  return-par[find(x)]

n, m = map(int, input().split()) #要素の数
par = [-1] * n #
import numpy as np
path = []
par = np.array(par)
for i in range(m):
  a, b = map(int, input().split())
  path.append([a-1, b-1])
ans_l = [n*(n-1)//2]
for i in range(m-1, 0, -1):
  unite(path[i][0], path[i][1])
  if len(par[par < 0]) == 0:
    ans_l.append(0)
  ans = np.dot(np.array([par[par < 0]]).T, np.array([par[par < 0]]))
  ans_l.append((np.sum(ans)-np.trace(ans))//2)
for i in range(m-1, -1, -1):
  print(ans_l[i])