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
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
using ll = long long;

bool is_vowel(char c) {
    const vector<char> vowels = {'a', 'e', 'i', 'o', 'u', 'y'};
    for (auto vowel : vowels) {
        if (c == vowel) {
            return true;
        }
    }
    return false;
}

ll count_bad_subwords(const string& s) {
    int n = s.size();
    vector<int> letter_type(n);
    for (int i = 0; i < n; ++i) {
        letter_type[i] = is_vowel(s[i]);
    }
    deque<int> bad_triples;
    for (int i = 0; i+2 < n; ++i) {
        if (letter_type[i] == letter_type[i+1]
                and letter_type[i+1] == letter_type[i+2]) {
            bad_triples.push_back(i);
        }
    }
    ll res = 0;
    for (int i = 0; i < n and !bad_triples.empty(); ++i) {
        auto triple_start = bad_triples.front();
        auto triple_end = triple_start+2;
        res += n-triple_end;
        if (triple_start == i) {
            bad_triples.pop_front();
        }
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    auto res = count_bad_subwords(s);
    cout << res << endl;
    return 0;
}