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

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

#define MAX 256

int f(int z) {
  if (z < 10)
    return 1;
  return 1 + f(z / 10);
}

int main(void) {

  int ans[200];
  for (long i = 0; i < 200; i++) {
    ans[i] = 0;
  }

  long a, b;
  long i = 0;

  while (scanf("%ld%ld", &a, &b) != EOF) {
    ans[i] = f(a + b);
    i++;
  }

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

  return 0;
}

Error: TLE

Fixed submission:

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

#define MAX 256

int main(void) {

  int a, b, c[MAX], t = 0;
  int i = 0, s;

  while (t == 0) {
    c[i] = 0;
    scanf("%d%d", &a, &b);
    s = a + b;
    while (s >= 10) {
      c[i]++;
      s = s / 10;
    }
    i++;
  }

  for (int j = 0; j < i; j++) {
    printf("%d", c[j]);
  }

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

#include <iostream>

int main() {
  while (1) {
    double a, b;

    std::cin >> a;
    std::cin >> b;

    if (std::cin.eof()) {
      break;
    }

    double c = a + b;
    int ans = 1;
    bool flag = false;

    while (!flag) {
      if (c / 10 >= 1) {
        c /= 10;
        ans += 1;
      } else {
        flag = true;
      }
    }

    std::cout << ans << std::endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

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

    int c = a + b;
    int digit = 1;
    bool loop = true;
    while (loop) {
      if (c / 10 >= 1) {
        digit += 1;
        c = (c - (c % 10)) / 10;
      } else {
        loop = false;
        break;
      }
    }
    std::cout << digit << std::endl;
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int a, b;
  while (cin >> a >> b) {
    int n = a + b;
    int ans = 0;
    while (n > 0) {
      n /= 10;
      ans++;
    }
    if (ans == 0)
      ans++;
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  while (1) {
    int a, b;
    cin >> a >> b;
    int n = a + b;
    int ans = 0;
    while (n > 0) {
      n /= 10;
      ans++;
    }
    if (ans == 0)
      ans++;
    cout << ans << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b;

  while (cin >> a >> b) {
    a += b;
    int t = 1, cnt = 0;
    while (1) {
      if (a < t) {
        break;
      } else {
        t *= 10;
        ++cnt;
      }
    }
    cout << cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include "stdio.h"

int main() {
  int a = 0, b = 0, c = 0, count = 0;
  while (1) {
    scanf("%d %d", &a, &b);
    c = a + b;
    while (c > 0) {
      c = c / 10;
      count++;
    }
    printf("%d\\n", count);
    count = 0;
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef long long ll;

using namespace std;

int main(void) {
  int a, b;
  while (1) {
    if (cin >> a == 0)
      break;
    cin >> b;

    if (a == 0 && b == 0) {
      cout << "1" << endl;
      continue;
    }

    int count = 0;
    int c = a + b;
    while (c != 0) {
      c /= 10;
      count++;
    }

    cout << count << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

typedef long long ll;

using namespace std;

int main(void) {
  int a, b;
  while (1) {
    cin >> a &&cin >> b;
    if (a == EOF)
      break;

    if (a == 0 && b == 0) {
      cout << "1" << endl;
      continue;
    }

    int count = 0;
    int c = a + b;
    while (c != 0) {
      c /= 10;
      count++;
    }

    cout << count << endl;
  }

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

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

int main() {
  int a, b;

  while (scanf("%d%d", &a, &b) != EOF) {
    int cnt = 0;
    int sum = a + b;

    while (1) {
      sum /= 10;
      cnt++;
      if (!sum)
        break;
    }
    cout << cnt << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int digit(int a) {
  int cnt = 0;

  while (a) {
    a /= 10;
    cnt++;
  }
  return cnt;
}
int main() {
  int a, b;

  while (1) {
    int n = 0;
    cin >> a >> b;

    n = digit(a + b);

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

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

int a, b;

int main() {
  while (scanf("%d %d", &a, &b) != EOF) {
    int i = 0;
    a = a + b;
    while (a > 0) {
      a = a / 10;
      ++i;
    }

    cout << i << endl;
  }
}

Error: TLE

Fixed submission:

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

int a;
int b;

int main() {
  while (cin >> a >> b, a != EOF) {
    int i;
    a = a + b;
    while (a > 0) {
      a = a / 10;
      ++i;
    }

    cout << i << endl;
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int a, b;
  while (cin >> a >> b) {
    int sum = a + b;
    int i = 1;
    int count = 0;
    while (sum / i != 0) {
      count++;
      i *= 10;
    }
    cout << count << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  while (true) {
    int a, b;
    cin >> a >> b;
    int sum = a + b;
    int i = 1;
    int count = 0;
    while (sum / i != 0) {
      count++;
      i *= 10;
    }
    cout << count;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Runtime Error

#define scanf_s scanf
#include <iostream>
#include <stdio.h>
using namespace std;
#define MAX 200
int main(void) {
  int a, b, sum, cou = 0;
  while (scanf_s("%d %d", &a, &b) != EOF) {
    sum = a + b;
    while (1) {
      if (sum <= 0)
        break;
      sum /= 10;
      ++cou;
    }
    printf("%d\\n", cou);
    cou = 0;
  }
}

Error: -11

Fixed submission:

#define scanf_s scanf
#include <iostream>
#include <stdio.h>
using namespace std;
#define MAX 200
int main(void) {
  int a, b, i, sum, cou = 0;
  int ans[MAX] = {0};
  while (scanf_s("%d %d", &a, &b) != 0) {
    sum = a + b;
    ++ans[cou];
    if (sum != 0) {
      while (1) {
        if (sum <= 1)
          break;
        sum /= 10;
        ++ans[cou];
      }
    }
    ++cou;
  }
  for (i = 0; i < cou; ++i) {
    if (i != 0)
      printf("\\n");
    printf("%d", ans[i]);
  }
}
Problem p00002 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
char d[9];
int main() {
  for (int a, b; ~scanf("%d %d", &a, &b);
       printf("%d\\n", sprintf(d, "%d", a + b)))
    ;
}

Error: -11

Fixed submission:

#include <cstdio>
char s[9];
int main() {
  for (int a, b; ~scanf("%d %d", a, b); printf("%d\\n", sprintf(s, "%s", a + b)))
    ;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b;
  int count;
  int wa;
  while (cin >> a && cin >> b) {
    count = 1;
    wa = a + b;
    while ((wa /= 10) != 0) {
      count++;
    }
    cout << count << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main(int argc, char *argv[]) {
  ifstream fin(argv[1]);
  int a, b;
  int count;
  int wa;
  while (!fin.eof()) {
    fin >> a >> b;
    count = 1;
    wa = a + b;
    while (wa / 10 != 0) {
      count++;
      wa /= 10;
    }
    cout << count << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int a, b, c, k;
  string str;
  while (1) {
    k = 1;
    getline(cin, str);
    if (str.size() == 0) {
      break;
    }
    sscanf(str.c_str(), "%d %d", &a, &b);
    c = a + b;
    while (c / 10 > 0) {
      c /= 10;
      k++;
    }
    printf("%d\\n", k);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b, c;
  while (1) {
    int k = 1;
    cin >> a >> b;
    c = a + b;
    while (c / 10 > 0) {
      c /= 10;
      k++;
    }
    cout << k << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int digit(int num) {
  if ((num / 10) > 0)
    return (digit(num / 10)) + 1;
  else
    return 1;
}

int main() {
  int num1, num2, result = 0;
  char buf[32];
  while (fscanf(stdin, "%d %d", &num1, &num2) != EOF) {
    result = digit(num1 + num2);
    cout << result << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

using namespace std;

int digit(int num) {
  if ((num / 10) > 0) {
    return (digit(num / 10)) + 1;
  } else
    return 1;
}

int main() {
  int num1, num2, result = 0;
  char buf[64];
  while (1) {
    fgets(buf, 64, stdin);
    if (buf[0] == '\\0')
      break;
    num1 = 0;
    num2 = 0;
    sprintf(buf, "%d %d", num1, num2);
    result += digit(num1);
    result += digit(num2);
    cout << result << endl;
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  int a, b;
  int sum;
  int loop_i, loop_j;
  int cnt = 0;

  while (scanf("%d %d", &a, &b) != EOF) {
    sum = 0;
    sum = a + b;
    for (loop_i = 0; sum != 0; loop_i++)
      sum /= 10;
    printf("%d\\n", loop_i);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int a, b;
  int sum;
  int loop_i, loop_j;
  int cnt = 0;

  while (1) {
    sum = 0;
    fscanf(stdin, "%d %d", &a, &b);
    sum = a + b;
    do {
      sum = sum / 10;
      cnt++;
      if (sum == 0)
        break;
    } while (1);
    printf("%d\\n", cnt);
  }
  return 0;
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <math.h>

using namespace std;

int main(void) {
  long a, b;

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

    cout << (int)log10(a + b) + 1 << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>

using namespace std;

int main(void) {
  int a, b;

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

    cout << (int)log10(a + b) + 1 << endl;
  }

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

#include <stdio.h>
int main() {
  int a;
  while (scanf("%d", &a) != EOF) {
    int b;
    scanf("%d", &b);

    int temp = a + b;
    int ans = 1;
    while ((temp /= 10) > 0) {
      ans++;
    }
    printf("%d\\n", ans);
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>
int main() {
  while (true) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == EOF || b == EOF)
      break;

    int temp = a + b;
    int ans = 1;
    while ((temp /= 10) >= 10) {
      ans++;
    }
    printf("%d\\n", ans);
  }
}
Problem p00002 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main(void) {
  int i, a, x, b, c;
  while ((scanf("%d%d", &a, &b)) != EOF) {
    c = 0;
    x = a + b;
    while (x != 0) {
      x = x / 10;
      c++;
    }
    printf("%d\\n", c);
  }
}

Error: 0

Fixed submission:

#include <stdio.h>
int main(void) {
  int i, a, x, b, c;
  x = 0;
  c = 1;
  b = 1;
  while (scanf("%d%d", &a, &b) != EOF) {
    x = a + b;
    while (1) {
      if (x / b != 0) {
        c++;
        b *= 10;
      } else
        break;
    }
    printf("%d\\n", c);
  }
}
Problem p00002 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
int main() {
  int a, b;
  while (std::cin >> a >> b) {
    int n = a + b;
    if (n < 10)
      std::cout << 1 << std::endl;
    else if (n < 100)
      std::cout << 2 << std::endl;
    else if (n < 1000)
      std::cout << 3 << std::endl;
    else if (n < 10000)
      std::cout << 4 << std::endl;
    else if (n < 100000)
      std::cout << 5 << std::endl;
    else if (n < 1000000)
      std::cout << 6 << std::endl;
    else if (n < 10000000)
      std::cout << 7 << std::endl;
    else if (n < 100000000)
      std::cout << 8 << std::endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
int main() {
  int d = 200;
  while (d > 0) {
    int a, b;
    std::cin >> a >> b;
    int n = a + b;
    if (n < 10)
      std::cout << 1 << std::endl;
    if (n >= 10 && n < 100)
      std::cout << 2 << std::endl;
    if (n >= 100 && n < 1000)
      std::cout << 3 << std::endl;
    if (n >= 1000 && n < 10000)
      std::cout << 4 << std::endl;
    if (n >= 10000 && n < 100000)
      std::cout << 5 << std::endl;
    if (n >= 100000 && n < 1000000)
      std::cout << 6 << std::endl;
    if (n >= 1000000 && n < 10000000)
      std::cout << 7 << std::endl;
  }
  return 0;
}
Problem p00006 (C++) — buggy submission, verdict: Time Limit Exceeded

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

  for (int i = a.length() - 1; i > -1; i--) {
    cout << a[i];
  }
  cout << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string a;
  while (1) {
    cin >> a;
    if (a.length() < 20)
      break;
  }
  for (int i = a.length() - 1; i > -1; i--) {
    cout << a[i];
  }
  return 0;
}
Problem p00006 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;

constexpr int INF = 1000000000; /* 1e+9a */
constexpr int MODULO = 1000000007;

#define int long

#define REP(i, f, n) for (int i = (f); i < (n); ++i)
#define PER(i, f, n) for (int i = (n - 1); i >= f; --i)

constexpr int evx[4] = {1, 0, -1, 0};
constexpr int evy[4] = {0, 1, 0, -1};

//----------------------------------
//----------------------------------

signed main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  PER(i, 0, s.size())
  cout << s[i];
  cout << endl;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;

constexpr int INF = 1000000000; /* 1e+9a */
constexpr int MODULO = 1000000007;

#define int long

#define REP(i, f, n) for (int i = (f); i < (n); ++i)
#define PER(i, f, n) for (int i = (n - 1); i >= f; --i)

constexpr int evx[4] = {1, 0, -1, 0};
constexpr int evy[4] = {0, 1, 0, -1};

//----------------------------------
//----------------------------------

signed main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  PER(i, s.size(), 0)
  cout << s[i];
  cout << endl;
}
Problem p00006 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string s, ans = "";
  int sl;
  cin >> s;
  sl = s.size();
  for (int i = sl - 1; i > -1; i--)
    ans += s[i];
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  char x[30];
  int i = 0;
  scanf("%s\\n", &x);
  while (x[i] != '\\0')
    i++;
  for (int j = i - 1; j > -1; j++)
    cout << x[i];
}
Problem p00006 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  char str[21];
  int i, j;
  scanf("%s", str);

  for (i = 0; str[i] != '\\0'; i++) {
  }

  for (j = i - 1; j > -1; j--) {
    printf("%c", str[j]);
  }

  puts("");

  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>
int main() {
  char str[20];
  int i, j;
  scanf("%s", str);

  for (i = 0; str[i] != '\\0'; i++) {
  }

  for (j = i - 1; j > -1; j--) {
    printf("%c", str[j]);
  }

  puts("");

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

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main(void) {
  string str;
  cin >> str;
  reverse(str.begin(), str.end());
  cout << str << endl;
  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
#include <string.h>
int main(void) {

  int i, j, n;
  i = 0;
  j = 0;
  char a[20], b[20];

  scanf("%s", a);

  n = strlen(a);

  for (i = n - 1; i >= 0; i--) {
    b[n - 1 - i] = a[i];
    printf("%c\\n", b[n - 1 - i]);
  }
  b[n] = '\\0';

  printf("%s\\n", b);
  return 0;
}
Problem p00006 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>

using namespace std;

int main() {
  string str;
  cin >> str;

  for (int i = str.size() - 1; i >= 0; i--) {
    cout << str[i];
  }
  cout << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  string str;
  cin >> str;

  for (int i = str.size() - 1; i >= 0; i++) {
    cout << str[i];
  }
  cout << endl;
  return 0;
}
Problem p00006 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>

using namespace std;

int main() {
  string str;
  string ans;
  cin >> str;
  ans = str;
  for (int i = 0; i < str.size(); i++) {
    ans[i] = str[str.size() - i - 1];
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  string str;
  string ans;
  while (1) {
    cin >> str;
    ans = str;
    for (int i = 0; i < str.size(); i++) {
      ans[i] = str[str.size() - i - 1];
    }
    cout << ans << endl;
  }
}
Problem p00006 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
string s;
int main() {
  cin >> s;
  for (string::reverse_iterator it = s.rbegin(); it != s.rend(); it++)
    cout << *it;
  cout << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
string s;
int main() {
  cin >> s;
  for (unsigned i = s.size() - 1; i >= 0; i--)
    cout << s[i];
  return 0;
}
Problem p00006 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  char c[20];

  scanf("%s", &c);
  int i;

  for (i = 0; i < 20; i++) {
    if ((int(c[19 - i]) != -52) && (int(c[19 - i] != 0))) {
      printf("%c", c[19 - i]);
    }
  }
  printf("\\n");

  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>

int main() {
  char c[20];

  scanf("%s", c);
  int i;

  for (i = 0; i < 20; i++) {
    if ((int(c[19 - i]) != -52) && (int(c[19 - i] != 0))) {
      printf("%c", c[19 - i]);
    }
  }

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

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

using namespace std;

int main() {
  string S;

  cin >> S;

  for (string::size_type i = 0; i < S.size() / 2; i++) {
    swap(S[i], S[S.size() - i - 1]);
  }

  for (string::size_type i = 0; i < S.size(); i++) {
    cout << S[i];
  }

  cout << endl;

  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

int main() {
  string S;

  cin >> S;

  for (string::size_type i = S.size() - 1; i >= 0; i--) {
    cout << S[i];
  }

  cout << endl;

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

#include <stdio.h>
#include <string.h>

int main(void) {
  char str[20];
  scanf("%s", str);
  for (int i = strlen(str) - 1; i >= 0; i--) {
    printf("%c", str[i]);
  }
  printf("\\n");
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
#include <string.h>

int main(void) {
  char str[20];
  scanf("%s", str);
  for (int i = strlen(str) - 1; i > 0; i--)
    printf("%s", str[i - 1]);
  printf("\\n");
  return 0;
}
Problem p00006 (C++) — buggy submission, verdict: Runtime Error

#include <cstring>
#include <iostream>
using namespace std;
int main() {
  char stra[21], strb[21];
  int a, c;
  cin >> stra;
  a = strlen(stra);
  for (int i = 0; i < a; i++) {
    c = a - i - 1;
    strb[i] = stra[c];
    strb[i + 1] = '\\0';
  }
  cout << strb << endl;
}

Error: 0

Fixed submission:

#include <cstring>
#include <iostream>

using namespace std;

int main() {
  char stra[20], strb[20];
  int a, c;
  cin >> stra;
  a = strlen(stra);
  for (int i = 0; i < a; i++) {
    c = a - i - 1;
    strb[i] = stra[c];
    strb[i + 1] = '\\0';
  }
  cout << strb << endl;
}
Problem p00006 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int n = 0;
  char a[1000];
  for (int i = 0; i < 1000; i++)
    a[i] = '\\0';
  scanf("%s", a);
  while (a[n] != '\\0')
    n++;
  for (int i = n - 1; i >= 0; i--)
    printf("%c", a[i]);
  printf("\\n");
}

Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  int n = 0;
  char a[1000];
  for (int i = 0; i < 1000; i++)
    a[i] = '\\0';
  scanf("%s", a);
  while (a[n] != '\\0')
    n++;
  for (int i = n - 1; i >= 0; i++)
    printf("%c", a[i]);
  printf("\\n");
}
Problem p00006 (C++) — buggy submission, verdict: Runtime Error

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

int main(int argc, char *argv[]) {
  char rcv[21];
  char out[21];
  fscanf(stdin, "%s\\n", rcv);
  int cnt = 0;
  for (int i = 0; i < 21; i++) {
    if (rcv[i] == '\\0') {
      for (int j = i - 1; j != -1; j--) {
        out[cnt] = rcv[j];
        cnt++;
      }
      out[cnt] = '\\0';
      break;
    }
  }
  printf("%s\\n", out);

  return 0;
}

Error: 0

Fixed submission:

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

int main(int argc, char *argv[]) {
  char rcv[20];
  char out[20];
  fscanf(stdin, "%s\\n", rcv);
  int cnt = 0;
  for (int i = 0; i < 20; i++) {
    if (rcv[i] == '\\0') {
      for (int j = i - 1; j != -1; j--) {
        out[cnt] = rcv[j];
        cnt++;
      }
      out[cnt] = '\\0';
      break;
    }
  }
  printf("%s\\n", out);

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

#include <iostream>
#include <string>
using namespace std;
int main() {
  char a;
  string str;
  cin >> str;
  for (int i = 0; i < str.size() - 1 - i; i++) {
    a = str[i];
    str[i] = str[str.size() - 1 - i];
    str[str.size() - 1 - i] = a;
  }
  cout << str << endl;
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  char a;
  string str;
  cin >> str;
  for (int i = 0; i != str.size() - 1 - i; i++) {
    a = str[i];
    str[i] = str[str.size() - 1 - i];
    str[str.size() - 1 - i] = a;
  }
  cout << str << endl;
}