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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <cstdio>
#include <iostream>
#include <string>

char samogloski[] = {'a', 'e', 'i', 'o', 'u', 'y'};
constexpr int samogloski_len = 6;

bool samogloska(char c) {
    for (int i = 0; i < samogloski_len; i++) {
        if(c == samogloski[i])
            return true;
    }
    return false;
}

void print(int* tab, size_t len) {
    printf("[%d", tab[0]);
    for (size_t i = 1; i < len; i++) {
        printf(", %d", tab[i]);
    }
    printf("]\n");
}

int main()
{
    char c;
    unsigned int all_possible = 0;
    unsigned int result = 0;
    std::string str;
    std::cin >> str;
    size_t len = str.length();
    // Count all possible fragments
    all_possible = len * (len + 1) / 2;
    // Remove those, which consists one or two letters
    all_possible -= (2 * len - 1);

    int *left_stats = new int[len];
    int *right_stats = new int[len];
    int counter_samogloski = 0;
    int counter_spolgloski = 0;
    for (int i = 0; i < len; i++) {
        if (samogloska(str[i])) {
            counter_samogloski += 1;
            if (counter_samogloski >= 3) {
                left_stats[i] = 1;
                right_stats[i - 2] = 1;
            }
            counter_spolgloski = 0;
        } else {
            counter_spolgloski += 1;
            if (counter_spolgloski >= 3) {
                left_stats[i] = 1;
                right_stats[i - 2] = 1;
            }
            counter_samogloski = 0;
        }
        
    }
    unsigned int left_safe_length = 0;
    unsigned int right_safe_length = 0;
    unsigned int word_count = 0;
    for (int i = 0; i <= len; i++) {
        if (i < len && left_stats[i] == 0) {
            left_safe_length += 1;
        } else {
            if (left_safe_length > 2) {
                word_count = left_safe_length * (left_safe_length + 1) / 2;
                word_count -= (2 * left_safe_length - 1);
                all_possible -= word_count;
            }
            left_safe_length = 0;
        }
        if (i < len && right_stats[i] == 0) {
        	right_safe_length += 1;
        } else {
        	if (right_safe_length > 2) {
        		word_count = right_safe_length * (right_safe_length + 1) / 2;
        		word_count -= (2 * right_safe_length -1);
        		all_possible -= word_count;
        	}
        	right_safe_length = 0;
        }
    }
    result = all_possible;
    printf("%d", result);
    if (right_stats) {
        delete[] right_stats;
        right_stats = nullptr;
    }
    if (left_stats) {
        delete[] left_stats;
        left_stats = nullptr;
    }
    return 0;
}