Problems
10130 - Contiguous
SUBMIT PROBLEM

Contiguous

Time Limit: 1 sec

 

The Problem

You will be given a string S, You need to find count of all contiguous substrings starting and ending with same character.

 

For example,

If a string is "abcab" then the count of all contiguous substrings starting and ending with same character is 7.
There are 15 substrings of "abcab" a, ab, abc, abca, abcab, b, bc, bca , bcab, c, ca, cab, a, ab, b Out of the above substrings, there  are 7 substrings : a, abca, b, bcab, c, a and b.

 

The Input

There will be several line of inputs. Each line contains a string with lowercase alphabets.There will not be any white spaces. The length of a string not more than 250. Input is terminated by EOF.

 

The Output

For each line of input.You need to show the count of all contiguous substrings starting and ending with same character in a separate line.

 

Sample Input

abcab

accdab

 

Sample Output

7

8

 

 

 

[Outsbook Round #1 Online Contest]

Problem Setter: Parag Paul