alexjercan/bugnet huggingface dataset:
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

using namespace std;

int main(void) {
  char in[12][12], data[10];
  int i, j, flag = 0, out = 0, y, x;

  for (i = 0; i < 12; i++) {
    for (j = 0; j < 12; j++) {
      in[i][j] = '0';
    }
  }

  while (1) {
    for (i = 2; i < 10; i++) {
      if (scanf("%s", data) == EOF)
        flag = 1;
      if (flag == 1)
        break;
      for (j = 0; j < 8; j++) {
        in[i][j + 2] = data[j];
      }
    }
    if (flag == 1)
      break;

    for (i = 2; i < 10; i++) {
      for (j = 2; j < 10; j++) {
        if (in[i][j] == '1') {
          y = i;
          x = j;
          out = 1;
          break;
        }
      }
      if (out == 1)
        break;
    }
    out = 0;

    if (in[y][x + 1] == '1' && in[y + 1][x] == '1' && in[y + 1][x + 1] == '1')
      printf("A\\n");
    if (in[y + 1][x] == '1' && in[y + 2][x] == '1' && in[y + 3][x] == '1')
      printf("B\\n");
    if (in[y][x + 1] == '1' && in[y][x + 2] == '1' && in[y][x + 3] == '1')
      printf("C\\n");
    if (in[y + 1][x - 1] == '1' && in[y + 1][x] == '1' &&
        in[y + 2][x - 1] == '1')
      printf("D\\n");
    if (in[y][x + 1] == '1' && in[y + 1][x + 1] == '1' &&
        in[y + 1][x + 2] == '1')
      printf("E\\n");
    if (in[y + 1][x] == '1' && in[y + 1][x + 1] == '1' &&
        in[y + 2][x + 1] == '1')
      printf("F\\n");
    if (in[y][x + 1] == '1' && in[y + 1][x - 1] == '1' && in[y + 1][x] == '1')
      printf("G\\n");
  }

  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>

using namespace std;

int main(void) {
  char in[8][8];
  int i, j, flag = 0, out = 0, y, x;

  while (1) {
    for (i = 0; i < 8; i++) {
      if (scanf("%s", in[i]) == EOF)
        flag = 1;
      if (flag == 1)
        break;
    }
    if (flag == 1)
      break;

    for (i = 0; i < 8; i++) {
      for (j = 0; j < 8; j++) {
        if (in[i][j] == '1') {
          y = i;
          x = j;
          out = 1;
          break;
        }
      }
      if (out == 1)
        break;
    }
    out = 0;

    if (in[y][x + 1] == '1' && in[y + 1][x] == '1' && in[y + 1][x + 1] == '1')
      printf("A\\n");
    if (in[y + 1][x] == '1' && in[y + 2][x] == '1' && in[y + 3][x] == '1')
      printf("B\\n");
    if (in[y][x + 1] == '1' && in[y][x + 2] == '1' && in[y][x + 3] == '1')
      printf("C\\n");
    if (in[y + 1][x - 1] == '1' && in[y + 1][x] == '1' &&
        in[y + 2][x - 1] == '1')
      printf("D\\n");
    if (in[y][x + 1] == '1' && in[y + 1][x + 1] == '1' &&
        in[y + 1][x + 2] == '1')
      printf("E\\n");
    if (in[y + 1][x] == '1' && in[y + 1][x + 1] == '1' &&
        in[y + 2][x + 1] == '1')
      printf("F\\n");
    if (in[y][x + 1] == '1' && in[y + 1][x - 1] == '1' && in[y + 1][x] == '1')
      printf("G\\n");
  }

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

#include <cstdlib>
#include <iostream>
using namespace std;
int field[12][12];

char search(int y, int x) {
  if (field[y][x + 1] == 1) { // A
    if (field[y][x + 2] == 1) {
      return 'C';
    }
    if (field[y + 1][x] == 1 && field[y + 1][x + 1] == 1) {
      return 'A';
    }
    if (field[y + 1][x] == 1 && field[y + 1][x - 1] == 1) {
      return 'G';
    }
    if (field[y + 1][x + 1] == 1 && field[y + 1][x + 2] == 1) {
      return 'E';
    }
  }
  if (field[y + 2][x] == 1) {
    return 'B';
  }
  if (field[y + 1][x - 1] == 1) {
    return 'D';
  }
  if (field[y + 2][x + 1] == 1) {
    return 'F';
  }
  return 'X';
}

void solve() {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (field[i + 1][j + 1] != 0) {
        cout << search(i + 1, j + 1) << endl;
        return;
      }
    }
  }
}

