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: Runtime Error

Solution code:
N = int(input())
def prime_dict(n):
    a = {}
    if n%2 == 0:
        a[2] = 1
        n//=2
        exp2 = 2
    while n%(2**exp2) == 0:
        a[2] += 1
        n //= 2**exp2
        exp2 += 1
    f = 3
    expn = 1
    while f**expn <= n:
        while f**expn <= n:
            if n%(f**expn) == 0:
                if f not in a:
                    a[f] = 1
                else:
                    a[f] += 1
                n //= f**expn
            expn += 1
        f += 2
        expn = 1
    if n!= 1:
        a[n] = 1
    return a

primes = prime_dict(N)
ans = sum(primes.values())
print(ans)

Submission status: Runtime Error

Solution code:
def main():
  ## IMPORT MODULE
  #import sys
  from collections import Counter

  #sys.setrecursionlimit(100000)
  #input=lambda :sys.stdin.readline().rstrip()

  #f_inf=float("inf")
  #MOD=10**9+7
  
  if 'get_ipython' in globals(): 
    ## SAMPLE INPUT
    n = 64

  else:
    ##INPUT 
    n = input()
    #a, b = map(int, input().split())

  ## SUBMITION CODES HERE
  def prime_fact(n):
    P= []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            P.append(i)
            n //= i
    if n != 1:
        P.append(n)
    return P

  cnt = Counter(prime_fact(n))

  ans = 0
  for c in cnt.values():
    tmp = 1
    while c >= tmp:
      c -= tmp
      ans += 1
      tmp += 1
    
  print(ans)
    
main()

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;

const int MAX = 1000005;
vector<int> ans, a;
bitset<MAX> prime;
int _max = -1;

void sieve() {
  prime.set();
  prime[0] = prime[1] = false;
  for (int i = 4; i < MAX; i += 2) {
    prime[i] = false;
  }
  for (int i = 3; i * i < MAX; i += 2) {
    if (prime[i]) {
      for (int j = i * i; j < MAX; j += 2 * i) {
        prime[j] = false;
      }
    }
  }
}

void _fill(long long n) {
  long long pr = 2;
  int pos = 1;
  
  while (pr * pr <= n) {
    int e = 0;
    while (n % pr == 0) {
      e++;
      n /= pr;
    }
    if (e > 0) {
      _max = max(_max, e);
      ans.push_back(e);
    }
    pr = a[pos++];
  }
  if (n > 1) {
    ans.push_back(1);
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  sieve();
  for (int i = 2; i < MAX; i++) {
    if (prime[i]) {
      a.push_back(i);
    }
  }
  vector<int> b, c;   
  for (int i = 1;; i++) {
    int foo = i * (i + 1) / 2;
    if (foo > MAX) break;
    b.push_back(foo);
    c.push_back(i);
  }
  long long n;
  cin >> n;
  _fill(n);
  int cnt = 0;
  for (int i = 0; i < (int)ans.size(); i++) {
    //cout << ans[i] << endl;
    int pos = lower_bound(b.begin(), b.end(), ans[i]) - b.begin();
    if (b[pos] > ans[i]) {
      cnt += c[pos - 1];
    } else {
      cnt += c[pos];
    }
  }
  cout << cnt << '\n';
  return 0;
}

Submission status: Runtime Error

Solution code:
n=int(input())
cnt=0
for i in range(2,int(n**0.5)+2):
    if n%i==0:
        expo=0
    while n%i==0:
        n//=i
        expo+=1
    j=1
    while expo-j>=0:
        cnt+=1
        expo-=j
        j+=1
if n>1:
    cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n=int(input())
cnt=0
for i in range(2,int(n**0.5)+2):
    if n%i==0:
        expo=0
    while n%i==0:
        n//=i
        expo+=1
        j=1
    while expo-j>=0:
        cnt+=1
        expo-=j
        j+=1
if n>1:
	cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
def factorization(n):
    arr = []
    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])

    return arr
N = int(input())
ans = 0
if N != 1:
    fact_list = factorization(N)
    for _, i in fact_list:
        j = 1
        while i >= j:
            ans += 1
            i = i - j
            j += 1
            
