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

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int[] x = new int[N];
        int[] y = new int[N];
        double[][] r = new double[N][N];
        double sum = 0;
        int a = 1;

        for(int i=1; i<=N; i++){
            a *= i;
        }

        for(int i=0; i<N; i++){
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                if(j!=i){
                    r[i][j] = Math.sqrt(Math.pow(x[i] - x[j], 2) + Math.pow(y[i] - y[j], 2));
                    sum += r[i][j] * a / N;
                }
            }
        }
        System.out.println(sum/a);
    }
}

Measured memory_bytes: 23764
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
//#define all(v) ((v).begin(),(v).end())
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    ll n,k;
    cin>>n>>k;
    vector<pair<ll,ll>> p(n);
    rep(i,0,n){
        cin>>p[i].fi>>p[i].se;
    }

    sort(all(p));
    ll t=0;
    rep(i,0,n){
        t+=p[i].se;
        if(t>=k){
            cout<<p[i].fi<<endl;
            return 0;
        }
    }


}




Measured memory_bytes: 1792
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

S = 0

for k in range (0 , N):
	S += A[k]

m = 0
for j in range (0 , N):
	if A[j] >= (S / ( 4 * M )):
		m = m + 1

if m >= M:
  	print ( "Yes" )
else:
 	print ( "No" ) 


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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scahf("%c",&a);
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

const int N = 2e5 + 10;
char a[N];
int n;

int main() {
    ss(a + 1);
    n = strlen(a + 1);
    int res = 0;
    repi(i, 1, n)res += a[i] - '0';
    puts(res % 9 ? "No" : "Yes");
    return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

itn N;
itn A[202020];
int B[202020];
int C[202020];


void solve() {
    int tmp = 0;
    FOR(N) {
        C[i] = B[i] * (B[i] - 1) / 2;
        tmp += C[i];
    }
    FOR(N) {
        int a = A[i];
        int b = B[a] - 1;
        int ans = tmp - C[a] + (b >= 1 ? b * (b - 1) / 2 : 0);
        cout << ans << ' ';
    }
    cout << "\n";
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N) {
        cin >> A[i];
        A[i]--;
        B[A[i]]++;
    }


    solve();
    return 0;
}


Measured memory_bytes: 7040
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    string S;
    map<char, int> mci;
    cin >> S;
    REP(i, S.size()) mci[S[i]]++;
    if (mci.size() == S.size()) cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
}

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

int r;                               //変数宣言
int c;
int dp[200][200];
int main() {
	cin >> r >> c;
	for (int i = 0; i <= r; i++)
		dp[i][c] = 0;
	for (int i = 0; i < c; i++)
		dp[r][i] = 0;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> dp[i][j];
			dp[i][c] += dp[i][j];
			dp[r][j] += dp[i][j];
			dp[r][c] += dp[i][j];
		}
	}
	for (int i = 0; i <= r; i++) {
		for (int j = 0; j < c; j++)
			cout << dp[i][j] << " ";
		cout << dp[i][c] << endl;
	}
	return 0;
}



Measured memory_bytes: 3184
#include<stdio.h>
int main(){
	int i,j,n;
	char a[10000]={0};
	while(scanf("%s",a)!=EOF){
		j=0,n=0;
		for(i=2;a[i]!='\0';i++){
			if(a[i-2]=='J'&&a[i-1]=='O'&&a[i]=='I')++j;
			if(a[i-2]=='I'&&a[i-1]=='O'&&a[i]=='I')++n;
		}
		printf("%d\n%d\n",j,n);
	}
	return 0;
}


Measured memory_bytes: 2080
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();
        long ans = 1;
        long A[] = new long[N];
        long max = 1000000000000000000l;

        for(int i = 0; i < N; i++) {
            A[i] = scan.nextLong();
            if(A[i] == 0) {
                os.println(0);
                return;
            }
        }

        for(int i = 0; i < N; i++) {
            long ten = 0;
            long temp = A[i];
            while(temp/10 > 1){
                temp /= 10;
                ten++;
            }
            temp = ans;
            while(temp/10 > 1){
                temp /= 10;
                ten++;
            }
            if(ten > 18) {
                os.println(-1);
                return;
            }
            if(ten == 18) {
                temp = ans;
                while(temp/10 > 1){
                    temp /= 10;
                }
                int ansFirst = (int)temp;
                temp = A[i];
                while(temp/10 > 1){
                    temp /= 10;
                }
                int AFirst = (int)temp;
                if(ansFirst != 1 || AFirst != 1){
                    os.println(-1);
                    return;
                }
            }
            ans *= A[i];
            if(ans > max) {
                os.println(-1);
                return;
            }
        }
        os.println(ans);

    }

}

