akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )
#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = (c).begin(); it != (c).end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define PB( n ) push_back( ( n ) )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define fst first
#define snd second

const double p500[] = { 70, 55, 50, 43, 40, 37.5, 35.5 };
const double p1000[] = { 148, 116, 105, 89, 83, 77, 71 };
const string rank[] = {	"NA", "E", "D", "C", "B", "A",	"AA", "AAA" };

struct Team
{
	string name;
	int point;

	Team( string name, int point )
	{
		this -> name = name;
		this -> point = point;

		return;
	}

	bool operator < ( const Team &a ) const
	{
		return point > a.point;
	}
};

int main()
{
	bool first = true;

	while ( true )
	{
		int n;
		cin >> n;

		if ( n == 0 )
		{
			break;
		}

		if ( first )
		{
			first = false;
		}
		else
		{
			cout << endl;
		}

		vector<Team> teams;

		REP( i, 0, n )
		{
			string name;
			int a, b, c;

			cin >> name >> a >> b >> c;

			teams.PB( Team( name, a * 3 + c ) );
		}

		stable_sort( ALL( teams ) );

		REP( i, 0, n )
		{
			cout << teams[i].name << ',' << teams[i].point << endl;
		}
	}

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  string ans = "No";
  for(int i = 0 ; i < s.size() - 1 ; i++){
    if(s.substr(i, 2) == "AC"){
      ans = "Yes";
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/*
https://qiita.com/ageprocpp/items/4904faa76b2edee2dccf#e%E5%95%8F%E9%A1%8C
https://note.com/tanon_cp/n/ncff944647054#XYX7K
https://drken1215.hatenablog.com/entry/2018/06/08/210000
勉強させていただいた記事
*/

#include <bits/stdc++.h>

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
    int N,K;
    cin>>N>>K;
    ll res=0;
    COMinit();
    rep(i,min(N,K+1)){
        res=(res+COM(N-1,i)*COM(N,i))%INF;
    }
    cout<<res<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
//2^15なら大丈夫そう

int C[15];
    vector<pair<int, int> > V[15];
int solve(int a,int A[],int n){
    int c,d;
    if(a<=n-1){
        A[a]=0;
        c=solve(a+1,A,n);
        A[a]=1;
        d=solve(a+1,A,n);
        return max(c,d);
    }
    else{
        bool x;
        int z;
        REP(i,n){
            if(A[i]==1) C[i]=1;
            else C[i]=0;
        }
        REP(i,n){
            bool x=true;
            REP(j,V[i].size()){
                z=V[i][j].first;
                if(C[z]!=V[i][j].second) x=false;
            }
            if((A[i]==1 && x==false)||(A[i]==0 && x==true)) return 0;
        }
        int ans =0;
        REP(i,n){
            if(C[i]==1) ans++;
        }
        return ans;
    }
}
int main(){
    int n,a,x,y,ans,A[15];
    cin>>n;
    REP(i,15) C[i]=A[i]=0;
    REP(i,n){
        cin>>a;
        REP(j,a){
            cin>>x>>y;
            V[i].push_back(make_pair(x-1,y));
        }
    }
    ans=solve(0,A,n);
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
#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 N, K;
	cin >> N >> K;

	ll M = N * K;
	vvmint dp(N + 2, vmint(M + 1, 0));

	dp[N + 1][0] = 1;

	for (ll i = N; i >= 1; i--) {
		rep(j, M+1) {

			ll x = j / i;

			if (j + x + 1 > M) { continue; }

			ll r = (x + 1) * i - j - 1;

			
			ll c = min(r, K) + 1;
			ll d = min(i, K) + 1 - c;
			ll e = K + 1 - c - d;

			//cout << i << " " << j << " " << c << " " << d <<" "<<e<< endl;


			dp[i][j + x] += dp[i + 1][j] * c;

			dp[i][j + x+1] += dp[i + 1][j] * d;

			dp[i][j] += dp[i + 1][j] * e;
		}
	}

	//repn(i, N)rep(j, M + 1)cout << i << " " << j << " " << dp[i][j] << endl;

	mint sousa = 0;
	rep(i, M + 1) sousa += dp[1][i] * i;

	mint ans = pw(K + 1, N) * K * N / 2;
	ans -= sousa;

	cout << ans << endl;
}

Measured memory_bytes: 8320
import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
import collections
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29

def main():
    s = collections.deque(list(input()))
    q = int(input())
    count = 0
    for i in range(q):
        tfc = list(input().split())
        if tfc[0]=='1':
            count = abs(count - 1)
        else:
            t,f,c = tfc
            if count:
                if f=='1':
                    s.append(c)
                else:
                    s.appendleft(c)
            else:
                if f=='1':
                    s.appendleft(c)
                else:
                    s.append(c)
    if count:
        t = []
        for i in range(len(s)):
            t.append(s.pop())
        print(''.join(t))
    else:
        print(''.join(s))
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 93160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N;
    cin >> N;
    int L[N];
    rep(i, N) cin >> L[i];
    int ans = 0;
    rep2(i, 0, N-1){
        rep2(j, i+1, N-1){
            rep2(k, j+1, N-1){
                int v[] = {L[i], L[j], L[k]};
                sort(v, v+3);
                if(v[0] != v[1] && v[1] != v[2] && v[0]+v[1] > v[2]) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int w_point[2001][2001] = {};
int h_point[2001][2001] = {};
bool G[2001][2001] = {};
int H, W;

void calc_w_point(int h, int w) {
    // 障害物があればreturn
    if(!G[h][w]) return;
    // 障害物がなくて直前も障害物がない場合
    else if(w > 0 && G[h][w-1]) w_point[h][w] = w_point[h][w-1];
    // 直前が障害物だった場合...探索開始
    else {
        int tmp = 0;
        for(int i = 0; w+i < W; i++) {
            // 障害物がなければtmp++
            if(G[h][w+i]) tmp++;
            // となりに障害物があればreturn
            else break;
        }

        w_point[h][w] = tmp;
    }
};

void calc_h_point(int h, int w) {
    // 障害物があればreturn
    if(!G[h][w]) return;
    // 障害物がなくて直前も障害物がない場合
    else if(w > 0 && G[h-1][w]) h_point[h][w] = h_point[h-1][w];
    // 直前が障害物だった場合...探索開始
    else {
        int tmp = 0;
        for(int i = 0; h+i < H; i++) {
            // 障害物がなければtmp++
            if(G[h+i][w]) tmp++;
            // となりに障害物があればreturn
            else break;
        }

        h_point[h][w] = tmp;
    }
};

int main() {
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        string line; cin >> line;
        for(int j = 0; j < W; j++) {
            if(line.at(j) == '.') G[i][j] = true;
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            calc_w_point(i, j);
        }
    }

    for(int j = 0; j < W; j++) {
        for(int i = 0; i < H; i++) {
            calc_h_point(i, j);
        }
    }

    int max = 0;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            int point = w_point[i][j] + h_point[i][j];
            if(max < point) max = point;
        }
    }

    cout << max - 1 << endl;
}


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

int main(){
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int cnt = 0;
  for(int i = 0;i <= A;i++){
    for(int j = 0;j <= B;j++){
      for(int k = 0;k <= C;k++){
        if(i * 500 + j * 100 + k * 50 == X){
          cnt++;
        }
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

// 繰り返し２乗法
lli PowMod(lli n, lli pow, lli mod) {
	if (pow == 0) return 1;
	if (pow % 2 == 0) {
		lli tmp = PowMod(n, pow / 2, mod);
		return tmp * tmp % mod;
	}
	return n * PowMod(n, pow - 1, mod) % mod;
}

int main(void) {
  lli n;
  scanf("%lld", &n);

  lli ans = PowMod(10, n, MOD) - PowMod(9, n, MOD) - PowMod(9, n, MOD) + PowMod(8, n, MOD);
  ans %= MOD;
  ans = (ans + MOD) % MOD;
  printf("%lld\n", ans);
  return 0;
}


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	set<char> color;
  char s;
  ll n;
  cin >> n;
  rep(i, n) {
    cin >> s;
    color.insert(s);
  }
  if (color.size() == 4) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
ps = list(map(int, input().split()))
res = 0
for i in range(n):
    if ps[i] == i+1:
        if i < n - 1:
            ps[i],ps[i+1] = ps[i+1],ps[i]
            res += 1
        else:
            ps[i], ps[0] = ps[0], ps[i]
            res += 1
print(res)

Measured memory_bytes: 20668
#!/usr/bin/env python
# coding: utf-8

# In[9]:


N = int(input())
X = []; Y = []
for _ in range(N):
    x,y = map(int, input().split())
    X += [x]
    Y += [y]


# In[10]:


dic = {}
for i in range(N):
    for j in range(N):
        if i != j:
            x = X[i]-X[j]
            y = Y[i]-Y[j]
            dic[(x,y)] = dic.get((x,y),0) + 1
if N == 1:
    print(1)
else:
    print(N-max(dic.values()))


# In[ ]:






Measured memory_bytes: 9320
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static String solve(String s) {
        String alpha = "abcdefghijklmnopqrstuvwxyz";
        boolean bool = false;
        for (int i = 0; i < alpha.length(); i++){
            bool = false;
            for (int x = 0; x < s.length(); x++){
                if (s.charAt(x) == alpha.charAt(i)){
                    bool = true;
                    break;
                }
            }
            if (!bool){
                return alpha.charAt(i)+"";
            }
        }
        return "None";
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String s = in.next();
        System.out.println(solve(s));
    }
}

Measured memory_bytes: 25328
//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int n,c=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int k=i,nd=0;
        while(k!=0)
        {
            k/=10;
            nd++;
        }
        if(nd%2)
            c++;
    }
    cout<<c<<endl;



}
//Alhamdulillah


















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

int main(){
	int a, b, A;
	char op;
	
	while(1){
		cin >> a >> op >> b;
		
		if ( op == '+'){
			A = a + b;
		}else if ( op == '-'){
			A = a - b;
		}else if ( op == '*'){
			A = a * b;
		}else if ( op == '/'){
			A = a / b;
		}else{
			break;
		}
		cout << A << endl;

	}
		
    return 0;
}

Measured memory_bytes: 3076
/*
Date: 2017/01/07 19:53:23 Saturday
*/
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define rep(i,a,n) for(int i=(a);i<=(n);++i)
#define dep(i,a,n) for(int i=(a);i>=(n);--i)
#define eps 1e-8
#define pi 3.1415926535897
#define sqr(x) ((x)*(x))
#define MAX(a,b) a=max(a,b)
#define MIN(a,b) a=min(a,b)
#define SZ(x) ((int)(x).size())
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define POSIN(x,y) (1<=(x)&&(x)<=n&&1<=(y)&&(y)<=m)
#define all(x) (x).begin(),(x).end()
#define COUT(S,x) cout<<fixed<<setprecision(x)<<S<<endl
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#ifdef LOCAL
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...) 
#endif
typedef long long ll;
typedef double lf;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<lf,lf> pff;
typedef complex<double> CD;
const int inf=0x3f3f3f3f;
const int mo=1000000007;
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
template<class T1,class T2>inline void gn(T1&r,T2&s){gn(r),gn(s);}
template<class T1,class T2,class T3>inline void gn(T1&r,T2&s,T3&t){gn(r),gn(s),gn(t);}
template<class T1,class T2,class T3,class T4>inline void gn(T1&r,T2&s,T3&t,T4&u){gn(r),gn(s),gn(t),gn(u);}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
const int DX[]={1,0,-1,0},DY[]={0,1,0,-1};
ll powmod(ll a,ll b) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll powmod(ll a,ll b,ll mo) {ll res=1;a%=mo;for(;b;b>>=1){if(b&1)res=res*a%mo;a=a*a%mo;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
//*******************************************

const int N=111111,M=111111;
int l,m,n,t,C;
int main(){
#ifdef LOCAL
	freopen("B.in","r",stdin);//freopen("B.out","w",stdout);
#endif
	scanf("%d%d",&n,&m);
	int ans=0;
	rep(i,0,n)rep(j,0,n)if(m-i-j>=0&&m-i-j<=n)++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define range(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) range(i, 0, a)
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? LLONG_MAX : INT_MAX;
const int MOD = 1000000007;
const long double EPS = 1e-8;

signed main() {
	int n;
	cin >> n;
	int a[n * 3];
	priority_queue <int> pear, berry;
	int sumFor = 0, sumBack = 0;
	rep (i, n * 3) {
		cin >> a[i];
		if (i < n) {
			sumFor += a[i];
			pear.push(-a[i]);
		}
	}
	map <int, int> forward;
	forward[n - 1] = sumFor;
	range (i, n, 2 * n) {
		sumFor += a[i];
		pear.push(-a[i]);
		sumFor += pear.top();
		pear.pop();
		forward[i] = sumFor;
	}
	reverse(a, a + (3 * n));
	int ans = -INF;
	rep (i, 2 * n) {
		if (i < n) {
			sumBack += a[i];
			berry.push(a[i]);
		} else {
			if (i == n) {
				ans = max(ans, forward[3 * n - i - 1] - sumBack);
			}
			sumBack += a[i];
			berry.push(a[i]);
			sumBack -= berry.top();
			berry.pop();
			ans = max(ans, forward[3 * n - i - 2] - sumBack);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11124
#include<stdio.h>
int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    int i;
    int a[100005];
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    int min = 0;
    for (i = 0; i < n; i++)
        if (a[min] > a[i])
            min = i;
    int ans = 0;
    k--;
    ans += (min + k - 1) / k;
    min = k * ans + 1;
    min = n - min;
    ans += (min + k - 1) / k;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define sz 200002
#define pb push_back
#define ff first
#define ln '\n'
#define ss second
#define ll long long
#define VEC vector<ll int>v
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}



int main()
{
    ll int n,m,res,a,b;

    cin>>n>>m;
    if(n<10)res=m+(10-n)*100;
    else res=m;
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	int a, b, c;
	std::cin >> a >> b;
	c = a + b;
	if (c >= 24) {
		std::cout << c - 24 << std::endl;
	}
	else {
		std::cout << c << std::endl;
	}
}

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

int main()
{
  int n,m,x;
  cin >> n >> m >> x;
  int a[m];
  
  for (int i = 0; i < m; i++)
  {
    cin >> a[i];
  }
  

  int addcount=0;
  int x2=x;
  while (x2<n)
  {
    x2++;
    for (int i = 0; i < m; i++)
    {
      if (a[i]==x2)
      {
        addcount++;
      }
    }
  }

  int deccount=0;
  x2=x;
  while (x2!=0)
  {
    x2--;
    for (int i = 0; i < m; i++)
    {
      if (a[i]==x2)
      {
        deccount++;
      }
    }
  }
  if (addcount < deccount)
  {
    cout << addcount << "\n";
  }else
  {
    cout << deccount << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)

template<typename T>
T powint (const T& x, const T& y) {
  T ret = 1;
  for(int i=0; i<y; ++i) ret *= x;
  return ret;
}

long long factorial(long long X) {
  long long ans = 1;
  for(int i=1; i<X+1 ; ++i) ans *= i;
  return ans;
}

long long combination(long long n, long long r) {
  long long ans = 1;
  // for (long long i = n; i > (n-r); --i) ans *= i;
  for (long long i = 1; i <= r; ++i) {
    ans *= n+1-i;
    ans /= i;
  }
  return ans;
}

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> v(N);
  rep(i, N) cin >> v[i];

  sort(v.begin(), v.end(), greater<ll>());
  double maxave = 0.0;
  for (ll i = 0; i < A; ++i) {
    maxave += static_cast<double>(v[i]);
  }
  maxave /= static_cast<double>(A);
  ll count = 0;
  ll range = A-1;
  rep (i, N) {
    if (v[i] == v[A-1]) {
      count++;
      range = i;
    }
  }
  ll comb = 0;
  cerr << count <<" "<< range << endl;
  if(v[0] != v[A-1]) {
    comb += combination(count, count-(range-(A-1)));
    cerr << "a" << endl;
    // comb += factorial(count) /(factorial(count-(range-(A-1))) * factorial(range-(A-1)));
  }
  else if(range > B-1) {
    for (ll i = count-(range-(A-1)); i <= count-(range-(B-1)); ++i) {
      comb += combination(count, i);
      // comb += factorial(count) / (factorial(i) * factorial(count - i));
      cerr <<i<<" "<< comb << endl;
    }
  }
  else {
    for (ll i = count-(range-(A-1)); i <= count; ++i) {
      comb += combination(count, i);
      // comb += factorial(count) / (factorial(i) * factorial(count - i));
            cerr << i <<" "<< comb <<" "<< combination(count,i)<< endl;
    }
  }    
  cout << fixed << setprecision(16) << maxave << endl;
  cout << comb << endl;
  return 0;
}


Measured memory_bytes: 3780
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1
 
struct Node {int p, l, r;};
 
Node T[MAX];
int n, D[MAX];
 
void print(int u){
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";
     
    if(T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";
     
    cout << "[";
     
    for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
        if(i)cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}
 
int rec(int u, int p){
    D[u] = p;
    if(T[u].r != NIL) rec(T[u].r, p);
    if(T[u].l != NIL) rec(T[u].l, p + 1);
    return 0;
}
 
int main(void){
    int i, j, d, v, c, l, r;
    cin >> n;
    for(i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;
     
    for(i = 0; i < n; i++){
        cin >> v >> d;
        for(j = 0; j < d; j++){
            cin >> c;
            if(j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for(i = 0; i < n; i++){
        if(T[i].p == NIL) r = i;
    }
     
    rec(r, 0);
     
    for(i = 0; i < n; i++) print(i);
     
    return 0;
}


Measured memory_bytes: 7780
#include<stdio.h>
int main(){
	
	int j,i=1,H[10000],W[10000],a=-1,k,l,m;
	while(i==1){
		a++;
		scanf("%d %d",&H[a],&W[a]);
		if(H[a]==0 && W[a]==0) i=0;
		
	}
	
	
	for(j=0;j<a;j++){
		
		for(m=0;m<H[j];m++){
		
			if(m%2==0){
				for(k=0;k<W[j];k++){
					if(k%2==0){
						printf("#");
					}
					if(k%2==1){
						printf(".");
					}
			
				}
				printf("\n");
			}
			if(m%2==1){
			
				for(k=0;k<W[j];k++){
			
					if(k%2==1){
						printf("#");
					}
					if(k%2==0){
						printf(".");
					}
			
				}
			
				printf("\n");
			
			}
		}
		printf("\n");
		
	}
	
	return 0;
	
}

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

int main() {
	int x=0,n;
	int max=0;
	string s;
	cin>>n;
	cin>>s;
	for(const char& c: s) {
		if(c=='D') x-=1;
		else if(++x>max){
			max=x;
		}
	}
	cout<<max;
	return 0;
}

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

class Program
{
    static void Main(string[] args) {
        string s = Console.ReadLine();
        List<string> str = new List<string>();
        for(int i = 0; i < s.Length; i ++) {
            if (s[i] != 'A' && s[i] != 'T' && s[i] != 'G' && s[i] != 'C') s = s.Replace(s[i],' ');
        }
        str = s.Split().ToList();
        string ans = "";
        for(int i = 0; i < str.Count(); i ++) {
            if (str[i].Length > ans.Length) ans = str[i];
        }
        Console.WriteLine(ans.Length);
    }
}

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

typedef complex<double> Pt;
double cross(const Pt &a, const Pt &b) { return imag(conj(a)*b); }

int main()
{
    double x1, x2, x3, y1, y2, y3, xp, yp;
    while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp)
    {
        Pt a = Pt(x1, y1), b = Pt(x2, y2), c = Pt(x3, y3), p = Pt(xp, yp);
        a -= p; b -= p; c -= p;
        double d = cross(a, b) * cross(b, c);
        double e = cross(b, c) * cross(c, a);
        cout << (d > 0 && e > 0 ? "YES" : "NO") << endl;
    }
}

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

int main() {
    int k, n;
    cin >> k >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int max = -1;
    int memo;
    rep(i, n-1){
        int d = a[i+1]-a[i];
        if(d > max){
            max = d;
            memo = i;
        }
    }
    if(a[0]+(k-a[n-1]) > max){
        // cout << a[0]+(k-a[n-1]) << endl;
        max = a[0]+(k-a[n-1]);
        memo = n-1;
    }
    // cout << memo << endl;
    // cout << n-1 << endl;
    if(memo == n-1){
        int min = 10000000;
        int max = -1;

        rep(i, n){
            if(max < a[i]) max = a[i];
            if(min > a[i]) min = a[i];
        }

        cout << max - min << endl;
    }else{
        int temp = k-a[memo+1];
        cout << a[memo] + temp;
    }
    




}

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

int Bsearch(int e,int n){
  //cout << n << endl;
  int l=0,r=e;
  int i=(l+r)/2;
  while(r-l>=1){
    i=(l+r)/2;
    //cout << "i:" << i << endl;
    if(e == pow(i,n)){
      //cout << "aaa:" << i << endl;
      return i;
    }else if(e > pow(i,n)){
      l=i+1;
    }else{
      r=i;
    }
  }
  //cout << "i:" << i << endl;
  return i;
}

int a[2000][2000];

int main(){
  int x,y,z,e;
  while(cin>>e,e){
    memset(a,0,sizeof(a));
    y=Bsearch(e,2);
    z=Bsearch(e,3);

    int m=1000000;
    //cout << "z:" << z << " y:" << y << endl;
    for(int i=0;i<=1000;i++){
      for(int j=0;j<=100;j++){
	x=e-i*i-j*j*j;
	if(x>=0)m = min(x+i+j,m);
      }
    }
    cout <<m << endl; 
  }
}

Measured memory_bytes: 16892
#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n;
    cin>>n;
    char a[n];
    int sum=1,i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<n;i++)
    {
        if(a[i]!=a[i-1])
            sum++;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 384
import java.io.*;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			String str[] = new String[8];
			int field[][] = new int[8][8];
			int n = Integer.parseInt(br.readLine());
			br.readLine();
			for (int i=0;i<n;i++) {
				for (int j=0;j<8;j++) {
					str[j] = br.readLine();
					for (int k=0;k<8;k++) {
						field[j][k] = Character.getNumericValue(str[j].charAt(k));
					}
				}
				int x = Integer.parseInt(br.readLine())-1;
				int y = Integer.parseInt(br.readLine())-1;
				if (field[y][x]==1) Chein(field,x,y);
				System.out.println("Data "+(i+1)+":");
				for (int j=0;j<8;j++) {
					for (int k=0;k<8;k++) System.out.print(field[j][k]);
					System.out.println("");
				}
				br.readLine();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void Chein(int[][] m,int x,int y) {
		m[y][x] = 0;
		for (int i=1;i<=3;i++) {
			if (x-i>=0&&m[y][x-i]==1) Chein(m,x-i,y);
			if (x+i<=7&&m[y][x+i]==1) Chein(m,x+i,y);
			if (y-i>=0&&m[y-i][x]==1) Chein(m,x,y-i);
			if (y+i<=7&&m[y+i][x]==1) Chein(m,x,y+i);
		}
	}
}

Measured memory_bytes: 16932
/* ex5_3.c Grid Compression
    dada__              */
#include<stdio.h>
#include<stdlib.h>
int main(void){
    int row, col, i, j;
    int *judge_row, *judge_col;
    char **grid;
    scanf("%d %d", &row, &col); //行と列の数の入力

    //動的メモリ確保
    judge_row=(int*)calloc(row, sizeof(int));
    if(judge_row==NULL){
        exit(1);
    }
    judge_col=(int*)calloc(col, sizeof(int));
    if(judge_col==NULL){
        exit(1);
    }
    
    //二次元配列メモリの動的確保
    grid=(char**)calloc(row, sizeof(char*));
    if(grid==NULL){
        exit(1);
    }
    for(i=0;i<row;i++){
        grid[i]=(char*)calloc(col, sizeof(char));
        if(grid[i]==NULL){
            exit(1);
        }
    }

    //各マス目の記号の入力
    for(i=0;i<row;i++){
        for(j=0;j<col;j++){
            scanf(" %c", &grid[i][j]);
            if(grid[i][j]=='#'){
                judge_row[i]=1;
                judge_col[j]=1;
            }
        }
    }

    //各判定に基づいた出力
    for(i=0;i<row;i++){
        if(judge_row[i]==1){ //行の判定が1の場合に出力
            for(j=0;j<col;j++){
                if(judge_col[j]==1){//列の判定が1の場合に出力
                    printf("%c", grid[i][j]);
                }
            }
            printf("\n");
        }
    }

    //確保と逆順にメモリ領域の解放
    for(i=0;i<row;i++){
        free(grid[i]);
    }
    free(grid);
    free(judge_row);
    free(judge_col);

    return 0;
}

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

int main() {
  
  int N; cin >> N; int64_t sum = 0;
  
  vector<int64_t> vecA(N), vecB(N);
  
  for (int i = 0; i < N; i++) {
    
    int64_t A, B; cin >> A >> B;
    
    vecA[i] = A; vecB[i] = B;
    
  }
  
  for (int i = N - 1; 0 <= i; i--) {
    
    int64_t tmp = vecA[i] + sum;
    
    if (tmp % vecB[i] != 0) {
      
      sum += vecB[i] * (tmp / vecB[i] + 1) - tmp;
      
    }
    
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 4816
#include<stdio.h>


int main()
{
	int a,b,c,t;
	scanf("%d%d%d",&a,&b,&c);
	if(a>=b){
		t=a;a=b;b=t;
	}
	if(b>=c){
		t=b;b=c;c=t;
	}	
	if(a>=b){
		t=a;a=b;b=t;
	}
	if(a>=b){
		t=a;a=b;b=t;
	}
	if(b>=c){
		t=b;b=c;c=t;
	}	
	if(a>=b){
		t=a;a=b;b=t;
	}
	printf("%d\n",c-a);
	
	
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		int cnt = 0;
		for (int i = 0; i < a.length; i++) {
			if (a[i] != i + 1) {
				cnt++;
			}
		}
		if (cnt <= 2) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	ll n;
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
// Need start
#include<vector>
// Need end
using namespace std;

template <class T>
class WarshallFloyd {
    private:
        T identity_;
        vector<vector<T>> dist_;
    public:
        WarshallFloyd(int node_num, T identity):
        identity_(identity), dist_(vector<vector<T>>(node_num, vector<T>(node_num, identity))) {}
        void addEdge(int from, int to, T cost) {
            dist_[from][to] = cost;
        }
        void calcShortestPath() {
            int n = (int)dist_.size();
            for (int k = 0; k < n; ++k) {
                for (int i = 0; i < n; ++i) {
                    for (int j = 0; j < n; ++j) {
                        if (dist_[i][k] == identity_ || dist_[k][j] == identity_) continue;
                        dist_[i][j] = min(dist_[i][j], dist_[i][k] + dist_[k][j]);
                    }
                }
            }
        }
        T getDist(int from, int to) {
            return dist_[from][to];
        }
};

using ll = long long;

const ll INF = 1LL << 50;

int main() {
    // This sample is Atcoder Beginners Contest 143 E
    int N, M;
    ll L;
    cin >> N >> M >> L;
    WarshallFloyd<ll> warshall_floyd1(N, INF);
    int A, B;
    ll C;
    for (int i = 0; i < M; ++i) {
        cin >> A >> B >> C;
        --A, --B;
        warshall_floyd1.addEdge(A, B, C);
        warshall_floyd1.addEdge(B, A, C);
    }
    int Q;
    cin >> Q;
    vector<int> S(Q), T(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> S[i] >> T[i];
        --S[i], --T[i];
    }
    warshall_floyd1.calcShortestPath();
    WarshallFloyd<ll> warshall_floyd2(N, INF);
    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (warshall_floyd1.getDist(i, j) > L) {
                continue;
            }
            warshall_floyd2.addEdge(i, j, 1);
            warshall_floyd2.addEdge(j, i, 1);
        }
    }
    warshall_floyd2.calcShortestPath();
    for (int i = 0; i < Q; ++i) {
        ll ans = warshall_floyd2.getDist(S[i], T[i]);
        cout << (ans == INF ? -1 : ans - 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

void solve(string s) {
  const int n = s.size();
  string res;
  for (int i = 0; i < n; i += 2) {
    res += s[i];
  }
  cout << res << endl;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	string s;
	cin >> s;
	solve(s);
	return 0;
}


Measured memory_bytes: 640
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var M = parseInt(input[0].split(" ")[1]);
  var min=N;
  var max=0;
  for(var i=0;i<M;i++){
    min=Math.min(min,parseInt(input[i+1].split(" ")[1]));
    max=Math.max(max,parseInt(input[i+1].split(" ")[0]));
  }
  var ans=min-max+1;
  if(ans<0){
    ans=0;
  }



  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29092
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        char ss[] = inp.next().toCharArray();
        char s = ss[ss.length - 1];
        if (s == '2' || s == '4' || s == '5' || s == '7' || s == '9') {
            System.out.println("hon");
        }
        else if (s == '0' || s == '1' || s == '6' || s == '8') {
            System.out.println("pon");
        }
        else {
            System.out.println("bon");
        }
    }
}


Measured memory_bytes: 35620
#include<iostream>
using namespace std;
int main(){
    int h, w;
    
    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0)break;
        
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i%2 == 0){
                    if(j%2 == 0){
                        cout << '#';
                    }else{
                        cout << ".";
                    }
                }else{
                    if(j%2 == 0){
                        cout << ".";
                    }else{
                        cout << '#';
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));


int main(){	
	long long N;
	string s;
	scanf("%lld",&N);
	cin >> s;
	bool sheep[N];
	bool flg = false;
	rep(i, 4) {
		sheep[0] = i%2 == 0;
		sheep[1] = i < 2;
		rep(j, N-2) {
			if (sheep[j+1] && s[j+1] == 'o') sheep[j+2] = sheep[j];
			if (!sheep[j+1] && s[j+1] == 'o') sheep[j+2] = !sheep[j];
			if (sheep[j+1] && s[j+1] == 'x') sheep[j+2] = !sheep[j];
			if (!sheep[j+1] && s[j+1] == 'x') sheep[j+2] = sheep[j];
		}
		if ((sheep[N-1] && s[N-1] == 'o' && sheep[N-2] == sheep[0]) 
			|| (!sheep[N-1] && s[N-1] == 'o' && sheep[N-2] != sheep[0])
			|| (sheep[N-1] && s[N-1] == 'x' && sheep[N-2] != sheep[0])
			|| (!sheep[N-1] && s[N-1] == 'x' && sheep[N-2] == sheep[0])) {
			if ((sheep[0] && s[0] == 'o' && sheep[N-1] == sheep[1]) 
			|| (!sheep[0] && s[0] == 'o' && sheep[N-1] != sheep[1])
			|| (sheep[0] && s[0] == 'x' && sheep[N-1] != sheep[1])
			|| (!sheep[0] && s[0] == 'x' && sheep[N-1] == sheep[1])) {
				flg = true;
				break;
			}
		}
	}
	
	if (flg) {
		rep(i, N) {
			if (sheep[i]) cout << "S"; else cout << "W";
		}
		cout << endl;
	} else {
		cout << "-1" << endl;
	}

	return 0;
}



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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

string s;

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

	cin >> s;

	int n = (int)s.size();
	s = ' ' + s;
		
	if(s[1] == '0'){
		cout << "-1\n";
		return 0;
	}

	if(s[n] == '1'){
		cout << "-1\n";
		return 0;
	}

	for(int i = 1; i < n; i++){
		if(s[i] != s[n - i]){
			cerr << "wher\n";
			cerr << i << ' ' << n - i << '\n';
			cout << "-1\n";
			return 0;
		}
	}

	int last = 1;

	int cur = 1;
	int cnt = 2;
	cout << "1 2\n";

	for(int i = 2; i < n; i++){
		if(s[i] == '0'){
			continue;
		}
		
		//cerr << last << ' ' << i << '\n';
		cur = cnt++;
		for(int j = 1; j <= i - (last + 1); j++){
			//edg.push_back(make_pair(cur, cnt++));
			cout << cur << ' ' << cnt++ << '\n';
		}
		
		cout << cur << ' ' << cnt << '\n';
		last = i;
	}

	return 0;
}

Measured memory_bytes: 1664
#include<iostream>

using namespace std;

const static long long MAX_K = 1000000000000000000;

long long A, B, C, K;



int main() {

  cin >> A >> B >> C >> K;

  long long A1 = B + C;
  long long B1 = A + C;
  long long C1 = A + B;

  if (K % 2 == 0)
    if (A - B > MAX_K)
      cout << "Unfair" << endl;
    else 
      cout << A - B << endl;
  else 
    if (A1 - B1 > MAX_K)
      cout << "Unfair" << endl;
    else 
      cout << A1 - B1 << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

# In[43]:


N, A, B, C, D = map(int, input().split())
S = input()
"""
7 1 3 7 6
.#..#..
"""


# In[55]:


if '##' in S[A-1:C] or '##' in S[B-1:D]:
    print('No')
else:# A~C B~D間に##は無い
    if C<D: # ACBD or ABCD
        print('Yes')
    else: # ABDC
        if '...' in S[B-2:D+1]:
            print('Yes')
        else:
            print('No')

"""
if C<D: # C < D のとき、A~C、B~Dに#が2連続じゃなければYes
    shc = 0
    for s in S[A-1:C]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
    shc = 0
    for s in S[B-1:D]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
elif C>D: # C > Dのとき、順番入れ替えが必要, dotが3個以上並べば、入れ替えられる
    #print(1)
    shc = 0
    dc = 0
    mdc = 0
    for i, s in enumerate(S[A-1:C]): # A~Cで　#が二個以上あればアウト
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
            if dc>0:
                mdc = max(dc, mdc)
                dc = 0
        if s == '.':
            dc += 1
            shc = 0
        if i >= C-A:
            mdc = max(dc, mdc)
    if mdc >= 3:
        #print(2)
        pass
    elif mdc < 3: # A~Cに dotが3個以上並んでいないとき、
        #print(2)
        shc = 0
        for i, s in enumerate(S[0:A:-1]):
            if shc >1:
                l = A-i+1
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
            if i >= A-1 and shc > 1:
                l = A-i+2
        else:
            l = 0
            
        shc = 0
        for i, s in enumerate(S[C:]):
            if shc >1:
                r = C+i-2
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
            if i >= N-C-1 and shc > 1:
                r = C+i-2
        else:
            r = N
        
        #print(l, r)
        mdc = 0
        dc = 0
        for i, s in enumerate(S[l:r]):
            #print('{}: {}'.format(i, dc))
            if s == '#':
                if dc>0:
                    mdc = max(dc, mdc)
                    dc = 0
            if s == '.':
                dc += 1
            if i >= r-l-1:
                mdc = max(dc, mdc)
        if mdc < 3:
            ans = 'No'
print(ans)
"""


# In[ ]:






Measured memory_bytes: 3572
n = int(input())
v = list(map(int,input().split()))
v.sort()
for i in range(n-1):
    new = (v[0] + v[1])/2
    v.append(new)
    v[0] = 10 ** 6
    v[1] = 10 ** 6
    v.sort()
print(v[0])

Measured memory_bytes: 3060
using System;
using System.Linq;

namespace ITP1 {
	class Program {
		public static void Main() {
			int[] input = Console.ReadLine()
				.Split()
				.Select(i => int.Parse(i))
				.ToArray();
			if (input[0] < input[1]) Console.WriteLine("a < b");
			else if (input[0] > input[1]) Console.WriteLine("a > b");
			else Console.WriteLine("a == b");

		}
	}
}



Measured memory_bytes: 9348