1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>

using namespace std;

int dane[200000], slownik[26]={1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string input;
    cin>>input;
    int n=input.size(),pocz=0;
    long long wynik=0;
    for(int i=0;i<n;++i)dane[i]=slownik[input[i]-'a'];
    for(int i=1;i<n-1;++i)
    {
        int suma=dane[i-1]+dane[i]+dane[i+1];
        if(suma==3||suma==0)
        {
            wynik+=((i-pocz)*(n-i-1));
            pocz=i;
        }
    }
    cout<<wynik;
    return 0;
}