Measured memory_bytes: 50940
#include<stdio.h>
int main()
{
	long long int x, y;
	scanf("%lld %lld", &x, &y);
	if (x < y)
	{
		x ^= y;
		y ^= x;
		x ^= y;
	}
	if (x == y)
		printf("Brown\n");
	else if ((x - y) % 3 == 0)
		printf("Alice\n");
	else if ((x - y) % 3 == 2)
		printf("Alice\n");
	else if (x > y + 1)
		printf("Alice\n");
	else
		printf("Brown\n");
	return 0;
}

Measured memory_bytes: 1612
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lld;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<"NO"<<endl;return 0
const int mod=1000000007;
const int big=1e9+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
const int hi=100000;
int main(void){
	int i,x,k;cin>>x>>k;
	vector<int>kai(k+2);
	vector<int>sna(k+2);//時間,砂
	vector<int>msna(k+2);
	int uegen=big;//山時間
	kai[0]=0;
	for(i=0;i<k;i++){cin>>kai[i+1];}
	kai[k+1]=big;
	int now=0,mtnow=0;
	int j=0;
	vector<pair<int,int>> uebt(k+2);//時間,a
	
	for(i=0;i<kai.size()-1;i++){
		sna[i]=now;msna[i]=mtnow;
		uebt[i]=mp(kai[i],x-mtnow);
		if(i%2==0){now-=kai[i+1]-kai[i];mtnow-=kai[i+1]-kai[i];if(now<=0){now=0;}}
		else{now+=kai[i+1]-kai[i];mtnow+=kai[i+1]-kai[i];if(now>=x){mineq(uegen,kai[i+1]-now+x);now=x;}}
		
	}
	uebt[k+1]=(mp(0,uegen));//a=0ですでにぶつかるパターン
	sort(uebt.begin(),uebt.end());
	vector<pair<int,int>> uebtlis;//時間,a
	uebtlis.pub(uebt[0]);
	for(i=1;i<k+2;i++){
		if(uebtlis.back().sec>uebt[i].sec){uebtlis.pub(uebt[i]);}
	}
	//uegen 今の上の時間
	//上が当たった->aをその地点でストップ,tがそこより大きいクエリはa=それ
	//ぶつかりやすさ=mtnow順
	//上も離れている->max(a=0の元々,a=aiのxの制約を無視した答え)を出す
	int q;cin>>q;
	for(i=0;i<q;i++){
		int t,a;cin>>t>>a;
		auto it=upper_bound(uebtlis.begin(),uebtlis.end(),mp(t,big));it--;
		mineq(a,it->sec);
		int mebas=upper_bound(kai.begin(),kai.end(),t)-kai.begin()-1;
		int sokara=t-kai[mebas];
		int aoans=max(sna[mebas],msna[mebas]+a);
		if(mebas%2==0){aoans-=sokara;}
		else{aoans+=sokara;}
		mineq(aoans,x);
		maxeq(aoans,0);
		cout<<aoans<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
import math

H, W, N = map(int, input().split())
count = [0]*10
count[0] = (H-2)*(W-2)
rectmap={}

#print(board)
for i in range(0,N):
    a, b = input().split()
    a = int(a)
    b = int(b)
    ab = (a, b)
    al = max(a-1, 2)
    au = min(a+2, H)
    bl = max(b-1, 2)
    bu = min(b+2, W)

    for j in range(al, au):
        for k in range(bl, bu):
            if (j,k) in rectmap:
                rectmap[(j,k)] +=1
            else:
                rectmap[(j,k)] = 1
#            print(rectmap)
##    for j in range(a-1, a+2):
##        for k in range(b-1, b+2):
##            if j>1 and j<H and k>1 and k<W:
##                rectmap.append([j-1, k-1])
#print(rectmap)
for i in rectmap.values():
    count[i]+=1
    count[0]-=1
for c in count:
    print(c)
#print(H,W,N)
#print(ab)


Measured memory_bytes: 151728
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e6+10;
const int E = 1e6+10;  
ll X,Y,A,B,C;
ll p[maxn],q[maxn],r[maxn];
priority_queue<int,vector<int>,greater<int> > Q;

int main(){
	cin>>X>>Y>>A>>B>>C;
	F(i,1,A){
		cin>>p[i];
	}
	F(i,1,B){
		cin>>q[i];
	}
	F(i,1,C){
		cin>>r[i];
	}	
	sort(p+1,p+1+A);
	sort(q+1,q+1+B);
	sort(r+1,r+1+C);
	ll sum = 0;
	dF(i,A,A-X+1){
		sum+=p[i];
		Q.push(p[i]);
	} 
	dF(i,B,B-Y+1){
		sum+=q[i];
		Q.push(q[i]);
	}
	dF(i,C,1){
		int tmp = Q.top();
		if(tmp>=r[i]) break;
		else{
			Q.pop();
			sum-=tmp;
			sum+=r[i];
			Q.push(r[i]);
		}
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3704
// 2011/10/19 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int m, n;
		cin >> m >> n;
		if(m==0&&n==0)
			break;

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

		int S[101];
		S[0] = 0;
		for(int i=1; i<=n; i++)
			S[i] = S[i-1]+B[i];

		int DP[101][21];

		for(int i=1; i<=n; i++)
			DP[i][1] = S[i];

		for(int j=1; j<=m; j++)
			DP[1][j] = B[1];

		for(int i=2; i<=n; i++){
			for(int j=2; j<=m; j++){
				if(B[i]>=DP[i-1][j-1]){
					DP[i][j] = B[i];
					continue;
				}
				DP[i][j] = DP[i-1][j-1];


				for(int k=i-2; k>=1; k--){
					if(S[i]-S[k]>=DP[k][j-1]){
						if(DP[i][j]>S[i]-S[k])
							DP[i][j] = S[i]-S[k];
						break;
					}
					if(DP[i][j]>DP[k][j-1])
						DP[i][j] = DP[k][j-1];
				}
			}
		}

		cout << DP[n][m] << endl;
	}

	return 0;
}

Measured memory_bytes: 0
///    *****       *     **    **   *******     *   **    ** //////
///    **         * *    ** *  **      **      * *   **  **  /////////
///    *****     *****   **  * **      **     *****   ****  /////////////
///       **    *******  **   ***  **  **    *******   **   ////////
///    *****   **     ** **    **  ******   **     **  **   /////
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back

void solve()
{
  int n,sum=0;
  cin>>n;
  int b[n-1];cin>>b[0];sum+=(2*b[0]);
  for(int i=1;i<n-1;i++)
  {
      cin>>b[i];
      if(b[i-1]>b[i])
      {
          sum-=(b[i-1]-b[i]);
          sum+=(b[i]);
      }
      else
      {
          sum+=b[i];
      }
  }cout<<sum;
}
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
word = input()
wordArray = list(word)
#print(wordArray)
lent = len(wordArray)

iterV=(int)(lent/2)

if(lent%2==0):
 iterV=iterV+1
#print(iterV)

num=0

for i in range(iterV):
    #print("Word at:",i,wordArray[i])
    #print("Word at:",lent-1,wordArray[lent-1])
    if(wordArray[i] != wordArray[lent-1]):       
       wordArray[i]=wordArray[lent-1]      
       #print("else Word at post swap:",i,wordArray[i])
       #print("else Word at post swap:",lent-1,wordArray[lent-1])
       num=num+1       
    lent=lent-1
#print(" else Num:",num)
#print(" else lent:",lent)

print(num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if(A == B && B == C) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3524
/*
Maior Subsequência comum
LCS - Longest Common Subsequence
*/

#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

string get_lcs(string & s1, string & s2) {
  string lcs = "";
	int len_s1 = s1.size(), len_s2 = s2.size();

	int mat[len_s1 + 1][len_s2 + 1];

	for(int i = 0; i <= len_s1; i++) {
		mat[i][0] = 0;
	}
	for(int i = 0; i <= len_s2; i++) {
		mat[0][i] = 0;
	}

	for(int i = 1; i <= len_s1; i++) {
		for(int j = 1; j <= len_s2 ; j++) {
			if(s1[i - 1] == s2[j - 1]) {
				mat[i][j] = mat[i - 1][j - 1] + 1;
			} else {
				mat[i][j] = max(mat[i][j - 1], mat[i - 1][j]);
			}
		}
	}
  
  int i = len_s1;
  int j = len_s2;
  while (i >= 0 && j >= 0) {
    if (mat[i][j] > mat[i - 1][j] && mat[i][j] > mat[i][j - 1]) {
      lcs = s1[i - 1] + lcs;
      i--; j--;
    } else if (mat[i][j] == mat[i - 1][j]) i--;
      else j--;
  }

	return lcs;
}

int main(int argc, char * argv[]) {
	string s1, s2;
  cin >> s1;
  cin >> s2;

	string lcs = get_lcs(s1, s2);

	cout << lcs << endl;

	return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n; cin >> n;
    map<ll, ll> mp;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        ll a; cin >> a;
        mp[a]++;
        sum += a;
    }

    int q; cin >> q;
    V<P<ll, ll> > v(q);
    for(int i = 0; i < q; i++){
        ll b, c; cin >> b >> c;
        v[i] = make_pair(b, c);
    }

    for(int i = 0; i < q; i++){
        ll tmp = mp[v[i].first];
        ll s = tmp * v[i].first;
        ll r = tmp * v[i].second;
        mp[v[i].first] = 0;
        mp[v[i].second] += tmp;
        cout << sum - s + r << endl;
        sum = sum - s + r;
    }


    return 0;
}


Measured memory_bytes: 10596
#include<bits/stdc++.h>
#define ll long long

int take()
{
    int n;
    scanf("%d",&n);
    return n;

}

ll takes()
{
    ll n;
    scanf("%lld",&n);
    return n;

}
#define M 5005
#define Int take()
#define LL takes()
#define end return 0
#define fo(n) for(int i=1;i<=n;i++)
#define rfo(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)
using namespace std;

int main(){
    string s;
    cin>>s;
    bool ans=0;

    for(int i=1;i<(s.size());i++){
        string p="";
        p+=s[i-1];p+=s[i];
        if(p=="AC") ans=1;
    }

    if(ans) printf("Yes\n");
    else printf("No\n");
end;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var v = sc.ArrayDouble(N);
        Array.Sort(v);
        double sum = v[0];
        for (int i = 1; i < N; i++) {
            sum = (sum + v[i]) / 2;
        }
        WriteLine(sum);
        
    }
    
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 1001

int lcs(char *,char *);
int mojisu(char *);
int max(int, int);

int main(){
  char s1[N][N], s2[N][N];
  int n, i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%s",s1[i],s2[i]);
  }
  for(i=0;i<n;i++)
    printf("%d\n",lcs(s1[i],s2[i]));
  return 0;
}

int lcs(char x[], char y[])
{
  int c[N][N];
  int m,n,i,j;
  int maxl=0;
  char X[N],Y[N];
  
  m=mojisu(x);
  n=mojisu(y);

  X[0]=' ';
  Y[0]=' ';
  for(i=1;i<N;i++){
  X[i] =x[i-1];  
  Y[i] =y[i-1];
  }

  for(i=0;i<=m;i++)
    c[i][0]=0;
  for(j=1;j<=n;j++)
    c[0][j]=0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(X[i]==Y[j])
	c[i][j]=c[i-1][j-1]+1;
      else
	c[i][j]=max(c[i-1][j],c[i][j-1]);

      maxl=max(maxl,c[i][j]);
    }
  }

  return maxl;
}

