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

#include <bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n, x[MAXN], y[MAXN], p[MAXN];
ll ans[MAXN];
int distx[15][(1 << 15)], disty[15][(1 << 15)];
void solve(int mask, int submask) {
  ll res = 0;
  for (int i = 0; i < n; i++) {
    if (!(mask & (1 << i))) {
      int dist = min(max(x[i], -x[i]), max(y[i], -y[i]));
      dist = min(dist, distx[i][submask]);
      dist = min(dist, disty[i][mask ^ submask]);
      res += 1LL * dist * p[i];
    }
  }
  ans[__builtin_popcount(mask)] = min(ans[__builtin_popcount(mask)], res);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d%d%d", &x[i], &y[i], &p[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (1 << n); j++) {
      distx[i][j] = INF;
      for (int k = 0; k < n; k++)
        if (j & (1 << k))
          distx[i][j] = min(distx[i][j], max(x[i] - x[k], x[k] - x[i]));
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (1 << n); j++) {
      disty[i][j] = INF;
      for (int k = 0; k < n; k++)
        if (j & (1 << k))
          disty[i][j] = min(disty[i][j], max(y[i] - y[k], y[k] - y[i]));
    }
  }
  for (int i = 0; i <= n; i++)
    ans[i] = 1000000000000000000LL;
  for (int i = 0; i < (1 << n); i++) {
    int sub = i;
    do {
      solve(i, sub);
      sub = (sub - 1) & i;
    } while (sub != i);
  }
  for (int i = 0; i <= n; i++)
    printf("%lld\\n", ans[i]);
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int n, x[MAXN], y[MAXN], p[MAXN];
ll ans[MAXN];
void solve(int mask, int submask) {
  vector<int> v1, v2;
  for (int i = 0; i < n; i++) {
    if (mask & (1 << i))
      v1.push_back(i);
    else
      v2.push_back(i);
  }
  ll res = 0;
  for (auto a : v2) {
    int dist = min(max(x[a], -x[a]), max(y[a], -y[a]));
    for (auto b : v1) {
      if (submask & (1 << b))
        dist = min(dist, max(y[a] - y[b], y[b] - y[a]));
      else
        dist = min(dist, max(x[a] - x[b], x[b] - x[a]));
    }
    res += 1LL * dist * p[a];
  }
  ans[__builtin_popcount(mask)] = min(ans[__builtin_popcount(mask)], res);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d%d%d", &x[i], &y[i], &p[i]);
  for (int i = 0; i <= n; i++)
    ans[i] = 1000000000000000000LL;
  for (int i = 0; i < (1 << n); i++) {
    int sub = i;
    do {
      solve(i, sub);
      sub = (sub - 1) & i;
    } while (sub != i);
  }
  for (int i = 0; i <= n; i++)
    printf("%lld\\n", ans[i]);
  return 0;
}
Problem p02604 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const ll INF = 1LL << 62;

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n), y(n), p(n);
  rep(i, n) cin >> x[i] >> y[i] >> p[i];

  vector<vector<ll>> xsel(1 << n, vector<ll>(n));
  vector<vector<ll>> ysel(1 << n, vector<ll>(n));
  rep(i, 1 << n) {
    rep(j, n) {
      xsel[i][j] = abs(x[j]);
      ysel[i][j] = abs(y[j]);
      rep(k, n) {
        if ((i >> k) & 1) {
          xsel[i][j] = min(xsel[i][j], abs(x[j] - x[k]));
          ysel[i][j] = min(ysel[i][j], abs(y[j] - y[k]));
        }
      }
    }
  }

  vector<ll> ans(n + 1, INF);
  rep(i, 1 << n) {
    ll cnt = __builtin_popcount(i);
    for (ll j = i; j >= 0; j--) {
      j &= i;
      ll cost = 0;
      rep(k, n) {
        if (!((i >> k) & 1)) {
          cost += 1LL * min(xsel[j][k], ysel[i - j][k]) * p[k];
        }
      }
      ans[cnt] = min(ans[cnt], cost);
    }
  }

  for (ll i = 0; i <= n; i++)
    cout << ans[i] << endl;
}


Error: TLE

