The Great Run

I had run this code on idle and it works but it doesn’t on codechef(Python3.5), it shows wrong answer(It is the question in practice->beginner->The Great Run)-

t=int(input())

c=0

while(t>0):

(n,k)=map(int,input().split())

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

for i in range(0,n-k+1):

	sm=0

	for j in range(i,(i+k)):

		sm+=d[j]

	if(sm>c):

		c=sm

print (c)

    t-=1

You should re-initialize c within each test case, not before.