Problem:


Score : 400 points

Problem Statement

Given is a positive integer N. Consider repeatedly applying the operation below on N:

First, choose a positive integer z satisfying all of the conditions below:

z can be represented as z=p^e, where p is a prime number and e is a positive integer;

z divides N;

z is different from all integers chosen in previous operations.

Then, replace N with N/z.

Find the maximum number of times the operation can be applied.

Constraints

All values in input are integers.

1 \leq N \leq 10^{12}

Input

Input is given from Standard Input in the following format:

N

Output

Print the maximum number of times the operation can be applied.

Sample Input 1

24

Sample Output 1

3

We can apply the operation three times by, for example, making the following choices:

Choose z=2 (=2^1). (Now we have N=12.)

Choose z=3 (=3^1). (Now we have N=4.)

Choose z=4 (=2^2). (Now we have N=1.)

Sample Input 2

1

Sample Output 2

0

We cannot apply the operation at all.

Sample Input 3

64

Sample Output 3

3

We can apply the operation three times by, for example, making the following choices:

Choose z=2 (=2^1). (Now we have N=32.)

Choose z=4 (=2^2). (Now we have N=8.)

Choose z=8 (=2^3). (Now we have N=1.)

Sample Input 4

1000000007

Sample Output 4

1

We can apply the operation once by, for example, making the following choice:

z=1000000007 (=1000000007^1). (Now we have N=1.)

Sample Input 5

997764507000

Sample Output 5

7



Sample input:
24


Sample output:
3

Submission status: Time Limit Exceeded

Solution code:
from math import trunc
n = int(input())
ans = 0
for i in range(2, n+1):
    if n % i == 0:
        x = 0
        while n % i == 0:
            n //= i
            x += 1
        ans += trunc((-1+(8*x+1)**0.5)/2)
        if n == 1:
            break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def INT():
    return int(input())

def MI():
    return map(int, input().split())

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

from math import sqrt

N = INT()
tmp = N
fact = {}
is_prime = True

for n in range(2, int(sqrt(N)) + 1):
    if tmp == 1:
        break
    
    e = 0
    while 1:
        if tmp % n != 0:
            break
        tmp //= n
        e += 1
    
    if e == 0:
        continue

    fact[n] = e

if tmp != 1:
    
    fact[tmp] = 1

if fact == {}:
    fact[N] = 1

ans = 0

for p in fact.keys():
    e = 1
    z = p**e
    
    while 1:
        if N % z != 0:
            break
        N //= z
        e += 1
        z = pow(p, e)
        ans += 1
        
    if N == 1:
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

ans =0
for i in range(2,int(n**0.5)+5):
    cnt = 0
    while n%i==0:
        n//=i
        cnt += 1
        s=0
    while cnt:
        s +=1
        cnt -= s
        ans += 1
if n!=1:ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input(""))
s=0
i=1
while(n>i):
    
    i+=1
    if (n%i!=0):
        continue
    t=0
    while(n%i==0):
        n/=i
        t+=1
    k=1
    while(t>=k):
    
        t-=k
        s+=1
        k+=1

print(s)

Submission status: Time Limit Exceeded

Solution code:
n=int(input(""))
s=0
i=1
while(n>i):
    if (i==1 or i==2):
        i-=1
    i+=2
    t=0
    while(n%i==0):
        n/=i
        t+=1
    k=1
    while(t>=k):
    
        t-=k
        s+=1
        k+=1

print(s)

Submission status: Time Limit Exceeded

Solution code:
n=int(input(""))
s=0
i=1
while(n>i):
    i+=1
    t=0
    while(n%i==0):
        n/=i
        t+=1
    k=1
    while(t>=k):
    
        t-=k
        s+=1
        k+=1

print(s)

Submission status: Time Limit Exceeded

Solution code:
import math
a=int(input())
b=[]
ans=0
for i in range(2,a,1):
  cnt=0
  if a%i==0:
    while a%i==0:
      cnt+=1
      a=a/i
    ans+=(math.sqrt(2*cnt+0.25)-0.5)//1
  else:
    pass
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
import math
a=int(input())
b=[]
ans=0
for i in range(2,a,1):
  cnt=0
  if a%i==0:
    while a%i==0:
      cnt+=1
      a=a/i
    ans+=(math.sqrt(2*cnt+0.25)-0.5)//1
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
import math
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

