SRM 310 DIV 2 easy mid hard

agonize about (int vs long long)