Language: C++

#include <stdio.h>
#include <vector>
#include <string>

using namespace std;

struct DATA{
	int start;
	int end;
	int fileID;
	DATA(int start, int end, int fileID){
		this->start = start, this->end = end, this->fileID = fileID;
	}
};

vector<DATA> data;

void Write(int fileID, int file_length)
{
	int size = (int)data.size();
	for(int i = 0; i < size; i++){
		if(data[i].fileID == -1){
			if(file_length <= data[i].end - data[i].start + 1){
				data.insert(data.begin() + i, DATA(data[i].start, data[i].start + file_length - 1, fileID));
				data[i+1].start = data[i+1].start + file_length;
			}else{
				data[i].fileID = fileID;
				file_length -= data[i].end - data[i].start + 1;
			}
		}
	}
}

void Arrange()
{
	for(int i = 0; i < (int)data.size()-1; i++){
		if(data[i].fileID == -1){
			if(data[i+1].fileID == -1){
				data[i].end = data[i+1].end;
				data.erase(data.begin() + (i+1));
				i--;
			}
		}
	}
}

void Delete(int fileID)
{
	int size = (int)data.size();
	for(int i = 0; i < size; i++){
		if(data[i].fileID == fileID) data[i].fileID = -1;
	}
	Arrange();
}

void Reference(int pos)
{
	int size = (int)data.size();
	for(int i = 0; i < size; i++){
		if(data[i].end >= pos){
			printf("%d\n", data[i].fileID);
			return;
		}
	}
}

int main(void)
{
	int N;
	char com[5];
	int op1, op2;
	
	scanf("%d", &N);
	data.push_back( DATA(0, 1000000001, -1) );
	
	for(int i = 0; i < N; i++){
		
		scanf("%s", com);
		if(strcmp(com, "W") == 0){
			scanf("%d %d", &op1, &op2);
			Write(op1, op2);
		}else if(strcmp(com, "D") == 0){
			scanf("%d", &op1);
			Delete(op1);
		}else if(strcmp(com, "R") == 0){
			scanf("%d", &op1);
			Reference(op1);
		}
	}
	return 0;
}
		

Compiler output:
a.cc: In function 'void Write(int, int)':
a.cc:20:25: error: reference to 'data' is ambiguous
   20 |         int size = (int)data.size();
      |                         ^~~~
In file included from /usr/include/c++/14/vector:69,
                 from a.cc:2:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:16:14: note:                 'std::vector<DATA> data'
   16 | vector<DATA> data;
      |              ^~~~
a.cc:22:20: error: reference to 'data' is ambiguous
   22 |                 if(data[i].fileID == -1){
      |                    ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:16:14: note:                 'std::vector<DATA> data'
   16 | vector<DATA> data;
      |              ^~~~
a.cc:23:43: error: reference to 'data' is ambiguous
   23 |                         if(file_length <= data[i].end - data[i].start + 1){
      |                                           ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:16:14: note:                 'std::vector<DATA> data'
   16 | vector<DATA> data;
      |              ^~~~
a.cc:23:57: error: reference to 'data' is ambiguous
   23 |                         if(file_length <= data[i].end - data[i].start + 1){
      |                                                         ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:16:14: note:                 'std::vector<DATA> data'
   16 | vector<DATA> data;
      |              ^~~~
a.cc:24:33: error: reference to 'data' is ambiguous
   24 |                                 data.insert(data.begin() + i, DATA(data[i].start, data[i].start + file_length - 1, fileID));
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:16:14: note:                 'std::vector<DATA> data'
   16 | vector<DATA> data;
      |              ^~~~
a.cc:24:45: error: reference to 'data' is ambiguous
   24 |                                 data.insert(data.begin() + i, DATA(data[i].start, data[i].start + file_length - 1, fileID));
      |                                             ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:16:14: note:                 'std::vector<DATA> data'
   16 | vector<DATA> data;
      |              ^~~~
a.cc:24:67: error: expected primary-expression before '(' token
   24 |                                 data.insert(data.begin() + i, DATA(data[i].start, data[i].start + file_length - 1, fileID));
      |                                                                   ^
a.cc:24:68: error: reference to 'data' is ambiguous
   24 |                                 data.insert(data.begin() + i, DATA(data[i].start, data[i].start + file_length - 1, fileID));
      |                                                                    ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:16:14: note:                 'std::vector<DATA> data'
   16 | vector<DATA> data;
      |              ^~~~
a.cc:24:83: error: reference to 'data' is ambiguous
   24 |                                 data.insert(data.begin() + i, DATA(data[i].start, data[i].start + file_length - 1, fileID));
      |                                                                                   ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'