Problem:


Score : 300 points

Problem Statement

You are given an integer N.
Find the number of the positive divisors of N!, modulo 10^9+7.

Constraints

1≤N≤10^3

Input

The input is given from Standard Input in the following format:

N

Output

Print the number of the positive divisors of N!, modulo 10^9+7.

Sample Input 1

3

Sample Output 1

4

There are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.

Sample Input 2

6

Sample Output 2

30

Sample Input 3

1000

Sample Output 3

972926972



Sample input:
3


Sample output:
4

Submission status: Runtime Error

Solution code:
from collections import deque, defaultdict
from functools import reduce
from operator import mul

N = int(input())
MOD = 10**9 + 7

# 素数の一覧
prime_nums = set([2]) if N > 1 else set()
prime_nums = prime_nums.union(set(range(3, N+1, 2)))
queue = deque([i for i in prime_nums if i*i <= N+1])
while queue:
    num = queue.popleft()
    prime_nums.difference_update({i for i in range(num*2, N+1, num)})
prime_nums = sorted(list(prime_nums))

# 素因数分解
factors = defaultdict(int)
for i in range(2, N+1):
    for j in prime_nums:
        while True:
            if i % j == 0:
                factors[j] += 1
                i //= j
            else:
                break


ans = reduce(mul, [(v+1) % MOD for v in factors.values()])
print(ans % MOD)

Submission status: Runtime Error

Solution code:
N = int(input())
#N,M = map(int,input().split())
#A = list(map(int,input().split()))
#A = [list(map(int,input().split())) for i in range(N)]
def prime_dict(n):
    a = {}
    if n%2 == 0:
        a[2] = 1
        n//=2
    while n%2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f*f <= n:
        if n%f == 0:
            if f not in a:
                a[f] == 1
            else:
                a[f] += 1
        else:
            f += 2
    if n!= 1:
        a[n] = 1
    return a
ans = 1
mod = 10**9+7
prime2 = {}
for i in range(2,N+1):
    prime = prime_dict(i)
    for k,v in prime.items():
        if k not in prime2:
            prime2[k] = v
        else:
            prime2[k] += v
for i in prime2.values():
    ans = (ans*(i+1))%mod
print(ans)

Submission status: Runtime Error

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N=one_int()

dicts={}
for i in range(2,N+1):
    lists = factorization(i)
    for item in lists:
        if item[0] != 1:
            if item[0] in dicts:
                dicts[item[0]] += item[1]
            else:
                dicts[item[0]] = item[1]

div=10**9 + 7
ans=1

for k,v in dicts.items():
    ans *= (v+1)%div

print(ans%div)

Submission status: Runtime Error

Solution code:
N=int(input())
import math
N_f=math.factorial(N)
s=[]
for i in range(1,round(N_f**0.5)+2):
    if N_f%i==0:
        s.append(i)
        s.append(N_f/i)
ans=set([int(i) for i in s])
print(len(ans)%(10**9+7))

Submission status: Runtime Error

Solution code:
N=int(input())
import math
N_f=math.factorial(N)
s=[]
for i in range(1,round(N_f**0.5)+2):
    if N_f%i==0:
        s.append(i)
        s.append(N_f/i)
ans=set([int(i) for i in s])
print(len(ans))

Submission status: Runtime Error

Solution code:
n = int(input())

