Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline int readint() {
	char c = getchar(); int w = 1; int x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
	x *= w;
	return x;
}
inline ll readll() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
	x *= w;
	return x;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
struct node{
    ll d,id;
};
bool f[300010][300010];
bool cmp1(node a,node b){
    return a.d>b.d;
}
node x[300010],y[300010];
int main(){
    ll h,w,m;
    cin>>h>>w>>m;
    for(int i=1;i<=m;i++){
        ll u,v;
        cin>>u>>v;
        x[u].d++;y[v].id=i;
        y[v].d++;y[v].id=i;
        f[u][v]=1;
    }
    sort(x+1,x+h+1,cmp1);
    sort(y+1,y+w+1,cmp1);
    cout<<x[1].d+y[1].d-f[x[1].id][y[1].id]<<endl;
    return 0;
}
/* stuff to remember
	* int overflow, array bounds
	* special cases (n=1? n=0?)
	* do something instead of nothing and stay organized
	* USE STATIC ARRAYS
	* DEFINING ARRAYS BEFORE main()
	* DO NOT DEFINE ARRAYS IN main()
	* USE INT INSTEAD OF LL,NOTICE THE MLE
*/

Compiler output:
/tmp/cc79gQC4.o: in function `main':
a.cc:(.text+0x322): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc79gQC4.o
a.cc:(.text+0x338): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc79gQC4.o
a.cc:(.text+0x353): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/cc79gQC4.o
a.cc:(.text+0x369): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/cc79gQC4.o
a.cc:(.text+0x37f): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/cc79gQC4.o
a.cc:(.text+0x39a): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/cc79gQC4.o
a.cc:(.text+0x3ea): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc79gQC4.o
a.cc:(.text+0x3f5): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc79gQC4.o
a.cc:(.text+0x41d): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/cc79gQC4.o
a.cc:(.text+0x428): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/cc79gQC4.o
a.cc:(.text+0x441): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status