func_code_string: #include <bits/stdc++.h>   using namespace std;   template <class T, class T2>   inline int chkmax(T &x, const T2 &y) {     return x < y ? x = y, 1 : 0;   }   template <class T, class T2>   inline int chkmin(T &x, const T2 &y) {     return x > y ? x = y, 1 : 0;   }   const int MAXN = (1 << 20);   int n, m;   int64_t g[MAXN], b[MAXN];   void read() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> b[i];     for (int i = 0; i < m; i++) cin >> g[i];   }   void solve() {     sort(b, b + n);     sort(g, g + m);     if (b[n - 1] > g[0]) {       cout << -1 <<   n ;       return;     }     int64_t answer = 0;     for (int i = 0; i < n; i++) answer += b[i] * 1ll * m;     for (int i = m - 1; i >= 0; i--) answer += g[i];     if (b[n - 1] == g[0])       answer -= m * 1ll * b[n - 1];     else {       answer -= (m - 1) * 1ll * b[n - 1];       answer -= b[n - 2];     }     cout << answer <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     read();     solve();     return 0;   }   