Language: C++

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int H, W, M;
  cin >> H >> W >> M;
  
  
  
  vector<int> Hi(H, 0);
  vector<int> Wi(W, 0);
  vector<vector<bool>> judge(H, vector<bool>(W,false));
  for(int i = 0; i<M; i++){
    int h,w;
    cin >> h >> w;
    Hi[h-1]++;
    Wi[w-1]++;
    judge[h-1][w-1]=true;
  }
  
  
  ll max_h = 0;
  ll max_w = 0;
  
  for(int i = 0; i<H; i++){
    max_h = max(max_h, Hi[i]);
  }
  for(int i = 0; i<W; i++){
    max_w = max(max_w, Wi[i]);
  }
  
  
  
  vector<int> X(0);
  vector<int> Y(0);
  
  for(int i = 0; i<H; i++){
    if(Hi[i] == max_h){
      X.push_back(i);
    }
  }
  for(int i = 0; i<W; i++){
    if(Wi[i] == max_w){
      Y.push_back(i);
    }
  }
  
  bool x = true;
  for(int i = 0; i<X.size(); i++){
    for(int j = 0; j<Y.size(); j++){
      if(!judge[X[i]][Y[j]]){
        x = false;
      }
    }
  }
  
  if(x){
    cout << max_h+max_w-1 << endl;
  }
  else{
    cout << max_h+max_w << endl;
  }
      
    
}

      
      
       




Compiler output:
a.cc: In function 'int main()':
a.cc:34:16: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   34 |     max_h = max(max_h, Hi[i]);
      |             ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:34:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   34 |     max_h = max(max_h, Hi[i]);
      |             ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:34:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   34 |     max_h = max(max_h, Hi[i]);
      |             ~~~^~~~~~~~~~~~~~
a.cc:37:16: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   37 |     max_w = max(max_w, Wi[i]);
      |             ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:37:16: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   37 |     max_w = max(max_w, Wi[i]);
      |             ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:37:16: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |     max_w = max(max_w, Wi[i]);
      |             ~~~^~~~~~~~~~~~~~