Here's your approach:
Read , the number of registration requests.
Create an empty map from string to integer.
For each of the requests, read the username.
Check if the username exists in the map.
If not found, output OK and insert username with value 0.
If found, get its count, output username concatenated with count, then increment the count in the map. This solution processes each request in time for map operations, giving you total time. Maps provide fast lookup and update, making the solution both clean and fast.