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

#include <bits/stdc++.h>
#define forna(i, a, n) for (int i = a; i < n; i++)
typedef long long int lli;
#define MOD 1000000007
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli t, n, m, tot = 0;
  string s;
  cin >> n;
  forna(i, 1, n + 1) {
    forna(j, 1, n + 1) {
      if (i * j > n - 1)
        break;
      tot++;
    }
  }
  cout << tot << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define forna(i, a, n) for (int i = a; i < n; i++)
typedef long long int lli;
#define MOD 1000000007
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lli t, n, m, tot;
  string s;
  lli maxi[1000000];
  maxi[1] = 1;
  forna(i, 2, 1000000) {
    tot = 0;
    for (int j = 1; j * j <= i; j++) {
      if (i % j == 0) {
        if (j * j != i)
          tot += 2;
        else
          tot++;
      }
    }
    maxi[i] = maxi[i - 1] + tot;
  }
  cin >> n;
  cout << maxi[n - 1];
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

Error: TLE

Fixed submission:

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

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

#include <bits/stdc++.h>
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(nullptr);
#define ll long long int
#define f(i, a, b) for (int i = a; i < b; i++)
#define fr(i, a, b) for (int i = a; i >= b; i--)
#define l long int
#define endl '\\n'
#define pb push_back
#define pf pop.front()
using namespace std;

long int divisor[1000001];

void solve() {
  l n;

  cin >> n;
  for (l i = 1; i < n; i++) {
    for (l j = i; j <= n; j += i) {
      divisor[j]++;
    }
  }

  ll ans = 0;

  for (l i = 1; i < n; i++)
    ans += divisor[n - i];

  cout << ans << endl;
}

