stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>



using namespace std;



int main()

{

 string x;

    cin>>x;

    int a=0,b=0;

    for(int i=0;i<3;i++){

        if(x.at(i)=='A'){

            a++;

        }

        else{

            b++;

        }

    }

    if(a==0|| b==0){

        cout<<"No";

    }

    else{

        cout<<"Yes";

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.349529935191001x):
#include <stdio.h>



int main(){

	char S, A, B;

	scanf("%c%c%c", &S, &A, &B);

	if(S, A != B){

		printf("Yes\n");

	}else if(S, B != A){

		printf("Yes\n");

	}else if(A, B != S){

		printf("Yes\n");

	}else if( S == A, A == B){

		printf("No\n");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int main() {

    string a;

    cin>>a;

    set <char> s;

    for (int i=0;i<a.length();i++)

        s.insert(a[i]);

    if (s.size()==2)

        cout<<"Yes"<<endl;



    else cout<<"No"<<endl;

    

    

    

}

// Faster C++ solution for the same problem (measured speedup: 5.419070835046562x):
#include <stdio.h>



int main(){

	char S, A, B;

	scanf("%c%c%c", &S, &A, &B);

	if(S, A != B){

		printf("Yes\n");

	}else if(S, B != A){

		printf("Yes\n");

	}else if(A, B != S){

		printf("Yes\n");

	}else if( S == A, A == B){

		printf("No\n");

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>



using namespace std;



int main()

{

 string x;

    cin>>x;

    int a=0,b=0;

    for(int i=0;i<3;i++){

        if(x.at(i)=='A'){

            a++;

        }

        else{

            b++;

        }

    }

    if(a==0|| b==0){

        cout<<"No";

    }

    else{

        cout<<"Yes";

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.344885016131751x):
#include <stdio.h>



int main() {

	char A, B, C;

	scanf("%c %c %c", &A, &B, &C);

	

	if(A==B && A!=C)

	puts("Yes");

	

	if(B==C && B!=A)

	puts("Yes");

	

	if(A==C && B!=A)

	puts("Yes");

	

	if(A==B && A==C)

	puts("No");

	

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int main() {

    string a;

    cin>>a;

    set <char> s;

    for (int i=0;i<a.length();i++)

        s.insert(a[i]);

    if (s.size()==2)

        cout<<"Yes"<<endl;



    else cout<<"No"<<endl;

    

    

    

}

// Faster C++ solution for the same problem (measured speedup: 5.41436553463511x):
#include <stdio.h>



int main() {

	char A, B, C;

	scanf("%c %c %c", &A, &B, &C);

	

	if(A==B && A!=C)

	puts("Yes");

	

	if(B==C && B!=A)

	puts("Yes");

	

	if(A==C && B!=A)

	puts("Yes");

	

	if(A==B && A==C)

	puts("No");

	

	return 0;

}
// Slower C++ solution:
#include <iostream>



using namespace std;



int main()

{

 string x;

    cin>>x;

    int a=0,b=0;

    for(int i=0;i<3;i++){

        if(x.at(i)=='A'){

            a++;

        }

        else{

            b++;

        }

    }

    if(a==0|| b==0){

        cout<<"No";

    }

    else{

        cout<<"Yes";

    }



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.33515448974074x):
#include <stdio.h>



int main (){

	char A[11];

	scanf("%s", &A);

	if(A[0]==A[1] && A[1]==A[2])

	{ 

	puts("No"); 

	}

	else 

	{

	puts("Yes");	

	}

return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int main() {

    string a;

    cin>>a;

    set <char> s;

    for (int i=0;i<a.length();i++)

        s.insert(a[i]);

    if (s.size()==2)

        cout<<"Yes"<<endl;



    else cout<<"No"<<endl;

    

    

    

}

// Faster C++ solution for the same problem (measured speedup: 5.404508516838406x):
#include <stdio.h>



int main (){

	char A[11];

	scanf("%s", &A);

	if(A[0]==A[1] && A[1]==A[2])

	{ 

	puts("No"); 

	}

	else 

	{

	puts("Yes");	

	}

return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstdint>

#include <vector>

#include <algorithm>

#include <set>

#include <string>



int main() {

  char buf[4];

  scanf("%s", buf);

  std::string s = buf;



  if (s == std::string(3, 'A') || s == std::string(3, 'B')) {

    puts("No");

  } else {

    puts("Yes");

  }

}


// Faster C++ solution for the same problem (measured speedup: 4.9471903673165665x):
#include <cstdio>

#include <type_traits>



int main() {

  static_assert(std::is_same<long, decltype(1234567890987654321-1234567890987654321)>::value, "");



  char s[4];

  scanf("%s", s);

  puts(((s[0]+s[1]+s[2]) % 3 == 0)? "No": "Yes");

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <complex>



using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long

#define fori(n) for(int i = 0; i < n; ++i)

#define forj(n) for(int j = 0; j < n; ++j)

#define endl "\n";

typedef long long ll;

typedef pair<int, int> pii;



int32_t main(){

    IOS;

    string s;

    cin >> s;

    if (s == "AAA" || s == "BBB")

        cout << "No";

    else

        cout << "Yes";



}




// Faster C++ solution for the same problem (measured speedup: 5.448537470078827x):
#include<stdio.h>

int main(){

	char a, b, c;

	scanf("%c%c%c", &a, &b, &c);

	if(a==b && a!=c){

		puts("Yes");

	}

	else if(c==b && a!=c){

		puts("Yes");

	}

	else if(a==c && a!=b){

		puts("Yes");

	}

	else{

		puts("No");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <complex>



using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long

#define fori(n) for(int i = 0; i < n; ++i)

#define forj(n) for(int j = 0; j < n; ++j)

#define endl "\n";

typedef long long ll;

typedef pair<int, int> pii;



int32_t main(){

    IOS;

    string s;

    cin >> s;

    if (s == "AAA" || s == "BBB")

        cout << "No";

    else

        cout << "Yes";



}




// Faster C++ solution for the same problem (measured speedup: 5.423538632027167x):
#include  <stdio.h>

 

int main(void)

{

   char a[4];

    scanf("%s",&a);

    

    

        if(a[0] != a[1] || a[0] != a[2])

        {

           puts("Yes");

        }

    

        else puts("No");

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <complex>



using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long

#define fori(n) for(int i = 0; i < n; ++i)

#define forj(n) for(int j = 0; j < n; ++j)

#define endl "\n";

typedef long long ll;

typedef pair<int, int> pii;



int32_t main(){

    IOS;

    string s;

    cin >> s;

    if (s == "AAA" || s == "BBB")

        cout << "No";

    else

        cout << "Yes";



}




// Faster C++ solution for the same problem (measured speedup: 5.399753165165107x):
#include<stdio.h>

int main()

{

	char X[5];

	scanf("%s",&X);

	

	if(X[0]=='A' && X[1]=='A' && X[2]=='B' || X[0]=='B' && X[1]=='B' && X[2]=='A')

	{

		printf("Yes");

	}

	if(X[0]=='A' && X[1]=='B' && X[2]=='A' || X[0]=='B' && X[1]=='A' && X[2]=='B')

	{

		printf("Yes");

	}

	if(X[0]=='B' && X[1]=='A' && X[2]=='A' || X[0]=='A' && X[1]=='B' && X[2]=='B')

	{

		printf("Yes");

	}

	if(X[0]=='A' && X[1]=='A' && X[2]=='A' || X[0]=='B' && X[1]=='B' && X[2]=='B')

	{

		printf("No");

	}

	

	

	

	

	

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <complex>



using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long

#define fori(n) for(int i = 0; i < n; ++i)

#define forj(n) for(int j = 0; j < n; ++j)

#define endl "\n";

typedef long long ll;

typedef pair<int, int> pii;



int32_t main(){

    IOS;

    string s;

    cin >> s;

    if (s == "AAA" || s == "BBB")

        cout << "No";

    else

        cout << "Yes";



}




// Faster C++ solution for the same problem (measured speedup: 5.423483642262745x):
#include<stdio.h>

	int main(){

		char S[3];

		

		scanf ("%s", &S);

		

		if (S[0]==S[2] && S[1]==S[2]){

			puts("No");

		}else  {

			puts("Yes");

		}

		return 0;

	}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <complex>



using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long

#define fori(n) for(int i = 0; i < n; ++i)

#define forj(n) for(int j = 0; j < n; ++j)

#define endl "\n";

typedef long long ll;

typedef pair<int, int> pii;



int32_t main(){

    IOS;

    string s;

    cin >> s;

    if (s == "AAA" || s == "BBB")

        cout << "No";

    else

        cout << "Yes";



}




// Faster C++ solution for the same problem (measured speedup: 5.4068911607513215x):
#include <stdio.h>



int main(){

	

char S[5];



scanf ("%s", &S);

if(S[0]==S[1]&&S[1]==S[2])

{

	printf("No");

}

else{

	printf("Yes");

}

	

	

	

	

	return 0;

	

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <complex>



using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long

#define fori(n) for(int i = 0; i < n; ++i)

#define forj(n) for(int j = 0; j < n; ++j)

#define endl "\n";

typedef long long ll;

typedef pair<int, int> pii;



int32_t main(){

    IOS;

    string s;

    cin >> s;

    if (s == "AAA" || s == "BBB")

        cout << "No";

    else

        cout << "Yes";



}




// Faster C++ solution for the same problem (measured speedup: 5.402184959634691x):
#include <stdio.h>

#include <string.h>



 int main()

{

    char S[3];

    scanf("%s",S);

    if ((strcmp(S , "AAB") == 0) || (strcmp(S , "ABA") == 0) || (strcmp(S , "BBA") == 0) || (strcmp(S , "BAB") == 0) || (strcmp(S , "ABB") == 0) || (strcmp(S , "BAA") == 0))

    {

        puts("Yes");

    }

    else 

    {

        puts("No");

    }



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <complex>



using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long

#define fori(n) for(int i = 0; i < n; ++i)

#define forj(n) for(int j = 0; j < n; ++j)

#define endl "\n";

typedef long long ll;

typedef pair<int, int> pii;



int32_t main(){

    IOS;

    string s;

    cin >> s;

    if (s == "AAA" || s == "BBB")

        cout << "No";

    else

        cout << "Yes";



}




// Faster C++ solution for the same problem (measured speedup: 5.436924051066547x):
#include <stdio.h>



int main()

{

	char A, B, C;

	scanf("%c%c%c", &A, &B, &C);

	

	if(A==B && B==C && C==A)

	{

		printf("No");

	}

	else if(A==B || B==C || C==A)

	{

		printf("Yes");

	}

	else

	{

		printf("No");

	}

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <complex>



using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long

#define fori(n) for(int i = 0; i < n; ++i)

#define forj(n) for(int j = 0; j < n; ++j)

#define endl "\n";

typedef long long ll;

typedef pair<int, int> pii;



int32_t main(){

    IOS;

    string s;

    cin >> s;

    if (s == "AAA" || s == "BBB")

        cout << "No";

    else

        cout << "Yes";



}




// Faster C++ solution for the same problem (measured speedup: 5.423858409419343x):
#include <stdio.h>



int main(){

	char a1, a2, a3;

	scanf("%c %c %c", &a1, &a2, &a3);

	if (a1, a2 != a3){

		printf("Yes\n");

	}

	else if (a1, a3 != a2){

		printf("Yes\n");

	}

	else if (a2, a3 != a1){

		printf("Yes\n");

	}

	else if (a1 == a2, a2 == a3){

		printf("No\n");

	}

	

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <complex>



using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long

#define fori(n) for(int i = 0; i < n; ++i)

#define forj(n) for(int j = 0; j < n; ++j)

#define endl "\n";

typedef long long ll;

typedef pair<int, int> pii;



int32_t main(){

    IOS;

    string s;

    cin >> s;

    if (s == "AAA" || s == "BBB")

        cout << "No";

    else

        cout << "Yes";



}




// Faster C++ solution for the same problem (measured speedup: 5.4068911607513215x):
#include <stdio.h>

int main() {

    char S[4];

    scanf("%s", &S);

    if(S[0] != S[1]) {

        printf("Yes");

    }

    else if (S[1] != S[2]){

        printf("Yes");

    }

    else {

        printf("No");

    }

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#include <complex>



using namespace std;



#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define int long long

#define fori(n) for(int i = 0; i < n; ++i)

#define forj(n) for(int j = 0; j < n; ++j)

#define endl "\n";

typedef long long ll;

typedef pair<int, int> pii;



int32_t main(){

    IOS;

    string s;

    cin >> s;

    if (s == "AAA" || s == "BBB")

        cout << "No";

    else

        cout << "Yes";



}




// Faster C++ solution for the same problem (measured speedup: 5.432531196810261x):
#include <stdio.h>



int main() {

	char A, B, C;

	scanf("%c %c %c", &A, &B, &C);

	

	if(A==B && A==C)

	puts("No");

	

	else

	puts("Yes");

	

	return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <algorithm>

#include <map>



typedef long long LL;

const int MN = 20;



int N, A[MN];



struct dat {

	dat() {}

	int a, b, c, d;

	dat(int l, int r, int cl, int cr)

		: a(l), b(r), c(cl), d(cr) {}

	friend bool operator < (dat i, dat j) {

		if (i.a != j.a) return i.a < j.a;

		if (i.b != j.b) return i.b < j.b;

		if (i.c != j.c) return i.c < j.c;

		return i.d < j.d;

	}

};

std::map<dat, LL> f;

LL F(int l, int r, int cl, int cr) {

	dat now(l, r, cl, cr);

	if (f.find(now) != f.end()) return f[now];

	if (l > r) return 0;

	LL ans = 0x3f3f3f3f3f3f3f3f;

	for (int i = l; i <= r; ++i)

		ans = std::min(ans, F(l, i - 1, cl, cl + cr) + (LL)A[i] * (cl + cr) + F(i + 1, r, cl + cr, cr));

	return f[now] = ans;

}



int main() {

	scanf("%d", &N);

	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);

	N -= 2;

	printf("%lld\n", F(1, N, 1, 1) + A[0] + A[N + 1]);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.264226853142489x):
#include <cstdio>

#include <algorithm>

#include <map>



typedef long long LL;

const int MN = 20;



int N, A[MN];



LL F(int l, int r, int cl, int cr) {

	if (l > r) return 0;

	LL ans = 0x3f3f3f3f3f3f3f3f;

	for (int i = l; i <= r; ++i)

		ans = std::min(ans, F(l, i - 1, cl, cl + cr) + (LL)A[i] * (cl + cr) + F(i + 1, r, cl + cr, cr));

	return ans;

}



int main() {

	scanf("%d", &N);

	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);

	N -= 2;

	printf("%lld\n", F(1, N, 1, 1) + A[0] + A[N + 1]);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

using namespace std;

ll f[20][20][20][20];

ll a[20];

ll dfs(int l,int r,int x,int y) {

	if(l+1>=r) return 0;

	ll ans=1e18;

	for(int i=l+1;i<r;i++) {

		ans=min(ans,dfs(l,i,x,x+y)+dfs(i,r,x+y,y)+a[i]*(x+y));

	}

	return f[l][r][x][y]=ans;

}

int main() {

	int n;

	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);

	memset(f,-1,sizeof f);

	printf("%lld\n",a[1]+a[n]+dfs(1,n,1,1));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.2839316605301234x):
#include <bits/stdc++.h>

#define ll long long

using namespace std;

ll a[20];

ll dfs(int l,int r,int x,int y) {

	if(l+1>=r) return 0;

	ll ans=1e18;

	for(int i=l+1;i<r;i++) {

		ans=min(ans,dfs(l,i,x,x+y)+dfs(i,r,x+y,y)+a[i]*(x+y));

	}

	return ans;

}

int main() {

	int n;

	scanf("%d",&n);

	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);

	printf("%lld\n",a[1]+a[n]+dfs(1,n,1,1));

	return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <iostream>

#include <algorithm>

#include <cstring>

#include <map>

#define pii pair<int,int>

#define MP make_pair

#define fir first

#define sec second

#define PB push_back

#define db long double

#define ll long long

using namespace std;

template <class T>

inline void rd(T &x) {

	x=0; char c=getchar(); int f=1;

	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }

	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;

}

/*

f[l,r,xl,xr]:

	in range [l,r], l and r were the first values vomitted

	l is counted xl times

	r is counted xr times

	f is the minimum possible sum of the contribution of values in range (l,r) ? 

*/

const int N=20;

map<pii,ll> mp[N][N];

int n;

int a[N];

ll dfs(int l,int r,int xl,int xr) {

	if(r==l+1) return 0;

	if(mp[l][r].count(MP(xl,xr))) return mp[l][r][MP(xl,xr)];

	ll ans=1e18;

	for(int k=l+1;k<r;++k)

		ans=min(ans,dfs(l,k,xl,xl+xr)+dfs(k,r,xl+xr,xr)+(xl+xr)*(ll)a[k]);

	return mp[l][r][MP(xl,xr)]=ans;

}

int main() {

	rd(n);

	for(int i=1;i<=n;++i) rd(a[i]);

	printf("%lld\n",dfs(1,n,1,1)+a[1]+a[n]);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.2258429589186886x):
#include<cstdio>

using namespace std;

long long n,v[19],ct;

long long Min(long long a,long long b){return a<b?a:b;}

long long DP(int l,int r,int s1,int s2)

{

	if(l+1==r)return v[l]*s1+v[r]*s2;

	long long as=2e18;

	for(int i=l+1;i<r;i++)as=Min(as,DP(l,i,s1,s1+s2)+DP(i,r,s1+s2,s2)-v[i]*(s1+s2));

	return as;

}

int main(){scanf("%lld",&n);for(int i=1;i<=n;i++)scanf("%lld",&v[i]);printf("%lld\n",DP(1,n,1,1));}//
// Slower C++ solution:
#include <bits/stdc++.h>



typedef long long ll;



int n;

ll a[20];



inline void down(ll &x, const ll y) {x > y ? x = y : 0;}



ll dfs(int l, int r, int cl, int cr) {

	if (l > r) return 0;

	int i; ll ret = LLONG_MAX;

	for (i = l; i <= r; ++i) down(ret, (cl + cr) * a[i] + dfs(l, i - 1, cl, cl + cr) + dfs(i + 1, r, cl + cr, cr));

	return ret;

}



int main() {

	int i;

	scanf("%d", &n);

	for (i = 1; i <= n; ++i) scanf("%lld", a + i);

	printf("%lld\n", a[1] + a[n] + dfs(2, n - 1, 1, 1));

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.82225829454047x):
#include<cstdio>

using namespace std;

long long n,v[19],ct;

long long Min(long long a,long long b){return a<b?a:b;}

long long DP(int l,int r,int s1,int s2)

{

	if(l+1==r)return v[l]*s1+v[r]*s2;

	long long as=2e18;

	for(int i=l+1;i<r;i++)as=Min(as,DP(l,i,s1,s1+s2)+DP(i,r,s1+s2,s2)-v[i]*(s1+s2));

	return as;

}

int main(){scanf("%lld",&n);for(int i=1;i<=n;i++)scanf("%lld",&v[i]);printf("%lld\n",DP(1,n,1,1));}//
// Slower C++ solution:
#include <iostream>

#include <fstream>

#include <cstdio>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <vector>

#include <string>

#include <list>

#include <queue>

#include <deque>

#include <stack>

#include <set>

#include <map>

#include <bitset>

#include <sstream>

#include <iomanip>



using namespace std;



typedef long long ll;

typedef vector <int> vi;

typedef vector <vector <int>> vii;

typedef vector <long long> vll;

typedef vector <string> vs;

typedef vector <char> vc;

typedef set <int> si;

typedef set <string> ss;

typedef queue <int> qi;

typedef queue <long long> qll;

typedef queue <string> qs;

typedef queue <char> qc;

typedef struct board board;

typedef pair <int, int> pi;

typedef pair <long long, long long> pll;

typedef pair <int, pair<int, int>> pii;



#define eb emplace_back

#define ppb pop_back

#define clr(a) a.clear()

#define F first

#define S second

#define mkp make_pair



#define sz(x) (int)(x).size()

#define all(x) (x).begin(), (x).end()



#define left(x) x * 2

#define right(x) x * 2 + 1



#define meme(a, b, c) fill(a + 1, a + 1 + b, c)



#define max(a, b) (a > b ? a : b)

#define min(a, b) (a > b ? b : a)

#define abs(a) (a > 0? a : -(a))



#define move(s) s += "#"



#define fr(i, a, b) for (ll i = a; i <= b; ++ i)

#define rf(i, a, b) for (ll i = a; i >= b; -- i)



#define eprintf(...) fprintf(stderr, __VA_ARGS__);



void to_pray() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    cerr << "Ready\n";

}



const int N = 4e6 + 10;

const int NN = 1e3 + 10;

const int NNN = 2e3 + 9;

const int MOD = 1e9 + 7;

const int INF = 1e9 + 7;

const ll LLINF = 1e17 + 7;

const ll P = 53;

const int EPS = 1e-9 - 8;

const int vN = 2e4 + 10;

const int sz = (1 << 22) - 1;

const double PI = acos(-1);



ll a[20];



ll rec(int l, int r, ll x1, ll xr) {

	if (r - l == 1)

		return a[l] * x1 + a[r] * xr;

	ll ans = 1ll << 60;

	for (int i = l + 1; i < r; ++ i) {

		ans = min(ans, rec(l, i, x1, x1 + xr) + rec(i, r, x1 + xr, xr) - (x1 + xr) * a[i]);

	}

	return ans;

}



int main () {

    to_pray();

	

    int n;

    cin >> n;

    

    for (int i = 1; i <= n; ++ i)

    	cin >> a[i];

    

    cout << rec(1, n, 1, 1);

    

    //eprllf("%.18lf seconds\n", (double)clock() / CLOCKS_PER_SEC);

    cout << '\n';

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.0023980849388705x):
#include<cstdio>

using namespace std;

long long n,v[19],ct;

long long Min(long long a,long long b){return a<b?a:b;}

long long DP(int l,int r,int s1,int s2)

{

	if(l+1==r)return v[l]*s1+v[r]*s2;

	long long as=2e18;

	for(int i=l+1;i<r;i++)as=Min(as,DP(l,i,s1,s1+s2)+DP(i,r,s1+s2,s2)-v[i]*(s1+s2));

	return as;

}

int main(){scanf("%lld",&n);for(int i=1;i<=n;i++)scanf("%lld",&v[i]);printf("%lld\n",DP(1,n,1,1));}//
// Slower C++ solution:
//

//  main.cpp

//  chalka

//

//  Created by Бахтияр on 16/11/19.

//  Copyright © 2019 Бахтияр. All rights reserved.

//



#include <iostream>

#include <algorithm>

#include <vector>

#include <cmath>

#include <set>

#include <map>

#include <unordered_map>

#include <iomanip>

#include <stack>

#include <queue>

#include <deque>

using namespace std;

int n,a[20];

 

long long dp(int l,int r,long long xl,long long xr) {

    if(l+1==r) return 0;

    long long ret=1e18;

    for(int i=l+1;i<r;i++) ret=min(ret,dp(l,i,xl,xl+xr)+dp(i,r,xl+xr,xr)+(xl+xr)*a[i]);

    return ret;

}

 

int main() {

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

    cout<<dp(1,n,1,1)+a[1]+a[n];

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.900035038435164x):
#include<cstdio>

using namespace std;

long long n,v[19],ct;

long long Min(long long a,long long b){return a<b?a:b;}

long long DP(int l,int r,int s1,int s2)

{

	if(l+1==r)return v[l]*s1+v[r]*s2;

	long long as=2e18;

	for(int i=l+1;i<r;i++)as=Min(as,DP(l,i,s1,s1+s2)+DP(i,r,s1+s2,s2)-v[i]*(s1+s2));

	return as;

}

int main(){scanf("%lld",&n);for(int i=1;i<=n;i++)scanf("%lld",&v[i]);printf("%lld\n",DP(1,n,1,1));}//
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;

typedef long long ll;

int n;

ll a[ 19 ];



ll calc(int l, int r, ll xl, ll xr) {

      if (r - l == 1) return a[l] * xl + a[r] * xr;

      ll ans = 1ll << 60;

      for (int i = l + 1; i < r; i++) {

        ans = min(ans, calc(l, i, xl, xl + xr) + calc(i, r, xl + xr, xr) - (xl + xr) * a[i]);

      }

      return ans;

    }





int main()

{

    scanf( "%d", &n );

    for( int i = 1; i <= n; i ++ )

    {

        scanf( "%lld", &a[ i ] );

    }

    printf( "%lld", calc( 1, n, 1, 1 ) );

}














// Faster C++ solution for the same problem (measured speedup: 4.86200248075507x):
#include<cstdio>

using namespace std;

long long n,v[19],ct;

long long Min(long long a,long long b){return a<b?a:b;}

long long DP(int l,int r,int s1,int s2)

{

	if(l+1==r)return v[l]*s1+v[r]*s2;

	long long as=2e18;

	for(int i=l+1;i<r;i++)as=Min(as,DP(l,i,s1,s1+s2)+DP(i,r,s1+s2,s2)-v[i]*(s1+s2));

	return as;

}

int main(){scanf("%lld",&n);for(int i=1;i<=n;i++)scanf("%lld",&v[i]);printf("%lld\n",DP(1,n,1,1));}//