stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):


#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<ll,int> Pa;



struct BIT{

  int d[500005];

  int n;

 void init(int _n){

   n = _n;

   memset(d,0,sizeof(d));

 }

  // i?????????x???????????? ???1????????°?????????

  void add(int i, int x){

    while(i <= n){

      d[i] += x;

      i += i & -i;

    }

  }



  // a1??????ai?????§???????¨?????±???????

  int sum(int i){

    int s = 0;

    while(i > 0){

      s += d[i];

      i -= i & -i;

    }

    return s;

  }

};



ll N,P,Q;

BIT bit;

Pa C[500005];

int main(){

  cin >> N >> P >> Q;

  ll sum = 0;

  for(int i=0;i<N;i++){

    ll c; cin >> c; sum+=c;

    C[i] = Pa( (ll)(Q-i)*P - c , i );

  }

  sort( C, C + N );

  bit.init(N);

  ll res = sum;

  for(int i=N-1;i>-1;i--){

    ll p = N-1-i;

    // cout << C[i].second << endl;

    //cout << sum << " " << C[i].first << " " << p << " = " << sum + C[i].first + 2LL*p*P << endl;

    res = max( res, sum + C[i].first + 2LL*p*P );

    sum = sum + C[i].first + 2LL * p * P;

    bit.add( C[i].second+1, 1 );

  }

  cout << res << endl;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<ll,int> Pa;



ll N,P,Q;

Pa C[500005];

int main(){

  cin >> N >> P >> Q;

  ll sum = 0;

  for(int i=0;i<N;i++){

    ll c; cin >> c; sum+=c;

    C[i] = Pa( (ll)(Q-i)*P - c , i );

  }

  sort( C, C + N );

  ll res = sum;

  for(int i=N-1;i>-1;i--){

    ll p = N-1-i;

    res = max( res, sum + C[i].first + 2LL*p*P );

    sum = sum + C[i].first + 2LL * p * P;

  }

  cout << res << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <vector>

#include <iostream>

#include <algorithm>



using namespace std;



int main()

{

	long long N, P, Q; vector<long long> C;



	cin >> N >> P >> Q;



	C = vector<long long>(N);



	long long zenbugaishoku = 0;



	for (int i = 0; i < N; i++)

	{

		cin >> C[i];



		zenbugaishoku += C[i];

	}

	

	vector<long long> A(N);



	for (int i = 0; i < N; i++)

	{

		A[i] = C[i] - (Q - i) * P;

	}



	sort(A.begin(), A.end());



	long long Answer = zenbugaishoku;



	long long sum = zenbugaishoku;



	for (int i = 0; i < N; i++)

	{

		sum -= A[i];



		sum += 2 * i * P;



		Answer = max(sum, Answer);

	}



	cout << Answer << endl;



	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>



using namespace std;



int main()

{

	long long P, Q, C, A[500000];



	int N;



	scanf("%d", &N);



	scanf("%lld", &P);

	scanf("%lld", &Q);



	long long zenbugaishoku = 0;



	for (int i = 0; i < N; i++)

	{

		scanf("%lld", &C);



		zenbugaishoku += C;



		A[i] = C - (Q - i) * P;

	}



	sort(A, A + N);



	long long Answer = zenbugaishoku;



	long long sum = zenbugaishoku;



	for (int i = 0; i < N; i++)

	{

		sum -= A[i];



		sum += 2 * i * P;



		Answer = max(sum, Answer);

	}



	printf("%lld\n", Answer);



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <vector>

#include <iostream>

#include <algorithm>



using namespace std;



int main()

{

	long long N, P, Q; vector<long long> C;



	scanf("%lld", &N);

	scanf("%lld", &P);

	scanf("%lld", &Q);



	C = vector<long long>(N);



	long long zenbugaishoku = 0;



	for (int i = 0; i < N; i++)

	{

		scanf("%lld", &C[i]);



		zenbugaishoku += C[i];

	}

	

	vector<long long> A(N);



	for (int i = 0; i < N; i++)

	{

		A[i] = C[i] - (Q - i) * P;

	}



	sort(A.begin(), A.end());



	long long Answer = zenbugaishoku;



	long long sum = zenbugaishoku;



	for (int i = 0; i < N; i++)

	{

		sum -= A[i];



		sum += 2 * i * P;



		Answer = max(sum, Answer);

	}



	printf("%lld\n", Answer);



	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>

#include <algorithm>



using namespace std;



int main()

{

	long long P, Q, C, A[500000];



	int N;



	scanf("%d", &N);



	scanf("%lld", &P);

	scanf("%lld", &Q);



	long long zenbugaishoku = 0;



	for (int i = 0; i < N; i++)

	{

		scanf("%lld", &C);



		zenbugaishoku += C;



		A[i] = C - (Q - i) * P;

	}



	sort(A, A + N);



	long long Answer = zenbugaishoku;



	long long sum = zenbugaishoku;



	for (int i = 0; i < N; i++)

	{

		sum -= A[i];



		sum += 2 * i * P;



		Answer = max(sum, Answer);

	}



	printf("%lld\n", Answer);



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define f first

#define s second

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;

typedef pair<ll,P> PP;

const int MAX_N = 1<<19;

 

/*    BIT  sum:O(logN)   add:O(logN)  */

 

//[1,n]

class BIT{

public:

  int bit[MAX_N+1],n;

  BIT(){memset(bit,0,sizeof(bit));}

  BIT(int n){this->n=n,memset(bit,0,sizeof(bit));}

 

  int sum(int i){

    int s=0;

    while(i>0){

      s+=bit[i];

      i-=i&-i;

    }

    return s;

  }

   

  void add(int i,int x){

    while(i<=n){

      bit[i]+=x;

      i+=i&-i;

    }

  }

};

 

 

ll n,p,Q;

PP C[MAX_N];

 

int main(){

  cin>>n>>p>>Q;

  BIT B(n);

 

  for(int i=0;i<n;i++){

    cin>>C[i].s.f;

    C[i].s.s=i+1;

    C[i].f=-(n-i-1)*p+C[i].s.f;

  }

  sort(C,C+n,greater<PP>());

 

  ll sum=n*(2*Q*p+(n-1)*p)/2,ans=sum;

  for(int i=0;i<n;i++){

    ll idx=C[i].s.s,cost=C[i].s.f;

    ll l=B.sum(idx),r=i-l;

    sum+=-(Q+(idx-1)-l*2)*p-(n-idx-r)*p*2+cost;

    B.add(idx,1);

    ans=max(ans,sum);

  }

  cout<<ans<<endl;

   

  return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

ll n,p,Q;



ll calc(ll a,ll l,ll n){return (a+l)*n/2;}



int main(){

  cin>>n>>p>>Q;

  vector<ll> V;

  

  for(int i=0;i<n;i++){

    ll C;

    cin>>C;

    V.push_back(C-p*(Q+i)-2*p*(n-i-1));

  }



  sort(V.begin(),V.end(),greater<ll>());

  ll sum = p*calc(Q,Q+n-1,n);

  ll ans = sum;

  for(int i=0;i<n;i++){

    sum += V[i]+ 2*p*i ;

    ans =max(ans,sum);

  }

  cout<<ans<<endl;

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main(){

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);



    long long a, b, c, d, x, y;

    cin >> a >> b >> c >> d;

    long long ara[5];

    ara[0] = a*c, ara[1] = a*d, ara[2] = b*c, ara[3] = b*d;

    long long maxi = ara[0];

    for(int i=0; i<4 ; i++){

        if(maxi < ara[i]) maxi = ara[i];

    }

    cout << maxi << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

typedef long long LL;





int main()

{	 

	int i;

	LL a, b, c, d, x[4], ans;

		

	scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

	x[0] = a * c, x[1] = a * d;

	x[2] = b * c, x[3] = b * d;

	for(ans = x[0], i = 1; i < 4; i++){

		if(x[i] > ans) ans = x[i];

	}

	printf("%lld\n", ans);

		

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

#include <algorithm>

#include <queue>

#include <cstring>

#include <cstdio>

#include <set>

#include <map>



const int MAXN = 2e5 + 10;

typedef long long ll;



using namespace std;



int main()

{

	ll a, b, c, d, x, y;

	cin >> a >> b >> c >> d;

	ll maxn = a*c;

	maxn = max(maxn, a*d);

	maxn = max(maxn, b*c);

	maxn = max(maxn, b*d);

	cout << maxn <<endl;

	return 0;

} 

// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <iostream>

#include<algorithm>

using namespace std;



int main() {

	long long int a,b,c,d,z[4]={0};

	cin>>a>>b>>c>>d;

	z[0]=a*c;

	z[1]=a*d;

	z[2]=b*c;

	z[3]=b*d;

	long long int sum=-1000000000000000000;

	for(int i=0;i<4;i++){

		if(z[i]>sum){

			sum=z[i];

		}

	}

	cout<<sum;

	return 0;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

long long a[10];

int main(){

	for(int i = 1;i <= 4;i++)

		cin >> a[i];

	long long res;

	res = a[1]*a[3];

	for(int i = 1;i <= 2;i++){

		for(int j = 3;j <= 4;j++){

			res = max(res,a[i]*a[j]);

		}

	}

	cout << res;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

#include<cstring>

typedef long long ll;

using namespace std;

int main()

{

	ll a[3],b[3],s[10];

	for(int i=0;i<2;i++) cin>>a[i];

	for(int i=0;i<2;i++) cin>>b[i];

	int t=0;

	for(int i=0;i<2;i++)

	{

		for(int j=0;j<2;j++)

		{

			ll sum=a[i]*b[j];

			s[t++]=sum;

		}

	}

	sort(s,s+t);

	printf("%lld\n",s[t-1]);

} 

// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main() {

    long long a,b,c,d;

    cin>>a>>b>>c>>d;

    long long ans;

    ans=max(a*c, a*d);

    ans=max(ans, b*c);

    ans=max(ans, b*d);

    cout<<ans<<"\n";

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define mod 1000000007

int main()

{

ll a,b,c,d,e,f,g,h,t,tt,ans;

cin>>a>>b>>c>>d;

e=a*c;

f=a*d;

g=b*c;

h=b*d;

t=max(e,f);

tt=max(g,h);

ans=max(t,tt);

cout<<ans<<endl;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

int main()

{

    long long int a,b,c,d;

    cin >> a >> b >> c >> d;

    long long int i,j,k,l;

    i = a*c;

    j = b*c;

    k = a*d;

    l = b*d;

    cout << max(i,max(j,max(k,l))) << endl;

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/*

   * * * * *       *        * * * * * * * * * * * * * * * * * * * * * * * *     * * * * * * *               * *               * * * * * * * * * *

   * * * * *      * *       * * * * * * * * * * * * * * * * * * * * * *    *    * * * * * * *              * * *             * ** * * * * * * * * *

   * *           * * *            * *     * *     * *      * *          * * *   * * *       *             * * * *           * * * *       * *    * *

   * * * * *    * * * *           * *     * *     * *       * * * * * * *  * *  * * * * * * *            * * * * *         * *  * *       * * * * *

   * * * * *   * * * * *          * *     * *     * *        * * * * ** *   * * * * * * * * *           * * * * * *       * *   * * * *   * * * *

         * *  * * * * * *   * *   * *     * *     * *       * * * * * * *    * ** *     * * *          * * * * * * *     * *    * * * *   * *  * *

         * * * *       * *  * *   * *     * *     * *      * *          *     * * *     * * *         * *       * * *   * *     * *       * *   * *

   * * * * ** *         * * * * * * * * * * * * * * * * * * * * * * * * *      *  * * * * * * * * * ** *         * * * * *      * * * * * * *    * *

   * * * * * *           * ** * * * * * * * * * * * * * * * * * * * * * *       * * * * * * * * * * * *           * * * *       * * * * * * *     * *

*/

 

#include <iostream>

#include <algorithm>

#include <string>

#include <vector>

#include <cstdio>

#include <cmath>

#include <cstring>

#include <cstdlib>

#include <set>

#define ll long long

#define rep(i, a, b) for (int i = int(a); i <= int(b); i++)

#define sz(a) int((a).size())

#define shit while(t--)

#define fr for(int i=0;i<n;i++)

int maxo=1e9+7;

using namespace std;

int arr[95];

int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    ll a,b,c,d,ans=-1000000000000000000;

    cin>>a>>b>>c>>d;

 

    ans=max(ans,a*c);

    ans=max(ans,a*d);

    ans=max(ans,c*b);

    ans=max(ans,d*b);

 

    cout<<ans<<endl;

 

    return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int main()

{

	long long int n,i,j,a,b,c,d,ara[4];

	cin>>a>>b>>c>>d;

	ara[0]=a*c;

	ara[1]=a*d;

	ara[2]=b*c;

	ara[3]=b*d;

	sort(ara,ara+4);

	cout<<ara[3]<<'\n';

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<algorithm>

using namespace std;

typedef long long ll;

int main(){

	ll a,b,c,d;

    cin>>a>>b>>c>>d;

    ll maxx=0;

    ll a1=a*c;

    ll b1=a*d;

    ll c1=b*c;

    ll d1=b*d;

    cout<<max(max(a1,b1),max(c1,d1))<<endl;



	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/**

 * author  : UshanGhosh

 * created : 2020-09-19 17:13:12

**/ 



#include<bits/stdc++.h>

using namespace std;



#define    ll      long long

#define    pii     pair<int,int>

#define    vii     vector<int>

#define    vcc     vector<char>

#define    pll     pair<long long, long long>

#define    mem     memset

#define    sof     sizeof

#define    co1     __builtin_popcountll

#define    PB      push_back

#define    UB      upper_bound

#define    LB      lower_bound

#define    MP      make_pair

#define    TS      to_string

#define    F       first

#define    S       second

#define    pi      acos(-1)

#define    mod     (int)1e9+7

#define    inf     (long long)1e18

#define    endl    '\n'



int main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;

    cin>>a>>b>>c>>d;

    ll ans = max(a*c,max(a*d,max(b*c,b*d)));

    cout<<ans<<"\n";

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>



using namespace std;



#define ios         ios_base::sync_with_stdio(false);

#define ll          long long

#define ld          long double

#define db(x)       cout << "[" << #x << ": " << (x) << "]\n"

#define db2(x,y)    cout << "[" << #x << ": " << (x) << "]  [" << #y << ": " << (y) << "]\n"

#define db3(x,y,z)  cout << "[" << #x << ": " << (x) << "]  [" << #y << ": " << (y) << "]  [" << #z << ": " << (z) << "]\n"

#define cn          23

#define sn          1007

#define bn          200007

#define M           100000007

#define inf         LLONG_MAX





int main()

{

        ios;

        ll a,b,c,d; cin >> a >> b >> c >> d;

        ll ac = a*c, ad = a*d, bc = b*c, bd = b*d;

        cout << max(max(max(ac,ad),bc),bd);

}


// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

using namespace std;



int main()

{

	long long a,b,c,d;

	cin>>a>>b>>c>>d;

	long long sum1,sum2,sum3,sum4,sum;

	sum1=a*c;

	sum2=a*d;

	sum3=b*c;

	sum4=b*d;

	sum=max(max(sum1,sum2),max(sum3,sum4));

	cout<<sum<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define mod 1000000007

int main()

{

ll a,b,c,d,e,f,g,h,t,tt,ans;

cin>>a>>b>>c>>d;

e=a*c;

f=a*d;

g=b*c;

h=b*d;

ans=max(max(e,f),max(g,h));

cout<<ans<<endl;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>



long long int max(long long int a, long long int b, long long int c, long long int d)

{

	if(a > b && a > c && a > d) return a;

	else if(b > a && b > c && b > d) return b;

	else if(c > b && c > a && c > d) return c;

	else return d;

}



int main()

{

	long long int a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	printf("%lld\n", max(a*c, a*d, b*c, b*d));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
//Mahir Ratanpara (DA-IICT)

#include<bits/stdc++.h>

using namespace std;

#define Ff(i,a,n) for(i=a;i<n;i++)

#define Fr(i,a,n) for(i=a;i>n;i--)

#define ll long long

#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define pb push_back

#define ff first

#define ss second

#define all(x) x.begin(), x.end()

#define clr(x) memset(x, 0, sizeof(x))

#define sortall(x) sort(all(x))

#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)

typedef pair<ll, ll>	pa;

typedef vector<ll>		vc;

typedef vector<pa>		vp;

typedef vector<vc>		vvc;

int mpow(int base, int exp); 

void ipgraph(ll n,ll m);

void dfs(int u, int par);

const int mod = 1000000007;

const int N = 3e5, M = N;

//=======================



vc g[N];



int main() {

    FAST;

    ll t, i, l,j, k, p, q, r, x, y, u, v, n, m;

    n=4;

    vc a(n);

    Ff(i,0,n)

    cin>>a[i];



    ll maxi=-1e18;

    Ff(i,0,2)

    {

      Ff(j,2,n)

      {

        maxi=max(maxi,a[i]*a[j]);

      }

    }

    cout<<maxi<<"\n";

    return 0;

}



int mpow(int base, int exp) {

  base %= mod;

  int result = 1;

  while (exp > 0) {

    if (exp & 1) result = ((ll)result * base) % mod;

    base = ((ll)base * base) % mod;

    exp >>= 1;

  }

  return result;

}



void ipgraph(ll n, ll m){

	int i, u, v;

	while(m--){

		cin>>u>>v;

		g[u-1].pb(v-1);

		g[v-1].pb(u-1);

	}

}



void dfs(int u, int par){

	for(int v:g[u]){

		if (v == par) continue;

		dfs(v, u);

	}

}

// Optimized solution to the same problem (faster):
#include "bits/stdc++.h"

using namespace std;

#define ll long long int

#define MUL(A,B,C)	(max(A*C, B*C))

int main(){

	ll a[4];

	for(int i=0; i<4; i++)  scanf("%lld", &a[i]);

	printf("%lld\n", max(MUL(a[0],a[1],a[2]), MUL(a[0],a[1],a[3])));

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define endl "\n"



vector<ll> adj[100005];

ll vis[100005];

ll n, m;



void add(ll x, ll y) {

  adj[x].push_back(y);

  adj[y].push_back(x);

}



void solve() {

  ll a, b, c, d;

  cin >> a >> b >> c >> d;

  ll ans1 = max(a, b) * min(c, d);

  ll ans2 = min(a, b) * max(c, d);

  ll ans3 = max(a, b) * max(c, d);

  ll ans4 = min(a, b) * min(c, d);

  ll ans5 = max(max(ans1, ans2), max(ans3, ans4));

  cout << ans5 << endl;

}



int main() {

  ll t;

  // cin >> t;

  t = 1;

  while (t--)

    solve();

  return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



#define ll long long

#define endl "\n"



int main() {

  ll a, b, c, d;

  cin >> a >> b >> c >> d;

  ll ans1 = a * c;

  ll ans2 = a * d;

  ll ans3 = b * c;

  ll ans4 = b * d;

  cout << max(max(ans1, ans2), max(ans3, ans4)) << endl;

  return 0;

}

// Fastest known solution for this problem: