akhauriyash/Code-Regression huggingface dataset:
import Control.Applicative
import Control.Monad
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Text.Printf
import Debug.Trace

solve x = sub x 1
  where
    sub x i
      | x <= i = i
      | otherwise = sub (x-i) (i+1)

main = do
  [x] <- getInts
  print $ solve x


-- util
getInts :: IO [Integer]
getInts = map (fst . fromJust . B.readInteger) . B.words <$> B.getLine



Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0; i<(int)(n); i++)
typedef long long ll;

ll f(ll b, ll n){
    if(n < b) return n;
    return f(b, n/b) + (n % b);
}

ll solve(ll n, ll s){
    ll res = -1;
    if(n < s) return -1;
    if(n == s) return n+1;
    for(ll b=2; b*b<=n; b++) if(f(b, n) == s) return b;
    for(ll p=1; p*p<=n && p<=s; p++){
        if((n - s)%p != 0) continue;
        ll b = (n - s)/p + 1;
        if(f(b, n) == s) res = b;
    }
    return res;
}

int main(){
    ll n, s;
    scanf("%lld %lld", &n, &s);

    printf("%lld\n", solve(n, s));
    return 0;
}


Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          fozubaoyou    no BUGs alive
*/
#include <bits/stdc++.h>
using namespace std;

int main(){
    int a, b; cin >> a >> b;
    cout << a/b << " " << a%b << " " << fixed << setprecision(5) << (double)a/b << endl;
}

Measured memory_bytes: 3268
#include <iostream>
using namespace std;

int h, w;

int main()
{
    while (cin >> h >> w)
    {
        if (h == 0 && w == 0)
            return 0;
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
                    cout << "#";
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3104
double*q,s[99],*p=s+2,v,atof();short t[9];main(c){for(;~scanf("%s%c",t,&c);c&2&&printf("%f\n",*--p))v=*--p,q=p-1,*q=*t>47?p++,*p++=atof(t),*q:*t&1?*t&2?*t&4?*q/v:*q+v:*q-v:*q*v;}  

Measured memory_bytes: 0
<?php
  $s = explode(" ", trim(fgets(STDIN)));
for($i=0; $i<$s[0]; $i++){
    $arr[] = explode(" ", trim(fgets(STDIN)));
}
 
for($i=0; $i<$s[0]; $i++){
    if($arr[$i][1] <= $s[1]){
        $check[] = $arr[$i][0];
    }
}
if(!isset($check)){
    echo "TLE";
}else{
    echo min($check);
}
?>

Measured memory_bytes: 4728
n=int(input())
s=list(input())
t=list(reversed(s))
#print(s,t)

S,T=[],[]
x,y=0,0
for i in range(n):
    if s[i]=='W':
        x+=1
        S.append(x)
    else:
        S.append(x)
    
    if t[i]=='E':
        y+=1
        T.append(y)
    else:
        T.append(y)

S=[0]+S
T=[0]+T

T.reverse()
#print(S,T)

z=3*(10**5)
for j in range(n):
    z=min(z,S[j]+T[j+1])
    #print(S[j],T[j+1])

print(z)


    






Measured memory_bytes: 24944
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
void stb(int n){
	int y;
	if(n == 0)return ;
	if(n<0){
		y=-(n%-2);
		if(y==1)
			stb((n/-2)+1);
		else
			stb((n/-2));
		printf("%d",y);
	}
	else{
		y=n%-2;
		stb(n/-2);
		printf("%d",y);
	}
}
int main(){
	int m;
	cin>>m;
	stb(m);
	if(m==0)
	printf("%d",0);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;

int main(){
	int p=2000,j=2000,n;
	for(int i=0;i<3;i++){
		scanf("%d",&n);
		if(n<p)p=n;
	}
	for(int i=0;i<2;i++){
		scanf("%d",&n);
		if(n<j)j=n;
	}
	printf("%d\n",p+j-50);
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>

using namespace std;

const string S4[4] = {"abcc", "abdd", "ccab", "ddab"};
const string S5[5] = {"abbcc", "ad..a", "bd..a", "b.eez", "oorrz"};
const string S6[6] = {"oorrzz", ".a.b.c", ".a.b.c", "d.e.f.", "d.e.f.", "oorrzz"};
const string S7[7] = {".oorrzz", "oabb...", "oa.c...", "rddc...", "r...abb", "z...a.c", "z...ddc"};

char s[1010][1010];

inline void solve(int&n, int x) {
	if(x == 4)
		for(int i = 0; i < x; i++) for(int j = 0; j < x; j++)
				s[n + i][n + j] = S4[i][j];
	if(x == 5)
		for(int i = 0; i < x; i++) for(int j = 0; j < x; j++)
				s[n + i][n + j] = S5[i][j];
	if(x == 6)
		for(int i = 0; i < x; i++) for(int j = 0; j < x; j++)
				s[n + i][n + j] = S6[i][j];
	if(x == 7)
		for(int i = 0; i < x; i++) for(int j = 0; j < x; j++)
				s[n + i][n + j] = S7[i][j];
	n += x;
}

int main() {
	int n; cin >> n;
	if(n <= 2) return puts("-1"), 0;
	if(n == 3) {
		puts("a.."); puts("a.."); puts(".bb");
		return 0;
	}
	for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++)
			s[i][j] = '.';
	int x = n % 4, N = 1;
	if(x == 0) solve(N, 4);
	if(x == 1) solve(N, 5);
	if(x == 2) solve(N, 6);
	if(x == 3) solve(N, 7);
	while(N <= n) solve(N, 4);
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++)
			putchar(s[i][j]);
		puts("");
	}
	return 0;
}



Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000009
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define flash  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc(t,T) for(long long t=0;t<T;t++)
#define rep(i,s,n,d) for(long long i=s;i<n;i=i+d)

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}
/*bool cxp pair<ll, pll> &a,
              const pair<ll, pll> &b)
{
    return (a.ff < b.ff);
}*/

