https://www.codechef.com/COOK118B/problems/CHEFSHIP

Why am I getting TLE for this question???Even thought the test cases are passing?
#include<bits/stdc++.h>
using namespace std;

int main()
{
// RUCHITA;
int t;
cin>>t;
while(t–)
{
string s;
cin>>s;
int l = 1,co = 0;
int n=s.length();
while(l<(n/2))
{
if( (s.substr(0,l) == s.substr(l,l)) and (s.substr(2*l,(n/2)-l) == s.substr(n/2+l,(n/2)-l)) )
co++;
l++;

    }
    cout << co <<"\n";
}
return 0;

}