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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    int n = s.size();
    s += s;
    int n2 = s.size();
    vector<vector<int>> nxt(n2, vector<int>(26, n2));
    for(int i = n2 - 2; i >= 0; i--){
        nxt[i] = nxt[i+1];
        nxt[i][s[i+1] - 'a'] = i+1;
    }
    int m = t.size();
    int cur = 0;
    long long ans = 1;
    if(s[0] == t[0]) cur = 0;
    else if(nxt[0][t[0]-'a'] == n2){
        cout << -1 << endl;
        return 0;
    }
    else{
        ans += nxt[0][t[0]-'a'];
        cur = nxt[0][t[0]-'a'] % n;
    }
    for(int i = 1; i < m; i++){
        int nex = nxt[cur][t[i]-'a'];
        if(nex == n2){
            cout << -1 << endl;
            return 0;
        }
        ans += (nex - cur);
        nex %= n;
        cur = nex;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 27116
#include <stdio.h>

void sort(int a[]) {
  int i, j, t;
  for (i = 5; i > 1; i--)
    for (j = 0; j < i - 1; j++)
      if (a[j] < a[j+1]) {
	t = a[j];
	a[j] = a[j+1];
	a[j+1] = t;
      }
}

int main(void) {
  int a[5], i;

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

  sort(a);

  printf("%d", a[0]);
  for (i = 1; i < 5; i++)
    printf(" %d", a[i]);
  putchar('\n');

  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int q;
  cin>>q;
  while(q--){
    int x,y,X,Y;
    cin>>x>>y>>X>>Y;
    X+=x;
    Y+=y;

    int n,ans=0;
    cin>>n;
    while(n--){
      int a,b;
      cin>>a>>b;
      if(x<=a&&a<=X && y<=b&&b<=Y)ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int border=-1;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        border+=a[i];
    }
    border/=m*4;
    int x=0;
    for(int i=0;i<n;i++){
        if(a[i]>border)x++;
    }
    if(x>=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#define REP(i,n)   for(int i=0; i<(int)(n); ++i)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); ++i)

#define in cin
#define out cout
#define pb push_back
using namespace std;

int main(){
	int a, b ,c,d,e;
	in >> a >> b >> c >> d >> e;
	int f, g;
	f = b / d;
	g = c / e;
	if (b%d)f++;
	if (c%e)g++;
	a -= max(f, g);

	
	out << a << endl;
	return 0;

}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

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

	vll d(M + 1, 0);
	vll c(M + 1, 0);
	repn(i, M)cin >> d[i] >> c[i];

	ll dig = 0;
	repn(i, M)dig += c[i];
	ll s = 0;
	repn(i, M)s += d[i] * c[i];
	//cout << s << endl;
	ll ans = dig - 1 + (s + 8) / 9 - 1;
	cout << ans << endl;
}


Measured memory_bytes: 6420
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int A, B, C;
    std::cin >> A >> B >> C;

    std::cout << A*B/2 << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    int M;
    cin >> M;
    cout << 48 - M << endl;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

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

def lcm(a, b):
  return a*b//gcd(a,b)

E = lcm(C, D)

print(B-A+1 - B//C + (A-1)//C - B//D + (A-1)//D + B//E - (A-1)//E)

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
def pin(type=int):
    return map(type,input().split())
N,K =pin()
R,S,P =pin()
T, =pin(str)


#Tに勝つ手を列挙する 
winT = []
win = "rpsr"
for i in range(N):
    for j in range(3):
        if T[i] ==win[j]:
            winT.append(win[j+1])
#print(winT)

#K個前の手を使えない条件…？
#print(K,"個前を使えない")
#i番目に使った手をi+K番目に使えない.使ったら消す
for i in range (N-K):
    if winT[i] == winT[i+K]:
        winT[i+K] = "0"
        #print(i)
#print(winT)

ans=0
for i in range(N):
    if winT[i]=="p":
        ans+=P
    elif winT[i]=="r":
        ans+=R
    elif winT[i]=="s":
        ans+=S
print(ans)

Measured memory_bytes: 4212
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()

from collections import deque
class Dinic(object):
    def __init__(self,n):
        self.__n=n
        self.__E=[[] for _ in range(n)]
        self.__level=None
        self.__iter=None

    def add_link(self,u,v,w):
        self.__E[u].append([v,w,len(self.__E[v])])
        self.__E[v].append([u,0,len(self.__E[u])-1])

    def __bfs(self,s):
        level=[-1]*self.__n
        level[s]=0
        Q=deque([s])
        while(Q):
            v=Q.popleft()
            for nv,w,rev in self.__E[v]:
                if(w>0 and level[nv]<0):
                    level[nv]=level[v]+1
                    Q.append(nv)
        self.__level=level

    def __dfs(self,v,t,flow):
        if(v==t): return flow
        for i in range(self.__iter[v],len(self.__E[v])):
            self.__iter[v]=i
            nv,w,rev=self.__E[v][i]
            if(w==0 or self.__level[v]>=self.__level[nv]): continue
            d=self.__dfs(nv,t,min(flow,w))
            if(d==0): continue
            self.__E[v][i][1]-=d
            self.__E[nv][rev][1]+=d
            return d
        return 0

    def flow(self,s,t):
        flow=0
        while(True):
            self.__bfs(s)
            if(self.__level[t]<0): return flow
            self.__iter=[0]*self.__n
            current_flow=self.__dfs(s,t,INF)
            while(current_flow):
                flow+=current_flow
                current_flow=self.__dfs(s,t,INF)

def resolve():
    n=int(input())
    AB=[tuple(map(int,input().split())) for _ in range(n)]
    CD=[tuple(map(int,input().split())) for _ in range(n)]

    # bipartite の maximum matching で解く
    mf=Dinic(2*n+2)
    for i in range(n):
        mf.add_link(0,i+1,1)
        mf.add_link(n+i+1,2*n+1,1)
    for i in range(n):
        a,b=AB[i]
        for j in range(n):
            c,d=CD[j]
            if(a<c and b<d):
                mf.add_link(i+1,n+j+1,1)

    print(mf.flow(0,2*n+1))
resolve()

Measured memory_bytes: 44248
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import copy

n = ni()
g = [{} for _ in range(n)]

for i in range(n-1):
    a,b = na()
    a,b = a-1,b-1
    g[a][i] = b
    g[b][i] = a

dis = [float('inf')]*n
near = [-1]*n
gg = [copy.deepcopy(line) for line in g]

def dfs(v,start,depth):
    if dis[v] > depth:
        dis[v] = depth
        near[v] = start
    if not g[v]:
        return
    while g[v]:
        key,nv = g[v].popitem()
        g[nv].pop(key)
        dfs(nv,start,depth+1)

dfs(0,0,0)
g = gg
dfs(n-1,n-1,0)

print('Fennec' if 2*near.count(0) > n else 'Snuke')


Measured memory_bytes: 161676
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int y=sc.nextInt();
  		
		int ans=0;
		
  		for(int b=x;b>=0;b--){
        if((4*b+2*(x-b))==y){
        ans=1;
          break;
        }
        }
       
 	if(ans==1){
    		System.out.println("Yes");
    	}else{
     		System.out.println("No");
   	 }

    	
    }
}

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

int N;

int compress(vector<int> &ox, vector<int>& nx){
	vector<int> x;
	for(auto v : ox){
		x.push_back(v - 1);
		x.push_back(v);
		x.push_back(v + 1);
	}

	sort(x.begin(), x.end());
	x.erase(unique(x.begin(), x.end()), x.end());
	nx.resize(ox.size());
	for(int i = 0; i < ox.size(); i++){
		nx[i] = (lower_bound(x.begin(), x.end(), ox[i]) - x.begin());
	}
	return x.size();
}

int field[500][500];
int DX[] = {1, 0, -1, 0};
int DY[] = {0, 1, 0, -1};
int W;
int H;

void dfs(int x, int y){
	if(0 <= x && x < W && 0 <= y && y < H){
		if(field[y][x] != 0) return;
		field[y][x] = 2;
		for(int i = 0; i < 4; i++){
			dfs(x + DX[i], y + DY[i]);
		}
		return;
	}
}

int main(){
	vector<int> x, cx;
	vector<int> y, cy;

	while(cin >> N, N){
		x.clear();
		cx.clear();
		cy.clear();
		y.clear();

		for(int i = 0; i < N; i++){
			int l, t, r, b;
			cin >> l >> t >> r >> b;
			l *= 2;
			t *= 2;
			r *= 2;
			b *= 2;
			x.push_back(l);
			x.push_back(r);
			y.push_back(t);
			y.push_back(b);
		}

		W = compress(x, cx);
		H = compress(y, cy);
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				field[i][j] = 0;
			}
		}
		for(int i = 0; i < N; i++){
			int l = cx[i * 2];
			int r = cx[i * 2 + 1];
			int t = cy[i * 2];
			int b = cy[i * 2 + 1];
			for(int j = l; j <= r; j++){
				field[t][j] = 1;
				field[b][j] = 1;
			}
			for(int j = b; j <= t; j++){
				field[j][l] = 1;
				field[j][r] = 1;
			}
		}
		int ans = 0;
		for(int i = 0; i < H; i++){
			for(int j = 0; j < W; j++){
				if(field[i][j] == 0){
					dfs(j, i);
					ans++;
				}
			}
		}
		cout << ans << endl;
	}

}

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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

