malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long t1, t2, x1, x2, t0, ans1, ans2, z1, z2, y20;   inline void trr(const long long& y1_gdssdfjsdgf, const long long& y2) {     if (y1_gdssdfjsdgf == 0 && y2 == 0) return;     if (ans1 == -1) {       if ((y1_gdssdfjsdgf * t1 + y2 * t2) >= t0 * (y1_gdssdfjsdgf + y2)) {         ans1 = y1_gdssdfjsdgf;         ans2 = y2;       }       return;     }     z1 = (ans1 * t1 + ans2 * t2) * (y1_gdssdfjsdgf + y2) -          t0 * (y1_gdssdfjsdgf + y2) * (ans1 + ans2);     z2 = (y1_gdssdfjsdgf * t1 + y2 * t2) * (ans1 + ans2) -          t0 * (y1_gdssdfjsdgf + y2) * (ans1 + ans2);     if ((z1 >= 0 && z2 >= 0) &&         (z1 > z2 || ((z1 == z2) && (y1_gdssdfjsdgf + y2 > ans1 + ans2)))) {       ans1 = y1_gdssdfjsdgf;       ans2 = y2;     }   }   int main() {     cin >> t1 >> t2 >> x1 >> x2 >> t0;     ans1 = -1;     ans2 = -1;     trr(0, x2);     trr(x1, 0);     trr(x1, x2);     for (long long y1_gdssdfjsdgf = 0; y1_gdssdfjsdgf <= x1; y1_gdssdfjsdgf++)       if (t2 != t0) {         y20 = ((t0 - t1) * y1_gdssdfjsdgf) / (t2 - t0);         for (long long y2 = max(0LL, y20 - 2); y2 <= min(x2, y20 + 2); y2++) {           trr(y1_gdssdfjsdgf, y2);         }       }     cout << ans1 <<     << ans2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e3 + 10;   const int mod = 998244353;   int f[N][N], g[N][N];   int mn[N][N], indl[N], indr[N];   bool bz[N][N];   int a[1000001];   int n, m;   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= m; i++) scanf( %d , &a[i]);     int x = m;     m = 1;     for (int i = 2; i <= x; i++)       if (a[i] != a[m]) a[++m] = a[i];     for (int i = 1; i <= m; i++) {       if (!indl[a[i]]) indl[a[i]] = i;       indr[a[i]] = i;     }     if (m > 3 * n) {       printf( 0 n );       return 0;     }     for (int i = 1; i <= n; i++)       for (int j = indl[i]; j <= indr[i]; j++)         if (a[j] < i) {           printf( 0 n );           return 0;         }     for (int i = 1; i <= m; i++) {       mn[i][i] = a[i];       for (int j = i + 1; j <= m; j++) mn[i][j] = min(mn[i][j - 1], a[j]);     }     for (int i = 1; i <= m + 1; i++) f[i][i - 1] = g[i][i - 1] = 1;     for (int i = 1; i <= m; i++)       for (int l = 1; l + i - 1 <= m; l++) {         int r = i + l - 1;         int x = mn[l][r], idl = indl[x], idr = indr[x];         if (idl > r || idr < l) continue;         int v = 1;         int lll = idl;         while (lll != idr) {           int rrr = lll + 1;           while (a[rrr] != a[lll]) rrr++;           v = (long long)v * f[lll + 1][rrr - 1] % mod;           lll = rrr;         }         for (int mid = idr; mid <= r; mid++)           g[l][r] = (g[l][r] + (long long)f[l][idl - 1] * f[mid + 1][r] % mod *                                    v % mod * f[idr + 1][mid] % mod) %                     mod;         for (int ll = l; ll <= idl; ll++)           f[l][r] = (f[l][r] + (long long)g[ll][r] * f[l][ll - 1]) % mod;       }     printf( %d n , f[1][m]);     return 0;   }
#include <bits/stdc++.h>   int a[300004], pos[300004];   using namespace std;   int main() {     int n, temp;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       pos[a[i]] = i;     }     bool flag = false;     for (int i = 1; i <= n && !flag; i++)       for (int j = i + 1; j <= min(n, i + 5) && !flag; j++) {         temp = 2 * a[j] - a[i];         if (temp <= n && temp > 0 && pos[temp] > j) flag = 1;         temp = 2 * a[i] - a[j];         if (temp <= n && temp > 0 && pos[temp] < i) flag = 1;       }     if (flag)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
/*   ID: c4ts0up   LANG: C++   TASK:    URL:    */      #include <bits/stdc++.h>   using namespace std;      typedef long long ll;   typedef long double ld;   #define pb push_back   #define ff first   #define ss second   #define endl   n       void fast_io() {       ios_base::sync_with_stdio(false);       cin.tie(NULL);   }      const ll MOD = 1e9+7, NMAX = 1005;   ll t, n, k;      ll dp[NMAX][NMAX][2];   bool vis[NMAX][NMAX][2];      // devuelve la cantidad de particulas generadas por esta   ll Generadas(ll tam, ll pla, bool dir) {       // Caso base       if (tam == 1) return 1LL;       else if (pla < 0 || pla >= n) return 1LL;       // Caso dp       else if (vis[tam][pla][dir]) return dp[tam][pla][dir];       // Caso recursivo       else {           if (dir) dp[tam][pla][dir] = (Generadas(tam-1, pla-1, !dir) + Generadas(tam, pla+1, dir))%MOD;           else dp[tam][pla][dir] = (Generadas(tam-1, pla+1, !dir) + Generadas(tam, pla-1, dir))%MOD;              vis[tam][pla][dir] = true;           return dp[tam][pla][dir];       }   }      int main() {       /*//       freopen( entrada.in ,  r , stdin);       freopen( salida.out ,  w , stdout);       //*/          cin >> t;       while (t--) {           cin >> n >> k;           for (int i=0; i<=n; i++) {               for (int j=0; j<=k; j++) vis[j][i][0] = vis[j][i][1] = false;            }           cout << Generadas(k, 0, 1) << endl;       }       //system( pause );       return 0;   }
#include <bits/stdc++.h>   std::string colors( RGBYW );   struct Card {     int color;     int number;     bool operator<(const Card& rhs) const {       if (color == rhs.color)         return (number < rhs.number);       else         return color < rhs.color;     }   };   int mapColor(char color) {     size_t pos = colors.find_first_of(color);     if (pos != std::string::npos) {       return pos;     }     return -1;   }   bool isNumberHinted(int number, long long hint) {     long long mask = (1 << number) << 5;     return hint & mask;   }   bool isColorHinted(int color, long long hint) {     long long mask = (1 << color);     return hint & mask;   }   int bitCount(long long n) {     int count = 0;     while (n > 0) {       count++;       n = n & (n - 1);     }     return count;   }   void codeforces442a() {     int n = 0;     int minAns = 10;     std::cin >> n;     std::set<Card> cards;     for (int i = 0; i < n; ++i) {       Card card;       char color;       char number;       std::cin >> color;       std::cin >> number;       card.color = mapColor(color);       card.number = number -  1 ;       cards.insert(card);     }     if (cards.size() == 1) {       std::cout <<  0 ;       return;     }     for (long long hint = 0; hint < (1 << 10); ++hint) {       if (bitCount(hint) >= minAns) continue;       bool isValid = true;       for (std::set<Card>::iterator i = cards.begin();            i != cards.end() && isValid; ++i)         for (std::set<Card>::iterator j = cards.begin();              j != cards.end() && isValid; ++j) {           if (i != j) {             bool areHintedAsDifferent = false;             Card firstCard = *i;             Card secondCard = *j;             if (firstCard.color == secondCard.color) {               areHintedAsDifferent = isNumberHinted(firstCard.number, hint) ||                                      isNumberHinted(secondCard.number, hint);             } else if (firstCard.number == secondCard.number) {               areHintedAsDifferent = isColorHinted(firstCard.color, hint) ||                                      isColorHinted(secondCard.color, hint);             } else {               areHintedAsDifferent = isNumberHinted(firstCard.number, hint) ||                                      isNumberHinted(secondCard.number, hint) ||                                      isColorHinted(firstCard.color, hint) ||                                      isColorHinted(secondCard.color, hint);             }             if (!areHintedAsDifferent) {               isValid = false;             }           }         }       if (isValid) {         int numHints = bitCount(hint);         if (minAns > numHints) {           minAns = numHints;         }       }     }     std::cout << minAns;   }   int main() {     codeforces442a();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a, b, m[1001][1001];   void solve() {     cin >> n >> a >> b;     if (a > 1 and b > 1) {       cout <<  NO  <<   n ;       return;     }     if (a == 1 and b == 1) {       if (n == 1) {         cout <<  YES  <<   n ;         cout << 0;         return;       }       if (n <= 3) {         cout <<  NO  <<   n ;         return;       }       for (int i = 1; i < n; i++) {         m[i][i + 1] = 1;         m[i + 1][i] = 1;       }       cout <<  YES  <<   n ;       for (int i = 1; i < n + 1; i++) {         for (int j = 1; j < n + 1; j++) {           cout << m[i][j];         }         cout <<   n ;       }       return;     }     if (a == 1) {       for (int i = 1; i < b; i++) {         for (int j = 1; j < n + 1; j++) {           if (i == j) continue;           m[i][j] = 1;           m[j][i] = 1;         }       }       cout <<  YES  <<   n ;       for (int i = 1; i < n + 1; i++) {         for (int j = 1; j < n + 1; j++) {           cout << m[i][j];         }         cout <<   n ;       }       return;     }     if (b == 1) {       for (int i = a; i < n + 1; i++) {         for (int j = a; j < n + 1; j++) {           if (i == j) continue;           m[i][j] = 1;           m[j][i] = 1;         }       }       cout <<  YES  <<   n ;       for (int i = 1; i < n + 1; i++) {         for (int j = 1; j < n + 1; j++) {           cout << m[i][j];         }         cout <<   n ;       }       return;     }   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1010;   const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};   long long k;   int n, m, h[N][N];   bool mark[N][N];   int pre[N * N], sz[N * N];   int find(int x) { return pre[x] = (pre[x] == x ? x : find(pre[x])); }   bool merge(int x, int y) {     int a = find(x), b = find(y);     if (a == b) return false;     if (rand() % 2) swap(a, b);     sz[b] += sz[a];     pre[a] = b;     return true;   }   inline int id(int i, int j) { return i * m + j; }   int res[N][N];   void dfs(int i, int j, int v) {     if (i < 0 || i >= n || j < 0 || j >= m || h[i][j] < v) return;     if (res[i][j] || !k) return;     res[i][j] = v;     k -= v;     for (int d = 0; d < 4; d++) {       int ni = i + di[d], nj = j + dj[d];       dfs(ni, nj, v);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m >> k;     vector<tuple<int, int, int>> pos;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         pre[id(i, j)] = id(i, j);         sz[id(i, j)] = 1;         cin >> h[i][j];         pos.emplace_back(h[i][j], i, j);       }     sort(pos.rbegin(), pos.rend());     bool good = false;     for (auto p : pos) {       int v, i, j;       tie(v, i, j) = p;       for (int d = 0; d < 4; d++) {         int ni = i + di[d], nj = j + dj[d];         if (ni < 0 || ni >= n || nj < 0 || nj >= m || !mark[ni][nj]) continue;         merge(id(i, j), id(ni, nj));       }       mark[i][j] = true;       if (k % v == 0 && k / v <= sz[find(id(i, j))]) {         dfs(i, j, h[i][j]);         good = true;         break;       }     }     if (good) {       cout <<  YES n ;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) cout << res[i][j] <<    ;         cout <<   n ;       }     } else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int ans, n, m, x, y;     cin >> n >> m;     int lo = (n + 1) / 2;     ans = (lo + m - 1) / m;     ans *= m;     if (ans > n)       cout << -1 << endl;     else       cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, dp[1 << 19][21], a[22][22], ans;   long long lowbit(long long x) { return (x & (-x)); }   int main() {     memset(a, 0, sizeof(a));     memset(dp, 0, sizeof(dp));     scanf( %lld%lld , &n, &m);     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       a[x - 1][y - 1] = a[y - 1][x - 1] = 1;     }     for (int i = 0; i <= n; i++) dp[1 << i][i] = 1;     for (int mask = 1; mask < (1 << n); mask++) {       for (int ed = 0; ed < n; ed++) {         if (!dp[mask][ed]) continue;         for (int nxt = 0; nxt < n; nxt++) {           if (!a[ed][nxt]) continue;           if (lowbit(mask) > (1 << nxt)) continue;           if (mask & (1 << nxt)) {             if ((lowbit(mask)) == (1 << nxt)) ans += dp[mask][ed];           } else             dp[(mask | (1 << nxt))][nxt] += dp[mask][ed];         }       }     }     printf( %lld , (ans - m) / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename P, typename Q>   ostream& operator<<(ostream& os, pair<P, Q> p) {     os <<  (  << p.first <<  ,  << p.second <<  ) ;     return os;   }   int main(int argc, char* argv[]) {     int n, k;     while (scanf( %d%d , &n, &k) == 2) {       vector<int> v;       for (int i = 0; i < n; ++i) {         int m;         scanf( %d , &m);         v.push_back(m);       }       long long int sum = 0;       for (int i = 0; i < n; ++i) {         long long int s = sum + i + 1;         if (k <= s) {           printf( %d n , v[k - sum - 1]);           break;         }         sum = s;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char buf[256];   signed main() {     long long n;     scanf( %lld , &n);     stack<long long> cur;     set<long long> si;     long long tmp = 1, ans = 0;     for (long long i = 0; i < n * 2; i++) {       scanf( %s , buf);       string s(buf);       if (s ==  add ) {         long long x;         scanf( %lld , &x);         cur.push(x);       }       if (s ==  remove ) {         if (cur.empty() || cur.top() == tmp) {           if (!cur.empty()) cur.pop();           tmp++;         } else {           while (!cur.empty()) {             si.insert(cur.top());             cur.pop();           }           si.erase(tmp);           tmp++;           ans++;         }       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300100, mod = 998244353;   inline void Add(int &a, int b) { a = a + b >= mod ? a + b - mod : a + b; }   int head[maxn], nxt[maxn << 1], ver[maxn << 1], tot;   inline void addedge(int a, int b) {     nxt[++tot] = head[a];     ver[tot] = b;     head[a] = tot;     nxt[++tot] = head[b];     ver[tot] = a;     head[b] = tot;   }   int n, f[maxn][2], g[maxn][2], h[maxn];   inline void treedp(int x, int fat) {     f[x][0] = f[x][1] = g[x][0] = g[x][1] = h[x] = 1;     for (int i = head[x]; i; i = nxt[i]) {       int y = ver[i];       if (y == fat) continue;       treedp(y, x);       f[x][0] = (0ll + f[y][0] + f[y][1] + g[y][0] + g[y][1] + h[y]) % mod *                 f[x][0] % mod;       f[x][1] = (0ll + f[y][0] + g[y][0] + g[y][1] + h[y]) % mod * f[x][1] % mod;       h[x] = (0ll + g[y][0] + g[y][1] + h[y]) % mod * h[x] % mod;     }     g[x][0] = (f[x][0] + mod - h[x]) % mod;     g[x][1] = (f[x][1] + mod - h[x]) % mod;   }   int main() {     scanf( %d , &n);     for (int i = 1, a, b; i < n; i++) scanf( %d%d , &a, &b), addedge(a, b);     treedp(1, 0);     int ans = (0ll + g[1][0] + g[1][1] + h[1] - 1 + mod) % mod;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a[120], n, t;   bool check();   int main() {     cin >> t;     while (t--) {       cin >> n;       for (int i = 1; i <= n; i++) cin >> a[i];       sort(a + 1, a + n + 1);       if (check())         cout <<  YES n ;       else         cout <<  NO n ;     }   }   bool check() {     for (int i = 1; i < n; i++) {       if (a[i + 1] == a[i] || a[i + 1] == a[i] + 1)         continue;       else         return false;     }     return true;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 110000;   string s;   int n, cnt1, cnt0, cntq, m, p;   char last0, last1;   int may01, may10;   int main() {     cin >> s;     n = s.size();     for (int i = 0; i < n; i++)       if (s[i] ==  1 )         cnt1++;       else if (s[i] ==  0 )         cnt0++;       else         cntq++;     m = n / 2 + n % 2 - 1;     p = n - m - 2;     if (cnt1 <= m) puts( 00 );     if (m + 1 - cnt1 <= cntq && m + 1 >= cnt1) {       int q1 = (m + 1 - cnt1);       int q0 = cntq - q1;       if (q0 + cnt0 == p + 1) {         if (s[n - 1] ==  1  || (s[n - 1] ==  ?  && q1 > 0)) {           may01 = 1;         }         if (s[n - 1] ==  0  || (s[n - 1] ==  ?  && q0 > 0)) {           may10 = 1;         }         if (may01) puts( 01 );         if (may10) puts( 10 );       }     }     if (cnt0 <= p) puts( 11 );   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = 3.1415926535897932384626433832795l;   template <typename T>   inline auto sqr(T x) -> decltype(x * x) {     return x * x;   }   template <typename T1, typename T2>   inline bool umx(T1& a, T2 b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   template <typename T1, typename T2>   inline bool umn(T1& a, T2 b) {     if (b < a) {       a = b;       return 1;     }     return 0;   }   const int N = 2000;   struct Input {     int n;     string s[N];     bool read() {       if (!(cin >> n)) {         return 0;       }       getline(cin, s[0]);       for (int i = int(0); i < int(n); ++i) {         getline(cin, s[i]);       }       return 1;     }     void init(const Input& input) { *this = input; }   };   struct Data : Input {     vector<int> ans[N];     void write() {       for (int i = int(0); i < int(n); ++i) {         printf( %d , ((int)(ans[i]).size()));         for (int j = int(0); j < int(((int)(ans[i]).size())); ++j) {           printf(  %d , ans[i][j]);         }         puts(  );       }     }     virtual void solve() {}     virtual void clear() { *this = Data(); }   };   struct Solution : Data {     static const int L = (N + 63) >> 6;     unsigned long long m[N][L];     unsigned long long u[N][L];     bool need[N];     int pos[N];     void solve() {       memset(m, 0, sizeof m);       for (int i = int(0); i < int(n); ++i) {         vector<unsigned long long> q((((int)(s[i]).size()) + 8) / 9, 0);         for (int j = int(((int)(s[i]).size())) - 1; j >= int(0); --j) {           (q[((int)(q).size()) - 1 - j / 9] *= 10) +=               s[i][((int)(s[i]).size()) - 1 - j] -  0 ;         }         for (int k = int(0); k < int(L * 2); ++k) {           unsigned long long r = 0;           for (int j = int(0); j < int(((int)(q).size())); ++j) {             q[j] += r * 1000000000;             r = q[j] & ((1ull << 32) - 1);             q[j] >>= 32;           }           m[i][k >> 1] |= r << (32 * (k & 1));         }       }       memset(u, 0, sizeof u);       for (int i = int(0); i < int(n); ++i) {         u[i][i >> 6] |= 1ull << (i & 63);         for (int j = int(0); j < int(i); ++j)           if (need[j]) {             if (m[i][pos[j] >> 6] & (1ull << (pos[j] & 63))) {               for (int k = int(0); k < int(L); ++k) {                 m[i][k] ^= m[j][k];               }               for (int k = int(0); k < int((i + 63) >> 6); ++k) {                 u[i][k] ^= u[j][k];               }             }           }         need[i] = 0;         for (int j = int(0); j < int(N); ++j) {           if (m[i][j >> 6] & (1ull << (j & 63))) {             need[i] = 1;             pos[i] = j;             break;           }         }         if (!need[i]) {           for (int j = int(0); j < int(i); ++j) {             if (u[i][j >> 6] & (1ull << (j & 63))) {               ans[i].push_back(j);             }           }         }       }     }     void clear() { *this = Solution(); }   };   Solution sol;   int main() {     cout.setf(ios::showpoint | ios::fixed);     cout.precision(20);     sol.read();     sol.solve();     sol.write();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ans[1009];   int main() {     memset(ans, -1, sizeof(ans));     for (int i = 1; i <= 15; i += 2) {       int x = (i * i + 1) / 2;       int y = (i - 1) / 4 * 2;       for (int j = 0; j <= y; j++) {         for (int k = 0; k <= (x - 1 - 2 * y) / 4; k++) {           for (int l = 0; l <= 1; l++) {             if (x - 2 * j - 4 * k - l >= 0 && ans[x - 2 * j - 4 * k - l] == -1)               ans[x - 2 * j - 4 * k - l] = i;           }         }       }       x = i * i - x;       y = ((i - 1) / 2 + 1) / 2 * 2;       for (int j = 0; j <= y; j++)         for (int k = 0; k <= (x - 2 * y) / 4; k++) {           if (x - 2 * j - 4 * k >= 0 && ans[x - 2 * j - 4 * k] == -1)             ans[x - 2 * j - 4 * k] = i;         }     }     int n;     scanf( %d , &n);     printf( %d , ans[n]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char spots[9][9];     for (int i = 0; i < 9; i++) {       for (int j = 0; j < 3; j++) {         string input;         cin >> input;         for (int k = 0; k < input.size(); k++) {           spots[i][j * 3 + k] = input[k];         }       }     }     int first, second;     cin >> first >> second;     first--;     second--;     int targetedFirst = first % 3;     int targetedSecond = second % 3;     bool changed = false;     for (int i = targetedFirst * 3; i < targetedFirst * 3 + 3; i++) {       for (int j = targetedSecond * 3; j < targetedSecond * 3 + 3; j++) {         if (spots[i][j] ==  . ) {           changed = true;           spots[i][j] =  ! ;         }       }     }     if (changed == false) {       for (int i = 0; i < 9; i++) {         for (int j = 0; j < 9; j++) {           if (spots[i][j] ==  . ) {             spots[i][j] =  ! ;           }         }       }     }     for (int i = 0; i < 9; i++) {       for (int j = 0; j < 9; j++) {         cout << spots[i][j];         if (j % 3 == 2) {           cout <<    ;         }       }       if (i % 3 == 2 && i != 8) {         cout << endl;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[1000005];   int n, m, k;   int main() {     scanf( %d%d%d , &n, &m, &k);     memset(arr, 0, sizeof arr);     for (int i = 0; i < m; ++i) {       int number;       scanf( %d , &number);       arr[number] = 1;     }     bool flg = 0;     int where = 1;     if (arr[where] == 1) flg = 1;     while (k--) {       int num1, num2;       scanf( %d%d , &num1, &num2);       if (num1 == where && !flg) {         where = num2;         if (arr[where] == 1) flg = 1;       } else if (num2 == where && !flg) {         where = num1;         if (arr[where] == 1) flg = 1;       }     }     printf( %d , where);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct debugger {     static void call(const char* it) {}     template <typename T, typename... aT>     static void call(const char* it, T a, aT... rest) {       string b;       for (; *it && *it !=  , ; ++it)         if (*it !=    ) b += *it;       cerr << b <<  =  << a <<    ;       call(++it, rest...);     }   };   int dr[] = {0, 1, 1, -1, 0, -1, -1, 1};   int dc[] = {1, 0, 1, 1, -1, 0, -1, -1};   char field[4][4];   int dt = 0;   int tour(int r, int c, char c1, char c2, int d) {     if (r < 0 || r > 3 || c < 0 || c > 3) return 0;     if (field[r][c] == c2) {       dt++;       if (dt > 1) return 0;     } else if (field[r][c] != c1)       return 0;     int ans = 1;     ans += tour(r + dr[d], c + dc[d], c1, c2, d);     return ans;   }   int main() {     {       ios_base::sync_with_stdio(false);       cin.tie(NULL);       cout.tie(NULL);     };     for (int i = 0; i < 4; i++)       for (int j = 0; j < 4; j++) cin >> field[i][j];     int y = 0;     for (int i = 0; i < 4; i++) {       for (int j = 0; j < 4; j++) {         for (int k = 0; k < 4; k++) {           if (tour(i, j,  x ,  . , k) == 3) {             y = 1;             break;           }           dt = 0;         }         if (y) break;       }       if (y) break;     }     if (y)       cout <<  YES n ;     else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[105];   int main() {     int ans = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 2; i <= n - 1; i++) {       if (a[i] == 0 && a[i - 1] == 1 && a[i + 1] == 1) {         ans++;         a[i + 1] = 0;       }     }     printf( %d n , ans);   }