Problem p00088 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 100000;
int main() {
  map<char, string> s;
  s[' '] = "101";
  s['\\''] = "000000";
  s[','] = "000011";
  s['-'] = "10010001";
  s['.'] = "010001";
  s['?'] = "000001";
  s['A'] = "100101";
  s['B'] = "10011010";
  s['C'] = "0101";
  s['D'] = "0001";
  s['E'] = "110";
  s['F'] = "01001";
  s['G'] = "10011011";
  s['H'] = "010000";
  s['I'] = "0111";
  s['J'] = "10011000";
  s['K'] = "0110";
  s['L'] = "00100";
  s['M'] = "10011001";
  s['N'] = "10011110";
  s['O'] = "00101";
  s['P'] = "111";
  s['Q'] = "10011111";
  s['R'] = "1000";
  s['S'] = "00110";
  s['T'] = "00111";
  s['U'] = "10011100";
  s['V'] = "10011101";
  s['W'] = "000010";
  s['X'] = "10010010";
  s['Y'] = "10010011";
  s['Z'] = "10010000";
  map<string, char> t;
  t["00000"] = 'A';
  t["00001"] = 'B';
  t["00010"] = 'C';
  t["00011"] = 'D';
  t["00100"] = 'E';
  t["00101"] = 'F';
  t["00110"] = 'G';
  t["00111"] = 'H';
  t["01000"] = 'I';
  t["01001"] = 'J';
  t["01010"] = 'K';
  t["01011"] = 'L';
  t["01100"] = 'M';
  t["01101"] = 'N';
  t["01110"] = 'O';
  t["01111"] = 'P';
  t["10000"] = 'Q';
  t["10001"] = 'R';
  t["10010"] = 'S';
  t["10011"] = 'T';
  t["10100"] = 'U';
  t["10101"] = 'V';
  t["10110"] = 'W';
  t["10111"] = 'X';
  t["11000"] = 'Y';
  t["11001"] = 'Z';
  t["11010"] = ' ';
  t["11011"] = '.';
  t["11100"] = ',';
  t["11101"] = '-';
  t["11110"] = '\\'';
  t["11111"] = '?';
  string in;
  while (getline(cin, in)) {
    string in1 = "", ans = "";
    REP(i, in.size()) { in1 += s[in[i]]; }
    while (in1.size() % 5 != 0)
      in1 += '0';
    REP(i, in1.size() / 5) {
      in.assign(in1, i * 5, 5);
      ans += t[in];
    }
    cout << ans << endl;
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define INF 1000000001
#define MOD 10000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const ull B = 100000007;
string angou[26] = {"100101",   "10011010", "0101",     "0001",     "110",
                    "01001",    "10011011", "010000",   "0111",     "10011000",
                    "0110",     "00100",    "10011001", "10011110", "00101",
                    "111",      "10011111", "1000",     "00110",    "00111",
                    "10011100", "10011101", "000010",   "10010010", "10010011",
                    "10010000"};
int to_i(string s) {
  int res = 0, k = 1;
  for (int i = 4; i >= 0; i--) {
    if (s[i] == '1')
      res += k;
    k *= 2;
  }
  return res;
}
string to(char c) {
  if (c == ' ')
    return "101";
  if (c == '\\'')
    return "000000";
  if (c == '-')
    return "10010001";
  if (c == '.')
    return "010001";
  if (c == '?')
    return "000001";
  return angou[c - 'A'];
}
char from(string a) {
  int aa = to_i(a);
  if (0 <= aa && aa <= 25)
    return 'A' + aa;
  if (aa == 26)
    return ' ';
  if (aa == 27)
    return '.';
  if (aa == 28)
    return ',';
  if (aa == 29)
    return '-';
  if (aa == 30)
    return '\\'';
  return '?';
}
int main() {
  string s;
  getline(cin, s);
  string t = "";
  REP(i, s.size()) t += to(s[i]);
  while (t.size() % 5 != 0)
    t += '0';
  s = "";
  cout << t << endl;
  for (int i = 0; i < t.size(); i += 5) {
    string a;
    a.assign(t, i, 5);
    s += from(a);
  }
  cout << s << endl;
}