Applied Mathematics
Time limit: 1 s.
Memory limit: 256 MB
A renowned mathematician believes that the entirety of mathematics boils down to a single problem: \(X \text{ ? } Y \text{ ? } Z\). He has spent countless hours obsessing over it, stressing day and night, and still hasn’t found a solution.

The variables \(X, Y, Z\) are known integers. The two operations between them are missing. Each \(\text{?}\) can be replaced by either a plus (\(+\)) or a multiplication (\(\times\)) sign.
Your task is to choose the operations to maximize the value of the expression.
Input
The input consists of \(3\) integers \(X\), \(Y\) and \(Z\). \((-10^6 \le X, Y, Z \le 10^6)\)
Output
Your output must be a single integer, the maximum possible value of the expression if the operations are selected optimally.
Scoring
In this problem, each test case will be scored separately. Your score is the sum of scores for all test cases.
Example
Input
1 2 3
Output
7
Note
In the sample testcase the value of the expression is maximized in the following assignment:
\[1 \mathbin{\color{red}{+}} 2 \mathbin{\color{red}{\times}} 3 = 7\]
Solution
There are only four possible choices for the two operators. Evaluate all of them and print the maximum. Use long long, because the product can be as large as \(10^{18}\).
The complexity is \(O(1)\).
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
long long x, y, z;
cin >> x >> y >> z;
cout << max( {
x + y + z,
x + y * z,
x * y + z,
x * y * z
}) << '\n';
}