alexjercan/bugnet huggingface dataset:
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 all(v) v.begin(), v.end()
typedef long long ll;

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

  int ans = 0;

  for (int c = 1; c <= n - 1; c++) {
    int tmp = n - c;

    int tmpi = 1; // tmpの約数の個数
    for (int i = 2; i * i <= tmp; i++) {
      int ex = 0; // 次数
      while (tmp % i == 0) {
        ex++;
        tmp /= i;
      }
      tmpi *= ex + 1;

      if (tmp == 1)
        break;
    }
    if (tmp != 1)
      tmpi *= 2;

    ans += tmpi;
  }

  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

  int ans = 0;

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

  cout << ans << endl;
}
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 < (int)(n); i++)

int main() {
  int N, Ans = 0;
  cin >> N;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j * j <= N - i; j++) {
      if ((N - i) % j == 0) {
        if (j == sqrt(N - i)) {
          Ans++;
        } else {
          Ans++;
          Ans++;
        }
      }
    }
  }
  cout << Ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N, A, B, Ans = 0;
  cin >> N;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= sqrt(N - i); j++) {
      if ((N - i) % j == 0) {
        if (j == sqrt(N - i)) {
          Ans++;
        } else {
          Ans++;
          Ans++;
        }
      }
    }
  }
  cout << Ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int ans = 0;

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


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int ans = 0;
  for (int a = 1; a < n; a++) {
    for (int c = 1; c < n; c++) {
      if ((n - c) % a == 0)
        ans++;
    }
  }
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
using namespace std;
#define N_MAX 1000000

int N;

int input() {
  cin >> N;
  return 0;
}

// int solve(){
//     long long count_total = 0;
//     // long long memo[N_MAX];
//     // memo[1]=1;
//     for (int c=1;c<N;c++){
//         // N-cの約数の数を求める
//         int count=0;
//         for (int a=1;a<=N-c/2+1;a++){
//             if ((N-c)%a==0){
//                 count++;
//             }
//         }
//         count

//     }
//     cout << count_total << endl;
//     return 0;
// }

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

int main() {
  input();
  solve();
  return 0;
}

Error: TLE

Fixed submission:

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

int N;

int input() {
  cin >> N;
  return 0;
}

