But I got memory limit exceeded. I downloaded the test data and ran the program on my own computer without problems. Eventually I found out that when compiling with GHC 7.6.3 (the version Kattis uses) rather than 7.8.3, this program runs out of memory.
Can someone explain why it only works on the later compiler? Is there a workaround so that I can submit to Kattis?