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

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

ans = 0
cur_max = 0

for x in a:
    if cur_max > x:
        ans += cur_max - x
    cur_max = max(cur_max, x)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = A
A = np.array(A)
B = np.array(B)
emp = np.zeros(N)
Amax_ind = np.argmax(A)
emp[Amax_ind:] = max(A)
A[Amax_ind:] = 0
while True:
    subAmax_ind = np.argmax(A)
    emp[subAmax_ind:Amax_ind] = max(A)
    A[subAmax_ind:Amax_ind] = 0
    Amax_ind = subAmax_ind
    if 0 not in emp:
        break
print(int(sum(emp-B)))
Problem p02659 (python)

Fixed submission:
import math
A, B = map(str, input().split())
A = int(A)
B = list(B)
del B[1]
B = ''.join(B)
B_int = int(B)
print((A * B_int) // 100)

Buggy submission (verdict: Runtime Error):
import math
a, b = input().split()
print(math.floor(a*b))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(math.floor(A*B))
Problem p02676 (python)

Fixed submission:
K = int(input())
S = list(input())
S2 = []

if len(S) <= K:
    print(''.join(S))
else:
    for i in range(K):
        n = S[i]
        S2.append(n)
if len(S2) == K:
    print(''.join(S2) + '...')

Buggy submission (verdict: Runtime Error):
K = int(input())
S = list(input())
S2 = []

for i in range(K):
    n = S[i]
    S2.append(n)

S2.append('...')
print(''.join(S2))
Problem p02771 (python)

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

if a == b and b == c:
  print("No")
elif a != b and b != c and a != c:
  print("No")
else:
  print("Yes")

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

for i in range(n):
  if not a[i] % 2 != 0 or (a[i] % 3 == 0 or a[i] % 5 == 0):
    print("DNIED")
    exit()
else:
  print("APPROVED")

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

if a == b and b == c:
  print(No)
elif a != b and b != c and a != c:
  print(No)
else:
  print(Yes)

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

if a == b == c:
  print(Yes)
else:
  print(No)

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

if a == b ==c:
  print(Yes)
else:
  print(No)
Problem p02777 (python)

Fixed submission:
S,T = input().split()
A,B = map(int,input().split())
U = input()

if U == S:
  A = A - 1
else:
  B = B - 1
print(A,B)

Buggy submission (verdict: Runtime Error):
S,T = int().split()
A,B = map(int,input().split())
U = input()

if U == S:
  A = A - 1
else:
  B = B - 1
print(A,B)
Problem p02779 (python)

Fixed submission:
n = input()
a = list(input().split())

b = set(a)

if len(a) == len(b):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n = input()
a = list(input().split())

b = set(a)

if len(a) == len(b):
  print(YES)
else:
  print(NO)

Buggy submission (verdict: Runtime Error):
n = input()
a = list(input().split())

b = set(a)

if len(a) == len(b):
  print(YES)
else:
  print(NO)

Buggy submission (verdict: Runtime Error):
n = input()
s = set(input().split())
if len(s) == n:
  print(YES)
else:
  print(NO)

Buggy submission (verdict: Runtime Error):
n = input()
s = input().split()
if len(set(s)) == n:
  print(YES)
else:
  print(NO)
Problem p02989 (python)

Fixed submission:
N = int(input())
P = sorted(list(map(int, input().split())))

print(P[N//2]-P[N//2-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
P = sorted(list(map(int, input().split())))

print(L[N//2]-L[N//2-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
 
print(L[N//2]-L[N//2-1])

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

L[N//2]-L[N//2-1]
Problem p03012 (python)

Fixed submission:
N = int(input())
*W, = map(int, input().split())
 
s1, s2 = 0, sum(W)
ans = sum(W)
 
for i in range(N):
  s1 += W[i]
  s2 -= W[i]
  ans = min(ans, abs(s1 - s2))
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
*W, = map(int, input().split())

s1, s2 = 0, sum[W]
ans = sum[W]

for i in range(N):
  s1 += W[i]
  s2 -= W[i]
  ans = min(ans, abs(s1 - s2))
print(ans)
Problem p02571 (python)

Fixed submission:
S=input()
T=input()
cnt=0
ans=len(T)
 
for i in range(len(S)-len(T)+1):
    cnt=0
    for j in range(len(T)):
        if S[i+j]!=T[j]:
            cnt+=1
    ans=min(ans,cnt)
        
print(ans)

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

cnt=0
ans=0

b=[0]*len(S)
a=[0]*len(S)
for i in range(len(S)):
    cnt = 0
    for j in range(len(T)):
        cnt = 0
        #print(S[i],T[j])
        if S[i]==T[j]:
            cnt+=1
            if j != len(T):
                for k in range(j+1,len(T)-j-2):
                    if S[i+k]==T[j+k]:
                        cnt+=1
                    else:
                        b[i]=cnt
                        break
            b[i]=cnt
            a[i]=j

for i in range(len(a)):
    if a[i]==a.index(a[i]):
        c = a.index(a[i])
        ans = b[c]
        break
        
print(len(T)-ans)
Problem p02835 (python)

Fixed submission:
A123 = sum(list(map(int, input().split())))
print('bust' if A123 > 21 else 'win')

Buggy submission (verdict: Runtime Error):
A123 = sum(list(map(int, input().split())))
print('bust' if A123 > 21, else 'win')
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()))
 
ans = 0
 
for i in range(N):
  ans += B[A[i]-1]
  if i >0 and A[i] - A[i-1] ==1:
    ans += C[A[i]-2]
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
B = [int(input()) for i in range(N)]
C = [int(input()) for i in range(N-1)]

ans = 0

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

Fixed submission:
import math
N, D =map(int, input().split())
print(math.ceil(N/(2*D+1)))

Buggy submission (verdict: Runtime Error):
import math
N, D=map(int, input().split())
print(math.ceil(N/(2*D+1))
Problem p02987 (python)

Fixed submission:
S = input()
x = list(set(S))
print("Yes" if len(set(S)) == 2 and S.count(x[0]) == 2 and S.count(x[1]) == 2 else "No")

Buggy submission (verdict: Runtime Error):
S = input()
x = list(set(S))
print("Yes" if len(set(S)) == 2 and len(S.remove(x[0])) == 2 and len(S.remove(x[1])) == 2 else "No")

Buggy submission (verdict: Runtime Error):
S = input()
x = list(set(S))
print("Yes" if len(set(S)) == 2 and len(S.remove(x[0])) == 2 and len(S.remove(x[0])) == 2 else "No")
Problem p03012 (python)

Fixed submission:
N=int(input())
W=list(map(int, input().split()))
 
sum1,sum2=0,0
ans=0
dif=1000
 
for i in range(N):
    sum1=sum(W[0:i])
    sum2=sum(W[i:])
    now = abs(sum1-sum2)
    if dif > now:
        dif =now
 
print(dif)

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

sum1,sum2=0,0
ans=0
dif=1000

for i in range(N):
    sum1=sum(W[0:i])
    sum2=sum(W[i:])
    now = abs(sum1-sum2)
    if dif > now:
        dif =now

print(dif)
Problem p02572 (python)

Fixed submission:
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    cumsum_a = [0] * len(a)
    cumsum_a[0] = a[0]
    for i in range(1, len(a)):
        cumsum_a[i] += cumsum_a[i-1] + a[i]

    sum_val = 0
    num = 10 ** 9 + 7
    for i in range(0, n - 1):
        sum_val += a[i] * (cumsum_a[-1] - cumsum_a[i])
        if sum_val > num:
            sum_val %= num
    print(sum_val)

Buggy submission (verdict: Runtime Error):
import numpy as np
if __name__ == '__main__':
    n = int(input())
    a = np.array(input().split()).astype(np.int64)

    num = 10**9+7

    mat = np.tril(a.reshape((-1, 1)) * a, k=-1)
    mat %= num
    sum = (np.sum(mat)) % num
    print(sum)
Problem p02623 (python)

Fixed submission:
if __name__ == '__main__':
    n, m, k = map(int, input().strip().split())
    a = list(map(int, input().strip().split()))
    b = list(map(int, input().strip().split()))

    min = 0
    a_count = 0
    for i, a_min in enumerate(a):
        if a_min + min <= k:
            min += a_min
            a_count += 1
        else:
            break
    b_count = 0

    for i, b_min in enumerate(b):
        if b_min + min <= k:
            min += b_min
            b_count += 1
        else:
            break

    max_count = a_count + b_count
    if not max_count == n + m and not b_count == m:
        for i in a[:a_count][::-1]:
            min -= i
            a_count -= 1
            while b_count < len(b) and min + b[b_count] <= k:
                min += b[b_count]
                b_count += 1
            if a_count + b_count > max_count:
                max_count = a_count + b_count
            if b_count >= len(b):
                break
    print(max_count)

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    n, m, k = map(int, input().strip().split())
    a = list(map(int, input().strip().split()))
    b = list(map(int, input().strip().split()))

    min = 0
    a_count = 0
    for i, a_min in enumerate(a):
        if a_min + min <= k:
            min += a_min
            a_count += 1
        else:
            break
    b_count = 0

    for i, b_min in enumerate(b):
        if b_min + min <= k:
            min += b_min
            b_count += 1
        else:
            break

    max_count = a_count + b_count
    if not max_count == n+m:
        for i in range(a_count, 0, -1):
            min -= a[i - 1]
            a_count -= 1
            while min + b[b_count] < k:
                min += b[b_count]
                b_count += 1
            if a_count + b_count > max_count:
                max_count = a_count + b_count
    print(max_count)
Problem p02624 (python)

Fixed submission:
if __name__ == '__main__':
    n = int(input().strip())
    ans = 0

    for i in range(1, n + 1):
        limit = int(n / i)
        ans += limit * (limit + 1) * i / 2
    print(int(ans))

Buggy submission (verdict: Runtime Error):
if __name__ == '__main__':
    n = int(input().strip())
    ans = 0

    for i in range(n):
        limit = int(n / i)
        ans += limit * (limit + 1) / 2
    print(ans)
Problem p02685 (python)

Fixed submission:
import copy
n,m,k = map(int, input().split())
if m==1:
    if (n-1==k):
        print(1)
    else:
        print(0)
    exit()

mod = 998244353
if (n-1==k):
    print(pow(m,n,mod))
    exit()
#dp[i][j]:i個まで、j組
def com(n,r,m):
    #a = math.factorial(n)%m
    a = 1
    for i in range(1,n+1):
        a *= i
        a %= m
    A = pow(a,m-2,m)
    
    
    b= copy.deepcopy(A)   
    for i in range(n,r,-1):
        b = (b*i)%m
    
    c = copy.deepcopy(A)
    for i in range(n,n-r,-1):
        c = (c*i)%m
       
    return (a*b*c)%m

ans = m*pow(m-1,n-1,mod)
ans %= mod
#print(ans)
p = pow(m-1,n-k-2,mod)
#com(n-1,i,mod)
c = com(n-1,k+1,mod)
#print(c)
for i in range(k,0,-1):
    p *= (m-1)
    p %= mod
    c *= (i+1)
    c *= pow(n-i-1,mod-2,mod)
    c %= mod
    ans += m * p * c
    ans %= mod
    #print(m-1,i,mod)
    #print(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import copy
n,m,k = map(int, input().split())
if m==1:
    if (n-1<=k):
        print(1)
    else:
        print(0)
    exit()
mod = 998244353
#dp[i][j]:i個まで、j組
def com(n,r,m):
    #a = math.factorial(n)%m
    a = 1
    for i in range(1,n+1):
        a *= i
        a %= m
    A = pow(a,m-2,m)
    
    
    b= copy.deepcopy(A)   
    for i in range(n,r,-1):
        b = (b*i)%m
    
    c = copy.deepcopy(A)
    for i in range(n,n-r,-1):
        c = (c*i)%m
       
    return (a*b*c)%m

ans = m*pow(m-1,n-1,mod)
ans %= mod
#print(ans)
p = pow(m-1,n-k-2,mod)
#com(n-1,i,mod)
c = com(n-1,k+1,mod)
for i in range(k,0,-1):
    p *= (m-1)
    p %= mod
    c *= (i+1)
    c *= pow(n-i-1,mod-2,mod)
    c %= mod
    ans += m * p * c
    ans %= mod
    #print(m-1,i,mod)
    #print(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import copy
n,m,k = map(int, input().split())
mod = 998244353
#dp[i][j]:i個まで、j組
def com(n,r,m):
    #a = math.factorial(n)%m
    a = 1
    for i in range(1,n+1):
        a *= i
        a %= m
    A = pow(a,m-2,m)
    
    
    b= copy.deepcopy(A)   
    for i in range(n,r,-1):
        b = (b*i)%m
    
    c = copy.deepcopy(A)
    for i in range(n,n-r,-1):
        c = (c*i)%m
       
    return (a*b*c)%m

ans = m*pow(m-1,n-1,mod)
ans %= mod
#print(ans)
p = pow(m-1,n-k-2,mod)
#com(n-1,i,mod)
c = com(n-1,k+1,mod)
for i in range(k,0,-1):
    p *= (m-1)
    p %= mod
    c *= (i+1)
    c *= pow(n-i-1,mod-2,mod)
    c %= mod
    ans += m * p * c
    ans %= mod
    #print(m-1,i,mod)
    #print(ans)
print(ans)
Problem p02819 (python)

Fixed submission:
import bisect
x = int(input())
def eratosthenes(limit):
    A = [i for i in range(2,limit+1)]
    P = []
    time = 0
    while True:
        prime = min(A)
        
        if prime > limit**0.5:
            break
        P.append(prime)
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
    for a in A:
        P.append(a)
    return P
L = eratosthenes(100005)
y = bisect.bisect_left(L,x)
print(L[y])

Buggy submission (verdict: Runtime Error):
import bisect
x = int(input())
def eratosthenes(limit):
    A = [i for i in range(2,limit+1)]
    P = []
    time = 0
    while True:
        prime = min(A)
        
        if prime > limit**0.5:
            break
        P.append(prime)
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
    for a in A:
        P.append(a)
    return P
L = eratosthenes(100000)
y = bisect.bisect_left(L,x)
print(L[y])
Problem p03011 (python)

Fixed submission:
p,q,r = map(int, input().split())
print(min(p+q,p+r,q+r))

Buggy submission (verdict: Runtime Error):
import copy
h,w = map(int, input().split())
s = [list(input()) for _ in range(h)]
t = copy.deepcopy(s)
for i in range(h):
    count = 0
    for j in range(w):
        if (s[i][j]=='.'):
            count += 1
            
        else:
            for k in range(j-1,j-count-1,-1):
                s[i][k]=count
            count = 0
    for k in range(w-1,w-count-1,-1):
        s[i][k]=count
    count = 0

for i in range(w):
    count = 0
    for j in range(h):
        if (t[j][i]=='.'):
            count += 1
            
        else:
            for k in range(j-1,j-count-1,-1):
                t[k][i]=count
            count = 0
    for k in range(h-1,h-count-1,-1):
        t[k][i]=count
    count = 0

ans = 0
for i in range(h):
    for j in range(w):
        if (s[i][j]!="#"):
            if (s[i][j]+t[i][j]-1 > ans):
                ans = s[i][j]+t[i][j]-1
print(ans)
Problem p03013 (python)

Fixed submission:
n,m = map(int, input().split())
a = [int(input()) for _ in range(m)]
mod = 1000000007
fib = [1,1,2]
for i in range(3,n+1):
    fib.append((fib[i-2]+fib[i-1])%mod)
if (m==0):
    print(fib[n])
    exit()
ans = 0
ans += fib[a[0]-1]

for i in range(1,m):
    if (a[i]-a[i-1]!=1):
        ans *= fib[a[i]-a[i-1]-2]
        ans %= mod
    else:
        print(0)
        exit()
ans *= fib[n-a[m-1]-1]
print(ans%mod)

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = [int(input()) for _ in range(m)]
mod = 1000000007
fib = [1,1,2]
for i in range(3,n+1):
    fib.append((fib[i-2]+fib[i-1])%mod)
ans = 0
ans += fib[a[0]-1]

for i in range(1,m):
    if (a[i]-a[i-1]!=1):
        ans *= fib[a[i]-a[i-1]-2]
        ans %= mod
    else:
        print(0)
        exit()
ans *= fib[n-a[m-1]-1]
print(ans%mod)
Problem p03038 (python)

Fixed submission:
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

b = [list(map(int, input().split())) for _ in range(m)]
b.sort(key=lambda x: x[1], reverse=True)

x = 0
y = 0
for i in range(m):
    for j in range(b[i][0]):
        if (a[x] < b[i][1]):
            a[x] = b[i][1]
            x += 1
            if (x == n):
                y = 1
                break
        else:
            y = 1
            break
    if (y==1):
        break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

b = [list(map(int, input().split())) for _ in range(m)]
b.sort(key=lambda x: x[1], reverse=True)

x = 0
y = 0
for i in range(m):
    for j in range(b[i][0]):
        if (a[x] < b[i][1]):
            a[x] = b[i][1]
            x += 1
        else:
            y = 1
            break
    if (y==1):
        break
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

b = [list(map(int, input().split())) for _ in range(m)]
b.sort(key=lambda x: x[1], reverse=True)

x = 0
for i in range(m):
    for j in range(b[i][0]):
        if (a[x] < b[i][1]):
            a[x] = b[i][1]
            x += 1
print(sum(a))
Problem p02629 (python)

Fixed submission:
n = int(input())
s = 'abcdefghijklmnopqrstuvwxyz'
t = 0
res = ""
while n > 26:
    n -= 1
    res += s[n % 26]
    n //= 26

res += s[n - 1]
print(res[::-1])

Buggy submission (verdict: Runtime Error):
import itertools

n = int(input())
s = 'abcdefghijklmnopqrstuvwxyz'
t = 0
if n <= 26:
    print(s[n - 1])
    exit()
for i in range(2, 100):
    t += 26 ** i
    n -= 26 ** (i - 1)
    if n <= t:
        t = i
        break
res = list(itertools.product(s, repeat=t))[n - 1]

print("".join(res))
Problem p02659 (python)

Fixed submission:
from decimal import Decimal, ROUND_DOWN, getcontext
a, b = map(str, input().split())
getcontext().prec = 19
getcontext().rounding = ROUND_DOWN
x = Decimal(a)
y = Decimal(b)
print("{:}".format(Decimal(int(x * y)), rounding=ROUND_DOWN))

Buggy submission (verdict: Runtime Error):
a, b = map(str, input().split())
n = len(a)
al = int(a[:n//2])
ar = int(a[n//2:])
b = float(b)
print(al, ar)
res = str(int(al*b)) + str(int(ar * b))
print(res)

Buggy submission (verdict: Runtime Error):
a, b = map(str, input().split())
n = len(a)
al = int(a[:n//2])
ar = int(a[n//2:])
print(al, ar)
res = str(al*b) + str(ar * b)
print(res)
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
n = int(input())
print(r**2)
Problem p02623 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N, M, K = map(int, input().split())
result = 0 # max
a_time = list(map(int, input().split()))
b_time = list(map(int, input().split()))

sum = 0

a_num = 0
for i in range(N):
    sum += a_time[i]
    a_num += 1
    if sum > K:
        sum -= a_time[i]
        a_num -= 1
        break
i = a_num
j = 0
while i >= 0:
    while sum < K and j < M:
        sum += b_time[j]
        j += 1
    if sum > K:
        j -= 1
        sum -= b_time[j]
    if result < i + j:
        result = i + j
    i -= 1
    sum -= a_time[i]

print(result)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N, M, K = map(int, input().split())
result = 0 # max
a_time = list(map(int, input().split()))
b_time = list(map(int, input().split()))

sum = 0

a_num = 0
for i in range(N):
    sum += a_time[i]
    a_num += 1
    if sum > K:
        sum -= a_time[i]
        a_num -= 1
        break
i = a_num
while i >= 0:
    sum -= a_time[i]
    for j in range(M):
        sum += b_time[j]
        if sum > K:
            sum -= b_time[j]
            break
    if result < i + j:
        result = i + j
    i -= 1

print(result)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N, M, K = map(int, input().split())
result = 0 # max
a_time = list(map(int, input().split()))
b_time = list(map(int, input().split()))

sum = 0

a_num = 0
for i in range(N):
    sum += a_time[i]
    a_num += 1
    if sum > K:
        sum -= a_time[i]
        a_num -= 1
        break
i = a_num
while i >= 0:
    sum -= a_time[i]
    for j in range(M):
        sum += b_time[j]
        if sum > K:
            sum -= b_time[j]
            break
    print('result={} i={} j={}'.format(result, i, j))
    if result < i + j:
        result = i + j
    i -= 1

print(result)
Problem p03013 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc129_c

mod = 1000000007
N, M = map(int, input().strip().split())
a = [int(input()) for _ in range(M)]
a.append(N+1)

def fibonacci(x):
    a = 1
    b = 1
    if x <= 2:
        return a
    else:
        for _ in range(x-2):
            tmp = a
            a = b
            b = tmp + b
        return b

res = 1
prev_a = -1
for cur_a in a:
    if  cur_a - prev_a == 1:
        res = 0
        break
    res *= fibonacci(cur_a - prev_a - 1) % mod
    res %= mod
    prev_a = cur_a
    continue

print(res)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc129_c

mod = 1000000007
N, M = map(int, input().strip().split())
a = [int(input()) for _ in range(M)]
a.append(N+1)

def fibonacci(x):
    if x > 2:
        return fibonacci(x-1) + fibonacci(x-2)
    else:
        return 1

res = 1
prev_a = -1
for cur_a in a:
    if  cur_a - prev_a == 1:
        res = 0
        break
    res *= fibonacci(cur_a - prev_a - 1) % mod
    res %= mod
    prev_a = cur_a
    continue

print(res)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc129_c

N, M = map(int, input().strip().split())
a = [int(input()) for _ in range(M)]
a.append(N+1)

def fibonacci(x):
    if x > 2:
        return fibonacci(x-1) + fibonacci(x-2)
    else:
        return 1

res = 1
prev_a = -1
for cur_a in a:
    if  cur_a - prev_a == 1:
        res = 0
        break
    res *= fibonacci(cur_a - prev_a - 1)
    res %= 1000000007
    prev_a = cur_a
    continue

print(res)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc129_c

N, M = map(int, input().strip().split())
a = [int(input()) for _ in range(M)]

def fibonacci(x):
    if x > 2:
        return fibonacci(x-1) + fibonacci(x-2)
    else:
        return 1

res = 1
count = 0
for i in range(N+1):
    if i in a:
        if count == 0:
            res = 0
            break
        res *= fibonacci(count)
        res %= 1000000007
        count = 0
        continue
    count += 1

if res != 0:
    res *= fibonacci(count)
    res %= 1000000007

print(res)
Problem p02597 (python)

Fixed submission:
from collections import Counter

N = int(input())
S = input()

c = Counter(S)
S_target = 'R' * c['R'] + 'W' * c['W']

ans = 0
for a, b in zip(S, S_target):
    if b == 'W':
        break
    if a != b:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

c = Counter(S)
S_target = 'R' * c['R'] + 'W' * c['W']

ans = 0
for a, b in zip(S, S_target):
    if b == 'W':
        break
    if a != b:
        ans += 1
print(ans)