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

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#define INF 100000000
using namespace std;
typedef pair<int, int> P;
int N, M, S, G1, G2, C[105][105], d[105], R, t;
void dij(int f) {

  priority_queue<P, vector<P>, greater<P>> Q;
  fill(d, d + N, INF);
  d[f] = 0;
  Q.push(P(0, f));
  for (; !Q.empty();) {
    P p = Q.top();
    Q.pop();
    int v = p.second;
    if (d[v] < p.first)
      continue;
    for (int i = 0; i < N; i++)
      if (C[v][i] && d[i] > d[v] + C[v][i]) {
        d[i] = d[v] + C[v][i];
        Q.push(P(d[i], i));
      }
  }
}

int main() {
  for (; scanf("%d%d%d%d%d", &N, &M, &S, &G1, &G2), N;) {
    S--;
    G1--;
    G2--;
    R = INF;
    memset(C, 0, sizeof(C));
    for (int i = 0; i < M; i++) {
      int f, t, c;
      scanf("%d%d%d", &f, &t, &c);
      f--;
      t--;
      C[f][t] = c;
    }
    for (int i = 0; i < N; i++) {
      t = 0;
      dij(S);
      t += d[i];
      dij(i);
      t += d[G1] + d[G2];
      R = min(R, t);
    }
    printf("%d\\n", R);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef struct P {
  int p, c, f[105];
  // int operator <(const P a){return p<a.p;};
} P;

struct Order {
  bool operator()(P const &a, P const &b) const { return a.c > b.c; }
};

int N, M, S, G1, G2, C[105][105];
int main() {
  for (; scanf("%d%d%d%d%d", &N, &M, &S, &G1, &G2), N;) {
    S--;
    G1--;
    G2--;
    memset(C, 0, sizeof(C));
    for (int i = 0; i < M; i++) {
      int f, t, c;
      scanf("%d%d%d", &f, &t, &c);
      f--;
      t--;
      C[f][t] = C[t][f] = c;
    }
    priority_queue<P, vector<P>, Order> Q;
    P tmp;
    tmp.p = S;
    tmp.c = 0;
    memset(tmp.f, 0, sizeof(tmp.f));
    tmp.f[S] = 1;
    Q.push(tmp);
    for (; !Q.empty();) {
      tmp = Q.top();
      Q.pop();
      if (tmp.f[G1] && tmp.f[G2]) {
        printf("%d\\n", tmp.c);
        break;
      }
      for (int i = 0; i < N; i++)
        if (C[tmp.p][i]) {
          if (tmp.f[i] == 1 && i != G1 && i != G2) // alrady passed
          {
            P ins = tmp;
            ins.f[i]++;
            ins.p = i;
            Q.push(ins);
          } else if (tmp.f[i] == 0) // new node
          {
            P ins = tmp;
            ins.f[i]++;
            ins.c += C[tmp.p][i];
            ins.p = i;
            Q.push(ins);
          }
        }
    }
  }
  return 0;
}
Problem p01131 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

string keitai[]{".,!? ", "abc",  "def", "ghi", "jkl",
                "mno",   "pqrs", "tuv", "wxyz"};
int main() {
  int n;
  cin >> n;
  string s;
  rep(j, n) {
    cin >> s;
    int cnt = 0;
    string ans;
    rep(i, s.size()) {
      if (s[i] == '0') {
        if (cnt)
          ans +=
              keitai[s[i - 1] - '1'][(cnt - 1) % keitai[s[i - 1] - '1'].size()];
        cnt = 0;
      } else
        cnt++;
    }
    if (ans != "")
      cout << ans << endl;
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

string keitai[]{".,!? ", "abc",  "def", "ghi", "jkl",
                "mno",   "pqrs", "tuv", "wxyz"};
int main() {
  string s;
  while (cin >> s) {
    int cnt = 0;
    string ans;
    rep(i, s.size()) {
      if (s[i] == '0') {
        if (cnt)
          ans +=
              keitai[s[i - 1] - '1'][(cnt - 1) % keitai[s[i - 1] - '1'].size()];
        cnt = 0;
      }
      if (i && s[i - 1] != s[i])
        cnt = 0;
      else
        cnt++;
    }
    cout << ans << endl;
  }
}
Problem p01131 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int main() {
  string a;
  string d[10] = {"",    ".,!? ", "abc",  "def", "ghi",
                  "jkl", "mno",   "pqrs", "tuv", "wxyz"};
  int m;
  cin >> m;
  for (int z = 0; z < m; z++) {
    cin >> a;
    string c = "";
    for (int i = 0; i < a.length();) {
      while (a[i] == '0' && i < a.length())
        i++;
      if (i == a.length())
        break;
      int j = i;
      while (a[j] == a[i] && i < a.length()) {
        i++;
      }
      int sum = i - j - 1;
      sum %= d[(int)a[j] - '0'].length();
      if (i < a.length() && a[i] == '0')
        c += d[(int)a[j] - '0'][sum];
    }
    if (c != "")
      cout << c << endl;
  }
}

Error: -8

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int main() {
  string a;
  string d[10] = {"",    ".,!?", "abc",  "def", "ghi",
                  "jkl", "mno",  "pqrs", "tuv", "wxyz"};
  while (cin >> a) {
    char b;
    string c = "";
    for (int i = 0; i < a.length(); i++) {
      b = a[i];
      int i2 = i;
      while (a[i] == b)
        i++;
      int sum = i - i2;
      sum %= d[(int)b - '0'].length();
      sum--;
      c += d[(int)b - '0'][sum];
    }
    cout << c << endl;
  }
}
Problem p01131 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  string bottan[] = {
      "",
      ".,!? ", // 1
      "abc",   // 2
      "def",   // 3
      "ghi",   // 4
      "jkl",   // 5
      "mno",   // 6
      "pqrs",  // 7
      "tuv",   // 8
      "wxyz",  // 9
  };
  int cnt[] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};

  cin >> n;
  while (n--) {
    string str;
    cin >> str;
    int len = str.size();
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < len; i++) {
      if (str[i] == '0') {
        if (cnt1 != 0) {
          if (cnt2 % cnt[cnt1] == 0) {
            cout << bottan[cnt1][cnt[cnt1] - 1];
          } else {
            cout << bottan[cnt1][cnt2 % cnt[cnt1] - 1];
          }
        }
        cnt1 = 0;
        cnt2 = 0;
      } else {
        if (cnt1 == 0) {
          cnt1 = str[i] - '0';
          cnt2++;
        } else {
          cnt2++;
        }
      }
    }
    cout << endl;
  }
}

Error: -8

Fixed submission:

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

int main() {
  int n;
  string bottan[] = {
      "",
      ".,!? ", // 1
      "abc",   // 2
      "def",   // 3
      "ghi",   // 4
      "jkl",   // 5
      "mno",   // 6
      "pqrs",  // 7
      "tuv",   // 8
      "wxyz",  // 9
  };
  int cnt[] = {5, 3, 3, 3, 3, 3, 4, 3, 4};

  cin >> n;
  while (n--) {
    string str;
    cin >> str;
    int len = str.size();
    int cnt1 = 0, cnt2 = 0;
    for (int i = 0; i < len; i++) {
      if (str[i] == '0') {
        if (cnt1 != 0) {
          if (cnt2 % cnt[cnt1] == 0) {
            cout << bottan[cnt1][cnt[cnt1] - 1];
          } else {
            cout << bottan[cnt1][cnt2 % cnt[cnt1] - 1];
          }
        }
        cnt1 = 0;
        cnt2 = 0;
      } else {
        if (cnt1 == 0) {
          cnt1 = str[i] - '0';
          cnt2++;
        } else {
          cnt2++;
        }
      }
    }
    cout << endl;
  }
}
Problem p01131 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string>
using namespace std;
string table[] = {"",    ".,!? ", "abc",  "def", "ghi",
                  "jkl", "mno",   "pqrs", "tuv", "wxyz"};
char str[1280];
int main() {
  int a;
  scanf("%d", &a);
  while (a--) {
    scanf("%s", str);
    int renzoku = 0;
    char now = '0';
    for (int i = 0; str[i]; i++) {
      if (now != str[i]) {
        if (now != '0') {
          printf("%c",
                 table[now - '0'][(renzoku - 1) % table[now - '0'].size()]);
        }
        renzoku = 1;
        now = str[i];
      } else
        renzoku++;
    }
    printf("\\n");
  }
}

Error: 0

Fixed submission:

#include <stdio.h>
#include <string>
using namespace std;
string table[] = {"",    ".,!? ", "abc",  "def", "ghi",
                  "jkl", "mno",   "pqrs", "tuv", "wxyz"};
char str[128];
int main() {
  int a;
  scanf("%d", &a);
  while (a--) {
    scanf("%s", str);
    int renzoku = 0;
    char now = '0';
    for (int i = 0; str[i]; i++) {
      if (now != str[i]) {
        if (now != '0') {
          printf("%c",
                 table[now - '0'][(renzoku - 1) % table[now - '0'].size()]);
        }
        renzoku = 1;
        now = str[i];
      } else
        renzoku++;
    }
    printf("\\n");
  }
}
Problem p01131 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, p = 0, cnt;
  string key[] = {"",    ".,!? ", "abc",  "def", "ghi",
                  "jkl", "mno",   "pqrs", "tuv", "wxyz"};
  string str;

  cin >> n;
  while (cin >> str) {
    for (char &c : str) {
      n = c - '0';
      if (n) {
        cnt++;
      } else if (p == n) {
      } else {
        cout << key[p][(cnt - 1) % key[p].size()];
        cnt = 0;
      }
      p = n;
    }
    cout << endl;
  }

  return 0;
}

