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
#ifdef _MSC_VER
  #ifndef __GNUC__
    #pragma warning(disable: 4996)
  #endif
  #define main main0
#endif
#include <iostream>
#include <string>
using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  bool vowel = false;
  string vowels = "aeiouy";
  unsigned long long result = 0;
  string text;
  size_t first = 2, last = 0, pos = (size_t)-1;

  cin >> text;
  size_t length = text.length();

  do {
    if(vowel)
      pos = text.find_first_of(vowels, pos + 1);
    else
      pos = text.find_first_not_of(vowels, pos + 1);
    if(string::npos == pos)
      pos = length;
    vowel = !vowel;
    if(pos - last >= 3) {
      result += (unsigned long long)(last - first + 3) * (length - last - 2);
      if(pos - last > 3)  // pierwszy+ostatni: (length - first - 1) + (length - pos + 1) == length * 2 - first - pos
        result += (unsigned long long)(length * 2 - last - pos - 2) * (pos - last - 3) / 2;
      first = pos;
    }
    last = pos;
  } while(pos < length);

  cout << result << endl;

  return 0;
}