Language: C++

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <math.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
#define int ll
#define INF (1LL<<60)
#define mod 1000000007
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };


// 行き先、容量、逆辺
struct edge{
	int to, cap, rev;
};

const int MAX_V = 100000;
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap){
	edge e1{ to, cap, G[to].size() };
	G[from].push_back(e1);
	edge e2{ from, 0, G[from].size() - 1};
	G[to].push_back( e2);
}

void bfs(int s){
	memset(level, -1, sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while (!que.empty()){
		int v = que.front(); que.pop();
		for (int i = 0; i < G[v].size(); i++){
			edge &e = G[v][i];
			if (e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int f){
	if (v == t) return f;
	for (int &i = iter[v]; i < G[v].size(); i++){
		edge &e = G[v][i];
		if (e.cap>0 && level[v] < level[e.to]){
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for (;;){
		bfs(s);
		if (level[t] < 0) return flow;
		memset(iter, 0, sizeof(iter));
		int f;
		while ((f = dfs(s, t, INF)) > 0)
			flow += f;
	}
}




int N;
const int MAX_N = 100;
int a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N];

bool g[MAX_N][MAX_N];

signed main(){

	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i] >> b[i];
	for (int i = 0; i < N; i++)
		cin >> c[i] >> d[i];

	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			if (a[i] < c[j] && b[i] < d[j])
				g[i][j] = true;
		}
	}

	int s = 2 * N, t = s + 1;
	for (int i = 0; i < N; i++)
		add_edge(s, i, 1);

	for (int i = 0; i < N; i++)
		add_edge(N + i, t, 1);

	for (int i = 0; i < N; i++){
		for (int j = 0; j < N; j++){
			if (g[i][j])
				add_edge(i, N + j, 1);
		}
	}

	cout << max_flow(s, t) << endl;

	return 0;
}


Compiler output:
a.cc: In function 'void add_edge(long long int, long long int, long long int)':
a.cc:36:37: warning: narrowing conversion of 'G[to].std::vector<edge>::size()' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'long long int' [-Wnarrowing]
   36 |         edge e1{ to, cap, G[to].size() };
      |                           ~~~~~~~~~~^~
a.cc:38:42: warning: narrowing conversion of '(G[from].std::vector<edge>::size() - 1)' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'long long int' [-Wnarrowing]
   38 |         edge e2{ from, 0, G[from].size() - 1};
      |                           ~~~~~~~~~~~~~~~^~~
a.cc: In function 'void bfs(long long int)':
a.cc:43:9: error: 'memset' was not declared in this scope
   43 |         memset(level, -1, sizeof(level));
      |         ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include <math.h>
  +++ |+#include <cstring>
   14 | using namespace std;
a.cc: In function 'long long int max_flow(long long int, long long int)':
a.cc:80:17: error: 'memset' was not declared in this scope
   80 |                 memset(iter, 0, sizeof(iter));
      |                 ^~~~~~
a.cc:80:17: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'