Import java. Io .*;
Import java. util .*;
Public class maxlength {// find the word with the longest Length
Static void max (int A [], string mystr []) {
String [] sigstr;
Int max = A [0];
For (INT I = 0; I <A. length; I ++ ){
If (A [I]> MAX) max = A [I];
}
// System. Out. println (max );
For (INT I = 0; I <A. length; I ++) {// find the subscript and output of the longest word
If (A [I] = max) system. Out. println ("the longest word is:" + mystr [I]);
}
}
Static void Nums (string mystr []) {// find the most frequently occurring word and Output
Int [] A = new int [mystr. Length];
For (INT I = 1; I <mystr. length; I ++ ){
A [I] = 1;
}
For (INT I = 1; I <mystr. length; I ++)
For (Int J = I-1; j> = 0; j --){
If (mystr [I]. Equals (mystr [J]) A [I] ++;
}
Int max = A [0];
For (INT I = 0; I <A. length; I ++ ){
If (A [I]> MAX) max = A [I];
}
// System. Out. println (max );
For (INT I = 0; I <A. length; I ++ ){
If (A [I] = max) system. Out. println ("the most frequently used word is:" + mystr [I]);
}
}
Public static void main (string [] ARGs) throws exception {
Bufferedreader BR = new bufferedreader (New inputstreamreader (system. In ));
String STRs = Br. Readline ();
String [] mystr = STRs. Split (""); // enter a string of words, separated by spaces, where each word is stored in an array
Int [] A = new int [mystr. Length];
For (INT I = 0; I <mystr. length; I ++ ){
A [I] = 0;
}
For (INT I = 0; I <mystr. length; I ++ ){
A [I] = mystr [I]. Length ();
}
Max (A, mystr); // find the word with the longest Length
Nums (mystr); // find the word that appears most frequently and Output
}
}