func_code_string: #include <bits/stdc++.h>   using namespace std;   struct Comm {     int first;     int second;     Comm(int a, int b) {       first = a;       second = b;     }     bool operator<(const Comm& other) const {       if (this->first == other.first) return this->second < other.second;       return this->first < other.first;     }   };   vector<int> P;   vector<int> G;   vector<Comm> ans;   int n;   int main() {     int x, scoP = 0, scoG = 0;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &x);       if (x == 1)         scoP++;       else         scoG++;       P.push_back(scoP);       G.push_back(scoG);     }     int pntP = 0, pntG = 0, setP = 0, setG = 0;     int maxPoint = max(scoP, scoG);     for (int i = maxPoint; i > 0; i--) {       int tar1 = i, tar2 = i;       int pos = 0;       setP = setG = pntG = pntP = 0;       while (pos < n && !(pntG == pntP && pntG == n)) {         pntP = lower_bound(P.begin() + pos, P.end(), tar1) - P.begin();         pntG = lower_bound(G.begin() + pos, G.end(), tar2) - G.begin();         if (pntP < pntG) {           setP++;           pos = pntP + 1;           tar1 = P[pntP] + i;           tar2 = G[pntP] + i;         }         if (pntP > pntG) {           setG++;           pos = pntG + 1;           tar1 = P[pntG] + i;           tar2 = G[pntG] + i;         }       }       int tmp = max(setG, setP);       if (tmp == setG && x == 1 || tmp == setP && x == 2 || setG == setP ||           pntG == pntP && pntG == n) {         continue;       }       Comm m(tmp, i);       ans.push_back(m);     }     printf( %d n , ans.size());     sort(ans.begin(), ans.end());     for (int i = 0; i < ans.size(); i++) {       printf( %d %d n , ans[i].first, ans[i].second);     }     return 0;   }   