Type-Based Amortized Stack Memory Prediction