alexjercan/bugnet huggingface dataset:
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define ll long long
#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  ll size = n;
  queue<int> a;
  for (ll i = 2; i * i <= size; i++) {
    if (n % i != 0)
      continue;
    int co = 0;
    while (n % i == 0) {
      n /= i;
      co++;
    }
    if (co == 0)
      continue;
    a.push(co);
    if (n == 1)
      break;
  }
  if (n != 1)
    a.push(1);

  ll ans = 0;
  while (!a.empty()) {
    for (ll i = 1;; i++) {
      if (i * (i + 1) > 2 * a.front()) {
        ans += i - 1;
        a.pop();
        break;
      }
    }
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

#define ll long long
#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  ll size = n;
  queue<int> a;
  for (int i = 2; i * i <= size; i++) {
    if (n % i != 0)
      continue;
    int co = 0;
    while (n % i == 0) {
      n /= i;
      co++;
    }
    if (co == 0)
      continue;
    a.push(co);
    if (n == 1)
      break;
  }
  if (n != 1)
    a.push(1);

  ll ans = 0;
  while (!a.empty()) {
    for (int i = 1;; i++) {
      if (i * (i + 1) > 2 * a.front()) {
        ans += i - 1;
        a.pop();
        break;
      }
    }
  }

  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

// 2020-06-02
#include <bits/stdc++.h>
using namespace std;
#define loop(v, st, en) for (int v = st; v < en; v++)
#define loopdesc(v, st, en) for (int v = st; v >= en; v--)
#define INF 1E9
#define clr(v, d) memset(v, d, sizeof(v))
#define pb push_back
#define MP make_pair
#define P(x) cout << #x << " = { " << x << " }\\n"
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<pll> vll;
const int M = 2e5 + 5;

vi prime_fact(ll n) {
  vi ans;
  ll y = n;

  for (ll i = 2; i * i <= n; i++) {
    if (y % i == 0) {
      int cnt = 0;
      while (y % i == 0) {
        cnt++;
        y /= i;
      }
      ans.push_back(cnt);
    }
  }
  if (ans.size() == 0)
    ans.pb(0);
  if (y > 1)
    ans.pb(1);
  return ans;
}

ll calc(ll n) {
  double x = sqrt(1 + 8 * n) - 1;
  return floor(x / 2.0);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // freopen("input.txt", "r", stdin);
  ll x;
  cin >> x;
  if (x == 1) {
    cout << "0";
    return 0;
  }
  vi a = prime_fact(x);
  if (a[0] == 0) {
    cout << "1";
    return 0;
  }
  ll ans = 0;
  loop(i, 0, a.size()) ans += calc(a[i]);
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

// 2020-06-02
#include <bits/stdc++.h>
using namespace std;
#define loop(v, st, en) for (int v = st; v < en; v++)
#define loopdesc(v, st, en) for (int v = st; v >= en; v--)
#define INF 1E9
#define clr(v, d) memset(v, d, sizeof(v))
#define pb push_back
#define MP make_pair
#define P(x) cout << #x << " = { " << x << " }\\n"
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<pll> vll;
const int M = 2e5 + 5;

vll prime_fact(ll n) {
  vll ans;
  ll y = n;
  int cnt = 0;
  for (ll i = 2; i * i <= n; i++) {
    if (y % i == 0) {
      cnt++;
      ans.push_back(MP(i, 0));
      while (y % i == 0) {
        y /= i;
        ans[ans.size() - 1].second++;
      }
    }
  }
  if (cnt == 0)
    ans.pb(MP(0, 0));
  return ans;
}

ll calc(ll n) {
  ll x = sqrt(1 + 8 * n) - 1;
  return x / 2;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // freopen("input.txt", "r", stdin);
  ll x;
  cin >> x;
  if (x == 1)
    return puts("0");
  vll a = prime_fact(x);
  if (a[0].first == 0)
    return puts("1");
  ll ans = 0;
  loop(i, 0, a.size()) ans += calc(a[i].second);
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i, s, e) for (i64(i) = (s); (i) < (e); (i)++)
#define all(x) x.begin(), x.end()

template <class T> static inline std::vector<T> ndvec(size_t &&n, T val) {
  return std::vector<T>(n, std::forward<T>(val));
}
template <class... Tail> static inline auto ndvec(size_t &&n, Tail &&...tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(
      n, ndvec(std::forward<Tail>(tail)...));
}
template <class Cond> struct chain {
  Cond cond;
  chain(Cond cond) : cond(cond) {}
  template <class T> bool operator()(T &a, const T &b) const {
    if (cond(a, b)) {
      a = b;
      return true;
    }
    return false;
  }
};
template <class Cond> chain<Cond> make_chain(Cond cond) {
  return chain<Cond>(cond);
}

int main() {
  i64 N;
  cin >> N;
  map<i64, i64> mp;
  for (i64 i = 2; i * i <= N; i++) {
    if (N % i == 0) {
      i64 cnt = 0;
      while (N % i == 0) {
        cnt++;
        N /= i;
      }
      mp[i] = cnt;
    }
  }
  if (N > 1) {
    mp[N] = 1;
  }
  i64 ans = 0;
  for (auto pp : mp) {
    auto p = pp.second;
    i64 ok = 0;
    i64 ng = 1e9;
    for (int i = 0; i < 50; i++) {
      i64 mid = (ok + ng) / 2;
      if (mid * (mid + 1) / 2 <= p) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    ans += ok;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i, s, e) for (i64(i) = (s); (i) < (e); (i)++)
#define all(x) x.begin(), x.end()

template <class T> static inline std::vector<T> ndvec(size_t &&n, T val) {
  return std::vector<T>(n, std::forward<T>(val));
}
template <class... Tail> static inline auto ndvec(size_t &&n, Tail &&...tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(
      n, ndvec(std::forward<Tail>(tail)...));
}
template <class Cond> struct chain {
  Cond cond;
  chain(Cond cond) : cond(cond) {}
  template <class T> bool operator()(T &a, const T &b) const {
    if (cond(a, b)) {
      a = b;
      return true;
    }
    return false;
  }
};
template <class Cond> chain<Cond> make_chain(Cond cond) {
  return chain<Cond>(cond);
}

int main() {
  i64 N;
  cin >> N;
  map<i64, i64> mp;
  for (int i = 2; i * i <= N; i++) {
    if (N % i == 0) {
      i64 cnt = 0;
      while (N % i == 0) {
        cnt++;
        N /= i;
      }
      mp[i] = cnt;
    }
  }
  if (N > 1) {
    mp[N] = 1;
  }
  i64 ans = 0;
  for (auto pp : mp) {
    auto p = pp.second;
    i64 ok = 0;
    i64 ng = 1e9;
    for (int i = 0; i < 50; i++) {
      i64 mid = (ok + ng) / 2;
      if (mid * (mid + 1) / 2 <= p) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    ans += ok;
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _USE_MATH_DEFINES

// #include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll n;
  int ans = 0;
  cin >> n;

  ll num = n;
  for (ll i = 2; i <= n; i++) {
    if (num < i * i)
      break;
    int count = 0;
    int last_count = 0;
    while (num % i == 0) { // 素数で割り切れなくなるまで割っていく
      count++;
      if (count > last_count) {
        ans++;
        last_count = count;
        count = 0;
      }
      // x.at(i)++; //割った個数を配列に足す
      num /= i;
    }
    if (i >= 3)
      i++;
  }

  if (num != 1)
    ans++;
  cout << ans << endl;
  return 0;
} // end of main

// 実行は、Opt + Ctl + N
// デバッグする場合は、デバッグビューでドロップダウンリストから[(lldb)Launch]を選択する
// まずビルド: Command + Shift + B
// その後、F5
// ターミナルが開くので、入力はそちらに。
// F9でブレークポイント設置
// F11でステップイン実行

// 学び
// 少数の掛け算は誤差が発生する。整数に直して行うこと。ABC169_C
//

Error: TLE

Fixed submission:

#define _USE_MATH_DEFINES

// #include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll n;
  int ans = 0;
  cin >> n;

  ll num = n;
  for (ll i = 2; i <= n; i++) {
    if (num < i)
      break;
    int count = 0;
    int last_count = 0;
    while (num % i == 0) { // 素数で割り切れなくなるまで割っていく
      count++;
      if (count > last_count) {
        ans++;
        last_count = count;
        count = 0;
      }
      // x.at(i)++; //割った個数を配列に足す
      num /= i;
    }
    if (i >= 3)
      i++;
  }
  cout << ans << endl;
  return 0;
} // end of main

// 実行は、Opt + Ctl + N
// デバッグする場合は、デバッグビューでドロップダウンリストから[(lldb)Launch]を選択する
// まずビルド: Command + Shift + B
// その後、F5
// ターミナルが開くので、入力はそちらに。
// F9でブレークポイント設置
// F11でステップイン実行

// 学び
// 少数の掛け算は誤差が発生する。整数に直して行うこと。ABC169_C
//
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define inf 1e18
#define inp(arr, n)                                                            \\
  for (int i = 0; i < n; i++)                                                  \\
  cin >> arr[i]
#define fr(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  if (n == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<ll> p;
  vector<ll> f;
  if (n % 2 == 0) {
    ll count = 0;
    while (n % 2 == 0) {
      count++;
      n /= 2;
    }
    p.push_back(2);
    f.push_back(count);
  }
  for (ll i = 3; i <= (ll)sqrt(n); i += 2) {
    if (n % i == 0) {
      ll count = 0;
      while (n % i == 0) {
        count++;
        n /= i;
      }
      p.push_back(i);
      f.push_back(count);
    }
  }
  if (n > 2) {
    p.push_back(n);
    f.push_back(1);
  }
  ll c = 0;
  fr(i, 0, f.size() - 1) {
    ll a = f[i];
    ll b = (ll)((-1 + sqrt(1 + 8 * a)) / 2);
    c += b;
  }
  cout << c << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mod 1000000007
#define inf 1e18
#define inp(arr, n)                                                            \\
  for (int i = 0; i < n; i++)                                                  \\
  cin >> arr[i]
#define fr(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  vector<ll> p;
  vector<ll> f;
  if (n % 2 == 0) {
    ll count = 0;
    while (n % 2 == 0) {
      count++;
      n /= 2;
    }
    p.push_back(2);
    f.push_back(count);
  }
  for (ll i = 3; i <= (ll)sqrt(n); i += 2) {
    if (n % i == 0) {
      ll count = 0;
      while (n % i == 0) {
        count++;
        n /= i;
      }
      p.push_back(i);
      f.push_back(count);
    }
  }
  if (n > 2) {
    p.push_back(n);
    f.push_back(1);
  }
  ll c = 0;
  fr(i, 0, f.size() - 1) {
    ll a = f[i];
    ll b = (ll)((-1 + sqrt(1 + 8 * a)) / 2);
    c += b;
  }
  cout << c << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

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

using namespace std;

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

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

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

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

using namespace std;

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

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

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll, ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(), v.end())
#define ull unsigned long long
#define tell(a) cout << a << " "
#define el cout << endl
#define rev(v) reverse(v.begin(), v.end())
#define rep(i, a, n) for (int i = a; i < n; i++)
#define M 1000000007
ll power(ll x, ll y, ll p) {
  ll res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

bool solve(ll n, ll k) {
  if ((k * (k + 1)) / 2 < 0)
    return false;
  if (n >= (k * (k + 1)) / 2) {
    return true;
  }

  return false;
}
ll a[50];
int main() {
  IOS;
  a[0] = 0;
  a[1] = 1;
  a[2] = 1;
  for (ll i = 3; i < 50; i++) {
    a[i] = 1LL;
    for (ll j = 1; j <= i; j++) {
      if (!solve(i, j))
        break;
      a[i] = j;
    }
  }
  ll n;
  cin >> n;
  ll ans = 0;
  ll c = 0;
  while (n % 2 == 0) {
    c++;
    n /= 2;
  }
  ans += a[c];
  for (ll i = 3; i * i <= n; i += 2) {
    c = 0;
    while (n % i == 0) {
      c++;
      n /= i;
    }
    ans += a[c];
  }
  if (n > 1)
    ans += 1;
  cout << ans;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll, ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(), v.end())
#define ull unsigned long long
#define tell(a) cout << a << " "
#define el cout << endl
#define rev(v) reverse(v.begin(), v.end())
#define rep(i, a, n) for (int i = a; i < n; i++)
#define M 1000000007
ll power(ll x, ll y, ll p) {
  ll res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}

bool solve(ll n, ll k) {
  if (n >= (k * (k + 1)) / 2) {
    return true;
  }

  return false;
}
ll a[50];
int main() {
  IOS;
  a[0] = 0;
  a[1] = 1;
  a[2] = 1;
  for (ll i = 3; i < 50; i++) {
    a[i] = 1LL;
    ll j;
    ll l = 1, h = i;
    while (l <= h) {
      ll m = (l + h) / 2;
      if (solve(i, m)) {
        a[i] = m;
        l = m + 1;
      } else
        h = m - 1;
    }
  }
  ll n;
  cin >> n;
  ll ans = 0;
  ll c = 0;
  while (n % 2 == 0) {
    c++;
    c /= 2;
  }
  ans += a[c];
  for (ll i = 3; i * i <= n; i += 2) {
    c = 0;
    while (n % i == 0) {
      c++;
      n /= i;
    }
    ans += a[c];
  }
  if (n > 1)
    ans += 1;
  cout << ans;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

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

long long N;

vector<pair<long long, long long>> prime_factorize(long long N) {
  vector<pair<long long, long long>> res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0)
      continue;
    long long ex = 0;

    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    res.push_back({a, ex});
  }

  if (N != 1)
    res.push_back({N, 1});
  return res;
}

int main() {
  cin >> N;
  vector<pair<long long, long long>> p = prime_factorize(N);
  int cnt = 0;

  for (auto a : p) {
    int have = a.second;
    int dec = 1;

    while (have >= dec) {
      have -= dec;
      dec++;
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

Error: WA

Fixed submission:

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

long long N;

vector<pair<long long, long long>> prime_factorize(long long N) {
  vector<pair<long long, long long>> res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0)
      continue;
    long long ex = 0;

    while (N % a == 0) {
      ++ex;
      N /= a;
    }

    res.push_back({a, ex});
  }

  if (N != 1)
    res.push_back({N, 1});
  return res;
}

int main() {
  cin >> N;
  vector<pair<long long, long long>> p = prime_factorize(N);

  vector<long long> dic;

  for (auto a : p) {
    for (int i = 0; i < a.second; i++) {
      dic.push_back(pow(a.first, i + 1));
    }
  }

  sort(dic.begin(), dic.end());

  int i = 0;
  int cnt = 0;

  if (dic.size() != 0 && dic.size() != 1) {

    while (N / dic[i] > 0) {
      N /= dic[i];
      cout << N << endl;
      cnt++;
      i++;
    }
  }

  if (dic.size() == 1)
    cnt = 1;
  cout << cnt << endl;

  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

ll n;

int solve();

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

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

Error: TLE

Fixed submission:

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

int main() {
  long n;
  cin >> n;
  int count = 0;
  for (int i = 2; i * i <= n; i++) {
    int count2 = 0;
    while (n % i == 0) {
      count2 += 1;
      n /= i;
    }
    for (int j = 1; count2 >= j * (j + 1) / 2; j++)
      count += 1;
  }
  if (n != 1)
    count += 1;
  cout << count << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000000007
#define REP(i, n) for (int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for (int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
  cout << fixed << setprecision(10);

  LLI n;
  cin >> n;
  LLI ans = 0;
  for (LLI i = 2; i < 2000001; i++) {
    LLI v = i;
    while (v <= n) {
      if (n % v == 0) {
        ans++;
        n /= v;
      }
      v *= i;
    }
    while (n % i == 0)
      n /= i;
  }
  if (2000001 <= n)
    ans++;
  cout << ans;

  return 0;
}

Error: WA

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000000007
#define REP(i, n) for (int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for (int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

LLI power(LLI a, LLI b) {
  LLI res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}
int main() {
  cout << fixed << setprecision(10);

  LLI n;
  cin >> n;
  LLI ans = 0;
  for (LLI i = 2; i < 2000001; i++) {
    for (LLI j = 1; j < 100; j++) {
      LLI v = power(i, j);
      if (n < v)
        break;
      if (n % v == 0) {
        ans++;
        n /= v;
      }
    }
  }
  if (20000001 <= n)
    ans++;
  cout << ans;

  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  long N;
  cin >> N;
  int ans = 0;
  for (long i = 2; i * i < N; i++) {
    int crt = 0;
    while (N % i == 0) {
      crt++;
      N /= i;
    }
    int j = 1;
    while (crt >= j) {
      crt -= j;
      ans++;
      j++;
    }
  }
  if (N != 1) {
    ans++;
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  long N;
  cin >> N;
  int ans = 0, j, crt;
  for (int i = 2; i * i < N; i++) {
    crt = 0;
    while (N % i == 0) {
      crt++;
      N /= i;
    }
    j = 1;
    while (crt >= j) {
      crt -= j;
      ans++;
      j++;
    }
  }
  if (N != 1) {
    ans++;
  }

  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

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

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

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

  int ans = 0;

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

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

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

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

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

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

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

  int ans = 0;

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

  cout << ans << endl;

  return 0;
}