Fast working sliding window script, mem usage 20GB