<jupyter_start><jupyter_text>Префикс-функция. <NAME><jupyter_code># %%pixie_debugger
def prefix_function_trivial(s):
    n = len(s)
    pi = [0]*n
    for i in range(n):
        for k in range(0, i+1):
            if s[0:k] == s[i-k+1:(i-k+1)+k]:
                pi[i] = k
    return pi

print(prefix_function_trivial("aabaaab"))
print(prefix_function_trivial("aaaaaaa"))<jupyter_output>[0, 1, 0, 1, 2, 2, 3]
[0, 1, 2, 3, 4, 5, 6]<jupyter_text>Palindroms  [palindromes](https://e-maxx.ru/algo/palindromes_count)  <NAME><jupyter_code>def manaker_palindrom_find(s):
    l = 0, r = -1
    n = len(s)
    for i in range(n):
        k = 0
        if i > r:
            k = 1
        else:
            k = min(d1[l+r-i], r-i+1)
            while((i+k < n) and (i-k >= 0) and s[i+k] == s[i-k]):
                k += 1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17976190476190476, 'fraction_numerical': 0.03333333333333333, 'mean_word_length': 2.4048582995951415, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '448952', 'license': 'MIT', 'n_tokens_mistral': 398, 'n_tokens_neox': 371, 'n_words': 74, 'path': 'Strings.ipynb', 'repo_name': 'polyzer/py_algorithms', 'size': '874'}