Useful Java algorithms found in many contests