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
#include <stdio.h>
#include <stdlib.h>

#define MAX_N 200000

char S[MAX_N + 10];

int isVowel(char c) {
    return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y' ? 1 : 0;
}

int main() {
    scanf("%s\n", S);
    int n = 0;
    while (n < MAX_N && S[n]) {
        n++;
    }

    unsigned long long res = 0;
    int count = 1;
    for (int i=1; i<n; i++) {
        int curVowel = isVowel(S[i]);
        int prevVowel = isVowel(S[i-1]);

        if (curVowel != prevVowel) {
            count = 1;
            continue;
        }

        count++;
        if (count == 3) { // e.g. kostka, i=4 -> left=3, right=2 -> res += left*right
            unsigned long long left = i - 1;
            unsigned long long right = n - i;
            res += left * right;
        } else if (count > 3) { // e.g. aaaabb, i=3 -> right=3 -> res += right
            unsigned long long right = n - i;
            res += right;
        }
    }
    printf("%lld\n", res);
    return 0;
}