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

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

#define pll pair<ll, ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5 + 1;
map<ll, ll> m;

void prime(ll n) {
  while (n > 1 && n % 2 == 0) {
    n /= 2;
    m[2]++;
  }

  for (int i = 3; i * i <= n; i += 2) {
    while (n % i == 0) {
      n /= i;
      m[i]++;
    }
  }

  if (n > 2)
    m[n]++;
}

void solve() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0;
    return;
  }
  prime(n);
  ll ans = 0;
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    ll k = (*itr).ff;
    ll c_val = 1;
    while (m[k] > 0) {
      if (m[k] - c_val < c_val + 1) {
        ans++;
        break;
      } else {
        ans++;
      }
      m[k] -= c_val;
      c_val++;
    }
  }
  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
  return 0;
}

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

#define pll pair<ll, ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5 + 1;
map<ll, ll> m;

void prime(ll n) {
  while (n > 1 && n % 2 == 0) {
    n /= 2;
    m[2]++;
  }

  for (ll i = 3; i * i <= n; i += 2) {
    while (n % i == 0) {
      n /= i;
      m[i]++;
    }
  }

  if (n > 2)
    m[n]++;
}

void solve() {
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0;
    return;
  }
  prime(n);
  ll ans = 0;
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    ll k = (*itr).ff;
    ll c_val = 1;
    while (m[k] > 0) {
      if (m[k] - c_val < c_val + 1) {
        ans++;
        break;
      } else {
        ans++;
      }
      m[k] -= c_val;
      c_val++;
    }
  }
  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  // cin>>t;
  while (t--) {
    solve();
  }
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<int> fc;
  for (int i = 2; i * i < N; i++) {
    if (N % i == 0) {
      int cnt = 0;
      while (N % i == 0) {
        cnt++;
        N /= i;
      }
      fc.push_back(cnt);
    }
  }
  if (N != 1) {
    fc.push_back(1);
  }
  int M = fc.size();
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int t = 0;
    int f = 10000;
    while (f - t > 1) {
      int m = (f + t) / 2;
      if (m * (m + 1) / 2 <= fc[i]) {
        t = m;
      } else {
        f = m;
      }
    }
    ans += t;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  vector<int> fc;
  for (long long i = 2; i * i < N; i++) {
    if (N % i == 0) {
      int cnt = 0;
      while (N % i == 0) {
        cnt++;
        N /= i;
      }
      fc.push_back(cnt);
    }
  }
  if (N != 1) {
    fc.push_back(1);
  }
  int M = fc.size();
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int t = 0;
    int f = 10000;
    while (f - t > 1) {
      int m = (f + t) / 2;
      if (m * (m + 1) / 2 <= fc[i]) {
        t = m;
      } else {
        f = m;
      }
    }
    ans += t;
  }
  cout << ans << endl;
}
Problem p02660 (C++)

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

int solve(long long n) {
  if (n == 1) {
    return 0;
  }
  vector<int> f;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      f.push_back(i);
      n /= i;
    }
  }
  if (n > 1)
    f.push_back(n);

  int ans = 0;
  int i = 0;
  while (i < f.size()) {
    int j = i + 1;
    while (j < f.size() && f.at(j) == f.at(i))
      j++;
    int count = j - i;
    i = j;
    int sum = 0;
    for (int x = 1; count >= sum + x; x++, ans++)
      sum += x;
  }
  return ans;
}

int main() {
  long long n;
  cin >> n;
  cout << solve(n) << endl;
}

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

int solve(long long n) {
  if (n == 1) {
    return 0;
  }
  vector<long long> f;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      f.push_back(i);
      n /= i;
    }
  }
  if (n > 1)
    f.push_back(n);

  int ans = 0;
  int i = 0;
  while (i < f.size()) {
    int j = i + 1;
    while (j < f.size() && f.at(j) == f.at(i))
      j++;
    int count = j - i;
    i = j;
    int sum = 0;
    for (int x = 1; count >= sum + x; x++, ans++)
      sum += x;
  }
  return ans;
}

int main() {
  long long n;
  cin >> n;
  cout << solve(n) << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
//-----------------------
// author : xyqkoala
// time : 2020-07-23
//-----------------------

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long LL;
const int MOD = 1e9 + 7;

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int T = 1;
  // cin>>T;
  while (T--) {
    solve();
  }
  return 0;
}

void solve() {
  LL n;
  cin >> n;
  unordered_map<int, int> t;
  for (int i = 2; i * i <= n; i++) {
    if (n % i)
      continue;
    while (n % i == 0) {
      n = n / i;
      t[i]++;
    }
  }
  if (n > 1)
    t[n]++;
  int res = 0;
  for (auto item : t) {
    int cnt = 2 * item.second;
    int tcnt = sqrt(cnt);
    if ((tcnt * (tcnt + 1) > cnt))
      tcnt--;
    res += tcnt;
  }
  cout << res << endl;
}


