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

#include <bits/stdc++.h>
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define ll long long
#define all(x) (x).begin(), (x).end()
#define print(x)                                                               \\
  if (x)                                                                       \\
    cout << "YES\\n";                                                           \\
  else                                                                         \\
    cout << "NO\\n";
#define f(i, x, y) for (ll i = x; i <= y; i++)
#define rf(i, x, y) for (ll i = x; i >= y; i--)
#define pb push_back
#define F first
#define S second
using namespace std;
ll res[1000000 + 1];
ll dp[1000000 + 1];
void scieve(ll n = 1000000) {
  for (ll i = 2; i <= n; i++) {
    if (dp[i] == 0) {
      for (ll j = i * 2; j <= n; j += i) {
        if (i != j / i)
          dp[j] += (1 + dp[j / i]);
        else
          dp[j]++;
      }
    }
  }
}
int main() {
  // #ifndef HP
  //   freopen("in.txt", "r", stdin);
  //   freopen("out.txt", "w", stdout);
  // #endif

  fastio;
  int t = 1;
  scieve();
  // cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    res[0] = 0;
    res[1] = 0;
    res[2] = 1;
    for (ll i = 3; i <= n; i++) {
      res[i] = res[i - 1] + dp[i - 1] + 2;
    }
    cout << res[n];
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define ll long long
#define all(x) (x).begin(), (x).end()
#define print(x)                                                               \\
  if (x)                                                                       \\
    cout << "YES\\n";                                                           \\
  else                                                                         \\
    cout << "NO\\n";
#define f(i, x, y) for (ll i = x; i <= y; i++)
#define rf(i, x, y) for (ll i = x; i >= y; i--)
#define pb push_back
#define F first
#define S second
using namespace std;
ll res[1000000 + 1];
ll scieve(ll n) {
  ll x = 2;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      if (n / i != i)
        x += 2;
      else
        x += 1;
    }
  }
  return x;
}
int main() {
  // #ifndef HP
  //   freopen("in.txt", "r", stdin);
  //   freopen("out.txt", "w", stdout);
  // #endif

  fastio;
  int t = 1;
  // cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    res[0] = 0;
    res[1] = 0;
    res[2] = 1;
    for (ll i = 3; i <= n; i++) {
      res[i] = res[i - 1] + scieve((ll)(i - 1));
    }
    cout << res[n];
  }
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
int dy[] = {0, 1, -1, 0, 1, -1, 1, -1, 0};
/*
int main()
{
        int r, c;
        cin >> r >> c;
        int sy, sx, gy, gx;
        vector<vector<char>>field(r,vector<char>(c));
        sy--, sx--, gy--, gx--;
        for (int i = 0; i < r; i++)
        {
                for (int j = 0; j < c; j++)
                {
                        cin >> field[i][j];
                }
        }
        queue<pair<int,int>>q;
        q.push({ sx,sy });
        vector<vector<int>>d(c, vector<int> (r, -1));
        d[sx][sy] = 0;

        while (!q.empty())
        {
                pair<int, int>p = q.front;
                q.pop();
                for (int i = 0; i < 4; i++)
                {
                        int nx = p.first + dx[i], ny = p.second + dy[i];
                        if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny]
!= -1 || field[nx][ny] == '#')continue; q.push({ nx,ny }); d[nx][ny] =
d[p.first][p.second] + 1;
                }
        }

        cout << d[gx][gy] << endl;
}*/

