Problem p03013 (python)

Fixed submission:
N,M=map(int,input().split())
A=[int(input()) for n in range(M)]
S=[1]*(N+1)
for a in A:
  S[a]=0
for i in range(2,N+1):
  S[i]=(S[i-1]+S[i-2])%1000000007*S[i]

print(S[-1])

Buggy submission (verdict: Runtime Error):
import math
def calc_pattern(stairs):
    if stairs<=3:
        return stairs
    d=stairs//2+1
    l=[(math.factorial(i+(stairs-i*2))/math.factorial(i)/math.factorial(stairs-i*2))%1000000007  for i in range(d)]
    return int((sum(l))%1000000007)

N,M=map(int,input().split())
A=[-1]
A.extend([int(input()) for m in range(M)])
A.append(N+1)
s=1
for m in range(M+1):
    if A[m+1]==1 or A[m]==N-1:
        continue
    if A[m]+1==A[m+1]:
        print(0)
        exit()
    else:
        s*=calc_pattern(A[m+1]-1 - (A[m]+1))
        s%=1000000007
print(int(s))

Buggy submission (verdict: Runtime Error):
import math
def calc_pattern(stairs):
    if stairs<=3:
        return stairs
    d=stairs//2+1
    l=[(math.factorial(i+(stairs-i*2))/math.factorial(i)/math.factorial(stairs-i*2))%1000000007  for i in range(d)]
    return (sum(l))%1000000007

N,M=map(int,input().split())
A=[-1]
A.extend([int(input()) for m in range(M)])
A.append(N+1)
s=1
for m in range(M+1):
    if A[m+1]==1 or A[m]==N-1:
        continue
    if A[m]+1==A[m+1]:
        print(0)
        exit()
    else:
        s*=calc_pattern(A[m+1]-1 - (A[m]+1))
        s%=1000000007
print(int(s))

Buggy submission (verdict: Runtime Error):
import math
def calc_pattern(stairs):
    if stairs<=4:
        return stairs
    d=stairs//2+1
    l=[(math.factorial(i+(stairs-i*2))/math.factorial(i)/math.factorial(stairs-i*2))%1000000007  for i in range(d)]
    return (sum(l))%1000000007
"""
for stairs in range(1,11):
    print(stairs, calc_pattern(stairs))
"""
N,M=map(int,input().split())
A=[-1]
A.extend([int(input()) for m in range(M)])
A.append(N+1)
#print(A)
s=1
for m in range(M+1):
    if A[m+1]==1 or A[m]==N-1:
        continue
    if A[m]+1==A[m+1]:
        print(0)
        exit()
    else:
        #print("{} ~ {}".format(A[m]+1, A[m+1]-1))
        #print(calc_pattern(A[m+1]-1 - (A[m]+1)))
        s*=calc_pattern(A[m+1]-1 - (A[m]+1))
        s%=1000000007
        #print(s)
print(int(s))
# 0~A[0]-1, A[0]+1~A[1]-1
# A の先頭に-1を入れれば、A[i]+1~A[i+1]-1 で統一できそう

Buggy submission (verdict: Runtime Error):
import math
def calc_pattern(stairs):
    if stairs<=4:
        return stairs
    d=stairs//2+1
    l=[(math.factorial(i+(stairs-i*2))/math.factorial(i)/math.factorial(stairs-i*2))%1000000007  for i in range(d)]
    return (sum(l))%1000000007
N,M=map(int,input().split())
A=[-1]
A.extend([int(input()) for m in range(M)])
A.append(N+1)
s=1
for m in range(M+1):
    if A[m+1]==1 or A[m]==N-1:
        continue
    if A[m]+1==A[m+1]:
        print(0)
        exit()
    else:
		s*=calc_pattern(A[m+1]-1 - (A[m]+1))
        s%=1000000007
print(int(s))

Buggy submission (verdict: Runtime Error):
import math
def calc_pattern(stairs):
    if stairs<=4:
        return stairs
    d=stairs//2+1
    l=[(math.factorial(i+(stairs-i*2))/math.factorial(i)/math.factorial(stairs-i*2))%1000000007  for i in range(d)]
    return (sum(l))%1000000007

N,M=map(int,input().split())
A=[-1]
A.extend([int(input()) for m in range(M)])
A.append(N+1)

s=1
for m in range(M+1):
    if A[m+1]==1 or A[m+1]==N-1:
        continue
    if A[m]+1==A[m+1]:
        print(0)
        exit()
    else:
        s*=calc_pattern(A[m+1]-1 - (A[m]+1))
        s%=1000000007
print(int(s))

Buggy submission (verdict: Runtime Error):
import math
def calc_pattern(stairs):
    d=stairs//2
    l=[(math.factorial(i+(d-i)*2)/math.factorial(i)/math.factorial((d-i)*2))%1000000007  for i in range(d+1)]
    return (sum(l))%1000000007

#stairs=10
#print(calc_pattern(stairs))

# if A[i]+1==A[i+1]: print(0) exit()
N,M=map(int,input().split())
#A=[int(input()) for n in range(M)]
A=[-1]
A.extend([int(input()) for m in range(M)])
A.append(N+1)
#print(A)
# now=0, for a in A:
# 0~A[0]-1, A[0]+1~A[1]-1
# A の先頭に-1を入れれば、A[i]+1~A[i+1]-1 で統一できそう
s=1
for m in range(M+1):
    if A[m]+1==A[m+1]:
        print(0)
        exit()
    else:
        #print("{} ~ {}".format(A[m]+1, A[m+1]-1))
        #print(calc_pattern(A[m+1]-1 - (A[m]+1)))
        s=(s * calc_pattern(A[m+1]-1 - (A[m]+1)))%1000000007
print(int(s))