prithivMLmods/Coder-Stat huggingface dataset:
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>

using namespace std;

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

Fixed submission:
#include <iostream>
#include <string>

using namespace std;

int main() {
  while (1 == 1) {
    int a, b;
    string op;
    int result;
    cin >> a >> op >> b;
    if (op == "?")
      break;
    if (op == "+") {
      result = a + b;
      cout << result << endl;
    }
    if (op == "-") {
      result = a - b;
      cout << result << endl;
    }
    if (op == "*") {
      result = a * b;
      cout << result << endl;
    }
    if (op == "/") {
      result = a / b;
      cout << result << endl;
    }
  }
}
Problem p02401 (C++)

Buggy submission (status: 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;
    printf("%d\n", ans);
  }
  return 0;
}


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;
    else
      break;
    printf("%d\n", ans);
  }
  return 0;
}
Problem p02401 (C++)

Buggy submission (status: Runtime Error):
#include <cassert>
#include <cmath>
#include <iostream>
// #define NDEBUG
int main(void) {
  using namespace std;
  static const int INPUT_MAX = 20000;
  static const int INPUT_MIN = 0;
  int input_a = 0;
  int input_b = 0;
  int ans = 0; /* 解 */
  char op = 0; /* 演算子 */

  while (1) {
    cin >> input_a >> op >> input_b;

    /* 入力値の前提条件 最大・最小の制限*/
    assert(INPUT_MIN <= input_a && input_a <= INPUT_MAX);
    assert(INPUT_MIN <= input_b && input_b <= INPUT_MAX);
    /* 入力値の前提条件 0の割り算でないこと*/
    assert(!((input_a == 0 || input_b == 0) && op == '/'));

    /* Calculation */
    if (op == '+') {
      ans = input_a + input_b;
      cout << ans << endl;
    } else if (op == '-') {
      ans = input_a - input_b;
      cout << ans << endl;
    } else if (op == '*') {
      ans = input_a * input_b;
      cout << ans << endl;
    } else if (op == '/') {
      ans = input_a / input_b;
      cout << ans << endl;
    } else if (op == '?') {
      break;
    } else {
      cout << "Input Error" << endl;
      break;
    }
  }

  return 0;
}


Fixed submission:
#include <cassert>
#include <cmath>
#include <iostream>
// #define NDEBUG
int main(void) {
  using namespace std;
  static const int INPUT_MAX = 20000;
  static const int INPUT_MIN = 0;
  int input_a = 0;
  int input_b = 0;
  int ans = 0; /* 解 */
  char op = 0; /* 演算子 */

  while (1) {
    cin >> input_a >> op >> input_b;

    /* 入力値の前提条件 最大・最小の制限*/
    assert(INPUT_MIN <= input_a && input_a <= INPUT_MAX);
    assert(INPUT_MIN <= input_b && input_b <= INPUT_MAX);
    /* 入力値の前提条件 0の割り算でないこと*/
    assert(!(input_b == 0 && op == '/'));

    /* Calculation */
    if (op == '+') {
      ans = input_a + input_b;
      cout << ans << endl;
    } else if (op == '-') {
      ans = input_a - input_b;
      cout << ans << endl;
    } else if (op == '*') {
      ans = input_a * input_b;
      cout << ans << endl;
    } else if (op == '/') {
      ans = input_a / input_b;
      cout << ans << endl;
    } else if (op == '?') {
      break;
    } else {
      cout << "Input Error" << endl;
      break;
    }
  }

  return 0;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
using namespace std;
int main() {
  int x, y;
  char z;
  while (1) {
    scanf("%d %c %d", &x, z, &y);
    if (z == '?') {
      return 0;
    } else if (z == '+') {
      printf("%d\n", x + y);

    } else if (z == '-') {
      printf("%d\n", x - y);

    } else if (z == '/') {
      printf("%d\n", x / y);

    } else if (z == '*') {
      printf("%d\n", x * y);
    }
  }
  return 0;
}


Fixed submission:
#include <cstdio>
using namespace std;
int main() {
  int x, y;
  char z;
  while (1) {
    scanf("%d %c %d", &x, &z, &y);
    if (z == '?') {
      return 0;
    } else if (z == '+') {
      printf("%d\n", x + y);

    } else if (z == '-') {
      printf("%d\n", x - y);

    } else if (z == '/') {
      printf("%d\n", x / y);

    } else if (z == '*') {
      printf("%d\n", x * y);
    }
  }
  return 0;
}
Problem p02401 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

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

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

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

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

  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 if (op == '/') {
      cout << a / b << endl;
    }
  }

  return 0;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
