akhauriyash/Code-Regression huggingface dataset:
N = int(input())
a = [int(x) for x in input().split()]

B_s = sorted([y - x - 1 for x, y in enumerate(a)])


medians = []
if N%2 == 0 :
    medians.append(B_s[N // 2])
    medians.append(B_s[N // 2 + 1])
else :
    medians.append(B_s[N // 2])
    
min_sum = sum(a)

for m in medians :
    sum_over = 0
    
    for i in range(N) :
        sum_over += abs(B_s[i] - m)
        
    min_sum = min(min_sum, sum_over)
    
print(min_sum)
    
    
    
    
    

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

int main(){
  	int N;
  	double T, A;
  	cin >> N >> T >> A;
  	vector<double> H(N);
  	for(int i=0; i<N; i++){
    	cin >> H[i];
    }
  
  	int ans=0;
  	double dif = 11451419;
  	for(int i=0; i<N; i++){
    	if(abs(T - 0.006*H[i] - A) < dif){
        	ans = i;
          	dif = abs(T - 0.006*H[i] - A);
        }
    }
  	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 384
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	vector<string> v(3);
	while(1){
		rep(i,3){
			cin>>v[i];
			if(v[i][0]=='0'){
				return;
			}
		}
		int ans=0;
		rep(i,3){
			if(v[i][0]==v[i][1]&&v[i][1]==v[i][2]){
				if(v[i][0]=='b'){
					ans=1;
				}
				if(v[i][0]=='w'){
					ans=2;
				}
			}
			if(v[0][i]==v[1][i]&&v[1][i]==v[2][i]){
				if(v[0][i]=='b'){
					ans=1;
				}
				if(v[0][i]=='w'){
					ans=2;
				}
			}
		}
		if(v[0][0]==v[1][1]&&v[1][1]==v[2][2]){
			if(v[0][0]=='b'){
				ans=1;
			}
			if(v[0][0]=='w'){
				ans=2;
			}
		}
		if(v[2][0]==v[1][1]&&v[1][1]==v[0][2]){
			if(v[1][1]=='b'){
				ans=1;
			}
			if(v[1][1]=='w'){
				ans=2;
			}
		}
		if(ans==0){
			puts("NA");
		}
		if(ans==1){
			puts("b");
		}
		if(ans==2){
			puts("w");
		}
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

int main() {
	int n;cin>>n;
	string s;
	unordered_set<string>st;
	while(n--)
	{
	    cin>>s;
	    st.insert(s);
	}
	cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 17616
from functools import reduce

n = int(input())

E = reduce(lambda ac, v: ac + v * (n - v + 1), range(1, n + 1), 0)
V = 0
for _ in range(n - 1):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    V += a * (n - b + 1)
print(E - V)


Measured memory_bytes: 75056
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut aa: [usize; n],
    }
    aa.sort();
    aa.reverse();

    let mut total: usize = 0;
    total += aa[0];
    for i in 1..(aa.len() / 2) {
        total += aa[i] * 2
    }
    if aa.len() % 2 == 1 {
        total += aa[aa.len() / 2];
    }
    print!("{}", total);
}


Measured memory_bytes: 6232
#include<iostream>
#include<string>
using namespace std;
int main()
{
    char s[5000];
    long long n,i,j,k,total=0,red[5000]={0},green[5000]={0},blue[5000]={0},r=0,g=0,b=0,x,y;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>s[i];
    }
    for(i=1;i<=n;i++)
    {
        if(s[i]=='R')
        {
            r++;
            red[i]=red[i-1]+1;
            blue[i]=blue[i-1];
            green[i]=green[i-1];
        }
        else if(s[i]=='G')
        {
            g++;
            green[i]=green[i-1]+1;
            red[i]=red[i-1];
            blue[i]=blue[i-1];
        }
        else if(s[i]=='B')
        {
            b++;
            blue[i]=blue[i-1]+1;
            red[i]=red[i-1];
            green[i]=green[i-1];
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {          
            if((s[i]=='R'&&s[j]=='G')||(s[i]=='G'&&s[j]=='R'))
            {
                x=b-blue[j];
                y=(j-i)+j;
                if(s[y]=='B'&&x>0&&y<=n)
                {
                    x--;
                }
                if(x>0)
                {
                    total=total+x;
                }                
            }
            else if((s[i]=='R'&&s[j]=='B')||(s[i]=='B'&&s[j]=='R'))
            {
                x=g-green[j];
                y=(j-i)+j;
                if(s[y]=='G'&&x>0&&y<=n)
                {
                    x--;
                }
                if(x>0)
                {
                    total=total+x;  
                }              
            }
            else if((s[i]=='B'&&s[j]=='G')||(s[i]=='G'&&s[j]=='B'))
            {
                x=r-red[j];
                y=(j-i)+j;
                if(s[y]=='R'&&x>0&&y<=n)
                {
                    x--;
                }
                if(x>0)
                {
                    total=total+x; 
                }               
            }
        }
    }
    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 3740
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	string p[110];
	int h, w; cin >> h >> w;
	for (int i = 0; i < h; i++){
		cin >> p[i];
	}
	for (int i = 0; i < h; i++) {
		cout << p[i] << endl;
		cout << p[i] << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans =0
a.sort()
for i in range(n-2):
    for j in range(i,n,1):
        if(not a[i] == a[j]):
            for k in range(j,n,1):
                if(not a[j]==a[k]):
                    if(a[i]+a[j]>a[k]):
                        ans +=1
                    else:
                        break
print(ans)

Measured memory_bytes: 9196
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef long long ll;

ll fabs(ll a){
	if(a<0)return -a;
	return a;
}

int main(){
	int n;
	cin>>n;
	ll a[n];
	rep(i,n){
		cin>>a[i];
		a[i]-=i;
	}
	sort(a,a+n);
	ll ans=0;
	rep(i,n)ans+=fabs(a[i]-a[n/2]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mp make_pair
#define F first
#define S second
#define maxn 100010

long long int a[maxn];

long long int dif[maxn];
int n;
int prev (int ind){
	if (ind==1) return n;
	return ind-1;
}


int main(){
	//int n;
	cin>>n;
	for (int i=1; i<=n; i++) cin>>a[i];
	for (int i=1; i<=n; i++){
		dif[i]= a[i]-a[prev(i)];
	}	
	long long int S= 0LL;
	for (int i=1; i<=n; i++) S+=a[i];
	long long int q;	
	long long int t= 1LL*n*(n+1LL)/2LL;
	if (S%t!=0){
		cout<<"NO"<<endl;
		return 0;
	}	
	q= S/t;
	//q%=n;
	for (int i=1; i<=n; i++){
		dif[i]-=q;
	//	dif[i]%=n;
	//	if (dif[i]<0) dif[i]+=n;
		if (dif[i]%n!=0){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	long long int u= 0LL;
	for (int i=1; i<=n; i++){
		if (dif[i]>0){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

//4 5 1 2 3 --> 1 1 -4 1 1 


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(fabs(a-c)<=d){
        cout<<"Yes";
    }
    else if(fabs(b-c)<=d && fabs(a-b)<=d){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
total = 0
for i in range(N):
    total += min(A[i], B[i])
    B[i] -= min(A[i], B[i])
    A[i] -= min(A[i], B[i])
    total += min(A[i+1], B[i])
    A[i+1] -= min(A[i+1], B[i])

print(total)


Measured memory_bytes: 18624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<ll,ll>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((ll)x.size())
#define MOD (ll)(1e9+7)
#define INF (9e18)
#define EPS (1e-6)
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif

void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
	INIT();
	//code...
	ll a,b; cin>>a>>b;
	ll n=gcd(a,b);
	int ans=1;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			ans++;
			while(n%i==0) n/=i;
		}
	}
	if(n!=1) ans++;
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  string s, t;
  cin >> s;
  for (int i = 0; i < s.size(); i += 2) {
    t += "hi";
  }
  if (s == t) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define For(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Rep(i,n) For(i,0,n)
#define Each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 100+1
#define MAX_M 2000+1
#define MAX_L 100+1

struct edge{
	int to, cost, th;
	edge(int a, int b, int c):to(a),cost(b),th(c){}
};

struct state{
	int v, cost, tsum;
	state(int a, int b, int c):v(a),cost(b),tsum(c){}
};

bool operator<(const state& a, const state& b){ return a.tsum > b.tsum; }

vector<edge> G[MAX_M];
int tsum[MAX_N][MAX_L];

int N, M, L;

void solve(){
	Rep(i,MAX_N)Rep(j,MAX_L) tsum[i][j] = INF;

	int res = INF;
	priority_queue<state> Q;
	Q.push(state(0,L,0));
	while(!Q.empty()){
		state s = Q.top(); Q.pop();
		//dbg(s.v);
		if(s.v == N-1){ res = min(res, s.tsum); continue; }
		if(tsum[s.v][s.cost] != INF) continue;
		tsum[s.v][s.cost] = s.tsum;
		Rep(i, G[s.v].size()){
			if(G[s.v][i].cost <= s.cost){
				Q.push(state(G[s.v][i].to, s.cost-G[s.v][i].cost, s.tsum));
			}
			Q.push(state(G[s.v][i].to, s.cost, s.tsum+G[s.v][i].th));
		}
	}
	printf("%d\n", res);
}

int main(){
	while(1){
		scanf("%d %d %d", &N, &M, &L);
		if(N == 0) break;
		Rep(i,N) G[i].clear();
		Rep(i,M){
			int a, b, c, d;
			scanf("%d %d %d %d", &a, &b, &c, &d);
			a--; b--;
			G[a].pb(edge(b,c,d));
			G[b].pb(edge(a,c,d));
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 12232
import java.util.Scanner;
class Main{
  public static void main(String args[]){
    Scanner scan=new Scanner(System.in);
    int a=scan.nextInt();
    int b=scan.nextInt();
    int c=scan.nextInt();
    int d=(int)(Math.floor(b/a));
    d=Math.min(d,c);
    System.out.println(d);
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int X[11] = { 0,2,5,5,4,5,6,3,7,6 };

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	vector<int> dp(N + 1, -1000000);
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}
	sort(A.rbegin(), A.rend());

	dp[N] = 0;
	for (int i = N; i >= 0; i--) {
		for (int j = 0; j < M; j++) {
			if (i + X[A[j]] <= N) {
				dp[i] = max(dp[i], dp[i + X[A[j]]] + 1);
			}
		}
	}

	int cur = 0;
	string res;
	while (cur < N) {

		for (int j = 0; j < M; j++) {
			if (cur + X[A[j]] <= N) {
				if (dp[cur] == dp[cur + X[A[j]]] + 1) {
					res.push_back(A[j] + '0');
					cur += X[A[j]];
					break;
				}
			}
		}

	}
	


	cout << res << endl;
}

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

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 ll INF = 1LL << 60;

int main() {
    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    long double area = W * H / 2.0;
    if (W == x * 2 && H == y * 2) {
        printf("%.10Lf 1\n", area);
    } else {
        printf("%.10Lf 0\n", area);
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b,W,t,d;
    while(scanf("%d%d%d",&W,&a,&b)!=EOF)
    {
       
        if(a>b)
        {
            t=b;
            b=a;
            a=t;
        }
        d=b-a-W;
        if(d>0)
            printf("%d\n",d);
        else 
            printf("0\n");
    }
    return 0;
}

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

struct union_find{
    union_find(int n){
        for(int i=0; i<=n; i++){
            par.push_back(i);
            rank.push_back(0);
            size.push_back(1);
        }
    }
    int find(int x){
        if(par[x]==x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(rank[x] < rank[y]){
            par[x] = y;
            size[y]+= size[x];
        }else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
            size[x]+=size[y];
        }
    }
    int getSize(int x){
        return size[x];
    }

    private:
        vector<int> par, rank, size;
};

int main(){
    ll N, M;
    cin >> N >> M;
    vector<pair<int,int>> bridge(M+1);
    for(int i=1; i<=M; i++){
        int A, B;  cin >> A >> B;
        bridge[i] = make_pair(A, B);
    }

    union_find island(N);
    vector<ll> conv(M+2,0); // 橋 i 建設後の便利さ = conv[i]
    conv[M+1] = 0; // 橋が 1 つも無いとき便利さは 0

    // 橋 M, M-1, ……, 1 の順に橋を建設する
    for(int i=M; i>=0; i--){
        int A = bridge[i].first;
        int B = bridge[i].second;
        // A と B の根を求める
        A = island.find(A);
        B = island.find(B);
        if(A==B){
            // A, B が互いに行き来できるとき、AとBを繋いでも便利さは増えない
            conv[i] = conv[i+1];
        }else{
            // A, B が互いに行き来できないとき、
            // A, B の各グループの連結成分の数の積だけ便利さが増える
            conv[i] = conv[i+1] + island.getSize(A)*island.getSize(B);
        }
        // A と B を併合
        island.unite(A,B);
    }

    // （橋 i 崩落後の不便さ）+（橋 i + 1 建設後の便利さ）= N*(N-1)/2
    for(int i=1; i<=M; i++){
        ll ans = N*(N-1)/2 - conv[i+1];
        cout << ans << endl;
    }
}


Measured memory_bytes: 4332
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
    int A, B, C;
    cin >> A >> B >> C;
    if (A != B && A != C && B != C) cout << "No";
    else if (A == B && A == C && B == C) cout << "No";
    else cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll n;
vll a = {7, 5, 3};
ll count(ll n, ll d){
	ll res = 0, state = 1;
	REP(i, d) state *= 3;
	REP(i, state){
		ll tmp = i, num = 0, dig = 1, id;
		vll used(3);
		REP(j, d){
			id = tmp % 3;
			num += dig * (a[id]);
			used[id] = 1;
			tmp /= 3;
			dig *= 10;
		}
		if(num <= n) res += used[0] * used[1] * used[2];
	}
	return res;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> n;
	ll tmp = n, d = 0;
	while(tmp){
		tmp /= 10;
		d++;
	}
	ll ans = 0;
	for(int i = 3; i <= d; i++) ans += count(n, i);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#B問題
S = list(str(input()))
N = len(S)
front = []
back = []
for i in range(N):
    if i < N//2:
        front.append(S[i])
    else:
        back.append(S[i])


for i in range(N):
    #print(front,back)
    del back[-1]
    if i%2 == N%2:
        f = front.pop(-1)
        back.insert(0,f)
    if front == back:
        MAX = (N-i-1)
        break
        
print(MAX)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int line_max;
char buffer[2000];
char bunsyou[200][2000];
int cx,cy;

void a(void) {
	cx=0;
}

void e(void) {
	cx=strlen(bunsyou[cy]);
}

void p(void) {
	if(cy>0)cy--;
	cx=0;
}

void n(void) {
	if(cy<line_max-1)cy++;
	cx=0;
}

void f(void) {
	if(cx<strlen(bunsyou[cy]))cx++;
	else if(cy<line_max-1) {
		cy++;
		cx=0;
	}
}

void b(void) {
	if(cx>0)cx--;
	else if(cy>0) {
		cy--;
		cx=strlen(bunsyou[cy]);
	}
}

void d(void) {
	int i,length;
	if(cx<strlen(bunsyou[cy])) {
		length=strlen(&bunsyou[cy][cx])-1;
		memmove(&bunsyou[cy][cx],&bunsyou[cy][cx+1],length);
		bunsyou[cy][cx+length]=0;
	} else if(cy<line_max-1) {
		strcat(bunsyou[cy],bunsyou[cy+1]);
		for(i=cy+2;i<line_max;i++) {
			strcpy(bunsyou[i-1],bunsyou[i]);
		}
		line_max--;
	}
}

void k(void) {
	int i;
	if(cx>=strlen(bunsyou[cy])) {
		if(cy<line_max-1) {
			strcat(bunsyou[cy],bunsyou[cy+1]);
			for(i=cy+2;i<line_max;i++) {
				strcpy(bunsyou[i-1],bunsyou[i]);
			}
			line_max--;
			buffer[0]='\n';
			buffer[1]=0;
		}
	} else {
		strcpy(buffer,&bunsyou[cy][cx]);
		bunsyou[cy][cx]=0;
	}
}

void y(void) {
	int i,length;
	if(buffer[0]==0)return;
	if(buffer[0]=='\n') {
		for(i=line_max;i>cy+1;i--) {
			strcpy(bunsyou[i],bunsyou[i-1]);
		}
		line_max++;
		strcpy(bunsyou[cy+1],&bunsyou[cy][cx]);
		bunsyou[cy][cx]=0;
		cy++;
		cx=0;
	} else {
		length=strlen(buffer);
		memmove(&bunsyou[cy][cx+length],&bunsyou[cy][cx],
			strlen(&bunsyou[cy][cx])+1);
		memmove(&bunsyou[cy][cx],buffer,length);
		cx+=length;
	}
}

int main(void) {
	char* cp;
	char cmd[10];
	int i;
	line_max=0;
	while(1) {
		fgets(bunsyou[line_max],sizeof(bunsyou[line_max]),stdin);
		cp=strchr(bunsyou[line_max],'\n');
		if(cp)*cp=0;
		if(strcmp(bunsyou[line_max],"END_OF_TEXT")==0) {
			bunsyou[line_max][0]=0;
			break;
		} else {
			line_max++;
		}
	}
	while(1) {
		scanf("%s",cmd);
		if(cmd[0]=='-')break;
		switch(cmd[0]) {
			case 'a':a();break;
			case 'e':e();break;
			case 'p':p();break;
			case 'n':n();break;
			case 'f':f();break;
			case 'b':b();break;
			case 'd':d();break;
			case 'k':k();break;
			case 'y':y();break;
		}
	}
	for(i=0;i<line_max;i++)puts(bunsyou[i]);
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(){
vector <long long>a(1000007);
long long n,k,q,i,j,sum=0;
cin>>n;
for(i=0;i<n;i++){
        cin>>j;
    a[j]++;
    sum=sum+j;
}
cin>>q;
for(i=0;i<q;i++){
        cin>>j>>k;
        sum-=(a[j]*j);
        sum+=(a[j]*k);
        a[k]+=a[j];
        a[j]=0;
        cout<<sum<<"\n";

}


}

Measured memory_bytes: 10956
#include"bits/stdc++.h"
using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '1') {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool palin(string s,int l,int r)
{
	 int i=l,j=r/2+1;
	 while(i<=r/2 && j<=r)
	 {
	 	if(s[i]!=s[j])
	 	return false;
	 	i++;
	 	j++;
	 }
	 return true;
}
int main() {
	string s;
	cin>>s;
	int l=s.length(),ans;
	l--;
	for(int i=l-2;i>=1;i=i-2)
	{
		if(palin(s,0,i))
		{
			ans=i+1;
			break;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
<?php
$n = intval(trim(fgets(STDIN)));
$p1 = 0;
$p2 = 0;

for($i = 0;$i < $n;++$i){
  $input = explode(" ", trim(fgets(STDIN)));
  $s1 = $input[0];
  $s2 = $input[1];
  $c = strnatcmp($s1, $s2);
  if($c > 0){
    $p1 += 3;
  }else if($c < 0){
    $p2 += 3;
  }else{
    $p1 += 1;
    $p2 += 1;
  }
}

print($p1 . " " . $p2 . "\n");



Measured memory_bytes: 9232
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

string BASE_CONVERSION(ll num, ll base, ll digit){
    string s = "";
    ll x = pow(base,digit-1);
    for(ll i = 0; i < digit; i++) s += to_s(num / x), num %= x, x /= base;
    return s;
}

int main(){
    ll N; cin >> N;
    vector<vector<P>> P(N);
    rep(i,N){
        ll A; cin >> A;
        rep(j,A){
            ll x,y; cin >> x >> y; x--;
            P[i].pb({x,y});
        }
    }
    ll ans = 0;
    rep(i,pow(2,N)){
        string x = BASE_CONVERSION(i,2,N);
        bool judge = true;
        rep(j,N){
            ll A = sz(P[j]);
            if(x[j] == '0') continue;
            rep(k,A){
                ll pos = x[P[j][k].first] - '0';
                ll num = P[j][k].second;
                if(pos != num) judge = false;
            }
        }
        ll ct = 0;
        if(judge) rep(j,N) ct += x[j] == '1';
        ans = max(ans,ct);
    }

    print(ans);

}

Measured memory_bytes: 512
var n;
var p = [];
var r = [];

function init(){
	rep(n, function(i){
		p[i] = i;
		r[i] = 0;
	});
}

function find(x){
	if(p[x] === x){
		return x;
	}
	return p[x] = find(p[x]);
}

function same(x, y){
	return find(x) === find(y);
}

function unite(x, y){
	var a = find(x);
	var b = find(y);

	if(a === b){
		return;
	}

	if(r[a] > r[b]){
		p[b] = a;
	}
	else{
		p[a] = b;
		if(r[a] === r[b]){
			++r[b];
		}
	}
}

function main(){
	n = scan();
	init();
	var q = scan();
	rep(q, function(){
		var t = scan();
		var x = scan();
		var y = scan();
		if(t === 0){
			unite(x, y);
		}
		else{
			print(+same(x, y));
		}
	});
}
 
function rep(a, b, c){
	if(c === undefined){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
var input = '';
var input_index = 0;
 
function scan(type){
	if(type === 'string'){
		return input[input_index++];
	}
	else{
		return +input[input_index++];
	}
}
 
function print(val){
	console.log(val);
}
 
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.split(/\s+/);
	main();
});

Measured memory_bytes: 44672
n=int(input())
t,x,y=[0],[0],[0]
for i in range(n):
    T,X,Y=map(int,input().split())
    t.append(T)
    x.append(X)
    y.append(Y)
#print(t,x,y)
for i in range(n):
    time=t[i+1]-t[i]
    dx=abs(x[i+1]-x[i])
    dy=abs(y[i+1]-y[i])

    if time<dx+dy or (time+dx+dy)%2!=0:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 11744
#include<bits/stdc++.h>
using namespace std;
string str;
int c=999,f=999;
int main(){
	cin>>str;
	int l=str.length();
	for(int i=0;i<l;i++){
		if(str[i]=='C'&&c==999){
			c=i;
		}
		if(str[i]=='F'){
			f=i;
		}
	}
	if(c!=999&&f!=999&&c<f){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ll,ii>
#define endl '\n'

int n,m;
int arr[105][105];

vector<int> al[105];

int r[10005]; //which left node is it connected to
bool visited[10005];
bool dfs(int i){
  if (visited[i]) return false;
  visited[i]=true;
  for (int x=0;x<al[i].size();x++){
    if (r[al[i][x]/m]==-1 || dfs(r[al[i][x]/m])){
      r[al[i][x]/m]=i;
      return true;
    }
  }
  return false;
}

int ans[105][105];

int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
	
	cin>>n>>m;
	
	for (int x=0;x<n;x++)
		for (int y=0;y<m;y++) cin>>arr[x][y],arr[x][y]--;
		
	for (int x=0;x<n;x++)
		for (int y=0;y<m;y++)
			al[x].push_back(arr[x][y]);
			
	for (int x=0;x<m;x++){
		memset(r,-1,sizeof(r));
		
		for (int y=0;y<n;y++) {
			memset(visited,false,sizeof(visited));
			dfs(y);
		}
		
		for (int y=0;y<n;y++){
			for (int z=0;z<al[r[y]].size();z++){
				if (al[r[y]][z]/m==y){
					ans[r[y]][x]=al[r[y]][z];
					al[r[y]].erase(al[r[y]].begin()+z);
					break;
				}
			}
		}
	}
	
	for (int x=0;x<n;x++){
		for (int y=0;y<m;y++) cout<<ans[x][y]+1<<" ";
		cout<<endl;
	}
	
	vector<int> temp;
	
	for (int x=0;x<m;x++){
		temp.clear();
		for (int y=0;y<n;y++) temp.push_back(ans[y][x]);
		
		sort(temp.begin(),temp.end());
		
		for (int y=0;y<n;y++) ans[y][x]=temp[y];
	}
	
	for (int x=0;x<n;x++){
		for (int y=0;y<m;y++) cout<<ans[x][y]+1<<" ";
		cout<<endl;
	}
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    ll A, B, K;
    cin >> A >> B >> K;

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

    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int sum = 0;
		for (int i = 0; i < 10; i++) {
			sum += sc.nextInt();
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 17312
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int dp[21][100000];

signed main(void) {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    int l;
    cin >> l;

    rep(i,n){
        dp[0][i] = upper_bound(all(a),a[i]+l) - a.begin() - 1;
    }
    rep(k,20)rep(i,n){
        dp[k+1][i] = dp[k][dp[k][i]];
    }

    int q;
    cin >> q;
    rep(i,q){
        int a,b;
        cin >> a >> b;
        a--,b--;
        if(b<a)swap(a,b);
        int ans = 0;
        for(int k = 20; k >= 0; k--)if(dp[k][a]<b){
            a = dp[k][a];
            ans += 1<<k;
        }
        cout << ans + 1 << endl;
    }

}


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

UL gcd(UL a, UL b) { return b ? gcd(b, a % b) : a; }

int main() {

	UL X; cin >> X;
	UL ans = 360 / gcd(360, X);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    static int N;
    static string[] s;

    public static void Main(string[] args)
    {
        N = Input.NextInt();
        s = new string[N];
        for (int i = 0; i < N; i++)
        {
            s[i] = Input.NextString();
        }

        int n_BA = 0;
        int n_B_ = 0;
        int n__A = 0;
        for (int i = 0; i < N; i++)
        {
            var ss = s[i];
            var ss_a = ss[0];
            var ss_b = ss[ss.Length - 1];
            if (ss_a == 'B')
            {
                if (ss_b == 'A')
                    n_BA++;
                else
                    n_B_++;
            }
            else
            {
                if (ss_b == 'A')
                    n__A++;
            }
        }

        int ans = 0;
        if (n_BA > 0)
            ans = n_BA - 1;
        if (n_BA > 0 && n__A > 0)
        {
            ans++;
            n__A--;
        }
        if (n_BA > 0 && n_B_ > 0)
        {
            ans++;
            n_B_--;
        }
        ans += Math.Min(n__A, n_B_);

        for (int i = 0; i < N; i++)
        {
            var ss = s[i];

            var si = 0;
            while (true)
            {
                var x = ss.IndexOf("AB", si, StringComparison.Ordinal);
                if (x == -1)
                    break;
                si = x + 2;
                ans++;
            }
        }

        Console.WriteLine(ans);
    }
}

public static class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13652
// diverta2019_a
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n, k;
  cin >> n >> k;
  cout << n-k+1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
const int N = 1e5 + 7;
int a[N], n, x;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  cin >> n >> x;
  rep(i, 0, n) cin >> a[i];
  ll ans = 0;
  if (a[0] > x) ans += a[0] - x, a[0] = x;
  rep(i, 1, n) {
  	int ned = max(0, a[i] + a[i - 1] - x);
  	a[i] -= ned;
  	ans += ned;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
  int n,s;
  int witch[20000]={};
  int all;
  while(1){
    scanf("%d %d",&n,&s);
    if(n==0 && s==0) break;

    all=0;
    for(int i=0;i<n;i++){ scanf("%d",&witch[i]); }

    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        if((witch[i]+witch[j])>s) all++;
      }
    }
    printf("%d\n",all);
  }
  return 0;
}



Measured memory_bytes: 2028
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(i=0;i<n;i++)
#define ll long long
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x,y; cin >> x>>y;
	int sum = x +(y/2);
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<map>
#define LL long long
#define LD long double
using namespace std;
const int NN=100000 +117;
const int MM=100000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen(".out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
LL a[NN]={};
int ord[NN]={};
int siz[NN]={};
map<LL,int> ind;
bool cmp(int x,int y){
	return a[x]>a[y];
}
vector<int> p[NN]={};
int dis[NN]={};
void dfs(int x){
	for(int i=0;i<p[x].size();++i){
		int cur=p[x][i];
		dis[cur]=dis[x]+1;
		dfs(cur);
	}
}
int main(){
	//open();
	n=read();
	for(int i=1;i<=n;++i){
		scanf("%lld",&a[i]);
		ord[i]=i;
		ind[a[i]]=i;
	}
	sort(ord+1,ord+1+n,cmp);
	bool fl=0;
	for(int i=1;i<n;++i){
		int x=ord[i];
		siz[x]+=1;
		LL xt=a[x]-n+2*siz[x];
		if(xt>=a[x])fl=1;
		int tp=ind[xt];
		if(!tp){
			fl=1;
		}
		else{
			p[tp].push_back(x);
			siz[tp]+=siz[x];
		}
	}
	dfs(ord[n]);
	LL chk=0;
	for(int i=1;i<=n;++i)chk+=dis[i];
	if(chk!=a[ord[n]])fl=1;
	if(fl){
		printf("-1\n");
	}
	else{
		for(int x=1;x<=n;++x){
			for(int i=0;i<p[x].size();++i){
				printf("%d %d\n",x,p[x][i]);
			}
		}
	}

	close();
	return 0;
}

Measured memory_bytes: 17408
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int a1,b,c,d,i,j,a[1000],n,flg[1000],p1,p2;
	double mx,xx;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	for(i=0;i<n;i++)	flg[i]=0;
	sort(a,a+n);
	mx=-1.0;
	for(i=0;i<n-1;i++)	{
		c=a[i];
		flg[i]=1;
		for(j=i+1;j<n;j++)	{
			d=a[j];
			flg[j]=1;
			p1=n-1;
			while(1)	{
				if(flg[p1]==0)	{
					a1=a[p1];
					flg[p1]=1;
					break;
				}
				p1--;
			}
			p2=n-1;
			while(1)	{
				if(flg[p2]==0)	{
					b=a[p2];
					flg[p2]=1;
					break;
				}
				p2--;
			}
//			printf("a=%d b=%d c=%d d=%d\n",a1,b,c,d);	
			xx=(double)(a1+b)/(d-c);
			mx=max(xx,mx);
//			printf("%lf\n",xx);
			flg[j]=0;	flg[p1]=0;	flg[p2]=0;			
//			printf("i=%d j=%d\n",i,j);
		}
		flg[i]=0;
	}
	printf("%lf\n",mx);
	
    return 0;
}


Measured memory_bytes: 2792
s = str(input().split())
i = 0 + 2
while True:
    if s[i] == s[i + 1]:
        print_ans = 'Bad'
        break
    else:
        print_ans = 'Good'
    i += 1
    if i == 3 + 2:
        break
    
print(print_ans)

Measured memory_bytes: 61844
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int N; cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    int xor_all = 0;
    for (int i = 0; i < N; i++) {
        xor_all ^= a[i];
    }

    for (int i = 0; i < N; i++) {
        cout << (xor_all ^ a[i]) << endl;
    }
}


int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4044
#define _USE_MATH_DEFINES
#include <iomanip>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <tuple>
#include <climits>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef vector<vector<double>> VVD;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) (a).begin(),(a).end()

const int MOD = 1000000007;

template<class T>bool chmax(T &a, const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}

template<class T>bool chmin(T &a, const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}

int main(){
	cout<<fixed;
	int n;cin>>n;
	VD v(n);
	rep(i,n)cin>>v.at(i);
	sort(all(v));
	double ans=0;
	rep(i,n-1){
		if(i==0){
			ans=(v.at(0)+v.at(1))/2;
		}else{
			ans=(ans+v.at(i+1))/2;
		}
	}
	cout<<setprecision(9)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}



int main(){
    int H,W,N;
    cin >> H >> W >> N;
    int num_max=max(W,H);
    int num=0;
    int ans=0;
        while(num<N){
            num=num+num_max;
            ++ans;
        }
        cout << ans;
}

Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
--import Data.Array
--import Data.Array.Unboxed
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete

triMap f (x:xs@(y:z:_)) = f x y z : triMap f xs
triMap _ _ = []

main = do
    n <- getInt
    a <- (0:) . (++[0]) <$> getInts
    let def_cost = sum . binMap (\x y -> abs (x-y)) $ a
    let ress = map (+def_cost) . triMap (\x y z -> abs (x-z) - abs (x-y) - abs (y-z)) $ a
    mapM_ print ress
    

Measured memory_bytes: 29820
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    string s;
    cin >> s;
    bool f = s[0] == 'A';
    f &= (s.back() >= 'a' && s.back() <= 'z');
    int cnt = 0;
    for(int i = 2; i < (int)s.size()-1; ++i) {
        if(s[i] == 'C') cnt++;
    }
    f &= cnt == 1;
    REP(i, 1, s.size()) {
        if(s[i] != 'C') f &= s[i] >= 'a' && s[i] <= 'z';
    }
    cout << (f?"AC" : "WA") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e15;
 
int main() {
  ll n;
  cin >> n;
  vec a(n);
  for(ll i=0;i<n;i++) cin >> a[i];
  mat dp(n+1,vec(n+1,0));
  for(ll i=0;i<n;i++) dp[i][i]=0;
  for(ll len=1;len<=n;len++) {
    for(ll i=0;i+len<=n;i++) {
      ll j=i+len;
      if((n-len)%2==0) {
        dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1]);
      }
      else {
        dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1]);
      }
    }
  }
  cout << dp[0][n] << endl;
}

Measured memory_bytes: 70784
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            int MAX = 50000;
            int sqrtMAX = (int)Math.Sqrt(MAX);

            int[] isPrime = Enumerable.Range(0, MAX + 1).ToArray();
            isPrime[0] = isPrime[1] = -1;

            for (int i = 2; i <= sqrtMAX; i++)
            {
                if (isPrime[i] == -1) continue;

                for (int j = i * i; j <= MAX; j += i)
                {
                    isPrime[j] = -1;
                }
            }

            var primes = isPrime.Where(p => p != -1).ToArray();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int len = n / 2, count = 0;

                for (int i = 0; primes[i] <= len; i++)
                {
                    int checknum = n - primes[i];

                    if (isPrime[checknum] != -1) count++;
                }
                sb.AppendLine(count.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 10080
#include<bits/stdc++.h>
using namespace std;
int main(){long long n,k,q,i,s=0;
cin>>n;
long a[n+1],b[n+1],c[n];
for(i=1;i<=n;i++)
cin>>a[i];
for(i=1;i<=n;i++)
cin>>b[i];
for(i=1;i<n;i++)
cin>>c[i];
for(i=1;i<=n;i++){
    s=s+b[a[i]];
    if(i!=n){
        if((a[i]+1)==a[i+1])
        s=s+c[a[i]];
    }

}cout<<s;
    return 0;
}


Measured memory_bytes: 256