1.

/**

 * @group Lermer Florian, Sayli Hidir, Taskin Umut

 * @contact lermer@gmail.de, saylihidir@hotmail.de taskin_umut@yahoo.de

 * @Problem_ID=10815

 * @Link http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=20&problem=1756&mosmsg=Submission+received+with+ID+7057887

 *

 * @status Accepted

 * @Version V1.03

 *

 * @problematical_issues - tried to use replaceAll function but it does not work


 */

import java.util.Scanner;

import java.util.Set;

import java.util.TreeSet;

public class Main {

       

        /**

         * @param args

         */

        public static void main(String[] args) {

                // TODO Auto-generated method stub

                Set<String> in=new TreeSet<String>();

                Scanner sc=new Scanner(System.in);

                while(sc.hasNext())

                {

                        String[] st=sc.next().split("[^a-zA-Z]");

                        for (String string : st) {

                                in.add(string.toLowerCase());

                        }

                }

                in.remove("");

                for (String str : in) {

                        System.out.println(str);

                }

        }

}

2.

/**
 * Angewandte Mathematik, SS09, IFB 2C
 * ACM Problem #10815 (Andy's First Dictonary)
 * http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&Itemid=8&category=20&page=show_problem&problem=1756
 *
 * @author Christian Posselt
 * @author Jonathan Schubert
 * @version 1.0, 04/08/2009
 *
 * Status : Accepted
 * Runtime: 0.460
 */

import java.io.*;
import java.util.*;
import java.util.regex.Pattern;

class Main {
   
    public static void main(String[] args) throws IOException
    {
        //Set up needed variables
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line;
       
        //TreeSet is a ordered Set
        Set<String> dict = new TreeSet<String>();
       
        try
        {
            while(true)
            {
                line = reader.readLine();
               
                if(line==null)
                    break;
           
                //split to String Array when sign is not a character
                Pattern p = Pattern.compile("[^a-zA-Z]");
                String[] nextwords = p.split(line);
               
                //add words of line to TreeSet
                for(String str:nextwords)
                {
                    String next = str.toLowerCase();
                    dict.add(next);
                }
               
                //remove Strings coming from empty lines.
                dict.remove("");
            }
        }
        finally
        {
            System.out.println(dict.toString());
            for(String str:dict)
                System.out.println(str);
        }
       
    }
}