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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k = 1, m = 0;
  scanf("%d", &n);
  while (k * k < n) {
    m = (n / k - k) * 2 + m + 1;
    if (n % k == 0)
      m -= 2;
    k++;
  }

  printf("%d", m);
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int wy(long long int n) {
  int m, y, t = 0;
  for (int i = 1; i <= n + 1; i++) {
    if (i * i > n) {
      return t;
    } else if (n % i == 0)
      if (i * i == n) {
        t++;
      } else
        t = t + 2;
  }
}
int main() {
  int k, mas = 0;
  scanf("%d", &k);
  for (int p = 1; p < k; p++)
    mas = wy(p) + mas;
  printf("%d", mas);
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int n, ans;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (i * j >= n)
        break;
      else
        ans++;
    }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int n, ans = 1;
bool p[maxn];
vector<int> v;
vector<int>::iterator it;
void check(int k) {
  int result = 1;
  if (p[k]) {
    ans += 2;
    return;
  }
  for (it = v.begin(); it != v.end(); it++) {
    if ((*it) > k)
      break;
    if (k % (*it) == 0) {
      int temp = 0;
      while (k % (*it) == 0 && k > 0) {
        k /= (*it);
        temp++;
      }
      result *= (temp + 1);
    }
  }
  ans += result;
  return;
}
int main() {
  cin >> n;
  memset(p, true, sizeof(p));
  for (int i = 2; i <= sqrt(n); i++)
    if (p[i] == 1)
      for (int j = i + i; j <= n; j += i)
        p[j] = 0;
  for (int i = 2; i <= n; i++)
    if (p[i])
      v.push_back(i);
  for (int i = 2; i < n; i++)
    check(i);
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

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


Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
#include <vector>

using namespace std;

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

#include <iostream>
using namespace std;

int main() {
  int n, 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 <iostream>
#include <map>
using namespace std;

// 素因数分解
template <typename T> map<T, T> prime_factor(T n) {
  map<T, T> ret;
  for (T i = 2; i * i <= n; i++) {
    T tmp = 0;
    while (n % i == 0) {
      tmp++;
      n /= i;
    }
    ret[i] = tmp;
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}
/*  divisor_num(n)
    入力：整数 n
    出力：nの約数の個数
    計算量：O(√n)
*/
template <typename T> T divisor_num(T N) {
  map<T, T> pf = prime_factor(N);
  T ret = 1;
  for (auto p : pf) {
    ret *= (p.second + 1);
  }
  return ret;
}
/*

int yakusu(int N){
    int res = 0;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res++;
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res++;
        }
    }
    // 小さい順に並び替える
    return res;
}

int  memo[1000000 + 10] = {0};

int yakusu2(int N){
    if(memo[N] == 0){

    }
    else{
        return memo[N];
    }
}
*/

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i < n; i++) {
    // int y = yakusu(n - i);
    long long y = divisor_num(n - i);
    // printf("%d + %d(%lld通り)\\n", i, n - i, y);
    ans += y;
  }

  cout << ans << endl;

  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int n, ans;
int pls(int x) {
  int res = 0;
  for (int i = 1; i < sqrt(x); i++)
    if (!(x % i))
      res += 2;
  if (int(sqrt(x)) * int(sqrt(x)) == x)
    res++;
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++)
    ans += pls(i);
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, ans,
    p[1000] = {
        2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,  41,
        43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,  97,  101,
        103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
        173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239,
        241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313,
        317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397,
        401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467,
        479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569,
        571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643,
        647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
        739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823,
        827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911,
        919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009};
int pls(int x) {
  int res = 1, cnt = 0, ff = x;
  //    cout<<x<<endl;
  for (int i = 0; p[i] <= x; i++) {
    if (!(x % p[i]))
      cnt++;
    while (!(x % p[i])) {
      cnt++;
      x /= p[i];
    }
    if (cnt) {
      //            cout<<p[i]<<" "<<cnt<<endl;
      res *= cnt;
      cnt = 0;
    }
  }
  //    if(int(sqrt(x))*int(sqrt(x))==x)res++;
  return res;
}
int main() {
  cin >> n;
  ans = 1;
  for (int i = 2; i < n; i++)
    ans += pls(i);
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  ll res = 0;
  for (int c = 1; c < n; ++c) {
    res = res + (n - 1) / c;
  }
  cout << res << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;

ll coc(ll n) {
  ll res = 0;
  for (ll i = 1; i <= (sqrt(n)); ++i) {
    if (n % i == 0) {
      if ((i * i) == n)
        res++;
      else
        res += 2;
    }
  }
  return res;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  ll res = 0;
  for (int c = 1; c < n; ++c) {
    ll z = coc(n - c);
    res = res + z;
  }
  cout << res << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi cnt(n);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < n; j += i) {
      cnt[j]++;
    }
  }
  ll ans = 0;
  for (int i = 1; i < n; i++)
    ans += cnt[i];
  cout << ans;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

inline vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i)
        res.push_back(n / i);
    }
  }
  sort(all(res));
  return res;
}

