fork download
  1. /******************************************************************************
  2.  
  3.   Online C++ Compiler.
  4.   Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include<bits/stdc++.h>
  10.  
  11. using namespace std;
  12. int main(){
  13. map < string, int >m;
  14. int n;
  15. cin >> n;
  16.  
  17. while (n-- > 0)
  18. {
  19. string s;
  20. cin >> s;
  21. if (m[s] == 0)
  22. {
  23. cout << "OK" << endl;
  24. m[s]++;
  25. }
  26. else
  27. {
  28.  
  29. cout << s << m[s] << endl;
  30. m[s]++;
  31. }
  32.  
  33. }
  34.  
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0s 5264KB
stdin
6
first
first
second
second
third
third
stdout
OK
first1
OK
second1
OK
third1