Problem p03013 (python)

Fixed submission:
import sys
mod = 10**9+7
def main():
    n,m=map(int,input().split(' '))
    if m > 0:
        aaa = set(map(int,sys.stdin))
    else:
        aaa = set()

    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 1 if 1 not in aaa else 0
    for i in range(2,n+1):
        if i in aaa:
            continue
        dp[i] = dp[i-1]+dp[i-2]

    print(dp[n]%mod)

main()

Buggy submission (verdict: Runtime Error):
import math
mod = 10**9+7

def stairs(n):
    a = 1/math.sqrt(5)
    b = (1+math.sqrt(5))/2
    c = (1-math.sqrt(5))/2
    return int(a*(b**(n+1)-c**(n+1)))%mod

def main():
    n,m = map(int,input().split(' '))
    a=[-1]
    a_list=[]
    ans = 1
    if m !=0:
        for i in range(m):
            a.append(int(input()))
        a.append(n+1)
        for i in range(m+1):
            a_list.append(a[i+1]-a[i]-2)
        for i in a_list:
            if i <0:
                ans = 0
                break
            ans *= stairs(i)
            ans %= mod
        print(ans)
    else:
        print(stairs(n)%mod)

main()

Buggy submission (verdict: Runtime Error):
import math
mod = 10**9+7

def stairs(n):
    a = 1/math.sqrt(5)
    b = (1+math.sqrt(5))/2
    c = (1-math.sqrt(5))/2
    return int(a*(b**(n+1)-c**(n+1)))%mod

def main():
    n,m = map(int,input().split(' '))
    a=[-1]
    a_list=[]
    ans = 1
    for i in range(m):
        a.append(int(input()))
    a.append(n+1)
    for i in range(m+1):
        a_list.append(a[i+1]-a[i]-2)
    for i in a_list:
        if i <0:
            ans = 0
            break
        ans *= stairs(i)
        ans %= mod
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
import math
mod = 10**9+7

def stairs(n):
    a = 1/math.sqrt(5)
    b = (1+math.sqrt(5))/2
    c = (1-math.sqrt(5))/2
    return int(a*(b**(n+1)-c**(n+1)))%mod

def main():
    n,m = map(int,input().split(' '))
    a=[-1]
    a_list=[]
    ans = 1
    for i in range(m):
        a.append(int(input()))
    a.append(n+1)
    for i in range(m+1):
        a_list.append(a[i+1]-a[i]-2)
    print(a_list)
    for i in a_list:
        if i <0:
            ans = 0
            break
        ans *= stairs(i)
        ans %= mod
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
mod = 10**9+7

def stairs(n):
    if n == 0:
        return 1
    elif n == 1:
        return 1
    else:
        return stairs(n-1)%mod+stairs(n-2)%mod

def main():
    n,m = map(int,input().split(' '))
    a=[-1]
    a_list=[]
    ans = 1
    for i in range(m):
        a.append(int(input()))
    a.append(n+1)
    for i in range(m+1):
        a_list.append(a[i+1]-a[i]-2)
    for i in a_list:
        if i <0:
            ans = 0
            break
        ans *= stairs(i)
        ans %= mod
    print(ans)

main()

Buggy submission (verdict: Runtime Error):
mod = 10**9+7

def stairs(n):
    if n ==0:
        return 1
    if n ==1:
        return 1
    else:
        return stairs(n-1)+stairs(n-2)
def main():
    n,m=map(int,input().split(' '))
    a = [-1]
    a_dis=[]
    ans = 1
    for i in range(m):
        a.append(int(input()))
    for i in range(m):
        a_dis.append(a[i+1]-a[i]-2)
    a_dis.append(n-a[-1]-1)
    for i in a_dis:
        if i <0:
            ans = 0
            break
        tmp = stairs(i)%mod
        ans *=tmp
        ans %= mod
        tmp = 0
    print(ans)

main()