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

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <memory>    // unique_ptr, shared_ptr, weak_ptr
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector

using namespace std;

using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;

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

const int INF = 1 << 30;
const ll MOD = 1000000007;

int main() {
  long long N;
  int cnt = 0;
  cin >> N;

  for (auto i = 1; i <= N; i++) {
    for (auto j = 1; i * j <= N; j++) {
      long long c = N - i * j;
      if (c > 0)
        cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <memory>    // unique_ptr, shared_ptr, weak_ptr
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector

using namespace std;

using ll = long long int;
using vi = vector<int>;
using vvi = vector<vi>;

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

const int INF = 1 << 30;
const ll MOD = 1000000007;

int main() {
  int n, cnt = 0;
  cin >> n;

  // A*B+C == N
  for (int i = 1; i < n; i++) {
    for (int j = 1; j < n; i++) {
      if (i * j < n)
        cnt++;
    }
  }
  cout << cnt << endl;

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

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

vector<int> getDivisors(int n) {
  vector<int> res;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        res.push_back(i);
      } else {
        res.push_back(i);
        res.push_back(n / i);
      }
    }
  }
  return res;
}

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

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

Error: TLE

Fixed submission:

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

vector<int> getDivisors(int n) {
  vector<int> res;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        res.push_back(i);
      } else {
        res.push_back(i);
        res.push_back(n / i);
      }
    }
  }
  return res;
}

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

  int n, ans = 0;
  cin >> n;
  set<pair<pair<int, int>, int>> st;
  for (int i = 1; i <= n; i++) {
    int x = n - i;
    vector<int> vt = getDivisors(x);
    for (int j = 0; j < vt.size(); j++) {
      st.insert({{x / vt[j], vt[j]}, i});
    }
  }
  cout << st.size();
}
Problem p02548 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int MOD = 1e9 + 7;

int main() {
  int n, cnt = 0, 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;
  return 0;
}


Error: -8

Fixed submission:

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

