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
#include <iostream>
#include <ctype.h>

using namespace std;

bool isVowel(char c){
	c = tolower(c);
	string vowels = "aeiouy";
	for(char letter : vowels)
		if(c == letter)
			return true;
	return false;
}

const int MAX_N = 200005;
int word[MAX_N];
int wordSeq[MAX_N];
int leftSeq[MAX_N];
int rightSeq[MAX_N];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie();
	string s;
	cin>>s;
	int n = s.length();
	//convert to bits
	for(int i=0; i<n; ++i)
		word[i] = isVowel(s[i]);
	//find seq
	int seq = 1;
	int prev = word[0];
	
	for(int i=1; i<n; ++i){
		if(prev == word[i]){
			++seq;
			if(seq == 3){
				wordSeq[i-1] = 1;
				wordSeq[i-2] = 1;
			}
			if(seq >= 3){
				wordSeq[i] = 1;
			}
		}
		else{
			seq = 1;
		}
		prev = word[i];
	}
	//count seq from left
	
	int counter = wordSeq[0];
	for(int i=1; i<n; ++i){
		if(wordSeq[i]){
			++counter;
			leftSeq[i] = leftSeq[i-1] + 1;
		}
		else{
			if(counter >= 3){
				leftSeq[i-2] = leftSeq[i-3];
				leftSeq[i-1] = leftSeq[i-2];
			}
			leftSeq[i] = leftSeq[i-1];
			counter = 0;
		}
	}
	//count seq from right
	
	counter = wordSeq[n-1];
	for(int i=n-2; i>=0; --i){
		if(wordSeq[i]){
			++counter;
			rightSeq[i] = rightSeq[i+1] + 1;
		}
		else{
			if(counter >= 3){
				rightSeq[i+2] = rightSeq[i+3];
				rightSeq[i+1] = rightSeq[i+2];
			}
			rightSeq[i] = rightSeq[i+1];
			counter = 0;
		}
	}
	long long int result = 0;
	//calculate result
	prev = 0;
	for(int i=0; i<n; ++i){
		if(leftSeq[i] != prev){
			int res = (i+1) * (n-i-2);
			res -= (i+1) * rightSeq[i+3];
			res -= leftSeq[i-1] * (n-i-2);
			res += rightSeq[i+3] * leftSeq[i-1];
			//cout << i << "->" << (i+1) * (n-i-2) << " " << i * rightSeq[i+3] << " " << leftSeq[i-1] * (n-1) << " " << rightSeq[i+3] * leftSeq[i-1] << endl;
			result += res;
		}
		prev = leftSeq[i];
	}
	/*
	for(int i=0; i<n; ++i){
		cout<<leftSeq[i]<<" ";	
	}
	cout<<endl;
	for(int i=0; i<n; ++i){
		cout<<rightSeq[i]<<" ";	
	}
	//*/
	cout<<result<<endl;
}