malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     long long dp[100001], dp2[100001];     long long n;     string a, b;     long long match, k;     cin >> a >> b >> k;     string a2 = a;     n = a.length();     a = a + a.substr(0, n - 1);     match = 0;     for (int i = 0; i <= 2 * n - 2; i++) {       if (a.substr(i, n) == b) match++;     }     dp[0] = dp2[0] = 0;     dp[1] = match;     dp2[1] = n - match - 1;     if (a2 == b) {       dp[1] = match - 1;       dp2[1] = n - match;       dp[0] = 1;     }     for (int i = 2; i <= k; i++) {       dp[i] = ((dp[i - 1] * (match - 1)) % 1000000007 +                (dp2[i - 1] * match) % 1000000007) %               1000000007;       dp2[i] = ((dp[i - 1] * (n - match)) % 1000000007 +                 (dp2[i - 1] * (n - match - 1)) % 1000000007) %                1000000007;     }     cout << (dp[k]) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int state[10000];   int cnt, sum;   void dfs(int depth) {     if (depth >= m) {       for (int i = 0; i < n - 1; ++i) {         for (int j = i + 1; j < n; ++j) {           if (state[i] > state[j]) ++cnt;         }       }     } else {       for (int i = 0; i < n; ++i) {         for (int j = i; j < n; ++j) {           for (int a = i, b = j; a < b; ++a, --b) swap(state[a], state[b]);           dfs(depth + 1);           for (int a = i, b = j; a < b; ++a, --b) swap(state[a], state[b]);         }       }     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) {       scanf( %d , &state[i]);     }     cnt = 0;     dfs(0);     double ans = cnt / pow(n * (n - 1) / 2 + n, m);     printf( %.12f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1e9 + 7;   const long long int inf = 2e9 + 5;   double PI = 3.14159265358979323846;   void solve() {     int n;     cin >> n;     int x = (int)sqrt(n);     int best = inf;     for (int i = max(1, x - 2); i <= x + 2; i++) {       for (int j = max(1, x - 2); j <= x + 2; j++) {         if (i * j >= n) {           best = min(best, i + j - 2);         }       }     }     cout << best <<   n ;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int T;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   double pi = acos((double)-1);   const int MOD = 1000000007;   const int INF = 2147483647;   int main() {     clock_t tStart = clock();     int tests = 1;     for (int test = 1; test <= tests; test++) {       int n, m, dx, dy;       cin >> n >> m >> dx >> dy;       vector<int> xi(m, 0), yi(m, 0);       for (int i = 0; i < m; i++) {         cin >> xi[i] >> yi[i];       }       vector<int> y(n, 0);       int step_x = 0, step_y = 0;       for (int i = 0; i < n; i++) {         y[step_x] = step_y;         step_x += dx;         step_y += dy;         step_x %= n;         step_y %= n;       }       vector<int> groups_counter(n, 0);       int groups_counter_max = 0;       int groups_counter_index = 0;       for (int i = 0; i < m; i++) {         int k = (yi[i] - y[xi[i]] + n) % n;         groups_counter[k]++;         if (groups_counter[k] > groups_counter_max) {           groups_counter_max = groups_counter[k];           groups_counter_index = k;         }       }       cout << 0 <<     << groups_counter_index << endl;     }   }
#include <bits/stdc++.h>   constexpr int P = 998244353;   struct Matrix {     int a[4];     Matrix() : a{} {}     friend Matrix operator*(const Matrix &lhs, const Matrix &rhs) {       Matrix res;       res.a[0] = (1ll * lhs.a[0] * rhs.a[0] + 1ll * lhs.a[1] * rhs.a[2]) % P;       res.a[1] = (1ll * lhs.a[0] * rhs.a[1] + 1ll * lhs.a[1] * rhs.a[3]) % P;       res.a[2] = (1ll * lhs.a[2] * rhs.a[0] + 1ll * lhs.a[3] * rhs.a[2]) % P;       res.a[3] = (1ll * lhs.a[2] * rhs.a[1] + 1ll * lhs.a[3] * rhs.a[3]) % P;       return res;     }   };   struct SegmentTree {     const int n;     std::vector<int> a;     std::vector<Matrix> t;     SegmentTree(const std::vector<int> &a) : n(a.size()), a(a), t(4 * n) {       build(1, 0, n);     }     void build(int p, int l, int r) {       if (r - l == 1) {         t[p].a[0] = a[l] + 1;         t[p].a[1] = 1;         t[p].a[2] = (l && a[l - 1] == 1) ? (9 - a[l]) : 0;       } else {         int m = (l + r) / 2;         build(2 * p, l, m);         build(2 * p + 1, m, r);         t[p] = t[2 * p] * t[2 * p + 1];       }     }     void update(int p, int l, int r, int x) {       if (r - l == 1) {         t[p].a[0] = a[l] + 1;         t[p].a[2] = (l && a[l - 1] == 1) ? (9 - a[l]) : 0;       } else {         int m = (l + r) / 2;         if (x < m) {           update(2 * p, l, m, x);         } else {           update(2 * p + 1, m, r, x);         }         t[p] = t[2 * p] * t[2 * p + 1];       }     }     void modify(int x, int y) {       a[x] = y;       update(1, 0, n, x);       if (x + 1 < n) update(1, 0, n, x + 1);     }     int query() { return t[1].a[0]; }   };   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(nullptr);     int n, m;     std::cin >> n >> m;     std::vector<int> a(n);     for (int i = 0; i < n; ++i) {       char c;       std::cin >> c;       a[i] = c -  0 ;     }     SegmentTree t(a);     while (m--) {       int x, y;       std::cin >> x >> y;       --x;       t.modify(x, y);       std::cout << t.query() <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   int a[205], b[105];   set<int> st;   int n;   void solve() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> b[i];     st.clear();     for (int i = 1; i <= 2 * n; i++) st.insert(i);     for (int i = 1; i <= n; i++) {       st.erase(b[i]);     }     if (st.size() != n) {       cout << -1 << endl;       return;     }     for (int i = 1; i <= n; i++) {       a[2 * i - 1] = b[i];     }     for (int i = 2; i <= 2 * n; i += 2) {       auto tmp = st.upper_bound(a[i - 1]);       if (tmp == st.end()) {         cout << -1 << endl;         return;       }       a[i] = *tmp;       st.erase(tmp);     }     for (int i = 1; i <= 2 * n; i++) {       cout << a[i] <<    ;     }     cout << endl;   }   int main() {     ios::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, a[100005], b[100005];   char s1[100005], s2[100005];   long long x11, x01, x10, x00, ans;   int main() {     scanf( %d , &N);     cin >> s1;     cin >> s2;     for (int i = 1; i <= N; ++i) a[i] = s1[i - 1] -  0 , b[i] = s2[i - 1] -  0 ;     for (int i = 1; i <= N; ++i) {       if (!a[i] && !b[i])         x00++;       else if (!a[i] && b[i])         x01++;       else if (a[i] && !b[i])         x10++;       else         x11++;     }     ans = x11 * x00 + x00 * x10 + x10 * x01;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   short p[402][402 * 402];   int a[402][402], n, m, l, r, j, i, d[402][402], f[402][402], ans;   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; ++i)       for (j = 1; j <= m; ++j) scanf( %d , &a[i][j]);     for (j = 1; j <= m; ++j) {       for (l = n; l >= 1; --l)         for (r = l; r <= n; ++r) {           f[l][r] = max((int)max(p[r][a[l][j]], p[l][a[r][j]]),                         max(f[l + 1][r], f[l][r - 1]));           if (l != r && a[l][j] == a[r][j]) f[l][r] = j;           d[l][r] = max(d[l][r], f[l][r]);           ans = max(ans, (r - l + 1) * (j - d[l][r]));         }       for (i = 1; i <= n; ++i) p[i][a[i][j]] = j;     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 100005;   const double eps = 1e-8, Pi = acos(-1.0);   int n;   double a, x[Maxn], y[Maxn], dis[Maxn];   pair<double, double> pos[Maxn];   priority_queue<double, vector<double>, greater<double> > Pr;   bool check(double r) {     int m = 0;     for (int i = 1; i <= n; i++) {       double l = sqrt((x[i] - a) * (x[i] - a) + y[i] * y[i]);       if (l > dis[i] + r || dis[i] > l + r || r > dis[i] + l) continue;       double p = atan2(y[i], x[i] - a);       double range = acos((l * l + r * r - dis[i] * dis[i]) / (2 * l * r));       double L = p - range, R = p + range;       if (L < -Pi) L += 2 * Pi;       if (L > Pi) L -= 2 * Pi;       if (R < -Pi) R += 2 * Pi;       if (R > Pi) R -= 2 * Pi;       if (L > R) swap(L, R);       pos[++m] = make_pair(L, R);     }     sort(pos + 1, pos + 1 + m);     while (!Pr.empty()) Pr.pop();     for (int i = 1; i <= m; i++) {       while (!Pr.empty() && Pr.top() < pos[i].first) Pr.pop();       if (!Pr.empty() && Pr.top() <= pos[i].second) return true;       Pr.push(pos[i].second);     }     return false;   }   int main() {     scanf( %d%lf , &n, &a);     for (int i = 1; i <= n; i++)       scanf( %lf%lf , &x[i], &y[i]),           dis[i] = sqrt((x[i] + a) * (x[i] + a) + y[i] * y[i]);     double l = 0, r = 2 * a;     while (r - l >= eps) {       double mid = (l + r) / 2;       if (check(mid))         r = mid;       else         l = mid;     }     printf( %.10lf , l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long small(char a, char b) {     return min(abs(a - b), min(a + 26 - b, b + 26 - a));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, pos;     cin >> n >> pos;     string x;     cin >> x;     bool gotomid = 0;     int mid = n / 2;     if (pos > mid) {       pos = n - pos + 1;     }     long long res = small(x[pos - 1], x[n - pos]);     int right = -1, left = 1e5;     for (int i = mid - 1; i >= pos; i--)       if (x[i] != x[n - 1 - i]) {         right = i;         break;       }     for (int i = 0; i < pos - 1; i++)       if (x[i] != x[n - 1 - i]) {         left = i;         break;       }     if (left == 1e5 && right == -1)       cout << res;     else if (left != 1e5 && right == -1) {       for (int i = left; i < pos - 1; i++)         if (x[i] != x[n - 1 - i]) res += small(x[i], x[n - 1 - i]);       res += pos - 1 - left;       cout << res;     } else if (left == 1e5 && right != -1) {       for (int i = right; i >= pos; i--)         if (x[i] != x[n - 1 - i]) res += small(x[i], x[n - 1 - i]);       res += right - (pos - 1);       cout << res;     } else {       for (int i = left; i < pos - 1; i++)         if (x[i] != x[n - 1 - i]) res += small(x[i], x[n - 1 - i]);       for (int i = right; i >= pos; i--)         if (x[i] != x[n - 1 - i]) res += small(x[i], x[n - 1 - i]);       res += 2 * min(pos - 1 - left, right - (pos - 1)) +              max(pos - 1 - left, right - (pos - 1));       cout << res;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, w[100010], in1, in2, in3;   double ans;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &w[i]);     for (int i = 1; i <= m; i++) {       scanf( %d%d%d , &in1, &in2, &in3);       ans = max(ans, (w[in1] + w[in2]) * 1.0 / in3);     }     printf( %.15lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t LINF = 1LL << 62;   struct Point {     int x, y;     bool operator<(const Point& o) const {       return x < o.x || (x == o.x && y < o.y);     }   };   inline int64_t cross(const Point& o, const Point& a, const Point& b) {     return (a.x - o.x) * (int64_t)(b.y - o.y) -            (a.y - o.y) * (int64_t)(b.x - o.x);   }   int64_t solve(vector<Point> a, int m) {     int n = ((int)(a).size());     Point o = a[0];     sort(a.begin() + 1, a.end(),          [o](const Point& a, const Point& b) { return cross(o, a, b) > 0; });     vector<vector<int>> works(n);     vector<vector<vector<int64_t>>> dp(n);     works[0] = {0};     dp[0] = vector<vector<int64_t>>(1, vector<int64_t>(m + 1, -LINF));     dp[0][0][1] = 0;     int64_t ans = 0;     for (int i = 1; i < n; ++i) {       for (int j = i - 1; j > 0; --j) {         if (works[i].empty() || cross(a[i], a[works[i].back()], a[j]) < 0) {           works[i].push_back(j);         }       }       works[i].push_back(0);       reverse(works[i].begin(), works[i].end());       dp[i] = vector<vector<int64_t>>(((int)(works[i]).size()),                                       vector<int64_t>(m + 1, -LINF));       for (int j = 0; j < ((int)(works[i]).size()); ++j) {         int prev = works[i][j];         int pos = 0, step = 1;         while (step < ((int)(works[prev]).size())) {           step *= 2;         }         for (; step > 0; step /= 2) {           if (pos + step < ((int)(works[prev]).size()) &&               cross(a[i], a[prev], a[works[prev][pos + step]]) <= 0) {             pos += step;           }         }         for (int k = 2; k <= m; ++k) {           dp[i][j][k] = max(j == 0 ? -LINF : dp[i][j - 1][k],                             dp[prev][pos][k - 1] + cross(o, a[prev], a[i]));         }       }       ans = max(ans, dp[i].back().back());     }     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<Point> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i].x >> a[i].y;     }     sort(a.begin(), a.end());     int64_t ans = 0;     for (int i = 0; i < n; ++i) {       ans = max(ans, solve(vector<Point>(a.begin() + i, a.end()), m));     }     cout << ans / 2;     if (ans % 2 == 0) {       cout <<  .00 n ;     } else {       cout <<  .50 n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, start, x;     cin >> n >> start >> x;     int ans = x;     int val, nt;     cout <<  ?   << start << endl;     cin >> val >> nt;     if (val >= x) {       cout <<  !   << val << endl;       return 0;     }     int best = start;     long long diff = x - val;     int step = sqrt(n);     start = ((rand() << 4 + rand()) % n + n) % n + 1;     bool was[n + 1];     fill(was, was + n + 1, 0);     for (int i = 0; i < min(1000, n / 2); i++) {       while (was[start]) {         start = ((rand() << 4 + rand()) % n + n) % n + 1;       }       was[start] = 1;       cout <<  ?   << start << endl;       cin >> val >> nt;       if (val < x and nt == -1) {         cout <<  !   << -1 << endl;         return 0;       }       if (val < x and x - val < diff) diff = x - val, best = start;     }     while (1) {       cout <<  ?   << best << endl;       cin >> val >> nt;       if (val < x and nt == -1) {         cout <<  !   << -1 << endl;         return 0;       }       if (val >= x) {         cout <<  !   << val << endl;         return 0;       }       best = nt;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:200000000 )   using namespace std;   template <typename T>   inline T Abs(T x) {     return (x >= 0) ? x : -x;   }   template <typename T>   inline T sqr(T x) {     return x * x;   }   template <typename T>   inline string toStr(T x) {     stringstream st;     st << x;     string s;     st >> s;     return s;   }   template <typename T>   inline int bit(T mask, int b) {     return (b >= 0 && (mask & (T(1) << b)) != 0) ? 1 : 0;   }   inline int nextInt() {     int x;     if (scanf( %d , &x) != 1) throw;     return x;   }   inline long long nextInt64() {     long long x;     if (scanf( %lld , &x) != 1) throw;     return x;   }   inline double nextDouble() {     double x;     if (scanf( %lf , &x) != 1) throw;     return x;   }   const int INF = (int)1E9;   const long long INF64 = (long long)1E18;   const long double EPS = 1E-9;   const long double PI = 3.1415926535897932384626433832795;   const int MAXN = 500100;   const int OSN = (1 << 19) - 1;   int n, lst[MAXN], rst[MAXN], tree[2 * OSN + 10], tree0[2 * OSN + 10];   vector<int> g[MAXN], st;   void DFS(int v, int prev) {     lst[v] = int(st.size());     st.push_back(v);     for (int i = 0; i < (int)(g[v].size()); i++) {       int u = g[v][i];       if (u != prev) DFS(u, v);     }     rst[v] = int(st.size() - 1);   }   void update(int v, int value) {     v += OSN;     tree[v] = value;     while (v > 0) {       v = (v - 1) >> 1;       tree[v] = max(tree[v], value);     }   }   void update(int v, int l, int r, int ll, int rr, int value) {     if (l > rr || ll > r || ll > rr) return;     if (ll <= l && r <= rr) {       tree0[v] = value;       return;     }     int mid = (l + r) >> 1;     update(2 * v + 1, l, mid, ll, rr, value);     update(2 * v + 2, mid + 1, r, ll, rr, value);   }   int getMax(int v, int l, int r, int ll, int rr) {     if (l > rr || ll > r || ll > rr) return 0;     if (ll <= l && r <= rr) return tree[v];     int mid = (l + r) >> 1;     return max(getMax(2 * v + 1, l, mid, ll, rr),                getMax(2 * v + 2, mid + 1, r, ll, rr));   }   int getMax(int v, int l, int r, int x) {     if (l > x || x > r) return 0;     if (l == r) return tree0[v];     int mid = (l + r) >> 1;     int ans = tree0[v];     ans = max(ans, getMax(2 * v + 1, l, mid, x));     ans = max(ans, getMax(2 * v + 2, mid + 1, r, x));     return ans;   }   int check(int v) {     int t0 = getMax(0, 0, OSN, lst[v], rst[v]);     int t1 = getMax(0, 0, OSN, lst[v]);     return int(t0 < t1);   }   int main() {     n = nextInt();     for (int i = 0; i < (int)(n - 1); i++) {       int v = nextInt() - 1;       int u = nextInt() - 1;       g[v].push_back(u);       g[u].push_back(v);     }     DFS(0, 0);     int q = nextInt();     for (int i = 0; i < (int)(q); i++) {       int type = nextInt();       int v = nextInt() - 1;       if (type == 1) update(0, 0, OSN, lst[v], rst[v], i + 1);       if (type == 2) update(lst[v], i + 1);       if (type == 3) printf( %d n , check(v));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const long long inf = (1ll << 60);   int n, m, k, cnt, a, b, v[N], p[N], ta[N], tb[N], td[N], ca[N << 2], cb[N << 2],       cd[N << 2], flag[N], pa, pb, pc, pd;   long long A[N], B[N], C[N], D[N], co[N], sum, ans = inf;   int read() {     int x = 0, f = 1;     char s;     while ((s = getchar()) >  9  || s <  0 )       if (s ==  - ) f = -1;     while (s <=  9  && s >=  0 )       x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();     return x * f;   }   bool cmp(const int a, const int b) { return v[a] < v[b]; }   void build(const int o, const int l, const int r) {     if (l == r) {       ca[o] = ta[l], cb[o] = tb[l], cd[o] = td[l];       return;     }     int mid = l + r >> 1;     build(o << 1, l, mid);     build(o << 1 | 1, mid + 1, r);     ca[o] = ca[o << 1 | 1];     cb[o] = cb[o << 1 | 1];     cd[o] = cd[o << 1 | 1];   }   long long query(const int o, const int l, const int r, const int need) {     if (l == r)       return A[max(need, ca[o])] + B[max(need, cb[o])] + D[cd[o]] -              co[l] * (max(need, ca[o]) + max(need, cb[o]) + cd[o] + k - need - m);     int mid = l + r >> 1;     long long t =         max(need, ca[o << 1]) + max(need, cb[o << 1]) + cd[o << 1] + k - need;     if (t >= m)       return query(o << 1, l, mid, need);     else       return query(o << 1 | 1, mid + 1, r, need);   }   int main() {     n = read(), m = read(), k = read();     for (int i = 1; i <= n; ++i) v[i] = read(), p[i] = i;     sort(p + 1, p + n + 1, cmp);     for (int i = 1; i <= n; ++i) {       if (i == 1 || co[cnt] < v[p[i]]) co[++cnt] = v[p[i]];       v[p[i]] = cnt;     }     a = read();     for (int i = 1; i <= a; ++i) b = read(), flag[b] |= 1;     a = read();     for (int i = 1; i <= a; ++i) b = read(), flag[b] |= 2;     for (int i = 1; i <= n; ++i) {       if (flag[i] == 0) D[++pd] = co[v[i]], ++td[v[i]];       if (flag[i] == 1) A[++pa] = co[v[i]], ++ta[v[i]];       if (flag[i] == 2) B[++pb] = co[v[i]], ++tb[v[i]];       if (flag[i] == 3) C[++pc] = co[v[i]];     }     sort(A + 1, A + pa + 1);     sort(B + 1, B + pb + 1);     sort(C + 1, C + pc + 1);     sort(D + 1, D + pd + 1);     for (int i = 1; i <= cnt; ++i)       ta[i] += ta[i - 1], tb[i] += tb[i - 1], td[i] += td[i - 1];     for (int i = 1; i <= pa; ++i) A[i] += A[i - 1];     for (int i = 1; i <= pb; ++i) B[i] += B[i - 1];     for (int i = 1; i <= pd; ++i) D[i] += D[i - 1];     build(1, 0, cnt);     for (int i = 0; i <= min(m, pc); ++i) {       sum += C[i];       if (min(pa, pb) >= k - i && 2 * k - 2 * i <= m - i && i + pa + pb + pd >= m)         ans = min(ans, sum + query(1, 0, cnt, k - i));     }     printf( %lld n , ans == inf ? -1 : ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int len, i;     bool chk = true;     string str;     cin >> str;     char ch =  a ;     len = str.size();     for (i = 0; i < len; i++) {       if (str[i] > ch) {         chk = false;         break;       } else if (str[i] == ch)         ch++;     }     chk ? printf( YES n ) : printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4e5 + 10;   long long gi() {     long long x = 0, o = 1;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) o = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * o;   }   int n, tt;   long long m, k, d[N];   pair<long long, long long> p[N];   int main() {     int T = gi();     while (T--) {       m = gi();       n = gi();       k = gi();       for (int i = 1; i <= n; i++) d[i] = gi();       d[++n] = m;       for (int i = n; i; i--) d[i] -= d[i - 1];       if (!k) {         cout << *max_element(d + 1, d + n + 1) - *min_element(d + 1, d + n + 1)              <<   n ;         continue;       }       long long l = 1, r = 1e15;       while (l < r) {         long long mid = (l + r + 1) >> 1, sum = 0;         for (int i = 1; i <= n; i++) {           sum += d[i] / mid - 1;           if (sum >= k) break;         }         if (sum >= k)           l = mid;         else           r = mid - 1;       }       long long mx = l;       l = 1, r = 1e15;       while (l < r) {         long long mid = (l + r) >> 1, sum = 0;         for (int i = 1; i <= n; i++) {           sum += (d[i] + mid - 1) / mid - 1;           if (sum > k) break;         }         if (sum <= k)           r = mid;         else           l = mid + 1;       }       long long mn = l;       tt = 0;       for (int i = 1; i <= n; i++) {         if ((d[i] + mn - 1) / mn > d[i] / mx) {           long long t = d[i] / mx;           p[++tt].first = d[i] / (t + 1);           t = (d[i] + mn - 1) / mn;           if (t == 1)             p[tt].second = 1e18;           else             p[tt].second = (d[i] + t - 2) / (t - 1);         }       }       sort(p + 1, p + tt + 1);       long long low = mn, ans = 1e18;       for (int i = 1, j; i <= tt; i = j + 1) {         j = i;         while (j < tt && p[j + 1].first == p[i].first) ++j;         ans = min(ans, low - p[i].first);         for (int k = i; k <= j; k++) low = max(low, p[k].second);       }       ans = min(ans, low - mx);       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 3.141592653589793238;   long long powmod(long long a, long long b) {     long long res = 1;     a %= 1000000007;     for (; b; b >>= 1) {       if (b & 1) res = res * a % 1000000007;       a = a * a % 1000000007;     }     return res;   }   char str[200005];   int lps[200005];   int kmp() {     int i = 0, j = 1, m = strlen(str);     lps[0] = 0;     while (j < m) {       while (i && str[i] != str[j]) {         i = lps[i - 1];       }       if (str[i] == str[j]) ++i;       lps[j++] = i;     }     if (m % (m - i) == 0) return (m - i);     return m;   }   int main() {     scanf( %s , str);     cout << kmp() << endl;     return 0;   }