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

using namespace std;

  bool isEnd(int character) {
    return character == -1 || character == 10 || character == 13;
  }

  int main() {
    bool vowels[128];
    for (int i = 0; i < 128; i++) {
      vowels[i] = false;
    }
    vowels['a'] = true;
    vowels['e'] = true;
    vowels['i'] = true;
    vowels['o'] = true;
    vowels['u'] = true;
    vowels['y'] = true;

    int letter = getchar();
    long vowelsCount = vowels[letter] ? 1 : 0;
    long consonantCount = vowels[letter] ? 0 : 1;
    long lastProblem = -1;
    long letterCount = 1;

    long problems = 0;
    long fragments = 0;

    while (!isEnd(letter = getchar())) {
      letterCount++;
      if (vowels[letter]) {
        vowelsCount++;
        consonantCount = 0;
      } else {
        consonantCount++;
        vowelsCount = 0;
      }
      if (vowelsCount >= 3) {
        problems += ((letterCount - 3) - lastProblem);
        lastProblem = letterCount - 3;
      }
      if (consonantCount >= 3) {
        problems += ((letterCount - 3) - lastProblem);
        lastProblem = letterCount - 3;
      }
      fragments += problems;
    }
    printf("%d", fragments);
    return 0;
  }