akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int n = io.nextInt();
		int[] a = new int[n+1];
		for(int i=1;i<=n;i++){
			a[i] = io.nextInt();
		}
	
		// + - 
		long sum = 0;
		long now=0;
		long border = 1;
		long end = 0;
		long ans_p=0;
	
		for(int i=1;i<=n;i++){
			sum += a[i];
			end = border-sum;
			if(border>0){
				if(now<end){
					ans_p += Math.abs(now-end);
					now = end;
				}
			}else{
				if(now>end){
					ans_p += Math.abs(now-end);
					now = end;
				}
			}
			border = -border;
		}
		
		//- +
		sum=0;
		now=0;
		border = -1;
		end = 0;
		long ans_m=0;
		
		for(int i=1;i<=n;i++){
			sum += a[i];
			end = border-sum;
			if(border>0){
				if(now<end){
					ans_m += Math.abs(now-end);
					now = end;
				}
			}else{
				if(now>end){
					ans_m += Math.abs(now-end);
					now = end;
				}
			}
			border = -border;
		}
		System.out.println(Math.min(ans_p,ans_m));
	}
}

Measured memory_bytes: 50244
#include<iostream>
#include<algorithm>
#include<functional>
#include<climits>

using namespace std;


template<class S=int, class T=std::less<S>, S nil=INT_MAX>
class RMQ{
friend class RMQ2D;

	static int calcsize(int n){
		int res=1;
		while(res<n)res<<=1;
		return res;
	}
	RMQ(){}
	~RMQ(){
		
	}
	void build(int n,const S a[],S *dat){
		int m=n;
		n=calcsize(n);
		//dat=new S[2*n-1];
		for(int i=0;i<m;i++)dat[n-1+i]=a[i];
		for(int i=m;i<n;i++)dat[n-1+i]=nil;
		for(int i=n-2;i>=0;i--){
			dat[i]=std::min(dat[i*2+1],dat[i*2+2],T());
		}
	}
	/*void update(int k,int a){//k番目をaに変更
		k+=n-1;
		dat[k]=a;
		while(k>0){
			k=(k-1)/2;
			dat[k]=std::min(dat[k*2+1],dat[k*2+2],T());
		}
	}*/
	S query(const S *dat,int a,int b,int k,int l,int r)const{//[a,b)の最小(大)値
		if(r<=a||b<=l)return nil;
		if(a<=l&&r<=b)return dat[k];
		else{
			S vl=query(dat,a,b,k*2+1,l,(l+r)/2);
			S vr=query(dat,a,b,k*2+2,(l+r)/2,r);
			return std::min(vl,vr,T());
		}
	}
};



class RMQ2D{
	typedef unsigned int S;
	typedef std::less<S> T;
	static const S nil=~0u;
	int h,w;
	S *datrmq;
	RMQ<S,T,nil> *rmq;
	int query(int a,int b,int k,int l,int r,int xs,int xe)const{
		if(r<=a||b<=l)return nil;
		if(a<=l&&r<=b)return rmq[k].query(datrmq+k*(2*w-1),xs,xe, 0,0,w);
		else{
			S vl=query(a,b,k*2+1,l,(l+r)/2,xs,xe);
			S vr=query(a,b,k*2+2,(l+r)/2,r,xs,xe);
			return std::min(vl,vr);
		}
	}
public:
	RMQ2D(int h,int w,const S a[]){
		S *dat;
		int n=h,m=w;
		h=this->h=RMQ<S,T,nil>::calcsize(h);
		w=this->w=RMQ<S,T,nil>::calcsize(w);
		datrmq=new S[(2*h-1)*(2*w-1)];
		dat=new S[2*w-1];
		for(int i=0;i<w;i++)dat[i]=nil;
		rmq=new RMQ<S,T,nil>[2*h-1];

		for(int i=0;i<n;i++)rmq[h-1+i].build(m,a+i*m,datrmq+(h-1+i)*(2*w-1));
		for(int i=n;i<h;i++)rmq[h-1+i].build(m,dat,datrmq+(h-1+i)*(2*w-1));
		for(int i=h-2;i>=0;i--){
			rmq[i].build(m,dat,datrmq+i*(2*w-1));
			for(int j=0;j<2*w-1;j++){
				S *a=datrmq+(i*2+1)*(2*w-1);
				S *b=datrmq+(i*2+2)*(2*w-1);
				datrmq[i*(2*w-1)+j]=std::min(a[j],b[j]);
				//rmq[i].dat[j]=std::min(rmq[i*2+1].dat[j],rmq[i*2+2].dat[j],T());
			}
		}
		delete[] dat;
	}
	~RMQ2D(){
		delete[] rmq;
		delete[] datrmq;
	}
	void update(int y,int x,int a){
		//「あとで」
	}
	int query(int ys,int ye,int xs,int xe)const{//[ys,ye)+[xs,xe)の最小(大)値
		return query(ys,ye,0,0,h,xs,xe);
	}
};

