#define PROBLEM "https://judge.yosupo.jp/problem/zalgorithm"
#include"template.hpp"
#include"string/z-algorithm.hpp"intmain(){strings;cin>>s;for(autox:z_algorithm(s))cout<<x<<" ";}
#line 1 "verify/yosupo/string/zalgorithm.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/zalgorithm"
#line 2 "template.hpp"
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>usingnamespacestd;usingnamespace__gnu_pbds;usingll=longlong;usingdb=longdouble;usingvi=vector<int>;usingvl=vector<ll>;usingvd=vector<db>;usingpii=pair<int,int>;usingpll=pair<ll,ll>;usingpdd=pair<db,db>;constintINF=INT_MAX/2;constintMOD=998244353;constintMOD2=1000000007;constllLINF=LLONG_MAX/2;constdbDINF=numeric_limits<db>::infinity();constdbEPS=1e-9;constdbPI=acos(db(-1));template<classT>usingordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;template<classT>usingordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;mt19937rng(chrono::steady_clock::now().time_since_epoch().count());mt19937_64rng64(chrono::steady_clock::now().time_since_epoch().count());#line 2 "string/z-algorithm.hpp"
/**
* Author: Teetat T.
* Date: 2024-06-14
* Description: Z Algorithm. z[i] := the length of the longest common prefix between s and s[i:].
*/template<classSTR>vector<int>z_algorithm(constSTR&s){intn=(int)s.size();vector<int>z(n);z[0]=n;for(inti=1,l=0,r=1;i<n;i++){if(i<r)z[i]=min(r-i,z[i-l]);while(i+z[i]<n&&s[z[i]]==s[i+z[i]])z[i]++;if(i+z[i]>r)l=i,r=i+z[i];}returnz;}#line 4 "verify/yosupo/string/zalgorithm.test.cpp"
intmain(){strings;cin>>s;for(autox:z_algorithm(s))cout<<x<<" ";}