public String compression(String a) {
        if (a.length() < 2)
            return a;
        for (int i = 0; i < a.length(); ++i) {
            int index = i + 1;
            while (index < a.length() && a.charAt(i) == a.charAt(index))
                ++index;
            if (index != i + 1) {
                a = a.substring(0, i + 1) + (index - i) + a.substring(index);
            }
        }
        return a;
    }