Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
using ll = long long;
using graph = vector<vector<int>>;

const ll mod = 1000000007;
const int INF = 1001001001;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int h, w; cin >> h >> w;
	int m; cin >> m;
	vector<int> x(h+1), y(w+1);
	vector<pair<int, int>> p;
	for(int i = 0; i < m; i++){
		int a, b; cin >> a >> b;
		x[a]++;
		y[b]++;
		p.push_back({a, b});
	}
	int xmx = *max_element(x.begin(), x.end()), ymx = *max_element(y.begin(), y.end());
	set<int, int> tmpx, tmpy;
	for(int i = 1; i <= h; i++){
		if(x[i] == xmx) tmpx.insert(i);
	}
	for(int i = 1; i <= w; i++){
		if(y[i] == ymx) tmpy.insert(i);
	}
	bool ok = false;
	set<pair<int, int>> st;
	for(auto i : tmpx){
		for(auto j : tmpy){
			//cout << tmpx[i] << " " << tmpy[j] << endl;
			st.insert({i, j});
		}
	}
	for(int i = 0; i < m; i++){
		//cout << p[i].first << " " << p[i].second << endl;
		if(!st.count(p[i])){
			if(tmpx.count(p[i].first && tmpy.count(p[i].second)){
				ok = true;
			}
		}
	}
	int ans = xmx + ymx;
	if(!ok) ans--;
	//cout << ans << endl;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:42:77: error: expected ')' before '{' token
   42 |                         if(tmpx.count(p[i].first && tmpy.count(p[i].second)){
      |                           ~                                                 ^
      |                                                                             )
a.cc:45:17: error: expected primary-expression before '}' token
   45 |                 }
      |                 ^
In file included from /usr/include/c++/14/map:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = int; _Alloc = std::allocator<int>; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, int, std::allocator<int> >::const_iterator]':
/usr/include/c++/14/bits/stl_set.h:751:25:   required from 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = int; _Compare = int; _Alloc = std::allocator<int>; size_type = long unsigned int; key_type = int]'
  751 |       { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
      |                ~~~~~~~~~^~~~~
a.cc:42:42:   required from here
   42 |                         if(tmpx.count(p[i].first && tmpy.count(p[i].second)){
      |                                                     ~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:2545:40: error: expression cannot be used as a function
 2545 |               || _M_impl._M_key_compare(__k,
      |                  ~~~~~~~~~~~~~~~~~~~~~~^~~~~
 2546 |                                         _S_key(__j._M_node))) ? end() : __j;
      |                                         ~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = int; _Alloc = std::allocator<int>; key_type = int]':
/usr/include/c++/14/bits/stl_tree.h:2169:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const int&; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = int; _Alloc = std::allocator<int>]'
 2169 |         = _M_get_insert_unique_pos(_KeyOfValue()(__v));
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:514:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = int; _Compare = int; _Alloc = std::allocator<int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, int, std::allocator<int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<int>, int>::rebind<int>; typename _Alloc::value_type = int; value_type = int]'
  514 |           _M_t._M_insert_unique(__x);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:26:30:   required from here
   26 |                 if(x[i] == xmx) tmpx.insert(i);
      |                                 ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_tree.h:2116:42: error: expression cannot be used as a function
 2116 |           __comp = _M_impl._M_key_compare(__k, _S_key(__x));
      |                    ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:2127:33: error: expression cannot be used as a function
 2127 |       if (_M_impl._M_key_compare(_S_key(__j._M_node), __k))
      |           ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_(_Base_ptr, _Base_ptr, _Arg&&, _NodeGen&) [with _Arg = const int&; _NodeGen = std::_Rb_tree<int, int, std::_Identity<int>, int, std::allocator<int> >::_Alloc_node; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = int; _Alloc = std::allocator<int>; iterator = std::_Rb_tree<int, int, std::_Identity<int>, int, std::allocator<int> >::iterator; _Base_ptr = std::_Rb_tree_node_base*]':
/usr/include/c++/14/bits/stl_tree.h:2174:26:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const int&; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = int; _Alloc = std::allocator<int>]'
 2174 |           return _Res(_M_insert_(__res.first, __res.second,
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
 2175 |                                  _GLIBCXX_FORWARD(_Arg, __v), __an),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:514:25:   required from 'std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = int; _Compare = int; _Alloc = std::allocator<int>; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, int, std::allocator<int> >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<int>; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<int>, int>::rebind<int>; typename _Alloc::value_type = int; value_type = int]'
  514 |           _M_t._M_insert_unique(__x);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:26:30:   required from here
   26 |                 if(x[i] == xmx) tmpx.insert(i);
      |                                 ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_tree.h:1824:56: error: expression cannot be used as a function
 1824 |                               || _M_impl._M_key_compare(_KeyOfValue()(__v),
      |                                  ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
 1825 |                                                         _S_key(__p)));
      |                                                         ~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_lower_bound(_Const_Link_type, _Const_Base_ptr, const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = int; _Alloc = std::allocator<int>; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, int, std::allocator<int> >::const_iterator; _Const_Link_type = const std::_Rb_tree_node<int>*; _Const_Base_ptr = const std::_Rb_tree_node_base*]':
/usr/include/c++/14/bits/stl_tree.h:2543:42:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = int; _Alloc = std::allocator<int>; const_iterator = std::_Rb_tree<int, int, std::_Identity<int>, int, std::allocator<int> >::const_iterator]'
 2543 |       const_iterator __j = _M_lower_bound(_M_begin(), _M_end(), __k);
      |                            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:751:25:   required from 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = int; _Compare = int; _Alloc = std::allocator<int>; size_type = long unsigned int; key_type = int]'
  751 |       { return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
      |                ~~~~~~~~~^~~~~
a.cc:42:42:   required from here
   42 |                         if(tmpx.count(p[i].first && tmpy.count(p[i].second)){
      |                                                     ~~~~~~~~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1964:36: error: expression cannot be used as a function
 1964 |         if (!_M_impl._M_key_compare(_S_key(__x), __k))
      |              ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(_Const_Link_type) [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = int; _Alloc = std::allocator<int>; _Const_Link_type = const std::_Rb_tree_node<int>*]':
/usr/include/c++/14/bits/stl_tree.h:2116:47:   required from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos(const key_type&) [with _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = int; _Alloc = std::allocator<int>; key_type = int]'
 2116 |           __comp = _M_impl._M_key_compare(__k, _S_key(__x));
      |                                                ~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:2169:4:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_unique(_Arg&&) [with _Arg = const int&; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = int; _Alloc = std::allocator<int>]'
 2169 |         = _M_get_insert_unique_pos(_KeyOfValue()(__v));
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bit