Binary strings
Easy
Execution time limit is 1 second
Runtime memory usage limit is 256 megabytes
A binary string is a sequence composed solely of the characters '0' and '1'. A suffix of a string is formed by removing the first K (where K ≥ 0) characters from the original string. For instance, the suffixes of the string "1001" are "1001", "001", "01", "1", and the empty string.
You are provided with N binary strings. Your task is to determine how many pairs of these strings have one string as a suffix of the other.
Input
The first line contains an integer N (2 ≤ N ≤ 100000). Each of the following N lines contains one non-empty binary string. The total length of all strings combined does not exceed 200000.
Output
Output a single integer representing the number of such pairs.
Examples
Input #1
Answer #1
Submissions 60
Acceptance rate 28%