#include <iostream>
using namespace std;

#define MAX 20000

int main(void) {
  int a, b, flag = 0;
  char op;
  while (1) {
    do {
      cin >> a >> op >> b;
    } while (a < 0 || a > MAX || b < 0 ||
             b > MAX && op != '+' && op != '-' && op != '*' && op != '/' &&
                 op != '?');

    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", a / b);
      if (b == 0)
        break;
      break;
    case '?':
      if (a == 0 && b == 0)
        flag = 1;
      break;
    }
    if (flag == 1)
      break;
  }
  return 0;
}

Fixed submission:
#include <cstdio>
#include <iostream>
using namespace std;

#define MAX 20000

int main(void) {
  int a, b, flag = 0;
  char op;
  while (1) {
    do {
      cin >> a >> op >> b;
    } while (a < 0 || a > MAX || b < 0 ||
             b > MAX && op != '+' && op != '-' && op != '*' && op != '/' &&
                 op != '?');

    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", a / b);
      if (b == 0)
        break;
      break;
    case '?':
      flag = 1;
      break;
    }
    if (flag == 1)
      break;
  }
  return 0;
}
Problem p02401 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
// #define shosu(n) setprecision(n)
// #define ENDL endl
using namespace std;
int main() {
  int A, B;
  char s;
  while (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 9;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
// #define shosu(n) setprecision(n)
// #define ENDL endl
using namespace std;
int main() {
  int A, B;
  char s;
  while (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;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}


Fixed submission:
#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;
}
Problem p02401 (C++)

Buggy submission (status: 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;
    }
  }
  return 0;
}


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;
    }
    cin >> a >> op >> b;
  }
  return 0;
}
Problem p02401 (C++)

Buggy submission (status: 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 (!(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;
}

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 (!(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;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02401 (C++)

Buggy submission (status: 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 >> 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;
}

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 >> 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;
}
Problem p02401 (C++)

Buggy submission (status: 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));
  }
  return 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));
  }
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>
int main() {
  int a, b;
  char op;
  while (scanf("%d %c %d", &a, &op, &b)) {
    if (a == 0 && op == '?' && b == 0)
      break;

    if (op == '+')
      printf("%d\n", a + b);

    if (op == '-')
      printf("%d\n", a - b);

    if (op == '*')
      printf("%d\n", a * b);

    if (op == '/')
      printf("%d\n", a / b);
  }
  return 0;
}

Fixed submission:
#include <cstdio>
int main() {
  int a, b;
  char op;
  while (scanf("%d %c %d", &a, &op, &b)) {
    if (op == '?')
      break;

    if (op == '+')
      printf("%d\n", a + b);

    if (op == '-')
      printf("%d\n", a - b);

    if (op == '*')
      printf("%d\n", a * b);

    if (op == '/')
      printf("%d\n", a / b);
  }
  return 0;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
int main() {
  int a, b;
  char c;
  while (scanf("%d%c%d", &a, &c, &b) != EOF) {
    if (c == '?') {
      break;
    }
    if (c == '+') {
      printf("%d\n", a + b);
    }
    if (c == '-') {
      printf("%d\n", a - b);
    }
    if (c == '*') {
      printf("%d\n", a * b);
    }
    if (c == '/') {
      printf("%d\n", a / b);
    }
  }
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  int a, b;
  char c;
  while (scanf("%d %c %d", &a, &c, &b) != EOF) {
    if (c == '?') {
      break;
    }
    if (c == '+') {
      printf("%d\n", a + b);
    }
    if (c == '-') {
      printf("%d\n", a - b);
    }
    if (c == '*') {
      printf("%d\n", a * b);
    }
    if (c == '/') {
      printf("%d\n", a / b);
    }
  }
  return 0;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}


Fixed submission:
#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;
}
Problem p02401 (C++)

