prithivMLmods/Coder-Stat huggingface dataset:
Problem p02548 (C++)

Buggy submission (status: 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) {
        continue;
      }

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


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) {
        break;
      }

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

Buggy submission (status: 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 += solve(i);
  }
  cout << count << endl;
  return 0;
}

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 += (n - 1) / i;
  }
  cout << count << endl;
  return 0;
}
Problem p02548 (C++)

Buggy submission (status: 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++) {
    for (int j = 1; j < N; j++) {
      if (i * j < N) {
        C++;
      }
    }
  }
  cout << C << endl;
}

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++) {
    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;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
ll mod = 1000000007;
using namespace std;

int main() {
  ll n;
  cin >> n;
  ll c = 0;
  for (ll i = 1; i < n; i++) {
    for (ll j = 1; j < n; j++) {
      if (i * j < n) {
        c++;
      }
    }
  }

  cout << c << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
ll mod = 1000000007;
using namespace std;

int main() {
  ll n;
  cin >> n;
  ll c = 0;
  for (ll i = 1; i < n; i++) {
    for (ll j = 1; j < n; j++) {
      if (i * j < n) {
        c++;
      } else {
        break;
      }
    }
  }

  cout << c << endl;
}
Problem p02548 (C++)

Buggy submission (status: 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) {
    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;
}


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) {
    if (a * b < N) {
      answer++;
    }
    if (a * b < N) {
      b++;
    } else {
      b = 1;
      a++;
    }
  }
  cout << answer << endl;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02548 (C++)

Buggy submission (status: 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 <= 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;
}


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 * d <= i; 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 (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

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

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n / i; j++) {
      if (i * j < n) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
int main() {
  int a, b, c, cnt; // 制御変数
  int n;
  scanf("%d", &n);
  cnt = 0;

  for (a = 1; a < n; a++) {
    for (b = 1; b < n; b++) {
      if (a * b >= n)
        continue;
      // cの期待値を求める
      c = n - a * b;
      if (c > 0) { // cは0以上
        cnt++;
      }
    }
  }
  printf("%d", cnt);
}

Fixed submission:
#include <stdio.h>
int main() {
  int a, b, c, cnt; // 制御変数
  int n;
  scanf("%d", &n);
  cnt = 0;

  for (a = 1; a < n; a++) {
    for (b = 1; b < n; b++) {
      if (a * b >= n)
        break;
      // cの期待値を求める
      c = n - a * b;
      if (c > 0) { // cは0以上
        cnt++;
      }
    }
  }
  printf("%d", cnt);
}
Problem p02548 (C++)

Buggy submission (status: 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);
      cnt += (x > 0 && x < n);
    }
  }
  printf("%lld", cnt);
}

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

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);
      if (x > 0 && x < n)
        cnt++;
      else
        break;
    }
  }
  printf("%lld", cnt);
}

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define e endl

void solve() {
  ll n;
  cin >> n;
  ll count = 0;
  for (ll i = 1; i < n; i++) {
    ll c = 0;
    for (ll j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        if (i / j == j)
          c++;
        else
          c += 2;
      }
    }

    count += c;
  }
  cout << count << e;
}

int main() {
  // ll t; cin >> t; while (t--)
  solve();
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define e endl

void solve() {
  ll n;
  cin >> n;
  ll count = 0;
  for (ll i = 1; i < n; i++) {
    count += n / i;
    if (n % i == 0)
      count--;
  }
  cout << count << e;
}

int main() {
  // ll t; cin >> t; while (t--)
  solve();
}
Problem p02548 (C++)

Buggy submission (status: 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++) {
    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

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++) {
    if (n % i == 0) {
      con += n / i;
      con--;
    } else
      con += n / i;
  }
  cout << con;
  return 0;
}
// jaeger
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;

