Problem p03013 (python)

Fixed submission:
a = [-1]

N, M = map(int, input().split(' '))

for _ in range(M):
    a.append(int(input()))
a.append(N+1)

#print(a)

b = []
for i in range(M+1):
    b.append(a[i+1] - a[i] - 2)

if min(b) < 0:
    print(0)
else:
    result = 1

    f_list = []
    for i in range(max(b)+1):
        if i == 0 or i == 1:
            f_list.append(1)
        else:
            f_list.append(f_list[i-2] + f_list[i-1])

    for i in range(M+1):
        result = result * f_list[b[i]]
        result = result % (10**9 + 7)

    print(result)

Buggy submission (verdict: Runtime Error):
a = [-1]

N, M = map(int, input().split(' '))

for _ in range(M):
    a.append(int(input()))
a.append(N+1)

#print(a)

b = []
for i in range(M+1):
    b.append(a[i+1] - a[i] - 2)

#print(b)

def func(n):
    if n == -1:
        retval = 0
    elif n >= 0 and n <= 1:
        retval = 1
    else:
        retval = func(n-2) + func(n-1)
    return retval % (10**9 + 7)

result = 1

for i in range(M+1):
    result = result * func(b[i])
    result = result % (10**9 + 7)

print(result)

Buggy submission (verdict: Runtime Error):
a = [-1]

N, M = map(int, input().split(' '))

for _ in range(M):
    a.append(int(input()))
a.append(N+1)

#print(a)

b = []
for i in range(M+1):
    b.append(a[i+1] - a[i] - 2)

#print(b)

def func(n):
    if n == -2:
        retval = 0
    elif n >= -1 and n <= 1:
        retval = 1
    else:
        retval = func(n-2) + func(n-1)
    return retval % (10**9 + 7)

result = 1

for i in range(M+1):
    result = result * func(b[i])
    result = result % (10**9 + 7)

print(result)

Buggy submission (verdict: Runtime Error):
a = [0]

N, M = map(int, input().split(' '))

for _ in range(M):
    a.append(int(input()))
a.append(N+1)

#print(a)

b = []
for i in range(M+1):
    b.append(a[i+1] - a[i] - 2)

#print(b)

def func(n):
    if n == -2:
        retval = 0
    elif n == -1:
        retval = 1
    elif n == 0:
        retval = 1
    elif n == 1:
        retval = 1
    else:
        retval = func(n-2) + func(n-1)
    return retval % (10**9 + 7)

result = 1

for i in range(M+1):
    result = result * func(b[i])
    result = result % (10**9 + 7)

print(result)

Buggy submission (verdict: Runtime Error):
a = [0]

N, M = map(int, input().split(' '))

for _ in range(M):
    a.append(int(input()))
a.append(N+1)

#print(a)

b = []
for i in range(M+1):
    b.append(a[i+1] - a[i] - 2)

#print(b)

def func(n):
    if n == -1:
        retval = 1
    elif n == 0:
        retval = 1
    elif n == 1:
        retval = 1
    else:
        retval = func(n-2) + func(n-1)
    return retval % (10**9 + 7)

result = 1

for i in range(M+1):
    result = result * func(b[i])
    result = result % (10**9 + 7)

print(result)

Buggy submission (verdict: Runtime Error):
a = [0]

N, M = map(int, input().split(' '))

for _ in range(M):
    a.append(int(input()))
a.append(N+1)

print(a)

b = []
for i in range(M+1):
    b.append(a[i+1] - a[i] - 2)

print(b)

def func(n):
    if n == -1:
        retval = 1
    elif n == 0:
        retval = 1
    elif n == 1:
        retval = 1
    else:
        retval = func(n-2) + func(n-1)
    return retval % (10**9 + 7)

result = 1

for i in range(M+1):
    result = result * func(b[i])
    result = result % (10**9 + 7)

print(result)