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

Buggy submission (status: Time Limit Exceeded):
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for (int i = (a); i > (b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i)&1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19;

long long T[maxN];
const long long INF = 1000000000000000000ll;

void solve() {
  long long n;
  scanf("%lld", &n);
  int res = 0;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) {
      int c = 0;
      while (n % i == 0)
        n /= i, c++;

      int j = 0, s = 0;
      while (s + j + 1 <= c)
        j++, s += j;
      res += j;
    }

  if (n != 1ll)
    res++;
  printf("%d\n", res);
}

int main() {
  int t = 1;
  // scanf ("%d", &t);
  while (t--)
    solve();
  return 0;
}


Fixed submission:
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for (int i = (a); i > (b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define SZ(x) ((int)(x).size())
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i)&1)
#define ft first
#define sd second
#define kw(a) ((a) * (a))
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 19;

long long T[maxN];
const long long INF = 1000000000000000000ll;

void solve() {
  long long n;
  scanf("%lld", &n);
  int res = 0;
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) {
      int c = 0;
      while (n % i == 0)
        n /= i, c++;

      int j = 0, s = 0;
      while (s + j + 1 <= c)
        j++, s += j;
      res += j;
    }

  if (n != 1ll)
    res++;
  printf("%d\n", res);
}

int main() {
  int t = 1;
  // scanf ("%d", &t);
  while (t--)
    solve();
  return 0;
}
Problem p02660 (C++)

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

using ll = long long;
// print(fixed << setprecision(10));
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repk(i, n, k) for (ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  ll n;
  cin >> n;
  int ans = 0, cnt, p;
  for (int i = 2; i * i < n; i++) {
    if (n % i == 0) {
      cnt = 0;
      p = i;
      while (n % p == 0) {
        n /= p;
        p *= i;
        cnt++;
      }
      ans += cnt;
      while (n % i == 0) {
        if (n % p == 0)
          n /= p;
        else
          p /= i;
      }
    }
    if (i != 2)
      i++;
  }
  if (n != 1)
    ans++;
  print(ans);
  return 0;
}

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

using ll = long long;
// print(fixed << setprecision(10));
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repk(i, n, k) for (ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9 + 7;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  ll n;
  cin >> n;
  int ans = 0, cnt, p;
  for (ll i = 2; i * i < n; i++) {
    if (n % i == 0) {
      cnt = 0;
      p = i;
      while (n % p == 0) {
        n /= p;
        p *= i;
        cnt++;
      }
      ans += cnt;
      while (n % i == 0) {
        if (n % p == 0)
          n /= p;
        else
          p /= i;
      }
    }
    if (i != 2)
      i++;
  }
  if (n != 1)
    ans++;
  print(ans);
  return 0;
}
Problem p02660 (C++)

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

vector<pair<int64, int>> Factorize(int64 x) {
  vector<pair<int64, int>> r;
  for (int d = 2; d * d <= x; d++) {
    int c = 0;
    while (x % d == 0) {
      x /= d;
      c++;
    }
    if (c > 0) {
      r.push_back({d, c});
    }
  }
  if (x > 1)
    r.push_back({x, 1});
  return r;
}

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

  int64 n;
  cin >> n;
  auto pfs = Factorize(n);
  int count = 0;
  for (auto [p, f] : pfs) {
    // cout << "p: " << p << " f: " << f << endl;
    for (int i = 1; i <= f; i++) {
      // cout << i << " " << f << endl;
      f -= i;
      count++;
    }
  }
  cout << count << endl;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

vector<pair<int64, int>> Factorize(int64 x) {
  vector<pair<int64, int>> r;
  for (int64 d = 2; d * d <= x; d++) {
    int c = 0;
    while (x % d == 0) {
      x /= d;
      c++;
    }
    if (c > 0) {
      r.push_back({d, c});
    }
  }
  if (x > 1)
    r.push_back({x, 1});
  return r;
}

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

  int64 n;
  cin >> n;
  auto pfs = Factorize(n);
  int count = 0;
  for (auto [p, f] : pfs) {
    // cout << "p: " << p << " f: " << f << endl;
    for (int i = 1; i <= f; i++) {
      // cout << i << " " << f << endl;
      f -= i;
      count++;
    }
  }
  cout << count << endl;
}
Problem p02660 (C++)

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

#define ll long long
#define ull unsigned ll

#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0

int main()