s=dict(Counter(prime_factorize(n)))
#print(s)
sum_ans=0
for i in s.values():
  
  if i==1:
    sum_ans+=1
    
  else:
    k=1
    while i:
      i-=k
      k+=1
      #print(i)
      sum_ans+=1
      
print(sum_ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

def pf(n):
    sn = int(math.sqrt(n)) + 1
    ps = []
    for i in range(1, sn):
        if (n%i)==0:
            ps.append(i)
            ps.append(int(n/i))
    del ps[0]
    return ps        

n = int(input())
ps = []
num = pf(n)
for i in num:
    if is_prime(i):
        ps.append(i)
        
zs = []        
for p in ps:
    z = p
    while(z<=n):
        zs.append(z)
        z *= p
zs.sort()

cnt = 0
for z in zs:
    if(n>1):
        if(n%z==0):
            n /= z
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import math

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

def pf(n):
    sn = int(math.sqrt(n)) + 1
    ps = []
    for i in range(1, sn):
        if (n%i)==0:
            ps.append(i)
            ps.append(int(n/i))
    del ps[0]
    return ps        

n = int(input())
ps = []
num = pf(n)
for i in num:
    if is_prime(i):
        ps.append(i)
        
zs = []        
for p in ps:
    z = p
    while(z<=n):
        zs.append(z)
        z *= p
zs.sort()
cnt = 0
for z in zs:
    if(n>1):
        if(n%z==0):
            n /= z
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d={}
for k in range(2,10**6):
  while n%k<1: n//k; d[k]=d.get(k,0)+1
a=0
for i in d.values():
  t=c=0
  while t+c<i: c+=1; t+=c
  a+=c
print(a+(n>1))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
d={}
for k in range(2, 10**6):
  while n%k<1: n//k; d[k]=d.get(k, 0)+1
a=0
for i in d.values():
  t=c=0
  while t+c<i: c+=1; t+=c
  a+=c
print(a+(n>1))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
c = 0
for i in range(2, n+1):
    if n %i ==0:
        c += 1
        n //=i
print(c)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ans=0
for s in range(2,10*12):
 while n>0:
  if  n%s==0:
    n=n/s
    s=s*s
    ans+=1
  else:
    s=s+2

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
from collections import defaultdict

N = int(input())
dic = defaultdict(int)

def func(N):
  if N == 1:
    return 1
  
  for i in range(2, N+1):
    if N % i == 0:
      N = N // i
      dic[i] += 1
      return func(N)

func(N)

def func2(k):
  n = 1
  count = 1
  while count * (count+1) // 2 <= k:
    count += 1
  return count-1

res = 0

for value in dic.values():
  if value > 0:
    res += func2(value)

print(res)

Submission status: Time Limit Exceeded

Solution code:
#Div Game
N  = int(input())

def factorization(n):
    ans = []
    count = 0
    while n%2 == 0 :
        count += 1
        n /= 2
    if count!=0:
        ans.append([2, count])

    prime = 3
    while prime<=n:
        count = 0
        while n%prime == 0 :
            count += 1
            n /= prime
        if count !=0 :
            ans.append([prime, count])
        prime += 2
    return ans

fact_N = factorization(N)
Ans = 0
for i in fact_N:
    count = 1
    while count <= i[1]:
        i[1] -= count
        count += 1
    Ans += count-1

print(Ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def pcheck(n):
    if n == 1:
        return False
    else:
        root = int(n ** 0.5)
        for i in range(2, root + 1):
            if n % i == 0:
                return False
        return True

if n == 1:
    print('0')
elif pcheck(n) == True:
    print('1')
else:
    rootn = int(n ** 0.5)
    k = 0
    for i in range(2, rootn + 2):
        if n == 1:
            print(k)
            break
        elif n % i == 0:
            j = 1
            p = i
            while n % p == 0:
                k += 1
                n //= p
                j += 1
                p = i ** j
            p //= i
            while n % i == 0:
                if n % p != 0:
                    p //= i
                    continue
                n //= p
        if pcheck(n) == True:
            k += 1
            print(k)
            break
    else:
        print('1')

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

def pcheck(n):
    if n == 1:
        return False
    else:
        root = int(n ** 0.5)
        for i in range(2, root + 1):
            if n % i == 0:
                return False
        return True

if n == 1:
    print('0')
else:
    rootn = int(n ** 0.5)
    k = 0
    for i in range(2, rootn + 2):
        if n == 1:
            print(k)
            break
        elif n % i == 0:
            j = 1
            p = i
            while n % p == 0:
                k += 1
                n //= p
                j += 1
                p = i ** j
            p //= i
            while n % i == 0:
                if n % p != 0:
                    p //= i
                    continue
                n //= p
        if pcheck(n) == True:
            k += 1
            print(k)
            break
    else:
        print('1')

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
n=N
p=2
dcmp={}
while n>1:
    if n%p==0:
        dcmp[p]=1+(dcmp[p] if p in dcmp else 0)
    else:
        p+=1
cnt=0
for k,v in dcmp.items():
    i=1
    while True:
        dcmp[k]-=i
        if dcmp[k]<0:
            break
        i+=1
        cnt+=1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt

n = int(input())

if n == 1:
    print(0)

n_sqrt = int(sqrt(n))

dp = [-1] * (n_sqrt+2)

for i in range(2, n_sqrt+2):
    if dp[i] == -1:
        dp[i] = 1
        for j in range(i*2, n_sqrt+2, i):
            dp[j] = 0

prime = []

for i in range(2, n_sqrt+2):
    if dp[i] == 1:
        prime.append(i)

prime.append(n)

memo = []
for p in prime:
    cnt = 0
    while n%p==0:
        n //= p
        cnt += 1

    if cnt:
        memo.append(cnt)

if n > 1:
    memo.append(1)

ans = 0

for j in memo:
    k = 1
    while True:

        if k*(k+1)//2 <= j <= k*(k+3)//2:
            ans += k
            break
        k += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

n = int(input())
b = 0
if n == 1:
    print(0)
    sys.exit()
for a in range(2,int(n /2)+1):
    if n % a == 0:
        b = b+1
        n = n/a
if b == 0:
    b =1
print(b)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
b = 0
for a in range(2,n):
    if n % a == 0:
        b = b+1
        n = n/a
print(b)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())

def factorint(N):
    """
    Nを作っている素数を辞書で返す．
    input 100
    output Counter({2: 2, 5: 2})
    """
    table = []
    tmp = 2
    while(N > 1):
        for i in range(tmp,N+1):
            if N%i == 0:
                while N%i == 0:
                    N = N//i
                    table.append(i)
                tmp = i+1
                break
    table_ = collections.Counter(table)
    return table_

factors = factorint(N)
ans = 0

for key in factors.keys():
    f_c = factors[key]
    tmp = 1
    while f_c >= tmp:
        ans += 1
        f_c -= tmp
        tmp += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0

    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

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

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

n = int(input())
if n==1:
    print(0)
elif is_prime(n):
    print(1)
else:
    cnt = 0
    for i in range(2, n):
        if is_prime(i):
            c = 1
            while n%pow(i,c)==0:
                n /= pow(i,c)
                cnt += 1
                c += 1
        if n < i:
            break
    print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# D - Div Game
from collections import deque

def pf(N):
    ans = deque([])
    p = 2
    while N>1:
        if N%p==0:
            k = 0
            while N%p==0:
                N //= p
                k += 1
            ans.append(k)
        p += 1+(p>2)
    return ans

def func(a):
    tmp = 0
    while True:
        a -= tmp+1
        if a<0:
            return tmp
        else:
            tmp += 1

N = int(input())
ans = 0
l = pf(N)
while len(l)>0:
    ans += func(l.popleft())
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
c = 0
i = 0
for p in range(2, n): #nが合成数
  if n%p == 0:
    c += 1
    n /= p
    i += 1
if n != 1 and i == 0: #nが素数
  c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
from math import sqrt
n = int(input())

import math
import random
from itertools import permutations, combinations

class Prime:
    seed_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]

    def is_prime(self, n):
        """
        prime test (hybrid)

        see also: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_brute_force(n)
        else:
            return self.is_prime_miller_rabin(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

    def is_prime_brute_force(self, n):
        """
        brute force prime test
        use with is_prime_common if you want to skip seed_primes

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

    def is_prime_miller_rabin(self, n):
        """
        miller rabin prime test
        use with is_prime_common if you want to skip seed_primes

        see also
            algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
            implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
            improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """

        d = n - 1
        while d & 1 == 0:
            d >>= 1

        # use one of these lines / upper is more efficient.
        witnesses = self.get_witnesses(n)
        # witnesses = [random.randint(1, n - 1) for _ in range(100)]

        for w in witnesses:
            y = pow(w, d, n)

            while d != n - 1 and y != 1 and y != n - 1:
                y = (y * y) % n
                d <<= 1

            if y != n - 1 and d & 1 == 0:
                return False

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 3825123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        """
        pseudo prime generator
        :param x:
        :param n:
        :param seed:
        :return: pseudo prime
        """
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        """
        find one of factor of n
        this function is based to Pollard's rho algorithm

        see also
            algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
            implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98

        :param n:
        :param seed:
        :return: factor
        """
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

        while n > 1:
            factor = self.find_factor(n)

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes


