Problem p03013 (python)

Fixed submission:
import sys
N, M = map(int, input().split())
if N == 1:
    print(1)
    sys.exit()
ana = [0] * M
ans = [0] * N
mod = 10 ** 9 + 7
if M != 0:
    for i in range(M):
      ans[int(input())-1] = -1
if ans[0] == -1 and ans[1] == -1:
    print(0)
    sys.exit()
elif ans[0] == -1:
    ans[0] = 0
    ans[1] = 1
elif ans[1] == -1:
    ans[0] = 1
    ans[1] = 0
else:
    ans[0] = 1
    ans[1] = 2

if N != 2:
    for i in range(2,N):
        if ans[i] == -1:
            ans[i] = 0
        else:
            ans[i] = (ans[i-1]  + ans[i-2]) % mod
print(ans[N-1])

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
N, M = map(int, input().split())
stairs = [0]*(N+1)
for _ in range(M):
    stairs[int(input())] = 1
ans = [0]*(N+1)
ans[1] = 1 if stairs[1] == 0 else 0
ans[2] = 1 + ans[1] if stairs[2] == 0 else ans[1]
for i in range(3,N+1):
    if stairs[i] == 1:
        ans[i] = 0
        continue
    ans[i] = (ans[i-1] + ans[i-2]) % MOD
print(ans[N])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, M = map(int,input().split())
hole = [0] * (N+1)
for i in range(M):
    hole[int(input())] = 1
flg_one = False
flg_two = False
if hole[1] == 1:
    first = 0
    second = 1
    flg_one = True
elif hole[2] == 1:
    first = 1
    second = 0
    flg_two = True
else:
    first = 1
    second = 2

if flg_one and flg_two:
    print(0)
    exit()
flg = False

for i in range(3,N):
    if hole[i] == 1:
        if flg:
            print(0)
            exit()
        flg = True
        first = second
        second = 0
        flg = False
        continue
    tmp = first + second
    tmp %= 1000000007
    first = second
    second = tmp
    flg = False
tmp = first + second
tmp %= 1000000007
print(tmp)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ana = [0] * M
ans = [0] * N
mod = 10 ** 9 + 7
if M != 0:
    for i in range(M):
      ans[int(input())-1] = -1

if ans[0] == -1:
    ans[0] = 0
    ans[1] = 1
elif ans[1] == -1:
    ans[0] = 1
    ans[1] = 0
else:
    ans[0] = 1
    ans[1] = 2

if N != 2:
    for i in range(2,N):
        if ans[i] == -1:
            ans[i] = 0
        else:
            ans[i] = (ans[i-1]  + ans[i-2]) % mod
print(ans[N-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ana = [0] * M
ans = [0] * N
mod = 10 ** 9 + 7
if M != 0:
    for i in range(M):
      ans[int(input())-1] = -1

if ans[0] == -1:
    ans[0] = 0
    ans[1] = 1
elif ans[1] == -1:
    ans[0] = 1
    ans[1] = 0
else:
    ans[0] = 1
    ans[1] = 2

for i in range(2,N):
    if ans[i] == -1:
        ans[i] = 0
    else:
        ans[i] = (ans[i-1]  + ans[i-2]) % mod
print(ans[N-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ana = [0] * M
ans = [0] * N
mod = 10 ** 9 + 7
for i in range(M):
  ans[int(input())-1] = -1

if ans[0] == -1:
    ans[0] = 0
    ans[1] = 1
elif ans[1] == -1:
    ans[0] = 1
    ans[1] = 0
else:
    ans[0] = 1
    ans[1] = 2

for i in range(2,N):
    if ans[i] == -1:
        ans[i] = 0
    else:
        ans[i] = (ans[i-1]  + ans[i-2]) % mod
print(ans[N-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ana = [0] * M
for i in range(M):
  ana[i] = input()
ans = [0] * N
ans[0] = 1# 一段目まで登る方法は一通り
ans[1] = 2# 二段目まで登る方法は二通り
 
for i in range(2,N):
    tmp = i+1
    tmp2 = str(tmp)
    if tmp2 in ana:
        continue
    else:
        ans[i] = (ans[i-1] + ans[i-2]) % 1000000007
 
print(ans[N-1])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ana = []
for _ in range(M):
  ana.append(input())
ans = [0] * N
ans[0] = 1# 一段目まで登る方法は一通り
ans[1] = 2# 二段目まで登る方法は二通り
 
for i in range(2,N):
    tmp = i+1
    tmp2 = str(tmp)
    if tmp2 in ana:
        ans[i] = 0
    else:
        ans[i] = (ans[i-1] + ans[i-2]) % 1000000007
 
print(ans[N-1])