@@ -0,0 +1,973 @@
+// http://codeforces.com/problemset/problem/499/B%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.Scanner;%0Aimport java.util.StringJoiner;%0A%0Apublic class Solution %7B%0A%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%09%09int m = read.nextInt();%0A%09%09%0A%09%09// Clear buffer%0A%09%09read.nextLine();%0A%0A%09%09Map%3CString, String%3E language = new HashMap%3CString, String%3E();%0A%09%09for (int i = 0; i %3C m; ++i) %7B%0A%09%09%09String%5B%5D line = read.nextLine().split(%22 %22);%0A%09%09%09String a = line%5B0%5D;%0A%09%09%09String b = line%5B1%5D;%0A%09%09%09language.put(a, b);%0A%09%09%7D%0A%09%09%0A%09%09String%5B%5D lectureText = read.nextLine().split(%22 %22);%0A%09%09StringJoiner output = new StringJoiner(%22 %22);%0A%09%09for (String word : lectureText) %7B%0A%09%09%09String alternativeWord = language.get(word);%0A%09%09%09if (word.length() %3C= alternativeWord.length()) %7B%0A%09%09%09%09output.add(word);%0A%09%09%09%7D%0A%09%09%09else %7B%0A%09%09%09%09output.add(alternativeWord);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09System.out.println(output);%0A%09%09%0A%09%09// Close scanner%0A%09%09read.close();%0A%09%7D%0A%09%0A%7D%0A

Create Lecture.java