int main() {
  int n;
  cin >> n;
  int ans = 0;
  int x;
  for (int i = 1; i < n; i++) {

    for (int j = 1; j < n; j++) {
      if (i * j > n) {
        break;
      }

      if (n - (i * j) > 0) {
        ans += 1;
      }
    }
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;
int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
int dy[] = {0, 1, -1, 0, 1, -1, 1, -1, 0};
/*
int main()
{
        int r, c;
        cin >> r >> c;
        int sy, sx, gy, gx;
        vector<vector<char>>field(r,vector<char>(c));
        sy--, sx--, gy--, gx--;
        for (int i = 0; i < r; i++)
        {
                for (int j = 0; j < c; j++)
                {
                        cin >> field[i][j];
                }
        }
        queue<pair<int,int>>q;
        q.push({ sx,sy });
        vector<vector<int>>d(c, vector<int> (r, -1));
        d[sx][sy] = 0;

        while (!q.empty())
        {
                pair<int, int>p = q.front;
                q.pop();
                for (int i = 0; i < 4; i++)
                {
                        int nx = p.first + dx[i], ny = p.second + dy[i];
                        if (nx < 0 || ny < 0 || nx >= c || ny >= r || d[nx][ny]
!= -1 || field[nx][ny] == '#')continue; q.push({ nx,ny }); d[nx][ny] =
d[p.first][p.second] + 1;
                }
        }

        cout << d[gx][gy] << endl;
}*/

int main() {
  int n;
  cin >> n;
  int ans = 0;
  int x;
  for (int i = 1; i < n; i++) {

    for (int j = 1; j < n; j++) {
      if (i * j > n) {
        continue;
      }

      if (n - (i * j) > 0) {
        ans += 1;
      }
    }
  }
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define ll long long int
#define pb push_back
#define f(i, x, y) for (i = x; i < y; i++)
#define vll vector<ll>
#define fast                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

void solve() {
  ll n;
  cin >> n;

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

int main() {
  fast;
  ll t = 1;
  // cin>>t;
  while (t--)
    solve();
  return 0;
}


Error: TLE

Fixed submission:

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

#define ll long long int
#define pb push_back
#define f(i, x, y) for (i = x; i < y; i++)
#define vll vector<ll>
#define fast                                                                   \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

ll fac(ll n) {
  ll i, ans = 0;
  for (i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      ll f1 = i;
      ll f2 = n / i;
      if (f1 == f2)
        ans++;
      else
        ans += 2;
    }
  }
  return ans;
}

void solve() {
  ll n;
  cin >> n;

  ll i = 1;
  ll ans = 0;
  for (i = 1; i < n; i++) {
    ans += fac(n - i);
  }
  cout << ans << endl;
}

int main() {
  fast;
  ll t = 1;
  // cin>>t;
  while (t--)
    solve();
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

const int MOD = 1000000007;

int main() {
  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 <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

const int MOD = 1000000007;

int prime(int n) {
  vector<int> x(n + 1);
  int num = n;
  int res = 1;

  for (int i = 2; i <= n; i++) {
    while (num % i == 0) {
      x.at(i)++;
      num /= i;
    }
  }
  sort(all(x), greater<int>());
  for (int i = 0; x.at(i) > 0; i++) {
    res *= x.at(i) + 1;
  }
  return res;
}

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

  int ans = 0;
  for (int i = 1; i < n; i++) {
    ans += prime(n - i);
  }

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>

using namespace std;
const long long P = 1000000007;

long long solve(long long n) {
  int res = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0)
      res += 2;
    if (n % i == 0 && i == sqrt(n))
      res--;
  }
  return res;
}

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

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>

using namespace std;
const long long P = 1000000007;

long long solve(long long n) {
  int res = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0)
      res += 2;
    if (n % i == 0 && i == sqrt(n))
      res--;
  }
  return res;
}

int main() {
  long long n;
  cin >> n;
  long long count = 0;
  for (int i = 1; i < n; i++) {
    count += solve(i);
  }
  cout << count << 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++)
using ll = long long;
int enumd(int N) {
  int res = 0;
  for (int i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res++;
      // 重複しないならば i の相方である N/i も push
      if (N / i != i)
        res++;
    }
  }
  return res;
}

int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i < n; i++) {
    long long N = n - i;
    const auto &res = enumd(N);
    ans += res;
  }
  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++)
using ll = long long;
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() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i < n; i++) {
    long long N = n - i;
    const auto &res = enum_divisors(N);
    ans += res.size();
  }
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

//                        Bismillahir Rahmanir Rahim
// ALGO:
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define INF INT_MAX
#define MX 1000010
#define mod 1000000007
#define dout                                                                   \\
  if (debug)                                                                   \\
  cout
#define FR(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n) for (int i = 1; i <= n; i++)
const double Pi = acos(-1);
using namespace std;
int debug = 01;
bitset<10000001> pr;
int pl[664580], s;
void sieve(int mx) {
  for (int p = 4; p <= mx; p += 2)
    pr[p] = 1;
  for (int p = 3; p * p <= mx; p += 2)
    if (!pr[p])
      if (p <= sqrt(mx))
        for (int i = p * p; i <= mx; i += p)
          pr[i] = 1;
  for (int i = 2; i <= mx; i++)
    if (!pr[i])
      pl[s++] = i;
}
void solve() {
  sieve(1000000);
  int n, c = 1;
  cin >> n;
  for (int i = 2; i < n; i++) {
    int x = i, y = 1;
    for (int j = 0; pl[j] * pl[j] <= x; j++) {
      int t = 1;
      while (!(x % pl[j])) {
        x /= pl[j];
        t++;
      }
      y *= t;
    }
    if (x != 1)
      y *= 2;
    c += y;
  }
  cout << c;
}
int main() {
  Fast int tst = 1;
  // cin>>tst;
  for (int T = 1; T <= tst; T++) {
    // cout<<"Case "<<T<<": ";
    solve();
  }
}


