func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long inf = 0x3f3f3f3f3f3f3f3f;   const long long N = 5000;   long long n, m, s, t;   vector<pair<long long, long long> > nei[N + 1];   vector<long long> rv[N + 1];   void ae(long long x, long long y, long long z) {     nei[x].push_back(make_pair(y, z)), nei[y].push_back(make_pair(x, 0));     rv[x].push_back(nei[y].size() - 1), rv[y].push_back(nei[x].size() - 1);   }   long long dep[N + 1];   bool bfs() {     memset(dep, -1, sizeof(dep));     dep[s] = 0;     queue<long long> q;     q.push(s);     while (q.size()) {       long long x = q.front();       q.pop();       for (long long i = 0; i < nei[x].size(); i++) {         long long y = nei[x][i].first, c = nei[x][i].second;         if (c && !~dep[y]) dep[y] = dep[x] + 1, q.push(y);       }     }     return ~dep[t];   }   long long now[N + 1];   long long dfs(long long x = s, long long flw = inf) {     if (x == t || !flw) return flw;     long long res = 0, tmp;     for (long long &i = now[x]; i < nei[x].size(); i++) {       long long y = nei[x][i].first, &c = nei[x][i].second;       if (dep[y] == dep[x] + 1 && (tmp = dfs(y, min(flw, c)))) {         res += tmp, flw -= tmp;         c -= tmp, nei[y][rv[x][i]].second += tmp;         if (!flw) break;       }     }     return res;   }   long long dinic() {     long long res = 0;     while (bfs()) {       memset(now, 0, sizeof(now));       res += dfs();     }     return res;   }   long long a[N], b[N], c[N], d[N];   vector<long long> nums_x, nums_y;   void discrete() {     sort(nums_x.begin(), nums_x.end()), sort(nums_y.begin(), nums_y.end());     nums_x.resize(unique(nums_x.begin(), nums_x.end()) - nums_x.begin());     nums_y.resize(unique(nums_y.begin(), nums_y.end()) - nums_y.begin());     for (long long i = 1; i <= n; i++)       a[i] = lower_bound(nums_x.begin(), nums_x.end(), a[i] - 1) -              nums_x.begin() + 1,       b[i] = lower_bound(nums_y.begin(), nums_y.end(), b[i] - 1) -              nums_y.begin() + 1,       c[i] = lower_bound(nums_x.begin(), nums_x.end(), c[i]) - nums_x.begin(),       d[i] = lower_bound(nums_y.begin(), nums_y.end(), d[i]) - nums_y.begin();   }   long long row[N], col[N];   signed main() {     cin >> m >> n;     for (long long i = 1; i <= n; i++) {       cin >> a[i] >> b[i] >> c[i] >> d[i];       nums_x.push_back(a[i] - 1), nums_x.push_back(c[i]);       nums_y.push_back(b[i] - 1), nums_y.push_back(d[i]);     }     discrete();     s = 1, t = 2;     long long now = 2;     for (long long i = 1; i < nums_x.size(); i++)       row[i] = ++now, ae(s, now, nums_x[i] - nums_x[i - 1]);     for (long long i = 1; i < nums_y.size(); i++)       col[i] = ++now, ae(now, t, nums_y[i] - nums_y[i - 1]);     for (long long i = 1; i <= n; i++) {       for (long long j = a[i]; j <= c[i]; j++)         for (long long k = b[i]; k <= d[i]; k++) ae(row[j], col[k], inf);     }     cout << dinic();     return 0;   }   