alexjercan/bugnet huggingface dataset:
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int n, i, j, t[100][100] = {0};
  int b, f, r, v;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> b >> f >> r >> v;
    if (b == 1) {
      t[f][r] += v;
    } else if (b == 2) {
      t[f + 4][r] += v;
    } else if (b == 3) {
      t[f + 8][r] += v;
    } else if (b == 4) {
      t[f + 12][r] += v;
    }
  }
  for (i = 1; i <= 15; i++) {
    if (i % 4 == 0)
      cout << "####################";
    else {
      for (j = 1; j <= 10; j++) {
        cout << " " << t[i][j];
      }
    }
    cout << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, i, j, t1[3][10] = {0}, t2[3][10] = {0};
  int t3[3][10] = {0}, t4[4][11] = {0};
  int b, f, r, v;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> b >> f >> r >> v;
    if (b == 1) {
      t1[f][r] = v;
    } else if (b == 2) {
      t2[f][r] = v;
    } else if (b == 3) {
      t3[f][r] = v;
    } else if (b == 4) {
      t4[f][r] = v;
    }
  }
  for (i = 1; i <= 3; i++) {
    for (j = 1; j <= 10; j++) {
      cout << " " << t1[i][j];
    }
    cout << endl;
  }

  cout << "####################" << endl;
  for (i = 1; i <= 3; i++) {
    for (j = 1; j <= 10; j++) {
      cout << " " << t2[i][j];
    }
    cout << endl;
  }
  cout << "####################" << endl;
  for (i = 1; i <= 3; i++) {
    for (j = 1; j <= 10; j++) {
      cout << " " << t3[i][j];
    }
    cout << endl;
  }

  cout << "####################" << endl;
  for (i = 1; i <= 3; i++) {
    for (j = 1; j <= 10; j++) {
      cout << " " << t4[i][j];
    }
    cout << endl;
  }

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

#include <iostream>
using namespace std;

int main() {
  int c[5][5][15];
  int n, b, f, r, v;

  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int t = 1; t <= 10; t++) {
        c[i][j][t] = 0;
      }
    }
  }

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    c[b][f][r] += v;
  }

  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int t = 1; t <= 10; t++) {
        cout << ' ' << c[i][j][t];
      }
      cout << endl;
    }
    if (i != 4)
      cout << "####################" << endl;
  }
  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int c[4][3][10];
  int n, b, f, r, v;

  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int t = 1; t <= 10; t++) {
        c[i][j][t] = 0;
      }
    }
  }

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    c[b][f][r] += v;
  }

  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int t = 1; t <= 10; t++) {
        cout << ' ' << c[i][j][t];
      }
      cout << endl;
    }
    if (i != 4)
      cout << "####################" << endl;
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
using namespace std;
int main() {
  int b, f, r, v;
  int F[10][3][4];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 4; k++) {
        F[i][j][k] = 0;
      }
    }
  }
  int num;
  scanf("%d", &num);
  for (int i = 0; i < num; i++) {
    scanf(" %d %d %d %d", &b, &f, &r, &v);
    F[r - 1][f - 1][b - 1] += v;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        printf(" %d", F[k][j][i]);
      }
      printf("\\n");
    }
    if (i != 3) {
      printf("####################\\n");
    }
  }
}


Error: -11

Fixed submission:

