akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  
  int N,Q,sum;  
       
  cin >> N;        
  vector<int> A(N);    
  for(int i=0; i<N; i++) cin >> A.at(i);         
  cin >> Q;      
  vector<int> m(Q);    
  for(int i=0; i<Q; i++) cin >> m.at(i);       
  
  vector<int> p(pow(2,N), 0);
  for(int bit = 1; bit < (1<<N); ++bit) {
      sum = 0;
      for (int j = 0; j < N; ++j) {
        if (bit & (1 << j)) sum += A.at(j);
      }
     p.at(bit) = sum;
  }
  
  for(int i=0; i<Q; i++) {
    bool flag = false;
    for (int j = 0; j < p.size(); ++j) {
        if (m.at(i) == p.at(j)) flag = true;;
    }
    if(flag) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}


Measured memory_bytes: 7232
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char X, Y;
    cin >> X >> Y;
    if (X < Y)
        cout << "<" << endl;
    else if (X == Y)
        cout << "=" << endl;
    else
        cout << ">" << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll nc2(int n){
    ll ans;
    ans = ll(n)*(ll(n)-1)/2;
    return ans;
}

int main(){
    int N;
    cin >> N;
    int a[N] = {0};
    int cnt[N] = {0};
    rep(i, N) {
        cin >> a[i];
        cnt[a[i]-1] += 1;
    }
    ll all=0;
    rep(i, N) {
        all += nc2(cnt[i]);
    }
    rep(i, N) {
        if (cnt[a[i]-1] == 2){
            cout << all-1 << endl;
        }
        else if (cnt[a[i]-1] > 2){
            cout << all - (nc2(cnt[a[i]-1]) - nc2(cnt[a[i]-1]-1)) << endl;
        }
        else
            cout << all << endl;
    }
    return 0;
}

Measured memory_bytes: 4096
#include<stdio.h>

int suma(int n){
  return n*(n+1)/2;
}

int sumb(int n,int m){
  return suma(m+n-1)-suma(m-1);
}

int main(){
  int ans[1001];
  int i,j;
  int a;

  for(i=0;i<1001;i++){
    ans[i]=0;
  }

  for(i=2;i<45;i++){
    j=1;
    while(sumb(i,j)<=1000){
      ans[sumb(i,j)]++;
      j++;
    }
  }

  while(1){
    scanf("%d",&a);
    if(a==0){
      break;
    }
    else{
      printf("%d\n",ans[a]);
    }
  }

  return 0;
}

Measured memory_bytes: 604
// template.cpp

// Defines.
//#define DEBUG
#define NUMBER_OF_DIGITS 6

// Includes.
#include <bits/stdc++.h>

#ifdef DEBUG
#include <chrono>
#endif

// Usings.
using namespace std;

// Main function.
int main()
{
#ifdef DEBUG
	chrono::system_clock::time_point start, end;
	
	start = chrono::system_clock::now();
#endif
	
	// settings.
	ios::sync_with_stdio(false);
	
	//cout << fixed;
	//cout << setprecision(NUMBER_OF_DIGITS);
	
	// logic.
	long long n;
	cin >> n;
	
	long long b;
	long long start = (long long)pow((double)n, 0.5);
	for (long long a = start; a > 0; a--)
	{
		if ((n % a) == 0)
		{
			b = n / a;
			break;
		}
	}
	
	int counter = 0;
	while(b != 0)
	{
		counter++;
		b /= 10;
	}
	
	cout << counter << endl;

#ifdef DEBUG
	end = chrono::system_clock::now();
	
	double elapsed = chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
	cout << elapsed << "[ms]" << endl;
#endif
	
	return 0;
}


