Problem:
 Score : 300 points    Problem Statement There is a staircase with N steps. Takahashi is now standing at the foot of the stairs, that is, on the 0 -th step.
He can climb up one or two steps at a time.  However, the treads of the a_1 -th, a_2 -th, a_3 -th, \ldots , a_M -th steps are broken, so it is dangerous to set foot on those steps.  How many are there to climb up to the top step, that is, the N -th step, without setting foot on the broken steps?
Find the count modulo 1\ 000\ 000\ 007 .      Constraints  1 \leq N \leq 10^5  0 \leq M \leq N-1  1 \leq a_1 < a_2 <  ...  < a_M \leq N-1         Input Input is given from Standard Input in the following format:  N  M  a_1  a_2  .  .  .  a_M       Output Print the number of ways to climb up the stairs under the condition, modulo 1\ 000\ 000\ 007 .        Sample Input 1 6 1
3      Sample Output 1 4  There are four ways to climb up the stairs, as follows:   0 \to 1 \to 2 \to 4 \to 5 \to 6  0 \to 1 \to 2 \to 4 \to 6  0 \to 2 \to 4 \to 5 \to 6  0 \to 2 \to 4 \to 6        Sample Input 2 10 2
4
5      Sample Output 2 0  There may be no way to climb up the stairs without setting foot on the broken steps.       Sample Input 3 100 5
1
23
45
67
89      Sample Output 3 608200469  Be sure to print the count modulo 1\ 000\ 000\ 007 .