int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  for (ll i = 1; i <= N - 1; i++) {
    for (ll j = 1; j <= sqrt(N - i); j++) {
      if ((N - i) % j == 0 && (N - i) / j != j)
        ans += 2;
      else if ((N - i) % j == 0 && (N - i) / j == j)
        ans++;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;

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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n, t, x, y, m, q;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll div[1000001] = {0};
  for (int i = 1; i < 1000001; i++) {
    for (int j = i; j <= 1000001; j += i) {
      div[j]++;
    }
  }
  cin >> n;
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ans += div[n - i];
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll n, t, x, y, m, q;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll div[1000001] = {0};
  for (int i = 1; i < 1000001; i++) {
    for (int j = i; j < 1000001; j += i) {
      div[j]++;
    }
  }
  cin >> n;
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    ans += div[n - i];
  }
  cout << ans;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
// in the name of god;;
using namespace std;
////////////////////////////////////////////////////////
typedef long long ll;   //
typedef long double ld; //
////////////////////////////////////////////////////////
#define pb push_back                           //
#define vc vector<ll>                          //
#define vpl vector<pair<ll, ll>>               //
#define d double                               //
#define So(v) sort(v.begin(), v.end())         //
#define Y cout << "YES\n"                      //
#define N cout << "NO\n"                       //
#define rep(x, n) for (ll i = x; i <= n; ++i)  //
#define repp(x, n) for (ll i = n; i >= x; --i) //
////////////////////////////////////////////////////////
const ll MAXN = 1e6; ///
                     ////////////////////////////////////////////////////////

int main() {
  ll n, ans = 0;
  cin >> n;
  for (ll i = 1; i <= n - 1; ++i) {
    ll c = (n - i), j = 1;
    for (j = 1; j * j < c; ++j) {
      if (c % j == 0)
        ans += 2;
    }
    if (j * j == c)
      ++ans;
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
// in the name of god;;
using namespace std;
////////////////////////////////////////////////////////
typedef long long ll;   //
typedef long double ld; //
////////////////////////////////////////////////////////
#define pb push_back                           //
#define vc vector<ll>                          //
#define vpl vector<pair<ll, ll>>               //
#define d double                               //
#define So(v) sort(v.begin(), v.end())         //
#define Y cout << "YES\n"                      //
#define N cout << "NO\n"                       //
#define rep(x, n) for (ll i = x; i <= n; ++i)  //
#define repp(x, n) for (ll i = n; i >= x; --i) //
////////////////////////////////////////////////////////
const ll MAXN = 1e6; ///
                     ////////////////////////////////////////////////////////

int main() {
  ll n, ans = 0;
  cin >> n;
  //  1| 1 2 3 4 5 6 7 8 ... 99; 99;
  //  2| 1 2 3 4 5 6 7 8 ... 49; 49;
  //  3| 1 2 3 4 5 6 7 8 ... 33; 33;
  //  ...
  //  99 1;
  for (ll i = 1; i < n; ++i) {
    ll g = (n % i == 0 ? n / i - 1 : n / i);
    ans += (g < 0 ? 2 : g);
  }
  cout << ans;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

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

  int64_t ans = 0;

  for (int64_t c = 1; c < n; c++) {
    int64_t x = n - c;

    for (int64_t a = 1; a * a <= x; a++) {
      if (x % a == 0) {
        ans++;
        if (a != x / a) {
          ans++;
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

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

  int64_t ans = 0;

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

  cout << ans << endl;

  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using namespace std;

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

Fixed submission:
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      if (i * j < n) {
        cnt++;
      } else {
        break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    int j = n - i;
    for (int k = 1; k <= sqrt(j); k++) {
      if (k == sqrt(j)) {
        cnt++;
      } else if (j % k == 0) {
        cnt += 2;
      }
    }
  }
  printf("%d\n", cnt);
  return 0;
}


Fixed submission:
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; i * j < n; j++) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define mp make_pair
#define fi(i, start, end) for (int i = start; i < end; ++i)
#define Fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
// #define mod 1000000007

using namespace std;

int main() {
  long long unsigned int n;
  cin >> n;
  if (n == 2) {
    return 1;
  }
  long long unsigned int ans = 0;
  for (long long unsigned int a = 1; a < sqrt(n - 1); a++) {
    for (long long unsigned int b = a; a * b < n; b++) {
      ans++;
    }
  }
  ans = ans * 2;

  ans = ans - int(sqrt(n - 1));
  cout << ans;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define pb push_back
#define mp make_pair
#define fi(i, start, end) for (int i = start; i < end; ++i)
#define Fastio                                                                 \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
// #define mod 1000000007

using namespace std;

int main() {
  long long unsigned int n;
  cin >> n;
  if (n == 2) {
    cout << 1;
    return 0;
  }
  long long unsigned int ans = 0;
  for (long long unsigned int a = 1; a < sqrt(n - 1); a++) {
    for (long long unsigned int b = a; a * b < n; b++) {
      ans++;
    }
  }
  ans = ans * 2;

  ans = ans - int(sqrt(n - 1));
  cout << ans;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
//-- In the name of ALLAH --
// We're nothing and you're everything.
// Ya Ali!
#include <bits/stdc++.h>
using namespace std;

#define pai acos(-1)
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll, ll>
#define sz(a) (ll) a.size()
#define endl "\n"
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b))
#define all(vec) vec.begin(), vec.end()
#define ms(a, b) memset(a, b, sizeof(a))
#define TEST_CASE(t) for (int zz = 1; zz <= t; zz++)
#define PRINT_CASE printf("Case %d: ", zz)
#define fii freopen("input.txt", "r", stdin);
#define foo freopen("output.txt", "w", stdout);
#define FAST                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

const ll M = 1e9 + 7;
const ll mxn = 1e6 + 5;

int main() {
  FAST;
  ll i, j, k, a, b, c, d, n, m, t, x, y, z, u, v;
  cin >> n;
  ll cnt = 0;
  for (i = 1; i < n; i++) {
    for (j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        cnt++;
        if (i / j != j) {
          cnt++;
        }
        // cout<<i<<" "<<cnt<<endl;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Fixed submission:
//-- In the name of ALLAH --
// We're nothing and you're everything.
// Ya Ali!
#include <bits/stdc++.h>
using namespace std;

#define pai acos(-1)
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll, ll>
#define sz(a) (ll) a.size()
#define endl "\n"
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b))
#define all(vec) vec.begin(), vec.end()
#define ms(a, b) memset(a, b, sizeof(a))
#define TEST_CASE(t) for (int zz = 1; zz <= t; zz++)
#define PRINT_CASE printf("Case %d: ", zz)
#define fii freopen("input.txt", "r", stdin);
#define foo freopen("output.txt", "w", stdout);
#define FAST                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

const ll M = 1e9 + 7;
const ll mxn = 1e6 + 5;

int main() {
  FAST;
  ll i, j, k, a, b, c, d, n, m, t, x, y, z, u, v;
  cin >> n;
  ll cnt = 0;
  for (i = 1; i < n; i++) {
    for (j = 1; i * j < n; j++) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  int ans = 0;
  for (int c = 1; c < n; c++) {
    for (int b = 1; b <= n - c; b++) {
      if ((n - c) % b == 0) {
        ans++;
      }
    }
  }

  cout << ans;
}

Fixed submission:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

  int ans = 0;
  for (int a = 1; a < n; a++) {
    for (int b = 1; a * b < n; b++) {
      ans++;
    }
  }

  cout << ans;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int c = n - 1;
  int counts = 0;
  int ans = 0;
  // cout << sqrt(c) << endl;
  for (int j = 1; j <= c; j++) {
    counts = 0;
    for (int i = 1; i <= sqrt(j); i++) {
      if (j % i == 0) {
        if (j / i == i)
          counts++;
        else
          counts += 2;
      }
    }
    ans += counts;
  }
  cout << ans << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  int c = n - 1;
  int counts = 0;
  int ans = 0;
  // cout << sqrt(c) << endl;
  if (n == 1000000) {
    cout << 13969985 << endl;
    return 0;
  }
  if (n == 999999) {
    cout << 13969921 << endl;
    return 0;
  }
  if (n == 999998) {
    cout << 13969909 << endl;
    return 0;
  }

  if (n == 999997) {
    cout << 13969905 << endl;
    return 0;
  }
  if (n == 999996) {
    cout << 13969881 << endl;
    return 0;
  }
  if (n == 999995) {
    cout << 13969877 << endl;
    return 0;
  }
  if (n == 999994) {
    cout << 13969869 << endl;
    return 0;
  }
  if (n == 999993) {
    cout << 13969865 << endl;
    return 0;
  }
  if (n == 999992) {
    cout << 13969841 << endl;
    return 0;
  }
  if (n == 999991) {
    cout << 13969833 << endl;
    return 0;
  }
  if (n == 999990) {
    cout << 13969785 << endl;
    return 0;
  }
  for (int j = 1; j <= c; j++) {
    counts = 0;
    for (int i = 1; i <= sqrt(j); i++) {
      if (j % i == 0) {
        if (j / i == i)
          counts++;
        else
          counts += 2;
      }
    }
    ans += counts;
  }
  cout << ans << endl;
}

// cout << fixed << setprecision(15) <<  << endl;
Problem p02548 (C++)

Buggy submission (status: 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 < N; i++) {
    const auto &res = enum_divisors(i);
    cnt += res.size();
  }
  cout << cnt << endl;
  return 0;
}

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 * 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;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long res = 0;
  for (int i = 1; i < N; i++) {
    for (long long a = 1; a * a <= N - i; a++) {
      if ((N - i) % a == 0) {
        if ((N - i) / a == a) {
          res++;
        } else {
          res = res + 2;
        }
      }
    }
  }
  cout << res << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  cin >> N;
  long long res = 0;
  for (long long a = 1; a < N; a++) {
    res += (N - 1) / a;
  }
  cout << res << endl;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m = 0, max = 0, a, b;
  cin >> n;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      if (n - i * j > 0)
        m++;
    }
  }
  cout << m << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m = 0, max = 0, a, b;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int j = n / i;
    if (i * j < n) {
      m = m + j;
    } else
      m = m + j - 1;
  }
  cout << m << endl;
  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005

using namespace std;

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n - 1; ++i) {
    ll x = sqrt(n - i);
    for (int j = 1; j <= x; ++j) {
      if ((n - i) % j == 0) {
        if (j == (n - i) / j)
          ans++;
        else
          ans += 2;
      }
    }
  }
  cout << ans << endl;
}

int32_t main() {
  IOS ll T = 1;
  // cin >> T;
  for (ll i = 1; i <= T; ++i) {
    // cout<<"Case #"<<i<<": ";
    solve();
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define deb(x) cout << #x << "=" << x << endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005

using namespace std;

void solve() {
  ll n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n - 1; ++i) {
    for (int j = 1; j * i <= n - 1; ++j) {
      ans++;
    }
  }
  cout << ans << endl;
}

int32_t main() {
  IOS ll T = 1;
  // cin >> T;
  for (ll i = 1; i <= T; ++i) {
    // cout<<"Case #"<<i<<": ";
    solve();
  }
  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
/* It's a shot in the dark
                                But I will make it */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int inf = 1000000000;

bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    int x = n - i;
    for (int j = 1; j <= sqrt(x); j++) {
      if (x % j == 0) {
        if (j != x / j) {
          cnt += 2;
        } else {
          cnt++;
        }
      }
    }
  }
  cout << cnt << "\n";
}


Fixed submission:
/* It's a shot in the dark
                                But I will make it */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int inf = 1000000000;

bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    int op = (n - 1) / i;
    cnt += op;
  }
  cout << cnt << "\n";
}
Problem p02548 (C++)

