class DSU:
def __init__(self, n):
self.parent = list(range(n))
self.rank = [1] * n
self.components = n
def find(self, x):
if self.parent[x] != x:
self.parent[x] = self.find(self.parent[x])
return self.parent[x]
def union(self, x, y):
rootX = self.find(x)
rootY = self.find(y)
if rootX != rootY:
if self.rank[rootX] > self.rank[rootY]:
self.parent[rootY] = rootX
elif self.rank[rootX] < self.rank[rootY]:
self.parent[rootX] = rootY
else:
self.parent[rootY] = rootX
self.rank[rootX] += 1
self.components -= 1
return self.components
def minimum_string_length_for_components(s):
n = len(s)
results = [0] * n
for k in range(1, n + 1):
dsu = DSU(n)
substring_lengths = {}
for length in range(1, n + 1):
for start in range(n - length + 1):
substr = s[start:start + length]
if substr not in substring_lengths:
substring_lengths[substr] = length
for i in range(start, start + length - 1):
dsu.union(i, i + 1)
for substr in sorted(substring_lengths.keys(), key=lambda x: substring_lengths[x]):
length = substring_lengths[substr]
current_components = dsu.components
if current_components <= k:
results[k - 1] = length
break
for start in range(n - length + 1):
if s[start:start + length] == substr:
for i in range(start, start + length - 1):
dsu.union(i, i + 1)
return results
# Read input
import sys
input = sys.stdin.read
data = input().strip()
# Calculate and print results
results = minimum_string_length_for_components(data)
print(" ".join(map(str, results)))
Y2xhc3MgRFNVOgogICAgZGVmIF9faW5pdF9fKHNlbGYsIG4pOgogICAgICAgIHNlbGYucGFyZW50ID0gbGlzdChyYW5nZShuKSkKICAgICAgICBzZWxmLnJhbmsgPSBbMV0gKiBuCiAgICAgICAgc2VsZi5jb21wb25lbnRzID0gbgogICAgCiAgICBkZWYgZmluZChzZWxmLCB4KToKICAgICAgICBpZiBzZWxmLnBhcmVudFt4XSAhPSB4OgogICAgICAgICAgICBzZWxmLnBhcmVudFt4XSA9IHNlbGYuZmluZChzZWxmLnBhcmVudFt4XSkKICAgICAgICByZXR1cm4gc2VsZi5wYXJlbnRbeF0KICAgIAogICAgZGVmIHVuaW9uKHNlbGYsIHgsIHkpOgogICAgICAgIHJvb3RYID0gc2VsZi5maW5kKHgpCiAgICAgICAgcm9vdFkgPSBzZWxmLmZpbmQoeSkKICAgICAgICBpZiByb290WCAhPSByb290WToKICAgICAgICAgICAgaWYgc2VsZi5yYW5rW3Jvb3RYXSA+IHNlbGYucmFua1tyb290WV06CiAgICAgICAgICAgICAgICBzZWxmLnBhcmVudFtyb290WV0gPSByb290WAogICAgICAgICAgICBlbGlmIHNlbGYucmFua1tyb290WF0gPCBzZWxmLnJhbmtbcm9vdFldOgogICAgICAgICAgICAgICAgc2VsZi5wYXJlbnRbcm9vdFhdID0gcm9vdFkKICAgICAgICAgICAgZWxzZToKICAgICAgICAgICAgICAgIHNlbGYucGFyZW50W3Jvb3RZXSA9IHJvb3RYCiAgICAgICAgICAgICAgICBzZWxmLnJhbmtbcm9vdFhdICs9IDEKICAgICAgICAgICAgc2VsZi5jb21wb25lbnRzIC09IDEKICAgICAgICByZXR1cm4gc2VsZi5jb21wb25lbnRzCgpkZWYgbWluaW11bV9zdHJpbmdfbGVuZ3RoX2Zvcl9jb21wb25lbnRzKHMpOgogICAgbiA9IGxlbihzKQogICAgcmVzdWx0cyA9IFswXSAqIG4KICAgIGZvciBrIGluIHJhbmdlKDEsIG4gKyAxKToKICAgICAgICBkc3UgPSBEU1UobikKICAgICAgICBzdWJzdHJpbmdfbGVuZ3RocyA9IHt9CgogICAgICAgIGZvciBsZW5ndGggaW4gcmFuZ2UoMSwgbiArIDEpOgogICAgICAgICAgICBmb3Igc3RhcnQgaW4gcmFuZ2UobiAtIGxlbmd0aCArIDEpOgogICAgICAgICAgICAgICAgc3Vic3RyID0gc1tzdGFydDpzdGFydCArIGxlbmd0aF0KICAgICAgICAgICAgICAgIGlmIHN1YnN0ciBub3QgaW4gc3Vic3RyaW5nX2xlbmd0aHM6CiAgICAgICAgICAgICAgICAgICAgc3Vic3RyaW5nX2xlbmd0aHNbc3Vic3RyXSA9IGxlbmd0aAogICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICBmb3IgaSBpbiByYW5nZShzdGFydCwgc3RhcnQgKyBsZW5ndGggLSAxKToKICAgICAgICAgICAgICAgICAgICBkc3UudW5pb24oaSwgaSArIDEpCiAgICAgICAgCiAgICAgICAgZm9yIHN1YnN0ciBpbiBzb3J0ZWQoc3Vic3RyaW5nX2xlbmd0aHMua2V5cygpLCBrZXk9bGFtYmRhIHg6IHN1YnN0cmluZ19sZW5ndGhzW3hdKToKICAgICAgICAgICAgbGVuZ3RoID0gc3Vic3RyaW5nX2xlbmd0aHNbc3Vic3RyXQogICAgICAgICAgICBjdXJyZW50X2NvbXBvbmVudHMgPSBkc3UuY29tcG9uZW50cwogICAgICAgICAgICBpZiBjdXJyZW50X2NvbXBvbmVudHMgPD0gazoKICAgICAgICAgICAgICAgIHJlc3VsdHNbayAtIDFdID0gbGVuZ3RoCiAgICAgICAgICAgICAgICBicmVhawogICAgICAgICAgICBmb3Igc3RhcnQgaW4gcmFuZ2UobiAtIGxlbmd0aCArIDEpOgogICAgICAgICAgICAgICAgaWYgc1tzdGFydDpzdGFydCArIGxlbmd0aF0gPT0gc3Vic3RyOgogICAgICAgICAgICAgICAgICAgIGZvciBpIGluIHJhbmdlKHN0YXJ0LCBzdGFydCArIGxlbmd0aCAtIDEpOgogICAgICAgICAgICAgICAgICAgICAgICBkc3UudW5pb24oaSwgaSArIDEpCiAgICAKICAgIHJldHVybiByZXN1bHRzCgojIFJlYWQgaW5wdXQKaW1wb3J0IHN5cwppbnB1dCA9IHN5cy5zdGRpbi5yZWFkCmRhdGEgPSBpbnB1dCgpLnN0cmlwKCkKCiMgQ2FsY3VsYXRlIGFuZCBwcmludCByZXN1bHRzCnJlc3VsdHMgPSBtaW5pbXVtX3N0cmluZ19sZW5ndGhfZm9yX2NvbXBvbmVudHMoZGF0YSkKcHJpbnQoIiAiLmpvaW4obWFwKHN0ciwgcmVzdWx0cykpKQo=