1.

/**
* Angewandte Mathematik, SS11
* Problem: 10008 What's Cryptanalysis?
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=949
*
* @author Unverzart Michael
* @author Wurth Manuel
* @version 1.0, 28/5/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.092
*/

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
int lines = new Integer(reader.readLine());
int[] alphabetcount = new int[26];
int[] alphabet = new int[26];
for (int k = 0; k < 26; k++) {
alphabet[k] = k;
}
for (int i = 1; i <= lines; i++) {
char[] array = reader.readLine().toUpperCase().toCharArray();
for (int j = 0; j < array.length; j++) {
if((int)(array[j])-65 >= 0 && (int)(array[j])-65 <=26) alphabetcount[(int)(array[j])-65]++;
}
}
//sort
for (int i = 0; i < 25; i++) {
for (int j = 0; j < 25 - i; j++){
if (alphabetcount[j] < alphabetcount[j + 1]) {
int t;
t = alphabetcount[j];
alphabetcount[j] = alphabetcount[j + 1];
alphabetcount[j + 1] = t;
t = alphabet[j];
alphabet[j] = alphabet[j + 1];
alphabet[j + 1] = t;
}
}
}
for (int i = 0; i < 26; i++) {
if(alphabetcount[i]>0)System.out.println((char)(alphabet[i]+65) + " " + alphabetcount[i]);
}
}
}


2.

/**
* Angewandte Mathematik, SS11
* Problem: 10008 - What's Cryptanalysis
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=949
*
* @author Markus Schöllner
* @author Andreas Maier
* @version 1.0, 05/29/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.136
*/


import java.util.*;
import java.io.*;

public class Main {

public static void main(String[] args) throws IOException, NumberFormatException {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));

Map<Character, LetterAmount> letters = new HashMap<Character,LetterAmount>();

int N = Integer.parseInt(buffer.readLine());
String[] line;
Character currentLetter;

//liest die Zeilen ein, und schreibt die Anzahl der Buchstaben in eine HashMap
for(int c = 0; c < N;c++){
line = buffer.readLine().toUpperCase().replaceAll("\\s", "").replaceAll("\\d", "").replaceAll("\\p{Punct}", "").split("");

for(int i = 1; i< line.length;i++){
currentLetter = line[i].charAt(0);
if(letters.containsKey(currentLetter)){
letters.get(currentLetter).amount++;
}
else {
letters.put(currentLetter, new LetterAmount(currentLetter));
}
}
}
/*schreibt die Werte der HashMap in eine ArrayList
* Beispiel:
* 2
* abcdefg
* 123 adee j
* Inhalt der Hashmap
* {D=D 2, E=E 3, F=F 1, G=G 1, A=A 2, B=B 1, C=C 1, J=J 1}
*
* Inhalt der ArrayList
* [D 2, E 3, F 1, G 1, A 2, B 1, C 1, J 1]
*/
ArrayList<LetterAmount> letterAmount = new ArrayList<LetterAmount>();
letterAmount.addAll(letters.values());
//sortiert die ArrayList absteigend
Collections.sort(letterAmount);
Collections.reverse(letterAmount);

//gibt die ArrayList aus
for(LetterAmount letter: letterAmount) {
System.out.println(letter);
}
}
}
class LetterAmount implements Comparable<LetterAmount> {
Character letter;
int amount;

public LetterAmount(Character letter) {
this.letter = letter;
this.amount = 1;
}

public int compareTo(LetterAmount letterAmount) {
if(amount - letterAmount.amount == 0) return letterAmount.letter - letter;
else return amount - letterAmount.amount;
}

public String toString() {
return letter+ " "+amount;
}
}


-------------------------------------------------------------------


1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 10008 - What's Cryptanalysis?
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=12&page=show_problem&problem=949
*
* @author Evgeni Pavlidis
* @version 1.0, 06/02/2010
*
* Method : Ad hoc
* Status : Accepted
* Runtime: 0.076
*/

import java.io.*;
import java.util.*;

class Main {

public static void main(String...args) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int lines = Integer.parseInt(reader.readLine());

int[] stat = new int[26];
Map<Integer, Set<Character>> map = new TreeMap<Integer, Set<Character>>(Collections.reverseOrder());


String input;
for(int l = 0; l < lines; l++)
{
input = reader.readLine();
input = input.toUpperCase();

for(int i = 0; i < input.length(); i++)
if(Character.isLetter(input.charAt(i)))
stat[input.charAt(i)-'A']++;
}

for(int i = 0; i < 26; i++)
if(stat[i] > 0)
{
if(map.get(stat[i]) == null)
map.put(stat[i], new TreeSet<Character>());
map.get(stat[i]).add((char)(i+'A'));
}

//System.out.println(map);
for(int i : map.keySet())
for(char c : map.get(i))
System.out.println(c + " " + i);
}
}