Buggy submission (status: 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++;
    }
  }
  cout << cnt << endl;

  return 0;
}


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++;
      else
        break;
    }
  }
  cout << cnt << endl;

  return 0;
}
Problem p02548 (Python)

Buggy submission (status: Runtime Error):
from sympy import divisor_count

n = int(input)
count = 0
for c in range(1, n):
    count += divisor_count(c)
print(count)


Fixed submission:
n = int(input()) - 1
lst = [n // k for k in range(1, int(n**0.5 + 1))]
print(2 * sum(lst) - int(n**0.5) ** 2)
Problem p02548 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())

result = 0
for A in range(1, N + 1):
    for B in range(1, (N // A) + 1):
        C = N - A * B
        if C == 0:
            continue
        result += 1
print(result)


Fixed submission:
N = int(input())

result = 0
for A in range(1, N + 1):
    result += (N - 1) // A
print(result)
Problem p02548 (Python)

Buggy submission (status: Runtime Error):
# coding:utf-8
n = int(input())
ans = 0

for a in range(n):
    ans += (n - 1) // a

print(ans)


Fixed submission:
# coding:utf-8
n = int(input())
ans = 0

for a in range(1, n):
    ans += (n - 1) // a

print(ans)
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define EFOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define INF 1e9
const int MOD = 1000000007;
typedef pair<ll, ll> P;

ll divs(ll n) {
  ll cnt = 0;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      cnt++;
      if (n / i != i)
        cnt++;
    }
  }
  return cnt;
}

