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
#include <iostream>
#include <algorithm>

//#define _DEBUG
#ifdef _DEBUG
#define CERR(n) cerr<<n
#else
#define CERR(n)
#endif

using namespace std;
#define WOVEL 1

string str;
const string wovels = "aeiouy";
inline bool isWovel(char c) {
	return std::binary_search(wovels.begin(), wovels.end(), c);
}

constexpr inline long long comb(long long k) {
	return k*(k+1)/2;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin>>str;
	char* c = &str[0];
	int n = str.size();
	int currentCount=0;
	int currentType = WOVEL;
	long long res=0LL;

	int rangeStart=0;

	for(int i=0;i<n;++i,++c) {
		if(currentType == isWovel(*c)) {
			if(++currentCount==3) {
				CERR(" [" << rangeStart<<","<<i<<") --> +"<<comb(i-rangeStart) << endl);
				res += comb((i-rangeStart));
			}
		}
		else {
			if(currentCount>2) {
				res += ((currentCount<<1)-7);
				CERR(" <" << currentCount <<"> --> +"<<(currentCount<<1)-7 << endl);
				rangeStart = i-2;
			}
			currentType = !currentType;
			currentCount = 1;
		}
	}
	if(currentCount>2) {
		CERR(" <" << currentCount <<"> --> +"<<(currentCount<<1)-7 << endl);
		res += ((currentCount<<1)-7);
		rangeStart = n-2;
	}
	CERR(" [" << rangeStart<<","<<n<<") --> +"<<comb(n-rangeStart) << endl);
	res += comb((n-rangeStart));

	CERR(comb(n)<<" - " <<res << " --> ");
	cout << (comb(n)-res);
	return 0;
}