5 added 230 characters in body
source | link

Counting all pairs, filtering Inf/NaN out and dividing by two:

q_N#:L;N-" +"f#ee2m*{z~:*\Lfmd2/:.-:mh/}%{zL<},:+2/

Alternatively, filtering coordinates first so we count each pair once and don't run into Inf/NaN:

q_N#:L;N-" +"f#ee2m*{0f=:<},{z~:*\Lfmd2/:.-:mh/}%:+
q_N#:L;N-" +"f#ee2m*{z~:*\Lfmd2/:.-:mh/}%{zL<},:+2/

Counting all pairs, filtering Inf/NaN out and dividing by two:

q_N#:L;N-" +"f#ee2m*{z~:*\Lfmd2/:.-:mh/}%{zL<},:+2/

Alternatively, filtering coordinates first so we count each pair once and don't run into Inf/NaN:

q_N#:L;N-" +"f#ee2m*{0f=:<},{z~:*\Lfmd2/:.-:mh/}%:+
4 deleted 1 character in body
source | link

CJam, 5251 chars

q_N#:L;N-" +"f#ee2m*{z~:*\1*\Lfmd2/Lffmd:.-:mh/}%{zL<},:+2/

CJam, 52 chars

q_N#:L;N-" +"f#ee2m*{z~:*\1/Lffmd:.-:mh/}%{zL<},:+2/

CJam, 51 chars

q_N#:L;N-" +"f#ee2m*{z~:*\Lfmd2/:.-:mh/}%{zL<},:+2/
3 added 4 characters in body
source | link

CJam, 6252 chars

q_N#:L;N-:i:(3f%:(ee2m*" +"f#ee2m*{e_~@*\aa@aa+Lffmdz~:*\1/Lffmd:.-:mh/}%{zL<},:+2/

Explanation (old)

CJam, 62 chars

q_N#:L;N-:i:(3f%:(ee2m*{e_~@*\aa@aa+Lffmd:.-:mh/}%{zL<},:+2/

Explanation

CJam, 52 chars

q_N#:L;N-" +"f#ee2m*{z~:*\1/Lffmd:.-:mh/}%{zL<},:+2/

Explanation (old)

2 added 1148 characters in body
source | link
1
source | link