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):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
from collections import defaultdict
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)


def make_prime_list_2(num):
    if num < 2:
        return []

    
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]


def search_divisor_num_of_factorial_num(num):
    if num <= 0:
        return 0
    elif num == 1:
        return 1
    elif num == 2:
        return 2
    else:
        
        dict_counter = defaultdict(int)
        
        dict_memo = defaultdict(list)

        for a_num in range(2, num + 1):
            num_sqrt = math.ceil(math.sqrt(a_num))
            prime_list = make_prime_list_2(num_sqrt)

            
            now_num = a_num

            for prime in prime_list:
                while a_num % prime == 0:
                    
                    if a_num in dict_memo:
                        for memo in dict_memo[a_num]:
                            dict_counter[memo] += 1
                            dict_memo[now_num].append(memo)

                        a_num = 1

                    else:
                        dict_counter[prime] += 1
                        dict_memo[now_num].append(prime)
                        a_num //= prime

            if a_num != 1:
                dict_counter[a_num] += 1
                dict_memo[now_num].append(a_num)

        divisor_num = 1
        dict_fact = dict(dict_counter)
        for value in dict_fact.values():
            divisor_num *= (value + 1)

        return divisor_num
print(search_divisor_num_of_factorial_num(_I())%mod)

Solution (Python):
import math

N = int(input())

def prime(n):
    if n <=1:return []
    primes = [i for i in range(n+1)]
    primes[1] = 0
    for i in primes:
        if i == 0:continue
        if i > math.sqrt(n):break
        for j in range(2*i, n+1, i):primes[j]=0
            
    return [prime for prime in primes if prime!=0]

cnt =[0]*N

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

cnts =1
for l in cnt:
    if l>0:cnts*=l+1
      
print(cnts%(10**9+7))

Solution (Python):


import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def primes(n):
    ps = []
    i = 2
    while i * i <= n:
        while n % i == 0:
            ps.append(i)
            n //= i
        i += 1
    if n > 1:
        ps.append(n)
    return ps


def main():
    n = int(input())
    pl = []
    for i in range(1,n+1):
        pl += primes(i)

    counter = Counter(pl)
    
    ans = 1
    for v in counter.values():
        ans *= (v + 1)
        ans %= 1000000007
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
MOD = 10 ** 9 + 7
x = 1
for i in range(2, N + 1):
  x *= i

count = 1
ans = 1
for i in range(2, N + 1):
  if x % i != 0:
    continue
  count = 1
  while x % i == 0:
    x //= i
    count += 1
  ans *= count
print(ans % MOD)

Solution (Python):
N = int(input())
ps = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 }
bs = []
for n in range(1, N+1):
  a = n
  while a > 1:
    prime = True
    for p in ps:
      if a%p == 0:
        prime = False
        bs.append(p)
        a = a//p
    if prime:
      bs.append(a)
      a = 1

ps2 = set(bs)
r = 1
for p in ps2:
  c = bs.count(p)
  r = r*(c+1)%1000000007
print(r)

Solution (Python):
N = int(input())
es = [0] * 1001
ans = 1

def div(n):
    b = 2
    while b <= n:
        while n%b==0:
            n //= b
            es[b] += 1
        b += 1

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

for e in es:
    ans *= e + 1
    ans %= 10**9+7
print(ans)

Solution (Python):

n = int(input())

histogram = [0] * (n + 1)
for i in range(2,n+1):
    x = i
    p = 2
    while x > 1:
        while x % p == 0:
            histogram[p] += 1
            x //= p
        p += 1
answer = 1
for a in filter(lambda x:x>0,histogram):
    answer = (answer * (a+1)) % (1e9+7)
print(int(answer))

Solution (Python):
p=[2];A=1000
for L in range(3,A):
    chk=True
    for L2 in p:
        if L%L2 == 0:chk=False
    if chk==True:p.append(L)
n = int(input())
ll = [[0]*len(p) for _ in [0]*(n+1)]
for i in range(1,n+1):
  for j in range(len(p)):
    ll[i][j] = ll[i-1][j]
    tmp = i
    while True:
      if tmp%p[j] == 0:
        ll[i][j] += 1
        tmp = tmp//p[j]
      else:
        break
ans = 1
for i in ll[-1]:
  ans*=(i+1)
print(ans%(10**9+7))

Solution (Python):
from collections import defaultdict

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

primeCount = defaultdict(int)

