• How to use preprocessing?

Question related to mission Haunted House

 

I would like to solve this mission by some kind of preprocessing. However, calling the preprocessing function from main doesn't work. Is there any better way than doing the preprocessing again in each step? I would like to call the preprocessing function once and then access its results every time I run my checkio function, but I have no idea how to do it except for calling it from main, which seems forbidden.