Problem p02401 (C++) — buggy submission, verdict: Runtime Error

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

// macros
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define INT_IN(a)                                                              \\
  int a;                                                                       \\
  cin >> a
#define STR_IN(s)                                                              \\
  string s;                                                                    \\
  cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;

// util functions
template <class T> inline T sqr(T x) { return x * x; }

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T> inline T max(vector<T> v) {
  T max = v[0];
  FOR(i, 1, v.size()) max = MAX(v[i], max);
  return max;
}
template <typename T> inline T min(vector<T> v) {
  T min = v[0];
  FOR(i, 1, v.size()) min = MIN(v[i], min);
  return min;
}
template <typename T> inline vector<T> concat(vector<T> a, vector<T> b) {
  vector<T> ab;
  ab.reserve(a.size() + b.size());
  ab.insert(ab.end(), a.begin(), a.end());
  ab.insert(ab.end(), b.begin(), b.end());
  return ab;
}

// types
typedef long long LL;

// consts
const double EPS = 1e-10;
const double PI = acos(-1.0);

// debug
#define dump(x) #x << " = " << (x) << endl
#define debug(x)                                                               \\
#x << " = " << (x) << " (L" << __LINE__ << ")"                               \\
     << " " << __FILE__ << endl

int main() {
  char op;
  while (true) {
    INT_IN(a);
    cin >> op;
    INT_IN(b);
    if (op == '?')
      break;
    PRINTLN((op == '+'   ? a + b
             : op == '-' ? a - b
             : op == '*' ? a * b
                         : a / b));
  }
  return 0;
}

Error: -8

Fixed submission:

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

// macros
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define INT_IN(a)                                                              \\
  int a;                                                                       \\
  cin >> a
#define STR_IN(s)                                                              \\
  string s;                                                                    \\
  cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;

// util functions
template <class T> inline T sqr(T x) { return x * x; }

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T> inline T max(vector<T> v) {
  T max = v[0];
  FOR(i, 1, v.size()) max = MAX(v[i], max);
  return max;
}
template <typename T> inline T min(vector<T> v) {
  T min = v[0];
  FOR(i, 1, v.size()) min = MIN(v[i], min);
  return min;
}
template <typename T> inline vector<T> concat(vector<T> a, vector<T> b) {
  vector<T> ab;
  ab.reserve(a.size() + b.size());
  ab.insert(ab.end(), a.begin(), a.end());
  ab.insert(ab.end(), b.begin(), b.end());
  return ab;
}

// types
typedef long long LL;

// consts
const double EPS = 1e-10;
const double PI = acos(-1.0);

// debug
#define dump(x) #x << " = " << (x) << endl
#define debug(x)                                                               \\
#x << " = " << (x) << " (L" << __LINE__ << ")"                               \\
     << " " << __FILE__ << endl

int main() {
  char op;
  do {
    INT_IN(a);
    cin >> op;
    INT_IN(b);
    PRINTLN((op == '+'   ? a + b
             : op == '-' ? a - b
             : op == '*' ? a * b
                         : a / b));
  } while (op != '?');
  return 0;
}