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

Solution (Python):
N = int(input())
mod = 10**9+7

prime = []
for i in range(2, 1000) :
    flag = True
    for p in prime :
        if i%p == 0 :
            flag = False
    if flag == True :
        prime.append(i)

pcount = [0 for _ in range(len(prime))]

def bek(n, p) :
    temp = 0
    while n%p == 0 :
        temp += 1
        n //= p
    return temp

for i in range(len(prime)) :
    for j in range(1,N+1) :
        pcount[i] += bek(j, prime[i])

ans = 1
for i in range(len(prime)) :
    ans = (ans * (pcount[i]+1))%mod

print(ans)

Solution (Python):
from collections import defaultdict

def main():
  n = int(input())
  mod = 10**9 + 7
  primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
  fact = defaultdict(int)
  for i in range(2, n + 1):
    tmp = i
    for j in primes:
      if tmp % j == 0:
        cnt = 0
        while tmp % j == 0:
          cnt += 1
          tmp //= j
        fact[j] += cnt
    if tmp != 1:
      fact[tmp] += 1
    if not fact:
      fact[i] = 1
  ans = 1
  for f in fact.values():
    ans = ans * (f + 1) % mod
  print(ans)
 
if __name__ == "__main__":
  main()

Solution (Python):
N=int(input())
b=1
for a in range(1,N+1):
    b*=a
numbers=[2]
for c in range(3,N+1):
    count=0
    for d in numbers:
        if not c%d==0:
            count+=1
        else:
            pass
    if count==len(numbers):
        numbers.append(c)
    else:
        pass
answers=[]
while b>1:
    for e in numbers:
        kazu=0
        while b%e==0:
            b=b//e
            kazu+=1
        answers.append(kazu)
kotae=1
for f in answers:
    kotae*=(f+1)
print(kotae%(10**9+7))

Solution (Python):
import math
mod = 10 ** 9 + 7
n = int(input())
list = [0] * (n + 1)


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


def extgcd(a, b):
    r = [1, 0, a]
    w = [0, 1, b]
    while w[2]!=1:
        q = r[2] // w[2]
        r2 = w
        w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]]
        r = r2
        w = w2
    
    return [w[0], w[1]]


def mod_inv(a,m):
    x = extgcd(a, m)[0]
    return (m + x % m) % m

for x in range(n - 1):
    facList = factorization(x + 2)
    for fac in facList:
        list[fac[0]] += fac[1]
ans = 1
for x in list:
    ans *= x + 1
    ans %= mod