#include <cstdio>
using namespace std;
int main() {
  int b, f, r, v;
  int F[10][3][4];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 4; k++) {
        F[i][j][k] = 0;
      }
    }
  }
  int num;
  scanf("%d", &num);
  for (int i = 0; i < num; i++) {
    scanf(" %d %d %d %d", b, f, r, v);
    F[b][f][r] += v;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        printf("%d ", F[k][j][i]);
      }
      printf("\\n");
    }
    printf("####################\\n");
  }
}
Problem p02409 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int rooms[4][3][10] = {0};

  int n;

  cin >> n;

  int b, f, r, v;

  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    rooms[b - 1][f - 1][r - 1] = rooms[b - 1][f - 1][r - 1] + v;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      cout << " ";
      for (int k = 0; k < 10; k++) {
        cout << rooms[i][j][k];
        if (k != 9)
          cout << " ";
      }
      cout << endl;
    }
    if (i != 3)
      cout << "####################" << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int rooms[4][3][10] = {0};

  int n;

  cin >> n;

  int b, f, r, v;

  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    rooms[b - 1][f - 1][r - 1] = rooms[b - 1][f - 1][r - 1] + v;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      cout << " ";
      for (int k = 0; k < 10; k++) {
        cout << rooms[i][j][k];
        if (k != 9)
          cout << " ";
      }
      cout << endl;
    }
    if (i != 3)
      cout << "####################" << endl;
  }
  while (1)
    ;
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iomanip>
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int n = 0, a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0;
  cin >> n;
  int x[10][3][4] = {};
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        x[k][j][i] = {};
      }
    }
  }

  for (i = 0; i < n; i++) {
    cin >> a >> b >> c >> d;
    x[c - 1][b - 1][a - 1] += d;
  }

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        cout << ' ' << x[k][j][i];
      }
      cout << endl;
    }
    if (i < 3) {
      cout << "####################" << endl;
    }
  }

  // cout << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iomanip>
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  cout << "Hello World" << endl;
  int n = 0, a = 0, b = 0, c = 0, d = 0, i = 0, j = 0, k = 0;
  cin >> n;
  int x[10][3][4];
  for (i = 0; 1 < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        x[k][j][i] = 0;
      }
    }
  }
  cout << n;
  for (i = 0; i < n; i++) {
    cin >> a >> b >> c >> d;
    x[a - 1][b - 1][c - 1] += d;
  }

  for (i = 0; 1 < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        cout << ' ' << x[k][j][i];
      }
      cout << endl;
    }
    cout << '####################' << endl;
  }

  cout << endl;
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

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

    cout << result << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

    cout << result << endl;
  }
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

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

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

    } else {
      cout << "F" << endl;
    }
    cin >> m >> f >> r;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

  cin >> m >> f >> r;
  while (m != -1 || f != -1 || r != -1) {
    if (m == -1 || f == -1) {
      cout << "F" << endl;
    } else if (m + f >= 80) {
      cout << "A" << endl;
    } else if (m + f < 80 && m + f >= 65) {
      cout << "B" << endl;
    } else if (m + f < 65 && m + f >= 50) {
      cout << "C" << endl;
    } else if (m + f < 50 && 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 m, f, r;

  while (1) {

    cin >> m >> f >> r;

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

    else if (m + f < 30)
      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 == f == r == -1)
      break;

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

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

#include <stdio.h>
typedef struct GRADE {
  int m; //??????????¨?????????°???
  int f; //??????????¨?????????°
  int r; //???????¨?????????°

  char grad; //??????
};
int main() {
  GRADE std[100];
  int i = 0, j;
  int sum, sum2;
  while (1) {
    scanf("%d %d %d", &std[i].m, &std[i].f, &std[i].r);
    if (std[i].m == -1 && std[i].f == -1 && std[i].r == -1) {
      break;
    }
    i++;
  }

  for (j = 0; j < i; j++) {

    sum = std[j].m + std[j].f;

    sum2 = std[j].r;
    if (sum < 30 || std[j].m == -1 || std[j].f == -1) {
      std[j].grad = 'F';
    } else if (sum >= 80) {
      std[j].grad = 'A';
    } else if (sum >= 65 && sum < 80) {
      std[j].grad = 'B';
    } else if ((sum >= 50 && sum < 65) || sum2 >= 50) {
      std[j].grad = 'C';
    } else if (sum >= 30 && sum < 50) {
      std[j].grad = 'D';
    }

    printf("%c\\n", std[j].grad);
  }

  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>
typedef struct GRADE {
  int m; //??????????¨?????????°???
  int f; //??????????¨?????????°
  int r; //???????¨?????????°

  char grad; //??????
};
int main() {
  GRADE std[10];
  int i = 0, j;
  int sum, sum2;
  while (1) {
    scanf("%d %d %d", &std[i].m, &std[i].f, &std[i].r);
    if (std[i].m == -1 && std[i].f == -1 && std[i].r == -1) {
      break;
    }
    i++;
  }

  for (j = 0; j < i; j++) {

    sum = std[j].m + std[j].f;

    sum2 = std[j].r;
    if (sum < 30 || std[j].m == -1 || std[j].f == -1) {
      std[j].grad = 'F';
    } else if (sum >= 80) {
      std[j].grad = 'A';
    } else if (sum >= 65 && sum < 80) {
      std[j].grad = 'B';
    } else if ((sum >= 50 && sum < 65) || sum2 >= 50) {
      std[j].grad = 'C';
    } else if (sum >= 30 && sum < 50) {
      std[j].grad = 'D';
    }

    printf("%c\\n", std[j].grad);
  }

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

#include <iostream>
using namespace std;
int main() {
  int m, f, r, sum;
  while (1) {
    cin >> m >> f >> r;
    sum = m + f;
    if (m == -1 && f == -1 && r == -1) {
      break;
    } else if (m == -1 || f == -1) {
      cout << "F";
    } else if (sum >= 80) {
      cout << "A";
    } else if (sum >= 65) {
      cout << "B";
    } else if (sum >= 50) {
      cout << "C";
    } else if (sum >= 30) {
      if (r >= 50) {
        cout << "C";
      } else {
        cout << "D";
      }
    } else {
      cout << "F";
    }
    cout << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int m, f, r, sum;
  while (1) {
    cin >> m >> f >> r;
    if (m == f == r == -1) {
      break;
    }
    sum = m + f;
    if (sum >= 80) {
      cout << "A";
    } else if (sum >= 65) {
      cout << "B";
    } else if (sum >= 50) {
      cout << "C";
    } else if (sum >= 30) {
      if (r >= 50) {
        cout << "C";
      } else {
        cout << "D";
      }
    } else if (sum < 30) {
      cout << "F";
    }
  }
  return 0;
}
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) {
    if ((m & f & r) == -1)
      break;
    int sum = m + f;
    if ((m | f) == -1)
      cout << "F" << endl;
    else if (sum >= 80)
      cout << "A" << endl;
    else if (sum >= 65 && sum < 80)
      cout << "B" << endl;
    else if (sum >= 50 && sum < 65)
      cout << "C" << endl;
    else if (sum >= 30 && sum < 50) {
      if (r >= 50)
        cout << "C" << endl;
      else
        cout << "D" << endl;
    } else
      cout << "F" << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int m, f, r;
  while (1) {
    cin >> m >> f >> r;
    int s = m + f;
    if (m == -1 || f == -1)
      cout << "F" << endl;
    if (s >= 80)
      cout << "A" << endl;
    if (s >= 65 && s < 80)
      cout << "B" << endl;
    if (s >= 50 && s < 65)
      cout << "C" << endl;
    if (s >= 30 && s < 50) {
      if (r >= 50)
        cout << "C" << endl;
      else
        cout << "D" << endl;
    }
    if (s < 30)
      cout << "F" << endl;
  }
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {

  int m, f, sum, r;
  char rank;

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

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int m, f, sum, r;
  char rank;

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

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

#include <iostream>
using namespace std;
int main() {
  int m = 0;
  int f = 0;
  int r = 0;
  while (1) {
    cin >> m >> f >> r;
    int a = 0;
    a = m + f;
    if (m == -1 && f == -1 && r == -1)
      break;

    if (m == -1) {
      cout << "F"
           << "\\n";
    } else if (f == -1) {
      cout << "F"
           << "\\n";
    } else if (80 <= a) {
      cout << "A"
           << "\\n";
    } else if (65 <= a && a < 80) {
      cout << "B"
           << "\\n";
    } else if (50 <= a && a < 65) {
      cout << "C"
           << "\\n";
    } else if (30 <= a && a < 50 && 50 <= r) {
      cout << "C"
           << "\\n";
    } else if (30 <= a && a < 50) {
      cout << "D"
           << "\\n";
    } else if (a < 30) {
      cout << "F"
           << "\\n";
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int m = 0, f = 0, r = 0;
  for (;;) {
    cin >> m >> f >> r;
    if (m = -1) {
      cout << "F";
    } else if (f = -1) {
      cout << "F";
    } else if (80 <= m + f) {
      cout << "A";
    } else if (65 <= m + f < 80) {
      cout << "B";
    } else if (50 <= m + f < 65) {
      cout << "C";
    } else if (30 <= m + f < 50 && 50 <= r) {
      cout << "C";
    } else if (30 <= m + f < 50) {
      cout << "D";
    } else if (m + f < 30) {
      cout << "F";
    } else if (m + f + r == -3) {
      return 0;
    }
  }
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

int main(int argc, char const *argv[]) {
  int m, f, r;
  std::cin >> m >> f >> r;
  while (!(m == -1 && m == f && m == r)) {
    if (m == -1 || f == -1 || m + f < 30) {
      std::cout << "F";
    } else if (m + f >= 80) {
      std::cout << "A";
    } else if (m + f >= 65) {
      std::cout << "B";
    } else if (m + f >= 50) {
      std::cout << "C";
    } else {
      if (r >= 50) {
        std::cout << "C";
      } else {
        std::cout << "D";
      }
    }
    std::cin >> m >> f >> r;
    std::cout << std::endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>

int main(int argc, char const *argv[]) {
  int m, f, r;
  std::cin >> m >> f >> r;
  while (!(m == -1 && m == f && m == r)) {
    if (m == -1 || f == -1 || m + f < 30) {
      std::cout << "F";
    } else if (m + f >= 80) {
      std::cout << "A";
    } else if (m + f >= 65) {
      std::cout << "B";
    } else if (m + f >= 50) {
      std::cout << "C";
    } else {
      if (r >= 50) {
        std::cout << "C";
      } else {
        std::cout << "D";
      }
    }
    std::cout << std::endl;
  }
}
Problem p02411 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {

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

#include <iostream>
using namespace std;
int main() {
  int m, f, r, gokei, i;
  i = 1;
  while (i = 1) {
    cin >> m >> f >> r;
    gokei = m + f;
    if (m == -1 && f == -1) {
      break;
    } else if (m == -1 || f == -1) {
      cout << "F" << endl;
    } else {
      if (80 <= gokei && gokei <= 100) {
        cout << "A" << endl;
      } else if (65 <= gokei && gokei < 80) {
        cout << "B" << endl;
      } else if (50 <= gokei && gokei < 65) {
        cout << "C" << endl;
      } else if (30 <= gokei && gokei < 50) {
        if (r >= 50) {
          cout << "C" << endl;
        } else {
          cout << "D" << endl;
        }
      } else if (0 <= gokei && gokei < 30) {
        cout << "F" << endl;
      }
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int m, f, r, gokei, i;
  i = 1;
  while (i = 1) {
    cin >> m >> f >> r;
    gokei = m + f;
    if (m == -1) {
      cout << "F" << endl;
    } else if (f == -1) {
      cout << "F" << endl;
    } else {
      if (80 <= gokei && gokei <= 100) {
        cout << "A" << endl;
      } else if (65 <= gokei && gokei < 80) {
        cout << "B" << endl;
      } else if (50 <= gokei && gokei < 65) {
        cout << "C" << endl;
      } else if (30 <= gokei && gokei < 50) {
        if (r <= 50) {
          cout << "C" << endl;
        } else {
          cout << "D" << endl;
        }
      } else if (0 <= gokei && gokei < 30) {
        cout << "F" << endl;
      } else if (gokei == -2) {
        break;
      }
    }
  }
}
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;
    } else if (m == -1 || f == -1) {
      cout << "F"
           << "\\n";
    } else if (m + f >= 80) {
      cout << "A"
           << "\\n";
    } else if (m + f >= 65 && m + f < 80) {
      cout << "B"
           << "\\n";
    } else if (m + f >= 50 && m + f < 65) {
      cout << "C"
           << "\\n";
    } else if (m + f >= 30 && m + f < 50 && r >= 50) {
      cout << "C"
           << "\\n";
    } else if (m + f >= 30 && m + f < 50) {
      cout << "D"
           << "\\n";
    } else if (m + f < 30) {
      cout << "F"
           << "\\n";
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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


Error: TLE

Fixed submission:

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

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