print(ans)

Submission status: Runtime Error

Solution code:
ef D(argN = None):
	answer = 0
	N = argN or int(input())
	if N==1:
		print(answer)
	else:
		# 素因数pを見つける。範囲は2から√Nまででよい。
		for p in range(2, int(N**0.5)+2):
			e = 0
			while (N % p == 0):
				N /= p
				e += 1
			# z=p**eが見つかった
			if e>0:
				# eを1, 2, 3, 4...に分けられる回数カウント
				for i in range(1, e+1):
					if e >= 1:
						e -= i
						answer += 1
		# もし素因数が見つからなかった場合、N自身を素数ととらえて1回カウント
		if answer==0:
			answer = 1
		print(answer)
        
D()

Submission status: Runtime Error

Solution code:
n = int(input())

def factorization(x):
   arr = []
   tmp = x
   for i in range(2, int(n**0.5)+1):
      if tmp % i == 0:
         cnt = 0
         while tmp % i == 0:
            cnt += 1
            tmp //= i
         arr.append([i, cnt])
   if tmp != 1:
      arr.append([tmp, cnt])
   if len(arr) == 0:
      arr.append([x, 1])
   return arr

if n == 1:
   print(0)
   exit()

ans = 0
for p, i in factorization(n):
   j = 0
   while i > j:
      j += 1
      i -= j
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())

def factorization(x):
   arr = []
   tmp = x
   for i in range(2, int(n**0.5+1)):
      if tmp % i == 0:
         cnt = 0
         while tmp % i == 0:
            tmp //= i
            cnt += 1
         arr.append([i, cnt])
   if tmp != 1:
      arr.append([i, cnt])
   if len(arr) == 0:
      arr.append([x, 1])
   return arr

if n == 1:
   print(0)
   exit()

