Language: C++

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

typedef pair<long, long> P;

int binary_search(vector<P> &tmp, long long &x, long long &y_up, long long &y_down){
    int ok = (int)tmp.size();
    int ng = -1;
    while (abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        if (tmp[mid].first >= x) ok = mid;
        else ng = mid;
    }
    int res = 0;
    while (tmp[ok].first == x && ok != (int)tmp.size()){
        if (y_up <= tmp[ok].second && tmp[ok].second <= y_down) res++;
        if (y_down < tmp[ok].second) break;
        ok++;
    }
    return res;
}

int main(){
    long long h, w, n;
    cin >> h >> w >> n;

    vector<P> tmp(n);
    for (int i = 0; i < n; i++) cin >> tmp[i].first >> tmp[i].second;
    sort(tmp.begin(), tmp.end());

    vector<long long> ans(10, 0);
    for (int elm = 0; elm < n; elm++){
        long long x = tmp[elm].first;
        long long y = tmp[elm].second;
        for (int i = - 2; i < 1; i++){
            for (int j = -2; j < 1; j++){
                if (x + i <= 0 || h < x + i || y + j <= 0 || w < y + j) continue;
                if (x + i + 2 <= 0 || h < x + i + 2 || y + j + 2 <= 0 || w < y + j + 2) continue;
                int ss = 0;
                ss += binary_search(tmp, x + i, y + j, y + j + 2);
                ss += binary_search(tmp, x + i + 1, y + j, y + j + 2);
                ss += binary_search(tmp, x + i + 2, y + j, y + j + 2);
                ans[ss]++;
            }
        }
    }

    long long tt = 0;
    for (int i = 1; i < 10; i++){
        ans[i] /= i;
        tt += ans[i];
    }

    ans[0] = (h - 2) * (w - 2) - tt;
    for (int i = 0; i < 10; i++) cout << ans[i] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:36: error: no matching function for call to 'binary_search(std::vector<std::pair<long int, long int> >&, long long int, long long int, long long int)'
   40 |                 ss += binary_search(tmp, x + i, y + j, y + j + 2);
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:6:5: note: candidate: 'int binary_search(std::vector<std::pair<long int, long int> >&, long long int&, long long int&, long long int&)' (near match)
    6 | int binary_search(vector<P> &tmp, long long &x, long long &y_up, long long &y_down){
      |     ^~~~~~~~~~~~~
a.cc:6:5: note:   conversion of argument 4 would be ill-formed:
a.cc:40:62: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'long long int'
   40 |                 ss += binary_search(tmp, x + i, y + j, y + j + 2);
      |                                                        ~~~~~~^~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:2194:5: note: candidate: 'template<class _FIter, class _Tp> bool std::binary_search(_FIter, _FIter, const _Tp&)'
 2194 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2194:5: note:   candidate expects 3 arguments, 4 provided
/usr/include/c++/14/bits/stl_algo.h:2228:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> bool std::binary_search(_FIter, _FIter, const _Tp&, _Compare)'
 2228 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2228:5: note:   template argument deduction/substitution failed:
a.cc:40:36: note:   deduced conflicting types for parameter '_FIter' ('std::vector<std::pair<long int, long int> >' and 'long long int')
   40 |                 ss += binary_search(tmp, x + i, y + j, y + j + 2);
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:41:36: error: no matching function for call to 'binary_search(std::vector<std::pair<long int, long int> >&, long long int, long long int, long long int)'
   41 |                 ss += binary_search(tmp, x + i + 1, y + j, y + j + 2);
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:6:5: note: candidate: 'int binary_search(std::vector<std::pair<long int, long int> >&, long long int&, long long int&, long long int&)' (near match)
    6 | int binary_search(vector<P> &tmp, long long &x, long long &y_up, long long &y_down){
      |     ^~~~~~~~~~~~~
a.cc:6:5: note:   conversion of argument 4 would be ill-formed:
a.cc:41:66: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'long long int'
   41 |                 ss += binary_search(tmp, x + i + 1, y + j, y + j + 2);
      |                                                            ~~~~~~^~~
/usr/include/c++/14/bits/stl_algo.h:2194:5: note: candidate: 'template<class _FIter, class _Tp> bool std::binary_search(_FIter, _FIter, const _Tp&)'
 2194 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2194:5: note:   candidate expects 3 arguments, 4 provided
/usr/include/c++/14/bits/stl_algo.h:2228:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> bool std::binary_search(_FIter, _FIter, const _Tp&, _Compare)'
 2228 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2228:5: note:   template argument deduction/substitution failed:
a.cc:41:36: note:   deduced conflicting types for parameter '_FIter' ('std::vector<std::pair<long int, long int> >' and 'long long int')
   41 |                 ss += binary_search(tmp, x + i + 1, y + j, y + j + 2);
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:42:36: error: no matching function for call to 'binary_search(std::vector<std::pair<long int, long int> >&, long long int, long long int, long long int)'
   42 |                 ss += binary_search(tmp, x + i + 2, y + j, y + j + 2);
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:6:5: note: candidate: 'int binary_search(std::vector<std::pair<long int, long int> >&, long long int&, long long int&, long long int&)' (near match)
    6 | int binary_search(vector<P> &tmp, long long &x, long long &y_up, long long &y_down){
      |     ^~~~~~~~~~~~~
a.cc:6:5: note:   conversion of argument 4 would be ill-formed:
a.cc:42:66: error: cannot bind non-const lvalue reference of type 'long long int&' to an rvalue of type 'long long int'
   42 |                 ss += binary_search(tmp, x + i + 2, y + j, y + j + 2);
      |                                                            ~~~~~~^~~
/usr/include/c++/14/bits/stl_algo.h:2194:5: note: candidate: 'template<class _FIter, class _Tp> bool std::binary_search(_FIter, _FIter, const _Tp&)'
 2194 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2194:5: note:   candidate expects 3 arguments, 4 provided
/usr/include/c++/14/bits/stl_algo.h:2228:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> bool std::binary_search(_FIter, _FIter, const _Tp&, _Compare)'
 2228 |     binary_search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2228:5: note:   template argument deduction/substitution failed:
a.cc:42:36: note:   deduced conflicting types for parameter '_FIter' ('std::vector<std::pair<long int, long int> >' and 'long long int')
   42 |                 ss += binary_search(tmp, x + i + 2, y + j, y + j + 2);
      |                       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~