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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#pragma GCC optimize(2) // 手动O2开关
using namespace std;
const int maxn = 30;
typedef long long ll;

int x[maxn], y[maxn], r[maxn], d[maxn], dd[maxn], cun[maxn];
ll ans[maxn];
int cnt;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &x[i], &y[i], &r[i]);
    d[i] = min(abs(x[i]), abs(y[i]));
  }
  memset(ans, 0x3f, sizeof(ans));
  for (int i = 0; i < (1 << n); i++) {
    int now = i;
    cnt = 0;
    for (int j = 0; j < 15; j++) {
      if ((now >> j) & 1)
        cun[++cnt] = j + 1;
    }
    for (int j = 0; j < (1 << cnt); j++) {
      ll ans_ = 0;
      memcpy(dd, d, sizeof(dd));
      for (int k = 0; k < cnt; k++) {
        if ((j >> k) & 1) {
          for (int e = 1; e <= n; e++) {
            dd[e] = min(dd[e], abs(x[e] - x[cun[k + 1]]));
          }
        } else {
          for (int e = 1; e <= n; e++) {
            dd[e] = min(dd[e], abs(y[e] - y[cun[k + 1]]));
          }
        }
      }
      for (int i = 1; i <= n; i++) {
        ans_ += 1ll * dd[i] * r[i];
      }
      ans[cnt] = min(ans[cnt], ans_);
    }
  }
  for (int i = 0; i <= n; i++) {
    printf("%lld\n", ans[i]);
  }
}

Fixed submission:
#include <bits/stdc++.h>
#pragma GCC optimize(2) // 手动O2开关
using namespace std;
const int maxn = 17;
typedef long long ll;

int x[maxn], y[maxn], r[maxn], d[maxn], dd[maxn], cun[maxn];
ll ans[maxn];
int cnt;

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &x[i], &y[i], &r[i]);
    d[i] = min(abs(x[i]), abs(y[i]));
  }
  memset(ans, 0x3f, sizeof(ans));
  for (int i = 0; i < (1 << n); i++) {
    int now = i;
    cnt = 0;
    for (int j = 0; j < 15; j++) {
      if ((now >> j) & 1)
        cun[++cnt] = j + 1;
    }
    for (int j = 0; j < (1 << cnt); j++) {
      ll ans_ = 0;
      memcpy(dd, d, sizeof(dd));
      for (int k = 0; k < cnt; k++) {
        if ((j >> k) & 1) {
          for (int e = 1; e <= n; e++) {
            dd[e] = min(dd[e], abs(x[e] - x[cun[k + 1]]));
          }
        } else {
          for (int e = 1; e <= n; e++) {
            dd[e] = min(dd[e], abs(y[e] - y[cun[k + 1]]));
          }
        }
      }
      for (int i = 1; i <= n; i++) {
        ans_ += 1ll * dd[i] * r[i];
      }
      ans[cnt] = min(ans[cnt], ans_);
    }
  }
  for (int i = 0; i <= n; i++) {
    printf("%lld\n", ans[i]);
  }
}
Problem p02604 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
short x[16], y[16];
int p[16];
long long ans[16];
short mi[16], m1[16];
short px[16][16], py[16][16];
int ppk, st;
short cnt, now;
int main(void) {

  char n;
  scanf("%hd", &n);
  for (char i = 0; i < n; i++)
    scanf("%hd%hd%d", &x[i], &y[i], &p[i]);
  int ma = 1;
  for (char i = 0; i <= n; ++i)
    ans[i] = 1000000000000000;
  for (char i = 0; i < n; ++i)
    ma *= 3;
  for (char i = 0; i < n; ++i) {
    short x1 = x[i] > 0 ? x[i] : -x[i], y1 = y[i] > 0 ? y[i] : -y[i];
    m1[i] = x1 > y1 ? y1 : x1;
  }
  for (char i = 0; i < n; ++i) {
    for (char j = 0; j < n; ++j) {
      px[i][j] = x[i] - x[j];
      py[i][j] = y[i] - y[j];
      if (px[i][j] < 0)
        px[i][j] = -px[i][j];
      if (py[i][j] < 0)
        py[i][j] = -py[i][j];
    }
  }
  for (int zhu = 0; zhu < ma; ++zhu) {
    ppk = zhu, cnt = n, st = ma / 3;
    for (char i = 0; i < n; i++)
      mi[i] = m1[i];
    for (char i = 0; i < n; i++, st /= 3) {
      now = ppk / st;
      switch (now) {
      case 2:
        for (char j = 0; j < n; ++j)
          if (mi[j] > px[i][j])
            mi[j] = px[i][j];
        break;
      case 1:
        for (char j = 0; j < n; ++j)
          if (mi[j] > py[i][j])
            mi[j] = py[i][j];
        break;
      case 0:
        cnt--;
      }
      ppk -= st * now;
    }
    long long sum = 0;
    for (char i = 0; i < n; ++i)
      sum += (long long)mi[i] * p[i];
    if (ans[cnt] > sum)
      ans[cnt] = sum;
  }
  for (char i = 0; i <= n; i++)
    printf("%lld\n", ans[i]);
}


