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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

vector<vector<int>> edges(100000);
vector<int> used(100000,-1);
int c = 0;

void dfs(int i,int p = -1) {
    used[i] = c;
    for (int& j : edges[i]) if (j != p && used[j] < 0) dfs(j,i);
}

int main() {
    int n,m;
    cin >> n >> m;
    for (int i = 0;i < m;++i) {
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    for (int i = 0;i < n;++i) if (used[i] < 0) {
        c++;
        dfs(i);
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 10752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Long.parseLong;
import static java.lang.Integer.parseInt;

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {

    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = parseInt(in.readLine());
      long[] seq = new long[n];

      for(int i=0; i<n; i++)
        seq[i] = parseLong(in.readLine());

      Arrays.parallelSort(seq);

      long[] resU = new long[n];  // /\/\Pattern
      long[] resD = new long[n];  // \/\/Pattern

      // Odd or Even
      if((n&1) == 0) {
        for(int i=0; i<n; i++) {
          if( i==0 ) {
            resU[i] = -1;
            resD[i] =  1;
          }
          else if( i==n-1 ) {
            resU[i] =  1;
            resD[i] = -1;
          }
          else {
            resU[i] = (i&1) == 1 ?  2 : -2;
            resD[i] = (i&1) == 1 ? -2 :  2; 
          }
        }
      }
      else {
        for(int i=0; i<n; i++) {
          if( i==0 ) {
            resU[i] = -1;
            resD[i] =  1;
          }
          else if( i==n-1 ) {
            resU[i] = -1;
            resD[i] =  1;
          }
          else {
            resU[i] = (i&1) == 1 ?  2 : -2;
            resD[i] = (i&1) == 1 ? -2 :  2; 
          }
        }
      }
      Arrays.parallelSort(resU);
      Arrays.parallelSort(resD);

      long sumU=0,sumD=0;
      for(int i=0; i<n; i++) {
        sumU += seq[i] * resU[i];
        sumD += seq[i] * resD[i];
      }

      System.out.println(Math.max(sumU, sumD));
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

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

#include <boost/algorithm/string/classification.hpp>  // is_any_of
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/math/tools/minima.hpp>
#include <boost/multi_array.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>

const int MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); ++i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::replace_all;
using boost::algorithm::split;
using boost::math::tools::brent_find_minima;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;
// TOP
void Main()
{
	int d, w;
	cin >> d >> w;
	vector<string> V(d + 2);
	string e = "......................................................";
	V.at(0) = e;
	V.at(d + 1) = e;
	for (int i = 1; i < d + 1; i++)
	{
		string s;
		cin >> s;

		V.at(i) = "." + s + ".";
	}
	for (int i = 1; i < d + 1; i++)
	{
		for (int j = 1; j < w + 1; j++)
		{
			if (V.at(i).at(j) == '.')
			{
				int cnt;
				cnt = 0;
				if (V.at(i - 1).at(j - 1) == '#') cnt++;
				if (V.at(i - 1).at(j) == '#') cnt++;
				if (V.at(i - 1).at(j + 1) == '#') cnt++;
				if (V.at(i).at(j - 1) == '#') cnt++;
				if (V.at(i).at(j + 1) == '#') cnt++;
				if (V.at(i + 1).at(j - 1) == '#') cnt++;
				if (V.at(i + 1).at(j) == '#') cnt++;
				if (V.at(i + 1).at(j + 1) == '#') cnt++;
				V.at(i).at(j) = cnt + '0';
			}
		}
	}
	for (int i = 1; i < d + 1; i++)
	{
		for (int j = 1; j < w + 1; j++)
		{
			cout << V.at(i).at(j);
		}
		cout << endl;
	}
}
// END

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c; cin>>a>>b>>c;
    for(int i=0;i<c;i++){
        if(i%2==0){
            if(a%2!=0) a--;
            int tmp;
            tmp=a/2;
            a-=tmp;
            b+=tmp;
        }
        else{
            if(b%2!=0) b--;
            int tmp;
            tmp=b/2;
            b-=tmp;
            a+=tmp;
        }
    }
    cout<<a<<' '<<b<<endl;
}

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

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

typedef long long llong;
typedef pair<int, int> pii;

void solve(){

	int n;
	cin >> n;

	vector<int> arr(n);
	vector<llong> leftover(n);

	for(int i = 0; i < n; i++) cin >> arr[i];

	//base case
	leftover[0] = arr[0] % 2;	
	llong ans = arr[0] / 2;

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

		llong used = (leftover[i - 1] + arr[i]) / 2;
		ans += used;

		if(!arr[i]) continue;
		leftover[i] = (leftover[i - 1] % 2) == (arr[i] % 2) ? 0 : 1;
	}

	cout << ans;

}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;
}

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

