Language: C++

import java.util.*;

class Main
{

  

    public static void main(String args[])
    {
	Scanner in = new Scanner(System.in);
	int N;
	while(true)
	    {
		N = in.nextInt();
		if(N == 0)break;
		LinkedList<P> list = new LinkedList<P>();
		list.add(new P(0,0,-1));

		String c;
		int I,S;
		for(int i=0;i<N;i++)
		    {
			c = in.next();
			if(c.equals("W"))
			    {
				I = in.nextInt();
				S = in.nextInt();
				for(int j=0;j<list.size()-1;j++)
				    {	
					int v1 = list.get(j).r;
					int v2 = list.get(j+1).l;
					if(v1 == v2)continue;
					//System.out.println("add ! " + j + " " + v1 + " " + v2);
					list.add(j+1,new P(v1,Math.min((v2-v1)+v1,v1+S),I) ); 
					S -= (v2-v1);
					if(S < 0)S = 0;

					if(S == 0)break;
				    }
				if(S != 0)
				    {

						int lass = (list.size()-1 >= 0?list.get(list.size()-1).r:0);
						list.add(new P(lass,lass+S,I));

				    }
					
			    }
			else if(c.equals("D"))
			    {
				I = in.nextInt();
				for(int j=1;j<list.size();j++)
				    {
					int v = list.get(j).id;
					if(v == I)
					    {
						P p = list.remove(j);
					    }
				    }
			    }
			else
			    {
				I = in.nextInt();
				boolean found = false;
				for(int j=1;j<list.size();j++)
				    {
					P p = list.get(j);
					if(p.l <= I && I < p.r)
					    {
						found = true;
						System.out.println(p.id);
						break;
					    }
				    }
				if(!found)System.out.println(-1);
			    }
			/*
			System.out.println("------------");
			for(int j=0;j<list.size();j++)
			    {
				System.out.println(list.get(j).l + " - " +list.get(j).r + " : " + list.get(j).id);
			    }
			System.out.println("------------");
			*/
		    }
	    }
    }
}

class P
{
    public int r,l,id;
    P(int rl,int rr,int rid)
    {
	r = rr;
	l = rl;
	id = rid;
    }
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:11: error: expected ':' before 'static'
    8 |     public static void main(String args[])
      |           ^~~~~~~
      |           :
a.cc:8:29: error: 'String' has not been declared
    8 |     public static void main(String args[])
      |                             ^~~~~~
a.cc:88:2: error: expected ';' after class definition
   88 | }
      |  ^
      |  ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:10:9: error: 'Scanner' was not declared in this scope
   10 |         Scanner in = new Scanner(System.in);
      |         ^~~~~~~
a.cc:14:21: error: 'in' was not declared in this scope; did you mean 'int'?
   14 |                 N = in.nextInt();
      |                     ^~
      |                     int
a.cc:16:17: error: 'LinkedList' was not declared in this scope
   16 |                 LinkedList<P> list = new LinkedList<P>();
      |                 ^~~~~~~~~~
a.cc:16:28: error: 'P' was not declared in this scope
   16 |                 LinkedList<P> list = new LinkedList<P>();
      |                            ^
a.cc:16:31: error: 'list' was not declared in this scope
   16 |                 LinkedList<P> list = new LinkedList<P>();
      |                               ^~~~
a.cc:16:42: error: 'LinkedList' does not name a type
   16 |                 LinkedList<P> list = new LinkedList<P>();
      |                                          ^~~~~~~~~~
a.cc:16:56: error: expected primary-expression before ')' token
   16 |                 LinkedList<P> list = new LinkedList<P>();
      |                                                        ^
a.cc:17:30: error: expected type-specifier before 'P'
   17 |                 list.add(new P(0,0,-1));
      |                              ^
a.cc:19:17: error: 'String' was not declared in this scope
   19 |                 String c;
      |                 ^~~~~~
a.cc:23:25: error: 'c' was not declared in this scope
   23 |                         c = in.next();
      |                         ^
a.cc:34:58: error: expected type-specifier before 'P'
   34 |                                         list.add(j+1,new P(v1,Math.min((v2-v1)+v1,v1+S),I) );
      |                                                          ^
a.cc:44:62: error: expected type-specifier before 'P'
   44 |                                                 list.add(new P(lass,lass+S,I));
      |                                                              ^
a.cc:57:51: error: expected ';' before 'p'
   57 |                                                 P p = list.remove(j);
      |                                                   ^
a.cc:64:33: error: 'boolean' was not declared in this scope; did you mean 'bool'?
   64 |                                 boolean found = false;
      |                                 ^~~~~~~
      |                                 bool
a.cc:67:43: error: expected ';' before 'p'
   67 |                                         P p = list.get(j);
      |                                           ^
a.cc:68:44: error: 'p' was not declared in this scope
   68 |                                         if(p.l <= I && I < p.r)
      |                                            ^
a.cc:70:49: error: 'found' was not declared in this scope
   70 |                                                 found = true;
      |                                                 ^~~~~
a.cc:71:49: error: 'System' was not declared in this scope
   71 |                                                 System.out.println(p.id);
      |                                                 ^~~~~~
a.cc:75:37: error: 'found' was not declared in this scope
   75 |                                 if(!found)System.out.println(-1);
      |                                     ^~~~~
a.cc:75:43: error: 'System' was not declared in this scope
   75 |                                 if(!found)System.out.println(-1);
      |                                           ^~~~~~
a.cc: At global scope:
a.cc:92:11: error: expected ':' before 'int'
   92 |     public int r,l,id;
      |           ^~~~
      |           :
a.cc:99:2: error: expected ';' after class definition
   99 | }
      |  ^
      |  ;