int32_t main() {
  FAST l T = 1;

  while (T--) {
    solve();
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define FAST                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(nullptr);
#define ll long long int
#define f(i, a, b) for (int i = a; i < b; i++)
#define fr(i, a, b) for (int i = a; i >= b; i--)
#define l long int
#define endl '\\n'
#define pb push_back
#define pf pop.front()
using namespace std;

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

int32_t main() {
  FAST l T = 1;

  while (T--) {
    solve();
  }
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define F first
#define S second
#define ALL(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define FORB(i, a, b) for (int i = a; i >= b; i--)
#define INT_MAXI 2147483647
#define INT_MINI -2147483648
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // cout<<"input"<<endl;freopen("input.txt","r",stdin);
  // cout<<"output"<<endl;freopen("output.txt","w",stdout);

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

  return 0;
}

Error: TLE

Fixed submission:

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define F first
#define S second
#define ALL(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define FORB(i, a, b) for (int i = a; i >= b; i--)
#define INT_MAXI 2147483647
#define INT_MINI -2147483648
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;

bool prime[1000001];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  // cout<<"input"<<endl;freopen("input.txt","r",stdin);
  // cout<<"output"<<endl;freopen("output.txt","w",stdout);

  prime[1] = true;
  for (int i = 2; i <= 1000000; i++)
    if (prime[i] == false) {
      for (int j = i + i; j <= 1000000; j += i)
        prime[j] = true;
    }
  ll n;
  cin >> n;

  ll sum = 0;
  for (ll i = n - 1; i >= 1; i--) {
    if (!prime[i]) {
      sum += 2;
      continue;
    }
    ll akhir = sqrt(i);

    for (ll j = 1; j <= akhir; j++)
      if (i % j == 0) {
        if (i / j == j)
          sum += 1;
        else
          sum += 2;
      }
  }
  cout << sum << endl;

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

#include <bits/stdc++.h>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#include <algorithm>
#include <cmath>
using namespace std;
pair<ll, ll> norm(ll a, ll b) {
  if (a < 0) {
    a *= -1;
    b *= -1;
  } else if ((a == 0) && (b < 0)) {
    b *= -1;
  }
  ll d = __gcd(abs(a), abs(b));
  a = (ll)(a / d);
  b = (ll)(b / d);
  pair<ll, ll> p = mp(a, b);
  return p;
}
bool decreasing(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.first > b.first)
    return true;
  else if (a.first == b.first) {
    if (a.second < b.second)
      return false;
    else
      return true;
  } else
    return false;
}
ll expo(ll x, ll y) {
  ll res = 1;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
int main() {
  // ios_base::sync_with_stdio(false);
  // cin.tie(NULL);
  // int T,p;
  // cin>>T;
  // for(p=1;p<=T;p++)
  // {
  ll N;
  cin >> N;
  ll i, j, k, a, b, c;
  ll count = 0;
  for (i = 1; i < N; i++) {
    a = N - 1;
    b = (ll)(a / i);
    count += b;
  }
  cout << count;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#include <algorithm>
#include <cmath>
using namespace std;
pair<ll, ll> norm(ll a, ll b) {
  if (a < 0) {
    a *= -1;
    b *= -1;
  } else if ((a == 0) && (b < 0)) {
    b *= -1;
  }
  ll d = __gcd(abs(a), abs(b));
  a = (ll)(a / d);
  b = (ll)(b / d);
  pair<ll, ll> p = mp(a, b);
  return p;
}
bool decreasing(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.first > b.first)
    return true;
  else if (a.first == b.first) {
    if (a.second < b.second)
      return false;
    else
      return true;
  } else
    return false;
}
ll expo(ll x, ll y) {
  ll res = 1;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res;
}
int main() {
  // ios_base::sync_with_stdio(false);
  // cin.tie(NULL);
  // int T,p;
  // cin>>T;
  // for(p=1;p<=T;p++)
  // {
  ll N;
  cin >> N;
  ll i, j, k, a, b, c;
  ll count = 0;
  for (i = 1; i < N; i++) {
    a = N - i;
    for (j = 1; j * j <= a; j++) {
      if (a % j == 0) {
        k = a / j;
        if (k == j)
          count++;
        else
          count += 2;
      }
    }
  }
  cout << count;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, f, t) for (int i = int(f); i <= int(t); i++)

int count(int n) {
  vector<int> data;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      data.push_back(i);
      if (n / i != i)
        data.push_back(n / i);
    }
  }
  return data.size();
}

int main() {
  int n, ans = 0;
  cin >> n;
  vector<int> data(n);
  FOR(i, 1, n - 1) data.at(i - 1) = count(i);
  FOR(i, 1, n - 1) ans += data.at(i - 1);
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i, n) for (int i = 0; i < int(n); i++)
#define RREP(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define FOR(i, f, t) for (int i = int(f); i <= int(t); i++)
#define RFOR(i, f, t) for (int i = int(f); i >= int(t); i--)
#define ALL(vec) (vec).begin(), (vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans)                                                               \\
  if (ans)                                                                     \\
    cout << "YES" << endl;                                                     \\
  else                                                                         \\
    cout << "NO" << endl;
#define Yes(ans)                                                               \\
  if (ans)                                                                     \\
    cout << "Yes" << endl;                                                     \\
  else                                                                         \\
    cout << "No" << endl;
#define yes(ans)                                                               \\
  if (ans)                                                                     \\
    cout << "yes" << endl;                                                     \\
  else                                                                         \\
    cout << "no" << endl;

ll count(ll n) {
  vector<ll> data;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      data.push_back(i);
      if (n / i != i)
        data.push_back(n / i);
    }
  }
  return data.size();
}

