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

#include "iostream"
#include "stdio.h"
using namespace std;

int main() {
  double r, pi;
  cin >> r;
  pi = 3.141592653589;
  double circleL = r * 2 * pi;
  double circleS = r * r * pi;
  printf("%0.5f %0.5f", circleS, circleL);
}


Error: WA

Fixed submission:

#include "iostream"
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  double fa = a, fb = b;
  cout << (a - a % b) / b << " " << a % b << " " << fa / fb;
  return 0;
}
Problem p02400 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {

  cout << fixed << setprecision(12);

  double r;
  cin >> r;

  double PI = acos(-1);
  double area = r * r * PI;
  double cir = (r + r) * PI;
  cout << area << " " << cir << endl;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  cout << fixed << setprecision(12);

  int a, b;
  cin >> a >> b;

  cout << a / b << "";
  cout << a % b << "";
  cout << (double)a / b << endl;
}
Problem p02400 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  double a;
  scanf("%lf", &a);
  printf("%lf %lf\\n", M_PI * a * a, 2 * M_PI * a);
}


Error: -8

Fixed submission:

#include <stdio.h>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d %d %lf\\n", a / b, a % b, a / (double)b);
}
Problem p02400 (C++) — buggy submission, verdict: Runtime Error

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

int main() {
  double r;
  cin >> r;

  double S = r * r * M_PI;
  double shu = 2 * r * M_PI;

  printf("%.5f %.5f", S, shu);
}

Error: -11

Fixed submission:

#include <stdio.h>
#define PI 3.14159267

int main() {
  int r;
  double s, l;
  scanf("%d", r);
  s = r * r * PI;
  l = 2 * PI * r;
  printf("%d %d\\n", s, l);
  return 0;
}
Problem p02400 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
int main() {
  double r, pi = 3.141592653589;
  scanf("%lf", &r);
  printf("%lf %lf\\n", r * r * pi, 2 * r * pi);
  return 0;
}

Error: -8

Fixed submission:

#include <cstdio>
int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  printf("%d %d %lf\\n", a / b, a % b, (double)a / b);
  return 0;
}
Problem p02400 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const double pi = 3.141592653589793;
int main() {
  double r, l, a;

  cin >> r;

  l = 2 * r * pi;
  a = r * r * pi;

  printf("%.6lf ", a);
  printf("%.6lf\\n", l);

  return 0;
}

Error: TLE

Fixed submission:

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

const double pi = 3.1415926535;
int main() {
  double r, l, a;

  cin >> r;

  l = 2 * r * pi;
  a = r * r * pi;

  printf("%.6lf ", a);
  printf("%.6lf\\n", l);

  while (1) {
  }

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

#include <stdio.h>

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

  while (1) {
    scanf("%d %c %d", &a, &op, &b);

    if (op == '?')
      break;

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

    printf("%d\\n", ans);
  }

  return 0;
}


Error: TLE

Fixed submission:

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

#include <stdio.h>

