import java.util.*; import java.io.*; public class WordFrequency { static public void main(String[] args) { HashMap words = new HashMap(); String delim = " \t\n.,:;?!-/()[]\"\'"; BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String line, word; Count count; try { while ((line = in.readLine()) != null) { StringTokenizer st = new StringTokenizer(line, delim); while (st.hasMoreTokens()) { word = st.nextToken().toLowerCase(); count = (Count) words.get(word); if (count == null) { words.put(word, new Count(word, 1)); } else { count.i++; } } } } catch (IOException e) {} Set set = words.entrySet(); Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); word = (String) entry.getKey(); count = (Count) entry.getValue(); System.out.println(word + (word.length() < 8 ? "\t\t" : "\t") + count.i); } } static class Count { Count(String word, int i) { this.word = word; this.i = i; } String word; int i; } }