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
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

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

bool isTriple(const string & text, uint start) {
    return isVovel(text[start]) == isVovel(text[start + 1]) && isVovel(text[start]) == isVovel(text[start + 2]);
}

uint calcMin3Sets(uint start, uint end) {
    const uint size = end - start;
    return size < 3 ? 0 : (size + 1) * size / 2 - 2 * size + 1;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    vector<pair<uint, uint>> triples;
    string input;
    cin >> input;

    if (input.size() < 3) {
        cout << 0 << endl;
        return 0;
    }

    // wczytaj triples
    for (uint i = 0; i < input.size() - 2; i++) {
        if (isTriple(input, i)) {
            if (!triples.empty() && triples.back().second > i) {
                triples.back().second = i + 3;
            } else {
                triples.push_back(make_pair(i, i + 3));
            }
        }
    }

    //policz zbiory dozwolone
    uint allowed = input.size() * 2 - 1;  //wszystkie zbiory 1 i 2-elementowe
    uint from = 0;
    for (auto i = triples.begin(); i != triples.end(); i++) {
        allowed += calcMin3Sets(from, i->first + 2);
        from = i->second - 2;
    }
    allowed += calcMin3Sets(from, input.size());

    cout << (input.size() + 1) * (input.size()) / 2 - allowed << endl;
    return 0;
}