optimized l2 to pass kattis