Question: 
Write a function to find all pairs in an integer array whose sum is equal to a given number.


Model's Code:
def get_pairs_count(arr, target_sum, pair_count):
    count = 0
    seen = {}
    
    for num in arr:
        complement = target_sum - num
        if complement in seen:
            count += seen[complement]
        
        if num in seen:
            seen[num] += 1
        else:
            seen[num] = 1
    
    return count if count == pair_count else 0



Sample Correct Code:
def get_pairs_count(arr, n, sum):
    count = 0 
    for i in range(0, n):
        for j in range(i + 1, n):
            if arr[i] + arr[j] == sum:
                count += 1
    return count


Asserts:
assert get_pairs_count([1, 5, 7, -1, 5], 5, 6) == 3
assert get_pairs_count([1, 5, 7, -1], 4, 6) == 2
assert get_pairs_count([1, 1, 1, 1], 4, 2) == 6


Tests:
Test 1 of 3: FAIL: AssertionError()

Test 527 of 974: 388/527 (73.62428842504744%): failed