akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
int a;
  cin>>a;
  if(a<1200) cout<<"ABC";
  else if(a<2800) cout<<"ARC";
  else cout<<"AGC";
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<bits/stdc++.h> 
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const int INF = 1e9;


int n,a;
vector<int> v;
int main(){
  cin>>n;
  REP(i,n){
    cin>>a;v.push_back(a);
  }
  sort(v.begin(),v.end());
  cout<<v[n-1]-v[0]<<endl;
  return 0;
}




Measured memory_bytes: 256
h, w, n = map(int, input().split())
test = [input() for i in range(h)]
ans = 0
for binh in range(2 ** h):
	for binw in range(2 ** w):
		tmp = 0
		for l in range(h):
			for m in range(w):
				if ((binh >> l) & 1) == 0  and ((binw >> m) & 1) == 0 and test[l][m] == "#":
					tmp += 1
		if tmp == n:
			ans += 1	
print(ans)	

Measured memory_bytes: 9080
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxb = 50;
int n; LL k; int cnt[maxb][2];

LL dfs(const int i, const bool less)
{
    if (i < 0)
        return 0;
    LL ans = 0;
    if (less) 
        ans += (1LL<<i)*max(cnt[i][0],cnt[i][1]) + dfs(i-1,less);
    else if (k & (1LL<<i)) {
        if (cnt[i][1] >= cnt[i][0])
            ans += (1LL<<i)*cnt[i][1] + dfs(i-1,true);
        else
            ans += (1LL<<i)*cnt[i][0] + dfs(i-1,less);
    }
    else
        ans += (1LL<<i)*cnt[i][1] + dfs(i-1,less);
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> n >> k) {
        memset(cnt,0,sizeof(cnt));
        FOR(i,0,n) {
            LL a; cin >> a;
            FOR(j,0,maxb) {
                if (a & (1LL<<j))
                    cnt[j][1]++;
                else
                    cnt[j][0]++;
            }
        }
        cout << dfs(maxb-1,false) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n,d,x;
	int a[110];
	cin>>n>>d>>x;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=x;
	for(int i=0;i<n;i++){
		ans+=(d-1)/a[i]+1;
	}
	cout<<ans<<endl;
			
}

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

n = int(input())
# スペース区切りの整数入力
weight = input().split()

ans = 10000
for i in range(1,n-1):
  sum1=0
  sum2=0
  an = 0
  for j,w in enumerate(weight):
    if j <= i:
      sum1 += int(w)
    else:
      sum2 += int(w)
  if sum1 > sum2:
    an = sum1-sum2
  else:
    an = sum2-sum1
  if ans > an:
    ans = an


print(str(ans))

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

using ll = long long;

int main()
{
  int s, w;
  cin >> s >> w;
  if(s <= w){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
  


}

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

int main() {
	int h,w;cin>>h>>w;
	vector<vector<char>> v(h,vector<char>(w,0)),r(h,vector<char>(w,'.')),b(h,vector<char>(w,'.'));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>v[i][j];
			if(i==0){
				r[i][j]='#';
				continue;
			}
			if(i==h-1){
				b[i][j]='#';
				continue;
			}
			if(j%2){
				b[i][j]='#';
			}else{
				r[i][j]='#';
			}
			if(v[i][j]=='#'){
				r[i][j]='#';
				b[i][j]='#';
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<r[i][j];
		}
		cout<<endl;
	}
	cout<<endl;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<b[i][j];
		}
		cout<<endl;
	}
	return 0;
}


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

int a[100], b[100];
long long f[100][100];
set<int> v[100];
bool over[100], must[100];