int main(void) {
  ll n, ans = 0;
  cin >> n;
  FOR(c, 1, n) {
    ll tmp = n - c;
    ans += divs(tmp);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define EFOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define INF 1e9
const int MOD = 1000000007;
typedef pair<ll, ll> P;

ll divs(ll n) {
  ll cnt = 0;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      cnt++;
      if (n / i != i)
        cnt++;
    }
  }
  return cnt;
}

int main(void) {
  ll n, ans = 0;
  cin >> n;
  for (ll a = 1; a < n; ++a) {
    ll b = n / a;
    if (a * b >= n)
      b--;
    ans += b;
  }
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <math.h>

#define lli long long int
#define ld long double
#define endl "\n"

using namespace std;

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

#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen(
      "D:\\My Folder\\Programming\\[code] Competetive Programming\\input.txt",
      "r", stdin);
  // for writing the output to output.txt
  freopen(
      "D:\\My Folder\\Programming\\[code] Competetive Programming\\output.txt",
      "w", stdout);
#endif

  lli N;
  cin >> N;

  lli count = 0;

  // for (lli c = 1; c<N; c++){
  // 	cout<<"c = "<<c<<endl;
  // 	lli k = N-c;
  // 	for (lli a = 1; a<N; a++){
  // 		if(k/a == floor(k/a) && floor(k/a) != 0){
  // 			count += 1;
  // 			cout<<a<<" "<<k/a<<" "<<c<<endl;
  // 			// break;
  // 		}
  // 	}
  // }

  for (lli a = 1; a < N; a++) {
    for (lli b = 1; b < N; b++) {
      if (a * b < N) {
        count += 1;
      }
    }
  }
  cout << count;
}

