Language: C++

//:55-
#include <iostream>
#include <utility>
#include <map>
using namespace std;

int main(){
  int N;
  while(cin >> N && N>0){
    map<pair<int,int>,int> files;
    for(int j=0;j<N;j++){
      char cmd;
      int I,S,P;
      int h=0, e;
      bool flg;
      cin >> cmd;

      map<pair<int,int>,int>::iterator f;
      switch(cmd){
      case 'W':
      cin >> I >> S;
      while(S>0){
	e=1000000000;
	for(f=files.begin();f!=files.end();++f){
	  if(f->first.first < e && f->first.first > h) e=f->first.first;
	}
	if(S>=h-e){
	  map[make_pair(h,e-1)]=I;
	  S-=h-e;
	}else{
	  map[make_pair(h,h+S)]=I;
	  S=0;
	}
	for(h=e+1;;h++){
	  flg=true;
	  for(f=files.begin();f!=files.end();++f){
	    if(f->first.first<=h && h<=f->first.second){
	      flg=(f->second==-1);
	      break;
	    }
	  }
	  if(flg) break;
	}
      }
      break;
      case 'D':
	cin >> I;
	for(f=files.begin();f!=files.end();++f){
	  if(f->second==I) f->second=-1;
	  if(h>f->first.first) h=f->first.first;
	}
	break;
      case 'R':
	cin >> P;
	for(f=files.begin();f!=files.end();++f){
	  if(P>=f->first.first && P<=f->first.second){
	    cout << f->second << endl;
	    break;
	  }
	}
	If(f==files.end()) cout << -1 << endl;
	break;
      }
    }
    cout << endl;
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:24: error: expected ']' before '(' token
   28 |           map[make_pair(h,e-1)]=I;
      |                        ^
      |                        ]
a.cc:28:33: error: class template argument deduction failed:
   28 |           map[make_pair(h,e-1)]=I;
      |                                 ^
a.cc:28:33: error: no matching function for call to 'map(int&)'
In file included from /usr/include/c++/14/map:63,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_map.h:1473:5: note: candidate: 'template<class _InputIterator, class _Compare, class _Allocator, class, class, class> std::map(_InputIterator, _InputIterator, _Compare, _Allocator)-> map<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type, typename iterator_traits< <template-parameter-1-1> >::value_type::second_type, _Compare, _Allocator>'
 1473 |     map(_InputIterator, _InputIterator,
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1473:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:1482:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Allocator, class, class> std::map(initializer_list<pair<_T1, _T2> >, _Compare, _Allocator)-> map<_Key, _Tp, _Compare, _Allocator>'
 1482 |     map(initializer_list<pair<_Key, _Tp>>,
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1482:5: note:   template argument deduction/substitution failed:
a.cc:28:33: note:   mismatched types 'std::initializer_list<std::pair<_T1, _T2> >' and 'int'
   28 |           map[make_pair(h,e-1)]=I;
      |                                 ^
/usr/include/c++/14/bits/stl_map.h:1489:5: note: candidate: 'template<class _InputIterator, class _Allocator, class, class> std::map(_InputIterator, _InputIterator, _Allocator)-> map<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type, typename iterator_traits< <template-parameter-1-1> >::value_type::second_type, less<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type>, _Allocator>'
 1489 |     map(_InputIterator, _InputIterator, _Allocator)
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1489:5: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:1495:5: note: candidate: 'template<class _Key, class _Tp, class _Allocator, class> std::map(initializer_list<pair<_T1, _T2> >, _Allocator)-> map<_Key, _Tp, less<_Key>, _Allocator>'
 1495 |     map(initializer_list<pair<_Key, _Tp>>, _Allocator)
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1495:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:102:11: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Alloc>)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  102 |     class map
      |           ^~~
/usr/include/c++/14/bits/stl_map.h:102:11: note:   template argument deduction/substitution failed:
a.cc:28:33: note:   mismatched types 'std::map<_Key, _Tp, _Compare, _Alloc>' and 'int'
   28 |           map[make_pair(h,e-1)]=I;
      |                                 ^
/usr/include/c++/14/bits/stl_map.h:197:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map()-> std::map<_Key, _Tp, _Compare, _Alloc>'
  197 |       map() = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:197:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:219:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const std::map<_Key, _Tp, _Compare, _Allocator>&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  219 |       map(const map&) = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:219:7: note:   template argument deduction/substitution failed:
a.cc:28:33: note:   mismatched types 'const std::map<_Key, _Tp, _Compare, _Allocator>' and 'int'
   28 |           map[make_pair(h,e-1)]=I;
      |                                 ^
/usr/include/c++/14/bits/stl_map.h:227:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Allocator>&&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  227 |       map(map&&) = default;
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:227:7: note:   template argument deduction/substitution failed:
a.cc:28:33: note:   mismatched types 'std::map<_Key, _Tp, _Compare, _Allocator>' and 'int'
   28 |           map[make_pair(h,e-1)]=I;
      |                                 ^
/usr/include/c++/14/bits/stl_map.h:240:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::initializer_list<std::pair<const _Key, _Tp> >, const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  240 |       map(initializer_list<value_type> __l,
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:240:7: note:   template argument deduction/substitution failed:
a.cc:28:33: note:   mismatched types 'std::initializer_list<std::pair<const _Key, _Tp> >' and 'int'
   28 |           map[make_pair(h,e-1)]=I;
      |                                 ^
/usr/include/c++/14/bits/stl_map.h:252:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const std::map<_Key, _Tp, _Compare, _Allocator>&, std::__type_identity_t<_Alloc>&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  252 |       map(const map& __m, const __type_identity_t<allocator_type>& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:252:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:256:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Allocator>&&, std::__type_identity_t<_Alloc>&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  256 |       map(map&& __m, const __type_identity_t<allocator_type>& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:256:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:262:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::initializer_list<std::pair<const _Key, _Tp> >, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  262 |       map(initializer_list<value_type> __l, const allocator_type& __a)
      |       ^~~
/usr/include/c++/14/bits/stl_map.h:262:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:268:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  268 |         map(_InputIterator __first, _InputIterator __last,
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:268:9: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:285:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  285 |         map(_InputIterator __first, _InputIterator __last)
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:285:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:302:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator, const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>'
  302 |         map(_InputIterator __first, _InputIterator __last,
      |         ^~~
/usr/include/c++/14/bits/stl_map.h:302:9: note:   candidate expects 3 arguments, 1 provided
a.cc:28:33: note: explicit deduction guides not considered for copy-initialization
   28 |           map[make_pair(h,e-1)]=I;
      |                                 ^
a.cc:31:24: error: expected ']' before '(' token
   31 |           map[make_pair(h,h+S)]=I;
      |                        ^
      |                        ]
a.cc:31:33: error: class template argument deduction failed:
   31 |           map[make_pair(h,h+S)]=I;
      |                                 ^
a.cc:31:33: error: no matching function for call to 'map(int&)'
/usr/include/c++/14/bits/stl_map.h:1473:5: note: candidate: 'template<class _InputIterator, class _Compare, class _Allocator, class, class, class> std::map(_InputIterator, _InputIterator, _Compare, _Allocator)-> map<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type, typename iterator_traits< <template-parameter-1-1> >::value_type::second_type, _Compare, _Allocator>'
 1473 |     map(_InputIterator, _InputIterator,
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1473:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:1482:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Allocator, class, class> std::map(initializer_list<pair<_T1, _T2> >, _Compare, _Allocator)-> map<_Key, _Tp, _Compare, _Allocator>'
 1482 |     map(initializer_list<pair<_Key, _Tp>>,
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1482:5: note:   template argument deduction/substitution failed:
a.cc:31:33: note:   mismatched types 'std::initializer_list<std::pair<_T1, _T2> >' and 'int'
   31 |           map[make_pair(h,h+S)]=I;
      |                                 ^
/usr/include/c++/14/bits/stl_map.h:1489:5: note: candidate: 'template<class _InputIterator, class _Allocator, class, class> std::map(_InputIterator, _InputIterator, _Allocator)-> map<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type, typename iterator_traits< <template-parameter-1-1> >::value_type::second_type, less<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type>, _Allocator>'
 1489 |     map(_InputIterator, _InputIterator, _Allocator)
      |     ^~~
/usr/include/c++/14/bits/stl_map.h:1489:5: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_map.h:1495:5: note: candidate: 'template<class _Key, cla