#include <iostream>
#include <string.h>
using namespace std;
#define MAX 300
void DemTieng(char s1[]);
int myStrcmp(char s1[], char s2[]);
int myStrlen(char s[], int k);
void myStrcpy(char s[], int vt, char s1[], int k);
void myMemmove(char s[], int vt, int k);
int myStrstr(char s[], char s1[]);
void mySubstr(char s[], int b, int count, char ss[]);
bool myStrcat(char s1[], char s2[]);
struct Words{
char str[MAX];
int soLan = 0;
};
Words A[MAX];
int phantu_A=0;
Words B[MAX];
int phantu_B=0;
void myStrcpy(char s[], int vt, char s1[], int k){ //gan chuoi s1 bang chuoi s tu vi tri vt cua chuoi s
for (int i = 0; i < k; i++){
s1[i] = s[i + vt];
}
s1[k] = '\0';
}
int myStrlen(char s[], int k){
int length = 0;
for (int i = k; s[i] != '\0'; i++){
length++;
}
return length;
}
int myStrcmp(char s1[], char s2[]){ //so sanh hai chuoi co giong nhau khong, giong nhau tra ve 1 , khong giong tra ve 0
bool onlyWhitespace=true;
for (int i=0;i<myStrlen(s1,0);i++) if (s1[i]!=' ') {
onlyWhitespace=false;
//cout << myStrlen(s2,0) << endl;
break;
}
if (onlyWhitespace==true) return 0;
if (myStrlen(s2,0)==0) return -1; //
if (myStrlen(s1,0)!=myStrlen(s2,0)) return 0;
for (int i=0;i<myStrlen(s1,0);i++)
if (s1[i]!=s2[i]) return 0;
return 1;
}
bool check_ton_tai(char s[]){
for (int i=1;i<=phantu_B;i++)
if (myStrcmp(s,B[i].str) == 1) return false;
return true;
}
void DemTieng(char s1[]){
int length = myStrlen(s1,0);
// Chuyen tat ca cac tu them vao mang A
int i=0;
while (i<length){
while (s1[i]==' '&&i<length) ++i;
if (i<length){
++phantu_A;
int pos_start=i;
int pos_end;
while (s1[i]!=' '&&i<length) ++i;
if (i<length) pos_end=i-1; else pos_end=length-1;
myStrcpy(s1,pos_start,A[phantu_A].str,pos_end-pos_start+1);
}
}
for (int i=1;i<=phantu_A;i++){
if (check_ton_tai(A[i].str)==true){
++phantu_B;
myStrcpy(A[i].str,0,B[phantu_B].str,myStrlen(A[i].str,0));
int dem = 0;
for (int j=1;j<=phantu_A;j++)
if (myStrcmp(A[j].str,B[phantu_B].str)==1) ++dem;
B[phantu_B].soLan = dem;
}
}
for (int i=1;i<=phantu_B;i++) cout << B[i].str << ": " << B[i].soLan << endl;
}
int main()
{
char s[MAX];
cin.getline(s,MAX);
if (myStrcmp(s, "") == 0)
cout << "Chuoi rong." << endl;
else
DemTieng(s);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgTUFYIDMwMAoKdm9pZCBEZW1UaWVuZyhjaGFyIHMxW10pOwppbnQgbXlTdHJjbXAoY2hhciBzMVtdLCBjaGFyIHMyW10pOwppbnQgbXlTdHJsZW4oY2hhciBzW10sIGludCBrKTsKdm9pZCBteVN0cmNweShjaGFyIHNbXSwgaW50IHZ0LCBjaGFyIHMxW10sIGludCBrKTsKdm9pZCBteU1lbW1vdmUoY2hhciBzW10sIGludCB2dCwgaW50IGspOwppbnQgbXlTdHJzdHIoY2hhciBzW10sIGNoYXIgczFbXSk7CnZvaWQgbXlTdWJzdHIoY2hhciBzW10sIGludCBiLCBpbnQgY291bnQsIGNoYXIgc3NbXSk7CmJvb2wgbXlTdHJjYXQoY2hhciBzMVtdLCBjaGFyIHMyW10pOwoKc3RydWN0IFdvcmRzewogICAgY2hhciBzdHJbTUFYXTsKICAgIGludCBzb0xhbiA9IDA7CiAgICB9OwoKCldvcmRzIEFbTUFYXTsKaW50IHBoYW50dV9BPTA7CgpXb3JkcyBCW01BWF07CmludCBwaGFudHVfQj0wOwoKCgp2b2lkIG15U3RyY3B5KGNoYXIgc1tdLCBpbnQgdnQsIGNoYXIgczFbXSwgaW50IGspeyAvL2dhbiBjaHVvaSBzMSBiYW5nIGNodW9pIHMgdHUgdmkgdHJpIHZ0IGN1YSBjaHVvaSBzCiAgICBmb3IgKGludCBpID0gMDsgaSA8IGs7IGkrKyl7CiAgICAgICAgczFbaV0gPSBzW2kgKyB2dF07CiAgICB9CiAgICBzMVtrXSA9ICdcMCc7CgoKfQoKCmludCBteVN0cmxlbihjaGFyIHNbXSwgaW50IGspewogICAgaW50IGxlbmd0aCA9IDA7CiAgICBmb3IgKGludCBpID0gazsgc1tpXSAhPSAnXDAnOyBpKyspewogICAgICAgIGxlbmd0aCsrOwogICAgfQogICAgcmV0dXJuIGxlbmd0aDsKCn0KCmludCBteVN0cmNtcChjaGFyIHMxW10sIGNoYXIgczJbXSl7ICAvL3NvIHNhbmggaGFpIGNodW9pIGNvIGdpb25nIG5oYXUga2hvbmcsIGdpb25nIG5oYXUgdHJhIHZlIDEgLCBraG9uZyBnaW9uZyB0cmEgdmUgMAogICAgYm9vbCBvbmx5V2hpdGVzcGFjZT10cnVlOwoKICAgIGZvciAoaW50IGk9MDtpPG15U3RybGVuKHMxLDApO2krKykgaWYgKHMxW2ldIT0nICcpIHsKICAgICAgICBvbmx5V2hpdGVzcGFjZT1mYWxzZTsKICAgICAgICAvL2NvdXQgPDwgbXlTdHJsZW4oczIsMCkgPDwgZW5kbDsKICAgICAgICBicmVhazsKICAgIH0KCiAgICBpZiAob25seVdoaXRlc3BhY2U9PXRydWUpIHJldHVybiAwOwogICAgaWYgKG15U3RybGVuKHMyLDApPT0wKSByZXR1cm4gLTE7IC8vCiAgICBpZiAobXlTdHJsZW4oczEsMCkhPW15U3RybGVuKHMyLDApKSByZXR1cm4gMDsKICAgIGZvciAoaW50IGk9MDtpPG15U3RybGVuKHMxLDApO2krKykKICAgICAgICBpZiAoczFbaV0hPXMyW2ldKSByZXR1cm4gMDsKICAgIHJldHVybiAxOwoKfQoKYm9vbCBjaGVja190b25fdGFpKGNoYXIgc1tdKXsKICAgIGZvciAoaW50IGk9MTtpPD1waGFudHVfQjtpKyspCiAgICAgICAgaWYgKG15U3RyY21wKHMsQltpXS5zdHIpID09IDEpIHJldHVybiBmYWxzZTsKCiAgICByZXR1cm4gdHJ1ZTsKCn0KCgoKCnZvaWQgRGVtVGllbmcoY2hhciBzMVtdKXsKICAgIGludCBsZW5ndGggPSBteVN0cmxlbihzMSwwKTsKCgogICAgLy8gQ2h1eWVuIHRhdCBjYSBjYWMgdHUgdGhlbSB2YW8gbWFuZyBBCiAgICBpbnQgaT0wOwogICAgd2hpbGUgKGk8bGVuZ3RoKXsKICAgICAgICB3aGlsZSAoczFbaV09PScgJyYmaTxsZW5ndGgpICsraTsKICAgICAgICBpZiAoaTxsZW5ndGgpewogICAgICAgICAgICArK3BoYW50dV9BOwogICAgICAgICAgICBpbnQgcG9zX3N0YXJ0PWk7CiAgICAgICAgICAgIGludCBwb3NfZW5kOwogICAgICAgICAgICB3aGlsZSAoczFbaV0hPScgJyYmaTxsZW5ndGgpICsraTsKICAgICAgICAgICAgaWYgKGk8bGVuZ3RoKSBwb3NfZW5kPWktMTsgZWxzZSBwb3NfZW5kPWxlbmd0aC0xOwogICAgICAgICAgICBteVN0cmNweShzMSxwb3Nfc3RhcnQsQVtwaGFudHVfQV0uc3RyLHBvc19lbmQtcG9zX3N0YXJ0KzEpOwogICAgICAgIH0KCiAgICB9CgoKCgogICAgZm9yIChpbnQgaT0xO2k8PXBoYW50dV9BO2krKyl7CiAgICAgICAgaWYgKGNoZWNrX3Rvbl90YWkoQVtpXS5zdHIpPT10cnVlKXsKICAgICAgICAgICAgKytwaGFudHVfQjsKICAgICAgICAgICAgbXlTdHJjcHkoQVtpXS5zdHIsMCxCW3BoYW50dV9CXS5zdHIsbXlTdHJsZW4oQVtpXS5zdHIsMCkpOwogICAgICAgICAgICBpbnQgZGVtID0gMDsKICAgICAgICAgICAgZm9yIChpbnQgaj0xO2o8PXBoYW50dV9BO2orKykKICAgICAgICAgICAgICAgIGlmIChteVN0cmNtcChBW2pdLnN0cixCW3BoYW50dV9CXS5zdHIpPT0xKSArK2RlbTsKICAgICAgICAgICAgQltwaGFudHVfQl0uc29MYW4gPSBkZW07CgogICAgICAgIH0KCiAgICB9CgogICAgZm9yIChpbnQgaT0xO2k8PXBoYW50dV9CO2krKykgY291dCA8PCBCW2ldLnN0ciA8PCAiOiAiIDw8ICBCW2ldLnNvTGFuIDw8IGVuZGw7CgoKfQoKCgoKaW50IG1haW4oKQp7CgljaGFyIHNbTUFYXTsKICAgIGNpbi5nZXRsaW5lKHMsTUFYKTsKCWlmIChteVN0cmNtcChzLCAiIikgPT0gMCkKCQljb3V0IDw8ICJDaHVvaSByb25nLiIgPDwgZW5kbDsKCWVsc2UKCQlEZW1UaWVuZyhzKTsKCXJldHVybiAwOwp9Cgo=