Multi-shape pulse pile-up correction: The MCPPU code