Error: -8

Fixed submission:

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

int main() {
  int n, p, cnt;
  string key[] = {"",    ".,!? ", "abc",  "def", "ghi",
                  "jkl", "mno",   "pqrs", "tuv", "wxyz"};
  string str;

  cin >> n;
  while (cin >> str) {
    for (char &c : str) {
      n = c - '0';
      if (n) {
        cnt++;
      } else {
        cout << key[p][(cnt - 1) % key[n].size()];
        cnt = 0;
      }
      p = n;
    }
    cout << endl;
  }

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

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

const string button[] = {
    "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz",
};

void solve() {
  string line;
  cin >> line;
  char pre = '0';
  int count = -1;
  for (unsigned i = 0; i < line.size(); ++i) {
    if (line[i] == '0') {
      int key = pre - '0';
      if (key == 0)
        continue;
      int index = count % button[key].size();
      cout << button[key][index];
      count = -2;
    }
    count++;
    pre = line[i];
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    solve();
  }
  return 0;
}

Error: 0

Fixed submission:

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

const string button[] = {
    "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz",
};

void solve() {
  string line;
  cin >> line;
  char pre;
  int count = -1;
  for (unsigned i = 0; i < line.size(); ++i) {
    if (line[i] == '0') {
      int key = pre - '0';
      if (key == 0)
        continue;
      int index = count % button[key].size();
      cout << button[key][index];
      count = -2;
    }
    count++;
    pre = line[i];
  }
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    solve();
  }
  return 0;
}
Problem p01131 (C++) — buggy submission, verdict: Runtime Error

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int i, j, k;
  int n, m;
  int a[10] = {0};                            // 押された回数
  int b[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4}; // 割り算
  int c;                                      // 押されたボタン
  char d[5][10] = {{'0', ' ', 'c', 'f', 'i', 'l', 'o', 's', 'v', 'z'},
                   {'0', '.', 'a', 'd', 'g', 'j', 'm', 'p', 't', 'w'},
                   {'0', ',', 'b', 'e', 'h', 'k', 'n', 'q', 'u', 'x'},
                   {'0', '!', '0', '0', '0', '0', '0', 'r', '0', 'y'},
                   {'0', '?', '0', '0', '0', '0', '0', '0', '0', '0'}};
  char e[1025];

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s", e);
    c = 0;
    for (j = 0; j < strlen(e); j++) {
      if (e[j] == '0') {
        if (c != 0) {
          printf("%c", d[a[c] % b[c]][c]);
          a[c] = 0;
          c = 0;
        }
      } else {
        if (e[j] == '1')
          c = 1;
        else if (e[j] == '2')
          c = 2;
        else if (e[j] == '3')
          c = 3;
        else if (e[j] == '4')
          c = 4;
        else if (e[j] == '5')
          c = 5;
        else if (e[j] == '6')
          c = 6;
        else if (e[j] == '7')
          c = 7;
        else if (e[j] == '8')
          c = 8;
        else if (e[j] == '9')
          c = 9;
        a[c]++;
      }
    }
    printf("\\n");
  }

  return 0;
}

