@@ -0,0 +1,1011 @@
+// http://codeforces.com/problemset/problem/977/B%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.Scanner;%0A%0Apublic class Solution %7B%0A%09%0A%09public static void main(String%5B%5D args) %7B%0A%09%09Scanner read = new Scanner(System.in);%0A%09%09%0A%09%09int n = read.nextInt();%0A%0A%09%09// Clear buffer%0A%09%09read.nextLine();%0A%09%09%0A%09%09String line = read.nextLine();%0A%09%09%0A%09%09int maxFrequency = 0;%0A%09%09String maxFrequencySubstring = %22%22;%0A%09%09%0A%09%09Map%3CString, Integer%3E substringFrequencies = new HashMap%3CString, Integer%3E();%0A%09%09for (int i = 0; i %3C= line.length()-2; ++i) %7B%0A%09%09%09String substring = line.substring(i, i+2);%0A%09%09%09%0A%09%09%09Integer substringFrequency = substringFrequencies.get(substring);%0A%09%09%09if (substringFrequency == null) %7B%0A%09%09%09%09substringFrequency = 0;%0A%09%09%09%7D%0A%09%09%09substringFrequencies.put(substring, substringFrequency+1);%0A%09%09%09%0A%09%09%09if (substringFrequency+1 %3E maxFrequency) %7B%0A%09%09%09%09maxFrequency = substringFrequency+1;%0A%09%09%09%09maxFrequencySubstring = substring;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09System.out.println(maxFrequencySubstring);%0A%09%09%0A%09%09// Close scanner%0A%09%09read.close();%0A%09%7D%0A%7D%0A

Create Two-gram.java