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

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

int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int i = 1; i < n; i++) {
    count += (n - 1) / i;
  }
  cout << count;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int i = 1; i < n; i++) {
    int a = n - i;
    for (int j = 1; j * j <= a; j++) {
      if (j * (a / j) == a)
        count += 2;
      if (j * (a / j) == a && j == a / j)
        count--;
    }
  }
  cout << count;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int factorize(long n) {

  map<long, long> prime;
  for (long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      prime[i]++;
      n /= i;
    }
  }
  if (n != 1) {
    prime[n] = 1;
  }
  long res = 1;
  for (auto it : prime) {
    res *= it.second + 1;
  }
  return res;
}

int main() {

  int n;
  cin >> n;
  long ans = 0;
  for (int c = 1; c < n; c++) {
    int nc = n - c;

    ans += factorize(nc);
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

long enum_divisors(long N) {
  long res = 0;

  for (long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res += 1;
      if (N / i != i) {
        res += 1;
      }
    }
  }
  return res;
}

int main() {

  long N;
  cin >> N;
  long res = 0;
  for (int c = 1; c < N; ++c) {
    res += enum_divisors(N - c);
  }

  cout << res << endl;

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

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int enum_divisors(int N) {
  int res = 0;

  for (int i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res += 1;
      if (N / i != i) {
        res += 1;
      }
    }
  }
  return res;
}

int main() {

  int N;
  cin >> N;
  long res = 0;
  for (int c = 1; c < N; ++c) {
    res += enum_divisors(N - c);
  }

  cout << res << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int enum_divisors(long N) {
  int res = 0;

  for (long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res += 1;
      if (N / i != i) {
        res += 1;
      }
    }
  }
  return res;
}

int main() {

  long N;
  cin >> N;
  long res = 0;
  for (int c = 1; c < N; ++c) {
    res += enum_divisors(N - c);
  }

  cout << res << endl;

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

#include <algorithm>
#include <iostream>
#include <math.h>
#include <time.h>

using namespace std;

const int prime_list[] = {
    2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,  43,
    47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101, 103, 107,
    109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
    191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263,
    269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
    353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
    439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521,
    523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613,
    617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
    709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
    811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887,
    907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997};
const int num_primes = 168;

int num_divisions(int n) {
  int ret = 1, i = 0, _n = n;
  while (_n > 1 && i < num_primes) {
    const int p = prime_list[i++];
    int d = 1;
    while (_n % p == 0)
      _n /= p, d++;
    ret *= d;
  }
  if (_n > 1)
    ret *= 2;
  return ret;
}

int main() {
  long N, ret = 0;
  cin >> N;
  for (int c = 1; c < N; c++) {
    ret += num_divisions(N - c);
  }
  cout << ret << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>
#include <time.h>

using namespace std;

int num_divisions(int n) {
  int sq = sqrt(n), ret = 0;
  for (int i = 1; i <= sq; i++)
    if (n % i == 0)
      ret += 1 + (i * i != n);
  return ret;
}

int main(int argc, char **argv) {
  // int N = 1000000;
  int N, ret = 0;
  cin >> N;
  // clock_t start = clock();
  for (int c = 1; c < N; c++)
    ret += num_divisions(N - c);
  // clock_t end = clock();
  // const double time =
  //     static_cast<double>( end - start ) / CLOCKS_PER_SEC * 1000.0;
  // cout << "time " << time << "[ms]" << endl;
  cout << ret << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define pii pair<int, int>
#define fi first
#define pb push_back
#define si second
#define int unsigned long long
#define mod 1000000007
#define debug(x) cout << #x << " " << x << endl;
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define double long double
#define all(o) o.begin(), o.end()
using namespace std;
int power(int x, int y) {
  int res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % mod;
    y = y >> 1; // y = y/2
    x = (x * x) % mod;
  }
  return res % mod;
}
int inv(int n) { return power(n, mod - 2) % mod; }

int a[2000005], p[1000006];
int32_t main() {

  fast int n, i, j;
  int ans = 0;
  cin >> n;
  for (i = 1; i <= 1000; i++)
    p[i * i] = 1;
  for (i = 2; i <= 1e6; i++) {
    if (a[i] == 0) {
      for (j = i; j <= 1e6; j += i)
        if (a[j] == 0)
          a[j] = i;
    }
  }
  for (i = 1; i < n; i++) {
    int rem = n - i;
    int per = p[rem];
    map<int, int> mp;

    while (rem > 1) {
      mp[a[rem]]++;
      rem /= a[rem];
    }
    int c = 1;
    for (auto x : mp)
      c *= (x.si + 1);
    ans += c;
  }
  cout << ans << "\\n";
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define pii pair<int, int>
#define fi first
#define pb push_back
#define si second
#define int unsigned long long
#define mod 1000000007
#define debug(x) cout << #x << " " << x << endl;
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define double long double
#define all(o) o.begin(), o.end()
using namespace std;
int power(int x, int y) {
  int res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % mod;
    y = y >> 1; // y = y/2
    x = (x * x) % mod;
  }
  return res % mod;
}
int inv(int n) { return power(n, mod - 2) % mod; }

int32_t main() {

  fast int n, i, j;
  int c = 0;
  cin >> n;
  for (i = 1; i < n; i++) {
    int rem = n - i;

    for (j = 1; j * j <= rem; j++) {
      if (rem % j == 0) {
        if (j * j == rem)
          c++;
        else
          c += 2;
      }
    }
  }
  cout << c << "\\n";
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <math.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, count = 0;
  cin >> N;
  for (int i = 1; i < N; i++) {
    count += floor((N - 1) / i);
  }
  cout << count << endl;
}

Error: TLE

Fixed submission:

#include <math.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
int yakusu(int n) {
  int ans = 0;

  for (int i = 1; i <= pow(n, 0.5); i++) {
    if (n % i == 0)
      ans += 2;
  }
  int r = floor(sqrt((double)n));
  if (r * r == n)
    ans--;
  return (ans);
}
int main() {
  int N, count = 0;
  cin >> N;
  for (int i = 1; i < N; i++) {
    int temp = yakusu(N - i);
    count += temp;
  }
  cout << count << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

ll f[1000050] = {0};

int main() {
  ll n, i, j;
  cin >> n;

  for (i = 1; i <= n; i++) {
    f[i]++;
    for (j = 2 * i; j <= n; j += i) {
      f[j]++;
    }
  }
  // for(i=1; i<=10; i++)
  // cout<<f[i]<<" ";

  ll a, b, c, res = 0;
  ;
  for (c = 1; c < n; c++) {
    ll num = n - c;

    res += f[num];
  }
  cout << res << 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;

  ll a, b, c, res = 0;
  ;
  for (c = 1; c < n; c++) {
    ll num = n - c;

    for (ll i = 1; i * i <= num; i++) {
      if (num % i == 0) {
        a = i;
        b = num / i;

        if (a == b)
          res++;
        else
          res += 2;
      }
    }
  }
  cout << res << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= n / i; j++) {
      if (i * j < n) {
        cnt++;
      }
    }
  }

  cout << cnt << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int n, cnt = 0, eq = 0;
  cin >> n;

  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      if (i * j < n) {
        cnt++;
      }
    }
  }

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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
// #include<bits/stdc++.h>

#define PI 2 * acos(0.0)
#define pb push_back

using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ans += (n - 1) / i;
  }

  cout << ans << "\\n";

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
// #include<bits/stdc++.h>

