Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
A = set([int(input()) for _ in range(M)])
MOD = 1000000007
memo = [0]*(N+1)
memo[0] = 1
if 1 not in A:
    memo[1] = 1
for i in range(2, N+1):
    if i not in A:
        memo[i] = (memo[i-2] + memo[i-1])%MOD
print(memo[N])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10*10)
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
MOD = 1000000007
def Fib(n, A, MOD, memo={}):
    if n in A:
        return 0
    elif n == 0:
        return 1
    elif n == 1:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = ( Fib(n-1, A, MOD, memo) + Fib(n-2, A, MOD, memo) ) % MOD
        return memo[n]

print(Fib(N, A, MOD))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10*20)
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
MOD = 1000000007
def Fib(n, A, MOD, memo={}):
    if n in A:
        return 0
    elif n == 0:
        return 1
    elif n == 1:
        return 1
    elif n in memo:
        return memo[n]
    else:
        memo[n] = ( Fib(n-1, A, MOD, memo) + Fib(n-2, A, MOD, memo) ) % MOD
        return memo[n]

print(Fib(N, A, MOD))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10*50)
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
MOD = 1000000007
def Fib(n, A, MOD, memo={}):
    if n in A:
        return 0
    elif n == 1:
        return 1
    elif n == 2:
        if 1 in A:
            return 1
        else:
            return 2
    elif n in memo:
        return memo[n]
    else:
        memo[n] = ( Fib(n-1, A, MOD, memo) + Fib(n-2, A, MOD, memo) ) % MOD
        return memo[n]

print(Fib(N, A, MOD))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10*20)
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
MOD = 1000000007
def Fib(n, A, MOD, memo={}):
    if n in A:
        return 0
    elif n == 1:
        return 1
    elif n == 2:
        if 1 in A:
            return 1
        else:
            return 2
    elif n in memo:
        return memo[n]
    else:
        memo[n] = ( Fib(n-1, A, MOD, memo) + Fib(n-2, A, MOD, memo) ) % MOD
        return memo[n]

print(Fib(N, A, MOD))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
MOD = 1000000007
def Fib(n, A, MOD, memo={}):
    if n in A:
        return 0
    elif n == 1:
        return 1
    elif n == 2:
        if 1 in A:
            return 1
        else:
            return 2
    elif n in memo:
        return memo[n]
    else:
        memo[n] = ( Fib(n-1, A, MOD, memo) + Fib(n-2, A, MOD, memo) ) % MOD
        return memo[n]

print(Fib(N, A, MOD))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
MOD = 1000000007
def Fib(n, A, memo={}):
    global MOD
    if n in A:
        return 0
    elif n == 1:
        return 1
    elif n == 2:
        return 2
    elif n in memo:
        return memo[n]
    else:
        memo[n] = ( Fib(n-1, A, memo) + Fib(n-2, A, memo) ) % MOD
        return memo[n]

print(Fib(N, A))