Count is one of WNJXYK’s favorite tasks. Recently, he had a very long string and he wondered that how many substrings which contains exactly one kind of lowercase in this long string. But this string is so long that he had kept counting for several days. His friend Kayaking wants to help him, so he turns to you for help.
Input
The input starts with one line contains exactly one positive integer TT which is the number of test cases.
Each test case contains one line with a string which you need to do a counting task on.
Output
For each test case, output one line containing “y” where y is the number of target substrings.
Sample Input
3
qwertyuiop
qqwweerrttyyuuiioopp
aaaaaaaaaa
Sample Output
10
30
55
Hint
1<=T<=20,1<=len(string)<=105,1<=∑len(string)<=105
Strings only contain lowercase English letters.

ac

#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int v[20089],s[2],m;
int dp[20089][50];
int main(){
long long int n,s,sum;
char x;
string a;
cin>>n;
while(n--)
{
s=0,sum=0;
cin>>a;
a+='0';
x=a[0];
for(int i=0;i<a.size();i++)
{
if(a[i]==x)
{
s++;
}
else
{
sum+=s*(s+1)/2;
x=a[i];
s=1;
}
}
cout<<sum<<endl;
}
}