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

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge {
  int to, from, cost;
};

#ifdef DEBUGLOCAL
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template <class T> void pv(T a, T b) {
  for (T i = a; i != b; ++i)
    debug << *i << " ";
  debug << endl;
}
template <class T> void chmin(T &t, T f) {
  if (t > f)
    t = f;
}
template <class T> void chmax(T &t, T f) {
  if (t < f)
    t = f;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; +--)
#define repn(i, m, n) for (int i = (m); i <= (n); ++i)
#define repnd(i, m, n) for (int i = (n)-1; i >= (m); +--)
#define rep0(i, n) for (i = 0; i < (n); ++i)
#define all(n) n.begin(), n.end()
#define sz(n) ((int)(n).size())
#define MP make_pair
#define PB push_back
#define SS stringstream
#define PUTLINE debug << "LINE:" << __LINE__ << endl;

const int INF = 2147483647;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[] = {1, -1, 0, 0, 1, -1, 1, -1, 0};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1, 0};

string str[21];
string num[10][7] = {{"#######", "#.....#", "#...|.#", "#.....#", "#...|.#",
                      "#..-..#", "#######"},
                     {"#######", "#..-..#", "#...|.#", "#..-..#", "#.|...#",
                      "#..-..#", "#######"},
                     {"#######", "#..-..#", "#...|.#", "#..-..#", "#...|.#",
                      "#..-..#", "#######"},
                     {"#######", "#.....#", "#.|.|.#", "#..-..#", "#...|.#",
                      "#.....#", "#######"},
                     {"#######", "#..-..#", "#.|...#", "#..-..#", "#...|.#",
                      "#..-..#", "#######"},
                     {"#######", "#..-..#", "#.|...#", "#..-..#", "#.|.|.#",
                      "#..-..#", "#######"},
                     {"#######", "#..-..#", "#...|.#", "#.....#", "#...|.#",
                      "#.....#", "#######"},
                     {"#######", "#..-..#", "#.|.|.#", "#..-..#", "#.|.|.#",
                      "#..-..#", "#######"},
                     {"#######", "#..-..#", "#.|.|.#", "#..-..#", "#...|.#",
                      "#..-..#", "#######"}};

vstring rotate(vstring vs) {
  vstring res;
  rep(i, 7) {
    string st;
    rep(j, 7) {
      st += vs[6 - j][i] == '-'   ? '|'
            : vs[6 - j][i] == '|' ? '-'
                                  : vs[6 - j][i];
    }
    res.PB(st);
  }
  return res;
}

int saikoro(vstring men) {
  rep(j, 9) {
    int i;
    rep0(i, 7) if (num[j][i] != men[i]) break;
    if (i == 7)
      return j + 1;
  }
  // rep(i,7)cout<<men[i]<<endl;
  assert(0);
  return 0;
}

vstring cut(int y, int x) {
  vstring res;
  rep(i, 7) { res.PB(str[y + i].substr(x, 7)); }
  return res;
}

vstring lr(vstring vs) {
  vstring res;
  rep(i, 7) {
    string rev = vs[i];
    reverse(all(rev));
    res.PB(rev);
  }
  return res;
}

vstring ud(vstring vs) {
  vstring res;
  rep(i, 7) { res.PB(vs[6 - i]); }
  return res;
}

int main() {
  for (;;) {
    cin >> str[0];
    if (str[0] == "0")
      break;
    repn(i, 1, 20) cin >> str[i];
    int m[6], s[6];
    s[0] = saikoro(lr(cut(0, 7)));
    s[1] = saikoro(lr(rotate(cut(7, 0))));
    s[2] = saikoro(lr(cut(7, 7)));
    s[3] = saikoro(lr(rotate(rotate(rotate(cut(7, 14))))));
    s[4] = saikoro(lr(cut(7, 21)));
    s[5] = saikoro(ud(lr(cut(14, 7))));
    m[0] = saikoro(lr(cut(0, 36)));
    m[1] = saikoro(lr(rotate(cut(7, 29))));
    m[2] = saikoro(lr(cut(7, 36)));
    m[3] = saikoro(lr(rotate(rotate(rotate(cut(7, 43))))));
    m[4] = saikoro(lr(cut(7, 50)));
    m[5] = saikoro(ud(lr(cut(14, 36))));
    int aa = 0, bb = 0;
    rep(i, 6) rep(j, 6) {
      if (s[i] > m[j])
        ++aa;
      if (s[i] < m[j])
        ++bb;
    }
    if (aa >= bb)
      cout << "HIGH\\n";
    else
      cout << "LOW\\n";
  }
  return 0;
}

