Call a triple (a,b,c) good if and only if (a,b),(a,c), and (b,c) all belong to S. For i in {1,2,…,n}, let di be the number of pairs in S that contain i, and let Di be the set of numbers paired with i in S (so ∣Di∣=di). Consider a pair (i,j)∈S. Our goal is to estimate the number of integers k such that any permutation of {i,j,k} is good, that is, ∣Di∩Dj∣. Note that i∈/Di and j∈/Dj, so i,j∈/Di∩Dj; thus any k∈Di∩Dj is different from both i and j, and {i,j,k} has three elements as required. Now, since Di∪Dj⊆{1,2,…,n},
∣Di∩Dj∣=∣Di∣+∣Dj∣−∣Di∪Dj∣≤di+dj−n.
Summing all the results, and having in mind that each good triple is counted three times (one for each two of the three numbers), the number of good triples T is at least
T≥31(i,j)∈S∑(di+dj−n).
Each term di appears each time i is in a pair from S, that is, di times; there are m pairs in S, so n is subtracted m times. By the Cauchy-Schwarz inequality
T≥31(i=1∑ndi2−mn)≥31(n(∑i=1ndi)2−mn).
Finally, the sum ∑i=1ndi is 2m, since di counts the number of pairs containing i, and each pair (i,j) is counted twice: once in di and once in dj. Therefore
T≥31(n(2m)2−mn)=4m3n(m−4n2).