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

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
using namespace std;
// kaewasuretyuui
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int, pii> pip;
typedef vector<pip> vip;
const double PI = acos(-1);
const double EPS = 1e-8;
const int inf = 1e8;
int main() {
  map<string, int> m;
  m["Rock"] = 1;
  m["Fire"] = 2;
  m["Scissors"] = 3;
  m["Snake"] = 4;
  m["Human"] = 5;
  m["Tree"] = 6;
  m["Wolf"] = 7;
  m["Sponge"] = 8;
  m["Paper"] = 9;
  m["Air"] = 10;
  m["Water"] = 11;
  m["Dragon"] = 12;
  m["Devil"] = 13;
  m["Lightning"] = 14;
  m["Gun"] = 15;
  int n;
  while (cin >> n, n) {
    vector<string> in(n);
    rep(i, n) cin >> in[i];
    in.erase(unique(all(in)), in.end());
    if (in.size() == 1) {
      cout << "Draw" << endl;
      continue;
    }
    bool h = false;
    rep(i, in.size()) {
      bool hh = true;
      rep(j, in.size()) {
        int t = m[in[i]], s = m[in[j]];
        if (t == s)
          continue;
        if (t > s && t - s < 8 || t < s && 15 - s + t < 8)
          hh = false;
      }
      if (hh) {
        h = true;
        cout << in[i] << endl;
        break;
      }
    }
    if (!h)
      cout << "Draw" << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
using namespace std;
// kaewasuretyuui
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int, pii> pip;
typedef vector<pip> vip;
const double PI = acos(-1);
const double EPS = 1e-8;
const int inf = 1e8;
int main() {
  map<string, int> m;
  m["Rock"] = 1;
  m["Fire"] = 2;
  m["Scissors"] = 3;
  m["Snake"] = 4;
  m["Human"] = 5;
  m["Tree"] = 6;
  m["Wolf"] = 7;
  m["Sponge"] = 8;
  m["Paper"] = 9;
  m["Air"] = 10;
  m["Water"] = 11;
  m["Dragon"] = 12;
  m["Devil"] = 13;
  m["Lightning"] = 14;
  m["Gun"] = 15;
  int n;
  while (cin >> n, n) {
    vector<string> in(n);
    rep(i, n) cin >> in[i];
    in.erase(unique(all(in)), in.end());
    if (in.size() == 1) {
      cout << "Draw" << endl;
      continue;
    }
    bool h = false;
    rep(i, n) {
      bool hh = true;
      rep(j, n) {
        int t = m[in[i]], s = m[in[j]];
        if (t == s)
          continue;
        if (t > s && t - s < 8 || t < s && 15 - s + t < 8)
          hh = false;
      }
      if (hh) {
        h = true;
        cout << in[i] << endl;
        break;
      }
    }
    if (!h)
      cout << "Draw" << endl;
  }
}