Store the coordinates along with their frequencies
for ( int i = 0 ; i < n ; i ++ ) m [ make_pair ( x [ i ] , y [ i ] ) ] ++ ; map < pair < int , int > , int > :: iterator i ; for ( i = m . begin ( ) ; i != m . end ( ) ; i ++ ) { cout << ( i -> first ) . first << " ▁ " << ( i -> first ) . second << " ▁ " << i -> second << " STRNEWLINE " ; } }