Buggy submission (status: 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 (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;
}

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 (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;
}
Problem p02401 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int a, b, s;
  char op;
  while (1) {
    cin >> a >> b >> op;
    if (op == '?')
      break;

    if (op == '+') {
      s = a + b;
    } else if (op == '-') {
      s = a - b;
    } else if (op == '*') {
      s = a * b;
    } else {
      s = a / b;
    }
    cout << s << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int a, b, s;
  char op;
  while (1) {
    cin >> a >> op >> b;
    if (op == '?')
      break;

    if (op == '+') {
      s = a + b;
    } else if (op == '-') {
      s = a - b;
    } else if (op == '*') {
      s = a * b;
    } else {
      s = a / b;
    }
    cout << s << endl;
  }
  return 0;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

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

Fixed submission:
#include <stdio.h>

int main(void) {
  int a, b;
  char ch;
  while (1) {
    scanf("%d", &a);
    getchar();
    ch = getchar();
    scanf("%d", &b);
    if (ch == '?') {
      break;
    }
    switch (ch) {
    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", a / b);
      break;
    }
  }
  return 0;
}
Problem p02401 (C++)

Buggy submission (status: 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 == '?' && a == 0 && b == 0)
        break;
    }
  }
  return (0);
}

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 == '?')
        break;
    }
  }
  return (0);
}
Problem p02401 (C++)

Buggy submission (status: 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;
}

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 (status: Runtime Error):
#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;
    }
  }
}

Fixed submission:
#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;
    }
  }
}
Problem p02401 (C++)

Buggy submission (status: 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 (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;
}


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 (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;
}
Problem p02401 (C++)

Buggy submission (status: 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 (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;
}


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 (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;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main(void) {

  int a, b, s;
  char op;

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


Fixed submission:
#include <iostream>
using namespace std;
int main(void) {

  int a, b, s;
  char op;

  while (1) {
    cin >> a >> op >> b;
    if (op == '?')
      break;
    switch (op) {
    case ('+'):
      s = a + b;
      break;
    case ('-'):
      s = a - b;
      break;
    case ('*'):
      s = a * b;
      break;
    case ('/'):
      s = a / b;
      break;
    }
    cout << s << endl;
  }
  return 0;
}
Problem p02401 (C++)

Buggy submission (status: 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 == '?' && 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;
    }
  }
}

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 == '?') {
      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 (status: 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 (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;
}

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 (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 (status: Time Limit Exceeded):
#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;
}

Fixed submission:
#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;
}
Problem p02401 (C++)

Buggy submission (status: 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);
}


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 (status: 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 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 0;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
  }
}

Fixed submission:
#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;
  }
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {

  while (1) {
    int a, b;
    char 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 if (op == '*') {
      cout << a * b << endl;
    } else if (op == '*') {
      break;
    }
  }
  return 0;
}

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

int main() {

  while (1) {
    int a, b;
    char 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 if (op == '*') {
      cout << a * b << endl;
    } else if (op == '?') {
      break;
    }
  }
  return 0;
}
Problem p02401 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

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

  while (cin >> a >> op >> b) { // '?' puts cin into an error state, to end

    switch (op) {
    case '+':
      a += b;
      break;
    case '-':
      a -= b;
      break;
    case '*':
      a *= b;
      break;
    case '/':
      a /= b;
      break;
    default:
      cout << "error" << endl;
      return -1;
    }

    cout << a << endl;
  }

  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;

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

  while (cin >> a >> op >> b && op != '?') {

    switch (op) {
    case '+':
      a += b;
      break;
    case '-':
      a -= b;
      break;
    case '*':
      a *= b;
      break;
    case '/':
      a /= b;
      break;
    default:
      cout << "error" << endl;
      return -1;
    }

    cout << a << endl;
  }

  return 0;
}
Problem p02401 (C++)

