Chef Chefina and theier friendship

Does anyone know Why this code is giving TLE?

t=int(input())

for i in range(t):
x=input()
n=len(x)
i=1
j=(n//2)-i
j_old=j
cnt=0
if(x.count(x[0])==n):
print(n//2-1)
else:
while(i<=j_old):
#print(i,j)
a=x[0:i]
b=x[i:(2*i)]
c=x[(2i):(2i)+j]
d=x[((2i)+j):((2i)+(2*j))]
if(a==b and c==d):
cnt+=1
i+=1
j=(n//2)-i

	print(cnt)

Can you share the link to this submission?

You r doing Brute force and after the contest the test cases are updated so it will not pass buddy :slight_smile: … try Hashing :slight_smile: