func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   long long POW(long long a, long long b, long long MMM = MOD) {     long long ret = 1;     for (; b; b >>= 1, a = (a * a) % MMM)       if (b & 1) ret = (ret * a) % MMM;     return ret;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) {     if (a == 0 || b == 0) return a + b;     return a * (b / gcd(a, b));   }   int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};   int ddx[] = {0, 0, 1, 1, 1, -1, -1, -1}, ddy[] = {1, -1, 1, 0, -1, 1, 0, -1};   vector<int> v[2];   vector<pair<int, int> > ans;   int main() {     v[0].push_back(0);     v[1].push_back(0);     int n;     scanf( %d , &n);     for (int(i) = (1); (i) <= (n); (i) += (1)) {       int x;       scanf( %d , &x);       v[x - 1].push_back(i);     }     for (int(t) = (1); (t) <= (n); (t) += (1)) {       int cnt[2] = {0};       int now = 0, last = -1;       while (1) {         int p1 = upper_bound(v[0].begin(), v[0].end(), now) - v[0].begin() - 1;         int p2 = upper_bound(v[1].begin(), v[1].end(), now) - v[1].begin() - 1;         if (p1 + t >= v[0].size() && p2 + t >= v[1].size()) break;         int t1 = 987654321, t2 = 987654321;         if (p1 + t < v[0].size()) t1 = v[0][p1 + t];         if (p2 + t < v[1].size()) t2 = v[1][p2 + t];         if (t1 < t2) {           cnt[0]++;           last = 0;           now = t1;         } else {           cnt[1]++;           last = 1;           now = t2;         }       }       if (now == n) {         if (cnt[0] > cnt[1] && last == 0) ans.push_back(make_pair(cnt[0], t));         if (cnt[0] < cnt[1] && last == 1) ans.push_back(make_pair(cnt[1], t));       }     }     sort(ans.begin(), ans.end());     printf( %d n , ans.size());     for (auto a : ans) printf( %d %d n , a.first, a.second);   }   