int main() {
  int n, cnt = 0, ans = 0;
  cin >> n;
  fo(i, n) {
    if (n % i == 0)
      ans += (n / i) - 1;
    else
      ans += (n / i);
  }
  cout << ans;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
using namespace std;
int main() {
  long a, b, c, n;
  long i, j;
  unsigned long ans = 1;
  unsigned long tmp, tmp2;

  cin >> n;
  for (i = 2; i <= n - 1; i++) {
    tmp = 1;
    j = i;
    for (a = 2; a * a <= j; a++) {
      if (j % a == 0) {
        tmp2 = 1;
        while (j % a == 0) {
          j = j / a;
          tmp2++;
        }
        tmp *= tmp2;
      }
    }
    if (j == 1) {
      ans += tmp;
    } else {
      ans += (tmp * 2);
    }
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  long a, b, c, n;
  long i, j;
  unsigned long ans = 0;

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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pp pop_back
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define f0(i, a, n) for (i = a; i < n; i++)
#define f1(I, a, b) for (i = a; i <= b; i++)
#define stp setprecision
#define nl endl
#define ipt(a)                                                                 \\
  for (i = 0; i < n; i++)                                                      \\
    cin >> a[i];
#define pll pair<ll, ll>
#define vl vector<ll>
#define mp map<ll, ll>
int main() {
  fast;
  ll n, i, j;
  cin >> n;
  ll c = 0, s = 0;
  for (i = 1; i <= n - 1; i++) {
    if (n % i)
      s += n / i;
    else
      s += n / i - 1;
  }
  cout << s;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pp pop_back
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define f0(i, a, n) for (i = a; i < n; i++)
#define f1(I, a, b) for (i = a; i <= b; i++)
#define stp setprecision
#define nl endl
#define ipt(a)                                                                 \\
  for (i = 0; i < n; i++)                                                      \\
    cin >> a[i];
#define pll pair<ll, ll>
#define vl vector<ll>
#define mp map<ll, ll>
int main() {
  fast;
  ll n, i, j;
  cin >> n;
  ll c = 0, s = 0, d = 1;
  for (i = 1; i <= n - 1; i++) {
    ll k = n - i, d = 1, c = sqrt(k);
    ll f = k, x = 0;
    while (k % 2 == 0) {
      x++;
      k = k / 2;
    }
    d = d * (x + 1);
    x = 0;

    for (j = 3; k > 1 && j <= f; j += 2) // Checking for every prime number
    {
      x = 0;
      while (k % j == 0) {
        x++;
        k /= j;
      }
      d = d * (x + 1);
    }
    if (k > 2) {
      x++;
      d = d * (x + 1);
    }

    if (f == 1)
      s++;
    else if (k > 2)
      s += 2;

    else
      s += d;
  }
  cout << s;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
void solve() {
  int n;
  cin >> n;
  int spf[n + 1];
  for (int i = 0; i <= n; i++) {
    spf[i] = i;
  }
  for (int i = 2; i * i <= n; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j <= n; j += i) {
        if (spf[j] == j) {
          spf[j] = i;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    int x = n - i;
    int temp = 1;
    while (x != 1) {
      int z = x;
      int cnt = 0;
      while (z % spf[x] == 0) {
        cnt++;
        z /= spf[x];
      }
      x = z;
      temp *= (cnt + 1);
    }
    ans += temp;
  }
  cout << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
void solve() {
  int n;
  cin >> n;
  int spf[n + 1];
  for (int i = 0; i <= n; i++) {
    spf[i] = i;
  }
  for (int i = 2; i * i <= n; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j <= n; j += i) {
        if (spf[j] == j) {
          spf[j] = i;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    int x = n - i;
    for (int j = 1; j * j <= x; j++) {
      if (x % j == 0) {
        if (j != x / j)
          ans += 2;
        else {
          ans++;
        }
      }
    }
  }
  cout << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

// #pragma GCC oplmize(2)
//  #pragma GCC optimize("Ofast")
//  #pragma GCC target("avx,avx2,fma")
//  #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld", &x)
#define scs(x) scanf("%s", x + 1)
#define pr(x) printf("%lld\\n", x)
#define prs(x) printf("%s\\n", x)
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;
ll n, s, a[maxn];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  sc(n);
  for (int i = 1; i * i <= n; i++) {
    for (int j = i + 1; i * j <= n; j++) {
      a[i * j] += 2;
    }
    a[i * i] += 1;
  }
  while (n--) {
    s += a[n];
  }
  pr(s);
  return 0;
}

Error: TLE

Fixed submission:

// #pragma GCC oplmize(2)
//  #pragma GCC optimize("Ofast")
//  #pragma GCC target("avx,avx2,fma")
//  #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld", &x)
#define scs(x) scanf("%s", x + 1)
#define pr(x) printf("%lld\\n", x)
#define prs(x) printf("%s\\n", x)
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-8;
ll n, s, a[maxn];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  sc(n);
  for (int i = 1; i <= n; i++) {
    s = 0;
    for (int j = 1; j <= sqrt(i); j++) {
      if (i % j == 0) {
        if (i / j == j)
          s++;
        else
          s += 2;
      }
    }
    a[i] = a[i - 1] + s;
  }
  pr(a[n - 1]);
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define endl "\\n"
typedef long long ll;
#define mx 1000011
int dp[mx];
void solve() {

  int n;
  cin >> n;
  for (int i = 2; i < mx; i++) {
    if (!dp[i]) {
      for (int j = i; j < mx; j += i)
        dp[j] = i;
    }
  }
  int ans = 1;

  for (int i = 2; i <= n - 1; i++) {
    int x = i;
    map<int, int> mp;
    while (x != dp[x]) {
      int f = dp[x];
      mp[f] += 1;
      x /= dp[x];
    }
    mp[x] += 1;
    map<int, int>::iterator it = mp.begin();
    int res = 1;
    for (; it != mp.end(); it++) {
      int r = it->second;
      res *= (r + 1);
    }
    ans += res;
  }
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define endl "\\n"
typedef long long ll;
int find(int n) {
  int ans = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans++;
      if (n / i != i)
        ans++;
    }
  }
  return ans;
}
void solve() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n - 1; i++) {
    int x = n - i;
    ans += find(x);
  }
  cout << ans << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1000000007;

ll return_ans(ll x);

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

  cout << ans;
  return 0;
}

ll return_ans(ll x) {
  ll count = 1;
  for (ll i = 2; i * i <= x; ++i) {
    if (x % i != 0)
      continue;
    ll ex = 0;
    while (x % i == 0) {
      ++ex;
      x /= i;
    }
    if (ex != 0) {
      count *= (ex + 1);
    }
  }
  if (x != 1)
    count *= 2;
  return count;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
const int INF = 1000000007;

ll return_ans(ll x);

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i, n - 1) { ans += return_ans(i + 1); }

  cout << ans;
  return 0;
}

ll return_ans(ll x) {
  ll count = 0;
  for (ll i = 1; i * i <= x; ++i) {
    if (x % i == 0) {
      if (x / i == i) {
        count += 1;
      } else {
        count += 2;
      }
    }
  }
  return count;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

vector<int> divisor(int n) {
  vector<int> v;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        v.push_back(i);
      else {
        v.push_back(i);
        v.push_back(n / i);
      }
    }
  }
  return v;
}

int main() {
  int a, b, i, j, n, t;
  cin >> n;
  vector<int> v;
  int count = 0;
  v = divisor(n);
  for (i = 1; i <= n; i++) {
    count += n / i;
  }
  count -= v.size();
  cout << count - 2;
}

Error: TLE

Fixed submission:

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

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

#include <bits/stdc++.h>
using namespace std;
int n, ans, nn, ans1;
signed main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n && (i * j) < n; j++) {
      ans++;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int n, a[50005], b[50005], ans, nn, ans1;
signed main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    nn = n - i;
    for (int j = 1; j <= sqrt(nn); j++) {
      if (nn % j == 0) {
        if (j != sqrt(nn))
          ans++;
        else
          ans1++;
      }
    }
  }
  cout << ans * 2 + ans1 << endl;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define rep2(x, fr, to) for (int x = (fr); x < (to); x++)
#define rep(x, to) for (int x = 0; x < (to); x++)
#define repr(x, fr, to) for (int x = (fr); x >= (to); x--)
#define all(c) c.begin(), c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<ll> VL;
const int MD = 1e9 + 7;
void dbg() { cerr << "\\n"; }
template <class F, class... S> void dbg(const F &f, const S &...s) {
  cerr << f << ": ";
  dbg(s...);
}

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

  VI ys(1100000);

  for (ll j = 1; j <= n; j++) {
    rep2(i, 1, n) {
      if (j * i > n)
        break;
      ys[i * j]++;
    }
  }
  ll ans = 0;
  rep2(i, 1, n) {
    int su = n - i;
    ll sm = ys[su];
    ans += sm;
  }
  cout << ans << "\\n";

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define rep2(x, fr, to) for (int x = (fr); x < (to); x++)
#define rep(x, to) for (int x = 0; x < (to); x++)
#define repr(x, fr, to) for (int x = (fr); x >= (to); x--)
#define all(c) c.begin(), c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<ll> VL;
const int MD = 1e9 + 7;
void dbg() { cerr << "\\n"; }
template <class F, class... S> void dbg(const F &f, const S &...s) {
  cerr << f << ": ";
  dbg(s...);
}

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

  ll ans = 0;
  rep2(i, 1, n) {
    int su = n - i;
    for (ll j = 1; j * j <= su; j++) {
      ll sm = 0;
      if (su % j == 0) {
        if (j * j == su)
          sm++;
        else
          sm += 2;
      }
      ans += sm;
      // dbg(i, sm, ans);
    }
  }
  cout << ans << "\\n";

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

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

int main() {
  long n;
  cin >> n;
  long a = 1, b = 1, c = 1;
  long long ans = 0;
  while (a < n) {
    while (b < n) {
      if (a * b < n) {
        // cout << a << " : " << b << endl;
        ans++;
      } else {
        break;
      }
      b++;
    }
    a++;
    b = 1;
  }
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
vector<long long> primeNumbers;
vector<long long> primeCounts;
long long ans = 0;
bool isPrime(long long n) {
  // cout << n << endl;
  if (n == 0)
    return false;
  if (n == 1)
    return false;
  if (n == 2)
    return true;
  double sq = sqrt(n);
  for (long long i = 2; i <= sq; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
void getPrimeNumbers(long long n) {
  if (isPrime(n)) {
    primeNumbers.push_back(n);
  }
  if (n > 1) {
    getPrimeNumbers(n - 1);
  }

  // cout << "getPrimeNumbers" << endl;
  // cout << n << endl;
  // if(isPrime(n)){
  // primeNumbers.push_back(n);
  // return;
  //}
  // double sq = sqrt(n);
  // if(n==1){
  // return;
  //}
  // for(long long i = 2; i<=sq; i++ ){
  // if(n%i==0){
  ////cout << n << endl;
  // if(isPrime(i))primeNumbers.push_back(i);
  // getPrimeNumbers(n/i);
  // break;
  //}
  //}
}
long getFactorizeNum(long value) {
  long ans = 0;
  for (long i = 0; i < primeNumbers.size(); i++) {
    while (true) {
      if (value % primeNumbers[i] == 0) {
        value /= primeNumbers[i];
        ans++;
      } else {
        break;
      }
    }
    if (value == 1) {
      break;
    }
  }
  return ans;
}

int main() {
  long n;
  cin >> n;
  getPrimeNumbers(n);
  long a = 1, b = 1, c = 1; // every number > 0
  long long ans = 0;
  vector<long> dp(n + 1, -1);
  dp[1] = 1;
  for (long i = 0; i < primeNumbers.size(); i++) {
    // cout << primeNumbers[i] << endl;
    dp[primeNumbers[i]] = 2;
    for (long j = 2; j < n; j++) {
      long tmp = pow(primeNumbers[i], j);
      if (tmp <= n) {
        dp[tmp] = j + 1;
      } else {
        break;
      }
    }
  }
  while (c < n) {
    long tmp = n - (n - c);
    long oldAns = ans;
    if (dp[tmp] == -1) {
      // not prime number
      // ans+=getFactorizeNum(tmp)+1;
      while (a <= tmp) {
        if (tmp % a == 0) {
          if (tmp / a == a) {
            ans++;
          } else if ((tmp / a) > a) {
            ans++;
            ans++;
          } else {
            break;
          }
        }
        a++;
      }
    } else {
      ans += dp[tmp];
    }
    // cout << tmp << " : ";
    // cout << ans-oldAns << endl;
    a = 1;
    c++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02548 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
  int n;
  cin >> n;
  long long count = 0;
  for (int a = 1; a <= n - 1; a++) {
    count += (n - 1) / a;
  }

  cout << count << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
  int n;
  cin >> n;
  long long count = 0;
  for (int c = 1; c <= n - 1; c++) {
    for (int a = 1; a <= sqrt(n - c); a++) {
      if ((n - c) % a == 0 && a != sqrt(n - c))
        count += 2;
      else if ((n - c) % a == 0 && a == sqrt(n - c))
        count++;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repl(i, l, r) for (int i = l; i < r; i++)
using ll = long long;
const int inf = 2e9 + 10;
const ll MOD = 1e9 + 7;
const ll INF = 9e18 + 10;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

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: -8

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repl(i, l, r) for (int i = l; i < r; i++)
using ll = long long;
const int inf = 2e9 + 10;
const ll MOD = 1e9 + 7;
const ll INF = 9e18 + 10;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main() {
  int n, x, m;
  cin >> n >> x >> m;
  int t = (x * x) % m;
  ll sum = 0;
  set<int> l;
  l.insert(x);
  while (l.find(t) != l.end()) {
    l.insert(t);
    t = (t * t) % m;
  }

  set<int>::iterator it;
  int ff = 0;
  for (it = l.find(t); it != l.end(); it++) {
    ff++;
    sum += *it;
  }
  ll ans = 0;
  int dd = 0;
  for (it = l.begin(); it != l.find(t); it++) {
    ans += *it;
    dd++;
  }
  int kk = n - dd;

  int si = kk / ff;
  ans += (si * sum);
  int cnt = 0;
  for (it = l.find(t); cnt < si; it++) {
    ans += *it;
    cnt++;
  }
  cout << ans << endl;

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

#include <cmath>
#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int N;
  int count = 0;
  int a;
  cin >> N;
  for (int c = 1; c < N; c++) {
    for (a = 1; a * a < N - c; a++) {
      if ((N - c) % a == 0) {
        count += 2;
      }
    }
    if (a * a == N - c) {
      count++;
    }
  }
  cout << count << endl;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int N;
  int count = 0;
  cin >> N;
  for (int c = 1; c < N; c++) {
    for (int a = 1; a < N - c + 1; a++) {
      if ((N - c) % a == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
}