prime = Prime()
fact_dict = prime.find_factors(n)
cnt = 0
for k in fact_dict.values():
    x = 1
    while k >= 0:
        if k >= x:
            k -= x
            cnt += 1
        else:
            break
        x += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
r = 0
p = 2
while n > 1:
    e = 0
    while n%p == 0:
       e += 1
       n /= p
    i = 1
    while e >= i:
        e -= i
        r += 1
        i += 1
    p += 1
print(r)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

tmp_sosu_list = list(range(2, 1000001))
z_list = []

while True:
    min_num = min(tmp_sosu_list)
    if min_num >= 1000:
        z_list.extend(tmp_sosu_list)
        break

    z_list.append(min_num)
    i = 0
    while True:
        if i >= len(tmp_sosu_list):
            break
        elif tmp_sosu_list[i] % min_num == 0:
            tmp_num = tmp_sosu_list[i] // min_num
            while tmp_num % min_num == 0:
                tmp_num = tmp_num // min_num
                if tmp_num == 1:
                    z_list.append(tmp_sosu_list[i])
            tmp_sosu_list.pop(i)
        i += 1
list.sort(z_list)

tmp_n = n
counter = 0
for z in z_list:
    if tmp_n % z == 0:
        tmp_n = tmp_n // z
        counter += 1
