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

bool is_vowel(char c) {
    return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y';
}

int main(int argc, char** argv) {
    std::string input;
    std::cin >> input;
    const auto len = input.size();

    char c;
    size_t prev_center_idx = 0;
    size_t consecutive_vowels = 0;
    size_t consecutive_consonants = 0;
    size_t total = 0;
    for (size_t idx = 0; idx < len; idx++) {
        c = input[idx];
        if (is_vowel(c)) {
            consecutive_consonants = 0;
            consecutive_vowels += 1;
        }
        else {
            consecutive_vowels = 0;
            consecutive_consonants += 1;
        }

        if (consecutive_vowels >= 3 || consecutive_consonants >= 3) {
            size_t center_idx = idx - 1;
            total += (center_idx - prev_center_idx) * (len - center_idx - 1);
            prev_center_idx = center_idx;
        }
    }

    std::cout << total << std::endl;
    return 0;
}