int main() {
    while (1) {
        int n, m;
        cin >> n >> m;
        if (!n) return 0;

        vector<int> s(n);
        for (int i = 0; i < n; ++i) cin >> s[i];

        int dsum = 0;
        vector<int> d(m);
        for (int i = 0; i < m; ++i) {
            cin >> d[i];
            dsum += d[i];
        }
        vector<int> sum(1 << n, 0);
        for (int i = 0; i < (1 << n); ++i)
            for (int j = 0; j < n; ++j)
                if ((i >> j) & 1) sum[i] += s[j];

        vector<int> dp(1 << n);
        for (int i = 0; i < (1 << n); ++i) {
            dp[i] = dsum;
            for (int j = 0; j < n; ++j) {
                if ((i >> j) & 1) {
                    int a = dp[i ^ (1 << j)];
                    for (int k = 0; k < m; ++k)
                        if (abs(d[k] - sum[i ^ (1 << j)]) > abs(sum[i] - d[k]))
                            a += abs(sum[i] - d[k]) - abs(d[k] - sum[i ^ (1 << j)]);

                    dp[i] = min(dp[i], a);
                }
            }
        }
        cout << dp[(1 << n) - 1] << "\n";
    }
}

Measured memory_bytes: 3204
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>

using namespace std;

typedef long long LL;

const int N = 110;

int n, m;
int w[N];
int res;

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i ++)  scanf("%d", &w[i]);
    for(int i = 0; i <= min(n, m); i ++)
        for(int j = 0; i + j <= min(n, m); j ++)
        {
            int p = m - i - j;      //  剩余次数
            
            vector<int> a;
            for(int k = 0; k < i; k ++)  a.push_back(w[k]);
            for(int k = n - j; k < n; k ++)  a.push_back(w[k]);
            sort(a.begin(), a.end());
            
            int sum = 0;
            for(int i = 0; i < a.size(); i ++)
            {
                if(a[i] < 0 and p > 0)  p --;
                else  sum += a[i];
            }
            //printf("i = %d j = %d  sum = %d\n", i, j, sum);
            res = max(res, sum);
        }
    printf("%d", res);
    return 0;
}

Measured memory_bytes: 384
#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>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

int solve(int n,vector<ll> a){
    multiset<ll>s;
    rep(i,n){
        auto it=s.lower_bound(a[i]);
        if(it!=s.begin())s.erase(--it);
        s.insert(a[i]);
    }
    return s.size();
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);

int n;
cin>>n;
vector<ll>a(n);
rep(i,n)cin>>a[i];

cout<<solve(n,a)<<endl;
return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;
import java.util.LinkedList;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        LinkedList<Integer> a = new LinkedList<Integer>();
        LinkedList<Integer> b = new LinkedList<Integer>();
        LinkedList<String> op = new LinkedList<String>();
        int n=0;
        while(true){
            n++;
            a.add(sc.nextInt());
            if(a.get(n-1)<0 || 20000<a.get(n-1)){
                System.exit(-1);
            }
            op.add(sc.next());
            b.add(sc.nextInt());
            if(b.get(n-1)<0 || 20000<b.get(n-1)){
                System.exit(-1);
            }
            if(op.get(n-1).equals("?")){
                break;
            }
        }
        for(int i=0; i<n-1; i++){
            if(op.get(i).equals("+")){
                System.out.println(a.get(i)+b.get(i));
            }else if(op.get(i).equals("-")){
                System.out.println(a.get(i)-b.get(i));
            }else if(op.get(i).equals("*")){
                System.out.println(a.get(i)*b.get(i));
            }else if(op.get(i).equals("/")){
                System.out.println(a.get(i)/b.get(i));
            }
        }
    }
}

Measured memory_bytes: 26456
object Main extends App {
  var n = scala.io.StdIn.readInt()
  var s = scala.io.StdIn.readLine()
  var inputArray =  s.split(" ").map(_.toInt)
  var total = 0
  var active = 0

  for (i<-0 to n - 1) {
    if (active < inputArray(i)) {
      total += inputArray(i) - active
    }
    active = inputArray(i)
  }
  println(total)
}

Measured memory_bytes: 25300
fn ncd(x: i32) -> i32 {
    let mut num = 0;
    for i in 1..x + 1 {
        if x % i == 0 {
            num += 1;
        }
    }
    num
}

fn main() {
    let n: i32 = read_line();
    let mut ans = 0;
    for i in 1..n + 1 {
        if i % 2 == 1 && ncd(i) == 8 {
            ans += 1;
        }
    }

    println!("{}", ans);
}

