func_code_string: #include <bits/stdc++.h>   using namespace std;   struct option {     int s;     int t;     bool operator<(const option &next) const {       if (this->s == next.s)         return this->t < next.t;       else         return this->s < next.s;     }   };   vector<int> num1;   vector<int> num2;   vector<option> oLis;   int n, sum1, sum2;   int winner;   bool solve(int);   int main() {     scanf( %d , &n);     int a;     sum1 = 0;     sum2 = 0;     for (int i = 0; i < n; i++) {       scanf( %d , &a);       if (a == 1)         sum1++;       else         sum2++;       if (i == n - 1) winner = a;       num1.push_back(sum1);       num2.push_back(sum2);     }     if (sum1 == sum2) {       printf( 0 n );       return 0;     }     int sum = sum1 > sum2 ? sum1 : sum2;     for (int i = 1; i <= sum; i++) solve(i);     sort(oLis.begin(), oLis.end());     printf( %d n , oLis.size());     for (int i = 0; i < (int)oLis.size(); i++)       printf( %d %d n , oLis[i].s, oLis[i].t);     return 0;   }   bool solve(int x) {     int tmp1, tmp2;     int pos1, pos2;     int score1, score2;     bool flag = true;     pos1 = 0;     pos2 = 0;     score1 = 0;     score2 = 0;     for (int i = 0; i < n; i++) {       tmp1 = lower_bound(num1.begin(), num1.end(), pos1 + x) - num1.begin();       tmp2 = lower_bound(num2.begin(), num2.end(), pos2 + x) - num2.begin();       if (tmp1 != n || tmp2 != n) {         if (tmp1 < tmp2) {           score1++;           pos1 = num1[tmp1];           pos2 = num2[tmp1];         } else {           score2++;           pos1 = num1[tmp2];           pos2 = num2[tmp2];         }       } else {         tmp1 = tmp2 = n - 1;         if (num1[tmp1] != pos1 || num2[tmp2] != pos2) flag = false;         break;       }     }     if (flag) {       if ((winner == 1 && score2 > score1) || (winner == 2 && score1 > score2) ||           (score1 == score2))         return false;       option tem;       tem.s = score1 > score2 ? score1 : score2;       tem.t = x;       oLis.push_back(tem);       return true;     }     return false;   }   