Language: C++

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

int main() {
    int n,m,k,r,c,maxic,maxir;
    cin>>n>>m>>k;
    vector<int,int >row(300001,0);
    vector<int,int >col(300001,0);
    map<pair<int,int>,int> chk;
    for(int i=0;i<k;i++) {
        cin>>r>>c;
        row[r-1]++;
        col[c-1]++;
        chk[{r-1,c-1}]=1;
    }
    int ans=0;
    r = 0;
    c = 0;
    maxic = -1;
    maxir = -1;

    for(int i=0;i<max(m,n);i++) {
        if(row[i]>maxir) {
            maxir=row[i];
            r=i;
        }
        else if(row[i]==maxir && chk[{r,c}]==0) {
            maxir=row[i];
            r=i;
        }

        if(col[i]>maxic) {
            maxic=col[i];
            c=i;
        }
        else if(col[i]==maxic && chk[{r,c}]==0) {
            maxic=col[i];
            c=i;
        }
    }

    if(chk[{r,c}]==1) ans=row[r]+col[c]-1;
    else ans=row[r]+col[c];
    cout<<ans<<endl;
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'struct std::_Vector_base<int, int>':
/usr/include/c++/14/bits/stl_vector.h:428:11:   required from 'class std::vector<int, int>'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
a.cc:7:24:   required from here
    7 |     vector<int,int >row(300001,0);
      |                        ^
/usr/include/c++/14/bits/stl_vector.h:87:28: error: 'int' is not a class, struct, or union type
   87 |         rebind<_Tp>::other _Tp_alloc_type;
      |                            ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:89:9: error: 'int' is not a class, struct, or union type
   89 |         pointer;
      |         ^~~~~~~
/usr/include/c++/14/bits/stl_vector.h: In instantiation of 'class std::vector<int, int>':
a.cc:7:24:   required from here
    7 |     vector<int,int >row(300001,0);
      |                        ^
/usr/include/c++/14/bits/stl_vector.h:518:20: error: '_M_allocate' has not been declared in 'std::vector<int, int>::_Base'
  518 |       using _Base::_M_allocate;
      |                    ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:519:20: error: '_M_deallocate' has not been declared in 'std::vector<int, int>::_Base'
  519 |       using _Base::_M_deallocate;
      |                    ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:521:20: error: '_M_get_Tp_allocator' has not been declared in 'std::vector<int, int>::_Base'
  521 |       using _Base::_M_get_Tp_allocator;
      |                    ^~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:7:33: error: call of overloaded 'vector(int, int)' is ambiguous
    7 |     vector<int,int >row(300001,0);
      |                                 ^
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = int; _Alloc = int; size_type = long unsigned int; value_type = int; allocator_type = int]'
  569 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = int; _Alloc = int; size_type = long unsigned int; allocator_type = int]'
  556 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
a.cc:8:33: error: call of overloaded 'vector(int, int)' is ambiguous
    8 |     vector<int,int >col(300001,0);
      |                                 ^
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = int; _Alloc = int; size_type = long unsigned int; value_type = int; allocator_type = int]'
  569 |       vector(size_type __n, const value_type& __value,
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = int; _Alloc = int; size_type = long unsigned int; allocator_type = int]'
  556 |       vector(size_type __n, const allocator_type& __a = allocator_type())
      |       ^~~~~~
a.cc:12:12: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   12 |         row[r-1]++;
      |            ^
a.cc:13:12: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   13 |         col[c-1]++;
      |            ^
a.cc:23:15: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   23 |         if(row[i]>maxir) {
      |               ^
a.cc:24:22: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   24 |             maxir=row[i];
      |                      ^
a.cc:27:20: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   27 |         else if(row[i]==maxir && chk[{r,c}]==0) {
      |                    ^
a.cc:28:22: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   28 |             maxir=row[i];
      |                      ^
a.cc:32:15: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   32 |         if(col[i]>maxic) {
      |               ^
a.cc:33:22: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   33 |             maxic=col[i];
      |                      ^
a.cc:36:20: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   36 |         else if(col[i]==maxic && chk[{r,c}]==0) {
      |                    ^
a.cc:37:22: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   37 |             maxic=col[i];
      |                      ^
a.cc:42:30: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   42 |     if(chk[{r,c}]==1) ans=row[r]+col[c]-1;
      |                              ^
a.cc:42:37: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   42 |     if(chk[{r,c}]==1) ans=row[r]+col[c]-1;
      |                                     ^
a.cc:43:17: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   43 |     else ans=row[r]+col[c];
      |                 ^
a.cc:43:24: error: no match for 'operator[]' (operand types are 'std::vector<int, int>' and 'int')
   43 |     else ans=row[r]+col[c];
      |                        ^