Problem p03013 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

def acinput():
    return list(map(int, input().split(" ")))


N, M = acinput()
a = [0]*(N+1)
for i in range(M):
    a[int(input())] = 1


Mod = 1000000007


def solve(x):
    global dp, Mod
    if dp[x] >= 0:
        return dp[x]

    if x < 0:
        return 0

    res = 0
    zeroflg = True

    if  a[x-2] != 1:
        res += solve(x-2) 
        zeroflg = False

    if a[x-1] != 1:
        res += solve(x-1)
        zeroflg = False

    if zeroflg:
        return 0
    dp[x] = res% Mod
    return res


dp = [-1]*(N+1)
dp[0] = 1
dp[1] = 1

print(solve(N) % Mod)


'''
5 1
1
'''

Buggy submission (verdict: Runtime Error):
import sys
    sys.setrecursionlimit(1000000)

def acinput():
    return list(map(int, input().split(" ")))


N, M = acinput()
a = [0]*(N+1)
for i in range(M):
    a[int(input())] = 1


Mod = 1000000007


def solve(x):
    global dp, Mod
    if dp[x] >= 0:
        return dp[x]

    if x < 0:
        return 0

    res = 0
    zeroflg = True

    if  a[x-2] != 1:
        res += solve(x-2) 
        zeroflg = False

    if a[x-1] != 1:
        res += solve(x-1)
        zeroflg = False

    if zeroflg:
        return 0
    dp[x] = res% Mod
    return res


dp = [-1]*(N+1)
dp[0] = 1
dp[1] = 1

print(solve(N) % Mod)


'''
5 1
1
'''

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int, input().split(" ")))


N, M = acinput()
a = [0]*(N+100)
for i in range(M):
    a[int(input())] = 1


Mod = 1000000007


def solve(x):
    global dp, Mod
    if dp[x] >= 0:
        return dp[x]

    if x < 0:
        return 0

    res = 0
    zeroflg = True

    if  a[x-2] != 1:
        res += solve(x-2) 
        zeroflg = False

    if a[x-1] != 1:
        res += solve(x-1)
        zeroflg = False


    if zeroflg:
        return 0
    dp[x] = res% Mod
    return res


dp = [-1]*(N+100)
dp[0] = 1
dp[1] = 1

print(solve(N) % Mod)


'''
5 1
1
'''

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int, input().split(" ")))


N, M = acinput()
a = [0]*(N+100)
for i in range(M):
    a[int(input())] = 1


Mod = 1000000007


def solve(x):
    global dp, Mod
    if dp[x] >= 0:
        return dp[x]

    if x < 0:
        return 0

    res = 0
    zeroflg = True
    try:
        if  a[x-2] != 1:
            res += solve(x-2) 
            zeroflg = False
    except:
        pass
    try:
        if a[x-1] != 1:
            res += solve(x-1)
            zeroflg = False
    except:
        pass

    if zeroflg:
        return 0
    dp[x] = res% Mod
    return res


dp = [-1]*(N+100)
dp[0] = 1
dp[1] = 1

print(solve(N) % Mod)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int, input().split(" ")))


N, M = acinput()
a = [0]*(N+100)
for i in range(M):
    a[int(input())] = 1


Mod = 1000000007


def solve(x):
    global dp, Mod
    if dp[x] >= 0:
        return dp[x]

    if x < 0:
        return 0

    res = 0
    zeroflg = True
    try:
        if  a[x-2] != 1:
            res += (solve(x-2) % Mod)
            zeroflg = False
    except:
        pass
    try:
        if a[x-1] != 1:
            res += (solve(x-1) % Mod)
            zeroflg = False
    except:
        pass

    if zeroflg:
        return 0
    dp[x] = res
    return res


dp = [-1]*(N+100)
dp[0] = 1
dp[1] = 1

print(solve(N) % Mod)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int, input().split(" ")))


N, M = acinput()
a = [0]*(N+100)
for i in range(M):
    a[int(input())] = 1


Mod = 1000000007


def solve(x):
    global dp, M
    if dp[x] >= 0:
        return dp[x]

    if x < 0:
        return 0

    res = 0
    zeroflg = True
    try:
        if x-2 >= 0 and a[x-2] != 1:
            res += solve(x-2) % Mod
            zeroflg = False
    except:
        pass
    try:
        if x-1 >= 0 and a[x-1] != 1:
            res += solve(x-1) % Mod
            zeroflg = False
    except:
        pass

    if zeroflg:
        return 0
    dp[x] = res
    return res


dp = [-1]*(N+10)
dp[0] = 1
dp[1] = 1

print(solve(N) % Mod)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N,M=acinput()
a=[0]*(N+100)
for i in range(M):
    a[int(input())]=1


Mod=1000000007

def solve(x):
    global dp,M
    if dp[x]>=0:
        return dp[x]

    if x<0:
        return 0

    res=0
    zeroflg=True
    if  x-1>=0 and a[x-1]!=1:
        res+=solve(x-1)%Mod
        zeroflg=False
    if x-2>=0 and a[x-2]!=1:
        res+=solve(x-2)%Mod
        zeroflg=False
    
    if zeroflg:
        return 0
    dp[x]=res
    return res

dp=[-1]*(N+10)
dp[0]=1
dp[1]=1

print(solve(N)%Mod)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N,M=acinput()
a=[0]*(N+100)
for i in range(M):
    a[int(input())]=1


