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 bi<aj. For this, count the cnt[x] — the number of pairs with ai<bi≤x fo