#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; bool check(ll a, ll b, ll c){ if(a<=0 || b<=0 || c<=0) return false; if((ac && a!=c) || (a>b && b>t; const ll INF=3e18; for(int i=0; i>a>>b>>c>>x>>y>>z; if(a>c) swap(a, c), swap(x, z); if(check(a, b, c)){ cout<<0< v; for(int k=0; k<4; k++){ if(a-k>0) v.push_back(a-k); if(b-k>0) v.push_back(b-k); if(c-k>0) v.push_back(c-k); } for(int i=0; i<4; i++){ for(int j=0; j<4; j++){ ll a1=a-i, b1=b-i-j, c1=c-j; if(a1<=0 || b1<=0 || c1<=0 || a1==c1) continue; if(check(a1, b1, c1)){ ans=min(ans, x*i+y*j); continue; } if(b1>=2){ if(a1>c1 && c1-(a1-b1+1)>0) ans=min(ans, x*i+y*j+z*(a1-b1+1)); else if(a10) ans=min(ans, x*i+y*j+z*(c1-b1+1)); } } } for(int i=0; i<4; i++){ for(int j=0; j<4; j++){ ll a1=a-j, b1=b-i, c1=c-i-j; if(a1<=0 || b1<=0 || c1<=0 || a1==b1) continue; if(check(a1, b1, c1)){ ans=min(ans, y*i+z*j); continue; } if(a1>b1 && b1>=c1 && check(a1-(b1-c1+1), b1-(b1-c1+1), c1)){ ans=min(ans, y*i+z*j+x*(b1-c1+1)); } } } for(int i=0; i<4; i++){ for(int j=0; j<4; j++){ ll a1=a-i-j, b1=b-j, c1=c-i; if(a1<=0 || b1<=0 || c1<=0 || b1==c1) continue; if(check(a1, b1, c1)){ ans=min(ans, z*i+x*j); continue; } if(a1<=b1 && b1