def primeList(n):
    p = 2
    primeList = defaultdict(int)
    while n > 1:
        if n % p == 0:
            while n % p == 0:
                primeList[p] += 1
                n //= p
        p += 1
    if n >= 2:
        primeList[n] = 1
    return primeList

for i in range(1, N + 1):
    for prime, count in primeList(i).items():
        primeCount[prime] += count

ans = 1
for _, count in primeCount.items():
    ans *= (count + 1)
    ans %= MOD

print(ans)

Solution (Python):
n = int(input())

v = [2]
for i in range(3,n+1):
    sosu = True
    for j in v:
        if i%j == 0:
            sosu = False
    if sosu:
        v.append(i)


ans = 1
for j in v:
    count = 0
    for i in range(1,n+1):
        while i%j == 0:
            count += 1
            i= i//j
    ans = (ans * (count+1))%(10**9+7)
print(ans)

Solution (Python):
import collections
n = int(input())
ls = []
for i in range(2, n + 1):
    t = i
    for j in range(2, i + 1):
        while True:
            if t % j == 0:
                t //= j
                ls.append(j)
            else:
                break
ls = collections.Counter(ls)
cnt = 1
for i in ls.values():
    cnt *= ((i + 1) % (10 ** 9 + 7))
print(cnt % (10 ** 9 + 7))

Solution (Python):
from collections import Counter

MOD = 10**9 + 7
N = int(input())
count = Counter()
ans = 1
num = []

for i in range(2, N+1):
    
    for n in num:
        while not i % n:
            count[n] += 1
            i //= n
        if i == 1:
            break
    else:
        num.append(i)
        count[i] = 1
        
for n in count.values():
    ans = ans * (n+1) % MOD
print(ans)

Solution (Python):
n = int(input())
mod = 10**9+7
prime = [1 for _ in range(1000)]
for i in range(1,n+1):
  now = i
  div = 2
  while now > 1:
    if now % div == 0:
      now //= div
      prime[div-1] += 1
    else:
      div += 1
ans = 1
for i in range(n):
  ans *= prime[i]
  ans %= mod
print(ans)

Solution (Python):

import collections
import itertools
import sys
import time

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

def get_primes(max_val):
    is_prime = [True] * (max_val + 1)
    for i in range(2, max_val+1):
        if not is_prime[i] or i * i > max_val:
            continue
        for j in range(i*i, max_val+1, i):
            is_prime[j] = False
    res = []
    for i in range(2, len(is_prime)):
        if is_prime[i]:
            res.append(i)
    return res

def get_prime_factor(n, primes):
    if n == 1:
        return (1, 1)
    res = []
    for p in primes:
        if p * p > n:
            break
        c = 0
        while not n % p:
            n //= p
            c += 1
        if c:
            res.append((p, c))
    if n != 1:
        res.append((n, 1))
    return res

primes = get_primes(1000000)

n=getint()
if n == 1:
    print("1")
    sys.exit(0)

factors = collections.defaultdict(int)
for i in range(2,n+1):
    tmp = get_prime_factor(i,primes)
    for p, c in tmp:
        factors[p] += c

res = 1
for p,c in factors.items():
    res *= c + 1
    res %= 10**9+7

print(res)

Solution (Python):
import math

def is_prime(n):
  if n == 1:
    return False

  for i in range(2, int(math.sqrt(n)) + 1):
    if n % i == 0:
      return False
  return True

N = int(input())

pn_l = []
for i in range(2, N + 1):
  if is_prime(i):
    pn_l.append(i)

ans = 1
n_factorial = math.factorial(N)
for pn in reversed(pn_l):
  s = 0
  while n_factorial % pn == 0:
    s += 1
    n_factorial //= pn
  ans *= s + 1 
print(ans % (10**9+7))

Solution (Python):
N = int(input())
p = 1
for i in range(2, N + 1):
    p *= i
ans = 1
for i in range(2, N + 1):
    if p % i != 0:
        continue
    c = 1
    while p % i == 0:
        p //= i
        c += 1
    ans *= c
