Language: C++

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i, a, b) for(int i = a; i < b; i++)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define trarr(a,n) rep(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) rep(i,0,n)rep(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 3e5+10;
void solve(int _t){
	int h, w;
	int m;
	cin >> h >> w >> m;
	vector<pii> v;
	int x[N] = {0};
	int y[N] = {0};
	vector<int> xv[N], yv[N];
	int mxxv = -1;
	int mxxi = 0;
	int mxyv = -1;
	int mxyi = 0;
	rep(i, 0, m){
		int a, b;
		cin >> a >> b;
		v.pb(mp(a, b));
		x[b]++;
		xv[b].pb(i);
		y[a]++;
		yv[a].pb(i);
		if(mxxv < x[b]){
			mxxv = x[b];
			mxxi = b;
		}
		if(mxyv < y[a]){
			mxyv = y[a];
			mxyi = a;
		}
	}
	ll ans = mxyv;
	// tr(ans, mxyv, mxyi, v[mxyi]);
	rep(i, 0, sz(yv[mxyi])){
		// tr(v[i]);
		int ind = yv[mxyi][i];
		x[v[ind].ss]--;
		y[v[ind].ff]--;
	}
	mxxv = 0;
	mxxi = 0;
	rep(i, 0, N){
		if(mxxv < x[i]){
			mxxv = x[i];
			mxxi = i;
		}
	}
	ans+=mxxv;
	cout<<max(ans, 0)<<endl;

}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	rep(test, 1, t+1){
		solve(test);
	}
	return 0;
}  #include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i, a, b) for(int i = a; i < b; i++)
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define trarr(a,n) rep(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) rep(i,0,n)rep(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 3e5+10;
void solve(int _t){
	int h, w;
	int m;
	cin >> h >> w >> m;
	vector<pii> v;
	int x[N] = {0};
	int y[N] = {0};
	vector<int> xv[N], yv[N];
	int mxxv = -1;
	int mxxi = 0;
	int mxyv = -1;
	int mxyi = 0;
	rep(i, 0, m){
		int a, b;
		cin >> a >> b;
		v.pb(mp(a, b));
		x[b]++;
		xv[b].pb(i);
		y[a]++;
		yv[a].pb(i);
		if(mxxv < x[b]){
			mxxv = x[b];
			mxxi = b;
		}
		if(mxyv < y[a]){
			mxyv = y[a];
			mxyi = a;
		}
	}
	ll ans = mxyv;
	// tr(ans, mxyv, mxyi, v[mxyi]);
	rep(i, 0, sz(yv[mxyi])){
		// tr(v[i]);
		int ind = yv[mxyi][i];
		x[v[ind].ss]--;
		y[v[ind].ff]--;
	}
	mxxv = 0;
	mxxi = 0;
	rep(i, 0, N){
		if(mxxv < x[i]){
			mxxv = x[i];
			mxxi = i;
		}
	}
	ans+=mxxv;
	cout<<max(ans, 0)<<endl;

}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	rep(test, 1, t+1){
		solve(test);
	}
	return 0;
}  

Compiler output:
a.cc:99:4: error: stray '#' in program
   99 | }  #include<bits/stdc++.h>
      |    ^
a.cc: In function 'void solve(int)':
a.cc:88:18: error: no matching function for call to 'max(long long int&, int)'
   88 |         cout<<max(ans, 0)<<endl;
      |               ~~~^~~~~~~~
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:1:
/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:88:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   88 |         cout<<max(ans, 0)<<endl;
      |               ~~~^~~~~~~~
/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:88:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   88 |         cout<<max(ans, 0)<<endl;
      |               ~~~^~~~~~~~
a.cc: At global scope:
a.cc:99:5: error: 'include' does not name a type
   99 | }  #include<bits/stdc++.h>
      |     ^~~~~~~
a.cc:124:10: error: redefinition of 'template<class S, class T> std::ostream& operator<<(std::ostream&, const std::pair<_T1, _T2>&)'
  124 | ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
      |          ^~~~~~~~
a.cc:26:10: note: 'template<class S, class T> std::ostream& operator<<(std::ostream&, const std::pair<_T1, _T2>&)' previously declared here
   26 | ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
      |          ^~~~~~~~
a.cc:126:10: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)'
  126 | ostream& operator<<(ostream& out,vector<T> const& v){
      |          ^~~~~~~~
a.cc:28:10: note: 'template<class T> std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)' previously declared here
   28 | ostream& operator<<(ostream& out,vector<T> const& v){
      |          ^~~~~~~~
a.cc:129:6: error: redefinition of 'template<class T> void trace(const char*, T&&)'
  129 | void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
      |      ^~~~~
a.cc:31:6: note: 'template<class T> void trace(const char*, T&&)' previously declared here
   31 | void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
      |      ^~~~~
a.cc:131:6: error: redefinition of 'template<class T, class ... Args> void trace(const char*, T&&, Args&& ...)'
  131 | void trace(const char* names, T&& arg1, Args&&... args){
      |      ^~~~~
a.cc:33:6: note: 'template<class T, class ... Args> void trace(const char*, T&&, Args&& ...)' previously declared here
   33 | void trace(const char* names, T&& arg1, Args&&... args){
      |      ^~~~~
a.cc:134:10: error: redefinition of 'const long double PI'
  134 | const ld PI = acos(-1);
      |          ^~
a.cc:36:10: note: 'const long double PI' previously defined here
   36 | const ld PI = acos(-1);
      |          ^~
a.cc:135:10: error: redefinition of 'const long double EPS'
  135 | const ld EPS = 1e-9;
      |          ^~~
a.cc:37:10: note: 'const long double EPS' previously defined here
   37 | const ld EPS = 1e-9;
      |          ^~~
a.cc:136:11: error: redefinition of 'const int inf'
  136 | const int inf = 1e9+10;
      |           ^~~
a.cc:38:11: note: 'const int inf' previously defined here
   38 | const int inf = 1e9+10;
      |           ^~~
a.cc:137:10: error: redefinition of 'const long long int INF'
  137 | const ll INF = 1e18+10;
      |          ^~~
a.cc:39:10: note: 'const long long int INF' previously defined here
   39 | const ll INF = 1e18+10;
      |          ^~~
a.cc:138:11: error: redefinition of 'const int P'
  138 | const int P = 1e9+7;
      |           ^
a.cc:40:11: note: 'const int P' previously defined here
   40 | const int P = 1e9+7;
      |           ^
a.cc:139:11: error: redefinition of 'const int N'
  139 | const int N = 3e5+10;
      |           ^
a.cc:41:11: note: 'const int N' previously defined here
   41 | const int N = 3e5+10;
      |           ^
a.cc:140:6: error: redefinition of 'void solve(int)'
  140 | void solve(int _t){
      |      ^~~~~
a.cc:42:6: note: 'void solve(int)' previously defined here
   42 | void solve(int _t){
      |      ^~~~~
a.cc: In function 'void solve(int)':
a.cc:186:18: error: no matching function for call to 'max(long long int&, int)'
  186 |         cout<<max(ans, 0)<<endl;
      |               ~~~^~~~~~~~
/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:186:18: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  186 |         cout<<max(ans, 0)<<endl;
      |               ~~~^~~~~~~~
/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
/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:186:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  186 |         cout<<max(ans, 0)<<endl;
      |               ~~~^~~~~~~~
a.cc: At global scope:
a.cc:189:5: error: redefinition of 'int main()'
  189 | int main(){
      |     ^~~~
a.cc:91:5: note: 'int main()' previously defined here
   91 | int main(){
      |     ^~~~