Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;

struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

const int MAXH=300001;
const int MAXW=300001;
int main(){
    int H,W,M;cin >> H >> W >> M;
    int tate[MAXW];
    int yoko[MAXH];
    bool onw[MAXW];
    bool onh[MAXW];

    memset(onw, false, sizeof(onw));  
    memset(onh, false, sizeof(onh));  
    memset(tate, 0, sizeof(tate));
    memset(yoko, 0, sizeof(yoko));
    int h[MAXH];
    int w[MAXW];
    rep(i,M){
        cin >> h[i] >> w[i];
        tate[w[i]]++;
        yoko[h[i]]++;
    }
    ll ans = 0;
    ll maxw=0,maxh=0;
    ll x=0,y=0;
    Rep(i,W){
        maxw = max(tate[i],maxw);
    }
    Rep(i,W){
        if(maxw==tate[i]){
            onw[i] = true;
            x++;
        }
    }

    Rep(i,H){
        maxh = max(maxh,yoko[i]);
    }

    Rep(i,H){
        if(maxh==yoko[i]){
            onh[i] = true;
            y++;
        }
    }

    ans = x*y;
    rep(i,M){
        if(onw[w[i]] && onh[h[i]]){
            ans--;
        }
    }
    cout << ans << endl;
    ll tma = maxh+maxw;
    if(ans>0)cout << tma << endl;
    else cout << tma-1 << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:19: error: no matching function for call to 'max(int&, ll&)'
   57 |         maxw = max(tate[i],maxw);
      |                ~~~^~~~~~~~~~~~~~
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:57:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   57 |         maxw = max(tate[i],maxw);
      |                ~~~^~~~~~~~~~~~~~
/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:57:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |         maxw = max(tate[i],maxw);
      |                ~~~^~~~~~~~~~~~~~
a.cc:67:19: error: no matching function for call to 'max(ll&, int&)'
   67 |         maxh = max(maxh,yoko[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:67:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   67 |         maxh = max(maxh,yoko[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:67:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   67 |         maxh = max(maxh,yoko[i]);
      |                ~~~^~~~~~~~~~~~~~