print(ans % 1000000007)

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):
n = int(input())
mod = 10**9 + 7
divisor = [[i,0] for i in range(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

for i in range(2,n+1):
    lst = factorization(i)
    for l in lst:
        divisor[l[0]][1] += l[1]

ans = 1
for d in divisor:
    if d[1] != 0:
        ans *= (d[1] + 1)
        ans %= mod
print(ans)

Solution (Python):
def factor(n):
    for i in range(2, n+1):
        if n % i == 0:
            l = factor(n // i)
            l.append(i)
            return l
    return []

from collections import Counter
N = int(input())
c = Counter()
for i in range(1, N+1):
    c += Counter(factor(i))
p = 1
for _, i in c.items():
    p *= (i+1)
    p %= 1000000007
print(p)

Solution (Python):

import sys, math, fractions, itertools

MOD = 1000000007  

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def solve(N: int):
    primes = [n for n in range(1, N+1) if is_prime(n)]
    counter = [0] * len(primes)
    for n in range(2, N+1):
        for i, p in enumerate(primes):
            mod = 0
            c = 0
            r = n
            while(mod == 0):
                mod = r % p
                r /= p
                if mod == 0:
                    c += 1
            counter[i] += c
    res = 1
    for c in counter:
        res *= (c+1)
        res %= MOD
    print(res)
    return 



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):
N = int(input())
p_numbers = [2]
p_dict = {}
for num in range(3, N+1):
  is_prime = True
  for p_num in p_numbers:
    if num%p_num == 0:
      is_prime = False
      break
  if is_prime:
    p_numbers.append(num)
for num in range(1, N+1):
  for prime in p_numbers:
    div = num
    while True:
      if div%prime == 0:
        if prime in p_dict:
          p_dict[prime] += 1
        else:
          p_dict[prime] = 1
      else:
        break
      div = div//prime
ans = 1
for value in p_dict.values():
  ans *= (value+1)
print(ans%(10**9+7))

Solution (Python):
from sys import stdin
from math import sqrt
from collections import defaultdict

MOD = 1000000007
def is_prime(x):
    if x == 2:
        return True

    if x < 2 or x % 2 == 0:
        return False

    i = 3
    while i <= sqrt(x):
        if x % i == 0:
            return False
        i = i + 2
    
    return True


N = int(stdin.readline().rstrip())
primes = []
for i in range(2, N+1):
    if is_prime(i):
        primes.append(i)

dic = defaultdict()
for i in primes:
    dic[i] = 0

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

ans = 1
for i in primes:
    ans *= (1+dic[i])

print(ans % MOD)

Solution (Python):
n = int(input())
p = 10**9+7
cnt = [0 for i in range(n+1)]


def cnt_factor(n):
    i = 2
    k = n
    while i <= n:
        if k % i == 0:
            k = k // i
            cnt[i] += 1
        else:
            i += 1

for i in range(2, n+1):
    cnt_factor(i)


ans = 1
for i in range(2, n+1):
    ans *= (cnt[i]+1) % p

print(ans % p)

Solution (Python):
import math
N = int(input())
plist = [2]
for i in range(3, N + 1):
    for prime in plist:
        if i % prime == 0:
            break
    else:
        plist.append(i)
ans = 1
for prime in plist:
    s = 0
    for i in range(1, int(math.log(N, prime)) + 1):
        s += N // (prime ** i)
    ans = ans * (s + 1) % (10 ** 9 + 7)
print(ans)

Solution (Python):
import math

N = int(input())
mod = int(1E9+7)

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

def main():
    P = [0 for _ in range(N+1)]
    for n in range(2, N+1):
        A = prime(n)
        for a in A:
            P[a] += 1

    ans = 1
    for p in P:
        ans =  ans * (p+1) % mod

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
import math
n=int(input())
l=[2]
for i in range(3,n+1):
    for p in l:
        if i%p==0:break
    else: l.append(i)
a=1
for p in l:
    s=0
    for i in range(1,int(math.log(n,p))+1):
        s+=n//p**i
    a=a*(s+1)%(10**9+7)
print(a)

Solution (Python):
import math

n = int(input())

prime_n = [2]

for i in range(3,n+1,2):
    if all( i % prime != 0 for prime in prime_n):
        prime_n.append(i)

multiply = []

for i in prime_n:
    k = 1
    temp = 0
    while i**k <= n:
        temp += math.floor(n/(i**k))
        k+=1
    
    multiply.append(temp)

ans = 1

for i in multiply:
    ans*=(i+1)
    ans%=((10**9)+7)

print(ans)

Solution (Python):

from collections import defaultdict
import sys

def soinsuu(soinsuu_dic, num):
    for i in range(2, int(num ** 0.5) + 1):
        while num % i == 0:
            num //= i
            soinsuu_dic[i] += 1
    if num > 1:
        soinsuu_dic[num] += 1
    return soinsuu_dic

def main():
    num = int(input())
    soinsuu_dic = defaultdict(int)

    for i in range(2, num + 1):
        soinsuu_dic = soinsuu(soinsuu_dic, i)


    ans = 1
    mod = 10 ** 9 + 7
    for ele, value in soinsuu_dic.items():
        ans *= value + 1
        ans %= mod

    print(ans)




if __name__ == '__main__':
    main()

Solution (Python):
from functools import reduce
N = int(input())
g = 10 ** 9 + 7


def mul(a, b):
  return (a * b) % g

d = []
DP = [None for _ in range(N+1)]
DP[0] = [0 for _ in range(N+1)]
ans = DP[0].copy()
for i in range(2, N+1):
  for j in (x for x in d if x * x <= N):
    if i % j == 0:
      DP[i] = DP[j].copy()
      for k in range(1, N+1):
          DP[i][k] += DP[i//j][k]
      break
  else:
    d.append(i)
    DP[i] = DP[0].copy()
    DP[i][i] = 1
  for k in range(1, N+1):
      ans[k] += DP[i][k]

print(reduce(mul, [x + 1 for x in ans[1:N+1]]))

Solution (Python):
from functools import reduce
N = int(input())
g = 10 ** 9 + 7


def mul(a, b):
  return (a * b) % g

def adda(a, p1, p2):
    for x in range(len(a)):
        a[x] = p1[x] + p2[x]

d = []
DP = [[0 for _ in range(N+1)] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]
for i in range(2, N+1):
  for j in (x for x in d if x * x <= N):
    if i % j == 0:
      adda(DP[i], DP[j], DP[i//j])
      break
  else:
    d.append(i)
    DP[i][i] = 1
  adda(ans, ans, DP[i])

print(reduce(mul, [x + 1 for x in ans[1:N+1]]))

Solution (Python):
from functools import reduce
N = int(input())
g = 10 ** 9 + 7


def mul(a, b):
  return (a * b) % g

def adda(a, p1, p2):
    for x in range(len(a)):
        a[x] = p1[x] + p2[x]

d = []
DP = [[0 for _ in range(N+1)] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]
for i in range(2, N+1):
  for j in (x for x in d if x * x <= N):
    if i % j == 0:
      adda(DP[i], DP[j], DP[i//j])
      break
  else:
    d.append(i)
    DP[i][i] = 1
  adda(ans, ans, DP[i])

print(reduce(mul, [x + 1 for x in ans[1:N+1]]))

Solution (Python):
from functools import reduce
N = int(input())
g = 10 ** 9 + 7

def add(a, b):
  return (a + b) % g
def mul(a, b):
  return (a * b) % g

def adda(a, p1, p2):
    for x in range(len(a)):
        a[x] = add(p1[x], p2[x])

d = []
DP = [[0 for _ in range(N+1)] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]
for i in range(2, N+1):
  for j in (x for x in d if x * x <= N):
    if i % j == 0:
      adda(DP[i], DP[j], DP[i//j])
      break
  else:
    d.append(i)
    DP[i][i] = 1
  adda(ans, ans, DP[i])

print(reduce(mul, [x + 1 for x in ans[1:N+1]]))

Solution (Python):
from functools import reduce
N = int(input())
g = 10 ** 9 + 7

def add(a, b):
  return (a + b) % g
def mul(a, b):
  return (a * b) % g

def adda(a, p1, p2):
    for x in range(len(a)):
        a[x] = add(p1[x], p2[x])

d = []
DP = [[0 for _ in range(N+1)] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]
for i in range(2, N+1):
  for j in (x for x in d if x * x <= N):
    if i % j == 0:
      adda(DP[i], DP[j], DP[i//j])
      break
  else:
    d.append(i)
    DP[i][i] = 1
  adda(ans, ans, DP[i])

print(reduce(mul, [x + 1 for x in ans[1:N+1]]))

Solution (Python):
import math
N = int(input())
Nfact = math.factorial(N)
ans = 1
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
c = factorize(Nfact)
for a,b in c:
  ans *= b+1
print(ans%(10**9+7))

Solution (Python):
n = int(input())
mod = 10 ** 9 + 7
def prime(n):
    number = [i+2 for i in range(n-1)]
    while len(number) > 0:
        yield min(number)
        number = [x for x in number if x % min(number) != 0]

prime_number = []
for i in prime(n):
    prime_number.append(i)
prime_factor = {}
for i in prime_number:
    prime_factor[i] = 0

for i in range(1, n + 1):
    for j in prime_number:
        if i == 1:
            break
        else:
            while i % j == 0:
                i //= j
                prime_factor[j] += 1
num = 1
for i in prime_factor.values():
    num *= i + 1
    num %= mod
print(num)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b, c, d = LI()
    print(max(a * b, c * d))
    return


def B():
    _ = II()
    s = S()
    d = {}
    d["I"] = 1
    d["D"] = -1
    ans = 0
    now = 0
    for i in s:
        now += d[i]
        ans = max(ans, now)
    print(ans)
    return


def C():
    def primes2(n):
        """https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n/3035188
        """ Returns  a list of primes < n """
        sieve = [True] * (n//2)
        for i in range(3,int(n**0.5)+1,2):
            if sieve[i//2]:
                sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)
        return [2] + [2*i+1 for i in range(1,n//2) if sieve[i]]
    n = II()
    prime = primes2(n+1)
    d = []
    for i in prime:
        b = n
        f = 0
        while b:
            b = b // i
            f += b
        d.append(f%mod)
    ans = 1
    for i in d:
        ans *= (i + 1)
        ans %= mod
    print(ans)
    return


def D():
    return


if __name__ == '__main__':
    C()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, b, c, d = LI()
    print(max(a * b, c * d))
    return


def B():
    _ = II()
    s = S()
    d = {}
    d["I"] = 1
    d["D"] = -1
    ans = 0
    now = 0
    for i in s:
        now += d[i]
        ans = max(ans, now)
    print(ans)
    return


def C():
    def primes2(n):
        """https://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n/3035188
        """ Returns  a list of primes < n """
        sieve = [True] * (n//2)
        for i in range(3,int(n**0.5)+1,2):
            if sieve[i//2]:
                sieve[i*i//2::i] = [False] * ((n-i*i-1)//(2*i)+1)
        return [2] + [2*i+1 for i in range(1,n//2) if sieve[i]]
    n = II()
    prime = primes2(n+1)
    d = defaultdict(int)
    for i in prime:
        b = n
        while b:
            b = b // i
            d[i] += b
            d[i] %= mod
    ans = 1
    for i in d.values():
        ans *= (i + 1)
        ans %= mod
    print(ans)
    return


def D():
    return


if __name__ == '__main__':
    C()

Solution (Python):
import math
import collections

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)
    
    factor.append(n)
    return factor

n = int(input())
c = collections.Counter([])
for num in range(2, n+1):
  prime_list = trial_division(num)
  c.update(prime_list)
res = 1
for prime, count in c.most_common():
  if(prime > 1):
    res = res * (count + 1)
print(res % (pow(10,9) + 7))

Solution (Python):
def main():
    n=int(input())
    a=[0]*(n+1)
    ans=1
    for i in range(1,n+1):
        num=i
        for j in range(2,i+1):
            if num%j==0:
                while num>1 and num%j==0:
                    num//=j
                    a[j]+=1

    for i in a:
        ans=ans*(i+1)%(10**9+7)
    print(ans)
    return

main()

Solution (Python):

import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  

def solve(N: int):
    elms = [0] * (N + 1)
    for i in range(2, N + 1):
        tmp = i
        j = 2
        while j <= i:
            while tmp % j == 0:
                elms[j] += 1
                tmp //= j
            j += 1
    ret = 1
    for e in elms:
        if e > 0:
            ret *= e + 1
            ret %= MOD
    print(ret)
    return


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 sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())

exp_list = [0]*1010

def prime_factorize(N): 
    exponent = 0
    while N%2 == 0:
        exponent+=1
        N //= 2
    if exponent: factorization = [[2,exponent]]
    else: factorization = []
    i=1
    while i*i <=N:
        i += 2
        if N%i != 0: continue
        exponent = 0
        while N%i == 0:
            exponent+=1
            N //= i
        factorization.append([i,exponent])
    if N!= 1: factorization.append([N,1])
    assert N != 0, "zero"
    for p,e in factorization:
        exp_list[p] += e

for i in range(2,n+1):
    prime_factorize(i)


MOD = 10**9+7
ans = 1
for i in exp_list:
    ans *= i+1
    ans %= MOD
print(ans)

Solution (Python):
def c_factors_of_factorial(N, MOD=10**9 + 7):
    from math import factorial
    from functools import reduce
    from operator import mul
    from collections import defaultdict

    def prime_factorization(n):
        if n == 1:
            return {2: 0}  
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table

    ans = reduce(mul, [v + 1 for v in prime_factorization(factorial(N)).values()])
    return ans % MOD

N = int(input())
print(c_factors_of_factorial(N))

Solution (Python):



from decimal import Decimal
import math
from collections import defaultdict

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


def prime(num):
    if n < 2:
        return []
    p_l = [i for i in range(num+1)]
    p_l[1] = 0
    num_s = math.sqrt(num)

    for p in p_l:
        if p == 0:
            continue
        if p > num_s:
            break

        for np in range(2*p,num,p):
            p_l[np] = 0

    return [p for p in p_l if p != 0]

def make(num):
    if num <= 1:
        return False
    else:
        num_s = math.floor(math.sqrt(num))
        p_l = prime(num_s)

        dict_counter = defaultdict(int)
        for p in p_l:
            while num % p == 0:
                dict_counter[p] += 1
                num //= p
        if num != 1:
            dict_counter[num] += 1

        dict_counter = dict(dict_counter)

        return dict_counter

if n == 1:
    print(1)
    quit()

sum = [0]*n
for i in range(2,n+1):
    x = list(make(i).items())
    for j,k in x:
        sum[j-1] += k

ans = 1
for i in sum:
    if i > 0:
        ans *= (i+1)
print(ans % mod)

Solution (Python):
def c_factors_of_factorial(N, MOD=10**9 + 7):
    from math import factorial
    from functools import reduce
    from operator import mul
    from collections import defaultdict

    def prime_factorization(n):
        if n == 1:
            return {2: 0}  
        i, table = 2, defaultdict(int)
        while i**2 <= n:
            while n % i == 0:
                table[i] += 1
                n //= i
            i += 1
        if n > 1:
            table[n] = 1
        return table

    ans = reduce(mul, [v + 1 for v in prime_factorization(factorial(N)).values()])
    return ans % MOD

N = int(input())
print(c_factors_of_factorial(N))

Solution (Python):
import sys
import numpy as np
n=int(input())
mod=10**9+7
if n==1:print(1);sys.exit()
def searchPrimeNum(N):
    max = int(np.sqrt(N))
    searchList = [i for i in range(2,N+1)]
    primeNum = []
    while searchList[0] <= max:
        primeNum.append(searchList[0])
        tmp = searchList[0]
        searchList = [i for i in searchList if i % tmp != 0]
    primeNum.extend(searchList)
    return primeNum
l=len(searchPrimeNum(n))
plist=searchPrimeNum(n)
cnt=[0]*l
for i in range(l):
  k=1 
  while plist[i]**k<=n:
    cnt[i]+=n//(plist[i]**k)
    k+=1
ans=1
for i in cnt:
  ans=(ans*(i+1))%mod
print(ans)

Solution (Python):
N = int(input())
y = [0]*(N+1)
for i in range(1,N+1):
    M = i
    while M > 1:
        for j in range(2,M+1):
            if M%j == 0:
                M = M//j
                y[j] += 1
                break
ans = 1
for i in y:
    ans = (ans*(i+1))%(10**9+7)
print(ans)

Solution (Python):
primes = {
    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}


def split_primes(x: int) -> int:
    """
    x <= 1000 (10^3)
    """
    if x in primes:
        return {x: 1}

    exp_dict = {}
    while x != 1:
        for prime in primes:
            if prime not in exp_dict:
                exp_dict[prime] = 0
            if x % prime == 0:
                exp_dict[prime] = exp_dict[prime] + 1
                x = int(x / prime)
                break
    return exp_dict


def main():
    N = int(input())
    mod_target = 10 ** 9 + 7

    exp_dict = {}
    for i in range(2, N + 1):
        n_exp = split_primes(i)
        for new_exp in n_exp:
            exp_dict[new_exp] = n_exp[new_exp] + (
                exp_dict[new_exp] if (new_exp in exp_dict) else 0
            )
    count = 1
    for key in exp_dict:
        count = (count * (exp_dict[key] + 1)) % mod_target
    print(count)


if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())

mul_num = [1]*(N+1)

for i in range(N,2,-1):
    
    for j in range(2,i):
        if i%j==0:
            mul_num[int(i/j)] += mul_num[i]
            mul_num[j] += mul_num[i]
            mul_num[i] =0


ans=1
for i in mul_num[2:]:
    if i>0:
      ans *= (i+1)
print(ans%(10**9+7))