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
// Grzegorz Bukowiec
// Potyczki Algorytmiczne 2018
// Zadanie 1B - Jezyk polski

#include <iostream>
#include <vector>
#include <string>
using namespace std;

enum Type { VOWEL, CONSONANT, MIXED };
struct Block {
	Type type;
	unsigned start;
	unsigned end;
	
	Block(Type t, unsigned s, unsigned e) {
		type = t;
		start = s;
		end = e;
	}
};

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

bool areConflicting(char a, char b) {
	return (isVowel(a) && isVowel(b)) || (!isVowel(a) && !isVowel(b));
}

bool areConflicting(char a, char b, char c) {
	return areConflicting(a, b) && areConflicting(a, c);
}

long long words(int start, int end) {
	long long length = end - start + 1;
	return length * (length + 1) / 2;
}

long long shortWords(int start, int end) {
	long long length = end - start + 1;
	return 2 * length - 1;
}

int main() {
	string wishes;
	cin >> wishes;
	vector<Block> badBlocks;
	
	for (int i = 0; i < (int)wishes.size() - 2; ++i) {
		if (areConflicting(wishes[i], wishes[i + 1], wishes[i + 2])) {
			unsigned j = i + 2;
			for ( ; j < wishes.size() - 1; ++j) {
				if (!areConflicting(wishes[j], wishes[j + 1])) {
					break;
				}
			}
			badBlocks.push_back(Block(isVowel(wishes[i]) ? VOWEL : CONSONANT, i, j));
			i = j;
		}
	}
	
	/*for (unsigned i = 0; i < badBlocks.size(); ++i) {
		cout << (badBlocks[i].type == VOWEL ? 'V' : 'C') << " " << badBlocks[i].start << "-" << badBlocks[i].end << endl;
	}*/
	
	long long allWords = words(0, wishes.size() - 1);
	long long goodWords = 0;
	
	if (badBlocks.empty()) {
		goodWords = allWords;
	} else if (badBlocks.front().start > 0) {
		goodWords += words(0, badBlocks.front().start + 1) - 3;
	}
	for (unsigned i = 1; i < badBlocks.size(); ++i) {
		goodWords += words(badBlocks[i - 1].end - 1, badBlocks[i].start + 1) - 6;
	}
	if (!badBlocks.empty() && badBlocks.back().end < wishes.size() - 1) {
		goodWords += words(badBlocks.back().end - 1, wishes.size() - 1) - 3;
	}
	
	for (unsigned i = 0; i < badBlocks.size(); ++i) {
		goodWords += shortWords(badBlocks[i].start, badBlocks[i].end);
	}
	
	cout << allWords - goodWords;
	
	return 0;
}