Help me in solving DSSA99 problem

My issue

time limit exceeded

My code

def subset_sum_brute_force(numbers, target_sum):
    n = len(numbers)
    flag = 0

    # Generate all possible subsets using binary representation
    for i in range(2**n):
        subset = []
        for j in range(n):
            if (i >> j) & 1:

        # Check if the subset sum equals the target sum
        if sum(subset) == target_sum:
            flag = 1
    if flag == 0:

t = int(input())
for _ in range(t):
    X, N = map(int, input().split())
    A = list(map(int, input().split()))
    subset_sum_brute_force(A, X)

Learning course: Kalasalingam Academy of Research and Education
Problem Link: CodeChef: Practical coding for everyone