Problem p00282 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;

// #define int long long
#define DBG 1
#define dump(o)                                                                \
  if (DBG) {                                                                   \
    cerr << #o << " " << (o) << " ";                                           \
  }
#define dumpl(o)                                                               \
  if (DBG) {                                                                   \
    cerr << #o << " " << (o) << endl;                                          \
  }
#define dumpc(o)                                                               \
  if (DBG) {                                                                   \
    cerr << #o;                                                                \
    for (auto &e : (o))                                                        \
      cerr << " " << e;                                                        \
    cerr << endl;                                                              \
  }
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  vector<string> b = {"",    "Man", "Oku", "Cho", "Kei", "Gai",
                      "Jo",  "Jou", "Ko",  "Kan", "Sei", "Sai",
                      "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"};
  for (int m, n; cin >> m >> n && m;) {
    vector<int> v(b.size(), 0);
    v[0] = 1;
    rep(i, 0, n) {
      rep(j, 0, v.size()) { v[j] *= m; }
      rep(j, 0, v.size() - 1) {
        int add = v[j] / 10000;
        if (add) {
          v[j + 1] += add;
          v[j] %= 10000;
        }
      }
    }
    dumpc(v);
    rrep(j, 0, v.size()) {
      if (v[j] == 0)
        continue;
      cout << v[j] << b[j];
    }
    cout << endl;
  }
  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;

// #define int long long
#define DBG 0
#define dump(o)                                                                \
  if (DBG) {                                                                   \
    cerr << #o << " " << (o) << " ";                                           \
  }
#define dumpl(o)                                                               \
  if (DBG) {                                                                   \
    cerr << #o << " " << (o) << endl;                                          \
  }
#define dumpc(o)                                                               \
  if (DBG) {                                                                   \
    cerr << #o;                                                                \
    for (auto &e : (o))                                                        \
      cerr << " " << e;                                                        \
    cerr << endl;                                                              \
  }
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  vector<string> b = {"",    "Man", "Oku", "Cho", "Kei", "Gai",
                      "Jo",  "Jou", "Ko",  "Kan", "Sei", "Sai",
                      "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"};
  for (int m, n; cin >> m >> n && m;) {
    vector<int> v(b.size(), 0);
    v[0] = 1;
    rep(i, 0, n) {
      rep(j, 0, v.size()) { v[j] *= m; }
      rep(j, 0, v.size() - 1) {
        int add = v[j] / 10000;
        if (add) {
          v[j + 1] += add;
          v[j] %= 10000;
        }
      }
    }
    dumpc(v);
    rrep(j, 0, v.size()) {
      if (v[j] == 0)
        continue;
      cout << v[j] << b[j];
    }
    cout << endl;
  }
  return 0;
}