Language: C++

#include<iostream>
#include<stdio.h>
#include<string>
#include<stack>
#include<string.h>
using namespace std;
int main(){
    int H,W,M;
    cin >> H;
    cin >> W;
    cin >> M;
    map<pair<int,int>,int> C;
    map<int,int> x_var;
    map<int,int> y_var;
    for(int i=0;i<M;i++){
        int x,y;
        cin >> x;
        cin >> y;
        x_var[x-1]++;
        y_var[y-1]++;
        C[make_pair(x-1,y-1)]++;
    }
    vector<int> x_vec(H);
    vector<int> y_vec(W);
    map<int,int> :: iterator it;
    int max_x=0;
    int max_y=0;
    for(it=x_var.begin();it!=x_var.end();it++){
        if(it->second > max_x){
            max_x=it->second;
            x_vec.clear();
            x_vec.push_back(it->first);
        }
        else if(it->second == max_x){
            x_vec.push_back(it->first);
        }
    }
    for(it=y_var.begin();it!=y_var.end();it++){
        if(it->second > max_y){
            max_y=it->second;
            y_vec.clear();
            y_vec.push_back(it->first);
        }
        else if(it->second == max_y){
            y_vec.push_back(it->first);
        }
    }
    int total=max_x+max_y-1;
    for(int i=0;i<x_vec.size();i++){
        for(int j=0;j<y_vec.size();j++){
            if(C[make_pair(x_vec[i],y_vec[j])] == 0){
                cout << total+1 << endl;
                return 0;
            }
        }
    }
    cout << total << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:5: error: 'map' was not declared in this scope
   12 |     map<pair<int,int>,int> C;
      |     ^~~
a.cc:6:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>'
    5 | #include<string.h>
  +++ |+#include <map>
    6 | using namespace std;
a.cc:12:22: error: expected primary-expression before ',' token
   12 |     map<pair<int,int>,int> C;
      |                      ^
a.cc:12:23: error: expected primary-expression before 'int'
   12 |     map<pair<int,int>,int> C;
      |                       ^~~
a.cc:13:9: error: expected primary-expression before 'int'
   13 |     map<int,int> x_var;
      |         ^~~
a.cc:14:9: error: expected primary-expression before 'int'
   14 |     map<int,int> y_var;
      |         ^~~
a.cc:19:9: error: 'x_var' was not declared in this scope
   19 |         x_var[x-1]++;
      |         ^~~~~
a.cc:20:9: error: 'y_var' was not declared in this scope
   20 |         y_var[y-1]++;
      |         ^~~~~
a.cc:21:9: error: 'C' was not declared in this scope
   21 |         C[make_pair(x-1,y-1)]++;
      |         ^
a.cc:23:5: error: 'vector' was not declared in this scope
   23 |     vector<int> x_vec(H);
      |     ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include<string.h>
  +++ |+#include <vector>
    6 | using namespace std;
a.cc:23:12: error: expected primary-expression before 'int'
   23 |     vector<int> x_vec(H);
      |            ^~~
a.cc:24:12: error: expected primary-expression before 'int'
   24 |     vector<int> y_vec(W);
      |            ^~~
a.cc:25:9: error: expected primary-expression before 'int'
   25 |     map<int,int> :: iterator it;
      |         ^~~
a.cc:28:9: error: 'it' was not declared in this scope; did you mean 'int'?
   28 |     for(it=x_var.begin();it!=x_var.end();it++){
      |         ^~
      |         int
a.cc:28:12: error: 'x_var' was not declared in this scope
   28 |     for(it=x_var.begin();it!=x_var.end();it++){
      |            ^~~~~
a.cc:31:13: error: 'x_vec' was not declared in this scope
   31 |             x_vec.clear();
      |             ^~~~~
a.cc:35:13: error: 'x_vec' was not declared in this scope
   35 |             x_vec.push_back(it->first);
      |             ^~~~~
a.cc:38:9: error: 'it' was not declared in this scope; did you mean 'int'?
   38 |     for(it=y_var.begin();it!=y_var.end();it++){
      |         ^~
      |         int
a.cc:38:12: error: 'y_var' was not declared in this scope
   38 |     for(it=y_var.begin();it!=y_var.end();it++){
      |            ^~~~~
a.cc:41:13: error: 'y_vec' was not declared in this scope
   41 |             y_vec.clear();
      |             ^~~~~
a.cc:45:13: error: 'y_vec' was not declared in this scope
   45 |             y_vec.push_back(it->first);
      |             ^~~~~
a.cc:49:19: error: 'x_vec' was not declared in this scope
   49 |     for(int i=0;i<x_vec.size();i++){
      |                   ^~~~~
a.cc:50:23: error: 'y_vec' was not declared in this scope
   50 |         for(int j=0;j<y_vec.size();j++){
      |                       ^~~~~
a.cc:51:16: error: 'C' was not declared in this scope
   51 |             if(C[make_pair(x_vec[i],y_vec[j])] == 0){
      |                ^