Fixed submission:
//-----------------------
// author : xyqkoala
// time : 2020-07-23
//-----------------------

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long LL;
const int MOD = 1e9 + 7;

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int T = 1;
  // cin>>T;
  while (T--) {
    solve();
  }
  return 0;
}

void solve() {
  LL n;
  cin >> n;
  unordered_map<int, int> t;
  for (LL i = 2; i * i <= n; i++) {
    if (n % i)
      continue;
    while (n % i == 0) {
      n = n / i;
      t[i]++;
    }
  }
  if (n > 1)
    t[n]++;
  int res = 0;
  for (auto item : t) {
    int cnt = 2 * item.second;
    int tcnt = sqrt(cnt);
    if ((tcnt * (tcnt + 1) > cnt))
      tcnt--;
    res += tcnt;
  }
  cout << res << endl;
}
Problem p02660 (C++)

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

// ----本問について----
// 問題：
// 問題文URL：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ll n;

vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ans;
  ll index = -1;
  for (ll i = 2; i <= n; i++) {
    if (index == -1 && i > sqrt(n)) {
      ans.push_back(make_pair(n, 1));
      break;
    }
    if (n % i == 0) {
      ans.push_back(make_pair(i, 0));
      index++;
    }
    while (n % i == 0) {
      n /= i;
      ans[index].second++;
    }
  }
  return ans;
}

void solve() {
  vector<pair<ll, ll>> a = primeFac(n);
  ll ans = 0;
  rep(i, a.size()) {
    ll index = a[i].second;
    ll m = 0;
    while (index >= (m + 1) * (m + 2) / 2) {
      m++;
    }
    ans += m;
    // cout << "底:" << a[i].first << " 指数:" << index << " m:" << m << endl;
  }
  cout << ans << endl;
}

int main() {
  cin >> n;
  solve();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define vl vector<long long>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：
// 問題文URL：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ll n;

vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ans;
  ll index = -1;
  for (ll i = 2; i <= n; i++) {
    if (i > sqrt(n)) {
      ans.push_back(make_pair(n, 1));
      break;
    }
    if (n % i == 0) {
      ans.push_back(make_pair(i, 0));
      index++;
    }
    while (n % i == 0) {
      n /= i;
      ans[index].second++;
    }
  }
  return ans;
}

void solve() {
  vector<pair<ll, ll>> a = primeFac(n);
  ll ans = 0;
  rep(i, a.size()) {
    ll index = a[i].second;
    ll m = 0;
    while (index >= (m + 1) * (m + 2) / 2) {
      m++;
    }
    ans += m;
    // cout << "底:" << a[i].first << " 指数:" << index << " m:" << m << endl;
  }
  cout << ans << endl;
}

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false),
            cout << fixed << setprecision(9), 0);
// int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv
// ./prog.exe") >> 8), 0);
int main() {
  Int N;
  cin >> N;
  Int ans = 0;
  for (int p = 2; p * p <= N; p++) {
    int cnt = 0;
    while (N % p == 0)
      cnt++, N /= p;
    for (int i = 1; i <= cnt; i++) {
      ans += 1, cnt -= i;
    }
  }
  if (N != 1)
    ans += 1;
  cout << ans << '\n';
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false),
            cout << fixed << setprecision(9), 0);