def divi(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

import math

num = math.factorial(n)

print(len(divi(num))%1000000007)

Submission status: Runtime Error

Solution code:
N=int(input())
lim=10**9+7
import numpy as np
def seachPrimeNum(N):
    max_ = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max_:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

ans = 1
l=seachPrimeNum(N)
#print(l)
for p in l:
    temp=0
    k=1
    while True:
        if p**k>N:
            break
        temp += N//(p**k)
        k+=1
    ans = (ans * (temp + 1)) % lim
    #print(N//p + 1)
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
mod=10**9+7

def prime_factorization(n):
    '''
    素因数分解を求める

    Parameters:
    n : int
        求める数
    
    Returns:
    r : list
        素因数分解の結果
    '''
    r=[1]*(n+1)
    for i in range(1,n+1):
        for j in range(2,i+1):
            while i % j == 0:
                r[j] += 1
                i //= j
    
    return r

r = prime_factorization(N)
ans = 1
for i in r:
    ans *= i
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

def gcd(num):
    result = []
    for i in range(2, int(num**(1/2))+2):
        r = 0
        while num%i == 0:
            num = num//i
            r += 1
        if r != 0:
            result.append(r)
    return result

c = 1
for i in range(1, n+1):
    c *= i
o = 1
res = gcd(c)
if len(res) != 0:
    for i in range(len(res)):
        o *= res[i]+1
    print(o%(10**9 + 7))
else:
    print(2)

Submission status: Runtime Error

Solution code:
def PrimeNumber(N):
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans

N=int(input())

mod=10**9+7
PN=PrimeNumber(N)
P=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        if temp<j:
            break
        cnt=0
        while temp%j==0:
            cnt+=1
            temp=temp//j
        P[j]+=cnt

ans=1

for i in range(1,N+1):
    if P[i]!=0:
        ans=(ans*(P[i]+1))%mod
print(ans)

Submission status: Runtime Error

Solution code:
def PrimeNumber(N):
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans

N=int(input())

mod=10**9+7
PN=PrimeNumber(N)
P=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        cnt=0
        while temp%j==0:
            cnt+=1
            temp=temp//j
        P[j]+=cnt

ans=1

for i in range(1,N+1):
    if P[i]!=0:
        ans=(ans*(P[i]+1))%mod
print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
N = int(input())
A = list(range(2,N+1))
sqrt = N**(1/2)
idx = 0
if N == 1:
    print(1)
while True:
    p = A[idx]
    if p > sqrt:
        break
    check_numbers = A[idx+1:]
    for check_number in check_numbers:
        if check_number % p == 0:
            A.remove(check_number)
    idx += 1

ans = 1
B = [1] * 1001
for n in range(2, N+1):
    for a in A:
        if n == 1:
            break
        while True:
            if n % a == 0:
                B[a] += 1
                n //= a
            else:
                break
MOD = 10**9+7
print(reduce(lambda a,b: a*b , B)%MOD)

Submission status: Runtime Error

Solution code:
from functools import reduce
def factorial(N): return reduce(lambda x,y: x*y, [i for i in range(1,N+1)])

def is_prime(N):
  if N == 1: return False
  for i in range(2,int(N**0.5)+1):
    if N%i == 0: return False
  return True

def trial_division(N, factors):
  val = N
  cnt = 0
  
  if is_prime(N) is True:
    i = N
    if i not in factors: factors[i] = 1
    else: factors[i] += 1
  else:
    for i in range(2,N):
      while val % i == 0:
        val //= i
        if i not in factors: factors[i] = 1
        else: factors[i] += 1
        cnt += 1

      if cnt == 0:
        if i not in factors: factors[i] = 1
        else: factors[i] += 1


N = int(input())
factors = {}

for i in range(2,N+1):
  trial_division(i,factors)
print(reduce(lambda x,y: x*y,[factor+1 for factor in factors.values()])%(10**9+7))

Submission status: Runtime Error

Solution code:
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

n = int(input())
print(len(make_divisors(math.factorial(n)L))%(10**9+7))

Submission status: Runtime Error

Solution code:
x

Submission status: Runtime Error

Solution code:
def PrimeNumber(N):
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans


N=int(input())

PN=PrimeNumber(N)
c=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        while temp>0 and j<=i:
            if temp%j==0:
                c[j]+=1
                temp=temp//j
            else:
                break

ans=1
for i in PN:
    ans*=(c[i]+1)
    ans%=(10**9+7)

print(ans)

Submission status: Runtime Error

Solution code:
def PrimeNumber(N):
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans


N=int(input())

PN=PrimeNumber(N)
c=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        if j>i:
            break
        while temp>=j:
            if temp%j==0:
                c[j]+=1
                temp=temp//j
            else:
                break

ans=1
for i in PN:
    ans*=(c[i]+1)
    ans%=(10**9+7)

print(ans)

Submission status: Runtime Error

Solution code:
def PrimeNumber(N):
    ans = list(range(2, N + 1))
    i = 0
    while ans[i] < N ** 0.5 + 1:
        j = 2
        temp = ans[i]
        while temp * j <= ans[-1]:
            if temp * j in ans:
                ans.remove(temp * j)
            j += 1
        i += 1
    return ans


N=int(input())

PN=PrimeNumber(N)
c=[0]*(N+1)

for i in range(2,N+1):
    temp=i
    for j in PN:
        if j>i:
            break
        while temp>=j:
            if temp%j==0:
                c[j]+=1
                temp=temp//j
            else:
                break

ans=1
for i in PN:
    ans*=(c[i]+1)
ans=ans%(10**9+7)
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
if n==1:print(1);exit()
l=[i for i in range(1,n+1) if isPrime(i)==True]
ans=1
INF=10**9+7
for i in l:
    tmp=0
    tmpi=i
    while n//i>0:
        tmp+=n//i
        i*=tmpi
    ans=(ans*(tmp+1))%INF
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
result=[]
for i in range(2,n+1):
	for j in range(2,n+1):
		if i %j==0 and j not in result:
			result.append(j)
print(len(j)%(1000000007))

Submission status: Runtime Error

Solution code:
import time
import math
def sieve(n):
    prime = []
    limit = math.sqrt(n)
    data = [i for i in range(2, n+1)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


n = int(input())
prime = sieve(n)
ans = 1
for sosu in prime:
    cnt = 0
    for i in range(2, n+1):
        num = i
        while num % sosu == 0:
            num //= sosu 
            cnt += 1
    ans *= (cnt + 1)
print(ans % (10**9 + 7))

Submission status: Runtime Error

Solution code:
n=int(input())
d=dict()
m=[2,3,5,7,11,13,17,19,23,29,31]
for i in m:
  d[i]=0
  nn=n
  while nn:
    d[i]+=nn//i
    nn//=i
ans=1
for i in dict.values():
  ans*=i+1
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math

N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

divorces = make_divisors(math.factorial(N))
print(len(divorces)%(10**9 + 7))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import math

N = int(input())
result = 1

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

divorces = make_divisors(math.factorial(N))

print(len(divorces)%(10**9 + 7))

Submission status: Runtime Error

Solution code:
n=int(input())
d=dict()
if n==1:
  print(1)
else:
  for i in range(2,n+1):
    for j in range(2,i+1):
      if i%j==0:
        if j not in d:
          d[i]=1
        else:
          d[i]+=1
  ans=1
  for i in d.values():
    ans*=i+1
  print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
d=dict()
if n==1:
  print(1)
else:
  for i in range(2,n+1):
    for j in range(2,i+1):
      if i%j==0:
        if j not in d:
          d[i]=1
        else:
          d[i]+=1
  ans=1
  for i in d.values():
    ans*=i+1

Submission status: Runtime Error

Solution code:
import array
import textwrap
import math
mod = 10 ** 9 + 7
def prime(end, typecode="L"):
    assert end > 1
    # 整数iが素数であるかをis_prime[i]が示す
    # 最初はすべてTrueで初期化しておく
    # 最終的にprimesではなくこれを返してもよい
    is_prime = array.array("B", (True for i in range(end)))
    # 0, 1はいずれも素数ではない
    is_prime[0] = False
    is_prime[1] = False
    # 素数を格納する配列
    primes = array.array(typecode)
    # 篩う
    for i in range(2, end):
        if is_prime[i]:  # iが素数であるとき
            primes.append(i)  # 素数の配列に加える
            for j in range(2 * i, end, i):  # iを超えるiの倍数について
                is_prime[j] = False  # 素数ではないため除外する
    return primes.tolist()

n = int(input())
a = prime(n)
ans = 1
for i in a:
  b = 0
  c = i
  while c <= n:
    b += n // c
    c = c * i
  b += 1
  ans *= b
  ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
import array
import textwrap
import math
mod = 10 ** 9 + 7
def prime(end, typecode="L"):
    assert end > 1
    # 整数iが素数であるかをis_prime[i]が示す
    # 最初はすべてTrueで初期化しておく
    # 最終的にprimesではなくこれを返してもよい
    is_prime = array.array("B", (True for i in range(end)))
    # 0, 1はいずれも素数ではない
    is_prime[0] = False
    is_prime[1] = False
    # 素数を格納する配列
    primes = array.array(typecode)
    # 篩う
    for i in range(2, end):
        if is_prime[i]:  # iが素数であるとき
            primes.append(i)  # 素数の配列に加える
            for j in range(2 * i, end, i):  # iを超えるiの倍数について
                is_prime[j] = False  # 素数ではないため除外する
    return primes.tolist()

n = int(input())
a = prime(n)
ans = 1
print(a)
for i in a:
  b = 0
  c = i
  while c <= n:
    b += n // c
    c = c * i
  ans *= b + 1
  ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:

N = int(input())

def cal(n):
    if n>1:
        return n * cal(n-1)
    else:
        return n

b = cal(N)

li = []
for i in range(b):
    i += 1
    if b % i ==0:
        li.append(i)
        
print(len(li) % (1e9 + 7))

Submission status: Runtime Error

Solution code:
import numpy as np
MOD = 10**9 + 7


def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2, N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


N = int(input())
N_list = seachPrimeNum(N)
ans_list = [0 for i in range(len(N_list))]
for i in range(2, N+1):
    temp_i = i
    for j in range(len(N_list)):
        while temp_i % N_list[j] == 0:
            temp_i = temp_i // N_list[j]
            ans_list[j] += 1
ans = 1
for i in range(len(ans_list)):
    ans = ans * (ans_list[i]+1) % MOD
print(ans)

Submission status: Runtime Error

Solution code:
S=input();
s=[];
x=[];
X=[];
so=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,83,89,97,101,107,109,113,127,131,137,139,149,151,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,809,811,821,823,827,829,839,853,857,859,863,877,881,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];
ans=1;
for h in range(S):
    Y=h+1;
    for i in so:
        j=0;
        while Y%i==0:
            Y=Y/i;
            s=s+[i];
            j+=1;
for i in so:
    x=x+[s.count(i)];
X=[X+1 for X in x];
for i in X:
    ans=ans*i;
print(ans%1000000007);

Submission status: Runtime Error

Solution code:
S=input();
s=[];
x=[];
X=[];
so=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,83,89,97,101,107,109,113,127,131,137,139,149,151,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,809,811,821,823,827,829,839,853,857,859,863,877,881,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];
ans=1;
for h in range(S):
    Y=h+1;
    for i in so:
        j=0;
        while Y%i==0:
            Y=Y/i;
            s=s+[i];
            j+=1;
