#include #include #include #include using namespace std; using ll = long long; int main(void){ int n, k, q; cin >> n >> k >> q; multiset small, big; big.insert(1e18); for(int i=0; i> a; small.insert(a); } auto f=[&](){ while(small.size()>k){ auto p=prev(small.end()); big.insert(*p); small.erase(p); } while(small.size()> t; if(t==1){ ll x; cin >> x; small.insert(x); f(); } else if(t==2){ ll y; cin >> y; auto p=prev(small.end()); auto q=big.begin(); ll ad=(*p)+y; small.erase(p); small.insert(ad); small.insert(*q); big.erase(q); f(); } else{ cout << *small.rbegin() << '\n'; } } return 0; }