// int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv
// ./prog.exe") >> 8), 0);
int main() {
  Int N;
  cin >> N;
  Int ans = 0;
  for (Int p = 2; p * p <= N; p++) {
    int cnt = 0;
    while (N % p == 0)
      cnt++, N /= p;
    for (int i = 1; i <= cnt; i++) {
      ans += 1, cnt -= i;
    }
  }
  if (N != 1)
    ans += 1;
  cout << ans << '\n';
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
// 高知能系Vtuberの高井茅乃です。
// Twitter: https://twitter.com/takaichino
// YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i <= n; i++)
#define MODA 1000000007

int main() {
  // エラトステネスの篩でP_max以下の素数vector primeをつくる
  bool *pr;
  ll P_max = 1000000; // 10^6くらいまでが現実的か
  pr = (bool *)malloc(sizeof(bool) * (P_max + 1));
  REP(i, P_max + 1) pr[i] = true;
  pr[0] = false;
  pr[1] = false;
  for (ll i = 2; i * i <= P_max; i++) {
    if (pr[i] == true) {
      for (ll j = 2 * i; j <= P_max; j += i) {
        pr[j] = false;
      }
    }
  }
  vector<ll> prime;
  for (ll i = 2; i <= P_max; i++) {
    if (pr[i])
      prime.push_back(i);
  }
  //
  ll n;
  cin >> n;
  // 整数Xの素因数分解の結果をmapで返す。上のvector primeはもちろんいる
  ll X = n;
  ll diving = X; // これをどんどん割っていく。dividingが正しい
  map<ll, ll> prf;
  for (ll i = 0; diving > 1 && prime[i] * prime[i] <= X; i++) {
    while (diving % prime[i] == 0) {
      diving /= prime[i];
      prf[prime[i]]++;
    }
  }
  if (diving > 1)
    prf[diving]++;
  // これは素因数分解の結果が見たくなったときに使うもの
  // for(auto i = prf.begin(); i!= prf.end(); i++) cout << i->first << "," <<
  // i->second << " "; cout << endl;
  //
  ll re = 0;
  ll ans = 0;
  for (auto i = prf.begin(); i != prf.end(); i++) {
    for (re = 1; re <= i->second; re++) {
      ans++;
      i->second -= re;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
// 高知能系Vtuberの高井茅乃です。
// Twitter: https://twitter.com/takaichino
// YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i, n) for (int i = 0; i < n; i++)
#define REP1(i, n) for (int i = 1; i <= n; i++)
#define MODA 1000000007

int main() {
  // エラトステネスの篩でP_max以下の素数vector primeをつくる
  bool *pr;
  ll P_max = 2000000; // 10^6くらいまでが現実的か
  pr = (bool *)malloc(sizeof(bool) * (P_max + 1));
  REP(i, P_max + 1) pr[i] = true;
  pr[0] = false;
  pr[1] = false;
  for (ll i = 2; i * i <= P_max; i++) {
    if (pr[i] == true) {
      for (ll j = 2 * i; j <= P_max; j += i) {
        pr[j] = false;
      }
    }
  }
  vector<ll> prime;
  for (ll i = 2; i <= P_max; i++) {
    if (pr[i])
      prime.push_back(i);
  }
  //
  ll n;
  cin >> n;
  // 整数Xの素因数分解の結果をmapで返す。上のvector primeはもちろんいる
  ll X = n;
  ll diving = X; // これをどんどん割っていく。dividingが正しい
  map<ll, ll> prf;
  for (ll i = 0; diving > 1 && prime[i] * prime[i] <= X; i++) {
    while (diving % prime[i] == 0) {
      diving /= prime[i];
      prf[prime[i]]++;
    }
  }
  if (diving > 1)
    prf[diving]++;
  // これは素因数分解の結果が見たくなったときに使うもの
  // for(auto i = prf.begin(); i!= prf.end(); i++) cout << i->first << "," <<
  // i->second << " "; cout << endl;
  //
  ll re = 0;
  ll ans = 0;
  for (auto i = prf.begin(); i != prf.end(); i++) {
    for (re = 1; re <= i->second; re++) {
      ans++;
      i->second -= re;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
  long long N;
  cin >> N;

  unordered_map<long long, int> factor;

  long long a = 2;

  long long N0 = N;

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

  while (N > 1) {
    if (N % a == 0) {
      N /= a;
      factor[a] += 1;
    } else {
      a++;

      if (N0 < a * a) {
        a = N0;
      }
    }
  }

  int count = 0;

  for (const auto &f : factor) {
    int e_sum = f.second;

    int e = 1;

    while (true) {
      if (e_sum >= e) {
        count++;
        e_sum -= e;
        e++;
      } else {
        break;
      }
    }
  }

  cout << count << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <unordered_map>

using namespace std;

int main() {
  long long N;
  cin >> N;

  unordered_map<long long, int> factor;

  long long a = 2;

  long long N0 = N;

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

  while (N > 1) {
    if (N % a == 0) {
      N /= a;
      factor[a] += 1;
    } else {
      a++;

      if (N < a * a) {
        a = N;
      }
    }
  }

  int count = 0;

  for (const auto &f : factor) {
    int e_sum = f.second;

    int e = 1;

    while (true) {
      if (e_sum >= e) {
        count++;
        e_sum -= e;
        e++;
      } else {
        break;
      }
    }
  }

  cout << count << endl;

  return 0;
}
Problem p02660 (C++)

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

int main() {
  cin >> n;
  if (n == 1) {
    cout << 0;
    return 0;
  }

  ll cnt = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ll times = 0;
      while (n % i == 0) {
        n /= i;
        times++;
      }
      ll t = 1;
      while (t <= times) {
        cnt++;
        times -= t;
        t++;
      }
    }
  }
  if (n != 1)
    cnt++;

  cout << cnt;
  return 0;
}


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

int main() {
  cin >> n;
  if (n == 1) {
    cout << 0;
    return 0;
  }

  ll cnt = 0;
  if (n % 2 == 0) {
    ll times = 0;
    while (n % 2 == 0) {
      n /= 2;
      times++;
    }
    ll t = 1;
    while (t <= times) {
      cnt++;
      times -= t;
      t++;
    }
  }

  for (ll i = 3; i * i <= n; i += 2) {
    if (n % i == 0) {
      ll times = 0;
      while (n % i == 0) {
        n /= i;
        times++;
      }
      ll t = 1;
      while (t <= times) {
        cnt++;
        times -= t;
        t++;
      }
    }
  }
  if (n != 1)
    cnt++;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  int cnt = 0;
  cin >> n;
  int cnt2 = 0;
  vector<pair<long, long>> v(0);
  for (int i = 2; i * i < n; i++) {
    while (n % i == 0) {
      cnt++;
      n = n / i;
    }
    if (cnt != 0)
      v.push_back(make_pair(i, cnt));
    cnt = 0;
  }
  if (n != 1)
    v.push_back(make_pair(n, 1));
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < 1000; j++) {
      if (j * (j + 1) / 2 > v[i].second) {
        cnt2 += j - 1;
        break;
      }
    }
  }

  cout << cnt2 << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  int cnt = 0;
  cin >> n;
  int cnt2 = 0;
  vector<pair<long, long>> v(0);
  for (long i = 2; i * i < n; i++) {
    while (n % i == 0) {
      cnt++;
      n = n / i;
    }
    if (cnt != 0)
      v.push_back(make_pair(i, cnt));
    cnt = 0;
  }
  if (n != 1)
    v.push_back(make_pair(n, 1));
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < 1000; j++) {
      if (j * (j + 1) / 2 > v[i].second) {
        cnt2 += j - 1;
        break;
      }
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
#define LL long long
int p[50], m[50], tot;
int main() {
  LL n;
  int i, j, ans = 0;
  scanf("%lld", &n);
  for (i = 2; i * i <= n; i++)
    if (n % i == 0) {
      p[++tot] = i;
      while (n % i == 0)
        n /= i, m[tot]++;
    }
  if (n > 1)
    p[++tot] = n, m[tot] = 1;
  for (i = 1; i <= tot; i++) {
    j = 1;
    while (1) {
      if (m[i] >= j)
        ans++, m[i] -= j;
      else
        break;
      j++;
    }
  }
  printf("%d\n", ans);
  return 0;
}

Fixed submission:
#include <stdio.h>
#define LL long long
int p[50], m[50], tot;
int main() {
  LL n;
  int i, j, ans = 0;
  scanf("%lld", &n);
  for (i = 2; (LL)i * i <= n; i++)
    if (n % i == 0) {
      p[++tot] = i;
      while (n % i == 0)
        n /= i, m[tot]++;
    }
  if (n > 1)
    p[++tot] = n, m[tot] = 1;
  for (i = 1; i <= tot; i++) {
    j = 1;
    while (1) {
      if (m[i] >= j)
        ans++, m[i] -= j;
      else
        break;
      j++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
Problem p02660 (C++)

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

int main() {
  int64_t n;
  cin >> n;
  int total = 0; // ｚの合計
  int64_t i = 2;
  while (n > 1) {
    int count = 1; // 各素因数におけるeのパターン数
    for (int j = 1; n % i == 0; j++) {
      if (j == count * (count + 1) / 2) {
        total++;
        count++;
      }
      n /= i;
    }
    if (i == 2)
      i++;
    else
      i += 2;
  }

  cout << total << endl;
}


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

int main() {
  int64_t n;
  cin >> n;
  int total = 0; // ｚの合計
  int64_t i = 2;
  while (n > 1) {
    if (i > 1000000) {
      total++;
      break;
    }

    int count = 1; // 各素因数におけるeのパターン数
    for (int j = 1; n % i == 0; j++) {
      if (j == count * (count + 1) / 2) {
        total++;
        count++;
      }
      n /= i;
    }
    if (i == 2)
      i++;
    else
      i += 2;
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <cmath>
#include <ctime>
#include <map>
#include <math.h>
#include <typeinfo>
#define R(i, n) for (int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

map<ll, int> primeFactor(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;
  SL(N);
  map<ll, int> m = primeFactor(N);
  int ans = 0;
  for (auto x : m) {
    int e = 1;
    while (x.second - e >= 0) {
      ans++;
      x.second -= e;
      e++;
    }
  }
  P(ans);
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <cmath>
#include <ctime>
#include <map>
#include <math.h>
#include <typeinfo>
#define R(i, n) for (int i = 0; i < n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", &a[i])
#define SAL(i, n, a) R(i, n) scanf("%lld", &a[i])
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

map<ll, int> primeFactor(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;
  SL(N);
  map<ll, int> m = primeFactor(N);
  int ans = 0;
  for (auto x : m) {
    int e = 1;
    while (x.second - e >= 0) {
      ans++;
      x.second -= e;
      e++;
    }
  }
  P(ans);
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>

int f[50];
long long n;
int res = 0;

int main() {
  for (int i = 1; i < 10; i++) {
    f[i * (i + 1) / 2] = i;
  }
  for (int i = 1; i < 50; i++) {
    if (f[i] < f[i - 1]) {
      f[i] = f[i - 1];
    }
  }
  scanf("%lld", &n);
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      res += f[cnt];
    }
  }
  if (n != 1) {
    res += f[1];
  }
  printf("%d\n", res);
}


Fixed submission:
#include <cstdio>

int f[50];
long long n;
int res = 0;

int main() {
  for (int i = 1; i < 10; i++) {
    f[i * (i + 1) / 2] = i;
  }
  for (int i = 1; i < 50; i++) {
    if (f[i] < f[i - 1]) {
      f[i] = f[i - 1];
    }
  }
  scanf("%lld", &n);
  for (int i = 2; 1ll * i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      res += f[cnt];
    }
  }
  if (n != 1) {
    res += f[1];
  }
  printf("%d\n", res);
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
inline void qread() {}
template <class T1, class... T2> inline void qread(T1 &IEE, T2 &...ls) {
  register T1 __ = 0, ___ = 1;
  register char ch;
  while (!isdigit(ch = getchar()))
    ___ = (ch == '-') ? -___ : ___;
  do {
    __ = (__ << 1) + (__ << 3) + (ch ^ 48);
  } while (isdigit(ch = getchar()));
  __ *= ___;
  IEE = __;
  qread(ls...);
  return;
}
ll n, ans;
ll f[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= 10; i++) {
    f[i] = i * (i + 1) / 2;
  }
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    int id = lower_bound(f + 1, f + 11, cnt) - f;
    if (f[id] > cnt)
      id--;
    ans += id;
  }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 1e5 + 5;
const ll maxm = 1e3 + 5;
inline void qread() {}
template <class T1, class... T2> inline void qread(T1 &IEE, T2 &...ls) {
  register T1 __ = 0, ___ = 1;
  register char ch;
  while (!isdigit(ch = getchar()))
    ___ = (ch == '-') ? -___ : ___;
  do {
    __ = (__ << 1) + (__ << 3) + (ch ^ 48);
  } while (isdigit(ch = getchar()));
  __ *= ___;
  IEE = __;
  qread(ls...);
  return;
}
ll n, ans;
ll f[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= 10; i++) {
    f[i] = i * (i + 1) / 2;
  }
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    int id = lower_bound(f + 1, f + 11, cnt) - f;
    if (f[id] > cnt)
      id--;
    ans += id;
  }
  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 int64_t ll;

vector<ll> factors(ll N) {
  vector<ll> ret;

  if (N % 2 == 0) {
    ret.push_back(2);
    while (N % 2 == 0)
      N /= 2;
  }

  ll root = sqrt(N);
  for (ll p = 3; p <= root; p += 2) {
    if (N % p)
      continue;
    ret.push_back(p);
    while (N % p == 0)
      N /= p;
  }

  if (N > 1)
    ret.push_back(N);
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  ll N;
  cin >> N;

  ll score = 0;
  for (ll p : factors(N)) {
    // divide out increasing powers of p
    for (ll q = p; N % q == 0; q *= p) {
      N /= q;
      score++;
    }
    // leftover power of p
    if (N % p == 0)
      N /= p;
  }

  assert(N == 1);
  cout << score << endl;
}


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

vector<ll> factors(ll N) {
  vector<ll> ret;

  if (N % 2 == 0) {
    ret.push_back(2);
    while (N % 2 == 0)
      N /= 2;
  }

  ll root = sqrt(N);
  for (ll p = 3; p <= root; p += 2) {
    if (N % p)
      continue;
    ret.push_back(p);
    while (N % p == 0)
      N /= p;
  }

  if (N > 1)
    ret.push_back(N);
  return ret;
}

int main() {
  ios_base::sync_with_stdio(false);
  ll N;
  cin >> N;

  ll score = 0;
  for (ll p : factors(N)) {
    // divide out increasing powers of p
    for (ll q = p; N % q == 0; q *= p) {
      N /= q;
      score++;
    }
    // leftover powers of p
    while (N % p == 0)
      N /= p;
  }

  assert(N == 1);
  cout << score << endl;
}
Problem p02660 (C++)

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a, int64_t b) { return (a % b == 0 ? b : gcd(b, a % b)); }
int64_t lcm(int64_t a, int64_t b) { return a / gcd(a, b) * b; }
int factorial(int a) {
  int b = 1;
  while (a) {
    b *= a--;
  }
  return b;
} // 13以下対応
bool is_prime(int64_t a) {
  if (a <= 1)
    return false;
  for (int64_t i = 2; (int64_t)i * i <= a; i++) {
    if (a % i == 0)
      return false;
  }
  return true;
}
int get_adp(double x, int n) {
  return (int)round((x - (int)x) * pow(10, n)) % 10;
} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n) { return n * (2 * s + n - 1) / 2; }

// 順列の全列挙
//  vector<int> v(N);
//  iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
//  do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
//  } while( next_permutation(v.begin(), v.end()) );

// bit全探索
//  for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
//  }

int main() {
  int64_t n, ans = 0, temp;

  cin >> n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    temp = i;
    while (n % temp == 0) {
      n /= temp;
      ans++;
      temp *= i;
    }
    while (n % i == 0)
      n /= i;
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}

// 6534603030013

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a, int64_t b) { return (a % b == 0 ? b : gcd(b, a % b)); }
int64_t lcm(int64_t a, int64_t b) { return a / gcd(a, b) * b; }
int factorial(int a) {
  int b = 1;
  while (a) {
    b *= a--;
  }
  return b;
} // 13以下対応
bool is_prime(int64_t a) {
  if (a <= 1)
    return false;
  for (int64_t i = 2; (int64_t)i * i <= a; i++) {
    if (a % i == 0)
      return false;
  }
  return true;
}
int get_adp(double x, int n) {
  return (int)round((x - (int)x) * pow(10, n)) % 10;
} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n) { return n * (2 * s + n - 1) / 2; }

// 順列の全列挙
//  vector<int> v(N);
//  iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
//  do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
//  } while( next_permutation(v.begin(), v.end()) );

// bit全探索
//  for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
//  }

int main() {
  int64_t n, ans = 0, temp;

  cin >> n;
  for (int64_t i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    temp = i;
    while (n % temp == 0) {
      n /= temp;
      ans++;
      temp *= i;
    }
    while (n % i == 0)
      n /= i;
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}

// 6534603030013
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <map>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#define inf 1e9 + 7
using namespace std;
typedef long long ll;
const double pi = acos(-1);

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n;
  cin >> n;
  map<int, int> mp;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      mp[i]++;
      n /= i;
      i--;
    }
  }
  if (n != 1)
    mp[n]++;
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    for (int i = 1; itr->second >= i; i++) {
      ans++;
      itr->second -= i;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <map>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
#define inf 1e9 + 7
using namespace std;
typedef long long ll;
const double pi = acos(-1);

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      mp[i]++;
      n /= i;
      i--;
    }
  }
  if (n != 1)
    mp[n]++;
  int ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    for (int i = 1; itr->second >= i; i++) {
      ans++;
      itr->second -= i;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll n;
  cin >> n;
  int 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++;
    }
    for (ll j = 1;; j++) {
      if (cnt >= j) {
        cnt -= j;
        ans++;
      } else
        break;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}

Fixed submission:
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using ll = long long;

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++;
    }
    for (ll j = 1;; j++) {
      if (cnt >= j) {
        cnt -= j;
        ans++;
      } else
        break;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i, n) for (int i = 0; i < n; i++)