int main() {
  int n, ans = 0;
  cin >> n;
  FOR(i, 1, n - 1) ans += count(i);
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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


Error: TLE

Fixed submission:

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

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

#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef map<string, int> msi;
typedef pair<int, int> PII;

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
typedef map<string, int> msi;
typedef pair<int, int> PII;

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

//"BISMILLAHIR RAHMANIR RAHIM"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e9 + 7;
ll fact(ll x, ll y) {
  ll f = 1, i = 1;
  while (i <= y) {
    f = ((f % M) * (x % M)) % M;
    i++;
  }
  return f;
}
int main() {
  ll n, i, cnt = 0, x, y, j;
  cin >> n;
  for (i = 1; i < n; i++) {
    for (j = 1; i * j < n; j++)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Error: TLE

Fixed submission:

//"BISMILLAHIR RAHMANIR RAHIM"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const long long M = 1e9 + 7;
ll fact(ll x, ll y) {
  ll f = 1, i = 1;
  while (i <= y) {
    f = ((f % M) * (x % M)) % M;
    i++;
  }
  return f;
}
int main() {
  ll n, i, cnt = 0, x, y, j;
  cin >> n;
  for (i = 1; i < n; i++) {
    x = n - i;
    for (j = 1; j * j < x; j++) {
      if (x % j == 0)
        cnt += 2;
    }
    y = sqrt(x);
    if (y * y == x)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

vector<int> d(1000000 + 10);
void era() {
  rep(i, d.size()) { d[i] = i; }
  int n = d.size() - 1;
  for (int i = 2; i * i <= n; i++) {
    if (d[i] != i)
      continue;
    for (int j = i * 2; j <= n; j += i) {
      if (d[j] != j)
        continue;
      d[j] = i;
    }
  }
}

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  era();
  for (int c = 1; c < n; c++) {
    int m = n - c;
    int tmp = 1;
    int before = 0;
    vector<int> p;
    while (m > 1) {
      if (d[m] != before) {
        p.push_back(1);
        before = d[m];
      } else {
        p[p.size() - 1]++;
      }
      m /= d[m];
    }
    rep(i, p.size()) tmp *= (p[i] + 1);
    ans += tmp;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int c = 1; c < n; c++) {
    int m = n - c;
    for (int b = 1; b * b <= m; b++) {
      if (m % b == 0) {
        if (m / b == b) {
          ans++;
        } else {
          ans += 2;
        }
      }
    }
  }
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  map<ll, ll> m;
  for (ll i = 1; i <= n; i++) {
    for (ll j = 1; j <= n; j++) {
      m[i * j]++;
    }
  }
  for (ll i = 1; i <= n; i++) {
    ans += m[n - i];
  }
  cout << ans;
}
Problem p02548 (C++) — buggy submission, verdict: 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 = n - 1;
  for (int i = 2; i < n; i++) {
    if (n % i == 0) {
      count += (n / i) - 1;
    } else {
      count += (n / i);
    }
  }
  cout << count;
}


Error: TLE

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 = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i * j < n) {
        count++;
      }
    }
  }
  cout << count;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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


Error: TLE

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++) {
    for (int j = i; j < n; j++) {
      if (i * j < n) {
        count += 2;
        if (i == j)
          count--;
      }
    }
  }
  cout << count;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

Error: TLE

Fixed submission:

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

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

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

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template <class T> T gcd(T a, T b) { return ((b == 0) ? a : gcd(b, a % b)); }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  // freopen("input.in", "r", stdin);
  // freopen("output.out", "w", stdout);
  ll n;
  cin >> n;
  ll ans = 0;
  repn(i, 1, n) {
    // we guess a
    ll l = 1, r = n;
    while (l < r) {
      ll mid = (l + r + 1) / 2;
      if (mid * i < n)
        l = mid;
      else
        r = mid - 1;
    }
    ans += l;
  }
  cout << ans << endl;
  return 0;
}
/*
Things to look out for:
        - Integer overflows
        - Array bounds
        - Special cases
Be careful!
*/


Error: TLE

Fixed submission:

