Count total Ordered_pairs
foreach ( KeyValuePair < int , int > entry in m ) { int X = entry . Key ; int Y = entry . Value ; for ( int j = 1 ; j <= Y ; j ++ ) { if ( m [ j ] >= X ) orderedPairs ++ ; } } return orderedPairs ; }