Fixed submission:
#include <stdio.h>
#pragma GCC optimize(2)
short x[16], y[16];
int p[16];
long long ans[16];
short mi[16], m1[16];
short px[16][16], py[16][16];
int ppk, st;
short cnt, now;
int main(void) {

  char n;
  scanf("%hd", &n);
  for (char i = 0; i < n; i++)
    scanf("%hd%hd%d", &x[i], &y[i], &p[i]);
  int ma = 1;
  for (char i = 0; i <= n; ++i)
    ans[i] = 1000000000000000;
  for (char i = 0; i < n; ++i)
    ma *= 3;
  for (char i = 0; i < n; ++i) {
    short x1 = x[i] > 0 ? x[i] : -x[i], y1 = y[i] > 0 ? y[i] : -y[i];
    m1[i] = x1 > y1 ? y1 : x1;
  }
  for (char i = 0; i < n; ++i) {
    for (char j = 0; j < n; ++j) {
      px[i][j] = x[i] - x[j];
      py[i][j] = y[i] - y[j];
      if (px[i][j] < 0)
        px[i][j] = -px[i][j];
      if (py[i][j] < 0)
        py[i][j] = -py[i][j];
    }
  }
  for (int zhu = 0; zhu < ma; ++zhu) {
    ppk = zhu, cnt = n, st = ma / 3;
    for (char i = 0; i < n; i++)
      mi[i] = m1[i];
    for (char i = 0; i < n; i++, st /= 3) {
      now = ppk / st;
      switch (now) {
      case 2:
        for (char j = 0; j < n; ++j)
          if (mi[j] > px[i][j])
            mi[j] = px[i][j];
        break;
      case 1:
        for (char j = 0; j < n; ++j)
          if (mi[j] > py[i][j])
            mi[j] = py[i][j];
        break;
      case 0:
        cnt--;
      }
      ppk -= st * now;
    }
    long long sum = 0;
    for (char i = 0; i < n; ++i)
      sum += (long long)mi[i] * p[i];
    if (ans[cnt] > sum)
      ans[cnt] = sum;
  }
  for (char i = 0; i <= n; i++)
    printf("%lld\n", ans[i]);
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll, ll>
#define ALL(a) a.begin(), a.end()
#define YESNO(i) puts((i) ? "YES" : "NO");
#define YesNo(i) puts((i) ? "Yes" : "No");
#define yesno(i) puts((i) ? "yes" : "no");
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll l, r, d, ans = 0;
  for (ll i = l; i <= r; i++) {
    if (i % d == 0)
      ans++;
  }
  print(ans);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll, ll>
#define ALL(a) a.begin(), a.end()
#define YESNO(i) puts((i) ? "YES" : "NO");
#define YesNo(i) puts((i) ? "Yes" : "No");
#define yesno(i) puts((i) ? "yes" : "no");
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll l, r, d, ans = 0;
  cin >> l >> r >> d;
  for (ll i = l; i <= r; i++) {
    if (i % d == 0)
      ans++;
  }
  print(ans);
  return 0;
}
Problem p02606 (C++)

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

int main() {
  // your code goes here
  int l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  while (l <= r) {
    if (l % d == 0)
      cnt++;
  }
  cout << cnt;
  return 0;
}

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

int main() {
  // your code goes here
  int l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  while (l <= r) {
    if (l % d == 0)
      cnt++;
    l++;
  }
  cout << cnt;
  return 0;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, d;
  cin >> l, r, d;
  cout << r / d - l / d << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, d;
  cin >> l >> r >> d;
  cout << r / d - (l - 1) / d << endl;
}
Problem p02606 (C++)

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

using namespace std;
#define IO                                                                     \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);
typedef long long ll;
long long N = 1e+5;