fn read_line<T: std::str::FromStr>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P; //0:無色　1:赤 2:緑
int main(){
    vector<P> v;
    ll x,y; cin >> x >> y;
    ll a,b,c; cin >> a >> b >> c;
    for(ll i=0;i<a;i++){
        ll aa; cin >> aa;
        v.push_back(P(aa,1));
    }
    for(ll i=0;i<b;i++){
        ll aa; cin >> aa;
        v.push_back(P(aa,2));
    }
    for(ll i=0;i<c;i++){
        ll aa; cin >> aa;
        v.push_back(P(aa,0));
    }
    sort(v.begin(),v.end(), greater<P>());
    ll xc=0,yc=0,nc=0,ans=0;
    for(ll i=0;i<a+b+c;i++){
        if(xc>=x && v[i].second==1) continue;
        if(yc>=y && v[i].second==2) continue;
        if(xc+yc+nc>=x+y) break;
        if(v[i].second==1) xc++;
        else if (v[i].second==2) yc++;
        else nc++;
        ans+=v[i].first;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10604
n = gets # ignores
h = gets.chomp.split.map(&:to_i)

answer = 0
current = 0
h.each_cons(2) do |a, b|
  if a >= b
    current += 1
  else
    answer = [answer, current].max
    current = 0
  end
end
puts [answer, current].max


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

int n, a[101000], x;

int main()
{
	scanf("%d%d", &n, &x);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	std::sort(a + 1, a + n + 1);
	int ans = 0;
	for(int i = 1; i < n; i++)
	{
		if(x >= a[i]) x -= a[i], ans++;
	}
	if(x == a[n]) ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<cstdio>
using namespace std;
int K, A[100005];
long long eval(long long N){
    for(int i = 1;i <= K;i++) N =N - N % A[i];
    return N;
}
int main(){
    cin >> K;
    for(int i = 1;i <= K;i++) cin >> A[i];
    long long  l = 0, r = 1e18;
    while(l <= r){
        long long  mid = (l + r) / 2;
        if(eval(mid) >= 2) r = mid - 1;
        else l = mid + 1;
    }
    long long L = l;
    l = 0, r = 1e18;
    while(l <= r){
        long long  mid = (l + r) / 2;
        if(eval(mid) <= 2) l = mid + 1;
        else r = mid - 1;
    }
    long long R = r;
    if(L > R) puts("-1");
    else cout << L << ' '<< R << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    map<string , int> mp;
    int mx = 0;
    set<string> st;
    for(int i = 1; i <= n; i ++) {
        string s;
        cin >> s;
        mp[s] ++;
        if(mp[s] == mx) {
            st.insert(s);
        }
        if(mp[s] > mx) {
            mx = mp[s];
            st.clear();
            st.insert(s);
        }
    }
    for(auto to: st) {
        cout << to << '\n';
    }
    return 0;
}


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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define mod 1000000007
#define mmod 998244353
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define all(v) v.begin(),v.end()



int main() {
	string s;
	cin >> s;
	int ans = 0;
	rep(i, 0, 3) {
		if (s[i] == 'R') {
			ans++;
		}
	}
	if (ans == 2 && s[1] == 'S') {
		cout << 1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int a[200005];
long long b[200005];
int main()
{
	int n;
	long long cnt=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]+i<=200000)
			b[a[i]+i]++;
	}

	for(int i=n;i>=2;i--)
	{
		if(a[i]+i<=200000)
			b[a[i]+i]--;
		if(i-a[i]>=0)
			cnt+=b[i-a[i]];
	}
	cout<<cnt;
}

Measured memory_bytes: 5904
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
MOD = 10**9+7

N,W = imn()
wv = [iln() for _ in range(N)]

dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for sum_w in range(W+1):
        if wv[i][0] <= sum_w:
            dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w-wv[i][0]]+wv[i][1])
        dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
print(dp[N][W])

Measured memory_bytes: 181448
N = int(input())
S = input()

w_N = S.count(".")
ans = w_N
b = 0
w = 0

for i, s in enumerate(S):
    if s == "#":
        b += 1
    if s == ".":
        w += 1
    ans = min(ans,b + w_N - w)

print(ans)

Measured memory_bytes: 3500
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        City[] cities = new City[n];
        for (int i = 0; i < n; i++) {
            cities[i] = new City(i, sc.nextInt(), sc.nextInt());
        }
        Arrays.sort(cities, new Comparator<City>() {
            public int compare(City c1, City c2) {
                return c1.x - c2.x;
            }
        });
        PriorityQueue<Path> queue = new PriorityQueue<>();
        for (int i = 1; i < n; i++) {
            queue.add(new Path(cities[i].idx, cities[i - 1].idx, cities[i].x - cities[i - 1].x));
        }
        Arrays.sort(cities, new Comparator<City>() {
            public int compare(City c1, City c2) {
                return c1.y - c2.y;
            }
        });
        for (int i = 1; i < n; i++) {
            queue.add(new Path(cities[i].idx, cities[i - 1].idx, cities[i].y - cities[i - 1].y));
        }
        long total = 0;
        UnionFindTree uft = new UnionFindTree(n);
        while (queue.size() > 0) {
            Path p = queue.poll();
            if (uft.same(p)) {
                continue;
            }
            total += p.cost;
            uft.unite(p);
        }
        System.out.println(total);
    }
    
    static class UnionFindTree {
        int[] parents;
        
        public UnionFindTree(int size) {
            parents = new int[size];
            for (int i = 0; i < size; i++) {
                parents[i] = i;
            }
        }
        
        public int find(int x) {
            if (parents[x] == x) {
                return x;
            } else {
                return parents[x] = find(parents[x]);
            }
        }
        
        public boolean same (int x, int y) {
            return find(x) == find(y);
        }
        
        public boolean same (Path p) {
            return same(p.from, p.to);
        }
        
        public void unite(int x, int y) {
            int xx = find(x);
            int yy = find(y);
            if (xx == yy) {
                return;
            }
            parents[xx] = yy;
        }
        
        public void unite(Path p) {
            unite(p.from, p.to);
        }
    }
    
    static class Path implements Comparable<Path> {
        int from;
        int to;
        int cost;
        
        public Path (int from, int to, int cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }
        
        public int compareTo(Path another) {
            return cost - another.cost;
        }
    }
    
    static class City {
        int idx;
        int x;
        int y;
        
        public City(int idx, int x, int y) {
            this.idx = idx;
            this.x = x;
            this.y = y;
        }
    }
}

