Problem:
Score : 200 points

Problem Statement

Given are integers a,b,c and d.
If x and y are integers and a \leq x \leq b and c\leq y \leq d hold, what is the maximum possible value of x \times y?

Constraints

-10^9 \leq a \leq b \leq 10^9

-10^9 \leq c \leq d \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

a b c d

Output

Print the answer.

Sample Input 1

1 2 1 1

Sample Output 1

2

If x = 1 and y = 1 then x \times y = 1.
If x = 2 and y = 1 then x \times y = 2.
Therefore, the answer is 2.

Sample Input 2

3 5 -4 -2

Sample Output 2

-6

The answer can be negative.

Sample Input 3

-1000000000 0 -1000000000 0

Sample Output 3

1000000000000000000

Solution in C++ (GCC 9.2.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define yes cout << "YES" \
                 << "\n"
#define no cout << "NO" \
                << "\n"
#define MOD 1000000007
using namespace std;
const double pi = 3.14159265358979323846;
const int MAX_CHARS = 256;

template <typename T>
T Maxnun(T x, T y)
{
    return (x > y) ? x : y;
}
long long fast_power(long long base, long long power)
{
    long long result = 1;
    while (power > 0)
    {

        if (power % 2 == 1)
        { // Can also use (power & 1) to make code even faster
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power / 2; // Can also use power >>= 1; to make code even faster
    }
    return result;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
template <typename T, typename X>
void pairsort(T a[], T b[], T n)
{
    pair<T, X> a_p[n];
    for (T i = 0; i < n; i++)
    {
        a_p[i].first = a[i];
        a_p[i].second = b[i];
    }
    sort(a_p, a_p + n);
    for (T i = 0; i < n; i++)
    {
        b[i] = a_p[i].second;
    }
}
ll power(ll x, ll y)
{
    ll res = 1; // Initialize result

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = res * x;

        // y must be even now
        y = y >> 1; // y = y/2
        x = x * x;  // Change x to x^2
    }
    return res;
}
ll kthRoot(ll n, ll k)
{
    return pow(k,
               (1.0 / k) * (log(n) / log(k)));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << std::max(std::max(b * d, b * c), std::max(a * c, a * d));
}