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
#include <cstdio>
#include <cstring>

const unsigned long long MaxLen = 200005LLU;

int main(void) {
	char wrd[MaxLen];
	unsigned long long len = 0, spBlk = 0, samBlk = 0, gapStart = 0,
						goodWords = 0, badWords = 0, gapLen;
	bool first = true;
	
	fgets(wrd,MaxLen,stdin);

	for(len=0;wrd[len]!='\n' && wrd[len]!='\0';++len) {
		switch(wrd[len]) {
			case 'a':
			case 'e':
			case 'i':
			case 'o':
			case 'u':
			case 'y':
				if(spBlk>2) { 
					gapStart = len-2;
				}

				if(samBlk==2 && len>2) {
					gapLen = len-gapStart;
					goodWords += gapLen*(gapLen-3)/2+1;
					gapStart = MaxLen;
				}

				spBlk = 0;
				++samBlk;
				break;
			default:
				if(samBlk>2) {
					gapStart = len-2;
				}

				if(spBlk==2 && len>2) {
					gapLen = len-gapStart;
					goodWords += gapLen*(gapLen-3)/2+1;
					gapStart = MaxLen;
				}

				samBlk = 0;
				++spBlk;
				break;
		}
	}

	if(gapStart<len && samBlk<3 && spBlk<3) {
		gapLen = len-gapStart;
		goodWords += gapLen*(gapLen-3)/2+1;
	}

	badWords = (len<3) ? 0 : (len*(len-3)/2+1-goodWords);
	printf("%llu\n",badWords);

	return 0;
}