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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <bits/stdc++.h>

using namespace std;

const int totalSize = 200010;
int values[totalSize];
int nextInvalid[totalSize];

int letters[200];

int main(int argc, char** argv)
{
	ios::sync_with_stdio( false );

    letters[(int)'a'] = 1;
    letters[(int)'e'] = 1;
    letters[(int)'i'] = 1;
    letters[(int)'o'] = 1;
    letters[(int)'u'] = 1;
    letters[(int)'y'] = 1;
    

    string text;
    cin >> text;
    int size = text.size();
    
    fill(values, values + size, -1);
    
    for (size_t i=2; i<text.size(); ++i)
    {
        int v = letters[(int)text[i-2]] + letters[(int)text[i-1]] + letters[(int)text[i]];
        
        if (v == 0 || v == 3)
        {
            values[i-2] = 1;
        }
        else
        {
            values[i-2] = -1;
        }
    }
    
    fill(nextInvalid, nextInvalid+size, -1);
    
    int index = size-1;
    int prev = -1;
    while(index >= 0)
    {
        if (values[index] == 1)
        {
            nextInvalid[index] = 0;
            prev = 0;
        }
        else
        {
            if (prev == -1)
                nextInvalid[index] = -1;
            else
                nextInvalid[index] = ++prev;
        }
        index--;
    }
    
    long long sumAll = 0;
    for (int i=0; i<size; ++i)
    {
        if (nextInvalid[i] == -1)
            continue;
        
        int v = size - i - 2 - nextInvalid[i];
     
        sumAll += v;
    }
    printf("%lld\n", sumAll);
        

    return 0;
}