Fixed submission:

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

const ll INF = 1LL << 62;

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n), y(n), p(n);
  rep(i, n) cin >> x[i] >> y[i] >> p[i];

  vector<vector<ll>> xsel(1 << n, vector<ll>(n));
  vector<vector<ll>> ysel(1 << n, vector<ll>(n));
  rep(i, 1 << n) {
    rep(j, n) {
      xsel[i][j] = abs(x[j]);
      ysel[i][j] = abs(y[j]);
      rep(k, n) {
        if ((i >> k) & 1) {
          xsel[i][j] = min(xsel[i][j], abs(x[j] - x[k]));
          ysel[i][j] = min(ysel[i][j], abs(y[j] - y[k]));
        }
      }
    }
  }

  vector<ll> ans(n + 1, INF);
  rep(i, pow(3, n)) {
    int info = i;
    vector<vector<int>> state(3); // 0: x train, 1: y train, 2: no train
    rep(j, n) state[info % 3].push_back(j), info /= 3;

    int xi = 0, yi = 0;
    for (auto a : state[0])
      xi += pow(2, a);
    for (auto a : state[1])
      yi += pow(2, a);

    ll cost = 0;
    for (auto k : state[2])
      cost += 1LL * min(xsel[xi][k], ysel[yi][k]) * p[k];

    int cnt = state[0].size() + state[1].size();
    ans[cnt] = min(ans[cnt], cost);
  }

  for (ll i = 0; i <= n; i++)
    cout << ans[i] << endl;
}
Problem p02604 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <limits>
using namespace std;
using i64 = long long;
int n, i;
int x[20], y[20], p[20], z[20];
i64 ans[20];
char b[20], s[20], c[20];

void ct(int j) {
  i64 result = 0;
  for (int i = 1; i <= n; ++i) {
    if (b[i] != 0)
      continue;
    int t = z[i];
    for (int u = 0; u < j; ++u)
      if (c[u] == 1)
        t = min(t, abs(x[i] - x[s[u]]));
      else
        t = min(t, abs(y[i] - y[s[u]]));
    result += t * (i64)p[i];
  }
  ans[j] = min(ans[j], result);
}

void sk(int i, int j) {
  if (i > n) {
    ct(j);
    return;
  }
  s[j] = i;
  c[j] = b[i] = 1;
  sk(i + 1, j + 1);
  c[j] = b[i] = 2;
  sk(i + 1, j + 1);
  b[i] = 0;
  sk(i + 1, j);
}

int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d%d%d", &x[i], &y[i], &p[i]);
    z[i] = min(abs(x[i]), abs(y[i]));
  }
  for (i = 0; i <= n; ++i)
    ans[i] = numeric_limits<i64>::max();
  sk(1, 0);
  for (i = 0; i <= n; ++i)
    printf("%lld\\n", ans[i]);
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <limits>
using namespace std;
using i64 = long long;
int n, i;
int x[20], y[20], p[20];
i64 ans[20];
char b[20];

void ct(int j) {
  i64 result = 0;
  for (int i = 1; i <= n; ++i) {
    if (b[i] != 0)
      continue;
    int t = min(abs(x[i]), abs(y[i]));
    for (int u = 1; u <= n; ++u)
      if (b[u] == 1)
        t = min(t, abs(x[i] - x[u]));
      else if (b[u] == 2)
        t = min(t, abs(y[i] - y[u]));
    result += t * (i64)p[i];
  }
  ans[j] = min(ans[j], result);
}

void sk(int i, int j) {
  if (i > n) {
    ct(j);
    return;
  }
  b[i] = 1;
  sk(i + 1, j + 1);
  b[i] = 2;
  sk(i + 1, j + 1);
  b[i] = 0;
  sk(i + 1, j);
}

