First, let's count the number of pairs with LIS=4. Clearly, we should consider only pairs with ai<bi, and have to count the number of such pairs (i,j) that b_i<a_j. For this, count the cnt[x] — the number of pairs with a_i < b_i\le x fo