Is there a way to make it run faster and reduce redundancy? here is my code to solve the Magic Checkerboard on Kattis: