#include #include #include #include #include using namespace std; struct lsh{long x,y;}e[1005]; bool cmp0(lsh a,lsh b) {return(a.xe[i-1].x) j++;a[e[i].y]=j;} for (i=1;i<=q;i++) {scanf("%ld%ld",&Q[i].l,&Q[i].r);Q[i].id=i;Q[i].lk=(Q[i].l-1)/gn+1;} sort(Q+1,Q+q+1,cmp);L=1,R=0; for (i=1;i<=q;i++) { while (RQ[i].r) work(R--,1); while (LQ[i].l) work(--L,0); prt[Q[i].id]=ans; } for (i=1;i<=q;i++) printf("%ld\n",prt[i]); return 0; }