func_code_string: #include <bits/stdc++.h>   template <typename T>   void MACRO_VAR_Scan(T& t) {     std::cin >> t;   }   template <typename First, typename... Rest>   void MACRO_VAR_Scan(First& first, Rest&... rest) {     std::cin >> first;     MACRO_VAR_Scan(rest...);   }   template <typename T>   void MACRO_VEC_ROW_Init(int n, T& t) {     t.resize(n);   }   template <typename First, typename... Rest>   void MACRO_VEC_ROW_Init(int n, First& first, Rest&... rest) {     first.resize(n);     MACRO_VEC_ROW_Init(n, rest...);   }   template <typename T>   void MACRO_VEC_ROW_Scan(int p, T& t) {     std::cin >> t[p];   }   template <typename First, typename... Rest>   void MACRO_VEC_ROW_Scan(int p, First& first, Rest&... rest) {     std::cin >> first[p];     MACRO_VEC_ROW_Scan(p, rest...);   }   template <class T>   inline T CHMAX(T& a, const T b) {     return a = (a < b) ? b : a;   }   template <class T>   inline T CHMIN(T& a, const T b) {     return a = (a > b) ? b : a;   }   template <class T>   using V = std::vector<T>;   template <class T>   using VV = V<V<T>>;   template <typename S, typename T>   std::ostream& operator<<(std::ostream& os, std::pair<S, T> p) {     os <<  (  << p.first <<  ,   << p.second <<  ) ;     return os;   }   using ll = long long;   using ull = unsigned long long;   using ld = long double;   using PAIR = std::pair<ll, ll>;   using PAIRLL = std::pair<ll, ll>;   constexpr ll INFINT = 1 << 30;   constexpr ll INFINT_LIM = (1LL << 31) - 1;   constexpr ll INFLL = 1LL << 60;   constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62);   constexpr double EPS = 1e-6;   constexpr ll MOD = 1000000007;   constexpr double PI = 3.141592653589793238462643383279;   template <class T, size_t N>   void FILL(T (&a)[N], const T& val) {     for (auto& x : a) x = val;   }   template <class ARY, size_t N, size_t M, class T>   void FILL(ARY (&a)[N][M], const T& val) {     for (auto& b : a) FILL(b, val);   }   template <class T>   void FILL(std::vector<T>& a, const T& val) {     for (auto& x : a) x = val;   }   template <class ARY, class T>   void FILL(std::vector<std::vector<ARY>>& a, const T& val) {     for (auto& b : a) FILL(b, val);   }   struct Trie {     std::vector<std::vector<ll>> g;     ll p;     Trie() : p(0) {       g.emplace_back(std::vector<ll>(2, -1));       ++p;     }     void add(const std::string& s) {       size_t par = 0;       for (size_t i = 0; i < s.size(); ++i) {         ll t = s[i] -  0 ;         if (g[par][t] == -1) {           g.emplace_back(std::vector<ll>(2, -1));           g[par][t] = p++;         }         par = g[par][t];       }     }     ll next(size_t par, char c) {       ll t = c -  0 ;       return g[par][t];     }   };   bool ng(std::string s) {     return s ==  1100  || s ==  1010  || s ==  0111  || s ==  1111 ;   }   signed main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     ;     ll n;     MACRO_VAR_Scan(n);     ;     std::string s;     for (ll i = 0; i < ll(n); ++i) {       char c;       MACRO_VAR_Scan(c);       ;       s += c;     }     Trie tr;     std::vector<ll> c(n, 0);     for (ll i = 0; i < ll(n); ++i) {       auto S = s.substr(0, i + 1);       std::reverse((S).begin(), (S).end());       std::vector<ll> dp(S.size() + 1, 0);       dp[0] = 1;       for (ll j = 0; j < ll(S.size()); ++j) {         for (ll k = 0; k < ll(4); ++k) {           if (j < k) break;           if (k == 3) {             if (ng(S.substr(j - 3, 4))) continue;           }           (dp[j + 1] += dp[j - k]) %= MOD;         }       }       ll p = 0;       ll len = 0;       for (ll j = 0; j < ll(S.size()); ++j) {         ll ne = tr.next(p, S[j]);         if (ne == -1) break;         p = ne;         dp[++len] = 0;       }       tr.add(S);       for (ll j = (1); j < (S.size() + 1); ++j) {         (c[i] += dp[j]) %= MOD;       }     }     for (ll i = 0; i < ll(n - 1); ++i) (c[i + 1] += c[i]) %= MOD;     for (ll i = 0; i < ll(n); ++i) {       std::cout << (c[i]);       std::cout <<   n ;       ;     }     return 0;   }   