Buggy python submission (verdict: Time Limit Exceeded):

import sys
input = sys.stdin.readline
def isSafe(position):
    return not position in listM


STEP = 2
N,M = map(int,input().split())
dp = [0] * (N+1)
cnt = 0


listM=[int(input()) for i in range(M)]
dp[0] = 1

for i in range(N):
    if i+1 > N:
        break
    if isSafe(i+1):
        dp[i+1] += dp[i]
    if i+2 > N:
        break
    if isSafe(i+2):
        dp[i+2] += dp[i]
        #dp[j] = 0
    #print(dp)
        
print(dp[N] % 1000000007)

Fixed submission:

import sys
input = sys.stdin.readline
def isSafe(position):
    return not position in listM
 
 
STEP = 2
N,M = map(int,input().split())
dp = [0] * (N+1)
cnt = 0
 
 
listM={int(input()) for i in range(M)}
dp[0] = 1
 
for i in range(N):
    if i+1 > N:
        break
    if isSafe(i+1):
        dp[i+1] += dp[i]
    if i+2 > N:
        break
    if isSafe(i+2):
        dp[i+2] += dp[i]
        #dp[j] = 0
    #print(dp)
        
print(dp[N] % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):

import sys
input = sys.stdin.readline
def isSafe(position):
    return not position in listM


STEP = 2
N,M = map(int,input().split())
dp = [0] * (N+1)
cnt = 0


listM=[int(input()) for i in range(M)]
dp[0] = 1

for i in range(N):
    if i+1 > N:
        break
    if isSafe(i+1):
        dp[i+1] += dp[i]
    if i+2 > N:
        break
    if isSafe(i+2):
        dp[i+2] += dp[i]
        #dp[j] = 0
    #print(dp)
        
print(dp[N] % 1000000007)

Fixed submission:

import sys
input = sys.stdin.readline
def isSafe(position):
    return not position in listM
 
 
STEP = 2
N,M = map(int,input().split())
dp = [0] * (N+1)
cnt = 0
 
 
listM={int(input()) for i in range(M)}
dp[0] = 1
 
for i in range(N):
    if i+1 > N:
        break
    if isSafe(i+1):
        dp[i+1] += dp[i]
    if i+2 > N:
        break
    if isSafe(i+2):
        dp[i+2] += dp[i]
        #dp[j] = 0
    #print(dp)
        
print(dp[N] % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):

import sys
input = sys.stdin.readline
def isSafe(position):
    return not position in listM


STEP = 2
N,M = map(int,input().split())
dp = [0] * (N+1)
cnt = 0


listM=[int(input()) for i in range(M)]
dp[0] = 1

for i in range(N):
    for k in range(1, STEP+1):
        if i+k > N:
            break
        if isSafe(i+k):
            dp[i+k] += dp[i]
            
        #dp[j] = 0
    #print(dp)
        
print(dp[N] % 1000000007)

Fixed submission:

import sys
input = sys.stdin.readline
def isSafe(position):
    return not position in listM
 
 
STEP = 2
N,M = map(int,input().split())
dp = [0] * (N+1)
cnt = 0
 
 
listM={int(input()) for i in range(M)}
dp[0] = 1
 
for i in range(N):
    if i+1 > N:
        break
    if isSafe(i+1):
        dp[i+1] += dp[i]
    if i+2 > N:
        break
    if isSafe(i+2):
        dp[i+2] += dp[i]
        #dp[j] = 0
    #print(dp)
        
print(dp[N] % 1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
def isSafe(position):
    return not position in listM


STEP =2
N,M= map(int,input().split())
dp = [0] * (N+1)
cnt = 0


listM=[]
for i in range(M):
    listM.append(int(input()))

dp[0] = 1

for i in range(N):
    for k in range(1, STEP+1):
        if i+k > N:
            break
        if isSafe(i+k):
            dp[i+k] += dp[i]
            
        #dp[j] = 0
    #print(dp)
        
print(dp[N] % 1000000007)

Fixed submission:

import sys
input = sys.stdin.readline
def isSafe(position):
    return not position in listM
 
 
STEP = 2
N,M = map(int,input().split())
dp = [0] * (N+1)
cnt = 0
 
 
listM={int(input()) for i in range(M)}
dp[0] = 1
 
for i in range(N):
    if i+1 > N:
        break
    if isSafe(i+1):
        dp[i+1] += dp[i]
    if i+2 > N:
        break
    if isSafe(i+2):
        dp[i+2] += dp[i]
        #dp[j] = 0
    #print(dp)
        
print(dp[N] % 1000000007)