int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; ++i)
    scanf("%d%d%d", &x[i], &y[i], &p[i]);
  for (i = 0; i <= n; ++i)
    ans[i] = numeric_limits<i64>::max();
  sk(1, 0);
  for (i = 0; i <= n; ++i)
    printf("%lld\\n", ans[i]);
}
Problem p02604 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
int64_t X[1 << 15][15], Y[1 << 15][15];
int64_t AX[15], AY[15], AP[15], ans[16];
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    cin >> AX[i] >> AY[i] >> AP[i];
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < n; ++j) {
      X[i][j] = abs(AX[j]);
      for (int k = 0; k < n; ++k)
        if (i >> k & 1)
          X[i][j] = min(X[i][j], abs(AX[k] - AX[j]));
      Y[i][j] = abs(AY[j]);
      for (int k = 0; k < n; ++k)
        if (i >> k & 1)
          Y[i][j] = min(Y[i][j], abs(AY[k] - AY[j]));
    }
  }
  for (int i = 0; i <= n; ++i)
    ans[i] = 1e18;
  for (int i = 0; i < (1 << n); ++i) {
    int c = __builtin_popcount(i);
    for (int j = i;; j = (j - 1) & i) {
      int64_t tmp = 0;
      for (int a = 0; a < n; ++a) {
        tmp += min(X[j][a], Y[j ^ i][a]) * AP[a];
      }
      ans[c] = min(ans[c], tmp);
      if (j == 0)
        break;
    }
  }
  for (int i = 0; i <= n; ++i)
    cout << ans[i] << '\\n';

  return 0;
}
// 2020.07.25 21:54:09


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
#define PB push_back
#define MP make_pair
const int maxn = 200009;
const int MOD = 1e9 + 7;
inline int64_t ABS(int64_t a) { return a >= 0 ? a : -a; }
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  int n;
  cin >> n;
  vector<int64_t> X(n), Y(n), P(n);
  vector<int64_t> ans(n + 1, 1e18);
  vector<vector<int64_t>> C(n + 1);
  for (int i = 0; i < n; ++i)
    cin >> X[i] >> Y[i] >> P[i];
  for (int i = 0; i < (1 << n); ++i)
    C[__builtin_popcount(i)].PB(i);
  for (int c = 0; c <= n; ++c) {
    if (c && ans[c - 1] == 0) {
      ans[c] = 0;
      continue;
    }
    if (c)
      ans[c] = ans[c - 1];
    for (int i : C[c]) {
      vector<int> zero, one;
      for (int j = 0; j < n; ++j)
        if (i >> j & 1)
          one.PB(j);
        else
          zero.PB(j);
      for (int a = i;; a = (a - 1) & i) {
        vector<int64_t> XX, YY;
        int64_t tmp = 0;
        for (auto b : one)
          if (a >> b & 1)
            XX.PB(X[b]);
          else
            YY.PB(Y[b]);
        for (auto b : zero) {
          if (X[b] == 0 || Y[b] == 0)
            continue;
          int64_t Min = min(ABS(X[b]) * P[b], ABS(Y[b]) * P[b]);
          for (auto j : XX)
            Min = min(Min, P[b] * ABS(X[b] - j));
          for (auto j : YY)
            Min = min(Min, P[b] * ABS(Y[b] - j));
          tmp += Min;
          if (tmp >= ans[c])
            break;
        }
        ans[c] = min(ans[c], tmp);
        if (a == 0)
          break;
      }
    }
  }

  for (int i = 0; i <= n; ++i)
    cout << ans[i] << '\\n';

  return 0;
}
// 2020.07.25 20:31:25
Problem p02605 (C++) — buggy submission, verdict: Runtime Error

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

typedef map<int, set<int>> msi;

#define F first
#define S second

const int inf = 2e9;

int n, ans;
msi xup, xdown, yleft, yright;
msi upm, upp, downm, downp;
msi leftm, leftp, rightm, rightp;

