Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
mod = 10**9 + 7
a = [1] * (n+1)
for i in range(m):
    b = int(input())
    a[b] = 0

        
for i in range(2,n+1):
    if a[i] != 0:
        a[i] = a[i-1] + a[i-2]
#print(a)
print(a[n] % mod)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
mod = 10**9 + 7
a = [-1] * (n+1)
a[0]=0
for i in range(1,m+1):
    b = int(input())
    a[b] = 0

if a[1] == 0:
    a[2] = 1
else:
    a[1] = 1
    if a[2] != 0:
        a[2] = 2
        
for i in range(3,n+1):
    if a[i] != 0:
        a[i] = a[i-1] + a[i-2]
#print(a)
print(a[n] % mod)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
@lru_cache(maxsize=1000)
def fib(n):
	if n < 2:
		return n
	else:
		return fib(n - 1) + fib(n - 2)



n,m = map(int,input().split())
a = []
a.append(0)
for i in range(m):
	b = int(input())
	b -= 1
	a.append(b)

a.append(n)

b = []
for i in range(n+1):
	b.append(fib(i))
	
c = []
#if a[1] == 0:
	#c.append(1)
#else:
	#c.append(b[a[1] - a[0] ])
	
	
i = 0
while i <= m + 1:
	if a[i + 1] - a[i] - 2 >= 0:
		c.append(b[a[i + 1] - a[i]  - 2])
		i += 1
	#elif a[i + 1] - a[i] - 2 == 0:
		#c.append(1)
	else:
		c.append(0)
		break
#print(c)
d = c[0] 
i = 1
#print(d)
while i < len(c):
	d = d * c[i]
	i += 1

e = 1000000007
print(d % e)
#print(b[0])

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
2.@lru_cache(maxsize=1000)
3.def fib(n):
4.    if n < 2:
5.        return n
6.    else:
7.        return fib(n - 1) + fib(n - 2)
8. 
9.n,m = map(int,input().split())
10.a = []
11.a.append(0)
12.for i in range(m):
13.    b = int(input())
14.    b -= 1
15.    a.append(b)
16.a.append(n)
17.b = []
18. 
19.for i in range(n):
20.    b.append(fib(i))
21. 
22.c = []
23.#if a[1] == 0:
24.    #c.append(1)
25.#else:
26.    #c.append(b[a[1] - a[0] ])
27.i = 0
28.while i <= m:
29.    #if a[i + 1] - a[i] - 2 >= 0:
30.    c.append(b[a[i + 1] - a[i]  - 2])
31.    i += 1
32.    #elif a[i + 1] - a[i] - 2 == 0:
33.        #c.append(1)
34.    #else:
35.        #c.append(0)
36.        #break
37.#print(c)
38.d = c[0] 
39.i = 1
40.#print(d)
41.while i < len(c):
42.    d = d * c[i]
43.    i += 1
44.e = 1000000007
45.print(d % e)
46.#print(b[0])

Buggy submission (verdict: Runtime Error):
from functools import lru_cache
@lru_cache(maxsize=1000)
def fib(n):
    if n < 2:
        return n
    else:
        return fib(n - 1) + fib(n - 2)

n,m = map(int,input().split())
a = []
a.append(0)
for i in range(m):
    b = int(input())
    b -= 1
    a.append(b)
a.append(n)
b = []

for i in range(1,n):
    b.append(fib(i))

c = []
if a[1] == 0:
    c.append(1)
else:
    c.append(b[a[1] - a[0] ])
i = 1
while i <= m:
    if a[i + 1] - a[i] - 2 >= 0:
        c.append(b[a[i + 1] - a[i]  - 2])
        i += 1
    #elif a[i + 1] - a[i] - 2 == 0:
        #c.append(1)
    else:
        c.append(0)
        break
#print(c)
d = c[0] 
i = 1
#print(d)
while i < len(c):
    d = d * c[i]
    i += 1
e = 1000000007
print(d % e)
#print(b[0])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = []
a.append(0)
for i in range(m):
    b = int(input())
    b -= 1
    a.append(b)
a.append(n)
b = []

for i in range(1,n):
    b.append(fib(i))

c = []
if a[1] == 0:
    c.append(1)
else:
    c.append(b[a[1] - a[0] ])
i = 1
while i <= m:
    if a[i + 1] - a[i] - 2 >= 0:
        c.append(b[a[i + 1] - a[i]  - 2])
        i += 1
    #elif a[i + 1] - a[i] - 2 == 0:
        #c.append(1)
    else:
        c.append(0)
        break
#print(c)
d = c[0] 
i = 1
#print(d)
while i < len(c):
    d = d * c[i]
    i += 1
e = 1000000007
print(d % e)
#print(b[0])