int mojisu(char A[])
{
  int i;
  for(i=0;i<N;++i)
    if(A[i]=='\0')
      break;
       
  return i;
}

int max(int x, int y)
{
  if(y>x)return y;
  return x;
}



Measured memory_bytes: 5820
#include "bits/stdc++.h"
using namespace std;
using     ll=long long;
using    vll=vector<   ll>;
using   vvll=vector<  vll>;
using  vvvll=vector< vvll>;
using vvvvll=vector<vvvll>;
constexpr ll INF = 1LL << 60;
struct Fast{ //cin,cout高速化のおまじない＋桁数指定
	Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(std::numeric_limits<double>::max_digits10); }
} fast;
#define rep(i, S, E)  for (ll i = (S); i <= (E); i++)
#define dep(i, E, S)  for (ll i = (E); i >= (S); i--)
#define each(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; }
template<class T> inline T MinE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v,0,(ll)v.size()-1); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v,0,(ll)v.size()-1); }
template<class T> inline T Sum(vector<T> &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v) { return Sum(v,0,v.size()-1); }
template<class T> inline ll sz(T &v){ return (ll)v.size(); }
template<class T> inline T POW(T a, ll n){ T r=1; for (; n>0; n>>=1, a*=a){ if (n&1)r*=a; } return r; }
inline ll POW(int a, ll n){ return POW((ll)a, n); }
inline ll CEIL(ll a, ll b){ return (a+b-1)/b; }


