func_code_string: #include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > allModify;   class Polygon {    private:     int n;     vector<int> label;     vector<set<int> > adj;     void splitPolygon(Polygon &a, Polygon &b, int x, int y) const {       if (x > y) return (splitPolygon(a, b, y, x));       for (int i = (x), _b = (y); i <= _b; i = i + 1) a.label.push_back(label[i]);       for (int i = (0), _b = (x); i <= _b; i = i + 1) b.label.push_back(label[i]);       for (int i = (y), _b = (n - 1); i <= _b; i = i + 1)         b.label.push_back(label[i]);       a.n = a.label.size();       b.n = b.label.size();       a.adj.assign(a.n, set<int>());       b.adj.assign(b.n, set<int>());       for (int i = 0, _n = (n); i < _n; i = i + 1)         for (__typeof((adj[i]).begin()) it = (adj[i]).begin();              it != (adj[i]).end(); it++) {           int j = *it;           Polygon &cur = (x <= i && i <= y && x <= j && j <= y) ? a : b;           int idi = lower_bound(cur.label.begin(), cur.label.end(), label[i]) -                     cur.label.begin();           int idj = lower_bound(cur.label.begin(), cur.label.end(), label[j]) -                     cur.label.begin();           cur.adj[idi].insert(idj);           cur.adj[idj].insert(idi);         }       int idx, idy;       idx =           lower_bound(a.label.begin(), a.label.end(), label[x]) - a.label.begin();       idy =           lower_bound(a.label.begin(), a.label.end(), label[y]) - a.label.begin();       a.adj[idx].insert(idy);       a.adj[idy].insert(idx);       idx =           lower_bound(b.label.begin(), b.label.end(), label[x]) - b.label.begin();       idy =           lower_bound(b.label.begin(), b.label.end(), label[y]) - b.label.begin();       b.adj[idx].insert(idy);       b.adj[idy].insert(idx);     }     int prevInSet(const set<int> &s, set<int>::iterator it) const {       if (it == s.begin()) it = s.end();       it--;       return (*it);     }     int nextInSet(const set<int> &s, set<int>::iterator it) const {       it++;       if (it == s.end()) it = s.begin();       return (*it);     }     bool haveEdge(int i, int j) const { return (adj[i].find(j) != adj[i].end()); }     pair<int, int> tryChange(int i, set<int>::iterator it) const {       int x = prevInSet(adj[i], it);       int y = nextInSet(adj[i], it);       return (make_pair(x, y));     }     void fixChange(int u, int v, int x, int y) {       adj[u].erase(v);       adj[v].erase(u);       adj[x].insert(y);       adj[y].insert(x);       allModify.push_back(make_pair(label[u], label[v]));     }     void debug(void) const {       printf( POLYGON of %d n , n);       printf( LABEL:  );       for (int i = 0, _n = (n); i < _n; i = i + 1) printf( %d  , label[i]);       printf(  n );       for (int i = 0, _n = (n); i < _n; i = i + 1) {         printf( adj of %d:  , i);         for (__typeof((adj[i]).begin()) it = (adj[i]).begin();              it != (adj[i]).end(); it++)           printf( %d  , *it);         printf(  n );       }       printf( ___END___ n );     }       public:     Polygon() { n = 0; }     Polygon(int n) {       this->n = n;       for (int i = 0, _n = (n); i < _n; i = i + 1) label.push_back(i + 1);       adj.assign(n, set<int>());       for (int i = 0, _n = (n); i < _n; i = i + 1) {         adj[i].insert((i + 1 + n) % n);         adj[i].insert((i - 1 + n) % n);       }     }     void input(void) {       for (int love = 0, _n = (n - 3); love < _n; love = love + 1) {         int x, y;         scanf( %d%d , &x, &y);         x--;         y--;         adj[x].insert(y);         adj[y].insert(x);       }     }     void modify(const Polygon &goal) {       if (n < 4) return;       for (int i = 0, _n = (n); i < _n; i = i + 1)         for (__typeof((adj[i]).begin()) it = (adj[i]).begin();              it != (adj[i]).end(); it++)           if (*it != (i + 1) % n && *it != (i - 1 + n) % n &&               goal.haveEdge(i, *it)) {             int j = *it;             Polygon A, B, goalA, goalB;             splitPolygon(A, B, i, j);             goal.splitPolygon(goalA, goalB, i, j);             A.modify(goalA);             B.modify(goalB);             return;           }       for (int i = 0, _n = (n); i < _n; i = i + 1)         for (__typeof((adj[i]).begin()) it = (adj[i]).begin();              it != (adj[i]).end(); it++)           if (*it != (i + 1) % n && *it != (i - 1 + n) % n) {             pair<int, int> tmp = tryChange(i, it);             if (goal.haveEdge(tmp.first, tmp.second)) {               int j = *it;               fixChange(i, j, tmp.first, tmp.second);               Polygon A, B, goalA, goalB;               splitPolygon(A, B, tmp.first, tmp.second);               goal.splitPolygon(goalA, goalB, tmp.first, tmp.second);               A.modify(goalA);               B.modify(goalB);               return;             }           }       int chs = -1;       for (int i = 0, _n = (n); i < _n; i = i + 1)         if (goal.adj[i].size() < 3)           if (chs < 0 || adj[i].size() < adj[chs].size()) chs = i;       int u = chs;       int x = (u - 1 + n) % n;       int y = (u + 1 + n) % n;       while (adj[u].size() > 2) {         for (__typeof((adj[u]).begin()) it = (adj[u]).begin();              it != (adj[u]).end(); it++)           if (*it != x && *it != y) {             pair<int, int> tmp = tryChange(u, it);             fixChange(u, *it, tmp.first, tmp.second);             break;           }       }       Polygon A, B, goalA, goalB;       splitPolygon(A, B, x, y);       goal.splitPolygon(goalA, goalB, x, y);       A.modify(goalA);       B.modify(goalB);     }   };   void process(void) {     int n;     scanf( %d , &n);     Polygon src(n), des(n);     src.input();     des.input();     src.modify(des);     printf( %d n , (int)allModify.size());     for (__typeof((allModify).begin()) it = (allModify).begin();          it != (allModify).end(); it++)       printf( %d %d n , it->first, it->second);   }   int main(void) {     process();     return 0;   }   