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

#include <iostream>
#include <string>
using namespace std;
int main() {
  string s, r;
  int i;
  const char *a[7] = {
      "afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty ",
  };
  while (cin >> s) {
    r = "";
    for (i = 0; i + 1 < s.size(); i += 2) {
      if (s[i] > '6' || s[i + 1] > '5' || s[i] < '1' || s[i + 1] < '1')
        break;
      r += a[s[i + 1] - '1'][s[i] - '1'];
    }
    if (i != s.size())
      cout << "NA" << endl;
    else
      cout << r << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  string s, r;
  int i;
  const char *a[7] = {
      "afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty ",
  };
  while (cin >> s) {
    r = "";
    for (i = 0; i + 1 < s.size(); i += 2) {
      if (s[i] > '6' || s[i + 1] > '5')
        break;
      r += a[s[i + 1] - '1'][s[i] - '1'];
    }
    if (i != s.size())
      cout << "NA" << endl;
    else
      cout << r << endl;
  }
  return 0;
}
Problem p00127 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

char c[6][5] = {
    {'a', 'b', 'c', 'd', 'e'}, {'f', 'g', 'h', 'i', 'j'},
    {'k', 'l', 'm', 'n', 'o'}, {'p', 'q', 'r', 's', 't'},
    {'u', 'v', 'w', 'x', 'y'}, {'z', '.', '?', '!', ' '},
};

int main() {

  bool checker;

  string str;

  while (true) {
    cin >> str;
    if (cin.eof()) {
      break;
    }

    checker = false;

    for (int i = 0; i < str.size(); i++) {
      if (str[i] < '1' || str[i] > '6') {
        printf("NA\\n");
        checker = true;
        break;
      }
    }

    if (checker) {
      continue;
    }

    if (str.size() % 2 != 0) {
      printf("NA\\n");
      continue;
    }
    for (int i = 0; i < str.size(); i += 2) {
      if (str[i + 1] - '0' - 1 >= 5) {
        printf("NA\\n");
        checker = true;
        break;
      }
    }

    if (checker) {
      continue;
    }

    for (int i = 0; i < str.size(); i += 2) {
      printf("%c", c[str[i] - '0' - 1][str[i + 1] - '0' - 1]);
    }
    printf("\\n");
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

char c[6][5] = {
    {'a', 'b', 'c', 'd', 'e'}, {'f', 'g', 'h', 'i', 'j'},
    {'k', 'l', 'm', 'n', 'o'}, {'p', 'q', 'r', 's', 't'},
    {'u', 'v', 'w', 'x', 'y'}, {'z', '.', '?', '!', ' '},
};

int main() {

  string str;

  while (true) {
    cin >> str;
    if (cin.eof()) {
      break;
    }

    for (int i = 0; i < str.size(); i++) {
      if (str[i] < '1' || str[i] > '6') {
        while (true)
          ;
      }
    }

    if (str.size() % 2 != 0) {
      printf("NA\\n");
      continue;
    }
    for (int i = 0; i < str.size(); i += 2) {
      if (str[i + 1] - '0' - 1 >= 5) {
        printf("NA");
        break;
      }
      printf("%c", c[str[i] - '0' - 1][str[i + 1] - '0' - 1]);
    }
    printf("\\n");
  }

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

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string ans, s;
string table[] = {"afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "};

int main() {
  while (cin >> s) {
    bool f = 0;
    ans = "";
    if (s.size() % 2 != 0) {
      cout << "NA" << endl;
      continue;
    }
    if (s.size() == 0)
      cout << "NA" << endl;
    for (int i = 0; i < s.size(); i += 2) {
      if (s[i] > '6' || s[i] < '1' || s[i + 1] > '5' || s[i] < '1') {
        f = 1;
        break;
      }
      ans += table[s[i + 1] - '1'][s[i] - '1'];
    }
    if (f)
      cout << "NA" << endl;
    else
      cout << ans << endl;
    ans.clear();
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (long long i = (a); i < (b); i++)
#define REP(i, N) for (long long i = 0; i < (N); i++)
#define ALL(s) (s).begin(), (s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

string ans, s;
string table[] = {"afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "};

int main() {
  while (cin >> s) {
    bool f = 0;
    ans = "";
    if (s.size() % 2 != 0) {
      cout << "NA" << endl;
      continue;
    }
    if (s.size() == 0)
      cout << "NA" << endl;
    for (int i = 0; i < s.size(); i += 2) {
      if (s[i] > '6' || s[i] < '1' || s[i + 1] > '6' || s[i] < '1')
        f = 1;
      ans += table[s[i + 1] - '1'][s[i] - '1'];
    }
    if (f)
      cout << "NA" << endl;
    else
      cout << ans << endl;
    ans.clear();
  }
}
Problem p00127 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
#define all(n) n.begin(), n.end()

string res[6];

const char OFS = '1';
int main() {
  res[0] = "abcde";
  res[1] = "fghij";
  res[2] = "klmno";
  res[3] = "pqrst";
  res[4] = "uvwxy";
  res[5] = "z.?! ";

  string s;
  while (getline(cin, s)) {
    bool na = false;
    int l = s.size();
    if (l % 2)
      na = true;
    s = s + "z";
    REP(l / 2) {
      if (s[i * 2] >= '7' || s[i * 2] == '0')
        na = true;
      if (s[i * 2 + 1] >= '6' || s[i * 2] == '0')
        na = true;
    }

    if (na) {
      cout << "NA" << endl;
      continue;
    }

    int v, h;
    REP(l / 2) {
      v = (int)(s[i * 2] - OFS);
      h = (int)(s[i * 2 + 1] - OFS);
      cout << res[v][h];
      // cout << res[(char)(s[i*2] - OFS)][(char)(s[i*2+1] - OFS)];
    }
    cout << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
#define all(n) n.begin(), n.end()

string res[6];

const char OFS = '1';
int main() {
  res[0] = "abcde";
  res[1] = "fghij";
  res[2] = "klmno";
  res[3] = "pqrst";
  res[4] = "uvwxy";
  res[5] = "z.?! ";

  string s;
  while (getline(cin, s)) {
    bool na = false;
    int l = s.size();
    if (l % 2)
      na = true;
    s += "z";
    REP(l / 2) {
      if (s[i * 2] >= '7')
        na = true;
      if (s[i * 2 + 1] >= '6')
        na = true;
    }
    // cout << s << endl;

    if (na) {
      cout << "NA" << endl;
      continue;
    }

    int v, h;
    REP(l / 2) {
      v = (int)(s[i * 2] - OFS);
      h = (int)(s[i * 2 + 1] - OFS);
      cout << res[v][h];
      // cout << res[(char)(s[i*2] - OFS)][(char)(s[i*2+1] - OFS)];
    }
    cout << endl;
  }
  return 0;
}
Problem p00127 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  char p[5][6] = {{'a', 'f', 'k', 'p', 'u', 'z'},
                  {'b', 'g', 'l', 'q', 'v', '.'},
                  {'c', 'h', 'm', 'r', 'w', '?'},
                  {'d', 'i', 'n', 's', 'x', '!'},
                  {'e', 'j', 'o', 't', 'y', ' '}};
  string s;
  while (cin >> s) {
    bool flag = false;
    for (size_t i = 0; i < s.size(); i += 2) {
      if (s[i] > '6' || s[i] < '1' || s[i + 1] > '5' || s[i] < '1')
        flag = true;
    }
    if (flag || s.size() % 2) {
      cout << "NA" << endl;
    } else {
      for (size_t i = 0; i < s.size(); i += 2) {
        cout << p[s[i + 1] - '0' - 1][s[i] - '0' - 1];
      }
      cout << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <stack>
#include <string>

using namespace std;

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s;
  int n;
  char mozi[10][10] = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
  bool flag = true;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s.size() % 2 == 1) {
      puts("NA");
      continue;
    } else {
      char str[201], kari[200];
      long int length = s.length();
      s.copy(str, length, 0);
      for (int i = 0; i < s.size(); i += 2) {
        if (0 <= (int)str[i] - 49 <= 5 && 0 <= (int)str[i + 1] - 49 <= 4)
          kari[i] = mozi[(int)str[i] - 49][(int)str[i + 1] - 49];
        else
          flag = false;
      }
      if (flag == true) {
        for (int i = 0; i < s.size(); i += 2) {
          cout << kari[i];
        }
      } else {
        cout << "NA";
      }
      puts("");
    }
  }
  return 0;
}
Problem p00127 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main() {
  string alpha = "abcdefghijklmnopqrstuvwxyz.?! ";
  char table[5][6];

  int t = 0;
  rep(i, 6) {
    rep(j, 5) {
      table[j][i] = alpha[t];
      t++;
    }
  }

  string s;
  while (cin >> s) {
    if (s.size() % 2 != 0) {
      cout << "NA" << endl;
    } else {
      t = 0;
      bool flag = true;
      vector<char> v;
      while (true) {
        if (t >= s.size()) {
          break;
        }

        int a = s[t] - '1';
        int b = s[t + 1] - '1';

        if (0 <= a && a < 6 && 0 <= b && b < 5) {
          v.push_back(table[b][a]);
        } else {
          flag = false;
        }

        t += 2;
      }
      if (flag) {
        rep(i, v.size()) { cout << v[i]; }
        cout << endl;
      } else {
        cout << "NA" << endl;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main() {
  string alpha = "abcdefghijklmnopqrstuvwxyz.?! ";
  char table[5][6];

  int t = 0;
  rep(i, 6) {
    rep(j, 5) {
      table[j][i] = alpha[t];
      t++;
    }
  }

  string s;
  while (cin >> s) {
    if (s.size() % 2 != 0) {
      cout << "NA" << endl;
    } else {
      t = 0;
      bool flag = true;
      while (flag) {
        if (t >= s.size()) {
          break;
        }

        int a = s[t] - '1';
        int b = s[t + 1] - '1';
        bool flag = true;

        if (0 <= a && a < 6 && 0 <= b && b < 5) {
          cout << table[b][a];
          t += 2;
        } else {
          flag = false;
        }
      }
      cout << endl;
    }
  }
  return 0;
}
Problem p00127 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string map[6];
  map[0] = "abcde";
  map[1] = "fghij";
  map[2] = "klmno";
  map[3] = "pqrst";
  map[4] = "uvwxy";
  map[5] = "z.?! ";
  string str;
  while (cin >> str) {
    int num[1000] = {0};
    int len = str.size();
    bool flag = false;
    for (int i = 0; i < len; i += 2) {
      if (str[i] <= '0' || str[i] > '6') {
        flag = true;
        break;
      } else if (str[i + 1] <= '0' || str[i + 1] > '5') {
        flag = true;
        break;
      }
    }
    if (len % 2 == 1 || flag) {
      cout << "NA" << endl;
      continue;
    }
    for (int i = 0; i < len; i += 2) {
      for (int j = i; j < i + 2; j++) {
        string tmp = "";
        tmp += str[j];
        istringstream ss(tmp);
        ss >> num[j];
        // cout << num[j] << endl;
      }
    }
    for (int i = 0; i < len; i += 2) {
      cout << map[num[i] - 1][num[i + 1] - 1];
    }
    cout << endl;
  }
}

Error: 0

Fixed submission:

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

int main() {
  string map[6];
  map[0] = "abcde";
  map[1] = "fghij";
  map[2] = "klmno";
  map[3] = "pqrst";
  map[4] = "uvwxy";
  map[5] = "z.?! ";
  string str;
  while (cin >> str) {
    int num[1000] = {0};
    int len = str.size();
    if (len % 2 == 1) {
      cout << "NA" << endl;
      continue;
    }
    for (int i = 0; i < len; i += 2) {
      for (int j = i; j < i + 2; j++) {
        string tmp = "";
        tmp += str[j];
        istringstream ss(tmp);
        ss >> num[j];
        // cout << num[j] << endl;
      }
    }
    for (int i = 0; i < len; i += 2) {
      cout << map[num[i] - 1][num[i + 1] - 1];
    }
    cout << endl;
  }
}
Problem p00127 (C++) — buggy submission, verdict: Time Limit Exceeded

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctype.h>
#include <exception>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)

using namespace std;
typedef long long int lint;

vector<string> keys;
vector<char> vals;
map<string, char> encoder;

bool AOJ0127() {
  string str, ret;
  if (!(cin >> str))
    return false;

  if (str.size() % 2) {
    cout << "NA" << endl;
    return true;
  }

  REP(i, str.size() / 2) {
    string buf = str.substr(2 * i, 2);
    if (encoder.find(buf) == encoder.end()) {
      cout << "NA" << endl;
      return true;
    }
    ret.push_back(encoder[buf]);
  }
  cout << ret << endl;

  return true;
}

int main() {
  FOR(i, 1, 7) {
    FOR(j, 1, 6) {
      string key;
      key.push_back('0' + i);
      key.push_back('0' + j);
      keys.push_back(key);
    }
  }

  for (char c = 'a'; c <= 'z'; c++) {
    vals.push_back(c);
  }
  vals.push_back('.');
  vals.push_back('?');
  vals.push_back('!');
  vals.push_back(' ');

  REP(i, keys.size()) { encoder[keys[i]] = vals[i]; }

  while (AOJ0127()) {
  }

  return 0;
}

Error: TLE

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctype.h>
#include <exception>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)

using namespace std;
typedef long long int lint;

vector<string> keys;
vector<char> vals;
map<string, char> encoder;

bool AOJ0127() {
  string str, ret;
  cin >> str;

  if (str.size() % 2) {
    cout << "NA" << endl;
    return true;
  }

  REP(i, str.size() / 2) {
    string buf = str.substr(2 * i, 2);
    if (encoder.find(buf) == encoder.end()) {
      cout << "NA" << endl;
      return true;
    }
    ret.push_back(encoder[buf]);
  }
  cout << ret << endl;

  return true;
}

int main() {
  FOR(i, 1, 7) {
    FOR(j, 1, 6) {
      string key;
      key.push_back('0' + i);
      key.push_back('0' + j);
      keys.push_back(key);
    }
  }

  for (char c = 'a'; c <= 'z'; c++) {
    vals.push_back(c);
  }
  vals.push_back('.');
  vals.push_back('?');
  vals.push_back('!');
  vals.push_back(' ');

  REP(i, keys.size()) { encoder[keys[i]] = vals[i]; }

  while (AOJ0127()) {
  }

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

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

int main() {
  string a;
  while (cin >> a) {

    if (a.length() % 2 == 1) {
      cout << "NA" << endl;
      continue;
    }
    string t = "";
    bool p = true;
    for (int b = 0; b < a.length(); b += 2) {
      if (a[b] > '6' || a[b] < '1' || a[b + 1] > '5' || a[b + 1] < '1') {
        cout << "NA" << endl;
        p = false;
        break;
      }
      int s = (a[b] - 49) * 5 + (a[b + 1] - 49) + 97;
      if (s < 123)
        t += (char)s;
      else {
        switch (s) {
        case 123:
          t += '.';
          break;
        case 124:
          t += '?';
          break;
        case 125:
          t += '!';
          break;
        case 126:
          t += ' ';
          break;
        }
      }
    }
    if (p)
      cout << t << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  string a;
  while (cin >> a) {
  k:;
    if (a.length() % 2) {
      cout << "NA" << endl;
      continue;
    }
    for (int b = 0; b < a.length(); b += 2) {
      if (a[b] < '1' || a[b] > '6' || a[b + 1] < '1' || a[b + 1] > '5') {
        cout << "NA" << endl;
        goto k;
      }
      int s = (a[b] - 49) * 5 + (a[b + 1] - 49);
      if ((s + 97) < '{')
        cout << (char)(s + 97);
      else {
        switch (s + 97) {
        case 123:
          cout << '.';
          break;
        case 124:
          cout << '?';
          break;
        case 125:
          cout << '!';
          break;
        case 126:
          cout << ' ';
          break;
        }
      }
    }
    cout << endl;
  }
}
Problem p00127 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
using namespace std;
int main() {
  string nums, text, ch;
  ch = "abcdefghijklmnopqrstuvwxyz.?! ";
  while (cin >> nums) {
    text = "";
    if (nums.size() % 2) {
      cout << "NA" << endl;
    } else {
      for (int i = 0; i < nums.size() / 2; i++) {
        if ('0' < nums[i * 2] && nums[i * 2] < '7' && '0' < nums[i * 2 + 1] &&
            nums[i * 2 + 1] < '6')
          text = text + ch[5 * (nums[i * 2] - 49) + (nums[i * 2 + 1] - 49)];
        else {
          text = "NA";
          break;
        }
      }
      cout << text << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>
int main(void) {
  char mozi[5][7];
  // 初期化
  strcpy(mozi[0], "afkpuz");
  strcpy(mozi[1], "bglqv.");
  strcpy(mozi[2], "chmrw?");
  strcpy(mozi[3], "dinsx!");
  strcpy(mozi[4], "ejoty ");
  //
  int cnt;
  char snum[] = "0123456789";
  char svar[1000];

  scanf("%d", &cnt);
  for (int f1 = 0; f1 < cnt; f1++) {
    fflush(stdin);
    scanf("%s", svar);
    fflush(stdin);
    if (strlen(svar) % 2 == 1)
      printf("NA\\n");
    else {
      while (svar[0] != '0') {
        int x, y;
        for (int f2 = 0; f2 < 10; f2++) {
          if (svar[0] == snum[f2]) {
            y = f2 - 1;
          }
          if (svar[1] == snum[f2]) {
            x = f2 - 1;
          }
        }
        // printf("svar->%s\\n",svar);
        // printf("x->%d y->%d\\n",x,y);
        for (int f = 0; f < 2; f++) {
          for (int f2 = 0; f2 < strlen(svar) - 1; f2++) {
            svar[f2] = svar[f2 + 1];
          }
        }
        svar[strlen(svar) - 1] = '0';
        svar[strlen(svar) - 2] = '0';
        printf("%c", mozi[x][y]);
      }
      printf("\\n");
    }
  }
  return 0;
}
Problem p00127 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string str;
  vector<string> vs = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
  while (cin >> str) {
    if (str.size() % 2) {
      cout << "NA" << endl;
      continue;
    }
    string ans;
    for (int i = 0; i < str.size(); i += 2) {
      int a = str[i] - '0' - 1;
      int b = str[i + 1] - '0' - 1;

      if (0 <= a && a < 6 && 0 <= b && b < 5) {
        ans += vs[a][b];
      } else {
        ans = "NA";
        break;
      }
    }

    cout << ans << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  string str;
  vector<string> vs = {"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "};
  while (cin >> str) {
    if (str.size() % 2) {
      cout << "NA" << endl;
      continue;
    }
    string ans;
    for (int i = 0; i < str.size(); i += 2) {
      int a = str[i] - '0' - 1;
      int b = str[i + 1] - '0' - 1;

      if (a < 6 && b < 5) {
        ans += vs[a][b];
      } else {
        ans = "NA";
        break;
      }
    }

    cout << ans << endl;
  }

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

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  while (true) {
    int d[5];
    for (int i = 0; i < 5; ++i, n /= 10)
      d[4 - i] = n % 10;

    char soro[7][5 + 1];
    memset(soro, '*', sizeof(soro));
    for (int i = 0; i < 7; ++i)
      soro[i][5] = '\\0';

    for (int i = 0; i < 5; ++i)
      soro[d[i] >= 5 ? 0 : 1][i] = ' ';
    for (int i = 0; i < 5; ++i)
      soro[d[i] % 5 + 2][i] = ' ';

    for (int i = 0; i < 7; ++i) {
      puts(soro[i]);
      if (i == 1)
        puts("=====");
    }
    if (scanf("%d", &n) != EOF)
      putchar('\\n');
    else
      break;
  }

  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

typedef long long ll;

using namespace std;

int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int d[5];
    for (int i = 0; i < 5; ++i, n /= 10)
      d[4 - i] = n % 10;

    char soro[7][5 + 1];
    memset(soro, '*', sizeof(soro));
    for (int i = 0; i < 7; ++i)
      soro[i][5] = '\\0';

    for (int i = 0; i < 5; ++i)
      soro[d[i] >= 5 ? 0 : 1][i] = ' ';
    for (int i = 0; i < 5; ++i)
      soro[d[i] + 2][i] = ' ';

    for (int i = 0; i < 7; ++i) {
      puts(soro[i]);
      if (i == 1)
        puts("=====");
    }
    putchar('\\n');
  }

  return 0;
}