Measured memory_bytes: 99256
#define _CRT_SECURE_NO_DEPRECATE
#include<bits/stdc++.h>
#define Rint register int
#define MP make_pair
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii; // 注意必要时改类型
typedef vector<int> vi;
const int N = 1e5;
int n, k, h[N];
ll dp[N];
void Process() {
	cin >> n >> k;
	for (Rint i = 0; i < n; ++i)
		cin >> h[i];
	dp[0] = (ll)0;
	for (Rint i = 1; i < n; ++i) {
		ll min_val = 9e18;
		for (Rint j = 1; j <= k && i - j >= 0; ++j) {
			min_val = min(min_val, dp[i - j] + (ll)abs(h[i] - h[i - j]));
		}
		dp[i] = min_val;
	}

	cout << dp[n - 1] << endl;

}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef _DEBUG
	int tt = clock();
	freopen("in.txt", "r", stdin);
#endif 
	int Tcase = 1;
	// cin >> Tcase;
	while (Tcase--) {
		Process();
	}

#ifdef _DEBUG
	cerr << "\nTIME = " << clock() - tt << endl;
	tt = clock();
#endif
	return 0;
}

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

#define time_assert(x) if(!(x))while(true)

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n, d, a;
	cin >> n >> d >> a;
	vector<pair<int,int>> monsters;
	for(int i = 0; i < n; i++) {
		int x, h;
		cin >> x >> h;
		h = (h + a - 1) / a;
		monsters.emplace_back(x, h);
	}
	sort(monsters.begin(), monsters.end());
	time_assert((int) monsters.size() == n);
	
	vector<int> change(n + 1); // 0 .. n
	
	long long answer = 0;
	int running_sum = 0;
	for(int i = 0; i < n; i++) {
		running_sum += change[i];
		int my_health = monsters[i].second - running_sum;
		if(my_health <= 0) { // already killed
			continue;
		}
		// find the last monster still hit by a bomb starting here
		int low = i, high = n - 1;
		int ok = -1;
		while(low <= high) {
			int mid = (low + high) / 2;
			if(monsters[mid].first <= monsters[i].first + 2LL * d) {
				ok = mid;
				low = mid + 1;
			}
			else {
				high = mid - 1;
			}
		}
		time_assert(ok != -1);
		running_sum += my_health;
		change[ok+1] -= my_health;
		// add_interval(i, ok, -my_health);
		answer += my_health;
	}
	cout << answer << endl;
}

Measured memory_bytes: 2672
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	k := getNextInt(scanner)
	k--

	points := make(Points, n)
	for i := 0; i < n; i++ {
		x := getNextInt(scanner)
		y := getNextInt(scanner)
		points[i] = &Point{
			x: x,
			y: y,
		}
	}
	sort.Sort(points)

	ans := int64(0)

	for i := 0; i < n-k; i++ {
		for ii := i + k; ii < n; ii++ {
			yy := make([]int, 0)
			for iii := i; iii < ii+1; iii++ {
				yy = append(yy, points[iii].y)
			}
			sort.Ints(yy)
			min := int64(1) << 62
			for iii := 0; iii+k <= ii-i; iii++ {
				if min > int64(yy[iii+k])-int64(yy[iii]) {
					min = int64(yy[iii+k]) - int64(yy[iii])
				}
			}

			m := int64(points[ii].x-points[i].x) * int64(min)
			if ans == 0 || ans > m {
				ans = m
			}
		}
	}
	fmt.Fprintln(writer, ans)

	writer.Flush()
}

// Point ...
type Point struct {
	x, y int
}

// Points ...
type Points []*Point

func (a Points) Len() int           { return len(a) }
func (a Points) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Points) Less(i, j int) bool { return a[i].x < a[j].x }


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mod 1000000007
// #define mod 998244353
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0)
	{
		cout << "Zero" << endl;
		return 0;
	}
	if (a > 0)
	{
		cout << "Positive" << endl;
		return 0;
	}
	cout << ((b - a) % 2 ? "Positive" : "Negative") << endl;
	return 0;
}

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

int main() {
  int N,re=0;cin >> N;
  
  vector<string>  str(N);
  for (int i=0;i<N; i++ ){
    cin >> str.at(i);
  }
  set<string> str2(str.begin(), str.end());
  re = str2.size();
  cout << re << endl;

}


Measured memory_bytes: 25080
#include <stdio.h>

int main (void)
{
int n,i;
int a[n+1];

scanf("%d",&n);

for(i = 0;i<n;i++)
scanf("%d",&a[i]);

int max =a[0],min = a[0];

for(i = 0;i<n;i++)
{
max = (max> a[i]?max:a[i]);
min = (min <a[i]?min:a[i]);
}

printf("%d\n",max-min);

return 0;
}


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

class Main {
  public static void main(String[] args){
    int[] m = new int[10];
    input(m, 10);
    Arrays.sort(m);
    reverse(m);
    output(m, 3);
  }

  private static void reverse(int[] m){
    int n = m.length;
    for (int i = 0; i < n / 2; i++){
      int tmp = m[i];
      m[i] = m[n - i - 1];
      m[n - i - 1] = tmp;
    }
  }

  private static void output(int[] m, int n){
    for (int i = 0; i < n; i++){
      System.out.println(m[i]);
    }
  }

