Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
mod=10**9+7

    
dp=[0]*(n+1)
dp[0]=1

a=set(int(input()) for i in range(m))

for i in range(1,n+1):
    if i in a:
        continue
    x=dp[i-1]
    if i>1:
        x+=dp[i-2]
    dp[i]=x%mod
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7

    
def fib(j):
    if j==1:
        return 1
    if j==2:
        return 2
    return fib(j-1)+fib(j-2)


ans=1
now=0

for i in range(m):
    a=int(input())
    if a==now:
        ans=0
        break
    if a-1==now:
        now=a+1
        continue
    ans*=fib((a-now-1))
    ans=ans%mod
    now=a+1

if now!=n:
    ans*=fib((n-now))
    ans=ans%mod
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7

    
def fib(j):
    if j==1:
        return 1
    if j==2:
        return 2
    return fib(j-1)+fib(j-2)


ans=1
now=0

for i in range(m):
    a=int(input())
    if a==now:
        ans=0
        break
    if a-1==now:
        now=a+1
        continue
    ans*=fib((a-now-1))
    ans=ans%mod
    now=a+1

ans*=fib((n-now))
ans=ans%mod
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())

a=[int(input()) for i in range(m)]

def fib(n):
    if n==0:
        return 1
    if n==1:
        return 1
    if n==2:
        return 2
    return fib(n-1)+fib(n-2)

ans=1
check=0
for i in a:
    if i-check==1 and i!=1:
        print(0)
        exit()
    if i-check==1 and i==1:
        check=1
    else:
      ans*= fib(i-check-2)
      check=i
ans*=fib(n-a[-1]-1)
print(ans%((10**9)+7))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())

a=[int(input()) for i in range(m)]

def fib(n):
    if n==1:
        return 1
    if n==2:
        return 2
    return fib(n-1)+fib(n-2)

ans=1
check=0
for i in a:
    if i-check==1 and i!=1:
        print(0)
        exit()
    if i-check==1 and i==1:
        check=2
    else:
      ans*= fib(i-check-1)
      check=i+1
ans*=fib(n-a[-1]-1)
print(ans%((10**9)+7))

Buggy submission (verdict: Runtime Error):
import sys
#input = sys.stdin.readline
sys.setrecursionlimit(10**9)
n,m=map(int,input().split())

a=[int(input()) for i in range(m)]

def fib(n):
    if n==1:
        return 1
    if n==2:
        return 2
    return fib(n-1)+fib(n-2)

ans=1
check=0
for i in a:
    if i-check==1 and i!=1:
        print(0)
        exit()
    if i-check==1 and i==1:
        check=2
    else:
      ans*= fib(i-check-1)
      check=i+1
ans*=fib(n-a[-1]-1)
print(ans%((10**9)+7))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())

a=[int(input()) for i in range(m)]

def fib(n):
    if n==1:
        return 1
    if n==2:
        return 2
    return fib(n-1)+fib(n-2)

ans=0
check=0
for i in a:
    if i-check==1:
        print(0)
        exit()
    ans+= fib(i-check-1)
    check=i
ans+=fib(n-check-1)
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())

a=[int(input()) for i in range(m)]

def fib(n):
    if n==1:
        return 1
    if n==2:
        return 2
    return fib(n-1)+fib(n-2)

ans=0
check=0
for i in a:
    if i-check==1:
        ans=0
        exit()
    ans+= fib(i-check-1)
    check=i
ans+=fib(n-check-1)
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())

a=[int(input()) for i in range(m)]

def fib(n):
    if n==1:
        return 1
    if n==2:
        return 2
    return fib(n-1)+fib(n-2)

ans=0
check=0
for i in a:
    if i-check==1:
        ans=0
        break
    ans+= fib(i-check-1)
    check=i
if ans!=0:
    ans+=fib(n-check-1)
print(ans%(10**+7))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n,m=map(int,input().split())

a=[int(input()) for i in range(m)]

def fib(n):
    if n==1:
        return 1
    if n==2:
        return 2
    return fib(n-1)+fib(n-2)

ans=0
check=0
for i in a:
    if i-check==1:
        ans=0
        break
    ans+= fib(i-check-1)
    check=i
if ans!=0:
    ans+=fib(n-check-1)
print(ans)