print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def primes_for(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

def factorial(n):
    res = 1
    for i in range(1, N+1):
        res *= i
    return res

N = INT()
f = factorial(N)
divisor = 1
A = [0] * (N + 1)

prime_list = primes_for(N)
tmp = f
for p in prime_list:
    cnt = 0
    if tmp % p == 0:
        while tmp % p == 0: 
            tmp = tmp // p
            A[p] += 1

for a in A:
    divisor *= (a + 1)
print(divisor % mod)

Solution (Python):
import math
MOD = 10**9 + 7

n = int(input())

array = [0] * 1000

for i in range(2, n+1):
  tmp = i
  j = 2
  while j <= math.ceil(math.sqrt(tmp)):
    if tmp % j == 0:
      while tmp % j ==0:
        array[j] += 1
        tmp //= j
    
    j += 1
      
  if tmp != 1:
    array[tmp] += 1
  
ans = 1
for v in array:
  ans = ((v+1)*ans) % MOD
  
print(ans)

Solution (Python):
n = int(input())
mod = 10 ** 9 + 7
prime = [1] * 1001  
for num in range(2, n + 1):
    while num % 2 == 0:  
        prime[2] += 1  
        num //= 2  
    odd = 3
    while odd ** 2 <= num:  
        while num % odd == 0:  
            prime[odd] += 1  
            num //= odd  
        odd += 2 
    if num != 1:  
        prime[num] += 1
ans = 1  
for i in range(1001):
    ans *= prime[i]  
print(ans % mod)

Solution (Python):
def main():
    N = int(input())
    MOD = 10**9 + 7

    def Eratosthenes(sup: int) -> set:
        from math import sqrt
        primes = {i for i in range(2, sup+1)}
        for i in range(2, int(sqrt(sup+1))+1):
            if i in primes:
                mul = 2
                while i*mul <= sup:
                    primes.discard(i*mul)
                    mul += 1
        return primes

    ps = Eratosthenes(N)
    ans = 1
    for p in ps:
        cur = 0
        i = 1
        while N//(p**i) > 0:
            cur += N//(p**i)
            i += 1
        ans *= (cur+1)
        ans %= MOD
    print(ans % MOD)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
N = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


M = defaultdict(int)

for n in range(1, N+1):
    P = prime_factorize(n)
    for p in P:
        M[p] += 1

MOD = 10 ** 9 + 7
ans = 1
for k, v in M.items():
    ans *= v+1
    ans %= MOD

print(ans)

Solution (Python):






def factorization(n: int):
    if n == 1:
        return []  
    
    arr = []
    temp = n
    for i in range(2, int(n**0.5) + 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


MOD = 10**9 + 7
from collections import defaultdict
N = int(input())
factor_num = defaultdict(lambda: 0)
for n in range(1, N + 1):
    tmp = factorization(n)
    for k, v in tmp:
        factor_num[k] += v


ans = 1
for v in factor_num.values():
    ans *= (v + 1)
    if ans >= MOD:
        ans %= MOD
print(ans)

Solution (Python):


num = int(input().rstrip())

md = 1000000000 + 7

cnt = {}


def prime_devide(n):
    current = n

    ret = {}
    div = 2
    while current > 1:
        if current % div == 0:
            ret[div] = 0
            while current % div == 0:
                ret[div] += 1
                current = int(current / div)
        div += 1
    return ret


if num == 1:
    print(1)

else:
    for i in range(2, num + 1):
        tmp = prime_devide(i)
        for k, v in tmp.items():
            if k in cnt:
                cnt[k] += v
            else:
                cnt[k] = v
    ans = 1
    for k, v in cnt.items():
        ans *= (v + 1)
        ans = ans % md
    ans = ans % md
    print(ans)

Solution (Python):
N = int(input())
a = {}
for i in range(N):
	b = i + 1
	j = 2
	while j * j <= b:
		while b % j == 0:
			if j in a:
				a[j] += 1
			else:
				a[j] = 1
			b /= j
		j += 1
	if b != 1:
		if b in a:
			a[b] += 1
		else:
			a[b] = 1
c = 1
for i in a.values():
	c *= i + 1
print(c % 1000000007)

Solution (Python):

from collections import Counter
from functools import reduce
import sys


def fc(n: int):
    for p in range(2, n + 1):
        while 1:
            q, r = divmod(n, p)
            if r != 0:
                break
            yield p
            n = q
        if n == 1:
            break


MOD = 1000000007  


def solve(N: int):
    fs = Counter()
    for i in range(1, N + 1):
        fs.update(fc(i))
    print(reduce(lambda a, b: a * (b + 1) % MOD, fs.values(), 1))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
U = 10**3
T = np.zeros(U,np.int32)
T[2]=1
T[3::2]=1
for i in range(U):
  if i*i>U:
    break
  if T[i]==1:
    T[i*i::2*i] = 0
pls = np.where(T)[0]
N = int(input())
MOD = 10**9+7
dic = {}
for i in range(2,N+1):
  for p in pls:
    if p>i:
      break
    while i%p==0:
      dic[p] = dic.get(p,0)+1
      i //= p
ans = 1
for v in dic.values():
  ans *= (v+1)
  ans %= MOD
print(ans)

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

def sieve(n):
    prime=[]
    limit=n**0.5
    data=[i+1 for i in range(1,n)]
    while True:
        p=data[0]
        if limit<=p:
            return prime+data
        prime.append(p)
        data=[e for e in data if e%p!=0]
        
ans=1
prime=sieve(n+1)
for p in prime:
    cnt=0
    j=1
    while p**j<=n:
        cnt+=n//(p**j)
        cnt%=mod
        j+=1
    ans*=(cnt+1)
    ans%=mod
print(ans)

Solution (Python):
from collections import Counter
from math import factorial


def main():
    number = factorial(int(input()))
    mod = 10 ** 9 + 7
    prime_factors = []
    while not number % 2:
        prime_factors.append(2)
        number //= 2
    i = 3
    while i <= number:
        if not number % i:
            number //= i
            prime_factors.append(i)
        else:
            i += 2
    answer = 1
    for p in list(Counter(prime_factors).values()):
        answer = answer * (p + 1) % mod
    print(answer)


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
mod = 10**9 + 7
li = [0] * (10**3 + 10)

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

for i in range(1,n+1):
    li2 = factorization(i)
    for j in li2:
        li[j[0]] += j[1]

ans = 1

for i in li[2:]:
    if i != 0:
        ans *= (i+1)
        ans %= mod

print(ans)

Solution (Python):
N = int(input())
mod = 10**9+7
li = [0] * 1001
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
if N ==1:
    print(1)
else:
    ans = 1
    for i in range(2,N+1):
        arr = factorization(i)
        n = len(arr)
        for j in range(n):
            x = arr[j][0]
            y = arr[j][1]
            li[x] += y
    for i in range(2,1000):
        k = li[i]+1
        ans = ans * k % mod
    print(ans)

Solution (Python):
n = int(input())
l = []
for i in range(1, n+1):
    num = 2
    while i != 1:
        if i % num==0:
            i //= num
            l.append(num)
        else:
            num += 1
ans = 1
for i in set(l):
    ans *= (l.count(i) + 1) % (10**9+7)
print(ans% (10**9+7))

Solution (Python):
n = int(input())
if n == 1:
    print(1)
    exit()
mod = 10**9+7
ans = {}
ans[2] = 0
for i in range(2,n+1):
    for j in ans.keys():
        while i % j == 0:
            ans[j] += 1
            i //= j
    if i != 1:
        ans[i] = 1
k = 1
for i in ans.values():
    k *= i+1
    k %= mod
print(k)

Solution (Python):
import math


def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2, tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor


n = int(input())
mod = 10**9 + 7
ans = {}
for i in range(2, n+1):
    for s in trial_division(i):
        if s == 1:
            continue
        if s in ans.keys():
            ans[s] += 1
        else:
            ans[s] = 1
w = 1
for i in ans.values():
    w *= (i+1)
    w %= mod
print(w)

Solution (Python):
NUM = 10**9 + 7
def solve():
    N = int(input())
    dict = {}
    for n in range(2, N + 1):
        for i in range(2, n + 1):
            while n % i == 0:
                n //= i
                if not i in dict.keys():
                    dict[i] = 1
                else:
                    dict[i] += 1
    res = 1
    for i in dict.values():
        res *= (i + 1)
        res %= NUM
    return res

if __name__ == '__main__':
    print(solve())

Solution (Python):
from math import floor, sqrt
from collections import defaultdict
def factors(n):
    d = defaultdict(int)
    for i in range(2,floor(sqrt(n))+1):
        while n % i == 0:
            n //= i
            d[i] += 1
        if n == 1:
            break
    if n != 1:
        d[n] += 1
    return d
N = int(input())
mod = 10**9+7
d = defaultdict(int)
for i in range(1,N+1):
    e = factors(i)
    for k in e:
        d[k] += e[k]
ans = 1
for k in d:
    ans = (ans*(d[k]+1)) % mod
print(ans)

Solution (Python):
from math import floor, sqrt
from collections import defaultdict
def factors(n):
    d = defaultdict(int)
    for i in range(2,floor(sqrt(n))+1):
        while n % i == 0:
            n //= i
            d[i] += 1
        if n == 1:
            break
    if n != 1:
        d[n] += 1
    return d
N = int(input())
mod = 10**9+7
d = defaultdict(int)
for i in range(1,N+1):
    e = factors(i)
    for k in e:
        d[k] += e[k]
ans = 1
for k in d:
    ans = (ans*(d[k]+1)) % mod
print(ans)

Solution (Python):
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

from collections import defaultdict
d = defaultdict(int)

N = int(input())

li = []

for n in range(1, N+1):
  a = factorization(n)
  for i in a:
    d[i[0]] += i[1]

ans = 1

for i in d:
  if i == 1:
    continue
  
  ans = ans * (d[i] + 1)

print(ans % (10**9 + 7))

Solution (Python):
N = int(input())
insu_list = [[2, 0]]
ans = 1

for i in range(N):
    n = i+1
    for j in range(len(insu_list)):
        while n % insu_list[j][0] == 0:
            n /=insu_list[j][0]
            insu_list[j][1] += 1
    if n != 1:
        insu_list.append([n, 1])
for i in range(len(insu_list)):
    ans *= insu_list[i][1] + 1
print(ans%(10**9+7))

Solution (Python):
LARGE = 10 ** 9 + 7

def prime_factorize_dict(N):
    d = dict()
    for n in range(1, N + 1):
        while not n & 1:
            d[2] = d.get(2, 0) + 1
            n >>= 1
        f = 3
        while f * f <= n:
            if not n % f:
                d[f] = d.get(f, 0) + 1
                n //= f
            else:
                f += 2
        if n != 1:
            d[n] = d.get(n, 0) + 1
    return d

N = int(input())
total = 1
for p in prime_factorize_dict(N).values():
    total *= (p + 1)

print(total % LARGE)

Solution (Python):
import math

N = int(input())

class remainder():
    def __init__(self, mod=(10**9 + 7)):
        self.mod = mod
    
    def mul(self, a, b):
        return ((a % self.mod) * (b % self.mod)) % self.mod

    def pow(self, a, b):
        bp = []
        
        bp.append(a)

        n = len(bin(b)) - 2
        for x in range(n):
            bp.append(bp[x]**2 % self.mod)

        res = 1
        for x in range(n):
            if b >> x & 1:
                res = (res * bp[x]) % self.mod
        
        return res

    def div(self, a, b):
        
        return self.mul(a, self.pow(b, self.mod - 2))


def findAllOfPrime(N):
    prime = [True] * (N + 1)
    prime[0] = False
    prime[1] = False

    x = 2
    while x**2 <= N:
        if prime[x]:
            j = 2
            while x * j <= N:
                prime[x * j] = False
                j += 1
        x += 1

    return prime

re = remainder()
primes = set()
for n in range(1, N + 1):
    prime = findAllOfPrime(n)
    for i, p in enumerate(prime):
        if p:
            primes.add(i)

A = math.factorial(N)
ans = 1
for p in primes:
    cnt = 1
    while A % p == 0:
        cnt += 1
        A //= p
    ans = re.mul(ans, cnt)
print(ans)

Solution (Python):
import numpy as np
primes = np.array([  2,   3,   5,   7,  11,  13,  17,  19,  23,  29,  31,  37,  41,
        43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97, 101,
       103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 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, 797, 809, 811, 821, 823,
       827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911,
       919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997],dtype = np.int64)
n = int(input())
div = primes[primes <= n]
mod = 10**9 + 7
def divide(p,n):
    if n < p:
        return 0
    return divide(p,n//p) + n//p
ans = 1
for p in div:
    ans *= (divide(p,n) + 1) 
    ans %= mod
print(ans)

Solution (Python):
def prim(p):
  if p == 2:
    return True
  else:
    flg = False
    count = 0
    for i in range(1, int(p ** 0.5) + 1):
      if p % i == 0:
        count += 1
    if count == 1:
      flg = True
    return flg
N = int(input())
if N == 1:
  print(1)
else:
  p_list = []
  for j in range(2, N + 1):
    if prim(j):
      p_list.append(j)
  l = []
  for p in p_list:
    k = 1
    add = 0
    while N // (p ** k):
      add += N // (p ** k)
      k += 1
    l.append(add + 1)
  ans = 1
  for r in l:
    ans *= r
    ans = ans % (10 ** 9 + 7)
  print(ans)

Solution (Python):


def main():
    N = int(input())
    prime_num = [1]*1001
    for n in range(2,N+1,1):
        while n % 2 == 0:
            prime_num[2] += 1
            n //= 2
        
        f = 3
        while f * f <= n:
            while n % f == 0:
                prime_num[f] += 1
                n //= f
            f += 2
        if n != 1:
            prime_num[n] += 1
    ans = 1
    for i in range(1001):
        ans *=prime_num[i]
    print(ans % (10**9+7))
    

if __name__ == '__main__':
    main()

Solution (Python):
import math
 
def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append([b, e])
        b, e = b + 1, 0
    if n > 1:
        fct.append([n, 1])
    return fct
 
n = int(input())
mod = 10 ** 9 + 7
 
l = [0] * (n + 1)
 
for i in range(1, n + 1):
  soi = factorize(i)
  for j in range(len(soi)):
    l[soi[j][0]] += soi[j][1]
 
ans = 1
for i in range(1, n + 1):
  ans = ans * (l[i] + 1) % mod
 
print(ans)

Solution (Python):
mod = 1000000000 + 7
 
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 = int(input())
dat = [0] * 2000 
 

res = 1
for i in range(1, n + 1):
    d = factorization(i)
    for j in range(len(d)):
        dat[d[j][0]] += d[j][1]
 
for i in range(2, n + 1):
    res *= (dat[i] + 1)
    res %= mod
 
print(res)

Solution (Python):
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np

Mod = 1000000007
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): 
    n = int(input())
    p = sieve_of_eratosthenes(n+1)
    ansdict = defaultdict(int)
    for i in range(1,n+1):
        for j in p:
            subans = 0
            while i % j == 0:
                ansdict[j] += 1
                i //= j
    ans = 1
    for i in ansdict.values():
        ans *= i+1
        ans %= Mod

    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):
mod = 1000000000 + 7

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 = int(input())
dat = [0] * 2000

res = 1
for i in range(1, n + 1):
    d = factorization(i)
    for j in range(len(d)):
        dat[d[j][0]] += d[j][1]

for i in range(2, n + 1):
    if dat[i] == 0:
        continue
    
    res *= (dat[i] + 1)
    res %= mod

print(res)

Solution (Python):

from collections import defaultdict
def primeFactors(n):
    res = []
    while n%2==0:
        res.append(2)
        n //= 2
    x = 3
    while n>1 and n>=x*x:
        while n%x==0:
            res.append(x)
            n //= x
        x += 2
    if n>1:
        res.append(n)
    return res

def modpow(a,n,m):
    res = 1
    while n>0:
        if n%2==1:
            res = (res * a) % m
        a = (a*a) % m
        n = n//2
    return res

MOD = 10**9 + 7
n = int(input())
d = defaultdict(int)
for i in range(1,n+1):
    for r in primeFactors(i):
        d[r] += 1

res = 1
for k in d.keys():
    res *= (d[k]+1)
    res %= MOD
print(res)

Solution (Python):
def prime_factorization(N):
	'''
	return: [[2,3], [3,5]] (2^3 * 3^5)
	        [] if N==1
	O(sqrt{N}) (maybe)
	'''
	ans = []
	cnt=0
	while N%2==0:
		cnt+=1
		N//=2
	if cnt!=0:
		ans.append([2,cnt])

	f = 3
	while f*f<=N:
		cnt=0
		while N%f==0:
			N//=f
			cnt+=1
		if cnt!=0:
			ans.append([f,cnt])
		f+=2
	if N!=1:
		ans.append([N,1])
	return ans


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

for i in range(2,N+1):
	T = prime_factorization(i)
	for t in T:
		if t[0] not in d:
			d[t[0]] = t[1]
		else:
			d[t[0]] += t[1]
ans = 1
mod = 10**9+7
for i in d:
	ans = (ans*(d[i]+1))%mod

print(ans)

Solution (Python):
n = int(input())
s, ans, num = 1, 1, 2
for i in range(2, n+1):
  s *= i
l = []
while s != 1:
  if not s % num:
    l.append(num)
    s //= num
  else:
    num += 1
for i in set(l):
  ans *= l.count(i)+1
print(ans%(10**9+7))

Solution (Python):
import sys
input = sys.stdin.readline
MOD = 10**9 + 7


def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


N = int(input())
ans = 1
for prime in primes(N):
    count = 0
    for i in range(1, N + 1):
        while not i % prime:
            count += 1
            i /= prime

    ans *= (count + 1)

print(ans % MOD)

Solution (Python):
x = int(input())
p_list = {}


def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


for i in range(1,x+1):
  
  
  for k in prime_factors(i):
    p_list[k] = p_list.get(k, 0) + 1
    
    




divn = 1e9+7
ans = 1

for k in p_list.keys():
    ans *= p_list[k] + 1
    ans = ans % divn

print(int(ans))

Solution (Python):
import math
from collections import defaultdict

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

d = defaultdict(int)
d[1] = 0

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

ans = 1
for i in d.values():
    ans = (ans*(i+1)) % MOD
print(ans)

Solution (Python):

N=int(input())
MOD=10**9 + 7
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)
    return divisors