  private static void input(int[] m, int n){
    Scanner cin = new Scanner(System.in);
    for (int i = 0; i < n; i++){
      m[i] = cin.nextInt();
    }
  }
}

Measured memory_bytes: 26080
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>

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

using namespace std;

int n;
vector<vector<int> > neigh;

pair<int, int> Find_furthest(int start){
    vector<bool> is_visited(n, false);
    queue<int> indices, dist;
    is_visited[start] = true;
    indices.push(start);
    dist.push(0);
    int ans_i = -1, ans_dist = -1;
    while (!indices.empty()){
        int a = indices.front();
        if (dist.front() > ans_dist){
            ans_dist = dist.front();
            ans_i = a;
        }
        for (int b : neigh[a])
            if (!is_visited[b]){
                is_visited[b] = true;
                indices.push(b);
                dist.push(dist.front() + 1);
            }
        indices.pop();
        dist.pop();
    }
    return {ans_i, ans_dist};
}

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    cin >> n;
    neigh.resize(n);
    FOR (i, n - 1){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        neigh[a].push_back(b);
        neigh[b].push_back(a);
    }
    FOR (i, n)
        if (neigh[i].size() == 1){
            int max_dist = Find_furthest(Find_furthest(i).first).second;
            if (max_dist % 3 == 1)
                cout << "Second" << endl;
            else
                cout << "First" << endl;
            return 0;
        }
    cout << "First" << endl;
}


Measured memory_bytes: 13700
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
cur = [list(map(int, input().split())) for _ in range(M)]

def check(n):
    if len(str(n)) != N:
        return False
    ok = True
    for pos, val in cur:
        ok &= str(n)[pos - 1] == str(val)
    return ok

i = 0
for i in range(10 ** N):
    if check(i):
        print(i)
        exit()
print(-1)

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

