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

#include "bits/stdc++.h"

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;

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

int main(void) {
  ll N;
  cin >> N;

  auto f = factor(N);

  ll ans = 0;

  for (auto x : f) {
    int i = 1;
    int y = x.second;
    while (y >= i) {
      y -= i;
      i++;
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;

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

int main(void) {
  ll N;
  cin >> N;

  auto f = factor(N);

  ll ans = 0;

  for (auto x : f) {
    int i = 1;
    int y = x.second;
    while (y >= i) {
      y -= i;
      i++;
      ans++;
    }
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
using namespace std;
bool isprime(long long n) {
  long long i;
  for (i = 2; i <= sqrt(n); i++) {
    if (n % i == 0)
      return true;
  }
  if (n == 1)
    return true;
  return false;
}
int main() {
  long long n, k = 1, p = 0, q, i, l = n;
  cin >> n;
  l = n;
  for (i = 2; i <= sqrt(l); i++) {
    n = l;
    if (l % i == 0) {
      if (!isprime(i)) {
        k = 1;
        q = k;
        while (n % i == 0) {
          n /= i;
          k--;
          if (k == 0) {
            k = q + 1;
            q = k;
            p++;
          }
        }
      }
      n = l;
      if (!isprime(n / i)) {
        k = 1;
        q = k;
        while (n % (l / i) == 0) {
          n /= (l / i);
          k--;
          if (k == 0) {
            k = q + 1;
            q = k;
            p++;
          }
        }
      }
    }
  }
  if (l != 1 && p == 0)
    p++;
  cout << p << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
using namespace std;
bool isprime(long long n) {
  long long i;
  for (i = 2; i <= sqrt(n); i++) {
    if (n % i == 0)
      return true;
  }
  if (n == 1)
    return true;
  return false;
}
int main() {
  long long n, k = 1, p = 0, q, i, l = n;
  cin >> n;
  l = n;
  for (i = 2; i <= sqrt(l); i++) {
    if (isprime(n)) {
      if (n % i == 0) {
        k = 1;
        q = k;
        while (n % i == 0) {
          n /= i;
          k--;
          if (k == 0) {
            k = q + 1;
            q = k;
            p++;
          }
        }
      }
    } else {
      p++;
      break;
    }
  }
  cout << p << endl;

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

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

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

  ll ans = 0;
  for (ll i = 2; i * i < n; i++) {
    int cnt = 0, j = 1;
    while (n % i == 0)
      n /= i, cnt++;
    while (cnt >= j)
      cnt -= j, ans++, j++;
  }

  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

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

  ll ans = 0;
  for (int i = 2; i * i < n; i++) {
    int cnt = 0, j = 1;
    while (n % i == 0)
      n /= i, cnt++;
    while (cnt >= j)
      cnt -= j, ans++, j++;
  }

  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long ll;
// const int INF = 2e9;
// const ll INF = 9e18;

vector<pair<ll, ll>> primeFactorial(ll n) {
  vector<pair<ll, ll>> res;
  for (ll i = 2; i * i <= n; i++) {
    ll r = 0;
    while (n % i == 0) {
      r++;
      n /= i;
    }
    res.emplace_back(i, r);
  }
  if (n > 1) {
    res.emplace_back(n, 1);
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  vector<pair<ll, ll>> res = primeFactorial(N);
  ll ans = 0;
  auto calc = [&](ll x) { return x * (x + 1) / 2; };
  for (int i = 0; i < res.size(); i++) {
    ll large = 1e6;
    ll small = 0;
    while (large - small > 1) {
      ll mid = (large + small) / 2;
      if (calc(mid) > res[i].second)
        large = mid;
      else
        small = mid;
    }
    ans += small;
  }
  cout << ans << "\\n";
}

Error: TLE

Fixed submission:

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

typedef long long ll;
// const int INF = 2e9;
// const ll INF = 9e18;

vector<pair<int, int>> primeFactorial(int n) {
  vector<pair<int, int>> res;
  for (int i = 2; i * i <= n; i++) {
    int r = 0;
    while (n % i == 0) {
      r++;
      n /= i;
    }
    res.emplace_back(i, r);
  }
  if (n > 1) {
    res.emplace_back(n, 1);
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<pair<int, int>> res = primeFactorial(N);
  ll ans = 0;
  auto calc = [&](ll x) { return x * (x + 1) / 2; };
  for (int i = 0; i < res.size(); i++) {
    ll large = 1e6;
    ll small = 0;
    while (large - small > 1) {
      ll mid = (large + small) / 2;
      if (calc(mid) > res[i].second)
        large = mid;
      else
        small = mid;
    }
    ans += small;
  }
  cout << ans << "\\n";
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
#define ll long long int
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);

int main() {

  ll n;
  cin >> n;

  ll ans = 0;
  for (int i = 2; i <= 10000010; i++) {
    if (n % i == 0) {

      ll num = 0;
      while (n % i == 0) {
        n /= i;
        num++;
      }

      for (int j = 1; j < 10000; j++) {
        if (num < j)
          break;
        num -= j;
        ans++;
      }
    }
  }
  if (n != 1)
    ans++;
  cout << ans;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
#define ll long long
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);

int main() {

  fastio;

  ll n;
  cin >> n;

  ll ans = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {

      ll num = 0;
      while (n % i == 0) {
        n /= i;
        num++;
      }

      for (int j = 1;; j++) {
        if (num < j)
          break;
        num -= j;
        ans++;
      }
    }
  }
  if (n != 1)
    ans++;
  cout << ans;

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long

vector<pair<ll, int>> findFactor(ll n) {
  vector<pair<ll, int>> v;
  for (ll i = 2; i <= sqrt(n); i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    if (cnt > 0)
      v.emplace_back(i, cnt);
  }
  if (n > 1)
    v.emplace_back(n, 1);
  return v;
}

int main() {
  ll n;
  cin >> n;
  int cnt = 0;
  for (const auto p : findFactor(n)) {
    // cout << p.first << " " << p.second << endl;
    int i = 1, sum = 1;
    while (sum <= p.second) {
      i++;
      sum += i;
    }
    cnt += i - 1;
  }
  cout << cnt << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long

bool isPrime(ll n) {
  if (n == 1)
    return false;
  for (ll i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

vector<pair<ll, int>> findFactor(ll n) {
  vector<pair<ll, int>> v;
  for (ll i = 2; i < n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    if (cnt > 0)
      v.emplace_back(i, cnt);

    if (isPrime(n)) {
      v.emplace_back(n, 1);
      return v;
    }
  }
  return v;
}

int main() {
  ll n;
  cin >> n;
  int cnt = 0;
  for (const auto p : findFactor(n)) {
    int i = 1, sum = 1;
    while (sum <= p.second) {
      i++;
      sum += i;
    }
    cnt += i - 1;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
using namespace std;

int main() {
  long long n;
  cin >> n;
  long long i = 2, num = 0, ans = 0;
  bool is_composite = false;
  while (n != 1) {
    if (n % i == 0) {
      is_composite = true;
      num++;
      n /= i;
    } else {
      long long j = 1;
      while (num - j >= 0) {
        num -= j;
        j++;
        ans++;
      }
      num = 0;
      is_composite = false;
      if (i % 2 == 1)
        i += 2;
      else
        i++;
    }
    if (i > sqrt(n) && is_composite == false) {
      // 素数
      ans++;
      break;
    }
  }
  long long j = 1;
  while (num - j >= 0) {
    num -= j;
    j++;
    ans++;
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;

int main() {
  long long n;
  cin >> n;
  long long i = 2, num = 0, ans = 0;
  bool is_composite = false;
  while (n != 1) {
    if (n % i == 0) {
      is_composite = true;
      num++;
      n /= i;
    } else {
      long long j = 1;
      while (num - j >= 0) {
        num -= j;
        j++;
        ans++;
      }
      num = 0;
      if (i % 2 == 1)
        i += 2;
      else
        i++;
    }
    if (i > sqrt(n) && is_composite == false) {
      // 素数
      cout << 1;
      return 0;
    }
  }
  long long j = 1;
  while (num - j >= 0) {
    num -= j;
    j++;
    ans++;
  }
  cout << ans;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define int long long
#define IOS()                                                                  \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);
using namespace std;
int st[10000000];
signed main() {
  IOS();
  // set<int> st;
  int k;
  while (cin >> k) {
    if (k == 1) {
      cout << 0 << "\\n";
      continue;
    }
    int ans = 0;
    int n = 0;
    for (int i = 2; i * i <= k; i++) {
      // cout<<k<<" "<<st[i]<<"\\n";
      if (k < i)
        break;
      if (k % i)
        continue;
      int n = 0;
      while (k % i == 0) {
        n++;
        k /= i;
      }
      // cout<<"n"<<n<<"\\n";
      ans += double(-1 + sqrt(1 + 8 * n)) / 2;
      // cout<<ans<<" ";
    }
    if (k != 1)
      ans++;
    cout << ans << "\\n";
  }
}
// 2^12*5^12


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define int long long
#define IOS()                                                                  \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);
using namespace std;
signed main() {
  IOS();
  // set<int> st;
  int k;
  while (cin >> k) {
    if (k == 1) {
      cout << 0 << "\\n";
      continue;
    }
    int ans = 0;
    int n = 0;
    while (k % 2 == 0) {
      k /= 2;
      n++;
    }
    ans += double(double(-1 + sqrt(1 + 8 * n)) / 2);
    for (int i = 3; i <= k; i += 2) {
      if (k % i)
        continue;
      // cout<<k<<" "<<st[i]<<"\\n";
      if (k < i)
        break;
      int n = 0;
      while (k % i == 0) {
        n++;
        k /= i;
      }
      // cout<<"n"<<n<<"\\n";
      ans += double(double(-1 + sqrt(1 + 8 * n)) / 2);
      // cout<<ans<<" ";
    }
    if (ans == 0)
      ans = 1;
    cout << ans << "\\n";
  }
}
// 2^12*5^12
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<ll> p;
  for (ll a = 2; a * a <= n; a++) {
    if (n % a == 0) {
      p.push_back(0);
      while (n % a == 0) {
        p.back()++;
        n /= a;
      }
    }
  }
  if (n != 1)
    p.push_back(1);
  int cnt = 0;
  for (int i = 0; i < (int)p.size(); i++) {
    int num = 1;
    while (p[i] - num >= 0) {
      cnt++;
      p[i] -= num;
      num++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<ll> p;
  for (int a = 2; a * a <= n; a++) {
    if (n % a == 0) {
      p.push_back(0);
      while (n % a == 0) {
        p.back()++;
        n /= a;
      }
    }
  }
  if (n != 1)
    p.push_back(1);
  int cnt = 0;
  for (int i = 0; i < (int)p.size(); i++) {
    int num = 1;
    while (p[i] - num >= 0) {
      cnt++;
      p[i] -= num;
      num++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

template <typename T> auto factorization(T x) {
  vector<pair<T, T>> ans;
  for (ll i = 2; i * i <= x; ++i) {
    if (x % i != 0)
      continue;
    ll count = 0;
    while (x % i == 0) {
      ++count;
      x /= i;
    }
    ans.push_back(make_pair(i, count));
  }
  if (x != 1)
    ans.push_back(make_pair(x, 1));
  return ans;
}

int main() {
  cout << setprecision(15) << fixed;
  ll N;
  cin >> N;
  auto fac = factorization(N);
  ll res = 0;
  for (auto &&f : fac) {
    ll e = f.second;
    ll tmp = 0, cur = 1;
    while (e >= cur)
      e -= cur++, ++tmp;
    res += tmp;
  }
  cout << res << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

template <typename T> auto factorization(T x) {
  vector<pair<T, int>> ans;
  for (T i = 2; i * i <= x; ++i) {
    if (x % i == 0) {
      T count = 0;
      while (x % i == 0) {
        ++count;
        x /= i;
      }
      ans.push_back(make_pair(i, count));
    }
  }
  if (x != 1)
    ans.push_back(make_pair(x, 1));
  return ans;
}

int main() {
  cout << setprecision(15) << fixed;
  int N;
  cin >> N;
  auto fac = factorization(N);
  ll res = 0;
  for (auto &&f : fac) {
    ll e = f.second;
    ll tmp = 0, cur = 1;
    while (e >= cur)
      e -= cur++, ++tmp;
    res += tmp;
  }
  cout << res << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
using namespace std;

int main() {
  long long n, a[100][2], i, j, k, ans;
  cin >> n;
  for (i = 0; i < 100; i++)
    for (j = 0; j < 2; j++)
      a[i][j] = 0;
  j = 0;
  ans = 0;
  while (n > 1) {
    for (i = 2; i < n; i++) {
      if (pow(i, 2) > n) {
        a[j][0] = i;
        j++;
        a[j - 1][1]++;
        n = 1;
      } else if (n % i == 0) {
        a[j][0] = i;
        j++;
        while (n % i == 0) {
          n /= i;
          a[j - 1][1]++;
        }
      }
    }
  }
  for (i = 0; i < j; i++) {
    k = 1;
    while (a[i][1] > 0) {
      a[i][1] -= k;
      if (a[i][1] >= 0)
        k++;
    }
    ans = ans + k - 1;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long long n, a[100][2], i, j, k, ans;
  cin >> n;
  for (i = 0; i < 100; i++)
    for (j = 0; j < 2; j++)
      a[i][j] = 0;
  i = 2;
  j = 0;
  ans = 0;
  while (n > 1) {
    if (n % i == 0) {
      a[j][0] = i;
      j++;
      while (n % i == 0) {
        n /= i;
        a[j - 1][1]++;
      }
    }
    i++;
  }
  for (i = 0; i < j; i++) {
    k = 1;
    while (a[i][1] > 0) {
      a[i][1] -= k;
      if (a[i][1] >= 0)
        k++;
    }
    ans = ans + k - 1;
  }
  cout << ans << endl;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1) {
    mp[n]++;
  }
  ll ans = 0;
  vector<ll> s(51);
  for (int i = 0; i < 50; ++i) {
    s[i + 1] = s[i] + (i + 1);
  }
  for (auto a : mp) {
    ll key = a.first;
    ll value = a.second;
    ll res = upper_bound(s.begin(), s.end(), value) - s.begin() - 1;
    ans += res;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll n;
  cin >> n;
  map<ll, ll> mp;
  for (int i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n != 1) {
    mp[n]++;
  }
  ll ans = 0;
  vector<ll> s(51);
  for (int i = 0; i < 50; ++i) {
    s[i + 1] = s[i] + (i + 1);
  }
  for (auto a : mp) {
    ll key = a.first;
    ll value = a.second;
    ll res = upper_bound(s.begin(), s.end(), value) - s.begin() - 1;
    ans += res;
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>
#include <utility>
#include <vector>

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

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

  auto factors = prime_factor(n);

  int totalCount = 0;
  for (const auto &factor : factors) {
    auto count = factor.second;
    auto suber = 1;
    while (true) {
      count -= suber;
      if (count < 0) {
        break;
      }
      ++suber;
      ++totalCount;
    }
  }

  std::cout << totalCount;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <utility>
#include <vector>

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

  std::vector<std::pair<long long, int>> factors;
  long long diviser = 2;
  while (n > 1) {
    int count = 0;
    while (n % diviser == 0) {
      n /= diviser;
      ++count;
    }
    if (count > 0) {
      factors.push_back(std::make_pair(diviser, count));
    }
    ++diviser;
  }

  int totalCount = 0;
  for (const auto &factor : factors) {
    auto count = factor.second;
    int suber = 1;
    while (count >= 1) {
      count -= suber;
      if (count < 0) {
        break;
      }
      ++totalCount;
      ++suber;
    }
  }

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

#include <iostream>
#include <utility>
#include <vector>
using namespace std;

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

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

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

  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int64_t N;
  cin >> N;
  int64_t temp = N;
  int count = 0;
  for (int64_t i = 2; i <= N; i++) {
    if (temp % i == 0) {
      count += 1;
      temp = temp / i;
    }
  }
  cout << count << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

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

ll n;
vector<int> x;

// int c;

// int count(int num) {
//     int i = 0;
//     ll sum = 0;
//     int c = 0;
//     while(1) {
//         ++i;
//         sum += i;
//         if (sum > num) break;
//         c++;
//     }
//     return c;
// }

void dec(ll num) {
  for (ll i = 2; i * i <= num; ++i) {
    int y = 0;
    while (num % i == 0) {
      num /= i;
      ++y;
    }
    if (y != 0)
      x.push_back(y);
  }
  if (num != 1)
    x.push_back(1);
}

int main() {
  cin >> n;
  dec(n);
  int ans = 0;
  for (auto i : x) {
    int b = 1;
    while (b <= i) {
      i -= b;
      ++b;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

ll n;
vector<int> x;
int c;

int count(int num) {
  int i = 0;
  ll sum = 0;
  int c = 0;
  while (1) {
    ++i;
    sum += i;
    if (sum > num)
      break;
    c++;
  }
  return c;
}

void dec(ll num) {
  for (int i = 2; i * i <= num; ++i) {
    int cnt_i = 0;
    while (num % i == 0) {
      num /= i;
      ++cnt_i;
    }
    if (cnt_i != 0)
      x.push_back(cnt_i);
  }
  if (num != 1)
    x.push_back(1);
}

int main() {
  cin >> n;
  dec(n);
  int ans = 0;
  for (auto i : x) {
    int b = 1;
    while (b <= i) {
      i -= b;
      ++b;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
int main() {

  ull N;
  cin >> N;
  int ans = 0;
  for (int i = 2; i <= 1000000; ++i) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    for (int j = 1; j <= cur; ++j) {
      if (cur < j)
        break;
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

  ll N;
  cin >> N;
  int ans = 0;
  for (int i = 2; i * i <= N; ++i) {
    int cur = 0;
    while (N % i == 0) {
      cur++;
      N /= i;
    }
    for (int j = 1; j <= 10000; ++j) {
      if (cur < j)
        break;
      ans++;
      cur -= j;
    }
  }
  if (N > 1)
    ans++;
  cout << ans << endl;

  return 0;
}