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

void test()
{
    using namespace std;

    array<char, 256> types;
    types.fill('1');

    for (unsigned char c : "aeiouy")
        types[c] = '2';

    string word;
    cin >> word;

    for_each(word.begin(), word.end(), [&](char &c) { c = types[c]; });

    auto calculate = [&]() -> long long
    {
        if (word.size() < 3)
            return 0;

        long long answer = 0;

        const auto begin = word.begin();
        const auto end = word.end();

        auto it = begin+2;
        for (; it != end; ++it)
        {
            const bool is_seq = (*it == *prev(it) && *it == *prev(it, 2));

            if (is_seq) break;
        }

        auto last_seq = it;

        for (2; it != end; ++it)
        {
            const bool is_seq = (*it == *prev(it) && *it == *prev(it, 2));

            if (is_seq)
                last_seq = it;

            answer += distance(begin, last_seq)-1;
        }

        return answer;
    };

    cout << calculate() << '\n';
}

int main()
{   
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    test();
    return 0;
}