#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) #define indexOf(v,x) (find(all(v),x)-v.begin()) int highest_pop(unsigned int b){ #ifdef __GNUC__ return 31-__builtin_clz(b); #else int res=0; for(int i=4;i>=0;i--){ int shift=1<>shift){ b>>=shift; res|=shift; } } return res; #endif } template class Set{ unsigned int summary; Set *ch[1<<5]; static int low_bits(unsigned int a){ return a&((1<>(U-5); } static int index(unsigned int high,unsigned int low){ return high<(); ch[high]->insert(low_bits(v)); } bool erase(int v){ int high=high_bits(v); if(!ch[high])return true; if(!ch[high]->erase(low_bits(v))){ delete ch[high]; ch[high]=NULL; return summary&=~(1<nextvalue(low))!=-1){ return index(high,a); }else{ high=summary&~((1<min()); } } int prevvalue(int v)const{ int high=high_bits(v); int low=low_bits(v); int a; if(ch[high] && (a=ch[high]->prevvalue(low))!=-1){ return index(high,a); }else{ high=summary&((1<max()); } } int min()const{ if(!summary)return -1; int high=highest_pop(summary&-summary); return index(high,ch[high]->min()); } int max()const{ if(!summary)return -1; int high=highest_pop(summary); return index(high,ch[high]->max()); } bool member(int v)const{ int high=high_bits(v); return ch[high] && ch[high]->member(low_bits(v)); } }; template<> class Set<5>{ unsigned int summary; public: Set():summary(0){} void clear(){summary=0;} void insert(int v){ summary|=1<>v&1; } }; Set<15> xset[20021]; int main(){ int n,ans=0; cin>>n; rep(i,n){ bool hit=false; int x,y; cin>>x>>y; for(int a=max(0,y-20);!hit&&a