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

// Radhe Radhe
#include <bits/stdc++.h>
#define godspeed                                                               \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define mod 1000000007
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define en '\\n'
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep1(i, a, b) for (ll i = a; i <= b; i++)
#define repVect(i, n) for (ll i = 0; i < sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout << "Yes" << '\\n'
#define no cout << "No" << '\\n'
using namespace std;

int main() {
  godspeed ll n, i, j, k;
  string s;
  ll ans = 0;
  cin >> n;
  for (i = 1; i < n; i++) {
    ll lol = n / i;
    if (n % i)
      ans += lol;
    else
      ans += lol - 1;
    /*for(j=1; j<n; j++)
    {
        if(i*j<n){

            ans++;
        cout<<++noo<<": "<<i<<" "<<j<<" "<<i*j<<en;
        }
    }*/
  }
  cout << ans << en;
  return 0;
}


Error: TLE

Fixed submission:

// Radhe Radhe
#include <bits/stdc++.h>
#define godspeed                                                               \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define mod 1000000007
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define en '\\n'
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep1(i, a, b) for (ll i = a; i <= b; i++)
#define repVect(i, n) for (ll i = 0; i < sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout << "Yes" << '\\n'
#define no cout << "No" << '\\n'
using namespace std;

int main() {
  godspeed ll n, i, j, k;
  string s;
  ll ans = 0;
  cin >> n;
  ll noo = 0;
  for (i = 1; i < n; i++) {
    for (j = 1; j < n; j++) {
      if (i * j < n) {

        ans++;
        //  cout<<++noo<<": "<<i<<" "<<j<<" "<<i*j<<en;
      }
    }
  }
  cout << ans << en;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main() {

  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i < n; i++)
    ans += (n - 1) / i;

  cout << ans;

  return 0;
}

Error: TLE

Fixed submission:

#pragma GCC optimize(2)
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int cc[1000005];

void build(void) {
  for (int i = 1; i <= 1000000; i++) {
    int cur = i;

    for (int j = 1; j * j <= cur; j++) {
      if (j * j == cur)
        cc[i]++;
      else if (cur % j == 0)
        cc[i] += 2;
    }
  }
}

int main() {
  // clock_t start = clock();
  build();
  // cout << fixed << setprecision(12) << (long double)(clock() - start) /
  // CLOCKS_PER_SEC << endl;
  int n;
  cin >> n;

  int ans = 0;
  for (int i = 1; i < n; i++)
    ans += cc[n - i];

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
// #define s second
#define mod 1000000007
const ll N = 2e5 + 5;
unordered_map<ll, vector<ll>> adj;
vector<ll> vis(300005, 0);
vector<ll> p(100005, 0);
ll c[100005];
ll cnt;
ll n;
void dfs(ll node) {
  if (vis[node])
    return;
  vis[node] = 1;
  cnt++;
  for (auto i : adj[node]) {
    dfs(i);
  }
}
struct range {
  ll l;
  ll r;
  ll index;
};
bool cmp(range &p1, range &p2) { return p1.l < p2.l; }

int main() {
  ll n;
  cin >> n;
  ll i, j;
  ll temp;
  ll cnt = 0;
  for (i = 1; i <= sqrt(n - 1); i++) {
    for (j = i; j * i < n; j++)
      cnt++;
  }
  cnt *= 2;
  cnt -= int(sqrt(n - 1));
  cout << cnt;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define f first
// #define s second
#define mod 1000000007
const ll N = 2e5 + 5;
unordered_map<ll, vector<ll>> adj;
vector<ll> vis(300005, 0);
vector<ll> p(100005, 0);
ll c[100005];
ll cnt;
ll n;
void dfs(ll node) {
  if (vis[node])
    return;
  vis[node] = 1;
  cnt++;
  for (auto i : adj[node]) {
    dfs(i);
  }
}
struct range {
  ll l;
  ll r;
  ll index;
};
bool cmp(range &p1, range &p2) { return p1.l < p2.l; }

int main() {
  ll n;
  cin >> n;
  ll i, j;
  ll temp;
  ll cnt = 0;
  for (j = 1; j < n; j++) {
    temp = n - j;
    for (i = 1; i * i <= temp; i++) {

      if (temp % i == 0) {
        if (i == temp / i)
          cnt++;
        else
          cnt += 2LL;
      }
    }
  }
  cout << cnt;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  ll ans = 0;
  int k = n - 1;
  for (int i = 1; i < n; i++) {
    ans += k / i;
  }

  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

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

  ll ans = 0;
  for (int i = 1; i < n; i++) {
    int k = n - i;
    for (int j = 1; j * j <= k; j++) {
      if (k % j == 0) {
        if (k / j == j) {
          ans++;
        } else {
          ans += 2;
        }
      }
    }
  }

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

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

void solve() {

  // A * B + C = N
  int n;
  cin >> n;
  // int a,b,c;
  int count = 0;

  for (int i = 1; i < n; i++) {
    count += (n - 1) / i;
  }

  cout << count;
}

int main() { solve(); }

Error: TLE

Fixed submission:

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

void solve() {

  // A * B + C = N
  int n;
  cin >> n;
  // int a,b,c;
  int count = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      if (n - (i * j) > 0) {
        count++;
      }
    }
  }
  cout << count;
}

int main() { solve(); }
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N, a, f;
  int count = 0;

  cin >> N;

  for (int i = 0; i < N; i++) {
    f = 0;
    for (int j = 0; j < N; j++) {
      if (f == 1) {
        break;
      }
      a = (i + 1) * (j + 1);
      if (a < N) {
        count += 1;
      } else {
        f = 1;
      }
    }
  }
  cout << count << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int N, a, b;
  int count = 0;

  cin >> N;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      b = (N - (j + 1));
      if (b == 0) {
        continue;
      }
      a = b % (i + 1);
      if (a == 0) {
        count += 1;
      }
    }
  }
  cout << count << endl;
}
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 a = 1; a < n; a++) {
    count += (n - 1) / a;
  }

  cout << count;
}