{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // cout.tie(NULL);

  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  long long n;
  cin >> n;

  ll count = 0;
  ll ans = 0;
  bool isPrime = true;
  if (n == 1)
    isPrime = false;

  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      isPrime = false;
      while (n % i == 0) {
        n /= i;
        count++;
      }
      double now = -0.5 + 0.5 * (sqrt(1.0 + 8.0 * (double)count));
      // cout << i << " " << count << " " << now << endl;
      ans += (long long)now;
      count = 0;
      now = 0.0;
    }
  }
  if (n > 1)
    ans += 1;
  if (!isPrime)
    cout << ans << endl;
  else
    cout << 1 << endl;

  return 0;
}

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

#define ll long long
#define ull unsigned ll

#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define INFLL 9e18
#define INF 2e9
#define EPS 1e-9
#define pb push_back
#define emp emplace_back
#define PI acos(-1.0)
#define endl "\n"
#define mp make_pair
#define DEBUG 0

int main()

{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // cout.tie(NULL);

  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  long long n;
  cin >> n;

  ll count = 0;
  ll ans = 0;
  bool isPrime = true;
  if (n == 1)
    isPrime = false;

  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      isPrime = false;
      while (n % i == 0) {
        n /= i;
        count++;
      }
      double now = -0.5 + 0.5 * (sqrt(1.0 + 8.0 * (double)count));
      // cout << i << " " << count << " " << now << endl;
      ans += (long long)now;
      count = 0;
      now = 0.0;
    }
  }
  if (n > 1)
    ans += 1;
  if (!isPrime)
    cout << ans << endl;
  else
    cout << 1 << endl;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define rep(i, cc, n) for (int i = cc; i <= n; ++i)
#define drep(i, cc, n) for (int i = cc; i >= n; --i)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
typedef long long ll;
using namespace std;

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

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

ll choose2(ll n) { return n * (n - 1) / 2; }

int main() {
  ll n;
  cin >> n;
  vector<int> res;

  int cnt = 0;

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

  for (int a = 2; a * a <= n; a++) {
    if (n % a != 0)
      continue;

    int ex = 0;
    int tmp = 0;
    while (n % a == 0) {
      ex++;
      if (tmp < ex) {
        cnt++;
        tmp = ex;
        ex = 0;
      }
      n /= a;
    }
  }

  if (n != 1)
    cnt++;

  cout << cnt << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
#define rep(i, cc, n) for (int i = cc; i <= n; ++i)
#define drep(i, cc, n) for (int i = cc; i >= n; --i)
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
typedef long long ll;
using namespace std;

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

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

ll choose2(ll n) { return n * (n - 1) / 2; }

int main() {
  ll n;
  cin >> n;
  vector<int> res;

  int cnt = 0;

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

  for (ll a = 2; a * a <= n; a++) {
    if (n % a != 0)
      continue;

    int ex = 0;
    int tmp = 0;
    while (n % a == 0) {
      ex++;
      if (tmp < ex) {
        cnt++;
        tmp = ex;
        ex = 0;
      }
      n /= a;
    }
  }

  if (n != 1)
    cnt++;

  cout << cnt << endl;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define endl '\n'
// pair<int, int> *p=new pair<int, int>[n];
// std::vector<pair<int,int>> vp;
// v.push_back(make_pair(x,y))
// pair<int, int> p[1000001];
// string *s=new string [n];
// int freq[e];
// freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, sum, mn = 999999999, avg, pos, dif, j, dis, mx, xi,
                                  yi, q;
vector<ll> v;
set<int> s;
map<string, ll> mp;
bool PE(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0)
      return false;
  return true;
}
bool PR(string s) {
  int n = s.length();
  for (int i = 0; i < n / 2; i++)
    if (s[i] != s[n - i - 1])
      return false;
  return true;
}

int main(void) {
  SpeeD ll n;
  cin >> n;
  c = 0;
  while (n % 2 == 0) {
    n /= 2;
    c++;
  }
  // cout<<c;

  ll dif = (-1 + sqrt(1 + 8 * c)) / 2;

  for (int i = 3; i * i <= n; i++) {
    c1 = 0;
    while (n % i == 0) {
      c1++, n /= i;
    }

    dif += (-1 + sqrt(1 + 8 * c1)) / 2;
  }
  // cout<<n;
  if (n > 2)
    dif++;

  cout << dif;
}


Fixed submission:
#include <bits/stdc++.h>
#define SpeeD ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define ll long long
#define endl '\n'
// pair<int, int> *p=new pair<int, int>[n];
// std::vector<pair<int,int>> vp;
// v.push_back(make_pair(x,y))
// pair<int, int> p[1000001];
// string *s=new string [n];
// int freq[e];
// freq[a[i]-'a']++; freq[a[i]]++;
using namespace std;
ll n, t, m, c1, c2, c, x, y, sum, mn = 999999999, avg, pos, dif, j, dis, mx, xi,
                                  yi, q;
vector<ll> v;
set<int> s;
map<string, ll> mp;
bool PE(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0)
      return false;
  return true;
}
bool PR(string s) {
  int n = s.length();
  for (int i = 0; i < n / 2; i++)
    if (s[i] != s[n - i - 1])
      return false;
  return true;
}

