Buggy python submission (verdict: Time Limit Exceeded):
import sys

mod = 10 ** 9 + 7
n, m, *a = [int(x) for x in sys.stdin.read().split()]

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

print(dp[-1])

Fixed submission:
import sys

mod = 10 ** 9 + 7
n, m, *a = [int(x) for x in sys.stdin.read().split()]

safe = sorted(set(range(1,n+1)) - set(a))
dp = [0] * (n + 2)
dp[0] = 0
dp[1] = 1
for i in safe:
    dp[i+1] = (dp[i] + dp[i-1]) % mod

print(dp[-1])

Buggy python submission (verdict: Runtime Error):
# 2019-11-14 10:01:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

mod = 10 ** 9 + 7
def main():
    n, m, *broken_treads = [int(x) for x in sys.stdin.read().split()]
    safe = sorted((set(range(1, n+1)) - set(broken_treads)))

    p = [0] * (n + 1) # p[i] は連続するi段の、1~i段目までの登り方の総パターン
    p[1] = 1
    for i in range(2, n+1):
        p[i] = p[i-1] + p[i-2]

    count = 1 # 最初に0th stepを踏んでいるので1
    sections = []
    for i in range(1, n+1):
        if i in safe:
            count += 1
        else:
            if count >= 1:
                sections.append(p[count])
                count = 0
            else: # countが0だったら一つ前も壊れている
                print(0)
                sys.exit()
    
    if count >= 1:    # if the last is not broken.
        sections.append(p[count])

    ans = reduce(lambda x, y: x * y % mod, sections)
    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
import sys

mod = 10 ** 9 + 7
n, m, *a = [int(x) for x in sys.stdin.read().split()]

safe = sorted(set(range(1,n+1)) - set(a))
dp = [0] * (n + 2)
dp[0] = 0
dp[1] = 1
for i in safe:
    dp[i+1] = (dp[i] + dp[i-1]) % mod

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
# 2019-11-14 10:01:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

mod = 10 ** 9 + 7
def main():
    n, m, *broken_treads = [int(x) for x in sys.stdin.read().split()]
    safe = sorted((set(range(1, n+1)) - set(broken_treads)))

    p = [0, 1] # p[i] は連続するi段の、1~i段目までの登り方の総パターン
    for _ in range(n):
        p.append(p[-1] + p[-2])

    count = 1 # 最初に0th stepを踏んでいるので1
    sections = []
    for i in range(1, n+1):
        if i in safe:
            count += 1
        else:
            if count >= 1:
                sections.append(p[count])
                count = 0
            else: # countが0だったら一つ前も壊れている
                print(0)
                sys.exit()
    
    if count >= 1:    # if the last is not broken.
        sections.append(p[count])

    ans = reduce(lambda x, y: x * y % mod, sections)
    print(ans)

if __name__ == "__main__":
    main()


Fixed submission:
import sys

mod = 10 ** 9 + 7
n, m, *a = [int(x) for x in sys.stdin.read().split()]

safe = sorted(set(range(1,n+1)) - set(a))
dp = [0] * (n + 2)
dp[0] = 0
dp[1] = 1
for i in safe:
    dp[i+1] = (dp[i] + dp[i-1]) % mod

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
# 2019-11-14 10:01:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

mod = 10 ** 9 + 7
def main():
    n, m, *broken_treads = [int(x) for x in sys.stdin.read().split()]
    safe = sorted((set(range(1, n+1)) - set(broken_treads)))

    pattern_for_each_section = []
    ans = 1
    p = [0, 1]
    continuous_broken_count = 0
    for i in range(1, n+1):
        if i in safe:
            continuous_broken_count = 0
            p.append(p[-1] + p[-2])
        else:
            continuous_broken_count += 1
            if continuous_broken_count == 1:
                pattern_for_each_section.append(p[-1])
                p = [1, 0]
            else:
                print(0)
                sys.exit()
    
    if continuous_broken_count == 0:
        pattern_for_each_section.append(p[-1])
    

    for c in pattern_for_each_section:
        ans = ans * c % mod
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys

mod = 10 ** 9 + 7
n, m, *a = [int(x) for x in sys.stdin.read().split()]

safe = sorted(set(range(1,n+1)) - set(a))
dp = [0] * (n + 2)
dp[0] = 0
dp[1] = 1
for i in safe:
    dp[i+1] = (dp[i] + dp[i-1]) % mod

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
# 2019-11-14 10:01:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

mod = 10 ** 9 + 7
def main():
    n, m, *broken_treads = [int(x) for x in sys.stdin.read().split()]
    safe = sorted((set(range(1, n+1)) - set(broken_treads)))

    ans = 1
    p_pre_pre = 0
    p_pre = 1 # 0th step
    count = 0
    continuous_broken_count = 0
    for i in range(1, n+1):
        if i in safe:
            continuous_broken_count = 0
            count += 1
            if count % 2 == 1:
                p_pre_pre = p_pre + p_pre_pre
            else:
                p_pre = p_pre_pre + p_pre
        elif count != 0:
            continuous_broken_count = 1
            if count % 2 == 1:
                ans = ans * p_pre_pre % mod
            else:
                ans = ans * p_pre % mod
            p_pre_pre = 1
            p_pre = 0
            count = 0
        else:
            continuous_broken_count += 1
            if continuous_broken_count == 2:
                print(0)
                sys.exit()
            p_pre_pre = 1    
            p_pre = 0

    if count != 0:      # if n-th tread is not broken.
        if count % 2 == 1:
            ans = ans * p_pre_pre % mod
        else:
            ans = ans * p_pre % mod

    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys

mod = 10 ** 9 + 7
n, m, *a = [int(x) for x in sys.stdin.read().split()]

safe = sorted(set(range(1,n+1)) - set(a))
dp = [0] * (n + 2)
dp[0] = 0
dp[1] = 1
for i in safe:
    dp[i+1] = (dp[i] + dp[i-1]) % mod

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
# 2019-11-14 10:01:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

mod = 10 ** 9 + 7
def main():
    n, m, *broken_treads = [int(x) for x in sys.stdin.read().split()]
    safe = sorted((set(range(1, n+1)) - set(broken_treads)))

    case = []
    p_pre_pre = 0
    p_pre = 1 # 0th step
    count = 0
    continuous_broken_count = 0
    for i in range(1, n+1):
        if i in safe:
            continuous_broken_count = 0
            count += 1
            if count % 2 == 1:
                p_pre_pre = p_pre + p_pre_pre
            else:
                p_pre = p_pre_pre + p_pre
        elif count != 0:
            continuous_broken_count = 1
            if count % 2 == 1:
                case.append(p_pre_pre)
            else:
                case.append(p_pre)
            p_pre_pre = 1
            p_pre = 0
            count = 0
        else:
            continuous_broken_count += 1
            if continuous_broken_count == 2:
                print(0)
                sys.exit()
            p_pre_pre = 1
            p_pre = 0

    if count != 0:      # if n-th tread is not broken.
        if count % 2 == 1:
            case.append(p_pre_pre)
        else:
            case.append(p_pre)

    ans = 1
    for c in case:
        ans = (ans * c) % mod
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys

mod = 10 ** 9 + 7
n, m, *a = [int(x) for x in sys.stdin.read().split()]

safe = sorted(set(range(1,n+1)) - set(a))
dp = [0] * (n + 2)
dp[0] = 0
dp[1] = 1
for i in safe:
    dp[i+1] = (dp[i] + dp[i-1]) % mod

print(dp[-1])