t=1
l=[]
x=dict()
ans=1
for i in range(1,N+1):
    t=t*i
    a=make_divisors(i)
    for j in range(len(a)):
        if a[j] in x:
            x[a[j]]=0
        else:
            x[a[j]]=0
for idx in x:
    a=make_divisors(idx)
    if len(a)==2:
        l.append(idx)


for i in range(1,N+1):
    n=i
    for j in range(len(l)):
        count=0
        while(1):
            if n%l[j]==0:
                n=n//l[j]
                count+=1
            else:
                break
        x[l[j]]+=count
for idx in x:
    if x[idx]!=0:
        ans=ans*(x[idx]+1)

ans=ans%MOD
print(ans)

Solution (Python):
import math

N = int(input())

d = {}

def primeFactor(n):
    for i in range(2, int(math.sqrt(n)) + 1):
        while n % i == 0:
            d[i] += 1
            n = n // i
    if n != 1:
        if n in d.keys():
            d[n] += 1
        else:
            d[n] = 1
    

ans = 1
mod = 10**9 + 7

for i in range(1, N + 1):
    primeFactor(i)

for v in d.values():
    ans *= (v + 1) 
    ans %= mod

print(ans)

Solution (Python):
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    N = int(input())
    mod = 1000000007

    if N == 1:
        print(1)
        exit()

    p = defaultdict(int)
    for i in range(1, N+1):
        d = 2
        j = int(i**0.5)
        while d <= j:
            while i % d == 0:
                p[d] += 1
                i //= d
            d += 1
        if i != 1:
            p[i] += 1

    ans = 1
    for k in p.values():
        ans = (ans * (k+1))%mod
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