ans = 0
for p, i in factorization(n):
   j = 0
   while i > j:
      j += 1
      i -= j
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
def func(N):
    tmp=N
    arr=[]
    for i in range(2,(N**0.5//1+1)):
        if tmp%i==0:
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
            
    if tmp!=1:
        arr.append([tmp, 1])
    if arr==[]:
        arr.append([tmp,1])
   
    return arr

N=int(input())
a=func(N)
ans=0
if a[0][0]==1:
        print(0)
        exit()
        
b=[1,3,6,10,15,21,28,36,45]
for i in a:
    for j in range(len(b)):
       if  i[1]<b[j]:
          ans+=j
          break
print(ans)

Submission status: Runtime Error

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

N=int(input())
a=func(N)
ans=0
if a[0][0]==1:
        print(0)
        exit()
        
b=[1,3,6,10,15,21,28,36,45]
for i in a:
    for j in range(len(b)):
       if  i[1]<b[j]:
          ans+=j
          break
print(ans)

Submission status: Runtime Error

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

N=int(input())
a=func(N)
ans=0
if a[0][0]==1:
        print(0)
        exit()
        
b=[1,3,6,10,15,21,28,36,45]
for i in a:
    for j in range(len(b)):
       if  i[1]<b[j]:
          ans+=j
          break
print(ans)

Submission status: Runtime Error

Solution code:
def func(N):
    tmp=N
    arr=[]
    for i in range(2,int(-(-N**0.5//1))+1):
        if tmp%i==0:
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    if arr==[] or temp!=1:
        arr.append([tmp,1])
   
    return arr

N=int(input())
a=func(N)
ans=0
if a[0][0]==1:
        print(0)
        exit()
        
b=[1,3,6,10,15,21,28,36,45]
for i in a:
    for j in range(len(b)):
       if  i[1]<b[j]:
          ans+=j
          break
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
def factorize(n, already):
    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])

    ret = []
    for a, b in arr:
        for i in range(1, b+1):
            ret.append(a*i)

    ret = set(ret) - set(already)
    return sorted(list(ret))[0]

already = []
z = 0
n = N
ans = 0
for _ in range(100000):
    z = factorize(n, already)
    if z > n or n == 1:
        break
    n = n // z
    already.append(z)
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math

n = int(input())
list = {}
while n>1:
    for i in range(math.sqrt(n)):
        if n%i==0:
            if i in list:
                list[i] = list[i]+1
            else:
                list[i] = 1
            break
if n%i==0:
    if i in list:
        list[i] = list[i]+1
    else:
        list[i] = 1
ans = 0
for i in list.keys():
    m = list[i]
    for j in range(m):
        if not j>m:
            ans += j
            m -= j
        else:
            break
print(ans)

Submission status: Runtime Error

Solution code:
def fc(n):
    wk =0
    h=0
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            wk+=1
            n//=i
            h=i
    if n!=1 and h < n:
        wk+=1
    return wk
 
n =int(input()

Submission status: Runtime Error

Solution code:
def fc(n):
    wk =0
    h=0
    for i in range(2,int(n**0.5)+1):
        if n%i==0:
            wk+=1
            n//=i
            h=i
    if n!=1 and h <
     n:
        wk+=1
    return wk

n =int(input())

print(fc(n))

Submission status: Runtime Error

Solution code:
from decimal import Decimal
A,B = map(str,input().split())
A = Decimal(A)
B = Decimal(B)
print(int(A*B))

Submission status: Runtime Error

Solution code:
from sys import stdin

def waru(a,b):
  if a%b != 0:
    return 0
  if a/b == 1:
    return b
  return waru(a/b,b)
  

def main():
  s = []
  read = stdin.readline
  N =int(read())
  i = 2
  table = []
  ap = table.append
  while i * i <= N:
    while N%i == 0:
      ap(i)
      N //= i
    i += 1
  if N > 1:
    ap(N)
  set_table = sorted(list(set(table)))
  kaisu = [0] * len(set_table)
  num = 0
  for i in table:
    if i == set_table[num]:
      kaisu[num] += 1
    else:
      num += 1
      kaisu[num] += 1
  maxk = max(kaisu)
  j = 1
  count = 0
  while j <= maxk:
    count += len([i for i in kaisu if i >= j])
    j = j + j + 1
  print(count)
    
      
      

  
  
  
if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
n = int(input())
if n == 1:
  print(0)
  exit()
  
from collections import Counter
def factorize(n):
  d = Counter()
  if n < 2:
    return d
  
  while n % 2 == 0:
    n //= 2
    d[2] += 1
    
    m = 3
    while m * m <= n:
      while n % m == 0:
        n //= m
        d[m] += 1
      m += 2
    if n > 1:
      d[n] += 1
    return d
  
fac = factorize(n)
ans = 0
for v in fac.values():
  n = 1
  while v >= n:
    v -= n
    ans += 1
    n += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(imput())


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



ans = 0
if N >= 2:
	for i in factorization(N):
		n = 1
		while True:
			z = i[0]**n
			if N % z == 0:
				N = N / z
				ans += 1
				n += 1
			else:
				break


			
			
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(imput())


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



ans = 0
if N >= 2:
	for i in factorization(N):
		n = 1
		while True:
			z = i[0]**n
			if N % z == 0:
				N = N / z
				ams += 1
				n += 1
			else:
				break


			
			
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(imput())


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



ans = 0
for i in factorization(N):
	n = 1
	while True:
		z = i[0]**n
		if N % z == 0:
			N = N / z
			ams += 1
			n += 1
		else:
			break
			

print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
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=cnt+1
            temp //= i
        arr.append([i, cnt])
if temp!=1:
    arr.append([temp, 1])
 
if arr==[]:
    arr.append([n, 1])
 
n = 0
if N == 1:
    print(0)
else:
    for i in range(len(arr)):
        a = 0
        b = arr[i]
        while a < b[1]:
            a = a+a+1
            n = n+1
    print(n)

Submission status: Runtime Error

Solution code:
import math

def prime(x):
    if x==1:
        prime=False
    else:
        prime=True
        for i in range(2,int(math.sqrt(x)+1)):
            if x%i==0:
                prime=False
                break
    return prime

def count_prime(N):
    if prime(N): #初期値が素数の場合
        big_prime=True
        
    else:　#初期値が素数でない場合
        big_prime=False
        rtN_init=int(math.sqrt(N)+1)
        p=[0 for n in range(int(math.sqrt(N)+1))]
        
        #素因数分解。ルートＮまでの範囲で素因数を探す。見つかったらpの素因数インデックスを++
        while N>1 and prime(N)==False:
            rtN=int(math.sqrt(N)+1)
            for i in range(2,rtN+1):
                if N%i==0 and prime(i):
                    p[i]+=1
                    N=N//i
                    break
        #素因数がルートNより大きい場合の処理
            if prime(N) and N>rtN_init:
                big_prime=True
    return p,big_prime

def main():
    N=int(input())
    p,q=count_prime(N)
    cnt=0
    
    for n in range(len(p)):
        num=1
        while p[n]>=1:
            p[n]-=num
            if p[n]>=0:
                cnt+=1
                num+=1
    if q==True:
        cnt+=1
    print(cnt)
        
if __name__=="__main__":
    main()

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = []
b= []
while n % 2 == 0:
    b.append(2)
    n //= 2
if(len(b)!= 0):
    a.append(b)
    b= [] 
f = 3
while f * f <= n:

    if n % f == 0:
        b.append(f)
        n //= f
    else:
        f += 2
        if(len(b)!= 0):
            a.append(b)
            b= [] 

       
if(len(b)!= 0):
        a.append(b)
        b= [] 
if (n != 1 ):
    if(n == a[len(a)-1][0]):
        a[len(a)-1].append(n)
    else:
        b.append(n)
        a.append(b)

ans =0
for i in range(len(a)):
    ans += int((-1 + math.sqrt(1 + 8 * len(a[i])))/2)

print(ans)

Submission status: Runtime Error

Solution code:
require 'prime'
p gets.to_i.prime_division.map{|_,m|((Math.sqrt(8*m+1)-1)/2).floor}.sum

Submission status: Runtime Error

Solution code:
N = int(input())
def factorize(n, already):
    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])

    ret = []
    for a, b in arr:
        for i in range(1, b+1):
            ret.append(a*i)

    ret = set(ret) - set(already)
    return sorted(list(ret))[0]

already = []
z = 0
n = N
ans = 0
while n >= z:
    if n == 1:
        break
    z = factorize(n, already)
    n = n // z
    already.append(z)
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
def factorize(n, already):
    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])

    ret = []
    for a, b in arr:
        for i in range(1, b+1):
            ret.append(a*i)

    ret = set(ret) - set(already)
    return sorted(list(ret))[0]