using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    int test = 0;
    for(int i=0; i<n/2; i++){
      if(s[i]!=s[i+(n/2)]){
          test = 1;
          break;}
    }
    if(test==0 && n%2==0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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



int main() {
  ll A,B,C,K;
  cin>>A>>B>>C>>K;
  ll ans;
  if(K<=A)
  {
    ans=K;
  }
  if(A<K&&K<=A+B)
  {
    ans=A;
  }  
  if(A+B<K)
  {
    ans=2*A+B-K;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)
#define ll long long

int main()
{
    int n,m,x;
    cin >> n >> m >> x;
    int c[n],a[n][m];
    F(i,0,n){
        cin >> c[i];
        F(j,0,m){
            cin >> a[i][j];
        }
    }

    bool f=true;
    int ans=1000000000;
    F(bit,0,(1<<n)){
        int money=0,stat[m]={};
        F(i,0,n){
            if(bit & (1<<i)){
                money+=c[i];
                F(j,0,m){
                    stat[j] += a[i][j];
                }
            }
        }

        f=true;
        F(i,0,m) if(stat[i]<x) {f=false; break;}
        if(f && money<ans) ans = money;
    }

    if(f) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename T>
void read(T &x)
{
    x=0;char c=getchar();bool p=0;
    for(;c<'0'||c>'9';c=getchar())if(c=='-')p=1;
    for(;c>='0'&&c<='9';c=getchar())x=(x<<3)+(x<<1)+(c^48);
    if(p)x=-x;
}
const ll MOD=1000000000+7;
ll ksm(ll basic,ll mi)
{
    ll tmp=1;
    while(mi)
    {
        if(mi&1)tmp=tmp*basic%MOD;
        mi>>=1;
        basic=basic*basic%MOD;
    }
    return tmp;
}
ll f[4005][4005];
int a[200005],b[200005],n;
ll fac[8005],inv[8005];
ll C(ll x,ll y)
{
    return fac[x]*inv[y]%MOD*inv[x-y]%MOD;
}
int main()
{
    fac[0]=inv[0]=1;
    for(ll i=1;i<=8000;++i)fac[i]=fac[i-1]*i%MOD;
    inv[8000]=ksm(fac[8000],MOD-2);
    for(ll i=7999;i;--i)inv[i]=inv[i+1]*(i+1)%MOD;
    read(n);
    for(int i=1;i<=n;++i)
    {
        read(a[i]),read(b[i]);
        ++f[-a[i]+2000][-b[i]+2000];
    }
    for(int i=0;i<=4000;++i)
    {
        for(int j=0;j<=4000;++j)
        {
            if(i)f[i][j]=(f[i][j]+f[i-1][j])%MOD;
            if(j)f[i][j]=(f[i][j]+f[i][j-1])%MOD;
        }
    }
    ll ans=0;
    for(int i=1;i<=n;++i)
    {
         ans=(ans+f[a[i]+2000][b[i]+2000])%MOD;
    }
    for(int i=1;i<=n;++i)
    {
         ans=(ans-C(2*a[i]+2*b[i],2*a[i])+MOD)%MOD;
    }
    ans=ans*ksm(2,MOD-2)%MOD;
    printf("%lld\n",ans);
    return 0;
}
/*
C(a[i]+b[i]+a[j]+b[j],a[i]+a[j]):从(-a[i],-b[i]）走到(a[j],b[j])
*/

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

int main(void){
	string s, t;
	cin >> s >> t;
	int dp[s.size()+1][t.size()+1] = {};
	for(int i = 0; i < s.size(); ++i){
		for(int j = 0; j < t.size(); ++j){
			dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
			if(s[i] == t[j]){
				dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1);
			}
		}
	}
	int i = s.size(), j = t.size();
	string ans = "";
	while(i > 0 && j > 0){
		if(dp[i][j] == dp[i-1][j]){
			i--;
		}else if(dp[i][j] == dp[i][j-1]){
			j--;
		}else{
			ans = s[i-1] + ans;
			i--; j--;
		}
	}
	//cout << dp[s.size()][t.size()] << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35456
def main():
    N, K = (int(i) for i in input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    ans = 10**12
    for i in range(N-K+1):
        ans = min(ans, H[i+K-1] - H[i])

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7384
#include<iostream>
using namespace std;
int main()
{
	string s;
	getline(cin,s);
	for(int i=0;i<s.length();++i){
	
	if(i==0)
	{
		cout<<s[0];
		
	}
	if(s[i]==' ')
{
	cout<<s[i+1];
}

}
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    string s;
    cin >> s;
    sort(all(s));
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2])cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

const int N = 5e5+7, RT = 800;
int cnt[N], a[N], out[N], l[N], r[N];
int ans = 0;

void add(int x) {
    if (cnt[x] == 0)    ans++;
    cnt[x]++;
}

void rem(int x) {
    cnt[x]--;
    if (cnt[x] == 0)    ans--;
}


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

    int n, q;
    cin>>n>>q;

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

    vector<int> qq;
    for (int i=1; i<=q; i++) {
        cin>>l[i]>>r[i];
        qq.push_back(i);
    }

    sort(qq.begin(), qq.end(), [](auto a, auto b) {return l[a]/RT != l[b]/RT ? l[a] < l[b] : r[a] < r[b];});

    int cl = 1, cr = 0;

    for (int id: qq) {
        while (cr < r[id])  add(a[++cr]);
        while (cl > l[id])  add(a[--cl]);
        while (cr > r[id])  rem(a[cr--]);
        while (cl < l[id])  rem(a[cl++]);

        out[id] = ans;
    }

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


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

using namespace std;

int main(){
    int n; cin >> n;
    int ans;
    
    if(n < 3 * 5 * 7) ans = 0;
    else if(n < 3 * 3 * 3 * 5) ans = 1;
    else if(n < 3 * 5 * 11) ans = 2;
    else if(n < 3 * 3 * 3 * 7) ans = 3;
    else if(n < 3 * 5 * 13) ans = 4;
    else ans = 5;
    
    cout << ans << endl;
}

Measured memory_bytes: 256
a, b, c, d = (int(s_i) for s_i in input())
if a + b + c + d == 7:
    print("{}+{}+{}+{}=7".format(a, b, c, d))
elif a - b + c + d == 7:
    print("{}-{}+{}+{}=7".format(a, b, c, d))
elif a + b - c + d == 7:
    print("{}+{}-{}+{}=7".format(a, b, c, d))
elif a + b + c - d == 7:
    print("{}+{}+{}-{}=7".format(a, b, c, d))
elif a - b - c + d == 7:
    print("{}-{}-{}+{}=7".format(a, b, c, d))
elif a - b + c - d == 7:
    print("{}-{}+{}-{}=7".format(a, b, c, d))
elif a + b - c - d == 7:
    print("{}+{}-{}-{}=7".format(a, b, c, d))
else: print("{}-{}-{}-{}=7".format(a, b, c, d))

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#define MOD 1000000007
#define MAXN 100006
using namespace std;
int n;
long long ans,sum[30];
char s[MAXN];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
		sum[s[i]-'a']++;
	long long ans=1;
	for(int i=0;i<=25;i++)
		ans=(ans*(sum[i]+1))%MOD;
	printf("%lld",(ans+MOD-1)%MOD);
} 

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);

    int all = 0;
    for(auto a : A) all ^= a;

    for(int i=0; i<N; i++)
    {
        if(i!=N-1) cout << (all^A[i]) << ' ';
        else cout << (all^A[i]) << '\n';
    }

    return 0;
}


Measured memory_bytes: 3968
#include <iostream>
#include <vector>
#include <stack>
#include <cmath>
using namespace std;

#define ll long long

ll GCD(ll a, ll b)
{
	if (b == 0)
	{
		return a;
	}
	return GCD(b, a % b);
}

ll FindLCM(vector<ll> arr, int n)
{
	ll ans = arr[0];

	for (int i = 1; i < n; i++)
	{
		ans = (((arr[i] * ans)) / (GCD(arr[i], ans)));
	}
	return ans;
}

int main()
{
	int n, k;
	cin >> n >> k;

	vector<ll> arr;
	for (int i = 1; i <= n; i++)
	{
		int cnt = 0;
		int temp = i;
		while (temp < k)
		{
			cnt++;
			temp *= 2;
		}
		arr.push_back(n * pow(2, cnt));
	}

	ll lcm = FindLCM(arr, n);

	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		sum += lcm / arr[i];
	}

	printf("%.12f\n", (double)sum / lcm);
}





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

ll euq(ll, ll);