#define MAX_V 100005   // TODO

// Strong Connect Component  SCC 
// strong connect component scc
//vector<edge> es(MAX_E);
int V;
vector<int> G[MAX_V];
vector<int> rG[MAX_V];
vector<int> vs;
bool used[MAX_V];
int cmp[MAX_V], ab[MAX_V], cd[MAX_V], size[MAX_V];

void add_edge(int from, int to){
    G[from].push_back(to);
    rG[to].push_back(from);
    rG[from].push_back(to);
    G[to].push_back(from);
}

void dfs(int v){
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++){
        if (!used[G[v][i]])dfs(G[v][i]);
    }
    vs.push_back(v);
}

void rdfs(int v, int k){
    used[v] = true;
    cmp[v] = k;
    for (int i = 0; i < rG[v].size(); i++){
        if (!used[rG[v][i]])rdfs(rG[v][i], k);
    }
}
int scc(){
    memset(used, 0, sizeof(used));
    vs.clear();
    for (int v = 0; v < V; v++){
        if (!used[v])dfs(v);
    }
    memset(used, 0, sizeof(used));
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--){
        if (!used[vs[i]])rdfs(vs[i], k++);
    }
    return k;
}

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> MINUS(N);
    vector<int> A(M), B(M);
    vector<int> C(K), D(K);
    rep(i, M){
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
    }
    rep(i, K){
        cin >> C[i] >> D[i];
        C[i]--; D[i]--;
    }
    V = N;
    for (int i = 0; i < M; i++){
        add_edge(A[i], B[i]);
    }
    int n = scc();
    
    int u = 0, num = 0;
    for (int v = 0; v < V; v++){
        //fprintf(stderr, "v = %d, cmp[v] = %d\n", v + 1, cmp[v]);
        
        size[cmp[v]]++;
    }
    rep(i, M)if (cmp[A[i]] == cmp[B[i]])ab[cmp[A[i]]]++, MINUS[A[i]]++, MINUS[B[i]]++;
    rep(i, K)if (cmp[C[i]] == cmp[D[i]])cd[cmp[C[i]]]++, MINUS[C[i]]++, MINUS[D[i]]++;
    
    int ans = 0;
    rep(i, n){
        if (size[i] >= 2){
            ans += size[i] * (size[i] - 1)/2 - ab[i] - cd[i];
            //fprintf(stderr, "%d, %d, %d\n", size[i], ab[i], cd[i]);
        }
            
    }
    rep(v, V){
        int g = cmp[v];
        cout << size[g] - 1 - MINUS[v] << " ";
    }
    return 0;
}