int main() {
  string str;
  while (1) {
    for (int i = 0; i < 8; i++) {
      getline(cin, str);
      if (str.size() == 0)
        return 0;
      for (int j = 0; j < 8; j++) {
        field[i + 1][j + 1] = atoi(str.substr(j, 1).c_str());
      }
    }
    solve();
    getline(cin, str); // kill \\n
  }
}

Error: TLE

Fixed submission:

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

int main() {
NEXT:
  char x;
  int k = 0;
  while (1) {
    cin.get(x);
    if (x == '1') {
      k = k % 7;
      break;
    }
    k++;
  }
  cin.get(x);
  if (x == '1') { // A,C,E,G
    cin.get(x);
    if (x == '1') // C
      cout << "C" << endl;
    else if (x == '0') { // A,E,G
      for (int i = 0; i < 6; i++) {
        cin.get(x);
      }
      if (x == '1')
        cout << "G" << endl; // G
      else if (x == '0') {
        cin.get(x);
        if (x == '1')
          cout << "A" << endl; // A
        else
          cout << "E" << endl; // E
      }
    }
  } else if (x == '0') { // B,D,F
    for (int i = 0; i < 6; i++) {
      cin.get(x);
    }
    if (x == '1')
      cout << "D" << endl;
    else if (x == '0') {
      cin.get(x);
      cin.get(x);
      if (x == '1')
        cout << "F" << endl;
      else
        cout << "B" << endl;
    }
  }
  while (1) {
    cin.get(x);
    if (x == '\\n') {
      cin.get(x);
      if (x == '\\n')
        goto NEXT;
    }
  }
}
Problem p00036 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <ctype.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;

char Types(char x[12][11]);

