for i in range(1,n):
for j in range(0,1001):
dp[i][j]=dp[i-1][j]
for j in range(0,1001):
dp[i][a[i]^j]=max(dp[i-1][j]+1,dp[i-1][a[i]^j])

why range here is 1001 and not 1024 because xor can vary till 1024. Although a[i] <=1000 but a[i]^j can be above 1000 till 1024.. no?? and this will affect when you are calculating max using dp.. because you have not updated cells of j>1000..