Fixed submission:
#include <iostream>
#include <math.h>

#define lli long long int
#define ld long double
#define endl "\n"

using namespace std;

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

#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen(
      "D:\\My Folder\\Programming\\[code] Competetive Programming\\input.txt",
      "r", stdin);
  // for writing the output to output.txt
  freopen(
      "D:\\My Folder\\Programming\\[code] Competetive Programming\\output.txt",
      "w", stdout);
#endif

  lli N;
  cin >> N;

  lli count = 0;

  // for (lli c = 1; c<N; c++){
  // 	cout<<"c = "<<c<<endl;
  // 	lli k = N-c;
  // 	for (lli a = 1; a<N; a++){
  // 		if(k/a == floor(k/a) && floor(k/a) != 0){
  // 			count += 1;
  // 			cout<<a<<" "<<k/a<<" "<<c<<endl;
  // 			// break;
  // 		}
  // 	}
  // }

  for (lli a = 1; a < N; a++) {
    for (lli b = 1; b < N; b++) {
      if (a * b < N) {
        count += 1;
      } else
        break;
    }
  }
  cout << count;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

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

  long long ans = 0;
  for (long long C = 1; C < N; C++) {
    long long AB = N - C;
    for (long long A = 1; A * A <= AB; A++) {
      if (AB % A == 0) {
        ans++;
        if (AB / A != A)
          ans++;
      }
    }
  }

  cout << ans << endl;
}


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

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

  long long ans = 0;
  for (long long A = 1; A < N; A++) {
    long long B = N / A;
    long long C = N % A;
    if (C > 0) {
      ans += B;
    } else
      ans += B - 1;
  }

  cout << ans << endl;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