for i in so:
    x=x+[s.count(i)];
X=[X+1 for X in x];
print(X);
for i in X:
    ans=ans*i;
print(ans%1000000007);

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
b = list(map(int,input().split()))

su = 0
c = [0]
for  i in range(len(b)-2):
	c.append(0)


for i in range(a[0] - 1):
	c[i] = b[i+1] - b[i]

for i in range(len(c)):
	if a[2] <= c[i]*a[1]:
		su += a[2]
	else:
		su += c[i]*a[1]

print(su)

Submission status: Runtime Error

Solution code:
import math
N = int(input())

res=1
for i in range(1,N+1):
    res=res*i

print(res%(1e9+7))

quit()

Submission status: Runtime Error

Solution code:
inputs = input().split()
N = int(inputs[0])
A = int(inputs[1])
B = int(inputs[2])

inputs = input().split()
for i in range(len(inputs)):
    inputs[i] = int(inputs[i])

xi = []
xi.append(inputs[0])
hirou = 0

for i in range(1, N):
    xi.append(inputs[i])
    diff = xi[i] - xi[i-1]
    if diff * A > B:
        hirou += B
    else:
        hirou += A * diff

print(hirou)

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())

inputs = map(int, input().split())

xi = []
xi.append(inputs[0])
hirou = 0

