I don't know if it's the number of "mods" (I have 7 mods in my AC submission), but - sure - avoiding mod is not a bad thing.
On the other hand: If numbers get too large, it also slows down the algorithm.
What could be done:
- Generate a large number of random generated testcases
- Do some profiling and look for the bottleneck
- Do e.g. some varations with calculations: Remove some mods or add some mods: What effect has it on the runtime?
- Try other possibilities of I/O. Though it has not to be really optimized, it must be considered here because of large I/O. raw_input() may be too slow in this case. Also try some output variations.
By the way: You know psyco?