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

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

string M[8];

bool inF(int y, int x) { return 0 <= x && x < 8 && 0 <= y && y < 8; }

int main() {

  while (cin >> M[0]) {
    for (int i = 1; i < 8; i++)
      cin >> M[i];

    char res = '#';

    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (M[i][j] - '0') {

          if (inF(i + 1, j + 1) && M[i + 1][j + 1] - '0') {
            if (inF(i + 2, j + 1) && M[i + 2][j + 1] - '0') {
              res = 'F';
              goto end;
            } else if (inF(i + 1, j + 2) && M[i + 1][j + 2] - '0') {
              res = 'E';
              goto end;
            } else {
              res = 'A';
              goto end;
            }
          }

          if (inF(i + 3, j) && M[i + 3][j] - '0') {
            res = 'B';
            goto end;
          }

          if (inF(i, j + 3) && M[i][j + 3] - '0') {
            res = 'C';
            goto end;
          }

          if (inF(i + 1, j - 1) && M[i + 1][j - 1] - '0') {
            if (inF(i, j + 1) && M[i][j + 1] - '0') {
              res = 'G';
              goto end;
            } else {
              res = 'D';
              goto end;
            }
          }
        }
      }
    }
  end:
    cout << res << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

string M[15];

int main() {

  for (int i = 1; i < 15; i++)
    M[i] = "-----------------------";

  while (cin >> M[0]) {
    for (int i = 1; i < 8; i++)
      cin >> M[i];

    char res = '#';

    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (M[i][j] - '0') {

          if (M[i + 1][j + 1] - '0') {
            if (M[i + 2][j + 1] - '0') {
              res = 'F';
              goto end;
            } else if (M[i + 1][j + 2] - '0') {
              res = 'E';
              goto end;
            } else {
              res = 'A';
              goto end;
            }
          }

          if (M[i + 3][j] - '0') {
            res = 'B';
            goto end;
          }

          if (M[i][j + 3] - '0') {
            res = 'C';
            goto end;
          }

          if (M[i - 1][j + 2] - '0') {
            res = 'D';
            goto end;
          }

          if (M[i + 1][j - 1] - '0') {
            res = 'G';
            goto end;
          }
        }
      }
    }
  end:
    cout << res << endl;
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

#define rep(x, to) for (int x = 0; x < to; x++)
#define rep2(x, from, to) for (int x = from; x < to; x++)

using namespace std;