int main() {
	memset(f,-1,sizeof(f));
	for (int i = 0; i <= 50; i++) f[i][i] = 0;
	for (int i = 1; i <= 50; i++) 
		for (int k = i; k > 0; k--) f[i][i%k] = k;
	for (int k = 1; k < 50; k++) 
		for (int j = 0; j < k; j++) if (f[k][j] > -1)
			for (int i = k+1; i <= 50; i++) if (f[i][k] > -1)
				if (f[i][j] == -1 || f[i][j] > f[i][k])
					f[i][j] = f[i][k];
	
	int n;
	cin >> n;
	int rest = n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		if (f[a[i]][b[i]] == -1) {
			cout << -1 << "\n";
			return 0;
		}
	}
	
	long long tot = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i]) {over[i] = true; rest--;}
		else v[i].insert(a[i]);	
	}
	for (int k = 50; k > 0; k--) {
		bool tf = false;
		for (int i = 0; i < n; i++) if (!over[i]) {
			bool must = true;
			for (auto it = v[i].begin(); it != v[i].end(); it++) {
				int cur = *it;
				if (f[cur][b[i]] < k) {must = false; break;}
			}
			if (must) {tf = true; break;}
		}
		if (tf) tot += ((long long)1<<k); else continue;
		for (int i = 0; i < n; i++) if (!over[i]) {
			for (auto it = v[i].begin(); it != v[i].end();) {
				int cur = *it;
				it++;
				if (cur < k) continue;
				int m = cur%k;
				if (m == b[i]) {over[i] = true;	rest--; break;}
				if (f[m][b[i]] > -1) v[i].insert(m);
				if (f[cur][b[i]] == k) v[i].erase(cur);
			}
		}
		if (!rest) break;
	}
	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>

int main(){
  int h, w;
  char s[128][128];
  scanf("%d %d", &h, &w);

  for(int i = 0; i < h; i++)
    scanf("%s", s[i]);

  for(int i = 0; i < w + 2; i++)
    printf("#");

  printf("\n");

  for(int i = 0; i < h; i++)
    printf("#%s#\n", s[i]);

  for(int i = 0; i < w + 2; i++)
    printf("#");

  printf("\n");

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e6+5;
ll px[N];
ll py[N];
void solve(){
	int n; 
	cin>>n;
	priority_queue<ll> xy,xxy,xyy,xxyy; 
	ll ans = 0;
	for(int i=1;i<=n;i++){
		cin>>px[i]>>py[i];
		if(i!=1){
			ll txy = xy.top();
			ll txxy = xxy.top();
			ll txyy = xyy.top();
			ll txxyy = xxyy.top();
			ans = max(txy-(px[i]+py[i]),ans);
			ans = max(ans,txyy+(py[i]-px[i]));
			ans = max(ans,txxy+(px[i]-py[i]));
			ans = max(ans,txxyy+(px[i]+py[i]));
		}
		xy.push(px[i]+py[i]);
		xxy.push(-px[i]+py[i]);
		xyy.push(px[i]-py[i]);
		xxyy.push(-px[i]-py[i]);
	}
	cout<<ans<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 12836
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] ms = new int[] { 2, 5, 5, 4, 5, 6, 3, 7, 6 };

		Scanner in = new Scanner(System.in);

		int N = in.nextInt();
		int M = in.nextInt();
		int[] A = new int[M];
		for (int i = 0; i < M; i++) {
			A[i] = in.nextInt();
		}

		Arrays.parallelSort(A);

		String[] dp = new String[N + 1];
		dp[0] = "";

		for (int n = 0; n < N; n++) {
			if (dp[n] == null) {
				continue;
			}
			for (int i = A.length - 1; 0 <= i; i--) {
				int m = ms[A[i] - 1];
				int use = n + m;
				if (N < use) {
					continue;
				}
				String value = A[i] + dp[n];
				if (check(value, dp[use])) {
					dp[use] = value;
				}
			}
		}
		System.out.println(dp[N]);
	}

	private static boolean check(String a, String b) {
		if (b == null || a.length() > b.length()) {
			return true;
		}
		if (b.length() > a.length()) {
			return false;
		}
		return a.compareTo(b) > 0;
	}
}


Measured memory_bytes: 315976
#define  _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}


#define int ll

unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void solve(){
    while (true) {
        int n;
        cin >> n;
        if (n == 0)return;
        vector<pair<int, int>> inputs;
        int hoge = 0;
        REP(i, n) {
            int a, b;
            cin >> a >> b;
            inputs.push_back(mp(a, b));
            hoge += a;
        }
        sort(ALL(inputs));
        if (hoge >= 2 * inputs.back().first) {
            int sum = 0;
            REP(i, inputs.size()) sum += inputs[i].first + inputs[i].second;
            cout << sum << endl;
            continue;
        }
        int dp[2024] = {};
        dp[0] = 0;
        for (int i = 0; i < (int)inputs.size() - 1; ++i) {
            for (int q = 1000; q >= 0;--q) {
                int hoge = q + inputs[i].second;
                if (hoge <= 2000) {
                    dp[hoge] = max(dp[hoge], dp[q] + inputs[i].second);
                }
            }
        }
        int sum = 0;
        REP(i, inputs.size()) sum += inputs[i].second;
        sum -= dp[2 * inputs.back().first - hoge];
        sum += inputs.back().first * 2;
        cout << sum << endl;
    }
}