int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    auto res = divisor(n - i);
    ans += res.size();
  }
  cout << ans;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int64_t n, ans = 0;
  cin >> n;
  for (auto a = 1; a < n; a++) {
    ans += n / a;
    if (n % a == 0)
      ans--;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

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

set<int> divisor(int n) {
  set<int> ret;
  for (auto i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.insert(i);
      if (n % (n / i) == 0)
        ret.insert(n / i);
    }
  }
  return ret;
}

int main() {
  int64_t n, ans = 0;
  cin >> n;
  for (auto i = 1; i <= n; i++) {
    int64_t tmp = n - i;
    if (tmp == 1)
      ans++;
    else {
      auto p = divisor(tmp);
      ans += p.size();
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

// A x B + C

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i, x, y) for (ll i = x; i < y; i++)
#define nvarep(n, a)                                                           \\
  ll n;                                                                        \\
  cin >> n;                                                                    \\
  vector<ll> a(n);                                                             \\
  rep(i, 0, n) cin >> a[i]
#define vecrep(n, a, type)                                                     \\
  vector<type> a(n);                                                           \\
  rep(i, 0, n) cin >> a[i]
#define lcm(a, b) (a / __gcd(a, b) * b)
#define range(a) (a).begin(), (a).end()
#define nnn "\\n"
#define spa " "
using P = pair<ll, ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;         // 2*10^9
const ll INF = 9223372036854775807; // 9*10^18

int d(int t) {
  map<int, int> m;
  for (int i = 2; i * i <= t; i++) {
    while (t % i == 0) {
      m[i]++;
      t /= i;
    }
  }
  if (t != 1)
    m[t]++;
  int res = 1;
  for (auto i : m)
    res *= (i.second + 1);
  return res;
}

signed main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i, 1, n) { ans += d(i); }
  cout << ans << nnn;
  return 0;
}

Error: TLE

Fixed submission:

// A x B + C

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i, x, y) for (ll i = x; i < y; i++)
#define nvarep(n, a)                                                           \\
  ll n;                                                                        \\
  cin >> n;                                                                    \\
  vector<ll> a(n);                                                             \\
  rep(i, 0, n) cin >> a[i]
#define vecrep(n, a, type)                                                     \\
  vector<type> a(n);                                                           \\
  rep(i, 0, n) cin >> a[i]
#define lcm(a, b) (a / __gcd(a, b) * b)
#define range(a) (a).begin(), (a).end()
#define nnn "\\n"
#define spa " "
using P = pair<ll, ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;         // 2*10^9
const ll INF = 9223372036854775807; // 9*10^18

int d(int t) {
  int res = 0;
  for (int i = 1; i * i <= t; i++) {
    if (t % i == 0) {
      res++;
      if (t / i != i)
        res++;
    }
  }
  return res;
}

signed main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i, 1, n) { ans += d(i); }
  cout << ans << nnn;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int arr[1000004];
void sieve() {

  for (int i = 1; i <= 1000000; i++)
    arr[i] = i;
  for (int i = 2; i <= 1000000; i += 2)
    arr[i] = 2;
  arr[1] = 1;
  for (int i = 3; i * i <= 1000000; i += 2) {
    if (arr[i] == i) {
      arr[i] = i;
      for (int j = i * i; j <= 1000000; j += i) {
        arr[j] = i;
      }
    }
  }
}

int get_divisor(int x) {
  map<int, int> mp;
  int mul = 1;
  while (x != 1) {
    int l = arr[x];
    while (x % l == 0) {

      x /= l;
      mp[l]++;
      if (x == 1)
        break;
    }
  }
  for (auto it = mp.begin(); it != mp.end(); it++) {

    if (it->first != 1)
      mul = mul * (it->second + 1);
  }
  return mul;
}

int main() {
  int a, b, c, d, e;
  cin >> a;
  sieve();
  long long sum = 0;
  for (int i = 2; i < a; i++) {

    sum += (get_divisor(i));
  }
  sum++;
  cout << sum << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {

  int a, b, c, d, e;
  cin >> a;
  long long m = 0;
  for (int i = 2; i < a; i++) {
    for (int j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        if (j == i / j)
          m++;
        else
          m += 2;
      }
    }
  }
  m++;
  cout << m << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

  return 0;
}


Error: TLE

Fixed submission:

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

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

