atcoder#AGC047B. [AGC047B] First Second
[AGC047B] First Second
Score : points
Problem Statement
Limak can repeatedly remove one of the first two characters of a string, for example $abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx$.
You are given different strings . Among pairs , in how many pairs could Limak obtain one string from the other?
Constraints
- consists of lowercase English letters
a
-z
.
Input
Input is given from Standard Input in the following format.
Output
Print the number of unordered pairs where and Limak can obtain one string from the other.
3
abcxyx
cyx
abc
1
The only good pair is .
6
b
a
abc
c
d
ab
5
There are five good pairs: , , , , .