int Prime_factorize(ll n) {
  int cnt = 0;
  for (int i = 2; i * i <= n; i++) {
    int th = 1;
    int now = 0;
    while (n % i == 0) {
      now++;
      if (th == now) {
        cnt++;
        now = 0;
        th++;
      }
      n /= i;
    }
    if (i != 2)
      i++;
  }
  if (n != 1)
    cnt++;
  return cnt;
}

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

  int cnt = Prime_factorize(n);

  cout << cnt << endl;

  return 0;
}

Fixed submission:
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i, n) for (int i = 0; i < n; i++)

int Prime_factorize(ll n) {
  int cnt = 0;
  for (ll i = 2; i * i <= n; i++) {
    int th = 1;
    int now = 0;
    while (n % i == 0) {
      now++;
      if (th == now) {
        cnt++;
        now = 0;
        th++;
      }
      n /= i;
    }
    if (i != 2)
      i++;
  }
  if (n != 1)
    cnt++;
  return cnt;
}

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

  int cnt = Prime_factorize(n);

  cout << cnt << endl;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1001001001;
vector<pair<int64_t, int64_t>> func(int64_t x) {
  vector<pair<int64_t, int64_t>> p;
  for (int i = 2; i * i <= x; i++) {
    int cnt = 0;
    if (x % i == 0) {
      while (x % i == 0) {
        cnt++;
        x /= i;
      }
      p.push_back(make_pair(i, cnt));
    }
  }
  if (x != 1) {
    p.push_back(make_pair(x, 1));
  }
  return p;
}

