but it runs over the 5-second time-limit
I downloaded the test data and found that on GHC 7.8.3, if I switch from -O2 to -O0, it runs three times faster (almost certainly fast enough for Kattis to accept). Can someone tell me what's going on? Is this a bug?