#undef int
int main() {
    init();
    solve();
}


Measured memory_bytes: 3268
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////

int main() {
	string S; cin >> S;
	ll ans = 0;
	ll tmp;
	for (int bit = 0; bit < (1<<(S.size()-1)); ++bit) {
		tmp = S[0] - '0';
		for (int i = 0; i < S.size()-1; ++i) {
			if (bit&(1 << i)) {
				ans += tmp;
				tmp = 0;
			}
			tmp = tmp * 10 + (S[i + 1] - '0');
		}
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  while(1){
  int a,b;
  cin>>a>>b;
  if(a==0 && b==0) break;
  int c=0;
  for(int i=1;i<b/3;i++){
    for(int j=1+i;j<=(b-i)/2;j++){
      int k=b-j-i;
      if(j!=k && i<=a && j<=a && k<=a){
	c++;
      }
    }
  }
  cout<<c<<endl;
  }
  return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  string s1, s2;
  cin >> s1 >> s2;

  std::reverse(s2.begin(), s2.end());
  if (s1 == s2) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	a := nextInt()
	fmt.Println(3*a*a)
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    vector<int> v(n + 1), h(n);
    for (int i = 0; i < n + 1; ++i) {
        cin >> v[i];
    }
    int ans = accumulate(v.begin(), v.end(), 0ll);
    for (int i = 0; i < n; i++) {
        cin >> h[i];

        if (h[i] >= v[i]) {
            h[i] -= v[i];
            v[i] = 0;
        } else {
            v[i] = v[i] - h[i];
            h[i] = 0;
        }

        if (h[i] >= v[i + 1]) {
            h[i] -= v[i + 1];
            v[i + 1] = 0;
        } else {
            v[i + 1] = v[i + 1] - h[i];
            h[i] = 0;
        }
    }
    cout << ans - accumulate(v.begin(), v.end(), 0ll) << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<int64_t> a(x);
  vector<int64_t> b(y);
  vector<int64_t> c(z);
  for (int i = 0; i < x; i++) cin >> a[i];
  for (int i = 0; i < y; i++) cin >> b[i];
  for (int i = 0; i < z; i++) cin >> c[i];

  // a + b
  vector<int64_t> ab(x * y);
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      ab[j + i * y] = a[i] + b[j];
    }
  }
  sort(ab.begin(), ab.end(), greater<int64_t>());

  vector<int64_t> ans;
  for (int i = 0; i < min(k, (int)ab.size()); i++) {
    for (int j = 0; j < z; j++) {
      ans.push_back(ab[i] + c[j]);
    }
  }
  sort(ans.begin(), ans.end(), greater<int64_t>());
  for (int i = 0; i < k; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 42856
#include <iostream>
#include <vector>
#include <set>

using namespace std;

vector<vector<int>> adj;
vector<bool> visited;

int dfs(int v,int p){
	if(!visited[v]){
		visited[v]=true;
		int n=1;
		for(auto c: adj[v]){
			if(c!=p)
				n+=dfs(c,v);
		}
		return n;
	}
	return 0;
}
int main(){
	int n,m,s,d,t,c=1;
	cin >> n >> m;
	set<pair<int,int>> fact;
	adj=vector<vector<int>>(n+1);
	visited=vector<bool>(n+1,false);	
	for(int i=0;i<m;i++){
		cin >> s >> d;
		if(s > d){
			t=s;
			s=d;
			d=t;
		}
		auto p=make_pair(s,d); 
		if(fact.find(p)==fact.end()){
			adj[s].push_back(d);
			adj[d].push_back(s);
			fact.insert(p);
		}
	}
	//printf("Input obtained successfully\n");
	for(int i=1;i<=n;i++){
		//printf("In the for loop and calling for %d\n",i);
		if(!visited[i]){
			c=max(c,dfs(i,-1));
		}
	}
	cout<<c<<"\n";
	return 0;
}

Measured memory_bytes: 32988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int x[n];
    for (int i = 0; i < n; i++) cin >> x[i];
    sort(x, x+n);
    ll ans = 1e9;
    for (int p = 1; p <= 100; p++) {
        ll sum = 0;
        for (int j = 0; j < n; j++) {
            sum += pow(x[j] - p, 2);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    int n;
    long[][] A;
    PriorityQueue<Edge> es;
    long[][] dp;
    final static long INF = 1000000007;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        es = new PriorityQueue<>((e1, e2) -> Long.compare(e1.cost, e2.cost));
        try (BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in)
        )) {
            String line = br.readLine();
            String[] elems;
            n = Integer.parseInt(line);
            A = new long[n][n];
            for (int i = 0; i < n; i++) {
                elems = br.readLine().split(" ");
                for (int j = 0; j < n; j++) {
                    A[i][j] = Long.parseLong(elems[j]);
                    if (j < i)
                        es.add(new Edge(i, j, A[i][j]));
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void solve() {
        dp = new long[n][n];
        for (int i = 0; i < n; i++)
            dp[i] = Arrays.copyOf(A[i], n);
        upd(dp);
        long ret = 0L;
        while (!es.isEmpty()) {
            Edge e = es.poll();
            if (e.cost > dp[e.a][e.b]) {
                es.add(e);
                break;
            }
            else {
                if (!check(e.a, e.b)) {
                    ret += dp[e.a][e.b];
                }
            }
        }
        if (!es.isEmpty()) {
            System.out.println(-1);
        }
        else {
            System.out.println(ret);
        }
    }

    private void upd(long[][] arr) {
        for (int k = 0; k < n; k++) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++)
                    arr[i][j] = Math.min(arr[i][j],
                            arr[i][k] + arr[k][j]);
            }
        }
    }

    private boolean check(int u ,int v) {
        boolean ret = false;
        for (int i = 0; i < n; i++)
            if (i != u && i != v)
                ret |= dp[u][v] == dp[u][i] + dp[i][v];
        return ret;
    }

    private void print(long[][] array) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (array[i][j] == INF)
                    System.out.printf("INF ");
                else
                    System.out.printf("%2d ", array[i][j]);
            }
            System.out.println();
        }
    }

    private class Edge {
        int a, b;
        long cost;
        Edge (int a, int b, long c) {
            this.a = a;
            this.b = b;
            this.cost = c;
        }

        @Override
        public String toString() {
            return String.format("%3d <-> %3d: %d", a, b, cost);
        }
    }
}


