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
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
const int maxN = 200001;

int tab[maxN];
bool hard[maxN];

int main ()
{
    string txt;
    int index = 0;
    int norm = 0;
    int vowelsCount = 0; // samogłoski
    int consCount = 0; // spółgłoski
    bool wasVowel = false; // czy samogłoska

    getline (cin, txt);

    char a = txt[txt.size() - 1];
    if (a =='a' || a =='e' || a =='i' || a =='o' || a =='u' || a == 'y') {
        txt = txt + "k";
    } else {
        txt = txt + "a";
    }

    for (int i = 0; i < txt.size(); i++) {
        char a = txt[i];

        if (a =='a' || a =='e' || a =='i' || a =='o' || a =='u' || a == 'y') {
            if (i == 0) { vowelsCount ++; wasVowel = true; }
            else {
                vowelsCount++;
                
                if (!wasVowel) {
                    if (consCount >= 3) {
                        if (tab[index] == 0) index --;
                        tab[index+1] = consCount;
                        hard[index+1] = true;
                        index +=2;
                    } else tab[index] += consCount;
                    
                    consCount = 0;
                }
            }
            wasVowel = true;
        } else {
            if (i == 0) { consCount ++; wasVowel = false; }
            else {
                consCount++;
                if (wasVowel) {
                    if (vowelsCount >= 3) {
                        if (tab[index] == 0) index --;
                        tab[index+1] = vowelsCount;
                        hard[index+1] = true;
                        index +=2;
                    } else tab[index] += vowelsCount;

                    vowelsCount = 0;
                }
            }

            wasVowel = false;
        }
    }

    if (tab[index] == 0) index --;

    // cout << " Index " << index << endl;

    long long sum = 0;

    for (int i = 0; i <= index; i++) {
        //cout << tab[i] << endl;
        // cout << "Sum = " << sum << endl;
        if (hard[i]) {
            // cout << "HArd" << endl;
            // nie jestem ostatni
            if (i != index) {
                // cout << " Nie ostatni " << endl;
                sum += (tab[i] + tab[i] - 1);
                // cout << sum << endl;
                // kolejny trudny
                if (hard[i+1]) {
                    sum += 10;
                    sum -= 3;
                    sum -= 3;
                }
            }
            // jestem ostatni
            else {
                // cout << "Ostatni" << endl;
                sum += (tab[i] + tab[i] - 1);
                // cout << sum << endl;
            }

        }
        // jest łatwe 
        else {
            // cout << "Easy" << endl;
            // nie jestem ostatni
            if (i != index) {
                // nie jestem pierwszy -> jestem w środku
                if (i != 0 ) { 
                    int prev = min(tab[i-1], 2);
                    int next = min(tab[i+1], 2);

                    int s = prev + tab[i] + next;

                    sum += (s * (s + 1) / 2);

                    sum -= (prev + prev - 1);
                    sum -= (next + next - 1);

                    continue;
                }
                
                // cout << "Nie ostatni" << endl;
                sum +=((tab[i] + min(tab[i+1], 2)) * (tab[i] + min(tab[i+1], 2) + 1)) / 2;
                // cout << sum << endl;
                sum -= (min(tab[i+1], 2) + min(tab[i+1], 2) - 1);
                // cout << sum << endl;
            }
            // jestem ostatni
            else {
                // nie jestem pierwszy
                if (i != 0 ) { 
                    int prev = min(tab[i-1], 2);

                    int s = prev + tab[i];

                    sum += (s * (s + 1) / 2);

                    sum -= (prev + prev - 1);

                    continue;
                }
                
                // cout << "Ostatni" << endl;
                sum += ((tab[i] * (tab[i] + 1)) / 2);
                // cout << sum << endl;
            }
        }
    }

    //cout << sum << endl;

    long long txtSize = txt.size() - 1;

    //cout << txtSize << endl;

    long long result = (txtSize * (txtSize + 1)) / 2;
    long long res = result - sum;
    cout << res;

    return 0;
}