PKU 1002

487-3279

#include <iostream>
#include <string>
#include <map>

using namespace std;

string normalize( string num );

int main()
{
    int n;
    cin >> n;

    map<string,int> count;

    for ( int i=0; i<n; i++ )
    {
        string num;
        cin >> num;

        string stand = normalize( num );

        count[stand] += 1;
    }

    bool dup = false;

    for ( map<string,int>::iterator it=count.begin();
          it!=count.end(); it++ )
    if ( it->second >= 2 )
    {
        cout << it->first << " " << it->second << endl;

        dup = true;
    }

    if ( ! dup )
        cout << "No duplicates." << endl;

    return 0;
}

string normalize( string num )
{
    string map = "ABCDEFGHIJKLMNOPRSTUVWXY";

    string stand;

    for ( int i=0; i<(int)num.length(); i++ )
        if ( '0' <= num[i]  &&  num[i] <= '9' )
            stand += num[i];
        else if ( 'A' <= num[i]  &&  num[i] <= 'Y' )
            stand += map.find(num[i])/3 + '2';

    stand.insert( 3, "-" );

    return stand;	
}