Problem p04000 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
inline ll powint(unsigned long long x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1)
      r *= x;
    x *= x;
    y >>= 1;
  }
  return r;
}
inline ll powmod(ll x, ll y, ll m = MOD) {
  ll r = 1;
  while (y) {
    if (y & 1)
      r *= x;
    x *= x;
    r %= m;
    x %= m;
    y >>= 1;
  }
  return r;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll h, w, n;
  cin >> h >> w >> n;
  vll a(n), b(n);
  vll ans(10, 0);
  ans[0] = (h - 2) * (w - 2);
  set<pll> p;
  rep(i, n) {
    cin >> a[i] >> b[i];
    p.emplace(a[i], b[i]);
    repr(xi, max(a[i] - 2, 1ll), min(a[i], h - 2) + 1) {
      repr(yi, max(b[i] - 2, 1ll), min(b[i], w - 2) + 1) {
        ll cnt = 0;
        repr(x, xi, xi + 3) repr(y, yi, yi + 3) {
          if (binary_search(ALL(p), pll(x, y))) {
            cnt++;
          }
        }
        ans[cnt - 1]--;
        ans[cnt]++;
      }
    }
  }
  /*
  sort(ALL(p));
  rep(i, n){
      repr(xi, max(p[i].first-2, 1ll), min(p[i].first, h-2)+1){
          repr(yi, max(p[i].second-2, 1ll), min(p[i].second, w-2)+1){
              ll cnt = 0;
              repr(x, xi, xi+3)repr(y, yi, yi+3){
                  if(binary_search(ALL(p), pll(x, y))){
                      cnt++;
                  }
              }
              ans[cnt-1]--;
              ans[cnt]++;
          }
      }
  }
   */
  rep(i, 10) { cout << ans[i] << endl; }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
inline ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
inline ll powint(unsigned long long x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1)
      r *= x;
    x *= x;
    y >>= 1;
  }
  return r;
}
inline ll powmod(ll x, ll y, ll m = MOD) {
  ll r = 1;
  while (y) {
    if (y & 1)
      r *= x;
    x *= x;
    r %= m;
    x %= m;
    y >>= 1;
  }
  return r;
}
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll h, w, n;
  cin >> h >> w >> n;
  vll a(n), b(n);
  vll ans(10, 0);
  ans[0] = (h - 2) * (w - 2);
  set<pll> p;
  rep(i, n) {
    cin >> a[i] >> b[i];
    p.emplace(a[i], b[i]);
    repr(xi, max(a[i] - 2, 1ll), min(a[i], h - 2) + 1) {
      repr(yi, max(b[i] - 2, 1ll), min(b[i], w - 2) + 1) {
        ll cnt = 0;
        repr(x, xi, xi + 3) repr(y, yi, yi + 3) {
          if (p.find(pll(x, y)) != p.end()) {
            cnt++;
          }
        }
        ans[cnt - 1]--;
        ans[cnt]++;
      }
    }
  }
  /*
  sort(ALL(p));
  rep(i, n){
      repr(xi, max(p[i].first-2, 1ll), min(p[i].first, h-2)+1){
          repr(yi, max(p[i].second-2, 1ll), min(p[i].second, w-2)+1){
              ll cnt = 0;
              repr(x, xi, xi+3)repr(y, yi, yi+3){
                  if(binary_search(ALL(p), pll(x, y))){
                      cnt++;
                  }
              }
              ans[cnt-1]--;
              ans[cnt]++;
          }
      }
  }
   */
  rep(i, 10) { cout << ans[i] << endl; }
  return 0;
}