Problem p03013 (python)

Fixed submission:
import copy
n,m = map(int,input().split())
a00 = 0
a0 = 1
if m > 0:
    ann = 0
    for i in range(m):
        an = int(input())
        if an != ann:
            for x in range(an-ann-1):
                ak = copy.copy(a00 + a0)
                a00 = copy.copy(a0)
                a0 = copy.copy(ak)
            ann = copy.copy(an)
            a00 = copy.copy(a0)
            a0 = 0
        else:
            ann = copy.copy(an)
    for j in range(n-an):
        ak = copy.copy(a00+a0)
        a00 = copy.copy(a0)
        a0 = copy.copy(ak)
else:
    for i in range(n):
        ak = copy.copy(a00 + a0)
        a00 = copy.copy(a0)
        a0 = copy.copy(ak)
print(a0 % 1000000007)

Buggy submission (verdict: Runtime Error):
import copy
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
if n == 1:
    if m == 1:
        print(0)
    else:
        print(1)
else:
    if 1 == a[0]:
        if 2 in a:
            a1 = 0
            a2 = 0
        else:
            a1 = 0
            a2 = 1
    else:
        if 2 in a:
            a1 = 1
            a2 = 0
        else:
            a1 = 1
            a2 = 2
    if n == 2:
        print(a2)
    else:
        for i in range(3,n+1):
            if i in a:
                a1 = copy.copy(a2)
                a2 = 0
            else:
                an = a1 + a2
                a1 = copy.copy(a2)
                a2 = copy.copy(an)
        print(a2 % 1000000007)

Buggy submission (verdict: Runtime Error):
import copy
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
if n == 1:
    if m == 1:
        print(0)
    else:
        print(1)
else:
    if 1 == a[0]:
        if 2 in a:
            a1 = 0
            a2 = 0
        else:
            a1 = 0
            a2 = 1
    else:
        if 2 in a:
            a1 = 1
            a2 = 0
        else:
            a1 = 1
            a2 = 2
    if n == 2:
        print(a2)
    else:
        for i in range(3,n+1):
            if i in a:
                a1 = copy.copy(a2)
                a2 = 0
            else:
                an = a1 + a2
                a1 = copy.copy(a2)
                a2 = copy.copy(an)
        print(a2 % 1000000007)

Buggy submission (verdict: Runtime Error):
import copy
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
if n == 1:
    if m == 1:
        print(0)
    else:
        print(1)
else:
    if 1 == a[0]:
        if 2 in a:
            a1 = 0
            a2 = 0
        else:
            a1 = 0
            a2 = 1
    else:
        if 2 in a:
            a1 = 1
            a2 = 0
        else:
            a1 = 1
            a2 = 2
    if n == 2:
        print(a2)
    else:
        for i in range(3,n+1):
            if i in a:
                a1 = copy.copy(a2)
                a2 = 0
            else:
                an = a1 + a2
                a1 = copy.copy(a2)
                a2 = copy.copy(an)
        print(a2 % 1000000007)

Buggy submission (verdict: Runtime Error):
import copy
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
if n == 1:
    if m == 1:
        print(0)
    else:
        print(1)
else:
    if 1 == a[0]:
        if 2 in a:
            a1 = 0
            a2 = 0
        else:
            a1 = 0
            a2 = 1
    else:
        if 2 in a:
            a1 = 1
            a2 = 0
        else:
            a1 = 1
            a2 = 2
    for i in range(3,n+1):
        if i in a:
            a1 = copy.copy(a2)
            a2 = 0
        else:
            an = a1 + a2
            a1 = copy.copy(a2)
            a2 = copy.copy(an)
    print(a2 % 1000000007)