Source Code
#include "bits/stdc++.h"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

void solve(){
   int n;
   cin>>n;
   map<string,int> m;
   for (int i = 0; i < n; ++i)
   {
       string s;
       cin>>s;
       m[s]++;
       if(m[s] == 1){
          cout<<"ok"<<endl;
       }
       else{
          cout<<s<<m[s]-1<<endl;
          string cur = s+to_string(m[s]-1);
          m[cur]++;
          m[s]++;
       }
   }
}

int main(){
    #ifndef ONLINE_JUDGE
     freopen("input.txt", "r", stdin);
     freopen("out.txt", "w",stdout);
    #endif
    FAST;

    int t = 1;
    // cin>>t;
    while(t--)
     solve(); 
}
Copy
Registration System moathhamudah
GNU G++17
295 ms
9.6 MB
Wrong Answer