#include <bits/stdc++.h>
// Implement class for minStack.
class minStack
{
// Write your code here.
stack<pair<int,int>>st;
public:
// Constructor
minStack()
{
// Write your code here.
}
// Function to add another element equal to num at the top of stack.
void push(int val)
{
// Write your code here
if(st.empty()) st.push({val,val});
else st.push({val, min(val, st.top().second)});
}
// Function to remove the top element of the stack.
int pop()
{
// Write your code here.
if(st.empty()) return -1;
int x = st.top().first;
st.pop();
return x;
}
// Function to return the top element of stack if it is present. Otherwise return -1.
int top()
{
// Write your code here.
if(st.empty()) return -1;
return st.top().first;
}
// Function to return minimum element of stack if it is present. Otherwise return -1.
int getMin()
{
// Write your code here.
if(st.empty()) return -1;
return st.top().second;
}
};


