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
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cmath>

using namespace std;

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

int main() {
  string s;
  cin >> s;
  if (s.size() < 3) {
    cout << 0 << endl;
    return 0;
  }

  int last = isVowel(s[0]) | (isVowel(s[1]) << 1) | (isVowel(s[2]) << 2); 
  long long result = 0;

  vector<int> limits;

  for (int i = 0; i < s.size()-2; ++i) {
    int last = isVowel(s[i]) | (isVowel(s[i+1]) << 1) | (isVowel(s[i+2]) << 2); 
    if (last == 0 || last == 7) {
      limits.push_back(i);
    }
  }

  limits.push_back(s.size());

  if (limits.size() == 1) { 
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < limits.size() - 1; ++i) {
    int tend = limits[i] + 2;
    int nend = min<int>(s.size(), limits[i+1]+2);
    result += (limits[i]+1) * (nend - tend);
  }

  cout << result << endl;

  return 0;
}