Store the coordinates along with their frequencies
for i in range ( n ) : NEW_LINE INDENT m [ ( x [ i ] , y [ i ] ) ] = m . get ( ( x [ i ] , y [ i ] ) , 0 ) + 1 NEW_LINE DEDENT e = sorted ( m ) NEW_LINE for i in e : NEW_LINE INDENT print ( i [ 0 ] , i [ 1 ] , m [ i ] ) NEW_LINE DEDENT