int main(void) {
  SpeeD ll n;
  cin >> n;
  c = 0;
  while (n % 2 == 0) {
    n /= 2;
    c++;
  }
  // cout<<c;

  ll dif = (-1 + sqrt(1 + 8 * c)) / 2;

  for (ll i = 3; i * i <= n; i++) {
    c1 = 0;
    while (n % i == 0) {
      c1++, n /= i;
    }

    dif += (-1 + sqrt(1 + 8 * c1)) / 2;
  }
  // cout<<n;
  if (n > 2)
    dif++;

  cout << dif;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll, ll>
#define mii map<pii, ll>
#define all(a) (a).begin(), (a).end()
#define fi first
#define si second
#define sz(x) (ll) x.size()
#define endl '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod 1000000007
#define inf 1000000000000000000
#define puts(n) cout << n;
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m, v) memset(m, v, sizeof(m))
using namespace std;
const ll M = 1000000 + 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<bool> isp(M, true);
  for (ll i = 2; i * i < M; i++) {
    if (isp[i]) {
      for (ll j = i * i; j < M; j += i)
        isp[j] = false;
    }
  }
  vi primes;
  for (ll i = 2; i < M; i++) {
    if (isp[i])
      primes.pb(i);
  }
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; primes[i] * primes[i] <= n; i++) {
    ll cnt = 0;
    while (n % primes[i] == 0) {
      cnt++;
      n /= primes[i];
    }
    ll sum = 0, val = 0;
    while (sum + val <= cnt) {
      sum += val;
      val++;
    }
    ans += (val - 1);
  }
  if (n != 1)
    ans++;
  cout << ans;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<ll, ll>
#define vi vector<ll>
#define vii vector<pii>
#define mi map<ll, ll>
#define mii map<pii, ll>
#define all(a) (a).begin(), (a).end()
#define fi first
#define si second
#define sz(x) (ll) x.size()
#define endl '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod 1000000007
#define inf 1000000000000000000
#define puts(n) cout << n;
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m, v) memset(m, v, sizeof(m))
using namespace std;
const ll M = 1000000 + 1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<bool> isp(M, true);
  for (ll i = 2; i * i < M; i++) {
    if (isp[i]) {
      for (ll j = i * i; j < M; j += i)
        isp[j] = false;
    }
  }
  vi primes;
  for (ll i = 2; i < M; i++) {
    if (isp[i])
      primes.pb(i);
  }
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i < primes.size() && primes[i] * primes[i] <= n; i++) {
    ll cnt = 0;
    while (n % primes[i] == 0) {
      cnt++;
      n /= primes[i];
    }
    ll sum = 0, val = 0;
    while (sum + val <= cnt) {
      sum += val;
      val++;
    }
    ans += (val - 1);
  }
  if (n != 1)
    ans++;
  cout << ans;

  return 0;
}
Problem p02660 (C++)

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  long long n;
  cin >> n;
  int ans = 0;
  int div = 2;
  while (n > 1 && div * div <= n) {
    int cur = 0;
    int next = 1;
    while (n % div == 0) {
      cur++;
      if (cur == next) {
        cur = 0;
        next++;
      }
      n /= div;
    }
    div++;
    ans += next - 1;
  }
  if (n > 1)
    ans++;
  cout << ans;

  return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  long long n;
  cin >> n;
  int ans = 0;
  int div = 2;
  while (n > 1 && div * 1LL * div <= n) {
    int cur = 0;
    int next = 1;
    while (n % div == 0) {
      cur++;
      if (cur == next) {
        cur = 0;
        next++;
      }
      n /= div;
    }
    div++;
    ans += next - 1;
  }
  if (n > 1)
    ans++;
  cout << ans;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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 = (1 << 30) - 1;
const ll LINF = (1LL << 60) - 1;

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;
}