Measured memory_bytes: 15472
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12
 
int main(){
    ll x,score;
    cin >> x;
    score= (x/500*1000) + ((x%500)/5*5);
    cout << score<<endl;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
R1='U'*dy+'R'*dx
R2='D'*dy+'L'*dx
R3='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
R4='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print(R1+R2+R3+R4)

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

int main(int argc, char const *argv[])
{
	double l; cin >> l;
	printf("%.12f\n", l * l * l / 27);
	return 0;
}


Measured memory_bytes: 256
def solve():
    n, x = map(int, input().split())
    L = list(map(int, input().split()))
    t = 0
    ans = 0
    for i in range(n):
        if t + L[i] > x:
            ans = i
            break
        t += L[i]
    else:
        ans = n
    return ans + 1
print(solve())


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,n,m,s,u;
	scanf("%d",&n);
	scanf("%d%d",&m,&s);
	for(i=0;i<n;i++)
	{
		scanf("%d",&u);
		s+=m/u+(m%u==0?0:1);
	}
	printf("%d",s);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef unsigned long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef pair<int, int> pint;
ll inf = 1000000000 + 7;




int main() {
	int H, W, h, w;


	cin >> H >> W >> h >> w;

	int ans = H * W - h * W - w*(H - h);

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

class Data{
	public:
	int y;
	int m;
	int d;
};

int getday(int y, int m, int d){
	int ret=0;
	
	for(int i=0;i<y;i++){
		if((i%4==0 && i%100 != 0) || i%400 == 0){
			ret += 366;
		}else{
			ret += 365;
		}
	}
	
	for(int i=1;i<m;i++){
		if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12){
			ret += 31;
		}else if(i==2){
			if((y%4==0 && y%100 != 0) || y%400 == 0){
				ret += 29;
			}else{
				ret += 28;
			}
		}else{
			ret += 30;
		}
	}
	ret += d;
	return ret;
}

int main(void){
	Data d1, d2;
	
	while(cin >> d1.y >> d1.m >> d1.d >> d2.y >> d2.m >> d2.d){
		if((d1.y|d1.m|d1.d|d2.y|d2.m|d2.d) & 1 << 31) break;
		
		cout << getday(d2.y,d2.m,d2.d) - getday(d1.y,d1.m,d1.d) << endl;;
	}
}

Measured memory_bytes: 0
N = int(input())
V = [int(i) for i in input().split()]
V_sort = sorted(V)

ans = 0
for i in range(len(V)-1):
    if i ==0:
        ans = (V_sort[i] + V_sort[i+1])/2
    else:
        ans = (ans + V_sort[i+1])/2
print(ans)

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

#define N 100100

int n, m, deg[N], vis[N];
vector <int> adj[N];
typedef pair <int, int> pii;
vector <pii> ans;

void dfs(int u, int pa = 0) {
    vis[u] = 1;
    for (auto v : adj[u]) {
        if (vis[v]) {
            if (v != pa && vis[v] == 1) {
                ans.emplace_back(pii(u, v));
                deg[u] ++;
            }
            continue;
        }
        dfs(v, u);
    }
    if (pa) {
        if (deg[u] & 1) ans.emplace_back(pii(u, pa)), deg[u] ++;
        else ans.emplace_back(pii(pa, u)), deg[pa] ++;
    }
    vis[u] = 2;
}

int main() {
    scanf("%d %d", &n, &m);
    while (m --) {
        int u, v;
        scanf("%d %d", &u, &v);
        adj[u].push_back(v), adj[v].push_back(u);
    }
    for (int i = 1; i <= n; i ++) if (!vis[i]) {
        dfs(i); if (deg[i] & 1) return puts("-1"), 0;
    }
    for (auto p : ans) printf("%d %d\n", p.first, p.second);

    return 0;
}


Measured memory_bytes: 14836
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#include <assert.h>
#include <numeric>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)(1e5)
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){fast;
	ll n,i,d=1,c=0;cin>>n;vi v(n);for(i=0;i<n;i++) cin>>v[i];
	sort(all(v));int f=n-1;for(i=1;i<n;i++){
		if(d%2==0) f--;
		c+=v[f];d++;
	}cout<<c<<endl;
}


