add contest and contest problems to database.
make exception messages more explicit.
fix coding style