int main() {
  char x[100];
  for (int i = 0; i < 100; i++) {
    x[i] = '0';
  }

  while (cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4] >> x[5] >> x[6] >> x[7] >>
         x[8] >> x[9] >> x[10] >> x[11] >> x[12] >> x[13] >> x[14] >> x[15] >>
         x[16] >> x[17] >> x[18] >> x[19] >> x[20] >> x[21] >> x[22] >> x[23] >>
         x[24] >> x[25] >> x[26] >> x[27] >> x[28] >> x[29] >> x[30] >> x[31] >>
         x[32] >> x[33] >> x[34] >> x[35] >> x[36] >> x[37] >> x[38] >> x[39] >>
         x[40] >> x[41] >> x[42] >> x[43] >> x[44] >> x[45] >> x[46] >> x[47] >>
         x[48] >> x[49] >> x[50] >> x[51] >> x[52] >> x[53] >> x[54] >> x[55] >>
         x[56] >> x[57] >> x[58] >> x[59] >> x[60] >> x[61] >> x[62] >> x[63]) {

    //        for(int i=0; i<64; i++){
    //            cin>>x[i];
    ////            if(x[i]==EOF){
    ////                flag=0;
    ////                break;
    ////            }
    //        }
    ////        if(flag!=1){
    ////            break;
    ////        }
    //
    int first = -1;
    for (int i = 0; i < 64; i++) {
      if (x[i] == '1') {
        first = i;
        break;
      }
    }
    //        if(first==-1){
    //            break;
    //        }

    if (x[first + 1] == '1') {
      if (x[first + 2] == '1') {
        cout << "C" << endl;
      } else if (x[first + 7] == '1') {
        cout << "G" << endl;
      } else if (x[first + 10] == '1') {
        cout << "E" << endl;
      } else {
        cout << "A" << endl;
      }
    } else {
      if (x[first + 7] == '1') {
        cout << "D" << endl;
      } else if (x[first + 9] == '1') {
        cout << "F" << endl;
      } else {
        cout << "B" << endl;
      }
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <ctype.h>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>

using namespace std;

char Types(char x[12][11]);

int main() {
  char x[100];
  for (int i = 0; i < 100; i++) {
    x[i] = '0';
  }
  int flag = 1;

  while (flag) {

    for (int i = 0; i < 64; i++) {
      cin >> x[i];
      if (x[i] == EOF) {
        flag = 0;
        break;
      }
    }
    if (flag != 1) {
      break;
    }

    int first;
    for (int i = 0; i < 64; i++) {
      if (x[i] == '1') {
        first = i;
        break;
      }
    }

    if (x[first + 1] == '1') {
      if (x[first + 2] == '1') {
        cout << "C" << endl;
      } else if (x[first + 7] == '1') {
        cout << "G" << endl;
      } else if (x[first + 10] == '1') {
        cout << "E" << endl;
      } else {
        cout << "A" << endl;
      }
    } else {
      if (x[first + 7] == '1') {
        cout << "D" << endl;
      } else if (x[first + 9] == '1') {
        cout << "F" << endl;
      } else {
        cout << "B" << endl;
      }
    }
  }

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

#include <iostream>
#include <string>
using namespace std;
int main() {
  int cnt = 0, x, y;
  char zero;
  while (cin >> zero) {
    char masu[8][8];
    cnt = 0;
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (i == 0 && j == 0) {
          masu[0][0] = zero;
        } else {
          cin >> masu[i][j];
        }
        if (masu[i][j] == '1' && cnt == 0) {
          x = i, y = j;
          cnt++;
        }
      }
    }
    if (masu[x][y + 1] == '1') {
      if (masu[x][y + 2] == '1') {
        cout << "C" << endl;
      } else if (masu[x + 1][y] == '0') {
        cout << "E" << endl;
      } else if (masu[x + 1][y + 1] == '0') {
        cout << "G" << endl;
      } else {
        cout << "A" << endl;
      }
    } else {
      if (masu[x + 1][y - 1] == '1') {
        cout << "D" << endl;
      } else if (masu[x + 1][y + 1] == '1') {
        cout << "F" << endl;
      } else {
        cout << "B" << endl;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int cnt = 0, x, y;
  while (true) {
    char masu[8][8];
    cnt = 0;
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        cin >> masu[i][j];
        if (masu[i][j] == '1' && cnt == 0) {
          x = i, y = j;
          cnt++;
        }
      }
    }
    if (masu[x][y + 1] == '1') {
      if (masu[x][y + 2] == '1') {
        cout << "C" << endl;
      } else if (masu[x + 1][y] == '0') {
        cout << "E" << endl;
      } else if (masu[x + 1][y + 1] == '0') {
        cout << "G" << endl;
      } else {
        cout << "A" << endl;
      }
    } else {
      if (masu[x + 1][y - 1] == '1') {
        cout << "D" << endl;
      } else if (masu[x + 1][y + 1] == '1') {
        cout << "F" << endl;
      } else {
        cout << "B" << endl;
      }
    }
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error


#include <iostream>
using namespace std;
#define rep(i, a) for (int i = 0; i < a; i++)
int main(void) {
  char maze[9][9];
  while (true) {
    rep(i, 8) rep(j, 8) cin >> maze[i][j];
    if (cin.eof())
      break;
    bool used = false;
    rep(y, 8) {
      rep(x, 8) {
        if (maze[y][x] == '1') {
          if (maze[y][x + 1] == '1' && maze[y + 1][x] == '1' &&
              maze[y + 1][x + 1] == '1')
            cout << "A" << endl;
          else if (maze[y + 1][x] == '1' && maze[y + 2][x] == '1' &&
                   maze[y + 3][x] == '1')
            cout << "B" << endl;
          else if (maze[y][x + 1] == '1' && maze[y][x + 2] == '1' &&
                   maze[y][x + 3] == '1')
            cout << "C" << endl;
          else if (maze[y + 1][x] == '1' && maze[y + 1][x - 1] == '1' &&
                   maze[y + 2][x - 1] == '1')
            cout << "D" << endl;
          else if (maze[y][x + 1] == '1' && maze[y + 1][x + 1] == '1' &&
                   maze[y + 1][x + 2] == '1')
            cout << "E" << endl;
          else if (maze[y + 1][x] == '1' && maze[y + 1][x + 1] == '1' &&
                   maze[y + 2][x + 1] == '1')
            cout << "F" << endl;
          else
            cout << "G" << endl;
          used = true;
        }
        if (used)
          break;
      }
      if (used)
        break;
    }
  }

  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
#include <vector>
#define MAX 999999
bool prime[MAX];
using namespace std;

int main(void) {
  int n;

  vector<int> dp(0, 0);
  // isPrime();

  fill(prime, prime + MAX, true);
  int cnt = 0;
  prime[0] = prime[1] = false;
  for (int i = 2; i < MAX; i++) {
    if (prime[i]) {
      cnt += i;
      for (int j = 2; j * i < MAX; j++) {
        prime[i * j] = false;
      }
      dp.push_back(cnt);
    }
  }

  while (cin >> n, n)
    cout << dp[n - 1] << endl;
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

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

vector<string> f;

const string P[7][4] = {
    {// A
     "1100", "1100", "0000", "0000"},
    {// B
     "1000", "1000", "1000", "1000"},
    {// C
     "1111", "0000", "0000", "0000"},
    {// D
     "0100", "1100", "1000", "0000"},
    {// E
     "1100", "0110", "0000", "0000"},
    {// F
     "1000", "1100", "0100", "0000"},
    {// G
     "0110", "1100", "0000", "0000"},
};

bool check(int x, int y, int k) {
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      int nx = x + j;
      int ny = y + i;
      if (P[k][i][j] == '1') {
        if (nx < 0 || nx >= 8 || ny < 0 || ny >= 8) {
          return false;
        }
        if (P[k][i][j] != f[ny][nx])
          return false;
      }
    }
  }
  return true;
}

int main(void) {
  while (cin.eof() == false) {
    f = vector<string>(8);
    string line;
    for (int i = 0; i < 8; i++) {
      getline(cin, line);
      f[i] = line;
      if (cin.eof())
        break;
    }
    if (cin.eof())
      break;
    getline(cin, line);

    char answer = 'A';
    bool not_found = true;
    for (int i = 0; not_found && i < 8; i++) {
      for (int j = 0; not_found && j < 8; j++) {
        for (int k = 0; not_found && k < 7; k++) {
          if (check(j, i, k)) {
            answer += k;
            not_found = false;
          }
        }
      }
    }

    cout << answer << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

vector<string> f;

const string P[7][4] = {
    {// A
     "1100", "1100", "0000", "0000"},
    {// B
     "1000", "1000", "1000", "1000"},
    {// C
     "1111", "0000", "0000", "0000"},
    {// D
     "0100", "1100", "1000", "0000"},
    {// E
     "1100", "0110", "0000", "0000"},
    {// F
     "1000", "1100", "0100", "0000"},
    {// G
     "0110", "1100", "0000", "0000"},
};

bool check(int x, int y, int k) {
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      int nx = x + j;
      int ny = y + i;
      if (P[k][i][j] == '1') {
        if (nx < 0 || nx > 8 || ny < 0 || ny > 8) {
          return false;
        }
        if (P[k][i][j] != f[ny][nx])
          return false;
      }
    }
  }
  return true;
}

int main(void) {
  while (cin.eof() == false) {
    f = vector<string>(8);
    string line;
    for (int i = 0; i < 8; i++) {
      getline(cin, line);
      f[i] = line;
      if (cin.eof())
        break;
    }
    if (cin.eof())
      break;
    getline(cin, line);

    char answer = 'A';
    bool not_found = true;
    for (int i = 0; not_found && i < 8; i++) {
      for (int j = 0; not_found && j < 8; j++) {
        for (int k = 0; not_found && k < 7; k++) {
          if (check(j, i, k)) {
            answer += k;
            not_found = false;
          }
        }
      }
    }

    cout << answer << endl;
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
/*
A 11 B 1 C 1111 D 01 E 110 F 10 G 011
  11   1          11   011   11   110
       1          10         01
       1
*/
int main() {
  string map[8], in;
  while (cin >> in) {
    map[0] = in;
    int h;
    string key[4];
    if (in == "00000000")
      h = 0;
    else {
      key[0] = in;
      h = 1;
    }
    for (int i = 1; i < 8; i++) {
      cin >> map[i];
      if (map[i] != "00000000")
        key[h++] = map[i];
    }
    if (h == 4)
      cout << "B" << endl;
    else if (h == 1)
      cout << "C" << endl;
    else if (h == 3) {
      bool flag = true;
      for (int i = 0; i < 8; i++)
        if (key[1][i] == '1') {
          if (key[0][i] == '1')
            flag = false;
          break;
        }
      if (flag)
        cout << "D" << endl;
      else
        cout << "F" << endl;
    } else {
      bool flag = true;
      for (int i = 0; i < 8; i++)
        if (key[0][i] == '1') {
          if (key[1][i] == '0')
            flag = false;
          break;
        }
      if (flag) {
        for (int i = 0; i < 8; i++)
          if (key[1][i] == '1') {
            if (key[0][i] == '0')
              flag = false;
            break;
          }
        if (flag)
          cout << "A" << endl;
        else
          cout << "G" << endl;
      } else {
        cout << "E" << endl;
      }
    }
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

/*
A 2*2 B 1*4 C 4*1 D 01 E 110 F 10 G 011
                    11   011   11   110
                    10         01
*/

int main() {
  while (true) {
    string in[4];
    string tmp;
    int j = 0;
    for (int i = 0; i < 8; i++) {
      cin >> tmp;
      if (tmp != "00000000") {
        in[j] = tmp;
        j++;
      }
    }
    scanf("\\n");
    if (j == 4) {
      cout << "B" << endl;
    } else if (j == 1) {
      cout << "C" << endl;
    } else if (j == 2) {
      if (in[0] == in[1]) {
        cout << "A" << endl;
      } else if (in[0] > in[1]) {
        cout << "E" << endl;
      } else {
        cout << "G" << endl;
      }
    } else {
      if (in[0] > in[1]) {
        cout << "F" << endl;
      } else {
        cout << "D" << endl;
      }
    }
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <cstring>

int main() {
  char p[7][19] = {
      "1100000011",  "10000000100000001",  "1111",     "1000000110000001",
      "11000000011", "100000001100000001", "110000011"};
  char f[65];
  char t;
  while (1 + scanf("%c", &t)) {
    while (t == 10) {
      scanf("%c", &t);
    }
    f[0] = t;
    for (int i = 1; i < 64; i++) {
      scanf("%c", &t);
      while (t == 10) {
        scanf("%c", &t);
      }
      f[i] = t;
    }
    f[64] = '\\0';
    for (int i = 0; i < 7; i++) {
      if (strstr(f, p[i])) {
        printf("%c\\n", i + 'A');
      }
    }
    scanf("%c", &t);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <cstring>

int main() {
  char p[7][19] = {
      "1100000011",  "10000000100000001",  "1111",     "1000000110000001",
      "11000000011", "100000001100000001", "110000011"};
  char f[65];
  char t;
  while (1 + scanf("%c", &t)) {
    while (t == 10) {
      scanf("%c", &t);
    }
    f[0] = t;
    for (int i = 1; i < 64; i++) {
      scanf("%c", &t);
      while (t == 10) {
        scanf("%c", &t);
      }
      f[i] = t;
    }
    f[64] = '\\0';
    for (int i = 0; i < 7; i++) {
      if (strstr(f, p[i])) {
        printf("%c\\n", i + 'A');
      }
    }
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;
int main() {
  string a[8];
  for (; cin >> a[0];) {
    for (int i = 1; i < 8; i++)
      cin >> a[i];
    char n = 'X';
    for (int i = 0; i < 8; i++)
      for (int j = 0; j < 8; j++)
        if (a[i][j] == '1') {
          if (i < 7 && j < 7 && a[i][j + 1] == '1' && a[i + 1][j] == '1' &&
              a[i + 1][j + 1] == '1')
            n = 'A';
          else if (i < 5 && a[i + 1][j] == '1' && a[i + 2][j] == '1' &&
                   a[i + 3][j] == '1')
            n = 'B';
          else if (j < 5 && a[i][j + 1] == '1' && a[i][j + 2] == '1' &&
                   a[i][j + 3] == '1')
            n = 'C';
          else if (j > 0 && i < 6 && a[i + 1][j] == '1' &&
                   a[i + 1][j - 1] == '1' && a[i + 2][j - 1] == '1')
            n = 'D';
          else if (i < 7 && j < 6 && a[i][j + 1] == '1' &&
                   a[i + 1][j + 1] == '1' && a[i + 1][j + 2] == '1')
            n = 'E';
          else if (i < 6 && j < 7 && a[i + 1][j] == '1' &&
                   a[i + 1][j + 1] == '1' && a[i + 2][j + 1] == '1')
            n = 'F';
          if (n != 'X')
            break;
        }
    if (n == 'X')
      n = 'G';
    cout << n << endl;
  }
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;
int main() {
  string a[8];
  for (; cin >> a[0];) {
    for (int i = 1; i < 8; i++)
      cin >> a[i];
    char n = 'X';
    for (int i = 0; i < 8; i++)
      for (int j = 0; j < 8; j++)
        if (a[i][j] == '1') {
          if (i < 7 && j < 7 && a[i][j + 1] == '1' && a[i + 1][j] == '1' &&
              a[i + 1][j + 1] == '1')
            n = 'A';
          else if (i < 5 && a[i + 1][j] == '1' && a[i + 2][j] == '1' &&
                   a[i + 3][j] == '1')
            n = 'B';
          else if (j < 5 && a[i][j + 1] == '1' && a[i][j + 2] == '1' &&
                   a[i][j + 3] == '1')
            n = 'C';
          else if (i < 6 && a[i][j + 1] == '1' && a[i - 1][j + 1] == '1' &&
                   a[i - 1][j + 2] == '1')
            n = 'D';
          else if (i < 7 && j < 6 && a[i][j + 1] == '1' &&
                   a[i + 1][j + 1] == '1' && a[i + 1][j + 2] == '1')
            n = 'E';
          else if (i < 6 && j < 7 && a[i + 1][j] == '1' &&
                   a[i + 1][j + 1] == '1' && a[i + 2][j + 1] == '1')
            n = 'F';

          if (n != 'X')
            break;
        }
    if (n == 'X')
      n = 'G';
    cout << n << endl;
  }
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
int main() {
  while (1) {
    std::string s[8];

    int x = 0, y = 0;
    for (int i = 0; i < 8; i++) {
      std::cin >> s[i];
      if (std::cin.eof())
        return 0;
    }

    for (int i = 0; i < 64; i++)
      if (s[i / 8][i % 8] == '1') {
        x = i % 8, y = i / 8;
        break;
      }

    char res;
    if (y + 1 < 8 && s[y + 1][x] == '1') {
      if (x - 1 >= 0 && s[y + 1][x - 1] == '1') {
        if (x + 1 < 8 && s[y][x + 1] == '1') {
          res = 'G';
        } else {
          res = 'D';
        }
      } else if (x + 1 < 8 && s[y + 1][x + 1] == '1') {
        if (s[y][x + 1] == '1') {
          res = 'A';
        } else {
          res = 'F';
        }
      } else {
        res = 'B';
      }
    } else {
      if (x + 1 < 8 && y + 1 < 8 && s[y + 1][x + 1] == '1') {
        res = 'E';
      } else {
        res = 'C';
      }
    }

    std::cout << res << std::endl;
  }
}

Error: 0

Fixed submission:

#include <iostream>
int main() {
  int f = 0;
  while (1) {
    std::string s[8];

    int x = 0, y = 0;
    for (int i = 0; i < 8; i++) {
      std::cin >> s[i];
      if (std::cin.eof())
        f = 1;
    }

    if (f)
      break;

    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++)
        if (s[i][j] == '1' && !x && !y)
          x = j, y = i;
    }

    char res;
    if (y + 1 < 8 && s[y + 1][x] == '1') {
      if (x - 1 >= 0 && s[y + 1][x - 1] == '1') {
        if (x + 1 < 8 && s[y][x + 1] == '1') {
          res = 'G';
        } else {
          res = 'D';
        }
      } else if (x + 1 < 8 && s[y + 1][x + 1] == '1') {
        if (s[y][x + 1] == '1') {
          res = 'A';
        } else {
          res = 'F';
        }
      } else {
        res = 'B';
      }
    } else {
      if (x + 1 < 8 && s[y + 1][x + 1] == '1') {
        res = 'E';
      } else {
        res = 'C';
      }
    }

    std::cout << res << std::endl;
  }

  return 0;
}