Measured memory_bytes: 4768
//file_name:ABC64_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    int b[9] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
        a[i] /= 400;
        if(a[i]>8)a[i]=8;
        b[a[i]]++;
    }
    
    


    ll ans = 0;

    rep(i,8){
        if(b[i]!=0)ans++;
    }
    if(ans==0){
        ans = 1;
        b[8]--;
    }

    cout << ans << ' ' << ans+b[8] <<  endl;
    return 0;
}



Measured memory_bytes: 256
def dfs(i, d, f, time, adj)
  time += 1
  d[i-1] = time
  
  adj[i-1].each do |j|
    time = dfs(j, d , f, time, adj) if d[j-1] == 0
  end
  
  time += 1
  f[i-1] = time
  return time
end

n = gets.to_i
adj = Array.new(n){ Array.new(3) }
n.times do
  u, k, *a = gets.split.map(&:to_i)
  adj[u-1] = a
end

d = Array.new(n, 0);
f = Array.new(n, 0);

time = 0
n.times do |i|
  time = dfs(i+1, d, f, time, adj) if d[i] == 0
end

(1..n).each do |i|
  puts "#{i} #{d[i-1]} #{f[i-1]}"
end

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

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


int main(){

	int N,T;
  	cin >> N >> T;
  	int best = INT_MAX;
  	
  	rep(i,N){
    
    	int ci,ti;
      	cin >> ci >> ti;
      
      	if(ti <= T)best = min(best,ci);
   
    }
	
  	if(best == INT_MAX){
    
      	cout <<"TLE"<<endl;
      
    }else{
    
    	cout << best <<endl;
    
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int find(int i,vector<int>&p,vector<int>&q){
	if(q[i]==i){
		return q[i];
	}else{
		return q[i] = find(p[i],p,q);
	}
}


int main(){
	int n,Q;
	while(cin >> n >> Q&&n!=0){
		vector<int>p(n);
		vector<int>q(n);
		ll ans = 0;
		for(int i=0;i<n;i++){
			q[i] = 0;
		}
		for(int i=1;i<n;i++){
			int t;
			cin >>t;
			t--;
			p[i] = t;
		}
		for(int i=0;i<Q;i++){
			char z;
			int k;
			cin >> z >> k;
			k--;
			if(z=='M'){
				q[k]=k;
			}else{
				ans += (ll)find(k,p,q);
				ans++;
			}
		}
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 4348
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll ct[11];
  ct[0]=0;
	ll p3=1;
	for(int i=1; i<=10; i++){
		p3*=3;
		ct[i]=ct[i-1]+p3-3*(1ll<<i)+3;
	}
	ll n;
	cin>>n;
	if(n<357){
		cout<<0<<endl;
		return 0;
	}
	int d=0;
	int n0=n;
	while(n0>0){
		n0/=10;
		d++;
	}
	ll ans=ct[d-1];
	ll a[10];
	for(int i=3; i<=8; i++){
		a[i]=i;
		for(int j=0; j<d-1; j++){
			a[i]*=10;
		}
	}
	if(a[3]>=n){
		cout<<ans<<endl;
		return 0;
	}
	for(int i=a[3]+1; i<=min(a[4], n); i+=2){
			int i0=i;
			int c3=0, c5=0, c7=0;
			bool ok=1;
			while(i0>0){
				if(i0%10==3) c3++;
				else if(i0%10==5) c5++;
				else if(i0%10==7) c7++;
				else{
					ok=0;
					break;
				}
				i0/=10;
			}
			if(ok && c3 && c5 && c7) ans++;
	}
	if(a[5]>=n){
		cout<<ans<<endl;
		return 0;
	}
	for(int i=a[5]+1; i<=min(a[6], n); i+=2){
			int i0=i;
			int c3=0, c5=0, c7=0;
			bool ok=1;
			while(i0>0){
				if(i0%10==3) c3++;
				else if(i0%10==5) c5++;
				else if(i0%10==7) c7++;
				else{
					ok=0;
					break;
				}
				i0/=10;
			}
			if(ok && c3 && c5 && c7) ans++;
	}
	if(a[7]>=n){
		cout<<ans<<endl;
		return 0;
	}
	for(int i=a[7]+1; i<=min(a[8], n); i+=2){
			int i0=i;
			int c3=0, c5=0, c7=0;
			bool ok=1;
			while(i0>0){
				if(i0%10==3) c3++;
				else if(i0%10==5) c5++;
				else if(i0%10==7) c7++;
				else{
					ok=0;
					break;
				}
				i0/=10;
			}
			if(ok && c3 && c5 && c7) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [float('inf') for _ in range(len(h))]
dp[0] = 0

for i in range(len(dp)):
    for j in range(max(i - K, 0), i):
        dp[i] = min(dp[i], dp[j] + abs(h[j] - h[i]))

print(dp[-1])


Measured memory_bytes: 56672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 10;

int main() {
    int n;
    cin >> n;
    typedef pair<int, int> pa;
    vector<pa> v;
    for(int i = 1, x; i <= n; i++) {
        cin >> x;
        v.push_back(pa(x, i));
    }
    sort(v.begin(), v.end());
    multiset<int> st;
    st.insert(0);
    st.insert(0);
    st.insert(n+1);
    st.insert(n+1);
    ll ans = 0;
    for(int i = n-1; i >= 0; i--) {
        auto it = st.lower_bound(v[i].second);
        auto nxt = next(it), pre0 = prev(it);
        auto pre1 = prev(pre0);
        ans += 1LL*(*pre0 - *pre1)*(*it - v[i].second)*v[i].first;
        ans += 1LL*(*nxt - *it)*(v[i].second-*pre0)*v[i].first;
        st.insert(v[i].second);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5748
#include<stdio.h>
#define N 250
int parent(int);
int left(int);
int right(int);
void maxHeapify(int*,int);

int x[N];
int n;
int main(){

  int i;

  scanf("%d",&n);
  
  for(i=1; i<=n; i++){
    scanf("%d",&x[i]);
  }

  for(i=1; i<=n; i++){
    printf("node %d: key = %d, ",i,x[i]);
    if(i!=1) printf("parent key = %d, ",x[parent(i)]);
    if(n>=left(i)) printf("left key = %d, ",x[left(i)]);
    if(n>=right(i)) printf("right key = %d, ",x[right(i)]);
    printf("\n");
  }
  
  
  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

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

using ll = long long;

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))
#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) ((x) / (y))
#define DIVROUND(x, y) (MOD(x, y) * 2 >= (y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

int main() {
  int K, S;

  cin >> K >> S;

  ll ans{};
  for (int i{}; i <= MIN(K, S); ++i) {
    for (int j{}; j <= MIN(K, S-i); ++j) {
      if (S - i - j <= K)
        ++ans;
    }
  }

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


Measured memory_bytes: 256
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
   
//#include <x86intrin.h>
#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;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)1e6 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int x, y, ans, fact[N];

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   return a;
}

inline int mult (int a, int b) {
   return 1ll * a * b % mod;
}

inline int binpow (int a, int b) {
   int res = 1;
   while (b) {
      if (b & 1) res = mult (res, a);
      a = mult (a, a);
      b >>= 1;
   }
   return res;
}

inline int C (int n, int k) {
   return mult (fact[n], binpow (mult (fact[k], fact[n - k]), mod - 2));
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> x >> y;
   fact[0] = 1;
   for (int i = 1; i <= 1000000; i ++) fact[i] = mult (fact[i - 1], i);
   for (int i = 0; i <= x; i ++) {
      int new_x = x - i, new_y = y - i * 2;
      if (new_x < 0 || new_y < 0) continue;
      if ((new_x & 1) || new_x / 2 != new_y) continue;
      ans = add (ans, C (i + new_y, i));
   }
   cout << ans;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 4224
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

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

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

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    Combination comb(n+1);
    for(int i = 1; i <= k; ++i){
        mint ans = comb(n-k+1, i) * comb(k-1, i-1);
        cout << ans.x << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ins insert
#define F first
#define S second
#define var auto
using namespace std;
typedef long long ll;
const int Max = 1e5 + 10;
const int Log = 20;
const int Mod = 1e9 + 7;
const ll INF = 1e18;

vector<int> N[Max];

bool white[Max];
int child[Max];
bool seen[Max];
int par[Max];
int h[Max];

void DFS(int v)
{
	seen[v] = true;
	for(var u : N[v])
		if(!seen[u])
		{
			par[u] = v;
			h[u] = h[v] - 1;
			DFS(u);
			child[v]++;
		}
}

bool erased[Max];

int main()
{
	int n;cin >> n;
	for(int i = 0; i < n - 1; i++)
	{
		int a , b;cin >> a >> b;
		N[a].pb(b);
		N[b].pb(a);
	}
	if(n == 2)
	{
		cout << "Second\n";
		return 0;
	}

	set<pair<int,int> > leafs;

	int root = -1;
	for(int i = 1; i <= n ; i++)
		if(N[i].size() >= 2)
			root = i;

	DFS(root);

	for(int i = 1; i <= n ; i++)
		if(N[i].size() == 1)
			leafs.ins({h[i] , i});

	bool win = false;
	while(leafs.size())
	{
		if(n == 2)
			break;
		if(n == 1)
		{
			win = true;
			break;
		}

		var v = *leafs.begin();
		//cout << v.S << '\n';
		leafs.erase(leafs.begin());
		var p = par[v.S];
		if(child[p] >= 2)
		{
			win = true;
			break;
		}
		var pp = par[p];

		if(pp)
		{
			child[pp]--;
			if(child[pp] == 0)
				leafs.ins({h[pp] , pp});
		}
		n -= 2;
	}
	if(win)
		cout << "First\n";
	else
		cout << "Second\n";
}



Measured memory_bytes: 12832
object Main extends App {
  val s = new java.util.Scanner(System.in)
  def f = { val n = s.nextInt; Iterator.continually(s.next).take(n) }
  val a = f.foldLeft(Map.empty[String, Int].withDefaultValue(0))((l, r) => l.updated(r, 1 + l(r)))
  val b = f.foldLeft(a)((l, r) => l.updated(r, l(r) - 1))
  val x = b.values.max
  println(if (x < 0) 0 else x)
}

Measured memory_bytes: 27204
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>


using namespace std;

int main()
{
    char c;
    cin >> c;

    int code1 = (int)c;
    code1 ++ ;

    c = (char)code1;

    cout << c << endl;

    return 0;
    

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define init(a,x) memset(a,x,sizeof(a))

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll n; cin>>n; vll v(n); forA(i,0,n,1)cin>>v[i];
	vll prefix(n); prefix[0]=v[0]; forA(i,1,n,1)prefix[i]=prefix[i-1]+v[i];
	ll ans=0;
	forA(i,0,n-1,1)
	{
		ll x = prefix[n-1]-prefix[i];
		ll temp = ((x%mod)*(v[i]%mod))%mod;
		ans = (ans+temp)%mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6292
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

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

struct edge {
  i64 from, to, cost;
  edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
  edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int d;
	cin >> d;
	string s = "Christmas";
	for(int i = 0; i < 25 - d; ++i) s += " Eve";
	cout << s << endl;
}

Measured memory_bytes: 896
using System.Collections.Generic;
using System.Linq;
using System;

public class P
{
    public int v { get; set; }
    public int w { get; set; }
    public string t { get; set; }
    public long d { get; set; }
    public string s { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var ps = new List<P>();
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var v = int.Parse(line[0]);
            var w = int.Parse(line[1]);
            var d = long.Parse(line[3]);
            ps.Add(new P { v = v, w = w, t = line[2], d = d, s = line[4] });
        }
        foreach (var x in ps.OrderBy(y =>y.v).ThenBy(y =>y.w).ThenBy(y =>y.t).ThenBy(y =>y.d).ThenBy(y =>y.s))
            Console.WriteLine("{0} {1} {2} {3} {4}",x.v,x.w,x.t,x.d,x.s);
    }
}




Measured memory_bytes: 47784
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) begin(x), end(x)
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
typedef pair <int,int> P;

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  
  cout<<max(max(a*c,a*d),max(b*c,b*d))<<endl;
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<pair<ll, ll>>> vvpll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, p;
    cin >> a >> p;
    out((3*a + p)/2);
    re0;
}

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

signed main() {
  int n,k,q;cin>>n>>k>>q;
  vector<int> score(n,k-q);
  for(int i=0;i<q;++i){
    int a;cin>>a;
    --a;
    score[a] += 1;
  }

  for(int i=0;i<n;++i){
    cout<< ((score[i] > 0) ? "Yes" : "No") <<endl;
    //cerr<<score[i]<<endl;
  }

  
  
  return 0;
}


Measured memory_bytes: 1408
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	if(b/a > c) System.out.println(c);
      	else System.out.println(b/a);
    }
}

Measured memory_bytes: 35536
#include<iostream>
using namespace std;
int main(){
	long long n;
	cin >> n;
	int A[100];
	for (int i = 0; i < n; i++) cin >> A[i];
	int m=0, k=1000000001;
	for (int i = 0; i < n; i++) {
		if (m < A[i]) m = A[i];
		if (k > A[i]) k = A[i];
	}
	cout << m - k;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var nk = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var v = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int n = nk[0];
        int k = nk[1];
        var ansList = new List<int>();
        ansList.Add(0);
        for (int i = k; i >= k / 2; i--)
        {
            for (int j = 0; j <= i; j++)
            {
                var jewel = new List<int>();
                for (int l = 0; l < n; l++)
                {
                    if (l < j || n - i + j<= l) jewel.Add(v[l]);
                }
                jewel = jewel.OrderBy(f => f).ToList();
                for (int l = 0; l < k - i; l++)
                {
                    if (jewel.Any() && jewel[0] < 0) jewel.RemoveAt(0);
                    else break;
                }
                ansList.Add(jewel.Sum());
            }
        }
        Console.WriteLine(ansList.Max());
    }
}

Measured memory_bytes: 15400
package main

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

func main() {
	strs := readStdin()

	if len(strs) != 2 {
		fmt.Fprintf(os.Stderr, "Wrong number of arguments.")
		os.Exit(1)
	}

	a, _ := strconv.Atoi(strs[0])
	b, _ := strconv.Atoi(strs[1])

	if a&b&1 == 1 {
		fmt.Printf("Odd")
	} else {
		fmt.Printf("Even")
	}
}

func readStdin() []string {
	scanner := bufio.NewScanner(os.Stdin)
	if !scanner.Scan() {
		fmt.Fprintf(os.Stderr, "No stdin passed.")
		os.Exit(1)
	}

	return strings.Split(scanner.Text(), " ")
}


Measured memory_bytes: 640
#coding:utf-8
n = input()
Ss = []
Scount = []
for i in xrange(n):
    S = raw_input()
    Ss.append(list(S))
    Scount.append(len(S))

#最小文字数のインデックスは？
min_index = Scount.index(min(Scount))
s = Ss[min_index]
Ss.pop(min_index)

memo = []


s = list(s)

for i in xrange(len(s)):
    check = []
    for j in xrange(len(Ss)):
        if s[i] in Ss[j]:
            check.append(str(1))
        else:
            check.append(str(-1))
    if "-1" in check:
        continue
    else:
        memo.append(s[i])
        for k in xrange(len(Ss)):
            Ss[k].pop(Ss[k].index(s[i]))

memo.sort()

answer = ""
for i in xrange(len(memo)):
    answer += memo[i]

print answer


Measured memory_bytes: 2696
fn getline() -> String {
    let mut __ret = String::new();
    std::io::stdin().read_line(&mut __ret).ok();
    return __ret;
}

fn main() {
    let s1 = getline();
    let a: i32 = s1.trim().parse().unwrap();

    let s2 = getline();
    let b: i32 = s2.trim().parse().unwrap();

    let s3 = getline();
    let h: i32 = s3.trim().parse().unwrap();

    println!("{}", (a + b) * h / 2);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main()
{
	int sequence[20], points[19], dishes, i, temp, ans = 0;
	
	scanf("%d", &dishes);
	for(i = 0; i < dishes; i++)
		scanf("%d", &sequence[i]);
	
	for(i = 0; i < dishes; i++) {
		scanf("%d", &temp);
		ans = ans + temp;
	}
	
	for(i = 0; i < dishes - 1; i++)
		scanf("%d", &points[i]);	
	
	for(i = 0; i < dishes - 1; i++){
		if (sequence[i + 1] == (sequence[i] + 1))
			ans = ans + points[sequence[i] - 1];
	}
	
	printf("%d\n", ans);	
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;

const int maxn=1000005;
long long c[maxn];
long long p[maxn], m;
void divide(long long n)
{
    m = 0;
    for(int i = 2; i <= sqrt(n)*10; i++)
	{
        if(n % i == 0)
		{
            p[++m] = i, c[m] = 0;
            while(n % i == 0)
			{
                n /= i, c[m]++;
            }
        }
    }
    if(n > 1)
	{
        p[++m]=n, c[m] = 1;
    }
}

long long ans=1;

long long val,mmm;

long long qm(long long a,long long b)
{
	long long qwe=1;
	while(b)
	{
		if(b&1)
		qwe=qwe*a;
		a=a*a;
		b>>=1;
	}
	return qwe;
}

int main()
{
	scanf("%lld%lld",&mmm,&val);
	divide(val);
	for(int i=1;i<=m;i++)
	{
	    long long k=c[i]/mmm;
		if(k!=0)
		{
		   long long rbq=qm(p[i],k);
		   ans *= rbq;
		}
	}
	printf("%lld",ans);
}

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

int main(void)
{
    ll n, x, ans;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ans = abs(x-a[0]);
    rep(i,n){
        ans = __gcd(ans, abs(x-a[i]));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3896
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}


int U[2010][2010],D[2010][2010],L[2010][2010],R[2010][2010];
char c[2010][2010];


main() {
    int H,W; cin >> H >> W;
    rep(i,H) rep(j,W) cin >> c[i][j];
    rep(i,H){
        rep(j,W){
            if(!i) {if(c[i][j]=='#') U[i][j]=0; else U[i][j]=1;} 
            if(!j) {if(c[i][j]=='#') L[i][j]=0; else L[i][j]=1;}
            if(i) {
                if(c[i][j]=='#') U[i][j]=0; else U[i][j]=U[i-1][j]+1;
            }
            if(j){
                if(c[i][j]=='#') L[i][j]=0; else L[i][j]=L[i][j-1]+1;
            }
        }
    }
    for(int i=H-1;i>=0;i--){
        for(int j=W-1;j>=0;j--){
            if(i==H-1) {if(c[i][j]=='#') D[i][j]=0; else D[i][j]=1;} 
            if(j==W-1) {if(c[i][j]=='#') R[i][j]=0; else R[i][j]=1;}
            if(i!=H-1){
                if(c[i][j]=='#') D[i][j]=0; else D[i][j]=D[i+1][j]+1;
            }
            if(j!=W-1){
                if(c[i][j]=='#') R[i][j]=0; else R[i][j]=R[i][j+1]+1;
            }
        }
    }
    int ans=0;
    rep(i,H){
        rep(j,W){
            int pos;
            if(c[i][j]=='#') pos=0;
            else pos = D[i][j]+U[i][j]+R[i][j]+L[i][j]-3;
            ans=max(ans,pos);
        }
    }
    cout << ans << endl;

    return 0;
}   

Measured memory_bytes: 130304
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main()
{
  string s;
  cin >> s;
  s[0] = '2';
  s[1] = '0';
  s[2] = '1';
  s[3] = '8';
  cout << s;
  return 0;
}


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

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 200010;
const int INF = 2147483600;

int N; int Node[MAXN<<1],Next[MAXN<<1],Root[MAXN+1],cnt;
inline void insert(int u,int v){ Node[++cnt]=v; Next[cnt]=Root[u]; Root[u]=cnt; }
int ans[MAXN+1],s[MAXN+1],mx[MAXN+1];
int fa[MAXN+1]; int s2[MAXN+1];

int dep[MAXN+1];
inline void Upd(int &A,int B){
	if(dep[A]<dep[B]) A=B;
}
inline void dfs(int k,int Fa,int C,int C2,int bns){
	mx[k]=max(mx[Fa],k); fa[k]=Fa;
	int T=mx[k],p=s[T]; s[k]++;  dep[k]=dep[Fa]+1; 
	if(k<mx[fa[mx[k]]]||k==mx[k]) Upd(C,fa[mx[k]]),Upd(C2,mx[k]);
	else Upd(C,mx[k]),Upd(C2,bns); s[C]--; if(dep[C2]<=dep[k]) s2[C2]--,s2[k]++;
	for(int x=Root[k];x;x=Next[x]){
		int v=Node[x]; if(v==Fa) continue; dfs(v,k,C,C2,(mx[k]==k?v:bns));
		s[k]+=s[v]; s2[k]+=s2[v];
	} ans[k]=s[k];
}
inline bool Y(int x){ return mx[x]==x; }
inline void dfs2(int k,int Fa){
	//ans[k]+=ans[k];
	//if(Y(k)&&!Y(Fa)) ++ans[k]; 
	ans[k]-=s2[k];
	//cout<<k<<": "<<ans[k]<<" "<<s[k]<<" "<<s2[k]<<endl;
	ans[k]+=ans[Fa];
	for(int x=Root[k];x;x=Next[x]){
		int v=Node[x]; if(v==Fa) continue;
		dfs2(v,k);
	}
}

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	N=read();
	for(int i=1;i<N;i++){
		int u=read(),v=read();
		insert(u,v); insert(v,u);
	} dfs(1,0,0,0,0); dfs2(1,0); 
	for(int i=2;i<=N;i++) printf("%d ",ans[i]-1);
	return 0;
}




Measured memory_bytes: 21632