Measured memory_bytes: 46792
#include<stdio.h>

int main(){
		int n,i,j,k,f[100][10];
		long p[100][11];
		long long ans=-2000000000000;
		scanf("%d",&n);
		for(i=0;i<n;i++){
				for(j=0;j<10;j++){
						scanf("%d",&f[i][j]);
				}
		}
		for(i=0;i<n;i++){
				for(j=0;j<11;j++){
						scanf("%lld",&p[i][j]);
				}
		}
		for(i=1;i<1024;i++){
				int joisino[10];
				int a=i,doko[100]={0};
				long long tmp=0;
				j=0;
				while(a>0){
						joisino[j]=a%2;
						if(a%2==1)a--;
						a=a/2;
						j++;
				}
				for(j=0;j<n;j++){
						for(k=0;k<10;k++){
								if(joisino[k]==1&&f[j][k]==1)doko[j]++;
						}
				}
				for(j=0;j<n;j++)tmp+=p[j][doko[j]];
				if(tmp>ans)ans=tmp;
		}
		printf("%lld\n",ans);
		return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T> class Segment {
public:
    vector<T> dat;
    int N;

    Segment(int N) : N(N) { dat.assign(N,0); }
    // sum [0,i)
    T sum(int i){
        int ret = 0;
        for(--i; i>=0; i=(i&(i+1))-1) ret += dat[i];
        return ret;
    }
    // sum [i,j)
    T get_inter(int i, int j) { return sum(j) - sum(i); }
    // add x to i
    void update(int i, T x) { for(; i < N; i|=i+1) dat[i] += x; }
};
int N,M,Q;

int main(){
  cin >> N >> M >> Q;
  vector<int> a(M);
  rep(i,0,M - 1) cin >> a[i];
  vector<int> q(Q);
  for(int i = 0;i < Q;i++) cin >> q[i];


  Segment<i64> seg(N);

  for(int i = 0;i < N;i++) seg.update(i,1);


  int now = 0;
  for(int i = 0;i < M;i++){
    int A = a[i] % (N - i);

    int x;

    
    if(A == 0){
      seg.update(now,-1);
      x = now;
    }
    else if(a[i] & 1){
      int ok = N;
      int ng = 0;
      while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        int idx = (now - (mid) + N) % N;
        i64 sum = 0;
        if(now < idx){
          sum += seg.get_inter(0,now);
          sum += seg.get_inter(idx,N);
        }
        else{
          sum += seg.get_inter(idx,now);
        }
        if(A <= sum) ok = mid;
        else ng = mid;
      }
      ok = (now - ok + N) % N;
      seg.update(ok,-1);
      //cout << i  << " " << ok << endl;
      x = ok;
    }
    else{
      int ok = N;
      int ng = 0;
      while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        int idx = (now + mid) % N;
        i64 sum = 0;
        if(now < idx){
          sum += seg.get_inter(now + 1,idx + 1);
        }
        else{
          sum += seg.get_inter(now + 1,N);
          sum += seg.get_inter(0,idx + 1);
        }
        if(A <= sum) ok = mid;
        else ng = mid;
      }
      ok = (now + ok) % N;

      seg.update(ok,-1);
      //cout << i  << " " << ok << endl;
      x = ok;
    }

    //cout << "x : " << x << endl;

    {
      int ok = N;
      int ng = 0;
      now = x;
      while(abs(ok - ng) > 1){
        int mid = (ok + ng) / 2;
        int idx = (now + mid) % N;
        i64 sum = 0;
        if(now < idx){
          sum += seg.get_inter(now + 1,idx + 1);
        }
        else{
          sum += seg.get_inter(now + 1,N);
          sum += seg.get_inter(0,idx + 1);
        }
        if(1 <= sum) ok = mid;
        else ng = mid;
      }

      now = (now + ok) % N;
      //cout << "next :" << now << endl;
    }


  }

  for(int i = 0;i < Q;i++) cout << seg.get_inter(q[i],q[i] + 1) << endl;
}



