Timeout means one of three things.
1) You took too long to think about the answer (generally this means > 100ms)
2) Your program crashed. Millions of ways for this to happen.
3) You didn't give an answer. Example in pseudocode:
if value < 3 then answer = 1
if value > 3 then answer = 2
value turns out to be 3, no answer is given.
One of those things is probably true in your code.