Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set                                                            \
  tree<int, null_type, less<int>, rb_tree_tag,                                 \
       tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define pb push_back
#define t_case                                                                 \
  ll tt;                                                                       \
  cin >> tt;                                                                   \
  while (tt--)
#define all(v) v.begin(), v.end()
#define ub(a, x) upper_bound(all(a), x) - a.begin()
#define lb(a, x) lower_bound(all(a), x) - a.begin()
#define fr(a, b, c) for (ll a = b; a < c; a++)
#define take(xx, n)                                                            \
  for (int i = 0; i < n; i++)                                                  \
    cin >> xx[i];
#define take1(xx, n)                                                           \
  for (int i = 1; i <= n; i++)                                                 \
    cin >> xx[i];
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
const auto inf = LLONG_MAX;

int main() {
  fastio
  // t_case
  {
    ll sum = 0, f = 1, ans = 0, n, m = 1, mx = -inf, mn = inf, x, y, k;
    cin >> n;

    fr(i, 1, n) {
      for (int j = 1; j * j <= i; j++) {
        if (i % j == 0) {
          if ((i / j) == j)
            ans++;
          else
            ans += 2;
        }
      }
    }
    cout << ans;
    cout << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set                                                            \
  tree<int, null_type, less<int>, rb_tree_tag,                                 \
       tree_order_statistics_node_update>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define endl '\n'
#define pb push_back
#define t_case                                                                 \
  ll tt;                                                                       \
  cin >> tt;                                                                   \
  while (tt--)
#define all(v) v.begin(), v.end()
#define ub(a, x) upper_bound(all(a), x) - a.begin()
#define lb(a, x) lower_bound(all(a), x) - a.begin()
#define fr(a, b, c) for (ll a = b; a < c; a++)
#define take(xx, n)                                                            \
  for (int i = 0; i < n; i++)                                                  \
    cin >> xx[i];
#define take1(xx, n)                                                           \
  for (int i = 1; i <= n; i++)                                                 \
    cin >> xx[i];
#define fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
const auto inf = LLONG_MAX;

int main() {
  fastio
  // t_case
  {
    ll sum = 0, f = 1, ans = 0, n, m = 1, mx = -inf, mn = inf, x, y, k;
    cin >> n;

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