Cleaning up some Codeforces duplicated code.