Stepan likes to repeat vowel letters when he writes words. For example, instead of the word "pobeda" he can write "pobeeeedaaaaa".
Sergey does not like such behavior, so he wants to write a program to format the words written by Stepan. This program must combine all consecutive equal vowels to a single vowel. The vowel letters are "a", "e", "i", "o", "u" and "y".
There are exceptions: if letters "e" or "o" repeat in a row exactly 2 times, like in words "feet" and "foot", the program must skip them and do not transform in one vowel. For example, the word "iiiimpleeemeentatiioon" must be converted to the word "implemeentatioon".
Sergey is very busy and asks you to help him and write the required program.
Input
The first line contains the integer n (1 ≤ n ≤ 100 000) — the number of letters in the word written by Stepan.
The second line contains the string s which has length that equals to n and contains only lowercase English letters — the word written by Stepan.
Output
Print the single string — the word written by Stepan converted according to the rules described in the statement.
Examples
Input
13
pobeeeedaaaaa
Output
pobeda
Input
22
iiiimpleeemeentatiioon
Output
implemeentatioon
Input
18
aeiouyaaeeiioouuyy
Output
aeiouyaeeioouy
Input
24
aaaoooiiiuuuyyyeeeggghhh
Output
aoiuyeggghhh
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
We are asked to write a program to compress a word by reducing consecutive repeated vowels (a, e, i, o, u, y) to a single vowel, with an exception: if the vowel is 'e' or 'o' and it repeats exactly 2 times consecutively, then we keep those two letters (i.e., do not compress them to one). However, if they repeat more than 2 times, we compress to a single? The problem statement: "combine all consecutive equal vowels to a single vowel. The vowel letters are ... There are exceptions: if letters "e" or "o" repeat in a row exactly 2 times, like in words "feet" and "foot", the program must skip them and do not transform in one vowel." So the general rule: For any vowel, if there are consecutive occurrences, we want to reduce them to a single vowel. Except if the vowel is 'e' or 'o' and the consecutive occurrence count is exactly 2, then we do NOT combine them; we leave them as two. For any other count (1, >2) we reduce to one? Wait: For 1 obviously nothing. For >2, we reduce to one. So basically we need to output a string where for each maximal block of consecutive equal letters, we:
If the letter is a vowel, and the block length >= 1.
If the block length > 0:
If the vowel is not 'e' and not 'o', we output a single instance of that vowel.
If the vowel is 'e' or 'o':
If block length == 2: output two copies (i.e., keep original)
else: output one copy.
If the letter is not a vowel, we output the block as is (i.e., do not compress consonants; they are not subject to compression). Actually the statement: "combine all consecutive equal vowels to a single vowel." It applies only to vowels. So for consonants, we don't combine or modify; they remain as they appear. But if there are consecutive equal consonants, we still output them as they are, because no rule says to combine them. So the compression only applies to consecutive vowels. But careful: The input string might contain mixed vowels and consonants. The rule only applies to runs of the same vowel. So we need to identify maximal runs of the same vowel? Actually note: consecutive equal vowels. For example, "aaa" -> "a". For "e" and "o" if exactly two, keep "ee" or "oo". But what about runs of different vowels consecutively? They are not equal, so they are separate runs; no compression across different vowels. Also note: we should only compress if the letters are vowels and equal. So we need to scan the string and for each character, if it's a vowel and the next is same vowel, we need to collapse to one except the special case.
Implementation: iterate through the string from left to right, keep track of the current character and count of consecutive occurrences? Simpler: use an output list; we can decide to add characters conditionally based on previous characters.
We can process as: for each character s[i], decide if we should output it based on whether it's part of a vowel run that has been already output with compression.
One approach: Scan and group runs (both vowel and consonant). For each run:
If the character is not a vowel (consonant), output the whole run unchanged.
If the character is a vowel:
If it is 'e' or 'o':
If run length == 2: output two of them.
else: output one.
Else (other vowels): output one (since run length >=1, we always output just one).
But careful: What about run length == 1? Output just one. So for other vowels (a,i,u,y) we always output just one regardless of length.
But is there any nuance? For 'e' and 'o' run length exactly 2, output two; else (including length 1, length >2) output one. So yes.
Now check examples:
Example 1: "pobeeeedaaaaa" length 13? Actually input shows "pobeeeedaaaaa" 13 letters? Let's count: p o b e e e e d a a a a a -> p(1) o(2) b(3) e(4) e(5) e(6) e(7) d(8) a(9) a(10) a(11) a(12) a(13) -> 13. Output "pobeda". So runs: 'p' (consonant) -> p; 'o' vowel 'o' run length 1 -> o (but output 'o'? Actually "pobeda" has 'o'? Yes "pobeda" is p o b e d a? Wait "pobeda" letters: p o b e d a. So original: p o b e e e e d a a a a a. After compression: p o b e d a. So 'o' length 1 -> output 'o' (single). 'b' consonant -> b. Then 'e' run length 4 -> since length >2, output one 'e' (instead of four). Then 'd' consonant -> d. Then 'a' run length 5 -> output one 'a'. So matches.
Example 2: Input: "iiiimpleeemeentatiioon". Let's break: Actually given: "iiiimpleeemeentatiioon". They output "implemeentatioon". Let's verify:
Original: maybe: i i i i m p l e e e m e e n t a t i i o o n? But they wrote "iiiimpleeemeentatiioon". Let's break: "iiii" (4 i's) then "mple" maybe? Actually "iiiimpleeemeentatiioon" seems to have: i i i i m p l e e e m e e n t a t i i o o n. Output: "implemeentatioon". That is: i m p l e m e e n t a t i o o n? Wait: output: "implemeentatioon": Let's see: i m p l e m e e n t a t i o o n? Actually "implemeentatioon" might be broken as: i m p l e m e e n t a t i o o n. But there is a missing 'e'? Let's compare properly.
Given original: "iiiimpleeemeentatiioon". I'll parse:
"iiii" -> 4 i's
"m" -> m
"p" -> p
"l" -> l
"eee" -> three e's? Actually "eee"? The string part "eee" appears? They wrote "leeeme"? Wait: "iiiimpleeemeentatiioon". After "iiii" there is "mpleeemeentatiioon"? Actually "iiiimpleeemeentatiioon": Could be "iiii" + "mple" + "eee" + "meentatiioon"? Not sure.
Better to copy: Input: "iiiimpleeemeentatiioon" (22 chars). Output: "implemeentatioon". So original: Let's count letters:
Indices (1-indexed):
1 i
2 i
3 i
4 i
5 m? Actually "iiiimple..." could be "iiii m p l e ..." So after i's, letters: 'm', 'p', 'l', 'e', ... Indeed "iiiimple" suggests the substring "iiii mple"? Because "simple" would be s i m p l e; but they have "iiiimple": that's like many i's then "mple". So indeed original: "iiii" + "mple" + ...? But "iiiimple" could be parsed as "iiii" + "mple". So after i's we have 'm','p','l','e'. So letters 5=m,6=p,7=l,8=e. Then continue: "eeemeentatiioon"? Actually the string: "iiiimpleeemeentatiioon". After "iiiimple" we have "eemeentatiioon"? The substring "eemeentatiioon"? Let's see: After "iiiimple", the next characters: maybe "eee"? Actually "iiiimpleeemeentatiioon": we have "iiiimple" then "ee" (double e?) Wait: Let's write exactly: "iiiimpleeemeentatiioon". If we split: "iiii" + "mple" + "ee" + "meentatiioon"? But "mple" is 4 letters, then "ee" two e's, then "meentatiioon"? That seems off.
Alternate approach: Let's count characters manually from example: Input length 22. Output length? "implemeentatioon" I count: i m p l e m e e n t a t i o o n = let's count: 1:i,2:m,3:p,4:l,5:e,6:m,7:e,8:e,9:n,10:t,11:a,12:t,13:i,14:o,15:o,16:n -> 16. So output 16.
Original 22. So difference 6 letters removed. Let's try to reconstruct original based on rules:
The compression of vowel runs (except e/o exactly 2) to single vowel.
So we have runs: e-run of length 2 preserved; o-run of length 2 preserved.
Original must have had some extra vowels that were compressed. For instance, at the beginning, output starts with 'i' but original had multiple i's? Since output starts with 'i', but original "iiiimple..." suggests there were 4 i's initially, compressed to 1 i (since i not e/o, any run >1 reduces to 1). So that matches: original "iiii" -> becomes "i". Then "mple"? Output has "mple"? Actually output: i m p l e ... Wait output is "implemeentatioon". After first 'i' we have 'm' 'p' 'l' 'e'? That's "imple"? Yes, output: i m p l e (positions 2-5) so that spells "imple"? Actually "imple" is i m p l e. But the original after i's we had "mple"? Could be original had "mple" (m, p, l, e). That would match because output has "mple" after the first i? But output has "i" then "mple"? That would be "imple". That seems to combine: i from many i's plus "mple" makes "imple". So original "iiii"+"mple" = "iiiimple", and output "imple". Yes. So original run: 'i' run (4) -> compress to 1 i; then consonants m, p, l; then e? Wait original "mple" includes 'e' at the end? Actually "mple" ends with 'e'. So original: after i's, we have 'm','p','l','e'. Then after that, output continues with "meentatioon". In output we have after "imple" there is "meentatioon"? Let's look: output "implemeentatioon". So after "imple" we have "meentatioon". Actually "imple" + "meentatioon" = "implemeentatioon". So the output splits as: "imple" + "meentatioon". But note "imple" ends with 'e', and the next character in output is 'm'. So original after the first 'e' (from mple) there might be additional characters that produced "meentatioon". Let's check original string: "iiiimpleeemeentatiioon". After "iiiimple" we have "eemeentatiioon"? Actually the string is "iiiimpleeemeentatiioon". So after "iiiimple" (i.e., characters 1-8: i,i,i,i,m,p,l,e) we have the next characters: the 9th character? Let's index:
String s = "iiiimpleeemeentatiioon". Let's write it with indices:
1 i
2 i
3 i
4 i
5 m
6 p
7 l
8 e
9 e? Actually after "e" from "mple" there is "e"? The string shows "eee"? Actually it says "iiiimpleeemeentatiioon". After "iiiimple" we see "e" then? The substring "eeeme..."? Actually "iiiimpleeeme..." could be broken as "iiiimple" + "ee" + "me..."? Wait "iiiimpleeemeentatiioon" contains "ee" after "e"? Let's count characters manually by copying the string exactly: I'll copy from problem: "iiiimpleeemeentatiioon". Let's count each character:
1: i
2: i
3: i
4: i
5: m
6: p
7: l
8: e
9: e
10: e
11: m
12: e
13: e
14: n
15: t
16: a
17: t
18: i
19: i
20: o
21: o
22: n
But I'm not sure if my counting is correct because I need to account for "eeemeentatiioon". The substring after "iiiimple" is "eeemeentatiioon". That would be: e e e m e e n t a t i i o o n. That's 15 characters? Actually: e(1), e(2), e(3), m(4), e(5), e(6), n(7), t(8), a(9), t(10), i(11), i(12), o(13), o(14), n(15). That would make total characters: 4(i's) + m,p,l,e = 8, plus 15 = 23, but input length is 22. So I've miscounted. Let's re-evaluate.
The string is "iiiimpleeemeentatiioon". Let's split into parts: "iiii", "mple", "ee", "me", "ent", "ati", "ioon"? Not sure.
Maybe it's better to use programming logic: The example is given, we trust that our rule yields that output.
Let's systematically parse:
Given n=22, s="iiiimpleeemeentatiioon". We need to confirm the length is 22.
Write s as characters list:
I'll write exactly as shown: i i i i m p l e e e m e e n t a t i i o o n
But that's 4+1+1+1+1+? Actually let's count:
1: i
2: i
3: i
4: i
5: m
6: p
7: l
8: e
9: e
10: e
11: m
12: e
13: e
14: n
15: t
16: a
17: t
18: i
19: i
20: o
21: o
22: n
That seems plausible: positions: 1-4: i's; 5:m;6:p;7:l;8:e;9:e;10:e;11:m;12:e;13:e;14:n;15:t;16:a;17:t;18:i;19:i;20:o;21:o;22:n. That adds to 22. So the string is: "iiiimpleeemeentatiioon". Indeed "iiiimple" is 8 chars (i,i,i,i,m,p,l,e) but we have at position 8 e, then 9 e,10 e, then 11 m, etc. So after the first e (position 8) there are two more e's (9,10) then m, then e,e,... So we have a run of e's from positions 8,9,10: that's 3 e's. Then after m (consonant) there is a run of e's at positions 12,13: two e's. Then later i's at 18,19: two i's. Then o's at 20,21: two o's.
Now apply our rule:
For vowel runs:
'i' at beginning: run length 4 -> since i is not e/o, compress to one 'i'.
Next consonants: m, p, l.
Next vowel: e run from positions 8,9,10 length 3. Since e is special, length >2 -> compress to one 'e'. So we output one 'e'.
Next consonant: m.
Next vowel: e run at positions 12,13 length 2. Since e and exactly 2, we keep both: output two e's.
Next consonant: n.
Next consonant: t? Actually t at position 15? Wait after e run we have n (consonant) at position 14? Actually we have after e run at 12,13, then n at 14, t at 15? Actually positions: 14:n, 15:t, 16:a, 17:t, 18:i, 19:i, 20:o, 21:o, 22:n. So after e run we have n (consonant), t (consonant), a (vowel? a is vowel), t (consonant), i i (vowel run), o o (vowel run), n (consonant). Let's proceed.
After e run (two e's) we have n (consonant) -> output n.
Next t (consonant) -> output t.
Next a at position 16 (vowel). Need to check run: a is alone? Position 16 is a, next is t (consonant) so run length 1. So output a (one).
Next t (consonant) -> output t.
Next i run at positions 18,19 length 2. Since i is not e/o, rule says compress all consecutive equal vowels to a single vowel. So for i, even length 2, we compress to one i. Because exception only for e and o. So i run length 2 -> compress to one i. So output one i.
Next o run at positions 20,21 length 2. For o, exception: exactly 2 stays as two. So output two o's.
Finally n (consonant) -> output n.
Now assemble output: from start: i (from i's), m, p, l, e (from three e's compressed), then m, then e e (from two e's), then n, t, a, t, i (from two i's compressed), o o, n. That gives: i m p l e m e e n t a t i o o n. Combine: "implemeentatioon"? Wait we have "imple" + "meentatioon"? Let's write: i m p l e -> "imple"? Actually i m p l e spells "imple". Then m -> "m", so after "imple" we have "m"? Actually sequence: i, m, p, l, e, m, e, e, n, t, a, t, i, o, o, n. So the string is: "implemeentatioon"? Let's join: i+m+p+l+e = "imple"; then +m = "implem"; then +e+e = "implemee"; then +n = "implemeen"; then +t = "implemeent"; then +a = "implemeenta"; then +t = "implemeentat"; then +i = "implemeentati"; then +o+o = "implemeentatioo"; then +n = "implemeentatioon". That's exactly "implemeentatioon"? Wait that's "implemeentatioon" but the example output is "implemeentatioon"? Actually the example output is "implemeentatioon"? They wrote "implemeentatioon". Let's see: Example 2 Output: "implemeentatioon". Yes that matches! So our rule is correct.
Now example 3: Input: "aeiouyaaeeiioouuyy". Output: "aeiouyaeeioouy". Let's test: original: a e i o u y a a e e i i o o u u y y. Process:
a (vowel, alone) -> a
e (alone) -> e
i -> i
o -> o
u -> u
y -> y (y is vowel per problem)
then a a: two a's. Since a is not e/o, compress to one a. So output a (single). So far: a e i o u y a.
then e e: two e's -> exception: keep two e's. So output e e.
then i i: two i's -> compress to one i. So output i.
then o o: two o's -> keep two o's. So output o o.
then u u: two u's -> compress to one u. So output u.
then y y: two y's -> compress to one y. So output y.
Now combined: a e i o u y a e e i o o u y. That's "aeiouyaeeioouy". The example output is "aeiouyaeeioouy". Yes matches.
Example 4: Input: "aaaoooiiiuuuyyyeeeggghhh". Output: "aoiuyeggghhh". Let's test:
Original: a a a o o o i i i u u u y y y e e e g g g h h h? Actually "aaaoooiiiuuuyyyeeeggghhh": aaa, ooo, iii, uuu, yyy, eee, ggg, hhh. Process:
aaa -> compress to a (since a not e/o)
ooo -> o (since o length 3 (>2) -> compress to one o, because exception only for exactly 2)
iii -> i (compress)
uuu -> u (compress)
yyy -> y (compress)
eee -> e (since length 3 -> compress to one e)
ggg -> ggg (consonants remain as is) -> ggg
hhh -> hhh
So output: a o i u y e g g g h h h? That would be "aoiuyeggghhh". Yes matches.
Thus solution is clear.
Now constraints: n up to 100,000. Simple O(n) approach works.
Implementation details: We'll iterate through s, maintaining an index i. While i < n: we find the current character ch = s[i]. If ch is not a vowel, we simply append ch to result and i++.
If ch is a vowel, we need to find the length of the consecutive block of that same vowel (only same vowel, because rule says "consecutive equal vowels". If the next vowel is different, it's a new block). So we need to count how many times the same vowel appears contiguously. Let count = number of consecutive ch starting at i.
Then if ch is 'e' or 'o':
if count == 2: append ch twice.
else: append ch once.
Else (other vowels):
append ch once (regardless of count, but count>=1, so just one).
Then i += count.
Edge cases: single vowel always append once.
Need to be careful about y: included as vowel.
Now check if any nuance: For e/o count == 2, we output two; for count > 2, we output one. So that's it.
Complexity O(n).
Now note: The input string is lowercase letters only. Output string length at most n.
Implementation in C++ or Python. The problem likely expects C++ but we can provide Python solution as well (since typical Codeforces problem). I'll write in Python for simplicity.
Now verification with examples.
Potential pitfalls: When scanning for runs, must ensure we only consider same vowel, not any vowel. So while i+1 < n and s[i+1] == ch, increment count. But what if next character is a different vowel? Then it's new block. So condition s[i+1] == ch ensures same vowel.
Thus we need to treat each block separately.
Now code:
def solve():
import sys
data = sys.stdin.read().split()
n = int(data[0])
s = data[1].strip()
vowels = set('aeiouy')
res = []
i = 0
while i < n:
ch = s[i]
if ch not in vowels:
res.append(ch)
i += 1
else:
# count consecutive same vowel
j = i
while j < n and s[j] == ch:
j += 1
count = j - i
if ch == 'e' or ch == 'o':
if count == 2:
res.append(ch * 2) # or append twice
else:
res.append(ch)
else:
# other vowels
res.append(ch)
i = j
print(''.join(res))
But careful: For ch not in vowels, we also might have runs of the same consonant; but we need to output all of them unchanged. Our loop will output each consonant individually, but that's fine because if we output each char individually, it's same as outputting the run. However we could also skip counting to be efficient but O(n) anyway. However, note that for consonants, we also have runs, but outputting each char one by one yields the same result. That's acceptable. But there is a subtlety: For consonants, we might inadvertently combine with vowel processing if we treat them as single char, which is fine. So the simple method: iterate i from 0 to n-1, and if s[i] not vowel, append; else if vowel, we need to know the length of the run. But if we just process each vowel individually without looking ahead, we might output multiple copies for a run (e.g., for e run of length 3, we would output each e separately because each e is vowel; but our rule says output only one e. So we need to compress runs. So we need to skip the extra copies. So we can't just iterate per character; we must detect runs of same vowel and skip the extra ones. So we need to while loop as above.
Alternatively, we could process with a state machine: keep previous char and whether we are in a vowel run? But the run detection is simpler as shown.
Now test with examples manually.
Example 1: s="pobeeeedaaaaa", n=13.
Processing:
i=0: ch='p' not vowel -> append 'p', i=1.
i=1: 'o' vowel, run: from i=1, s[1]='o', next s[2]='b' != 'o', count=1. Since 'o' and count=1 (not 2) -> append 'o' once. i=2.
i=2: 'b' not vowel -> append 'b', i=3.
i=3: 'e' vowel. Count run: j=3, s[3]='e'; s[4]='e'? Yes, continue; s[5]='e', s[6]='e'? Let's check: "pobeeeedaaaaa" indices: 0:p,1:o,2:b,3:e,4:e,5:e,6:e? Actually "pobeeeedaaaaa": after "b", there is "eeee"? The substring is "eeee"? It says "pobeeeedaaaaa": I think it's "p o b e e e e d a a a a a". So positions: 3:e,4:e,5:e,6:e? Actually let's index: 0:p,1:o,2:b,3:e,4:e,5:e,6:e? But there is also a 'd' later. The string length 13, so we need to count. Write: p(0), o(1), b(2), e(3), e(4), e(5), e(6), d(7), a(8), a(9), a(10), a(11), a(12). So yes e run length 4. So j goes to 7. count=4. ch='e', count !=2 -> append 'e' once. i=7.
i=7: 'd' not vowel -> append 'd', i=8.
i=8: 'a' vowel. Run: j=8, while s[j]=='a', j=9,10,11,12,13 -> count=5. ch='a' (other vowel) -> append 'a' once. i=13. Done. Output "pobeda". Works.
Example 2: as above works.
Now edge cases: e run length exactly 2: we need to output two e's. Our code: if count == 2: res.append(ch*2). That adds a string of two chars, which is fine.
Now about y: it's considered a vowel, so for y runs, we compress to one y regardless of count. Example 3 and 4 confirm.
Now the problem statement: "combine all consecutive equal vowels to a single vowel." For y, it's included as vowel. So correct.
Now confirm with given output lengths: For example 2, output length 16, which matches.
Now potential pitfalls: Input may contain newline, we handle with read().split().
Now what about large n? O(n) fine.
Now about memory: res list up to n (worst-case when no compression: all consonants). So fine.
Now about reading input: first line n, second line string. n may not be needed as string length is given, but we can ignore n and just read s. But we should use n to allocate maybe, but not necessary. In Python, we can just read the string and trust its length.
Now write final solution.
But wait: The problem statement says: "combine all consecutive equal vowels to a single vowel." The exception: if letters "e" or "o" repeat in a row exactly 2 times, ... skip them and do not transform in one vowel. That implies that for exactly 2, we do not combine (so we leave two). For other counts (including 1) we combine? Actually for count 1, there is no combining needed. So our rule for e/o: if count != 2, we output one. That's correct. But what about count == 1? Then we output one. That's fine.
Now confirm for e/o count >2: compress to one. That matches examples.
Now verify if there is any other exception: The phrase "like in words 'feet' and 'foot'" suggests that these are common English words where e or o double appears, and they should remain as double. But note: In English, there are words like "beer", "door", etc., but not mentioned. The rule is only for exactly two consecutive e or o. So that's it.
Now ensure that the compression applies only to vowels that are equal and consecutive. So if we have "ae", they are different vowels, no compression. So that's correct.
Now potential nuance: The input might contain uppercase? The statement says lowercase only.
Now finalize solution.
But wait: The problem might be from Codeforces Round? Possibly "A. Vowel Compression"? It's typical. The constraints up to 100k, so O(n) is fine.
We'll provide Python solution.
Now I'll produce final answer with explanation and code.
But the user asked: "Sergey is very busy and asks you to help him and write the required program." So we output code.
Now I'm ChatGPT, I need to respond with the solution. Usually answer: Provide code and brief explanation. But the instruction says: "You are an AI...". In this environment, the response should include the solution code and maybe explanation. However, the typical format: I output final code in a code block.
Thus final answer:
python
import sys
def main():
data = sys.stdin.read().split()
if not data:
return
n = int(data[0]) # not strictly needed
s = data[1]
vowels = set('aeiouy')
i = 0
n = len(s) # we can use actual length
res = []
while i < n:
ch = s[i]
if ch not in vowels:
res.append(ch)
i += 1
else:
j = i
# count consecutive same vowel
while j < n and s[j] == ch:
j += 1
cnt = j - i
if ch == 'e' or ch == 'o':
if cnt == 2:
res.append(ch * 2)
else:
res.append(ch)
else:
# other vowels: always one
res.append(ch)
i = j
sys.stdout.write(''.join(res))
if __name__ == '__main__':
main()
That solves the problem. ```python
import sys
def main():
data = sys.stdin.read().split()
if not data:
return
n = int(data[0]) # length of the word, not strictly needed
s = data[1] # the word itself
vowels = set('aeiouy') # all vowel letters according to the statement
code
i = 0
res = []
while i < len(s):
ch = s[i]
if ch not in vowels:
# consonant – always keep it
res.append(ch)
i += 1
else:
# vowel – count the length of the run of the same vowel
j = i
while j < len(s) and s[j] == ch:
j += 1
cnt = j - i
if ch == 'e' or ch == 'o':
if cnt == 2:
# exception: keep two copies
res.append(ch * 2)
else:
# all other lengths become a single vowel
res.append(ch)
else:
# a, i, u, y – always one vowel
res.append(ch)
i = j # skip the whole run
sys.stdout.write(''.join(res))