malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 10;   int n;   set<pair<pair<int, int>, int> > a;   int ans[MAXN];   inline pair<pair<int, int>, int> mpi(int a, int b, int c) {     return make_pair(make_pair(a, b), c);   }   void exit() {     cout <<  Impossible ;     exit(0);   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       pair<pair<int, int>, int> x;       scanf( %d , &x.first.second);       x.first.first = x.first.second % 3;       x.second = i;       a.insert(x);     }     a.insert(mpi(1000, 1000, 1000));     a.insert(mpi(-1000, -1000, -1000));     pair<pair<int, int>, int> x;     int olimp = 0;     for (int i = 0; i < n; i++) {       set<pair<pair<int, int>, int> >::iterator it =           a.lower_bound(mpi(i % 3, i - olimp, 0));       x = *it;       if (i % 3 != x.first.first) {         it--;         x = *it;       }       if (i % 3 != x.first.first) exit();       bool flag = false;       while (i - olimp + 1 < x.first.second) {         it--;         x = *it;         flag = true;       }       if (x.first.second < 0 || i % 3 != x.first.first) exit();       olimp = i + 1 - x.first.second;       ans[i + 1] = x.second;       a.erase(it);     }     cout <<  Possible  << endl;     for (int i = 1; i <= n; i++) printf( %d  , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   const double pp = 0.00000001;   const int maxn = 100005;   double ans, xo, da, mid;   int ci, w, i, n, x[maxn], y[maxn];   bool pd(double k) {     double ww, l = -1e9, r = 1e9;     int i;     for (i = 1; i <= n; i++) {       if (k * k < (y[i] - k) * (y[i] - k)) {         return 0;       }       ww = -1.0 * y[i] * y[i] + 2 * y[i] * k;       ww = sqrt(ww);       if (l < x[i] - ww) l = x[i] - ww;       if (r > x[i] + ww) r = x[i] + ww;     }     if (l <= r)       return true;     else       return false;   }   int main() {     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d%d , &x[i], &y[i]);       if (y[i] > 0)         w++;       else         y[i] = -y[i];     }     if (w != 0 && w != n) {       printf( -1 n );       return 0;     }     xo = 0;     da = 50000000000000.4949989;     ci = 0;     while (ci <= 100) {       ci++;       mid = (xo + da) / 2;       if (pd(mid)) {         ans = mid;         da = mid;       } else         xo = mid;     }     printf( %lf n , mid);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int64_t t, a[200005], n;     cin >> t;     while (t--) {       int64_t dem = 1;       cin >> n;       for (int i = 1; i <= n; i++) cin >> a[i];       sort(a + 1, a + n + 1);       for (int i = 1; i < n; i++) {         if (a[i] != a[i + 1]) dem++;       }       cout << dem << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s =   ;     cin >> s;     int y = 0;     while (s[y] ==  a  && y <= s.length()) ++y;     for (int i = y; i < s.length(); ++i) {       if (s[i] ==  a )         break;       else         --s[i];     }     if (y == s.length()) s[s.length() - 1] =  z ;     cout << s << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int n;     cin >> n;     long long int a[n], b[n];     long long int sum_1 = 0, sum_2 = 0, c = 0;     for (long long int i = 0; i <= n - 1; i++) {       cin >> a[i] >> b[i];       sum_1 += a[i];       sum_2 += b[i];     }     if (sum_1 % 2 == 0 && sum_2 % 2 == 0) {       cout <<  0  <<   n ;     } else if (n == 1) {       cout <<  -1  <<   n ;     } else {       for (long long int i = 0; i <= n - 1; i++) {         sum_1 -= a[i];         sum_1 += b[i];         sum_2 -= b[i];         sum_2 += a[i];         c++;         if (sum_1 % 2 == 0 && sum_2 % 2 == 0) {           cout << c <<   n ;           return 0;         }         c--;         sum_1 -= b[i];         sum_1 += a[i];         sum_2 -= a[i];         sum_2 += b[i];       }       cout <<  -1  <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   int f[210000 * 4], mn[210000 * 4];   void add(int u, int L, int R, int l, int r, int k) {     l = max(l, L);     r = min(r, R);     if (l >= r) return;     if (l == L && R == r) {       mn[u] += k;       f[u] += k;       return;     }     add(u * 2, L, ((L + R) >> 1), l, r, k);     add(u * 2 + 1, ((L + R) >> 1), R, l, r, k);     mn[u] = min(mn[u * 2], mn[u * 2 + 1]) + f[u];   }   int calc(int u, int L, int R, int k) {     if (L + 1 == R) return L;     k -= f[u];     if (mn[u * 2] <= k) return calc(u * 2, L, ((L + R) >> 1), k);     return calc(u * 2 + 1, ((L + R) >> 1), R, k);   }   int sa[210000], sb[210000], na, nb, a[210000];   int ans, st, ed;   int i, last, n, m, d;   int main() {     scanf( %d%d%d , &n, &m, &d);     for (int i = (1); i < (n + 1); i++) scanf( %d , a + i);     if (!d) {       for (int i = (1); i < (n + 1); i++) {         if (i == 1 || a[i] != a[i - 1]) last = i;         if (ans < i - last + 1) ans = i - last + 1, st = last, ed = i;       }     } else {       for (int i = (1); i < (n + 1); i++) {         if (i != 1 && (a[i] - a[i - 1]) % d) {           add(1, 1, n + 1, last + 1, i, 1100000);           last = i - 1;         }         if (mp[a[i]] > last) {           add(1, 1, n + 1, last + 1, mp[a[i]] + 1, 1100000);           last = mp[a[i]];         }         mp[a[i]] = i;         while (na && a[i] > a[sa[na]]) {           add(1, 1, n + 1, sa[na - 1] + 1, sa[na] + 1, (a[i] - a[sa[na]]) / d);           na--;         }         while (nb && a[i] < a[sb[nb]]) {           add(1, 1, n + 1, sb[nb - 1] + 1, sb[nb] + 1, (a[sb[nb]] - a[i]) / d);           nb--;         }         sa[++na] = sb[++nb] = i;         add(1, 1, n + 1, i, i + 1, i);         int tmp = calc(1, 1, n + 1, i + m);         if (i - tmp + 1 > ans) {           ans = i - tmp + 1;           st = tmp;           ed = i;         }       }     }     printf( %d %d n , st, ed);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 2e9;   const long long Inf = 1e10;   const int N = 500005;   const double pi = acos(-1);   inline int IN() {     int x = 0;     int ch = 0, f = 0;     for (ch = getchar(); ch != -1 && (ch < 48 || ch > 57); ch = getchar())       f = (ch ==  - );     for (; ch >= 48 && ch <= 57; ch = getchar())       x = (x << 1) + (x << 3) + ch -  0 ;     return f ? (-x) : x;   }   int Pow(int x, int y, int p) {     int a = 1;     for (; y; y >>= 1, x = (long long)x * x % p)       if (y & 1) a = (long long)a * x % p;     return a;   }   int n, a;   double rad[N], dis[N], ang[N];   struct po {     double x, y;     po(double xv = 0, double yv = 0) { x = xv, y = yv; }     double norm() { return sqrt(x * x + y * y); }     po operator-(const po &a) const { return (po){x - a.x, y - a.y}; }   } b[N], P, Q;   pair<double, double> A[N];   int tot;   set<double> st;   int check(double rng) {     tot = 0;     st.clear();     for (int i = (int)(1); i <= (int)(n); i++) {       if (dis[i] >= rng + rad[i]) continue;       if (dis[i] <= fabs(rng - rad[i])) continue;       double bet =           (rng * rng + dis[i] * dis[i] - rad[i] * rad[i]) / (2 * rng * dis[i]);       double alp = ang[i];       bet = acos(bet);       double l = alp - bet, r = alp + bet;       if (l < 0) l += 2 * pi;       if (r < 0) r += 2 * pi;       if (l > r) swap(l, r);       A[++tot] = make_pair(l, r);     }     sort(A + 1, A + tot + 1);     for (int i = (int)(1); i <= (int)(tot); i++) {       auto t = st.lower_bound(A[i].first);       if (t != st.end() && *t < A[i].second) return 1;       st.insert(A[i].second);     }     return 0;   }   int main() {     scanf( %d%d , &n, &a);     P = po(a, 0);     Q = po(-a, 0);     for (int i = (int)(1); i <= (int)(n); i++) {       double x, y;       scanf( %lf%lf , &x, &y);       b[i] = po(x, y);       rad[i] = (b[i] - Q).norm();       b[i] = b[i] - P;       ang[i] = atan2(b[i].y, b[i].x);       dis[i] = b[i].norm();     }     double l = 0, r = 2 * a;     for (int i = (int)(1); i <= (int)(100); i++) {       double md = (l + r) / 2.;       if (check(md))         r = md;       else         l = md;     }     printf( %.10lf n , (l + r) / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 5;   const int inf = 1e9 + 5e5 + 19;   int n, k;   int a[maxn];   bool in_b[maxn];   struct fenwick {     int n;     vector<int> val;     void init(int _n) {       n = _n;       val.assign(n + 5, -1);     }     void update(int x, int k) {       for (; x <= n; x += x & -x) val[x] = max(val[x], k);     }     int get(int x) {       int res = -1;       for (; x > 0; x -= x & -x) res = max(res, val[x]);       return res;     }   } tree;   void read_input() {     cin >> n >> k;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (; k > 0; --k) {       int x;       cin >> x;       in_b[x] = true;     }     in_b[0] = in_b[n + 1] = true;     a[0] = -inf;     a[n + 1] = inf;   }   int calc(const vector<int>& arr, int L, int R) {     if ((int)arr.size() == 0) return 0;     vector<int> vals;     for (int i = 0; i < (int)arr.size(); ++i) vals.push_back(arr[i] - i);     sort(vals.begin(), vals.end());     vals.erase(unique(vals.begin(), vals.end()), vals.end());     tree.init((int)vals.size());     int max_val = 0;     for (int i = 0; i < (int)arr.size(); ++i) {       if (arr[i] <= L || arr[i] >= R) continue;       if (arr[i] - L - 1 >= i && R - arr[i] - 1 >= (int)arr.size() - i - 1) {         int val = 1;         int p =             lower_bound(vals.begin(), vals.end(), arr[i] - i) - vals.begin() + 1;         val = max(val, tree.get(p) + 1);         tree.update(p, val);         max_val = max(max_val, val);       }     }     return (int)arr.size() - max_val;   }   void solve() {     int ans = 0;     for (int i = 0; i <= n;) {       int j = i + 1;       while (j <= n && !in_b[j]) ++j;       int L = a[i], R = a[j];       if (R - L < j - i) {         cout <<  -1 n ;         return;       }       vector<int> arr;       ++i;       for (; i < j; ++i) arr.push_back(a[i]);       ans += calc(arr, L, R);     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     read_input();     solve();   }
#include <bits/stdc++.h>   using namespace std;   int prime[500000];   long long gcd(long long x, long long y) {     if (y == 0) return x;     return gcd(y, x % y);   }   int main() {     long long n;     cin >> n;     long long x = n;     for (long long i = 2; i * i <= n; i++)       if (n % i == 0) {         x = gcd(x, i);         x = gcd(x, n / i);       }     cout << x << endl;   }
#include <bits/stdc++.h>   int n;   char s[11];   int main() {     scanf( %d , &n);     int pos = 20000;     for (int i = 1; i <= n; i++) {       int num;       scanf( %d%s , &num, s + 1);       if (s[1] ==  N ) {         if (pos + num > 20000) {           puts( NO );           return 0;         } else           pos += num;       } else if (s[1] ==  S ) {         if (pos - num < 0) {           puts( NO );           return 0;         } else           pos -= num;       } else {         if (pos == 0 || pos == 20000) {           puts( NO );           return 0;         }       }     }     if (pos == 20000)       puts( YES );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   int a[100010], b[100010];   bool check(int *a, int n, int id) {     int cntt = 0;     for (int i = 0; i < n; i++) {       if (i == id) continue;       b[cntt++] = a[i];     }     if (cntt == 1) return true;     for (int i = 1; i < cntt; i++)       if (b[i - 1] == 0 && b[i] != 0) return false;     if (cntt == 2) return true;     for (int i = 1; i < cntt - 1; i++) {       int num = b[i] * b[i];       if (num != b[i - 1] * b[i + 1]) return false;     }     return true;   }   bool check2(int *aa, int n) {     for (int i = 0; i < n; i++) b[i] = aa[i];     int cntt = 0;     if (b[0] == 0 && b[1] != 0) return false;     if (b[1] == 0 && b[2] != 0) return false;     if (b[1] * b[1] != b[0] * b[2]) return false;     bool zero = true;     int zeros = 0;     for (int i = 0; i < 3; i++) {       if (b[i] != 0)         zero = false;       else         zeros++;     }     if (zeros != 0) {       int cntt = 0;       for (int i = 3; i < n; i++)         if (b[i] != 0) cntt++;       if (cntt == 1) return true;       return false;     }     for (int i = 2; i < n; i++) {       int next = b[i - 1] * b[i - 1];       if (next % b[i - 2] != 0) return false;       next = next / b[i - 2];       if (next != b[i]) {         cntt++;         if (i != n - 1 && next != b[i + 1]) return false;         i++;         b[i - 1] = b[i - 2];       }     }     if (cntt == 1) return true;     return false;   }   int main() {     int n;     while (scanf( %d , &n) == 1) {       for (int i = 0; i < n; i++) scanf( %d , &a[i]);       int zeros = 0;       for (int i = 0; i < n; i++)         if (a[i] == 0) zeros++;       if (n == 1) {         puts( 0 );         continue;       }       if (zeros == n) {         puts( 0 );         continue;       }       if (zeros == n - 1 && a[0] == 0) {         puts( 1 );         continue;       }       if (check(a, n, -1)) {         puts( 0 );         continue;       }       if (check(a, n, 0) || check(a, n, 1) || check(a, n, 2)) {         puts( 1 );         continue;       }       if (check2(a, n)) {         puts( 1 );         continue;       }       puts( 2 );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, k, i, j;     long long int flag = 0;     cin >> n >> k;     long long int m = n * n;     long long int p;     char a[1000][1000];     if (m % 2 == 0) {       p = m / 2;     } else {       p = (m + 1) / 2;     }     if (k > p) {       cout <<  NO  << endl;     } else {       cout <<  YES  << endl;       for (i = 1; i <= n; i++) {         for (j = 1; j <= n; j++) {           a[i][j] =  S ;         }       }       long long int c = 0;       for (i = 1; i <= n; i++) {         for (j = 1; j <= n; j++) {           if (c == k) {             flag = 1;             break;           }           if (i % 2 != 0 && j % 2 != 0) {             a[i][j] =  L ;             c++;           }           if (i % 2 == 0 && j % 2 == 0) {             a[i][j] =  L ;             c++;           }         }         if (flag == 1) {           break;         }       }       for (i = 1; i <= n; i++) {         for (j = 1; j <= n; j++) {           cout << a[i][j];         }         cout << endl;       }     }   }
#include <bits/stdc++.h>   const int MN = 2e2 + 10;   template <typename T>   bool ckmin(T& a, const T& b) {     return b < a ? a = b, 1 : 0;   }   template <typename T>   bool ckmax(T& a, const T& b) {     return b > a ? a = b, 1 : 0;   }   template <typename F, int MN, int MM>   struct MaxFlow {    public:     int hd[MN], to[MM * 2], nx[MM * 2], q[MN], cur[MN], lvl[MN], N, M, S, T;     F flow[MM * 2], cap[MM * 2];     void init(int _N) {       N = _N;       memset(hd, -1, N * sizeof *hd);     }     void add1(int u, int v, F c) {       flow[M] = 0, cap[M] = c;       nx[M] = hd[u], to[M] = v, hd[u] = M++;     }     void adde(int u, int v, F c) {       add1(u, v, c);       add1(v, u, 0);     }     bool bfs() {       memset(lvl, 0, N * sizeof *lvl);       lvl[S] = 1;       q[0] = S;       for (int i = 0, Q = 1, x, y; i < Q; ++i) {         x = q[i];         for (int j = hd[x]; ~j; j = nx[j])           if (cap[j] - flow[j] > 0 && !lvl[y = to[j]])             lvl[y] = lvl[x] + 1, q[Q++] = y;       }       return lvl[T];     }     F dfs(int n, F f) {       if (n == T) return f;       for (int &i = cur[n], x; ~i; i = nx[i])         if (cap[i] - flow[i] > 0 && lvl[x = to[i]] == lvl[n] + 1) {           F r = dfs(x, std::min(f, cap[i] - flow[i]));           if (r > 0) return flow[i] += r, flow[1 ^ i] -= r, r;         }       return 0;     }     F saturate(int _S, int _T) {       S = _S, T = _T;       F ans = 0;       while (bfs()) {         F x;         memcpy(cur, hd, N * sizeof *hd);         for (bool ok = 0; x = dfs(S, 1);)           if (x)             ans += x, ok = 1;           else if (ok)             break;           else             return ans;       }       return ans;     }   };   MaxFlow<int, MN * MN * 2, MN * MN * 6> maxflow;   int N, M, cnt;   char a[MN][MN];   int main() {     scanf( %d%d , &N, &M);     maxflow.init(N * M * 2 + 2);     for (int i = 0; i < N; ++i) scanf(  %s , a[i]);     for (int i = 0; i < N; ++i)       for (int j = 0; j < M; ++j)         if (a[i][j] ==  # ) {           int u = i && a[i - 1][j] ==  #  ? i * M + j << 1 : -1;           int d = i + 1 < N && a[i + 1][j] ==  #  ? (i + 1) * M + j << 1 : -1;           int l = j && a[i][j - 1] ==  #  ? i * M + j << 1 | 1 : -1;           int r = j + 1 < M && a[i][j + 1] ==  #  ? i * M + j + 1 << 1 | 1 : -1;           if (~u && ~r) maxflow.adde(u, r, 1);           if (~u && ~l) maxflow.adde(u, l, 1);           if (~d && ~r) maxflow.adde(d, r, 1);           if (~d && ~l) maxflow.adde(d, l, 1);           ++cnt;           cnt -= (u != -1) + (l != -1);         }     for (int i = 0; i < N * M; ++i) {       maxflow.adde(N * M * 2, i * 2, 1);       maxflow.adde(i * 2 + 1, N * M * 2 + 1, 1);     }     printf( %d n , cnt + maxflow.saturate(N * M * 2, N * M * 2 + 1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, x;     cin >> n >> x;     long long a[n];     for (auto &i : a) cin >> i;     long long pre[n + 1];     pre[0] = 0;     for (long long i = 1; i <= n; i++) pre[i] = (pre[i - 1] + a[i - 1]) % x;     long long ans = 0;     for (long long i = 1; i <= n; i++) {       if (pre[i] != 0) ans = max(ans, i);     }     for (long long i = n; i >= 0; i--) {       if (pre[i] != pre[n]) ans = max(ans, n - i);     }     if (ans == 0)       cout << -1 <<   n ;     else       cout << ans <<   n ;   }   int32_t main() {     long long t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   class segmentTree {    public:     int* tree;     int N;     int size;     void update(int qidx, int val) { update(qidx, val, 0, N - 1, 0); }     void update(int qidx, int val, int left, int right, int idx) {       if (left == right && left == qidx) {         tree[idx] = val;       } else if (qidx >= left && qidx <= right) {         int mid = (left + right) / 2;         update(qidx, val, left, mid, 2 * idx + 1);         update(qidx, val, mid + 1, right, 2 * idx + 2);         tree[idx] = min(tree[2 * idx + 1], tree[2 * idx + 2]);       }     }     int query(int qleft, int qright) { return query(qleft, qright, 0, N - 1, 0); }     int query(int qleft, int qright, int left, int right, int index) {       if (left >= qleft && right <= qright) return tree[index];       if (right < qleft || left > qright) return INT_MAX;       int mid = (left + right) / 2;       return min(query(qleft, qright, left, mid, 2 * index + 1),                  query(qleft, qright, mid + 1, right, 2 * index + 2));     }     segmentTree(int n) {       N = n;       int start = 2;       while ((start - 1) < 2 * N) start *= 2;       size = start - 1;       tree = new int[size];       memset(tree, -1, sizeof(int) * size);     }   };   const int MX = 1e5 + 69;   int used[MX], used2[MX];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     memset(used, 0, sizeof used);     memset(used2, 0, sizeof used2);     int n;     cin >> n;     segmentTree tree = segmentTree(n + 1);     int totmex = 1;     vector<int> submex;     for (int i = 0; i < n; i++) {       int w;       cin >> w;       used[w]++;       while (used[totmex]) totmex++;       if (w != 1) {         submex.push_back(1);       } else {         tree.update(1, i);         continue;       }       int lastw = tree.query(w, w);       int minbelow = tree.query(1, w - 1);       if (minbelow > lastw) submex.push_back(w);       tree.update(w, i);     }     for (int w = 2; w <= n; w++) {       int lastw = tree.query(w, w);       int minbelow = tree.query(1, w - 1);       if (minbelow > lastw) submex.push_back(w);     }     submex.push_back(totmex);     for (int v : submex) used2[v]++;     for (int ans = 1; ans < 1e9; ans++)       if (!used2[ans]) {         cout << ans <<   n ;         exit(0);       }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200010;   char s[N];   vector<int> v[N];   set<int> s1, s2;   set<int>::iterator j;   inline int gi() {     int x = 0, o = 1;     char ch = getchar();     while (ch !=  -  && (ch <  0  || ch >  9 )) ch = getchar();     if (ch ==  - ) o = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * o;   }   int main() {     scanf( %s , s + 1);     int n = strlen(s + 1), sum = 0, k = 0;     for (int i = 1; i <= n; i++) {       sum += s[i] -  0 ;       if (sum + sum > i) return puts( -1 ), 0;       if (s[i] ==  1 )         s1.insert(i);       else         s2.insert(i);     }     sum = 0;     for (int i = n; i; i--) {       sum += s[i] -  0 ;       if (sum + sum > n - i + 1) return puts( -1 ), 0;     }     while (!s1.empty()) {       int now = 0;       bool flg = 0;       ++k;       while (now <= n) {         if (!flg) {           j = s2.lower_bound(now);           if (j == s2.end()) break;           now = (*j) + 1;           v[k].push_back(*j);         } else {           j = s1.lower_bound(now);           if (j == s1.end()) break;           now = (*j) + 1;           v[k].push_back(*j);         }         flg ^= 1;       }       for (int i = 0; i < v[k].size(); i++) {         if (s[v[k][i]] ==  0 )           s2.erase(v[k][i]);         else           s1.erase(v[k][i]);       }     }     for (j = s2.begin(); j != s2.end(); j++) v[++k].push_back(*j);     cout << k << endl;     for (int i = 1; i <= k; i++) {       printf( %d  , (int)v[i].size());       for (int j = 0; j < v[i].size(); j++) printf( %d  , v[i][j]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5 * 1000000 + 100;   char str[maxn << 1], s[maxn];   int p[maxn << 1];   int ans;   int n;   int f[maxn << 1];   void Init(void) {     str[0] =  $ , str[1] =  # ;     for (int i = 0; i < n; i++) {       str[i * 2 + 2] = s[i];       str[i * 2 + 3] =  # ;     }     int nn = 2 * n + 2;     str[nn] = 0;     int mx = 0, id;     for (int i = 1; i < nn; i++) {       if (mx > i) {         p[i] = min(p[2 * id - i], mx - i);       } else         p[i] = 1;       while (str[i + p[i]] == str[i - p[i]]) p[i]++;       if (i + p[i] > mx) mx = i + p[i], id = i;     }   }   void solve(void) {     long long ans = 0;     for (int i = 1; i <= n; i++) {       int l = 2, r = 2 * i;       int m = (l + r) >> 1;       if (p[m] * 2 - 1 >= r - l + 1) f[r] = f[m - 1 + ((m % 2) ? 0 : -1)] + 1;       ans += f[r];     }     printf( %I64d n , ans);   }   int main(void) {     scanf( %s , s);     n = strlen(s);     Init();     solve();     return 0;   }