unsigned int g[1000000];
int main(){
	int r,c,q;
	while(cin>>r>>c>>q,r|c|q){
		for(int i=0;i<r*c;i++)cin>>g[i];
		RMQ2D rmq(r,c,g);
		for(int i=0;i<q;i++){
			int y1,x1,y2,x2;
			cin>>y1>>x1>>y2>>x2;
			cout<<rmq.query(y1,y2+1,x1,x2+1)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 37736
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  int N;
  while(cin >> N && N){
    int r[1000], w[1000];
    REP(i, N) cin >> r[i] >> w[i];
    REP(i, N) FOR(j, i + 1, N) if(r[i] > r[j]) {
      swap(r[i], r[j]);
      swap(w[i], w[j]);
    }
    int sum = 0;
    REP(i, N - 1) sum += r[i];
    if(sum >= r[N - 1]){
      REP(i, N) sum += w[i];
      cout << sum + r[N - 1] << endl;
    }else{
      int rest = r[N - 1] - sum;
      assert(rest > 0);
      assert(rest <= 1000);
      bool dp[1010] = {};
      dp[0] = true;
      for(int i = 0; i < N - 1; i++){
        for(int j = rest; j - w[i] >= 0; j--){
          dp[j] |= dp[j - w[i]];
        }
      }
      int ans = 2 * r[N - 1];
      int sum_w = 0;
      REP(i, N) sum_w += w[i];
      for(int i = rest; i >= 0; i--){
        if(dp[i]){
          ans += sum_w - i;
          break;
        }
      }
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n; cin >> n;
    string s; cin >> s;
    int r = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') r++;
    }
    if (r*2 > n) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

int main() {
	ll n, m;
	cin >> n >> m;
	cout << (n == m ? "Yes" : "No") << endl;
}


Measured memory_bytes: 764
from collections import deque

h, w = map(int, input().split())
CC = [list(map(int, input().split())) for _ in range(10)]
AA = [list(map(int, input().split())) for _ in range(h)]

total = 0
memo = [-1] * 10
for A in AA:
    for a in A:
        if a == -1:
            continue
        if memo[a] != -1:
            total += memo[a]
        else:
            best = CC[a][1]
            q = deque()
            q.append((a, 0))
            used = {a}
            while q:
                node, cost = q.popleft()
                for to in range(10):
                    new_cost = cost + CC[node][to]
                    if to == node or new_cost >= best:
                        continue
                    if to == 1:
                        if new_cost < best:
                            best = new_cost
                    else:
                        q.append((to, new_cost))
                        used.add(to)
            memo[a] = best
            total += memo[a]
print(total)


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i, z, n) for(ll i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;
ll res(ll A,ll B,ll x){
    return  floor(double(A)/double(B)*double(x))-A*floor(double(x)/double(B));

}
int main(){
  ll A,B,N;
  ll x;
  cin >> A >> B >> N;
  ll max_res=0;
  if(N<B){
    cout << res(A,B,N) << endl;
    return 0;
  }else{
    cout << max(res(A,B,B-1),res(A,B,B)) << endl;
    return 0;
  }
  return 0;
}



Measured memory_bytes: 3600
n, k = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(key=abs, reverse=1)

mod = 10**9+7
ans = 1
sign = 1
for i in range(k):
    ans *= a[i]
    ans %= mod
    if a[i] < 0:
        sign *= -1
    elif a[i] == 0:
        sign = 0
if sign >= 0:
    print(ans)
else:
    t = None
    ok = True
    for i in reversed(range(k)):
        if a[i] < 0:
            break
    else:
        ok = False
    for j in range(k, n):
        if a[j] > 0:
            break
    else:
        ok = False

    if ok:
        t = (a[i], a[j])

    ok = True
    for i in reversed(range(k)):
        if a[i] > 0:
            break
    else:
        ok = False
    for j in range(k, n):
        if a[j] < 0:
            break
    else:
        ok = False

    if ok:
        if t is None:
            t = (a[i], a[j])
        else:
            if (t[1]*a[i] - t[0]*a[j]) * t[0]*a[j] < 0:
                t = (a[i], a[j])

    if t is None:
        ans = 1
        a.reverse()
        for i in range(k):
            ans *= a[i]
            ans %= mod
        print(ans)
    else:
        print(ans*t[1] * pow(t[0], mod-2, mod) % mod)


Measured memory_bytes: 31592
let draw h w =
	let rec draw_s w =
		match w with
		|0 -> print_string "\n"
		|_ -> print_string "#";draw_s (w-1)
	in
	let draw_d w =
		let rec dot w =
			match w with
			|0 -> print_string "\n"
			|1 -> print_string "#";dot 0
			|_ -> print_string ".";dot (w-1)
		in
		print_string "#";dot (w-1)
	in
	let rec draw_d_n w n =
		match n with
		|0 -> ()
		|_ -> draw_d w;draw_d_n w (n-1)
	in
	draw_s w;draw_d_n w (h-2);draw_s w;print_string "\n";;

let rec loop () =
	Scanf.sscanf(read_line()) "%d %d" (fun x y -> if x = 0 && y = 0 then () else (draw x y;loop()));;

loop();;



Measured memory_bytes: 2264
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int inf=1e9,mod=998244353;
int n,sl,fh,ans,a[mxn];
char s[mxn];
int rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
bool check(int x,int y,int z)
{
	a[1]=x;a[2]=y;a[3]=z;
	int p=1;
	for(int i=1;p<=3&&i<=n;++i)
		if(s[i]-'0'==a[p])
			p++;
	return p>3;
}
int main()
{
	n=rd();scanf("%s",s+1);
	for(int i=0;i<=9;++i)
		for(int j=0;j<=9;++j)
			for(int k=0;k<=9;++k)
				ans+=check(i,j,k);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    int r;
    cin >> r;
    cout << r*r << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

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


int main(){
  int N;
  cin >> N;
  ll t[N];
  cin >> t[0];
  ll ans = t[0];
  rep1(i,N-1){
    cin >> t[i];
    ans = ans/gcd(ans,t[i]) * t[i];
  }
  cout << ans << endl;
  
    
  return 0;

}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
int a,b,c,t=0;

	scanf("%d %d %d",&a,&b,&c);
	
	if(a<=b){
		t+=a;
		if(b<=c){
			t+=b;	
		}else{
			t+=c;	
		}
	}else{
		t+=b;
		if(a<=c){
			t+=a;	
		}else{
			t+=c;	
		}
	}
	
	printf("%d\n",t);
return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int palin(const char *s)
{
    int l=strlen(s);
    char t[l+1];
    for(int i=0;i<l;i++)
    {
        t[i]=s[l-i-1];
    }
    t[l]='\0';
    if(strcmp(s,t)==0)
    {
        return 0;
    }
    else
    {
        return 1;
    }
    
}


int main()
{

    char s[100];
    scanf("%s",s);
    int flag;

    flag=palin(s);

    if(flag!=0)
    {
        printf("No\n");
    }
    else
    {
        int n=strlen(s);
        char t[((n-1)/2)+1];
        for(int i=0;i<(strlen(s)-1)/2;i++)
        {
            t[i]=s[i];
        }
        t[sizeof(t)-1]='\0';

        flag=palin(t);
        
        if(flag==0)
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }
    }
    return 0;
}

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

int main(void) {
    double a,b,corner;
    cin>>a>>b>>corner;
    double s=0.0,l=0.0,h=0.0;
    s=(a*b*sin(corner*M_PI/180.00000000))/2;
    l=a+b+(sqrt(a*a+b*b-2*a*b*cos(corner*M_PI/180.00000000)));
    h=2*s/a;
    printf("%.8f\n",s);
    printf("%.8f\n",l);
    printf("%.8f\n",h);
    return 0;
}

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int n;
	cin >> n;

	vi f(n+1,0);
	FOR(x,1,101){
		FOR(y,1,101){
			FOR(z,1,101){
				int calc = x*x + y*y + z*z + x*y + y*z + z*x;
				if(calc <= 10000){
					f[calc]++;
				}
			}
		}
	}

	FOR(i,1,n+1){
		cout << f[i] << endl;
	}

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    int k; 
    string s;
    cin >> s >> k;
    set<string> st;
    for(int i = 0; i < s.length(); ++i){
        for(int L = 1; i + L <= s.length() && L <= k; ++L){
            st.insert(s.substr(i, L));
            while(st.size() > k)st.erase(--st.end());
        }
    }
    cout << *st.rbegin() << endl;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))
SUM=B[A[0]-1]
for i in range(1,len(A)):
    if A[i]==A[i-1]+1:
        SUM+=B[A[i]-1]+C[A[i-1]-1]
    else:
        SUM+=B[A[i]-1]
print(SUM)

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

int main(){
	int a,b;
  	cin >> a >> b;
  	int c[13]={13,1,2,3,4,5,6,7,8,9,10,11,12};
  	if (c[a-1]>c[b-1]) cout <<"Alice"<<endl;
  	else if (c[a-1]==c[b-1]) cout <<"Draw"<<endl;
  	else cout <<"Bob"<<endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  ll N; cin>>N;
  ll A[N+1], B[N];
  for(int i=0; i<N+1; i++){
    cin>>A[i];
  }
  for(int i=0; i<N; i++){
    cin>>B[i];
  }
  ll ans=0;
  for(int i=0; i<N; i++){
    if(A[i]<B[i]){
      ans+=A[i];
      B[i]-=A[i];
    }
    else{
      ans+=B[i];
      B[i]=0;
    }
    
    if(A[i+1]<B[i]){
      ans+=A[i+1];
      A[i+1]=0;
    }
    else{
      ans+=B[i];
      A[i+1]-=B[i];
    }
  }
  cout<<ans<<endl;
}

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

int a, b, c, k, ans;

int main() {
    cin >> a >> b >> c >> k;
    if (k){
        ans += min(k, a);
        k -= min(k, a);
    }
    if (k){
        k -= min(k, b);
    }
    if (k){
        ans -= min(k, c);
        k -= min(k, c);
    }
    cout << ans << "\n";
}


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

int main()
{  
   int N,M;
   cin>>N;
   vector<string> B(N);
   for(int i=0;i<N;i++) cin>>B[i];
   cin>>M;
   vector<string> R(M);
   for(int i=0;i<M;i++) cin>>R[i];
   
   int coin=0;
   
   for(int i=0;i<N;i++){
       int c=0;
       for(int j=0;j<N;j++){
           if(B[i]==B[j]) c++;
       }
       for(int j=0;j<M;j++){
           if(B[i]==R[j]) c--;
       }
       coin=max(coin,c);
       
   }
   cout<<coin<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;

#define REP(i,a,b) for(i=a; i<b; ++i)
#define rep(i,n) REP(i,0,n)

int b[501],r[501],m,n;
int primes[10050];
vector<int> G[1001];

int gcd(int x,int y) {
    if(y == 0) return x;
    return gcd(y,x%y);
}

bool bfs(vector<int> &pair_v,vector<int> &dist) {
    queue<int> Q;
    const int NIL = n+m;
    fill(dist.begin(), dist.end(), 1<<29);
    for(int i=0; i<n+m; ++i)
        if(pair_v[i] == NIL) {
            dist[i] = 0;
            Q.push(i);
        }

    while(!Q.empty()) {
        int v = Q.front(); Q.pop();
        if(v != NIL) {
            for(int i=0; i<G[v].size(); ++i) {
                if(dist[pair_v[G[v][i]]] == 1<<29) {
                    dist[pair_v[G[v][i]]] = dist[v]+1;
                    Q.push(pair_v[G[v][i]]);
                }
            }
        }
    }
    return dist[NIL] != 1<<29;
}

bool dfs(int v,vector<int> &pair_v,vector<int> &dist) {
    const int NIL = n+m;
    if(v != NIL) {
        for(int i=0; i<G[v].size(); ++i) {
            int u = G[v][i];
            if(dist[pair_v[u]] == dist[v]+1) {
                if(dfs(pair_v[u],pair_v,dist)) {
                    pair_v[u] = v;
                    pair_v[v] = u;
                    return true;
                }
            }
        }
        dist[v] = 1<<29;
        return false;
    }
    return true;
}

int biparate_matching() {
    vector<int> pair_v(n+m+1, n+m); // NIL == n+m
    vector<int> dist(n+m+1);
    int matching = 0;
    int bc = 0;
    while(bfs(pair_v,dist)) {
        //cout<<"bfs : "<<bc<<endl;
        bc++;
        for(int i=0; i<n+m; ++i) {
            if(pair_v[i] == n+m) if(dfs(i,pair_v,dist)) {
                    matching++;
                }
        }
    }
    return matching;
}

int main() {
    int i,j;
    while(cin>>m>>n, m|n) {
        rep(i,m) cin>>b[i];
        rep(i,n) cin>>r[i];


        rep(i,n+m) G[i].clear();
        rep(i,m) rep(j,n) {
            if(gcd(b[i],r[j]) > 1) {
                G[i].push_back(j+m);
                G[j+m].push_back(i);
                //cout<<"add edge "<<i<<" "<<j<<endl;
            }
        }

        //cout<<"let's matching"<<endl;

        cout<<biparate_matching()<<endl;
    }
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	s[2] == s[3] && s[4] == s[5] ? cout << "Yes" : cout << "No";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

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

    int max_profit = numeric_limits<int>::min();
    int min_value = numeric_limits<int>::max();

    for (int x; n-- && cin >> x;) {
        int profit = x - min_value;
        if (profit > max_profit)
            max_profit = profit;

        if (x < min_value)
            min_value = x;
    }

    cout << max_profit << endl;

    return 0;
}

Measured memory_bytes: 1164
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
s = sum(a)
a = Counter(a)
for _ in range(q):
    b, c = map(int, input().split())
    if b in a:
        a[c] += a[b]
        s += (c-b) * a[b]
        a[b] = 0
    print(s)

Measured memory_bytes: 21480
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC target ("avx,tune=native")

#include<bits/stdc++.h>
using namespace std;
const int maxn=3010;
int mod;
void plusle(int &a,int b){
    a+=b;if(a>=mod)a-=mod; return;
}
void minun(int &a,int b){
    a-=b; if(a<0)a+=mod; return;
}
int add(int a,int b) {
  a+=b;
  return a>=mod?a-mod:a;
}
int sub(int a,int b) {
  a-=b;
  return a<0?a+mod:a;
}
int mul(int a,int b) {
  return (int)((long long)a*b%mod);
}
int power(int a,int b) {
  int res=1;
  while (b>0) {
    if (b&1) {
      res=mul(res,a);
    }
    a=mul(a,a);
    b>>=1;
  }
  return res;
}
int inv(int x){
    return power(x,mod-2);
}
vector<int> mul(const vector<int> &p,int j){
    ///c[0]+(c[1]*x)+(c[2]*(x^2)+...)c[n-1]*(x^(n-1))
    ///(x-j)
    int n=(int)p.size();
    vector<int> s(n+1,0);
    for(int i=0;i<n;i++){
        plusle(s[i+1],p[i]);
    }
    for(int i=0;i<n;i++){
        plusle(s[i],mul(p[i],j));
    }
    return s;
}
vector<int> d( vector<int> p,int j){
    ///c[0]+c[1]*x+...+c[n-1]*(x^(n-1))
    ///x-j
    int n=(int)p.size();
    vector<int> s(n-1,0);
    for(int i=n-1;i>0;i--){
        plusle(p[i-1],mul(j,p[i]));
        s[i-1]=p[i];
    }
    return s;
}
int get(const vector<int> &g,int x){
    int res=0;
    int now=1;
    for(int i=0;i<(int)g.size();i++){
        plusle(res,mul(g[i],now));
        now=mul(now,x);
    }
    return res;
}
int a[maxn];

int main(){
    int p;
    scanf("%d",&p);
    mod=p;
    for(int i=0;i<p;i++){
        scanf("%d",&a[i]);
    }
    vector<int> t={0,1};
    for(int i=1;i<p;i++){
        t=mul(t,i);
    }
    vector<int> aa(p,0);
    for(int i=0;i<p;i++){
        if(a[i]==0)continue;
        vector<int> s=d(t,i);
        int cur=get(s,i);
        cur=inv(cur);
        for(int i=0;i<(int)s.size();i++){
            plusle(aa[i],mul(s[i],cur));
        }
    }
    for(int i:aa){
        printf("%d ",i);
    }
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next() + sc.next();
        sc.close();
        int num = Integer.parseInt(str);

        int rt = (int) Math.sqrt(num);

        if (rt * rt == num) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 21844
// template version 1.13
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  string s;cin>>s;
  if (s=="SUN"){
    cout << 7 << endl;
  }
  if (s=="MON"){
    cout << 6 << endl;
  }
  if (s=="TUE"){
    cout << 5 << endl;
  }
  if (s=="WED"){
    cout << 4 << endl;
  }
  if (s=="THU"){
    cout << 3 << endl;
  }
  if (s=="FRI"){
    cout << 2 << endl;
  }
  if (s=="SAT"){
    cout << 1 << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int H, N;
    
    cin >> H >> N;

    int A[N];
    for (int i = 0; i < N; i++){
        cin >> A[i];
    }

    for (int i = 0; i < N; i++){
        H = H - A[i];
    }

    if (H > 0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    
    return 0;
}


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

#define int long long

int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

string s;

signed main() {
    cin >> s;
    cout << s[0] + s[1] + s[2] - 3 * '0' << endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

h, w = map(int, raw_input().split())
N = int(raw_input())
l = np.array(map(int, raw_input().split()))

z = np.zeros((h * w, ), dtype=np.int64)

c = 0
for i in range(0, N):
    z[c:c + l[i]] = i + 1
    c += l[i]

for k in range(0, h):
    if k % 2 == 0:
        print str(z[k * w:k * w + w])[1:-1]
    else:
        print str(z[k * w:k * w + w][::-1])[1:-1]



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

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

    int N;
    cin >> N;
    string S;
    cin >> S;
    int len = S.size();

    for(int i = 0; i < len; i++) {
        printf("%c", (S[i] - 'A' + N + 26) % 26 + 'A');
    }

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
ans = 1
if N == 1:
    print(M)
else:
    for n in range(2, int(M ** 0.5) + 1):
        if M % n == 0 and M / N >= n:
            ans = max(ans, n)
            if M // n * N <= M:
                ans = max(ans, M // n)
    print(ans)


Measured memory_bytes: 3060
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  ll dp[1000010];
  rep(i,N){
    dp[i] = INF;
  }
  dp[0] = INF;
  vector<ll> h(N);
  rep(i,N){
    cin >> h[i];
  }
  dp[1] = 0;
  for(int i = 2;i <= N;i++){
    dp[i] = min(dp[i-1]+abs(h[i-1]-h[i-2]),dp[i-2]+abs(h[i-1]-h[i-3]));
  }
/*
  rep(i,N){
    cout << dp[i] <<endl;
  }
  */

  cout << dp[N] <<endl;
}


Measured memory_bytes: 3328
import java.util.ArrayList;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main{
	private static final int MAX_NUMBERS = 4;
	private static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		int[] a = new int[MAX_NUMBERS];
		int[] b = new int[MAX_NUMBERS]; 
		ArrayList<Integer> resultHit = new ArrayList<Integer>();
		ArrayList<Integer> resultBrow = new ArrayList<Integer>();
		
		try{
			while(true){
				setInputs(a, b);
				resultHit.add(getNumHit(a, b));
				resultBrow.add(getNumBrow(a, b));
			}
		}catch(NoSuchElementException e){
			//½àµÈ¢ÅÌÉ¤Âé
		}
		
		//qbgÆu[ÌÊXgðoÍ·é
		for(int i = 0; i < resultHit.size(); i++){
			System.out.println(resultHit.get(i) + " " + resultBrow.get(i));
		}
		
	}
	
	private static void setInputs(int[] a, int[] b){
		for(int i = 0; i < MAX_NUMBERS; i++){
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < MAX_NUMBERS; i++){
			b[i] = sc.nextInt();
		}
	}
	
	private static boolean checkBrow(int[] a, int[] b, int index){
		int target = b[index];
		for(int i = 0; i < MAX_NUMBERS; i++){
			if(i == index){
				//u[Í¯¶ÊuÌð`FbNµÈ¢
			}
			else if(a[i] == target){
				return true;
			}
		}
		return false;
	}
	
	private static boolean checkHit(int[] a, int[] b, int index){
		if(a[index] == b[index]){
			return true;
		}
		else{
			return false;
		}
	}
	
	public static int getNumBrow(int[] a, int[] b){
		int count = 0;
		for(int i = 0; i < MAX_NUMBERS; i++){
			if(checkBrow(a, b, i)){
				count++;
			}
		}
		return count;
	}
	
	public static int getNumHit(int[] a, int[] b){
		int count = 0;
		for(int i = 0; i < MAX_NUMBERS; i++){
			if(checkHit(a, b, i)){
				count++;
			}
		}
		return count;
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll t;
ll ret = 0;

void input() {
  IN(N);
}

void solve() {
  ret = pow(N, 3);
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

//Village
public class Main{

	double[] x, y;
	
	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double R = sc.nextDouble(), EPS = 1e-10;
		double cos1 = Math.cos(1*Math.PI/180), sin1 = Math.sin(1*Math.PI/180);
		x = new double[n]; y = new double[n];
		for(int i=0;i<n;i++){
			double X = sc.nextDouble(), Y = sc.nextDouble();
			x[i] = cos1*X-sin1*Y;
			y[i] = sin1*X+cos1*Y;
		}
		Integer[] v = new Integer[n];
		for(int i=0;i<n;i++)v[i]=i;
		Arrays.sort(v, new Comparator<Integer>() {
			public int compare(Integer o1, Integer o2) {
				return (int)Math.signum(x[o1]-x[o2]);
			}
		});
		int res = 0;
		boolean[] u = new boolean[n];
		for(int i=0;i<n;i++){
			int idx = v[i];
			if(u[idx])continue;
			u[idx] = true;
			res++;
			double lx = x[idx]-2*R-EPS, rx = x[idx]+2*R+EPS;
			int l = 0, r = n;
			while(r-l>1){
				int m = (l+r)/2;
				if(lx<=x[v[m]])r=m;
				else l=m;
			}
			int k1 = l;
			l = 0; r = n;
			while(r-l>1){
				int m = (l+r)/2;
				if(rx<x[v[m]])r=m;
				else l=m;
			}
			int k2 = r;
			if(k2==r)k2--;
			for(int j=k1;j<=k2;j++){
				int k = v[j];
				if(u[k])continue;
				if(Math.sqrt((x[idx]-x[k])*(x[idx]-x[k]) + (y[idx]-y[k])*(y[idx]-y[k])) < 2*R+EPS){
					u[k] = true;
				}
			}
		}
		System.out.println(res);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 20000
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
	int R[MAX], n;

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

	int maxv = -2000000000; // ???????°??????????????????????????¨????
	int minv = R[0];

	for (int i = 1; i < n; i++) {      // ????????§??????R[i]?????????????????°??????????????????
		maxv = max(maxv, R[i] - minv); // ?????§????????´??°
		minv = min(minv, R[i]);        // ???????????§???????°?????????????????????????
	}

	cout << maxv << endl;

	return 0;
}

Measured memory_bytes: 1940
import sys


class AlgSegmentTreeMin:
    def __init__(self, n, default_value):
        self.Nelem = n
        self.default_value = default_value
        self.size = 1 << (n.bit_length())
        self.data = [default_value] * (2 * self.size)

    def update(self, i, x):
        i += self.size
        self.data[i] = x
        i >>= 1
        while i:
            x = self.data[i + i]
            y = self.data[i + i + 1]
            self.data[i] = min(x, y)
            i >>= 1

    def get_value(self, left, right):
        left += self.size
        right += self.size + 1
        x = self.default_value
        while left < right:
            if left & 1:
                y = self.data[left]
                x = min(x, y)
                left += 1
            if right & 1:
                right -= 1
                y = self.data[right]
                x = min(x, y)
            left >>= 1
            right >>= 1
        return x



def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, input().rstrip('\n').split()))
    stree = AlgSegmentTreeMin(n, 10 ** 15)
    lrc = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    lrc.sort()
    stree.update(0, 0)
    for l, r, c in lrc:
        l -= 1
        r -= 1
        tm = stree.get_value(l, r-1)
        now = stree.get_value(r, r)
        tm = tm + c if tm + c < now else now
        stree.update(r, tm)
    mt = stree.get_value(n-1, n)
    print(mt if mt != stree.default_value else -1)


if __name__ == '__main__':
    solve()


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

/* TLE
int64_t Lucas(int n) {
  // base case
  if (n == 0) return 2;
  if (n == 1) return 1;
  
  // induction step
  if (n >= 2) return Lucas(n - 1) + Lucas(n - 2);
}
*/

int64_t Lucas(int N) {
  if (N == 0) return 2;
  if (N == 1) return 1;
  if (N >= 2) {
    int i = 2;
    int64_t luc_i = 3, luc_i_minus_1 = 1, luc_i_minus_2 = 2;
    while (i < N) {
      i++;
      luc_i_minus_2 = luc_i_minus_1;
      luc_i_minus_1 = luc_i;
      luc_i = luc_i_minus_1 + luc_i_minus_2;
    }
    return luc_i;
  } 
}

int main() {
/*  for (int i = 0; i <= 86; i++) {
    cout << "Lucas(" + to_string(i) + ") = " + to_string(Lucas(i)) << endl;
  }
*/  
  int N;
  cin >> N;
  cout<< Lucas(N);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

void square(double, double, double, double, double, double);
double edge(double, double, double, double);
void center(double, double, double, double, double, double);

double xp, yp;

int main () {

	double x1, y1, x2, y2, x3, y3, n;

	cin >> n;

	for(int i=0; i<n; i++) {
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		square(x1, y1, x2, y2, x3, y3);
	}

}


void square(double x1, double y1, double x2, double y2, double x3, double y3) {

	double r, a, b, c, s;

	a=edge(x1, x2, y1, y2);
	b=edge(x2, x3, y2, y3);
	c=edge(x3, x1, y3, y1);
	center(x1, y1, x2, y2, x3, y3);
	s=(a+b+c)/2;
	r=0.25*a*b*c/sqrt(s*(s-a)*(s-b)*(s-c));
	printf("%.3f %.3f %.3f\n", xp, yp, r);

}

double edge(double a, double b, double c, double d) {

	return sqrt(pow(a-b, 2)+pow(c-d, 2));

}

void center(double x1, double y1, double x2, double y2, double x3, double y3) {

	double a1=2*(x2-x1);
	double b1=2*(y2-y1);
	double c1=x1*x1-x2*x2+y1*y1-y2*y2;
	double a2=2*(x3-x1);
	double b2=2*(y3-y1);
	double c2=x1*x1-x3*x3+y1*y1-y3*y3;
	xp=(b1*c2-b2*c1)/(a1*b2-a2*b1);
	yp=(c1*a2-c2*a1)/(a1*b2-a2*b1);

}

Measured memory_bytes: 0
using System;

class D {
    static long F(long b, long n) {
        var answer = 0L;
        while (n != 0L) {
            answer += n % b;
            n /= b;
        }
        return answer;
    }

    static long Solve(long n, long s) {
        if (n == s) return n + 1L;
        var sqrtN = (long)Math.Round(Math.Sqrt(n));
        var sqrtNLower = sqrtN;
        if (n < sqrtNLower * sqrtNLower) --sqrtNLower;
        var sqrtNUpper = sqrtN;
        if (sqrtNUpper * sqrtNUpper < n) ++sqrtNUpper;
        for (long b = 2L; b < sqrtNUpper; ++b)
            if (F(b, n) == s) return b;
        for (long s1 = sqrtNLower; s1 != 0L; --s1) {
            var s2 = s - s1;
            var b = (n - s2) / s1;
            if (b >= 2L && F(b, n) == s) return b;
        }
        return -1L;
    }

    public static void Main() {
        var n = long.Parse(Console.ReadLine());
        var s = long.Parse(Console.ReadLine());
        Console.WriteLine(Solve(n, s));
    }
}


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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define bits(n) __builtin_popcount(n)


void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int cr=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
        cr++;
    }
    int res=0;
    for(int i=0;i<cr;i++)
    {
        if(s[i]=='W')
        res++;
    }
    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

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

Measured memory_bytes: 3748
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


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

  int a = 4*x - y;
  int b = -2*x + y;

  bool ans = true;
  if (a < 0) ans = false;
  if (b < 0) ans = false;
  if (a%2) ans = false;
  if (b%2) ans = false;

  cout << (ans ? "Yes" : "No") << "\n";
  return 0;
}


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

using namespace std;

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int main()
{
	int N;
	cin >> N;
	string s;
	cin >> s;
	int st = 0;
	int go = 0;
	rep(i, N) {
		if (s[i] == ')') {
			go--;
			if (go == -1) {
				st++;
				go = 0;
			}
		} else {
			go++;
		}
	}
	rep(i, st) cout << '(';
	cout << s;
	rep(i, go) cout << ')';
	cout << endl;
}


Measured memory_bytes: 256
s = list(input())

#str.reverse()も可能
s = "".join(s[::-1])
dream = "dream"
dream_r = "".join(dream[::-1])
dreamer = "dreamer"
dreamer_r = "".join(dreamer[::-1])
erase = "erase"
erase_r = "".join(erase[::-1])
eraser = "eraser"
eraser_r = "".join(eraser[::-1])



# 部分一致があるから、erのついている方を先にreplaceを用いて削除する
# replaceは元のstrを書き換えないので、sに代入してあげる必要がある
# dreamerの逆からreplaceすると、eraserの逆の頭の部分のreがdreamの逆とくっついて消えることがあったので順番は注意
s = s.replace(eraser_r, "")
s = s.replace(erase_r, "")
s = s.replace(dreamer_r, "")
s = s.replace(dream_r, "")



ans = "YES" if s == "" else "NO"
print(ans)

Measured memory_bytes: 4652
#include <iostream>
#include <vector>

using namespace std;

int main() {
  string S;
  cin >> S;

  int N = S.size();
  vector<int> s(N);
  for (int i = 0; i < N; ++i) s[i] = S[i] - '0';

  int64_t sum = 0;
  for (int i = 1 << (N - 1); i < 1 << N; ++i) {
    int64_t cur = 0;
    for (int j = 0; j < N; ++j) {
      cur = cur * 10 + s[j];
      if (i & (1 << j)) {
        sum += cur;
        cur = 0;
      }
    }

  }

  cout << sum << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

ll N, M;
string s;


void solve() {
    cin >> N >> M;
    if (N + M <= 16 && N <= 8 && M <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
}

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string n;
    cin >> n;
    int len=n.size();
    int sum=0;
    rep(i, len){
        sum += n[i] - '0';
    }   
    if(sum%9){
        cout << "No";
    }else{
        cout << "Yes";
    }
    cout << endl;
    return 0;
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

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

const int maxn = 1e5 + 5;

int n;
int a[maxn];
int id[maxn];

bool cmp(int i, int j){
    return a[i] < a[j];
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        id[i] = i;
    }
    sort(id + 1, id + 1 + n, cmp); 
    int ans = 0;
    for(int i = 1;i <= n;i++){
        if((id[i] - i) % 2){
            ans++;
        }
    }
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
constexpr int  INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	string s;
	cin >> s;
	if (s[0] == 'a' || s[0] == 'i' || s[0] == 'u' || s[0] == 'e' || s[0] == 'o') {
		cout<<"vowel"<<endl;
	}
	else {
		cout<<"consonant"<<endl;
	}
}

Measured memory_bytes: 256
n = int(input())
s = input()
rgb = [s.count('R'), s.count('G'), s.count('B')]

cnt = rgb[0]*rgb[1]*rgb[2]
for i in range(n-2):
    j = 1
    while i+j*2 <= n-1:
        if not (s[i] == s[i+j] or s[i+j] == s[i+j*2] or s[i] == s[i+j*2]):
            cnt -= 1
        j += 1

print(cnt)

Measured memory_bytes: 9208
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>
#include<time.h>

using namespace std;


#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;


/*vectorの要素を全部確認するやつだよ。普通に拡張for文したほうがいいよ。

for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}

*/


/*for文でx,yを上下左右確認するやつだよ。正直使いづらいよ。

int dy[] = { 0, 1, 0, -1 };
int dx[] = { 1, 0, -1, 0 };


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}

*/


/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}

*/


/*実行開始からの経過時間を表すよ。

while (clock() < 1900000) {  }

*/


/*まだ使えないテクニックのメモだよ。

for (int bit = 0; bit < (1<<n); ++bit)//bit全探索用のfor文だよ

*/


/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; ++i) {
	for (int j = 0; j < w; ++j) {

	}
}

*/



int main() {
	int n;

	while (1) {
		cin >> n;
		if (n == 0) { break; }


		int a[105];
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		sort(a, a + n);
		int ans = 0;
		int k = 0;
		for (int i = 1; i < n - 1; i++) {
			ans += a[i];
			k++;
		}
		cout << ans / k << endl;
	}


	return 0;
}



Measured memory_bytes: 3116