void relax(msi &a, msi &b, int mult) {
  for (auto &t : a) {
    if (!b.count(t.F))
      continue;
    for (int i : t.S) {
      auto it = b[t.F].lower_bound(i);
      if (it == b[t.F].end())
        continue;
      ans = min(ans, (*it - i) * mult);
    }
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    char d;
    cin >> x >> y >> d;
    if (d == 'U') {
      xup[x].insert(y);
      upm[x - y].insert(y);
      upp[x + y].insert(y);
    } else if (d == 'D') {
      xdown[x].insert(y);
      downm[x - y].insert(y);
      downp[x + y].insert(y);
    } else if (d == 'L') {
      yleft[y].insert(x);
      leftm[x - y].insert(y);
      leftp[x + y].insert(y);
    } else {
      yright[y].insert(x);
      rightm[x - y].insert(y);
      rightp[x + y].insert(y);
    }
  }
  ans = inf;
  relax(xup, xdown, 5);
  relax(yright, yleft, 5);
  relax(upm, leftm, 10);
  relax(upp, rightp, 10);
  relax(rightm, downm, 10);
  relax(leftp, downp, 10);
  if (ans == inf)
    cout << "SAFE";
  else
    cout << ans;
}


Error: WA

Fixed submission:

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

typedef map<int, vector<int>> mvi;

#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()

const int inf = 2e9;
const int N = 200100;

int n, ans;
mvi xup, xdown, yleft, yright;
mvi upm, upp, downm, downp;
mvi leftm, leftp, rightm, rightp;

void relax(mvi &a, mvi &b, int mult) {
  for (auto &t : a) {
    if (!b.count(t.F))
      continue;
    for (int i : t.S) {
      auto it = lower_bound(all(b[t.F]), i);
      if (it == b[t.F].end())
        continue;
      ans = min(ans, (*it - i) * mult);
    }
  }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    char d;
    cin >> x >> y >> d;
    if (d == 'U') {
      xup[x].pb(y);
      upm[x - y].pb(y);
      upp[x + y].pb(y);
    } else if (d == 'D') {
      xdown[x].pb(y);
      downm[x - y].pb(y);
      downp[x + y].pb(y);
    } else if (d == 'L') {
      yleft[y].pb(x);
      leftm[x - y].pb(y);
      leftp[x + y].pb(y);
    } else {
      yright[y].pb(x);
      rightm[x - y].pb(y);
      rightp[x + y].pb(y);
    }
  }
  ans = inf;
  relax(xup, xdown, 5);
  relax(yright, yleft, 5);
  relax(upm, leftm, 10);
  relax(upp, rightp, 10);
  relax(rightm, downm, 10);
  relax(leftp, downp, 10);
  if (ans == inf)
    cout << "SAFE";
  else {
    if (ans % 10 == 5)
      assert(0);
    cout << ans;
  }
}
Problem p02606 (C++) — buggy submission, verdict: 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 >> d;
  loop(i, l, r + 1) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt;
}


Error: -8

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;
  loop(i, l, r + 1) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt;
}
Problem p02606 (C++) — buggy submission, verdict: 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;

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;
}


Error: TLE

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;

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;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

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


Error: WA

Fixed submission:

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

#include <bits/stdc++.h>

using namespace std;

int main() {
  int L, R, d, i = 1, count = 0, mul;
  cin >> L >> R >> d;
  mul = d;
  while (mul <= R) {
    mul = i * d;
    if (mul >= L && mul <= R) {
      count++;
    }
    i++;
  }
  cout << count;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int L, R, d, i = 1, count = 0;
  cin >> L >> R >> d;

  while (i * d <= R) {
    int mul = i * d;
    if (mul >= L && mul <= R) {

      count++;
    }
  }
  cout << count;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#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";
}


Error: TLE

Fixed submission:

#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";
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int mul_max(int A, int B) {
  int C = 0;
  for (int i = 0; i < 10000; i++) {
    C += B;
    if (C > A) {
      break;
    }
  }
  return C - B;
}
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int X, Y;
  X = mul_max(A - 1, C) / C;
  Y = mul_max(B, C) / C;
  cout << Y - X << endl;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int mul_max(int A, int B) {
  int C = B;
  for (int i = 0; i < 10000; i++) {
    C += B;
    if (C >= A) {
      break;
    }
  }
  return C - B;
}
int main() {
  int A, B, C;
  int X, Y;
  X = mul_max(A, C) / C;
  Y = mul_max(B, C) / C;
  cout << X - Y << endl;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int L, R, n;
  cin >> L >> R >> n;
  int x = R - L + 1;
  int L1 = L;
  int cont = 0;
  for (int i = 0; i < x; i++) {
    if ((L1 + i) % n == 0) {
      cont++;
    }
  }
  cout << cont;
}


