I would suggest looking at some other solutions. Taking more than 1s for day 4 suggests your solution is inefficient. I would suggest profiling/timing your code or sections of your code to see where the bottleneck is.
My solution for day4 part 1 & 2 in a debug build takes <0.02s on my machine.
