fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define GG ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  4. int main () { GG;
  5. int n; string x;
  6. cin>>n;
  7. map<string,int> m;
  8.  
  9. for(int i=0;i<n;i++)
  10. { cin>>x;
  11. if(m.count(x))
  12. { cout<<x<<m[x]<<"\n";
  13. m[x]++;
  14. }
  15. else
  16. { m.insert({x,1});
  17. cout<<"OK\n";
  18. }
  19. }
  20.  
  21. return 0;}
Success #stdin #stdout 0s 5308KB
stdin
6
first
first
second
second
third
third
stdout
OK
first1
OK
second1
OK
third1