void solve() {
  ll n;
  cin >> n;
  auto mp = prime_factor(n);
  int ans = 0;
  for (auto p : mp) {
    int m = 1;
    while (p.se >= m) {
      ans++;
      p.se -= m;
      m++;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
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 = (1 << 30) - 1;
const ll LINF = (1LL << 60) - 1;

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;
}

void solve() {
  ll n;
  cin >> n;
  auto mp = prime_factor(n);
  int ans = 0;
  for (auto p : mp) {
    int m = 1;
    while (p.se >= m) {
      ans++;
      p.se -= m;
      m++;
    }
  }
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
Problem p02660 (C++)

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

map<long, int> fac(long n) {
  map<long, int> M;
  for (int i = 2; i <= n; i++) {
    if (n == 1)
      break;
    if (i * i > n) {
      M[n] = 1;
      break;
    }
    if (n % i == 0) {
      M[i] = 0;
      while (n % i == 0) {
        n /= i;
        M[i]++;
      }
    }
  }
  return M;
}

int main() {
  long N;
  cin >> N;
  map<long, int> M = fac(N);
  int c = 0;
  for (auto it = M.begin(); it != M.end(); it++) {
    c += (int)((-1.0 + sqrt(1.1 + 8.0 * it->second)) / 2.0);
  }
  cout << c << endl;
}

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

map<long, int> fac(long n) {
  map<long, int> M;
  for (long i = 2; i <= n; i++) {
    if (n == 1)
      break;
    if (i * i > n) {
      M[n] = 1;
      break;
    }
    if (n % i == 0) {
      M[i] = 0;
      while (n % i == 0) {
        n /= i;
        M[i]++;
      }
    }
  }
  return M;
}

int main() {
  long N;
  cin >> N;
  map<long, int> M = fac(N);
  int c = 0;
  for (auto it = M.begin(); it != M.end(); it++) {
    c += (int)((-1.0 + sqrt(1.1 + 8.0 * it->second)) / 2.0);
  }
  cout << c << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
/**
        1.对题分析，要让转化次数越大，则先从最小开始。
        2.对一个数的x质数，最多能分为多少个不同的数
        3.只需求到根号n以内的变化值
**/
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
int solve(int x) { // 计算以i为底，以x为指数一共有多少不同的值
  int now = 1, res = 0;
  while (now <= x) {
    x -= now;
    now++;
    res++;
  }
  return res;
}
int main() {
  ll n;
  int ans = 0;
  cin >> n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) { // 计算以i为底的指数为多少
        n /= i;
        cnt++;
      }
      ans += solve(cnt);
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}

Fixed submission:
/**
        1.对题分析，要让转化次数越大，则先从最小开始。
        2.对一个数的x质数，最多能分为多少个不同的数
        3.只需求到根号n以内的变化值
**/
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
int solve(int x) { // 计算以i为底，以x为指数一共有多少不同的值
  int now = 1, res = 0;
  while (now <= x) {
    x -= now;
    now++;
    res++;
  }
  return res;
}
int main() {
  ll n;
  int ans = 0;
  cin >> n;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) { // 计算以i为底的指数为多少
        n /= i;
        cnt++;
      }
      ans += solve(cnt);
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; 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>> a;
  for (int i = 2; i * i <= n; i++) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      x++;
    }
    a.emplace_back(i, x);
  }
  if (n != 1)
    a.emplace_back(n, 1);
  int ans = 0;
  for (auto i : a) {
    int x = 1;
    while (i.second - x >= 0) {
      i.second -= x;
      x++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; 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>> a;
  for (ll i = 2; i * i <= n; i++) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      x++;
    }
    a.emplace_back(i, x);
  }
  if (n != 1)
    a.emplace_back(n, 1);
  int ans = 0;
  for (auto i : a) {
    int x = 1;
    while (i.second - x >= 0) {
      i.second -= x;
      x++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int cnt[1000001];

int main() {
  long N, M;
  int ans = 0;
  cin >> N;
  M = N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 2; i < sqrt((double)N) + 1; i++) {
    if (N % i)
      continue;
    while (N % i == 0) {
      cnt[i]++;
      N /= i;
    }
  }
  if (N == M) {
    cout << 1 << endl;
    return 0;
  }
  cnt[N]++;
  for (int i = 2; i < 1000001; i++) {
    if (cnt[i] == 0)
      continue;
    int time = 1;
    while (time <= cnt[i]) {
      ans++;
      cnt[i] -= time;
      time++;
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int cnt[1000001];

int main() {
  long N, M;
  int ans = 0;
  cin >> N;
  M = N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 2; i < sqrt((double)N) + 1; i++) {
    if (N % i)
      continue;
    while (N % i == 0) {
      cnt[i]++;
      N /= i;
    }
  }
  if (N == M) {
    cout << 1 << endl;
    return 0;
  }
  if (N != 1)
    ans++;
  for (int i = 2; i < 1000001; i++) {
    if (cnt[i] == 0)
      continue;
    int time = 1;
    while (time <= cnt[i]) {
      ans++;
      cnt[i] -= time;
      time++;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
  ll n;
  cin >> n;
  vector<int> v(1000004, 1);
  int ans = 0;
  for (int i = 1; i < 1000000; i++) {
    if (i + 1 > n)
      break;
    if (v.at(i) == 0)
      continue;
    int a = i + 1;
    if ((n % a) == 0) {
      ans++;
      n = n / a;
      if (v.at(i) == 2)
        continue;
      for (int j = 1; j <= 1000000 / a; j++) {
        if (a * j - 1 < 1000000)
          v.at(a * j - 1) = 0;
      }
      ll h = a * a;
      while (h < 1000000) {
        v.at(h - 1) = 2;
        h *= a;
      }
    }
  }
  if (n > 1000000)
    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++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
  ll n;
  cin >> n;
  vector<int> v(1000004, 1);
  int ans = 0;
  for (int i = 1; i < 1000000; i++) {
    if (i + 1 > n)
      break;
    if (v.at(i) == 0)
      continue;
    int a = i + 1;
    if ((n % a) == 0) {
      ans++;
      n = n / a;
      if (v.at(i) == 2)
        continue;
      for (int j = 1; j <= 1000000 / a; j++) {
        if (a * j - 1 < 1000000)
          v.at(a * j - 1) = 0;
      }
      ll h = a * a;
      while (1 <= h && h < 1000000) {
        v.at(h - 1) = 2;
        h *= a;
      }
    }
  }
  if (n > 1000000)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define Q                                                                      \
  int t;                                                                       \
  scanf("%d", &t);                                                             \
  for (int q = 1; q <= t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
#define oset                                                                   \
  tree<lli, null_type, less<lli>, rb_tree_tag,                                 \
       tree_order_statistics_node_update>
#define ff first
#define ss second

int main() {
  lli n;
  cin >> n;
  map<lli, lli> mp;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1)
    mp[n]++;
  lli ans = 0;
  for (auto el : mp) {
    lli x = 1;
    while (el.ss >= x) {
      ans++;
      el.ss -= x;
      x++;
    }
  }
  cout << ans << "\n";
}


Fixed submission:
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define Q                                                                      \
  int t;                                                                       \
  scanf("%d", &t);                                                             \
  for (int q = 1; q <= t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
#define oset                                                                   \
  tree<lli, null_type, less<lli>, rb_tree_tag,                                 \
       tree_order_statistics_node_update>
#define ff first
#define ss second

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

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
typedef long long LL;
const int e[40] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
                   5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8};
LL IN(void) {
  LL x = 0;
  short f = 0, c = getchar();
  while (c < 48 || c > 57)
    f ^= c == 45, c = getchar();
  while (c > 47 && c < 58)
    x = x * 10 + c - 48, c = getchar();
  return f ? -x : x;
}
int main(void) {
  int x = 0;
  LL a = 0, i, N = IN();
  while (N % 2 == 0) {
    x++;
    N /= 2;
  }
  a += e[x], x = 0;
  while (N % 3 == 0) {
    x++;
    N /= 3;
  }
  a += e[x], x = 0;
  while (N % 5 == 0) {
    x++;
    N /= 5;
  }
  a += e[x];
  for (i = 0; i * i <= N; i += 6) {
    x = 0;
    while (N % (i + 1) == 0) {
      x++, N /= i + 1;
    }
    a += e[x];
    x = 0;
    while (N % (i + 5) == 0) {
      x++, N /= i + 5;
    }
    a += e[x];
  }
  if (N > 1)
    a++;
  return printf("%lld\n", a), 0;
}

Fixed submission:
#include <stdio.h>
typedef long long LL;
const int e[40] = {0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
                   5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8};
LL IN(void) {
  LL x = 0;
  short f = 0, c = getchar();
  while (c < 48 || c > 57)
    f ^= c == 45, c = getchar();
  while (c > 47 && c < 58)
    x = x * 10 + c - 48, c = getchar();
  return f ? -x : x;
}
int main(void) {
  int x = 0;
  LL a = 0, i, N = IN();
  while (N % 2 == 0) {
    x++;
    N /= 2;
  }
  a += e[x], x = 0;
  while (N % 3 == 0) {
    x++;
    N /= 3;
  }
  a += e[x], x = 0;
  while (N % 5 == 0) {
    x++;
    N /= 5;
  }
  a += e[x];
  for (i = 6; i * i <= N; i += 6) {
    x = 0;
    while (N % (i + 1) == 0) {
      x++, N /= i + 1;
    }
    a += e[x];
    x = 0;
    while (N % (i + 5) == 0) {
      x++, N /= i + 5;
    }
    a += e[x];
  }
  if (N > 1)
    a++;
  return printf("%lld\n", a), 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const int maxn = 500050;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const ll linf = 7e18;
ll power(ll x, ll y) {
  ll ans = 1;
  while (y) {
    if (y & 1)
      ans = ans * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}

ll gcd(ll x, ll y) {
  if (x % y == 0)
    return y;
  return gcd(y, x % y);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int i, j, k = 0;
  ll n;
  cin >> n;
  for (i = 2; i * i <= n; i++) {
    j = 0;
    while (n % i == 0) {
      n /= i;
      j++;
    }
    int cnt = 1;
    while (j >= cnt) {
      j -= cnt;
      cnt++;
      k++;
    }
  }
  if (n != 1)
    k++;
  cout << k << "\n";
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const int maxn = 500050;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const ll linf = 7e18;
ll power(ll x, ll y) {
  ll ans = 1;
  while (y) {
    if (y & 1)
      ans = ans * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}

ll gcd(ll x, ll y) {
  if (x % y == 0)
    return y;
  return gcd(y, x % y);
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int j, k = 0;
  ll n, i;
  cin >> n;
  for (i = 2; i * i <= n; i++) {
    j = 0;
    while (n % i == 0) {
      n /= i;
      j++;
    }
    int cnt = 1;
    while (j >= cnt) {
      j -= cnt;
      cnt++;
      k++;
    }
  }
  if (n != 1)
    k++;
  cout << k << "\n";
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < n; i++)
#define REPR(i, n) for (long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (long long i = m; i <= n; i++)
#define FORR(i, m, n) for (long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(), (v).end()
#define FIN                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
const ll inf = 1e15;

map<ll, ll> primes(ll n) {
  map<ll, ll> r;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      r[i]++;
      n /= i;
    }
  }

  if (n != 1)
    r[n] = 1;
  r[1] = 0;
  return r;
}

int main() {
  FIN

      ll n,
      k = 0;
  ;
  cin >> n;
  ll i;
  map<ll, ll> v;
  v = primes(n);
  for (i = 2; i * i <= n; i++) {
    // cout<<i<<" ";
    if (n % i == 0) {
      k = 0;
      while (n % i == 0) {
        n /= i;
        k++;
        // cout<<i<<" "<<n<<"\n";
      }
      v[i] = k;
    }
  }
  // cout<<endl<<i<<endl;
  ll ans = 0;
  for (auto i : v) {
    ll p = sqrt(1 + 8 * i.second) - 1;
    p /= 2;
    ans += p;
  }
  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < n; i++)
#define REPR(i, n) for (long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (long long i = m; i <= n; i++)
#define FORR(i, m, n) for (long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(), (v).end()
#define FIN                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9 + 7;
const ll inf = 1e15;

map<ll, ll> primes(ll n) {
  map<ll, ll> r;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      r[i]++;
      n /= i;
    }
  }

  if (n != 1)
    r[n] = 1;
  r[1] = 0;
  return r;
}

int main() {
  FIN

      ll n,
      k = 0;
  ;
  cin >> n;
  ll i;
  map<ll, ll> v;
  v = primes(n);
  for (i = 2; i * i <= n; i++) {
    // cout<<i<<" ";
    if (n % i == 0) {
      k = 0;
      while (n % i == 0) {
        n /= i;
        k++;
        // cout<<i<<" "<<n<<"\n";
      }
      v[i] = k;
    }
  }
  // cout<<endl<<i<<endl;
  ll ans = 0;
  for (auto i : v) {
    ll p = sqrt(1 + 8 * i.second) - 1;
    p /= 2;
    ans += p;
  }
  cout << ans;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<bool> prime(1000001, true);
  prime[0] = false;
  prime[1] = false;
  for (ll i = 2; i * i < 1000001; i++) {
    if (!prime[i])
      continue;
    for (ll j = 2 * i; j < 1000001; j += i) {
      prime[j] = false;
    }
  }
  vector<ll> primes;
  rep(i, 1000001) {
    if (prime[i])
      primes.push_back(i);
  }
  // rep(i, 100) cout << primes[i] << " ";
  // cout << "\n" << primes.back() << "\n";
  ll ans = 0;
  rep(i, 1000001) {
    ll p = primes[i];
    if (p * p > N)
      break;
    if (N % p != 0)
      continue;
    int c = 0;
    while (N % p == 0) {
      N /= p;
      c++;
    }
    rep(j, 1000001) {
      if (c > j) {
        ans++;
        c -= j + 1;
      } else {
        break;
      }
    }
  }
  if (N > 1)
    ans++;
  cout << ans << "\n";
}

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

typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<bool> prime(1000001, true);
  prime[0] = false;
  prime[1] = false;
  for (ll i = 2; i * i < 1000001; i++) {
    if (!prime[i])
      continue;
    for (ll j = 2 * i; j < 1000001; j += i) {
      prime[j] = false;
    }
  }
  vector<ll> primes;
  rep(i, 1000001) {
    if (prime[i])
      primes.push_back(i);
  }
  // rep(i, 100) cout << primes[i] << " ";
  // cout << "\n" << primes.back() << "\n";
  ll ans = 0;
  rep(i, primes.size()) {
    ll p = primes[i];
    if (p * p > N)
      break;
    if (N % p != 0)
      continue;
    int c = 0;
    while (N % p == 0) {
      N /= p;
      c++;
    }
    rep(j, 1000001) {
      if (c > j) {
        ans++;
        c -= j + 1;
      } else {
        break;
      }
    }
  }
  if (N > 1)
    ans++;
  cout << ans << "\n";
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

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

int main() {
  ll n;
  cin >> n;
  int ans = 0;
  vector<pair<ll, int>> fs;
  fs = factor(n);
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

int main() {
  ll n;
  cin >> n;
  int ans = 0;
  vector<pair<ll, int>> fs;
  fs = factor(n);
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ans++;
    }
  }
  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;

int calc(int n) {
  for (int i = 1;; i++) {
    if (i * (i + 1) > n * 2)
      return i - 1;
  }
}

vector<pair<ll, int>> prime_factorize(ll n) {
  vector<pair<ll, int>> vp;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      vp.push_back({i, cnt});
    }
  }
  if (n != 1)
    vp.push_back({n, 1});
  return vp;
}

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> vp = prime_factorize(n);
  int ans = 0;
  for (int i = 0; i < vp.size(); i++)
    ans += calc(vp[i].second);
  cout << ans << endl;
}

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

int calc(int n) {
  for (int i = 1;; i++) {
    if (i * (i + 1) > n * 2)
      return i - 1;
  }
}

vector<pair<ll, int>> prime_factorize(ll n) {
  vector<pair<ll, int>> vp;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      vp.push_back({i, cnt});
    }
  }
  if (n != 1)
    vp.push_back({n, 1});
  return vp;
}

int main() {
  ll n;
  cin >> n;
  vector<pair<ll, int>> vp = prime_factorize(n);
  int ans = 0;
  for (int i = 0; i < vp.size(); i++)
    ans += calc(vp[i].second);
  cout << ans << endl;
}
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;
typedef pair<int, int> P;
typedef long long ll;
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;
}

int main() {
  ll n;
  cin >> n;
  vector<pair<int, int>> prime;
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    if (n % i == 0) {
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      for (int j = 1;; j++) {
        cnt -= j;
        if (cnt >= 0)
          ans++;
        else
          break;
      }
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}


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

int main() {
  ll n;
  cin >> n;
  vector<pair<int, int>> prime;
  int ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    if (n % i == 0) {
      while (n % i == 0) {
        cnt++;
        n /= i;
      }
      for (int j = 1;; j++) {
        cnt -= j;
        if (cnt >= 0)
          ans++;
        else
          break;
      }
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++)

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

int main() {
  long long n;
  long long ii;
  long kotae;
  int i;
  int j;
  int k;
  int a[66];

  k = 1;
  a[0] = 0;
  a[1] = 0;
  for (i = 1; i < 11; i++) {
    a[k] = a[k - 1] + 1;
    k++;
    for (j = 0; j < i; j++) {
      a[k] = a[k - 1];
      k++;
    }
  }

  cin >> n;

  kotae = 0;

  for (ii = 2; i < 1000001; ii++) {
    i = 0;
    while (n > 0) {
      // iiで割り切れなければループを抜ける
      if (n % ii > 0) {
        break;
      }
      n = n / ii;
      i++;
    }
    kotae = kotae + a[i];
    if (ii > n) {
      break;
    }
  }
  if (n > 1)
    kotae++;
  cout << kotae << endl;
  return 0;
}


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

int main() {
  long long n;
  long long ii;
  long kotae;
  int i;
  int j;
  int k;
  int a[66];

  k = 1;
  a[0] = 0;
  a[1] = 0;
  for (i = 1; i < 11; i++) {
    a[k] = a[k - 1] + 1;
    k++;
    for (j = 0; j < i; j++) {
      a[k] = a[k - 1];
      k++;
    }
  }

  cin >> n;

  kotae = 0;

  for (ii = 2; i < 1000001; ii++) {
    i = 0;
    while (n > 0) {
      // iiで割り切れなければループを抜ける
      if (n % ii > 0) {
        break;
      }
      n = n / ii;
      i++;
    }
    kotae = kotae + a[i];
    if (ii * ii > n) {
      break;
    }
  }
  if (n > 1)
    kotae++;
  cout << kotae << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  // unordered_map<ll, int> count;
  // count.reserve(1024);
  vector<pair<ll, int>> factors;
  ll ans = 0;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      // ans = max(ans, count[i]);
      // ans -= count[i]/2;
      // ans += (count[i]+1)/2;
      n /= i;
      // factors.pb(i);
    }
    factors.pb(mp(i, cnt));
  }
  if (n != 1) {
    factors.pb(mp(n, 1));
    // count[n]++;
    // ans += 1;
  }
  for (auto it : factors) {
    int times = it.s;
    // int times = count[it];
    int curr = 1;
    while (times - curr >= 0) {
      times -= curr;
      curr++;
      ans++;
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  // unordered_map<ll, int> count;
  // count.reserve(1024);
  vector<pair<ll, int>> factors;
  ll ans = 0;
  for (ll i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      // ans = max(ans, count[i]);
      // ans -= count[i]/2;
      // ans += (count[i]+1)/2;
      n /= i;
      // factors.pb(i);
    }
    factors.pb(mp(i, cnt));
  }
  if (n != 1) {
    factors.pb(mp(n, 1));
    // count[n]++;
    // ans += 1;
  }
  for (auto it : factors) {
    int times = it.s;
    // int times = count[it];
    int curr = 1;
    while (times - curr >= 0) {
      times -= curr;
      curr++;
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02660 (C++)

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  long long int n;
  cin >> n;
  long long int ans = 0;
  for (long long int i = 0; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    long long int num = 0;
    while (n % i == 0) {
      n /= i;
      num += 1;
    }
    for (long long int j = 1;; j++) {
      if (num >= j) {
        num -= j;
        ans += 1;
      } else
        break;
    }
  }
  if (n != 1) {
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  long long int n;
  cin >> n;
  long long int ans = 0;
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    long long int num = 0;
    while (n % i == 0) {
      n /= i;
      num += 1;
    }
    for (long long int j = 1;; j++) {
      if (num >= j) {
        num -= j;
        ans += 1;
      } else
        break;
    }
  }
  if (n != 1) {
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

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

int fun(int x) {
  int ans = 0;
  for (int i = 1;; i++) {
    ans += i;
    if (ans == x)
      return i;
    else if (x < ans)
      return i - 1;
  }
}

int main() {
  ll n;
  cin >> n;
  ll half = sqrt(n);
  int ans = 0;
  for (int i = 0; i < half; i++) {
    int a = 0;
    while (n % i == 0) {
      a++;
      n /= i;
    }
    ans += fun(a);
  }
  if (n > 1)
    cout << ans + 1 << endl;
  else
    cout << ans << endl;

  return 0;
}

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

int fun(int x) {
  int ans = 0;
  for (int i = 1;; i++) {
    ans += i;
    if (ans == x)
      return i;
    else if (x < ans)
      return i - 1;
  }
}

int main() {
  ll n;
  cin >> n;
  ll half = sqrt(n);
  int ans = 0;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 2; i < half; i++) {
    int a = 0;
    while (n % i == 0) {
      a++;
      n /= i;
    }
    ans += fun(a);
  }
  if (n > 1)
    cout << ans + 1 << endl;
  else
    cout << ans << endl;

  return 0;
}