Error: WA

Fixed submission:

#include <stdio.h>

int main() {
  int L, R, d, ctr = 0;

  while (L <= R) {
    if (L % d == 0) {
      ctr = ctr + 1;
    }
    L++;
  }
  printf("%d\\n", ctr);
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int l, r, d;
  int h = 0;
  scanf("%d %d %d", &l, &r, &d);
  for (int i = l; i <= r; i++) {
    if (i % d == 0) {
      h++;
    }
  }
  printf("%d", h);
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
int main() {
  int L, R, d, ctr = 0;
  while (L <= R) {
    if (L % d == 0) {
      ctr = ctr + 1;
    } else {
      L++;
    }
  }
  printf("%d %d %d %d\\n", L, R, d, ctr);
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
ll power(ll x, ll y, ll p) {
  ll res = 1; // Initialize result

  x = x % p; // Update x if it is more than or
             // equal to p

  if (x == 0)
    return 0; // In case x is divisible by p;

  while (y > 0) {
    // If y is odd, multiply x with result
    if (y & 1)
      res = (res * x) % p;

    // y must be even now
    y = y >> 1; // y = y/2
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ll l, r, d;
  cin >> l >> r >> d;
  ll ans = 0;
  for (ll i = l; i <= r; i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans << "\\n";
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
ll power(ll x, ll y, ll p) {
  ll res = 1; // Initialize result

  x = x % p; // Update x if it is more than or
             // equal to p

  if (x == 0)
    return 0; // In case x is divisible by p;

  while (y > 0) {
    // If y is odd, multiply x with result
    if (y & 1)
      res = (res * x) % p;

    // y must be even now
    y = y >> 1; // y = y/2
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ll l, r, d;
  ll ans = 0;
  for (ll i = l; i <= r; i++) {
    if (l % d == 0)
      ans++;
  }
  cout << ans << "\\n";
}
Problem p02606 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;
int main() {
  int L = 0, R = 0, d = 0, count = 0;
  cin >> L >> R >> d;
  for (int i = L; i <= R; i++) {
    if (i % d == 0)
      count++;
  }
  cout << count << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;
int main() {
  int L, R, d, count = 0;
  cin >> L >> R >> d;
  for (int i = L; L <= R; i++) {
    if (i % d == 0)
      count++;
  }
  cout << count << endl;
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: 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++;
    l++;
  }
  cout << cnt;
  return 0;
}


Error: TLE

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++;
  }
  cout << cnt;
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int l, r, d, tot = 0;
  scanf("%d %d %d", &l, &r, &d, &tot);
  while (l <= r) {
    if (l % d == 0) {
      tot = tot + 1;
    }
    l++;
  }
  printf("%d\\n", tot);
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int L, R, d, ctr = 0;
  scanf("%d %d %d %d\\n", &L, &R, &d, &ctr);
  while (L <= R) {
    if (L % d == 0) {
      ctr = ctr + 1;
    } else {
      L++;
      R++;
    }
  }
  printf("%d %d %d %d\\n", L, R, d, ctr);
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: 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;
  cin >> l >> r >> d;
  for (ll i = l; i <= r; i++) {
    if (i % d == 0)
      ans++;
  }
  print(ans);
  return 0;
}


Error: WA

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;
  for (ll i = l; i <= r; i++) {
    if (i % d == 0)
      ans++;
  }
  print(ans);
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int L, R, d, i;
  int count = 0;
  scanf("%d %d %d", &L, &R, &d);

  for (i = L; i <= R; i++) {
    if (i % d == 0) {
      count++;
    }
  }
  printf("%d\\n", count);

  return 0;
}

Error: -8

Fixed submission:

#include <stdio.h>

int main() {
  int x, y, n;
  scanf("%d", &n);
  for (int i = 0; i <= n; i++) {
    if (i % x == 0 && i % y == 0) {
      puts("FizzBuzz");
    } else if (i % x == 0) {
      puts("Fizz");
    } else if (i % y == 0) {
      puts("Buzz");
    } else {
      printf("%d\\n", i);
    }
  }
  return 0;
}