print(counter)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

tmp_sosu_list = list(range(2, 100000001))
z_list = []

while True:
    min_num = min(tmp_sosu_list)
    if min_num >= 10000:
        z_list.extend(tmp_sosu_list)
        break

    z_list.append(min_num)
    i = 0
    while True:
        if i >= len(tmp_sosu_list):
            break
        elif tmp_sosu_list[i] % min_num == 0:
            tmp_num = tmp_sosu_list[i] // min_num
            while tmp_num % min_num == 0:
                tmp_num = tmp_num // min_num
                if tmp_num == 1:
                    z_list.append(tmp_sosu_list[i])
            tmp_sosu_list.pop(i)
        i += 1
list.sort(z_list)

tmp_n = n
counter = 0
for z in z_list:
    if tmp_n % z == 0:
        tmp_n = tmp_n // z
        counter += 1
print(counter)

Submission status: Time Limit Exceeded

Solution code:
def sub(n):
    for i in range(2, n+1):
        if n % i == 0:
            return int(n/i), i

def main():
    n = int(input())
    ps = []
    es = []
    while(True):
        if n == 1:
            break
        n, p = sub(n)
        if p in ps:
            es[ps.index(p)] += 1
        else:
            ps.append(p)
            es.append(1)
    ret = 0
    for i in range(len(es)):
        j = 1
        s = 0
        while (True):
            s += j
            if s > es[i]:
                ret += j-1
                break
            elif s == es[i]:
                ret += j
                break
            else:
                j += 1
    print(ret)
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:

n = int(input())

p = []
for i in range(2,n+1):
    p.append(i)

for i in p:
    for j in p:
        if j % i == 0 and j / i != 1:
            p.remove(j)
            
e = [i for i in range(1,5)]
pe = []

for i in p:
  for j in e:
    if not (i**j) in pe:
      pe.append(i**j)
count = 0
used = []
while n > 1:
  for i in pe:
    if n % i == 0:
      n = n / i
      count += 1
      pe.remove(i)
      break

print(count)

Submission status: Time Limit Exceeded

Solution code:
def prime_factorize(n):
    num_list = []
    for i in range(2,n):
        if n % i == 0 and i not in num_list:
            num_list.append(i)
            n //= i
    return (num_list)

