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

#include <iostream>
using namespace std;

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

  while (true) {
    cin >> a >> b >> c;

    if (b == '?')
      break;

    if (b == '+')
      cout << a + c << endl;
    else if (b == '-')
      cout << a - c << endl;
    else if (b == '*')
      cout << a * c << endl;
    else
      cout << a / c << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

  while (true) {
    cin >> a >> b >> c;

    if (a == 0 && c == 0)
      break;

    if (b == '+')
      cout << a + c << endl;
    else if (b == '-')
      cout << a - c << endl;
    else if (b == '*')
      cout << a * c << endl;
    else
      cout << a / c << endl;
  }

  return 0;
}
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;
      cin >> a >> op >> b;
    } else if (op == '-') {
      cout << a - b << endl;
      cin >> a >> op >> b;
    } else if (op == '*') {
      cout << a * b << endl;
      cin >> a >> op >> b;
    } 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 >> 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;
    }
  }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  return 0;
}

Error: TLE

Fixed submission:

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

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

  cin >> a >> op >> b;

  while (!(a == 0 && op == '?' && b == 0)) {
    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;
  }

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

#include <iostream>
#include <string>

using namespace std;

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

  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 if (op == "/")
      cout << a / b << endl;
    else if (op == "?")
      break;
  }
  return 0;
}

Error: -8

Fixed submission:

#include <iostream>
using namespace std;
int a, b, op, i;
int main() {
  cin >> a >> op >> b >> i;
  cout << "i" << a + b << endl;
  cout << "i" << a - b << endl;
  cout << "i" << a * b << endl;
  cout << "i" << a / b << endl;
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int x, y, ans;
  char op;
  cin >> x >> op >> y;
  while (op != '?') {
    switch (op) {
    case '+':
      ans = x + y;
      break;
    case '-':
      ans = x - y;
      break;
    case '*':
      ans = x * y;
      break;
    case '/':
      ans = x / y;
      break;
    }
    cout << ans << "\\n";
    cin >> x >> op >> y;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x, y, ans;
  char op;
  cin >> x;
  cin >> op;
  cin >> y;
  while (x != 0 || op != '?' || y != 0) {
    switch (op) {
    case '+':
      ans = x + y;
      break;
    case '-':
      ans = x - y;
      break;
    case '*':
      ans = x * y;
      break;
    case '/':
      ans = x / y;
      break;
    }
    cout << ans << "\\n";
    cin >> x;
    cin >> op;
    cin >> y;
  }
}
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;
  }
  return 0;
}


Error: TLE

Fixed submission:

#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;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

  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 {
      cout << a / b << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

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

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

  while (1) {
    cin >> a >> op >> b;
    if (a == 0 && b == 0) {
      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;
}
Problem p02401 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

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

    if (op == '?') {
      break;
    }
    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;
    }
  }

  return 0;
}


Error: 255

Fixed submission:

#include <iostream>

using namespace std;

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

  while (true) {
    cin >> a >> op >> b;
    if (op == '?') {
      return -1;
    }
    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;
    }
  }

  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;

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

Error: TLE

Fixed submission:


#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 '?':
      break;
    }
  }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int a, b;
char op;
int ans;

