My code is as follows:

```
class MinStack {
stack<long> myStack;
long min;
public:
void push(int x) {
if (myStack.empty()){
myStack.push(0);
min = x;
}
else{
myStack.push(x-min);
if (x < min) min = x;
}
}
void pop() {
if (!myStack.empty()) {
long x = myStack.top();
if (x < 0) min = min-x;
myStack.pop();
}
}
int top() {
long x = myStack.top();
if (x > 0) return (int)(x + min);
else return (int)min;
}
int getMin() {
return (int)min;
}
};
```

The test case I failed was the one involving long numbers:

```
Input: push(2147483646),push(2147483646),push(2147483647),top,pop,getMin,pop,getMin,pop,push(2147483647),top,getMin,push(-2147483648),top,getMin,pop,getMin
Output: [2147483647,2147483646,2147483646,2147483647,2147483647,-2147483647,-2147483648,-2147483648]
Expected: [2147483647,2147483646,2147483646,2147483647,2147483647,-2147483648,-2147483648,2147483647]
```

However, on my XCode, my code gives exactly what is expected. Anyone please advise?