func_code_string: #include <bits/stdc++.h>   using namespace std;   template <ostream& out = cout, class... T>   void prints(T&&...) {}   template <ostream& out = cout, class... T>   void printe(T&&...) {}   template <ostream& out = cout, class... T>   void printw(T&&...) {}   template <ostream& out = cout, class... T>   void printew(T&&...) {}   template <ostream& out = cout, class... T>   void printb(T&&...) {}   template <ostream& out = cout, class... T>   void printd(T&&...) {}   template <ostream& out = cout, class... T>   void printde(T&&...){};   template <class T>   istream& operator>>(istream& in, vector<T>& v) {     for (auto& e : v) {       in >> e;     }     return in;   }   int main() {     int n;     cin >> n;     vector<char> s(n);     cin >> s;     int k = 0;     bool pr;     for (int i = 0; i < n; i++) {       if (s[i] ==  1 ) {         k++;         pr = true;       } else {         break;       }     }     if (k == n) {       cout <<  YES ;       return 0;     }     int l = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  0 ) {         l++;         pr = false;       } else {         break;       }     }     if (l == n) {       cout <<  YES ;       return 0;     }     int m;     m = max(l, k);     for (int i = 0; i < n; i = i + m) {       if (s[i] ==  1  && pr) {         for (int j = 0; j < m; j++) {           if (s[j + i] !=  1 ) {             cout <<  NO ;             return 0;           }         }         pr = false;         continue;       }       if (s[i] ==  0  && !pr) {         for (int j = 0; j < m; j++) {           if (s[j + i] !=  0 ) {             cout <<  NO ;             return 0;           }         }         pr = true;         continue;       }       cout <<  NO ;       return 0;     }     cout <<  YES ;   }   