Why my code isn't working?

Problem Code : EOEO
According to post contest discussion , the approach i used for the below is correct
But somehow its not working for original constraints :

def highestPowerOf2(n):
return (n & (~(n - 1)))
def ispowerof2(num):
if((num & (num - 1)) == 0):
return 1
return 0
for _ in range(int(input())) :
ts = int(input())
if ts == 2 :
print(0)
elif ts % 2 == 1 :
print(ts//2)
elif ispowerof2(ts):
print(0)
else:
x = highestPowerOf2(ts)
y = ts/x
print(int(y//2))