Language: C++

#include<bits/stdc++.h>
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:8:20: error: 'mk' was not declared in this scope; did you mean 'k'?
    8 |     v.push_back(mk(mk(w,h),1));
      |                    ^~
      |                    k
a.cc:8:17: error: 'mk' was not declared in this scope; did you mean 'k'?
    8 |     v.push_back(mk(mk(w,h),1));
      |                 ^~
      |                 k
a.cc:13:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 's'
   13 |         if(v[i].s==p)o=i;
      |                 ^
a.cc:14:17: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   14 |       k=k%(v[o].f.f*2+v[o].f.s*2);
      |                 ^
a.cc:14:28: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   14 |       k=k%(v[o].f.f*2+v[o].f.s*2);
      |                            ^
a.cc:15:15: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   15 |       if(v[o].f.f<k)k-=v[o].f.f,qq++;
      |               ^
a.cc:15:29: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   15 |       if(v[o].f.f<k)k-=v[o].f.f,qq++;
      |                             ^
a.cc:16:15: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   16 |       if(v[o].f.s<k)k-=v[o].f.s,qq++;
      |               ^
a.cc:16:29: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   16 |       if(v[o].f.s<k)k-=v[o].f.s,qq++;
      |                             ^
a.cc:17:15: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   17 |       if(v[o].f.f<k)k-=v[o].f.f,qq++;
      |               ^
a.cc:17:29: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   17 |       if(v[o].f.f<k)k-=v[o].f.f,qq++;
      |                             ^
a.cc:18:15: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   18 |       if(v[o].f.s<k)k-=v[o].f.s,qq++;
      |               ^
a.cc:18:29: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   18 |       if(v[o].f.s<k)k-=v[o].f.s,qq++;
      |                             ^
a.cc:20:14: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 'f'
   20 |           p1.f.s=k,p1.f.f=v[o].f.f;
      |              ^
a.cc:20:23: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 'f'
   20 |           p1.f.s=k,p1.f.f=v[o].f.f;
      |                       ^
a.cc:20:32: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   20 |           p1.f.s=k,p1.f.f=v[o].f.f;
      |                                ^
a.cc:21:14: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 'f'
   21 |           p2.f.s=v[o].f.s-k,p2.f.f=v[o].f.f;
      |              ^
a.cc:21:23: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   21 |           p2.f.s=v[o].f.s-k,p2.f.f=v[o].f.f;
      |                       ^
a.cc:21:32: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 'f'
   21 |           p2.f.s=v[o].f.s-k,p2.f.f=v[o].f.f;
      |                                ^
a.cc:21:41: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   21 |           p2.f.s=v[o].f.s-k,p2.f.f=v[o].f.f;
      |                                         ^
a.cc:22:21: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   22 |           if(k>v[o].f.s)p1.s=v.size()+1,p2.s=v.size();
      |                     ^
a.cc:22:28: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 's'
   22 |           if(k>v[o].f.s)p1.s=v.size()+1,p2.s=v.size();
      |                            ^
a.cc:22:44: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 's'
   22 |           if(k>v[o].f.s)p1.s=v.size()+1,p2.s=v.size();
      |                                            ^
a.cc:23:19: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 's'
   23 |           else p1.s=v.size(),p2.s=v.size()+1;
      |                   ^
a.cc:23:33: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 's'
   23 |           else p1.s=v.size(),p2.s=v.size()+1;
      |                                 ^
a.cc:29:14: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 'f'
   29 |           p1.f.s=v[o].f.s,p1.f.f=k;
      |              ^
a.cc:29:23: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   29 |           p1.f.s=v[o].f.s,p1.f.f=k;
      |                       ^
a.cc:29:30: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 'f'
   29 |           p1.f.s=v[o].f.s,p1.f.f=k;
      |                              ^
a.cc:30:14: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 'f'
   30 |           p2.f.s=v[o].f.s,p2.f.f=v[o].f.f-k;
      |              ^
a.cc:30:23: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   30 |           p2.f.s=v[o].f.s,p2.f.f=v[o].f.f-k;
      |                       ^
a.cc:30:30: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 'f'
   30 |           p2.f.s=v[o].f.s,p2.f.f=v[o].f.f-k;
      |                              ^
a.cc:30:39: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   30 |           p2.f.s=v[o].f.s,p2.f.f=v[o].f.f-k;
      |                                       ^
a.cc:31:21: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, int> >, std::pair<std::pair<int, int>, int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, int>'} has no member named 'f'
   31 |           if(k>v[o].f.f)p1.s=v.size()+1,p2.s=v.size();
      |                     ^
a.cc:31:28: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 's'
   31 |           if(k>v[o].f.f)p1.s=v.size()+1,p2.s=v.size();
      |                            ^
a.cc:31:44: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 's'
   31 |           if(k>v[o].f.f)p1.s=v.size()+1,p2.s=v.size();
      |                                            ^
a.cc:32:19: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 's'
   32 |           else p1.s=v.size(),p2.s=v.size()+1;
      |                   ^
a.cc:32:33: error: 'struct std::pair<std::pair<int, int>, int>' has no member named 's'
   32 |           else p1.s=v.size(),p2.s=v.size()+1;
      |                                 ^