for i in range(1, N):
    xi.append(inputs[i])
    diff = xi[i] - xi[i-1]
    if diff * A > B:
        hirou += B
    else:
        hirou += A * diff

print(hirou)

Submission status: Runtime Error

Solution code:
N,A,B = list(map(int,input().split()))
inputs = list(map(int, input().split()))
exit(0)
xi = []
xi.append(inputs[0])
hirou = 0

for i in range(1, N):
    xi.append(inputs[i])
    diff = xi[i] - xi[i-1]
    if diff * A > B:
        hirou += B
    else:
        hirou += A * diff

print(hirou)

Submission status: Runtime Error

Solution code:
N,A,B = list(map(int,input().split()))
inputs = list(map(int, input().split()))
xi = []
xi.append(inputs[0])
hirou = 0

for i in range(1, N):
    xi.append(inputs[i])
    diff = xi[i] - xi[i-1]
    if diff * A > B:
        hirou += B
    else:
        hirou += A * diff

print(hirou)

Submission status: Runtime Error

Solution code:
N,A,B = list(map(int,input().split()))
inputs = list(map(int, input().split()))
xi = []
xi.append(inputs[0])
hirou = 0

for i in range(1, len(inputs)):
    xi.append(inputs[i])
    diff = xi[i] - xi[i-1]
    if diff * A > B:
        hirou += B
    else:
        hirou += A * diff

