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

#include <cmath>
#include <cstdio>
#include <iostream>
#define EPS 1e-10
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;

int main() {
  int n, a, b;
  bool DP[1000000];
  int cnt;

  while (cin >> n >> a >> b && a && n && b) {
    cnt = n;
    for (int i = 0; i <= n; i++)
      DP[i] = false;
    DP[0] = true;
    rep(i, n + 1) {
      if (DP[i]) {
        if (a + i <= n && !DP[a + i]) {
          cnt--;
          DP[a + i] = true;
        }
        if (b + i <= n && !DP[b + i]) {
          cnt--;
          DP[b + i] = true;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>
#define EPS 1e-10
#define REP(i, s, n) for (int i = s; i < n; i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
typedef long long ll;
int main() {
  ll n, a, b;
  ll A[2];
  ll nb;
  while (cin >> n >> a >> b && a && n && b) {
    ll count = n;
    bool fin = false;
    A[0] = a;
    A[1] = b;
    for (int i = 1; i <= n; i++) {

      if (i % a == 0) {
        count--;
        continue;
      } else if (i % b == 0) {
        count--;
        continue;
      } else {
        int dp[i + 1];
        for (int k = 0; k < i + 1; k++)
          dp[k] = -1;
        dp[0] = 0;
        for (int k = 0; k < 2; k++) {
          for (int j = 0; j <= i; j++) {
            if (dp[j] >= 0)
              dp[j] = A[k];
            else if (j < A[k] || dp[j - A[k]] <= 0) {
              dp[j] = -1;
            } else
              dp[j] = dp[j - A[k]] - 1;
          }
        }

        if (dp[i] >= 0)
          count--;
      }
    }
    cout << count << endl;
  }
  return 0;
}
Problem p00687 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int num[1000000];
int main() {
  int n, a, b;
  while (cin >> n >> a >> b, n + a + b) {
    n++;
    fill(num, num + n, 1);
    int j = 0;
    for (int i = 0; a * i + b * j < n; i++) {
      if (num[a * i + b * j] == 0)
        continue;
      for (j = 0; a * i + b * j < n; j++) {
        num[a * i + b * j] = 0;
      }
      j = 0;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
      if (num[i])
        cnt++;
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, a, b;
  while (cin >> n >> a >> b, n + a + b) {
    n++;
    int num[n];
    fill(num, num + n, 1);
    for (int i = 0; i < n; i++) {
      for (int j = 0; a * i + b * j < n; j++) {
        num[a * i + b * j] = 0;
      }
    }
    int cnt = 0;
    for (int i = 1; i < n; i++)
      if (num[i])
        cnt++;
    cout << cnt << endl;
  }
}
Problem p00687 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#define N 1000001
using namespace std;

int main() {
  int a, b, n, sum;
  bool flag[N];
  int c, aa, bb;

  while (cin >> n >> a >> b && (n || a || b)) {

    for (int i = 1; i <= n; i++)
      flag[i] = false;

    if (b > a) {
      sum = b;
      b = a;
      a = sum;
    }
    sum = 0;
    for (int i = b; i <= n; i++) {
      if (flag[i]) {
        sum++;
        continue;
      }
      c = 0;
      for (int n_ai = i; n_ai >= 0; n_ai -= a) {
        if (n_ai % b == 0) {
          ++sum;
          //	  aa = c;
          //	  bb = n_ai/b;
          aa = a * c;
          bb = n_ai;

          c = aa + bb;
          /*
          cout << "i="<<i<< "\\ta="<<a<<" b="<<b
               <<" aa="<<aa<<" bb="<<bb
               << "\\tn_ai="<<n_ai
               << endl;
          */
          for (int j = 2 * c; j <= n; j += c)
            flag[j] = true;
          break;
        }
        c++;
      }
    }
    cout << (n - sum) << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b, n, sum;

  while (cin >> n >> a >> b && (n || a || b)) {

    if (b > a) {
      sum = b;
      b = a;
      a = sum;
    }
    sum = 0;
    for (int i = a < b ? a : b; i <= n; i++) {
      for (int n_ai = i; n_ai >= 0; n_ai -= a) {
        if (n_ai % b == 0) {
          ++sum;
          break;
        }
      }
    }
    cout << (n - sum) << endl;
  }

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

#include <iostream>
using namespace std;

int main() {
  while (true) {
    int n, a, b;
    cin >> n >> a >> b;
    if ((n | a | b) == 0) {
      break;
    }
    int representableNum = 0;
    bool *isRepresentable = new bool[n + 1];
    fill_n(isRepresentable, n + 1, false);
    isRepresentable[0] = true;
    for (int j = 0; j < a; j++) {
      int x = b * j;
      if (n < x) {
        break;
      }
      while (x <= n) {
        if (isRepresentable[x] == false) {
          isRepresentable[x] = true;
          representableNum++;
        }
        x += a;
      }
    }
    cout << n - representableNum << endl;
    delete[] isRepresentable;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  while (true) {
    int n, a, b;
    cin >> n >> a >> b;
    if ((n | a | b) == 0) {
      break;
    }
    int representableNum = 0;
    bool *isRepresentable = new bool[n + 1];
    fill_n(isRepresentable, n + 1, false);
    for (int i = 1; a * i <= n; i++) {
      isRepresentable[a * i] = true;
      representableNum++;
    }
    for (int i = 1; b * i <= n; i++) {
      if (isRepresentable[b * i] == false) {
        isRepresentable[b * i] = true;
        representableNum++;
      }
    }
    for (int k = 1; k <= n; k++) {
      if (isRepresentable[k]) {
        continue;
      }
      for (int i = 1; a * i < k; i++) {
        if ((k - a * i) % b == 0) {
          isRepresentable[k] = true;
          representableNum++;
          break;
        }
      }
    }
    cout << n - representableNum << endl;
    delete[] isRepresentable;
  }
}
Problem p00687 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {

  bool dp[1000001];
  int a, b, n;
  while (cin >> n >> a >> b && !(n == 0 && a == 0 && b == 0)) {
    memset(dp, 0, sizeof(dp));
    dp[0] = dp[a] = dp[b] = true;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      if (i == a || i == b) {
        cnt++;
        continue;
      }
      if (i - a >= 0) {
        dp[i] = dp[i - a];
        if (dp[i])
          cnt++;
      }
      if (!dp[i] && i - b >= 0) {
        dp[i] = dp[i - b];
        if (dp[i])
          cnt++;
      }
    }
    cout << n - cnt << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

int main() {

  ll n, a, b;
  while (cin >> n >> a >> b && !(n == 0 && a == 0 && b == 0)) {
    set<ll> s;
    bool u[1000001];
    fill(u, u + 1000001, false);
    for (ll i = 0; a * i <= n; i++) {
      for (ll j = 0; b * j + a * i <= n; j++) {
        u[a * i + j * b] = true;
      }
    }
    ll cnt = 0;
    for (ll i = 1; i <= n; i++) {
      if (!u[i])
        cnt++;
    }
    cout << cnt << endl;
  }

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

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int A, B, C;

void func() {

  int left = -1 * max(abs(B), abs(C));
  int right = max(abs(B), abs(C));
  int p, q;

  for (int r = 1; r * r <= A; r++) {
    if (A % r != 0)
      continue;
    p = A / r;
    for (int s = left; s <= right; s++) {
      if (s != 0 && C % s != 0)
        continue;
      if (s != 0)
        q = C / s;
      else {
        q = B / r;
      }
      if (q != 0 && C % q != 0)
        continue;
      if (p == r && s > q)
        continue;

      if (p * r == A && (p * s + q * r) == B && q * s == C) {
        printf("%d %d %d %d\\n", p, q, r, s);
        return;
      }
    }
  }
  printf("Impossible\\n");
}

int main() {

  while (true) {
    scanf("%d %d %d", &A, &B, &C);
    if (A == 0 && B == 0 && C == 0)
      break;

    func();
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cfloat>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int A, B, C;

void func() {

  int left = -1 * max(abs(B), abs(C));
  int right = max(abs(B), abs(C));
  int p;

  for (int r = 1; r * r <= A; r++) {
    if (A % r != 0)
      continue;
    p = A / r;
    for (int s = left; s <= right; s++) {
      if (s != 0 && C % s != 0)
        continue;
      for (int q = left; q <= right; q++) {
        if (q != 0 && C % q != 0)
          continue;
        if (p == r && s > q)
          continue;

        if (p * r == A && (p * s + q * r) == B && q * s == C) {
          printf("%d %d %d %d\\n", p, q, r, s);
          return;
        }
      }
    }
  }
  printf("Impossible\\n");
}

int main() {

  while (true) {
    scanf("%d %d %d", &A, &B, &C);
    if (A == 0 && B == 0 && C == 0)
      break;

    func();
  }

  return 0;
}
Problem p00688 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define MAX 10001
vector<int> divisors[MAX];

int main() {
  divisors[0].push_back(0);
  for (int i = 1; i < MAX; ++i) {
    divisors[i].reserve(100);
    for (int j = 1; j <= i / 2 + 1; ++j) {
      if (i % j == 0) {
        divisors[i].push_back(j);
        divisors[i].push_back(-j);
      }
    }
    divisors[i].push_back(i);
    divisors[i].push_back(-i);
  }
  while (true) {
    int a, b, c;
    int p = 0, q = 0, r = 0, s = 0;
    cin >> a >> b >> c;
    if (a == 0 && b == 0 && c == 0)
      break;
    for (int i = 0; i < divisors[a].size(); ++i) {
      int tr = divisors[a][i];
      if (tr < 0)
        continue;
      int tp = a / tr;
      if (tp < tr)
        continue;
      for (int j = 0; j < divisors[(c < 0 ? -c : c)].size(); ++j) {
        int ts = c != 0 ? divisors[(c < 0 ? -c : c)][j] : 0;
        int tq = c != 0 ? c / ts : b;
        if (tp == tr && ts == 0 && tq < ts && b < 0)
          swap(ts, tq);
        if (tp == tr && tq < ts)
          continue;
        if (tp * ts + tq * tr == b) {
          p = tp;
          s = ts;
          q = tq;
          r = tr;
        }
      }
    }
    if (p == 0 && r == 0 && q == 0 && s == 0)
      cout << "Impossible" << endl;
    else
      cout << p << ' ' << q << ' ' << r << ' ' << s << endl;
  }
  return 0;
}

Error: -8

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define MAX 10001
vector<int> divisors[MAX];

int main() {
  divisors[0].push_back(0);
  for (int i = 1; i < MAX; ++i) {
    divisors[i].reserve(100);
    for (int j = 1; j <= i / 2; ++j) {
      if (i % j == 0) {
        divisors[i].push_back(j);
        divisors[i].push_back(-j);
      }
    }
    divisors[i].push_back(i);
  }
  while (true) {
    int a, b, c;
    int p = 0, q = 0, r = 0, s = 0;
    cin >> a >> b >> c;
    if (a == 0 && b == 0 && c == 0)
      break;
    for (int i = 0; i < divisors[a].size(); ++i) {
      int tr = divisors[a][i];
      // cout << "TR : " << tr << endl;
      if (tr < 0)
        continue;
      int tp = a / tr;
      // cout << "TP : " << tp << endl;
      if (tp < tr)
        continue;
      for (int j = 0; j < divisors[c].size(); ++j) {
        int ts = c != 0 ? divisors[c][j] : 0;
        int tq = c != 0 ? c / ts : b;
        // cout << "TS : " << ts << " TQ : " << tq << endl;
        if (tp == tr && tq < ts)
          continue;
        if (tp * ts + tq * tr == b) {
          p = tp;
          s = ts;
          q = tq;
          r = tr;
        }
      }
    }
    if (p == 0 && r == 0)
      cout << "Impossible\\n";
    else
      cout << p << " " << q << " " << r << " " << s << endl;
  }
  return 0;
}
Problem p00688 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for (int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int a, b, c;

void solve() {
  FOR(p, 1, 10001) {
    if (a % p)
      continue;
    int r = a / p;
    FOR(q, -10001, 10001) {
      int s;
      if (q == 0)
        s = b / p;
      else
        s = c / q;
      if (p < r || (r == p && q < s))
        continue;
      if (p * r == a && p * s + r * q == b && q * s == c) {
        cout << p << " " << q << " " << r << " " << s << endl;
        return;
      }
    }
  }
  cout << "Impossible" << endl;
}

int main() {
  while (cin >> a >> b >> c && a)
    solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for (int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int a, b, c;

void solve() {
  FOR(r, 1, 101) {
    FOR(p, r, 101) {
      FOR(q, -100, 101) {
        FOR(s, -100, 101) {
          if (r == p && q < s)
            break;
          if (p * r == a && p * s + r * q == b && q * s == c) {
            cout << p << " " << q << " " << r << " " << s << endl;
            return;
          }
        }
      }
    }
  }
  cout << "Impossible" << endl;
}

int main() {
  while (cin >> a >> b >> c && a)
    solve();
  return 0;
}
Problem p00688 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int a, b, c;
  while (cin >> a >> b >> c) {
    if (a == 0 && b == 0 && c == 0)
      break;
    int p = 2 * a, r = 2 * a;
    int q = -(-b + (sqrt((double)(b * b - 4 * a * c))));
    int s = -(-b - (sqrt((double)(b * b - 4 * a * c))));
    // int tmp = (int)sqrt((double)(b*b-4*a*c));
    // cout << b*b-4*a*c << endl;
    // cout << sqrt((double)b*b-4*a*c) << endl;
    // cout << q << " " << s << endl;
    int tmp = (int)sqrt((double)(b * b - 4 * a * c));
    // cout << tmp << endl;
    if (abs(sqrt((double)(b * b - 4 * a * c)) - (double)tmp) != 0 ||
        b * b - 4 * a * c < 0) {
      cout << "Impossible" << endl;
    } else {
      // cout << sqrt((double)(b*b-4*a*c)) << endl;
      // cout << q << " " << s << endl;
      for (int i = 100000; i > 1; i--) {
        if (!(p % i) && !(q % i)) {
          p /= i;
          q /= i;
        }
        if (!(r % i) && !(s % i)) {
          r /= i;
          s /= i;
        }
      }

      if (p < r) {
        swap(p, r);
        swap(q, s);
      }
      if (p == r) {
        if (q < s) {
          swap(q, s);
        }
      }
      cout << p << " " << q << " " << r << " " << s << endl;
    }
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int a, b, c;
  while (cin >> a >> b >> c) {
    if (a == 0 && b == 0 && c == 0)
      break;
    int p = 2 * a, r = 2 * a;
    int q = -(-b + (sqrt((double)(b * b - 4 * a * c))));
    int s = -(-b - (sqrt((double)(b * b - 4 * a * c))));
    // int tmp = (int)sqrt((double)(b*b-4*a*c));
    // cout << b*b-4*a*c << endl;
    // cout << sqrt((double)b*b-4*a*c) << endl;
    // cout << q << " " << s << endl;
    int tmp = (int)sqrt((double)(b * b - 4 * a * c));
    // cout << tmp << endl;
    if (abs(sqrt((double)(b * b - 4 * a * c)) - (double)tmp) != 0 ||
        b * b - 4 * a * c < 0) {
      cout << "Impossible" << endl;
    } else {
      // cout << sqrt((double)(b*b-4*a*c)) << endl;
      // cout << q << " " << s << endl;
      for (int i = 1000000; i > 1; i--) {
        if (!(p % i) && !(q % i)) {
          p /= i;
          q /= i;
        }
        if (!(r % i) && !(s % i)) {
          r /= i;
          s /= i;
        }
      }

      cout << p << " " << q << " " << r << " " << s << endl;
    }
  }
}
Problem p00688 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  while (cin >> a >> b >> c, a) {
    if (c == 0) {
      if (a == 1 && b < 0)
        cout << a << ' ' << 0 << ' ' << 1 << ' ' << b << endl;
      else
        cout << a << ' ' << b << ' ' << 1 << ' ' << 0 << endl;
    } else {
      for (int j = 1; j <= a; j++) {
        if (a % j == 0) {
          if (a / j >= j)
            for (int i = 10000; i >= -10000; i--) {
              long long t, p = 0;
              if (i * j + a / j * p == b && p * i == c) {
                cout << a / j << ' ' << i << ' ' << j << ' ' << p << endl;
                goto L;
              }
              if (i != 0) {
                if (c % abs(i) == 0)
                  t = c / i;
                else
                  continue;
              } else
                continue;
              if (i * j + a / j * t == b && t * i == c) {
                if (j * j == a && i < t)
                  cout << a / j << ' ' << t << ' ' << j << ' ' << i << endl;
                else
                  cout << a / j << ' ' << i << ' ' << j << ' ' << t << endl;
                goto L;
              }
            }
          else
            break;
        }
      }
      cout << "Impossible" << endl;
    L:;
    }
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  while (cin >> a >> b >> c, a || b || c) {
    for (int j = 1; j <= a; j++) {
      if (a % j == 0)
        if (a / j >= j)
          for (int i = 20000; i >= -20000; i--)
            if (i != 0)
              if (c % abs(i) == 0) {
                long long t = c / i;
                if (i * j + a / j * t == b && t * i == c) {
                  cout << a / j << ' ' << i << ' ' << j << ' ' << t << endl;
                  goto L;
                }
              }
    }

    cout << "Impossible" << endl;
  L:;
  }
}
Problem p00688 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int tx[] = {0, 1, 0, -1};
int ty[] = {-1, 0, 1, 0};

static const double EPS = 1e-8;

int main() {
  int a, b, c;
  while (~scanf("%d %d %d", &a, &b, &c)) {
    if (a == b && b == c && c == 0)
      break;

    if (c == 0) {
      if (a != 1)
        printf("%d %d %d %d\\n", a, b, 1, 0);
      else
        printf("%d %d %d %d\\n", 1, max(0, b), 1, min(0, b));
      continue;
    }

    for (int r = 1; r * r <= a; r++) {
      if (a % r != 0)
        continue;
      int p = a / r;
      for (int s = -10000; s <= 10000; s++) {
        if (s == 0)
          continue;
        if (s != 0 && c % s != 0)
          continue;
        int q = c / s;

        if (q * r != b - p * s)
          continue;
        if ((p > 0 && r > 0) && (p > r || (p == r && q >= s))) {
          printf("%d %d %d %d\\n", p, q, r, s);
          goto next;
        }
      }
    }
    printf("Impossible\\n");
  next:;
  }
}

Error: TLE

Fixed submission:

#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int tx[] = {0, 1, 0, -1};
int ty[] = {-1, 0, 1, 0};

static const double EPS = 1e-8;

int main() {
  int a, b, c;
  while (~scanf("%d %d %d", &a, &b, &c)) {
    if (a == b && b == c && c == 0)
      break;

    if (b * b - 4 * a * c < 0) {
      printf("Impossible\\n");
      continue;
    }
    for (int p = 1; p <= 100; p++) {
      for (int q = -100; q <= 100; q++) {
        for (int r = 1; r <= p; r++) {
          for (int s = -100; s <= 100; s++) {
            if (p * r == a && p * s + q * r == b && q * s == c) {
              if (p > r || (p == r && q >= s)) {
                printf("%d %d %d %d\\n", p, q, r, s);
                goto next;
              }
            }
          }
        }
      }
    }
  next:;
  }
}
Problem p00691 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define mp make_pair

template <class T> void pv(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << *i << " ";
  cout << endl;
}
template <class T> void chmin(T &t, T f) {
  if (t > f)
    t = f;
}
template <class T> void chmax(T &t, T f) {
  if (t < f)
    t = f;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

int main() {
  Int n;
  while (n = in()) {
    Int res = n * n * n;
    Int x, y;
    for (x = 1; x < n; x++) {
      for (y = x; y < n; y++) {
        if (n * n * n < x * x * x + y * y * y)
          break;
        chmin(res, n * n * n - x * x * x - y * y * y);
      }
    }
    cout << res << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define mp make_pair

template <class T> void pv(T a, T b) {
  for (T i = a; i != b; ++i)
    cout << *i << " ";
  cout << endl;
}
template <class T> void chmin(T &t, T f) {
  if (t > f)
    t = f;
}
template <class T> void chmax(T &t, T f) {
  if (t < f)
    t = f;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

int main() {
  Int n;
  while (n = in()) {
    n *= n * n;
    Int res = n;
    Int x, y;
    for (x = 1; x < n; x++) {
      for (y = x; y < n; y++) {
        if (n < x * x * x + y * y * y)
          break;
        chmin(res, n - x * x * x - y * y * y);
      }
    }
    cout << res << endl;
  }
  return 0;
}