Several source codes by badpoet on www.codeforces.com