int main() {
  while (1) {
    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 {
      break;
    }
    cout << ans << endl;
  }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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


Error: TLE

Fixed submission:

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

#include <stdio.h>
int main(void) {
  int a, b, flag = 0;
  char op;

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

Fixed submission:

#include <stdio.h>
int main(void) {
  int a, b, flag = 0;
  char op;

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

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

using namespace std;
int main() {
  int a, b, c, d, h, i;
  char e, g, f;
  while (scanf("%d%c%c%c%d", &a, &c, &g, &d, &b)) {
    if (g == '?') {
      return 0;
    } else if (g == '+') {
      c = a + b;
      cout << c << endl;
    } else if (g == '-') {
      d = a - b;
      cout << d << endl;
    } else if (g == '*') {
      h = a * b;
      cout << h << endl;
    } else if (g == '/') {
      i = a / b;
      cout << i << endl;
    }
  }
}

Error: TLE

Fixed submission:

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

using namespace std;
int main() {
  int a, b, c, d, h, i;
  char e, g, f;
  while (scanf("%d%c%c%c%d", &a, &c, &g, &d, &b)) {
    if (g == '?' && a == 0 && b == 0) {
      return 0;
    } else if (g == '+') {
      c = a + b;
      cout << c << endl;
    } else if (g == '-') {
      d = a - b;
      cout << d << endl;
    } else if (g == '*') {
      h = a * b;
      cout << h << endl;
    } else if (g == '/') {
      i = a / b;
      cout << i << endl;
    }
  }
}
Problem p02401 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

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);
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#define _USE_MATH_DEFINES
#include <iostream>
#include <math.h>
#include <stdio.h>

using namespace std;

int main() {
  int a[10000], b[10000];
  string c[10000];

  int i = 0;

  while (true) {
    scanf("%d %s %d", &a[i], &c[i], &b[i]);
    if (c[i] == "?")
      break;
    i++;
  }

  for (int j = 0; j < i; j++) {
    if (c[j] == "+")
      printf("%d\\n", a[i] + b[i]);
    else if (c[j] == "-")
      printf("%d\\n", a[i] - b[i]);
    else if (c[j] == "*")
      printf("%d\\n", a[i] * b[i]);
    else
      printf("%d\\n", a[i] / b[i]);
  }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a, b;
  char c;
  while (1) {
    cin >> a >> c >> b;
    if (c == '?')
      return 0;

    if (c == '+') {
      cout << a + b;
    } else if (c == '-') {
      cout << a - b;
    } else if (c == '*') {
      cout << a * b;
    } else if (c == '/') {
      cout << a / b;
    }
    cout << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b;
  char c;
  while (1) {
    cin >> a >> c >> b;
    if (a == b && c == '?')
      return 0;

    if (c == '+') {
      cout << a + b;
    } else if (c == '-') {
      cout << a - b;
    } else if (c == '*') {
      cout << a * b;
    } else if (c == '/') {
      cout << a / b;
    }
    cout << endl;
  }

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

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

int main() {
  int a, b, X;
  string d;
  while (1) {
    cin >> a >> d >> b;
    if (d == "?")
      break;
    if (d == "+")
      X = a + b;
    if (d == "-")
      X = a - b;
    if (d == "*")
      X = a * b;
    if (d == "/")
      X = a / b;
    cout << X << endl;
  }

  return (0);
}


Error: TLE

Fixed submission:

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

int main() {
  int a, b, X;
  string d;
  while (1) {
    cin >> a >> d >> b;
    if (d == " ?")
      break;
    if (d == "+")
      X = a + b;
    if (d == "-")
      X = a - b;
    if (d == "*")
      X = a * b;
    if (d == "/")
      X = a / b;
    cout << X << endl;
  }

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

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char c;
  int l[100];
  for (int i = 0;; i++) {
    cin >> a >> c >> b;
    if (c == '+') {
      l[i] = a + b;
    } else if (c == '-') {
      l[i] = a - b;
    } else if (c == '*') {
      l[i] = a * b;
    } else if (c == '/') {
      l[i] = a / b;
    } else if (c == '?') {
      for (int j = 0; j < i; j++) {
        cout << l[j] << endl;
      }
      break;
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b;
  char c;
  int l[100];
  for (int i = 0;; i++) {
    cin >> a >> c >> b;
    switch (c) {
    case '+':
      l[i] = a + b;
      continue;
    case '-':
      l[i] = a - b;
      continue;
    case '*':
      l[i] = a * b;
      continue;
    case '/':
      l[i] = a / b;
      continue;
    case '?':
      for (int j = 0; j < i; j++) {
        cout << l[j] << endl;
      }
      break;
    default:
      break;
    }
  }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define PI 3.14159265358979323

int main(int argc, char *argv[]) {
  char op;
  int a, b;

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

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

  return 0;
}

Error: TLE

Fixed submission:

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

#define PI 3.14159265358979323

int main(int argc, char *argv[]) {
  char op;
  int a, b;

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

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

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

#include <iostream>
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>
using namespace std;

int main(void) {
  int a, b;
  char op;
  while (1) {
    cin >> a >> op >> b;
    if (a == 0 and b == 0)
      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 == '?')
      break;
    switch (op) {
    case '+':
      a += b;
      cout << a << "\\n";
      break;
    case '-':
      a -= b;
      cout << a << "\\n";
      break;
    case '/':
      a /= b;
      cout << a << "\\n";
      break;
    case '*':
      a *= b;
      cout << a << "\\n";
      break;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

#include <iostream>
using namespace std;

int main() {

  int a, b, result;
  char op;

  while (1) {

    cin >> a >> op >> b;

    if (op == '?')
      break;

    if (op == '+') {
      result = a + b;
      cout << result << "\\n";
    } else if (op == '-') {
      result = a - b;
      cout << result << "\\n";
    } else if (op == '*') {
      result = a * b;
      cout << result << "\\n";
    } else if (op == '/') {
      result = a / b;
      cout << result << "\\n";
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {

  int a, b, op, result;

  while (1) {

    cin >> a >> op >> b;

    if (op == '?')
      break;

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

#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int a, b;
  string op;
  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 if (op == "/")
      cout << a / b << endl;
    else
      return 0;
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int a, b;
  string op;
  cin >> a >> op >> b;
  while (true) {
    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
      return 0;
  }
}
Problem p02401 (C++) — buggy submission, verdict: Runtime Error

#include <iomanip>
#include <iostream>

using namespace std;
int main() {
  int a, b;
  string op;
  while (true) {
    cin >> a >> op >> b;
    if (op == "?") {
      return 0;
    } else {
      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;
      }
    }
  }
}


Error: -8

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  string op;
  int a, b;
  op = "+";
  while (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 {
      cout << a / b << endl;
    }
  }
}
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;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a, b;
  char op;

  while (1) {
    cin >> a >> op >> b;
    if (op == '?' && a == 0 && b == 0)
      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>
int main() {
  int a, b;
  std::string op;
  while (1) {
    std::cin >> a >> op >> b;
    if (op == "?")
      break;
    if (op == "+") {
      std::cout << a + b << std::endl;
    } else if (op == "-") {
      std::cout << a - b << std::endl;
    } else if (op == "*") {
      std::cout << a * b << std::endl;
    } else if (op == "/") {
      std::cout << a / b << std::endl;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

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

  return 0;
}