print(hirou)

Submission status: Runtime Error

Solution code:

def main():
    [n, a, b] = list(map(int,input().split()))
    m = list(map(int,input().split()))
    cost = 0
    for i in range(1, n):
        cost += min([a*(m[i]-m[i-1]), b])
    print(cost)


if __name__ == "__main__":
    import sys
    import os
    if len(sys.argv) > 1:
        if sys.argv[1] == "-d":
            filename = "input1.txt"
            fd = os.open(filename, os.O_RDONLY)
            os.dup2(fd, sys.stdin.fileno())
            main()
    else:
        main()

Submission status: Runtime Error

Solution code:
primes = [2,3,5,7,11,13,17,19,23,29,31]

memo1 = {}
def factorization(n):
    result = []
    for prime in primes:
        while n % prime == 0:
            n = n / prime
            result.append(prime)
    if n != 1:
        result.append(n)
    return result

def num_of_factors(l):

    if len(l) == 1:
        return 2
    p2num = {}
    for prime in l:
        if prime not in p2num:
            p2num[prime] = 2
        else:
            p2num[prime] += 1
    return reduce(lambda x,y: x * y,p2num.values())

def factors_of_factorials(n):
    l = []
    for i in range(1,n+1):
        l += factorization(i)
    return num_of_factors(l) % (10**9 + 7)


n = int(raw_input())
print factors_of_factorials(n)

Submission status: Runtime Error

Solution code:
primes = [2,3,5,7,11,13,17,19,23,29,31]

memo1 = {}
def factorization(n):
    result = []
    for prime in primes:
        while n % prime == 0:
            n = n / prime
            result.append(prime)
    if n != 1:
        result.append(n)
    return result

def factors(l):
    p2num = {}
    for prime in l:
        if prime not in p2num:
            p2num[prime] = 2
        else:
            p2num[prime] += 1
    return reduce(lambda x,y: x * y,p2num.values())

def factors_of_factorials(n):
    l = []
    for i in range(1,n+1):
        l += factorization(i)
    return factors(l) % (10**9 + 7)


n = int(raw_input())
print factors_of_factorials(n)

Submission status: Runtime Error

Solution code:
N,A,B,C,D=map(int,raw_input().split());Z=[1]+[0]*N;M=10**9+7;I=[1,1];F=I+[];R=I+[]
for i in range(2,N+1):I+=[(M-M/i)*I[M%i]%M];F+=[i*F[-1]%M];R+=[I[i]*R[-1]%M]
for i in range(A,B+1):Z=[(Z[j]+sum(Z[j-i*k]*F[N-j+i*k]*R[N-j]*pow(R[i],k,M)*R[k]for k in range(C,min(D,j/i)+1)))%M for j in range(N+1)]
print Z[N]

Submission status: Runtime Error

Solution code:
#!/usr/bin/env pypy3
# -*- coding: UTF-8 -*-
import sys
import re
import math
import itertools
import collections
import bisect
#sys.stdin=file('input.txt')
#sys.stdout=file('output.txt','w')
#10**9+7
mod=1000000007
#mod=1777777777
pi=3.1415926535897932
IS=float('inf')
xy=[(1,0),(-1,0),(0,1),(0,-1)]
bs=[(-1,-1),(-1,1),(1,1),(1,-1)]
def niten(a,b): return abs(a-b) if a>=0 and b>=0 else  a+abs(b) if a>=0 else abs(a)+b if b>=0 else abs(abs(a)-abs(b))
def fib(n): return [(seq.append(seq[i-2] + seq[i-1]), seq[i-2])[1] for seq in [[0, 1]] for i in range(2, n)]
def gcd(a,b): return a if b==0 else gcd(b,a%b)
def lcm(a,b): return a*b/gcd(a,b)
def eucl(x1,y1,x2,y2): return ((x1-x2)**2+(y1-y2)**2)**0.5
def choco(xa,ya,xb,yb,xc,yc,xd,yd): return 1 if abs((yb-ya)*(yd-yc)+(xb-xa)*(xd-xc))<1.e-10 else 0
def pscl(num,l=[1]):
    for i in range(num):
        l = map(lambda x,y:x+y,[0]+l,l+[0])
    return l

n=int(input())
n,k=map(int,input().split())
l=[int(i) for i in input().split()]
ans=chk=0
print(ans)