already = []
z = 0
n = N
ans = 0
while n >= z:
    z = factorize(n, already)
    n = n // z
    already.append(z)
    ans += 1
    if n == 1:
        break
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
def factorize(n, already):
    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])

    ret = []
    for a, b in arr:
        for i in range(1, b+1):
            ret.append(a*i)

    ret = set(ret) - set(already)
    return list(ret)[0]

already = []
z = 0
n = N
ans = 0
while n >= z:
    z = factorize(n, already)
    n = n // z
    already.append(z)
    ans += 1
    if n == 1:
        break
print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<pair<ll, ll>> prime_factor(ll n) {
  vector<pair<ll, ll>> res;
  for (ll a =2; a * a <= n; a++) {
    if (n % a != 0) continue;
    ll ex = 0;
    while (n % a == 0) {
      ex++;
      n /= a;
    }
    res.push_back({a, ex});
  }
  if (n != 1) res.push_back({n, 1});
  return res;
} 


int main() {
  ll n;
  cin >> n;

  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }

  const auto &v = prime_factor(n);


  int ans = 0;
  for(auto x : v) {
    int m = x.second;
    int cnt = 1;
    while (m - cnt >= 0 ) {
      m -= cnt;
      cnt++;
      ans++;
    }
  }
  cout << ans << endl;
}

Submission status: Runtime Error

Solution code:
N = int(input())

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]



def insu(num):
    from collections import defaultdict
    primes = get_sieve_of_eratosthenes(int(num**(1 / 2)) + 1)
    res = defaultdict(int)
    for p in primes:
        while num % p == 0:
            res[p] += 1
            num //= p
    return res
ins = insu(N)
ans = 0
for v in ins.values():
    counter = 1
    while v >= counter:
        v -= counter
        counter += 1
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())

