#include #include #include #include #include #include #define SIZE 50 #define BIG 1000000 using namespace std; struct heap { long long data[BIG]; int count; heap() { count = 0; } bool isempty() { return count==0; } void add(long long a) { //printf("added: %lld\n", a); data[count++] = a; bubbleup(count); } void bubbleup(int pos) { int npos = pos/2; if(npos <= 0) return; if(data[npos-1] > data[pos-1]) { long long tmp = data[npos-1]; data[npos-1] = data[pos-1]; data[pos-1] = tmp; bubbleup(npos); } } void bubbledown(int pos) { int npos = pos*2; if(npos <= count) { long long tmp = data[npos-1]; if(npos+1 <= count) if(data[npos] < tmp) { tmp = data[npos]; npos++; } if(data[pos-1] > tmp) { data[npos-1] = data[pos-1]; data[pos-1] = tmp; bubbledown(npos); } } } long long remove() { long long res = data[0]; data[0] = data[count-1]; count--; bubbledown(1); return res; } }; char str[SIZE]; int N; long long X, Y; long long p[SIZE]; /* void fce(int pos, int num) { if(num > Y) return; if(num >= X) s.insert(num); for(int i=pos; i= X && curr <= Y) { if(last != curr) { if(printed++) printf(",%lld", curr); else printf("%lld", curr); } last = curr; } if(curr <= Y) { for(int i=0; i