int main() {
    ll A, B, C, D, count=0, k=1;
    cin >> A >> B >> C >> D;

    ll lmc = (C * D) / euq(C, D);

    count += B/C + B/D - B/lmc;
    count -= (A-1)/C + (A-1)/D - (A-1)/lmc; 
    cout << (B-A+1) - count << endl;
}

ll euq(ll a, ll b) {
    if(b>a) return euq(b, a);
    ll r;
    while((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

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

int main(){
  int N;
  cin >> N;
  int ans = 0;
  if(N <= 104){
    cout << 0;
    return 0;
  }
  else{
    for(int i = 105; i <= N; i += 2){
      int c = 0;
      for(int j = 1; j <= i; j++){
        if(i % j == 0){
		  c++;          
        }
        if(c == 8){
          ans++;
        }
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
n = int(input())
m=0
a=0
r=0
c=0
h=0
answer = 0
for i in range(0,n):
    s = input()
    if s[0] == 'M':
        m = m+1
    elif s[0] == 'A':
        a = a+1
    elif s[0] == 'R':
        r = r+1
    elif s[0] == 'C':
        c = c+1
    elif s[0] == 'H':
        h = h+1

march = [m,a,r,c,h]
for i in range(0,5):
    for j in range(i+1,5):
        for k in range(j+1,5):
            answer = answer + march[i]*march[j]*march[k]
print(answer)


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

int main()
{
	long long A, B, C, D;
	cin >> A >> B >> C >> D;

	long long ans = B - A + 1;
	ans -= B / C - (A - 1) / C;
	ans -= B / D - (A - 1) / D;
	long long lcm = C / __gcd( C, D ) * D;
	ans += B / lcm - (A - 1) /lcm;

	cout << ans << endl;
}


Measured memory_bytes: 3640
def main():

    five_hundred = int(input())
    one_hundred = int(input())
    fifty = int(input())
    x = int(input())
    ans = 0
    for i in range(five_hundred + 1):
        for j in range(one_hundred + 1):
            for k in range(fifty + 1):
                if 500 * i + 100 * j + 50 * k == x:
                    ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9060
if __name__ == '__main__':
    # ??????????????\???
    game_count = int(input())
    deck_taro = [''] * game_count
    deck_hanako = [''] * game_count
    for i in range(game_count):
        data = [x for x in input().split(' ')]
        deck_taro[i] = data[0]
        deck_hanako[i] = data[1]

    # ?????????????????????????????¨?????°?¨????
    point_taro = 0
    point_hanako = 0
    for i in range(game_count):
        if deck_taro[i] < deck_hanako[i]:
            point_hanako += 3
        elif deck_taro[i] > deck_hanako[i]:
            point_taro += 3
        else:
            point_hanako += 1
            point_taro += 1

    # ???????????????
    print('{0} {1}'.format(point_taro, point_hanako))

Measured memory_bytes: 7692
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int DX[8]={-1,0,1,0,-1,-1,1,1},DY[8]={0,-1,0,1,-1,1,-1,1};


int main(){
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		ll n;
		cin>>n;
		int t=0;
		while(n>=10){
			auto s=to_string(n);
			ll mx=0,m=s.size();
			for(int i=1;i<m;i++){
				auto s1=s.substr(0,i),s2=s.substr(i,m-i);
				mx=max(mx,atoll(s1.c_str())*atoll(s2.c_str()));
			}
			n=mx;
			t++;
		}
		cout<<t<<endl;
	}
}


Measured memory_bytes: 3288
#include<stdio.h>
int main(void){
	int i, w, n, ans[31], a, b, tmp;
	for(i=0;i<31;i++){
		ans[i] = i;
	}
	scanf("%d", &w);
	scanf("%d", &n);
	for(i=0;i<n;i++){
		scanf("%d,%d", &a, &b);
		tmp = ans[a];
		ans[a] = ans[b];
		ans[b] = tmp;
	}
	for(i=1;i<w+1;i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 596
def main():
    from collections import deque
    H, W = (int(i) for i in input().split())
    Ch, Cw = (int(i)-1 for i in input().split())
    Dh, Dw = (int(i)-1 for i in input().split())
    A = [input() for i in range(H)]
    V = [[-1]*W for i in range(H)]  # 頂点i
    d = ((1, 0), (0, 1), (-1, 0), (0, -1))

    def bfs_2d(sy, sx, v):
        que = deque()
        V[sy][sx] = v
        que.append((sy, sx))
        while que:
            uh, uw = que.popleft()
            for dy, dx in d:
                next_h = uh + dy
                next_w = uw + dx
                if not(0 <= next_h < H and 0 <= next_w < W):
                    continue
                if V[next_h][next_w] != -1:
                    continue
                if A[next_h][next_w] == '#':
                    continue
                V[next_h][next_w] = v
                que.append((next_h, next_w))

    vertex = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#" or V[h][w] != -1:
                continue
            bfs_2d(h, w, vertex)
            vertex += 1

    G = [[] for _ in range(vertex)]
    used = [set() for _ in range(vertex)]
    for h in range(H):
        for w in range(W):
            if A[h][w] == "#":
                continue
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    if h + dh < 0 or H <= h + dh or w + dw < 0 or W <= w + dw:
                        continue
                    if A[h+dh][w+dw] == "#":
                        continue
                    if V[h][w] == V[h+dh][w+dw]:
                        continue
                    if V[h+dh][w+dw] in used[V[h][w]]:
                        continue
                    G[V[h][w]].append((V[h+dh][w+dw]))
                    used[V[h][w]].add((V[h+dh][w+dw]))

    # for h in range(H):
    #     print(V[h])

    # for i in range(vertex):
    #     print(G[i])

    s = V[Ch][Cw]
    g = V[Dh][Dw]
    que = deque([0])

    dist = [-1 for _ in range(vertex)]
    que = deque()
    dist[s] = 0
    que.append(s)
    while que:
        u = que.popleft()
        for v in G[u]:
            if dist[v] != -1:
                continue
            dist[v] = dist[u] + 1
            que.append(v)

    print(dist[g])


if __name__ == '__main__':
    main()


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

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
    ll a, x, b, y;
    cin >> a >> x >> b >> y;

    cout << max({x * y, a*b, a*y, b * x}) << endl;
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<set>
using namespace std;

int main()
{
	long long N, A, B;
	cin >> N >> A >> B;

	if (A == B) {
		printf("1\n");
	} else if (A > B) {
		printf("0\n");
	} else {
		if (N == 1) {
			printf("0\n");
		} else if (N == 2) {
			printf("1\n");
		} else {
			printf("%lld\n", (B - A) * (N - 2) + 1);
		}
	}

}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(){
	int a[4],b[4];
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
		for(int i=0;i<4;i++)	scanf("%d",&b[i]);
		int hit=0,blow=0;
		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(a[i]==b[j]){
					if(i==j)	hit++;
					else 	blow++;
				}
			}
		}
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

Measured memory_bytes: 2564
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
            }
            int diam = 0;
            for (int x : a) diam = Math.max(diam, x);
            boolean[] used = new boolean[n];
            outer:
            for (int i = 0; i <= diam; ++i) {
                int d = Math.max(i, diam - i);
                for (int j = 0; j < n; ++j)
                    if (!used[j] && a[j] == d) {
                        used[j] = true;
                        continue outer;
                    }
                out.println("Impossible");
                return;
            }
            for (int i = 0; i < n; ++i)
                if (!used[i] && a[i] < (diam + 1) / 2 + 1) {
                    out.println("Impossible");
                    return;
                }
            out.println("Possible");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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


int main()
{	
	int n,x;
	while(cin>>n>>x)
	{
		if(n==0&&x==0)break;
		int sum=0;
		for(int i=1;i<=n-2;i++)
		{
			for(int j=i+1;j<=n-1;j++)
			{
				for(int k=j+1;k<=n;k++)
				{
					if(i+j+k==x)sum++;
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;	
}


Measured memory_bytes: 3076
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int ans=0,x[100010],i,n,a[100010],b[100010],c[100010],sum[100010];
  scanf("%lld\n",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&a[i]);
  }
  scanf("\n");
  for(i=0;i<n;i++){
    scanf("%lld",&b[i]);
  }
  scanf("\n");
  for(i=0;i<n;i++){
    scanf("%lld",&c[i]);
  }
  scanf("\n");
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  for(i=0;i<n;i++){
    int min=-1,max=n,mid;
    while(abs(min-max)>1){
      mid=(min+max)/2;
      if(b[i]<c[mid]){
        max=mid;
      }
      else{
        min=mid;
      }
    }
    x[i]=n-min-1;
  }
  sum[0]=0;
  for(i=0;i<n;i++){
    sum[i+1]=sum[i]+x[i];
  }
  for(i=0;i<n;i++){
    int min=-1,max=n,mid;
    while(abs(min-max)>1){
      mid=(min+max)/2;
      if(a[i]<b[mid]){
        max=mid;
      }
      else{
        min=mid;
      }
    }
    ans=ans+sum[n]-sum[min+1];
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include <queue>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main(){
    int N;
    cin >> N;
    set<int> P;
    for(int i = 0; i < N; i++){
        int x;
        cin >> x;
        P.insert(x);
    }
    int ans = P.size();
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int ans=0,f=1;char chr=getchar();
	while(!isdigit(chr)){if(chr=='-')f=-1;chr=getchar();}
	while(isdigit(chr)) {ans=(ans<<3)+(ans<<1)+chr-48;chr=getchar();}
	return ans*f;
}const int M=1E3+5;
int a[M],s,n;
int main(){
	n=read();
	for(int i=1;i<=n-1;i++)a[i]=read();
	s+=a[1]+a[n-1];
	for(int i=2;i<=n-1;i++){
		s+=min(a[i-1],a[i]);
	}cout<<s<<endl;
	return 0;
}


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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

 bool IsPrime(ll num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0){
            return false;
        }
    }
    return true;
}

int main(){
    ll n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;

    char cnt[n];

    ll ans = 0;
    for(ll i = 0; i < t.size(); i++){
        cnt[i] = t[i];
        if(t[i] == 'r'){
            if(i >= k && cnt[i-k] == 'r'){
                cnt[i] = 'z';
            }else{
                ans += p;
            }
        }else if(t[i] == 's'){
            if(i >= k && cnt[i-k] == 's'){
                cnt[i] = 'z';
            }else{
                ans += r;
            }
        }else{
            if(i >= k && cnt[i-k] == 'p'){
                cnt[i] = 'z';
            }else{
                ans += s;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512