Help me in solving MEANMEDIAN problem

My issue

Can anyone help me about how to reduce time complexity? Even though my code is correct, i can’t get out of this time complexity issue.

My code

# cook your dish here
T=int(input())
for _ in range(T):
    X, Y=map(int, input().split())
    C=0
    B= Y
    for i in range(-1000, 1001):
        C=i
        A=((X*3)-Y)-C
        if(C>=B and A<=B):
            break
    print(A, B, C)   

Learning course: Roadmap to 3*
Problem Link: https://www.codechef.com/learn/course/klu-roadmap-3star/KLURMP301/problems/MEANMEDIAN