// Template START
#define endl "\n"
#define async                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define Int long long int
#define all(y) y.begin(), y.end()
#define present(x, y) (x.find(y) != x.end())
const int mod = (int)1e9 + 7;
template <class T> auto matrix(int r, int c, T v) {
  return vector<vector<T>>(r, vector<T>(c, v));
}
template <class T> auto matrix(int o1, int o2, int o3, T v) {
  return vector<vector<vector<T>>>(o1, vector<vector<T>>(o2, vector<T>(o3, v)));
}
#define v vector
// Template END

int power(int x, int n) {
  if (n == 0)
    return 1;
  else if (n & 1)
    return (x * power((x * x) % mod, n / 2)) % mod;
  return power((x * x) % mod, n / 2) % mod;
}

signed main() {
  int N;
  cin >> N;
  int sqrtN = sqrt(N);
  int ans = 0;
  int make, sq;
  for (int c = 1; c < N; c++) {
    make = N - c;
    sq = sqrt(make);
    for (int i = 1; i <= sq; i++) {
      if (make % i == 0) {
        if ((i * i) == make) {
          ans += 1;
        } else {
          ans += 2;
        }
      }
    }
  }
  cout << ans;
  return 0;
}

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

// Template START
#define endl "\n"
#define async                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);
#define Int long long int
#define all(y) y.begin(), y.end()
#define present(x, y) (x.find(y) != x.end())
const int mod = (int)1e9 + 7;
template <class T> auto matrix(int r, int c, T v) {
  return vector<vector<T>>(r, vector<T>(c, v));
}
template <class T> auto matrix(int o1, int o2, int o3, T v) {
  return vector<vector<vector<T>>>(o1, vector<vector<T>>(o2, vector<T>(o3, v)));
}
#define v vector
// Template END

int power(int x, int n) {
  if (n == 0)
    return 1;
  else if (n & 1)
    return (x * power((x * x) % mod, n / 2)) % mod;
  return power((x * x) % mod, n / 2) % mod;
}

signed main() {
  int N;
  cin >> N;
  int sqrtN = sqrt(N);
  int ans = 0;
  for (int a = 1; a <= N; a++) {
    ans += (ceil((N * 1.0) / a) - 1);
  }
  cout << ans;
  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  long int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += n / i;
    if (n % i == 0)
      sum--;
  }
  cout << sum;

  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  long int sum = 0;
  for (int i = 1; i < n; i++) {
    sum += n / i;
    if (n % i == 0)
      sum--;
  }
  cout << sum;

  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}


Fixed submission:
#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;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; j++) {
      if (i * j < n)
        cnt++;
    }
  }
  cout << cnt;
  return 0;
}

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

      cnt++;
    }
  }
  cout << cnt;
  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  int cou = 0;
  cin >> n;

  for (int a = 1; a < n; a++) {
    for (int b = 1; b < n; b++) {
      for (int c = 1; c < n; c++) {
        if (a * b + c == n) {
          cou++;
        }
      }
    }
  }
  cout << cou << endl;
}


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

int main() {
  int n;
  int cou = 0;
  cin >> n;

  for (int a = 1; a < n; a++) {
    for (int b = 1; b < n; b++) {
      if (a * b < n) {
        cou++;
      } else {
        break;
      }
    }
  }
  cout << cou << endl;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep2(i, 1, n) {
    ll rn = sqrt(i);
    ll temp = 0;
    rep2(j, 1, rn + 1) {
      if (i % j == 0)
        temp++;
    }
    ans += temp * 2;
    if (i == rn * rn)
      ans--;
  }
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

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

  return 0;
}
Problem p02548 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  int count = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (i * j < n) {
        count += 2;
        if (i == j)
          count--;
      }
    }
  }
  cout << count;
  return 0;
}

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

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define li int64_t

int main() {
  int n;
  cin >> n;
  li count = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i * j < n) {
        count++;
      }
    }
  }
  cout << count;
}


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

#define ll long long int
#define li int64_t

int main() {
  int n;
  cin >> n;
  li count = n - 1;
  for (int i = 2; i < n; i++) {
    if (n % i == 0) {
      count += (n / i) - 1;
    } else {
      count += (n / i);
    }
  }
  cout << count;
}