Problem p03013 (python)

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

        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:
        # print(f'degrau: {i}')
        # print(f'main loop: i: {i}')
        if i in broken:
            # print('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:
            #     print('entrei')

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

            #         i += 1
            #         print(f'i: {i}')
            #         break
            #     i += 3
            #     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:
            #     i += 1

            # print('broken')
            # x = y
            # # y = x
            # print(f'x: {x}, y: {y}')
            # previous_broken = False
            # while i not in broken and (i + 1) not in broken and (i + 2) not in broken:
            #     i += 1
            # while c < 2:
            #     i += 1
            #     if i in broken:
            #         if previous_broken:
            #             impossible = True
            #         previous_broken = True
            #         continue
            #     else:
            #         previous_broken = False
            #         c += 1
            # i += 2
            # 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)

Buggy submission (verdict: Runtime Error):
def fib(n, broken):
    a = 1
    b = 1
    for i in range(n-2):
        # if i in broken:

        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:
        # print(f'degrau: {i}')
        c = 0
        if i in broken:
            if i + 1 in broken:
                impossible = True
            # print('broken')
            x = y
            # y = x
            # 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
            # i += 2
        else:
            y, x = x + y % 1000000007, y % 1000000007
            # print(f'x: {x}, y: {y}')
        i += 1
    print(0) if impossible else print(y % 1000000007)