what is wrong with my code.The question is Magic set

T=int(input())

l=[]

while T!=0:

cou=0

N,M=input().split()

inp = list(map(int,input().split()))

for i in range(len(inp)):

for j in range(i+1,len(inp)):
    sub=inp[i:j]

    if(len(sub)==0 or len(sub)==len(inp)):
        break
    else:
        s=0
        for k in sub:
            s=s+k
        if(s%int(M)==0):
            cou=cou+1

T=T-1
l.append(cou)

for i in l:

print(i)

for input: 1 4 3 1 2 2 3 output for my code is: 2 but other code the output is 1 what wrong with my code.

Your logic is wrong and another mistake you are doing is use brute force if I am right. You can go through editorial of this question. As you haven’t provided question’s link I think it is MGCSET.

https://discuss.codechef.com/questions/131399/mgcset-editorial