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

#include <iostream>
using namespace std;

int main() {
  int n = 0;
  cin >> n;
  bool over = false;

  int count = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < n; ++j) {
      int a = i * j;
      if (a >= n) {
        // cout << "e" <<  endl;
        break;
      }
      // cout << a << endl;

      for (int k = n - a; k < n; ++k) {
        int ans = i * j + k;
        // cout <<ans<< endl;
        // cout << "i " << i << " j " << j << " k " << k << endl;
        if (ans < n) {
          continue;
        } else if (ans > n) {
          break;
        }
        ++count;
        break;
      }
    }
  }
  cout << count;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

  int count = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (i * j >= n)
        break;
      for (int k = 1; k <= n; ++k) {
        if (i * j + k == n) {
          ++count;
        }
      }
    }
  }
  cout << count;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int num(int a) {
  int ans = 1;

  for (int i = 2; i <= sqrt(a); i++) {
    int cnt = 0;
    while (a % i == 0) {
      cnt++;
      a /= i;
    }
    ans *= (cnt + 1);
    if (a == 1)
      break;
  }
  if (a != 1)
    ans *= 2;

  return ans;
}
int N;
int main() {
  cin >> N;
  int x = 0;
  for (int i = 1; i < N; i++) {
    x = x + num(N - i);
  }
  cout << x;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
// 素因数分解
template <typename T> map<T, T> prime_factor(T n) {
  map<T, T> ret;
  for (T i = 2; i * i <= n; i++) {
    T tmp = 0;
    while (n % i == 0) {
      tmp++;
      n /= i;
    }
    ret[i] = tmp;
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}
/*  divisor_num(n)
    入力：整数 n
    出力：nの約数の個数
    計算量：O(√n)
*/
template <typename T> T divisor_num(T N) {
  map<T, T> pf = prime_factor(N);
  T ret = 1;
  for (auto p : pf) {
    ret *= (p.second + 1);
  }
  return ret;
}
long long N;
int main() {
  cin >> N;
  long long x = 0;
  for (int i = 1; i < N; i++) {
    x = x + divisor_num(N - i);
  }
  cout << x;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
/*
CE 头文件
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<deque>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

*/
using namespace std;
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a, b) memset(a, b, sizeof(a))
#define ios                                                                    \\
  std::ios::sync_with_stdio(false);                                            \\
  std::cin.tie(0);                                                             \\
  std::cout.tie(0);
// ios和scanf,printf不能混用.即用ios必须全部cin,cout.
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
const ll mod = 1000000007;

ll ksm(ll a, ll b) {
  ll res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const int N = 110;
PII factor[N];
int n, k;

int main() {
  scanf("%d", &n);
  n--;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += 1ll * n / i;
  }

  printf("%lld", ans);
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
/*
CE 头文件
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<deque>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>

*/
using namespace std;
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a, b) memset(a, b, sizeof(a))
#define ios                                                                    \\
  std::ios::sync_with_stdio(false);                                            \\
  std::cin.tie(0);                                                             \\
  std::cout.tie(0);
// ios和scanf,printf不能混用.即用ios必须全部cin,cout.
typedef vector<int> VI;
typedef long long ll;
typedef pair<int, int> PII;
const ll mod = 1000000007;

ll ksm(ll a, ll b) {
  ll res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
const int N = 110;
PII a[N];
int n;
int divide(int x) {
  int sum = 0;
  for (int i = 1; i <= sqrt(x); i++) {
    if (x % i == 0) {
      sum += 2;
    }
    if (i * i == x)
      sum--;
  }
  return sum;
}
int main() {
  scanf("%d", &n);
  ll ans = 0;
  rep(i, 1, n - 1) { ans = ans + 1ll * divide(i); }
  printf("%lld", ans);
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded


// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define endl "\\n"
#define int long long
int mod = 1e9 + 7;
int po(int x, int y, int m) {
  if (y == 0)
    return 1;
  int t = po(x, y / 2, m) % m;
  t = (t * t) % m;
  if (y & 1)
    return (t * x) % m;
  return t % m;
}

const int mx = 1000001;
vector<bool> prim(mx, true);

void seive() {
  for (int p = 2; p * p <= 1000001; p++) {
    if (prim[p] == true)
      for (int i = p * p; i <= 1000001; i += p)
        prim[i] = false;
  }
}

int div(int n) {
  int total = 1;
  for (int p = 2; p <= n; p++) {
    if (prim[p]) {
      int count = 0;
      if (n % p == 0) {
        while (n % p == 0) {
          n = n / p;
          count++;
        }
        total *= (count + 1);
      }
    }
  }
  return total;
}

signed main() {

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

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

  int n;
  cin >> n;
  seive();
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    ans += floor(n - 1) / i;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:


// Problem : C - A x B + C
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define endl "\\n"
#define int long long
int mod = 1e9 + 7;
int po(int x, int y, int m) {
  if (y == 0)
    return 1;
  int t = po(x, y / 2, m) % m;
  t = (t * t) % m;
  if (y & 1)
    return (t * x) % m;
  return t % m;
}

int div(int n) {
  int count = 0;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      if (n / i == i)
        count += 1;

      else
        count += 2;
    }
  }
  return count;
}

signed main() {

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

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

  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    ans += div(i);
  }
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      long long temp = (i * j);
      if (temp >= n)
        break;
      ans++;
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    int temp = n - i;
    for (int f = 1; f * f <= temp; f++) {
      if (temp % f == 0)
        ans += 2;
      if (f * f == temp)
        ans -= 1;
    }
  }
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <vector>

#define DOLL long double
#define LOLI long long int
using namespace std;

const long C_10PW9 = 1000000000;
const int ULCODE = 32;

int divc(int s) {
  int r = 0;
  int sq = sqrt(s);
  for (int i = 1; i <= sq; i++) {
    if (s % i == 0) {
      r++;
      if (s / i != i) {
        r++;
      }
    }
  }
  return r;
}
int main() {
  int n;
  cin >> n;
  int f = 0;
  for (int i = 1; i < n; i++) {
    int a = (n - 1) / i;
    f += a;
  }
  cout << f << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <vector>

#define DOLL long double
#define LOLI long long int
using namespace std;

const long C_10PW9 = 1000000000;
const int ULCODE = 32;

int divc(int s) {
  int r = 0;
  int sq = sqrt(s);
  for (int i = 1; i <= sq; i++) {
    if (s % i == 0) {
      r++;
      if (s / i != i) {
        r++;
      }
    }
  }
  return r;
}
int main() {
  int n;
  cin >> n;
  int f = 0;
  for (int i = 1; i < n; i++) {
    f += divc(i);
  }
  cout << f << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int count_div(int n) {
  int cnt = 0;
  map<int, int> mp;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        cnt++;
        n = n / i;
      }
      mp[i] = cnt;
      cnt = 0;
    }
  }
  if (n > 1)
    mp[n]++;
  int ans = 1;

  for (auto x : mp) {
    ans *= (x.second + 1);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n;
  cin >> n;

  ll ans = 0;
  for (ll i = 1; i < n; i++) {
    ans += count_div(n - i);
  }
  cout << ans << "\\n";
}


Error: TLE

Fixed submission:

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

ll count_div(ll n) {
  int cnt = 0;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt += 2;
    }
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n;
  cin >> n;

  ll ans = 0;
  for (ll i = 1; i < n; i++) {
    ans += count_div(n - i);
  }
  cout << ans << "\\n";
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

using namespace std;

// #Rohitpratap311
// #Keep Calm And Stay Happy

typedef long long ll;
typedef long double ld;

int main() {
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  // ios::sync_with_stdio(0);
  // cin.tie(0);
  int n;
  cin >> n;
  ll ans = 0;
  for (int c = 1; c < n; ++c) {
    int val = n - c;
    ll no = 0;
    for (int i = 1; i * i <= val; ++i) {
      if (val % i == 0)
        no += 2;
    }
    if (int(sqrt(val)) * int(sqrt(val)) == val) {
      no -= 1;
    }
    ans += no;
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

using namespace std;

// #Rohitpratap311
// #Keep Calm And Stay Happy

typedef long long ll;
typedef long double ld;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t = 1;
  // cin>>t;
  while (t--) {
    int n;
    cin >> n;
    ll ans = 0;
    for (int c = 1; c < n; ++c) {
      int val = n - c;
      ll no = 0;
      for (ll i = 1; i * i <= val; ++i) {
        if (val % i == 0)
          no += 2;
      }
      if (int(sqrt(val)) * int(sqrt(val)) == val) {
        no -= 1;
      }
      ans += no;
    }
    cout << ans;
  }
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  long long ans = 0;

  for (long i = 1; i < n; i++) {
    long x = n / i;
    if (n % i == 0)
      x--;
    ans += x;
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

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

long solv(long n);
int main() {
  long n;
  cin >> n;

  long long ans = 0;

  for (long i = 1; i < n; i++) {
    long tmp = n - i;
    ans += solv(tmp);
  }
  cout << ans;
  return 0;
}

long solv(long n) {
  long rt = sqrt(n);
  long cnt = 0;
  for (long i = 1; i <= rt; i++) {
    if (n % i == 0)
      cnt++;
  }

  cnt *= 2;
  if ((rt * rt) == n)
    cnt--;
  return cnt;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define inf 1e18
#define all(v) (v).begin(), (v).end()
using namespace std;

vector<int> dx = {-1, 1, 0, 0};
vector<int> dy = {0, 0, -1, 1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  int ans = 0;
  while (n > 0) {
    --n;
    int i = 1;
    while (i * i <= n) {
      if (n % i == 0) {
        ans += 2;
        if (n / i == i) {
          ans--;
        }
      }
      i++;
    }
  }
  cout << ans << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define inf 1e18
#define all(v) (v).begin(), (v).end()
using namespace std;

vector<int> dx = {-1, 1, 0, 0};
vector<int> dy = {0, 0, -1, 1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  int ans = 0;
  for (ll c = 1; c <= n - 1; ++c) {
    ll x = n - c;
    for (ll i = 1; i * i <= x; ++i) {
      if (x % i == 0) {
        // cout << i << " " << x/i <<"\\n";
        if (i * i == x) {
          ans++;
        } else {
          ans += 2;
        }
      }
    }
  }
  cout << ans << "\\n";
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\\n'
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define repab(i, a, b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define printarr(v)                                                            \\
  for (auto x : v) {                                                           \\
    cout << x << " ";                                                          \\
  }
#define debug1(a) cout << #a << " " << (a) << endl;
#define debug2(a, b)                                                           \\
  cout << #a << " " << (a) << " " << #b << " " << (b) << endl;
#define debug3(a, b, c)                                                        \\
  cout << #a << " " << (a) << " " << #b << " " << (b) << " " #c << " " << (c)  \\
       << endl;
typedef long double ld;

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  vector<ll> div(n + 1, 0);

  // For every number from 1 to n
  for (ll i = 1; i <= n; i++) {

    // Increase divisors count for
    // every number divisible by i
    for (ll j = 1; j * i < n; j++)
      if (j * i >= 0) {
        div[i * j]++;
      }
  }

  for (ll i = 1; i <= n; i++)
    ans += div[i];
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\\n'
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define repab(i, a, b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define printarr(v)                                                            \\
  for (auto x : v) {                                                           \\
    cout << x << " ";                                                          \\
  }
#define debug1(a) cout << #a << " " << (a) << endl;
#define debug2(a, b)                                                           \\
  cout << #a << " " << (a) << " " << #b << " " << (b) << endl;
#define debug3(a, b, c)                                                        \\
  cout << #a << " " << (a) << " " << #b << " " << (b) << " " #c << " " << (c)  \\
       << endl;
typedef long double ld;
void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i < n; i++) {
    if (n - (i) > 0) {
      ll val = n - i;
      for (ll j = 1; j * j <= val; j++) {
        if (val % j == 0) {
          ll a = j;
          ll b = val / j;
          if (a == b) {
            ans += 1;
          } else {
            ans += 2;
          }
        }
      }
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin                                                               \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)

vector<int> divisor;
void findDivisors(int n) {

  // Array to store the count
  // of divisors
  divisor.resize(n + 1, 0);
  //   memset(div, 0, sizeof div);

  // For every number from 1 to n
  for (int i = 1; i <= n; i++) {

    // Increase divisors count for
    // every number divisible by i
    for (int j = 1; j * i <= n; j++)
      divisor[i * j]++;
  }
}

int main() {
  fast_cin;
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif

  long long N;
  cin >> N;

  long long ans = 0;

  findDivisors(N);
  // ans=phi(N);
  // cout<<ans<<"\\n";
  for (int i = 1; i <= N - 1; i++) {
    ans += divisor[i];
  }
  cout << ans << "\\n";
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast_cin                                                               \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)

int phi(int n) {
  int result = n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0)
        n /= i;
      result -= result / i;
    }
  }
  if (n > 1)
    result -= result / n;
  return result;
}
long long countDivisors(long long n) {
  long long cnt = 0;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      // If divisors are equal,
      // count only one
      if (n / i == i)
        cnt++;

      else // Otherwise count both
        cnt = cnt + 2;
    }
  }
  return cnt;
}

int main() {
  fast_cin;
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif

  long long N;
  cin >> N;

  long long ans = 0;

  for (long long i = N - 1; i >= 1; i--) {
    ans += countDivisors(i);
  }
  // ans=phi(N);
  cout << ans << "\\n";
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  for (ll i = 1; i < n; i++) {
    m += (n - 1) / i;
  }

  cout << m << endl;
}


Error: TLE

Fixed submission:

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

ll divisor(ll n) {
  ll x = 0;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      x++;
      if (i * i != n)
        x++;
    }
  }
  return x;
}

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

  for (ll i = 1; i < n; i++) {
    m += divisor(n - i);
  }

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

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

int main() {
  int n;
  cin >> n;
  int total = 0;
  for (int a = 1; a < n; ++a) {
    total += (n - 1) / a;
  }
  cout << total << endl;
}

Error: TLE

Fixed submission:

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

int nextsosu(int b) {
  static vector<int> memo;
  if (b + 1 > memo.size()) {
    memo.resize(b + 1);
  } else if (memo[b] != 0) {
    return memo[b];
  }
  int r = b + 1;
  while (true) {
    int success = true;
    for (int i = 2; i < r; ++i) {
      if (r % i == 0) {
        success = false;
        break;
      }
    }
    if (success) {
      break;
    }
    ++r;
  }
  memo[b] = r;
  return r;
}

int func(int t) {
  int beBase = 1;

  int total = 1;
  for (int base; t != 1;) {
    base = nextsosu(beBase);
    beBase = base;
    int i = 1;
    while (t % base == 0) {
      t /= base;
      ++i;
    }
    total *= i;
  }
  return total;
}

int main() {
  int n;
  cin >> n;
  int total = 1;
  for (int i = 2; i < n; ++i) {
    total += func(i);
  }
  cout << total << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

// g++ -Wshadow -Wall -O2 -Wno-unused-result -Wno-psabi
#include "bits/stdc++.h"
#define f first
#define s second
#define inf 1e18
#define ll long long
#define mod 1000000007
#define pb emplace_back
#define vll vector<long long int>
#define ull unsigned long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(x) ((long long int)(x).size())
#define mll map<long long int, long long int>
#define pll pair<long long int, long long int>
using namespace std;

ll n;
const ll nax = 10e6 + 5;
ll cnt[nax] = {0};

void input() { cin >> n; }

void solve() {
  ll ans = 0;
  for (ll i = 1; i <= n; i++)
    for (ll j = i; j <= n; j += i)
      cnt[j]++;
  for (ll i = 1; i < n; i++)
    ans += cnt[i];
  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  ll t = 1;
  // cin >> t;
  while (t--) {
    input();
    solve();
    cout << endl;
  }
  cin.get();
  return 0;
}

Error: TLE

Fixed submission:

// g++ -Wshadow -Wall -O2 -Wno-unused-result -Wno-psabi
#include "bits/stdc++.h"
#define f first
#define s second
#define inf 1e18
#define ll long long
#define mod 1000000007
#define pb emplace_back
#define vll vector<long long int>
#define ull unsigned long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(x) ((long long int)(x).size())
#define mll map<long long int, long long int>
#define pll pair<long long int, long long int>
using namespace std;

ll n;

void input() { cin >> n; }

void solve() {
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    ll x = n - i;
    for (ll j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        ans += 2;
        if (j == x / j)
          ans--;
      }
    }
  }
  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  ll t = 1;
  // cin >> t;
  while (t--) {
    input();
    solve();
    cout << endl;
  }
  cin.get();
  return 0;
}