#K5001. Count Distinct Substrings

    ID: 28769 Type: Default 1000ms 256MiB

Count Distinct Substrings

Count Distinct Substrings

You are given a string (s) consisting of lowercase letters. Your task is to compute the number of distinct non-empty substrings of (s). A substring is defined as a contiguous sequence of characters within (s). Formally, any substring of (s) can be represented as (s[i:j]) for (0 \leq i < j \leq n), where (n) is the length of (s). For example, if (s = \texttt{abc}), the distinct substrings are: (\texttt{a}), (\texttt{b}), (\texttt{c}), (\texttt{ab}), (\texttt{bc}), and (\texttt{abc}) (a total of 6).

inputFormat

The input consists of a single line containing the string (s), which only includes lowercase English letters.

outputFormat

Output a single integer representing the number of distinct non-empty substrings of (s).## sample

abc
6