Language: C++

#include<iostream>
#include<map>
#include<set>
#include<vector>
typedef pair<int, int> pii;
using namespace std;
int main()
{
    int H, W, M;
    const int maxn = 3e5;
    cin >> H >> W >> M;
    int result = 0;
    int List[maxn][2];
    map<int, int> list_x, list_y;
    set<pii> match, column, row;

    //input and record
    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> y >> x;
        List[i][0] = x; List[i][1] = y;
        if (list_x.count(x) != 0)list_x[x]++;
        else list_x[x] = 1;
        if (list_y.count(y) != 0)list_y[y]++;
        else list_y[y] = 1;
        match.insert(make_pair(y, x));
    }
    // using set  to do a value sort
    for (int i = 1; i <= H; i++)
    {
        row.insert(make_pair(list_y[i], i));
    }
    for (int i = 1; i <= W; i++)
    {
        column.insert(make_pair(list_x[i], i));
    }
    int max_column_number = row.end()->second;
    int max_row_number = column.end()->second;
    vector<int> maxcolumn, maxrow;
    for (set<pii>::iterator it = row.end(); it != row.begin(); it--)
    {
        if (it->first == max_column_number)
        {
            maxrow.push_back(it->second);
        }
        else break;
    }
    for (set<pii>::iterator it = column.end(); it != column.begin(); it--)
    {
        if (it->first == max_row_number)
        {
            maxcolumn.push_back(it->second);
        }
        else break;
    }
    for(int i=0;i<maxcolumn.size();i++)
    {
        for (int j = 0; j < maxrow.size(); j++)
        {
            pii m = make_pair(maxrow[i], maxcolumn[j]);
            if (match.find(m) == match.end())
            {
                cout<< max_column_number + max_row_number;
                return 0;
            }
        }
    }
    cout<< max_column_number + max_row_number - 1;

   



         
    return 0;
}

Compiler output:
a.cc:5:9: error: 'pair' does not name a type
    5 | typedef pair<int, int> pii;
      |         ^~~~
a.cc: In function 'int main()':
a.cc:15:9: error: 'pii' was not declared in this scope
   15 |     set<pii> match, column, row;
      |         ^~~
a.cc:15:12: error: template argument 1 is invalid
   15 |     set<pii> match, column, row;
      |            ^
a.cc:15:12: error: template argument 2 is invalid
a.cc:15:12: error: template argument 3 is invalid
a.cc:27:15: error: request for member 'insert' in 'match', which is of non-class type 'int'
   27 |         match.insert(make_pair(y, x));
      |               ^~~~~~
a.cc:32:13: error: request for member 'insert' in 'row', which is of non-class type 'int'
   32 |         row.insert(make_pair(list_y[i], i));
      |             ^~~~~~
a.cc:36:16: error: request for member 'insert' in 'column', which is of non-class type 'int'
   36 |         column.insert(make_pair(list_x[i], i));
      |                ^~~~~~
a.cc:38:33: error: request for member 'end' in 'row', which is of non-class type 'int'
   38 |     int max_column_number = row.end()->second;
      |                                 ^~~
a.cc:39:33: error: request for member 'end' in 'column', which is of non-class type 'int'
   39 |     int max_row_number = column.end()->second;
      |                                 ^~~
a.cc:41:17: error: template argument 2 is invalid
   41 |     for (set<pii>::iterator it = row.end(); it != row.begin(); it--)
      |                 ^
a.cc:41:17: error: template argument 3 is invalid
a.cc:41:28: error: expected ';' before 'it'
   41 |     for (set<pii>::iterator it = row.end(); it != row.begin(); it--)
      |                            ^~~
      |                            ;
a.cc:41:29: error: 'it' was not declared in this scope; did you mean 'int'?
   41 |     for (set<pii>::iterator it = row.end(); it != row.begin(); it--)
      |                             ^~
      |                             int
a.cc:41:38: error: request for member 'end' in 'row', which is of non-class type 'int'
   41 |     for (set<pii>::iterator it = row.end(); it != row.begin(); it--)
      |                                      ^~~
a.cc:41:55: error: request for member 'begin' in 'row', which is of non-class type 'int'
   41 |     for (set<pii>::iterator it = row.end(); it != row.begin(); it--)
      |                                                       ^~~~~
a.cc:41:62: error: expected ')' before ';' token
   41 |     for (set<pii>::iterator it = row.end(); it != row.begin(); it--)
      |         ~                                                    ^
      |                                                              )
a.cc:41:64: error: 'it' was not declared in this scope; did you mean 'int'?
   41 |     for (set<pii>::iterator it = row.end(); it != row.begin(); it--)
      |                                                                ^~
      |                                                                int
a.cc:49:17: error: template argument 2 is invalid
   49 |     for (set<pii>::iterator it = column.end(); it != column.begin(); it--)
      |                 ^
a.cc:49:17: error: template argument 3 is invalid
a.cc:49:28: error: expected ';' before 'it'
   49 |     for (set<pii>::iterator it = column.end(); it != column.begin(); it--)
      |                            ^~~
      |                            ;
a.cc:49:41: error: request for member 'end' in 'column', which is of non-class type 'int'
   49 |     for (set<pii>::iterator it = column.end(); it != column.begin(); it--)
      |                                         ^~~
a.cc:49:61: error: request for member 'begin' in 'column', which is of non-class type 'int'
   49 |     for (set<pii>::iterator it = column.end(); it != column.begin(); it--)
      |                                                             ^~~~~
a.cc:49:68: error: expected ')' before ';' token
   49 |     for (set<pii>::iterator it = column.end(); it != column.begin(); it--)
      |         ~                                                          ^
      |                                                                    )
a.cc:61:16: error: expected ';' before 'm'
   61 |             pii m = make_pair(maxrow[i], maxcolumn[j]);
      |                ^~
      |                ;
a.cc:62:23: error: request for member 'find' in 'match', which is of non-class type 'int'
   62 |             if (match.find(m) == match.end())
      |                       ^~~~
a.cc:62:28: error: 'm' was not declared in this scope
   62 |             if (match.find(m) == match.end())
      |                            ^
a.cc:62:40: error: request for member 'end' in 'match', which is of non-class type 'int'
   62 |             if (match.find(m) == match.end())
      |                                        ^~~