#define PI 2 * acos(0.0)
#define pb push_back

using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;

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

  ll cnt = 0;
  int i, j, k;
  ll n;

  cin >> n;

  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      for (k = 1; k <= n; k++) {
        if ((i * j + k == n)) {
          // cout<<i<<" "<<j<<" "<<k<<"\\n";
          cnt++;
        }
      }
    }
  }

  cout << cnt << "\\n";

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

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

int n;

int main() {
  cin >> n;
  long long ans = 0;
  // for(int i=1; i<=20; i++) cout << uoc_so(i) << '\\n';
  for (int a = 1; a < n; a++) {
    int b = (n - 1) / a;
    ans += b;
  }
  cout << ans;
  return 0;
}


Error: TLE

Fixed submission:

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

int n;

int uoc_so(int val) {
  int res = 0;
  for (int i = 1; i <= sqrt(val); i++) {
    if (val % i == 0 && i != val / i)
      res += 2;
    if (val % i == 0 && i == val / i)
      res++;
  }
  return res;
}

int main() {
  cin >> n;
  int ans = 0;
  // cout << uoc_so(2) << " " << uoc_so(1) << endl;
  for (int c = 1; c < n; c++) {
    ans += uoc_so(n - c);
  }
  cout << ans;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <ctype.h>
#include <iostream>
#include <math.h>
#include <stack>
#include <string.h>
#include <string>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;
const long INF = 2000000000;

int main() {
  long n;
  cin >> n;
  long sum[n + 10];
  sum[0] = 0;
  for (int i = 1; i <= n - 1; i++) {
    long cnt1 = 0, cnt2 = 0;
    for (int j = 1; j <= sqrt(i); j++) {
      if (i % j == 0 & i / j >= 1) {
        if (i / j == j)
          cnt2++;
        else
          cnt1++;
      }
    }
    // cout << cnt1 << " " << cnt2 << endl;
    sum[i] = sum[i - 1] + cnt1 * 2 + cnt2;
  }
  cout << sum[n - 1] << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <ctype.h>
#include <iostream>
#include <math.h>
#include <stack>
#include <string.h>
#include <string>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;
const long INF = 2000000000;

int main() {
  long n;
  cin >> n;
  int cnt1 = 0, cnt2 = 0;
  for (int i = 1; i <= n - 1; i++) {
    for (int j = 1; j <= sqrt(n - i); j++) {
      if ((n - i) % j == 0 & (n - i) / j >= 1) {
        if ((n - i) / j == j)
          cnt2++;
        else
          cnt1++;
      }
    }
  }
  cout << cnt1 * 2 + cnt2 << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  /*
  for(ll i=1;i<N;i++){
    ll k=N-i;
    ll an =0;
    ll t;
    for(ll j=1;j*j<=k;j++){
      if(k%j==0) an++;
      t=j;
    }
    if(t*t==k){
      ans += 2*an - 1;
    }else{
      ans += 2*an;
    }
    */
  for (int i = 1; i < N; i++) {
    ans += (N - 1) / i;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (ll i = 1; i < N; i++) {
    ll k = N - i;
    ll an = 0;
    ll t;
    for (ll j = 1; j * j <= k; j++) {
      if (k % j == 0)
        an++;
      t = j;
    }
    if (t * t == k) {
      ans += 2 * an - 1;
    } else {
      ans += 2 * an;
    }
  }
  /*
  for(ll i=1;i<N;i++){
    ll num = i;
    vector<ll> a;
    for(int j=2;j<=num;j++){
      ll sum=0;
      while(num%j==0){
        sum++;
        num/=j;
      }
      //cout << sum << endl;
      a.push_back(sum);
    }
    ll an1 = 1;
    for(ll t=0;t<a.size();t++){
      an1 *= a[t]+1;
    }
    ans += an1;
  }
  */
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
long long arr[1000007];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  long long n, i, j, k, x, y, z;
  x = 0;
  cin >> n;
  for (i = 1; i < n; i++) {
    if (n % i == 0) {
      x = x + n / i - 1;
    } else {
      x = x + n / i;
    }
  }
  cout << x << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long arr[1000007];
void dhoond(long long int n) {
  long long x, y, z, i, j, k;
  x = 0;
  for (i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      j = n / i;
      if (j == i) {
        x++;
      } else {
        x += 2;
      }
    }
  }
  arr[n] = x;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  long long n, i, j, k, x, y, z;
  x = 0;
  cin >> n;
  for (i = 1; i < 1000002; i++) {
    dhoond(i);
  }
  for (i = 1; i < n; i++) {
    x = x + arr[i];
  }
  cout << x << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define int long long
#define forn(i, a, n) for (int i = a; i < n; i++)

int n;
int cnt[1000001];

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

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

  cin >> n;
  forn(i, 1, n) {
    forn(j, 1, sqrt(n)) {
      if (i * j >= n)
        break;
      cnt[i * j]++;
      if (i != j && i >= sqrt(n))
        cnt[i * j]++;
    }
  }
  int res = 0;
  forn(i, 1, n) { res += cnt[i]; }
  cout << res << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

#define int long long
#define forn(i, a, n) for (int i = a; i < n; i++)

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

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

  int n, ans = 0;
  cin >> n;
  forn(i, 1, n) {
    int cnt = 0;
    int k = n - i;
    for (int j = 1; j * j <= k; j++) {
      if (k % j == 0) {
        cnt++;
        if (k / j != j)
          cnt++;
      }
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007

#define ll long long

#define FOR(i, a, b) for (int i = a; i < (b); i++)

#define FORd(i, a, b) for (int i = a; i < (b); --i)

int n;

void solve() {

  int ans = 0;

  FOR(i, 1, n) {

    FOR(j, 1, n) {

      if (i * j >= n)
        break;

      ans++;
    }
  }

  cout << ans << "\\n";
}

int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  cin >> n;

  solve();

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007

#define ll long long

#define FOR(i, a, b) for (int i = a; i < (b); i++)

#define FORd(i, a, b) for (int i = a; i < (b); --i)

int n;

void solve() {

  int ans = 0;

  FOR(i, 1, n) {

    FOR(j, 1, n) {

      if (i * j > n)
        break;

      FOR(k, 1, n) {

        if (i * j + k == n)
          ans++;
      }
    }
  }

  cout << ans << "\\n";
}

int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  cin >> n;

  solve();

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  //	for(int i=1;i<=1000000;i++){
  cin >> n;
  if (n == 0 || n == 1) {
    cout << 0;
    return 0;
  } else if (n == 2) {
    cout << 1;
    return 0;
  }
  n--;
  unsigned long long ans = n;
  for (int i = 2; i < n; i++) {
    ans += n / i;
  }
  ans++;
  cout << ans;
  //	}
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long num;
  //	for(int x=1;x<=1000000;x++){
  //	n=x;
  num = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i * j < n)
        num++;
    }
  }
  cout << num;
  //	}

  return 0;
}
Problem p02548 (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;
using ll = long long;

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

  rep(i, n - 1) {
    int a = n - (i + 1);
    int s = sqrt(a);
    int cnt = 0;
    // rep(j, (int)(sqrt(a) + 1e-9)+1){
    for (int j = 1; j < s + 1e-9; j++)
      if (a % j == 0)
        cnt += 2;
    if (s * s == a)
      cnt--;
    ans += cnt;
  }
  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;
using ll = long long;

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

  rep(i, n - 1) {
    int a = n - (i + 1);
    int cnt = 0;
    rep(j, (int)(sqrt(a) + 1e-9)) {
      if (a % (j + 1) == 0) {
        cnt++;
        if (a != (j + 1) * (j + 1))
          cnt++;
      }
    }
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

// g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined
// -D_GLIBCXX_DEBUG -o

vector<bool> Sieve(1000005, true);
void sieve() {
  Sieve[0] = false;
  Sieve[1] = false;
  for (ll i = 2; i * i <= 1000000; i++) {
    if (Sieve[i] == true) {
      for (ll j = i * i; j <= 1000000; j += i) {
        Sieve[j] = false;
      }
    }
  }
}
ll getDiv(ll n) {
  ll res = 0;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res++;
      if (n / i != i)
        res++;
    }
  }
  return res;
}
int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  n--;
  for (int i = 1; i <= n; i++)
    ans += (n / i);
  cout << ans << "\\n";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back

// g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined
// -D_GLIBCXX_DEBUG -o

vector<bool> Sieve(1000005, true);
void sieve() {
  Sieve[0] = false;
  Sieve[1] = false;
  for (ll i = 2; i * i <= 1000000; i++) {
    if (Sieve[i] == true) {
      for (ll j = i * i; j <= 1000000; j += i) {
        Sieve[j] = false;
      }
    }
  }
}
ll getDiv(ll n) {
  ll res = 0;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res++;
      if (n / i != i)
        res++;
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll gd[100001] = {0};
  for (int i = 1; i <= 100000; i++) {
    gd[i] = gd[i - 1] + getDiv(i);
  }
  ll n;
  cin >> n;
  ll ans = 0;
  //  for(int i=0;i<n;i++)cout<<i<<" "<<Sieve[i]<<"\\n";
  if (n <= 100000) {
    cout << gd[n - 1] << "\\n";
    return 0;
  }
  ans = gd[100000];
  for (int i = 100001; i < n; i++) {
    ans += getDiv(i);
  }
  cout << ans << "\\n";
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n;
  cin >> n;
  int a, b, c;
  int ab;
  int m = 0;
  for (c = 1; c < n; ++c) {
    for (a = 1; a * a <= c; ++a) {
      b = c / a;
      if (a * b == c) {
        m += 2;
        if (a == b)
          m--;
      }
    }
  }
  cout << m << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  int a, b, c;
  int ab;
  int m = 0;
  for (c = 1; c < n; ++c) {
    ab = n - c;
    for (a = 1; a * a <= ab; ++a) {
      b = ab / a;
      if (a * b == ab) {
        m += 2;
        if (a == b)
          m--;
      }
    }
  }
  cout << m << endl;
}