#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 600000;
char st[maxn];
int f[maxn], len, i, dws[maxn], top;
struct node {node *ch[36], *f; int l, c; } a[maxn * 2], *head, *last, *b[maxn * 2];
void add(int x)
{
node *p = &a[++top], *mid = last;
last = p, p->l = mid->l + 1;
for (; mid && !mid->ch[x]; mid = mid->f) mid->ch[x] = p;
if (!mid) p->f = head; else
if (mid->l + 1 == mid->ch[x]->l) p->f = mid->ch[x]; else
{
node *q = mid->ch[x], *r = &a[++top];
*r = *q, r->l = mid->l + 1;
q->f = p->f = r;
for (; mid && mid->ch[x] == q; mid = mid->f) mid->ch[x] = r;
}
}
int main()
{
freopen("nsubstra.in", "r", stdin);
freopen("nsubstra.out", "w", stdout);
scanf("%s\n", st)\;
len = strlen(st);
head = last = &a[0];
for (i = 0; i < len; ++i) add(st[i] - 'a');
for (i = 0; i <= top; ++i) ++dws[a[i].l];
for (i = 1; i <= len; ++i) dws[i] += dws[i - 1];
for (i = 0; i <= top; ++i) b[--dws[a[i].l]] = &a[i];
for (last = head, i = 0; i < len; ++i)
(last = last->ch[st[i] - 'a'])->c++;
for (i = top; i > 0; --i)
{
f[b[i]->l] = max(f[b[i]->l], b[i]->c);
b[i]->f->c += b[i]->c;
}
for (i = len - 1; i > 0; --i)
f[i] = max(f[i + 1], f[i]);
for (i = 1; i <= len; ++i)
printf("%d\n", f[i]);
return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 600000;
char st[maxn];
int f[maxn], len, i, dws[maxn], top;
struct node {node *ch[36], *f; int l, c; } a[maxn * 2], *head, *last, *b[maxn * 2];
void add(int x)
{
node *p = &a[++top], *mid = last;
last = p, p->l = mid->l + 1;
for (; mid && !mid->ch[x]; mid = mid->f) mid->ch[x] = p;
if (!mid) p->f = head; else
if (mid->l + 1 == mid->ch[x]->l) p->f = mid->ch[x]; else
{
node *q = mid->ch[x], *r = &a[++top];
*r = *q, r->l = mid->l + 1;
q->f = p->f = r;
for (; mid && mid->ch[x] == q; mid = mid->f) mid->ch[x] = r;
}
}
int main()
{
freopen("nsubstra.in", "r", stdin);
freopen("nsubstra.out", "w", stdout);
scanf("%s\n", st)\;
len = strlen(st);
head = last = &a[0];
for (i = 0; i < len; ++i) add(st[i] - 'a');
for (i = 0; i <= top; ++i) ++dws[a[i].l];
for (i = 1; i <= len; ++i) dws[i] += dws[i - 1];
for (i = 0; i <= top; ++i) b[--dws[a[i].l]] = &a[i];
for (last = head, i = 0; i < len; ++i)
(last = last->ch[st[i] - 'a'])->c++;
for (i = top; i > 0; --i)
{
f[b[i]->l] = max(f[b[i]->l], b[i]->c);
b[i]->f->c += b[i]->c;
}
for (i = len - 1; i > 0; --i)
f[i] = max(f[i + 1], f[i]);
for (i = 1; i <= len; ++i)
printf("%d\n", f[i]);
return 0;
}