Language: C++

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

int main(){
   int  H,W,M;
   cin>>H>>W>>M;
   int AH[300100]={};
   int AW[300100]={};
   int ans=0;
   int h,w;
  set<pair<int,int>>s;
  //vector<pair<int,int>>ve(300100);
    for(int i=0;i<M;i++){
        cin>>h>>w;
        AH[h]++;
        AW[w]++;
      s.insert({h,w});    
    }
  vector<int>hp;
  vector<int>wp;
  int maxh=0;
  int maxw=0;
  for(int i=1;i<=M;i++){
    if(AH[i]>=maxh){
      maxh=AH[i];
    }
  }
  for(int i=i;i<=M;i++){
    if(AH[i]==maxh){
      hp.push_back(i);
    }
  }
  
  for(int i=1;i<=M;i++){
    if(AW[i]>=maxw){
      maxw=AW[i];
    }
  }  
  for(int i=i;i<=M;i++){
    if(AW[i]==maxw){
      wp.push_back(i);
    }
  }
  ans=maxh+maxw;
  
  int flag=1;
  for(int i=1;i<=M;i++){
    for(int j=1;j<=M;j++){
      if(A[i]==maxh && A[j]==maxw){
        if(s.find({*i,*j})!=s.end()) flag=0;
      }
    }
  }
  
  if(flag){
    cout<<ans<<endl;
  }
  else{
    cout<<ans-1<<endl;
  }
  return 0;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:10: error: 'A' was not declared in this scope
   49 |       if(A[i]==maxh && A[j]==maxw){
      |          ^
a.cc:50:20: error: invalid type argument of unary '*' (have 'int')
   50 |         if(s.find({*i,*j})!=s.end()) flag=0;
      |                    ^~
a.cc:50:23: error: invalid type argument of unary '*' (have 'int')
   50 |         if(s.find({*i,*j})!=s.end()) flag=0;
      |                       ^~
a.cc:50:18: error: no matching function for call to 'std::set<std::pair<int, int> >::find(<brace-enclosed initializer list>)'
   50 |         if(s.find({*i,*j})!=s.end()) flag=0;
      |            ~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:806:9: note: candidate: 'template<class _Kt> decltype (std::set<_Key, _Compare, _Alloc>::iterator{((std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::set<_Key, _Compare, _Alloc>::find(const _Kt&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  806 |         find(const _Kt& __x)
      |         ^~~~
/usr/include/c++/14/bits/stl_set.h:806:9: note:   template argument deduction/substitution failed:
a.cc:50:18: note:   couldn't deduce template parameter '_Kt'
   50 |         if(s.find({*i,*j})!=s.end()) flag=0;
      |            ~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:812:9: note: candidate: 'template<class _Kt> decltype (std::set<_Key, _Compare, _Alloc>::const_iterator{((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_find_tr(__x)}) std::set<_Key, _Compare, _Alloc>::find(const _Kt&) const [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]'
  812 |         find(const _Kt& __x) const
      |         ^~~~
/usr/include/c++/14/bits/stl_set.h:812:9: note:   template argument deduction/substitution failed:
a.cc:50:18: note:   couldn't deduce template parameter '_Kt'
   50 |         if(s.find({*i,*j})!=s.end()) flag=0;
      |            ~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:796:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; key_type = std::pair<int, int>]'
  796 |       find(const key_type& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_set.h:796:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::set<std::pair<int, int> >::key_type&' {aka 'const std::pair<int, int>&'}
  796 |       find(const key_type& __x)
      |            ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:800:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::const_iterator std::set<_Key, _Compare, _Alloc>::find(const key_type&) const [with _Key = std::pair<int, int>; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >; const_iterator = std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator; key_type = std::pair<int, int>]'
  800 |       find(const key_type& __x) const
      |       ^~~~
/usr/include/c++/14/bits/stl_set.h:800:28: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::set<std::pair<int, int> >::key_type&' {aka 'const std::pair<int, int>&'}
  800 |       find(const key_type& __x) const
      |            ~~~~~~~~~~~~~~~~^~~