https://www.codechef.com/viewsolution/58997286
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin>>t;
while(t--){
string s; cin>>s;
int j=0;
string r=s;
reverse(r.begin(), r.end());
if(s==r){
cout<<0<<endl;
}
else{
for(int i=s.length()-1;i>=s.length()/2;i--){
if(s[i]!=s[j]){
cout<<i<<endl;
break;
}
j++;
}
}
}
return 0;
}