Error: TLE

Fixed submission:

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

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

  int count = 0;
  for (int a = 1; a < n; a++) {
    for (int b = 1; b < n; b++) {
      if ((n - a * b) >= 1) {
        count++;
      }
    }
  }
  cout << count;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
using namespace std;
int main() {
  uint64 ans = 0;
  int n;
  cin >> n;
  rep(i, 1, n) {
    for (int j = 1; j * i < n; j++) {
      ans++;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
using namespace std;
int main() {
  uint64 ans = 0;
  int n;
  cin >> n;
  rep(i, 1, n) {
    rep(j, 1, i * j < n) { ans++; }
  }
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int main() {
  int N;
  cin >> N;
  int cou = 0;
  int nn = N - 1;
  for (int i = 1; i <= N; i++) {
    cou = cou + nn / i;
  }

  cout << cou << endl;
}

Error: TLE

Fixed submission:

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

#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))

int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int main() {
  int N;
  cin >> N;
  int cou = 0;
  int nn = N;
  for (int i = 1; i <= N - 1; i++) {
    nn = N - i;
    for (ll i = 1; i * i <= nn; i++) {
      if (nn % i == 0 && nn != i * i) {
        cou = cou + 2;
      }
      if (nn % i == 0 && nn == i * i) {
        cou = cou + 1;
      }
    }
  }

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

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

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

  int cnt = 0;
  for (int c = 1; c <= N - 1; ++c) {
    int target = N - c;
    double dThr = sqrt(target);
    for (int a = 1; a <= dThr; ++a) {
      // int ia = int(round(da));
      int b = target / a;
      if (a * b == target) {
        if (a == b)
          ++cnt;
        else
          cnt += 2;
      }
    }
  }

  cout << cnt << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

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

  int cnt = 0;
  for (int c = 1; c <= N - 1; ++c) {
    int target = N - c;
    double dThr = sqrt(target);
    for (int a = 1; a <= dThr; ++a) {
      // int ia = int(round(da));
      if (target % a == 0) {
        int b = target / a;
        if (a == b)
          ++cnt;
        else
          cnt += 2;
      }
    }
  }

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

#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define w(x)                                                                   \\
  int x;                                                                       \\
  cin >> x;                                                                    \\
  while (x--)

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

#define MAXN 1000001

int spf[MAXN];

void sieve() {
  spf[1] = 1;
  for (int i = 2; i < MAXN; i++)

    spf[i] = i;

  for (int i = 4; i < MAXN; i += 2)
    spf[i] = 2;

  for (int i = 3; i * i < MAXN; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j < MAXN; j += i)

        if (spf[j] == j)
          spf[j] = i;
    }
  }
}

long long int getFactorization(int x) {
  map<int, int> map;
  vector<int> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
    map[spf[x]]++;
    x = x / spf[x];
  }
  long long int ans = 1;
  for (auto i : map) {
    int x = i.first;
    int y = i.second;
    // cout<<x<<" "<<y<<" "
    ans *= (y + 1);
  }
  return ans;
}

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  sieve();
  long long int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    if (i == n - 1)
      ans++;
    else {
      int x = getFactorization(n - i);
      // if(x%2==1)
      // {
      //     ans--;
      // }
      ans += x;
    }
  }
  cout << ans;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define w(x)                                                                   \\
  int x;                                                                       \\
  cin >> x;                                                                    \\
  while (x--)

long long int give(long long int n) {
  long long int ans = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      ans++;
      if (n / i != i)
        ans++;
    }
  }
  return ans;
}

int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    // cout<<i<<" ";
    ans += give(n - i);
  }
  cout << ans;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

// nの約数の個数を返す
long long d_num(long long n) {
  long long cnt = 0;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0)
      cnt += 2;
    if (i * i == n)
      --cnt;
  }
  return cnt;
}

