# Can any one help me out why this is giving runtime error?

import math
testcasesma=int(input())
iiv=0
while(iiv<testcasesma):
p=int(input())
banana=list(map(int,input().split(" ")[:p]))
joana=0
catty=[]

``````while(joana<p):
ll=int(math.pow(2,joana))
catty.append(ll*banana[joana])
joana+=1
jzoo=0
ps=0
ns=0
while(jzoo<p):
love=jzoo+1
while(love<=p):
if((sum(catty[jzoo:love]))>0):
ps+=1
elif((sum(catty[jzoo:love]))<0):
ns+=1
love+=1
jzoo+=1

print(abs(ps-ns))
iiv+=1

it is working fine for one testcase it is giving runtime error for 2nd testcase here is the question link https://www.codechef.com/START89D/problems/POSITNEG this i am discussing after contest is completed.``````

Well, there are some logical issues with your code.
Try below code once, it may fix your error.

``````import math

testcasesma = int(input())
iiv = 0

while iiv < testcasesma:
p = int(input())
banana = list(map(int, input().split(" ")[:p]))
joana = 0
catty = []

while joana < p:
ll = int(math.pow(2, joana))
catty.append(ll * banana[joana])
joana += 1

jzoo = 0
ps = 0
ns = 0

while jzoo < p:
love = jzoo + 1
while love <= p:
if sum(catty[jzoo:love]) > 0:
ps += 1
elif sum(catty[jzoo:love]) < 0:
ns += 1
love += 1
jzoo += 1

print(abs(ps - ns))
iiv += 1
``````

Thanks