accepted solution to a subset problems from uva onlinejudge website.