Lapindromes problem in contest 1 Please help in telling whats wrong

#include
#include
using namespace std;

int main() {

int t;
cin>>t;

for(int i=0;i<t;i++){
    int q;
    string s,w,e,r,y;
    cin>>s;
    q=s.length();
    
    if(q%2==0){
       w = s.substr(0,((q/2)-1));
       e = s.substr(q/2,q-1);
       int k = e.compare(w);
        
        if(k==0 || w.length() == e.length())
            cout<<"YES";
        else
            cout<<"NO";
    
    }
    
    else{
        r = s.substr(0,q/2-1);
        y = s.substr((q/2)+1,q-1);
        
        int k = r.compare(y);
        
            if(k==0 || r.length() == y.length())
                cout<<"YES";
            else
                cout<<"NO";
        
    }
    
}
return 0;

}