#include<bits/stdc++.h>
using namespace std;
inline int read(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')
f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch-48);
ch=getchar();
}
return x*f;
}
struct akioi{
int value;
int pv=0;
};
akioi ak[1000005];
int n,op,x,k,top=0;
int main(){
n=read();
for(int kkksc03=0;kkksc03<n;kkksc03++){
op=read();
if(op==1){
x=read();
ak[++top].value=x;
}
if(op==2){
top--;ak[top].pv+=ak[top-1].pv;
}
if(op==3){
cout << ak[top].value+ak[top].pv << endl;
}
if(op==4){
x=read();k=read();
ak[top].pv+=x,ak[top-k+1].pv-=x;
}
}
return 0;
}
菜鸟一个,请各位夶佬看看为什么RE