malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     long long a, b, c, i, j, k, l, m, t, x, y, n, z;     string s;     map<long long, long long> mp;     map<long long, long long>::iterator it;     cin >> a >> s;     n = s.size();     long long a1[n + 1];     a1[0] = 0;     for (i = 1; i < n + 1; i++) a1[i] = s[i - 1] -  0  + a1[i - 1];     for (i = 0; i < n + 1; i++) {       for (j = i + 1; j < n + 1; j++) {         mp[a1[j] - a1[i]]++;       }     }     c = 0;     if (!a) c = (mp[0] * (n * (n + 1) - mp[0]));     if (!a) {       cout << c << endl;       return 0;     }     for (i = 0; i < n + 1; i++) {       for (j = i + 1; j < n + 1; j++) {         if (a1[j] - a1[i] != 0)           if (a % (a1[j] - a1[i]) == 0) {             it = mp.find(a / (a1[j] - a1[i]));             if (it != mp.end()) c = c + mp[a / (a1[j] - a1[i])];           }       }     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long prod = 1;     int arr[10];     for (int i = 0; i < 10; i++) arr[i] = 1;     int p = 0;     while (prod < n) {       p %= 10;       prod /= arr[p];       ++arr[p];       prod *= arr[p];       p++;     }     string s =  codeforces ;     for (int i = 0; i < 10; i++) {       for (int j = 0; j < arr[i]; j++) cout << s[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100 + 10;   const int maxe = maxn * 2;   int fir[maxn];   struct Edge {     int v, c, nxt;     Edge(int v = 0, int c = 0, int nxt = 0) : v(v), c(c), nxt(nxt) {}   } edge[maxe];   int cnt;   bool cir[maxn];   void init() {     memset(fir, -1, sizeof(fir));     cnt = 0;   }   void add_edge(int u, int v, int c) {     edge[cnt] = Edge(v, c, fir[u]);     fir[u] = cnt++;   }   bool dfs(int from, int to, int c) {     cir[from] = true;     if (from == to) return true;     for (int e = fir[from]; e != -1; e = edge[e].nxt)       if (!cir[edge[e].v]) {         if (edge[e].c != c) continue;         if (dfs(edge[e].v, to, c)) {           return true;         }       }     return false;   }   int solve(int from, int to) {     int ans = 0;     bool vis[maxn];     memset(vis, false, sizeof(vis));     for (int e = fir[from]; e != -1; e = edge[e].nxt)       if (!vis[edge[e].c]) {         memset(cir, false, sizeof(cir));         if (dfs(from, to, edge[e].c)) {           ans++;         }         vis[edge[e].c] = true;       }     return ans;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     init();     for (int i = 0; i < m; i++) {       int u, v, c;       scanf( %d%d%d , &u, &v, &c);       add_edge(u, v, c);       add_edge(v, u, c);     }     int q;     scanf( %d , &q);     while (q--) {       int u, v;       scanf( %d%d , &u, &v);       printf( %d n , solve(u, v));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   const long long INF = 1e17;   struct item {     long long t, d, p;   };   long long n, dp[105][2100][2], ans;   item arr[200], arrc[200];   long long solve(long long pos, long long tim) {     if (pos > n) return 0;     if (dp[pos][tim][0]) return max(dp[pos][tim][0], dp[pos][tim][1]);     long long ts = tim + arr[pos].t;     dp[pos][tim][0] = solve(pos + 1, tim);     if (ts < arr[pos].d) dp[pos][tim][1] = solve(pos + 1, ts) + arr[pos].p;     return max(dp[pos][tim][0], dp[pos][tim][1]);   }   bool comp(item l, item r) {     if (l.d == r.d) {       if (l.t == r.t) return l.p > r.p;       return l.t < r.t;     }     return l.d < r.d;   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> arr[i].t >> arr[i].d >> arr[i].p;       arrc[i] = {arr[i].t, arr[i].d, arr[i].p};     }     sort(arr + 1, arr + n + 1, comp);     ans = solve(1, 0);     cout << ans << endl;     long long ansar[300], m = 0;     long long tim = 0;     for (int i = 1; i <= n && ans; i++) {       if (dp[i][tim][1] == ans) {         ansar[++m] = i;         tim += arr[i].t;         ans -= arr[i].p;       }     }     cout << m << endl;     for (int i = 1; i <= m; i++) {       long long first = ansar[i];       for (int j = 1; j <= n; j++) {         if (arr[first].t == arrc[j].t && arr[first].d == arrc[j].d &&             arr[first].p == arrc[j].p) {           cout << j <<    ;           arrc[j].t = 1000000000000;           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> ve;   const int MAX = 51;   long long C[MAX][MAX];   void build() {     for (int i = 0; i < MAX; ++i)       for (int j = 0; j < MAX; ++j)         C[i][j] = (j == 0) ? 1 : ((i == 0) ? 0 : C[i - 1][j - 1] + C[i - 1][j]);   }   double memo[MAX][MAX][MAX];   double solve(int i, int last, int mx) {     if (i == m) {       if (last != n) return 0;       return mx;     }     double &ret = memo[i][last][mx];     if (ret == ret) return ret;     ret = 0;     for (int j = 0; j <= n - last; j++) {       ret += C[n - last][j] * 1LL *              solve(i + 1, last + j, max(mx, (j / ve[i]) + (j % ve[i] != 0)));     }     return ret;   }   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     build();     cin >> n >> m;     for (int i = 0; i < m; i++) {       int x;       cin >> x;       ve.push_back(x);     }     memset(memo, -1, sizeof memo);     cout << fixed << setprecision(20) << powl(1.0 / m, n) * solve(0, 0, 0)          << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int s[100005];   int bas[100005];   const int INF = 0x7fffffff;   bool cmp(int a, int b) { return a > b; }   int main() {     int n, m;     while (scanf( %d , &m) != EOF) {       memset(s, 0, sizeof(s));       memset(bas, 0, sizeof(bas));       int i, j;       int minbas = INF;       for (i = 0; i < m; i++) {         scanf( %d , &bas[i]);         if (minbas > bas[i]) minbas = bas[i];       }       scanf( %d , &n);       for (i = 0; i < n; i++) {         scanf( %d , &s[i]);       }       sort(s, s + n, cmp);       int sum = 0;       int tot = 0;       int pan = 0;       for (i = 0; i < n;) {         for (j = 0; j < minbas; j++) {           sum += s[i];           i++;           if (i >= n) {             pan = 1;             break;           }         }         i += 2;       }       printf( %d n , sum);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, arr[55] = {}, sm = 0, dp[55][2] = {};   long long rec(int ind, bool dt) {     if (ind == n - 1) {       if (dt)         return 0;       else         return arr[ind];     }     if (dp[ind][dt] != -1) return dp[ind][dt];     if (dt)       return dp[ind][dt] = min(rec(ind + 1, dt) + arr[ind], rec(ind + 1, !dt));     else       return dp[ind][dt] = max(rec(ind + 1, dt), rec(ind + 1, !dt) + arr[ind]);   }   int main() {     cin >> n;     for (int i = 0; i < 55; i++) {       dp[i][0] = -1;       dp[i][1] = -1;     }     for (int i = 0; i < n; i++) {       cin >> arr[i];       sm += arr[i];     }     long long ans = rec(0, 0);     cout << (sm - ans) <<     << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[251][251][51];   bool check(int n, int ans, int t) {     if (t == 0) {       if (ans == n) return 1;       return 0;     }     bool ret = 0;     if (arr[n][ans + 3][t - 1] == -1)       arr[n][ans + 3][t - 1] = check(n, ans + 3, t - 1);     ret |= arr[n][ans + 3][t - 1];     if (arr[n][ans + 4][t - 1] == -1)       arr[n][ans + 4][t - 1] = check(n, ans + 4, t - 1);     ret |= arr[n][ans + 4][t - 1];     if (arr[n][ans + 5][t - 1] == -1)       arr[n][ans + 5][t - 1] = check(n, ans + 5, t - 1);     ret |= arr[n][ans + 5][t - 1];     return ret;   }   int main() {     for (int i = 0; i < 251; i++)       for (int ii = 0; ii < 251; ii++)         for (int iii = 0; iii < 51; iii++) arr[i][ii][iii] = -1;     int n, k;     cin >> n >> k;     for (int i = 0; i <= n; i++) {       if (check(k - i * 2, 0, n - i)) {         cout << i;         return 0;       }     }     cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int maxn = 1000010;   struct Point {     long long x, y;     Point() {}     Point(long long x, long long y) : x(x), y(y) {}     bool operator<(const Point &rhs) const {       if (x == rhs.x) return y < rhs.y;       return x < rhs.x;     }   } p[5000];   long long fac[maxn];   long long powmod(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = res * a % mod;       a = a * a % mod;       b >>= 1;     }     return res;   }   long long C(long long n, long long m) {     if (m > n || m < 0) return 0;     long long s1 = fac[n], s2 = fac[m] * fac[n - m] % mod;     return s1 * powmod(s2, mod - 2) % mod;   }   long long dp[maxn];   int n, m, k;   int main() {     fac[0] = 1LL;     for (int i = 1; i < maxn; i++) fac[i] = fac[i - 1] * i % mod;     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= k; i++) {       scanf( %lld%lld , &p[i].x, &p[i].y);       p[i].x--, p[i].y--;     }     p[++k].x = n - 1;     p[k].y = m - 1;     sort(p + 1, p + k + 1);     for (int i = 1; i <= k; i++) {       dp[i] = C(p[i].x + p[i].y, p[i].x);       for (int j = 1; j < i; j++) {         if (p[j].y <= p[i].y) {           dp[i] += (mod - dp[j] * C(p[i].x - p[j].x + p[i].y - p[j].y,                                     p[i].x - p[j].x));           dp[i] %= mod;         }       }     }     printf( %lld n , (dp[k] + mod) % mod);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b;     cin >> a >> b;     long long int mx = 0;     for (long long int i = 0; i < a.size(); i++) {       long long int g = (a[i] -  0 );       mx = max(mx, g);     }     for (long long int i = 0; i < b.size(); i++) {       long long int g = (b[i] -  0 );       mx = max(mx, g);     }     mx++;     string h =   ;     long long int c = 0, s = 0;     for (long long int i = 0; i < 20; i++) {       if (a.size() < i) a =  0  + a;       if (b.size() < i) b =  0  + b;     }     for (long long int i = 18; i >= 0; i--) {       long long int q = (a[i] -  0 ), w = (b[i] -  0 );       s = (q + w + c) % mx;       char ch = ( 0  + s);       h = ch + h;       c = (q + w + c) / mx;     }     long long int k = 0;     while (h[k] ==  0 ) k++;     cout << 19 - k << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 1e6;   const long long int inf = 1e14;   const long long int mod = 1e9 + 7;   const double PI = acos(-1);   long long int powm(long long int a, long long int b) {     a = a % mod;     long long int res = 1;     while (b) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return res;   }   long long int n, a[N];   long double f(long double xn) {     set<long double> b = {0};     long double su = 0, ans = 0;     long double ma = 0, mi = 0;     for (int i = 0; i < n; i++) {       su += (long double)a[i] - xn;       ans = max({ans, abs(su - mi), abs(su - ma)});       ma = max(ma, su);       mi = min(mi, su);     }     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     long long int t = 1;     cout << fixed << std::setprecision(10);     while (t--) {       cin >> n;       long double B = -100000;       long double A = 100000;       for (int i = 0; i < n; i++) {         cin >> a[i];         B = max(B, (long double)a[i]);         A = min(A, (long double)a[i]);       }       for (int i = 0; i < 100; i++) {         long double m1 = (A * 2 + B) / 3.0;         long double m2 = (A + 2 * B) / 3.0;         if (f(m1) > f(m2))           A = m1;         else           B = m2;       }       cout << f(A) <<   n ;     }   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const long long mod = 1e9 + 7;   long long a[200010];   int main() {     long long n, k;     cin >> n >> k;     long long i;     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     long long sum = 0;     for (i = 1; i <= n; i++) {       long long temp = min(i, n - i + 1);       temp = min(temp, n - k + 1);       temp = min(temp, k);       sum += temp * a[i];     }     double ans = double(sum) / (n - k + 1);     printf( %.10lf , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     while (cin >> n) {       int m = n % 4;       cout << (m == 0 || m == 3 ? 0 : 1) << endl << n / 2 <<    ;       for (int i = n; i >= 4; i -= 4) cout << i - 1 <<     << i - 2 <<    ;       if (m == 2)         cout <<  1   << endl;       else if (m == 3)         cout <<  3   << endl;       else         cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e3 + 5;   int n, m, k;   struct node {     int x, y, step;   };   char s[maxn][maxn];   bool vis[maxn][maxn][4];   int go[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};   int bfs(int x, int y, int tx, int ty) {     for (int i = 0; i < 4; ++i) vis[x][y][i] = 1;     queue<node> q;     node tmp, tem;     tem.x = x, tem.y = y, tem.step = 0;     q.push(tem);     int xx, yy;     while (!q.empty()) {       tmp = q.front();       q.pop();       if (tmp.x == tx && tmp.y == ty) return tmp.step;       for (int i = 0; i < 4; i++) {         tem = tmp;         tem.step++;         for (int j = 1; j <= k; j++) {           xx = tem.x + go[i][0];           yy = tem.y + go[i][1];           if (xx < 0 || xx > n) break;           if (yy < 0 || yy > m) break;           if (s[xx][yy] !=  . ) break;           if (vis[xx][yy][i]) break;           tem.x = xx;           tem.y = yy;           vis[xx][yy][i] = 1;           q.push(tem);         }       }     }     return -1;   }   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++) scanf( %s , s[i] + 1);     int x, xx, y, yy;     scanf( %d%d%d%d , &x, &y, &xx, &yy);     printf( %d n , bfs(x, y, xx, yy));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long A[100005];   long long D[100005];   long long qzh[100005];   long long hzh[100005];   long long ans[100005];   long long dp[100005];   int main() {     int n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) scanf( %lld , &A[i]);     for (int i = 1; i <= n; i++) scanf( %lld , &D[i]);     for (int i = n; i >= 1; i--) {       hzh[i] = A[i] + hzh[i + 1];       dp[i] = max(dp[i + 1], hzh[i] - D[i]);     }     long long MIN = D[1];     for (int i = 1; i <= n; i++) {       MIN = min(MIN, D[i]);       qzh[i] = qzh[i - 1] + A[i];       ans[i] = max(dp[i + 1], qzh[i] - MIN + dp[i + 1]);     }     if (k == 0) {       long long res = 0;       for (int i = 1; i <= n; i++) {         res = max(res, dp[i]);       }       cout << res << endl;     } else if (k == 1) {       long long res = 0;       for (int i = 1; i < n; i++) {         res = max(res, ans[i]);       }       MIN = min(A[n], D[n]);       for (int i = n - 1; i >= 1; i--) {         dp[i] = hzh[i] - D[i];         res = max(res, dp[i] - MIN);         MIN = min(MIN, min(A[i], D[i]));       }       cout << res << endl;     } else {       long long res = 0;       for (int i = 1; i < n; i++) {         res = max(res, qzh[n] - D[i]);       }       res = max(res, A[n] - D[n]);       cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 50;   int mod = 1e9 + 7;   long long add(long long a, long long b) {     return (a % mod + b % mod + mod) % mod;   }   long long mul(long long a, long long b) { return (a % mod * (b % mod)) % mod; }   int dp[N][3];   int solve(int rem, int val) {     if (rem == 0) return val == 1;     int &ans = dp[rem][val];     if (~ans) return ans;     ans = solve(rem - 1, val);     ans = add(ans, solve(rem - 1, val * -1));     return ans;   }   int dp2[N][20];   int solve2(int remp, int rem) {     if (remp == 0) return rem == 0;     int &ans = dp2[remp][rem];     if (~ans) return ans;     ans = solve2(remp - 1, rem);     if (rem) ans = add(ans, solve2(remp, rem - 1));     return ans;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     memset(dp, -1, sizeof(dp));     memset(dp2, -1, sizeof(dp2));     int t;     cin >> t;     while (t--) {       int x, y;       cin >> x >> y;       map<int, int> co;       for (int i = 2; i * i <= x; i++) {         while (x % i == 0) {           x /= i;           co[i]++;         }       }       if (x != 1) co[x]++;       long long ans = solve(y, 1);       for (auto it : co) ans = mul(ans, solve2(y, it.second));       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, a[100001];     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     cout << 1 <<     << n << endl;     cout << 0 <<    ;     for (int i = 1; i < n; i++) cout << (n * (n - 1 - a[i])) <<    ;     cout << endl;     cout << 1 <<     << 1 << endl;     cout << (-a[0]) << endl;     if (n > 1) {       cout << 2 <<     << n << endl;       for (int i = 1; i < n; i++) cout << ((n - 1) * (a[i] - n)) <<    ;       cout << endl;     } else {       cout << 1 <<     << 1 << endl;       cout << 0 << endl;     }     return 0;   }
#include<cstdio>   #include<iomanip>   #include<iostream>   #include<cstring>   #include<string>   #include<cmath>   #include<map>   #include<algorithm>   #include<vector>   #include<set>   #include<queue>   #include<unordered_map>   #define Quick ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)   #define ll long long   #define P pair<int,int>   #define inf 0x3f3f3f3f   #define endl   n    #define PI acos(-1)   #define mem(a, b) memset(a, b, sizeof a)   using namespace std;   const int N =2007;   const int mod = 1e9 + 7;   ll a[N];   ll dp[N][N];   int main()   {       Quick;          //重新排序使其在每一位上的（max-min）总和最小          int n; cin >> n;       for (int i = 0; i < n; i++)cin >> a[i];       sort(a, a + n);       for (int i = 0; i < n; i++) {           for (int j = 0; j < n; j++) {               dp[i][j] = 1e12;//初始dp数组保留最大值。           }       }       //初始化dp数组。       dp[0][0] = a[n - 1] - a[0];       //减小这个差值，可以删掉一个最小的或者最大的       for (int i = 1; i < n; i++)       {           //只删除最大值i次           dp[i][0] = dp[i - 1][0] + a[n - i - 1] - a[0]; //删除最大值从右边删除，那么删除之后当前最大值就是a[n-i-1];           //只删除最小值i次           dp[0][i] = dp[0][i - 1] + a[n - 1] - a[i];     //删除最小值从左边删除，那么删除之后当前最小值就是a[i]。       }          //接下来开始进行状态转移取最优。       for (int i = 1; i < n; i++) {           for (int j = 1; i + j < n; j++) {               //i+j不得超过n次。               dp[i][j] = min(dp[i][j], dp[i - 1][j] + a[n - i - 1] - a[j]);//选择删除最大值               dp[i][j] = min(dp[i][j], dp[i][j - 1] + a[n - i - 1] - a[j]);//选择删除最小值           }       }       ll res = 1e12;       for (int i = 0; i < n; i++) {           res = min(res, dp[i][n - i - 1]);       }       cout << res << endl;   }
#include<bits/stdc++.h>    using namespace std;   void solve()   {    long long int n,s=0,sum=0,k;    cin>>n;    long long int arr[n+1];    for(int i=1;i<=n;i++)    {    cin>>arr[i];    if(i%2==1)    sum=sum+arr[i];    else    s=s+arr[i];}    if(sum>=s)    {     for(int i=1;i<=n;i++)        {         if(i%2==1)         cout<<arr[i]<<   ;         else         cout<< 1 <<   ;     }    }     else    {     for(int i=1;i<=n;i++)        {         if(i%2==0)         cout<<arr[i]<<   ;         else         cout<< 1 <<   ;     }    }     cout<<endl;   }   int main() {    int t=1;    cin >> t;    while(t--) {     solve();    }   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   struct point {     double x, y;     point() {}     point(double _x, double _y) {       x = _x;       y = _y;     }     point operator+(const point &t) { return point(x + t.x, y + t.y); }     point operator-(const point &t) { return point(x - t.x, y - t.y); }     double dist(const point &t) {       return ((x - t.x) * (x - t.x) + (y - t.y) * (y - t.y));     }   };   struct line {     double a, b, c;     line() {}     line(double _a, double _b, double _c) {       a = _a;       b = _b;       c = _c;     }     void build(const point &p, const point &q) {       a = p.y - q.y;       b = q.x - p.x;       c = -(p.x * (p.y - q.y) + p.y * (q.x - p.x));     }   };   int n, lt, rt;   point p[2000];   double mx = 1e+15, mn = -(1e+15);   bool intersect(const line &a, point &res) {     if (fabs(a.a) <= eps) return false;     res.y = p[0].y;     res.x = (-a.c - (a.b * res.y)) / a.a;     return true;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %lf%lf , &p[i].x, &p[i].y);     p[n] = p[0];     lt = int(min(p[0].x, p[1].x));     rt = int(max(p[0].x, p[1].x));     p[n + 1] = p[1];     for (int i = 1; i < n; i++) {       line l;       l.build(p[i], p[i + 1]);       point res, tt = p[i + 1] - p[i];       if (intersect(l, res)) {         if (tt.y < eps)           mx = min(mx, res.x);         else           mn = max(mn, res.x);       } else if ((p[1].x - p[0].x) * tt.x > eps) {         printf( 0 n );         return 0;       }     }     int x = ceil(mn - eps), y = floor(mx + eps);     printf( %d n , max(0, min(y, rt) - max(x, lt) + 1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long min(long long a, long long b) { return (a < b) ? a : b; }   int main() {     long long n, m, b_max_1 = 0, b_max_2 = 0, g_min = 1e9;     long long sum_b = 0, sum_g = 0;     cin >> n >> m;     long long b[n], g[m];     for (int i = 0; i < n; ++i) {       cin >> b[i];       sum_b += b[i];       if (b[i] > b_max_1) {         b_max_2 = b_max_1;         b_max_1 = b[i];       } else if (b[i] > b_max_2) {         b_max_2 = b[i];       }     }     sum_b = sum_b * m;     for (int i = 0; i < m; ++i) {       cin >> g[i];       sum_g += g[i];       g_min = min(g_min, g[i]);     }     if (b_max_1 > g_min) {       cout << -1 <<   n ;       return 0;     }     if (g_min > b_max_1)       sum_b = sum_b + sum_g - (m - 1) * b_max_1 - b_max_2;     else       sum_b = sum_b - m * b_max_1 + sum_g;     cout << sum_b <<   n ;     return 0;   }