int solve() {
  int a, b, c;
  cin >> a >> b >> c;
  int cnt = 0;
  for (int i = a; i <= b; i++) {
    if (i % c == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

int main() {
  IO;

  solve();
  return 0;
}


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

using namespace std;
#define IO                                                                     \
  ios::sync_with_stdio(false);                                                 \
  cin.tie(0);                                                                  \
  cout.tie(0);
typedef long long ll;
long long N = 1e+5;

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  int cnt = 0;
  for (int i = a; i <= b; i++) {
    if (i % c == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

int main() {
  IO;

  solve();
  return 0;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
// #include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll INF = 1e9;
const ll LINF = ll(1e18);
const ll MOD = 1000000007;
const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1},
         Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)                                                               \
  cout << #v << ":";                                                           \
  for (auto x : v) {                                                           \
    cout << x << ' ';                                                          \
  }                                                                            \
  cout << endl;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
// cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  int ans = 0;
  for (int i = a; i <= b; i++) {
    if (i % c == 0)
      ans++;
  }
  cout << ans << "\n";
}


Fixed submission:
// #include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll INF = 1e9;
const ll LINF = ll(1e18);
const ll MOD = 1000000007;
const ll dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const ll Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1},
         Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)                                                               \
  cout << #v << ":";                                                           \
  for (auto x : v) {                                                           \
    cout << x << ' ';                                                          \
  }                                                                            \
  cout << endl;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
// cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for (int i = a; i <= b; i++) {
    if (i % c == 0)
      ans++;
  }
  cout << ans << "\n";
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll l, r, d, cnt = 0;
  cin >> l >> r;

  for (ll i = l; i <= r; i++) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll l, r, d, cnt = 0;
  cin >> l >> r >> d;

  for (ll i = l; i <= r; i++) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll l, r, d, cnt = 0;
  cin >> l >> r;

  if (l % d == 0 || r % d == 0)
    cnt++;
  cnt += ((r - l) / d);

  cout << cnt << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll l, r, d, cnt = 0;
  cin >> l >> r >> d;

  if (l % d == 0 || r % d == 0)
    cnt++;
  cnt += ((r - l) / d);

  cout << cnt << endl;

  return 0;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):

#include <cstdint>
#include <iostream>
#include <string>

int main(int argc, char *argv[]) {
  const int32_t L = std::atoi(argv[1]);
  const int32_t R = std::atoi(argv[2]);
  const int32_t d = std::atoi(argv[3]);
  std::cout << (R - L) / d << std::endl;
  return 0;
}


Fixed submission:

#include <cstdint>
#include <iostream>
#include <string>

int main(int argc, char *argv[]) {
  int32_t L, R, d;
  std::cin >> L;
  std::cin >> R;
  std::cin >> d;
  int cnt = 0;
  for (int i = L; i <= R; ++i) {
    cnt += (i % d == 0) ? 1 : 0;
  }

  std::cout << cnt << std::endl;
  return 0;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < N; i++)
typedef long long ll;
#define dump(x) cerr << #x << "=" << x << endl
using P = pair<int, int>;

int main() {
  int l, r, d;
  cin >> l >> r, d;
  int cnt = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < N; i++)
typedef long long ll;
#define dump(x) cerr << #x << "=" << x << endl
using P = pair<int, int>;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  long long l, r, d;
  l--;
  long long ans = 0;
  ans += r / d;
  ans -= l / d;
  cout << ans << endl;
}

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

using namespace std;

