Problem: 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.

Submission attempts (in order):
def fib(n, broken):
    a = 1
    b = 1
    for i in range(n-2):
        

        a, b = b, a + b
    print(b)


t = int(input())
for _ in range(t):
    n, m = [int(x) for x in input().split()]
    broken = set()
    for _ in range(m):
        broken.add(int(input()))

    x = 0
    y = 1
    i = 1
    impossible = False
    while i <= n:
        
        c = 0
        if i in broken:
            if i + 1 in broken:
                impossible = True
            
            x = y
            
            # print(f'x: {x}, y: {y}')
            previous_broken = False
            while c < 2:
                i += 1
                if i in broken:
                    if previous_broken:
                        impossible = True
                    previous_broken = True
                    continue
                else:
                    previous_broken = False
                    c += 1
            
        else:
            y, x = x + y % 1000000007, y % 1000000007
            # print(f'x: {x}, y: {y}')
        i += 1
    print(0) if impossible else print(y % 1000000007)


def fib(n, broken):
    a = 1
    b = 1
    for i in range(n-2):
        

        a, b = b, a + b
    print(b)


# t = int(input())
t = 1

for _ in range(t):
    n, m = [int(x) for x in input().split()]
    broken = set()
    for _ in range(m):
        broken.add(int(input()))

    x = 0
    y = 1
    i = 1
    impossible = False
    c = 0
    while i <= n:
        
        if i in broken:
            x = y
            if i + 1 in broken:
                impossible = True
                break
            while not (i + 1 not in broken and i + 2 not in broken and i + 3 not in broken):
                c = 0
                for x in range(i + 1, i + 4):
                    if x in broken:
                        c += 1
                if c >= 2:
                    impossible = True

                # print(f'i: {i}')
                i += 3
            # if i + 1 not in broken and i + 2 not in broken and i + 3 not in broken:
            

            
            # x = y
            
            # print(f'x: {x}, y: {y}')
            
            # while i not in broken and (i + 1) not in broken and (i + 2) not in broken:
            
            # while c < 2:
            
            
            
            #             impossible = True
            
            #         continue
            #     else:
            
            #         c += 1
            
            # c = 0
        else:
            y, x = (x + y) % 1000000007, y % 1000000007
            # print(f'x: {x}, y: {y}')
            c = 0
        i += 1
        # print(y)
    print(0) if impossible else print(y % 1000000007)


def fib(n, broken):
    a = 1
    b = 1
    for i in range(n-2):
        

        a, b = b, a + b
    print(b)


# t = int(input())
t = 1

for _ in range(t):
    n, m = [int(x) for x in input().split()]
    broken = set()
    for _ in range(m):
        broken.add(int(input()))

    x = 0
    y = 1
    i = 1
    impossible = False
    c = 0
    while i <= n:
        
        
        if i in broken:
            
            x = y
            if i + 1 in broken:
                impossible = True
                break
            while not ((i + 1) not in broken and (i + 2) not in broken and (i + 3) not in broken):

                if i + 1 in broken and i + 2 in broken:
                    impossible = True
                if i + 2 in broken and i + 3 in broken:
                    impossible = True

                i += 1
            i += 2
            # while True:
            

            #     if not ((i + 1) not in broken and (i + 2) not in broken and (i + 3) not in broken):
            #         print('aqui')

            
            #         print(f'i: {i}')
            #         break
            
            #     break

            #     c = 0
            #     for x in range(i + 1, i + 4):
            #         if x in broken:
            #             c += 1
            #     if c >= 2:
            #         impossible = True

            #     print(f'i: {i}')
            # if i + 1 not in broken and i + 2 not in broken and i + 3 not in broken:
            

            
            # x = y
            
            # print(f'x: {x}, y: {y}')
            
            # while i not in broken and (i + 1) not in broken and (i + 2) not in broken:
            
            # while c < 2:
            
            
            
            #             impossible = True
            
            #         continue
            #     else:
            
            #         c += 1
            
            # c = 0
        else:
            y, x = (x + y) % 1000000007, y % 1000000007
            # print(f'x: {x}, y: {y}')
            c = 0
        i += 1
        # print(y)
    print(0) if impossible else print(y % 1000000007)


Verdicts: Runtime Error

Wrong Answer

Accepted