Problem p03013 (python)

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

N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

if M > 0:
    for i in range(M-1):
        if a[i+1] - a[i] == 1:
            print(0)
            exit()

check = set(a)
if 1 in check:
    dp = [0, 0, 1]
elif 2 in check:
    dp = [0, 1, 0]
else:
    dp = [0, 1, 2]
if N < 3:
    print(dp[N])
    exit()
for i in range(3, N+1):
    if i in check:
        dp.append(0)
    else:
        dp.append((dp[-1] + dp[-2])%1000000007)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

for i in range(M-1):
    if a[i+1] - a[i] == 1:
        print(0)
        exit()

check = set(a)
if a[0] == 1:
    dp = [0, 0, 1]
else:
    dp = [0, 1, 2]
if N < 3:
    print(dp[N])
    exit()
for i in range(3, N+1):
    if i in check:
        dp.append(0)
    else:
        dp.append((dp[-1] + dp[-2])%1000000007)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

for i in range(M-1):
    if a[i+1] - a[i] == 1:
        print(0)
        exit()

check = set(a)
if a[0] == 1:
    dp = [0, 0, 1, 1]
    start = 4
    if N < 4:
        print(dp[N])
        exit()
else:
    dp = [0, 1, 2]
    start = 3
    if N < 3:
        print(dp[N])
        exit()
for i in range(start, N+1):
    if i in check:
        dp.append(0)
    else:
        dp.append((dp[-1] + dp[-2])%1000000007)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

for i in range(M-1):
    if a[i+1] - a[i] == 1:
        print(0)
        exit()

check = set(a)
if a[0] == 1:
    dp = [0, 0, 1, 1]
    start = 4
else:
    dp = [0, 1, 2]
    start = 3
for i in range(start, N+1):
    if i in check:
        dp.append(0)
    else:
        dp.append((dp[-1] + dp[-2])%1000000007)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

if M == 0:
    arr = N
else:
    arr = [a[0] - 1]
    for i in range(M-1):
        print(a[i], a[i+1])
        diff = a[i+1] - a[i] - 1
        arr.append(diff)
        if diff == 0:
            print(0)
            exit()
    arr.append(N - a[-1] - 1)

count = [1, 1, 2]
for i in range(3, max(arr)+1):
    count.append(count[-1] + count[-2])

ans = 1
for value in arr:
    ans *= count[value]
    ans = ans % 1000000007

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

if M = 0:
    arr = N
else:
    arr = [a[0] - 1]
    for i in range(M-1):
        print(a[i], a[i+1])
        diff = a[i+1] - a[i] - 1
        arr.append(diff)
        if diff == 0:
            print(0)
            exit()
    arr.append(N - a[-1] - 1)

count = [1, 1, 2]
for i in range(3, max(arr)+1):
    count.append(count[-1] + count[-2])

ans = 1
for value in arr:
    ans *= count[value]
    ans = ans % 1000000007

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from collections import Counter
input = sys.stdin.readline

N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

arr = [a[0] - 1]
for i in range(M-1):
    print(a[i], a[i+1])
    diff = a[i+1] - a[i] - 1
    arr.append(diff)
    if diff == 0:
        print(0)
        exit()
arr.append(N - a[-1] - 1)

count = [1, 1, 2]
for i in range(3, max(arr)+1):
    count.append(count[-1] + count[-2])

ans = 1
for value in arr:
    ans *= count[value]
    ans = ans % 1000000007

print(ans)