Solution (Python):
def main(sample_file = ''):

    """ convenient functions
    
    
    
    
    
    """

    """convenient decorator
    
    
        
        
        
        
        
        
        
        
        
        
    """
    
    
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product 
    
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  
        b, e = 2, 0  
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict 
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
    from copy import deepcopy, copy 
    import operator
    from operator import itemgetter 
    
    
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd 
    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)
    def make_divisors(n, reversed=False):
        """create list of divisors
        
        Args:
            number (int): number from which list of divisors is created
            reversed (bool, optional): ascending order if False. Defaults to False.
        
        Returns:
            list: list of divisors
        """
        divisors = set()
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.add(i)
                divisors.add(n//i)
        return sorted(list(divisors),reverse=reversed)
    
    
    
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    modpow = lambda a, n, p = MOD: pow(a, n, p) 
    def modinv(a, p = MOD):
        
        
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        
        
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    class UnionFindTree:
        """union find tree class
        TODO: fix this description...
        how to use (example):
        >>  uf = UnionFindTree(N) 
        >>  if uf.find_root(a) == uf.find_root(b):
        >>      do something
        >>  else:
        >>      do something
        >>      uf.unite(a, b)
        """
        def __init__(self, N):
            self.root = [-1] * (N+1)
            self.rank   = [0]  * (N+1)
            self.connected_num = [1] * (N+1)
    
        def find_root(self,x):
            root = self.root
            while root[x] != -1:
                x = root[x]
            return x
    
        def unite(self,x,y):
            root = self.root
            rank = self.rank
            connected_num = self.connected_num
            find_root = self.find_root
    
            rx = find_root(x)
            ry = find_root(y)
            if rx != ry:
                if rank[rx] < rank[ry]:
                    root[rx] = ry
                    rx,ry = ry,rx
                else:
                    if rank[rx] == rank[ry]:
                        rank[rx] += 1
                    root[ry] = rx       
                connected_num[rx] += connected_num[ry]

    
    
    
    
    

    def BellmanFord(N, M, ABC, vertex_start, vertex_end, value_if_inf = -1, find_shortest = False):
        """to calculate furthest or shortest length between vertex_start and vertex_end using BellmanFord algorithm
        
        Args:
            N (int): number of vertices
            M (int): number of edges
            ABC (list): [(ai, bi, ci) for _ in range(N)] where i-th edge is directed from vertex ai to vertex bi and the length is ci 
            vertex_start (int): start vertex. usually use 0.
            vertex_end (int): end vertex. usually use N-1.
            value_if_inf (int or string as you like, optional): value you want when the furthest (or shortest) distance is infinite (or -infinite). Defaults to -1.
            find_shortest (bool, optional): choose False to find furthest path. Defaults to False.
        
        Returns:
            int or string: normally int (but can be str if you set value_if_inf to str)
            
        Example:
                N, M, P = R()
                ABC = [R() for _ in range(M)]
                ABC = [(a-1, b-1, c-P) for a, b, c in ABC]
                print(BellmanFord(N, M, ABC, 0, N-1, value_if_inf = 'inf'))

        """

        def make_reachable_list(N, M, ABC, vertex_start, vertex_end):
            reachable_to_direct = defaultdict(list)
            reachable_from_direct = defaultdict(list)
            reachable_from_start = [False] * N
            reachable_to_end = [False] * N
            reachable_from_start[vertex_start] = True
            reachable_to_end[vertex_end] = True
            reachable_from_both_sides = [False] * N
            dfs_from_start = []
            dfs_to_end = []
            for a, b, c in ABC:
                reachable_to_direct[a].append(b)
                reachable_from_direct[b].append(a)
                if a == vertex_start:
                    dfs_from_start.append(b)
                    reachable_from_start[b] = True
                if b == vertex_end:
                    dfs_to_end.append(a)
                    reachable_to_end[a] = True
            while dfs_from_start:
                v = dfs_from_start.pop()
                for i in reachable_to_direct[v]:
                    if not reachable_from_start[i]:
                        reachable_from_start[i] = True
                        dfs_from_start.append(i)
            while dfs_to_end:
                v = dfs_to_end.pop()
                for i in reachable_from_direct[v]:
                    if not reachable_to_end[i]:
                        reachable_to_end[i] = True
                        dfs_to_end.append(i)
            for i in range(N):
                reachable_from_both_sides[i] = reachable_from_start[i] and reachable_to_end[i]
            return reachable_from_both_sides
        
        reachable_from_both_sides = make_reachable_list(N, M, ABC, vertex_start, vertex_end)
        
        if find_shortest:
            dist = [INF for i in range(N)]
        else:
            dist = [-INF for i in range(N)]
        
        dist[vertex_start] = 0
        for i in range(N):
            updated = False
            for a, b, c in ABC:
                if not reachable_from_both_sides[a]:
                    continue
                elif find_shortest:
                    update_condition = dist[a] + c < dist[b]
                else:
                    update_condition = dist[a] + c > dist[b]
                if dist[a] != INF and update_condition:
                    dist[b] = dist[a] + c
                    updated = True
                    if i == N-1:
                        return value_if_inf
            if not updated:
                break
        return dist[vertex_end]

    """ initialize variables and set inputs
    
        
        
            
            
    
        
        
        
        
        
        
        
    
        
        
        
        
    
        
        
    """

    
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    R = lambda: list(map(int, r().split()))
    Rmap = lambda: map(int, r().split())
    Rfloat = lambda: list(map(float, r().split()))
    Rtuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    
    
    
    
    
    
    
    """

    
    if sample_file:
        sys.stdin = open(sample_file)
        
    
    

    N, M = R()
    A = [r_int() for _ in range(M)]
    l = [0] * (N+1)
    pre_a = -1
    for a in A:
        l[a] = -1
        if pre_a + 1 == a:
            print(0)
            return
        pre_a = a
    
    for i in range(N+1):
        if i == 0:
            l[i] = 1
        elif i == 1 and l[i] != -1:
            l[i] = 1
        elif l[i] != -1:
            if l[i-2] == -1 or l[i-1] == -1:
                l[i] = l[i-1] + l[i-2] + 1
            else:
                l[i] = (l[i-2] + l[i-1]) % (10**9+7)
    print(l[N])
    
    
    
    

    """memo: how to use defaultdict of list
    
    Dic = defaultdict(list)
    
    Dic[x].append(y)
    
    for k, v in Dic.items():
    """
    
    """memo: how to solve binary problems
    
    >>> a = 5
    >>> bin_str_a = format(a, '
    >>> print(bin_str_a)
    0b0101 
    """
    
    """memo: how to solve the problem
    creating simple test/answer
    greed
    simple dp
    graph
    """

if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())

a=set([int(input()) for _ in range(m)])


p,q=0,1

for i in range(1,n+1):
    
    p,q=q,(p+q)%(10**9+7)*(not i in a) 
print(q)

Solution (Python):
n, m = map(int, input().split())
A = [False for i in range(n+1)]
for i in range(m):
    a = int(input())
    A[a] = True

dp = [0 for i in range(n+1)]
dp[0] = 1

for i in range(1, n+1):
    if A[i]:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[-1])

Solution (Python):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
dp = [-1] * (N+1)
dp[0] = 1
dp[1] = 1

for a in A:
    dp[a] = 0

for i in range(2,N+1):
    if dp[i] == 0:
        pass
    else:
        dp[i] = dp[i-1] + dp[i-2]

print(dp[-1] % (1000000007))

Solution (Python):
N, M = map(int, input().split())
aset = set([int(input()) for _ in range(M)])
MOD = 10**9 + 7
dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if 1 in aset else 1
for i in range(2, N + 1):
    if i not in aset:
        dp[i] = dp[i - 1] + dp[i - 2]
print(dp[-1] % MOD)

Solution (Python):
n, m = map(int, input().split())
a = {int(input()) for _ in range(m)}

mod = 10**9+7
dp = [0]*(n+1)
dp[0]=1

if not 1 in a:
  dp[1]=1

for i in range(2, n+1):
  if i in a:
    continue
  else:
    dp[i] = dp[i-1]+dp[i-2]

print(dp[n]%mod)

Solution (Python):
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

dp = [-1]*(n+1)
dp[0] = 1
dp[1] = 1
for i in a:
    dp[i] = 0

for i in range(2, n+1):
    if dp[i] == 0:
        pass
    else:
        dp[i] = dp[i-1] + dp[i-2]
    
print(dp[n]%(10**9+7))

Solution (Python):
import math

def fib(n):
  if n==1:
    return 1
  elif n<=0:
    return 0
  tmp1,tmp2=1,2
  for _ in range(n-2):
    tmp1,tmp2=tmp2,tmp1+tmp2
  return tmp2

n,m=map(int,input().split())
if m==0:
  print(fib(n)%1000000007)
  exit()
a=[int(input()) for _ in range(m)]
ans=1

if n==2 and a[0]==1:
  print(1)
  exit()

for i in range(m):
  if i==0 and a[0]==1:
    pass
  if i==0 and a[0]!=1:
    ans*=fib(a[i]-1)
  elif i>0 and a[i]-a[i-1]==2:
    pass
  elif i>0 and a[i]-a[i-1]!=2:
  	ans*=fib(a[i]-a[i-1]-2)
  ans%=1000000007
  
if n-a[-1]>1: 
  ans*=fib(n-a[-1]-1)
ans%=1000000007
print(ans)

Solution (Python):
n,m=map(int,input().split())
a={int(input()) for _ in range(m)}
mod=10**9+7

dp=[0]*(n+1)
dp[0]=1
if 1 not in a:
   dp[1]=1

for i in range(2,n+1):
      if i in a:
            continue
      else:
            dp[i]=dp[i-2]+dp[i-1]
print(dp[-1]%mod)

Solution (Python):
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
dp=[0]*(n+1)
dp[0]=1
dp[1]=1
if 1 in a:
    dp[1]=0
a=set(a)
for i in range(2,n+1):
    if i in a:
        continue
    dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%(10**9+7))

Solution (Python):
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
dp=[0]*(n+1)
dp[0]=1
dp[1]=1
if 1 in a:
    dp[1]=0
a=set(a)
for i in range(2,n+1):
    if i in a:
        continue
    dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%(10**9+7))

Solution (Python):
def main():
    INF = 10 ** 9 + 7
    N, M, *a = map(int, open(0).read().split())
    a = set(a)
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in a else 0
    for i in range(2, N + 1):
        if i not in a:
            dp[i] = (dp[i - 1] + dp[i - 2]) % INF
    print(dp[-1])
    return


main()

Solution (Python):
def main():
    INF = int(1e9+7)
    N, M, *a = map(int, open(0).read().split())
    a = set(a)
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in a else 0
    for i in range(2, N + 1):
        if i not in a:
            dp[i] = (dp[i - 1] + dp[i - 2]) % INF
    print(dp[-1])
    return


main()

Solution (Python):
INF = int(1e9+7)


def main():
    N, M, *a = map(int, open(0).read().split())
    a = set(a)
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in a else 0
    for i in range(2, N + 1):
        if i not in a:
            dp[i] = (dp[i - 1] + dp[i - 2]) % INF
    print(dp[-1])
    return


main()

Solution (Python):
INF = int(1e9+7)


def modadd(a, b):
    
    return (a + b) % INF


def main():
    N, M, *a = map(int, open(0).read().split())
    a = set(a)
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in a else 0
    for i in range(2, N + 1):
        if i not in a:
            dp[i] = modadd(dp[i - 1], dp[i - 2])
    print(dp[N])
    return


main()

Solution (Python):
from sys import stdin
INF = int(1e9+7)
readlines = stdin.readlines


def modadd(a, b):
    
    return (a + b) % INF


def main():
    lines = readlines()
    N = int(lines[0].split()[0])
    a = set(map(int, lines[1:]))
    dp = [0] * (N + 1)
    dp[:2] = 1, 1 if 1 not in a else 0
    for i in range(2, N + 1):
        if i not in a:
            dp[i] = modadd(dp[i - 1], dp[i - 2])
    print(dp[N])
    return


main()

Solution (Python):
import sys

n, m = map(int, sys.stdin.readline().split())
A = [int(sys.stdin.readline()) for _ in range(m)]
bloken = [0 for i in range(n+1)]
for a in A:
    bloken[a]=1
    

dp = [0 for i in range(n+1)]
dp[0] =1


for i in range(1, n+1):
    if bloken[i]==1:
        continue
    if i-2>=0:
        dp[i] = dp[i-1] + dp[i-2]
    else:
        dp[i] = dp[i-1]


print(dp[-1]%1000000007)

Solution (Python):
n,m = map(int,input().split())
mat = [0 for i in range(n+1)]

for i in range(m):
    mat[int(input())] = -1

for i in range(n):
    if i == 0:
        mat[i] = 1
    if mat[i] == -1:
        continue
    if i + 1 < n+1:
        if mat[i+1] != -1:
            mat[i+1] += mat[i]
    if i + 2 < n+1:
        if mat[i+2] != -1:
            mat[i+2] += mat[i]
if mat[-1] >= 0:
    print(mat[-1]%1000000007)
else:
    print(0)

Solution (Python):
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
ans=[10*9]*n
ans[0]=1
for i in range(m):
    ans[a[i]-1]=0
if len(ans)>1 and ans[1]!=0:
    ans[1]=ans[0]+1
for j in range(n-2):
    if ans[j+2]==0:
        continue
    else:
        ans[j+2]=ans[j+1]+ans[j]
        ans[j+2]=ans[j+2]%(1000000007)
    
print(ans[n-1])

Solution (Python):
mod = 10**9+7
N, M = map(int, input().split())
a = set(int(input()) for _ in range(M))

dp = [0] * (N + 1)
dp[:2] = 1, 1 if 1 not in a else 0

for i in range(2, N+1):
    
    if not i in a:
        dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[-1])

Solution (Python):
N,M =map(int,input().split())
a = [int(input()) for i in range(M)]
DP = [1]*N
mod = 10**9 + 7
for i in a:
    DP[i-1] = 0
if(N != 1):
    for i in range(N):
        if(DP[i] != 0):
            if(i<1):
                DP[i] = DP[i-1]%mod
            else:
                DP[i] = (DP[i-2] + DP[i-1])%mod
else:
    DP = [1]
print(DP[-1])

Solution (Python):
N, M = map(int,input().split())
dp = [0]*(N+1)
broke = [0]*(N+1)
dp[0] = 1
dp[1] = 1

for _ in range(M):
    a = int(input())
    broke[a] = -1

for i in range(N-1):
    if broke[i] != -1 and broke[i+1] != -1:
        dp[i+2] = dp[i+1] + dp[i]
    elif broke[i] == -1and broke[i+1] != -1:
        dp[i+2] = dp[i+1]
    elif broke[i+1] == -1and broke[i] != -1:
        dp[i+2] = dp[i]
    else:
        print(0)
        exit()


MOD = 10**9+7
print(dp[N]%MOD)

Solution (Python):
n,m=map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()))
dp=[None]*(n+1)
dp[0]=1
dp[1]=1
if 1 in a:
    dp[1]=0
for i in a:
    dp[i]=0
for i in range(2,n+1):
    if dp[i]!=0 :
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%(10**9+7))

Solution (Python):
import sys

n, m = map(int, input().split(' '))
a = [True] * (n+1)

for i in range(m):
  num = int(input())
  a[num] = False

dp = [0] * (n+1)
dp[0] = 1
for i in range(n+1):
  
  if (i+1) <= (n):
    if a[i+1]:
      dp[i+1] = dp[i] + dp[i+1]
      dp[i+1] = dp[i+1] % (10**9 + 7)
  if (i+2) <= (n):
    if a[i+2]:
      dp[i+2] = dp[i] + dp[i+2]
      dp[i+2] = dp[i+2] % (10**9 + 7)
  


print(dp[n])

Solution (Python):
N,M = map(int,input().split())
A = set([int(input()) for _ in range(M)])
dp = [0]*(N+1)
dp[0] = 1
for i in range(1,N+1):
    dp[i] = (dp[i-1] + dp[i-2])%(1000000007)
    if i in A:dp[i] = 0
    
print(dp[N])

Solution (Python):
n, m = (int(i) for i in input().split()) 
a = [int(input()) for i in range(m)] 
is_broken = [1] * n
dp = [0] * (n + 1)
dp[0] = 1
mod = 1000000007
for i in a:
  is_broken[i] = 0

for i in range(n):
  if i >= 1:
    dp[i+1] = dp[i] * is_broken[i] + dp[i-1] * is_broken[i-1]
  else:
    dp[i+1] = dp[i] * is_broken[i]
print(dp[n]%mod)

Solution (Python):
fib=[0,0,1,2]
for i in range(4,100005):
  fib.append(fib[i-1]+fib[i-2])

n,m=map(int,input().split())
a=[int(input()) for i in range(m)]

a=set(a)

p,q=0,1

for i in range(1,n+1):
  p,q=q,(p+q)%(10**9+7)*(not i in a)

print(q)

Solution (Python):
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
A = set([int(input()) for _ in range(M)])
s = 1
s_ = 0
for n in range(1, N+1):
  if n in A:
    s, s_ = 0, s
    continue
  s, s_ = s + s_, s
print(s % (10 ** 9 + 7))

Solution (Python):
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
A = set([int(input()) for _ in range(M)])
s = [0 for _ in range(N + 1)]
s[0] = 1
if 1 not in A:
  s[1] = 1

for n in range(2, N+1):
  if n in A:
    continue
  else:
    s[n] = s[n-1] + s[n-2]
print(s[-1] % (10 ** 9 + 7))

Solution (Python):
n,m=map(int,input().split())
a={int(input()) for i in range(m)}

dp=[0]*(n+1)
dp[0]=1
if 1 in a:
      dp[1]=0
else:
      dp[1]=1

for i in range(2,len(dp)):
      if i in a:
            continue
      dp[i]=(dp[i-2]+dp[i-1])
      
print(dp[-1]%(10**9+7))

Solution (Python):
import sys 
sys.setrecursionlimit(10**6)

n, m = map(int, input().split())
a = [int(input()) - 1 for _ in range(m)]
a.append(n)

dp = [-1] * max(3, n + 1)
dp[0] = 1
dp[1] = 1
dp[2] = 2
def stepsum(n):
    if dp[n] != -1:
        return dp[n]
    dp[n] = stepsum(n-1) + stepsum(n-2)
    return dp[n]
prev = 0
ans = 1
for ai in a:
    if prev != 0 and ai - prev < 0:
        ans = 0
        break
    ans *= stepsum(ai - prev)
    prev = ai + 2

print(ans % ( 10 ** 9 + 7 ))

Solution (Python):
n,m=map(int,input().split())
a={int(input()) for i in range(m)}
mod=10**9+7

x=1 if 1 not in a else 0
dp=[1,x]+[0]*(n-1)

for i in range(2,n+1):
    if i in a:
        continue
    dp[i]=(dp[i-1]+dp[i-2])
print(dp[-1]%mod)

Solution (Python):
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]
ans = [1] * (n + 1)
for i in a:
    ans[i] = 0
for i in range(2, n + 1):
    if ans[i]:
        ans[i] = ans[i - 1] + ans[i - 2]
    if ans[i] >= 1000000007:
        ans[i] = ans[i] % 1000000007
print(ans[-1])

Solution (Python):
n,m=map(int,input().split())
a=set([int(input()) for i in range(m)])
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
    if i in a:
      dp[i]=0
print(dp[n])

Solution (Python):
N,M = map(int, input().split())
a_list = [int(input()) for _ in range(M)]

tmp =  [1]*(N+1)
for a in a_list:
    tmp[a] = 0
for i in range(2,N+1):
    if tmp[i]:
        tmp[i] = tmp[i-1]+tmp[i-2]
    if tmp[i]> 1000000007:
        tmp[i] = tmp[i] % 1000000007
print(tmp[-1] % 1000000007)

Solution (Python):
import math
import fractions
mod=1000000007
(n,m)=map(int,input().split())
a=[0]*(n+2)
b=[0]*(n+2)
for i in range(m):
    t=int(input())
    a[t]=1
b[0]=1
for i in range(n+1):
    if(a[i]==1):
        b[i]=0
        continue
    if(i==0):
        continue
    if(i==1):
        b[i]=b[i-1]
        continue
    b[i]=(b[i-1]+b[i-2])%mod

print(b[n]%mod)

Solution (Python):
n,m=map(int,input().split())
a=0
cnt=1
p,q,r=1,0,0

for i in range(m):
  a=int(input())
  while cnt<n and cnt<a:
      s,r,q=r,q,p
      p=(q+r)%(10**9+7)
      cnt+=1
      
  if a==cnt:
    s,r,q=r,q,p
    p=0
    cnt+=1
    
    
while cnt<=n:
    s,r,q=r,q,p
    p=(q+r)%(10**9+7)
    cnt+=1
    
print(p%(10**9+7))

Solution (Python):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
MOD = 10**9+7

is_safe = [True]*(N+1)
for a in A:
    is_safe[a] = False

dp = [0]*(N+1)

dp[0] = 1
if is_safe[1]:
    dp[1] = 1

for i in range(2, N+1):
    if is_safe[i-1]:
        dp[i] += dp[i-1]
    if is_safe[i-2]:
        dp[i] += dp[i-2]
    dp[i] %= MOD

print(dp[N])

Solution (Python):

n,m = map(int,input().split())
a=[]
for i in range(m):
    a.append(int(input()) )
from collections import deque
a=deque(a)
mod=10**9 + 7

dp=[0]*(n+2)
dp[0]=0
dp[1]=1
aa=0
if len(a)>0:
    aa=a.popleft()
for i in range(2,n+2):
    if i-1 == aa:
        dp[i]=0
        if len(a)>0:
            aa=a.popleft()
    else:
        dp[i]=( dp[i-1]+dp[i-2] )%mod
print(dp[-1])

Solution (Python):
n, m = map(int, input().split())
count = [[0, False] for _ in range(n+2)]
for _ in range(m):
    a = int(input())
    count[a][1] = True
count[n][0] = 1

for i in range(n)[::-1]:
    if count[i][1] and count[i+1][1]:
        print(0)
        exit(0)
    if count[i][1]:
        continue
    count[i][0] = (count[i+1][0] + count[i+2][0])
print(count[0][0] % 1000000007)

Solution (Python):

N, M = map(int, input().split())
broken = set([int(input()) for _ in range(M)])

MOD = 10**9+7
dp = [0 for i in range(N+2)]
dp[N] = 1

for i in reversed(range(N)):
    if i in broken:
        continue
    dp[i] = dp[i+1] + dp[i+2]
    dp[i] %= MOD

print(dp[0])

Solution (Python):
n, m = map(int, (input().split()))
a = {int(input()) for i in range(m)}
mod = 10 ** 9 + 7
 
x = 1 if 1 not in a else 0
dp = [1, x] + [0] * (n - 1)
 
for i in range(2, n + 1):
    if i in a:
        continue
    dp[i] = (dp[i - 1] + dp[i - 2])
 
print(dp[-1] % mod)

Solution (Python):
n,m  = map(int, input().split())
A = set(int(input()) for _ in range(m))
mod = 10**9+7

if 1 in A:
  dp_l = [1, 0] + [0]*(n-1)
else:
  dp_l = [1, 1] + [0]*(n-1)

if n==1:
  print(1)
else:
  for i in range(1, len(dp_l)):
    if i in A:
      dp_l[i] = 0
    else:
      dp_l[i] = (dp_l[i-1]+dp_l[i-2])%mod 
  print(dp_l.pop())

Solution (Python):
import sys

n,m=map(int,input().split())
broken=set(map(int,sys.stdin))

if n==1:
  print (1)
  sys.exit()
if n==2:
  if 1 not in broken and 2 not in broken:
    print (2)
  elif 2 in broken:
    print(0)
  elif 1 in broken and 2 not in broken:
    print(1)
  sys.exit()

way = [0]*n
if 1 not in broken:
  way[0]=1
if 1 not in broken and 2 not in broken:
  way[1]=2
elif 1 in broken and 2 not in broken:
  way[1]=1
for i in range(2,n):
  if i+1 in broken:
    way[i]=0
    continue
  way[i]=(way[i-1]+way[i-2])%1000000007
print(way[n-1])

Solution (Python):
N,M = map(int,input().split())
mod=10**9+7
A = {int(input()) for i in range(M)}

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    N,M = list(map(int,input().split()))
    a = []
    A = [0] * (1 + 10 ** 5)
    for _ in range(M):
        A[int(input())] = 1
    dp = [0] * (N + 1)
    dp[0] = 1
    if A[1]:
        dp[1] = 0
    else:
        dp[1] = 1
    for i in range(2,N + 1):
        if A[i]:
            dp[i] = 0
        else:
            dp[i] = dp[i-1] + dp[i-2]
            dp[i] %= 1000000007
    print(dp[N])
if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 1

[n,m] = inpl()
fibsec = [0]*(n+2)
fibsec[0] = 1
fibsec[1] = 1
fibsec[-1] = 0
for i in range(2,n+1):
    fibsec[i] = fibsec[i-1]+fibsec[i-2]

firsta = -1
for k in range(m):
    seconda = inp()
    ans = ans*(fibsec[seconda-firsta -2 ])%mod
    firsta = seconda

ans = ans*(fibsec[n-firsta-1])%mod
    

print(ans)

Solution (Python):
INF = float("inf") 

def main():
    n,m = map(int,input().split())
    issafe = [True]*n
    for i in range(m):
        a = int(input())
        issafe[a] = False
    dp = [0]*(n+1)
    dp[0],dp[1] = 1,1

    for i in range(2,n+1):
        if issafe[i-1]:
            dp[i] += dp[i-1]
        if issafe[i-2]:
            dp[i] += dp[i-2]

    print(dp[n]%(10**9+7))


if __name__ == "__main__":
    main()

Solution (Python):
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline

N, M = map(int, input().split())
n = [True for _ in range(N+1)]
for _ in range(M):
	n[int(input())] = False

dp = [0 for _ in range(N+1)]
dp[0] = 1

for i in range(N+1):
	if not n[i]:
		continue
	for j in [1, 2]:
		if i - j >= 0:
			dp[i] += dp[i-j]
print(dp[-1]%1000000007)

Solution (Python):
MOD = 1000000007

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

for i in range(M):
    a = int(input())
    dp[a] = -1
    
for i in range(N):
    if dp[i] == -1: continue

    dp[i] %= MOD
    
    if i+1 < N and dp[i+1] != -1: dp[i+1] += dp[i]
    if i+2 < N and dp[i+2] != -1: dp[i+2] += dp[i]

print(dp[-1] % MOD)