Problem p03013 (python)

Fixed submission:
def fib(num):
    a, b = 0, 1 
    for _ in range(num - 1):
#         print(a)
        a, b = a + b, a
    return a + b

def culcC(num):
    if num  < 2:
         return 1
    return fib(num) + fib(num-1)
            
n,m = map(int,input().split())
aa = [int(input()) for i in range(m)]

if n == 1:
    print(1)
elif m == 0:
    print(culcC(n) % 1000000007)
else:
    ans = 1
    stand = 0
    for i,a in enumerate(aa):
#        連続穴
        if stand == a:
            ans = 0
            break
        step_num = a - stand - 1
        c = culcC(step_num)
        ans *= c if c > 0 else 1
        stand = a + 1
        
    # 最後のaからnまでで計算
    ans *= culcC(n - aa[-1] - 1)
    
    print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
def fib(n):
    f = ((1 + 5**0.5) / 2)**n / 5**0.5 + 0.5
    return int(f)

def culcC(num):
    return fib(num) + fib(num-1)
            
n,m = map(int,input().split())
aa = [int(input()) for i in range(m)]

if n == 1:
    print(1)
elif m == 0:
    print(culcC(n) % 1000000007)
else:
    ans = 1
    stand = 0
    for i,a in enumerate(aa):
#        連続穴
        if stand == a:
            ans = 0
            break
        step_num = a - stand - 1
        c = culcC(step_num)
        ans *= c if c > 0 else 1
        stand = a + 1
        
    # 最後のaからnまでで計算
    ans *= culcC(n - aa[-1] - 1)
    
    print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def culcC(num):
    if num  < 2:
        return 1
    ret = 1
    minus2 = 1
    while(True):
#         ret += int(comb(num - minus2,minus2 if minus2 >0 else 1,exact=True))
        ret += cmb(num - minus2,minus2 if minus2 >0 else 1)
        minus2 += 1
        if num - 2 * minus2 < 0:
            break
    return ret
            
n,m = map(int,input().split())
aa = [int(input()) for i in range(m)]

if n == 1:
    print(1)
else:
    ans = 1
    stand = 0
    for i,a in enumerate(aa):
        
#        連続穴
        if stand == a:
            ans = 0
            break
            
        step_num = a - stand - 1
        ans *= culcC(step_num)
        stand = a + 1
#         print(step_num,ans,stand)
        
    # 最後のaからnまでで計算
    ans *= culcC(n - aa[-1] - 1)
    
    print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

def culcC(num):
    if num  < 2:
        return 1
    ret = 1
    minus2 = 1
    while(True):
        ret += int(comb(num - minus2,minus2 if minus2 >0 else 1,exact=True))
        minus2 += 1
        if num - 2 * minus2 < 0:
            break
    return ret
            
n,m = map(int,input().split())
aa = [int(input()) for i in range(m)]

if n == 1:
    print(1)
else:
    ans = 1
    stand = 0
    for i,a in enumerate(aa):
        
#        連続穴
        if stand == a:
            ans = 0
            break
            
        step_num = a - stand - 1
        ans *= culcC(step_num)
        stand = a + 1
#         print(step_num,ans,stand)
        
    # 最後のaからnまでで計算
    ans *= culcC(n - aa[-1] - 1)
    
    print(ans % 1000000007)