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

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int main() {

  while (1) {
    int a, b;
    string op;
    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 {
        cout << a / b << endl;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int main() {
  int a, b;
  string 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 {
        cout << a / b << endl;
      }
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>
using namespace std;

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


Error: TLE

Fixed submission:

#include <stdio.h>
using namespace std;

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

/*
 * iraira.cpp
 *
 *  Created on: 2018/05/02
 *      Author: J01003
 */
/*
 * taete.cpp
 *
 *  Created on: 2018/04/26
 *      Author: J01003
 */
#include <iostream>
#include <stdio.h>
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;
    }
    if (op == "?") {
      return 0;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

/*
 * iraira.cpp
 *
 *  Created on: 2018/05/02
 *      Author: J01003
 */
/*
 * taete.cpp
 *
 *  Created on: 2018/04/26
 *      Author: J01003
 */
#include <iostream>
#include <stdio.h>
using namespace std;

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

#include <iostream>
using namespace std;

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

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

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

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

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

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

#include <stdio.h>

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

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int a, b;
  char op;
  int ans;
  int loop = 1;
  scanf("%d %c %d", &a, &op, &b);
  while (loop) {
    switch (op) {
    case '+':
      ans = a + b;
      break;
    case '-':
      ans = a - b;
      break;
    case '*':
      ans = a * b;
      break;
    case '/':
      ans = a / b;
      break;
    case '?':
      break;
    }
    if (op != '?') {
      printf("%d\\n", ans);
    } else {
      loop = 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;
    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;
    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>
#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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  vector<int> v;
  int a, b, op;
  while (1) {
    scanf("%d", &a);
    scanf("%d", &op);
    scanf("%d", &b);
    if (op == '?') {
      break;
    } else if (op == '+') {
      v.push_back(a + b);
    } else if (op == '-') {
      v.push_back(a - b);
    } else if (op == '*') {
      v.push_back(a * b);
    } else if (op == '/') {
      v.push_back(a / b);
    }
  }

  for (int i = 0; i < v.size(); i++) {
    printf("%d\\n", v[i]);
  }

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

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


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int a, b, op, c;
  while (true) {
    cin >> a >> op >> b;
    if (op == '/')
      c = a / b;
    if (op == '+')
      c = a + b;
    if (op == '-')
      c = a - b;
    if (op == '*')
      c = a * b;
    if (op == '?')
      break;
    else
      cout << c << 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 != '?') {
    int c;
    if (op == '+')
      c = a + b;
    if (op == '-')
      c = a - b;
    if (op == '*')
      c = a * b;
    if (op == '/')
      c = a / b;
    cout << c << 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 = '?') {
    int c;
    if (op == '+')
      c = a + b;
    if (op == '-')
      c = a - b;
    if (op == '*')
      c = a * b;
    if (op == '/')
      c = a / b;
    cout << c << endl;
    cin >> a >> op >> b;
  }
}
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 != '?') {
    int c;
    if (op == '+')
      c = a + b;
    if (op == '-')
      c = a - b;
    if (op == '*')
      c = a * b;
    if (op == '/')
      c = a / b;
    cout << c << 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 != '?') {
    int c;
    if (op == '+')
      c = a + b;
    if (op == '-')
      c = a - b;
    if (op == '*')
      c = a * b;
    if (op == '/')
      c = a / b;
    cout << c << endl;
  }
}
Problem p02401 (C++) — buggy submission, verdict: Runtime Error

// class point	の練習（クラスの高度な実装）
#include <cstring>
#include <iomanip>
#include <iostream>
using namespace std;

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

  return 0;
}


Error: -11

Fixed submission:


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

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

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

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


Error: TLE

Fixed submission:

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


#include <cstdio>

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


Error: TLE

Fixed submission:


#include <cstdio>

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

#include <iostream>
using namespace std;
int main() {
  char 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 if (op == '/') {
      cout << a / b << endl;
    } else {
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  char op;
  int a, b;
  while (1) {
    cin >> a >> op >> b;
    if (a == 0 && b == 0 && 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;
    } else {
    }
  }

  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 << (int)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 << (int)a / b << endl;
    } else {
      break;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

Error: TLE

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int a, o, c;

  while (1) {
    cin >> a >> o >> c;
    if (o == '?')
      break;
    if (o == '+') {
      cout << a + c << endl;
    } else if (o == '-') {
      cout << a - c << endl;
    } else if (o == '*') {
      cout << a * c << endl;
    } else if (o == '/') {
      printf("%d\\n", a / c);
    }
  };
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

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

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

Error: TLE

Fixed submission:

#include <iostream>

int main() {
  int a, b;
  char op;
  std::cin >> a >> op >> b;

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

#include <iostream>
#include <string>
using namespace std;
int main() {
  int a, b;
  string op;
  for (int i = 0; i < 1000000; i++) {
    cin >> a;
    cin >> op;
    cin >> b;
    if (op == "+") {
      cout << a + b << endl;
    }
    if (op == "-") {
      cout << a - b << endl;
    }
    if (op == "*") {
      cout << a * b << endl;
    }
    if (op == "/") {
      cout << a / b << endl;
    }
    if (op == "?") {
      break;
    }
  }
}


Error: TLE

Fixed submission:

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

  cin >> a >> op >> b;
  for (int i = 0; i = 1; i = 0) {

    if (op == "+") {
      cout << a + b << endl;
    }

    if (op == "-") {
      cout << a - b << endl;
    }

    if (op == "*") {
      cout << a * b << endl;
    }

    if (op == "/") {
      cout << a / b << endl;
    }

    if (op == "?") {
      i = 1;
    }
  }
}
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;

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

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

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

  return 0;
}

Error: TLE

Fixed submission:

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

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

#include <cstdio>
#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 <cstdio>
#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 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;

    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 (op != '?') {
    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 <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, op, x;
  scanf("%d %c %d", &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: Time Limit Exceeded

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

Error: TLE

Fixed submission:

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

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

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

  do {
    // cin >> sa;
    // if (sa == '?') {
    //     break;
    // } else {
    //     cin >> op >> sb;
    // }

    cin >> a >> op >> b;

    // a = atoi(sa); b = atoi(sb);
    if (op == '+')
      cout << a + b << endl;
    if (op == '-')
      cout << a - b << endl;
    if (op == '*')
      cout << a * b << endl;
    if (op == '/') {
      if (b == 0) {
        continue;
      } else {
        cout << a / b << endl;
      }
    }
    // if (sa == '?' || op == '?') break;
    if (op == '?')
      break;
  } while (1);

  return 0;
}


Error: TLE

Fixed submission:

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

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

  return 0;
}