def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = [2]
    limit = int(n**0.5)
    data = [i + 1 for i in range(2, n, 2)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]



def insu(num):
    from collections import defaultdict
    primes = get_sieve_of_eratosthenes(int(num**(1 / 2)) + 1)
    res = defaultdict(int)
    for p in primes:
        while num % p == 0:
            res.append(p)
            num //= p
    return res
ins = insu(N)
ans = 0
for v in ins.values():
    counter = 1
    while v >= counter:
        v -= counter
        counter += 1
        ans += 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math  # Use sqrt, floor
import functools # Use reduce (Python 2.5+ and 3.x)

def euler_criterion(a, p):
    """p is odd prime, a is positive integer. Euler's Criterion will check if
	a is a quadratic residue mod p. If yes, returns True. If a is a non-residue
	mod p, then False"""
    return pow(a, (p - 1) // 2, p) == 1

def gcd(a,b):
	"""gcd(a,b) returns the greatest common divisor of the integers a and b."""
	a = abs(a); b = abs(b)
	while (a > 0):
		b = b % a
		tmp=a; a=b; b=tmp
	return b

def xgcd(a,b):
	"""xgcd(a,b) returns a tuple of form (g,x,y), where g is gcd(a,b) and
	x,y satisfy the equation g = ax + by."""
	a1=1; b1=0; a2=0; b2=1; aneg=1; bneg=1
	if(a < 0):
		a = -a; aneg=-1
	if(b < 0):
		b = -b; bneg=-1
	while (1):
		quot = -(a // b)
		a = a % b
		a1 = a1 + quot*a2; b1 = b1 + quot*b2
		if(a == 0):
			return (b, a2*aneg, b2*bneg)
		quot = -(b // a)
		b = b % a;
		a2 = a2 + quot*a1; b2 = b2 + quot*b1
		if(b == 0):
			return (a, a1*aneg, b1*bneg)

def power_mod(b,e,n):
	"""power_mod(b,e,n) computes the eth power of b mod n.
	(Actually, this is not needed, as pow(b,e,n) does the same thing for positive integers.
	This will be useful in future for non-integers or inverses.)"""
	if e<0: # Negative powers can be computed if gcd(b,n)=1
		e = -e
		b = inverse_mod(b,n)
	accum = 1; i = 0; bpow2 = b
	while ((e>>i)>0):
		if((e>>i) & 1):
			accum = (accum*bpow2) % n
		bpow2 = (bpow2*bpow2) % n
		i+=1
	return accum

def inverse_mod(a,n):
	"""inverse_mod(b,n) - Compute 1/b mod n."""
	(g,xa,xb) = xgcd(a,n)
	if(g != 1): raise ValueError("***** Error *****: {0} has no inverse (mod {1}) as their gcd is {2}, not 1.".format(a,n,g))
	return xa % n

def is_prime(n):
	"""is_prime(n) - Test whether n is prime using a variety of pseudoprime tests."""
	if n<0: n=-n  # Only deal with positive integers
	if n<2: return False # 0 and 1 are not prime
	if (n in (2,3,5,7,11,13,17,19,23,29)): return True
	return isprimeE(n,2) and isprimeE(n,3) and isprimeE(n,5)

def factor(n):
	"""factor(n) - Return a sorted list of the prime factors of n with exponents."""
	# Rewritten to align with SAGE.  Previous semantics available as factors(n).
	if ((abs(n) == 1) or (n == 0)): raise ValueError('Unable to factor {0}'.format(n))
	factspow = []
	currfact = None
	thecount = 1
	for thefact in factors(n):
		if thefact != currfact:
			if currfact != None:
				factspow += [(currfact,thecount)]
			currfact = thefact
			thecount = 1
		else:
			thecount += 1
	factspow += [(thefact,thecount)]
	return tuple(factspow)

def prime_divisors(n):
	"""prime_divisors(n) - Returns a sorted list of the prime divisors of n."""
	return tuple(set(factors(n)))

def euler_phi(n):
	"""euler_phi(n) - Computer Euler's Phi function of n - the number of integers
	strictly less than n which are coprime to n.  Otherwise defined as the order
	of the group of integers mod n."""
	if n == 1: return 1
	if n <= 0: return 0
	# For each prime factor p with multiplicity n, a factor of (p**(n-1))*(p-1)
	return functools.reduce(lambda a,x:a*(x[0]**(x[1]-1))*(x[0]-1),factor(n),1)

def carmichael_lambda(n):
	"""carmichael_lambda(n) - Compute Carmichael's Lambda function
	of n - the smallest exponent e such that b**e = 1 for all b coprime to n.
	Otherwise defined as the exponent of the group of integers mod n."""
	# SAGE equivalent is sage.crypto.util.carmichael_lambda(n)
	if n == 1: return 1
	if n <= 0: raise ValueError("*** Error ***:  Input n for carmichael_lambda(n) must be a positive integer.")
	# The gcd of (p**(e-1))*(p-1) for each prime factor p with multiplicity e (exception is p=2).
	def _carmichael_lambda_primepow(theprime,thepow):
		if ((theprime == 2) and (thepow >= 3)):
			return (2**(thepow-2)) # Z_(2**e) is not cyclic for e>=3
		else:
			return (theprime-1)*(theprime**(thepow-1))
	return functools.reduce(lambda accum,x:(accum*x)//gcd(accum,x),tuple(_carmichael_lambda_primepow(*primepow) for primepow in factor(n)),1)

def is_primitive_root(g,n):
	"""is_primitive_root(g,n) - Test whether g is primitive - generates the group of units mod n."""
	# SAGE equivalent is mod(g,n).is_primitive_root() in IntegerMod class
	if gcd(g,n) != 1: return False  # Not in the group of units
	order = euler_phi(n)
	if carmichael_lambda(n) != order: return False # Group of units isn't cyclic
	orderfacts = prime_divisors(order)
	for fact in orderfacts:
		if pow(g,order//fact,n) == 1: return False
	return True

def sqrtmod(a,n):
	"""sqrtmod(a,n) - Compute sqrt(a) mod n using various algorithms.
	Currently n must be prime, but will be extended to general n (when I get the time)."""
	# SAGE equivalent is mod(g,n).sqrt() in IntegerMod class
	if(not isprime(n)): raise ValueError("*** Error ***:  Currently can only compute sqrtmod(a,n) for prime n.")
	if(pow(a,(n-1)//2,n)!=1): raise ValueError("*** Error ***:  a is not quadratic residue, so sqrtmod(a,n) has no answer.")
	return TSRsqrtmod(a,n-1,n)

def TSRsqrtmod(a,grpord,p):
	"""TSRsqrtmod(a,grpord,p) - Compute sqrt(a) mod n using Tonelli-Shanks-RESSOL algorithm.
	Here integers mod n must form a cyclic group of order grpord."""
	# Rewrite group order as non2*(2^pow2)
	ordpow2=0; non2=grpord
	while(not ((non2&0x01)==1)):
		ordpow2+=1; non2//=2
	# Find 2-primitive g (i.e. non-QR)
	for g in range(2,grpord-1):
		if (pow(g,grpord//2,p)!=1):
			break
	g = pow(g,non2,p)
	# Tweak a by appropriate power of g, so result is (2^ordpow2)-residue
	gpow=0; atweak=a
	for pow2 in range(0,ordpow2+1):
		if(pow(atweak,non2*2**(ordpow2-pow2),p)!=1):
			gpow+=2**(pow2-1)
			atweak = (atweak * pow(g,2**(pow2-1),p)) % p
			# Assert: atweak now is (2**pow2)-residue
	# Now a*(g**powg) is in cyclic group of odd order non2 - can sqrt directly
	d = invmod(2,non2)
	tmp = pow(a*pow(g,gpow,p),d,p)  # sqrt(a*(g**gpow))
	return (tmp*inverse_mod(pow(g,gpow//2,p),p)) % p  # sqrt(a*(g**gpow))//g**(gpow//2)

################ Internally used functions #########################################

def isprimeF(n,b):
	"""isprimeF(n) - Test whether n is prime or a Fermat pseudoprime to base b."""
	return (pow(b,n-1,n) == 1)

def isprimeE(n,b):
	"""isprimeE(n) - Test whether n is prime or an Euler pseudoprime to base b."""
	if (not isprimeF(n,b)): return False
	r = n-1
	while (r % 2 == 0): r //= 2
	c = pow(b,r,n)
	if (c == 1): return True
	while (1):
		if (c == 1): return False
		if (c == n-1): return True
		c = pow(c,2,n)

def factorone(n):
	"""factorone(n) - Find a prime factor of n using a variety of methods."""
	if (is_prime(n)): return n
	for fact in (2,3,5,7,11,13,17,19,23,29):
		if n%fact == 0: return fact
	return factorPR(n)  # Needs work - no guarantee that a prime factor will be returned

def factors(n):
	"""factors(n) - Return a sorted list of the prime factors of n. (Prior to ver 0.7 named factor(n))"""
	if n<0: n=-n  # Only deal with positive integers
	if (is_prime(n)):
		return [n]
	fact = factorone(n)
	if ((abs(n) == 1) or (n == 0)): raise ValueError('Unable to factor \"{0}\"'.format(n))
	facts = factors(n//fact) + factors(fact)
	facts.sort()
	return facts

def factorPR(n):
	"""factorPR(n) - Find a factor of n using the Pollard Rho method.
	Note: This method will occasionally fail."""
	numsteps=2*math.floor(math.sqrt(math.sqrt(n)))
	for additive in range(1,5):
		fast=slow=1; i=1
		while i<numsteps:
			slow = (slow*slow + additive) % n
			i = i + 1
			fast = (fast*fast + additive) % n
			fast = (fast*fast + additive) % n
			g = gcd(fast-slow,n)
			if (g != 1):
				if (g == n):
					break
				else:
					return g
	return 1

################ Functions renamed in ver 0.7 (to align with SAGE) #################
def powmod(b,e,n):
	"""powmod(b,e,n) computes the eth power of b mod n. (Renamed power_mod(b,e,n) in ver 0.7)"""
	return power_mod(b,e,n)

def isprime(n):
	"""isprime(n) - Test whether n is prime using a variety of pseudoprime tests. (Renamed is_prime in ver 0.7)"""
	return is_prime(n)

def invmod(b,n):
	"""invmod(b,n) - Compute 1//b mod n. (Renamed inverse_mod(b,n) in ver 0.7)"""
	return inverse_mod(b,n)

def eulerphi(n):
    """eulerphi(n) - Compute Euler's Phi function of n - the number of integers strictly less than n which are coprime to n.
    (Renamed euler_phi(n) in ver 0.7)"""
    return euler_phi(n)

def carmichaellambda(n):
	"""carmichaellambda(n) - Compute Carmichael's Lambda function
	of n - the smallest exponent e such that b**e = 1 for all b coprime to n.
	Otherwise defined as the exponent of the group of integers mod n. (Renamed carmichael_lambda(n) in ver 0.7)"""
	return carmichael_lambda(n)

def isprimitive(g,n):
	"""isprimitive(g,n) - Test whether g is primitive - generates the group of units mod n. (Renamed is_primitive_root(g,n) in ver 0.8)"""
	# SAGE equivalent is mod(g,n).is_primitive_root() in IntegerMod class
	return is_primitive_root(g,n)
n = int(input())
print(len(factor(n)))

Submission status: Runtime Error

Solution code:
import sympy

n = int(input())

ans = 0
if n > 1:
    tmp = sympy.factorint(n)
    for v in tmp.values():
        i = 1
        while v > 0:
            if v - i >= 0:
                v -= i
                ans += 1
                i += 1
            else:
                break
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
A=a=int(input())
count=2
samenumcount=0
y=[]

if A==1:
    print(0)
    sys.exit()

while A!=1 and count<np.sqrt(a):
    if A%count==0:
        samenumcount+=1
        y.append(count**samenumcount)
        A=A/count
    else:
        count+=1
        samenumcount=0
y.sort()

count2=0
for i in y:
    if a==1:
      break
    if a%i==0:
        a=a/i
        count2+=1

if count2==0:
    print(1)
else:
    print(count2)