Language: C++

#include <iostream>
#include <string>
using namespace std;

#define INF 55

string name[10000], dp[10000]; //name????????????????????????????????????dp[i]???name[i]????????¨?????????
int snum[10000]; //name[i]???????????????snum[i]????????¨?????????????????§?¢????????????????????????????

// ????????????????????????????¢????????????¢??°
bool check(int n) {
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if(dp[i] == dp[j]) return false;
    }
  }
  return true;
}

// ???????????°?????¨???name[i]???????????°????¶???????????????°false
bool all_check(int n) {
  for (int i = 0; i < n; i++) {
    if(snum[i] < name[i].size()) return true;
  }
  return false;
}

int solve(int n, int count) {
  L:
  // ?????¨???????????°(count)???0????????°????????????dp?????????
  if (!count) {
    for (int i = 0; i < n; i++) {
      dp[i] = name[i][0];
      snum[i]++;
    }
    count++;
    // ??¨?????°?????£????????????????????°?????????
    if (check(n)) return count;
    else goto L;
  } else { // ????????°???1??\????????´???
    for (int i = 0; i < n; i++) {
      if(snum[i] >= name[i].size()) {snum[i] = INF; continue;}
      char tmp = name[i][snum[i]-1];

      // count == 1, ??????????????????????????£???????????????????????????????????????????????????????????????????????????dp????????????????????´
      if(count == 1 && (tmp == 'a' || tmp == 'i' || tmp == 'u' || tmp == 'e' || tmp == 'o')) {
        snum[i]++;
        dp[i]+=name[i][snum[i]-1];
      } else { // count > 1??????????????¨??????????????????????????????????????§????????°????????????(while??§?????£?????????)
        while (1) {
          if (snum[i] >= name[i].size()) {snum[i] = INF; break;} // ????????°?????????name????????§???????????£????????????
          tmp = name[i][snum[i]];
          if (tmp == 'a' || tmp == 'i' || tmp == 'u' || tmp == 'e' || tmp == 'o') break;
          snum[i]++;
        }
        snum[i]++;
        if (snum[i] < name[i].size()) dp[i]+=name[i][snum[i]]; // ??????????????????????????????????????§??????????????????
        else snum[i] = INF;
      }
    }
    if(!all_check(n)) return -1; // ?????¨??????snum?????¨???name???????????§????????´?????????????????????????????§-1
    /*cout << "print dp: \n";
    for (int i = 0; i < n; i++) cout << dp[i] << endl;
    */
    count++;
    // ??¨???????????????????????°?????£??????count?????????
    if (check(n)) return count;
    else goto L;
  }
  return -1;
}

int main(void) {
  int n;
  cin.tie(0);
  ios::sync_with_stdio(false);

  while (cin >> n, n) {
    memset(name, 0, sizeof(name));
    memset(dp, 0, sizeof(dp));
    fill(snum, snum + n, 0);
    for (int i = 0; i < n; i++) {
      cin >> name[i];
      cin.ignore(); // ???????????????????????????????????¨???(?????£??????????????????RE)
    }
    cout << solve(n, 0) << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:79:5: error: 'memset' was not declared in this scope
   79 |     memset(name, 0, sizeof(name));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | #include <string>