from itertools import combinations
def numOfPairs(q_len):
result = 0
comb = list(combinations(q, 2))
for pair in comb:
x, y = pair
op_minima
= min
(abs(x
-y
), abs(x
+y
)) op_maxima
= max
(abs(x
-y
), abs(x
+y
))
if op_minima <= minima and op_maxima >= maxima:
result += 1
print(result)
q = [-9,6,-2,1]
numOfPairs(q)
ZnJvbSBpdGVydG9vbHMgaW1wb3J0IGNvbWJpbmF0aW9ucwoKZGVmIG51bU9mUGFpcnMocV9sZW4pOgogICAgcmVzdWx0ID0gMAogICAgY29tYiA9IGxpc3QoY29tYmluYXRpb25zKHEsIDIpKQogICAgZm9yIHBhaXIgaW4gY29tYjoKICAgICAgICB4LCB5ID0gcGFpcgogICAgICAgIG1pbmltYSA9IG1pbihhYnMoeCksIGFicyh5KSkKICAgICAgICBtYXhpbWEgPSBtYXgoYWJzKHgpLCBhYnMoeSkpCiAgICAgICAgb3BfbWluaW1hID0gbWluKGFicyh4LXkpLCBhYnMoeCt5KSkKICAgICAgICBvcF9tYXhpbWEgPSBtYXgoYWJzKHgteSksIGFicyh4K3kpKQogICAgICAgIAogICAgICAgIGlmIG9wX21pbmltYSA8PSBtaW5pbWEgYW5kIG9wX21heGltYSA+PSBtYXhpbWE6CiAgICAgICAgICAgIHJlc3VsdCArPSAxCiAgICBwcmludChyZXN1bHQpCgpxID0gWy05LDYsLTIsMV0gICAgCm51bU9mUGFpcnMocSkK