Source Code
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define mem(a,n) memset((a),n,sizeof (a))
void fast();
ll gcd(ll x, ll y) { return(!y ? x : gcd(y, x % y)); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
int dx[]{ 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[]{ 0, 0, 1, -1, 1, -1, 1, -1 };
using namespace std;

int main()
{
    //freopen("input.txt" ,"r" ,stdin);
   //freopen("output.txt" ,"w" ,stdout);
    fast();
    int t; cin >> t;
    map<string, ll>mp;
    while (t--) {
        string s; cin >> s;
        if (mp[s] == 0) {
            cout << "ok\n";
            mp[s]++; 
        }
        else {

            while(mp[ s+to_string(mp[s])]!=0)mp[s]++;
            cout << s << mp[s] << "\n";
            mp[s + to_string(mp[s])]++;

        }
    //    cout << endl;
    }
   
    return 0;
}
void fast() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
Copy
Registration System Nourhan Hanna
GNU G++17
211 ms
9.8 MB
Accepted