@@ -0,0 +1,1585 @@
+import java.io.BufferedReader;%0Aimport java.io.InputStreamReader;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Apublic class ClosestString %7B%0A%0A    public static void main(String%5B%5D args) throws Exception %7B%0A        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));%0A        List%3CString%3E lines = new ArrayList%3C%3E();%0A        int numberOfLines = Integer.parseInt(reader.readLine());%0A        for (int i = 0; i %3C numberOfLines; i++) %7B%0A            lines.add(reader.readLine());%0A        %7D%0A        System.out.println(new ClosestString().run(lines));%0A    %7D%0A%0A    public String run(List%3CString%3E lines) %7B%0A        int minDistanceSum = Integer.MAX_VALUE;%0A        int minIdx = Integer.MAX_VALUE;%0A        for (int i = 0; i %3C lines.size(); i++) %7B%0A            String line = lines.get(i);%0A            int distanceSum = 0;%0A            for (int j = 0; j %3C lines.size(); j++) %7B%0A                if (i != j) %7B%0A                    distanceSum += hammingDistance(line, lines.get(j));%0A                %7D%0A            %7D%0A            if (distanceSum %3C minDistanceSum) %7B%0A                minDistanceSum = distanceSum;%0A                minIdx = i;%0A            %7D%0A        %7D%0A        return lines.get(minIdx);%0A    %7D%0A%0A    private int hammingDistance(String first, String second) %7B%0A        if (first.length() != second.length()) %7B%0A            return Integer.MAX_VALUE;%0A        %7D%0A        int diffCount = 0;%0A        for (int i = 0; i %3C first.length(); i++) %7B%0A            if (first.charAt(i) != second.charAt(i)) %7B%0A                diffCount++;%0A            %7D%0A        %7D%0A        return diffCount;%0A    %7D%0A%7D%0A

Add ClosestString