After yesterday, this was delightfully simple, mostly reading comprehension. I didn't even bother going through the effort of optimizing the second part, opting for a couple minute brute force instead.