#include <bits/stdc++.h>
using namespace std;
#define endl "\\n"
#define pb push_back
typedef long long ll;
int n, m;
ll ans = 0;
int factor[1000001];
// factor[i] stores the lowest prime that divides all numbers up to and
// including i
void init(int n) {
  factor[1] = 1;
  for (int i = 2; i <= n; ++i) {
    factor[i] = i;
  }
  for (int i = 4; i <= n; i += 2) {
    factor[i] = 2;
  }
  for (int i = 3; i * i <= n; ++i) {
    if (factor[i] == i) {
      for (int j = i * i; j <= n; j += i) {
        // if it has no prime factor before, then
        // stores the smallest prime divisor
        if (factor[j] == j)
          factor[j] = i;
      }
    }
  }
}
int fact(int n) {
  if (n == 1)
    return 1;
  int ans = 1, dup = factor[n], c = 1, j = n / factor[n];
  while (j != 1) {
    if (factor[j] == dup)
      c += 1;
    else {
      dup = factor[j];
      ans = ans * (c + 1);
      c = 1;
    }
    j = j / factor[j];
  }
  ans = ans * (c + 1);
  return ans;
}

int main() {
  cin >> n;
  init(n);
  for (int i = 1; i < n; ++i) {
    ans += fact(i);
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define endl "\\n"
#define pb push_back
typedef long long ll;
int n, m;
pair<int, int> dice;
int main() {
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int nf = 0;
    if (n - i <= 0)
      break;
    else if (n - i == 1) {
      ans++;
      continue;
    }
    int num = n - i;
    for (int j = 1; j <= sqrt(num); ++j) {
      if (num % j == 0) {
        if (num / j == j)
          nf += 1;
        else
          nf += 2;
      }
    }
    ans += nf;
  }
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int cnt = 0;
  for (long long int i = 1; i < n; i++) {
    for (long long int j = 1; i * j < n; j++) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int cnt = 0;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= n; j++) {
      for (long long int k = 1; k <= n; k++) {
        if ((i * j) + k == n) {
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl ("\\n")
#define pi (3.141592653589)
#define mod 1000000007
#define INF 1000000009
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define so sizeof
#define pii pair<ll, ll>
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define max3(a, b, c) max(c, max(a, b))
#define max4(a, b, c, d) max(d, max(c, max(a, b)))
#define repe(i, a) for (auto i : a)
#define st string
#define rep(i, a, b) for (ll i = a; i <= b; i++)
#define rrep(i, a, b) for (ll i = b; i >= a; i--)
#define fast                                                                   \\
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
void solve() {
  ll n;
  cin >> n;
  ll cnt = 0;
  rep(i, 1, n - 1) { cnt += (n - 1) / i; }
  //}
  cout << cnt << endl;
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  fast
  // ll t;
  // cin>>t;
  // while(t--)
  solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl ("\\n")
#define pi (3.141592653589)
#define mod 1000000007
#define INF 1000000009
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define so sizeof
#define pii pair<ll, ll>
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define max3(a, b, c) max(c, max(a, b))
#define max4(a, b, c, d) max(d, max(c, max(a, b)))
#define repe(i, a) for (auto i : a)
#define st string
#define rep(i, a, b) for (ll i = a; i <= b; i++)
#define rrep(i, a, b) for (ll i = b; i >= a; i--)
#define fast                                                                   \\
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
void solve() {
  ll n;
  cin >> n;
  ll cnt = 0;
  rep(i, 1, n - 1) {
    for (ll j = 1; j * j <= n - i; j++) {
      if ((j * ((n - i) / j)) == (n - i)) {
        //  cout<<j<<" "<<(n-i)/j<<" "<<i<<endl;
        if (j != (n - i) / j)
          cnt += 2;
        else
          cnt++;
      }
    }
  }
  cout << cnt << endl;
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  fast
  // ll t;
  // cin>>t;
  // while(t--)
  solve();
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

// AC - C - A x B + C

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, r, i, j, d, s = 0;
  cin >> n;
  r = sqrt(n);

  for (i = 1; i <= n; i++)
    for (j = 1; j <= (n / i); j++) {
      d = n - (i * j);
      if (d > 0)
        s = s + 1;
    }
  cout << s << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

// AC - C - A x B + C

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, r, i, j, d, s = 0;
  cin >> n;
  r = sqrt(n);

  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      d = n - (i * j);
      if (d > 0)
        s = s + 1;
    }
  cout << s << "\\n";
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef long long LL;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
  if (a > b)
    a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
  if (a < b)
    a = b;
}

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

  int ans = 0;
  for (int a = 1; a <= N - 1; a++) {
    int count = (N - 1) / a;
    ans += count;
  }

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
typedef long long LL;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
  if (a > b)
    a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
  if (a < b)
    a = b;
}

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

  LL ans = 0;
  for (int C = 1; C < N; C++) {
    int val = N - C;

    int valsqrt = (int)round(sqrt(val));

    int a = 1;
    while (a <= valsqrt) {
      if (val % a != 0) {
        a++;
        continue;
      }

      int b = val / a;
      if (a == b) {
        ans++;
      } else {
        ans += 2;
      }
      a++;
    }
  }

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