Error: TLE

Fixed submission:

//                        Bismillahir Rahmanir Rahim
// ALGO:
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);
#define INF INT_MAX
#define MX 1000010
#define mod 1000000007
#define dout                                                                   \\
  if (debug)                                                                   \\
  cout
#define FR(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n) for (int i = 1; i <= n; i++)
const double Pi = acos(-1);
using namespace std;
int debug = 01;
void solve() {
  int n, c = 1;
  cin >> n;
  for (int i = 2; i < n; i++) {
    for (int j = 1; j <= sqrt(i); j++)
      if (!(i % j)) {
        if (i / j == j)
          c++;
        else
          c += 2;
      }
  }
  cout << c;
}
int main() {
  Fast int tst = 1;
  // cin>>tst;
  for (int T = 1; T <= tst; T++) {
    // cout<<"Case "<<T<<": ";
    solve();
  }
}
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 sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

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

  ll ans = 0;
  for (ll a = 1; a < n; a++) {
    ans += (n - 1) / a;
  }

  cout << ans << endl;
}


Error: TLE

Fixed submission:

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

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

  ll ans = 0;

  for (ll c = 1; c < n; c++) {
    for (ll a = 1; a <= sqrt(n - c); a++) {
      if ((n - c) % a == 0)
        ans += 2;
      if (a * a == n - c)
        ans--;
    }
  }
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

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

