func_code_string: #include <bits/stdc++.h>   using namespace std;   using namespace std;   bool solve(int);   int main() {     int test = 0;     while (solve(test++))       ;     return 0;   }   const int N = 100 * 1000 + 5;   const int INF = int(1e9);   int n, b, m;   pair<int, int> a[N];   struct edge {     int to, f, c, rev;   };   const int V = 1000 * 1000 + 3;   vector<edge> g[V];   int lev[V];   int head, tail, q[V];   inline bool bfs(int s, int t) {     memset(lev, 63, sizeof(lev));     head = tail = 0;     lev[s] = 0;     q[head++] = s;     while (head != tail) {       int v = q[tail++];       for (int i = 0; i < int(int(g[v].size())); ++i)         if (g[v][i].f < g[v][i].c && lev[g[v][i].to] > lev[v] + 1) {           lev[g[v][i].to] = lev[v] + 1;           q[head++] = g[v][i].to;         }     }     return lev[t] < INF / 2;   }   inline void add(int from, int to, int c) {     edge f = {to, 0, c, int(g[to].size())};     edge b = {from, 0, 0, int(g[from].size())};     g[from].push_back(f);     g[to].push_back(b);   }   int ptr[V];   int dfs(int v, int t, int f) {     if (v == t) return f;     for (; ptr[v] < int(g[v].size()); ptr[v]++) {       edge& e = g[v][ptr[v]];       if (e.f == e.c || lev[e.to] != lev[v] + 1) continue;       int df = dfs(e.to, t, min(f, e.c - e.f));       if (df > 0) {         e.f += df;         g[e.to][e.rev].f -= df;         return df;       }     }     return 0;   }   inline int dinic(int s, int t) {     int ans = 0;     while (bfs(s, t)) {       memset(ptr, 0, sizeof(ptr));       for (int f; (f = dfs(s, t, INF)) != 0; ans += f)         ;     }     return ans;   }   int cnt5[N][5];   int calc(int r, int rem) { return cnt5[r][rem]; }   bool solve(int) {     if (!(cin >> m >> b >> n)) return false;     for (int i = 0; i < int(n); ++i) {       scanf( %d %d , &a[i].first, &a[i].second);       a[i].first++;     }     a[n++] = pair<int, int>(b + 1, m);     a[n++] = pair<int, int>(1, 0);     int cv = 5;     int S = cv++;     int T = cv++;     for (int i = 0; i < int(5); ++i) add(i, T, m / 5);     for (int i = 0; i < int(N - 1); ++i) {       for (int j = 0; j < int(5); ++j) cnt5[i + 1][j] = cnt5[i][j];       cnt5[i + 1][(i + 1) % 5]++;     }     sort(a, a + n);     for (int i = 0; i < int(n - 1); ++i) {       int lf = a[i].first;       int rg = a[i + 1].first;       int cnt = a[i + 1].second - a[i].second;       if (rg - lf < cnt || cnt < 0) {         puts( unfair );         return true;       }       if (cnt == 0) continue;       int v[5];       for (int i = 0; i < int(5); ++i) {         v[i] = calc(rg - 1, i) - calc(lf - 1, i);         add(cv, i, v[i]);       }       add(S, cv, cnt);       cv++;     }     puts(dinic(S, T) == m ?  fair  :  unfair );     return true;   }   