Error: -11

Fixed submission:

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int i, j, k;
  int n, m;
  int a[10] = {0};                            // 押された回数
  int b[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4}; // 割り算
  int c;                                      // 押されたボタン
  char d[5][10] = {{'0', ' ', 'c', 'f', 'i', 'l', 'o', 's', 'v', 'z'},
                   {'0', '.', 'a', 'd', 'g', 'j', 'm', 'p', 't', 'w'},
                   {'0', ',', 'b', 'e', 'h', 'k', 'n', 'q', 'u', 'x'},
                   {'0', '!', '0', '0', '0', '0', '0', 'r', '0', 'y'},
                   {'0', '?', '0', '0', '0', '0', '0', '0', '0', '0'}};
  char e[1000000007];

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s", e);
    for (j = 0; j < strlen(e); j++) {
      if (e[j] == '0') {
        printf("%c", d[a[c] % b[c]][c]);
        a[c] = 0;
      } else {
        if (e[j] == '1')
          c = 1;
        else if (e[j] == '2')
          c = 2;
        else if (e[j] == '3')
          c = 3;
        else if (e[j] == '4')
          c = 4;
        else if (e[j] == '5')
          c = 5;
        else if (e[j] == '6')
          c = 6;
        else if (e[j] == '7')
          c = 7;
        else if (e[j] == '8')
          c = 8;
        else if (e[j] == '9')
          c = 9;
        a[c]++;
      }
    }
    printf("\\n");
  }

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

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

