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

#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end());
#include <bits/stdc++.h>
#include <iostream>
#include <math.h> //pow(x,y)=x^y 99999とかの場合+1するif文
#define ll long long
#define rep(init, i, n) for (ll i = init; i < (n); i++)
#define rev(s) reverse(s.begin(), s.end())
#define sor(v) sort(v.begin(), v.end())
#define PI 3.14159265358979323846264338327950L
// コード自動整形 Shift + Option + F @vscode
using namespace std;

/////main/////
int main() {
  ll N, sum;
  cin >> N;
  sum = 0;
  ll temp = 0;
  rep(0, i, N / 2) {
    if (N % (1 + i) == 0) {
      temp = N / (i + 1) - 1;
      sum += temp;
    } else {
      temp = N / (i + 1);
      sum += temp;
    }
    // cout << temp << endl;
  }
  sum += N - N / 2 - 1;
  cout << sum << endl;
}
/////main/////

/////function/////


Error: TLE

Fixed submission:

#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end());
#include <bits/stdc++.h>
#include <iostream>
#include <math.h> //pow(x,y)=x^y 99999とかの場合+1するif文
#define rep(init, i, n) for (int i = init; i < (n); i++)
#define ll long long
#define rev(s) reverse(s.begin(), s.end())
#define sor(v) sort(v.begin(), v.end())
#define PI 3.14159265358979323846264338327950L
// コード自動整形 Shift + Option + F @vscode
using namespace std;

ll facctorialMethod(ll k); // 階乗を出力する

/*  divisor(n)
    入力：整数 n
    出力：nのすべての約数
    計算量：O(√n)
*/
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  // sort(ret.begin(), ret.end()); // 昇順に並べる
  return ret;
}

