Problem p03013 (python)

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

lists=[]
for i in range(m):
    a=int(input())
    lists.append(a)

fiblist=[1,1]
for j in range(10**5):
    nums=(fiblist[-1]+fiblist[-2])%(10**9+7)
    fiblist.append(nums)
lists.insert(0,0)
lists.append(n)
ans=1
if m>=2:
    for i in range(m+1):
        if i==0:
            ans=ans*fiblist[lists[1]-lists[0]-1]
            ans=ans%(10**9+7)
        elif i==m:
            ans=ans*fiblist[lists[m+1]-lists[m]-1]
            ans=ans%(10**9+7)
        elif i!=0 and i!=m:
            if lists[i+1]-lists[i]==1:
                ans=0
                break
            else:
                ans=ans*fiblist[lists[i+1]-lists[i]-2]
                ans=ans%(10**9+7)
    print(ans) 
if m==0:
    print(fiblist[n])
if m==1:
    print(fiblist[lists[1]-1]*fiblist[n-lists[1]-1]%(10**9+7))

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

lists=[]
for i in range(m):
    a=int(input())
    lists.append(a)

fiblist=[1,1]
for j in range(10**5):
    nums=(fiblist[-1]+fiblist[-2])%(10**9+7)
    fiblist.append(nums)
lists.insert(0,0)
lists.append(n)
ans=1
if m>=2:
    for i in range(m+1):
        if i==0:
            ans=ans*fiblist[lists[1]-lists[0]-1]
            ans=ans%(10**9+7)
        elif i==m:
            ans=ans*fiblist[lists[m+1]-lists[m]-1]
            ans=ans%(10**9+7)
        elif i!=0 and i!=m:
            if lists[i+1]-lists[i]==1:
                ans=0
                break
            else:
                ans=ans*fiblist[lists[i+1]-lists[i]-2]
                ans=ans%(10**9+7)
    print(ans) 
if m==0:
    print(fib(n))
if m==1:
    print(fib(lists[1]-1)*fib(n-lists[1]-1)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
if m>=2:
    lists=[]
    for i in range(m):
        a=int(input())
        lists.append(a)

    fiblist=[1,1]
    for j in range(10**5):
        nums=(fiblist[-1]+fiblist[-2])%(10**9+7)
        fiblist.append(nums)
    lists.insert(0,0)
    lists.append(n)
    ans=1
    for i in range(m+1):
        if i==0:
            ans=ans*fiblist[lists[1]-lists[0]-1]
            ans=ans%(10**9+7)
        elif i==m:
            ans=ans*fiblist[lists[m+1]-lists[m]-1]
            ans=ans%(10**9+7)
        elif i!=0 and i!=m:
            if lists[i+1]-lists[i]==1:
                ans=0
                break
            else:
                ans=ans*fiblist[lists[i+1]-lists[i]-2]
                ans=ans%(10**9+7)
    print(ans) 
if m==0:
    print(fib(n))
if m==1:
    print(fib(lists[0]-1)*fib(n-lists[0]-1)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
use=[0]
ans=1
for i in range(m):
    use.append(int(input()))
use.append(n)

if N>=2:        
    lists=[1,2]

    for i in range(n-2):
        lists.append((lists[-1]+lists[-2])%1000000007)

    
    for i in range(m+1):
    
        if use[i+1]-use[i]==1 and i>=1:
            ans=0
            break
        else:
            ans=(ans*lists[int(use[i+1]-use[i]-2)])%1000000007
            
            
    print(ans)
elif N==1:
    print(1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
use=[0]
ans=1
for i in range(m):
    use.append(int(input()))
use.append(n)
print(use)
if N>=2:        
    lists=[1,2]

    for i in range(n-2):
        lists.append((lists[-1]+lists[-2])%1000000007)

    
    for i in range(m+1):
    
        if use[i+1]-use[i]==1 and i>=1:
            ans=0
            break
        else:
            ans=(ans*lists[int(use[i+1]-use[i]-2)])%1000000007
            
            
    print(ans)
elif N==1:
    print(1)