Why is my code slow can someone suggest me

The problem I am facing is in these Question:CodeChef: Practical coding for everyone

My Solution is these
https://www.codechef.com/viewsolution/51521190

I just wanted to know why is my solution not getting me 100pts as it works which loop makes it slower

def count_combs(nums, n):
    count = 0
    num_set = set(nums)  # Convert nums list to set for constant-time lookup

    for i in nums:
        for j in nums:
            if i != j and (i + j) / 2 in num_set:  # Check if half-sum exists in the set
                count += 1
                break  # No need to continue checking for this element i

    return count

if __name__ == "__main__":
    n = int(input())
    nums = [int(input()) for _ in range(n)]
    print(count_combs(nums, n))
  1. Avoid Creating All Combinations: Instead of creating all combinations, we directly iterate through the list nums and compare each element with all the other elements.

  2. Use Sets for Constant-Time Lookup: We convert the nums list into a set num_set to enable constant-time lookup operations.

  3. Optimized Check for Half-Sum: We simplify the logic to check if the half-sum of two elements exists in the set num_set.