/////main/////
int main() {
  ll N;
  cin >> N;
  vector<ll> output = divisor(N);
  ll sum = 0;

  rep(2, i, N + 1) { // 2--N
    ll imput = i - 1;
    vector<ll> output = divisor(imput);
    sum += output.size();
  }
  cout << sum << endl;
  /*rep(0,i,output.size()){
      cout<<output.at(i)<<endl;
  }*/

  // cout<<output.size()<<endl;
}
/////main/////

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

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ull unsigned long long
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define mii map<int, int>
#define pii pair<int, int>
#define pq priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define w(t)                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
int32_t main() {
  int n, ans = 0;
  cin >> n;
  vector<int> dp(n, 0);
  for (int i = 1; i < n; i++)
    for (int j = i; j < n; j = j + i)
      dp[j]++;
  for (int i = 1; i < n; i++)
    ans += dp[i];
  cout << ans;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ull unsigned long long
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define mii map<int, int>
#define pii pair<int, int>
#define pq priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define w(t)                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
long pairmultiply(int x) {
  long ans = 2, p = sqrt(x);
  for (int i = 2; i <= p; i++) {
    if (x % i == 0)
      ans += 2;
  }
  if (p * p == x)
    ans--;
  return ans;
}
int32_t main() {
  int n;
  cin >> n;
  long ans = 1;
  for (int i = 2; i < n; i++) {
    long x = pairmultiply(i);
    ans += x;
  }
  cout << ans;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define M 1000000007
#define pi 3.14159265358979323846
#define cel(x, a) (x + a - 1) / a
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vpi vector<pii>
#define vpl vector<pll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ps(x, y) fixed << setprecision(y) << x
#define pf(x, y) setfill('x') << setw(y)
#define mp make_pair
#define F first
#define S second
/*.*Ashish_akj*.*/
#define lcm(m, n) (m / __gcd(m, n)) * n
#define all(v) v.begin(), v.end()
using namespace std;
const int N = 2e6 + 4;
/*
int ncr(int n, int r)
{
    long long p = 1, k = 1;
    if (n - r < r)
        r = n - r;

    if (r != 0) {
        while (r) {
            p *= n;
            k *= r;
            long long m = __gcd(p, k);
            p /= m;
            k /= m;

            n--;
            r--;
        }
    }

    else
        p = 1;
    return p;
} */
/*vector<bool>visited;
 vector<vector<int>>adj;
void dfs(int v)
{visited[v]=true;
for(int i:adj[v])
{if(!visited){dfs(i);}
}}
*/
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i < n; i++) {
    int p = (n - 1) / i;
    ans += p;
  }
  cout << ans;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define M 1000000007
#define pi 3.14159265358979323846
#define cel(x, a) (x + a - 1) / a
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vpi vector<pii>
#define vpl vector<pll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ps(x, y) fixed << setprecision(y) << x
#define pf(x, y) setfill('x') << setw(y)
#define mp make_pair
#define F first
#define S second
/*.*Ashish_akj*.*/
#define lcm(m, n) (m / __gcd(m, n)) * n
#define all(v) v.begin(), v.end()
using namespace std;
const int N = 2e6 + 4;
/*
int ncr(int n, int r)
{
    long long p = 1, k = 1;
    if (n - r < r)
        r = n - r;

    if (r != 0) {
        while (r) {
            p *= n;
            k *= r;
            long long m = __gcd(p, k);
            p /= m;
            k /= m;

            n--;
            r--;
        }
    }

    else
        p = 1;
    return p;
} */
/*vector<bool>visited;
 vector<vector<int>>adj;
void dfs(int v)
{visited[v]=true;
for(int i:adj[v])
{if(!visited){dfs(i);}
}}
*/
int cont(int no) {
  int cnt = 0;
  for (int i = 1; i <= sqrt(no); i++) {
    if (no % i == 0) {
      if (no / i == i) {
        cnt++;
      } else {
        cnt = cnt + 2;
      }
    }
  }
  return cnt;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i < n; i++) {
    int p = cont(i);
    ans += p;
  }
  cout << ans;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
long long enum_divisors(int N) {
  long long res = 0;
  for (int i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res++;
      if (N / i != i)
        res++;
    }
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long p = enum_divisors(n - i);
    ans += p;
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long enum_divisors(long long N) {
  long long res = 0;
  for (long long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res++;
      if (N / i != i)
        res++;
    }
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    long long p = enum_divisors(n - i);
    ans += p;
  }
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define mx 1005
using namespace std;
typedef long long ll;
vector<ll> prime;
void sieve() {
  bool flag[mx];
  memset(flag, 0, sizeof(flag));
  flag[1] = 1;
  for (int i = 4; i <= mx; i += 2) {
    flag[i] = 1;
  }
  for (int i = 3; i <= sqrt(mx); i += 2) {
    if (flag[i] == 0) {
      for (int j = 2 * i; j <= mx; j += i)
        flag[j] = 1;
    }
  }
  for (int i = 2; i < mx; i++) {
    if (flag[i] == 0) {
      prime.push_back(i);
    }
  }
  // for(int i=0;i<10;++i)
  // cout<<prime[i]<<endl;
}
ll NumOfDivisors(ll n) {
  ll sqrtn = sqrt(n);
  ll c = 0, ans = 1;
  for (int i = 0; i < prime.size() && prime[i] <= sqrtn; i++) {
    if (n % prime[i] == 0) {
      c = 0;
      while (n % prime[i] == 0) {
        n /= prime[i];
        c++;
      }
      sqrtn = sqrt(n);
      ans *= (c + 1);
    }
  }

  if (n != 1) {
    ans *= 2;
  }
  return ans;
}
int main() {
  ll n;
  cin >> n;
  ll c, ans = 0;
  sieve();
  ll x;
  for (int i = 1; i < n; i++) {
    x = NumOfDivisors(n - i);
    ans += x;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

/// in the name of ALLAH
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  ll c, ans = 0;
  for (int i = 1; i < n; i++) {
    ll x = n - i;
    c = 0;
    for (int i = 1; i <= sqrt(x); i++) {
      if (x % i == 0) {
        if (x / i == i)
          c++;
        else
          c += 2;
      }
    }
    ans += c;
  }
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

vector<vector<long long>> Factrization(long long X);

int main() {
  long long N, N_dash;
  long long pi;
  vector<vector<long long>> facts;
  long long ans = 0;
  std::cin >> N;

  for (long long i = 1; i <= N - 1; i++) {
    pi = (long long)floor(((double)N - 1.0) / (double)i);
    for (long long j = 1; j <= pi; j++) {
      ans++;
    }
  }

  std::cout << ans;
}

vector<vector<long long>> Factrization(long long X) {
  vector<vector<long long>> factors = {};
  long long n_loop, a, b;

  n_loop = (long long)floor(sqrt((float)X));
  for (long long i = 1; i <= n_loop; i++) {
    if (X % i == 0) {
      a = i;
      b = X / i;
      factors.push_back({a, b});
    }
  }
  return factors;
}

Error: TLE

Fixed submission:

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

vector<vector<long long>> Factrization(long long X);

int main() {
  long long N, N_dash;
  vector<vector<long long>> facts;
  long long ans = 0;
  std::cin >> N;

  for (long long i = 1; i <= N - 1; i++) {
    N_dash = N - i;
    facts = Factrization(N_dash);
    ans = ans + Factrization(N_dash).size() * 2;
    if (facts[facts.size() - 1][0] == facts[facts.size() - 1][1]) {
      ans = ans - 1;
    }
  }

  std::cout << ans;
}

vector<vector<long long>> Factrization(long long X) {
  vector<vector<long long>> factors = {};
  long long n_loop, a, b;

  n_loop = (long long)floor(sqrt((float)X));
  for (long long i = 1; i <= n_loop; i++) {
    if (X % i == 0) {
      a = i;
      b = X / i;
      factors.push_back({a, b});
    }
  }
  return factors;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_map>

using namespace std;

typedef long long ll;

void solve() {
  int n;
  cin >> n;
  int ans = 0;
  int sq = sqrt(n) + 1;

  for (int i = 1; i <= sq; i++) {
    for (int j = i; j <= n / i; j++) {
      if (i * j < n) {
        ans++;
        if (i != j)
          ans++;
      }
    }
  }

  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#if defined(_DEBUG)
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int q = 1;
  // cin >> q;
  for (; q > 0; q--) {
    solve();
    // cout << endl;
  }
}

Error: TLE

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#include <unordered_map>

using namespace std;

typedef long long ll;

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

  cout << ans;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#if defined(_DEBUG)
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int q = 1;
  // cin >> q;
  for (; q > 0; q--) {
    solve();
    // cout << endl;
  }
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
// 素因数分解

long long divisor_num(long long a) {
  long long ans = 1;

  for (int i = 2; i <= sqrt(a); i++) {
    int cnt = 0;
    while (a % i == 0) {
      cnt++;
      a /= i;
    }
    ans *= (cnt + 1);
    if (a == 1)
      break;
  }
  if (a != 1)
    ans *= 2;

  return ans;
}

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

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
// 素因数分解
template <typename T> map<T, T> prime_factor(T n) {
  map<T, T> ret;
  for (T i = 2; i * i <= n; i++) {
    T tmp = 0;
    while (n % i == 0) {
      tmp++;
      n /= i;
    }
    ret[i] = tmp;
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}
/*  divisor_num(n)
    入力：整数 n
    出力：nの約数の個数
    計算量：O(√n)
*/
template <typename T> T divisor_num(T N) {
  map<T, T> pf = prime_factor(N);
  T ret = 1;
  for (auto p : pf) {
    ret *= (p.second + 1);
  }
  return ret;
}
long long N;
int main() {
  cin >> N;
  long long ans = 0;
  for (int i = N - 1; i > 0; i--) {
    ans += divisor_num(i);
  }
  cout << ans;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}

inline bool read(int &a) {
  int s = 0, w = 1;
  char ch = getchar();
  if (ch == EOF) {
    return false;
  }
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = s * 10 + ch - '0', ch = getchar();
  a = s * w;
  return true;
}

inline void write(int x) {
  if (x < 0)
    putchar('-'), x = -x;
  if (x > 9)
    write(x / 10);
  putchar(x % 10 + '0');
}

inline void writeln(int x) {
  if (x < 0)
    putchar('-'), x = -x;
  if (x > 9)
    write(x / 10);
  putchar(x % 10 + '0');
  puts("");
}

signed main() {
  int n = read();

  int ans = 0;

  for (register int i = 1; i < n; i++) {
    ans += n / i;
    if (n % i == 0)
      ans--;
  }

  writeln(ans);
  return 0;
}

Error: TLE

Fixed submission:

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

inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}

inline bool read(int &a) {
  int s = 0, w = 1;
  char ch = getchar();
  if (ch == EOF) {
    return false;
  }
  while (ch < '0' || ch > '9') {
    if (ch == '-')
      w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = s * 10 + ch - '0', ch = getchar();
  a = s * w;
  return true;
}

inline void write(int x) {
  if (x < 0)
    putchar('-'), x = -x;
  if (x > 9)
    write(x / 10);
  putchar(x % 10 + '0');
}

inline void writeln(int x) {
  if (x < 0)
    putchar('-'), x = -x;
  if (x > 9)
    write(x / 10);
  putchar(x % 10 + '0');
  puts("");
}

signed main() {
  int n = read();

  int ans = 0;

  for (register int i = 1; i <= n - 1; i++) {
    int now = n - i;
    for (register int j = 1; j * j <= now; j++) {
      if (now % j == 0 && now != j * j)
        ans += 2;
      else if (now % j == 0)
        ans++;
    }
  }

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

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

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  rep(i, 1, N) ans += (N - 1) / i;

  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

ll yaku(ll a) {
  ll ans = 0;
  ll tmp = sqrt(a);
  rep(i, 1, tmp + 1) {
    if (a % i == 0 && a / i == i)
      ans++;
    else if (a % i == 0)
      ans += 2;
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  rep(i, 1, N) { ans += yaku(i); }
  cout << ans << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

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

Error: TLE

Fixed submission:

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

#include <iostream>
using namespace std;

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

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (n % i == 0) {
      ans += n / i - 1;
    } else {
      ans += n / i;
    }
  }
  printf("%d\\n", ans);
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll num(int n) {
  ll coun = 2;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (i == sqrt(n) && n / i == i) {
        coun++;
      } else
        coun += 2;
    }
  }
  return coun;
}
int main() {

  int n;
  scanf("%d", &n);
  ll ans = 0;
  for (int i = 1; i < n; i++) {
    if (i == 1) {
      ans += 1;
      continue;
    }
    ans += num(i);
    // cout<<ans<<endl;
  }
  printf("%lld\\n", ans);
}
Problem p02548 (C++) — buggy submission, verdict: Runtime Error

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b) {
  ll ex = 1;
  rep(i, b) { ex *= a; }
  return ex;
}

ll fact(ll a) {
  ll fc = 1;
  REP(i, 1, a + 1) { fc *= i; }
  return fc;
}

int main() {
  ll n;
  cin >> n;
  ll cnt = 0;
  REP(a, 1, n) { cnt += (n - 1) / a; }
  cout << cnt << endl;
}

Error: -8

Fixed submission:

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

ll expo(ll a, ll b) {
  ll ex = 1;
  rep(i, b) { ex *= a; }
  return ex;
}

ll fact(ll a) {
  ll fc = 1;
  REP(i, 1, a + 1) { fc *= i; }
  return fc;
}

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

#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main() {
  int n, i, s, d, nr, nrtot;
  scanf("%d", &n);
  nrtot = 0;
  for (i = 1; i <= n - 1; i++) {
    s = n - i;
    d = 2;
    nr = 1;
    while (d * d <= s) {
      if (s % d == 0) {
        int tau = 1;
        while (s % d == 0) {
          tau++;
          s /= d;
        }
        nr *= tau;
      }
      d++;
    }
    if (s > 1)
      nr *= 2;
    nrtot += nr;
  }
  printf("%d", nrtot);

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main() {
  int n, nrtot, i, s, d, nr;
  scanf("%d", &n);
  nrtot = 0;
  for (i = 1; i <= n - 1; i++) {
    s = n - i;
    d = 1;
    nr = 0;
    while (d * d <= s) {
      if (s % d == 0 && d * d < s)
        nr += 2;
      else if (s % d == 0)
        nr++;
      d++;
    }
    nrtot += nr;
  }
  printf("%d", nrtot);

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

#include <bits/stdc++.h>
using namespace std;
#define endl '\\n'
#define deb(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef double dd;
const int MOD = 1e9 + 7;

int div(int n) {
  int cnt = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1, tt = 0;
  // cin >> t;
  while (t--) {
    // tt++;
    // cout << "Case #" << t << ": ";
    solve();
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define endl '\\n'
#define deb(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef double dd;
const int MOD = 1e9 + 7;

int div(int n) {
  int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1, tt = 0;
  // cin >> t;
  while (t--) {
    // tt++;
    // cout << "Case #" << t << ": ";
    solve();
  }
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Runtime Error

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

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

Error: -8

Fixed submission:

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

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