// n以下の正の整数の約数の和を返す
long long d_num2(long long N) {
  long long cnt = 0;
  for (int n = 1; n <= N; ++n) {
    for (int i = 1; i * i <= n; ++i) {
      if (n % i == 0)
        cnt += 2;
      if (i * i == n)
        --cnt;
    }
  }
  return cnt;
}

int main() {
  int n;
  std::cin >> n;
  // long long sum = 0;
  // for (int c = 1; c <= n-1; ++c) {
  //   sum += d_num(n-c);
  // }
  std::cout << d_num2(n - 1) << std::endl;
  // std::cout << sum << std::endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

// nの約数の個数を返す
long long d_num(long long n) {
  long long cnt = 0;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0)
      cnt += 2;
    if (i * i == n)
      --cnt;
  }
  return cnt;
}

int main() {
  int n;
  std::cin >> n;
  long long sum = 0;
  for (int c = 1; c <= n - 1; ++c) {
    sum += d_num(n - c);
  }
  std::cout << sum << std::endl;

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

#include <iostream>
using namespace std;

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

  int count = 0;
  for (int a = 1; a < N; a++) {
    count += (N - 1) / a;
  }

  cout << count << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

  int count = 0;
  for (int c = 1; c < N; c++) {
    int T = N - c;
    for (int b = 1; b <= T; b++) {
      if (T % b == 0) {
        count++;
      }
    }
  }

  cout << count << endl;

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

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


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int res = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      if (i * j < n)
        res++;
    }
  }
  cout << res << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

// Template START
#define endl "\\n"
#define async                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define Int long long int
#define all(y) y.begin(), y.end()
#define present(x, y) (x.find(y) != x.end())
const int mod = (int)1e9 + 7;
template <class T> auto matrix(int r, int c, T v) {
  return vector<vector<T>>(r, vector<T>(c, v));
}
template <class T> auto matrix(int o1, int o2, int o3, T v) {
  return vector<vector<vector<T>>>(o1, vector<vector<T>>(o2, vector<T>(o3, v)));
}
#define v vector
// Template END

int power(int x, int n) {
  if (n == 0)
    return 1;
  else if (n & 1)
    return (x * power((x * x) % mod, n / 2)) % mod;
  return power((x * x) % mod, n / 2) % mod;
}

signed main() {
  int N;
  cin >> N;
  int sqrtN = sqrt(N);
  int ans = 0;
  for (int a = 1; a <= N; a++) {
    ans += (ceil((N * 1.0) / a) - 1);
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

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

// Template START
#define endl "\\n"
#define async                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define Int long long int
#define all(y) y.begin(), y.end()
#define present(x, y) (x.find(y) != x.end())
const int mod = (int)1e9 + 7;
template <class T> auto matrix(int r, int c, T v) {
  return vector<vector<T>>(r, vector<T>(c, v));
}
template <class T> auto matrix(int o1, int o2, int o3, T v) {
  return vector<vector<vector<T>>>(o1, vector<vector<T>>(o2, vector<T>(o3, v)));
}
#define v vector
// Template END

int power(int x, int n) {
  if (n == 0)
    return 1;
  else if (n & 1)
    return (x * power((x * x) % mod, n / 2)) % mod;
  return power((x * x) % mod, n / 2) % mod;
}

signed main() {
  int N;
  cin >> N;
  int sqrtN = sqrt(N);
  int ans = 0;
  int make, sq;
  for (int c = 1; c < N; c++) {
    make = N - c;
    sq = sqrt(make);
    for (int i = 1; i <= sq; i++) {
      if (make % i == 0) {
        if ((i * i) == make) {
          ans += 1;
        } else {
          ans += 2;
        }
      }
    }
  }
  cout << ans;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int prime_factor(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 main() {
  int N;
  cin >> N;
  int c = 1;
  for (int i = 2; i < N; i++) {
    c += prime_factor(i);
  }
  cout << c << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

// 素因数分解
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;
}

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

#include <bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll i, j, k, x, y, z, m, n, t, l, r;
  cin >> n;
  m = n;
  set<pair<ll, pair<ll, ll>>> s;
  ll cnt = 0;
  for (i = 1; i < n; i++) {
    l = i; // cout<<double(n)/double(l)<<'\\n';
    for (j = 1; j < double(n) / double(l); j++) {
      cnt++;
    }
  }
  cout << cnt << '\\n';
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define pb emplace_back
#define ll long long
#define mp make_pair
#define PI acos(-1)
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll i, j, k, x, y, z, m, n, t, l, r;
  cin >> n;
  m = n;
  set<pair<ll, pair<ll, ll>>> s;
  ll cnt = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      if (i * j < m) {
        x = i * j;
        s.insert(mp(i, mp(j, m - x)));
        s.insert(mp(j, mp(i, m - x)));
      } else
        break;
    }
  }
  cout << s.size() << '\\n';
}