int main() {
  long long l, r, d;
  cin >> l >> r >> d;
  l--;
  long long ans = 0;
  ans += r / d;
  ans -= l / d;
  cout << ans << endl;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {
  int x, y, z;
  cin >> x >> y;
  int cntr = 0;
  for (int i = x; i <= y; i++) {
    if (i % z == 0)
      cntr++;
  }
  cout << cntr;
}


Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int cntr = 0;
  for (int i = x; i <= y; i++) {
    if (i % z == 0)
      cntr++;
  }
  cout << cntr;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int L, R, d;
  int ans = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int ans = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans << endl;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, d;
  int sum = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int sum = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define loop(i, x, z) for (int i = x; i < z; i++)
int cnt = 0, l, r, d;
int main() {
  cin >> l >> r;
  loop(i, l, r + 1) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define loop(i, x, z) for (int i = x; i < z; i++)
int cnt = 0, l, r, d;
int main() {
  cin >> l >> r >> d;
  loop(i, l, r + 1) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n; i >= 0; --i)
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
const ll big = 1e18;
const double PI = 2 * asin(1);

int main() {
  int L, R, D;
  int ans = 0;
  for (int i = L; i <= R; ++i) {
    if (i % D == 0)
      ans++;
  }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n; i >= 0; --i)
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
const ll big = 1e18;
const double PI = 2 * asin(1);

int main() {
  int L, R, D;
  cin >> L >> R >> D;
  int ans = 0;
  for (int i = L; i <= R; ++i) {
    if (i % D == 0)
      ans++;
  }
  cout << ans << endl;
}
Problem p02606 (C++)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, a, b) for (int i = (a); i <= (b); i++)
#define repA(i, n) for (int i = n; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9 + 7); // 998244353;
const int N = (int)(1e6 + 5);

void pre() {}

void solve() {
  ll l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  repi(i, l, r) if (i % d == 0) cnt++;
  cout << cnt;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  //  freopen("output.txt","w",stdout);
#endif
  int t = 1;
  pre();
  cin >> t;
  rep(i, t) {
    //    cout<<"\nCase #"<<(i+1)<<"\n";
    solve();
    cout << '\n';
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, a, b) for (int i = (a); i <= (b); i++)
#define repA(i, n) for (int i = n; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9 + 7); // 998244353;
const int N = (int)(1e6 + 5);

void pre() {}

void solve() {
  ll l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  repi(i, l, r) if (i % d == 0) cnt++;
  cout << cnt;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  //  freopen("output.txt","w",stdout);
#endif
  int t = 1;
  pre();
  // cin>>t;
  rep(i, t) {
    //    cout<<"\nCase #"<<(i+1)<<"\n";
    solve();
    cout << '\n';
  }
  return 0;
}
Problem p02606 (C++)

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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i = i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans;
}

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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  cout << r / d - (l - 1) / d;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int L, R, d;
  int ans = 0;
  for (int i = L; i <= R; ++i)
    if (i % d == 0)
      ans++;
  cout << ans << "\n";
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int ans = 0;
  for (int i = L; i <= R; ++i)
    if (i % d == 0)
      ans++;
  cout << ans << "\n";
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int l, r, d;
  int ans = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans;
}

Fixed submission:
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int l, r, d;
  int ans = 0;
  cin >> l >> r >> d;
  for (int i = l; i <= r; i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

using namespace std;

int main() {
  int L, R, d;
  cout << R / d - (L - 1) / d;
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int L, R, d;
  cin >> L >> R >> d;
  cout << R / d - (L - 1) / d;
  return 0;
}
Problem p02606 (C++)

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

using namespace std;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; l <= r; ++i) {
    if (i % d == 0)
      ans++;
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; ++i) {
    if (i % d == 0)
      ans++;
  }
  cout << ans << '\n';
  return 0;
}
Problem p02606 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
/*
 *    coder :: ATUL_PANDEY_2608
 *        >>> INDIA <<<
 */
using namespace std;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define maxx 200006
#define ll long long
#define quick ios_base::sync_with_stdio(NULL), cin.tie(0);
#define listll vector<long long>
#define listi vector<int>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define minheap priority_queue<long long, vector<long long>, greater<long long>>
#define rep(i, a, b) for (int i = a; i < b; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

// end of #define

// define globals ...

// write function from here ...

int Main() {

  int a, b, d;
  cin >> a >> b >> d;

  int ans = 0;

  ans -= a / d;
  ans += b / d;
  if (a % d == 0)
    ans++;

  cout << ans;
}

int main() {
  quick;

  //      #ifndef ONLINE_JUDGE
  //   freopen ("input.txt", "r", stdin);
  //   freopen ("outt.txt", "w", stdout);
  // #endif

  Main();

  return 0;
}

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

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define maxx 200006
#define ll long long
#define quick ios_base::sync_with_stdio(NULL), cin.tie(0);
#define listll vector<long long>
#define listi vector<int>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define minheap priority_queue<long long, vector<long long>, greater<long long>>
#define rep(i, a, b) for (int i = a; i < b; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

// end of #define

// define globals ...

// write function from here ...

int Main() {

  int a, b, d;
  cin >> a >> b >> d;

  int ans = 0;

  ans -= a / d;
  ans += b / d;
  if (a % d == 0)
    ans++;

  cout << ans;

  return 0;
}

int main() {
  quick;

  //      #ifndef ONLINE_JUDGE
  //   freopen ("input.txt", "r", stdin);
  //   freopen ("outt.txt", "w", stdout);
  // #endif

  Main();

  return 0;
}
Problem p02607 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int i, n;
  cin >> n;
  int a[i], c = 0;
  for (i = 0; i < n; i++)
    cin >> a[i];
  for (i = 0; i < n; i++) {
    if (i % 2 == 0 && a[i] % 2 != 0)
      c++;
  }
  cout << c << endl;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int i, n;
  cin >> n;
  int a[n], c = 0;
  for (i = 0; i < n; i++)
    cin >> a[i];
  for (i = 0; i < n; i++) {
    if (i % 2 == 0 && a[i] % 2 != 0)
      c++;
  }
  cout << c << endl;
}
Problem p02607 (C++)

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

