Language: C++

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    int h, w, m; cin >> h >> w >> m;
    vector<P> exist;
    map<P, int> bomb;
    vi cx(h, 0);
    vi cy(w, 0);

    rep(i, m){
        int x, y; cin >> x >> y; x--; y--;
        cx[x]++;
        cy[y]++;
        bomb[{x, y}]++;
        exist.pb({x, y});
    }
    
    vector<P> cntx(h), cnty(w);
    rep(i, h) cntx[i] = {cx[i], i};
    rep(i, w) cnty[i] = {cy[i], i};
    
    sort(rall(cntx));
    sort(rall(cnty));
    
    /*
    for(auto [c, i] : cntx) cout << c << " " << i << endl;
    cout << endl;
    for(auto [c, i] : cnty) cout << c << " " << i << endl;
    */
    
    int ans = 0;
    for(auto [x, y] : exist){
        ans = max(ans, cx[x] + cy[y] - 1);
    }
    
    int mx = cntx[0].fi + cnty[0].fi;
    // cout << mx << endl << endl;
    if(ans >= mx) {
        cout << ans << endl;
        return;
    }
    
    vi candx, candy;
    rep(i, h){
        if(cntx[i].fi == cntx[0].fi) candx.pb(cntx[i].se);
        else break;
    }
    rep(i, w){
        if(cnty[i].fi == cnty[0].fi) candy.pb(cnty[i].se);
        else break;
    }

    for(auto x : candx){
        for(auto y : candy){
            // cout << x << " " << y << endl;
            //*
            if(bomb[x][y] == 0){
                cout << mx << endl;
                return;
            }
            //*/
        }
    }
    cout << mx - 1 << endl;
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Compiler output:
a.cc: In function 'void Main()':
a.cc:74:20: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'int')
   74 |             if(bomb[x][y] == 0){
      |                    ^
In file included from /usr/include/c++/14/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'int' to 'const std::map<std::pair<int, int>, int>::key_type&' {aka 'const std::pair<int, int>&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~