malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int mxn = 1e6 + 3;   struct node {     int v, i, j, id;   } a[mxn];   int n, m, r[mxn], c[mxn], f[mxn], v[mxn], o[mxn];   int cmp(node a, node b) { return a.v < b.v; }   int fffa(int x) { return f[x] == x ? x : f[x] = fffa(f[x]); }   int main() {     scanf( %d%d , &n, &m);     for (int(i) = (int)(1); (i) <= (int)(n); ++(i))       for (int(j) = (int)(1); (j) <= (int)(m); ++(j)) {         int id = (i - 1) * m + j;         scanf( %d , &o[id]);         a[id].v = o[id];         a[id].i = i;         a[id].j = j;         a[id].id = f[id] = id;       }     sort(a + 1, a + 1 + n * m, cmp);     for (int(i) = (int)(1); (i) <= (int)(n * m); ++(i)) {       int fi = fffa(r[a[i].i]);       int fj = fffa(c[a[i].j]);       v[a[i].id] = max(v[fi] + (a[i].v > o[fi]), v[fj] + (a[i].v > o[fj]));       int p = fffa(a[i].id);       if (a[i].v == o[fi]) f[fi] = p;       if (a[i].v == o[fj]) f[fj] = p;       r[a[i].i] = c[a[i].j] = p;     }     for (int(i) = (int)(1); (i) <= (int)(n); ++(i))       for (int(j) = (int)(1); (j) <= (int)(m); ++(j))         printf( %d%c , v[fffa((i - 1) * m + j)],    n [j == m]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2000000;   const long long int MOD = 1000000009;   const long long int P = 31;   int N;   long long int t[4 * MAXN] = {0};   long long int tp[4 * MAXN] = {0};   void make_push(int v, int l, int r, long long int tmp) {     t[v] += (r - l + 1) * tmp;     tp[v] += tmp;   }   void push(int v, int l, int r) {     if (l != r) {       make_push(2 * v + 1, l, (l + r) / 2, tp[v]);       make_push(2 * v + 2, (l + r) / 2 + 1, r, tp[v]);     }     tp[v] = 0;   }   void update(int ql, int qr, long long int qv, int v = 0, int l = 0,               int r = N - 1) {     if (qr < l || r < ql) return;     push(v, l, r);     if (ql <= l && r <= qr) {       make_push(v, l, r, qv);     } else {       update(ql, qr, qv, 2 * v + 1, l, (l + r) / 2);       update(ql, qr, qv, 2 * v + 2, (l + r) / 2 + 1, r);       t[v] = t[2 * v + 1] + t[2 * v + 2];     }   }   long long int get_ans(int qp, int v = 0, int l = 0, int r = N - 1) {     if (qp < l || r < qp) return 0;     push(v, l, r);     if (qp <= l && r <= qp)       return t[v];     else       return get_ans(qp, 2 * v + 1, l, (l + r) / 2) +              get_ans(qp, 2 * v + 2, (l + r) / 2 + 1, r);   }   int A[MAXN], T[MAXN], X[MAXN];   int id[MAXN];   long long int ans[MAXN];   vector<int> ts;   bool cmp(int idl, int idr) {     if (X[idl] != X[idr]) return X[idl] < X[idr];     return idl < idr;   }   int main() {     scanf( %d , &N);     for (int i = 0; i < N; i++) {       scanf( %d %d %d , &A[i], &T[i], &X[i]);       id[i] = i;     }     sort(id, id + N, cmp);     ts.reserve(N);     int lb, rb = 0;     int offs = 0, sz;     int tid;     while (rb < N) {       lb = rb;       while (rb < N && X[id[rb]] == X[id[lb]]) rb++;       sz = rb - lb;       for (int i = lb; i < rb; i++) {         ts.push_back(T[id[i]]);       }       sort(ts.begin(), ts.end());       for (int i = lb; i <= rb; i++) {         tid = lower_bound(ts.begin(), ts.end(), T[id[i]]) - ts.begin();         if (A[id[i]] == 1) {           update(offs + tid, offs + sz - 1, 1);         } else if (A[id[i]] == 2) {           update(offs + tid, offs + sz - 1, -1);         } else {           ans[id[i]] = get_ans(offs + tid);         }       }       offs += sz;       ts.clear();     }     for (int i = 0; i < N; i++) {       if (A[i] == 3) printf( %I64d n , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int h = 0, v = 0, size;     string s;     cin >> s;     size = s.size();     for (int i = 0; i < size; i++) {       if (s[i] ==  0 ) {         if (v == 0) {           cout <<  1 3 n ;           v++;         } else {           cout <<  3 3 n ;           v--;         }       } else {         if (h == 0) {           cout <<  3 1 n ;           h++;         } else {           cout <<  3 3 n ;           h--;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll MOD = 1e9 + 7, N = 1e5 + 10;   void test() {     string s;     cin >> s;     vector<ll> cnt(26);     for (auto c : s) {       cnt[c -  a ]++;     }     ll m;     cin >> m;     vector<ll> b(m);     for (ll i = 0; i < m; i++) {       cin >> b[i];     }     ll n = s.length();     vector<ll> done(m);     string res(m,  . );     ll up = 25;     for (ll i = 0; i < m; i++) {       ll mx = 1e9;       for (ll j = 0; j < m; j++) {         if (done[j]) continue;         mx = min(mx, b[j]);       }       if (mx == 1e9) break;       vector<ll> pos;       for (ll j = 0; j < m; j++) {         if (done[j]) continue;         if (mx == b[j]) {           pos.push_back(j);         }       }       ll v;       for (ll j = up; j >= 0; --j) {         if (cnt[j] >= pos.size()) {           v = j;           break;         }       }       up = v - 1;       for (auto &e : pos) {         res[e] = char(v +  a );       }       for (auto &e : pos) {         for (ll j = 0; j < m; j++) {           if (!done[j]) {             b[j] -= abs(j - e);           }         }       }       for (auto &e : pos) done[e] = 1;     }     cout << res <<   n ;     return;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ll tt = 1;     cin >> tt;     for (ll i = 0; i < tt; i++) test();     return 0;   }
#include <iostream>   #include <bits/stdc++.h>   using namespace std;   typedef long long int l;   #define fastIO              ios::sync_with_stdio(false), cin.tie(0)   #define pf                  push_front   #define pb                  push_back   #define popb                pop_back()   #define popf                pop_front()   #define loop(i,n)           for(int i=0;i<n;i++)   #define loope(i,n)           for(int i=0;i<=n;i++)   #define loop1(i,n)           for(int i=1;i<n;i++)   #define loops(i,x,n)        for(int i=x;i<n;i++)   #define loopr(i,n)          for(int i=n-1;i>=0;i--)   #define loop1e(i,n)          for(int i=1;i<=n;i++)   #define F first   #define S second   #define LB lower_bound   #define UB upper_bound   #define vc vector   #define vll vector<long long>   #define pll pair<long long,long long>   #define eb emplace_back   #define pb push_back   #define mp make_pair   #define INT_BITS 32   #define  st                  l t; cin>>t;   #define  sn                  l n; cin>>n;   #define all(x) x.begin(),x.end()   //#define  unordered_map<l,l>  u;   #define MOD1 1000000007   int main()   {       st;       while(t--)       {              l n;           cin>>n;           l a[n];           l k = n;   for(int i=0;i<n;i++){               a[i]=k;               k--;           }           if(n&1){               int p=n/2;               swap(a[p],a[p+1]);           }           for(int i=0;i<n;i++){               cout<<a[i]<<   ;           }           cout<<endl;          // cout<<endl;          }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ans[210000], k;   vector<pair<int, int>> item, b;   struct R {     int l, r, cc;     long long value;     R(int L, int R, int CC = 0, long long VALUE = 0) {       l = L, r = R, cc = CC, value = VALUE;     }   };   vector<R> range;   void update() {     long long value;     int l, r, c;     for (int i = 0; i < range.size(); i++) {       l = range[i].l, r = range[i].r;       c = range[i].cc, value = range[i].value;       for (int j = l; j <= r; j++) b[j].first -= value, ans[b[j].second] += c;     }     sort(b.begin(), b.end());     range.clear();     range.push_back(R(0, k - 1));   }   int main() {     int n, c, q, l, r;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d %d , &c, &q);       item.push_back(make_pair(-q, c));     }     sort(item.begin(), item.end());     scanf( %d , &k);     for (int i = 0; i < k; i++) scanf( %d , &c), b.push_back(make_pair(c, i));     sort(b.begin(), b.end());     int value = 0;     update();     for (int i = 0; i < n; i++) {       c = item[i].second;       q = range.size();       for (int j = 0; j < q; j++) {         l = range[j].l, r = range[j].r;         value = range[j].value;         if (b[l].first >= value + c)           range[j].value += c, ++range[j].cc;         else if (b[r].first >= c + value) {           int index = lower_bound(b.begin() + l, b.begin() + r + 1,                                   make_pair(c + value, 0)) -                       b.begin();           range.push_back(R(index, r, range[j].cc + 1, value + c));           range[j].r = index - 1;         }       }       if (range.size() > 500) update();     }     update();     for (int i = 0; i < k; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t, i, j, k, l, m, n, p, q, r, s = 0, a, b, c, d, ans = 0, x, y;     cin >> n >> k;     string s1;     cin >> s1;     for (i = 0; i < n; i++) {       if (s1[i] ==  G ) {         p = i;       } else if (s1[i] ==  T ) {         q = i;       }     }     if (abs(p - q) % k != 0) {       cout <<  NO n ;       return 0;     }     a = min(p, q);     b = max(p, q);     for (i = a; i <= b; i += k) {       if (s1[i] ==  # ) {         cout <<  NO n ;         return 0;       }     }     cout <<  YES n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int x, y, a, b;     double dis = 0;     cin >> x >> y;     a = x;     b = y;     n--;     while (n--) {       cin >> x >> y;       dis += (double)sqrt(pow(y - b, 2) + pow(x - a, 2));       a = x;       b = y;     }     dis = (dis / 50) * k;     printf( %.6f , dis);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int MAXN = 200010;   const long long MOD = 998244353;   int main() {     int n;     scanf( %d , &n);     if (n == 1)       printf( 1 2 n );     else       printf( %d 2 n , (n - 1) * 2);     printf( 1 2 n );   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1};   const int dy[] = {0, 1, 0, -1, -1, 1, -1, 1};   const int N = 3e5 + 2;   int v[N], n, q;   void read() {     cin >> n >> q;     for (int i = 1; i <= n; i++) cin >> v[i];     v[0] = 0;     v[n + 1] = 0;   }   int maxima_con[N], minima_con[N];   long long maxima_sum = 0, minima_sum = 0;   bool is_maxima(int indx) { return v[indx] > max(v[indx - 1], v[indx + 1]); }   bool is_minima(int indx) { return v[indx] < min(v[indx - 1], v[indx + 1]); }   void see(int indx) {     int &i = indx;     maxima_sum -= maxima_con[i];     minima_sum -= minima_con[i];     maxima_con[i] = 0;     minima_con[i] = 0;     if (is_maxima(i)) {       maxima_con[i] = v[i];       maxima_sum += maxima_con[i];     }     if (is_minima(i)) {       minima_con[i] = v[i];       minima_sum += minima_con[i];     }   }   void solve(int test_case) {     read();     for (int i = 1; i <= n; i++) {       see(i);     }     cout << maxima_sum - minima_sum;     cout <<   n ;     ;     for (int i = 0; i < q; i++) {       int l, r;       cin >> l >> r;       swap(v[l], v[r]);       for (int del = -1; del <= 1; del++) {         int indx = l + del;         if (indx > 0 && indx <= n) see(indx);         indx = r + del;         if (indx > 0 && indx <= n) see(indx);       }       cout << maxima_sum - minima_sum;       cout <<   n ;       ;     }   }   void clear_data() {     for (int i = 1; i <= n; i++) maxima_con[i] = 0, minima_con[i] = 0;     maxima_sum = 0;     minima_sum = 0;   }   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(0);     int t = 1;     cin >> t;     for (int i = 1; i <= t; i++) {       solve(i);       clear_data();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 10;   const long long mod = 1e9 + 7;   long long read() {     long long x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) x = (x << 1) + (x << 3) + c -  0 , c = getchar();     return x * f;   }   double ans;   struct BIT {     long long tr[N];     long long Bmax;     long long lb(long long x) { return (-x) & x; }     void init(long long n) {       Bmax = n;       for (long long i = 0; i <= n; i++) tr[i] = 0;     }     long long query(long long x) {       if (x <= 0) return 0;       long long res = 0;       while (x) {         res += tr[x];         x -= lb(x);       }       return res;     }     void update(long long x, long long w) {       if (x <= 0) return;       while (x <= Bmax) {         tr[x] += w;         x += lb(x);       }     }   } t1, t2;   int a[N];   int main() {     long long n = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (long long i = 1; i <= n; i++) {       ans += (double)1.00 * i * (i - 1) / 4.00 * (n - i + 1);     }     t1.init(n);     t2.init(n);     for (long long i = 1; i <= n; i++) {       long long o1 = t1.query(n) - t1.query(a[i]);       long long o2 = t2.query(n) - t2.query(a[i]);       t1.update(a[i], 1);       t2.update(a[i], i);       ans += (double)(1.00 * n * (n + 1) * o1 * 0.5 - 1.00 * (n - i + 1) * o2);     }     printf( %.10lf , ans / (1.00 * n * (n + 1) / 2));   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000005;   const int inf = 1e9 + 7;   long long fac[N], M, inv[N];   inline long long po(long long x, long long y, long long z) {     long long res = 1;     while (y) {       if (y & 1) res = res * x % z;       x = x * x % z;       y >>= 1;     }     return res;   }   long long ans[N], M2;   inline long long C(int x, int y) {     return fac[x] * inv[y] % M2 * inv[x - y] % M2;   }   int main() {     int n, m, a;     scanf( %d%d%d%lld , &n, &m, &a, &M);     long long res = 1;     for (int i = (1); i <= (2000000); i++) {       res = res * (long long)a % M;       if (res == 1) {         M2 = i;         break;       }     }     fac[0] = fac[1] = inv[0] = inv[1] = 1;     for (int i = (2); i <= (M2); i++) {       fac[i] = fac[i - 1] * (long long)i % M2;       inv[i] = po(fac[i], M2 - 2, M2);     }     ans[0] = 1;     for (int i = (1); i <= (N - 1); i++) {       ans[i] = ans[i - 1];       ans[i] += C(m, i);     }     for (int i = (n - 1); i >= (0); i--) printf( %lld  , po(a, ans[i], M));     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int II() {     int n;     scanf( %d , &n);     return n;   }   int table[100][100];   char message[100][200];   string names[100];   void recprint(int m, int s) {     if (m < 0) return;     recprint(m - 1, table[m][s]);     cout << names[s];     printf( :%s n , message[m]);   }   int main() {     int T = II();     while (T--) {       set<std::string> usernames;       int N = II();       for (int x = 0; x < N; x++) {         string s;         cin >> s;         usernames.insert(s);       }       for (auto it = usernames.begin(); it != usernames.end(); it++)         names[distance(usernames.begin(), it)] = *it;       int M = II();       int sa = N, sb = N;       for (int m = 0; m < M; m++) {         for (int x = 0; x < N; x++) table[m][x] = N;         string user;         user.clear();         char c = getchar();         while (c < 32) c = getchar();         while (c !=  : ) {           user += c;           c = getchar();         }         int it = distance(usernames.begin(), usernames.find(user));         if (it < N)           for (int x = 0; x < N; x++)             if (x != it) table[m][x] = -1;         user.clear();         char *msg = message[m];         c = getchar();         while (true) {           bool ended = false;           if (c ==  !  || c ==  ?  || c ==  .  || c ==  ,  || c ==     ||               c == 10) {             int it = distance(usernames.begin(), usernames.find(user));             if (it < N) table[m][it] = -1;             ended = true;           }           if (c == 10) break;           *msg = c;           msg++;           user += c;           if (ended) user.clear();           c = getchar();         }         *msg = 0;         for (int x = 0; x < N; x++)           if (table[m][x] != -1) table[m][x] = (x == sa ? sb : sa);         sa = sb = -1;         for (int x = 0; x < N; x++)           if (table[m][x] != -1) sa = x;         for (int x = 0; x < N; x++)           if (table[m][x] != -1)             if (x != sa) sb = x;       }       if (sa == -1)         printf( Impossible n );       else         recprint(M - 1, sa);     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( -O2 )   using namespace std;   void err(istream_iterator<string> it) { cerr << endl; }   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a <<   t ;     err(++it, args...);   }   template <typename T1, typename T2>   ostream& operator<<(ostream& c, pair<T1, T2>& v) {     c <<  (  << v.first <<  ,  << v.second <<  ) ;     return c;   }   template <template <class...> class TT, class... T>   ostream& operator<<(ostream& out, TT<T...>& c) {     out <<  {  ;     for (auto& x : c) out << x <<    ;     out <<  } ;     return out;   }   const int LIM = 1e5 + 5, MOD = 998244353;   int t, n, m, k, x, y, w;   inline long long powm(long long x, long long pw, long long Mod = MOD) {     x %= Mod;     long long res = 1;     while (pw) {       if (pw & 1LL) res = ((res * x)) % Mod;       pw >>= 1;       x = ((x * x)) % Mod;     }     return res;   }   inline long long inv(long long x, long long Mod = MOD) {     return powm(x, Mod - 2, Mod);   }   template <int mod>   struct FWHT {     vector<int> fwht(vector<int> P, bool inverse, bool nomod = 0) {       int sz = P.size();       for (int len = 1; 2 * len <= sz; len <<= 1) {         for (int i = 0; i < sz; i += 2 * len) {           for (int j = 0; j < len; ++j) {             int u = P[i + j];             int v = P[i + len + j];             if (nomod) {               P[i + j] = (u + v);               P[i + len + j] = (u - v);             } else {               P[i + j] = (u + v) % mod;               P[i + len + j] = (u - v + mod) % mod;             }           }         }       }       if (inverse) {         long long iv = inv(sz, mod);         for (int i = 0; i < sz; ++i) P[i] = P[i] * iv % mod;       }       return P;     }     vector<int> mult(vector<int> A, vector<int> B) {       A = fwht(A, 0);       B = fwht(B, 0);       for (int i = 0; i < A.size(); ++i) A[i] = A[i] * 1LL * B[i] % mod;       return fwht(A, 1);     }     vector<int> pow(vector<int> A, long long k) {       A = fwht(A, 0);       for (int i = 0; i < A.size(); ++i) A[i] = powm(A[i], k);       return fwht(A, 1);     }   };   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     int sz = (1 << k);     vector<int> A(sz, 0), B(sz, 0), C(sz, 0), D(sz, 0);     long long o1, o2, o3;     cin >> o1 >> o2 >> o3;     int totxor = 0;     for (int i = 0; i < n; ++i) {       cin >> x >> y >> w;       totxor ^= x;       y ^= x, w ^= x;       A[y]++;       B[w]++;       C[y ^ w]++;     }     FWHT<MOD> f;     A = f.fwht(A, 0, 1), B = f.fwht(B, 0, 1), C = f.fwht(C, 0, 1);     for (int i = 0; i < sz; ++i) {       int x1 = (n + A[i]) / 2, x2 = (n + B[i]) / 2, x3 = (n + C[i]) / 2;       int a1 = (x1 + x2 + x3 - n) / 2, b1 = x2 - a1, c1 = x1 - a1, d1 = x3 - a1;       D[i] = ((powm(o1 + o2 + o3, a1) * powm(o1 - o2 + o3 + MOD, b1) % MOD) *               powm(o1 + o2 - o3 + MOD, c1) % MOD) *              powm(o1 - o2 - o3 + MOD + MOD, d1) % MOD;     }     D = f.fwht(D, 1);     for (int i = 0; i < sz; ++i) cout << D[i ^ totxor] <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int *a = new int[m];     if (m % 2 == 0) {       for (int i = 0; i < m; i++) {         if (i % 2 == 0) a[i] = m / 2 - i / 2;         if (i % 2 == 1) a[i] = m / 2 + 1 + (i - 1) / 2;       }     } else {       for (int i = 0; i < m; i++) {         if (i % 2 == 1) a[i] = (m - 1) / 2 - (i - 1) / 2;         if (i % 2 == 0) a[i] = (m + 1) / 2 + i / 2;       }     }     for (int i = 0; i < n; i++) cout << a[i % m] << endl;     return 0;   }
#include  bits/stdc++.h    using namespace std;   #define pb          push_back   #define ll          long long   #define mp          make_pair   #define pii         pair<int,int>   #define vi          vector<int>   #define vii         vector<pii>   #define mi          map<int,int>   #define mii         map<pii,int>   #define all(a)      (a).begin(),(a).end()   #define x           first   #define y           second   #define sz(x)       (int)x.size()   #define endl          n    #define MOD         1000000007   #define hell        1000000007   #define debug(x) cout <<  >  << #x <<  :  << x << endl;   #define rep(i,a,b)  for(int i=a;i<b;i++)   #define rev(i,a,b)  for(int i=a;i>=b;i--)   #define ll          long long   #define bg(i)       i.begin()   #define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)           #define track(x)                cerr<<#x<< :  <<x<<endl   #define track2(x, y)             cerr<<#x<< :  <<x<<  |  <<#y<< :  <<y<<endl   #define track3(x, y, z)          cerr<<#x<< :  <<x<<  |  <<#y<< :  <<y<<  |  <<#z<< :  <<z<<endl   #define track4(a, b, c, d)       cerr<<#a<< :  <<a<<  |  <<#b<< :  <<b<<  |  <<#c<< :  <<c<<  |  <<#d<< :  <<d<<endl       #define ed(i)       i.end()   #define mem(a)      memset(a, 0, sizeof(a))   ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}   ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}   ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}   ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}   void self_max(int &a, int &b) {a = max(a, b); }   void self_min(int &a, int &b) {a = min(a, b); }      const ll sizes  = 1e7+1;   const ll mod  = 1000000007;      ll n, m , k , o , p;   // ll a[sizes];      void solve(){       cin >> n >> m >> k;       ll sum1 = 0 , sum2 = 0 , sum3 = 0 , sum = 0;       vector<ll>a , b , c, d;       for(int i = 0 ;  i < n ; i++){           cin >> o;           a.pb(o);           sum += o;                   sum1+=o;       }       for(int i = 0 ; i < m ; i++){           cin >> o;           b.pb(o);           sum2 += o;           sum += o;       }       for(int i = 0 ; i < k ; i++){           cin >> o;           c.pb(o);           sum3 += o;           sum += o;       }          sort(all(a));sort(all(b));sort(all(c));       d.push_back(a[0]);       d.pb(b[0]);       d.pb(c[0]);       sort(all(d));       ll mn = min(min(sum1 , sum2) , sum3);       mn = min(mn , d[0] + d[1]);          cout << sum - (2 * mn) << endl;;   }      int main() {       ios::sync_with_stdio(false);       cout<<fixed<<setprecision(2);       cin.tie(0);       cout.tie(0);       // fun();       int t = 1;       // cin >> t;         int p = t;         while(t--){           solve();       }      }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int maxn = 115 + 5;   char s[maxn][maxn];   int main() {     int n, m;     while (~scanf( %d%d , &n, &m)) {       int mini = inf, maxi = 0, minj = inf, maxj = 0;       getchar();       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= m; j++) {           scanf( %c , &s[i][j]);           if (s[i][j] ==  B ) {             mini = min(mini, i);             minj = min(minj, j);             maxi = max(maxi, i);             maxj = max(maxj, j);           }         }         getchar();       }       printf( %d %d n , (mini + maxi) / 2, (minj + maxj) / 2);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, two, one;     cin >> n >> m;     if (m < n - 1 || m > 2 * n + 2)       cout <<  -1 ;     else {       if (m < n) {         cout <<  0 ;         n--;       }       while (m > 0 || n > 0) {         two = max(m - n - 1, 0);         one = min(2 * n + 2, m);         if (two) {           cout <<  11 ;           m -= 2;           two--;         } else if (one) {           cout <<  1 ;           m--;           one--;         }         if (n) cout <<  0 ;         n--;       }     }     return 0;   }