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

// THIS IS THE AATMANIRBHAR SOLUTION I FOUND..!!!!!
#define see(x) cerr << __LINE__ << ": " << (#x) << " is " << (x) << '\\n';
#define pb push_back
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define int double
// #define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define P push
#define vvi vector<vector<int>>
#define vi vector<int>
#define vf vector<float>
#define vc vector<char>
#define vs vector<string>
#define pii vector<pair<int, int>>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define sort(v) sort(all(v))
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(j, a, b) for (int j = a - 1; j >= b; j--)
#define binod                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0)
const int N = 1e9 + 7, N1 = 1e7 + 5, N2 = 1e6 + 3, N3 = 1e5 + 3;
#define IX INT_MAX
#define IM INT_MIN

void solve() {
  int n;
  cin >> n;
  int cnt = 0;
  vi ans(n + 5, 0);
  for (int i = 1; i < sqrt(n); i++) {
    // see(i)
    for (int j = i; j < n; j++) {
      if (i == j and i * i < n)
        cnt++;
      else if (i * j < n)
        cnt += 2;
      else
        break;
    }
    // see(cnt)
  }
  cout << cnt;
}

signed main() {
  binod;
  int t1 = 1;
  // cin>>t1;
  //  cout<<fixed<<setprecision(9);
  while (t1--) {
    solve();
    cout << endl;
  }
}

// Don't judge me or anyone
// this is life,
// not a reality show


Error: TLE

Fixed submission:

///*.......................Shadman Sakib Utshob............................*///

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

#define Boost                                                                  \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0), cout.tie(0)
#define see(x) cerr << __LINE__ << ": " << (#x) << " is " << (x) << '\\n';
#define pb push_back
#define seecontent(v)                                                          \\
  cout << (#v) << " is ";                                                      \\
  for (auto x : v) {                                                           \\
    cout << x << " ";                                                          \\
  }                                                                            \\
  cout << "\\n\\n";
#define inf 1e10
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define ll long long
#define pii pair<ll, ll>
#define MOD 1000000007
#define fileout freopen("output.txt", "w", stdout)
#define mem(x, i) memset(x, i, sizeof x)
#define Ones(x) __builtin_popcount(x);
#define PI acos(-1.0)
#define ff first
#define ss second
#define T                                                                      \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define ok cout << "ok" << endl;
#define all(x) (x).begin(), (x).end()
#define ordered_set                                                            \\
  tree<int, null_type, less<int>, rb_tree_tag,                                 \\
       tree_order_statistics_node_update>
#define nln cout << endl;
#define maxn 300005

int dx[] = {-1, 0, 1, 0}; // up,right,down,left
int dy[] = {0, 1, 0, -1};

int main() {
  Boost;
  ll n, i, x = 0, val, j, div = 0, ans = 0, k, mul;
  cin >> n;
  vector<ll> a(n);
  for (i = 1; i <= n - 1; i++) {
    val = n - i;
    // see(val)
    div = 0;
    if (val == 1) {
      ans++;
    } else {
      for (j = 1; j <= val; j++) {
        for (k = 1; k <= val; k++) {
          mul = j * k;
          if (mul > val)
            break;
          if (mul == val) {
            div++;
            break;
          }
        }
      }
      // div*=2;

      //            x=sqrt(val);
      //            if((x*x)==val)
      //            {
      //                div--;
      //            }
      // see(div)
      ans += div;
    }
  }
  cout << ans << endl;

  return 0;
}