Problem p04002 (C++)

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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;

#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define rFOR(i, a, b) for (int(i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n - 1))
#define vREP(i, vec) for (auto(i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec)                                                          \
  for (auto(i) = (vec).end() - 1; (i) != (vec).begin() - 1; (i)--)

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class Shitting_Man {
private:
  int h, w, n;
  /* map[(i, j)] := (i ~ i+2, j ~ j+2)に含まれる黒の数 ; ただし,
     メモリサイズの都合上 0 は省く したがって, (0 ~ h-3, 0 ~
     w-3)までが期待するkeyである */
  map<pii, int> data;
  vector<lli> res;

public:
  Shitting_Man(int hh, int ww, int nn) {
    h = hh;
    w = ww;
    n = nn;
    res.resize(9, 0);
  }
  ~Shitting_Man(void){};
  void PUSH(int x, int y) {
    /* (x, y)を塗ると, (x-2~x, y-2~y)に影響を与える
     */
    for (int i = x; i >= x - 2; i--)
      if (0 <= i & i <= h - 3) {
        for (int j = y; j >= y - 2; j--)
          if (0 <= j & j <= w - 3) {
            data[make_pair(i, j)]++;
          }
      }
  }
  void calcu() {
    lli black_exist = 0;
    for (auto x : data) {
      res.at(x.second)++;
      black_exist++;
    }
    res.at(0) = (lli)(h - 2) * (lli)(w - 2) - black_exist;
  }
  void all(void) {
    int a, b;
    REP(i, n) {
      cin >> a >> b;
      PUSH(a - 1, b - 1);
    }
    calcu();
    vREP(ele, res) cout << *ele << "\n";
  }
};

int main(void) {
  int h, w, n;
  cin >> h >> w >> n;
  Shitting_Man A(h, w, n);
  A.all();
  return 0;
}

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

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;

#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define rFOR(i, a, b) for (int(i) = (b); (i) >= (a); i--)
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n - 1))
#define vREP(i, vec) for (auto(i) = (vec).begin(); (i) != (vec).end(); (i)++)
#define vrREP(i, vec)                                                          \
  for (auto(i) = (vec).end() - 1; (i) != (vec).begin() - 1; (i)--)

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class Shitting_Man {
private:
  int h, w, n;
  /* map[(i, j)] := (i ~ i+2, j ~ j+2)に含まれる黒の数 ; ただし,
     メモリサイズの都合上 0 は省く したがって, (0 ~ h-3, 0 ~
     w-3)までが期待するkeyである */
  map<pii, int> data;
  vector<lli> res;

public:
  Shitting_Man(int hh, int ww, int nn) {
    h = hh;
    w = ww;
    n = nn;
    res.resize(10, 0); // <~ コ↑コ↓
  }
  ~Shitting_Man(void){};
  void PUSH(int x, int y) {
    /* (x, y)を塗ると, (x-2~x, y-2~y)に影響を与える
     */
    for (int i = x; i >= x - 2; i--)
      if (0 <= i & i <= h - 3) {
        for (int j = y; j >= y - 2; j--)
          if (0 <= j & j <= w - 3) {
            data[make_pair(i, j)]++;
          }
      }
  }
  void calcu() {
    lli black_exist = 0;
    for (auto x : data) {
      res.at(x.second)++;
      black_exist++;
    }
    res.at(0) = (lli)(h - 2) * (lli)(w - 2) - black_exist;
  }
  void all(void) {
    int a, b;
    REP(i, n) {
      cin >> a >> b;
      PUSH(a - 1, b - 1);
    }
    calcu();
    vREP(ele, res) cout << *ele << "\n";
  }
};

int main(void) {
  int h, w, n;
  cin >> h >> w >> n;
  Shitting_Man A(h, w, n);
  A.all();
  return 0;
}