Language: C++

/**
        Bismilla- hir rahma-nir rahi-m
    @uthor Md Hasibur Rahman (Evan)
                JKKNIU
*/


#include<bits/stdc++.h>
#define         ll              long long
#define         FI              freopen("input.txt","r",stdin)
#define         FO              freopen("output.txt","w",stdout)
#define         PrintCase(i)    printf("Case %d: ",i)
#define         sc(a)           scanf("%d",&a)
#define         scl(a)          scanf("%lld",&a)
#define         rep(i,n)        for(int i=0;i<n;i++)
#define         pb              push_back
#define         MAX             1000000
#define         fast            ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define			endl			"\n"


using namespace std;

bool isPrime(ll a)
{
    for(ll i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}






bool isPowerOfTwo(ll a)
{
    if(a==1)
        return true;
    if(a&1)
        return false;
    while(a)
    {
        a/=2;
        if(a!=1 && a&1)
            return false;
        if(a==1)
            return true;
    }
    return true;
}




ll gcd(ll a, ll b)
{
    if(a<0 || b<0)
    {
        a = abs(a);
        b = abs(b);
    }
    if(a<b)
        swap(a,b);
    if(a%b==0 || b==0)
        return b;
    else
        return gcd(b,a%b);
}



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



ll power(ll base, ll exponent)
{
    ll ans = 1;
    for(ll i=1;i<=exponent;i++)
        ans*=base;
    return ans;
}




bool isPowerOfX(ll x, ll value)
{
    if(value==1)
        return true;
    while(value)
    {
        value/=x;
        if(value%x && value!=1)
            return false;
    }
    return true;
}



struct points
{
	ll r,c;
}v;

bool visit[444444];
int main()
{
    //fast;
    ll c,r,target;
    cin>>c>>r>>target;
    map<ll,ll>mpc,mpr;
    vector<points>p;
    rep(i,target)
    {
    	ll c,r;
    	cin>>c>>r;
    	mpc[c-1]++;
    	mpr[r-1]++;
		v.c = c-1;
		v.r = r-1;
		p.pb(v);	
	}
	ll ans = 0;
	ll el=-1,mxr=-1, mxc=-1;
	map<ll,ll>::iterator it;
	el = -1;
	for(it=mpr.begin();it!=mpr.end();it++)
	{
		if(el<it->second)
		{
			el = it->second;
			mxr = it->first;
		}
	}
	//cout<<mxc<<" .... "<<mxr<<endl;
	for(int i=0;i<target;i++)
	{
		if(p[i].r==mxr)
			visit[p[i].c] = true;
	}
	ans = -1;
	for(it = mpc.begin();it!=mpc.end();it++)
	{
		//cout<<ans<<"for "<<it->second<<" row "<<mxr<<endl;
		ll pev = ans;
			ans = max(ans,mpr[mxr] + it->second);
			if(visit[it->first] && pev!=ans)
				ans--;
	}
	cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:146:25: error: reference to 'visit' is ambiguous
  146 |                         visit[p[i].c] = true;
      |                         ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:8:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:112:6: note:                 'bool visit [444444]'
  112 | bool visit[444444];
      |      ^~~~~
a.cc:154:28: error: reference to 'visit' is ambiguous
  154 |                         if(visit[it->first] && pev!=ans)
      |                            ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:112:6: note:                 'bool visit [444444]'
  112 | bool visit[444444];
      |      ^~~~~