n = int(input())
insu = []
for i in range(2, n+1):
  insu = insu + prime_decomposition(i)
insu_c = Counter(insu)

r = 1
mod = 10**9 + 7
for c in insu_c.values():
  r *= (c+1)
  r %= mod
print(r)

Solution (Python):
from collections import Counter
mod = 10**9+7
n = int(input())

li = []
def prime_factor(n):
    L = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            L.append(i)
            n = n//i
    if n != 1:
        L.append(n)
    return L

for i in range(2,n+1):
    li.extend(prime_factor(i))

L = Counter(li)
ans = 1
for k,v in L.items():
    ans *=(v+1)%mod
print(ans%mod)

Solution (Python):
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
x=int(input())
from collections import Counter
retl=[]
for i in range(1,x+1):
    tmp=prime_factorize(i)
    retl+=tmp
    
f=(Counter(retl))
ret=1
mod=10**9+7
for j in f.values():
    ret*=(j+1)
    ret%=mod
    
print(ret)

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

from collections import Counter
mod = 10**9+7
n = int(input())
f = 1
d = Counter()
div = {}
for i in range(2,n+1):
    a,b = make_divisors(i)
    c,e = Counter(), Counter()
    if a > 1:
        c.update({a:1} if a not in div else div[a])
    if b > 1:
        e.update({b:1} if b not in div else div[b])
    div[i] = c + e
    d.update(div[i])


ans = 1
for v in d.values():
    ans = ans * (v+1) % mod
print(ans)

Solution (Python):
from collections import defaultdict


def get_prime_factors(n):
    factors = []

    while n % 2 == 0:
        factors.append(2)
        n //= 2

    div = 3
    while n != 1:
        while n % div == 0:
            factors.append(div)
            n //= div
        div += 2

    return factors


N = int(input())
MOD = int(1e9 + 7)
primes = defaultdict(lambda: 0)
for i in range(1, 1 + N):
    for f in get_prime_factors(i):
        primes[f] += 1
ans = 1
for val in primes.values():
    ans *= val + 1
    ans %= MOD
print(ans)

Solution (Python):


N = int(input())

fact = {}
for i in range(1, N+1):
    tmp = i
    w = 2
    while tmp != 1:
        if tmp % w == 0:
            add = w
            tmp //= w
        elif w**2 > tmp:
            add = tmp
            tmp = 1
        else:
            w += 1
            continue
        if add in fact:
            fact[add] += 1
        else: fact[add] = 1
ans = 1
for k in fact.values():
    ans = ans*(k+1)%(10**9 + 7)
print(ans)