int main(void) {

  int cnt = 0;
  string w[12];
  string ans;

  while (!cin.eof()) {
    ans = "G";
    rep(i, 8) cin >> w[i];
    if (cin.eof())
      break;
    rep(i, 8) rep(j, 8) if (w[i][j] == '1') {
      if (w[i][j + 1] == '1' && w[i][j + 2] == '1' && w[i][j + 3] == '1') {
        ans = "C";
        break;
      }
      if (w[i][j + 1] == '1' && w[i + 1][j + 1] == '1' && w[i + 1][j] == '1') {
        ans = "A";
        break;
      }
      if (w[i + 1][j - 1] == '1' && w[i + 1][j] == '1' &&
          w[i + 2][j - 1] == '1') {
        ans = "D";
        break;
      }
      if (w[i][j + 1] == '1' && w[i + 1][j + 1] == '1' &&
          w[i + 1][j + 2] == '1') {
        ans = "E";
        break;
      }
      if (w[i + 1][j] == '1' && w[i + 1][j + 1] == '1' &&
          w[i + 2][j + 1] == '1') {
        ans = "F";
        break;
      }
      if (w[i][j + 1] == '1' && w[i + 1][j - 1] == '1' && w[i + 1][j] == '1') {
        ans = "G";
        break;
      }
      if (w[i + 1][j] == '1' && w[i + 2][j] == '1' && w[i + 3][j] == '1') {
        ans = "B";
        break;
      }
    }
    cout << ans << endl;
    //		cnt++; if(cnt>40) break;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

#define rep(x, to) for (int x = 0; x < to; x++)
#define rep2(x, from, to) for (int x = from; x < to; x++)

using namespace std;

int main(void) {

  int cnt = 0;
  string w[8], ans;

  while (!cin.eof()) {
    ans = "?";
    rep(i, 8) rep(j, 8) cin >> w[i][j];
    if (cin.eof())
      break;
    rep(i, 8) rep(j, 8) if (w[i][j] == '1') {
      if (w[i][j + 1] + w[i + 1][j + 1] + w[i + 1][j] == 3 + 3 * '0') {
        ans = "A";
        break;
      }
      if (w[i + 1][j] + w[i + 2][j] + w[i + 3][j] == 3 + 3 * '0') {
        ans = "B";
        break;
      }
      if (w[i][j + 1] + w[i][j + 2] + w[i][j + 3] == 3 + 3 * '0') {
        ans = "C";
        break;
      }
      if (w[i + 1][j - 1] + w[i + 1][j] + w[i + 2][j - 1] == 3 + 3 * '0') {
        ans = "D";
        break;
      }
      if (w[i][j + 1] + w[i + 1][j + 1] + w[i + 1][j + 2] == 3 + 3 * '0') {
        ans = "E";
        break;
      }
      if (w[i + 1][j] + w[i + 1][j + 1] + w[i + 2][j + 1] == 3 + 3 * '0') {
        ans = "F";
        break;
      }
      if (w[i][j + 1] + w[i + 1][j - 1] + w[i + 1][j] == 3 + 3 * '0') {
        ans = "D";
        break;
      }
    }
    cout << ans << endl;
    //		cnt++; if(cnt>40) break;
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long int lli;
using namespace std;

int dx[7][4] = {{0, 0, 1, 1}, {0, 0, 0, 0}, {0, 1, 2, 3}, {0, 0, -1, -1},
                {0, 1, 1, 2}, {0, 0, 1, 1}, {0, -1, 0, 1}};
int dy[7][4] = {{0, 1, 1, 0}, {0, 1, 2, 3}, {0, 0, 0, 0}, {0, 1, 1, 2},
                {0, 0, 1, 1}, {0, 1, 1, 2}, {0, 1, 1, 0}};
string MAP[8];
string ans = "ABCDEFG";

int main() {
  while (1) {
    for (int i = 0; i < 8; ++i) {
      if (!(cin >> MAP[i])) {
        return 0;
      }
    }
    for (int i = 0; i < 8; ++i) {
      for (int j = 0; j < 8; ++j) {
        if (MAP[i][j] == '1') {
          for (int k = 0; k < 7; ++k) {
            bool ok = true;
            for (int l = 0; l < 4; ++l) {
              int nx = j + dx[k][l];
              int ny = i + dy[k][l];
              if ((0 <= nx && nx < 8 && 0 <= ny && ny < 8 &&
                   MAP[ny][nx] != '1') ||
                  (nx < 0 || 8 <= nx || ny < 0 || 8 <= ny)) {
                ok = false;
                break;
              }
            }
            if (ok) {
              cout << ans[k] << "\\n";
              break;
            }
          }
        }
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long int lli;
using namespace std;

int dx[7][4] = {{0, 0, 1, 1}, {0, 0, 0, 0}, {0, 1, 2, 3}, {0, 0, -1, -1},
                {0, 1, 1, 2}, {0, 0, 1, 1}, {0, -1, 0, 1}};
int dy[7][4] = {{0, 1, 1, 0}, {0, 1, 2, 3}, {0, 0, 0, 0}, {0, 1, 1, 2},
                {0, 0, 1, 1}, {0, 1, 1, 2}, {0, 1, 1, 0}};
string MAP[8];
string ans = "ABCDEFG";

int main() {
  while (1) {
    for (int i = 0; i < 8; ++i) {
      for (int j = 0; j < 8; ++j) {
        cin >> MAP[i][j];
      }
    }
    for (int i = 0; i < 8; ++i) {
      for (int j = 0; j < 8; ++j) {
        if (MAP[i][j] == '1') {
          for (int k = 0; k < 7; ++k) {
            bool ok = true;
            for (int l = 0; l < 4; ++l) {
              int nx = j + dx[k][l];
              int ny = i + dy[k][l];
              if ((0 <= nx && nx < 8 && 0 <= ny && ny < 8 &&
                   MAP[ny][nx] != '1') ||
                  (nx < 0 || 8 <= nx || ny < 0 || 8 <= ny)) {
                ok = false;
                break;
              }
            }
            if (ok) {
              cout << ans[k] << "\\n";
              break;
            }
          }
        }
      }
    }
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
#include <vector>
using namespace std;
char tetromino_figure(vector<string> v) {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (v[i][j] == '1') {
        if (v[i][j + 1] == '1' && v[i + 1][j] == '1' && v[i + 1][j + 1] == '1')
          return 'A';
        if (v[i + 1][j] == '1' && v[i + 2][j] == '1' && v[i + 3][j] == '1')
          return 'B';
        if (v[i][j + 1] == '1' && v[i][j + 2] == '1' && v[i][j + 3] == '1')
          return 'C';
        if (v[i + 1][j - 1] == '1' && v[i + 1][j] == '1' &&
            v[i + 2][j - 1] == '1')
          return 'D';
        if (v[i][j + 1] == '1' && v[i + 1][j + 1] == '1' &&
            v[i + 1][j + 2] == '1')
          return 'E';
        if (v[i + 1][j] == '1' && v[i + 1][j + 1] == '1' &&
            v[i + 2][j + 1] == '1')
          return 'F';
        if (v[i][j + 1] == '1' && v[i + 1][j - 1] == '1' && v[i + 1][j] == '1')
          return 'G';
      }
    }
  }
  return '0';
}
int main() {
  string s;
  while (cin >> s) {
    if (s == "\\n")
      continue;
    vector<string> v;
    for (int i = 1; i <= 3; i++)
      s += '0';
    v.push_back(s);
    for (int i = 2; i <= 8; i++) {
      cin >> s;
      for (int j = 1; j <= 3; j++)
        s += '0';
      v.push_back(s);
    }
    for (int i = 1; i <= 3; i++)
      v.push_back("00000000000");
    cout << tetromino_figure(v) << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
char tetromino_figure(vector<string> v) {
  for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
      if (v[i][j] == '1') {
        if (v[i][j + 1] == '1' && v[i + 1][j] == '1' && v[i + 1][j + 1] == '1')
          return 'A';
        if (v[i + 1][j] == '1' && v[i + 2][j] == '1' && v[i + 3][j] == '1')
          return 'B';
        if (v[i][j + 1] == '1' && v[i][j + 2] == '1' && v[i][j + 3] == '1')
          return 'C';
        if (v[i + 1][j - 1] == '1' && v[i + 1][j] == '1' &&
            v[i + 2][j - 1] == '1')
          return 'D';
        if (v[i][j + 1] == '1' && v[i + 1][j + 1] == '1' &&
            v[i + 1][j + 2] == '1')
          return 'E';
        if (v[i + 1][j] == '1' && v[i + 1][j + 1] == '1' &&
            v[i + 2][j + 1] == '1')
          return 'F';
        if (v[i][j + 1] == '1' && v[i + 1][j - 1] == '1' && v[i + 1][j] == '1')
          return 'G';
      }
    }
  }
  return '0';
}
int main() {
  string s;
  while (cin >> s) {
    if (s == "\\n")
      continue;
    vector<string> v;
    v.push_back(s);
    for (int i = 2; i <= 8; i++) {
      cin >> s;
      v.push_back(s);
    }
    cout << tetromino_figure(v) << endl;
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<string> v;
vector<string> f[7] = {
    {"11", "11"},   {"1", "1", "1", "1"}, {"1111"},      {"01", "11", "10"},
    {"110", "011"}, {"10", "11", "01"},   {"011", "110"}};
bool contain(vector<string> v1, vector<string> v2) {
  for (int i = 0; i <= (int)(v1.size() - v2.size()); i++) {
    for (int j = 0; j <= (int)(v1[0].size() - v2[0].size()); j++) {
      bool flag = true;
      for (int k = 0; k < v2.size(); k++) {
        if (v1[i + k].substr(j, v2[0].size()) != v2[k]) {
          flag = false;
          break;
        }
      }
      if (flag)
        return true;
    }
  }
  return false;
}
int main() {
  v.resize(8);
  while (cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> v[5] >> v[6] >> v[7]) {
    for (int i = 0; i < 7; i++) {
      if (contain(v, f[i]))
        cout << (char)(i + 65) << endl;
    }
  }
  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 9) > this->size() (which is 8)


Fixed submission:

#include <iostream>
#include <string>
#include <vector>
using namespace std;
vector<string> v;
vector<string> f[7] = {
    {"11", "11"},   {"1", "1", "1", "1"}, {"1111"},      {"01", "11", "10"},
    {"110", "011"}, {"10", "11", "01"},   {"011", "110"}};
bool contain(vector<string> v1, vector<string> v2) {
  for (int i = 0; i <= v1.size() - v2.size(); i++) {
    for (int j = 0; j <= v1[i].size() - v2[i].size(); j++) {
      bool flag = true;
      for (int k = i; k < i + v2.size(); k++) {
        if (v1[k].substr(j, v2[i].size()) != v2[k - 1]) {
          flag = false;
          break;
        }
      }
      if (flag)
        return true;
    }
  }
  return false;
}
int main() {
  v.resize(8);
  while (cin >> v[0] >> v[1] >> v[2] >> v[3] >> v[4] >> v[5] >> v[6] >> v[7]) {
    for (int i = 0; i < 7; i++) {
      if (contain(v, f[i]))
        cout << (char)(i + 65) << endl;
    }
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main() {
  while (true) {
    string a[8];
    vector<int> tracex;
    vector<int> tracey;
    bool flag = false;
    rep(i, 8) if (!(cin >> a[i])) return 0;
    rep(i, 8) rep(j, 8) if (a[i][j] == '1') {
      tracex.push_back(j);
      tracey.push_back(i);
    }
    REP(i, 1, tracex.size())
    tracex[i] -= tracex[0];
    REP(i, 1, tracey.size())
    tracey[i] -= tracey[0];
    // tracex[0]=0;tracey[0]=0;
    if (tracex[3] == 1 && tracey[3] == 1)
      cout << "A" << endl;
    if (tracex[3] == 3)
      cout << "C" << endl;
    if (tracey[3] == 3)
      cout << "B" << endl;
    if (tracex[1] == -1 && tracey[3] == 2)
      cout << "D" << endl;
    if (tracex[3] == 2)
      cout << "E" << endl;
    if (tracex[2] == 1 && tracey[3] == 2)
      cout << "F" << endl;
    if (tracex[2] == -1 && tracey[2] == 1)
      cout << "G" << endl;
    if (flag)
      break;
  }
  return 0;
}

Error: WA

Fixed submission:

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main() {
  while (true) {
    string a[8];
    vector<int> tracex;
    vector<int> tracey;
    bool flag = false;
    rep(i, 8) {
      cin >> a[i];
      if (cin.eof())
        flag = true;
    }
    rep(i, 8) rep(j, 8) if (a[i][j] == '1') {
      tracex.push_back(j);
      tracey.push_back(i);
    }
    REP(i, 1, tracex.size())
    tracex[i] -= tracex[0];
    REP(i, 1, tracey.size())
    tracey[i] -= tracey[0];
    // tracex[0]=0;tracey[0]=0;
    if (DEBUG)
      rep(i, tracey.size()) cout << tracex[i] << ":" << tracey[i] << endl;
    if (tracex[3] == 1 && tracey[3] == 1)
      cout << "A" << endl;
    if (tracex[3] == 3)
      cout << "C" << endl;
    if (tracey[3] == 3)
      cout << "B" << endl;
    if (tracex[1] == -1 && tracey[3] == 2)
      cout << "D" << endl;
    if (tracex[3] == 2)
      cout << "E" << endl;
    if (tracex[1] == 1 && tracey[3] == 2)
      cout << "F" << endl;
    if (tracex[2] == -1 && tracey[2] == 1)
      cout << "G" << endl;
    if (flag)
      break;
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>

char data[8][8];
int px, py;

int main() {
  while (true) {
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (!(std::cin >> data[i][j]))
          goto end;
        if (data[i][j] == '1')
          px = j, py = i;
      }
    }

    if (data[py][px - 1] == '1' && data[py - 1][px] == '1' &&
        data[py - 1][px - 1] == '1')
      printf("A\\n");
    else if (data[py - 1][px] == '1' && data[py - 2][px] == '1' &&
             data[py - 3][px] == '1')
      printf("B\\n");
    else if (data[py][px - 1] == '1' && data[py][px - 2] == '1' &&
             data[py][px - 3] == '1')
      printf("C\\n");
    else if (data[py - 1][px] == '1' && data[py - 1][px + 1] == '1' &&
             data[py - 2][px + 1] == '1')
      printf("D\\n");
    else if (data[py][px - 1] == '1' && data[py - 1][px - 1] == '1' &&
             data[py - 1][px - 2] == '1')
      printf("E\\n");
    else if (data[py - 1][px] == '1' && data[py - 1][px - 1] == '1' &&
             data[py - 2][px - 1] == '1')
      printf("F\\n");
    else if (data[py - 1][px] == '1' && data[py - 1][px + 1] == '1' &&
             data[py][px - 1] == '1')
      printf("G\\n");
  }
end:;
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>

char data[8][8];
int px, py;

int main() {
  while (true) {
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        std::cin >> data[i][j];
        if (std::cin.eof())
          break;
        if (data[i][j] == '1')
          px = j, py = i;
      }
    }

    if (data[py][px - 1] == '1' && data[py - 1][px] == '1' &&
        data[py - 1][px - 1] == '1')
      printf("A\\n");
    else if (data[py - 1][px] == '1' && data[py - 2][px] == '1' &&
             data[py - 3][px] == '1')
      printf("B\\n");
    else if (data[py][px - 1] == '1' && data[py][px - 2] == '1' &&
             data[py][px - 3] == '1')
      printf("C\\n");
    else if (data[py][px - 1] == '1' && data[py + 1][px - 1] == '1' &&
             data[py - 1][px] == '1')
      printf("D\\n");
    else if (data[py][px - 1] == '1' && data[py - 1][px - 1] == '1' &&
             data[py - 1][px - 2] == '1')
      printf("E\\n");
    else if (data[py][px - 1] == '1' && data[py - 1][px - 1] == '1' &&
             data[py + 1][px] == '1')
      printf("F\\n");
    else if (data[py - 1][px] == '1' && data[py - 1][px + 1] == '1' &&
             data[py][px - 1] == '1')
      printf("G\\n");
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Runtime Error

// A Figure on Surface

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

int main(void) {
  const int N = 8;
  while (1) {
    string a[N];
    int i, j;
    for (i = 0; i < N; i++) {
      cin >> a[i];
    }
    if (!cin)
      break;

    // ¶ã©çÌÀWð²×é
    for (i = 0; i < N; i++) {
      for (j = 0; j < N; j++) {
        if (a[i][j] == '1')
          goto DISCOVER;
      }
    }
  DISCOVER:
    // ÔÈñÄÇ¤ÅàÇ¢©çÀSÉs«Üµå¤
    if ((i < N - 1) && (j < N - 1) && (a[i][j] == a[i + 1][j]) &&
        (a[i][j] == a[i][j + 1]) && (a[i][j] == a[i + 1][j + 1]))
      cout << 'A' << endl;
    else if ((i < N - 3) && (a[i][j] == a[i + 3][j]))
      cout << 'B' << endl;
    else if ((j < N - 3) && (a[i][j] == a[i][j + 3]))
      cout << 'C' << endl;
    else if ((i < N - 2) && (j > 0) && (a[i][j] == a[i + 2][j - 1]))
      cout << 'D' << endl;
    else if ((j < N - 2) && (a[i][j] == a[i + 1][j + 2]))
      cout << 'E' << endl;
    else if ((i < N - 2) && (a[i][j] == a[i + 2][j + 1]))
      cout << 'F' << endl;
    else
      cout << 'G' << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

// A Figure on Surface

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

int main(void) {
  const int N = 8;
  while (1) {
    string a[N];
    int i, j;
    for (i = 0; i < N; i++) {
      cin >> a[i];
    }
    if (!cin)
      break;

    // ¶ã©çÌÀWð²×é
    for (i = 0; i < N; i++) {
      for (j = 0; j < N; j++) {
        if (a[i][j] == '1')
          goto DISCOVER;
      }
    }
  DISCOVER:
    // ÔÈñÄÇ¤ÅàÇ¢©çÀSÉs«Üµå¤
    if ((a[i][j] == a[i + 1][j]) && (a[i][j] == a[i][j + 1]) &&
        (a[i][j] == a[i + 1][j + 1]))
      cout << 'A' << endl;
    else if ((i < N - 3) && (a[i][j] == a[i + 3][j]))
      cout << 'B' << endl;
    else if ((j < N - 3) && (a[i][j] == a[i][j + 3]))
      cout << 'C' << endl;
    else if ((i < N - 2) && (j > 0) && (a[i][j] == a[i + 2][j - 1]))
      cout << 'D' << endl;
    else if ((j < N - 2) && (a[i][j] == a[i + 1][j + 2]))
      cout << 'E' << endl;
    else if ((i < N - 2) && (a[i][j] == a[i + 2][j + 1]))
      cout << 'F' << endl;
    else
      cout << 'G' << endl;
  }
  return 0;
}
Problem p00036 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

char m[8][8];
void figure(int, int);

int main() {

  while (1) {
    bool f = true;
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        cin >> m[i][j];
        if (cin.eof()) {
          return 0;
        }
      }
    }
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (m[i][j] == '1') {
          figure(i, j);
          f = false;
          break;
        }
      }
      if (!f) {
        break;
      }
    }
  }
}

void figure(int i, int j) {
  char s;
  if (m[i][j + 1] == '1' && m[i + 1][j + 1] == '1' && m[i + 1][j] == '1') {
    s = 'A';
  } else if (m[i + 1][j] == '1' && m[i + 2][j] == '1') {
    s = 'B';
  } else if (m[i][j + 1] == '1' && m[i][j + 2] == '1') {
    s = 'C';
  } else if (m[i][j + 1] == '1' && m[i + 1][j + 1] == '1') {
    s = 'E';
  } else if (m[i][j + 1] == '1') {
    s = 'G';
  } else if (m[i + 1][j + 1] == '1') {
    s = 'F';
  } else {
    s = 'D';
  }
  cout << s << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

char m[8][8];
void figure(int, int);

int main() {

  while (1) {
    bool f = true;
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        cin >> m[i][j];
      }
    }
    for (int i = 0; i < 8; i++) {
      for (int j = 0; j < 8; j++) {
        if (m[i][j] == '1') {
          figure(i, j);
          f = false;
          break;
        }
      }
      if (!f) {
        break;
      }
    }
  }
}

void figure(int i, int j) {
  char s;
  if (m[i][j + 1] == '1' && m[i + 1][j + 1] == '1' && m[i + 1][j] == '1') {
    s = 'A';
  } else if (m[i + 1][j] == '1' && m[i + 2][j] == '1') {
    s = 'B';
  } else if (m[i][j + 1] == '1' && m[i][j + 2] == '1') {
    s = 'C';
  } else if (m[i][j + 1] == '1' && m[i + 1][j + 1] == '1') {
    s = 'E';
  } else if (m[i][j + 1] == '1') {
    s = 'G';
  } else if (m[i + 1][j + 1] == '1') {
    s = 'F';
  } else {
    s = 'D';
  }
  cout << s << endl;
}
Problem p00036 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int s[8], count, f;
  while (cin >> s[0]) {
    count = 0;
    for (int i = 1; i < 8; i++) {
      cin >> s[i];
    }

    for (int i = 0; i < 8; i++) {
      if (s[i] > 0)
        count++;
    }

    if (count == 4)
      cout << "B" << endl;
    else if (count == 1)
      cout << "C" << endl;
    else if (count == 3) {
      for (int i = 0; i < 8; i++) {
        if (s[i] > 0) {
          if (s[i] < s[i + 2])
            cout << "D" << endl;
          else
            cout << "F" << endl;
          i = 9;
        }
      }
    } else if (count == 2) {
      for (int i = 0; i < 8; i++) {
        if (s[i] > 0) {
          if (s[i] == s[i + 1])
            cout << "A" << endl;
          else if (s[i] > s[i + 1])
            cout << "E" << endl;
          else
            cout << "G" << endl;
          i = 9;
        }
      }
    }
  }
  return (0);
}

Error: TLE

Fixed submission:

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

int main() {
  int s[8], count, f;
  while (1) {
    count = 0;
    for (int i = 0; i < 8; i++) {
      cin >> s[i];
      if (s[i] == EOF)
        break;
    }

    for (int i = 0; i < 8; i++) {
      if (s[i] > 0)
        count++;
    }

    if (count == 4)
      cout << "B" << endl;
    else if (count == 1)
      cout << "C" << endl;
    else if (count == 3) {
      for (int i = 0; i < 8; i++) {
        if (s[i] > 0) {
          if (s[i] < s[i + 2])
            cout << "D" << endl;
          else
            cout << "F" << endl;
          i = 9;
        }
      }
    } else if (count == 2) {
      for (int i = 0; i < 8; i++) {
        if (s[i] > 0) {
          if (s[i] == s[i + 1])
            cout << "A" << endl;
          else if (s[i] > s[i + 1])
            cout << "E" << endl;
          else
            cout << "G" << endl;
          i = 9;
        }
      }
    }
  }
  return (0);
}