N = int(input())
print(len(prime_factorize(N)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
def q(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
apple = q(n)
orange = set(apple)
bird = []

for i in orange:
    bird.append(apple.count(i))

cnt = 0

for i in bird:
    if i == 1:
        pass
    else:
        for j in range(1, 10**12):
            dog = 0
            if dog == -100:
                break
            else:
                i -= j
                if i >= 0:
                    cnt += 1
                else:
                    dog = -100  



print(cnt + bird.count(1))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
z_list = [i for i in range(2,n+1)][::-1]
ans = 0
while z_list:
  if n % z_list[-1] == 0:
    n = n / z_list[-1]
    z_list.pop()
    ans += 1
  else:
    num = z_list.pop()
    z_list = [i for i in z_list if i % num != 0]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
z_s = []

handan_1 = 0
for i in range(2,int(math.sqrt(N))+1):
    if N%i == 0:
        handan_1=1
        break

if handan_1 == 1:
    while N != 1:
        for z in range(2,N+1):
            if N % z == 0:
                break
        
        N //=z
        z_s.append(z)
    
    last=[]
    handan = 1
    for i in z_s:
        if handan % i == 0:
            handan*=i
        else:
            handan = 1 *i
        if handan not in last:
            last.append(handan)
            handan = 1
elif N != 1:
    last=[N]
else:
    last=[]
print(len(last))

Submission status: Time Limit Exceeded

Solution code:
import math
N=int(input())
z_s = []

while N != 1:
    for z in range(2,N+1):
        if N % z == 0:
            break
    
    N //=z
    z_s.append(z)

last=[]
handan = 1
for i in z_s:
    if handan % i == 0:
        handan*=i
    else:
        handan = 1 *i
    if handan not in last:
        last.append(handan)
        handan = 1

print(len(last))

Submission status: Time Limit Exceeded

Solution code:
def isPrime(x):
    if x==1:
        return False
    for i in range(2, int(x**0.5)+1):
        if x%i==0:
            return False
    return True

def primeFactorization2(x):
    ps = []
    es = []
    i=2
    while i<=x:
        if x%i==0 and isPrime(i):
            ps.append(i)
            e=0
            while x%i==0:
                x = x//i
                e+=1
            es.append(e)
        i+=1
    return [ps, es]


n=int(input())

if isPrime(n):
    print(1)
else:
    nums = primeFactorization2(n)[1]

    ans=0
    for i in nums:
        ans += int(((1+8*i)**0.5-1)/2)

    print(ans)

Submission status: Time Limit Exceeded

Solution code:
def isPrime(x):
    if x==1:
        return False
    for i in range(2, int(x**0.5)+1):
        if x%i==0:
            return False
    return True

def primeFactorization2(x):
    ps = []
    es = []
    i=2
    while i<=x:
        if x%i==0 and isPrime(i):
            ps.append(i)
            e=0
            while x%i==0:
                x = x//i
                e+=1
            es.append(e)
        i+=1
    return [ps, es]


n=int(input())
nums = primeFactorization2(n)[1]

ans=0
for i in nums:
    ans += int(((1+8*i)**0.5-1)/2)

if isPrime(n):
    print(1)
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

# 素数リスト生成　eratosthenes
def makePrime(m):
    p = [i for i in range(m + 1)]
    for i in p[3:]:
        if p[i] % 2 == 0: p[i] = 0

    root_m = m ** 0.5
    for i in range(3,m):
        if i > root_m: break
        if p[i] != 0:
            for j in range(i, m + 1, 2):
                if i * j >= m + 1: break
                p[i * j] = 0
    #return p
    return sorted(list(set(p)))[2:]


# 素数かどうか判定
def isPrime(x):
    if x <= 1:
        return False
    
    for i in range(2,math.floor(math.sqrt(x))+1):
        if (x % i) == 0:
            return False
    return True

# zの値を作成
def z_make(n,p):
    for prime in p:
        for i in range(1,100000000000):
            z = prime ** i
            
            if z >= n:
                break
            
            if not z in memo:
                memo.append(z)

def divGame2(n):
    for z in memo:
        global ans
        if n % z == 0:
            rem = n / z
            memo.remove(z)
            ans += 1
            #print("n=",n," z=",z,"rem=",rem," ans=",ans)
            return divGame2(rem)
        

memo = []  # memory
ans = 0    # answer
p = []     # Prime

n = int(input())
p = makePrime(100000)

if isPrime(n): # 素数だったら１が答え
    print(1)
else:
    z_make(n,p)  # zの値を生成。memoができる
    memo.sort()  # 念のため並び替え
    #print(memo)
    divGame2(n)  # メイン実行
    print(ans)   # 答えの出力

Submission status: Time Limit Exceeded

Solution code:
import math
def isPrime(n):
  if n<2:
    return False
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n))
  for p in range(3,n+1,2):
      if n % p == 0:
        return False
      if p > m:
        # 素数がnの平方根を超えたら終了
        break
  return True
N=int(input())
if isPrime(N):
    print(1)
else:
    n=N
    count=0
    s=0
    S=0
    for i in range(2,N+1):
        if n<i:
            break
        s=1
        count=0
        while 1:
            if n%i!=0:
                break
            count+=1
            n=int(n/i)
        while 1:
            if count<int(s*(s+1)/2):
                S+=s-1
                break
            s+=1
    print(S)

Submission status: Time Limit Exceeded

Solution code:
import math
def isPrime(n):
  if n<2:
    return False
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  m = math.floor(math.sqrt(n))
  for p in range(3,n+1,2):
      if n % p == 0:
        return False
      if p > m:
        # 素数がnの平方根を超えたら終了
        break
  return True
N=int(input())
if isPrime(N):
    print(1)
else:
    n=N
    count=0
    s=0
    S=0
    for i in range(2,N+1):
        if n<i:
            break
        s=0
        count=0
        while 1:
            if n%i!=0:
                break
            count+=1
            n=int(n/i)
        while 1:
            if count<int(s*(s+1)/2):
                S+=s-1
                break
            s+=1
    print(S)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
#import copy


def xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


def sp_xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example
        input   1
        retrun  [1]

        input   123
        return  [1,2,3]

        input   123
                4
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        return [int(k) for k in xsxs()]
    else:
        return [[int(k) for k in xsxs()] for _ in range(n)]


def xsxs(n=0):
    """
    args:
        int n: a number of lows to read
    example:
        input   AA
        retrun  AA

        input   A BBB CC
        return  ["A","BBB","CC"]

        input   A BB CCC
                D
        return  [["A","BBB","CC"],
                ["D"]]
    """
    if n == 0:
        temp = list(input().split())
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        return [list(input().split()) for _ in range(n)]


def sp_xsxs(n=0):
    """
    args:
        int n: a number of lows to read
        example:
            input   A
            retrun  ["A"]

            input   ABC
            return  ["A","B","C"]

            input   ABC
                    D
            return  [["A","B","C"],
                    ["D"]]
    """
    if n == 0:
        return [s for s in xsxs()]
    else:
        return [[s for s in xsxs()] for _ in range(n)]


def p_num(a):

    if a == 1:
        return [[a, 1]]
    else:
        tmp = 2
        ans = []
        while tmp < np.sqrt(a) + 1:
            n = 0
            p = [tmp]

            while a % tmp == 0:
                a = int(a / tmp)
                # p.append(tmp)
                n += 1
                c = 1
            if n != 0:
                p.append(n)
                ans.append(p)
            tmp += 1
            c = 0
        if c == 0:
            ans.append([a, 1])
        return ans


n = xnxn()

if n == 1:
    print(0)
    sys.exit()
else:
    a = p_num(n)
    c = 0
    for num in a:
        i = 1
        while n % (num[0]**i) == 0:
            n = n/(num[0]**i)
            i += 1
            c += 1
    print(c)

Submission status: Time Limit Exceeded

Solution code:
"""
D - Div Game
"""
def divgame(n) :
    s = []
    a = 0
    i = 3
    j = 1
    k = 1
    while n > 1 :
        if n % 2**j == 0 :
            n //= 2**j
            a += 1
            j += 1
        else :
            break
    while n > 1:
        if  n % i**k == 0:
            n //= i**k 
            s.append(i)
            i += 2
            a += 1
            k += 1
    return a
print(divgame(int(input())))
            
assert divgame(24) == 3
assert divgame(1) == 0
assert divgame(64) == 3
assert divgame(1000000007) == 1
assert divgame(997764507000) == 7