Problem p03013 (python)

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    N, M =map(int, input().split())
    a = [int(input()) for i in range(M)]

    sep = []
    pre = -1
    ok = True
    for t in a:
        tmp = t - pre - 1
        if tmp == 0:
            ok = False
            break
        sep.append(tmp)
        pre = t
    sep.append(N-pre)
    # print(sep)

    if not ok:
        print(0)
        return
    max_sep = max(sep)

    MOD = 1000000007
    fib = [1] * (max_sep)
    for i in range(2, max_sep):
        fib[i] = fib[i-2] + fib[i-1]
        fib[i] %= MOD
    
    ans = 1
    for s in sep:
        ans *= fib[s-1]
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()

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

group = []

MOD = 1000000007

if M == 0:
    group.append(N+1)
else:
    pre_a = int(input())
    group.append(pre_a)

    for i in range(M-1):
        a = int(input())
        tmp = a - pre_a - 1
        pre_a = a
        group.append(tmp)
    group.append(N - pre_a)

if 0 in group or -1 in group:
    print(0)
else:
    fiv = [1 for i in range(max(group))]
    fiv[0] = 1
    fiv[1] = 1
    for i in range(2, len(fiv)):
        fiv[i] = (fiv[i-1] + fiv[i-2]) % MOD
    ans = 1
    for g in group:
        ans *= fiv[g-1]
        ans %= MOD
    print(ans)

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

group = []

MOD = 1000000007

if M == 0:
    group.append(N+1)
else:
    pre_a = int(input())
    group.append(pre_a)

    for i in range(M-1):
        a = int(input())
        tmp = a - pre_a - 1
        pre_a = a
        group.append(tmp)
    group.append(N - pre_a)

if 0 in group:
    print(0)
else:
    fiv = [0 for i in range(max(group))]
    fiv[0] = 1
    fiv[1] = 1
    for i in range(2, len(fiv)):
        fiv[i] = (fiv[i-1] + fiv[i-2]) % MOD
    ans = 1
    for g in group:
        ans *= fiv[g-1]
    print(ans%MOD)

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

group = []

MOD = 1000000007

if M == 0:
    group.append(N)
else:
    pre_a = int(input())
    group.append(pre_a)

    for i in range(M-1):
        a = int(input())
        tmp = a - pre_a - 1
        pre_a = a
        group.append(tmp)
    group.append(N - pre_a)

if 0 in group:
    print(0)
else:
    fiv = [0 for i in range(max(group))]
    fiv[0] = 1
    fiv[1] = 1
    for i in range(2, len(fiv)):
        fiv[i] = (fiv[i-1] + fiv[i-2]) % MOD
    ans = 1
    for g in group:
        ans *= fiv[g-1]
    print(ans%MOD)

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

group = []

MOD = 1000000007

pre_a = int(input())
group.append(pre_a)

ok = True
for i in range(M-1):
    a = int(input())
    tmp = a - pre_a - 1
    pre_a = a
    group.append(tmp)
group.append(N - pre_a)

if 0 in group:
    print(0)
else:
    fiv = [0 for i in range(max(group))]
    fiv[0] = 1
    fiv[1] = 1
    for i in range(2, len(fiv)):
        fiv[i] = (fiv[i-1] + fiv[i-2]) % MOD
    ans = 1
    for g in group:
        ans *= fiv[g-1]
    print(ans%MOD)

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

group = []

MOD = 1000000007

pre_a = int(input())
group.append(pre_a)

ok = True
for i in range(M-1):
    a = int(input())
    tmp = a - pre_a - 1
    pre_a = a
    if tmp == 0:
        ok = False
    else:
        group.append(tmp)
    if not ok:
        break
group.append(N - pre_a)

if not ok:
    print(0)
elif max(group) == 1:
    print(1)
else:
    fiv = [0 for i in range(max(group))]
    fiv[0] = 1
    fiv[1] = 1
    for i in range(2, len(fiv)):
        fiv[i] = (fiv[i-1] + fiv[i-2]) % MOD
    ans = 1
    for g in group:
        ans *= fiv[g-1]
    print(ans%MOD)

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

group = []

MOD = 1000000007

pre_a = int(input())
group.append(pre_a)

ok = True
for i in range(M-1):
    a = int(input())
    tmp = a - pre_a - 1
    pre_a = a
    if tmp == 1:
        ok = False
    else:
        group.append(tmp)
    if not ok:
        break
group.append(N - pre_a)

if not ok:
    print(0)
elif max(group) == 1:
    print(1)
else:
    fiv = [0 for i in range(max(group))]
    fiv[0] = 1
    fiv[1] = 1
    for i in range(2, len(fiv)):
        fiv[i] = (fiv[i-1] + fiv[i-2]) % MOD
    ans = 1
    for g in group:
        ans *= fiv[g-1]
    print(ans%MOD)