Help me in solving MANYSUMS problem

My issue

runtime error?
I’ve run it on my pc software, it works perfectly fine
codechef needs to understand that there are various methods to approach a problem, however you are restricting the thinking by limiting the memory space and displaying errors
all i want to say is, don’t just stick to one solution of yours and expect every coder to approach the same

My code

# cook your dish here
t=int(input())
for i in range(t):
    l,r=map(int,input().split())
    temp=[]
    res=[]
    for i in range(l,r+1):
        temp.append(i)
    for j in temp:
        for i in range(l,r+1):
            s=j+i 
            res.append(s)
    a=list(set(res))
    print(len(a))
        
        

Learning course: Level up from 1* to 2*
Problem Link: CodeChef: Practical coding for everyone

@charan940461
Yeah u are right but your approach will take alot of memory and time because u r looping from l to r which is not right because of high value constraints .
So hint of some another logic .
Hint :- think of some maths logic .