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

#include <cassert>
#include <cmath>
#include <iostream>
// #define NDEBUG
int main(void) {
  using namespace std;
  static const int INPUT_MAX = 20000;
  static const int INPUT_MIN = 0;
  int input_a = 0;
  int input_b = 0;
  int ans = 0; /* 解 */
  char op = 0; /* 演算子 */

  while (1) {
    cin >> input_a >> op >> input_b;

    /* 入力値の前提条件 最大・最小の制限*/
    assert(INPUT_MIN <= input_a && input_a <= INPUT_MAX);
    assert(INPUT_MIN <= input_b && input_b <= INPUT_MAX);
    /* 入力値の前提条件 0の割り算でないこと*/
    assert(!(input_b == 0 && op == '/'));

    /* Calculation */
    if (op == '+') {
      ans = input_a + input_b;
      cout << ans << endl;
    } else if (op == '-') {
      ans = input_a - input_b;
      cout << ans << endl;
    } else if (op == '*') {
      ans = input_a * input_b;
      cout << ans << endl;
    } else if (op == '/') {
      ans = input_a / input_b;
      cout << ans << endl;
    } else if (op == '?') {
      break;
    } else {
      cout << "Input Error" << endl;
      break;
    }
  }

  return 0;
}


Error: 0

Fixed submission:

