#include #include #define LL long long using namespace std; const LL Maxn=100010; const LL Inf=(LL)1<<62; LL n,Kase,L,R,a[Maxn],Ans,last; struct Node {LL l,r;}T[Maxn]; inline LL Max(LL x,LL y) {return x>y?x:y;} inline LL Min(LL x,LL y) {return x>y?y:x;} inline bool cmp(Node A,Node B) {return A.llast) Ans+=Min(R+1,T[i].l)-last-1; last=Max(last,T[i].r); if (last>=R) break; } if (R>=last) Ans+=R-last; printf("%I64d\n",Ans); } return 0; }