int main() {
  int64_t N;
  cin >> N;
  auto k = func(N);
  int ans = 0;
  for (auto a : k) {
    int t = a.second;
    int tmp = 1, count = 0;
    while (t >= tmp) {
      t -= tmp;
      tmp++;
      count++;
    }
    ans += count;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int INF = 1001001001;
vector<pair<int64_t, int64_t>> func(int64_t x) {
  vector<pair<int64_t, int64_t>> p;
  for (int64_t i = 2; i * i <= x; i++) {
    int cnt = 0;
    if (x % i == 0) {
      while (x % i == 0) {
        cnt++;
        x /= i;
      }
      p.push_back(make_pair(i, cnt));
    }
  }
  if (x != 1) {
    p.push_back(make_pair(x, 1));
  }
  return p;
}

int main() {
  int64_t N;
  cin >> N;
  auto k = func(N);
  int ans = 0;
  for (auto a : k) {
    int t = a.second;
    int tmp = 1, count = 0;
    while (t >= tmp) {
      t -= tmp;
      tmp++;
      count++;
    }
    ans += count;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll N;
  cin >> N;
  int ans = 0;
  FOR(i, 2, 1000000000) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    FOR(j, 1, 10000) {
      if (cur < j)
        break;
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << "\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll N;
  cin >> N;
  int ans = 0;
  FOR(i, 2, 100000000) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    FOR(j, 1, 10000) {
      if (cur < j)
        break;
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << "\n";
  return 0;
}
Problem p02660 (C++)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
const int INF = 1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

int main() {
  ll n;
  cin >> n;
  map<int, int> primes;
  for (int p = 2; p * p <= n; p++) {
    int k = 0;
    while (n % p == 0) {
      n /= p;
      k++;
    }
    if (k > 0) {
      primes[p] = k;
    }
  }
  if (n > 1) {
    primes[n] = 1;
  }
  /*
  for(auto& prime : primes){
      cout << prime.first << " " << prime.second << endl;
  }
  */
  int ans = 0;
  for (auto prime : primes) {
    int i = 1;
    while (1) {
      if (((i + 2) * (i + 1)) > 2 * prime.second) {
        break;
      }
      i++;
    }
    // cout << i << endl;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
const int INF = 1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

int main() {
  ll n;
  cin >> n;
  map<ll, ll> primes;
  for (ll p = 2; p * p <= n; p++) {
    int k = 0;
    while (n % p == 0) {
      n /= p;
      k++;
    }
    if (k > 0) {
      primes[p] = k;
    }
  }
  if (n > 1) {
    primes[n] = 1;
  }
  /*
  for(auto& prime : primes){
      cout << prime.first << " " << prime.second << endl;
  }
  */
  int ans = 0;
  for (auto prime : primes) {
    int i = 1;
    while (1) {
      if (((i + 2) * (i + 1)) > 2 * prime.second) {
        break;
      }
      i++;
    }
    // cout << i << endl;
    ans += i;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cctype>
#include <cmath>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>

#include <algorithm>
#include <queue>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  long long n;
  cin >> n;
  long long p = 2;
  long long ans = 0;
  long long count = 1;
  long long now = 0;
  while (n > 1) {
    if (n % p == 0) {
      n /= p;
      now++;
      if (count == now) {
        ans++;
        now = 0;
        count++;
      }
    } else {
      if (p == 2) {
        p = 3;
      } else {
        p += 2;
      }
      count = 1;
      now = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <cctype>
#include <cmath>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>

#include <algorithm>
#include <queue>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  long long n;
  cin >> n;
  long long p = 2;
  long long ans = 0;
  long long count = 1;
  long long now = 0;
  while (n > 1) {
    if (n % p == 0) {
      n /= p;
      now++;
      if (count == now) {
        ans++;
        now = 0;
        count++;
      }
    } else {
      if (p == 2) {
        p = 3;
      } else {
        p += 2;
      }
      if (p * p > n) {
        ans++;
        break;
      }
      count = 1;
      now = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

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

#define ll long long

using namespace std;

ll p;

ll calc(ll n) {
  ll res = (1 + n) * n / 2;
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  freopen("input.txt", "r", stdin);
#endif

  ll ans = 0;
  cin >> p;
  vector<pair<int, int>> pref;
  for (int i = 2; i * i <= p; ++i) {
    if (p % i == 0) {
      int cnt = 0;
      while (p % i == 0) {
        p /= i;
        ++cnt;
      }
      pref.push_back(make_pair(i, cnt));
      ll l = 1, r = 10, res;
      while (l <= r) {
        ll mid = (l + r) >> 1;
        if (calc(mid) <= cnt) {
          res = mid;
          l = mid + 1;
        } else {
          r = mid - 1;
        }
      }
      ans += res;
    }
  }
  if (p > 1) {
    pref.push_back(make_pair(p, 1));
    ++ans;
  }
  cout << ans << '\n';

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


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

#define ll long long

using namespace std;

ll p;

ll calc(ll n) {
  ll res = (1 + n) * n / 2;
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  freopen("input.txt", "r", stdin);
#endif

  ll ans = 0;
  cin >> p;
  vector<pair<int, int>> pref;
  for (ll i = 2; i * i <= p; ++i) {
    if (p % i == 0) {
      int cnt = 0;
      while (p % i == 0) {
        p /= i;
        ++cnt;
      }
      pref.push_back(make_pair(i, cnt));
      ll l = 1, r = 10, res;
      while (l <= r) {
        ll mid = (l + r) >> 1;
        if (calc(mid) <= cnt) {
          res = mid;
          l = mid + 1;
        } else {
          r = mid - 1;
        }
      }
      ans += res;
    }
  }
  if (p > 1) {
    pref.push_back(make_pair(p, 1));
    ++ans;
  }
  cout << ans << '\n';

#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}
Problem p02660 (C++)

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

int main() {
  long n;
  cin >> n;
  map<int, int> p;

  while (n % 2 == 0) {
    n /= 2;
    p[2] += 1;
  }
  int i = 3;
  while (n != 1 || n >= i) {
    if (n % i == 0) {
      p[i]++;
      n /= i;
    } else {
      i += 2;
    }
  }

  int ans = 0;
  for (auto i : p) {
    int k = 1;
    while (i.second >= k) {
      ans++;
      i.second -= k;
      k++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  long n;
  cin >> n;
  map<int, int> p;

  while (n % 2 == 0) {
    n /= 2;
    p[2] += 1;
  }
  int i = 3;
  while (n != 1 || n >= i) {
    if (pow(n, 0.5) < i) {
      p[n]++;
      break;
    }
    if (n % i == 0) {
      p[i]++;
      n /= i;
    } else {
      i += 2;
    }
  }

  int ans = 0;
  for (auto i : p) {
    int k = 1;
    while (i.second >= k) {
      ans++;
      i.second -= k;
      k++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

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

vector<pair<ll, ll>> prime(ll n) {
  vector<pair<ll, ll>> mp;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i != 0)
      continue;

    ll ex = 0;
    while (n % i == 0) {
      ++ex;
      n /= i;
    }
    mp.push_back(make_pair(i, ex));
  }
  if (n != 1)
    mp.push_back(make_pair(n, 1));
  return mp;
}

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


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

vector<pair<ll, ll>> prime(ll n) {
  vector<pair<ll, ll>> mp;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i != 0)
      continue;

    ll ex = 0;
    while (n % i == 0) {
      ++ex;
      n /= i;
    }
    mp.push_back(make_pair(i, ex));
  }
  if (n != 1)
    mp.push_back(make_pair(n, 1));
  return mp;
}

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

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

using namespace std;

ll n;
int ans, p;

int main() {
  cin >> n;

  for (int i = 2; i * i <= n; ++i) {
    p = i;
    while (n % p == 0) {
      n /= p;
      ans++;
      p *= i;
    }
    while (n % i == 0) {
      n /= i;
    }
  }
  if (n != 1) {
    ans++;
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

ll n;
int ans, p;

int main() {
  cin >> n;

  for (ll i = 2; i * i <= n; ++i) {
    p = i;
    while (n % p == 0) {
      n /= p;
      ans++;
      p *= i;
    }
    while (n % i == 0) {
      n /= i;
    }
  }
  if (n != 1) {
    ans++;
  }
  cout << ans << endl;

  return 0;
}
Problem p02660 (C++)

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

vector<pair<long long, long long>> pf(long long N) {
  vector<pair<long long, long long>> v;
  for (int i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    long long counter = 0;
    while (N % i == 0) {
      counter++;
      N /= i;
    }
    v.push_back(make_pair(i, counter));
  }
  if (N != 1)
    v.push_back(make_pair(N, 1));
  return v;
}

long long find(long long n) {
  // long long ans;
  // long long sum = 0;
  long long l = 1;
  long long r = n;
  while (r - l > 1) {
    long long c = (l + r) / 2;
    if (c * (c + 1) / 2 <= n)
      l = c;
    else
      r = c;
  }
  return l;
  // for(int i =1; i <= n + 1000; i++){
  //     sum += i;
  //     if(sum > n) {
  //         ans = i - 1;
  //         break;
  //     }
  // }
}

int main() {
  long long N;
  cin >> N;
  // cout << find(N) << endl;
  vector<pair<long long, long long>> v = pf(N);
  long long ans = 0;
  for (int i = 0; i < v.size(); i++) {
    ans += find(v.at(i).second);
  }
  cout << ans << endl;
}

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

vector<pair<long long, long long>> pf(long long N) {
  vector<pair<long long, long long>> v;
  for (long long i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    long long counter = 0;
    while (N % i == 0) {
      counter++;
      N /= i;
    }
    v.push_back(make_pair(i, counter));
  }
  if (N != 1)
    v.push_back(make_pair(N, 1));
  return v;
}

long long find(long long n) {
  // long long ans;
  // long long sum = 0;
  long long l = 1;
  long long r = n;
  while (r - l > 1) {
    long long c = (l + r) / 2;
    if (c * (c + 1) / 2 <= n)
      l = c;
    else
      r = c;
  }
  return l;
  // for(int i =1; i <= n + 1000; i++){
  //     sum += i;
  //     if(sum > n) {
  //         ans = i - 1;
  //         break;
  //     }
  // }
}

int main() {
  long long N;
  cin >> N;
  // cout << find(N) << endl;
  vector<pair<long long, long long>> v = pf(N);
  long long ans = 0;
  for (int i = 0; i < v.size(); i++) {
    ans += find(v.at(i).second);
  }
  cout << ans << endl;
}