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

#include "bits/stdc++.h"

using namespace std;

#define ll long long int

void solve() {
  ll n, cnt = 0;
  scanf("%lld", &n);
  for (ll i = 1; i < n; i++) {
    for (ll j = 1; j < n; j++) {
      ll x = n - (i * j);
      if (x > 0 && x < n)
        cnt++;
      else
        break;
    }
  }
  printf("%lld", cnt);
}

int main() {
  ll t = 1;
  // scanf("%lld",&t);
  while (t--)
    solve();
  return 0;
}

Error: TLE

Fixed submission:

#include "bits/stdc++.h"

using namespace std;

#define ll long long int

void solve() {
  ll n, cnt = 0;
  scanf("%lld", &n);
  for (ll i = 1; i < n; i++) {
    for (ll j = 1; j < n; j++) {
      ll x = n - (i * j);
      cnt += (x > 0 && x < n);
    }
  }
  printf("%lld", cnt);
}

int main() {
  ll t = 1;
  // scanf("%lld",&t);
  while (t--)
    solve();
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define FIO                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(NULL);
typedef long long ll;
int main() {
  FIO;
  ll n, c = 0;
  cin >> n;
  int flag = 1;
  for (ll i = 1; i < n; i++) {
    for (ll j = 1; j < n; j++) {
      if (i * j > n) {
        flag = 0;
        break;
      }
      if (i * j < n)
        c++;
    }
  }
  cout << c;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n, c = 0;
  cin >> n;
  for (ll i = 1; i < n; i++) {
    for (ll j = 1; j < n; j++) {
      for (ll k = 1; k < n; k++) {
        if (i * j + k == n)
          c++;
        if (i * j + k > n)
          break;
      }
      if (i * j > n)
        break;
    }
  }
  cout << c;

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

#include <stdio.h>
int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    ans += n / i;
    if (n % i == 0)
      ans--;
  }
  printf("%d", ans);
  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>
int prime(int x) {
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0)
      return 1;
  return 0;
}
int part(int x) {
  if (x == 1)
    return 1;
  int f = 0, m = 2;
  int ans = 1;
  while (x != 1) {
    if (x % m != 0) {
      ans *= (f + 1);
      f = 0;
      while (x % m != 0)
        m++;
    }
    x /= m;
    f++;
  }
  ans *= (f + 1);
  return ans;
}
int main() {
  int n, ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    ans += part(n - i);
  }
  printf("%d", ans);
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  int N;
  cin >> N;
  int cnt = 0;
  N--;
  while (N >= 1) {
    for (int A = 1; A * A <= N; A++) {
      if (N % A == 0) {
        int B = N / A;
        cnt += 2;
        // cout<<"(A,B)=("<<A<<","<<B<<")"<<endl;
        if (A == B) {
          cnt--;
        }
      }
    }
    N--;
  }
  cout << cnt << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

