Language: C++

//tyama_C_fast.cpp
//much faster!

//PerlÅà¯é¯Ç½ªâçÈ¢B

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define hi(x) (x).first
#define lo(x) (x).second

struct comp{
    bool operator()(const unsigned a, const unsigned b){return hi(a)*lo(a) < hi(b)*lo(b);}
};

inline void solve(int n, int w, int d){
	vector<pair<int,int>> v;
	v.push_back(make_pair(w,d));
	while(n--){
		int p, s, state=0;
		scanf("%d %d", &p, &s);
		p--;
		s%=(hi(v.at(p))+lo(v.at(p)));
		
		unsigned x=hi(v.at(p)), y=lo(v.at(p)), _x=0, _y=0;
		while(s--){
			switch(state){
				case 0:{
					_x++;
					if(_x==x)state=1;
					break;
				}
				case 1:{
					_y++;
					/* impossible
					if(_y==y)state=2;
					break;
				}
				case 2:{
					_x--;
					if(_x==0)state=3;
					break;
				}
				case 3:{
					_y--;
					if(_y==0)state=0;
					*/
					break;
				}
			}
		}
		unsigned x1, x2, y1, y2;
		switch(state){
			case 0: /*case 2:*/{
				x1=_x;x2=x-_x;
				y1=y2=y;
				break;
			}
			case 1: /*case 3:*/{
				x1=x2=x;
				y1=_y;y2=y-_y;
				break;
			}
		}
		
		v.erase(v.begin()+p);
		if(x1*y1>x2*y2){
			v.push_back(make_pair(x2,y2));
			v.push_back(make_pair(x1,y1));
		}else{
			v.push_back(make_pair(x1,y1));
			v.push_back(make_pair(x2,y2));
		}
	}
	
	sort(v.begin(), v.end());
	while(v.size()){
		printf("%d", hi(v.at(0))*lo(v.at(0)));
		v.erase(v.begin());
		if(v.size())printf(" "); //±ÌÓÍPerl¾Æjoinªg¦é¨B
	}
	printf("\n");
}

int main(){
	int n,w,d;
	while(1){
		scanf("%d %d %d",&n,&w,&d);
		if(!n&&!w&&!d)return 0;
		solve(n, w, d);
	}
}

Compiler output:
a.cc: In member function 'bool comp::operator()(unsigned int, unsigned int)':
a.cc:11:19: error: request for member 'first' in 'a', which is of non-class type 'const unsigned int'
   11 | #define hi(x) (x).first
      |                   ^~~~~
a.cc:15:64: note: in expansion of macro 'hi'
   15 |     bool operator()(const unsigned a, const unsigned b){return hi(a)*lo(a) < hi(b)*lo(b);}
      |                                                                ^~
a.cc:12:19: error: request for member 'second' in 'a', which is of non-class type 'const unsigned int'
   12 | #define lo(x) (x).second
      |                   ^~~~~~
a.cc:15:70: note: in expansion of macro 'lo'
   15 |     bool operator()(const unsigned a, const unsigned b){return hi(a)*lo(a) < hi(b)*lo(b);}
      |                                                                      ^~
a.cc:11:19: error: request for member 'first' in 'b', which is of non-class type 'const unsigned int'
   11 | #define hi(x) (x).first
      |                   ^~~~~
a.cc:15:78: note: in expansion of macro 'hi'
   15 |     bool operator()(const unsigned a, const unsigned b){return hi(a)*lo(a) < hi(b)*lo(b);}
      |                                                                              ^~
a.cc:12:19: error: request for member 'second' in 'b', which is of non-class type 'const unsigned int'
   12 | #define lo(x) (x).second
      |                   ^~~~~~
a.cc:15:84: note: in expansion of macro 'lo'
   15 |     bool operator()(const unsigned a, const unsigned b){return hi(a)*lo(a) < hi(b)*lo(b);}
      |                                                                                    ^~