Error: -6
b93444c2-095c-4ac3-a8db-082930171ef1.out: /home/alex/Documents/bug-detection/input/Project_CodeNet/data/p00660/C++/s355171898.cpp:188: int main(): Assertion `0' failed.


Fixed submission:

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge {
  int to, from, cost;
};

#ifdef DEBUGLOCAL
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template <class T> void pv(T a, T b) {
  for (T i = a; i != b; ++i)
    debug << *i << " ";
  debug << endl;
}
template <class T> void chmin(T &t, T f) {
  if (t > f)
    t = f;
}
template <class T> void chmax(T &t, T f) {
  if (t < f)
    t = f;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; +--)
#define repn(i, m, n) for (int i = (m); i <= (n); ++i)
#define repnd(i, m, n) for (int i = (n)-1; i >= (m); +--)
#define rep0(i, n) for (i = 0; i < (n); ++i)
#define all(n) n.begin(), n.end()
#define sz(n) ((int)(n).size())
#define MP make_pair
#define PB push_back
#define SS stringstream
#define PUTLINE debug << "LINE:" << __LINE__ << endl;

const int INF = 2147483647;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[] = {1, -1, 0, 0, 1, -1, 1, -1, 0};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1, 0};

string str[21];
string num[10][7] = {{"#######", "#.....#", "#...|.#", "#.....#", "#...|.#",
                      "#..-..#", "#######"},
                     {"#######", "#..-..#", "#...|.#", "#..-..#", "#.|...#",
                      "#..-..#", "#######"},
                     {"#######", "#..-..#", "#...|.#", "#..-..#", "#...|.#",
                      "#..-..#", "#######"},
                     {"#######", "#.....#", "#.|.|.#", "#..-..#", "#...|.#",
                      "#.....#", "#######"},
                     {"#######", "#..-..#", "#.|...#", "#..-..#", "#...|.#",
                      "#..-..#", "#######"},
                     {"#######", "#..-..#", "#.|...#", "#..-..#", "#.|.|.#",
                      "#..-..#", "#######"},
                     {"#######", "#..-..#", "#...|.#", "#.....#", "#...|.#",
                      "#.....#", "#######"},
                     {"#######", "#..-..#", "#.|.|.#", "#..-..#", "#.|.|.#",
                      "#..-..#", "#######"},
                     {"#######", "#..-..#", "#.|.|.#", "#..-..#", "#...|.#",
                      "#..-..#", "#######"}};

vstring rotate(vstring vs) {
  vstring res;
  rep(i, 7) {
    string st;
    rep(j, 7) {
      st += vs[6 - j][i] == '-'   ? '|'
            : vs[6 - j][i] == '|' ? '-'
                                  : vs[6 - j][i];
    }
    res.PB(st);
  }
  return res;
}

int saikoro(vstring men) {
  rep(j, 9) {
    int i;
    rep0(i, 7) if (num[j][i] != men[i]) break;
    if (i == 7)
      return j + 1;
  }
  // rep(i,7)cout<<men[i]<<endl;
  assert(0);
  return 0;
}

vstring cut(int y, int x) {
  vstring res;
  rep(i, 7) { res.PB(str[y + i].substr(x, 7)); }
  return res;
}

vstring lr(vstring vs) {
  vstring res;
  rep(i, 7) {
    string rev = vs[i];
    reverse(all(rev));
    res.PB(rev);
  }
  return res;
}

vstring ud(vstring vs) {
  vstring res;
  rep(i, 7) { res.PB(vs[6 - i]); }
  return res;
}

int main() {
  assert(0);
  for (;;) {
    cin >> str[0];
    if (str[0] == "0")
      break;
    repn(i, 1, 20) cin >> str[i];
    int m = 0, s = 0;
    s += saikoro(lr(cut(0, 7)));
    s += saikoro(lr(rotate(cut(7, 0))));
    s += saikoro(lr(cut(7, 7)));
    s += saikoro(lr(rotate(rotate(rotate(cut(7, 14))))));
    s += saikoro(lr(cut(7, 21)));
    s += saikoro(ud(lr(cut(14, 7))));
    m += saikoro(lr(cut(0, 36)));
    m += saikoro(lr(rotate(cut(7, 29))));
    m += saikoro(lr(cut(7, 36)));
    m += saikoro(lr(rotate(rotate(rotate(cut(7, 43))))));
    m += saikoro(lr(cut(7, 50)));
    m += saikoro(ud(lr(cut(14, 36))));
    if (s >= m)
      cout << "HIGH\\n";
    else
      cout << "LOW\\n";
  }
  return 0;
}