>>310

空間計算量なら

takeLast n xs = diff x (drop n xs) where
 diff xs [] = xs
 diff (x:xs) (y:ys) = diff xs ys

みたいなの使えばgetContents使ってもO(1)で済むよ