Language: C++

using namespace std;
int main(){
  pair<pair<int,int>,int>p1,p2;
  int n,w,h,p,k,o;
  while(cin>>n>>w>>h,h){
    vector<pair<pair<int,int>,int> >v;
    v.push_back(mk(mk(w,h),1));
    while(n--){
      int qq=0;
      cin>>p>>k;
      for(int i=0;i<v.size();i++)
	if(v[i].s==p)o=i;
      k=k%(v[o].f.f*2+v[o].f.s*2);
      if(v[o].f.f<k)k-=v[o].f.f,qq++;
      if(v[o].f.s<k)k-=v[o].f.s,qq++;
      if(v[o].f.f<k)k-=v[o].f.f,qq++;
      if(v[o].f.s<k)k-=v[o].f.s,qq++;
      if(qq%2){
	  p1.f.s=k,p1.f.f=v[o].f.f;
	  p2.f.s=v[o].f.s-k,p2.f.f=v[o].f.f;
	  if(k>v[o].f.s)p1.s=v.size()+1,p2.s=v.size();
	  else p1.s=v.size(),p2.s=v.size()+1;
	  v.erase(v.begin()+o);
	  v.push_back(p1);
	  v.push_back(p2);
      }
      else{
	  p1.f.s=v[o].f.s,p1.f.f=k;
	  p2.f.s=v[o].f.s,p2.f.f=v[o].f.f-k;
	  if(k>v[o].f.f)p1.s=v.size()+1,p2.s=v.size();
	  else p1.s=v.size(),p2.s=v.size()+1;
	  v.erase(v.begin()+o);
	  v.push_back(p1);
	  v.push_back(p2);
      }
    }
    /* vector<int>vv;
    for(int i=0;i<v.size();i++)
      vv.push_back(v[i].f.f*v[i].f.s);
    sort(vv.begin(),vv.end());
    for(int i=0;i<vv.size();i++){
      if(i)cout<<' ';
      cout<<vv[i];
    }
    cout<<endl;*/
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'pair' was not declared in this scope
    3 |   pair<pair<int,int>,int>p1,p2;
      |   ^~~~
a.cc:1:1: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
  +++ |+#include <utility>
    1 | using namespace std;
a.cc:3:13: error: expected primary-expression before 'int'
    3 |   pair<pair<int,int>,int>p1,p2;
      |             ^~~
a.cc:5:9: error: 'cin' was not declared in this scope
    5 |   while(cin>>n>>w>>h,h){
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<pair<pair<int,int>,int> >v;
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:6:22: error: expected primary-expression before 'int'
    6 |     vector<pair<pair<int,int>,int> >v;
      |                      ^~~
a.cc:7:5: error: 'v' was not declared in this scope
    7 |     v.push_back(mk(mk(w,h),1));
      |     ^
a.cc:7:20: error: 'mk' was not declared in this scope; did you mean 'k'?
    7 |     v.push_back(mk(mk(w,h),1));
      |                    ^~
      |                    k
a.cc:7:17: error: 'mk' was not declared in this scope; did you mean 'k'?
    7 |     v.push_back(mk(mk(w,h),1));
      |                 ^~
      |                 k
a.cc:19:11: error: 'p1' was not declared in this scope; did you mean 'p'?
   19 |           p1.f.s=k,p1.f.f=v[o].f.f;
      |           ^~
      |           p
a.cc:20:11: error: 'p2' was not declared in this scope; did you mean 'p'?
   20 |           p2.f.s=v[o].f.s-k,p2.f.f=v[o].f.f;
      |           ^~
      |           p
a.cc:28:11: error: 'p1' was not declared in this scope; did you mean 'p'?
   28 |           p1.f.s=v[o].f.s,p1.f.f=k;
      |           ^~
      |           p
a.cc:29:11: error: 'p2' was not declared in this scope; did you mean 'p'?
   29 |           p2.f.s=v[o].f.s,p2.f.f=v[o].f.f-k;
      |           ^~
      |           p