Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Rename the Books

By mdvirus · Limits 1s, 1.0 GB

Everything is short in the Short Land. People use short words when talking to each other or writing something or messaging there. For example, they write ‘hapy’ instead of ‘happy’. They write ‘runing’ instead of ‘running’ etc. In other words, if they find a letter consecutively in a word, they write it once.

Long time ago, Short land was known as Long Land. Because, their ancestors used to write long words then. For example, they wrote ‘haaaappppyyyy’ instead of ‘hapy’. They wrote ‘runnninnnng’ instead of ‘runing’ etc.

Recently the historians of Short Land discovered an ancient library. There are $N$ books in that library. Since the ancient people used to write long words, the name of the books were also long. For example, the name of a famous book was ‘the alchemmmisst’. Your task is to rename these books maintaining the rule of Short Land.


You’ll be given the value of $N (N \le 10^5)$ in the first line of the input, which indicates the total number of books in the library. The name of all the books in the library will be inputted one at a time in the next $N$ lines. A book name can have a maximum of 10 words. Every word can have a maximum of 20 English lowercase letters.


Rename the books maintaining the current rule of Short Land and print it in $N$ lines.


the alchemmmisst
harrrryyyy potttterrrr
teachhh yoursellfff c
the alchemist
hary poter
teach yourself c



82% Solution Ratio

fire_tornadoEarliest, 6M ago

flybeyondcloudFastest, 0.1s

Abrar.614480Lightest, 10 MB

maddogShortest, 87B


Login to submit

Related Contests