Language: C++

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

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl;
  for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
vector<vector<bool>> is_bomb(H+ADD, vector<bool>(W+ADD, false));
  vector<ll> num_h(H+ADD, 0), num_w(W+ADD, 0);
vector<ll> maxs_h, maxs_w;
ll h_num_max = 0, w_num_max = 0;
using P = pair<ll, ll>;
using LP = pair<ll, P>;
int main(){
  ll H, W;
  cin >> H >> W;
  ll M;
  cin >> M;

  const ll ADD = 0;
  
  for(ll i=0; i<M; i++){
    ll h, w;
    cin >> h >> w;
    h--; w--;
    is_bomb[h][w] = true;
    num_h[h]++;
    num_w[w]++;
  }

  
  
  // for(ll i=0; i<H; i++){
  //   if(h_num_max < num_h[i]){
  //     h_num_max = num_h[i];
  //   }
  // }
  // for(ll i=0; i<W; i++){
  //   if(w_num_max < num_w[i]){
  //     w_num_max = num_w[i];
  //   }
  // }
  for(ll i=0; i<H; i++) h_num_max = max(h_num_max, num_h[i]);
  for(ll i=0; i<W; i++) w_num_max = max(w_num_max, num_w[i]);

  
  for(ll i=0; i<H; i++) if(num_h[i] == h_num_max) maxs_h.push_back(i);
  for(ll i=0; i<W; i++) if(num_w[i] == w_num_max) maxs_w.push_back(i);

//  cout << " num_h : "  ; print_vec(num_h);
//   cout << " num_w : "  ; print_vec(num_w);
//   cout << " maxs_h : "  ; print_vec(maxs_h);
//   cout << " maxs_w : "  ; print_vec(maxs_w);
  ll ans = 0;
  for(ll i=0; i<(ll)maxs_h.size(); i++){
    for(ll j=0; j<(ll)maxs_w.size(); j++){
        ll tmp = num_h[maxs_h[i]] + num_w[maxs_w[j]];
        if(is_bomb[maxs_h[i]][maxs_w[j]] == true) tmp--;
        else{
          cout << tmp << endl;
          return 0;
        }
        ans = max(ans, tmp);
    }
  }

  cout << ans << endl;

  return 0;
}


Compiler output:
a.cc:34:30: error: 'H' was not declared in this scope
   34 | vector<vector<bool>> is_bomb(H+ADD, vector<bool>(W+ADD, false));
      |                              ^
a.cc:34:32: error: 'ADD' was not declared in this scope
   34 | vector<vector<bool>> is_bomb(H+ADD, vector<bool>(W+ADD, false));
      |                                ^~~
a.cc:34:50: error: 'W' was not declared in this scope
   34 | vector<vector<bool>> is_bomb(H+ADD, vector<bool>(W+ADD, false));
      |                                                  ^
a.cc:34:52: error: 'ADD' was not declared in this scope
   34 | vector<vector<bool>> is_bomb(H+ADD, vector<bool>(W+ADD, false));
      |                                                    ^~~
a.cc:35:20: error: 'H' was not declared in this scope
   35 |   vector<ll> num_h(H+ADD, 0), num_w(W+ADD, 0);
      |                    ^
a.cc:35:22: error: 'ADD' was not declared in this scope
   35 |   vector<ll> num_h(H+ADD, 0), num_w(W+ADD, 0);
      |                      ^~~
a.cc:35:37: error: 'W' was not declared in this scope
   35 |   vector<ll> num_h(H+ADD, 0), num_w(W+ADD, 0);
      |                                     ^
a.cc:35:39: error: 'ADD' was not declared in this scope
   35 |   vector<ll> num_h(H+ADD, 0), num_w(W+ADD, 0);
      |                                       ^~~