void func(void)
{
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    else return gcd(b,a%b);
}
void printStack(stack<string> s){
    if(s.empty())return;

    string x=s.top();
    s.pop();
    printStack(s);
    cout<<x;
    s.push(x);

}


ll binaryexp(ll n,ll p){

    if(p==0) return 1;
    if(p%2==0) return binaryexp((n%mod)*(n%mod),p/2);
    else return ((n%mod)*binaryexp(((n%mod)*(n%mod))%mod,(p-1)/2)%mod);

}

#define meax 10000001
vll spf(meax,0);
void siv(){
    spf[1]=1;

   for(ll i=2;i<meax;i++)spf[i]=i;

   for(ll i=4;i<meax;i+=2){
        spf[i]=2;
    }
    for(ll i=3;i*i<meax;i++){
        if(spf[i]==i){
            for(ll j=i*i;j<meax;j+=i){
                if(spf[j]==j){
                    spf[j]=i;
                }
            }
        }
    }
}

int main(){
    ll n;
    cin>>n;
    vll a(n,0);
    rep(i,0,n,1)cin>>a[i];
    sort(a.begin(),a.end(),greater<ll>());
    ll sum=a[0];
    for(int i=1;i<=(n-1)/2;i++){

        if(n%2==1 && i==(n-1)/2)
        sum=sum+1*a[i];
        else if (n%2==0 && i==(n-1)/2)
              sum=sum+2*a[i];
        else{
             sum=sum+2*a[i];
        }
    }

    cout<<sum<<endl;

}


