Problem and Official Solution

The user input consists of a sequence of positive integers \(x_0\), \(y_0\), \(x_1\), \(y_1\), \(x_2\), \(y_2\), \(\dots\) We do not know the length in advance. A negative number or \(0\) instead of a value for \(y_n\) is the signal that the input is over. Create the program that calculates

\[\left(\max\left\{x_0,y_0\right\}+x_0y_0\right)+\left(\max\left\{x_1,y_1\right\}+x_1y_1\right)+\cdots+ \left(\max\left\{x_{n-1},y_{n-1}\right\}+x_{n-1}y_{n-1}\right).\]