Language: C++

#include <bits/stdc++.h>

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