Problem:
Score : 100 points

Problem Statement

You are given a string of length N. Calculate the number of distinct substrings of S.

Constraints

1 \leq N \leq 500,000

S consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

Print the answer.

Sample Input 1

abcbcba

Sample Output 1

21

Sample Input 2

mississippi

Sample Output 2

53

Sample Input 3

ababacaca

Sample Output 3

33

Sample Input 4

aaaaa

Sample Output 4

5

Solution in C# (.NET Core 3.1.201) (judge verdict: Runtime Error)

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ProblemD
    {
        static bool SAIKI = true;
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var S = NS;
            var lcpAry = LIB_String.LCPArray(S);
            Console.WriteLine(S.Length * (S.Length + 1) / 2 - lcpAry.Sum());
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static LIB_FastIO fastio = new LIB_FastIODebug();
        static public void Main(string[] args) { if (args.Length == 0) { fastio = new LIB_FastIO(); Console.SetOut(new Printer(Console.OpenStandardOutput())); } if (SAIKI) { var t = new Thread(Solve, 134217728); t.Start(); t.Join(); } else Solve(); Console.Out.Flush(); }
        static long NN => fastio.Long();
        static double ND => fastio.Double();
        static string NS => fastio.Scan();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static IOrderedEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x, _ => xorshift);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x) => Enumerable.OrderBy(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderBy<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderBy(x.OrderByRand(), selector);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x) => Enumerable.OrderByDescending(x.OrderByRand(), e => e);
        static IOrderedEnumerable<T1> OrderByDescending<T1, T2>(this IEnumerable<T1> x, Func<T1, T2> selector) => Enumerable.OrderByDescending(x.OrderByRand(), selector);
        static IOrderedEnumerable<string> OrderBy(this IEnumerable<string> x) => x.OrderByRand().OrderBy(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderBy<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderBy(selector, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<string> OrderByDescending(this IEnumerable<string> x) => x.OrderByRand().OrderByDescending(e => e, StringComparer.OrdinalIgnoreCase);
        static IOrderedEnumerable<T> OrderByDescending<T>(this IEnumerable<T> x, Func<T, string> selector) => x.OrderByRand().OrderByDescending(selector, StringComparer.OrdinalIgnoreCase);
        static string Join<T>(this IEnumerable<T> x, string separator = "") => string.Join(separator, x);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
    class LIB_FastIO
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIO() { str = Console.OpenStandardInput(); }
        readonly Stream str;
        readonly byte[] buf = new byte[1024];
        int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return isEof; }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        byte read()
        {
            if (isEof) throw new EndOfStreamException();
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0)
                {
                    isEof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        virtual public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    class LIB_FastIODebug : LIB_FastIO
    {
        Queue<string> param = new Queue<string>();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_FastIODebug() { }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override string Scan() => NextString();
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override long Long() => long.Parse(NextString());
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override double Double() => double.Parse(NextString());
    }
    class LIB_Bitset : IEquatable<LIB_Bitset>
    {
        long n;
        ulong[] ary;
        static readonly ulong[] ceil;
        static LIB_Bitset()
        {
            ceil = new ulong[64];
            ceil[0] = 0xffffffffffffffff;
            ceil[1] = 1;
            for (var i = 2; i < 64; i++)
            {
                ceil[i] = (ceil[i - 1] << 1) | 1;
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public LIB_Bitset(long size)
        {
            if (size <= 0) throw new Exception();
            n = size;
            ary = new ulong[((n - 1) >> 6) + 1];
        }
        public long Count => n;
        public long PopCount => ary.Sum(e => LIB_BitUtil.PopCount(e));
        public bool this[int idx]
        {
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            get { return LIB_BitUtil.IsSet(ary[idx >> 6], idx & 63); }
            [MethodImpl(MethodImplOptions.AggressiveInlining)]
            set
            {
                if (value) ary[idx >> 6] |= LIB_BitUtil.BitMask[idx & 63];
                else ary[idx >> 6] &= ~LIB_BitUtil.BitMask[idx & 63];
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Bitset operator &(LIB_Bitset x, LIB_Bitset y)
        {
            if (x.n < y.n) { var t = x; x = y; y = t; }
            var ret = new LIB_Bitset(x.n);
            for (var i = 0; i < ret.ary.Length; i++) ret.ary[i] = x.ary[i];
            for (var i = 0; i < y.ary.Length; i++) ret.ary[i] &= y.ary[i];
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Bitset operator |(LIB_Bitset x, LIB_Bitset y)
        {
            if (x.n < y.n) { var t = x; x = y; y = t; }
            var ret = new LIB_Bitset(x.n);
            for (var i = 0; i < ret.ary.Length; i++) ret.ary[i] = x.ary[i];
            for (var i = 0; i < y.ary.Length; i++) ret.ary[i] |= y.ary[i];
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Bitset operator ^(LIB_Bitset x, LIB_Bitset y)
        {
            if (x.n < y.n) { var t = x; x = y; y = t; }
            var ret = new LIB_Bitset(x.n);
            for (var i = 0; i < ret.ary.Length; i++) ret.ary[i] = x.ary[i];
            for (var i = 0; i < y.ary.Length; i++) ret.ary[i] ^= y.ary[i];
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Bitset operator &(LIB_Bitset x, long y)
        {
            var ret = new LIB_Bitset(x.n);
            for (var i = 0; i < ret.ary.Length; i++) ret.ary[i] = x.ary[i];
            ret.ary[0] &= (ulong)y;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Bitset operator |(LIB_Bitset x, long y)
        {
            var ret = new LIB_Bitset(x.n);
            for (var i = 0; i < ret.ary.Length; i++) ret.ary[i] = x.ary[i];
            ret.ary[0] |= (ulong)y;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Bitset operator ^(LIB_Bitset x, long y)
        {
            var ret = new LIB_Bitset(x.n);
            for (var i = 0; i < ret.ary.Length; i++) ret.ary[i] = x.ary[i];
            ret.ary[0] ^= (ulong)y;
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void Flip()
        {
            for (var i = 0; i < ary.Length; i++) ary[i] = ~ary[i];
            ary[ary.Length - 1] &= ceil[n & 63];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Bitset operator ~(LIB_Bitset x)
        {
            var ret = new LIB_Bitset(x.n);
            for (var i = 0; i < ret.ary.Length; i++) ret.ary[i] = ~x.ary[i];
            ret.ary[ret.ary.Length - 1] &= ceil[ret.n & 63];
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void ShiftLeft(int num)
        {
            var moveCnt = num >> 6;
            var moveBit = num & 63;
            for (var i = ary.Length - 1; i >= moveCnt; i--)
            {
                ary[i] = ary[i - moveCnt] << moveBit;
                if (moveBit > 0 && i > moveCnt) ary[i] |= ary[i - moveCnt - 1] >> (64 - moveBit);
            }
            ary[ary.Length - 1] &= ceil[n & 63];
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Bitset operator <<(LIB_Bitset x, int num)
        {
            var ret = new LIB_Bitset(x.n);
            var moveCnt = num >> 6;
            var moveBit = num & 63;
            for (var i = ret.ary.Length - 1; i >= moveCnt; i--)
            {
                ret.ary[i] = x.ary[i - moveCnt] << moveBit;
                if (moveBit > 0 && i > moveCnt) ret.ary[i] |= x.ary[i - moveCnt - 1] >> (64 - moveBit);
            }
            ret.ary[ret.ary.Length - 1] &= ceil[ret.n & 63];
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void ShiftRight(int num)
        {
            var moveCnt = num >> 6;
            var moveBit = num & 63;
            var aryMax = ary.Length - moveCnt;
            for (var i = 0; i < aryMax; i++)
            {
                ary[i] = ary[i + moveCnt] >> moveBit;
                if (moveBit > 0 && i < aryMax - 1) ary[i] |= ary[i + moveCnt + 1] << (64 - moveBit);
            }
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public LIB_Bitset operator >>(LIB_Bitset x, int num)
        {
            var ret = new LIB_Bitset(x.n);
            var moveCnt = num >> 6;
            var moveBit = num & 63;
            var aryMax = ret.ary.Length - moveCnt;
            for (var i = 0; i < aryMax; i++)
            {
                ret.ary[i] = x.ary[i + moveCnt] >> moveBit;
                if (moveBit > 0 && i < aryMax - 1) ret.ary[i] |= x.ary[i + moveCnt + 1] << (64 - moveBit);
            }
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public bool operator ==(LIB_Bitset x, LIB_Bitset y)
        {
            if (x.n < y.n) { var t = x; x = y; y = t; }
            var i = 0;
            for (; i < y.ary.Length; i++) if (x.ary[i] != y.ary[i]) return false;
            for (; i < x.ary.Length; i++) if (x.ary[i] != 0) return false;
            return true;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public bool operator !=(LIB_Bitset x, LIB_Bitset y) => !(x == y);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public bool Equals(LIB_Bitset x) => x == this;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override bool Equals(object x) => x == null ? false : Equals((LIB_Bitset)x);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public override int GetHashCode()
        {
            var t = ary.Aggregate((a, x) => a ^ x);
            return (int)(((t >> 32) ^ t) & 0x00000000ffffffff);
        }
    }
    class LIB_BitUtil
    {
        public static readonly ulong[] BitMask;
        static LIB_BitUtil()
        {
            BitMask = new ulong[64];
            BitMask[0] = 1;
            for (var i = 1; i < 64; i++) BitMask[i] = BitMask[i - 1] << 1;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public IEnumerable<long> ScanOne(long value)
        {
            for (; value > 0; value &= value - 1) yield return value & -value;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long PopCount(ulong value)
        {
            value = (value & 0x5555555555555555) + ((value >> 1) & 0x5555555555555555);
            value = (value & 0x3333333333333333) + ((value >> 2) & 0x3333333333333333);
            value = (value & 0x0f0f0f0f0f0f0f0f) + ((value >> 4) & 0x0f0f0f0f0f0f0f0f);
            value = (value & 0x00ff00ff00ff00ff) + ((value >> 8) & 0x00ff00ff00ff00ff);
            value = (value & 0x0000ffff0000ffff) + ((value >> 16) & 0x0000ffff0000ffff);
            value = (value & 0x00000000ffffffff) + ((value >> 32) & 0x00000000ffffffff);
            return (long)value;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public long PopCount(long value) => PopCount((ulong)value);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public bool IsSet(ulong value, int idx) => (value & BitMask[idx]) != 0;
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static public bool IsSet(long value, int idx) => IsSet((ulong)value, idx);
    }
    class LIB_String
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static int[] ZAlgorithm(long[] s)
        {
            var ret = new int[s.Length];
            ret[0] = s.Length;
            int i = 1, j = 0;
            while (i < s.Length)
            {
                while (i + j < s.Length && s[j] == s[i + j]) ++j;
                ret[i] = j;
                if (j == 0) { ++i; continue; }
                var k = 1;
                while (i + k < s.Length && k + ret[k] < j) { ret[i + k] = ret[k]; ++k; }
                i += k; j -= k;
            }
            return ret;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static int[] SAIS(int[] s, int upper)
        {
            var n = s.Length;
            if (n == 0) return new int[0];
            if (n == 1) return new[] { 0 };
            if (n == 2)
            {
                if (s[0] < s[1]) return new[] { 0, 1 };
                return new[] { 1, 0 };
            }
            var ls = new bool[n];
            for (var i = n - 2; i >= 0; --i)
            {
                ls[i] = s[i] == s[i + 1] ? ls[i + 1] : s[i] < s[i + 1];
            }
            var suml = new int[upper + 1];
            var sums = new int[upper + 1];
            for (var i = 0; i < n; ++i)
            {
                if (!ls[i]) ++sums[s[i]];
                else ++suml[s[i] + 1];
            }
            for (var i = 0; i <= upper; ++i)
            {
                sums[i] += suml[i];
                if (i < upper) suml[i + 1] += sums[i];
            }
            var sa = new int[n];
            Action<int[]> induce = plms =>
            {
                for (var i = 0; i < sa.Length; i++) sa[i] = -1;
                var buf = sums.ToArray();
                foreach (var d in plms)
                {
                    if (d == n) continue;
                    sa[buf[s[d]]++] = d;
                }
                for (var i = 0; i < buf.Length; i++) buf[i] = suml[i];
                sa[buf[s[n - 1]]++] = n - 1;
                for (var i = 0; i < n; ++i)
                {
                    var v = sa[i];
                    if (v >= 1 && !ls[v - 1]) sa[buf[s[v - 1]]++] = v - 1;
                }
                for (var i = 0; i < buf.Length; i++) buf[i] = suml[i];
                for (var i = n - 1; i >= 0; --i)
                {
                    var v = sa[i];
                    if (v >= 1 && ls[v - 1]) sa[--buf[s[v - 1] + 1]] = v - 1;
                }
            };
            var lmsMap = new int[n + 1];
            lmsMap[0] = lmsMap[n] = -1;
            var m = 0;
            for (var i = 1; i < n; i++)
            {
                if (!ls[i - 1] && ls[i]) lmsMap[i] = m++;
                else lmsMap[i] = -1;
            }
            var lms = new int[m];
            var lmsIdx = -1;
            for (var i = 1; i < n; ++i)
            {
                if (!ls[i - 1] && ls[i]) lms[++lmsIdx] = i;
            }
            induce(lms);
            if (m > 0)
            {
                var sortedLms = new int[m];
                var sortedLmsIdx = -1;
                foreach (var v in sa)
                {
                    if (lmsMap[v] != -1) sortedLms[++sortedLmsIdx] = v;
                }
                var recs = new int[m];
                var recUpper = 0;
                recs[lmsMap[sortedLms[0]]] = 0;
                for (var i = 1; i < m; ++i)
                {
                    var l = sortedLms[i - 1];
                    var r = sortedLms[i];
                    var endl = lmsMap[l] + 1 < m ? lms[lmsMap[l] + 1] : n;
                    var endr = lmsMap[r] + 1 < m ? lms[lmsMap[r] + 1] : n;
                    var same = true;
                    if (endl - l != endr - r) same = false;
                    else
                    {
                        while (l < endl)
                        {
                            if (s[l] != s[r]) break;
                            ++l; ++r;
                        }
                        if (l == n || s[l] != s[r]) same = false;
                    }
                    if (!same) ++recUpper;
                    recs[lmsMap[sortedLms[i]]] = recUpper;
                }

                var recsa = SAIS(recs, recUpper);
                for (var i = 0; i < m; ++i) sortedLms[i] = lms[recsa[i]];
                induce(sortedLms);
            }
            return sa;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static int[] SuffixArray(long[] ary)
        {
            var idx = new int[ary.Length];
            var s2 = new int[ary.Length];
            for (var i = 0; i < idx.Length; i++) idx[i] = i;
            Array.Sort(idx, (x, y) => ary[x].CompareTo(ary[y]));
            var now = 0;
            s2[idx[0]] = now;
            for (var i = 1; i < idx.Length; ++i)
            {
                if (ary[idx[i - 1]] != ary[idx[i]]) ++now;
            }
            return SAIS(s2, now);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static int[] SuffixArray(string s)
        {
            var s2 = new int[s.Length];
            for (var i = 0; i < s.Length; i++) s2[i] = (int)s[i];
            return SAIS(s2, 255);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        static int[] LCPArray(int[] ary, int[] sa)
        {
            var rnk = new int[ary.Length];
            for (var i = 0; i < rnk.Length; ++i) rnk[sa[i]] = i;
            var lcp = new int[ary.Length - 1];
            var h = 0;
            for (var i = 0; i < rnk.Length; ++i)
            {
                if (h > 0) --h;
                if (rnk[i] == 0) continue;
                var j = sa[rnk[i] - 1];
                for (; j + h < ary.Length && i + h < ary.Length; ++h)
                {
                    if (ary[j + h] != ary[i + h]) break;
                }
                lcp[rnk[i] - 1] = h;
            }
            return lcp;
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static int[] LCPArray(long[] ary, int[] suffixArray) => LCPArray(ary.Select(e => (int)e).ToArray(), suffixArray);
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static int[] LCPArray(long[] ary) => LCPArray(ary.Select(e => (int)e).ToArray(), SuffixArray(ary));
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static int[] LCPArray(string s, int[] suffixArray)
        {
            var s2 = new int[s.Length];
            for (var i = 0; i < s.Length; i++) s2[i] = (int)s[i];
            return LCPArray(s2, suffixArray);
        }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static int[] LCPArray(string s)
        {
            var s2 = new int[s.Length];
            for (var i = 0; i < s.Length; i++) s2[i] = (int)s[i];
            var sa = SAIS(s2, 255);
            return LCPArray(s2, sa);
        }
        /// <summary>
        /// 入力の各要素は0以上。-1の要素は任意と一致。
        /// マッチした位置の1文字目の位置を0-indexedで返す
        /// </summary>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public static List<int> ShiftAnd(long[] s, long[] t)
        {
            var finish = new LIB_Bitset(t.Length);
            finish[t.Length - 1] = true;
            var mask = s.Where(e => e >= 0).Distinct().ToDictionary(e => e, _ => new LIB_Bitset(t.Length));
            var fil = new LIB_Bitset(t.Length);
            mask[-1] = ~fil;
            fil |= 1;
            foreach (var item in t)
            {
                if (item >= 0 && mask.ContainsKey(item)) mask[item] |= fil;
                if (item == -1) foreach (var item2 in mask.Keys.ToArray()) mask[item2] |= fil;
                fil <<= 1;
            }
            var state = new LIB_Bitset(s.Length);
            var ret = new List<int>();
            for (var i = 0; i < s.Length; i++)
            {
                state = ((state << 1) | 1) & mask[s[i]];
                if ((state & finish) == finish) ret.Add(i - t.Length + 1);
            }
            return ret;
        }
    }
}