sum square difference code