Problem p03013 (python)

Fixed submission:
n, m = list(map(int, input().split()))
a = [input() for i in range(m)]
b = []
c = []
total_act = 0
total_act2 = 1
total = 1
if m == 0:
    for i in range(n + 1):
        if str(i) in a:
            total *= total_act
            total_act = 0
            total_act2 = 1
        else:
            total_act3 = total_act2 + total_act
            total_act2 = total_act
            total_act = total_act3
    total *= total_act
    print(total % 1000000007)
else:
    b.append(int(a[0]))
    for i in range(len(a) - 1):
        b.append(int(a[i + 1]) - int(a[i]) - 1)
        if int(a[i + 1]) - int(a[i]) - 1 == 0:
            print(0)
            exit()
    b.append(n - int(a[-1]))

    for i in range(max(b)):
        total_act3 = total_act2 + total_act
        total_act2 = total_act
        total_act = total_act3
        c.append(total_act)

    for i in b:
        total *= c[i - 1]
    print(total % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a = [input() for i in range(m)]
b = []
c = []
total_act = 0
total_act2 = 1
total = 1
# for i in range(n + 1):
#     if str(i) in a:
#         total *= total_act
#         total_act = 0
#         total_act2 = 1
#     else:
#         total_act3 = total_act2 + total_act
#         total_act2 = total_act
#         total_act = total_act3
# total *= total_act
# print(total % 1000000007)
b.append(int(a[0]))
for i in range(len(a) - 1):
    b.append(int(a[i + 1]) - int(a[i]) - 1)
    if int(a[i + 1]) - int(a[i]) - 1 == 0:
        print(0)
        exit()
b.append(n - int(a[-1]))

for i in range(max(b)):
    total_act3 = total_act2 + total_act
    total_act2 = total_act
    total_act = total_act3
    c.append(total_act)

for i in b:
    total *= c[i - 1]

print(total % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a = [input() for i in range(m)]
b = []
c = []
total_act = 0
total_act2 = 1
total = 1
# for i in range(n + 1):
#     if str(i) in a:
#         total *= total_act
#         total_act = 0
#         total_act2 = 1
#     else:
#         total_act3 = total_act2 + total_act
#         total_act2 = total_act
#         total_act = total_act3
# total *= total_act
# print(total % 1000000007)
b.append(int(a[0]))
for i in range(len(a) - 1):
    b.append(int(a[i + 1]) - int(a[i]) - 1)
b.append(n - int(a[-1]))

for i in range(max(b)):
    total_act3 = total_act2 + total_act
    total_act2 = total_act
    total_act = total_act3
    c.append(total_act)

for i in b:
    total *= c[i - 1]
    if i - 1 == -1:
        total = 0

print(total % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a = [input() for i in range(m)]
b = []
c = []
total_act = 0
total_act2 = 1
total = 1
b.append(int(a[0]))
for i in range(len(a) - 1):
    b.append(int(a[i + 1]) - int(a[i]) - 1)
for i in range(max(b)):
    total_act3 = total_act2 + total_act
    total_act2 = total_act
    total_act = total_act3
    c.append(total_act)
for i in b:
    total *= c[i - 1]

total *= c[n - int(a[-1]) - 1]
print(total % 1000000007)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
a = [input() for i in range(m)]
b = []
c = []
total_act = 0
total_act2 = 1
total = 1
b.append(int(a[0]))
for i in range(len(a) - 1):
    b.append(int(a[i + 1]) - int(a[i]) - 1)
print(b)
for i in range(max(b)):
    total_act3 = total_act2 + total_act
    total_act2 = total_act
    total_act = total_act3
    c.append(total_act)
print(c)
for i in b:
    total *= c[i - 1]

total *= c[n - int(a[-1]) - 1]
print(total % 1000000007)