int main() {
  int x, y;
  char op;
  while (scanf("%d %c %d", &x, &op, &y) && op != '?') {
    if (op == '+') {
      printf("%d\\n", x + y);
    } else if (op == '-') {
      printf("%d\\n", x - y);
    } else if (op == '*') {
      printf("%d\\n", x * y);
    } else if (op == '/') {
      printf("%d\\n", x / y);
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int x, y;
  char op;
  while (scanf("%d %c %d", &x, &op, &y)) {
  }

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

#include <iostream>
using namespace std;
int main() {

  int a, b, i, ans;
  char op;

  for (i = 1; i <= 100000000; i++) {
    ans = 0;
    cin >> a >> op >> b;
    if (op == '?')
      break;
    else if (op == '+') {
      ans = a + b;
    } else if (op == '-') {
      ans = a - b;
    } else if (op == '*') {
      ans = a * b;
    } else if (op == '/') {
      ans = a / b;
    }

    cout << ans << endl;
  }

  return 0;
}


Error: -8

Fixed submission:

#define USE_MATH_DEFINES
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main() {

  int a, b, d, r;
  double f;

  cin >> a >> b;
  d = a / b;
  r = a % b;
  f = a / b;
  cout << fixed;
  cout << setprecision(6) << d << " " << r << " " << f << endl;
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() {
  int a, b;
  char op;
  for (int n = 0;;) {
    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);
    }
  }
}


Error: 8

Fixed submission:

#include <cstdio>

int main() {
  int a, b, x;
  char op;
  scanf("%d %c %d", &a, &op, &b);
  {
    switch (op) {
    case '+':
      x = a + b;
      break;
    case '-':
      x = a - b;
      break;
    case '*':
      x = a * b;
      break;
    case '/':
      x = a / b;
      break;
    case '?':
      break;
    }
    printf("%d\\n", x);
    return 8;
  }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b;
  string 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;
  string 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 <iostream>
using namespace std;

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

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char op;
  while (true) {
    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 '?':
      break;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

  return 0;
}


Error: TLE

Fixed submission:

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

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

#include <iostream>

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

  while (1) {

    std::cin >> a >> p >> b;
    if (p == '?')
      break;
    else if (p == '+') {
      std::cout << a + b << "\\n";
    } else if (p == '-') {
      std::cout << a - b << "\\n";
    } else if (p == '*') {
      std::cout << a * b << "\\n";
    } else if (p == '/') {
      std::cout << a / b << "\\n";
    }
  }

  return 0;
}

Error: -8

Fixed submission:

#include <iostream>
int main() {
  int a, b;
  char *o;
  while (1) {
    std::cin >> a >> o >> b;
    if (o == "0")
      break;
    else if (o == "+")
      std::cout << a + b;
    else if (o == "-")
      std::cout << a - b;
    else if (o == "*")
      std::cout << a * b;
    else
      std::cout << a / b;
  }

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

#include <iostream>

using namespace std;

int main() {
  int a, b;
  string op;
  while (true) {
    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;
  string op;
  cin >> a >> op >> b;
  while (true) {
    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: Runtime Error

#include <iostream>
#include <vector>

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

int main() {
  int x, y;
  char op;
  while (cin >> x >> op >> y) {
    if (op == '?')
      break;
    if (op == '+')
      cout << x + y << endl;
    if (op == '-')
      cout << x - y << endl;
    if (op == '*')
      cout << x * y << endl;
    if (op == '/' && y != 0)
      cout << x / y << endl;
  }
}

Error: 255

Fixed submission:

#include <iostream>
#include <vector>

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

int main() {
  int x, y;
  char op;
  while (cin >> x >> op >> y) {
    if (op == '?')
      return -1;

    if (op == '+')
      cout << x + y << endl;
    if (op == '-')
      cout << x - y << endl;
    if (op == '*')
      cout << x * y << endl;
    if (op == '/' && y != 0)
      cout << x / y << endl;
  }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iomanip>
#include <iostream>

#define PI 3.141592653589

using namespace std;

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

  while (1) {
    cin >> a >> op >> b;

    if (op == '?') {
      break;
    }

    switch (op) {
    case '+':
      r = a + b;
      break;
    case '-':
      r = a - b;
      break;
    case '*':
      r = a * b;
      break;
    case '/':
      if (b == 0) {
        break;
      }
      r = a / b;
      break;
    default:
      break;
    }

    cout << r << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iomanip>
#include <iostream>

#define PI 3.141592653589

using namespace std;

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

  while (1) {
    cin >> a >> op >> b;

    if (a == 0 && b == 0) {
      break;
    }

    switch (op) {
    case '+':
      r = a + b;
      break;
    case '-':
      r = a - b;
      break;
    case '*':
      r = a * b;
      break;
    case '/':
      if (b == 0) {
        break;
      }
      r = a / b;
      break;
    default:
      break;
    }

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

#include <cstdio>

int main() {
  int a, b;
  char op;
  while (true) {
    scanf("%d %c %d", &a, &op, &b);
    if (op == '?')
      break;
    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 <cstdio>

int main() {
  int a, b;
  char op;
  while (true) {
    scanf("%d %c %d", &a, &op, &b);
    if (a == 0 && op == '?' && b == 0)
      break;
    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;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int a, b;
  int flag = 1;
  char op;
  while (flag) {
    scanf("%d %c %d", &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 == '?') {
      flag = 0;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int a, b;
  int flag = 1;
  char op[10];
  while (flag) {
    scanf("%d%s%d", &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 == "?") {
      flag = 0;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

int main() {
  int x, y;
  char op;
  while (1) {
    std::cin >> x;
    std::cin >> op;
    std::cin >> y;
    if (std::cin.good() == 0) {
      break;
    }
    switch (op) {
    case '+':
      std::cout << x + y << std::endl;
      break;
    case '-':
      std::cout << x - y << std::endl;
      break;
    case '*':
      std::cout << x * y << std::endl;
      break;
    case '/':
      std::cout << x / y << std::endl;
      break;
    default:
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

int main() {
  int x, y;
  char op;
  while (1) {
    std::cin >> x;
    std::cin >> op;
    std::cin >> y;
    switch (op) {
    case '+':
      std::cout << x + y << std::endl;
      break;
    case '-':
      std::cout << x - y << std::endl;
      break;
    case '*':
      std::cout << x * y << std::endl;
      break;
    case '/':
      std::cout << x / y << std::endl;
      break;
    case '?':
      break;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  char op;
  int a, b, result = 0;

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

Error: TLE

Fixed submission:

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

int main() {
  char op;
  int a, b, result = 0;

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

#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 <bits/stdc++.h>
using namespace std;

int main() {
  int a, op, b;
  while (true) {
    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
      cout << a / b << endl;
    if (op == '?')
      break;
  }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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


Error: TLE

Fixed submission:

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

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

#include <iostream>

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

  while (1) {
    std::cin >> a >> op >> b;

    if (op == '?') {
      break;
    }

    if (op == '+') {
      z = a + b;
    } else if (op == '-') {
      z = a - b;
    } else if (op == '*') {
      z = a * b;
    } else if (op == '/') {
      z = a / b;
    }
    std::cout << z << std::endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

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

  while (1) {
    std::cin >> a >> op >> b;

    if (op == '?') {
      break;
    }

    if (op == '+') {
      z = a + b;
    } else if (op == '-') {
      z = a - b;
    } else if (op == '*') {
      z = a * b;
    } else if (op == '/') {
      z = a / b;
    }
    std::cout << z << std::endl;
  }

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

#include <cstdio>

using namespace std;

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

  while (1) {
    scanf("%d %c %d", &a, &op, &b);

    switch (op) {
    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", (int)((float)a / b));
      break;
    }
    if (op == '?') {
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>

using namespace std;

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

  while (1) {
    scanf("%d%c%d", &a, &op, &b);

    switch (op) {
    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", (int)((float)a / b));
      break;
    }
    if (op == '?') {
      break;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#define PI 3.141592653589
using namespace std;

int main() {
  while (1) {
    int x, y;
    char c;
    cin >> x >> c >> y;

    if (c == '?')
      break;
    int z;
    switch (c) {
    case '+':
      z = x + y;
      break;
    case '-':
      z = x - y;
      break;
    case '*':
      z = x * y;
      break;
    case '/':
      z = x / y;
      break;
    case '%':
      z = x % y;
      break;
    }
    printf("%d\\n", z);
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#define PI 3.141592653589
using namespace std;

int main() {
  while (1) {
    int x, y;
    char c;
    cin >> x >> c >> y;

    if (c == 'c')
      break;
    int z;
    switch (c) {
    case '+':
      z = x + y;
      break;
    case '-':
      z = x - y;
      break;
    case '*':
      z = x * y;
      break;
    case '/':
      z = x / y;
      break;
    case '%':
      z = x % y;
      break;
    }
    printf("%d", z);
  }

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

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

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


Error: -8

Fixed submission:

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

int main() {
  while (1) {
    int a, b;
    char op;
    if (op == '?')
      break;
    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
      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 == '?')
      break;

    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;

  while (1) {
    cin >> a >> b >> op;
    if (op == '?')
      break;

    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;
}