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

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define mod 1000000007
using namespace std;
int main() {
  int a, b;
  char c;
  vector<int> ans;
  while (true) {
    cin >> a >> c >> b;
    if (c == '?')
      break;
    if (c == '+')
      ans.push_back(a + b);
    if (c == '-')
      ans.push_back(a - b);
    if (c == '*')
      ans.push_back(a * b);
    if (c == '/')
      ans.push_back(a / b);
  }
  rep(i, ans.size()) { cout << ans[i] << endl; }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define mod 1000000007
using namespace std;
int main() {
  int a, b;
  char c;
  vector<int> ans;
  while (true) {
    cin >> a >> c >> b;
    if (a == 0 && b == 0 && c == '?')
      break;
    if (c == '+')
      ans.push_back(a + b);
    if (c == '-')
      ans.push_back(a - b);
    if (c == '*')
      ans.push_back(a * b);
    if (c == '/')
      ans.push_back(a / b);
  }
  rep(i, ans.size()) { cout << ans[i] << endl; }
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int a, b;
  char s;

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

Error: TLE

Fixed submission:

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

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

int main() {
  int x = 0, y = 0, z = 0;
  char a[10];
  while (1) {
    cin >> x >> a >> y;
    if (a[0] == '+') {
      z = x + y;
    } else if (a[0] == '-') {
      z = x - y;
    } else if (a[0] == '*') {
      z = x * y;
    } else if (a[0] == '/') {
      z = x / y;
    } else if (a[0] == '?') {
      break;
    }
    cout << z << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

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

#include <iomanip>
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main() {

  int a, b;
  double aa, Output;
  int output;
  char op[2];
  while (1) {
    cin >> a >> op >> b;
    if (strcmp(op, "+") == 0) {
      output = a + b;
      cout << output << endl;

    } else if (strcmp(op, "-") == 0) {
      output = a - b;
      cout << output << endl;

    } else if (strcmp(op, "*") == 0) {
      output = a * b;
      cout << output << endl;

    } else if (strcmp(op, "/") == 0) {
      aa = (double)a;
      Output = a / b;
      cout << Output << endl;

    } else {
      break;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iomanip>
#include <iostream>
#include <math.h>
#include <string.h>
using namespace std;
int main() {
  /*
          double pai,r;
          double men,syu;
  //	pai=3.1415926538979;
          pai=M_PI;
          cin>>r;
          men=r*r*pai;
          syu=r*pai*2;
          cout<<fixed
                  <<setprecision(6)
                  <<men
                  <<" "
          //	<<fixed
          //	<<setprecision(6)
                  <<syu
                  <<endl;
  */
  int a, b;
  double aa, Output;
  int output;
  char op[2];
  cin >> a >> op >> b;
  while (1) {
    if (strcmp(op, "+") == 0) {
      output = a + b;
      cout << output << endl;

    } else if (strcmp(op, "-") == 0) {
      output = a - b;
      cout << output << endl;

    } else if (strcmp(op, "*") == 0) {
      output = a * b;
      cout << output << endl;

    } else if (strcmp(op, "/") == 0) {
      aa = (double)a;
      Output = a / b;
      cout << Output << endl;

    } else {
      break;
    }
  }

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

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define Rep(b, e, i) for (int i = b; i <= e; i++)
#define Repr(e, b, i) for (int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n - 1, i)
#define repr(n, i) Repr(n - 1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)), (x).end())

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; // Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int>>
    IntReversePrioQueue; // A->Z

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 31 - 1;
const int MOD = 1000000007;

void solve(void) {
  int a, b;
  char op;
  while (1) {
    cin >> a >> op >> b;
    if (op == '?')
      break;
    int ans = 0;
    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);
  }
}

int main(void) {
  solve();
  return 0;
}


Error: TLE

Fixed submission:

#include <stdio.h>
int main(void) {
  int a, b, op;
  scanf("%d %s %d", &a, &op, &b);
  while (op != '?') {
    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);
    scanf("%d %d %d", &a, &op, &b);
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

  return 0;
}

Error: TLE

Fixed submission:

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

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

  cin >> a >> op >> b;

  while (1) {
    if (op == '+') {
      result = a + b;
      cout << result << endl;
    } else if (op == '-') {
      result = a - b;
      cout << result << endl;
    } else if (op == '*') {
      result = a * b;
      cout << result << endl;
    } else if (op == '/') {
      result = a / b;
      cout << result << 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, ans;
  char op;
  while (1) {
    cin >> 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 '?':
      return 0;
    }
    cout << ans << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

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

#include <stdio.h>

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

Error: TLE

Fixed submission:

#include <stdio.h>

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

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

Error: TLE

Fixed submission:

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

#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  while (true) {
    int a, b;
    char c;
    cin >> a >> c >> b;
    if (c == '?')
      break;
    if (c == '+')
      cout << a + b << endl;
    if (c == '-')
      cout << a - b << endl;
    if (c == '*')
      cout << a * b << endl;
    if (c == '/')
      cout << a / b << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int a, b;
  char c;
  cin >> a >> c >> b;

  while (true) {
    if (c == '?')
      break;
    if (c == '+')
      cout << a + b << endl;
    if (c == '-')
      cout << a - b << endl;
    if (c == '*')
      cout << a * b << endl;
    if (c == '/')
      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 = 0;
  char op = 0;
  do {
    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;
    default:
      break;
    }
  } while (op != '?');
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b = 0;
  char op = 0;
  do {
    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;
    default:
      break;
    }
  } while (op = '?');
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Runtime Error

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

#define pi 3.141592653589

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

  while (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: 9

Fixed submission:

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

#define pi 3.141592653589

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

  while (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 9;
}
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 == '?')
      break;
    switch (c) {
    case '+':
      cout << a + b;
      break;
    case '-':
      cout << a - b;
      break;
    case '*':
      cout << a * b;
      break;
    case '/':
      cout << a / b;
      break;
    }
    cout << endl;
  }
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

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

#include <stdio.h>

int main() {
  int i;
  int a, b;
  char op;
  int cnt = 0;
  int x[10000];

  for (i = 0; i < 10000 && !cnt; i++) {
    scanf("%d %c %d", &a, &op, &b);

    switch (op) {
    case '+':
      x[i] = a + b;
      break;
    case '-':
      x[i] = a - b;
      break;
    case '*':
      x[i] = a * b;
      break;
    case '/':
      x[i] = a / b;
      break;
    case '?':
      if (i == 0)
        return 0;
      cnt = i;
      break;
    }
  }

  for (i = 0; i < 10000 && i < cnt; i++) {
    printf("%d\\n", x[i]);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  int i;
  int a, b;
  char op;
  int cnt = 0;
  int x[10000];

  for (i = 0; i < 10000 && !cnt; i++) {
    scanf("%d %c %d", a, op, b);
    switch (op) {
    case '+':
      x[i] = a + b;
      break;
    case '-':
      x[i] = a - b;
      break;
    case '*':
      x[i] = a * b;
      break;
    case '/':
      x[i] = a / b;
      break;
    case '?':
      if (!i)
        return 0;
      cnt = i;
      break;
    }
  }
  for (i = 0; i < 10000 && i < cnt - 1; i++) {
    printf("%d", x[i]);
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <iostream>
using namespace std;
#include <stdio.h>
int main(int argc, const char *argv[]) {
  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 {
      cout << a / b << endl;
    }
  }
  // insert code here...
  //  std::cout << "Hello, World!\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main(int argc, const char *argv[]) {
  int a, b, c, d, e, f;
  char op;
  cin >> a >> op >> b;
  while (1) {

    if (op == '?')
      break;

    else if (op == '+') {
      c = a + b;
      cout << c << endl;
    } else if (op == '-') {
      d = a - b;
      cout << d << endl;
    } else if (op == '*') {
      e = a * b;
      cout << e << endl;
    } else {
      f = a / b;
      cout << f << endl;
    }
  }
  // insert code here...
  //  std::cout << "Hello, World!\\n";
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a, b;
  string op;
  while (1) {
    cin >> a >> op >> b;
    int ans;
    if (op == "?")
      break;
    if (op == "+")
      ans = a + b;
    if (op == "-")
      ans = a - b;
    if (op == "*")
      ans = a * b;
    if (op == "/")
      ans = a / b;
    cout << ans << "\\n";
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double PI = acos(-1.0);

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int a, b;
  string op;
  cin >> a >> op >> b;

  while (1) {
    int ans;
    if (op == "?")
      break;
    if (op == "+")
      ans = a + b;
    if (op == "-")
      ans = a - b;
    if (op == "*")
      ans = a * b;
    if (op == "/")
      ans = a / b;
    cout << ans << "\\n";
  }

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

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

  while (op != '?') {

    cin >> a >> op >> 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;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

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

    if (op == '+') {
      cout << a + b << endl;
      break;
    }
    if (op == '-') {
      cout << a - b << endl;
      break;
    }
    if (op == '*') {
      cout << a * b << endl;
      break;
    }
    if (op == '/') {
      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, d;
  char c;
  while (cin >> a >> c >> b && !(c == '?')) {
    if (c == '+') {
      d = a + b;
    } else if (c == '-') {
      d = a - b;
    } else if (c == '*') {
      d = a * b;
    } else
      d = a / b;
    cout << d << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#define ll long long
using namespace std;
int main() {
  int a, b;
  char c;
  while (scanf("%d%c%d", &a, &c, &b) != EOF) {
    if (c == '?')
      continue;
    if (c == '-')
      printf("%d\\n", a - b);
    else if (c == '+')
      printf("%d\\n", a + b);
    else if (c == '*')
      printf("%d\\n", a * b);
    else if (c == '/')
      printf("%d\\n", a / b);
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

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


Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int a, b, ans;
  char c;
  while (1) {
    scanf("%d %c %d", &a, &c, &b);
    if (c == '+')
      ans = a + b;
    else if (c == '-')
      ans = a - b;
    else if (c == '*')
      ans = a * b;
    else if (c == '/')
      ans = a / b;
    printf("%d\\n", ans);
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  char op;
  int i = 0;
  string cu;
  int an[20001];
  int bn[20001];
  while (true) {
    cin >> a >> op >> b;
    an[i] = a;
    bn[i] = b;
    cu[i] = op;
    if (op == '?') {
      break;
    }
    i++;
  }
  for (int k = 0; k < i; k++) {
    if (cu[k] == '+') {
      cout << an[k] + bn[k] << endl;
    }
    if (cu[k] == '-') {
      cout << an[k] - bn[k] << endl;
    }
    if (cu[k] == '*') {
      cout << an[k] * bn[k] << endl;
    }
    if (cu[k] == '/') {
      cout << an[k] / bn[k] << endl;
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  char op;
  int i = 0;
  string cu;
  int an[20001];
  int bn[20001];
  while (true) {
    cin >> a >> op >> b;
    an[i] = a;
    bn[i] = b;
    cu[i] = op;
    if (a == 0 && op == '?' && b == 0) {
      break;
    }
    i++;
  }
  for (int k = 0; k < i; k++) {
    if (cu[k] == '+') {
      cout << an[k] + bn[k] << endl;
    }
    if (cu[k] == '-') {
      cout << an[k] - bn[k] << endl;
    }
    if (cu[k] == '*') {
      cout << an[k] * bn[k] << endl;
    }
    if (cu[k] == '/') {
      cout << an[k] / bn[k] << endl;
    }
  }
  return 0;
}
Problem p02401 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

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


Error: TLE

Fixed submission:

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

int main() {

  while (1) {
    int a, b;
    string op;
    cin >> a >> op >> b;
    if (a == 0 && op == "?" && b == 0)
      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;
  }
  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: Runtime Error

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

signed main() {
  int a, c;
  char b;
  while (cin >> a >> b >> c, b != '?') {
    switch (b) {
    case '+':
      printf("%d\\n", a + c);
      break;
    case '-':
      printf("%d\\n", a - c);
      break;
    case '*':
      printf("%d\\n", a * c);
      break;
    default:
      printf("%d\\n", a / c);
      break;
    }
  }
}

Error: TLE

Fixed submission:

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

signed main() {
  int a, c;
  char b;
  while (scanf("%d%c%d", &a, &b, &c), b != '?') {
    switch (b) {
    case '+':
      printf("%d\\n", a + c);
      break;
    case '-':
      printf("%d\\n", a - c);
      break;
    case '*':
      printf("%d\\n", a * c);
      break;
    default:
      printf("%d\\n", a / c);
      break;
    }
  }
}