Questions from UVa, SPOJ.br and Codeforces