#include <cassert>
#include <cmath>
#include <iostream>
// #define NDEBUG
int main(void) {
  using namespace std;
  static const int INPUT_MAX = 20000;
  static const int INPUT_MIN = 0;
  int input_a = 0;
  int input_b = 0;
  int ans = 0; /* 解 */
  char op = 0; /* 演算子 */

  while (1) {
    cin >> input_a >> op >> input_b;

    /* 入力値の前提条件 最大・最小の制限*/
    assert(INPUT_MIN <= input_a && input_a <= INPUT_MAX);
    assert(INPUT_MIN <= input_b && input_b <= INPUT_MAX);
    /* 入力値の前提条件 0の割り算でないこと*/
    assert(!((input_a == 0 || input_b == 0) && op == '/'));

    /* Calculation */
    if (op == '+') {
      ans = input_a + input_b;
      cout << ans << endl;
    } else if (op == '-') {
      ans = input_a - input_b;
      cout << ans << endl;
    } else if (op == '*') {
      ans = input_a * input_b;
      cout << ans << endl;
    } else if (op == '/') {
      ans = input_a / input_b;
      cout << ans << endl;
    } else if (op == '?') {
      break;
    } else {
      cout << "Input Error" << endl;
      break;
    }
  }

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

#include <cstdio>
using namespace std;
int main() {
  int x, y;
  char z;
  while (1) {
    scanf("%d %c %d", &x, &z, &y);
    if (z == '?') {
      return 0;
    } else if (z == '+') {
      printf("%d\\n", x + y);

    } else if (z == '-') {
      printf("%d\\n", x - y);

    } else if (z == '/') {
      printf("%d\\n", x / y);

    } else if (z == '*') {
      printf("%d\\n", x * y);
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;
int main() {
  int x, y;
  char z;
  while (1) {
    scanf("%d %c %d", &x, z, &y);
    if (z == '?') {
      return 0;
    } else if (z == '+') {
      printf("%d\\n", x + y);

    } else if (z == '-') {
      printf("%d\\n", x - y);

    } else if (z == '/') {
      printf("%d\\n", x / y);

    } else if (z == '*') {
      printf("%d\\n", x * y);
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int a, b;
  char c;
  while (scanf("%d %c %d", &a, &c, &b) != EOF) {
    if (c == '?') {
      break;
    }
    if (c == '+') {
      printf("%d\\n", a + b);
    }
    if (c == '-') {
      printf("%d\\n", a - b);
    }
    if (c == '*') {
      printf("%d\\n", a * b);
    }
    if (c == '/') {
      printf("%d\\n", a / b);
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int a, b;
  char c;
  while (scanf("%d%c%d", &a, &c, &b) != EOF) {
    if (c == '?') {
      break;
    }
    if (c == '+') {
      printf("%d\\n", a + b);
    }
    if (c == '-') {
      printf("%d\\n", a - b);
    }
    if (c == '*') {
      printf("%d\\n", a * b);
    }
    if (c == '/') {
      printf("%d\\n", a / b);
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {
  while (1) {
    int a, b;
    char op;
    cin >> a >> op >> b;

    if (op == '+') {
      cout << a + b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    } else
      break;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  while (1) {
    int a, b;
    char op;
    cin >> a >> op >> b;

    switch (op) {
    case '+':
      cout << a + b << endl;
      break;
    case '-':
      cout << a - b << endl;
      break;
    case '*':
      cout << a * b << endl;
      break;
    case '/':
      cout << a / b << endl;
      break;
    case '?':
    default:
      break;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int a, b, ans;
  string op;

  for (;;) {
    cin >> a;
    cin >> op;
    cin >> b;
    if (op == "+") {
      ans = a + b;
    } else if (op == "-") {
      ans = a - b;
    } else if (op == "*") {
      ans = a * b;
    } else if (op == "/") {
      ans = a / b;
    } else if (op == "?") {
      break;
    }
    cout << ans << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b, ans;
  char op[64];

  for (;;) {
    cin >> a >> op >> b;
    if (op == "+") {
      ans = a + b;
    } else if (op == "-") {
      ans = a - b;
    } else if (op == "*") {
      ans = a * b;
    } else if (op == "/") {
      ans = a / b;
    } else if (op == "?") {
      break;
    }
    cout << ans << endl;
  }
}
Problem p02401 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int a, b, s;
  char op;
  while (1) {
    cin >> a >> op >> b;
    if (op == '?')
      break;

    if (op == '+') {
      s = a + b;
    } else if (op == '-') {
      s = a - b;
    } else if (op == '*') {
      s = a * b;
    } else {
      s = a / b;
    }
    cout << s << endl;
  }
  return 0;
}

Error: -8

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b, s;
  char op;
  while (1) {
    cin >> a >> b >> op;
    if (op == '?')
      break;

    if (op == '+') {
      s = a + b;
    } else if (op == '-') {
      s = a - b;
    } else if (op == '*') {
      s = a * b;
    } else {
      s = a / b;
    }
    cout << s << endl;
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
#include <string.h>
int main() {
  int a, b;
  char op;
  while (1) {
    scanf("%d %s %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);
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>
int main() {
  int a, b;
  char op[10];
  scanf("%d %s %d", &a, op, &b);
  while (strcmp(op, "?") != 0) {
    if (strcmp(op, "+") == 0) {
      printf("%d\\n", a + b);
    } else if (strcmp(op, "-") == 0) {
      printf("%d\\n", a - b);
    } else if (strcmp(op, "*") == 0) {
      printf("%d\\n", a * b);
    } else if (strcmp(op, "/") == 0) {
      printf("%d\\n", a / b);
    } else {
      break;
    }
  }

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

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

using namespace std;

int main() {
  int a, b;
  int result[1001];
  char op;
  int i = 0;
  while (scanf("%d %c %d", &a, &op, &b), op != '?') {
    switch (op) {
    case '+':
      result[i++] = a + b;
      break;
    case '-':
      result[i++] = a - b;
      break;
    case '*':
      result[i++] = a * b;
      break;
    case '/':
      result[i++] = a / b;
      break;
    default:
      break;
    }
  }
  for (int j = 0; j < i; j++) {
    cout << result[j] << endl;
  }
}


Error: -11

Fixed submission:

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

using namespace std;

int main() {
  int a, b;
  int result[1001];
  char op;
  int i = 0;
  while (scanf("%d %c %d", a, op, b), op != '?') {
    switch (op) {
    case '+':
      result[i++] = a + b;
      break;
    case '-':
      result[i++] = a - b;
      break;
    case '*':
      result[i++] = a * b;
      break;
    case '/':
      result[i++] = a / b;
      break;
    }
  }
  for (int j = 0; j < i; j++) {
    cout << result[j] << endl;
  }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  while (op != '?') {
    if (op == '+') {
      cout << a + b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    }
    cin >> a >> op >> b;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;
  cin >> a >> b >> op;
  while (op != '?') {
    if (op = '+') {
      cout << a + b << endl;
    } else if (op = '-') {
      cout << a - b << endl;
    } else if (op = '*') {
      cout << a * b << endl;
    } else if (op = '/') {
      cout << a / b << endl;
    }
    cin >> a >> b >> op;
  }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  int a, b, ans;
  char op = 's';
  bool flag = false;

  do {
    switch (op) {
    case '+':
      ans = a + b;
      break;
    case '-':
      ans = a - b;
      break;
    case '*':
      ans = a * b;
      break;
    case '/':
      ans = a / b;
      break;
    default:
      flag = true;
      break;
    }

    if (!flag)
      printf("%d\\n", ans);
    flag = false;
    scanf("%d %c %d", &a, &op, &b);
  } while (op != '?');
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int a, b, ans;
  char op = 's';
  bool flag = false;

  do {
    switch (op) {
    case '+':
      ans = a + b;
      break;
    case '-':
      ans = a - b;
      break;
    case '*':
      ans = a * b;
      break;
    case '/':
      ans = a / b;
    default:
      flag = true;
      break;
    }

    if (!flag)
      printf("%d\\n", ans);
    flag = true;
  } while (op != '?');

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

#include <stdio.h>
int main() {
  int a, b, c;
  char op;
  while (1) {
    scanf("%d %c %d", &a, &op, &b);
    if (op == '?')
      break;
    else if (op == '+')
      c = a + b;
    else if (op == '/')
      c = a / b;
    else if (op == '*')
      c = a * b;
    else if (op == '-')
      c = a - b;
    printf("%d\\n", c);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int a, b, c;
  char op;
  while (1) {
    scanf("%d %c %d", &a, op, &b);
    if (op == '?')
      break;
    else if (op == '+')
      c = a + b;
    else if (op == '/')
      c = a / b;
    else if (op == '*')
      c = a * b;
    else if (op == '-')
      c = a - b;
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;
  while (1) {
    cin >> a >> op >> b;
    if (op == '?') {
      break;
    } else if (op == '+') {
      cout << a + b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  while (1) {
    if (op == '?') {
      break;
    } else if (op == '+') {
      cout << a + b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
  int a, b;
  char op;

  while (1) {
    cin >> a >> op >> b;
    if (op == '?')
      break;
    if (op == '+')
      cout << a + b << endl;
    if (op == '-')
      cout << a - b << endl;
    if (op == '/')
      cout << a / b << endl;
    if (op == '*')
      cout << a * b << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
  int a, b;
  char op;

  cin >> a >> op >> b;
  while (1) {
    if (op == '?')
      break;
    if (op == '+')
      cout << a + b << endl;
    if (op == '-')
      cout << a - b << endl;
    if (op == '/')
      cout << a / b << endl;
    if (op == '*')
      cout << a * b << endl;
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;

  while (1) {
    cin >> a >> op >> b;
    if (op == '+') {
      cout << a + b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    } else
      break;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;

  cin >> a >> op >> b;

  while (1) {

    if (op == '+') {
      cout << a + b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    } else
      break;
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
int main() {
  int a, b;
  char op;
  for (int i = 1;; i++) {
    scanf("%d %c %d", &a, &op, &b);
    if (op == '?')
      break;
    if (op == '+')
      printf("%d\\n", a + b);
    if (op == '-')
      printf("%d\\n", a - b);
    if (op == '*')
      printf("%d\\n", a * b);
    if (op == '/')
      printf("%d\\n", a / b);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  int a, b;
  char op;
  while (1) {
    scanf("%d %c %d", &a, &op, &b);
    if (a == 0 && b == 0 && op == '?')
      break;
    if (op == '+')
      printf("%d\\n", a + b);
    if (op == '-')
      printf("%d\\n", a - b);
    if (op == '*')
      printf("%d\\n", a * b);
    if (op == '/')
      printf("%d\\n", a / b);
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a, b;
  char c;
  for (;;) {
    cin >> a >> c >> b;
    if (c == '+')
      cout << a + b << endl;
    else if (c == '-')
      cout << a - b << endl;
    else if (c == '*')
      cout << a * b << endl;
    else if (c == '/')
      cout << a / b << endl;
    else if (c == '?')
      break;
  }
  getchar();
  getchar();
  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int a, b;
  char c;
  for (;;) {
    cin >> a >> c >> b;
    if (a != 0, b != 0 && c == '+')
      cout << a + b << endl;
    else if (a != 0, b != 0 && c == '-')
      cout << a - b << endl;
    else if (a != 0, b != 0 && c == '*')
      cout << a * b << endl;
    else if (a != 0, b != 0 && c == '/')
      cout << a / b << endl;
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int a(int a, int b) { return a + b; }
int b(int a, int b) { return a - b; }
int c(int a, int b) { return a * b; }
int d(int a, int b) { return a / b; }
int main() {
  int n, m;
  char op;
  while (cin >> n >> op >> m && op != '?') {
    if (op == '+')
      cout << a(n, m) << endl;
    else if (op == '-')
      cout << b(n, m) << endl;
    else if (op == '*')
      cout << c(n, m) << endl;
    else if (op == '/')
      cout << d(n, m) << endl;
  }
}


Error: TLE

Fixed submission:

#include <iomanip>
#include <iostream>
using namespace std;
int main() {
  int a, c, d;
  char op;
  cin >> a >> op >> c;
  while ((a > 0) || (c > 0)) {
    if (op == '+') {
      cout << (a + c) << endl;
    } else if (op == '-') {
      cout << (a - c) << endl;
    } else if (op == '*') {
      cout << (a * c) << endl;
    } else if (op == '/') {
      cout << (a / c) << endl;
    }
  }
  cin >> a >> op >> c;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  int a, b;
  char ch;
  while (1) {
    scanf("%d", &a);
    getchar();
    ch = getchar();
    scanf("%d", &b);
    if (ch == '?') {
      break;
    }
    switch (ch) {
    case '+':
      printf("%d\\n", a + b);
      break;
    case '-':
      printf("%d\\n", a - b);
      break;
    case '*':
      printf("%d\\n", a * b);
      break;
    case '/':
      printf("%d\\n", a / b);
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int a, b;
  char ch;
  while (1) {
    scanf("%d", &a);
    getchar();
    ch = getchar();
    scanf("%d", &b);
    if (a == 0 && ch == '?' && b == 0) {
      break;
    }
    switch (ch) {
    case '+':
      printf("%d\\n", a + b);
      break;
    case '-':
      printf("%d\\n", a - b);
      break;
    case '*':
      printf("%d\\n", a * b);
      break;
    case '/':
      printf("%d\\n", a / b);
      break;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, b;
  char op;
  while (1) {
    cin >> a >> op >> b;
    if (op == '+') {
      cout << a + b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    } else {
      break;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b;
  char op;
  while (1) {
    cin >> a >> b >> op;
    if (op == '+') {
      cout << a + b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    }
    if (op == '?')
      break;
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, b, x;
  char op;
  cin >> a >> op >> b;
  while (op != '?') {
    if (op == '+') {
      x = a + b;
    } else if (op == '-') {
      x = a - b;
    } else if (op == '*') {
      x = a * b;
    } else if (op == '/') {
      x = a / b;
    }
    cout << x << endl;
    cin >> a >> op >> b;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b, x;
  char op;
  while (op != '?') {
    cout << a << op << b;
    if (op == '+') {
      x = a + b;
    } else if (op == '-') {
      x = a - b;
    } else if (op == '*') {
      x = a * b;
    } else if (op == '/') {
      x = a / b;
    }
    cout << x << endl;
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {

  while (1) {
    int a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '+') {
      cout << a + b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '?') {
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {

  while (1) {
    int a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '+') {
      cout << a + b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '*') {
      break;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, b;
  char op;
  while (1) {
    cin >> a >> op >> b;
    switch (op) {
    case '+':
      cout << a + b << endl;
      break;
    case '-':
      cout << a - b << endl;
      break;
    case '*':
      cout << a * b << endl;
      break;
    case '/':
      cout << a / b << endl;
      break;
    case '?':
      return 0;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  while (1) {
    switch (op) {
    case '+':
      cout << a + b;
      break;
    case '-':
      cout << a - b;
      break;
    case '*':
      cout << a * b;
      break;
    case '/':
      cout << a / b;
      break;
    case '?':
      return 0;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;
  while (1) {
    cin >> a >> op >> b;
    if (op == '?') {
      break;
    } else if (op == '+') {
      cout << a + b << endl;
    } else if (op == '-') {
      cout << a - b << endl;
    } else if (op == '*') {
      cout << a * b << endl;
    } else if (op == '/') {
      cout << a / b << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;
  if (op == '+') {
    cout << a + b << endl;
  } else if (op == '-') {
    cout << a - b << endl;
  } else if (op == '*') {
    cout << a * b << endl;
  } else if (op == '/') {
    cout << a / b << endl;
  } else {
  };
  while (1) {
    cin >> a >> op >> b;
    if (op == '/' && b == 0)
      break;
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;

  while (cin >> a >> op >> b && op != '?') {

    switch (op) {
    case '+':
      a += b;
      break;
    case '-':
      a -= b;
      break;
    case '*':
      a *= b;
      break;
    case '/':
      a /= b;
      break;
    default:
      cout << "error" << endl;
      return -1;
    }

    cout << a << endl;
  }

  return 0;
}


Error: 255

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;

  while (cin >> a >> op >> b) { // '?' puts cin into an error state, to end

    switch (op) {
    case '+':
      a += b;
      break;
    case '-':
      a -= b;
      break;
    case '*':
      a *= b;
      break;
    case '/':
      a /= b;
      break;
    default:
      cout << "error" << endl;
      return -1;
    }

    cout << a << endl;
  }

  return 0;
}