Measured memory_bytes: 5132
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N, x;
  cin >> N >> x;
  vector<int> ms(N);
  for(int i = 0; i < N; ++i) {
    cin >> ms[i];
  }
  sort(ms.begin(), ms.end());
  int ans = 0;
  for(auto m : ms) {
    ans++;
    x -= m;
  }
  while(true) {
    if(x - ms[0] < 0) {
      cout << ans << endl;
      return 0;
    }
    ans++;
    x -= ms[0];
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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 = 1e9;
//const ll mod = 1000000007;
struct SegmentTree {
private:
    int n;
    vector<int> node;
 
public:
    SegmentTree() {
        int sz = 500;
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for(int i=0; i<sz; i++) node[i+n-1] = INF;
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
 
    void update(int x, int val) {
        x += (n - 1);
        if(val >= node[x]) return;
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }
    // hannkaikukann 
    int getmin(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return INF;
        if(a <= l && r <= b) return node[k];
 
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

ll dist[500][500];
bool a[500][500];
int dh[4] = {0, 0, 1, -1};
int dw[4] = {1, -1, 0, 0};
ll N;

void f(int h, int w, ll val) {
    chmin(dist[h][w], val);
    queue<i_i> que;
    que.push({h, w});
    while(!que.empty()) {
        auto tmp = que.front();
        que.pop();
        int nowh = tmp.first;
        int noww = tmp.second;
        for(int k = 0; k < 4; k++) {
            int newh = nowh + dh[k];
            int neww = noww + dw[k];
            if(newh < 0 or newh >= N or neww < 0 or neww >= N) continue;
            ll newc = dist[nowh][noww];
            if(a[nowh][noww]) newc++;
            if(chmin(dist[newh][neww], newc)) {
                que.push({newh, neww});
            }
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    ll ans = 0;
    for(ll h = 0; h < N; h++) {
        for(ll w = 0; w < N; w++) {
            dist[h][w] = min(min(h, N - 1 - h), min(w, N - 1 - w));
            a[h][w] = true;
        }
    }
    for(int i = 0; i < N * N; i++) {
        ll p;
        cin >> p;
        p--;
        ll h = p / N;
        ll w = p % N;
        ans += dist[h][w];
        ll val = dist[h][w];
        a[h][w] = false;
        f(h, w, val);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5856
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n,vector<int>(m));
  
  for (int i = 0; i < n; i++){
    cin >> c[i];
    for (int j = 0; j < m; j++) cin >> a[i][j];
    
  }
  

  int ans=-1;
  for(int i=0;i<(1<<n);i++){
    bitset<12> bs(i);
    vector<int> s(m);
    int ci=0;
    for(int j=0;j<n;j++){
      if(bs.test(j)){
        for(int k=0;k<m;k++){
          s[k]+=a[j][k];
        }
        ci+=c[j];
      }
    }
    bool f=true;
    for(int j=0;j<m;j++){
      if(s[j]<x) f=false;
    }
    if(f){
      if(ans==-1) ans=ci;
      ans=min(ans,ci);
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
    ll n,t,a,b,c,d,e,p,q,cnt=0;
    map<ll,ll>mp;
    vector<ll>vec;
    string s,s1,s2;
    ll ac=0,tle=0,wa=0,re=0;
    cin>>n;
    ll arr[n+5];
    set<ll>st;

    for(ll i=0;i<n;i++){
        cin>>arr[i];
        mp[arr[i]]++;
        st.insert(arr[i]);
    }

    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            for(ll k=j+1;k<n;k++){
                if(arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k] && (arr[i]<(arr[j]+arr[k]) && (arr[j]<(arr[i]+arr[k]) && arr[k]<(arr[j]+arr[i])))){
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;





   // cout<<cnt<<endl;

}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int r;
    cin >> r;
    cout << r * r << "\n";
    return 0;
}

Measured memory_bytes: 3588
n,l,t=map(int,input().split())
arr=[list(map(int,input().split())) for _ in range(n)]
ans=[]
cnt=0

for i in range(n):
  tmp=arr[i][0]  #蟻iの最初の座標
  # 衝突を考慮しなかった場合の各蟻のt秒後の座標をtmpに入れる
  # cntには円を周回した回数の合計値を入れる
  if arr[i][1]==1:
    tmp+=t
    tmp%=l
    cnt+=(arr[i][0]+t)//l
  else:
    tmp-=t
    tmp%=l
    cnt+=(arr[i][0]-t)//l
  ans.append(tmp)
ans=sorted(ans) #ansに格納したtmp（座標）を昇順にソート
cnt%=n #0番目目の蟻の衝突回数
tmp=[0]*n
for i in range(n):
  #初期位置0番目の蟻の最終位置は、原点から見て衝突数番目の位置にいるはず
  #各蟻の位置関係は、衝突を繰り返すので変わらず時計回りに位置するはず
  tmp[i]=ans[(cnt+i)%n]
ans=tmp
for pos in ans:
  print(pos)

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

using namespace std;

const int maxn = 2e5+10;

typedef long long ll;

int n, c[maxn], sz[maxn], used[maxn];

ll ans[maxn];

vector<int> grafo[maxn];

void dfs(int u, int p = 0){
    sz[u] = 1;
    for(auto v : grafo[u]){
        if(v == p) continue;
        dfs(v, u);
        sz[u] += sz[v];
    }
}

void solve(int u, int p = 0){
    ans[c[u]] += 1LL*(n - sz[u] - used[c[u]] + 1) * sz[u];

    ll sum = sz[u] - 1;

    for(auto v : grafo[u]){
        if(v == p) continue;
        sum -= sz[v];
        ans[c[u]] += sz[v] * sum;
    }

    int previous_used = used[c[u]];

    for(auto v : grafo[u]){
        if(v == p) continue;
        used[c[u]] = n - sz[v];
        solve(v, u);
    }

    used[c[u]] = previous_used + sz[u];
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    cin >> n;

    for(int i=1; i<=n; i++) cin >> c[i];

    for(int i=1; i<n; i++){
        int u, v;

        cin >> u >> v;

        grafo[u].push_back(v);
        grafo[v].push_back(u);
    }

    dfs(1);
    solve(1);

    for(int i=1; i<=n; i++) cout << ans[i] << "\n";

    return 0;
}


Measured memory_bytes: 34020
def divisors(N):
    res = []
    i = 1
    while i * i <= N:
        if N % i == 0:
            res.append(i)
            q = N // i
            if i != q:
                res.append(q)
        i += 1
    res.sort()
    return res

N, M = map(int, input().split())
print(max(d for d in divisors(M) if d * N <= M))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() { 
	int n,m;
	int sum=0,tmp;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>tmp;
		sum+=tmp;
	}
	if(sum>n)
		cout<<-1<<endl;
	else
		cout<<n-sum<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
 
const int N = 2e5 + 5;
const int mod = 1e7 + 7;
const int INF = 1e15;
const int LG = 21;

int arr[N];
int n, m, k;
vector<string> v1, v2;
int cnt[N];

void solve()
{
	int n, x, y;
	cin >> n >> x >> y;
	for(int i = 1; i <= n; i++)
	{
		for(int j = i + 1; j <= n; j++)
		{
			if(x <= i and j <= y)
			{
				cnt[min(j - i, i - x + 1 + y - j)]++;
			}
			else if(x >= i and j >= y)
			{
				cnt[x - i + 1 + j - y]++;	
			}
			else
			{
				cnt[min(j - i, abs(i - x) + 1 + abs(y - j))]++;
			}
		}
	}
	for(int i = 1; i < n; i++)
	{
		cout << cnt[i] << endl;
	}
}

 
int32_t main()
{	
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){  
  int n;
  cin >> n;
  vector<ld> p(n);
  vector<ld> dp(mx,0);
  rep(i,n){
    cin >> p[i];
  }
  dp[0]=1;

  rep(i,n){ 
    vector<ld> dpn(mx,0);
    rep(j,n+1){
      dpn[j+1] += dp[j]*p[i];
      dpn[j] += dp[j]*(1-p[i]);
    }
    rep(j,n+1){ dp[j] = dpn[j]; }
  }
  
  ld ans=0;
  for(int i=n/2+1; i<=n; i++){
    ans += dp[i];
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 6600
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int D;
vector<LL> c(26);
vector<vector<LL>> s;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

LL solve(const vector<LL>& t) {
  LL ans = 0;
  vector<LL> last(26, 0);
  for (int d = 1; d <= D; ++d) {
    int i = d - 1;
    int j = t[i];
    last[j] = d;
    ans += s[i][j];
    for (int k = 0; k < 26; ++k) {
      ans -= c[k] * (d - last[k]);
    }
  }
  return ans;
}

int main() {
  cin >> D;
  cin >> c;
  s.resize(D, vector<LL>(26, 0));
  for (int i = 0; i < D; ++i) cin >> s[i];

  vector<LL> t(D);
  for (int d  =  0; d < D; ++d) t[d] = rand() % 26;

  LL prev = solve(t);
  int d = 0;
  for (int i = 0; i < 1000; ++i) {
    auto best_t = t;
    for (int j = 0; j < 26; ++j) {
      t[i % D] = j;
      LL score = solve(t);
      if (score > prev) {
        prev = score;
        best_t = t;
      }
    }
    t = best_t;
  }

  for (int x : t) cout << x + 1 << endl;
}


Measured memory_bytes: 3716
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>N) {
		VI A(N), B(N);
		REP(i, N) cin>>A[i]>>B[i];
		ll ans=0;
		REPR(i, N) {
			A[i]+=ans;
			if(A[i]%B[i])ans+=B[i]-A[i]%B[i];
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//value at the index->find_by_order(index), index->order_of_key(elme) [both in O(logn)]
//mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
//cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define setbits(x)      __builtin_popcountll(x)
#define leadzero(x)     __builtin_clz(x)
#define trailzero(x)    __builtin_ctz(x)
#define bitsparity(x)   __builtin_parity(x)
#define mod             1000000007
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long 
#define pre(y,x)        fixed<<setprecision(y)<<x
#define dbg1(x)         cerr << "|" << #x << ": " << (x) << "|\n";
#define dbg2(x,y)       cerr << "|" << #x << ": " << (x) << "|" << #y << ": " << (y) << "|\n";
#define dbg3(x,y,z)     cerr << "|" << #x << ": " << (x) << "|" << #y << ": " << (y) << "|" << #z << ": " << (z) << "|\n";
#define ff              first
#define ss              second
#define pb              push_back
#define eb              emplace_back
#define popb            pop_back
#define all(v)          v.begin(), v.end()
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii;
typedef vector<pll> vll; 
typedef vector<ll> vl; 
typedef vector<vl> vvl;
typedef vector<string> vs;
ll power(ll a,ll b){if(b==0) return 1;ll res;while(b>0){if(b&1) res *= a;a *= a;b >>=1;}return res;}
int is(int n){if(n==1) return 0;for(int i=2;i*i<=n;i++){if(n%i==0) return false;}return true;}
bool ispoweroftwo(ll x){ return (x&&!(x&(x-1)));}
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;}
const int inf = 1e9;
const double pi = acos(-1);
const ll INF = 1e18;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////

inline void solve(){
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		ll ans = 1ll*b*d;
//		dbg1(ans);
		ans = max(ans, 1ll*a*c);
		ans = max(ans, 1ll*a*d);
		ans = max(ans, 1ll*b*c);
//		dbg1(ans);
		cout << ans ;
}	
int main(){
		FIO;
//		int t; cin >> t;
//		while(t--)
		solve();
		return 0;	
}
/*

*/

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>

class input
{
    std::istream& cin;

public:
    input() : cin(std::cin)
    {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
    }

    template <class T>
    inline input& operator>>(T& var)
    {
        cin >> var;
        return *this;
    }
    template <class T>
    inline input& operator,(T& var)
    {
        cin >> var;
        return *this;
    }

    template <class T>
    inline T read()
    {
        T var;
        cin >> var;
        return var;
    }

    template <class InputIterator>
    inline void read(InputIterator head, std::size_t n)
    {
        for (std::size_t i = 0; i < n; ++i) {
            cin >> *head;
            ++head;
        }
    }

    template <class T>
    inline std::vector<T> read(std::size_t n)
    {
        std::vector<T> res;
        res.reserve(n);

        for (std::size_t i = 0; i < n; ++i) {
            T tmp;
            cin >> tmp;
            res.emplace_back(tmp);
        }
        return res;
    }

    template <class T, class F>
    inline void online(std::size_t n, F&& f)
    {
        T var;
        for (std::size_t i = 0; i < n; ++i) {
            cin >> var;
            f(var);
        }
    }
};
template <class T, std::size_t n>
std::istream& operator>>(std::istream& in, std::array<T, n>& var)
{
    for (std::size_t i = 0; i < n; ++i) {
        in >> var[i];
    }
    return in;
}

class output
{
    std::ostream& cout;

public:
    class proxy
    {
        std::ostream& cout;

    public:
        proxy() : cout(std::cout) {}
        ~proxy() { cout << '\n'; }
        template <class T>
        proxy& operator,(T&& val)
        {
            cout << ' ' << val;
            return *this;
        }
    };

public:
    output() : cout(std::cout)
    {
        cout << std::fixed << std::setprecision(15);
    }

    template <class T>
    proxy operator<<(T&& val)
    {
        cout << val;
        return {};
    }

    template <class T>
    void print(const T& container)
    {
        bool first = true;
        for (auto&& x : container) {
            if (!first) {
                cout << ' ';
                first = false;
            }
            cout << x;
        }
    }
};

int main()
{
    input in;
    output out;

    std::map<std::string, int> result;
    result.insert(std::make_pair("SAT", 1));
    result.insert(std::make_pair("FRI", 2));
    result.insert(std::make_pair("THU", 3));
    result.insert(std::make_pair("WED", 4));
    result.insert(std::make_pair("TUE", 5));
    result.insert(std::make_pair("MON", 6));
    result.insert(std::make_pair("SUN", 7));

    out << result[in.read<std::string>()];
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


int main(){
  int i,j;
  int n;
  string ss;
  cin>>n>>ss;
  VI s(1005,0);
  VI w2(1005,0);
  VI w(1005,0);
  for(i=0;i<n;i++){
    int e=ss[i]-'0';
    for(j=0;j<100;j++){
      if(w2[j]>0) s[j*10+e]=1;
    }
    for(j=0;j<10;j++){
      if(w[j]>0) w2[j*10+e]=1;
    }
    w[e]=1;
  }
  int cnt=0;
  for(i=0;i<1000;i++){
    cnt+=s[i];
  }
  cout<<cnt<<endl;

  
  return 0;
}

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

void solve() {
	int a,b,c;
	cin >> a >> b >> c;

	int k;
	cin >> k;
	int cnt = 0;
	while(a >= b) b*=2, cnt++;
	while(b >= c) c*=2, cnt++;

	if(cnt <= k) cout << "Yes\n";
	else cout << "No\n";
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}



Measured memory_bytes: 3764
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

l,r=[int(i) for i in input().split()]
a=l//2019
b=r//2019
if a!=b:
    print(0)
elif l%2019==0 or r%2019==0:
    print(0)
else:
    min=10000000000000000
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            c=(i*j)%2019
            if c<min:
                min=c
    print(min)            
            




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, R;
	cin >> N >> R;
	int ans = R;
	if (N < 10) {
		ans += 100 * (10 - N);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256