Language: C++

/*
*   1. What was the key concept?
*   2. What mistake did I make? (if any)
*   3. Thing to remember from now on.
*/

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

#define INF 0x3f3f3f3f;
#define INFL 0x3f3f3f3f3f3f3f3f;
#define NITRO ios_base::sync_with_stdio(false); cin.tie(false)
#define PRECISE cout << fixed << setprecision(9)

using ll = long long int;
using ld = long double;

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;

int main(){

    int h, w, m;
    cin >> h >> w >> m;

    map<int, int> rows, cols;
    set<pair<int, int>> points;

    for (int i=0; i<m; i++){
        int r, c;
        cin >> r >> c;

        rows[r]++;
        cols[c]++;
        points.insert({r, c});
    }

    vector<pair<int, int>> rv, cv;
    for (auto v: rows) rv.emplace_back(v);
    for (auto v: cols) cv.emplace_back(v);

    auto comp = [](pair<int, int> a, pair<int, int> b) {
        return a.second > b.second;
    };

    sort(begin(rv), end(rv), comp);
    sort(begin(cv), end(cv), comp);

    ll ans = 0;

    int rp = 0, cp = 0;

    while (true){

        int cur = rv[rp].second + cv[cp].second;
        if (points.count({rv[rp].first, cv[cp].first})) cur--;

        ans = max(ans, cur);

        if (rp + 1 < rv.size() and rv[rp + 1].second > cv[cp + 1].second) rp++;
        else if (cp + 1 < cv.size()) cp++;
        else break;
    }

    cout << ans << endl;

    return 0;
}

// Check the corner cases. (n = 1).
// Check overflows. (int vs ll).
// Be consistent.

Compiler output:
a.cc: In function 'int main()':
a.cc:58:18: error: no matching function for call to 'max(ll&, int&)'
   58 |         ans = max(ans, cur);
      |               ~~~^~~~~~~~~~
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:7:
/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:58:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   58 |         ans = max(ans, cur);
      |               ~~~^~~~~~~~~~
/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:58:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   58 |         ans = max(ans, cur);
      |               ~~~^~~~~~~~~~