#include #include int main(){ int n,m,i,j,cross; int *a,*b; scanf("%d %d", &n, &m); a = (int*)malloc(n); b = (int*)malloc(n); for ( i = 0; i < n; i++){ scanf("%d %d", &a[i], &b[i]); } cross = 0; for ( i = 0; i < n-1; i++){ for (j = i+1; j < n; j++){ if( a[j] < a[i] || b[i] < a[j]){ if ( a[i] a[i] || b[i] > a[j]){ if( a[i] > b[j] || b[j] > b[i]){ cross += 1; } } } } printf("%d", cross/2); return 0; }