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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <cstdio>
#include <string.h>

using namespace std;

int n;
char s[200003];
bool sam[26]={1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0};
int sm;
int sp;
int pocz;
long long int wyn;


int main()
{
    //scanf("%d",&n);
    scanf("%s",s);
    n=strlen(s);
    for( int i=0; i<n; i++ )
    {
        if( sam[s[i]-'a'] )
        {
            sm++;
            sp=0;
        }
        else
        {
            sp++;
            sm=0;
        }
        if( sp>=3 || sm>=3 )
        {
            wyn+=(long long int)(n-i)*(long long int)(i-pocz-1);
            pocz=i-1;
        }
    }
    cout << wyn;
    return 0;
}