Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int n,m,k;
		cin>>n>>m>>k;
		int row[n+1] = {0};
		int col[m+1] = {0};
		multiset<pair<int,int> > st;
		f(i,k) {
			int u,v;
			cin>>u>>v;
			row[u]++;
			col[v]++;
			st.insert({u,v});
		}
		set<pair<int,int> > st1,st2;
		for(int i=1; i<=n; i++) {
			st1.insert({row[i],i});
		}
		for(int i=1; i<=m; i++) {
			st2.insert({col[i],i});
		}
		ll ans = 0;
		int c = 0;
		auto it1 = st1.rbegin();
		while(it1 != st1.rend() and c < 10000) {
			int c1 = 0;
			int x = it1->second;
			auto it2 = st2.rbegin();
			while(it2 != st2.rend() and c1 < 100) {
				int y = it2->second;
				if(st.find({x,y}) != st.end()) {
					ans = max(ans,1LL*it1->first + it2->first - 1);
				}
				else {
					ans = max(ans,1LL*it1->first + it2->first);
				}
				it2++;
				c1++;
			}
			c++;
			it1++;
		}
		int c = 0;
		auto it1 = st1.rbegin();
		while(it1 != st1.rend() and c < 100) {
			int c1 = 0;
			int x = it1->second;
			auto it2 = st2.rbegin();
			while(it2 != st2.rend() and c1 < 10000) {
				int y = it2->second;
				if(st.find({x,y}) != st.end()) {
					ans = max(ans,1LL*it1->first + it2->first - 1);
				}
				else {
					ans = max(ans,1LL*it1->first + it2->first);
				}
				it2++;
				c1++;
			}
			c++;
			it1++;
		}
		int c = 0;
		auto it1 = st1.rbegin();
		while(it1 != st1.rend() and c < 1000) {
			int c1 = 0;
			int x = it1->second;
			auto it2 = st2.rbegin();
			while(it2 != st2.rend() and c1 < 1000) {
				int y = it2->second;
				if(st.find({x,y}) != st.end()) {
					ans = max(ans,1LL*it1->first + it2->first - 1);
				}
				else {
					ans = max(ans,1LL*it1->first + it2->first);
				}
				it2++;
				c1++;
			}
			c++;
			it1++;
		}
		cout<<ans<<"\n";
 	}
 	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:98:21: error: redeclaration of 'int c'
   98 |                 int c = 0;
      |                     ^
a.cc:78:21: note: 'int c' previously declared here
   78 |                 int c = 0;
      |                     ^
a.cc:99:22: error: conflicting declaration 'auto it1'
   99 |                 auto it1 = st1.rbegin();
      |                      ^~~
a.cc:79:22: note: previous declaration as 'std::reverse_iterator<std::_Rb_tree_const_iterator<std::pair<int, int> > > it1'
   79 |                 auto it1 = st1.rbegin();
      |                      ^~~
a.cc:118:21: error: redeclaration of 'int c'
  118 |                 int c = 0;
      |                     ^
a.cc:78:21: note: 'int c' previously declared here
   78 |                 int c = 0;
      |                     ^
a.cc:119:22: error: conflicting declaration 'auto it1'
  119 |                 auto it1 = st1.rbegin();
      |                      ^~~
a.cc:79:22: note: previous declaration as 'std::reverse_iterator<std::_Rb_tree_const_iterator<std::pair<int, int> > > it1'
   79 |                 auto it1 = st1.rbegin();
      |                      ^~~