Buggy submission (status: 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 (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; }
}


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 (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 (status: Time Limit Exceeded):
#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;
}


Fixed submission:
#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;
}
Problem p02401 (C++)

Buggy submission (status: Time Limit Exceeded):
#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;
}


Fixed submission:
#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;
}
Problem p02401 (C++)

Buggy submission (status: 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;
  }
}


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 (status: 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;
  }
}


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 (status: 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;
}


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 (status: 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;
}

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 (status: 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 == '?')
      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;
  }
}

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 == '?')
      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;
  }
}
Problem p02401 (C++)

Buggy submission (status: 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 >> 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;
}


Fixed submission:
#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;
}
Problem p02402 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n, i, max, min;
  long long sum = 0;
  int a[i];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    sum = sum + a[i];
    if (i == 1) {
      max = a[i];
      min = a[i];
    } else {
      if (max < a[i]) {
        max = a[i];
      }
      if (min > a[i]) {
        min = a[i];
      }
    }
  }
  cout << min << " " << max << " " << sum << endl;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, i, max, min;
  long long sum = 0;
  int a[100000];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    sum = sum + a[i];
    if (i == 1) {
      max = a[i];
      min = a[i];
    } else {
      if (max < a[i]) {
        max = a[i];
      }
      if (min > a[i]) {
        min = a[i];
      }
    }
  }
  cout << min << " " << max << " " << sum << endl;
}
Problem p02402 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n, i, max, min;
  long long sum = 0;
  int a[i];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    sum = sum + a[i];
    if (i == 1) {
      max = a[i];
      min = a[i];
    } else {
      if (max < a[i]) {
        max = a[i];
      }
      if (min > a[i]) {
        min = a[i];
      }
    }
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n, i, max, min;
  long long sum = 0;
  int a[100000];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    sum = sum + a[i];
    if (i == 1) {
      max = a[i];
      min = a[i];
    } else {
      if (max < a[i]) {
        max = a[i];
      }
      if (min > a[i]) {
        min = a[i];
      }
    }
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}
Problem p02402 (Python)

Buggy submission (status: Runtime Error):
input()
li = map(int, input().split())
print(min(li), max(li), sum(li))


Fixed submission:
input()
li = list(map(int, input().split()))
print(min(li), max(li), sum(li))
Problem p02402 (Python)

Buggy submission (status: Runtime Error):
n = int(input())
a = map(int, input().split())
print(min(a), max(a), sum(a))


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
print(min(a), max(a), sum(a))
Problem p02402 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main() {
  long long a, n, max;
  long long goukei = 0;
  long long min = 999999999;
  long long array[9999999];
  cin >> n;
  for (;;) {
    for (a = 0; a < n; a++)
      cin >> array[a];
    int max = array[0];
    for (a = 0; a < n; a++)
      if (array[a] > max)
        max = array[a];
    for (a = 0; a < n; a++)
      if (array[a] < min)
        min = array[a];
    for (a = 0; a < n; a++)
      goukei += array[a];

    cout << min << " " << max << " " << goukei << endl;
    break;
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main() {
  long long a, n, max;
  long long goukei = 0;
  long long min = 999999999;
  long long array[1000000];
  cin >> n;
  for (;;) {
    for (a = 0; a < n; a++)
      cin >> array[a];
    int max = array[0];
    for (a = 0; a < n; a++)
      if (array[a] > max)
        max = array[a];
    for (a = 0; a < n; a++)
      if (array[a] < min)
        min = array[a];
    for (a = 0; a < n; a++)
      goukei += array[a];

    cout << min << " " << max << " " << goukei << endl;
    break;
  }

  return 0;
}