int main() {
  int N, C;
  C = 0;
  cin >> N;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j < N; j++) {
      if (i * j < N) {
        C++;
      }
    }
  }
  cout << C << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Runtime Error

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

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

  ll ans = 0;
  // vector<int> X(N, 0);
  for (int i = 1; i < N; i++) {
    // X[i * i]++;
    if (i * i >= N)
      break;
    ans++;

    for (int j = i + 1; j < N; j++) {
      if (i * j >= N)
        break;
      // X[i * j] += 2;
      ans += 2;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

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

vector<int> primes(int N) {
  vector<bool> is_prime(N + 1);
  for (int i = 0; i <= N; i++) {
    is_prime[i] = true;
  }
  vector<int> P;
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
  return P;
}

ll solve(vector<int> P, int i, int n, int N) {
  if (i == P.size()) {
    return 1;
  }
  int num = N / P[i]; // 素数　P[i] が含まれる数の上限
  ll ans = 0;

  int p = 1;
  for (int j = 0; j <= num; j++) {
    if (N < p * n)
      break;
    ll tmp = (j + 1) * solve(P, i + 1, p * n, N);
    // printf("%ld\\n", tmp);
    ans += tmp;
    p *= P[i];
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<int> P = primes(N - 1);
  ll ans = solve(P, 0, 1, N - 1);

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

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <math.h>
using namespace std;
#define endl '\\n'
#define pi pair<int, int>

typedef __uint128_t u128;

const u128 mod = 1e9 + 7;

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

  long long n;
  cin >> n;

  long long res = 0;
  for (int i = 1; i < n; ++i) {
    res += ((n - 1) / i);
  }
  cout << res;

  return 0;
}

Error: TLE

Fixed submission:

// g++ -std=c++17 -Wshadow -Wall -fsanitize=address -fsanitize=undefined
// -D_GLIBCXX_DEBUG -g PROGRAM -o OUTPUT -DLOCAL -lasan -lubsan
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define eps 1e-6
#define pi 3.141592653589793
using namespace std;

typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef vector<pair<int, PII>> VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;

inline ll modulo(ll a, ll m) { return (a % m + m) % m; }

inline ll modInverse(ll a, ll m) {
  assert(__gcd(a, m) == 1);
  ll m0 = m;
  ll y = 0, x = 1;

  if (m == 1)
    return 0;

  while (a > 1) {
    ll q = a / m;
    ll t = m;

    m = a % m, a = t;
    t = y;

    y = x - q * y;
    x = t;
  }

  if (x < 0)
    x += m0;

  return x;
}

inline ll modPow(ll x, ll y, ll m) { // x^y % m
  if (y == 0)
    return 1LL;
  else if (y == 1)
    return x;
  else {
    ll ans = modPow(x, y / 2, m) % m;
    if (y & 1) {
      return (((ans * ans) % m) * x) % m;
    } else {
      return (ans * ans) % m;
    }
  }
}

vector<string> split(char d, string s) {
  stringstream ss(s);
  string t;
  vector<string> words;
  while (getline(ss, t, d)) {
    words.pb(t);
  }

  return words;
}

int main(int argc, char *argv[]) {

  ios::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j * j <= i; ++j) {
      if (i % j == 0) {
        ans++;
        if (j * j != i)
          ans++;
      }
    }
  }

  cout << ans;

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

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

int main() {
  int answer = 0;
  int N;
  cin >> N;
  int a = 1;
  int b = 1;
  int c = 1;
  while (a < N) {
    if (a * b < N) {
      answer++;
    }
    if (a * b < N) {
      b++;
    } else {
      b = 1;
      a++;
    }
  }
  cout << answer << endl;
}


Error: TLE

Fixed submission:

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

int main() {
  int answer = 0;
  int N;
  cin >> N;
  int a = 1;
  int b = 1;
  int c = 1;
  while (a < N) {
    while (a * b + c <= N) {
      if (a * b + c == N) {
        answer++;
        c = 1;
        break;
      } else {
        c++;
      }
    }
    if (a * b < N) {
      b++;
    } else {
      b = 1;
      a++;
    }
  }
  cout << answer << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  long long n;
  cin >> n;
  n--;
  long long ans = 0;
  for (int i = 1; i <= n; i++) /*求从1到n约数个数的和*/
  {
    ans += n / i;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  long long n;
  cin >> n;

  int x;
  long long k = 0;
  for (x = 1; x <= n - 1; x++) {
    long long res = 1;
    long long z = x;
    unordered_map<int, int> primes;
    for (int i = 2; i <= z / i; i++) {

      while (z % i == 0) {
        z /= i;
        primes[i]++;
      }
    }
    if (z > 1)
      primes[z]++;

    for (auto prime : primes)
      res = res * (prime.second + 1) % mod;
    k += res;
  }

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

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int a = 1; a <= n; a++) {
    cnt += n / a;
    if (n % a == 0)
      cnt--;
  }
  cout << cnt << endl;
}

Error: TLE

Fixed submission:

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

#include <bits/stdc++.h>
#include <cstdlib>
#include <queue>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define STEP(i, n, step) for (int i = 0; i < n; i += step)
#define RANGE(n) for (int _ = 0; _ < n; _++)
#define FOR(i, m, n) for (int i = m; i < n; i++)

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const long long INF = 1LL << 60;
const int INT_INF = 1 << 29;

const int MAX = 100010;

void solve() {
  int N;
  cin >> N;
  int counter = 0;
  // cout << pow(N,.5) << endl;
  REP(i, N) {
    for (int d = 1; d * d <= i; d++) {
      if (i % d == 0) {
        if (i / d == d)
          counter++;
        else
          counter += 2;
      }
    }
  }
  cout << counter << endl;
  return;
}

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


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <cstdlib>
#include <queue>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define STEP(i, n, step) for (int i = 0; i < n; i += step)
#define RANGE(n) for (int _ = 0; _ < n; _++)
#define FOR(i, m, n) for (int i = m; i < n; i++)

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const long long INF = 1LL << 60;
const int INT_INF = 1 << 29;

const int MAX = 100010;

void solve() {
  int N;
  cin >> N;
  int counter = 0;
  // cout << pow(N,.5) << endl;
  REP(i, N) {
    for (int d = 1; d <= pow(i, .5); d++) {
      if (i % d == 0) {
        if (i / d == d)
          counter++;
        else
          counter += 2;
      }
    }
  }
  cout << counter << endl;
  return;
}

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

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

int main() {
  int N;
  cin >> N;
  int x = 0;

  for (int a = 1; a <= N - 1; a++) {
    x += (N - 1) / a;
  }

  cout << x << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int N;
  cin >> N;
  int sum = 1;

  for (int i = 2; i < N; i++) {
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) {
        sum++;
      }
    }
  }

  cout << sum << endl;
}