#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template <class T> T gcd(T a, T b) { return ((b == 0) ? a : gcd(b, a % b)); }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  // freopen("input.in", "r", stdin);
  // freopen("output.out", "w", stdout);
  int n;
  cin >> n;
  int ans = 0;
  repn(i, 1, n) {
    for (int j = 1; sq(j) <= (n - i); j++) {
      if ((n - i) % j == 0) {
        ans += (j == (n - i) / j ? 1 : 2);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
/*
Things to look out for:
        - Integer overflows
        - Array bounds
        - Special cases
Be careful!
*/
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

// #include <cmath>
// #include <cstdio>
// #include <cstring>
// #include <cstdlib>
// #include <iostream>
// #include <algorithm>
// using namespace std;
// char s[3010];
// int n,i,a,b,j,p,q;
// int main () {
////	freopen ("队列变换.in","r",stdin);
////	freopen ("队列变换.out","w",stdout);
//	scanf ("%d",&n);
//	for (i=1;i<=n;i++)
//		cin>>s[i];
//	a=1;
//	b=n;
//	for (i=1;i<=n;i++) {
//		for (j=i;j<=i+79&&j<=n;j++) {
//			if (s[a]==s[b]) {
//				p=a;
//				q=b;
//				while (p<=q&&s[p]==s[q]){
//					p++;
//					q--;
//				}
//				if (s[p]<=s[q]) {
//					printf ("%c",s[a]);
//					a++;
//				}
//				else {
//					printf ("%c",s[b]);
//					b--;
//				}
//			}
//			else {
//				if (s[a]>s[b]) {
//					printf ("%c",s[b]);
//					b--;
//				}
//				else {
//					printf ("%c",s[a]);
//					a++;
//				}
//			}
//		}
//		i+=79;
//		puts ("");
//	}
//	return 0;
//}
#include <cstdio>
long long n, ans, b, c, s, i;
int fj(int n) {
  int s = 1;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int a = 0;
      while (n % i == 0) {
        n /= i;
        a++;
      }
      s = s * (a + 1);
    }
  }
  if (n > 1)
    s = s * 2;
  return s;
}
int main() {
  scanf("%lld", &n);
  for (i = 1; i < n - 1; i++)
    s += fj(n - i);
  printf("%lld\\n", s + 1);
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
long long n, ans, i, b, c, s;
long long fj(long long n) {
  int i = 1, s = 0;
  while (n > 0) {
    if (n % i == 0)
      n /= i;
    i++;
    s++;
  }
  return s;
}
int main() {
  scanf("%lld", &n);
  for (i = 1; i <= n; i++)
    s += fj(n - i);
  printf("%lld\\n", s);
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <string.h>
using namespace std;
//
int main() {
  int N, a, b;
  a = 0;
  cin >> N;
  for (int i = 1; i < N; i++) {
    a = a + ((N - 1) / i);
  }
  cout << a << endl;
}

Error: -8

Fixed submission:

#include <bits/stdc++.h>
#include <string.h>
using namespace std;
//
int main() {
  int N, a, b;
  int c = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    a = N / i;
    b = N % i;
    if (a * i + b == N)
      c = c + 3;
    cerr << a << " " << b << " " << i << endl;
  }
  cout << c << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

vector<pair<long long, long long>> prime_factorize(long long N) {
  vector<pair<long long, long long>> res;
  for (long long a = 2; a * a <= N; ++a) {
    if (N % a != 0)
      continue;
    long long ex = 0;
    while (N % a == 0) {
      ++ex;
      N /= a;
    }
    res.push_back({a, ex});
  }
  if (N != 1)
    res.push_back({N, 1});
  return res;
}

int main() {
  long long N;
  cin >> N;
  int sum = 0;
  for (int i = 1; i < N; i++) {
    const auto &pf = prime_factorize(i);
    long long res = 1;
    for (auto p : pf)
      res *= p.second + 1;
    sum = sum + res;
  }
  cout << sum << endl;
}

Error: TLE

Fixed submission:

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

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() {
  long long N;
  cin >> N;
  long long sum = 0;
  for (int k = 1; k < N; k++) {
    const auto &res = enum_divisors(k);
    sum = sum + res.size();
  }
  cout << sum << endl;
}