int solve() {
  long long count = 0;
  for (int c = 1; c < N; c++) {
    // N-cの約数の数を求める。
    for (int a = 1; a <= N - c; a++) {
      if ((N - c) % a == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}

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

#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;
const double PI = 3.14159265358979323846;

ll wari(ll a) {

  ll i = 1;

  int count = 0;

  while (i * i <= a) {

    if (a % i == 0) {

      count++;

      if (i * i != a) {

        count++;
      }
    }

    i++;
  }

  return count;
}

int main() {
  int N;

  cin >> N;

  ll ans = 0;

  int i = 1;

  while (i < N) {

    int sub = N / i;

    int count = min(sub, i);

    int k_max = count;

    if (N == k_max * i) {

      k_max--;
    }

    count = k_max * 2;

    if (k_max == i) {

      count--;
    }

    ans += count;
    i++;
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
typedef long long int ll;

using namespace std;
const double PI = 3.14159265358979323846;

ll wari(ll a) {

  ll i = 1;

  int count = 0;

  while (i * i <= a) {

    if (a % i == 0) {

      count++;

      if (i * i != a) {

        count++;
      }
    }

    i++;
  }

  return count;
}

int main() {
  int N;

  cin >> N;

  ll ans = 0;

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

    ans += wari(N - i);
  }

  cout << ans << endl;

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

#include <bits/stdc++.h>
#define ll long long int
#define db long double
#define ull unsigned long long int
// #define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for (ll i = a; i <= b; i++)
#define all(a) a.begin(), a.end()
#define Nmax 1000005
// #define INF 10000000000000
#define MOD 1000000007
#define MAXN 200005

using namespace std;

ll mod = 998244353;

ll expo(ll base, ll exponent, ll mod) {
  ll ans = 1;
  while (exponent != 0) {
    if (exponent & 1)
      ans = (1LL * ans * base) % mod;
    base = (1LL * base * base) % mod;
    exponent >>= 1;
  }
  return ans % mod;
}

const ll M = 3000006;
ll f[M], inv[M];

void compute() {
  f[0] = 1;
  rep(i, 1, M - 1) { f[i] = (1LL * i * f[i - 1]) % mod; }
  inv[M - 1] = expo(f[M - 1], mod - 2, mod);
  for (ll i = M - 2; i >= 0; i--) {
    inv[i] = (1LL * (i + 1) * inv[i + 1]) % mod;
  }
}
ll C(ll n, ll r) {
  return (1LL * ((1LL * f[n] * inv[r]) % mod) * inv[n - r]) % mod;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // compute();
  int tests = 1;
  // cin>>tests;
  while (tests--) {
    ll i, j, k, n;
    cin >> n;
    ll ans = 0;
    rep(i, 1, sqrt(n)) {
      j = i;
      ll cur = 0;
      while (i * j < n) {
        j++;
        cur += 2;
      }
      cur--;
      ans += max(0LL, cur);
    }

    cout << ans;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long int
#define db long double
#define ull unsigned long long int
// #define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for (ll i = a; i <= b; i++)
#define all(a) a.begin(), a.end()
#define Nmax 1000005
// #define INF 10000000000000
#define MOD 1000000007
#define MAXN 200005

using namespace std;

ll mod = 998244353;

ll expo(ll base, ll exponent, ll mod) {
  ll ans = 1;
  while (exponent != 0) {
    if (exponent & 1)
      ans = (1LL * ans * base) % mod;
    base = (1LL * base * base) % mod;
    exponent >>= 1;
  }
  return ans % mod;
}

const ll M = 3000006;
ll f[M], inv[M];

void compute() {
  f[0] = 1;
  rep(i, 1, M - 1) { f[i] = (1LL * i * f[i - 1]) % mod; }
  inv[M - 1] = expo(f[M - 1], mod - 2, mod);
  for (ll i = M - 2; i >= 0; i--) {
    inv[i] = (1LL * (i + 1) * inv[i + 1]) % mod;
  }
}
ll C(ll n, ll r) {
  return (1LL * ((1LL * f[n] * inv[r]) % mod) * inv[n - r]) % mod;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // compute();
  int tests = 1;
  // cin>>tests;
  while (tests--) {
    ll i, j, k, n;
    cin >> n;
    ll ans = 0;
    rep(i, 1, n - 1) {
      ll val = n - i;
      rep(j, 1, sqrt(val)) {
        if (val % j == 0) {
          if (j != val / j)
            ans += 2;
          else
            ans++;
        }
      }
    }

    cout << ans;
  }

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

using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for (int i = r; i >= l; --i)
#define fr(i, l, r) for (int i = l; i < r; ++i)
#define forit(it, type, var)                                                   \\
  for (type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair;
priority_queue<ll, vector<ll>, greater<ll>> pq1, pq2;
#define maxN 1000000000000000000
ll power(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    res *= a;
    b--;
  }
  return res;
}
ll n, j, done[1000005] = {0}, st[1000005];
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  fr(i, 2, 1000000) {
    if (done[i] == 0) {
      for (j = i; j <= 1000000; j = j + i) {
        st[j] = i;
        done[j]++;
      }
    }
  }
  ll ans = 0;
  if (n == 1) {
    cout << "1" << endl;
    return 0;
  }
  st[1] = 1;
  fr(i, 1, n) {
    ll st1 = n - i, temp = 1;
    while (st1 > 1) {
      ll fl = st[st1], cnt = 0;
      while (st1 % fl == 0) {
        cnt++;
        st1 /= fl;
      }
      temp = temp * (cnt + 1);
    }
    ans += temp;
    //  cout<<ans<<endl;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for (int i = r; i >= l; --i)
#define fr(i, l, r) for (int i = l; i < r; ++i)
#define forit(it, type, var)                                                   \\
  for (type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair;
priority_queue<ll, vector<ll>, greater<ll>> pq1, pq2;
#define maxN 1000000000000000000
ll power(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    res *= a;
    b--;
  }
  return res;
}
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  ll ans = 0;
  fr(i, 1, n) {
    ll st = n - i;
    ll st1 = sqrt(st);
    fr(j, 1, st1 + 1) {
      if (st % j == 0) {
        if (j != st / j)
          ans += 2;
        else
          ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <cassert>
#include <numeric>
// #include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod = 1e9 + 7;
const int INF = 1001001001;
// const int inf=100000;
// const ll ful=1e18;
using namespace std;
// namespace mp = boost::multiprecision;
int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j * j <= n - i; ++j) {
      int num = n - i;
      if (num % j == 0) {
        ans++;
        if (num / j != j) {
          ans++;
        }
      }
    }
  }
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <cassert>
#include <numeric>
// #include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod = 1e9 + 7;
const int INF = 1001001001;
// const int inf=100000;
// const ll ful=1e18;
using namespace std;
// namespace mp = boost::multiprecision;
int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j * j <= n - i; ++j) {
      int num = n - i;
      if (num % j == 0) {
        ans++;
        if (num / j != j) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

// ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include <bits/stdc++.h>
#define startt                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
#define MOD 1000000007
#define MX 1000000000
#define NMAX 100005
#define MXL 1000000000000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\\n'
#define fr first
// read contraints to make sure its not brute force

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ll a = n / i;
    if (i * a >= n) {
      a--;
    }
    ans += max(0LL, a);
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

// ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
#include <bits/stdc++.h>
#define startt                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
#define MOD 1000000007
#define MX 1000000000
#define NMAX 100005
#define MXL 1000000000000000000
#define PI 3.14159265
#define pb push_back
using namespace std;
#define sc second
#define endl '\\n'
#define fr first
// read contraints to make sure its not brute force

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;

int main() {
  unordered_multimap<int, int> mp;
  unordered_map<int, int>::iterator it;
  int N, A, B, C, ans = 0;
  cin >> N;
  for (A = 1; A <= N; A += 1) {
    if (A >= N) {
      break;
    }
    for (B = 1; B <= N; B += 1) {
      if (A * B >= N) {
        break;
      }
      if (A * B < N) {
        mp.insert(pair<int, int>(A, B));
      }
    }
  }
  cout << mp.size() << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <vector>
using namespace std;

int main() {
  long long int N, A, B, C, ans = 0;
  cin >> N;
  for (A = 1; A <= N; A += 1) {
    if (A > N) {
      break;
    }
    for (B = 1; B <= N; B += 1) {
      if (A * B > N) {
        break;
      }
      for (C = 1; C <= N; C += 1) {
        if (A * B + C > N) {
          break;
        }
        if (A * B + C == N) {
          ans += 1;
        }
      }
    }
  }
  cout << ans << 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;
  int count2 = 0;
  for (int c = 1; c <= N; c++) {
    for (int i = 1; i * i <= (N - c); i++) {
      if ((N - c) % i == 0) {
        count++;
      }
      if (i * i == (N - c)) {
        count2++;
      }
    }
  }
  int ans = 2 * count - count2;
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

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

#include <bits/stdc++.h>

using namespace std;

typedef long long int lli;
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
typedef pair<lli, lli> pii;
#define all(vec) vec.begin(), vec.end()
#define ff first
#define ss second
#define pi 3.141592653589
#define inf 4e18
#define MOD 1000000007
#define pb push_back
#define endl "\\n"
#define for1(low, high, k) for (int i = low; i < high; i += k)
#define for2(low, high, k) for (int j = low; j < high; j += k)
#define rev(high, low, k) for (int i = high; i >= low; i -= k)

int main() {
  fast;
  lli n;
  cin >> n;
  lli sum = 0;
  for (int i = 1; i < n; i++) {
    int k = (n - 1) / i;
    if (k > i)
      sum += (k - i) * 2;
    if (k >= i)
      sum++;
  }
  cout << sum << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long int lli;
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
typedef pair<lli, lli> pii;
#define all(vec) vec.begin(), vec.end()
#define ff first
#define ss second
#define pi 3.141592653589
#define inf 4e18
#define MOD 1000000007
#define pb push_back
#define endl "\\n"
#define for1(low, high, k) for (int i = low; i < high; i += k)
#define for2(low, high, k) for (int j = low; j < high; j += k)
#define rev(high, low, k) for (int i = high; i >= low; i -= k)

int main() {
  fast;
  lli n;
  cin >> n;
  lli sum = 0;
  vector<lli> div(n, 0);
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        if (j != sqrt(i))
          div[i] += 2;
        else
          div[i]++;
      }
    }
    sum += div[i];
  }
  cout << sum << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll n;
  cin >> n;

  ll res = 1;
  rep1(b, n - 1) {
    for (int nc = b; nc <= n - 1; nc += b) {
      ++res;
    }
  }

  cout << res << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;

pair<map<ll, ll>, set<ll>> prime_factor(ll n) {
  map<ll, ll> res;
  set<ll> primes;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0)
      primes.insert(i);

    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) {
    res[n] = 1;
    primes.insert(n);
  }
  return make_pair(res, primes);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll n;
  cin >> n;

  map<ll, ll> mp;
  ll res = 0;
  for (ll i = 1; i < n; ++i) {
    if (i == 1)
      res += 1;
    else {
      mp = prime_factor(i).first;
      ll sm = 1;
      for (auto k : mp) {
        sm *= (k.second + 1);
      }
      res += sm;
    }
  }

  cout << res << endl;

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

#include <bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld, lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout << endl << "answer : " << x << endl << endl;
#define op(x) cout << x << endl;
#define maxn 500005
#define lld_max 5000000000000000000
#define messi                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
using namespace std;
int main() {
  messi lld t = 1; // cin>>t;
  while (t--) {
    lld n = 0, m = 0, k = 0, i = 0, j = 0, p = 0, q = 0, x = 0, y = 0, z = 0,
        ans = 0, cnt = 0, l = 0, r = 0, mid = 0, lo = 0, hi = 0;
    string s;
    bool flag = false;
    cin >> n;
    for (i = 1; i < n; i++)
      cnt += (n - 1) / i;
    op(cnt);
  }
  return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\\   /\\  |__)  /\\  |  \\ |__| \\ /  /\\  |
| /~~\\ /~~\\ |  \\ /~~\\ |__/ |  |  |  /~~\\ |
|________________________________________|

*/


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld, lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout << endl << "answer : " << x << endl << endl;
#define op(x) cout << x << endl;
#define maxn 500005
#define lld_max 5000000000000000000
#define messi                                                                  \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
using namespace std;
int main() {
  messi lld t = 1; // cin>>t;
  while (t--) {
    lld n = 0, m = 0, k = 0, i = 0, j = 0, p = 0, q = 0, x = 0, y = 0, z = 0,
        ans = 0, cnt = 0, l = 0, r = 0, mid = 0, lo = 0, hi = 0;
    string s;
    bool flag = false;
    cin >> n;
    for (i = 1; i < n; i++) {
      for (j = 1; j * j <= i; j++) {
        if (i % j == 0) {
          if (j == (i / j))
            cnt++;
          else
            cnt += 2;
        }
      }
    }
    op(cnt);
  }
  return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\\   /\\  |__)  /\\  |  \\ |__| \\ /  /\\  |
| /~~\\ /~~\\ |  \\ /~~\\ |__/ |  |  |  /~~\\ |
|________________________________________|

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

#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int func(int num) {

  int sum = 0;
  int i = 1;

  while (num >= i * i) {
    if (num % i == 0) {
      if (num / i == i) {
        sum += 1;
      } else {
        sum += 2;
      }
    }
    i++;
  }

  return sum;
}

int main() {

  int N = 0;

  cin >> N;

  int count = 0;

  for (int i = 1; i < N; i++) {
    count += func(N - i);
  }

  cout << count << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
using namespace std;

int func(int num) {

  int sum = 0;

  for (int i = 1; i <= num; i++) {
    if (num % i == 0) {
      // if((num/i) == i){
      //     sum += 1;
      // }
      // else{
      //     sum += 2;
      // }
      sum += 1;
    }
  }
  return sum;
}

int main() {

  int N = 0;

  cin >> N;

  int count = 0;

  for (int i = 1; i < N; i++) {
    count += func(N - i);
  }

  cout << count << endl;

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

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>

using namespace std;
typedef long long ll;
const ll INF = 1000000007;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (n); ++i)

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <stack>
#include <string>
#include <unordered_map>

using namespace std;
typedef long long ll;
const ll INF = 1000000007;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int a = 1; a <= N - i; a++) {
      if ((N - i) % a == 0)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}