Measured memory_bytes: 82996
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;cin>>n;string s[n];for(int i=0;i<n;i++)cin>>s[i];
  cin>>m;string t[m];for(int i=0;i<m;i++)cin>>t[i];
  int ans=0;
  for(int i=0;i<n;i++){
    int cnt=0;
    for(int j=0;j<n;j++){
      if(s[i]==s[j])cnt++;
    }
    for(int j=0;j<m;j++){
      if(s[i]==t[j])cnt--;
    }
    ans=max(cnt,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    string s;
    cin >> s;
    deque<char> dq;
    for(int i = 0; i < s.size(); i++){
        dq.push_back(s[i]);
    }
    int q, r = 0;
    cin >> q;
    for(int i = 0; i < q; i++){
        int a;
        cin >> a;
        if(a == 1){
            r ^= 1;
        }else{
            int b;
            char c;
            cin >> b >> c;
            if(r == 1){
                b = 3 - b;
            }
            if(b == 1){
                dq.push_front(c);
            }else{
                dq.push_back(c);
            }
        }
    }
    if(r == 0){
        cout << dq.front();
        dq.pop_front();
        while(!dq.empty()){
            cout << dq.front();
            dq.pop_front();
        }
        cout << endl;
    }else{
        cout << dq.back();
        dq.pop_back();
        while(!dq.empty()){
            cout << dq.back();
            dq.pop_back();
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;
using namespace std;

int main() {
	string S,T;
	cin >> S >> T;
	bool YorN = false;
	REP(i,S.size()) {
		int count = 0;

		REP(j,S.size()) {
			if (S.at(j) == T.at((T.size()+j+i) % T.size()))
				count++;
			else
				break;
 		}

 		if (count == S.size())
		YorN = true;
	}

	if (YorN)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

double x[10], y[10];

int city[10];
bool visited[10];

double city_length(int i, int j) {
	return sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
}

double calc_length(int N) {
	double length = 0;
	for (int i = 0; i < N - 1; ++i) {
		length += city_length(city[i], city[i + 1]);
	}
	return length;
}

double rec(int i, int N) {
	if (i == N) {
		return calc_length(N);
	}
	double sum = 0;
	for (int j = 0; j < N; ++j) if (!visited[j]) {
		visited[j] = true;
		city[i] = j;
		sum += rec(i + 1, N);
		visited[j] = false;
	}
	return sum;
}

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];

	double div = 1;
	for (int i = 1; i <= N; ++i) div *= i;
	cout << setprecision(10) << rec(0, N) / div << endl;
	return 0;
}

Measured memory_bytes: 3772
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
using namespace std;

int main() {
    int n;
    for (int cs=1; cin>>n, n; ++cs) {
        vector<vector<int> > v(n, vector<int>(n, 0));
        int x, y, k = 1;
        for (int i=0; i<=2*(n-1); ++i) {
            if (i % 2 == 0) {
                x = max(0, i-n+1);
                y = min(n-1, i);
                while (x < n && 0 <= y) {
                    v[y][x] = k++;
                    x ++; y --;
                }
            } else {
                x = min(i, n-1);
                y = max(0, i-n+1);
                while (0 <= x && y < n) {
                    v[y][x] = k++;
                    x --; y ++;
                }
            }
        }
        cout << "Case " << cs << ":" << endl;
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                cout << setw(3) << v[i][j];
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1232
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
int main() {
	int N, K, d = 1 << 30;
	scanf("%d%d", &N, &K);
	vector<int> H(N);
	rep(i, 0, N)scanf("%d", &H[i]);
	sort(all(H));
	rep(i, 0, N - K + 1)d = min(H[i + K - 1] - H[i], d);
	printf("%d\n", d);
	return 0;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

MAX = 3234566667
ans = []
def rec(x):
    if int(x) > MAX:
        return
    ans.append(int(x))
    last = int(x[-1])
    rec(x+str(last))
    if last != 0:
        rec(x+str(last-1))
    if last != 9:
        rec(x+str(last+1))
    return

K = INT()

for i in range(1, 10):
    rec(str(i))

ans.sort()
print(ans[K-1])


Measured memory_bytes: 7488
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if (a * b % 2 == 1){
    cout << "Odd" << endl;
  }else if (a * b % 2 == 0){
    cout << "Even" << endl;
  }  
}

Measured memory_bytes: 3532
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N,K;
    cin >> N >> K;

    vector<int> num(100010);
    int pla1=0;
    for(int i=0;i<N;i++){
        cin >> num[i];
        if(num[i]==1) pla1=i;
    }
    int sum=pla1/(K-1)+(N-pla1-1)/(K-1);

    if(pla1%(K-1)==0 && (N-pla1-1)%(K-1)==0);
    else if(pla1%(K-1)+(N-pla1-1)%(K-1)<=K-1) sum++;
    else sum+=2;
    
    
    cout << sum << endl;

}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n, m; cin >> n >> m;
    vector<pair<int64_t, int64_t>> students(n);
    vector<pair<int64_t, int64_t>> check_points(m);
    rep(i, n) {
        int64_t a, b; cin >> a >> b;
        students[i] = {a, b};
    }
    rep(i, m) {
        int64_t c, d; cin >> c >> d;
        check_points[i] = {c, d};
    }

    for (const auto &student: students) {
        int64_t mini = 1LL << 60;
        int ans = 0;
        rep(i, m) {
            auto point = check_points[i];
            auto dist = abs(student.first - point.first)
                + abs(student.second - point.second);
            if (dist < mini) {
                mini = dist;
                ans = i + 1;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
  }
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;


struct IntegralImage{
  VVLL I; 
  LL H;
  LL W;
  IntegralImage(VVLL M){
    I = M;
    H = M.size();
    W = M[0].size();
    // check
    bool isOK=true;
    REP(i,H){
      if(I[i].size()!=W){
        isOK=false;
      }
    }
    if(not isOK){
      cerr << "shape error :";
      REP(i,H){
        cerr << I[i].size() << " ";
      }
      cerr << endl;
      throw 0;
    }

    REP(i,H){
      REP(j,W-1){
        I[i][j+1] += I[i][j];
      }
    }
    REP(j,W){
      REP(i,H-1){
        I[i+1][j] += I[i][j];
      }
    }
  }
  LL get_sum( LL y, LL h, LL x, LL w){
    if(y<0 or x<0 or h<0 or w<0 or y+h>=H or x+w>=W){
      fprintf(stderr,"H=%lld, W=%lld, y=%lld, h=%lld, x=%lld, w=%lld\n",H,W,y,h,x,w);
      throw 1;
    }
    LL a1 = I[y+h][x+w];
    LL a2 = 0;
    if(y>0){
      a2 = I[y-1][x+w];
    }            
    LL a3 = 0;
    if(x>0){
      a3 = I[y+h][x-1];
    }            
    LL a4 = 0;
    if(y>0 && x>0){
      a4 = I[y-1][x-1];
    }
    return (a1 + a4 - a2 -a3);
  }

  void print( ){
    REP(i,I.size()){
      PRINTSP(I[i]);
    }  
  }
};


void func(){
  LL N;
  cin >> N;
  LL M;
  cin >> M;
  LL Q;
  cin >> Q;

  VVLL A(N,VLL(N,0));
  REP(i,M){
    LL l,r;
    cin >> l;
    cin >> r;
    l--;
    r--;
    A[l][r]++;
  }
  REP(i,N){
    //PRINTSP(A[i]);
  }
  IntegralImage II(A);
  //II.print();
  REP(j,Q){
    LL p,q;
    cin >>p;
    cin >>q;
    p--;
    q--;
    cout << II.get_sum(p,q-p,p,q-p) << endl;
  }




  //IntegralImage II();  
  


} 

int main()
{
  func();
  return 0;
}
 

Measured memory_bytes: 6912
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	T res(1);
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while(b){
		if(b&1){
			res*=a;res%=m;
		}
		a*=a;a%=m;
		b>>=1;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()){
		std::cout << vec[i];
		std::cout<<(i==(int)vec.size()-1?"\n":" ");
	}
}
template<typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
LP extGcd(lint a,lint b) {
	if(b==0)return {1,0};
	LP s=extGcd(b,a%b);
	std::swap(s.first,s.second);
	s.second-=a/b*s.first;
	return s;
}
LP ChineseRem(const lint& b1,const lint& m1,const lint& b2,const lint& m2) {
	lint p=extGcd(m1,m2).first;
	lint tmp=(b2-b1)*p%m2;
	lint r=(b1+m1*tmp+m1*m2)%(m1*m2);
	return std::make_pair(r,m1*m2);
}
template<typename F>
inline constexpr decltype(auto) lambda_fix(F&& f){
	return [f=std::forward<F>(f)](auto&&... args){
		return f(f,std::forward<decltype(args)>(args)...);
	};
}
#line 2 "main.cpp"
int n,h[100010],dp[100010];
int main() {
	std::cin>>n;
	rep(i,n)std::cin>>h[i];
	std::fill(dp,dp+n,INF);
	dp[0]=0;
	rep(i,n){
		if(i+1<n)chmin(dp[i+1],dp[i]+std::abs(h[i]-h[i+1]));
		if(i+2<n)chmin(dp[i+2],dp[i]+std::abs(h[i]-h[i+2]));
	}
	std::cout<<dp[n-1]<<std::endl;
	return 0;
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

mint f(int n){
    if(n==0) return 1;
    mint x = f(n/2);
    x *= x;
    if(n%2==1) x*=2;
    return x;
}

mint choose(int n,int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x / y;
}

int main(){
    cout << fixed << setprecision(10);
    ll n,a,b;
    cin >> n >> a >> b;
    mint ans = f(n);
    ans -= 1;
    ans -= choose(n,a);
    ans -= choose(n,b);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    double W, H, X, Y;
    cin >> W >> H >> X >> Y;
    cout << fixed << setprecision(10) << W * H / 2 << ' ' << (X == W / 2 && Y == H / 2 ? '1' : '0') << endl;
    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())

snu = [ False for i in range(n)]
count=0

for _ in range(k):
  d = int(input())
  snukes = [ int(x) for x in input().split()]
  for elem in snukes:
    if(not snu[elem-1]):
      snu[elem-1]=True
      count+=1
      
print(n-count)

Measured memory_bytes: 67568
N = int(input())
s = list(input())

ansj = "NO"
L = [["W", "W"], ["W", "S"], ["S", "W"], ["S", "S"]]
for i in range(4):
	t = ""
	x = L[i][0]
	y = L[i][1]
	t += x + y
	for j in range(2, N):
		judge = 0
		if s[j - 1] == "x":
			judge += 1
		if y == "W":
			judge += 1
		if x == "W":
			judge += 1

		if judge % 2 == 0:
			z = "S"
		else:
			z = "W"
		t += z
		x, y = y, z

	#判定
	ans1 = 0
	if t[0] == "W":
		ans1 += 1
	if s[0] == "x":
		ans1 += 1
	if t[1] != t[-1]:
		ans1 += 1

	ans2 = 0
	if t[-1] == "W":
		ans2 += 1
	if s[-1] == "x":
		ans2 += 1
	if t[-2] != t[0]:
		ans2 += 1

	if ans1 % 2 == 0 and ans2 % 2 == 0:
		print(t)
		ansj = "YES"
		break

if ansj == "NO":
	print(-1)

Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;

int main(){
    int a[101];
    int N;
    cin >> N;
    for(int i = 0; i < N;i++){
        cin >> a[i];
    }
    double b = 0.000000000;
    double ans = 0.000000000;

    for(int i = 0; i < N; i++){
         b += 1.000000000 / a[i];
    }
    ans = 1.00000000000/b;

    cout << ans<< endl;

}

Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))
sx = sorted(x)

min_mid = sx[int(n/2-1)]
max_mid = sx[int(n/2)]

for i in x:
    if i <= min_mid:    # 左半分から取られてる時
        print(max_mid)
    else:               # 右半分から取られてる時
        print(min_mid)


Measured memory_bytes: 25472
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long n, m, ans = 0;
    cin >> n >> m;
    if(m >= n * 2)
    {
        m -= n * 2;
        cout << n + m / 4;
    }
    else
        cout << m / 2 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

const int price[] = { 0, 100, 101, 102, 103, 104, 105 };
int x;
void solve(int i, int rem)
{
	if (i == 0)
	{
		if (rem == 0)
			cout << 1 << endl, exit(0);
		else
			return;
	}
	int max_v = rem / price[i];
	for (int j = 0; j <= max_v; j++)
	{
		int new_max = rem - price[i] * j;
		solve(i - 1, new_max);
	}
}

int main()
{

	cin >> x;
	solve(6, x);
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    long long int i, a, b, c, d;
    long long int e,f,j,z;
    scanf("%lld%lld%lld%lld", &a, &b, &c, &d);

    z=a*c;
    e=a*d;
    f=b*c;
    j=b*d;
    i = z;
   if(i<e)i=e;
   if(i<f)i=f;
   if(i<j)i=j;
   printf("%lld",i);

   return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n,l;
	cin>>n>>l;
	if(l <= 0 && l+n-1 >= 0){
		cout<<l*n+(n-1)*n/2 <<endl;	
	}else if(l+n-1<0){
		cout<<l*n+(n-1)*n/2 - (l+n-1)<<endl;
	}else{
		cout<<l*n+(n-1)*n/2 - l<<endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
    ll X,A,B;
    cin >> X >> A >> B;
    if(B-A <= 0){
      cout << "delicious" << endl;
    }else if(B-A <= X){
      cout << "safe" << endl;
    }else{
      cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n; cin >> n;
    int asum = 0, bsum = 0;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.rbegin(), a.rend());
    for(int i = 0; i < n; i++){
        if(i%2 == 0) asum += a[i];
        else bsum += a[i];
    }
    cout << asum - bsum << endl;    
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1

int main() {
int N, M;
  cin >> N >>M;
  if(N<=M){
  rep(i, M-1)
    cout << N;
    cout << N << endl;
  }
  else{
  rep(i, N-1)
    cout << M;
    cout << M << endl;
  }
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        long N = long.Parse(Console.ReadLine());
        List<int> act = new List<int>();
        N++;
        while(N > 1){
            if(N % 2 == 0){
                act.Add(2);
                N /= 2;
            }
            else{
                act.Add(1);
                N--;
            }
        }
        List<int> left = new List<int>();
        List<int> right = new List<int>();
        int count = 1;
        for(int i=act.Count-1;i>=0;i--){
            if(act[i] == 1){
                left.Add(count);
            }
            else{
                right.Add(count);
            }
            count++;
        }
        sb.Append((count*2-2)+"\n");
        for(int i=0;i<count-1;i++){
            sb.Append((i+1)+" ");
        }
        for(int i=left.Count-1;i>=0;i--){
            sb.Append(left[i]+" ");
        }
        for(int i=0;i<right.Count;i++){
            sb.Append(right[i]+" ");
        }
        sb.Append("\n");
    }
}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long A = inputLongArray[0];
            long B = inputLongArray[1];
            long result = A;
            long cnt = 0;

            if(B == 1)
            {
                Console.WriteLine(0);
                return;
            }
            while(true)
            {
                cnt++;
                if (B <= result)
                {
                    break;
                }
                result += (A - 1);
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

Measured memory_bytes: 13268
import sys

input = sys.stdin.readline

N, C = map(int, input().split())

T = 10 ** 5 + 1
A = [[0] * T for _ in range(C)]
for _ in range(N):
    s, t, c = map(int, input().split())
    A[c - 1][s - 1:t] = [1] * (t - s + 1)

ans = 0
for j in range(1, T):
    cnt = 0
    for i in range(C):
        cnt += A[i][j]
    ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 28532
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e10+10;

/*----------------------------------------------*/
bool c[3][3];
int a[3][3];
signed main(){
  rep(i,3){rep(j,3) cin>>a[i][j];}
  int n;
  cin>>n;
  rep(i,n){
    int b;
    cin>>b;
    rep(j,3){rep(k,3){
      if(b==a[j][k]) c[j][k]=true;
    }}
  }
  bool ok=false;
  rep(i,3){
    if(c[i][0]&&c[i][1]&&c[i][2]) ok=true;
  }
  rep(i,3){
    if(c[0][i]&&c[1][i]&&c[2][i]) ok=true;
  }
  if(c[0][0]&&c[1][1]&&c[2][2]) ok=true;
  if(c[2][0]&&c[1][1]&&c[0][2]) ok=true;
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
int main(void){
    int N,d[100005];
    scanf("%d",&N);
    for(int i=0;i<=N-1;i++){
        scanf("%d",&d[i]);
    }
    
    sort(d,d+N);
    
    if(N%2==0){
        printf("%d",d[N/2]-d[N/2-1]);
    }else{
        printf("0");
    }
}


Measured memory_bytes: 640
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int A[100000];
	rep(i, N) A[i] = getint();

	pakuri_sort(N, A);

	int L1 = 0, L2 = 0;
	int i = N - 1;
	for (; i >= 1; i--) {
		if (A[i - 1] == A[i]) {
			L1 = A[i];
			break;
		}
	}
	i -= 2;
	for (; i >= 1; i--) {
		if (A[i - 1] == A[i]) {
			L2 = A[i];
			break;
		}
	}

	printf("%lld", (ll)L1 * L2);

	Would you please return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
typedef pair<mp,ll> mmp;

int main(){
    while(1){
	ll c,n,m,s,d;
	cin>>c>>n>>m>>s>>d;
	if(c==0)break;
	s--,d--;
	vector<vector<mp> > g(n);
	for(ll i=0;i<m;i++){
		ll a,b,f;
		cin>>a>>b>>f;
		a--;
		b--;
		g[a].push_back(mp(f,b) );
		g[b].push_back(mp(f,a) );
	}
	priority_queue<mmp,vector<mmp>,greater<mmp> > q;
	q.push(mmp(mp(0,0),s) );
	vector<vector<bool> > used(n,vector<bool>(c+1,false) );
	while(!q.empty() ){
		mmp now = q.top();
		q.pop();
		ll ncost = now.first.first;
		ll cc = now.first.second;
		ll nn = now.second;
		//cout<<nn<<' '<<cc<<endl;
		if(nn==d){
		    	//cout<<"ok"<<endl;
			cout<<ncost<<endl;
			break;
		}
		if(used[nn][cc]) continue;
		used[nn][cc] = true;
		for(ll i=0;i<g[nn].size();i++){
			ll next = g[nn][i].second;
			ll nec = g[nn][i].first;
			if(used[next][cc])continue;
			q.push(mmp(mp(ncost+nec,cc),next) );
			if(cc < c){
			    if(used[next][cc+1])continue;
				q.push(mmp(mp(ncost+nec/2,cc+1),next) );
			}
		}
	}


    }
	return 0;
}



Measured memory_bytes: 3212
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
    int n,a[1000][3],i,b[1000],j,w=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
	    for(j=0;j<3;j++){
			scanf("%d",&a[i][j]);
		}
		sort(a[i],a[i]+3);
	}
	for(i=0;i<1000;i++) b[i]=0;
	for(i=0;i<n-1;i++){
	    for(j=i+1;j<n;j++){
		    if(b[i]==0){
			    if(a[i][0]==a[j][0]&&a[i][1]==a[j][1]&&a[i][2]==a[j][2]){
				    w++;
					b[j]=1;
				}
			}
		}
	}
	printf("%d\n",w);
	return 0;
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;cin>>n;
    if(n>=400 && n<=599)
    cout<<8;
    if(n>=600 && n<=799)
    cout<<7;
    if(n>=800 && n<=999)
    cout<<6;
    if(n>=1000 && n<=1199)
    cout<<5;
    if(n>=1200 && n<=1399)
    cout<<4;
    if(n>=1400 && n<=1599)
    cout<<3;
    if(n>=1600 && n<=1799)
    cout<<2;
    if(n>=1800 && n<=1999)
    cout<<1;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
#define endl "\n"
using namespace std;
 
 

 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 

 
ll mul_inv(ll a, ll b) {
    ll b0 = b, t, q;
    ll x0 = 0ll, x1 = 1ll;
    if (b == 1ll) return 1ll;
    while (a > 1ll) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0ll) x1 += b0;
    return x1;
}
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
#define arr2 array<ll,2>
#define arr3 array<ll,3>
#define varr2 vector<array<ll,2> >
#define varr3 vector<array<ll,3> >
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }


const ll maxn=2e5+2;





int main()
{ fastio;
//freopen("input.txt, "r", stdin); 
//freopen("output.txt", "w", stdout);

ll a[2],b[2];
forl(i,0,2)cin>>a[i];
forl(i,0,2)cin>>b[i];
ll ans=-1e18;
forl(i,0,2){
    forl(t,0,2){
        ans=max(ans,a[i]*b[t]);
    }
}
p1(ans);







return 0;
}





  







Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n,m; cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<bitset>
using namespace std;
const int inf = 1001001000;

void dfs(vector<vector<int>> &graph, int v, set<int> &seen){
	seen.insert(v);
	for (int i=0;i<graph[v].size();i++){
		int nxt = graph[v][i];
		if (seen.count(nxt)) continue;
		dfs(graph, nxt, seen);
	}
}

void print(vector<vector<int>> a){
	for (int i=0;i<a.size(); i++){
		if (a[i].size() == 0) continue;
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

int main(){
	while(true){
		int w,h; cin >> w >> h;
		if (w == 0 && h == 0) break;
		vector<vector<int>> map(h+2,vector<int>(w+2,0));
		for (int i=1;i<h+1;i++){
			for (int j=1;j<w+1;j++){
				int c; cin >> c;
				map[i][j] = c;
			}
		}
		vector<vector<int>> graph;
		int r = h+2,c=w+2;
		for (int i = 0; i < r; i++){
			for (int j = 0; j < c;j++){
				vector<int> a;
				if (map[i][j] == 1){	
					for (int k = -1; k < 2; k++){
						for (int l = -1; l < 2; l++){
							if (map[i+k][j+l] == 1) a.push_back((i+k)*c+j+l);
						}
					}
					
				}
				graph.push_back(a);
			}
		}
		set<int> gseen;
		int ans = 0;
		for (int i = 0; i < graph.size(); i++){
			set<int> seen;
			if (graph[i].size() == 0) continue;
			if (gseen.find(i) == gseen.end()){
				dfs(graph,i,seen);
				ans++;
				set_union(seen.begin(),seen.end(),gseen.begin(),gseen.end(),inserter(gseen,gseen.end()));
			}
			
		}
		cout << ans << endl;
	}
	
	return 0;
}




Measured memory_bytes: 3500
n = int(input())
array = list(map(int,input().split()))
count = 0;

for i in range(n-1):
    mini = i
    for j in range(i,n):
        if array[j] < array[mini]:
            mini = j
    if mini != i :
        array[i],array[mini] = array[mini],array[i]
        count += 1

print(" ".join(list(map(str,array))))
print(count)

Measured memory_bytes: 7660
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (long long)x.size()
#define  debug(x)          cout << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  REMOVE(v,a)       v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a

using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;
const ll MOD = 1e9+7;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}


ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}


const int N = 200001;
vi adj[N];



int main(){ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;cin>>n;
	ll a[n];
	rep(i,n){
		cin>>a[i];
		}
	ll ans = 0;
	for(ll i = 0; i<60 ; i++){
		vector<ll>one(n+1,0);
		vector<ll>zero(n+1,0);
		for(ll j = n-1; j>=0 ; j--){
			if(a[j]&(1ULL<<i)){
				one[j] = one[j+1]+1;
				zero[j] = zero[j+1];
				}else{
				one[j]=one[j+1];
				zero[j]=zero[j+1]+1;
					}
					
				
			
			}
			
		ll cnt = 0;
		
		for(ll j = 0 ; j<n-1; j++){
			if(a[j]&(1ULL<<i)){
				cnt+=zero[j+1];
				}else{
				cnt+=one[j+1];
					}
			
			}
		//debug(i)
		//debug(cnt);
		ll x = modpow(2,i,MOD);
		
		ll y = ((cnt%MOD)*(x%MOD))%MOD;
		y = (y+MOD)%MOD;
		
		ans+=y;
		ans=(ans+MOD)%MOD;
		
		}
	cout<<ans;	
	
}


Measured memory_bytes: 14908
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BPopularVote solver = new BPopularVote();
        solver.solve(1, in, out);
        out.close();
    }

    static class BPopularVote {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            int m = ni();
            int[] arr = new int[n];
            int sum = 0;
            int i = 0;
            for (i = 0; i < n; i++)
                sum += (arr[i] = ni());
            Arrays.sort(arr);
            int x = arr[n - m];
            if (x * 4 * m < sum)
                pn("No");
            else
                pn("Yes");
        }

        int ni() {
            return in.nextInt();
        }

        void pn(String zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
using namespace std;
// typedef vector<vector<ll>> matrix;
// const ll PRIME = 1e9 + 7;
// typedef pair<int,pair<int,int> >  ppi;


void solve()
{
   int n;
   cin>>n;
string a;
  cin>>a;
  int ans=0;
  int i=0,j=n-1;
  while(i<n&&j>=0 && i<j)
  {
      while(i<n&& a[i]=='R')
      {
          i++;
      }
      while(j>=0 && a[j]=='W')
      {     
          j--;
      }
    
      if(i<n && j>=0 && i<j)
      {
          swap(a[i],a[j]);
          ans++;
        //   cout<<a;
      }
  }
  cout<<ans;
}
int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int t;
    // cin >> t;
    t = 1;
    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3756