malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   bool dfs(int x, const vector<vector<int>> &g, vector<char> &used,            vector<int> &match, vector<int> &rev_match) {     if (used[x]) return false;     used[x] = 1;     for (int dest : g[x]) {       if (match[dest] == -1 || dfs(match[dest], g, used, match, rev_match)) {         match[dest] = x;         rev_match[x] = dest;         return true;       }     }     return false;   }   int matching(const vector<vector<int>> &g, int left, int right) {     vector<char> used(left);     vector<int> rev_match(left, -1), match(right, -1);     while (true) {       bool ok = false;       fill(used.begin(), used.end(), 0);       for (int i = 0; i < left; i++)         if (rev_match[i] == -1 && !used[i])           ok |= dfs(i, g, used, match, rev_match);       if (!ok) break;     }     return left - count(rev_match.begin(), rev_match.end(), -1);   }   void solve(istream &cin = std::cin, ostream &cout = std::cout) {     int n, m;     cin >> n >> m;     const int inf = int(1e9) + 1;     vector<vector<int>> g(n, vector<int>(n, inf));     for (int i = 0; i < n; i++) g[i][i] = 0;     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       --u, --v;       g[u][v] = g[v][u] = 1;     }     for (int k = 0; k < n; k++)       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);     int s, b, k, h;     cin >> s >> b >> k >> h;     vector<int> pos_s(s), fuel(s), atk(s);     vector<int> pos_b(b), def(b);     for (int i = 0; i < s; i++) {       cin >> pos_s[i] >> atk[i] >> fuel[i];       --pos_s[i];     }     for (int i = 0; i < b; i++) {       cin >> pos_b[i] >> def[i];       --pos_b[i];     }     vector<vector<int>> graph(s);     for (int i = 0; i < s; i++)       for (int j = 0; j < b; j++)         if (g[pos_s[i]][pos_b[j]] <= fuel[i] && def[j] <= atk[i])           graph[i].push_back(j);     const int len = matching(graph, s, b);     ll ans = min((ll)len * k, (ll)s * h);     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout << fixed;     cout << setprecision(20);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = (long long)(1000000007);   const double eps = 1e-9;   const double pi = 3.1415926535897932384626;   long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }   bool isprime(int n) {     if (n == 1) return false;     for (long long i = 2; i <= sqrt(n); i++) {       if (n % i == 0) return false;     }     return true;   }   int modExp(int b, int e, int m) {     int x = 1;     while (e != 0) {       if (e % 2 == 1) x = (x * b) % m;       b = (b * b) % m;       e = e / 2;     }     return x;   }   unsigned long long fact(unsigned long long n) {     unsigned long long ret = 1;     for (long long i = 1; i <= n; i++) {       ret *= i;     }     return ret;   }   int ans = 0;   int main() {     long long n;     cin >> n;     vector<pair<long long, long long> > vp;     for (long long i = 0; i <= n - 1; i++) {       int a, b;       cin >> a >> b;       vp.push_back(make_pair(a, b));     }     sort(vp.begin(), vp.end());     ans = vp[0].second;     for (long long i = 1; i <= n - 1; i++) {       if (vp[i].second >= ans)         ans = vp[i].second;       else         ans = vp[i].first;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, n, i, j, k, x, y, z, ans, l, r, mid, s, q;   long long a[100005], b[100005], c[100005], d[100005], p[100005], dp[100005][20];   vector<long long> v[100005], u[100005];   map<pair<int, int>, int> m;   void dfs(int x, int y, int z) {     dp[x][0] = y;     d[x] = z;     p[x] = y;     u[z].push_back(x);     for (int i = 0; i < v[x].size(); i++)       if (v[x][i] != y) dfs(v[x][i], x, z + 1);   }   int lca(int x, int y) {     if (d[x] < d[y]) swap(x, y);     for (int i = 18; i >= 0; i--)       if (d[x] - (1 << i) >= d[y]) x = dp[x][i];     if (x == y) return x;     for (int i = 18; i >= 0; i--)       if (dp[x][i] != dp[y][i]) {         x = dp[x][i];         y = dp[y][i];       }     return dp[x][0];   }   void build() {     dfs(1, 0, 0);     for (i = 1; i <= 18; i++)       for (j = 1; j <= n; j++) dp[j][i] = dp[dp[j][i - 1]][i - 1];   }   int main() {     ios::sync_with_stdio(NULL);     cin.tie(0);     cout.tie(0);     cin >> n;     for (i = 1; i < n; i++) {       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);       b[i] = x;       c[i] = y;       m[{x, y}] = m[{y, x}] = i;     }     build();     cin >> q;     for (i = 0; i < q; i++) {       cin >> x >> y;       if (d[x] < d[y]) swap(x, y);       z = lca(x, y);       a[x]++;       a[y]++;       a[z] -= 2;     }     for (i = 100000; i > 0; i--)       for (j = 0; j < u[i].size(); j++) {         x = u[i][j];         m[{x, p[x]}] = m[{p[x], x}] = a[x];         a[p[x]] += a[x];       }     for (i = 1; i < n; i++) cout << m[{b[i], c[i]}] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int mi[n];     for (int i = (0); i < (n); i++) mi[i] = 1e9;     int t = 1;     int z[1000];     do {       t *= 2;       vector<int> v;       int x = 0;       while (x < n) {         int f = 0;         for (int i = (0); i < (t / 2); i++) {           if (x + i < n)             v.push_back(x + i);           else             break;         }         x += t;       }       cout << v.size() <<   n ;       ;       set<int> temp;       for (int i = (0); i < (v.size()); i++) {         temp.insert(v[i]);         cout << v[i] + 1 <<    ;       }       cout <<   n ;       fflush(stdout);       for (int i = (0); i < (n); i++) cin >> z[i];       for (int i = (0); i < (n); i++) {         if (temp.find(i) == temp.end()) mi[i] = min(mi[i], z[i]);       }       v.resize(0);       x = 0;       temp.clear();       while (x < n) {         int f = 0;         for (int i = (0); i < (t / 2); i++) {           if (x + i + t / 2 < n)             v.push_back(x + i + t / 2);           else             break;         }         x += t;       }       cout << v.size() <<   n ;       ;       for (int i = (0); i < (v.size()); i++) {         temp.insert(v[i]);         cout << v[i] + 1 <<    ;       }       cout <<   n ;       fflush(stdout);       for (int i = (0); i < (n); i++) cin >> z[i];       for (int i = (0); i < (n); i++) {         if (temp.find(i) == temp.end()) mi[i] = min(mi[i], z[i]);       }     } while (t < n);     cout <<  -1 n ;     fflush(stdout);     for (int i = (0); i < (n); i++) cout << mi[i] <<    ;     cout <<   n ;     fflush(stdout);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int sze = n * 2;       int arr[sze];       for (int i = 0; i < sze; i++) cin >> arr[i];       sort(arr, arr + sze);       cout << arr[n] - arr[n - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   int n, m;   int a[202], b[202];   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     for (int i = 0; i < m; ++i) {       scanf( %d , &b[i]);     }     for (int w = 0; w <= 1 << 9; ++w) {       int o = 0;       for (int i = 0; i < n; ++i) {         int mx = -1;         for (int j = 0; j < m; ++j) {           if ((w & (a[i] & b[j])) == (a[i] & b[j])) {             mx = std::max(a[i] & b[j], mx);           }         }         if (mx == -1) {           o = -1;           break;         }         o |= mx;       }       if (o == w) {         printf( %d n , w);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long is_query = -(1LL << 62);   struct line {     long long m, b;     mutable function<const line*()> succ;     bool operator<(const line& rhs) const {       if (rhs.b != is_query) return m < rhs.m;       const line* s = succ();       if (!s) return 0;       long long x = rhs.m;       return b - s->b < (s->m - m) * x;     }   };   struct dynamic_hull : public multiset<line> {     const long long inf = LLONG_MAX;     bool bad(iterator y) {       auto z = next(y);       if (y == begin()) {         if (z == end()) return 0;         return y->m == z->m && y->b <= z->b;       }       auto x = prev(y);       if (z == end()) return y->m == x->m && y->b <= x->b;       long long v1 = (x->b - y->b);       if (y->m == x->m)         v1 = x->b > y->b ? inf : -inf;       else         v1 /= (y->m - x->m);       long long v2 = (y->b - z->b);       if (z->m == y->m)         v2 = y->b > z->b ? inf : -inf;       else         v2 /= (z->m - y->m);       return v1 >= v2;     }     void insert_line(long long m, long long b) {       auto y = insert({m, b});       y->succ = [=] { return next(y) == end() ? 0 : &*next(y); };       if (bad(y)) {         erase(y);         return;       }       while (next(y) != end() && bad(next(y))) erase(next(y));       while (y != begin() && bad(prev(y))) erase(prev(y));     }     __int128 eval(long long x) {       auto l = *lower_bound(line{x, is_query});       return (__int128)l.m * x + l.b;     }   };   int main() {     int n;     long long s;     cin >> n >> s;     vector<pair<long long, long long>> buildings(n);     for (int i = 0; i < n; ++i) {       cin >> buildings[i].second >> buildings[i].first;     }     sort(buildings.begin(), buildings.end());     assert(buildings[0].first == 0);     vector<long long> min_time(n + 1, s + 1);     vector<long long> max_cookies(n + 1, 0);     min_time[0] = 0;     max_cookies[0] = 0;     dynamic_hull dp_opt;     dp_opt.insert_line(buildings[0].second, 0);     for (int i = 1; i < n; ++i) {       long long left = min_time[i - 1];       long long right = s + 50;       while (left + 1 < right) {         long long mid = (left + right) / 2;         if (dp_opt.eval(mid) >= buildings[i].first) {           right = mid;         } else {           left = mid;         }       }       if (dp_opt.eval(left) - buildings[i].first < 0) {         ++left;       }       min_time[i] = left;       max_cookies[i] = dp_opt.eval(left) - buildings[i].first;       dp_opt.insert_line(           buildings[i].second,           max_cookies[i] - 1LL * buildings[i].second * min_time[i]);     }     long long ans = s;     for (int i = 0; i < n; ++i) {       ans = min(ans,                 min_time[i] + (s - max_cookies[i] - 1) / buildings[i].second + 1);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void read(T& x) {     bool fu = 0;     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     if (c ==  - ) fu = 1, c = getchar();     for (x = 0; c > 32; c = getchar()) x = x * 10 + c -  0 ;     if (fu) x = -x;   };   template <class T>   inline void read(T& x, T& y) {     read(x);     read(y);   }   template <class T>   inline void read(T& x, T& y, T& z) {     read(x);     read(y);     read(z);   }   inline char getc() {     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     return c;   }   const int N = 10010;   const double pi = 2 * acos(0);   const double eps = 1e-9;   int w, h, n, m, i, j, st, g;   double L0, R0, R;   long long x[N], y[N];   double d[1010][1010], an[1010][1010];   int p[N];   double c[N];   double D(int i, int j) {     return sqrt((1LL * (x[i] - x[j]) * (x[i] - x[j])) +                 (1LL * (y[i] - y[j]) * (y[i] - y[j])));   }   double geta(int i, int j) { return atan2(y[j] - y[i], x[j] - x[i]); }   bool same(double a, double b) { return abs(a - b) <= eps; }   double ans;   void add(double L, double R) {     if (R > pi) {       add(L, pi);       add(-pi, R - 2 * pi);     } else if (L < -pi) {       add(L + 2 * pi, pi);       add(-pi, R);     } else       c[++g] = L - 1e-15, c[++g] = R + 1e-15;   }   bool cmp(int x, int y) { return c[x] < c[y]; }   bool ok(double R) {     int i, j, k;     double tt;     g = 0;     c[++g] = -pi;     c[++g] = pi;     if (x[st] < R) {       tt = acos(x[st] / R);       for (k = 1; k <= 2; k++) add(-pi - tt, -pi + tt);     }     if (w - x[st] < R) {       tt = acos((w - x[st]) / R);       for (k = 1; k <= 2; k++) add(-tt, tt);     }     if (y[st] < R) {       tt = acos(y[st] / R);       for (k = 1; k <= 2; k++) add(-pi / 2 - tt, -pi / 2 + tt);     }     if (h - y[st] < R) {       tt = acos((h - y[st]) / R);       for (k = 1; k <= 2; k++) add(pi / 2 - tt, pi / 2 + tt);     }     for (i = 1; i <= n; i++)       if (i != st && d[st][i] < 2 * R && d[st][i] > eps) {         tt = acos(d[st][i] / 2 / R);         add(an[st][i] - tt, an[st][i] + tt);       }     for (i = 1; i <= g; i++) p[i] = i;     sort(p + 1, p + 1 + g, cmp);     int s = 0;     for (i = 1; i <= g; i++)       if ((s += (p[i] & 1 ? 1 : -1)) < 3 && i + 1 <= g &&           c[p[i + 1]] - c[p[i]] > eps)         return 1;     return 0;   }   int main() {     read(w, h, n);     for (i = 1; i <= n; i++) cin >> x[i] >> y[i];     for (i = 1; i <= n; i++) {       int t = rand() % i + 1;       swap(x[i], x[t]);       swap(y[i], y[t]);     }     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++) d[i][j] = D(i, j), an[i][j] = geta(i, j);     for (st = 1; st <= n; st++)       if (ok(R)) {         L0 = R;         R0 = 2e6;         while (L0 + eps < R0) {           R = (L0 + R0) / 2;           if (ok(R))             L0 = R;           else             R0 = R;         }       }     cout << fixed << setprecision(10) << R << endl;     scanf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1e5 + 1;   const long long MOD = 1e9 + 7;   const long long INF = 1e9;   void solve(long long a, long long b) {     if (a == 0 and b == 0) {       cout <<  0  << endl;     } else if (a == b) {       cout <<  1  << endl;     } else if (abs(a - b) % 2 == 1) {       cout <<  -1  << endl;     } else {       cout <<  2  << endl;     }     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int tc = 1;     cin >> tc;     for (int t = 1; t <= tc; t++) {       long long a, b;       cin >> a >> b;       solve(a, b);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[1001], i, n, sum = 0, max = 0;     int b[1001] = {0};     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     for (i = 0; i < n; i++) {       b[a[i]]++;     }     for (i = 0; i < 1001; i++) {       if (b[i] > max) max = b[i];       if (b[i]) sum++;     }     cout << max <<    ;     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int tt;     cin >> tt;     while (tt--) {       int a, b, c, saveb = 0;       string st, md, en;       st = md = en =   ;       cin >> a >> b >> c;       bool ub = false;       while (b) {         if (!ub) {           md +=  01 ;           b--;           ub = true;         } else {           if (b == 1 && md[md.size() - 1] ==  1 ) {             saveb = 1;             b--;           } else {             md += md[md.size() - 1] ^ 1;             b--;           }         }       }       if (a) {         if (!md.size())           st +=  00 ;         else           st +=  0 ;         a--;       }       for (int i = 1; i <= a; i++) {         st +=  0 ;       }       if (c) {         if (!md.size())           en +=  11 ;         else           en +=  1 ;         c--;       }       for (int i = 1; i <= c; i++) {         en +=  1 ;       }       if (saveb > 0) cout << 1;       cout << st << md << en <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   void CountTriangles(vector<int> A) {     int n = A.size();     sort(A.begin(), A.end());     int count = 0;     for (int i = n - 1; i >= 1; i--) {       int l = 0, r = i - 1;       while (l < r) {         if (A[l] + A[r] > A[i]) {           count += r - l;           r--;         } else           l++;       }     }     cout <<  No of possible solutions:   << count;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int a, b;     cin >> a >> b;     if (a >= b) {       cout << (b - 1) / 2 << endl;     } else {       long long int c = (2 * a - b + 1) / 2;       cout << max(0LL, c);     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:64000000 )   using namespace std;   int n, b[110], l, r, c, t, q[110], m;   int main() {     cin >> m >> n;     for (int i = 1; i <= m; i++) b[i] = 1 << 30;     for (int i = 0; i < n; i++) {       cin >> l >> r >> t >> c;       for (int j = l; j <= r; j++) {         if (t < b[j]) b[j] = t, q[j] = c;       }     }     int s = 0;     for (int i = 1; i <= m; i++) {       s += q[i];     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   #define pb push_back   #define mp make_pair   #define sz(a) ((int)a.size())   #define re return   #define all(a) a.begin(),a.end()   #define int long long   #define ld long double   #define rept(i,a,b) for(int i=(a);i<(b);i++)   #define rep(i,a) rept(i,0,a)   using namespace std;   void fail(string s){ cout<<s;exit(0); }   void fail(int s){ cout<<s;exit(0); }   void chmax(ld &a,ld b,pair<int,int> &c,pair<int,int> d){ if (b>a) a=b,c=d; }   int n,d;   int a[100005];   ld dp[100005][10];   ld lg[100005];   pair<int,int>l[100005][10];   signed main(){    cin>>n>>d;    rept(i,1,n+1){     cin>>a[i];     lg[i]=log2(a[i]);    }    rep(i,n+1) rep(j,10) dp[i][j]=-1.0;    dp[0][1]=0.0;    rep(i,n){     rep(j,10){      if (dp[i][j]>=0.0){       chmax(dp[i+1][j],dp[i][j],l[i+1][j],mp(0,j));       chmax(dp[i+1][j*a[i+1]%10],dp[i][j]+lg[i+1],l[i+1][j*a[i+1]%10],mp(1,j));      }     }    }    int pos=-1;    ld ans=0.0;     rept(i,1,n+1){     if (dp[i][d]>=ans){      ans=dp[i][d];      pos=i;     }    }    vector<int>v;    int x=l[pos][d].first,y=l[pos][d].second;    for (int i=pos-1;i>=0;i--){     if (x)      v.pb(i+1);     x=l[i][y].first,y=l[i][y].second;    }    if (!sz(v))     fail(-1);    cout<<sz(v)<<  n ;    rep(i,sz(v))     cout<<a[v[i]]<<   ;    return 0;   }
#include <bits/stdc++.h>   using namespace std;   void read(int& x) {     bool fu = 0;     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     if (c ==  - ) fu = 1, c = getchar();     for (x = 0; c > 32; c = getchar()) x = x * 10 + c -  0 ;     if (fu) x = -x;   };   char getc() {     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     return c;   }   const int N = 100010;   int n, i, j, k, l, p, x, a[N], s0, s1;   int b[N];   int main() {     read(n);     for (i = 1; i <= n; i++) read(a[i]);     for (i = 1; i <= n && a[i] == 0; i++) printf( 0 n );     for (; i <= n; i = j + 1) {       for (j = i; j <= n && a[j] > 0; j++)         ;       j--;       if (j + 1 > n) {         for (k = i; k <= n; k++) printf( pushStack n );         break;       }       b[0] = 0;       for (k = i; k <= j; k++) b[++b[0]] = a[k];       sort(b + 1, b + 1 + b[0]);       if (b[0] == 0)         printf( 0 n );       else if (b[0] == 1)         printf( pushStack n1 popStack n );       else if (b[0] == 2)         printf( pushStack npushQueue n2 popStack popQueue n );       else {         p = b[b[0] - 2];         for (k = i; k <= j; k++)           if (a[k] >= p) break;         s0 = k;         for (k = j; k >= i; k--)           if (a[k] >= p) break;         s1 = k;         if (s1 <= s0) printf( - - n );         for (k = i; k <= j; k++)           if (k == s1)             printf( pushStack n );           else if (k == s0)             printf( pushQueue n );           else if (a[k] >= p)             printf( pushFront n );           else if (k < s1)             printf( pushStack n );           else             printf( pushQueue n );         printf( 3 popStack popQueue popFront n );       }       j++;     }     scanf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct com {     int l, r;     long long c;     friend bool operator<(const com &a, const com &b) { return a.r < b.r; }   } a[100010];   int n, m, K;   long long cost[310][310], dp[310][310];   const long long inf = 0x3F3F3F3F3F3F3F3FLL;   int main() {     scanf( %d%d%d , &n, &m, &K);     memset(cost, 0x3F, sizeof(cost));     for (int i = 0; i < m; i++)       scanf( %d%d%I64d , &a[i].l, &a[i].r, &a[i].c),           cost[a[i].l][a[i].r] = min(cost[a[i].l][a[i].r], a[i].c);     for (int l = n; l >= 1; l--) {       for (int i = 1; i + l - 1 <= n; i++) {         int st = i, ed = i + l - 1;         if (st > 1) cost[st][ed] = min(cost[st][ed], cost[st - 1][ed]);         if (ed < n) cost[st][ed] = min(cost[st][ed], cost[st][ed + 1]);       }     }     memset(dp, 0x3F, sizeof(dp));     dp[0][0] = 0;     for (int i = 1; i <= n; i++)       for (int j = 0; j <= i; j++) {         dp[i][j] = min(dp[i][j], dp[i - 1][j]);         for (int k = 0; k <= j; k++)           dp[i][j] = min(dp[i - k][j - k] + cost[i - k + 1][i], dp[i][j]);       }     if (dp[n][K] == inf)       cout << -1 << endl;     else       cout << dp[n][K] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[107], b[107];   int ans[10000007];   int n, nMax, nMaxid, times, nMin, aol, aMin, aMax, aL;   void init() {     memset(a, 0, sizeof(a));     memset(ans, 0, sizeof(ans));     memset(b, 0, sizeof(b));     aol = 0;     aL = 0;   }   int check(int x) {     nMax = 0;     times = 0;     for (int i = 1; i <= n; i++) {       if (a[i] > nMax) {         nMax = a[i];         nMaxid = i;         times = 0;       }       if (a[i] == nMax) times++;     }     if (times < x) return 1;     return 0;   }   void makeans(int x) {     times -= x;     for (int i = 1; i <= n; i++)       if (a[i] == nMax) {         x--;         a[i]--;         ans[++aol] = i;         if (x == 0) break;       }     ++aol;     aL++;   }   void printans(int x) {     if (ans[x] == 0) {       for (int i = 1; i <= n; i++) printf( %d , b[i]);       printf(  n );       memset(b, 0, sizeof(b));     } else       b[ans[x]] = 1;   }   int main() {     while (scanf( %d , &n) != EOF) {       init();       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       while (check(2)) {         int yMax = -1, yID = 0;         for (int i = 1; i <= n; i++)           if (a[i] > yMax) {             if (i == nMaxid) continue;             yMax = a[i];             yID = i;           }         ans[++aol] = yID;         ans[++aol] = nMaxid;         ++aol;         aL++;         if (a[yID]) a[yID]--;         a[nMaxid]--;       }       aMin = 107;       aMax = 0;       for (int i = 1; i <= n; i++)         if (a[i] < aMin) aMin = a[i];       while (check(n)) {         if (times % 2 == 1) makeans(3);         while (times) makeans(2);       }       printf( %d n%d n , aMin, aL);       for (int i = 1; i <= aol; i++) printans(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, s1;     int count1 = 0, count2 = 0;     cin >> s >> s1;     for (int i = 0; i < s.size(); i++) {       if (s[i] != s1[i]) {         if (s[i] ==  4 )           count1++;         else           count2++;       }     }     if (count1 <= count2)       cout << count2;     else       cout << count1;     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int i = 0; i < t; i++) {       int n;       cin >> n;       map<int, int> m;       long long int a[n];       for (int j = 0; j < n; j++) {         cin >> a[j];         m[a[j] % 3]++;       }       long long int res = m[0];       if (m[1] >= m[2]) {         res += m[2];         m[1] = m[1] - m[2];         res += m[1] / 3;       } else {         res += m[1];         m[2] = m[2] - m[1];         res += m[2] / 3;       }       cout << res <<   n ;     }   }