Counting Substrings

Limits 1s, 512 MB

You are given a string t, a prefix p, and a suffix s. You have to find the number of distinct substrings starting with the prefix p and ending with the suffix s.

This is a companion discussion topic for the original entry at