int main() {
  int N, n = 0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for (int i = 1; i <= N; i++) {
    if (i % 2 != 0 && a.at(i) % 2 != 0)
      n++;
  }
  cout << n;
  return 0;
}

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

int main() {
  int N, n = 0;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  for (int i = 1; i <= N; i++) {
    if (i % 2 != 0 && a.at(i - 1) % 2 != 0)
      n++;
  }
  cout << n;
  return 0;
}
Problem p02607 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define mod 998244353
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  LL N;
  cin >> N;
  LL x;
  LL count = 0;
  x = 1;
  while (x <= N) {
    LL y;
    cin >> y;
    if (x % 2 and y % 2)
      count++;
    x++;
  }
  cout << count;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define mod 998244353
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  LL N;
  cin >> N;
  LL x;
  LL count = 0;
  x = 1;
  while (x <= N) {
    LL y;
    cin >> y;
    if (x % 2 and y % 2)
      count++;
    x++;
  }
  cout << count;
}
Problem p02607 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  int count = 0;
  int M;
  if (N % 2 == 0) {
    M == N / 2;
  } else if (!(N % 2 == 0)) {
    M == N / 2 + 1;
  }
  if (N % 2 == 0) {
    for (int i = 0; i <= N / 2; i++) {
      if (!(a.at(2 * i) % 2 == 0)) {
        count++;
      }
    }
  } else if (!(N % 2 == 0)) {
    for (int i = 0; i <= (N - 1) / 2; i++) {
      if (!(a.at(i * 2) % 2 == 0)) {
        count++;
      }
    }
  }
  cout << count << endl;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  int count = 0;
  int M;
  if (N % 2 == 0) {
    M == N / 2;
  } else if (!(N % 2 == 0)) {
    M == N / 2 + 1;
  }
  if (N % 2 == 0) {
    for (int i = 0; i < N / 2; i++) {
      if (!(a.at(2 * i) % 2 == 0)) {
        count++;
      }
    }
  } else if (!(N % 2 == 0)) {
    for (int i = 0; i <= (N - 1) / 2; i++) {
      if (!(a.at(i * 2) % 2 == 0)) {
        count++;
      }
    }
  }
  cout << count << endl;
}
Problem p02607 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  int count = 0;
  for (int i = 1; i < N + 1; i++) {
    cin >> a.at(i);
    if (i % 2 == 1 && a.at(i) % 2 == 1)
      count++;
  }

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

Fixed submission:
#include <bits/stdc++.h>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<int> a(N + 1);
  int count = 0;
  for (int i = 1; i < N + 1; i++) {
    cin >> a.at(i);
    if (i % 2 == 1 && a.at(i) % 2 == 1)
      count++;
  }

  cout << count << endl;
  return 0;
}
Problem p02607 (C++)

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

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

  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if ((i % 2 == 1) && (vec.at(i) % 2 == 1))
      ans++;
  }
  cout << ans;
}


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

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

  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (((i + 1) % 2 == 1) && (vec.at(i) % 2 == 1))
      ans++;
  }
  cout << ans;
}
Problem p02607 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
res = 0
for i in range(1, n + 1, 2):
    if a[i] % 2 != 0:
        res += 1

print(res)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
res = 0
for i in range(0, n, 2):
    if a[i] % 2 != 0:
        res += 1

print(res)
Problem p02607 (C++)

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

int main() {
  int n, c;
  c = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < n; i + 2) {
    if (vec.at(i) % 2 == 1) {
      c++;
    }
  }
  cout << c << endl;
}

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

int main() {
  int n, c;
  c = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < n; i++) {
    if (i % 2 == 1) {
      continue;
    }
    if (vec.at(i) % 2 == 1) {
      c++;
    }
  }
  cout << c << endl;
}
Problem p02607 (C++)

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

