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

#include <stdio.h>
int main() {
  int m, f, r, summf;
  while (1) {
    scanf("%d %d %d", &m, &f, &r);
    if (m == -1 && f == -1 && r == -1) {
      break;
    }
    summf = m + f;
    if (m == -1 || f == -1) {
      printf("F\\n");
    } else if (80 <= summf) {
      printf("A\\n");
    } else if (65 <= summf && summf < 80) {
      printf("B\\n");
    } else if (50 <= summf && summf < 65) {
      printf("C\\n");
    } else if (30 <= summf && summf < 50) {
      if (r >= 50) {
        printf("C\\n");
      } else
        printf("D\\n");
    } else if (summf < 30) {
      printf("F\\n");
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int m, f, r, summf;
  while (1) {
    scanf("%d %d %d", &m, &f, &r);
    if (m == -1 && f == -1 && r == -1) {
      continue;
    }
    summf = m + f;
    if (m == -1 || f == -1) {
      printf("F\\n");
    } else if (80 <= summf) {
      printf("A\\n");
    } else if (65 <= summf && summf < 80) {
      printf("B\\n");
    } else if (50 <= summf && summf < 65) {
      printf("C\\n");
    } else if (30 <= summf && summf < 50) {
      if (r >= 50) {
        printf("C\\n");
      } else
        printf("F\\n");
    } else if (summf < 30) {
      printf("F\\n");
    }
  }
  printf("\\n");
  return 0;
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int m, f, r;

  while (1) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }

    if (m == -1 || f == -1) {
      cout << 'F' << endl;
    } else if (m + f >= 80) {
      cout << 'A' << endl;
    } else if (m + f >= 65) {
      cout << 'B' << endl;
    } else if (m + f >= 50) {
      cout << 'C' << endl;
    } else if (m + f >= 30) {
      if (r >= 50) {
        cout << 'C' << endl;
      } else {
        cout << 'D' << endl;
      }
    } else {
      cout << 'F' << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int m, f, r;

  while (1) {
    cin >> m >> r >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }

    if (m == -1 || f == -1) {
      cout << 'F' << endl;
    } else if (m + f >= 80) {
      cout << 'A' << endl;
    } else if (m + f >= 65) {
      cout << 'B' << endl;
    } else if (m + f >= 50) {
      cout << 'C' << endl;
    } else if (m + f >= 30) {
      if (r >= 50) {
        cout << 'C' << endl;
      } else {
        cout << 'D' << endl;
      }
    } else {
      cout << 'F' << endl;
    }
  }

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

#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  int p;
  while (1) {
    cin >> a >> b >> c;

    p = a + b;

    if (a == -1 && b == -1 && c == -1)
      break;

    if (a == -1) {
      cout << "F" << endl;
      continue;
    }

    if (b == -1) {
      cout << "F" << endl;
      continue;
    }

    if (80 <= p)
      cout << "A";
    else if (65 <= p && p < 80)
      cout << "B";
    else if (50 <= p && p < 65)
      cout << "C";
    else if (30 <= p && p < 50)
      if (50 <= c)
        cout << "C";
      else
        cout << "D";
    else
      cout << "F";

    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int a, b, c;
  while (1) {
    cin >> a >> b >> c;

    if (a == -1)
      a = 0;
    if (b == -1)
      b = 0;

    if (80 <= a + b)
      cout << "A";
    else if (65 <= a + b && a + b < 80)
      cout << "B";
    else if (50 <= a + b && a + b < 65)
      cout << "C";
    else if (30 <= a + b && a + b < 50)
      if (50 <= c)
        cout << "C";
      else
        cout << "D";
    else
      cout << "F";

    cout << endl;

    if (a == -1 && b == -1 && c == -1)
      break;
  }
  return 0;
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> P;
typedef vector<P> vp;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define REPR(i, n) for (ll i = n - 1; i >= 0; i--)
#define FORR(i, n, m) for (ll i = n - 1; i >= m; i--)
#define all(in) in.begin(), in.end()
#define ALL(in, K) in, in + K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 3.14159265358979323846

int main() {
  ll m, f, r;
  ll roop = 0;
  char result[52];
  while (1) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    } else if (m == -1 || f == -1 || m + f < 30) {
      result[roop] = 'F';
    } else if (m + f >= 80) {
      result[roop] = 'A';
    } else if (m + f >= 65) {
      result[roop] = 'B';
    } else if (m + f >= 50 || (m + f >= 30 && r >= 50)) {
      result[roop] = 'C';
    } else {
      result[roop] = 'D';
    }
    roop++;
  }
  REP(i, roop) { cout << result[i] << endl; }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> P;
typedef vector<P> vp;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define REPR(i, n) for (ll i = n - 1; i >= 0; i--)
#define FORR(i, n, m) for (ll i = n - 1; i >= m; i--)
#define all(in) in.begin(), in.end()
#define ALL(in, K) in, in + K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define pi 3.14159265358979323846

int main() {
  ll m, f, r;
  ll roop = 0;
  char result[52];
  while (1) {
    cin >> m >> f >> r;
    if (m == 0 && f == 0 && r == 0) {
      break;
    } else if (m == -1 || f == -1 || m + f < 30) {
      result[roop] = 'F';
    } else if (m + f >= 80) {
      result[roop] = 'A';
    } else if (m + f >= 65) {
      result[roop] = 'B';
    } else if (m + f >= 50 || m + f >= 30 && r >= 50) {
      result[roop] = 'C';
    } else {
    }
    roop++;
  }
  return 0;
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  while (1) {
    int m, f, r;
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }
    if (m == -1 or f == -1) {
      cout << "F" << endl;
    } else if (m + f > 79) {
      cout << "A" << endl;
    } else if (m + f < 80 && m + f > 64) {
      cout << "B" << endl;
    } else if (m + f < 65 && m + f > 49) {
      cout << "C" << endl;
    } else if (m + f < 50 && m + f > 29 && r > 49) {
      cout << "C" << endl;
    } else if (m + f < 50 && m + f > 29) {
      cout << "D" << endl;
    } else {
      cout << "F" << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  while (1) {
    int m, f, r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }
    if (m == -1 or f == -1) {
      cout << "F" << endl;
    } else if (m + f > 79) {
      cout << "A" << endl;
    } else if (m + f < 80 && m + f > 64) {
      cout << "B" << endl;
    } else if (m + f < 65 && m + f > 49) {
      cout << "C" << endl;
    } else if (m + f < 50 && m + f > 29 && r > 49) {
      cout << "C" << endl;
    } else if (m + f < 50 && m + f > 29) {
      cout << "D" << endl;
    } else {
      cout << "F" << endl;
    }
  }
  return 0;
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int m, f, r;

  while (1) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }

    if (m == -1 || f == -1) {
      cout << 'F' << endl;
    } else if (m + f >= 80) {
      cout << 'A' << endl;
    } else if (m + f >= 65) {
      cout << 'B' << endl;
    } else if (m + f >= 50) {
      cout << 'C' << endl;
    } else if (m + f >= 30) {
      if (r >= 50) {
        cout << 'C' << endl;
      } else {
        cout << 'D' << endl;
      }
    } else {
      cout << 'F' << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int m, f, r;

  while (1) {
    cin >> m >> f >> r;

    if (m == -1 || f == -1) {
      cout << 'F' << endl;
    } else if (m + f >= 80) {
      cout << 'A' << endl;
    } else if (m + f >= 65) {
      cout << 'B' << endl;
    } else if (m + f >= 50) {
      cout << 'C' << endl;
    } else if (m + f >= 30) {
      if (r >= 50) {
        cout << 'C' << endl;
      } else {
        cout << 'D' << endl;
      }
    } else {
      cout << 'F' << endl;
    }
  }

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

/*
 * itikara.cpp
 *
 *  Created on: 2018/05/30
 *      Author: J01003
 */
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int m, f, r;
  while (1) {
    while (1) {
      cin >> m >> f >> r;
      if (m == -1 && f == -1 && r == -1) {
        return 0;
      };
      if (m == 0 && f == 0) {
        cout << "F" << endl;
        break;
      }
      if (m == -1) {
        cout << "F" << endl;
        break;
      }
      if (f == -1) {
        cout << "F" << endl;
        break;
      }
      if (m + f >= 80) {
        cout << "A" << endl;
        break;
      }
      if (m + f < 80 && m + f >= 65) {
        cout << "B" << endl;
        break;
      }
      if (m + f < 65 && m + f >= 50) {
        cout << "C" << endl;
        break;
      }
      if (m + f < 50 && m + f >= 30 && r >= 50) {
        cout << "C" << endl;
        break;
      }
      if (m + f < 50 && m + f >= 30) {
        cout << "D" << endl;
        break;
      }
      if (m + f < 30) {
        cout << "F" << endl;
        break;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

/*
 * itikara.cpp
 *
 *  Created on: 2018/05/30
 *      Author: J01003
 */
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int m, f, r;
  while (1) {
    while (1) {
      cin >> m >> f >> r;
      if (m == -1 && f == -1 && r == -1) {
        break;
      };
      if (m + f >= 80) {
        cout << "A" << endl;
        break;
      }
      if (m + f < 80 && m + f >= 65) {
        cout << "B" << endl;
        break;
      }
      if (m + f < 65 && m + f >= 50) {
        cout << "C" << endl;
        break;
      }
      if (m + f < 50 && m + f >= 30 && r >= 50) {
        cout << "E" << endl;
        break;
      }
      if (m + f < 50 && m + f >= 30) {
        cout << "D" << endl;
        break;
      }
      if (m + f < 30) {
        cout << "F" << endl;
        break;
      }
      if (m == -1 && f == -1 && r == -1) {
        break;
      };
    }
  }
  return 0;
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int m, f, r;
  while (true) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1)
      break;
    if (m == -1 || f == -1)
      cout << 'F' << endl;
    else if (m + f >= 80)
      cout << 'A' << endl;
    else if (m + f >= 65)
      cout << 'B' << endl;
    else if (m + f >= 50)
      cout << 'C' << endl;
    else if (m + f >= 30) {
      if (r >= 50)
        cout << 'C' << endl;
      else
        cout << 'D' << endl;
    } else
      cout << 'F' << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int m, f, r;
  while (true) {
    cin >> m >> f >> r;
    if (m == f == r == -1)
      break;
    if (m == -1 || f == -1)
      cout << 'F' << endl;
    else if (m + f >= 80)
      cout << 'A' << endl;
    else if (m + f >= 65)
      cout << 'B' << endl;
    else if (m + f >= 50)
      cout << 'C' << endl;
    else if (m + f >= 30) {
      if (r >= 50)
        cout << 'C' << endl;
      else
        cout << 'D' << endl;
    } else
      cout << 'F' << endl;
  }
  return 0;
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  while (true) {
    char grade;
    int m, f, r;
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1)
      break;
    if (m == -1 || f == -1) {
      grade = 'F';
    } else if (m + f >= 80) {
      grade = 'A';
    } else if (m + f >= 65) {
      grade = 'B';
    } else if (m + f >= 50) {
      grade = 'C';
    } else if (m + f >= 30) {
      (r >= 50) ? grade = 'C' : grade = 'D';
    } else {
      grade = 'F';
    }
    cout << grade << endl;
  }
}


Error: TLE

Fixed submission:

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

int main() {
  while (true) {
    char grade;
    int m, f, r;
    cin >> m >> f >> r;
    if (m == 0 && f == 0 && r == 0)
      break;
    if (m == -1 || f == -1) {
      grade = 'F';
    } else if (m + f >= 80) {
      grade = 'A';
    } else if (m + f >= 65) {
      grade = 'B';
    } else if (m + f >= 50) {
      grade = 'C';
    } else if (m + f >= 30) {
      (r >= 50) ? grade = 'C' : grade = 'D';
    } else {
      grade = 'F';
    }
    cout << grade << endl;
  }
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int m, f, r;
  while (cin >> m >> f >> r, m != -1 || f != -1 || r != -1) {
    if (m == -1 || f == -1)
      cout << 'F';
    else if (m + f >= 80)
      cout << 'A';
    else if (m + f >= 65)
      cout << 'B';
    else if (m + f >= 50)
      cout << 'C';
    else if (m + f >= 30) {
      if (r >= 50)
        cout << 'C';
      else
        cout << 'D';
    } else
      cout << 'F';
    cout << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int m, f, r;
  while (cin >> m >> f >> r, m != 0 || f != 0 || r != 0) {
    if (m + f >= 80)
      cout << 'A';
    else if (m + f >= 65)
      cout << 'B';
    else if (m + f >= 50)
      cout << 'C';
    else if (m + f >= 30) {
      if (r >= 50)
        cout << 'C';
      else
        cout << 'D';
    } else
      cout << 'F';
    cout << endl;
  }
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>

int main() {
  int m, f, r;
  int scores[50];
  char grade[5] = {'A', 'B', 'C', 'D', 'F'};
  while (1) {
    scanf("%d %d %d", &m, &f, &r);
    if (m == -1 && f == -1 && r == -1) {
      break;
    } else if (f == -1 || m == -1) {
      printf("%c\\n", grade[4]);
    } else if ((f + m) >= 80) {
      printf("%c\\n", grade[0]);
    } else if (65 <= (f + m) && (f + m) < 80) {
      printf("%c\\n", grade[1]);
    } else if (50 <= (f + m) && (f + m) < 65) {
      printf("%c\\n", grade[2]);
    } else if (30 <= (f + m) && (f + m) < 50) {
      if (r >= 50) {
        printf("%c\\n", grade[2]);
      } else if (-1 <= r && r < 50) {
        printf("%c\\n", grade[3]);
      }
    } else if ((f + m) < 30) {
      printf("%c\\n", grade[4]);
    }
  }
}


Error: TLE

Fixed submission:

#include <cstdio>

int main() {

  int a, b;
  char op;
  while (1) {
    scanf("%d %c %d", &a, &op, &b);
    if (op == '?') {
      break;
    } else if (op == '+') {
      printf("%d\\n", a + b);
    } else if (op == '-') {
      printf("%d\\n", a - b);
    } else if (op == '*') {
      printf("%d\\n", a * b);
    } else if (op == '/') {
      printf("%d\\n", a / b);
    }
  }
}
Problem p02412 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n, x, ctr;
  cin >> n >> x;
  while (n != 0 || x != 0) {
    ctr = 0;
    for (int i = 1; i <= n - 2; i++) {
      for (int j = i + 1; j <= n - 1; j++) {
        if (x - i - j > j && x - i - j <= n) {
          ctr++;
        }
      }
    }
    cout << ctr << endl;
    cin >> n >> x;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int n, x, ctr;
  cin >> n >> x;
  while (n != 0 || x != 0) {
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        if (n - i - j > 0) {
          ctr++;
        }
      }
    }
    cout << ctr << endl;
  }
}
Problem p02412 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <stack>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x;
  stack<int> st;
  int i, s;
  int cnt = 0;
  while (cin >> n >> x && (n > 0 || x > 0)) {
    st = stack<int>();
    i = 1;
    s = 0;
    cnt = 0;
    if (x == 0) {
      cout << 0 << "\\n";
      continue;
    }
    while (i <= n) {
      if (st.size() < 3 && s + i <= x) {
        st.push(i);
        s += i;
        if (st.size() == 3 && s == x)
          cnt++;
      }
      if (s >= x) {
        i = st.top() + 1;
        s -= st.top();
        st.pop();
      } else {
        i++;
      }
      while (i > n && st.size() > 0) {
        i = st.top() + 1;
        s -= st.top();
        st.pop();
      }
    }
    cout << cnt << "\\n";
  }
}

Error: 0

Fixed submission:

#include <iostream>
#include <stack>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x;
  while (cin >> n >> x && (n > 0 || x > 0)) {
    stack<int> st;
    int i = 1, s = 0;
    int cnt = 0;
    while (i <= n) {
      if (st.size() < 3 && s + i <= x) {
        st.push(i);
        s += i;
        if (st.size() == 3 && s == x)
          cnt++;
      }
      if (s >= x) {
        i = st.top() + 1;
        s -= st.top();
        st.pop();
      } else {
        i++;
      }
      while (i > n && st.size() > 0) {
        i = st.top() + 1;
        s -= st.top();
        st.pop();
      }
    }
    cout << cnt << "\\n";
  }
}
Problem p02412 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#define MAXNUM 200
#define MAXSUM 600
using namespace std;

int dp2[MAXNUM][MAXSUM];
int dp3[MAXNUM][MAXSUM];

int main() {
  int n, m, i, j;
  while (1) {
    cin >> n >> m;
    if (n == 0)
      break;
    for (i = 2; i <= n; i++) {
      for (j = 3; j <= m; j++) {
        dp2[i][j] = dp2[i - 1][j];
        if (j - i > 0 && i - 1 >= j - i)
          dp2[i][j]++;
        dp3[i][j] = dp3[i - 1][j];
        if (j - i > 0)
          dp3[i][j] += dp2[i - 1][j - i];
      }
    }

    cout << dp3[n][m] << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#define MAXNUM 100
#define MAXSUM 300
using namespace std;

int dp2[MAXNUM][MAXSUM];
int dp3[MAXNUM][MAXSUM];

int main() {
  int n, m, i, j;
  while (1) {
    cin >> n >> m;
    if (n == 0)
      break;
    for (i = 2; i <= n; i++) {
      for (j = 3; j <= m; j++) {
        dp2[i][j] = dp2[i - 1][j];
        if (j - i > 0 && i - 1 >= j - i)
          dp2[i][j]++;
        dp3[i][j] = dp3[i - 1][j];
        if (j - i > 0)
          dp3[i][j] += dp2[i - 1][j - i];
      }
    }

    cout << dp3[n][m] << endl;
  }
  return 0;
}
Problem p02412 (C++) — buggy submission, verdict: Runtime Error

#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
  while (true) {
    int i, j, k, n, m, x;
    scanf("%d", &n);
    scanf("%d", &m);

    if (n == 0 && m == 0) {
      break;
    }

    x = 0;
    for (i = 1; i < n - 1; i++) {
      for (j = i + 1; j < n; j++) {
        for (k = j + 1; k < n + 1; k++) {
          if (i + j + k == m) {
            x += 1;
          }
        }
      }
    }
    printf("%d\\n", x);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
  while (1) {
    int i, j, k, n, m, x;
    scanf("%d", n);
    printf(" ");
    scanf("%d", m);

    if (n == 0 && x == 0) {
      break;
    }

    x = 0;
    for (i = 1; i < n - 1; i++) {
      for (j = i + 1; j < n; j++) {
        for (k = j + 1; k < n + 1; k++) {
          if (i + j + k == m) {
            x += 1;
          }
        }
      }
    }
    printf("%d\\n", x);
  }
  return 0;
}
Problem p02412 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
template <typename T> std::string to_string(const T &n) {
  std::ostringstream stm;
  stm << n;
  return stm.str();
}

int main(void) {
  int n, x;
  int tx, ty, tz;
  int ans = 0;
  cin >> n >> x;
  while (n != 0 || x != 0) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        for (int k = 1; k <= n; k++) {
          if (i + j + k == x && (i != j && j != k && k != i))
            ans++;
        }
      }
    }
    cout << ans / 6 << "\\n";
    ans = 0;
    cin >> n >> x;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
template <typename T> std::string to_string(const T &n) {
  std::ostringstream stm;
  stm << n;
  return stm.str();
}

int main(void) {
  int n, x;
  int tx, ty, tz;
  int ans = 0;
  cin >> n >> x;
  while (n != -1 || x != -1) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        for (int k = 1; k <= n; k++) {
          if (i + j + k == x && (i != j && j != k && k != i))
            ans++;
        }
      }
    }
    cout << ans / 6 << "\\n";
    ans = 0;
    cin >> n >> x;
  }
  return 0;
}
Problem p02412 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {
  int n = 0;
  int x = 0;
  int count = 0;
  cin >> n >> x;
  while (!(n == 0 && x == 0)) {
    count = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        for (int k = 1; k <= n; k++) {
          if ((i + k + j) == x) {
            if (!(i == j || j == k || i == k) && (i < j && j < k)) {
              count++;
            }
          }
        }
      }
    }
    cout << count << endl;
    cin >> n >> x;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int a = 0;
  int b = 0;
  int c = 0;
  int n = 0;
  int x = 0;
  int count = 0;
  cin >> n >> x;
  while (!(n == 0 && x == 0)) {
    count = 0;
    for (int i = 1; i < n; i++) {
      for (int j = 1; j < n; j++) {
        for (int k = 1; k < n; k++) {
          if ((i + k + j) == x) {
            if ((i != j || j != k || i != k) && (i < j && j < k)) {
              count++;
            }
          }
        }
      }
    }
  }
  return 0;
}