Mod=1000000007

def solve(x):
    global dp,M
    if dp[x]>=0:
        return dp[x]

    if x<0:
        return 0

    res=0
    zeroflg=True
    if  a[x-1]!=1:
        res+=solve(x-1)%Mod
        zeroflg=False
    if a[x-2]!=1:
        res+=solve(x-2)%Mod
        zeroflg=False
    
    if zeroflg:
        return 0
    dp[x]=res
    return res

dp=[-1]*(N+10)
dp[0]=1
dp[1]=1

print(solve(N)%Mod)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N,M=acinput()
a=[0]*(N+1)
for i in range(M):
    a[int(input())]=1


Mod=1000000007

def solve(x):
    global dp,M
    if dp[x]>=0:
        return dp[x]

    if x<0:
        return 0

    res=0
    zeroflg=True
    if  a[x-1]!=1:
        res+=solve(x-1)%Mod
        zeroflg=False
    if a[x-2]!=1:
        res+=solve(x-2)%Mod
        zeroflg=False
    
    if zeroflg:
        return 0
    dp[x]=res
    return res

dp=[-1]*(N+1)
dp[0]=1
dp[1]=1

print(solve(N)%Mod)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N,M=acinput()
a=[0]*(N+1)
for i in range(M):
    a[int(input())]=1


Mod=1000000007

def solve(x):
    global dp,M
    if dp[x]>=0:
        return dp[x]

    res=0
    zeroflg=True
    if  a[x-1]!=1:
        res+=solve(x-1)%Mod
        zeroflg=False
    if a[x-2]!=1:
        res+=solve(x-2)%Mod
        zeroflg=False
    
    if zeroflg:
        return 0
    dp[x]=res
    return res

dp=[-1]*(N+1)
dp[0]=1
dp[1]=1

print(solve(N)%Mod)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N,M=acinput()
a=[0]*(N+1)
for i in range(N):
    a[int(input())]=1


M=1000000007

def solve(x):
    global dp,M
    if dp[x]>=0:
        return dp[x]

    res=0
    zeroflg=True
    if  a[x-1]!=1:
        res+=solve(x-1)%M
        zeroflg=False
    if a[x-2]!=1:
        res+=solve(x-2)%M
        zeroflg=False
    
    if zeroflg:
        return 0
    dp[x]=res
    return res

dp=[-1]*(N+1)
dp[0]=1
dp[1]=1

print(solve(N)%M)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N,M=acinput()
a=[0]*(N+1)
for i in range(M):
    a[int(input())]=1


M=1000000007

def solve(x):
    global dp,M
    if dp[x]>=0:
        return dp[x]

    res=0
    zeroflg=True
    if  a[x-1]!=1:
        res+=solve(x-1)%M
        zeroflg=False
    if a[x-2]!=1:
        res+=solve(x-2)%M
        zeroflg=False
    
    if zeroflg:
        return 0
    dp[x]=res
    return res

dp=[-1]*(N+1)
dp[0]=1
dp[1]=1

print(solve(N)%M)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N,M=acinput()
a=[0]*(N+1)
for i in range(M):
    a[int(input())]=1


M=1000000007

def solve(x):
    global dp,M
    if dp[x]>=0:
        return dp[x]

    res=0
    zeroflg=True
    if  a[x-1]==1:
        res+=solve(x-1)%M
        zeroflg=False
    if a[x-2]==1:
        res+=solve(x-2)%M
        zeroflg=False
    
    if zeroflg:
        return 0
    dp[x]=res
    return res

dp=[-1]*(N+1)
dp[0]=1
dp[1]=1

print(solve(N)%M)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N,M=acinput()
a=[0]*(N+1)
for i in range(M):
    a[int(input())]=1


M=1000000007

def solve(x):
    if dp[x]>=0:
        return dp[x]

    res=0
    zeroflg=True
    if not a[x-1]:
        res+=solve(x-1)%M
        zeroflg=False
    if not a[x-2]:
        res+=solve(x-2)%M
        zeroflg=False
    
    if zeroflg:
        return 0
    dp[x]=res
    return res

dp=[-1]*(N+1)
dp[0]=1
dp[1]=1

print(solve(N)%M)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N,M=acinput()
a=[0]*(N+1)
for i in range(M):
    a[int(input())]=1


M=(1000000007)

def solve(x):
    if x in dp:
        return dp[x]

    res=0
    zeroflg=True
    if not a[x-1]:
        res+=solve(x-1)%M
        zeroflg=False
    if not a[x-2]:
        res+=solve(x-2)%M
        zeroflg=False
    
    if zeroflg:
        return 0
    dp[x]=res
    return res

dp={}
dp[0]=1
dp[1]=1

print(solve(N)%M)

Buggy submission (verdict: Runtime Error):
def acinput():
    return list(map(int,input().split(" ")))


N,M=acinput()
a=[0]*(N+1)
for i in range(M):
    a[int(input())]=1


M=(1000000007)

def solve(x):
    if x in dp:
        return dp[x]

    res=0
    zeroflg=True
    if not a[x-1]:
        res+=solve(x-1)%M
        zeroflg=False
    if not a[x-2]:
        res+=solve(x-2)%M
        zeroflg=False
    
    if zeroflg:
        return 0
    dp[x]=res
    return res

dp={}
dp[0]=1
dp[1]=1
if a[1]:
    a[1]=1

print(solve(N)%M)