### My issue

for k in range(int(input())):

a,b=map(int,input().split())

l=

for i in range(0,a+1):

for j in range(0,a+1):

if(i+j==b):

l.append(i-j)

print(max(l))

this code is giving correct ouput, but when it comes to submission, it is showing that time limit exceeded.

### My code

```
for k in range(int(input())):
a,b=map(int,input().split())
l=[]
for i in range(0,a+1):
for j in range(0,a+1):
if(i+j==b):
l.append(i-j)
print(max(l))
```

Learning course: Level up from 1* to 2*

Problem Link: CodeChef: Practical coding for everyone