Language: C++

/****************************************

			LostMartian

****************************************/
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <fstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <functional>
#include <utility>
#include <climits>
#include <numeric>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <cassert>
using namespace std;
typedef long long ll;

template <typename Arg1>
void pn(Arg1&& arg1) {
	cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args) {
	cout << arg1 << " ";
	pn(args...);
}
template <typename Arg1>
void ps(Arg1&& arg1) {
	cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args) {
	cout << arg1 << " ";
	ps(args...);
}
template <typename Arg1>
void read(Arg1&& arg1) {
	cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) {
	cin >> arg1;
	read(args...);
}

#define rep(i,m,n) for(ll i=m; i<n; i++)
#define repr(i,m,n) for(ll i=m; i>=n; i--)
#define vll vector<ll >
#define vvl vector<vector<ll > >
#define pi pair<ll, ll >
#define vpi vector<pi >
#define umap unordered_map<ll, ll >
#define pb push_back
#define mk make_pair
#define sz size()
#define fi first
#define se second
#define all(x) x.rbegin(), x.rend()
#define test ll t; cin>>t; while(t--)
#define ini(a, x) memset(a, x, sizeof(a))
#define d(x) cout<<"Value of "#x" = "<<x<<"\n";
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define iAmSpeed ios_base::sync_with_stdio(false); cin.tie(NULL);
void LOCAL();
bool a[300005][300005];
int main()
{
	clock_t z = clock();
	//LOCAL();
	iAmSpeed
	set<pi > sst;
	ll h, w, m;
	cin >> h >> w >> m;
	ll mm = m;
	vpi row(h + 1), col(w + 1);
	rep(i, 0, h + 1) {
		row[i].se = i;
	}
	rep(i, 0, w + 1) {
		col[i].se = i;
	}
	rep(i, 0, m) {
		ll x, y;
		cin >> x >> y;
		row[x].fi += 1, col[y].fi += 1;
		sst.emplace(x, y);
	}
	sort(all(row));
	sort(all(col));
	ll xx=row[0].fi, yy=col[0].fi;
	for (ll r = 0; row[r].fi == xx; r++) {
		for (ll c = 0; col[c].fi == yy; c++) {
			if (!sst.count(make_pair(row[r].se, col[c].se))) {
				ll ans = row[r].fi + col[c].fi;
				pn(ans);
				return 0;
			}
		}
	}
	ll ans=row[0].fi+col[0].fi-1;
	pn(max((ll)0, ans));












	debug("Total Time: %.7f\n", (double)(clock() - z) / CLOCKS_PER_SEC);
	return 0;
}
void LOCAL() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:8:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::_Rb_tree_impl<std::less<std::pair<long long int, long long int> >, true>::~_Rb_tree_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<std::pair<long long int, long long int> >]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/map:62,
                 from a.cc:19:
/usr/include/c++/14/bits/stl_tree.h:658:16: note: called from here
  658 |         struct _Rb_tree_impl
      |                ^~~~~~~~~~~~~