void solve()
{
	ll n;  cin >> n;
	vector<ll> a(n);  rep(i,0,n-1){ ll a_; cin>>a_; a[i]=a_; }
	ll aa=MaxE(a);
	ll m=0,r=0;
	each(e,a){
		if (e==aa){
			m++;
		}
		else if (e==aa-1){
			r++;
		}
		else{
			cout << "No" << '\n'; return;
		}
	}

	if (r==0){
		if (aa==n-1 or aa<=n/2){
			cout << "Yes" << '\n'; return;
		}
		else{
			cout << "No" << '\n'; return;
		}
	}
	else{
		if (r+1<=aa and aa<=r+m/2){
			cout << "Yes" << '\n'; return;
		}
		else{
			cout << "No" << '\n'; return;
		}
	}
}


int main(){
#if 1
	solve();
#else
	ll t;  cin >> t;
	rep(i, 0, t-1){
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 3992
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    unsigned int N;
    string S;
    long long int v[6]={0};
    cin >> N;
    rep(i,N){
        cin >> S;
        if(S[0] =='M') v[0]++;
        if(S[0] =='A') v[1]++;
        if(S[0] =='R') v[2]++;
        if(S[0] =='C') v[3]++;
        if(S[0] =='H') v[4]++;
    }
    long long ans=0;

    for(int i=0; i<5; i++){
        for(int j=i+1; j<5; j++){
            for(int k=j+1; k<5; k++){
                ans+=v[i]*v[j]*v[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    map<string, int> count;
    int max_count = -1;
    for (int i = 0; i < N; i++)
    {
        string S;
        cin >> S;
        if (count.count(S) == 0)
        {
            count[S] = 0;
        }
        else
        {
            count[S]++;
        }
        max_count = max(max_count, count[S]);
    }
    vector<string> output;
    for (auto i = count.begin(); i != count.end(); i++)
    {
        auto key = i->first;
        auto value = i->second;
        if (value == max_count)
        {
            output.push_back(key);
        }
    }
    sort(output.begin(), output.end());
    for (int i = 0; i < output.size(); i++)
    {
        cout << output[i] << endl;
    }
}

Measured memory_bytes: 26868
import java.util.Scanner;

class Vector {
	public double x;
	public double y;
	
	Vector(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	public Vector sub(Vector a) {
		return new Vector(this.x - a.x, this.y - a.y);
	}
}

public class Main{
	public static final double EPS = 1e-10;
	
	public static boolean isParallel(Vector a, Vector b) {
		return equals(cross(a, b), 0.0);
	}

	public static boolean isParallel(Vector a1, Vector a2, Vector b1, Vector b2) {
		return isParallel(a1.sub(a2), b1.sub(b2));
	}
	
	public static double cross(Vector a, Vector b) {
		return a.x * b.y - a.y * b.x;
	}

	public static boolean equals(double a, double b) {
		return Math.abs(a - b) < EPS;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double x1, y1, x2, y2, x3, y3, x4, y4;
		for (int i = 0; i < n; i++) {
			x1 = sc.nextDouble();
			y1 = sc.nextDouble();
			x2 = sc.nextDouble();
			y2 = sc.nextDouble();
			x3 = sc.nextDouble();
			y3 = sc.nextDouble();
			x4 = sc.nextDouble();
			y4 = sc.nextDouble();
			Vector a1 = new Vector(x1, y1);
			Vector a2 = new Vector(x2, y2);
			Vector b1 = new Vector(x3, y3);
			Vector b2 = new Vector(x4, y4);
			
			if (isParallel(a1, a2, b1, b2)) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
	
}

Measured memory_bytes: 29964
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    unordered_set<string> us;
    rep(i, s.size()) us.emplace(s[i]);
    put(us.size());
    
    return 0;
}

Measured memory_bytes: 24044
import fractions

a, b, c, d =map(int,input().split())

under_a = a -1
cd_gcd = fractions.gcd(c, d)

b_mul = b - (b//c)-(b//d)+(b//(c*d//cd_gcd))
under_a_mul = under_a - (under_a//c)-(under_a//d)+(under_a//(c*d//cd_gcd))

print(int(b_mul-under_a_mul))

Measured memory_bytes: 5048
#include<stdio.h>
#include<math.h>

int main(){

	int i, j;
	double n, p, x[100], y[100], d[4] = {0};

	scanf("%lf", &n);
	for(i = 0; i < n; i++){
		scanf("%lf", &x[i]);
	}
	for(i = 0; i < n; i++){
		scanf("%lf", &y[i]);
	}


	for(i = 1; i <= 3; i++){
		p = i;
		for(j = 0; j < n; j++){
			d[i - 1] += pow(fabs(x[j] - y[j]), p);
		}

		d[i - 1] = pow(d[i - 1], 1 / p);

		printf("%.11lf\n", d[i - 1]);
	}


	d[3] = 0;
	for(i = 0; i < n; i++){
		if(d[3] < fabs(x[i] - y[i])){
			d[3] = fabs(x[i] - y[i]);
		}
	}
	printf("%.11lf", d[3]);


	return 0;
}

Measured memory_bytes: 712
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n, q, a[100005];    
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> q;
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, q) {
        ll x; cin >> x;
        ll sum = 0, ans = 0;
        int l = 0;
        rep(r, 0, n) {
            sum += a[r];
            while (sum > x) sum -= a[l++];
            ans += r - l + 1;
        }
        cout << ans << endl;
    }
    return 0;
}


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


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



    const int INF = 0x3f3f3f3f;
    const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
    const int NMAX = 1e5 + 5;
    const int MOD = 1e9 + 7;
    #define endl "\n"


        vector<int> tabBoth;
        vector<int> tabBob;
        vector<int> tabAlice;

    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        char tab[2*NMAX],tab1[2*NMAX];
        int count = 0;
        cin>>tab>>tab1;
        int l = strlen(tab1);
        for(int i=0 ; i<l ; ++i){
            if(tab[i] != tab1[i])count++;
        }
        cout<<count;

        return 0;
    }


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N;cin>>N;
    string str=to_string(N);
    int a;
    ll sum=0;
    rep(i,str.size()){
        sum+=str.at(i)-'0';
    }
    if(N%sum==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, char> Pc;
typedef pair<int, string> Ps;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};
const int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const string dir8[8] = {"U", "RU", "R", "RD", "D", "LD", "L", "LU"};

// Self settings
// clang-format off
#define MAX_N 100000
#define MAX 100000
#define INFTY (1<<30)
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
class Point { public: double x, y; Point(double x = 0, double y = 0) : x(x), y(y) {} Point operator+(Point p) { return Point(x + p.x, y + p.y); } Point operator-(Point p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(a * x, a * y); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x * x + y * y; } bool operator<(const Point& p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point& p) const { return fabs(x - p.y) < EPS && fabs(y - p.y) < EPS; } };
typedef Point Vector;
double norm(Vector a) { return a.x * a.x + a.y * a.y; }
double abs(Vector a) { return sqrt(norm(a));}
double dot(Vector a, Vector b) { return a.x * b.x + a.y * b.y; }
double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
struct Segment { Point p1, p2; };
typedef Segment Line;
struct Node { int data; Node *left, *right; Node(int data) : data(data), left(NULL), right(NULL) {} };
// clang-format on

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int N, X, Y;
  cin >> N >> X >> Y;
  // 1-indexed
  vector<int> ans(N + 1);
  for (int i = 1; i <= N; i++) {
    int A = i;
    for (int j = i + 1; j <= N; j++) {
      int B = j;
      int d = min({abs(B - A), abs(X - A) + 1 + abs(Y - B),
                   abs(Y - A) + 1 + abs(B - X)});
      ans[d]++;
    }
  }
  for (int i = 1; i < N; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= b) {
		for (int i = 0; i < b; i++) {
			cout << a;
		}
	} else {
		for (int i = 0; i < a; i++) {
			cout << b;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair
#define INF (1<<28)
typedef long long Int;

int N, B[64], C[64];
string A[64], D[64][64];
int g[64][64], vis[64];
int r[64], p[64];
Int f[64];

void collect(vector<int>& q, int at) {
    if (vis[at]) return ;
    vis[at] = 1;
    q.push_back(at);
    rep (i, N) if (g[at][i]) collect(q, i);
}

void prepare(vector<int>& q) {
    const int n = q.size();
    //vector<pair<int, int> > ps;
    //rep (i, n) ps.push_back(mp(C[q[i]], q[i]));
    //sort(ps.begin(), ps.end());
    //rep (i, n) r[i] = ps[n-1-i].second;
    rep (i, n) r[i] = q[i];
    rep (i, n) p[i] = B[r[i]];
    rep (i, n) {
        f[i] = 0;
        rep (j, n) if (g[r[i]][r[j]]) f[i] |= 1LL<<j;
    }
}

int n, a;

void rec(int k, Int u) {
    int s = 0;
    rep (i, n) if (u&(1LL<<i)) s += p[i];
    if (s < a) return ;
    if (k == n) a = s;
    else {
        rep (i, k) if (!(u&(1LL<<i)) && !(f[i]&u)) return ;
        const int mask = (1LL<<n) - 1;
        if (u&(1LL<<k)) rec(k+1, u&(mask-f[k]));
        if (r[k]) rec(k+1, u&(mask-(1LL<<k)));
    }
}

int solve() {
    memset(vis, 0, sizeof(vis));
    int ans = 0;
    rep (i, N) if (!vis[i]) {
        vector<int> q;
        collect(q, i);
        prepare(q);
        n = q.size();
        a = 0;
        rec(0, (1LL<<q.size())-1);
        ans += a;
    }
    return ans;
}

int main() {
    for (;;) {
        cin >> N;
        if (N == 0) return 0;
        map<string, int> of;
        rep (i, N) {
            cin >> A[i] >> B[i] >> C[i];
            of[A[i]] = i;
            rep (j, C[i]) cin >> D[i][j];
        }
        memset(g, 0, sizeof(g));
        rep (i, N) rep (j, C[i]) g[i][of[D[i][j]]] = 1;
        printf("%d\n", solve());
    }
}

Measured memory_bytes: 1396
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  string a,b;
  cin>>a>>b;
  for(int i=0;i<a.size();i++){
    a=a[a.size()-1]+a;
    a.pop_back();
    if(a==b){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
void main(){
	_scan();
	int[] a = _scanln();
	int ans_bit;
	foreach(elm; a)ans_bit = elm|ans_bit;
	int cnt;
	while( (ans_bit&1) == 0){
		cnt++;
		ans_bit = ans_bit >> 1;
	}
	cnt.writeln();
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2732
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define max3(a,b,c) max(a,max(b,c))
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define mo 998244353
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define eps 0.000001
#define ms 16
#define endl '\n'

 
using namespace std ;
 
#define N 100005

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

int main()
{  
/////////////////////////////////////
    
    fastio;
 
/////////////////////////////////////

    lli n;
    cin>>n;

    lli w[n+1],p[n+1]={0},sum=0;

    loopl(i,1,n+1) 
    {
        cin>>w[i];
        p[i] = p[i-1] + w[i];
        sum+=w[i];
    }

    lli ans = inf;
    loopl(i,1,n+1)
    {
        ans = min(ans , abs(p[i] - (sum-p[i])));
    }

    cout<<ans;

}

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

int main(){
    
    int N;
    int K;
    int M;
    int count=1; //count
    
    cin>>N>>K;
    M=N;
    for(int i=0;;++i){
        
        if(M<K){
            
            break;
        }
        M=M/K;
        ++count;
    }
    cout<<count<<endl;
        
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100, K = 3;

int dp[N + 1][K + 1], dq[N + 1][K + 1];

int main() {
	string s; cin >> s;
	int n = s.length();
	int k; cin >> k;
	dp[0][0] = 0;
	dq[0][0] = 1;
	for (int i = 0; i < n; i++) {
		int d = s[i] - '0';
		for (int j = 0; j <= k; j++) {
			dp[i + 1][j] += dp[i][j];
			if (j < k)
				dp[i + 1][j + 1] += dp[i][j] * 9;
			if (d == 0)
				dq[i + 1][j] += dq[i][j];
			else {
				dp[i + 1][j] += dq[i][j];
				if (j < k) {
					dp[i + 1][j + 1] += dq[i][j] * (d - 1);
					dq[i + 1][j + 1] += dq[i][j];
				}
			}
		}
	}
	cout << dp[n][k] + dq[n][k] << '\n';
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int n,m;
    string s;
    cin >> n>> m;
    if(n+m == 15)cout << "+" << endl;
    else if(n*m == 15)cout << "*" << endl;
    else cout << "x" << endl;
    
}




Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cstdlib>
using namespace std;
vector <map <int,int> > li(100000);
int n,m,k,r=2;
void dfs1(int y,int x){
  if(li[y][x]==0||li[y][x]==2) return;
  if(y==n-2||x==1) r=1;
  if(y==n-1||x==0){
    r=0;
    return;
  }
  li[y][x]=2;
  for(int i=-2;i<=2;i++)
    for(int j=-2;j<=2;j++)
      if(abs(i)==2||abs(j)==2)
	if(0<=y+i&&y+i<n&&0<=x+j&&x+j<m)
	  if(li[y+i][x+j]==1) li[y+i][x+j]=3;
  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++)
      if(abs(i)==1||abs(j)==1)
	if(0<=y+i&&y+i<n&&0<=x+j&&x+j<m)
	  if(li[y+i][x+j]==1||li[y+i][x+j]==3) dfs1(y+i,x+j); 
}
void dfs2(int y,int x){
  if(li[y][x]==0||li[y][x]==4) return;
  //if(li[y][x]==2) r=2;
  if(li[y][x]==3||y==1||x==m-2) r=min(r,1);
  li[y][x]=4;
  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++)
      if(abs(i)==1||abs(j)==1)
	if(0<=y+i&&y+i<n&&0<=x+j&&x+j<m)
	  if(li[y+i][x+j]) dfs2(y+i,x+j); 
}
int main(){
  int y,x;
  cin>>n>>m>>k;
  for(int i=0;i<k;i++){
    cin>>y>>x;
    li[y][x]=1;
  }
  for(int i=0;i<m-1&&r;i++) dfs1(0,i);
  for(int i=0;i<n-1&&r;i++) dfs1(i,m-1);
  for(int i=0;i<m-1&&r;i++) dfs2(n-1,i);
  for(int i=0;i<n-1&&r;i++) dfs2(i,0);
  /*  for(int i=0;i<n;i++){
     for(int j=0;j<m;j++) cout<<li[i][j]<<" ";
     cout<<endl;
     } */
  cout<<r<<endl;
  return 0;
}

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

int mp[50][50]={0};
int dx[8]={-1,-1,-1,0,0,1,1,1};
int dy[8]={-1,0,1,-1,1,-1,0,1};
 int W,H;
 void dfs(int w,int h);
int main(){
 
    while(true){
        
    int cnt=0;

    cin >>W >>H;
    if(W==0 && H==0) break;
    for (int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> mp[i][j];
        }
    }
    
//    memcpy(mp1,mp,sizeof(mp));
    
    for (int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if (mp[i][j]==1){
                cnt++;
                dfs(j,i);
            }
        }
    }
   cout <<cnt<<endl;
    } 

}

void dfs(int w,int h){
    mp[h][w]=0;
    int nx,ny;
    for (int i=0;i<8;i++){
        nx=w+dx[i];ny=h+dy[i];
        if(0<=nx && nx<W && 0<=ny && ny<H && mp[ny][nx]==1){
            dfs(nx,ny);
        }

    }

}



Measured memory_bytes: 3068
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<algorithm>
#include<iterator>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#define lli long long int
#define mp make_pair
#define FLASH ios_base::sync_with_stdio(false); cin.tie(0)
#define PI  3.141592653589793
#define fo(i,n) for(lli i=0;i<(n);i++)
#define FO(i,x,n) for(lli i=(x);i<(n);i++)
#define pb push_back
#define FI first
#define SE second
#define vi vector<lli>
#define pi pair<lli,lli>
#define vii vector<pi >
#define Endl endl
#define ITA 200005
#define ROH 100005
using namespace std;
lli mod = 1e9 +7,test; 
lli max(lli a,lli b){return a>b?a:b;}
lli min(lli a,lli b){return a>b?b:a;}

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

void solve(){

lli n,k;
cin>>n;

vector<vi > a(n,vi(3));
vector<vi > dp(n,vi(3 , -1));
fo(i,n){
  fo(j,3){
    cin>>a[i][j];
  }
}
fo(i,3){
  dp[0][i] = a[0][i];
}
FO(i,1,n){
    dp[i][0] = max(dp[i-1][1] + a[i][0] ,dp[i-1][2] + a[i][0] );
    dp[i][1] = max(dp[i-1][0] + a[i][1] ,dp[i-1][2] + a[i][1] );
    dp[i][2] = max(dp[i-1][1] + a[i][2] ,dp[i-1][0] + a[i][2] );
}

lli maxi = dp[n-1][0];
maxi = max(maxi , max(dp[n-1][1] , dp[n-1][2]));
cout<<maxi<<Endl;




}


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

}





Measured memory_bytes: 11136