char bt[9][8] = {".,!? ", "abc",  "def", "ghi", "jkl",
                 "mno",   "pqrs", "tuv", "wxyz"};

int main() {
  int N;
  for (scanf("%d", &N); N--;) {
    char mes[1280];
    scanf(" %s", mes);
    int len = strlen(mes);
    int prv = 0, count = 0;
    for (int i = 0; i < len; i++) {
      if (mes[i] == '0') {
        if (prv > 0) {
          --prv;
          printf("%c", bt[prv][--count % strlen(bt[prv])]);
        }
        count = 0;
      } else {
        count++;
      }
      prv = mes[i] - '0';
    }
    if (prv > 0) {
      --prv;
      printf("%c", bt[prv][--count % strlen(bt[prv])]);
    }
    puts("");
  }
  return 0;
}

Error: 0

Fixed submission:

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

char bt[9][8] = {".,!? ", "abc",  "def", "ghi", "jkl",
                 "mno",   "pqrs", "tuv", "wxyz"};

int main() {
  int N;
  for (scanf("%d", &N); N--;) {
    char mes[128];
    scanf(" %s", mes);
    int len = strlen(mes);
    int prv = 0, count = 0;
    for (int i = 0; i < len; i++) {
      if (mes[i] == '0') {
        if (prv > 0) {
          --prv;
          printf("%c", bt[prv][--count % strlen(bt[prv])]);
        }
        count = 0;
      } else {
        count++;
      }
      prv = mes[i] - '0';
    }
    if (prv > 0) {
      --prv;
      printf("%c", bt[prv][--count % strlen(bt[prv])]);
    }
    puts("");
  }
  return 0;
}
Problem p01131 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  string s;
  int N;
  char bot[10][20] = {"0",   ".,!? ", "abc",  "def", "ghi",
                      "jkl", "mno",   "pqrs", "tuv", "wxyz"};

  int count = 0, flag = 0;
  while (cin >> N) {
    for (int i = 0; i < N; i++) {
      count = 0;
      s.clear();
      cin >> s;
      for (int j = 0; j < (int)s.size(); j++) {
        if (s[j] != '0' && flag == 0) {
          flag = s[j] - '0';
        } else if (flag != 0 && s[j] != '0') {
          count++;
        } else if (s[j] == '0' && flag != 0) {
          if (count < 0 && count <= strlen(bot[flag]))
            cout << bot[flag][count];
          else {
            while (count > strlen(bot[flag]) - 1) {
              count = count - strlen(bot[flag]);
            }

            cout << bot[flag][count];
          }
          count = 0;
          flag = 0;
        }
      }
      cout << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  string s;
  int N;
  char bot[10][20] = {"0",   ".,!? ", "abc",  "def", "ghi",
                      "jkl", "mno",   "pqrs", "tuv", "wxyz"};

  int count = 0, flag = 0;
  while (1) {
    cin >> N;
    if (N == 0)
      break;
    for (int i = 0; i < N; i++) {
      count = 0;
      cin >> s;
      for (int j = 0; j < (int)s.size(); j++) {
        if (s[j] != '0' && flag == 0) {
          flag = s[j] - '0';
        } else if (flag != 0 && s[j] != '0') {
          count++;
        } else if (s[j] == '0' && flag != 0) {
          if (count <= strlen(bot[flag]))
            cout << bot[flag][count];
          else {
            while (count > strlen(bot[flag])) {
              count = count - strlen(bot[flag]);
            }
            cout << bot[flag][count];
          }
          count = 0;
          flag = 0;
        }
      }
      cout << endl;
    }
  }
  return 0;
}
Problem p01131 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;
int main() {
  char m[9][5] = {{'.', ',', '!', '?', ' '}, {'a', 'b', 'c', '1', '1'},
                  {'d', 'e', 'f', '1', '1'}, {'g', 'h', 'i', '1', '1'},
                  {'j', 'k', 'l', '1', '1'}, {'m', 'n', 'o', '1', '1'},
                  {'p', 'q', 'r', 's', '1'}, {'t', 'u', 'v', '1', '1'},
                  {'w', 'x', 'y', 'z', '1'}};
  int a, count = 0, c, d;
  char b[1025];
  cin >> a;
  for (int i = 0; i < a; i++) {
    scanf("%s", b);
    c = strlen(b);
    for (int j = 0; j < c; j++) {
      if (b[j] != '0')
        count++;
      else if (b[j - 1] != 0 && count) {
        d = b[j - 1] - '0';
        if (d == 1)
          cout << m[d - 1][(count - 1) % 5];
        else if (d == 7 || d == 9)
          cout << m[d - 1][(count - 1) % 4];
        else
          cout << m[d - 1][(count - 1) % 3];
        count = 0;
      }
    }
    cout << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;
int main() {
  char m[9][5] = {{'.', ',', '!', '?', ' '}, {'a', 'b', 'c', '1', '1'},
                  {'d', 'e', 'f', '1', '1'}, {'g', 'h', 'i', '1', '1'},
                  {'j', 'k', 'l', '1', '1'}, {'m', 'n', 'o', '1', '1'},
                  {'p', 'q', 'r', 's', '1'}, {'t', 'u', 'v', '1', '1'},
                  {'w', 'x', 'y', 'z', '1'}};
  int a, count = 0, c[100], d;
  char b[1025];
  cin >> a;
  for (int i = 0; i < a; i++) {
    scanf("%s", b);
    c[i] = strlen(b);
    for (int j = 0; j < c[i]; j++) {
      if (b[j] != '0')
        count++;
      else if (b[j - 1] != 0) {
        d = (int)(b[j - 1]) - 48;

        if (d == 1)
          if (count % 5 != 0)
            cout << m[d - 1][count % 5 - 1];
          else
            cout << m[d - 1][4];

        else if (d == 7 || d == 9)
          if (count % 4 != 0)
            cout << m[d - 1][count % 4 - 1];
          else
            cout << m[d - 1][3];

        else if (count % 3 != 0)
          cout << m[d - 1][count % 3 - 1];
        else
          cout << m[d - 1][2];
        count = 0;
      }
    }
    cout << endl;
  }
  return 0;
}
Problem p01131 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  const char C[10][6] = {
      {},
      {'.', ',', '!', '?', ' ', 5},
      {'a', 'b', 'c', 0, 0, 3},
      {'d', 'e', 'f', 0, 0, 3},
      {'g', 'h', 'i', 0, 0, 3},
      {'j', 'k', 'l', 0, 0, 3},
      {'m', 'n', 'o', 0, 0, 3},
      {'p', 'q', 'r', 's', 0, 4},
      {'t', 'u', 'v', 0, 0, 3},
      {'w', 'x', 'y', 'z', 0, 4},
  };
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    char s[1025];
    cin >> s;
    char c = 0;
    int pos = -1;
    for (int j = 0; s[j]; ++j) {
      int button = s[j] - '0';
      if (button == 0) {
        if (c != 0)
          cout << c;

        pos = -1;
        c = 0;
      } else {
        pos++;
        c = C[button][pos % (int)(C[button][5])];
      }
    }
    cout << endl;
  }
}

Error: WA

Fixed submission:

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

int main() {
  char inputString[80], outputString[80], hoge[2];
  char
      str; // êIÉê¶ªf[^ðÛ·éÏ
  int length, count, push, index, dataSet;
  int p[9][5] = {
      // e{^ðµ½Æ«ÌÏÚð ç©¶ßpÓ(óÌvfÍ@É·é)
      {'.', ',', '!', '?', ' '}, {'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', '@'},
  };
  scanf("%d", &dataSet); // ßÉf[^ZbgðüÍ

  for (int i = 0; i < dataSet;
       i++) { // f[^ZbgÌ¾¯üÍ³¹é
    // ÏÌú»
    count = 0;
    index = 0;
    push = 0;
    str = 0;

    scanf("%s", inputString); // 0-9Ì¶ÌÀÑüÍ

    length = strlen(inputString); // üÍ¶Ì·³ðßé

    for (
        int i = 0; i < length;
        i++) { // ê¶¸Â¶Ì·³ª¾¯²×é

      // ¶ðlÉÏ··é(Ï·µ½0-9ª»ÌÜÜ¶ÌîñðÂzñÌY¦ÉÎ)
      hoge[0] = inputString[i];
      push = atoi(hoge);

      if (push == 0) { // mè{^:0¾Á½ç
        count = 0;
        if (str != 0) {
          // êIÉÛ¶µÄ¢½¶ð¦ÉÇÁ
          outputString[index] = str;
          outputString[index + 1] = '\\0';
          str = 0;
          index++;
        }
      } else { // 0ÈOÌ{^¾Á½ç

        // êIÉ»ÝÌ¶ðÛ¶
        str = p[push - 1][count];
        // {^ðµ½ñðâ·
        count++;
        if (p[push - 1][count] == '@' || count == 5) {
          count = 0; // {^ðµ½ñð0É·é
        }
      }
    }

    // ¦Ì¶ñoÍ
    printf("%s \\n", outputString);
  }

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

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
struct Data {
  char c;
  int n;
};
int main(void) {

  int n;
  cin >> n;
  string str;
  string c[] = {".,!? ", "abc",  "def", "ghi", "jkl",
                "mno",   "pqrs", "tuv", "wxyz"};
  while (n--) {
    cin >> str;
    Data a[1200];
    char ch = 'A';
    int t = -1;
    for (int i = 0; i < str.size(); i++) {
      if (ch == str[i]) {
        a[t].n++;
      } else {
        ch = str[i];
        t++;
        a[t].c = ch;
        a[t].n = 1;
      }
    }
    t++;
    for (int i = 0; i < t; i++) {
      if (a[i].c == '0')
        continue;
      cout << c[a[i].c - '0' - 1][(a[i].n - 1) % c[a[i].c - '0' - 1].size()];
    }
    cout << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
struct Data {
  char c;
  int n;
};
int main(void) {

  int n;
  cin >> n;
  string str;
  string c[] = {".,!? ", "abc",  "def", "ghi", "jkl",
                "mno",   "pqrs", "tuv", "wxyz"};
  while (n--) {
    cin >> str;
    Data a[100];
    char ch = 'A';
    int t = -1;
    for (int i = 0; i < str.size(); i++) {
      if (ch == str[i]) {
        a[t].n++;
      } else {
        ch = str[i];
        t++;
        a[t].c = ch;
        a[t].n = 1;
      }
    }
    t++;
    for (int i = 0; i < t; i++) {
      if (a[i].c == '0')
        continue;
      cout << c[a[i].c - '0' - 1][(a[i].n - 1) % c[a[i].c - '0' - 1].size()];
    }
    cout << endl;
  }

  return 0;
}