int main() {
  int N, cnt = 0;
  cin >> N;
  vector<int> N_a(N);
  for (int i = 0; i < N; i++) {
    cin >> N_a.at(i);
  }
  for (int i = 0; N; i++) {
    if ((i + 1) % 2 == 1 && N_a.at(i) % 2 == 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

int main() {
  int N, cnt = 0;
  cin >> N;
  vector<int> N_a(N);
  for (int i = 0; i < N; i++) {
    cin >> N_a.at(i);
  }
  for (int i = 0; i < N; i++) {
    if ((i + 1) % 2 == 1 && N_a.at(i) % 2 == 1) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p02607 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

  for (auto &x : a) {
    cin >> x;
  }

  int t = n;
  if (t % 2 == 1) {
    t--;
  }

  int ans = 0;

  for (int i = 0; i <= t; i += 2) {
    if (a.at(i) % 2 == 1) {
      ans++;
    }
  }

  cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);

  for (auto &x : a) {
    cin >> x;
  }

  int t = n - 1;

  int ans = 0;

  for (int i = 0; i <= t; i += 2) {
    if (a.at(i) % 2 == 1) {
      ans++;
    }
  }

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

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

int main() {
  int N = 0;
  int count = 0;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  for (int i = 0; i < data.size(); i++) {
    if (data.at(2 * i) % 2 == 0)
      count++;
  }
  cout << count << endl;
  return 0;
}


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

int main() {
  int N = 0;
  int count = 0;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  for (int i = 0; i < data.size(); i += 2) {
    if (data.at(i) % 2 != 0)
      count++;
  }
  cout << count << endl;
  return 0;
}
Problem p02607 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  int N;
  cin >> N;
  vi a(N);
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1 && i % 2 == 1)
      ans++;
  }

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  int N;
  cin >> N;
  vi a(N + 1);
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1 && i % 2 == 1)
      ans++;
  }

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, ans;
  cin >> N;
  ans = 0;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(N);
  }
  if (N % 2 == 0) {
    for (int j = 0; j < N / 2; j++) {
      if (a.at(2 * j) % 2 == 1) {
        ans = ans + 1;
      }
    }
  } else {
    for (int k = 0; k < (N + 1) / 2; k++) {
      if (a.at(2 * k) % 2 == 1) {
        ans = ans + 1;
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
  int N, ans;
  cin >> N;
  ans = 0;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  if (N % 2 == 0) {
    for (int j = 0; j < N / 2; j++) {
      if (a.at(2 * j) % 2 == 1) {
        ans = ans + 1;
      }
    }
  } else {
    for (int k = 0; k < (N + 1) / 2; k++) {
      if (a.at(2 * k) % 2 == 1) {
        ans = ans + 1;
      }
    }
  }
  cout << ans << endl;
}
Problem p02607 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
li = []
for i in input().split():
    li.append(int(i))

a = 1
count = 0
for i in li:
    if a % 2 == 1 and li % 2 == 1:
        count += 1
    a += 1
print(count)


Fixed submission:
N = int(input())
li = []
for i in input().split():
    li.append(int(i))

a = 1
count = 0
for i in li:
    if a % 2 == 1 and i % 2 == 1:
        count += 1
    a += 1
print(count)
Problem p02608 (C++)

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

#define DEBUG 0

int main() {

  int N;

  cin >> N;

  vector<int> counter_n(N + 1, 0);

  for (int num = 1; num < N + 1; num++) {

    for (int i = 1; i < (int)sqrt(num) * 2; i++) {
      for (int j = i; j < (int)sqrt(num) * 2; j++) {
        for (int k = j; k < (int)sqrt(num) * 2; k++) {
          if (i * i + j * j + k * k == 2 * num) {
#if DEBUG
            cout << i << j << k << num << endl;
#endif

            int x2 = i + j - k;
            int y2 = i - j + k;
            int z2 = -i + j + k;

            if ((x2 > 0) && !(x2 & 1) && (y2 > 0) && !(y2 & 1) && (z2 > 0) &&
                !(z2 & 1)) {
              if ((x2 == y2) && (y2 == z2)) {
                counter_n.at(num)++;
              } else if ((x2 != y2) && (x2 != z2) && (y2 != z2)) {
                counter_n.at(num) += 6;
              } else {
                counter_n.at(num) += 3;
              }
            }
          }
        }
      }
    }
  }

  for (int i = 1; i < N + 1; i++) {
    cout << counter_n.at(i) << endl;
  }

  return 0;
}


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

#define DEBUG 0

int main() {

  int N;

  cin >> N;

  vector<int> counter_n(N + 1, 0);

  for (int num = 1; num < N + 1; num++) {

    for (int i = 1; i < (int)(sqrt(num) * 1.4); i++) {
      for (int j = i; j < (int)(sqrt(num) * 1.4); j++) {
        for (int k = j; k < (int)(sqrt(num) * 1.4); k++) {
          if (i * i + j * j + k * k == 2 * num) {
#if DEBUG
            cout << i << j << k << num << endl;
#endif

            int x2 = i + j - k;
            int y2 = i - j + k;
            int z2 = -i + j + k;

            if ((x2 > 0) && !(x2 & 1) && (y2 > 0) && !(y2 & 1) && (z2 > 0) &&
                !(z2 & 1)) {
              if ((x2 == y2) && (y2 == z2)) {
                counter_n.at(num)++;
              } else if ((x2 != y2) && (x2 != z2) && (y2 != z2)) {
                counter_n.at(num) += 6;
              } else {
                counter_n.at(num) += 3;
              }
            }
          }
        }
      }
    }
  }

  for (int i = 1; i < N + 1; i++) {
    cout << counter_n.at(i) << endl;
  }

  return 0;
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

// ループ
#define rep(i, n) for (int i = 0; i < (n); i++) // 普通のループ
#define repr(i, n) for (int i = n; i >= 0; i--) // 逆ループ

// 型名省略
typedef long long ll;
// 値
static const ll MX = 100005;
static const ll MX_ll = 1e18;

using namespace std;

// ソート
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

// #include "./lib/generic/search.h"

int main() {
  int n, x, y, z, ans = 0, max = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    max = 0;
    if (i <= 5) {
      cout << "0" << endl;
      continue;
    }
    x = 1;
    while (1) {
      if (x * x + x - i + 4 <= 0) {
        x++;
      }
      if (x * x + x - i + 4 > 0) {
        max = x - 1;
        break;
      }
    }
    for (x = 1; x <= max; x++) {
      for (y = 1; y <= max; y++) {
        for (z = 1; z <= max; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

// ループ
#define rep(i, n) for (int i = 0; i < (n); i++) // 普通のループ
#define repr(i, n) for (int i = n; i >= 0; i--) // 逆ループ

// 型名省略
typedef long long ll;
// 値
static const ll MX = 100005;
static const ll MX_ll = 1e18;

using namespace std;

// ソート
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

// #include "./lib/generic/search.h"

int main() {
  int n, x, y, z, ans = 0, max = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    ans = 0;
    max = 0;
    if (i <= 5) {
      cout << "0" << endl;
      continue;
    }
    x = 1;
    while (1) {
      if (x * x + x - i + 4 <= 0) {
        x++;
      }
      if (x * x + x - i + 4 > 0) {
        max = x - 1;
        break;
      }
    }
    for (x = 1; x <= max; x++) {
      for (y = x; y <= max; y++) {
        for (z = y; z <= max; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z)
              ans++;
            else if (x == y && y != z)
              ans += 3;
            else if (x != y && y == z)
              ans += 3;
            else if (x == z && y != z)
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    cout << ans << endl;
  }

  return 0;
}
Problem p02608 (C++)

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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, n) for (int i = 0; i <= (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define FORS(i, a, b) for (int i = a; i <= (b); i++)
// for container x
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define LB(v, x) distance((v).begin(), lower_bound(ALL(v), (x)))
#define UB(v, x) distance((v).begin(), upper_bound(ALL(v), (x)))

struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
#pragma endregion

int main() {
  int N;
  cin >> N;
  FORS(n, 1, N) {
    int ans = 0;
    for (int x = 1; x * x < n; x++) {
      for (int y = 1; y * y <= (n - x * x); y++) {
        // if (x*x+y*y+z*z+x*y+y*z+z*x==n) ans++;
        for (int z = 1; z * z <= (n - x * x - y * y - x * y); z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n)
            ans++;
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}

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

typedef long long ll;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, n) for (int i = 0; i <= (n); i++)
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define FORS(i, a, b) for (int i = a; i <= (b); i++)
// for container x
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define LB(v, x) distance((v).begin(), lower_bound(ALL(v), (x)))
#define UB(v, x) distance((v).begin(), upper_bound(ALL(v), (x)))

struct cww {
  cww() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;
#pragma endregion

int main() {
  int N;
  cin >> N;
  FORS(n, 1, N) {
    int ans = 0;
    for (int x = 1; x * x < n; x++) {
      for (int y = 1; y <= x; y++) {
        for (int z = 1; z <= y; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == n) {
            if (x == y && y == z && x == z)
              ans++;
            else if ((x == y && y != z) || (x == z && x != y) ||
                     (y == z && z != x))
              ans += 3;
            else
              ans += 6;
          }
        }
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
Problem p02608 (C++)

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

int Triplets(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {
  int N, x = 1, y = 1, z = 1;
  cin >> N;
  vector<int> ans(10001);
  for (z = 1; z < y + 1; z++) {
    for (y = z; y < x + 1; y++) {
      for (x = y; x < sqrt(N - 1) + 1; x++) {
        if (x == y && y == z) {
          ++ans.at(Triplets(x, y, z));
        } else if (x != y && y != z && z != x) {
          ans.at((Triplets(x, y, z))) += 6;
        } else {
          ans.at((Triplets(x, y, z))) += 3;
        }
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    cout << ans.at(i) << endl;
  }
}

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

int Triplets(int x, int y, int z) {
  return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {
  int N, x = 1, y = 1, z = 1;
  cin >> N;
  vector<int> ans(100000);
  for (z = 1; z < y + 1; z++) {
    for (y = z; y < x + 1; y++) {
      for (x = y; x < sqrt(N - 1) + 1; x++) {
        if (x == y && y == z) {
          ++ans.at(Triplets(x, y, z));
        } else if (x != y && y != z && z != x) {
          ans.at((Triplets(x, y, z))) += 6;
        } else {
          ans.at((Triplets(x, y, z))) += 3;
        }
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    cout << ans.at(i) << endl;
  }
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int cnt = 0;
    int N = i;
    for (int x = 1; x <= n; ++x) {
      for (int y = 1; y <= n; ++y) {
        for (int z = 1; z <= n; ++z) {
          int cal = x * x + y * y + z * z + x * y + y * z + z * x;
          if (cal < N)
            continue;
          if (cal == N)
            ++cnt;
          break;
        }
      }
    }
    cout << cnt << '\n';
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int cnt = 0;
    int N = i;
    for (int x = 1; x * x <= n; ++x) {
      for (int y = 1; y * y <= n; ++y) {
        for (int z = 1; z * z <= n; ++z) {
          int cal = x * x + y * y + z * z + x * y + y * z + z * x;
          if (cal < N)
            continue;
          if (cal == N)
            ++cnt;
          break;
        }
      }
    }
    cout << cnt << '\n';
  }
}
Problem p02608 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()

#define pi 3.14159265358979323846

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

const int MAX = 42;

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

  vector<ll> a(20000, 0);

  for (ll i = 1; i <= 100; i++) {
    for (ll j = 1; j <= 100; j++) {
      for (ll k = 1; k <= 100; k++) {
        ll f = i * i + j * j + k * k + i * j + j * k + k * i;
        a[f]++;
      }
    }
  }

  for (ll i = 1; i <= N; i++) {
    cout << a[i] << endl;
  }

  // cout << setprecision(8) << ans << endl;  // For double
}


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

using ll = long long int;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define all(x) (x).begin(), (x).end()

#define pi 3.14159265358979323846

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

const int MAX = 42;

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

  vector<ll> a(60000, 0);

  for (ll i = 1; i <= 100; i++) {
    for (ll j = 1; j <= 100; j++) {
      for (ll k = 1; k <= 100; k++) {
        ll f = i * i + j * j + k * k + i * j + j * k + k * i;
        a[f]++;
      }
    }
  }

  for (ll i = 1; i <= N; i++) {
    cout << a[i] << endl;
  }

  // cout << setprecision(8) << ans << endl;  // For double
}
Problem p02608 (C++)

Buggy submission (status: Time Limit Exceeded):
#pragma GCC optimize("Ofast")
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <vector>

const long long INFL = 1e17 + 7;
const long long INFI = 1e9 + 7;
const long long MOD = 1e9 + 7;
const double EPS = 1e-8;
const double PI = acos(-1);

using namespace std;

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

  int n;
  cin >> n;
  vector<int> count(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    for (int x = 1; x * x <= n; x++) {
      for (int y = x; y * y <= n; y++) {
        for (int z = y; z * z <= n; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z) {
              count[i]++;
              break;
            } else if (x != y && y != z) {
              count[i] += 6;
              break;
            } else {
              count[i] += 3;
              break;
            }
          }
        }
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << count[i] << endl;
  }

  return 0;
}


Fixed submission:
#pragma GCC optimize("Ofast")
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <vector>

const long long INFL = 1e17 + 7;
const long long INFI = 1e9 + 7;
const long long MOD = 1e9 + 7;
const double EPS = 1e-8;
const double PI = acos(-1);

using namespace std;

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

  int n;
  cin >> n;
  vector<int> count(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    for (int x = 1; x * x <= i; x++) {
      for (int y = x; y * y <= i; y++) {
        for (int z = y; z * z <= i; z++) {
          if (x * x + y * y + z * z + x * y + y * z + z * x == i) {
            if (x == y && y == z) {
              count[i]++;
              break;
            } else if (x != y && y != z) {
              count[i] += 6;
              break;
            } else {
              count[i] += 3;
              break;
            }
          }
        }
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << count[i] << endl;
  }

  return 0;
}