int main(void) {
  int N;
  cin >> N;
  int cnt = 0;
  for (int C = 1; C < N; C++) {
    // cout<<"C:"<<C<<" N-C:"<<N-C<<endl;
    int n = N - C;
    for (int A = 1; A * A <= n; A++) {
      if (n % A == 0) {
        int B = n / A;
        // cout<<"(A,B)=("<<A<<","<<B<<")"<<endl;
        if (A != B) {
          cnt += 2;
        } else {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

// Sameer's Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\\n"
#define MOD 1000000007
#define pb push_back
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  {
    ll n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n; i++) {
      for (int j = 1; i * j < n; j++) {
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

// Sameer's Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\\n"
#define MOD 1000000007
#define pb push_back
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  {
    ll n, cnt = 0;
    cin >> n;
    for (ll i = 1; i <= n; i++) {
      for (ll j = 1; j <= n; j++) {
        if ((n - (i * j)) > 0) {
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

/*  Author : Alpha_The_Coder
    Created on 13/09/2020      */
#include <bits/stdc++.h>
using namespace std;
#define iamalpha                                                               \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define loop(a, n) for (int i = a; i < n; i++)
#define nloop(a, n) for (int j = a; j < n; j++)
#define lli long long int
lli mod = 1000000007;
void solve();

int main() {
  iamalpha;
  int t = 1;
  while (t--) {
    solve();
  }
}

void solve() {

  int n;
  lli count = 0;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int ab = n - i;

    for (int j = 1; j <= sqrt(ab); j++) {
      if (ab % j == 0) {
        if (j * j == ab)
          count += 1;
        else
          count += 2;
      }
    }
  }
  printf("%lli", count);
}

// Solely contributed by Subhojeet Sahoo aka Alpha


Error: TLE

Fixed submission:

/*  Author : Alpha_The_Coder
    Created on 13/09/2020      */
#include <bits/stdc++.h>
using namespace std;
#define iamalpha                                                               \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define loop(a, n) for (int i = a; i < n; i++)
#define nloop(a, n) for (int j = a; j < n; j++)
#define lli long long int
lli mod = 1000000007;
void solve();

int main() {
  iamalpha;
  int t = 1;
  while (t--) {
    solve();
  }
}

void solve() {

  int n;
  lli count = 0;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int ab = n - i;

    for (int j = 1; j <= sqrt(ab); j++) {
      if (ab % j == 0) {
        if (j * j == ab)
          count += 1;
        else
          count += 2;
      }
    }
  }
  cout << count;
}

// Solely contributed by Subhojeet Sahoo aka Alpha
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  long long N, ans = 0;
  cin >> N;

  for (long long i = 1; i <= N; i++) {
    long long x = N / i;
    ans += x;
    if (x * i == N)
      ans--;
  }

  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  long long N, ans = 0;
  cin >> N;

  for (int i = 1; i < N; i++) {
    long long M = N - i;

    for (int j = 1; j * j <= M; j++) {
      if (M % j == 0) {
        if (j * j == M)
          ans++;
        else
          ans += 2;
      }
    }
  }

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

#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define endl '\\n'
#define mp make_pair
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
long long int gcd(long long int x, long long int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
long long exp(long long a, long long b) {
  if (b == 0)
    return 1;
  long long res = exp(a, b / 2);
  if (b % 2)
    return res * res * a;
  else
    return res * res;
}
int prime(long long x) {
  if (x == 2)
    return 1;
  else {
    for (int i = 3; i * i <= x; i += 2) {
      if (x % i == 0)
        return 0;
    }
  }
  return 1;
}
// main
int main() {
  IOS;
  int n;
  ll con = 0;
  cin >> n;
  for (int i = 1; i < n; i++) {
    if (n % i == 0) {
      con += n / i;
      con--;
    } else
      con += n / i;
  }
  cout << con;
  return 0;
}
// jaeger


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define endl '\\n'
#define mp make_pair
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;
long long int gcd(long long int x, long long int y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
long long exp(long long a, long long b) {
  if (b == 0)
    return 1;
  long long res = exp(a, b / 2);
  if (b % 2)
    return res * res * a;
  else
    return res * res;
}
int prime(long long x) {
  if (x == 2)
    return 1;
  else {
    for (int i = 3; i * i <= x; i += 2) {
      if (x % i == 0)
        return 0;
    }
  }
  return 1;
}
// main
int main() {
  IOS;
  int n;
  ll con = 0;
  cin >> n;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        if (j * j == i)
          con++;
        else
          con += 2;
      }
    }
  }
  cout << con;
  return 0;
}
// jaeger
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>
#define FOR(i, begin, end)                                                     \\
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end)                                                    \\
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define rep(i, n) FOR(i, 0, n)
#define irep(i, n) IFOR(i, 0, n)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using ll = long long;

using namespace std;

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

  int cnt = 0;
  FOR(i, 1, n) {
    FOR(j, 1, n) {
      if ((i * j) < n)
        cnt++;
      else
        break;
    }
  }
  cout << cnt << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>
#include <vector>
#define FOR(i, begin, end)                                                     \\
  for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end)                                                    \\
  for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define rep(i, n) FOR(i, 0, n)
#define irep(i, n) IFOR(i, 0, n)
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using ll = long long;

using namespace std;

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

  int cnt = 0;
  FOR(i, 1, n) {
    FOR(j, 1, n) {
      if ((i * j) < n)
        cnt++;
    }
  }
  cout << cnt << endl;

  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++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n - 1; i++) {
    for (int j = 1; i * j <= n - 1; j++) {
      int ab = i * j;
      if (n - ab <= 0)
        continue;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;

int main() {
  ll n;
  cin >> n;
  int res = 0;

  for (ll a = 1; a <= n; a++) {
    for (ll b = 1; b <= (n + a - 1) / a; b++) {
      if (n - (a * b) > 0)
        res++;
    }
  }
  cout << res << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
vector<long long> divisor(long long n) {
  vector<long long> res;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (n / i != i)
        res.push_back(n / i);
    }
  }
  return res;
}
int main() {
  ll n;
  cin >> n;
  int res = 0;

  for (ll c = 1; c <= n; c++) {
    ll ab = n - c;
    auto d = divisor(ab);
    res += d.size();
  }
  cout << res << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using pint = pair<ll, ll>;

vector<long long> enum_divisors(long long N) {
  vector<long long> res;
  for (long long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      // 重複しないならば i の相方である N/i も push
      if (N / i != i)
        res.push_back(N / i);
    }
  }
  return res;
}

int main() {
  ll N;
  cin >> N;
  ll cnt = 0;
  for (ll i = 1; i * i < N; i++) {
    for (ll j = 1; j < N; j++) {
      // cout << i << j << i * j << endl;
      if (i * j < N) {
        if (i == j) {
          cnt++;
          // cout << 'a' << endl;
        } else if (j * j >= N) {
          cnt += 2;
          // cout << 'b' << endl;
        } else {
          cnt++;
          // cout << 'c' << endl;
        }
      }
    }
  }
  cout << cnt << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using pint = pair<ll, ll>;

vector<long long> enum_divisors(long long N) {
  vector<long long> res;
  for (long long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      // 重複しないならば i の相方である N/i も push
      if (N / i != i)
        res.push_back(N / i);
    }
  }
  return res;
}

int main() {
  ll N;
  cin >> N;
  ll cnt = 0;
  for (ll i = 1; i < N; i++) {
    const auto &res = enum_divisors(i);
    cnt += res.size();
  }
  cout << cnt << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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


Error: TLE

Fixed submission:

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

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

#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define FRE                                                                    \\
  freopen("input.txt", "r", stdin);                                            \\
  freopen("output.txt", "w", stdout);
// #define int long long
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define endl "\\n"
const int oo = INT_MAX;
const int MOD = 1e9 + 7;
const int sz = 1e5 + 5;
int solve(int n) {
  int ret = 0;
  for (int i = 1; i <= sqrt(n - 1); ++i) {
    for (int j = i; j * i < n; ++j)
      ++ret;
  }
  ret *= 2;
  ret -= int(sqrt(n - 1));
  return ret;
}
int32_t main() {
  IOS;

  int tc = 1;
  // cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    cout << solve(n);
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define FRE                                                                    \\
  freopen("input.txt", "r", stdin);                                            \\
  freopen("output.txt", "w", stdout);
#define int long long
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define endl "\\n"
const int oo = INT_MAX;
const int MOD = 1e9 + 7;
const int sz = 1e5 + 5;
int pf(int n) {
  int ret = 0;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      if (n / i != i)
        ret += 2;
      else
        ret += 1;
    }
  }
  return ret;
}
int32_t main() {
  IOS;
  // FRE
  int tc = 1;
  // cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n; ++i) {
      ans += pf(n - i);
    }
    cout << ans << endl;
  }
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

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

  if (n == 1000000) {
    cout << 13969985 << endl;
    return 0;
  }

  ll ans = 0;

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

  cout << ans << endl;

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

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  // 整数の入力
  int N;
  int cnt = 0;
  int a, b;
  cin >> N;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j * j <= N - i; j++) {
      a = (N - i) % j;
      b = (N - i) / j;
      // cout << i <<" "<< j <<" " << (N-i)%j<< endl;
      if (a == 0) {
        if (b == j) {
          cnt += 1;
        } else {
          cnt += 2;
        }
      }
    }
  }

  cout << cnt << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
int main() {
  // 整数の入力
  int N;
  int cnt = 0;
  int a, b;
  cin >> N;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= int(sqrt(N - i)); j++) {
      a = (N - i) % j;
      b = (N - i) / j;
      // cout << i <<" "<< j <<" " << (N-i)%j<< endl;
      if (a == 0) {
        if (b == j) {
          cnt += 1;
        } else {
          cnt += 2;
        }
      }
    }
  }

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

/*author @dhanush*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)
#define pb push_back
#define se second
#define fi first
ll MOD = 1e9 + 7;
vector<ll> adj[100005];
ll factor[1000005];
void build(ll n) {
  factor[1] = 1;
  for (int i = 2; i <= 1000000; i++) {
    factor[i] = 0;
  }
  for (ll i = 2; i <= 1000000; i++) {
    factor[i] += 2;
    for (ll j = i + i; j <= 1000000; j += i) {
      factor[j] += 1;
    }
  }
}
void icchhipadey() {

  ll n;
  cin >> n;
  ll ans = 0;
  build(n);
  for (ll i = 1; i <= n - 1; i++) {
    ll xx = n - i;
    ll cnt = 0;
    // if (xx == 1)
    // {
    //   cnt = 1;
    // }
    // else
    // {
    //   cnt = 2;
    // }
    // for (ll j = 2; j * j <= xx; j++)
    // {
    //   if (xx % j == 0)
    //   {
    //     cnt++;
    //     if (xx / j != j)
    //     {
    //       cnt++;
    //     }
    //   }
    // }
    ans += factor[xx];
  }
  cout << ans << endl;
}

int main() {

  boost;
  icchhipadey();
}


Error: TLE

Fixed submission:

/*author @dhanush*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL)
#define pb push_back
#define se second
#define fi first
ll MOD = 1e9 + 7;
vector<ll> adj[100005];
ll col[100005];
ll vis[100005];
ll temp;
void dfs(ll n) {
  vis[n] = 1;
  temp = min(col[n], temp);
  for (auto x : adj[n]) {
    if (!vis[x]) {
      dfs(x);
    }
  }
}
void icchhipadey() {

  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n - 1; i++) {
    ll xx = n - i;
    ll cnt = 0;
    if (xx == 1) {
      cnt = 1;
    } else {
      cnt = 2;
    }
    for (ll j = 2; j * j <= xx; j++) {
      if (xx % j == 0) {
        cnt++;
        if (xx / j != j) {
          cnt++;
        }
      }
    }
    ans += cnt;
  }
  cout << ans << endl;
}

int main() {

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

#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  int t, n, i, j, k, l;
  cin >> n;
  int dp[n + 1];
  for (i = 1; i <= n; i++)
    dp[i] = 1;
  for (i = 2; i <= n; i++) {
    for (j = i; j <= n; j += i)
      dp[j]++;
  }
  l = 0;
  for (i = 1; i < n; i++) {
    l += dp[i];
  }
  cout << l;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  int t, n, i, j, k, l;
  cin >> n;
  l = 0;
  for (i = 1; i < n; i++) {
    for (j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        if (j * j == i)
          l++;
        else
          l += 2;
      }
    }
  }
  cout << l;
}