Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

/*💚💚💚 ITS A SLOW PROCESS BUT QUITING WONT SPEED IT UP 💚💚💚*/

#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
using namespace std;

/*-------------define----------------------------*/
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ceilval(a, b) (a + b - 1) / b
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define cf(x)                                                                  \\
  ll x;                                                                        \\
  cin >> x;                                                                    \\
  while (x--)

/*---------------bak****i end-----------------------*/

void zaroorat() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
}
typedef pair<int, int> pairs;

int main()

{
  zaroorat();

  ll n;
  cin >> n;
  ll cnt = 0;
  for (int i = 1; i < n; i++) {
    if (n % i == 0) {
      cnt += n / i - 1;
    } else {
      cnt += n / i;
    }
  }
  cout << cnt << endl;

  return 0;
}


Error: TLE

Fixed submission:

/*💚💚💚 ITS A SLOW PROCESS BUT QUITING WONT SPEED IT UP 💚💚💚*/

#include <bits/stdc++.h>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
using namespace std;

/*-------------define----------------------------*/
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ceilval(a, b) (a + b - 1) / b
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define cf(x)                                                                  \\
  ll x;                                                                        \\
  cin >> x;                                                                    \\
  while (x--)

/*---------------bak****i end-----------------------*/

void zaroorat() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
}
typedef pair<int, int> pairs;

int main()

{
  zaroorat();

  ll n;
  cin >> n;
  set<pair<pairs, int>> s;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < n; j++) {

      ll divd = i;
      ll div = j;
      ll rem = n - i * j;
      if (rem > 0) {
        pair<int, int> x = make_pair(divd, div);
        pair<int, int> y = make_pair(div, divd);
        pair<pair<int, int>, int> one = make_pair(x, rem);
        pair<pair<int, int>, int> sec = make_pair(y, rem);
        s.insert(one);
        s.insert(sec);
      }
    }
  }
  cout << s.size() << endl;

  return 0;
}