Stack memory issue

I was solving a question which required (according to my solution) stack implementation. First I used STL stack for the it. But memory limit was exceeded. Then I created my own class for stack but issue was still the same, which at least cleared that STL was not at fault. I need your advice, why is occupying 65952 KiB (that too at error).

Please note: I have provided code so that there is no other confusion as my code could be wrong as well. I am asking anyone to debug it, I am just interested in knowing memory issues.
And code is correctly working, those ampersand after cin or cout are actually appropriate >> and << operators, please ignore them

Code is provided below


using namespace std;

class st{
    vector<int> arr;
    int tp;
        tp = -1;
    void push(int a){
    void pop(){
    int top(){
        return arr[tp];
    int size(){
        return tp+1;
    void reset(){
        tp = -1;

int main(){
    int t;
    cin >> t;
    st s;
        vector<int> vec;
        vector<int> del;
        vector<int>::iterator itr;
        int a,n,k;
        cin >> n >> k;
        for(int i = 0; i < n; ++i){
            cin >> a;
            if(i > 0){
                while(s.size() and a > vec[]){del.push_back(;s.pop();}
        int i;
        for(i = 0; i < k && i < del.size(); ++i){
            itr = vec.begin()+del[i]-i;
        if(i != k){
            while(i < k){
                itr = vec.end()-i;
        for(i = 0; i < vec.size(); ++i) cout << vec[i] << " ";
        cout << endl;
    return 0 ;

first of all post the question for which u implemented this code.