#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<>i&1)ch[i].clear(); summary=0; } void insert(int v){ int high=high_bits(v); summary|=1<>high&1))return true; if(!ch[high].erase(low_bits(v))){ return summary&=~(1<>high&1) && (a=ch[high].nextvalue(low))!=-1){ return index(high,a); }else{ high=summary&~((1<>high&1) && (a=ch[high].prevvalue(low))!=-1){ return index(high,a); }else{ high=summary&((1<>high&1) && 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