Algorithms for Various Questions in Various Languages (Mostly Java)