prithivMLmods/Coder-Stat huggingface dataset:
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

const ld PI = 4 * atan((ld)1);
const int INF = 1e9 + 7;

int main() {
  setIO();
  ll n, ct = 0;
  cin >> n;
  for (int i = 2; i * i <= n; i++) {
    int rq = 1, ct1 = 0;
    while (n % i == 0) {
      ct1++;
      n /= i;
      if (ct1 == rq) {
        ct++;
        rq++;
        ct1 = 0;
      }
    }
  }
  if (n > 1)
    ct++;
  cout << ct << endl;
}

Fixed submission:
#include <bits/stdc++.h>

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

const ld PI = 4 * atan((ld)1);
const int INF = 1e9 + 7;

int main() {
  setIO();
  ll n, ct = 0;
  cin >> n;
  for (ll i = 2; i * i <= n; i++) {
    int rq = 1, ct1 = 0;
    while (n % i == 0) {
      ct1++;
      n /= i;
      if (ct1 == rq) {
        ct++;
        rq++;
        ct1 = 0;
      }
    }
  }
  if (n > 1)
    ct++;
  cout << ct << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int64_t N;
  cin >> N;
  vector<pair<int64_t, int>> table;

  int y = 0;
  while (N % 2 == 0) {
    N /= 2;
    y++;
    if (N % 2 != 0) {
      table.emplace_back(2, y);
    }
  }

  int i = 3;
  while (i * i < N) {
    int x = 0;
    while (N % i == 0) {
      N /= i;
      x++;
    }
    if (x != 0) {
      table.emplace_back(i, x);
    }
    i += 2;
  }

  if (N != 1) {
    table.emplace_back(N, 1);
  }

  /*for (int i = 0; i < table.size(); i++) {
        cout << table.at(i).first << " " << table.at(i).second <<endl;
  }*/

  int ans = 0;

  for (int i = 0; i < table.size(); i++) {
    int y = table.at(i).second;
    int b = 1;
    while (y >= b) {
      ans++;
      y -= b;
      b++;
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int64_t N;
  cin >> N;
  vector<pair<int64_t, int>> table;

  int y = 0;
  while (N % 2 == 0) {
    N /= 2;
    y++;
    if (N % 2 != 0) {
      table.emplace_back(2, y);
    }
  }

  int64_t i = 3;
  while (i * i < N) {
    int x = 0;
    while (N % i == 0) {
      N /= i;
      x++;
    }
    if (x != 0) {
      table.emplace_back(i, x);
    }
    i += 2;
  }

  if (N != 1) {
    table.emplace_back(N, 1);
  }

  /*for (int i = 0; i < table.size(); i++) {
        cout << table.at(i).first << " " << table.at(i).second <<endl;
  }*/

  int ans = 0;

  for (int i = 0; i < table.size(); i++) {
    int y = table.at(i).second;
    int b = 1;
    while (y >= b) {
      ans++;
      y -= b;
      b++;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
/**
 *    author:  Dooloper
 *    created: 06.06.2020 00:59:13
 **/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  cin.tie(0);
  ll N;
  cin >> N;
  vector<int> Eratosthenes((int)sqrt(N) + 10, 0);
  vector<int> factor;
  vector<ll> prime;

  /*エラトステネス*/
  for (ll i = 2; i * i < N; i++) {
    if (!Eratosthenes[i]) {
      for (ll j = 2; i * i * j * j <= N; j++)
        Eratosthenes[i * j] = 1;
    }
  }

  for (ll i : Eratosthenes) {
    if (!i) {
      int keep = 0;
      while (N % i == 0) {
        keep++;
        N /= i;
      }
      factor.emplace_back(keep);
    }
  }
  if (N > 1)
    factor.emplace_back(1);

  int ans = 0;
  for (int i : factor) {
    for (int j = 1; j <= i; j++) {
      ans++;
      i -= j;
    }
  }

  cout << ans << endl;
  return 0;
}


Fixed submission:
/**
 *    author:  Dooloper
 *    created: 06.06.2020 00:59:13
 **/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  cin.tie(0);
  ll N;
  cin >> N;
  vector<int> Eratosthenes((int)sqrt(N) + 10, 0);
  vector<int> factor;
  vector<ll> prime;

  /*エラトステネス*/
  for (ll i = 2; i * i < N; i++) {
    if (!Eratosthenes[i]) {
      for (ll j = 2; i * i * j * j <= N; j++)
        Eratosthenes[i * j] = 1;
    }
  }

  for (ll i = 2; i < Eratosthenes.size(); i++) {
    if (!Eratosthenes[i]) {
      int keep = 0;
      while (N % i == 0) {
        keep++;
        N /= i;
      }
      factor.emplace_back(keep);
    }
  }
  if (N > 1)
    factor.emplace_back(1);

  int ans = 0;
  for (int i : factor) {
    for (int j = 1; j <= i; j++) {
      ans++;
      i -= j;
    }
  }

  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  long N;
  cin >> N;
  if (N == 1)
    cout << 0 << endl;
  else {
    long num = N;
    int res = 0;
    for (int i = 2; i * i <= N; i++) {
      int cnt = 0;
      while (num % i == 0) {
        num /= i;
        ++cnt;
      }
      int j = 1;
      while (cnt - j >= 0) {
        cnt -= j;
        ++res;
        ++j;
      }
    }
    if (num != 1)
      ++res;
    cout << res << endl;
  }
}


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

int main() {
  long N;
  cin >> N;
  if (N == 1)
    cout << 0 << endl;
  else {
    long num = N;
    int res = 0;
    for (long i = 2; i * i <= N; i++) {
      int cnt = 0;
      while (num % i == 0) {
        num /= i;
        ++cnt;
      }
      int j = 1;
      while (cnt - j >= 0) {
        cnt -= j;
        ++res;
        ++j;
      }
    }
    if (num != 1)
      ++res;
    cout << res << endl;
  }
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace ::std;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream &operator>>(istream &I, vector<T> &v) {
  for (T &e : v)
    I >> e;
  return I;
}
template <class T> ostream &operator<<(ostream &O, const vector<T> &v) {
  for (const T &e : v)
    O << e << ' ';
  return O;
}

void _main() {
  ll n;
  cin >> n;
  map<ll, int> pf;
  for (int div = 2; div * div <= n; div++) {
    while (n % div == 0) {
      pf[div]++;
      n /= div;
    }
  }

  if (n > 1)
    pf[n]++;

  int ans = 0;
  for (auto &it : pf) {
    int i = 1;
    while (it.second - i >= 0) {
      ans++;
      it.second -= i++;
    }
  }

  cout << ans;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //        freopen("input.txt", "r", stdin);
  int _t = 1;
  //        cin >> _t;
  while (_t--)
    _main();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace ::std;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream &operator>>(istream &I, vector<T> &v) {
  for (T &e : v)
    I >> e;
  return I;
}
template <class T> ostream &operator<<(ostream &O, const vector<T> &v) {
  for (const T &e : v)
    O << e << ' ';
  return O;
}

void _main() {
  ll n;
  cin >> n;
  map<ll, int> pf;
  for (ll div = 2; div * div <= n; div++) {
    while (n % div == 0) {
      pf[div]++;
      n /= div;
    }
  }

  if (n > 1)
    pf[n]++;

  int ans = 0;
  for (auto &it : pf) {
    int i = 1;
    while (it.second - i >= 0) {
      ans++;
      it.second -= i++;
    }
  }

  cout << ans;
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //        freopen("input.txt", "r", stdin);
  int _t = 1;
  //        cin >> _t;
  while (_t--)
    _main();
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M
//--------------- O ---------------↓--------------//
// コンパイル
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
//
//
//
//
//
//
//
//------------↑------------- M -------------- E ---------------- M
//--------------- O ---------------↑--------------//

int main(void) {

  ll N;
  cin >> N;

  ll ans = 0;
  for (int i = 2; i * i <= N; ++i) {

    int e = 0;
    while (N % i == 0) {
      ++e;
      N /= i;
    }

    int k = 0;
    while (k * (k + 1) / 2 <= e)
      ++k;
    if (k * (k + 1) / 2 > e)
      --k;

    ans += k;
  }

  if (N != 1) {
    ++ans;
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M
//--------------- O ---------------↓--------------//
// コンパイル
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
//
//
//
//
//
//
//
//------------↑------------- M -------------- E ---------------- M
//--------------- O ---------------↑--------------//

int main(void) {

  ll N;
  cin >> N;

  ll ans = 0;
  for (ll i = 2; i * i <= N; ++i) {

    int e = 0;
    while (N % i == 0) {
      ++e;
      N /= i;
    }

    int k = 0;
    while (k * (k + 1) / 2 <= e)
      ++k;
    if (k * (k + 1) / 2 > e)
      --k;

    ans += k;
  }

  if (N != 1) {
    ++ans;
  }

  cout << ans << endl;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  /*int N;
  cin>>N;
  long long A[100000];
  long long answer=1;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]==0) answer=0;
  }
  if(answer==0) cout<<answer<<endl;
  else{
  for(int i=0;i<N;i++){
    answer=answer*A[i];
    if(answer>1000000000000000000){
      answer=-1;
      break;
    }
  }
  cout<<answer<<endl;
  }*/
  long long N;
  cin >> N;
  int div[1000001];
  for (int i = 0; i <= 1000000; i++) {
    div[i] = 0;
  }
  long long answer = 0;
  int i = 2;
  while (i * i <= N && N > 1) {
    if (N % i == 0) {
      int judge = 1;
      while (N % i == 0) {
        N = N / i;
        div[i]++;
        if (div[i] == judge) {
          div[i] = 0;
          answer++;
          judge++;
        }
      }
    }
    i++;
    if (N != 1 && i * i > N) {
      answer++;
    }
  }
  cout << answer << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
int main() {
  /*int N;
  cin>>N;
  long long A[100000];
  long long answer=1;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]==0) answer=0;
  }
  if(answer==0) cout<<answer<<endl;
  else{
  for(int i=0;i<N;i++){
    answer=answer*A[i];
    if(answer>1000000000000000000){
      answer=-1;
      break;
    }
  }
  cout<<answer<<endl;
  }*/
  long long N;
  cin >> N;
  int div[1000001];
  for (int i = 0; i <= 1000000; i++) {
    div[i] = 0;
  }
  long long answer = 0;
  long long i = 2;
  while (i * i <= N && N > 1) {
    if (N % i == 0) {
      int judge = 1;
      while (N % i == 0) {
        N = N / i;
        div[i]++;
        if (div[i] == judge) {
          div[i] = 0;
          answer++;
          judge++;
        }
      }
    }
    i++;
    if (N != 1 && i * i > N) {
      answer++;
    }
  }
  cout << answer << endl;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  // 素因数分解
  ll limit = n;
  map<ll, int> mp;
  for (int i = 2; i * i < n; i++) {
    ll x = 0;
    // 割り切れるなら
    while (n % i == 0) {
      n /= i;
      x++;
    }
    mp[i] = x;
  }
  if (n != 1) {
    mp[n]++;
  }

  int ans = 0;
  for (auto myPair : mp) {
    int count = myPair.second;
    int iter = 1;
    while (count >= iter) {
      count -= iter;
      iter++;
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  // 素因数分解
  ll limit = n;
  map<ll, int> mp;
  for (ll i = 2; i * i < n; i++) {
    ll x = 0;
    // 割り切れるなら
    while (n % i == 0) {
      n /= i;
      x++;
    }
    mp[i] = x;
  }
  if (n != 1) {
    mp[n]++;
  }

  int ans = 0;
  for (auto myPair : mp) {
    int count = myPair.second;
    int iter = 1;
    while (count >= iter) {
      count -= iter;
      iter++;
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb push_back
#define all(x) x.begin(), x.end()
#define inputSpeed() ios_base::sync_with_stdio(0), cin.tie(0)

#define MAXN (ll)(1e6 + 10)
// only one prime factor will be larger than 10^6
// Also, there are at most 40 prime factors.
bool composite[MAXN];
vector<pii> prime_factorise(ll N) {
  vector<pii> prime_factors;
  for (ll i = 2; i <= MAXN; i++) {
    if (!composite[i]) {
      // Found prime
      ll power = 0;
      while (N % (ll)i == 0) {
        N /= (ll)i;
        power++;
      }
      if (power) {
        prime_factors.pb({i, power});
      }
      // Update rest
      for (ll j = i * i; j <= MAXN; j += i) {
        composite[j] = true;
      }
    }
  }
  if (N > 1) {
    prime_factors.pb({N, 1});
  }
  return prime_factors;
}

int main() {
  inputSpeed();

  ll N;
  cin >> N;
  vector<pii> prime_factors = prime_factorise(N);

  // printf("N = 1\n");
  // for (auto f : prime_factors) {
  // 	printf("* %d ^ %d\n", f.x, f.y);
  // }

  int ans = 0;
  for (auto f : prime_factors) {
    // find out which triangular number it is
    for (int j = 1; j < 100; j++) {
      if (f.y - j >= 0) {
        f.y -= j;
        ans++;
      }
    }
  }
  printf("%d\n", ans);
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define x first
#define y second
#define pb push_back
#define all(x) x.begin(), x.end()
#define inputSpeed() ios_base::sync_with_stdio(0), cin.tie(0)

#define MAXN (ll)(1e6 + 10)
// only one prime factor will be larger than 10^6
// Also, there are at most 40 prime factors.
bool composite[MAXN];
vector<pii> prime_factorise(ll N) {
  vector<pii> prime_factors;
  for (ll i = 2; i < MAXN; i++) {
    if (!composite[i]) {
      // Found prime
      ll power = 0;
      while (N % (ll)i == 0) {
        N /= (ll)i;
        power++;
      }
      if (power) {
        prime_factors.pb({i, power});
      }
      // Update rest
      for (ll j = i * i; j <= MAXN; j += i) {
        composite[j] = true;
      }
    }
  }
  if (N > 1) {
    prime_factors.pb({N, 1});
  }
  return prime_factors;
}

int main() {
  inputSpeed();

  ll N;
  cin >> N;
  vector<pii> prime_factors = prime_factorise(N);

  // printf("N = 1\n");
  // for (auto f : prime_factors) {
  // 	printf("* %d ^ %d\n", f.x, f.y);
  // }

  int ans = 0;
  for (auto f : prime_factors) {
    // find out which triangular number it is
    for (int j = 1; j < 100; j++) {
      if (f.y - j >= 0) {
        f.y -= j;
        ans++;
      }
    }
  }
  printf("%d\n", ans);
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template <class T> inline void read(T &res) {
  char c;
  T flag = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-')
      flag = -1;
  res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9')
    res = res * 10 + c - '0';
  res *= flag;
}
#define MAX 1000000 // 求MAX范围内的素数
long long su[MAX], cnt;
bool isprime[MAX];
void prime() {
  cnt = 1;
  memset(isprime, 1, sizeof(isprime)); // 初始化认为所有数都为素数
  isprime[0] = isprime[1] = 0;         // 0和1不是素数
  for (long long i = 2; i <= MAX; i++) {
    if (isprime[i])
      su[cnt++] = i; // 保存素数i
    for (long long j = 1; j < cnt && su[j] * i < MAX; j++) {
      isprime[su[j] * i] = 0; // 筛掉小于等于i的素数和i的积构成的合数
    }
  }
}
int main() {
  prime();
  int a[] = {0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55};
  ll n, ans = 0;
  cin >> n;
  for (int i = 1;; i++) {
    if (i <= MAX && n < su[i])
      break;
    if (n % su[i] == 0) {
      int c = 0;
      while (n % su[i] == 0)
        n /= su[i], c++;
      // cout<<c<<endl;
      ans += upper_bound(a, a + 11, c) - a - 1;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template <class T> inline void read(T &res) {
  char c;
  T flag = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-')
      flag = -1;
  res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9')
    res = res * 10 + c - '0';
  res *= flag;
}
#define MAX 1000000 // 求MAX范围内的素数
long long su[MAX], cnt;
bool isprime[MAX];
void prime() {
  cnt = 1;
  memset(isprime, 1, sizeof(isprime)); // 初始化认为所有数都为素数
  isprime[0] = isprime[1] = 0;         // 0和1不是素数
  for (long long i = 2; i <= MAX; i++) {
    if (isprime[i])
      su[cnt++] = i; // 保存素数i
    for (long long j = 1; j < cnt && su[j] * i < MAX; j++) {
      isprime[su[j] * i] = 0; // 筛掉小于等于i的素数和i的积构成的合数
    }
  }
}
int main() {
  prime();
  int a[] = {0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55};
  ll n, ans = 0;
  cin >> n;
  for (int i = 1;; i++) {
    if (i < cnt && su[i] * su[i] > n)
      break;
    if (n % su[i] == 0) {
      int c = 0;
      while (n % su[i] == 0)
        n /= su[i], c++;
      // cout<<c<<endl;
      ans += upper_bound(a, a + 11, c) - a - 1;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
using namespace std;
vector<pair<long long, long long>> pre(long long n) {
  vector<pair<long long, long long>> res;
  for (int i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    int num = 0;
    while (n % i == 0) {
      num++;
      n /= i;
    }
    res.push_back(make_pair(i, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  long long n;
  cin >> n;
  const auto pf = pre(n);
  long long ans = 0;
  for (auto p : pf) {
    long long e = p.second;
    long long tmp = 0, cur = 1;
    while (e >= cur)
      e -= cur++, ++tmp;
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
vector<pair<long long, long long>> pre(long long n) {
  vector<pair<long long, long long>> res;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    int num = 0;
    while (n % i == 0) {
      num++;
      n /= i;
    }
    res.push_back(make_pair(i, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  long long n;
  cin >> n;
  const auto pf = pre(n);
  long long ans = 0;
  for (auto p : pf) {
    long long e = p.second;
    long long tmp = 0, cur = 1;
    while (e >= cur)
      e -= cur++, ++tmp;
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  // 素因数分解する
  vector<pair<ll, int>> f;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    if (cnt != 0)
      f.emplace_back(i, cnt);
  }
  if (n != 1)
    f.emplace_back(n, 1);

  // 答えを求める
  int ans = 0;
  for (auto p : f) {
    int x = p.second;
    int a = 1;
    while (x >= a) {
      x -= a;
      a++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

  // 素因数分解する
  vector<pair<ll, int>> f;
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    if (cnt != 0)
      f.emplace_back(i, cnt);
  }
  if (n != 1)
    f.emplace_back(n, 1);

  // 答えを求める
  int ans = 0;
  for (auto p : f) {
    int x = p.second;
    int a = 1;
    while (x >= a) {
      x -= a;
      a++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int ret(int n) {
  int i = sqrt(n);
  while (i * (i + 1) <= 2 * n)
    i++;
  if (i * (i + 1) > 2 * n)
    i--;
  return i;
}
int main() {
  long long n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      ans += ret(cnt);
    }
  }
  if (n > 1)
    ans += 1;
  cout << ans << "\n";
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int ret(int n) {
  int i = sqrt(n);
  while (i * (i + 1) <= 2 * n)
    i++;
  if (i * (i + 1) > 2 * n)
    i--;
  return i;
}
int main() {
  long long n;
  cin >> n;
  int ans = 0;
  for (long long i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      ans += ret(cnt);
    }
  }
  if (n > 1)
    ans += 1;
  cout << ans << "\n";
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

const int maxn = 1e6 + 100;
int prime[maxn]; // 就是个素数表
bool sf[maxn]; // 判断这个数是不是素数，sf[i]中的i是从1到maxn的数

void init() {  // 核心 欧拉筛代码
  int num = 0; // num 用来记筛到第几个质数
  memset(sf, true, sizeof(sf));
  for (int i = 2; i <= maxn; i++) { // 外层枚举1~maxn
    if (sf[i])
      prime[++num] = i;              // 如果是质数就加入素数表
    for (int j = 1; j <= num; j++) { // 内层枚举num以内的质数
      if (i * prime[j] > maxn)
        break;                  // 筛完结束
      sf[i * prime[j]] = false; // 筛掉...
      if (i % prime[j] == 0)
        break; // 避免重复筛
    }
  }
  sf[1] = false;
  sf[0] = false; // 1 0 特判
}

int main() {
  init();
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (int i = 2; i * i <= n; i++) {
    if (!sf[i])
      continue;
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1)
    mp[n]++;
  int ans = 0;
  for (auto i : mp) {
    for (int j = 1; i.second >= j; j++)
      i.second -= j, ++ans;
  }
  cout << ans << "\n";
}

Fixed submission:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

const int maxn = 1e6 + 100;
int prime[maxn]; // 就是个素数表
bool sf[maxn]; // 判断这个数是不是素数，sf[i]中的i是从1到maxn的数

void init() {  // 核心 欧拉筛代码
  int num = 0; // num 用来记筛到第几个质数
  memset(sf, true, sizeof(sf));
  for (int i = 2; i <= maxn; i++) { // 外层枚举1~maxn
    if (sf[i])
      prime[++num] = i;              // 如果是质数就加入素数表
    for (int j = 1; j <= num; j++) { // 内层枚举num以内的质数
      if (i * prime[j] > maxn)
        break;                  // 筛完结束
      sf[i * prime[j]] = false; // 筛掉...
      if (i % prime[j] == 0)
        break; // 避免重复筛
    }
  }
  sf[1] = false;
  sf[0] = false; // 1 0 特判
}

int main() {
  init();
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (ll i = 2; i * i <= n; i++) {
    if (!sf[i])
      continue;
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1)
    mp[n]++;
  int ans = 0;
  for (auto i : mp) {
    for (int j = 1; i.second >= j; j++)
      i.second -= j, ++ans;
  }
  cout << ans << "\n";
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)

void solve(long long N) {
  vector<pair<ll, ll>> res;
  for (int i = 2; i * i < N; i++) {
    ll b = 0;
    while (N % i == 0) {
      N /= i;
      b++;
    }
    res.emplace_back(i, b);
  }
  if (N != 1)
    res.emplace_back(N, 1);

  ll ans = 0;
  for (auto s : res) {
    ll p = s.second;
    ll b = 1;
    while (b <= p) {
      p -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
}

// void solve(long long N){
//     vector<pair<ll,int>> fs;
//     for(ll i = 2; i*i <= N; i++){
//         int x = 0;
//         while(N%i == 0){
//             N/=i;
//             ++x;
//         }
//         fs.emplace_back(i,x);
//     }
//     if(N != 1) fs.emplace_back(N,1);

//     int ans = 0;
//     for(auto p : fs) {
//         int x = p.second;
//         int b = 1;
//         while(b <= x){
//             x -= b;
//             b++;
//             ++ans;
//         }
//     }
//     cout << ans << endl;
// }

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (n); ++i)

void solve(long long N) {
  vector<pair<ll, ll>> res;
  for (ll i = 2; i <= N / i; i++) {
    ll b = 0;
    while (N % i == 0) {
      N /= i;
      b++;
    }
    res.emplace_back(i, b);
  }
  if (N != 1)
    res.emplace_back(N, 1);

  ll ans = 0;
  for (auto s : res) {
    ll p = s.second;
    ll b = 1;
    while (b <= p) {
      p -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
}

// void solve(long long N){
//     vector<pair<ll,int>> fs;
//     for(ll i = 2; i*i <= N; i++){
//         int x = 0;
//         while(N%i == 0){
//             N/=i;
//             ++x;
//         }
//         fs.emplace_back(i,x);
//     }
//     if(N != 1) fs.emplace_back(N,1);

//     int ans = 0;
//     for(auto p : fs) {
//         int x = p.second;
//         int b = 1;
//         while(b <= x){
//             x -= b;
//             b++;
//             ++ans;
//         }
//     }
//     cout << ans << endl;
// }

int main() {
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

long long n;

int solve(int x) {
  int s = 0, i = 0;
  while (s <= x) {
    i++;
    s += i;
  }
  return i - 1;
}

void process() {
  int kq = 0;
  int dem = 0;
  while (n % 2 == 0) {
    dem++;
    n /= 2;
  }
  kq += solve(dem);
  for (int i = 3; i * i <= n; i += 2) {
    dem = 0;
    while (n % i == 0) {
      dem++;
      n /= i;
    }
    kq += solve(dem);
  }
  if (n > 2)
    kq++;
  cout << kq;
}

int main() {
  scanf("%lld", &n);
  process();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

long long n;

int solve(int x) {
  int s = 0, i = 0;
  while (s <= x) {
    i++;
    s += i;
  }
  return i - 1;
}

void process() {
  int kq = 0;
  int dem = 0;
  while (n % 2 == 0) {
    dem++;
    n /= 2;
  }
  kq += solve(dem);
  for (long long i = 3; i * i <= n; i += 2) {
    dem = 0;
    while (n % i == 0) {
      dem++;
      n /= i;
    }
    kq += solve(dem);
  }
  if (n > 2)
    kq++;
  cout << kq;
}

int main() {
  scanf("%lld", &n);
  process();
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> fs;
  for (int i = 2; i * i <= n; i++) {
    int kosuu = 0;
    while (n % i == 0) {
      n /= i;
      kosuu++;
    }
    fs.emplace_back(i, kosuu);
  }
  if (n != 1)
    fs.emplace_back(n, 1);
  int ans = 0;
  for (auto p : fs) {
    int i = 1;
    while (p.second - i >= 0) {
      p.second -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> fs;
  for (ll i = 2; i * i <= n; i++) {
    int kosuu = 0;
    while (n % i == 0) {
      n /= i;
      kosuu++;
    }
    fs.emplace_back(i, kosuu);
  }
  if (n != 1)
    fs.emplace_back(n, 1);
  int ans = 0;
  for (auto p : fs) {
    int i = 1;
    while (p.second - i >= 0) {
      p.second -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

bool isPrime(lld k) {
  if (k == 1)
    return false;

  for (int i = 2; i * i <= k; i++) {
    if (k % i == 0)
      return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  lld n = 0;
  cin >> n;

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

  int ans = 0;

  vector<lld> v;

  map<lld, int> mp;

  v.push_back(1);
  for (int i = 2; i <= 100; i++) {
    v.push_back(v.back() + i);
  }

  for (lld i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      if (isPrime(n / i) && i != n / i) {
        mp[n / i]++;
      }
      n /= i;
    }
  }

  for (auto &p : mp) {
    ans += upper_bound(ALL(v), p.second) - v.begin();
  }

  cout << max(1, ans) << '\n';

  return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define MP make_pair
#define PB push_back
#define X first
#define Y second

typedef long long int lld;
typedef pair<int, int> pii;
typedef pair<lld, lld> pll;

bool isPrime(lld k) {
  if (k == 1)
    return false;

  for (lld i = 2; i * i <= k; i++) {
    if (k % i == 0)
      return false;
  }
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  lld n = 0;
  cin >> n;

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

  int ans = 0;

  vector<lld> v;

  map<lld, int> mp;

  v.push_back(1);
  for (int i = 2; i <= 100; i++) {
    v.push_back(v.back() + i);
  }

  for (lld i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      if (isPrime(n / i) && i != n / i) {
        mp[n / i]++;
      }
      n /= i;
    }
  }

  for (auto &p : mp) {
    ans += upper_bound(ALL(v), p.second) - v.begin();
  }

  cout << max(1, ans) << '\n';

  return 0;
}

// g++ sol.cpp -o sol.out -Wall -Wextra -Wshadow -fsanitize=undefined -std=c++17
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {

  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    ll cut = 1;
    while (cut <= cnt) {
      ans++;
      cnt -= cut;
      cut++;
    }
  }
  if (n > 1)
    ans++;
  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {

  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    ll cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    ll cut = 1;
    while (cut <= cnt) {
      ans++;
      cnt -= cut;
      cut++;
    }
  }
  if (n > 1)
    ans++;
  cout << ans;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (auto p : prime_factor(N)) {
    ll x = p.second;
    ll i = 1;
    while (x >= i) {
      x -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (auto p : prime_factor(N)) {
    ll x = p.second;
    ll i = 1;
    while (x >= i) {
      x -= i;
      i++;
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

// 素数判定
// から派生して、最初の約数を返す
int isPrime(ll a) {
  if (a == 1)
    return 1;
  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0)
      return i;
  }
  return -1;
}

void solve() {
  ll n;
  cin >> n;

  ll first_prime = isPrime(n);
  if (first_prime <= 0) {
    cout << 1;
    return;
  }
  if (first_prime == 1) {
    cout << 0;
    return;
  }

  map<ll, ll> mp;

  int ans = 0;
  for (int i = first_prime; i <= n; i++) {
    while (n % i == 0) {
      // cout << i << " ";
      mp[i]++;
      n /= i;
    }
  }

  for (auto &m : mp) {
    // cout << m.first << " : " << m.second << endl;
    int i = 1;
    while (m.second >= i) {
      m.second -= i;
      ++i;
      ++ans;
    }
  }
  cout << ans;
}

int main() {
  fastio;
  solve();

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

// 素数判定
// から派生して、最初の約数を返す
int isPrime(ll a) {
  if (a == 1)
    return 1;
  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0)
      return i;
  }
  return -1;
}

void solve() {
  ll n;
  cin >> n;

  ll first_prime = isPrime(n);
  if (first_prime <= 0) {
    cout << 1;
    return;
  }
  if (first_prime == 1) {
    cout << 0;
    return;
  }

  map<ll, ll> mp;

  int ans = 0;
  for (int i = first_prime; i <= n; i = isPrime(n)) {
    if (i == 1) {
      break;
    }
    if (i == -1) {
      mp[n]++;
      break;
    }
    while (n % i == 0) {
      // cout << i << " ";
      mp[i]++;
      n /= i;
    }
  }

  for (auto &m : mp) {
    // cout << m.first << " : " << m.second << endl;
    int i = 1;
    while (m.second >= i) {
      m.second -= i;
      ++i;
      ++ans;
    }
  }
  cout << ans;
}

int main() {
  fastio;
  solve();

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  vector<int> prm(1);
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        prm.back()++;
        n /= i;
      }
      prm.push_back(0);
    }
  }
  if (n > 1ll)
    prm.back()++;
  ll cnt = 0;
  for (int x : prm) {
    int prev = 0;
    for (int i = 1; i <= x; i++) {
      if (i * (i + 1) / 2 <= x)
        prev = i;
      else
        break;
    }
    cnt += prev;
  }
  cout << cnt;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  vector<int> prm(1);
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        prm.back()++;
        n /= i;
      }
      prm.push_back(0);
    }
  }
  if (n > 1ll)
    prm.back()++;
  ll cnt = 0;
  for (int x : prm) {
    int prev = 0;
    for (int i = 1; i <= x; i++) {
      if (i * (i + 1) / 2 <= x)
        prev = i;
      else
        break;
    }
    cnt += prev;
  }
  cout << cnt;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  long long n;
  cin >> n;
  int ans = 0;
  long long _n = n;
  for (int i = 2; i * i <= _n; i++)
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      // cout << i << ' ' << cnt << endl;
      for (int j = 1; cnt > 0; j++) {
        if (cnt < j)
          break;
        ans++;
        cnt -= j;
      }
    }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  long long n;
  cin >> n;
  int ans = 0;
  long long _n = n;
  for (int i = 2; (long long)i * i <= _n; i++)
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      // cout << i << ' ' << cnt << endl;
      for (int j = 1; cnt > 0; j++) {
        if (cnt < j)
          break;
        ans++;
        cnt -= j;
      }
    }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int prime_factrization(ll n) {
  vector<int> prime_num(int(sqrt(n)) + 1);
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      prime_num[i]++;
      n /= i;
    }
    int num = 1;
    while (prime_num[i] >= num) {
      prime_num[i] -= num;
      num++;
      ans++;
    }
  }
  if (n != 1)
    ans++;
  return ans;
}

int main() {
  ll N;
  cin >> N;
  int ans = prime_factrization(N);

  if (N != 1 && ans == 0)
    cout << 1 << endl;
  else
    cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int prime_factrization(ll n) {
  vector<int> prime_num(int(sqrt(n)) + 1);
  int ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      prime_num[i]++;
      n /= i;
    }
    int num = 1;
    while (prime_num[i] >= num) {
      prime_num[i] -= num;
      num++;
      ans++;
    }
  }
  if (n != 1)
    ans++;
  return ans;
}

int main() {
  ll N;
  cin >> N;
  int ans = prime_factrization(N);

  if (N != 1 && ans == 0)
    cout << 1 << endl;
  else
    cout << ans << endl;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
// c++ テンプレ
#include <bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef unsigned long LInt;
typedef long double ld;

#define inf 1e18
constexpr long long INFLL = 1e18;
#define mod 1000000007
priority_queue<llint, vector<llint>, greater<llint>> que;
priority_queue<llint> Que;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

map<llint, llint> mp;
bool prime[1000005];

void solve() {
  llint n;
  cin >> n;

  for (int i = 2; i < 1000005; i++) {
    if (prime[i])
      continue;
    for (int j = 2 * i; j < 1000005; j += i)
      prime[j] = true;
  }

  for (int i = 2; i < n; i++) {
    if (prime[i])
      continue;
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n > 1)
    mp[n]++;
  llint ans = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    for (int i = 1;; i++) {
      if (it->second >= i) {
        ans++;
        it->second -= i;
      } else
        break;
    }
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}


Fixed submission:
// c++ テンプレ
#include <bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef unsigned long LInt;
typedef long double ld;

#define inf 1e18
constexpr long long INFLL = 1e18;
#define mod 1000000007
priority_queue<llint, vector<llint>, greater<llint>> que;
priority_queue<llint> Que;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

map<llint, llint> mp;
bool prime[1000005];

void solve() {
  llint n;
  cin >> n;

  for (int i = 2; i < 1000005; i++) {
    if (prime[i])
      continue;
    for (int j = 2 * i; j < 1000005; j += i)
      prime[j] = true;
  }

  for (int i = 2; i < 1000005; i++) {
    if (prime[i])
      continue;
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n > 1)
    mp[n]++;
  llint ans = 0;
  for (auto it = mp.begin(); it != mp.end(); it++) {
    for (int i = 1;; i++) {
      if (it->second >= i) {
        ans++;
        it->second -= i;
      } else
        break;
    }
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;

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

  vector<int> pf;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i)
      continue;
    int cnt = 0;
    while (n % i == 0) {
      ++cnt;
      n /= i;
    }
    pf.push_back(cnt);
  }
  if (n != 1) {
    pf.push_back(1);
  }

  int ans = 0;
  for (auto e : pf) {
    for (int i = 1; i <= e; ++i) {
      e -= i;
      ++ans;
    }
  }

  cout << ans << endl;
}


Fixed submission:
#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;

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

  vector<int> pf;
  for (int64_t i = 2; i * i <= n; ++i) {
    if (n % i)
      continue;
    int cnt = 0;
    while (n % i == 0) {
      ++cnt;
      n /= i;
    }
    pf.push_back(cnt);
  }
  if (n != 1) {
    pf.push_back(1);
  }

  int ans = 0;
  for (auto e : pf) {
    for (int i = 1; i <= e; ++i) {
      e -= i;
      ++ans;
    }
  }

  cout << ans << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1000000007;
const ll mod = 1000000007;
const double PI = 3.14159265358979323846;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int cans(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

vector<pair<long long, long long>> prime_factorization(ll N) {
  vector<pair<long long, long long>> res;
  for (int p = 2; p * p <= N; p++) {
    if (N % p != 0)
      continue;
    int ex = 0; // exponetial part
    while (N % p == 0) {
      ex++;
      N /= p;
    }
    res.push_back({p, ex});
  }
  if (N != 1) {
    res.push_back({N, 1});
  }
  return res;
}
int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> a;
  a = prime_factorization(N);

  ll ans = 0;
  for (auto it : a) {
    ll num = it.second;
    ll cnt = 1;
    ll tmp = 0;
    while (num >= cnt) {
      num -= cnt;
      cnt++;
      tmp++;
    }
    ans += tmp;
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1000000007;
const ll mod = 1000000007;
const double PI = 3.14159265358979323846;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int cans(bool f) {
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

vector<pair<long long, long long>> prime_factorization(ll N) {
  vector<pair<long long, long long>> res;
  for (ll p = 2; p * p <= N; p++) {
    if (N % p != 0)
      continue;
    int ex = 0; // exponetial part
    while (N % p == 0) {
      ex++;
      N /= p;
    }
    res.push_back({p, ex});
  }
  if (N != 1) {
    res.push_back({N, 1});
  }
  return res;
}
int main() {
  ll N;
  cin >> N;
  vector<pair<ll, ll>> a;
  a = prime_factorization(N);

  ll ans = 0;
  for (auto it : a) {
    ll num = it.second;
    ll cnt = 1;
    ll tmp = 0;
    while (num >= cnt) {
      num -= cnt;
      cnt++;
      tmp++;
    }
    ans += tmp;
  }

  cout << ans << endl;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
#define pri(str) cout << str << endl
using ll = long long;
using P = pair<int, int>;

const ll MX = 1e18;
const long double PI = acos(-1);

vector<pair<ll, int>> divisor(ll n) {
  vector<pair<ll, int>> ret;
  for (ll i = 1; i * i <= n; ++i) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      ++x;
    }
    ret.emplace_back(i, x);
  }
  if (n != 1)
    ret.emplace_back(n, 1);
  return ret;
}

int main() {
  ll n;
  cin >> n;
  auto fs = divisor(n);

  int ans = 0;
  for (auto a : fs) {
    int x = a.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      ++b;
      ++ans;
    }
  }
  pri(ans);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
#define pri(str) cout << str << endl
using ll = long long;
using P = pair<int, int>;

const ll MX = 1e18;
const long double PI = acos(-1);

vector<pair<ll, int>> divisor(ll n) {
  vector<pair<ll, int>> ret;
  for (ll i = 2; i * i <= n; ++i) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      ++x;
    }
    ret.emplace_back(i, x);
  }
  if (n != 1)
    ret.emplace_back(n, 1);
  return ret;
}

int main() {
  ll n;
  cin >> n;
  auto fs = divisor(n);

  int ans = 0;
  for (auto a : fs) {
    int x = a.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      ++b;
      ++ans;
    }
  }
  pri(ans);
  return 0;
}