Problem p03013 (python)

Fixed submission:
import sys

mod = 10**9 + 7

def fibo(n):
    a, b = 0, 1
    if n == 1:
        return 1
    else:
        for i in range(n):
            a0 = a
            a = b
            b = a0 + b
        return b
        
N, M = map(int, input().split())
a = []
 
if M == 0:
    print(fibo(N) % mod)
    sys.exit()
 
for i in range(M):
    a.append(int(input()))
    
for j in range(len(a)-1):
    if a[j+1] - a[j] == 1:
        print(0)
        sys.exit()
    
hole = 0
pattern = 1
 
for i, k in enumerate(a):
    if i == 0:
        pattern *= fibo(k-1)
    else:
        if i > 0:
            pattern *= fibo(a[i]-a[i-1]-2)
        
pattern *= fibo(N-a[-1]-1)
print(pattern % mod)

Buggy submission (verdict: Runtime Error):
# PROXY

import math
N, M = [int(i) for i in input().split()]
list = i = [int(input()) for i in range(M)]
Nlist = []
counter = 1
while counter < M:
    Diff_id = list[counter] - list[counter - 1]
    Nlist.append(Diff_id - 2 if Diff_id != 1 else -1)
    counter += 1
Nlist.insert(0,list[0] -1 if list[0] - 1 != 0 else 1)
Nlist.insert(M,N - list[M - 1] - 1 if N - list[M - 1] - 1 != 0 else 1)
counter = 0
ANSER = 1
while counter <= M:
    SQ5 = math.sqrt(5)
    P = ((1 + SQ5) / 2)**(Nlist[counter] + 1)
    Q = ((1 - SQ5) / 2)**(Nlist[counter] + 1)
    HowMany = math.floor((P - Q ) / SQ5)
    ANSER *= HowMany
    counter += 1
print(ANSER % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
import sys

def fibo(n):
    a, b = 0, 1
    if n == 1:
        return 1
    else:
        for i in range(n):
            a0 = a
            a = b
            b = a0 + b
        return b
        
N, M = map(int, input().split())
a = []

if M = 0:
    print(fibo(N))
    sys.exit()

for i in range(M):
    a.append(int(input()))
    
for j in range(len(a)-1):
    if a[j+1] - a[j] == 1:
        print(0)
        sys.exit()
    
hole = 0
pattern = 1

for i, k in enumerate(a):
    if i == 0:
        pattern *= fibo(k-1)
    else:
        if i > 0:
            pattern *= fibo(a[i]-a[i-1]-2)
        
pattern *= fibo(N-a[-1]-1)
print(pattern % 1000000007)

Buggy submission (verdict: Runtime Error):
import sys

def fibo(n):
    a, b = 0, 1
    if n == 1:
        return 1
    else:
        for i in range(n):
            a0 = a
            a = b
            b = a0 + b
        return b
        
N, M = map(int, input().split())
a = []

for i in range(M):
    a.append(int(input()))
    
for j in range(len(a)-1):
    if a[j+1] - a[j] == 1:
        print(0)
        sys.exit()
    
hole = 0
pattern = 1

for i, k in enumerate(a):
    if i == 0:
        pattern *= fibo(k-1)
    else:
        pattern *= fibo(a[i]-a[i-1]-2)
        
pattern *= fibo(N-a[-1]-1)
print(pattern % 1000000007)

Buggy submission (verdict: Runtime Error):
import sys

def fibo(n):
    a, b = 0, 1
    if n == 1:
        return 1
    else:
        for i in range(n):
            a0 = a
            a = b
            b = a0 + b
        return b
        
N, M = map(int, input().split())
a = []

for i in range(M):
    a.append(int(input()))
    
for j in range(len(a)-1):
    if a[j+1] - a[j] == 1:
        print(0)
        sys.exit()
    
hole = 0
pattern = 1

for a_ in a:
    hole = a_ - hole
    pattern *= fibo(hole-1)
    hole = a_
    
pattern *= fibo(N-hole-1)

print(pattern % 1_000_000_007)