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

using namespace std;

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

deque<int> Q;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s;

    int len = s.length();
    int ctr = 1;
    bool type = isVowel(s[0]); // true jesli samogłoska
    for (int i = 1; i < len; i++) {
        if (isVowel(s[i]) == type) {
            ctr++;
            if (ctr >= 3) {
                Q.push_back(i);
            }
        } else {
            type = isVowel(s[i]);
            ctr = 1;
        }
    }
    
    long long sum = 0;
    for (int i = 0; i < len; i++) {
        int j = Q.front();
        if (i <= j - 2) {
            sum += (len - j);
            if (i == j - 2) {
                Q.pop_front();
            }
        }
    }
    cout << sum << "\n";
}