Function to count total Magic square subgrids
def CountMagicSquare ( Grid ) : NEW_LINE INDENT ans = 0 NEW_LINE for i in range ( 0 , R - 2 ) : NEW_LINE INDENT for j in range ( 0 , C - 2 ) : NEW_LINE DEDENT DEDENT