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

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
  int e;
  while (cin >> e, e) {
    int m = 20000000;
    int x, y, z;

    for (z = 0; z * z * z <= e; z++) {
      for (y = 0; y * y + z * z * z <= e; y++) {
        x = e - (y * y + z * z * z);
        m = min(m, x + y + z);
      }
    }
    cout << m << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
  int e;
  while (cin >> e, e) {
    int m = 20000000;
    int x, y, z;

    for (z = 0; (int)pow(z, 3) <= e; z++) {
      for (y = 0; (int)pow(y, 2) + (int)pow(z, 3) <= e; y++) {
        x = e - ((int)pow(y, 2) + (int)pow(z, 3));
        m = min(m, x + y + z);
      }
    }
    cout << m << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <iostream>
using namespace std;

int main() {
  int e, x;
  while (1) {
    cin >> e;
    if (e == 0)
      break;
    int m1 = 0, m = 1000;
    for (int y = 0; y * y <= e; y++)
      for (int z = 0; z * z * z <= e - y * y; z++) {
        x = e - z * z * z - y * y;
        m1 = x + y + z;
        if (m > m1)
          m = m1;
      }
    cout << m << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int e;
  while (1) {
    cin >> e;
    if (e == 0)
      break;
    int m1 = 0, m = 1000;
    for (int i = 0; i <= e; i++)
      for (int j = 0; j <= (e - i); j++)
        for (int k = 0; k <= (e - i - j); k++)
          if (e == i + (j * j) + (k * k * k)) {
            m1 = i + j + k;
            if (m > m1)
              m = m1;
          }
    cout << m << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

// Space Coconut Crab
#include <iostream>
using namespace std;
int count = 0; // ?¨???¬??¨ global ?????°
int solve(int E) {
  // ?????´????±???????
  // x+y*y+z*z*z=E
  int ans = E; // ?????§???
  for (int z = 0; z * z * z <= E; ++z)
    for (int y = 0; y * y <= E - z * z * z; ++y) {
      int x = E - y * y - z * z * z;
      ++count;
      if (x + y + z < ans) // x+y+z??????????°??????????ans?????´??°
        ans = x + y + z;
    }
  return ans;
}
int main() {
  int E;
  while (cin >> E && E > 0) {
    cout << solve(E) << endl;
  }
}
// ?????´?????????????????¨??????????????????????????????
// 10^11???...8?§???\\?????????

Error: TLE

Fixed submission:

// Space Coconut Crab
#include <iostream>
using namespace std;
int count = 0; // ?¨???¬??¨ global ?????°
int solve(int E) {
  // ?????´????±???????
  // x+y*y+z*z*z=E
  int ans = E; // ?????§???
  for (int z = 0; z * z * z <= E; ++z)
    for (int x = 0; x <= E - z * z * z; ++x)
      for (int y = 0; y * y <= E - x - z * z * z; ++y) {
        ++count;
        if (x + y * y + z * z * z == E)
          if (x + y + z < ans) // x+y+z??????????°??????????ans?????´??°
            ans = x + y + z;
      }
  return ans;
}
int main() {
  int E;
  while (cin >> E && E > 0) {
    cout << solve(E) << endl;
  }
}
// ?????´?????????????????¨??????????????????????????????
// 10^11???...8?§???\\?????????
// xy????±??????????z????±??????????????????????????????????
// zy
// xz
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int n;
void init() { n = 0; }

int input() {
  cin >> n;
  return n;
}

int solve() {
  int res = n;
  for (int z = 0; z * z * z <= n; z++) {
    for (int y = 0; y * y + z * z * z <= n; y++) {
      res = min(n - (z * z * z) - (y * y) + y + z, res);
    }
  }
  return res;
}

int main() {
  while (init(), input()) {
    cout << solve() << endl;
  }
}

Error: TLE

Fixed submission:

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

int n;
void init() { n = 0; }

int input() {
  cin >> n;
  return n;
}

int solve() {
  for (int m = 0; m <= n; m++) {
    for (int i = m; i >= 0; i--) {
      for (int j = m - i; j >= 0; j--) {
        if (i * i * i + j * j + (m - i - j) == n) {
          return m;
        }
      }
    }
  }
}

int main() {
  while (init(), input()) {
    cout << solve() << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int i, j, e, x, y, z, m, min;
  while (1) {
    min = 1000000;
    cin >> e;
    if (e == 0)
      break;
    for (y = 0; y <= 1000; y++) {
      for (z = 0; z <= 100; z++) {
        x = e - y * y - z * z * z;
        m = x + y + z;
        if (min > m && x >= 0 && y >= 0 && z >= 0) {
          // cout << "x" << x << " " << "y" << y << " " << "z" << z << endl;
          min = m;
          // cout << "min" << min << endl;
        }
      }
    }
    cout << min << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int i, j, k, e, x, y, z, m;
  while (1) {
    int min = 1000000;
    cin >> e;
    if (e == 0)
      break;

    for (x = 0; x <= 1000; x++) {
      for (y = 0; y <= 1000; y++) {
        for (z = 0; z <= 1000; z++) {
          if (x + y * y + z * z * z == e) {
            m = x + y + z;
            if (m < min)
              min = m;
            // cout << m << endl;
          }
        }
      }
    }
    cout << min << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REAP(i, a, n) for (int i = (a); i < (n); i++)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(), v.end()
typedef long long ll;

int main() {
  ll e;
  while (cin >> e, e) {
    ll m = e;
    for (int y = 0; y * y <= e; y++) {
      for (int z = 0; z * z * z + y * y <= e; z++) {
        m = min(m, y + z + (e - y * y - z * z * z));
      }
    }
    cout << m << endl;
  }
}


Error: TLE

Fixed submission:

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REAP(i, a, n) for (int i = (a); i < (n); i++)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(), v.end()
typedef long long ll;

int main() {
  ll e;
  while (cin >> e, e) {
    ll m = e;
    for (int y = 0; y * y <= e; y++) {
      for (int z = 0; z * z * z + y * y <= e; z++) {
        m = min(m, y + z + (e - (ll)pow(y, 2) - (ll)pow(z, 3)));
      }
    }
    cout << m << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int e;
  while (cin >> e, e != 0) {
    int m = 1000000;
    for (int z = 0; z * z * z <= e; z++) {
      int y = (int)sqrt(e - z * z * z);
      m = min(m, (e - z * z * z - y * y) + y + z);
    }

    cout << m << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int e;
  while (cin >> e, e != 0) {
    int m = 1000000;
    for (int z = 0; z * z * z <= e; z++) {
      for (int y = 0; y * y <= e - z * z * z; y++) {
        for (int x = 0; x <= e - z * z * z - y * y; x++) {
          if (x + y * y + z * z * z == e) {
            m = min(m, x + y + z);
            break;
          }
        }
      }
    }

    cout << m << endl;
  }

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

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  while (1) {
    int e;
    cin >> e;
    if (e == 0)
      break;
    int ans = e + 1;
    for (int y = 0; y * y <= e; y++)
      for (int z = 0; z * z * z <= e; z++)
        if (y * y + z * z * z <= e)
          ans = min(ans, e - y * y - z * z * z + y + z);
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  while (1) {
    int e;
    cin >> e;
    if (e == 0)
      break;
    int ans = e + 1;
    for (int x = 0; x * x <= e; x++)
      for (int y = 0; y * y <= e; y++)
        for (int z = 0; z * z * z <= e; z++)
          if (x + y * y + z * z * z == e)
            ans = min(ans, x + y + z);
    cout << ans << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iostream>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;

int main() {
  int e, ans;
  while (scanf("%d", &e), e) {
    ans = e;
    int x;
    double d = sqrt(e) + 1, g = pow(e, (double)1 / 3) + 1;
    rep(y, d) {
      rep(z, g) {
        x = e - y * y - z * z * z;
        if (x < 0)
          continue;
        ans = min(ans, x + y + z);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;

int main() {
  int e, ans;
  while (cin >> e, e) {
    ans = e;
    int x;
    rep(y, sqrt(e) + 1) {
      rep(z, pow(e, (double)1 / 3) + 1) {
        x = e - y * y - z * z * z;
        if (x < 0)
          continue;
        ans = min(ans, x + y + z);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  int e;
  while (cin >> e) {
    if (e == 0)
      break;
    int m = e, x, ct = 0;
    for (int z = pow(e, 0.333333333333333334) + 1; z >= 0; z--) {
      for (int y = 0; y < pow(e - z * z * z, 0.5) + 1; y++) {
        if (e - z * z * z - y * y >= 0) {
          x = e - z * z * z - y * y;
          m = min(m, x + y + z);
          ct++;
          if (ct > 10000) {
            goto end;
          }
        } else {
          break;
        }
      }
    }
  end:;
    cout << m << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  int e;
  while (cin >> e) {
    if (e == 0)
      break;
    int m = e;
    ;
    for (int z = 0; z < pow(e, 0.3333334) + 1; z++) {
      for (int y = 0; y < pow(e, 0.5) + 1; y++) {
        for (int x = 0; x < e + 1; x++) {
          if (x + y * y + z * z * z == e) {
            m = min(m, x + y + z);
            break;
          } else if (x + y * y + z * z * z > e)
            break;
        }
      }
    }
    cout << m << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int e, dp[1000001];
  for (int i = 0; i < 1000001; i++) {
    dp[i] = i;
  }

  for (int i = 0; i < 101; i++) {
    dp[i * i * i] = min(i, dp[i * i * i]);
    for (int j = 0; i * i * i + j * j < 1000001 && j < 1001; j++) {
      dp[j * j] = min(j, dp[j * j]);
      dp[i * i * i + j * j] = min(i + j, dp[i * i * i + j * j]);
    }
  }

  for (int i = 1; i < 1000001; i++) {
    dp[i] = min(dp[i - 1] + 1, dp[i]);
  }

  while (cin >> e, e) {
    cout << dp[e] << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int e;
  while (cin >> e, e) {
    int res = 1000000;
    for (int i = 0; i <= e && i < res; i++) {
      for (int j = 0; i + j * j <= e && i + j < res; j++) {
        for (int k = 0; i + j * j + k * k * k <= e && i + j + k < res; k++) {
          if (i + j * j + k * k * k == e) {
            res = min(res, i + j + k);
          }
        }
      }
    }

    cout << res << endl;
  }

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

#include <climits>
#include <iostream>
using namespace std;
int main() {
  int e, m, p, q, r, min, x;
  while (cin >> e, e) {
    min = INT_MAX;
    for (int z = 0; z * z * z <= e; z++)
      for (int y = 0; y * y + z * z * z <= e; y++) {
        x = e - z * z * z - y * y;
        if (x + y + z < min)
          min = x + y + z;
      }
    cout << min << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <climits>
#include <iostream>
using namespace std;
int main() {
  int x, y, z, e, m, p, q, r, min;
  while (cin >> e, e) {
    x = 0;
    y = 0;
    z = 0;
    min = INT_MAX;
    for (p = 0; p * p * p <= e; p++)
      if (p > z)
        z = p;
    for (int i = z; i >= 0; i--) {
      for (q = 0; q * q <= e - i; q++)
        if (q > y)
          y = q;
      for (int j = y; j >= 0; j--) {
        for (r = 0; r <= e - i - j; r++)
          if (r > x)
            x = r;
        for (int k = 0; k <= x; k++) {

          if (i * i * i + j * j + k == e) {
            if (min > i + j + k)
              min = i + j + k;
            break;
          }
        }
      }
    }
    cout << min << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
using namespace std;
int calcOver(int, int);
int calcM(int, int, int);

int main() {
  while (true) {
    int e;
    cin >> e;
    if (e == 0)
      break;
    int y = 0;
    int z = 0;
    int maxover = 0;
    int limity = pow(e, 1.0 / 2.0) + 1;
    int limitz = pow(e, 1.0 / 3.0) + 1;
    int maxy = limity;
    int maxz = limitz;
    int minm = e;
    bool flag = false;
    // cout << limity << ":" << limitz << endl;
    for (y = limity; y >= 0; --y) {
      for (int z = limitz; z >= 0; --z) {
        int m = calcM(e, y, z);
        // if((y + z <= m) && (m <= y + z + e)) {
        if (e >= calcOver(y, z)) {
          // cout << y << ":" << z << ":" << ":" << m << endl;
          if (minm > m) {
            maxy = y;
            maxz = z;
            minm = m;
          }
        }
      }
    }
    // cout << maxy << ":" << maxz << endl;
    cout << minm << endl;
  }
  return 0;
}

int calcOver(int y, int z) { return (y * y + z * z * z); }
int calcM(int e, int y, int z) { return (e - y * y - z * z * z + y + z); }

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
using namespace std;
int calcOver(int, int);
int calcM(int, int, int);

int main() {
  while (true) {
    int e;
    cin >> e;
    if (e == 0)
      break;
    int y = 0;
    int z = 0;
    int maxover = 0;
    int limity = pow(e, 1.0 / 2.0) + 1;
    int limitz = pow(e, 1.0 / 3.0) + 1;
    int maxy = limity;
    int maxz = limitz;
    int minm = e;
    bool flag = false;
    // cout << limity << ":" << limitz << endl;
    for (y = limity; y >= 0; --y) {
      for (int z = limitz; z >= 0; --z) {
        int m = calcM(e, y, z);
        if ((y + z <= m) && (m <= y + z + e)) {
          // cout << y << ":" << z << ":" << ":" << m << endl;
          if (minm > m) {
            maxy = y;
            maxz = z;
            minm = m;
          }
        }
      }
    }
    // cout << maxy << ":" << maxz << endl;
    cout << (e - pow(maxy, 2) - pow(maxz, 3) + maxy + maxz) << endl;
  }
  return 0;
}

int calcOver(int y, int z) { return (pow(y, 2) + pow(z, 3)); }
int calcM(int e, int y, int z) { return (e - pow(y, 2) - pow(z, 3) + y + z); }
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int e;

void solve() {
  int m = e;

  for (int y = 0; y * y <= e; y++) {
    for (int z = 0; z * z * z <= e; z++) {
      int x = e - (y * y) - (z * z * z);
      if (0 <= x) {
        m = min(m, x + y + z);
      }
    }
  }

  cout << m << endl;
}

int main() {
  while (1) {
    cin >> e;
    if (e == 0)
      break;
    solve();
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int e;

void solve() {
  int m = e;

  for (int x = 0; x <= e; x++) {
    for (int y = 0; y * y <= e; y++) {
      for (int z = 0; z * z * z <= e; z++) {
        if (x + y * y + z * z * z == e) {
          m = min(m, x + y + z);
        }
      }
    }
  }

  cout << m << endl;
}

int main() {
  while (1) {
    cin >> e;
    if (e == 0)
      break;
    solve();
  }

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

#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int e, m;
  while (cin >> e, e) {
    m = 1000000;
    for (int z = 0; pow(z, 3) <= e; z++) {
      int y = sqrt(e - pow(z, 3));
      int x = e - pow(y, 2) - pow(z, 3);
      m = min(m, x + y + z);
      // cout << x << ":" << y << ":" << z << " " << (x+y+z) << endl;
    }
    cout << m << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <utility>

using namespace std;

int main() {
  int e, m;
  while (cin >> e, e) {
    m = 1000000;
    for (int i = 0; pow(i, 3) <= e; i++) {
      for (int j = 0; (pow(i, 3) + pow(j, 2)) <= e; j++) {
        int k = e - pow(i, 3) - pow(j, 2);
        m = min(m, i + j + k);
      }
    }
    cout << m << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  while (1) {
    int e, min = 100000000, ans;
    cin >> e;
    if (e == 0)
      break;
    for (int i = 0; i * i * i <= e; i++) {
      for (int j = 0; j * j <= e; j++) {
        ans = e - (i * i * i + j * j);
        if (min > ans + j + i && e >= ans && ans >= 0)
          min = ans + i + j;
      }
    }
    cout << min << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  while (1) {
    int e, min = 100000000, ans;
    cin >> e;
    if (e == 0)
      break;
    for (int i = 0; i <= e; i++) {
      for (int j = 0; j <= e; j++) {
        ans = e - (i * i + j * j * j);
        if (min > ans + j + i && e >= ans && ans >= 0)
          min = ans + i + j;
      }
    }
    cout << min << endl;
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  while (true) {
    int e;
    cin >> e;

    if (e == 0) {
      break;
    }

    int ans = e;

    for (int y = 0; y * y <= e; y++) {
      for (int z = 0; z * z * z <= e; z++) {
        if (y * y + z * z * z <= e) {
          ans = min(e - y * y - z * z * z + y + z, ans);
        }
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  while (true) {
    int e;
    cin >> e;

    if (e == 0) {
      break;
    }

    int ans = e;

    for (int x = 0; x <= e; x++) {
      for (int y = 0; y * y <= e; y++) {
        for (int z = 0; z * z * z <= e; z++) {
          if (x + y * y + z * z * z == e) {
            ans = min(x + y + z, ans);
          }
        }
      }
    }

    cout << ans << endl;
  }

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

#include <iostream>
#include <math.h>
using namespace std;
int e;
int main() {
  for (;;) {
    cin >> e;
    ;
    int m = e;
    if (e == 0)
      break;
    for (int y = 0; y * y <= e; y++) {
      for (int z = 0; y * y + z * z * z <= e; z++) {
        int x = e - z * z * z - y * y;
        if (x + y + z < m) {
          m = x + y + z;
        }
      }
    }
    cout << m << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
using namespace std;
int e;
int main() {
  for (;;) {
    cin >> e;
    ;
    int m = e;
    if (e == 0)
      break;
    for (int y = 0; pow(y, 2) <= e; y++) {
      for (int z = 0; pow(y, 2) + pow(z, 3) <= e; z++) {
        int x = e - pow(z, 3) - pow(y, 2);
        if (x + y + z < m) {
          m = x + y + z;
        }
      }
    }
    cout << m << endl;
  }
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

// AOJ 2012

#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  vector<int> data;
  for (int i = 1; i * i <= 1000000; i++) {
    data.push_back(i * i);
  }

  int e;
  while (cin >> e, e) {
    int ret = 1001001001;
    for (int i = 0; 0 <= e - i * i * i; i++) {
      int y = sqrt(e - i * i * i);
      int x = e - i * i * i - y * y;
      ret = min(ret, x + y + i);
    }
    cout << ret << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

// AOJ 2012

#include <iostream>

using namespace std;

int main(void) {
  int e;
  while (cin >> e, e) {
    int minnum = 1001001;

    for (int i = 0; i <= 1000; i++) {
      for (int j = 0; j <= 100; j++) {
        for (int k = 0; k <= 100; k++) {
          if (i + (j * j) + (k * k * k) == e) {
            minnum = min(minnum, i + j + k);
          }
        }
      }
    }

    cout << minnum << endl;
  }

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

#include <math.h>
#include <stdio.h>
int main() {

  int E;
  while (1) {
    scanf("%d", &E);
    if (E == 0)
      break;
    int min = E;
    int m = E, max = 0;
    int i = 1;
    int y = 0, z = 0;
    for (int j = 0; j * j <= (E); j++) {

      for (int k = 0; k * k * k <= (E - j * j); k++) {
        i = E - j * j - k * k * k; // printf("%d %d %d\\n",i,j,k*k*k);
        if (i + j * j + k * k * k > E)
          break;
        if (i >= 0 && i + j * j + k * k * k == E && i + j + k < min) {
          min = i + j + k;
          max = j * j + k * k * k;
          y = j;
          z = k;
        }
      }
    }
    i = E - y * y - z * z * z;
    m = i + y + z;
    printf("%d\\n", min);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <math.h>
#include <stdio.h>
int main() {

  int E;
  while (1) {
    scanf("%d", &E);
    if (E == 0)
      break;
    int min = E;
    int m = E, max = 0;
    int i = 1;
    int y = 0, z = 0;
    for (int j = 0; j <= sqrt((double)(E)); j++) {

      for (int k = 0; k <= pow((double)(E - j * j) + 1, 1.0 / 3.0); k++) {
        i = E - j * j - k * k * k; // printf("%d %d %d\\n",i,j,k*k*k);
        if (i + j * j + k * k * k > E)
          break;
        if (i >= 0 && i + j * j + k * k * k == E && i + j + k < min) {
          min = i + j + k;
          max = j * j + k * k * k;
          y = j;
          z = k;
        }
      }
    }
    i = E - y * y - z * z * z;
    m = i + y + z;
    printf("%d\\n", min);
  }
  return 0;
}
Problem p01137 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n;
  // x+y*y+z*z*zの、xが最少となるyとzの組み合わせを探す。
  while (cin >> n, n) {
    int ans = 10e8, now = n, now2 = n, ans2 = 0, tmp = 10e8;
    for (int i = 0; i * i <= n; i++) {
      for (int j = 0; j * j * j <= n; j++) {
        if (n - i * i - j * j * j >= 0) {
          tmp = min(n - i * i - j * j * j, tmp);
          ans = min(i + j + (n - i * i - j * j * j), ans);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int e;

  while (cin >> e, e) {
    int m = 0;
    vector<int> anss(0);
    for (int i = 0; i <= e; i++) {
      for (int j = 0; j * j <= e; j++) {
        for (int k = 0; k * k * k <= e; k++) {
          if (i + j * j + k * k * k < e)
            break;
          if (i + j * j + k * k * k == e)
            anss.push_back(i + j + k);
        }
      }
    }
    sort(anss.begin(), anss.end());
    cout << anss[0] << endl;
  }
  return 0;
}