add qnikst`s solution

+ fix access violation error found by anonymous
+ speedup fix
add one more test
better output
add mix-mix`s solution