Measured memory_bytes: 4060
#include<bits/stdc++.h>
using namespace std;
const int N=100001;
vector <int> G[N];
int vis[N];
void dfs(int u){
	vis[u]=1;
	for (int i=0;i<G[u].size();i++){
		int v=G[u][i];
		if (vis[v]==0)dfs(v);
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	while(m--){
		int u,v;
		cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int cnt=0;
	for (int i=1;i<=n;i++){
		if (vis[i]==0){
			dfs(i);
			cnt++;
		}
	}
	cout<<cnt-1<<endl;
	return 0;
}

Measured memory_bytes: 9992
n = int(input())
l = list(map(int, input().split()))
c = set([])
free = 0
for r in l:
  if 1 <= r <= 399:
    c.add('grey')
  elif 400 <= r <= 799:
    c.add('brown')
  elif 800 <= r <= 1199:
    c.add('green')
  elif 1200 <= r <= 1599:
    c.add('cyan')
  elif 1600 <= r <= 1999:
    c.add('blue')
  elif 2000 <= r <= 2399:
    c.add('yellow')
  elif 2400 <= r <= 2799:
    c.add('orange')
  elif 2800 <= r <= 3199:
    c.add('red')
  elif r >= 3200:
    free += 1

if len(c) == 0:
  print(1, len(c)+free)
else:
  print(len(c), len(c)+free)

Measured memory_bytes: 3064
N = int(input())
x = [0]*N
u = [0]*N
answer = 0
for i in range(N):
    x[i], u[i] = map(str, input().split())
    if u[i] == "JPY":
        answer += int(x[i])
    else:
        answer += (float(x[i]) * 380000)



print(answer)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  double x,t;
  cin >> x >> t;
  cout << x / t << '\n';
  return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	x <- readInt
	let
	print $ fst $ head $ dropWhile ( ( < x ) . snd ) $ zip [ 1 .. ] $ scanl1 (+) [ 1 .. ]

Measured memory_bytes: 1148
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <string.h>
#include <math.h>
#include <map>
#include <time.h>
using namespace std;

int main(){ 
	int X;
	cin >> X;
	if (X == 3 || X == 5 || X == 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    string s;
    int h,w;
    cin >> h >> w;
    for(int i=0;i<h;i++){
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*input
5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3
*/
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int const mod = 1e9+7;
int power(int x, int y, int mod = 2e18){ int ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
int gcd(int a , int b){if(a==0)return b;return gcd(b%a,a);}
vector<int> v[100010];
int dp[100010];
bool vis[100010];
int finalans = 0 ;
int dfs(int i){
	vis[i]=1;
	int ans = 0 ; 
	if(dp[i]!=-1){
		return dp[i];
	}
	for(auto x : v[i]){
		ans = max(ans,1+dfs(x));
	}

	return dp[i]=ans;
}

signed main() {
	IOS;
	int n,m;
	cin>>n>>m;
	int x,y;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		v[x].pb(y);
	}
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i);
		}
	}
	for(int i=1;i<=n;i++)finalans=max(finalans,dp[i]);
	cout<<finalans;
return 0;
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(int i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

template<class T> bool umin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool umax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

const int MOD = 1e9+9 ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  

ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}
ll power(ll a, ll n) { ll r=1;while(n){if(n&1)r=(r*a)%MOD;n>>=1;a=(a*a)%MOD;}return r%MOD;}



vt<pii> dir =  {{-1,0} , {1, 0} , {0,-1} , {0,1}} ; 

// ==========Start Here==============
const int N=8 ; 
vt<int> p(N) ; 
vt<int> q(N) ; 
int n ;
int cnt = 0 ; 


int main() 
{ 
	int n ;
	cin >> n ; 
	int a[n] ; 
    rep(i,0,n) cin >> p[i] ; 
    rep(i,0,n) cin >> q[i] ;
    vt<int> s(n) ; 
    rep(i,0,n) s[i]  = i +1 ; 
    cnt = 1 ; 
    int pos1 = 0 , pos2 = 0 ; 
    while(next_permutation(all(s))) {
        bool ok = 1 ; 
        rep(i,0,n) {
            if(p[i] != s[i]) {
                ok = 0 ; 
                break ; 
            }
        }
        if(ok ) {
            pos1 = cnt ; 
        } 
        bool ok2 = 1 ; 
        rep(i,0,n) {
            if(q[i] != s[i]) {
                ok2 = 0 ; 
                break ; 
            }
        }
        if(ok2) {
            pos2 = cnt ; 
        } 
        cnt++;
    }
    cout << abs(pos2-pos1) ; 
    return 0; 
} 

Measured memory_bytes: 3636
from collections import deque
d = deque()
X = input()
for c in X:
    d.append(c)
    while len(d) >= 2:
        new = d.pop()
        last = d.pop()
        if last == "S" and new == "T":
            continue
        else:
            d.append(last)
            d.append(new)
            break
print(len(d))

Measured memory_bytes: 48864
n=int(input())
x=list(map(float,input().split()))
y=list(map(float,input().split()))
for p in range(1,4):
    Dxy=float(0)
    for i in range(n):
        Dxy+=abs(x[i]-y[i])**p
    Dxy=Dxy**(1/p)
    print(f'{Dxy:.6f}')
Dxy=float(0)
for i in range(n):
    if Dxy<abs(x[i]-y[i]):Dxy=abs(x[i]-y[i])
print(f'{Dxy:.6f}')


Measured memory_bytes: 5676
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] p = new int[n];
        for(int i = 0; i < n; i++){
            p[i] = scan.nextInt();
        }
        int out = 0;
        for(int i = 1; i < n - 1; i++){
            if(p[i - 1] < p[i] && p[i] < p[i + 1]){
                out++;
            }else if(p[i - 1] > p[i] && p[i] > p[i + 1]){
                out++;
            }
        }
        System.out.println(out);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef pair<int,int> P;

int main(){

    int n,m;cin >> n >> m;
    vector<P> jobs(n);
    rep(i,n){
        int a,b;
        cin >> a >> b;
        jobs[i] = make_pair(a,-b);
    }
    sort(jobs.rbegin(),jobs.rend());
    int ans = 0;
    priority_queue<int> que;
    for(int i = 1; i <= m ;i++){
        P job = jobs.back();
        while(i>=job.first && jobs.size()>0){
            jobs.pop_back();
            que.push(-job.second);
            job = jobs.back();
        }
        if(!que.empty()){
            ans += que.top();que.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
n = int(input())
H = list(map(int, input().split())) + [1 << 31]

ans = 0
curr = 0
for i in range(n):
    if H[i + 1] <= H[i]:
        curr += 1
    else:
        ans = max(ans, curr)
        curr = 0
print(ans)


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

int main(){
  int N;
  cin>>N;
  
  vector<int>X(N);
  for(int i=0;i<N;i++)
    cin>>X.at(i);
  
  vector<int>Y=X;
  
  sort(Y.begin(),Y.end());
  
  int res_S=Y.at(N/2-1) , res_L=Y.at(N/2);
  
  for(int i=0;i<N;i++){
    if(X.at(i)<=res_S)
      cout<<res_L<<endl;
    else
      cout<<res_S<<endl;
  }
  
}
  
  

Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;


int main(){
    string S;
    cin >> S;
    string ans = "";
    int flag = 0;
    for (int i=0; i<S.length(); i++) {
        if (flag == 0 and S[i]=='A') {
            flag = 1;
            ans += 'A';
        }
        if (flag == 1 and S[i]=='Z') {
            flag = 0;
            ans += 'Z';
        }
    }
    if(ans[ans.length()-1]=='A') ans = ans.substr(0,ans.length()-1);
    if (ans == "") {
        cout << -1 <<endl;
    }else{
        cout << ans<<endl;
    }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    string s;
    cin >> s;
    map<char, int> c;
    rep(i,s.size())c[s[i]]++;
    for (auto x:c){
        if (x.second!=2){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nl '\n' 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pii pair <int,int>
ll m=1000000007;

int main()
{
	fast;
	int n;cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	int XOR=a[0];
	vector<int>v;
	for(int i=1;i<n;i++)
	{
		XOR=XOR^a[i];
	}
	for(int i=0;i<n;i++)
	{
		v.push_back(a[i]^XOR);
	}
	for(auto i:v)
		cout<<i<<" ";
}

Measured memory_bytes: 5020
/*
    author: Salam_35
    Created at :

*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int t;cin >> t;while(t--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
    double n;
    cin>> n;
    cout<<setprecision(15)<<fixed<<2*pi*n<<endl;
}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
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;
}
int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}
pair<int, int> solve(pair<int, int> p) {
    int a = p.first, b = p.second;
    if(b > 0) {
        return make_pair(b, -a);
    }
    return make_pair(-b, a);
}
int mod_pow(int x, int n, int mm) {
    int res = 1;
    while(n > 0) {
        if(n & 1) res = res * x % mm;
        x = x * x % mm;
        n >>= 1;
    }
    return res;
}
signed main() {
    int N, M;
    cin >> N >> M;
    vector<int> Graph[N];
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        Graph[a].push_back(b);
        Graph[b].push_back(a);
    }
    queue<int> que;
    vector<int> dis(N, -1);
    dis[0] = 0;
    que.push(0);
    while(!que.empty()) {
        int now = que.front();
        que.pop();
        for(auto next : Graph[now]) {
            if(dis[next] == -1) {
                dis[next] = dis[now] + 1;
                que.push(next);
            }
        }
    }
    vector<int> Ans(N);
    for(int i = 1; i < N; i++) {
        int d = dis[i];
        for(auto pval : Graph[i]) {
            if(dis[pval] == d - 1) Ans[i] = pval;
        }
    }
    cout << "Yes" << endl;
    rep(i, N - 1) {
        cout << Ans[i + 1]+1 << endl;
    }
}


Measured memory_bytes: 13636
import java.util.Scanner;

public class Main {
	public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        int [] count = new int[26];
        
        while(scan.hasNext()){
            String line  = scan.next();
            
            for(int i = 0; i < line.length(); ++i){
                if(Character.isLowerCase(line.charAt(i))){
                    ++count[line.charAt(i) - 'a'];
                }
                
                else if(Character.isUpperCase(line.charAt(i))){
                    ++count[line.charAt(i) - 'A'];
                }
            }
        }
        
        for(int i = 0; i < count.length; ++i){
            System.out.println((char)('a' + i) + " : " + count[i]);
        }
    }
}

Measured memory_bytes: 19152
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);



int main(int argc, char* argv[])
{
  int h, w;
  cin >> h >> w;
  vector<int> nums(26, 0);
  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) {
      nums[s[j] - 'a']++;
    }
  }

  if (h % 2 == 1 && w % 2 == 0) swap(h, w);

  if (h % 2 == 0 && w % 2 == 0){
    int num_4 = (h * w) / 4;
    rep(i, num_4) {
      rep(j, nums.size()) {
        if (nums[j] >= 4) {
          nums[j] -= 4;
          break;
        }
      }
    }
  } else if (h % 2 == 0 && w % 2 == 1) {
    int num4 = (h * (w-1)) / 4;
    int num2 = h / 2;
    rep(i, num4) {
      rep(j, nums.size()) {
        if (nums[j] >= 4) {
          nums[j] -= 4;
          break;
        }
      }
    }
    rep(i, num2) {
      rep(j, nums.size()) {
        if (nums[j] >= 2) {
          nums[j] -= 2;
          break;
        }
      }
    }
  } else {
    int num4 = ((h-1) * (w-1)) / 4;
    int num2 = (h-1) / 2 + (w-1) / 2;
    rep(i, nums.size()) {
      if (nums[i] % 2 == 1) {
        nums[i]--;
        break;
      }
    }
    rep(i, num4) {
      rep(j, nums.size()) {
        if (nums[j] >= 4) {
          nums[j] -= 4;
          break;
        }
      }
    }
    rep(i, num2) {
      rep(j, nums.size()) {
        if (nums[j] >= 2) {
          nums[j] -= 2;
          break;
        }
      }
    }
  }

  rep(i, nums.size()) {
    if (nums[i] != 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;
const int MAX_N=500010;
const ll INF=99999999999;

int main(){
    ll N,a,sum,m,neg;
    sum=0; neg=0; m=INF;
    cin>>N;
    for(int n=0;n<N;n++){
        cin>>a;
        sum+=abs(a);
        m=min(m,abs(a));
        if(a<0) neg++;
    }
    if(neg%2==0){
        cout<<sum<<endl;
    }else{
        cout<<sum-2*m<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
def input_ints():
    return list(map(int, input().split()))

def main():
    n = int(input())
    a = input_ints()
    c = 0
    for i in range(n):
        if a[i] < 0:
            c += 1
            a[i] *= -1
    ans = sum(a)
    if c % 2:
        ans -= 2 * min(a)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14412
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector <ll> v
#define vii vector<pair<ll,ll>>v
#define pb push_back
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define while_ int t;cin>>t;while(t--)
using namespace std;

ll dp[100005][105];

ll maxP(int W,int n,int w[],int v[])
{
    if(n==0 || W<=0) return 0;

    if(dp[W][n]!=-1) return dp[W][n];
    ll op1=maxP(W,n-1,w,v);
    ll op2=(W>=w[n-1]) ? maxP(W-w[n-1],n-1,w,v) + v[n-1] :0;
    return dp[W][n]=max(op1,op2);
}

int main() {
    fastio
    memset(dp,-1,sizeof(dp));
    int n,W;
    cin>>n>>W;
    int w[n],v[n];
    f(i,0,n) cin>>w[i]>>v[i];
    cout<<maxP(W,n,w,v);
}













Measured memory_bytes: 82304
#include<iostream>
#include<algorithm>
#define INF 2e9
#define ll long long
using namespace std;
ll weight[110],value[110],dp[100002][102];
int main(){
    int n,W;
    scanf("%d %d",&n,&W);
    for(int i=1;i<=n;i++){
        scanf("%lld %lld",&weight[i],&value[i]);
    }
    for(int i=0;i<=n;i++){
        for(int j=1;j<=100000;j++){
            dp[j][i]=INF;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=100000;j++){
            if(j-value[i]>=0){
                //if(dp[j-value[i]][i-1]!=INF)
                dp[j][i]=min(dp[j][i-1],dp[j-value[i]][i-1]+weight[i]);
            }
            dp[j][i]=min(dp[j][i],dp[j][i-1]);
        }
    }
    /*
    for(int i=1;i<=n;i++){
        for(int j=1;j<=15;j++){
            cout<<dp[j][i]<<' ';
        }
        cout<<'\n';
    }*/
    for(int i=100000;i>=1;i--){
        //cout<<dp[i][n]<<' ';
        if(W>=dp[i][n]&&dp[i][n]!=INF){
            printf("%d",i);
            return 0;
        }
    }
    
    
    
}


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

bool isprime(int x){
  if(x == 2){
    return true;
  }
  if(x < 2 || x%2==0){
    return false;
  }
  for(int i=3;i<=sqrt(x);i+=2){
    if(x%i==0){
      return false;
    }
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  int pnum[n];
  for(int i=0;i<n;i++){
    pnum[i] = 0;
  }

  for(int i=0;i<n;i++){
    cin >> pnum[i];
  }

  int counter = 0;
  for(int i=0;i<n;i++){
    if(isprime(pnum[i])==true){
      counter++;
    }
  }
  cout << counter << endl;
}



Measured memory_bytes: 3100
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
#include<vector>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



int main() {

	string n;

	cin >> n;
	if (n[0] == n[2])cout << "Yes" << endl;
	else cout << "No" << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 3e5 + 1;

bool usd[101][101];
int n, a, b;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> a >> b;
    if (abs(a - b) % 2 == 0) {
        cout << "Alice";
        return 0;
    } else {
        cout << "Borys";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int b = int.Parse(input[0]);
		int c = int.Parse(input[1]);
        int d = int.Parse(input[2]);
      	int e = int.Parse(input[3]);
        int f = int.Parse(input[4]);
		
      	if(b == 0){
        	Console.WriteLine(1);
        }else if(c == 0 ){
          	Console.WriteLine(2);
        }else if(d == 0 ){
          	Console.WriteLine(3);
        }else if(e == 0 ){
          	Console.WriteLine(4);
        }else if(f == 0 ){
          	Console.WriteLine(5);
        }

	}
}

Measured memory_bytes: 27320
n = int(input())
lst_left = []
lst_right = []
total = 0
for i in range(n):
  s = input()
  h = 0
  b = 0
  for e in s:
    if e == "(":
      h += 1
    else:
      h -= 1
      b = min(b, h)
  if h>=0:
    lst_left.append((b, h))
  else:
    lst_right.append((b-h, -h))
  total += h
#lst_left = sorted(lst_left, key=lambda x:x[1], reverse=True)
lst_left = sorted(lst_left, key=lambda x:x[0], reverse=True)
#lst_right = sorted(lst_right, key=lambda x:x[1], reverse=True)
lst_right = sorted(lst_right, key=lambda x:x[0], reverse=True)

if total != 0:
  print("No")
  exit()
h = 0
for i in range(len(lst_left)):
  if h + lst_left[i][0] < 0:
    print("No")
    exit()
  else:
    h += lst_left[i][1]
h = 0
for i in range(len(lst_right)):
  if h + lst_right[i][0] < 0:
    print("No")
    exit()
  else:
    h += lst_right[i][1]
print("Yes")
  


Measured memory_bytes: 176276
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;






int main()
{
	int a;
	stack<int> s;
	while (cin >> a) {
		s.push(a);
		if (s.top() == 0) {
			s.pop();
			cout << s.top() << endl;
			s.pop();
		}
	}
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>
#include <functional>
#include <vector>
#include <set>

using namespace std;

#define ERROR_ID		0

#define PROCESS_ERROR(Condition)    \
{                                   \
		if (!(Condition))           \
		{                           \
			goto Exit0;             \
		}                           \
}

typedef unsigned char			BYTE;
typedef int						BOOL;
typedef unsigned long			DWORD;
typedef long long				LLONG;

inline int read() {
	int ret = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-') f = -f;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
	return ret * f;
}//快读优化

int main(int argc, char* argv[])
{
	string		szNumberStr;
	int			nLength;
	int			nResult				= INT_MAX;

	cin >> szNumberStr;

	nLength = szNumberStr.size();

	for (int i = 1; i < nLength; i++)
	{
		if (szNumberStr[i] != szNumberStr[i - 1])
		{
			nResult = min(nResult, max(i, nLength - i));
		}
	}
	cout << min(nResult, nLength) << endl;
	return 0;
}

Measured memory_bytes: 512
// 解答不能.
// Fading氏.
// https://atcoder.jp/contests/abc147/submissions/8852291
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
const LL MOD = 1e9 + 7;
LL A[303030];

int main(){
    int N;
    scanf("%d", &N);
    repx(i, 1, N + 1) scanf("%lld", &A[i]);
    LL ans = 0;
    rep(i, 60){
        int c = 0;
        repx(j, 1, N + 1) c += (A[j] >> i) & 1;
        ans = (ans + 1LL * (1LL << (1LL * i))% MOD * c % MOD * (1LL * N - c + MOD) % MOD) % MOD;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2560
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 

    for(int i = 0; i < 5; i++){
      int a = sc.nextInt();
      if(a == 0){System.out.println(i+1);}
    }
    
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 25256
# /usr/bin/python
# -*- coding: utf-8 -*-
import math







def main():
  N = int(input())
  An = list(map(int, input().split()))
  Bn = [0] * 9
  for a in An:
    Bn[min(a//400,8)] += 1
  for i in range(len(Bn)-1):
    Bn[i] = math.ceil(Bn[i]/1000)

  mn = max(1, sum(Bn[:-1]))
  mx = sum(Bn)

  return mn,mx

if __name__ == "__main__":
  ret1,ret2 = main()
  print(ret1,ret2)

Measured memory_bytes: 38384
n=int(input())
w=[""]*n
a=set()
for i in range(n):
    w[i]=input()
cnt=0
for x in w:
    if x in a:
        print("No")
        exit()
    else:
        if cnt>0:
            if bef!=x[0]:
                print("No")
                exit()
        bef=x[-1]
    cnt+=1
    a.add(x)
print("Yes")


Measured memory_bytes: 9164
#include <iostream>
#include <vector>
#include <deque>
#include <math.h>
#include <set>
#include <iomanip>
#include <time.h>
#include <list>
#include <stdio.h>
#include <queue>
#include <map>
#include <algorithm>
#include <assert.h>
#include <memory.h>

#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define sz(s) ( (int)s.size() )
#define all(s) s.begin(), s.end()

using namespace std;

const int N = 1e7 + 1;

int n, m;

inline bool check(int md)
{
    m = n;
    for (int i = md; i >= 1; i--)
    {
        if (m >= i)
            m -= i;
    }
    return m == 0;
}

main ()
{
    cin >> n;

    int l = 0, r = n;
    while (r - l > 1)
    {
        int md = (l + r) >> 1;
        if (check(md))
            r = md;
        else
            l = md;
    }
    for (int i = r; i >= 1; i--)
    {
        if(n >= i)
            printf("%d\n", i), n -= i;
    }
}


Measured memory_bytes: 384
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int n,a,b;

int ncr(int p, int q){
    if(q>p) return 0;
    int res=1;
    for(int i=p; i>max(q,p-q); i--){
        res*=i;
        res%=mod;
    }
    for(int i=1; i<=min(q,p-q); i++){
        res*=power(i,mod-2);
        res%=mod;
    }
    return res;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> a >> b;
    int ans=power(2,n)-1;
    if(ans<0) ans+=mod;
    ans-=ncr(n,a);
    if(ans<0) ans+=mod;
    ans-=ncr(n,b);
    if(ans<0) ans+=mod;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int x=max(a,c),y=min(b,d);
	if(y-x<=0)
	cout<<0<<endl;
	else
	cout<<y-x<<endl;
}

Measured memory_bytes: 256
def attack(i):
    attack = 0
    attack_i = A_list[i]
    if(B_list[i] > A_list[i]):
        B_list[i] = B_list[i] - A_list[i]
        attack = A_list[i]
        A_list[i] = 0 
        attack += min(B_list[i], A_list[i+1])
        A_list[i+1] = max(A_list[i+1] - B_list[i], 0)
    else:
        A_list[i] = A_list[i] -  B_list[i]
        attack += B_list[i]
    return attack

N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += attack(i)
print(ans)

Measured memory_bytes: 19004
N = int(input())

count = 0
total_count = 0

for i in range(1,N+1):
    for j in range(1,N+1):
        if i % j == 0:
            count += 1
    if count == 8 and i % 2 == 1:
        total_count += 1
    count = 0
print(total_count)

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

int main() {
  int a,b,c,i;
  cin>>a>>b>>c;
  int h[b]={};
  h[0]=a%b;
  bool eq=false;
  for(i=1;i<=b;i++){
    h[i]=(h[0]*i)%b;
    if(h[i]==c)
      eq=true;
  }
  if(eq)
    cout<<"YES";
  else cout<<"NO";
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
const int INF=1001001001;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数
const ll MAXN = 1001024; // b-a < MAXN, sqrt(b) < MAXN


int main(){
    int n,k;
    cin >> n >> k;
    int x[n];
    rep(i,n){
        cin >> x[i];
    }
    if(k==1){
        cout << abs(x[0]) << endl;
    }
    else{
        ll ans=100000000000000;
        rep(i, n - k+1)
        {
            ll l = x[i];
            ll r = x[i + k - 1];
            //l→rの場合
            if(ans>abs(l) + abs(r - l))
            ans = abs(l) + abs(r - l);
            if(ans>(abs(r)+abs(r-l)))
                ans = (abs(r) + abs(r - l));
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 640
N = int(input())
cards = [int(i) for i in input().split()]
alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += max(cards)
        cards.remove(max(cards))
    elif i % 2 == 1:
        bob += max(cards)
        cards.remove(max(cards))
print(alice - bob)

Measured memory_bytes: 3064
L=list()
R=list()
N=int(input())
for i in range(N):
  S=input()
  L.append(S)
M=int(input())
for i in range(M):
  S=input()
  R.append(S)
maxa=0
for i in range(N):
  s=L.count(L[i])-R.count(L[i])
  maxa=max(maxa,s)
print(maxa)

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

#define ms(s, n) memset(s, n, sizeof(s))
#define f(i, a, b) for (int i = (a); i <=(b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<ll> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) - 1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
int modulo(int a, int b) { return (a % b + b) % b; }
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

int main()
{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = max({a*c,a*d,b*c,b*d});
	cout << ans << endl;
	// read the stuff at the bottom
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* use int when constraints limits are tight
	* Time taken : global variable < pass by refernce < pass by value
	* It takes significant amt. of time in pass by value
	* Avoid Using endl
*/





























Measured memory_bytes: 3652
n,m,l = map(int,input().split())
g = [[float('inf')]*n for _ in range(n)]
for _ in range(m):
    a,b,c = map(int,input().split())
    a-=1
    b-=1
    g[a][b] = c
    g[b][a] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            g[i][j] = min(g[i][j],g[i][k] + g[k][j])
h = [[float('inf')]*n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if g[i][j]<=l:
            h[i][j] = 1

for k in range(n):
    for i in range(n):
        for j in range(n):
            h[i][j] = min(h[i][j],h[i][k] + h[k][j])
Q = int(input())
for _ in range(Q):
    s,t = map(int,input().split())
    s -=1
    t-=1
    if h[s][t] ==float('inf'):
        print(-1)
    else:
        print(h[s][t]-1)


Measured memory_bytes: 82232
#include<stdio.h>
#include<stdlib.h>
int main(){
  long long n,m,t=38,x[1010],y[1010],d[110],i,j;
  scanf("%lld",&n);
  for(i=0;i<n;i++)scanf("%lld %lld",&x[i],&y[i]);
  m=labs(x[0]+y[0])%2;
  for(i=0;i<n;i++){
    if(labs(x[i]+y[i])%2-m)break;
  }
  if(i-n){
    printf("-1\n");
    return 0;
  }
  m++;
  for(i=0;i<t;i++)d[t-i-1]=(1LL<<i);
  d[t]=d[t+1]=1;
  //printf("!%lld!",d[0]);
  printf("%lld\n%lld",t+m,d[0]);
  //printf("!%lld!",d[0]);
  for(i=1;i<t+m;i++)printf(" %lld",d[i]);
  printf("\n");
  for(i=0;i<n;i++){
    for(j=0;j<t+m;j++){
      if(labs(x[i])>labs(y[i])){
	if(x[i]<0){
	  printf("L");
	  x[i]+=d[j];
	}
	else{
	  printf("R");
	  x[i]-=d[j];
	}
      }
      else{
	if(y[i]<0){
	  printf("D");
	  y[i]+=d[j];
	}
	else{
	  printf("U");
	  y[i]-=d[j];
	}
      }
    }
    //printf("%d %d\n",x[i],y[i]);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <atomic>
#include <bitset>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <cmath>
using namespace std;

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

template<class T, class U> inline bool chmax(T& a, U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a, U b) { if (a > b) { a = b; return 1; } return 0; }

// 第一引数 == 第二引数 ? true : false
template<class T, class U>
bool check(T first, U second) {
    return (first == second);
}

// 約数列挙
vector<int64_t> divisor(int64_t n) {
  vector<int64_t> ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


// 数字和
template<class T>
T digitSum(T num) {
    T dig;
    T sum = 0;
    while (num) {
        dig = num % 10;
        sum += dig;
        num /= 10;
    }
    return sum;
}

string background_black(string s) { return "\x1b[40m" + s; }
string background_red(string s) { return "\x1b[41m" + s + "\x1b[40m"; }
string background_green(string s) { return "\x1b[42m" + s + "\x1b[40m"; }
string background_yellow(string s) { return "\x1b[43m" + s + "\x1b[40m"; }
string background_bleu(string s) { return "\x1b[44m" + s + "\x1b[40m"; }
string background_white(string s) { return "\x1b[47m" + s + "\x1b[40m"; }

string black(string s) { return "\x1b[30m" + s + "\x1b[37m"; }
string red(string s) {return "\x1b[31m" + s + "\x1b[37m"; }
string green(string s) { return "\x1b[32m" + s + "\x1b[37m"; }
string yellow(string s) { return "\x1b[33m" + s + "\x1b[37m"; }
string blue(string s) { return "\x1b[34m" + s + "\x1b[37m"; }
string white(string s) { return "\x1b[37m" + s + "\x1b[37m"; }

const int ten = 10;
const int hundred = 100;
const int thousand = 1000;

typedef long long ll;
typedef unsigned long long ull;

string tolower(string s) {
  string c;
  for (int i = 0; i < s.size(); i++) {
    if ((s[i] >= 'A') && (s[i] <= 'Z')) {
        c.push_back((s[i] + 0x20));
    } else {
        c.push_back(s[i]);
    }
  }
  return c;
}
#include <cstdlib>
string solve() {
  string str = "";
// int->string: to_string, string->int: stoi
//=============================================================================


  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    str += "x";
  }



//=============================================================================
  str += "\n";
  return str;
}

int main() {	
  std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
  cout << solve() << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define maxn 5010
#define inf (ll) 1<<30 

using namespace std ;
typedef long long ll ;

ll d[maxn] ;
int n, k ;
ll ans ;

void init(){
	scanf("%d%d",&n,&k) ;
	for(int i=0; i<n; i++) {
		scanf("%lld",&d[i]) ;
	}
}

int main(void){
	init() ;
	sort(d,d+n) ;

	ans = n ;

	for(int i=n-1; i>=0; i-- ) {
		ll sum = 0 ;
		for(int j=i; j>=0; j--) {
			if(sum+d[j]<k) {
				sum += d[j] ;
			} else {
				ans = min(ans, (ll)j) ;
			}
		}
	}
	printf("%lld\n",ans) ;


	return 0 ;

}

Measured memory_bytes: 256
z=input().strip().split()
R=int(z[0])
B=int(z[1])
G=int(z[2])
N=int(z[3])
count=0
n=N
while n>=0:
  copy=n
  while n>=0:
    if n%G==0:
      count+=1
    n-=B
  n=copy-R
print(count)

Measured memory_bytes: 3064
import java.util.Scanner;

/**
 * Created by Harry on 4/2/20.
 */
//https://atcoder.jp/contests/dp/tasks/dp_i
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        double[] p = new double[N];
        for(int i=0; i<N; i++){
            p[i] = scanner.nextDouble();
        }
        double[][] dp = new double[N+1][N+1];
        dp[0][0] = 1;
        for(int i=1; i<=N; i++){
            for(int j=0; j<=i; j++){
                dp[i][j] = dp[i-1][j]*(1-p[i-1])+(j-1>=0 ? dp[i-1][j-1]*p[i-1] : 0);
            }
        }
        double res = 0.0;
        for(int i=(N+1)/2; i<=N; i++){
            res += dp[N][i];
        }
        System.out.print(res);
    }
}


Measured memory_bytes: 123392
#include<iostream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>

#define ll long long

ll N, M;

using namespace std;

int main()
{
    cin >> N >> M;

    if (N*2 >= M) {
        cout << M/2 << endl;
    } else {
        cout << N + (M-2*N) / 4 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    multiset<int> D;
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        D.insert(temp);
    }
    int M;
    cin >> M;
    for (int i = 0; i < M; i++) {
        int temp;
        cin >> temp;
        auto itr = D.find(temp);
        if (itr == D.end()) {
            cout << "NO" << endl;
            return 0;
        }
        D.erase(itr);
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 9600