#K71142. Unique File Renamer
Unique File Renamer
Unique File Renamer
You are given a list of file names. Some file names may appear more than once. To avoid file name collisions, you must rename each file by appending a unique positive integer suffix to each file name in the order of its appearance. Specifically, if a file appears for the first time, append 1 as its suffix, if it appears again, increase the suffix accordingly.
For example, if the input file list is ["avengers", "infinitywar", "avengers", "endgame"], then the renamed list should be ["avengers1", "infinitywar1", "avengers2", "endgame1"].
Finally, output the renamed file list as a single string with the names separated by a space.
The renaming rule can be expressed mathematically as follows: if a file f appears for the k-th time, then its new name is given by \[ f_{new} = f + k, \] where k is a positive integer.
inputFormat
The first line of input contains an integer n indicating the number of file names.
The second line contains n file names separated by spaces.
outputFormat
Output a single line consisting of the renamed file names, separated by a single space.
## sample4
avengers infinitywar avengers endgame
avengers1 infinitywar1 avengers2 endgame1