malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5;   const int inf = 1e7;   int tree[4 * N + 100], ans[2 * N + 100];   vector<int> R[N + 100], C[N + 100];   vector<pair<pair<int, int>, pair<int, int> > > qr[N + 100], qc[N + 100];   void update(int v, int tl, int tr, int idx, int val) {     if (tl == tr) {       tree[v] = val;     } else {       int tm = (tl + tr) / 2;       if (idx <= tm) {         update(v * 2, tl, tm, idx, val);       } else {         update(v * 2 + 1, tm + 1, tr, idx, val);       }       tree[v] = min(tree[v * 2], tree[v * 2 + 1]);     }   }   int getMin(int v, int tl, int tr, int l, int r) {     if (l > r) {       return inf;     }     if (l == tl && r == tr) {       return tree[v];     }     int tm = (tl + tr) / 2;     return min(getMin(v * 2, tl, tm, l, min(r, tm)),                getMin(v * 2 + 1, tm + 1, tr, max(tm + 1, l), r));   }   int main() {     int n, m, k, q;     scanf( %d%d%d%d , &n, &m, &k, &q);     for (int i = 1; i <= k; i++) {       int x, y;       scanf( %d%d , &x, &y);       R[y].push_back(x);       C[x].push_back(y);     }     for (int i = 1; i <= q; i++) {       int x1, y1, x2, y2;       scanf( %d%d%d%d , &x1, &y1, &x2, &y2);       qc[x2].push_back(make_pair(make_pair(y1, y2), make_pair(x1, i)));       qr[y2].push_back(make_pair(make_pair(x1, x2), make_pair(y1, i)));     }     memset(tree, 0, sizeof tree);     for (int i = 1; i <= n; i++) {       for (auto it : C[i]) {         update(1, 1, m, it, i);       }       for (auto it : qc[i]) {         int mn = getMin(1, 1, m, it.first.first, it.first.second);         if (mn >= it.second.first) {           ans[it.second.second] = 1;         }       }     }     memset(tree, 0, sizeof tree);     for (int i = 1; i <= m; i++) {       for (auto it : R[i]) {         update(1, 1, n, it, i);       }       for (auto it : qr[i]) {         int mn = getMin(1, 1, n, it.first.first, it.first.second);         if (mn >= it.second.first) {           ans[it.second.second] = 1;         }       }     }     for (int i = 1; i <= q; i++) {       if (ans[i]) {         printf( YES n );       } else {         printf( NO n );       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1 << 30;   const long long INF = 1ll << 60;   const double Inf = 1e20;   const double eps = 1e-9;   void gmax(int &a, int b) { a = (a > b ? a : b); }   void gmin(int &a, int b) { a = (a < b ? a : b); }   const int P = 1e9 + 7;   const int maxn = 1000050;   int n, m, x[5], y[5], sz[maxn], Ans;   set<int> key;   map<int, int> id, g;   vector<int> adj[maxn];   bool vis[maxn];   int calc(int x) {     int l = x, r = x, ret = 0;     while (l <= n) {       ret = (ret + min(r, n) - l + 1) % P;       l = l << 1;       r = r << 1 | 1;     }     return ret;   }   void dfs(int x, int t) {     Ans = (Ans + 1ll * sz[x] * t) % P;     vis[x] = true;     for (auto p : adj[x])       if (!vis[p]) dfs(p, t);     vis[x] = false;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) {       scanf( %d%d , &x[i], &y[i]);       int t = x[i];       while (t) {         key.insert(t);         t >>= 1;       }       t = y[i];       while (t) {         key.insert(t);         t >>= 1;       }     }     key.insert(1);     for (auto p : key) {       if (key.find(p << 1) == key.end() && key.find(p << 1 | 1) == key.end())         g[p] = calc(p);       else {         g[p] = 1;         if (key.find(p << 1) == key.end() && (p << 1) <= n)           g[p << 1] = calc(p << 1);         if (key.find(p << 1 | 1) == key.end() && (p << 1 | 1) <= n)           g[p << 1 | 1] = calc(p << 1 | 1);       }     }     for (pair<int, int> p : g) {       id[p.first] = ((int)(id).size());       sz[id[p.first]] = p.second;     }     for (pair<int, int> p : id)       if (p.first != 1) {         adj[id[p.first >> 1]].push_back(p.second);         adj[p.second].push_back(id[p.first >> 1]);       }     for (int i = 1; i <= m; ++i)       adj[id[x[i]]].push_back(id[y[i]]), adj[id[y[i]]].push_back(id[x[i]]);     for (pair<int, int> p : id) dfs(p.second, sz[p.second]);     printf( %d n , Ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 7;   const int MX = 1e9 + 7;   const long long int INF = 1e18 + 9LL;   int n, m, k;   long long int value[N];   pair<long long int, pair<int, int> > edge[N];   int pt[N];   int rep[N];   int res = 0;   int Find(int a) {     if (rep[a] == a) return a;     return rep[a] = Find(rep[a]);   }   bool Union(int a, int b) {     a = Find(a), b = Find(b);     if (a == b) return false;     rep[a] = b;     return true;   }   void solve(int from, int to) {     int cnt = n;     for (int i = from; i <= to; ++i)       if (Union(edge[i].second.first, edge[i].second.second)) --cnt;     res = (res + pt[cnt]) % MX;     for (int i = from; i <= to; ++i)       rep[edge[i].second.first] = edge[i].second.first,       rep[edge[i].second.second] = edge[i].second.second;   }   int main() {     scanf( %d %d %d , &n, &m, &k);     for (int i = 1; i <= n; ++i) {       scanf( %lld , &value[i]);       rep[i] = i;     }     pt[0] = 1;     for (int i = 1; i < N; ++i) pt[i] = (pt[i - 1] + pt[i - 1]) % MX;     for (int i = 1; i <= m; ++i) {       int u, v;       scanf( %d %d , &u, &v);       edge[i] = {value[u] ^ value[v], {u, v}};     }     long long int ok = pt[k];     sort(edge + 1, edge + m + 1);     for (int i = 1; i <= m; ++i) {       int t = i;       while (t < m && edge[t + 1].first == edge[t].first) ++t;       solve(i, t);       i = t;       --ok;     }     res = (res + 1LL * pt[n] * (ok % MX)) % MX;     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     string s;     while (n--) cin >> s;     bool wall = false;     int segments = 0, i = 0;     while (i < s.size()) {       if (!wall && s[i] ==  B ) {         segments++;         wall = true;       } else if (wall && s[i] ==  . ) {         wall = false;       }       i++;     }     cout << segments << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = (long long)1e18;   const int mod = (int)1e9 + 7;   const int MAXN = (int)3e5 + 5;   long long n;   string s;   bool vr[27];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cin >> s;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  a ) {         vr[0] = 1;         cout <<  Mike  <<   n ;       } else {         bool cnt = 1;         for (int j = 0; j < s[i] -  a ; j++) {           if (vr[j]) {             cnt = 0;             cout <<  Ann  <<   n ;             break;           }         }         if (cnt) {           vr[s[i] -  a ] = true;           cout <<  Mike  <<   n ;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int nax = 200005;   const int mod = 998244353;   vector<int> graph[nax];   vector<int> degree(nax);   vector<int> level(nax);   vector<int> vis(nax);   vector<int> parent(nax);   vector<int> str[nax];   void dfs(int node, int l) {     vis[node] = 1;     level[node] = l + 1;     str[l + 1].push_back(node);     int d = 0;     for (auto i : graph[node]) {       if (vis[i] == 0) {         dfs(i, l + 1);         parent[i] = node;         d++;       }     }     degree[node] = d;     return;   }   void solve() {     int n;     cin >> n;     for (int i = 1; i < n + 1; i++) degree[i] = 0;     for (int i = 1; i < n + 1; i++) level[i] = 0;     for (int i = 1; i < n + 1; i++) parent[i] = 0;     for (int i = 1; i < n + 1; i++) vis[i] = 0;     for (int i = 1; i <= n; ++i) {       graph[i].clear();       str[i].clear();     }     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       graph[a].push_back(b);       graph[b].push_back(a);     }     dfs(1, 0);     int ans = 0;     for (int i = 1; i < n + 1; i++)       if (degree[i] == 0) ans++;     vector<int> rem(n + 1);     for (int i = n; i >= 2; i--) {       for (auto item : str[i]) {         if (degree[item] == 0) continue;         int check = 1;         for (auto child : graph[item]) {           if (level[child] > level[item] && rem[child] == 0) {             check = check & (!degree[child]);           }         }         if (check) {           rem[item] = 1;           degree[parent[item]]--;           if (degree[parent[item]] > 0) ans--;         }       }     }     cout << ans << endl;     return;   }   int main() {     int T;     T = 1;     scanf( %d , &T);     while (T--) {       solve();     }   }
#include <bits/stdc++.h>   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n;       scanf( %d , &n);       int flag;       if (n & 1) {         flag = 2;         for (int i = 1, tmp; i <= n; i++) {           scanf( %1d , &tmp);           if ((i & 1) && (tmp & 1)) flag = 1;         }         printf( %d n , flag);       } else {         flag = 1;         for (int i = 1, tmp; i <= n; i++) {           scanf( %1d , &tmp);           if (!(i & 1) && !(tmp & 1)) flag = 2;         }         printf( %d n , flag);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const string T =  abacaba ;   bool check(string s) {     int cnt = 0;     for (int i = 0; i < s.length() - 6; i++)       if (s.substr(i, 7) == T) cnt++;     return (cnt == 1);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n, f = 0, q = 0, qq = 0, p = 0;       cin >> n;       string s;       cin >> s;       bool flag = true;       for (int i = 0; i < n - 6; i++) {         string ss = s;         bool f = true;         for (int j = 0; j < 7; j++) {           if (s[i + j] != T[j] && s[i + j] !=  ? ) {             f = false;             break;           }           ss[i + j] = T[j];         }         if (f && check(ss)) {           flag = false;           cout <<  Yes  << endl;           for (int i = 0; i < n; i++) cout << ((ss[i] ==  ? ) ?  z  : ss[i]);           cout << endl;           break;         }       }       if (flag) cout <<  No n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[26];   bool work() {     char ch;     while (isalpha(ch = getchar())) ++cnt[ch -  a ];     int c = 0;     for (int x = 0; x < 26; ++x)       if (cnt[x] & 1) ++c;     return c == 0 || (c & 1);   }   int main() { puts(work() ?  First  :  Second ); }
#include <bits/stdc++.h>   const int mod = 998244353;   using namespace std;   long long gcd(long long a, long long b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = res * x;       y = y >> 1;       x = x * x;     }     return res;   }   long long pwr(long long a, long long b) {     if (b == 0) {       return 1;     }     long long p = pwr(a, b / 2);     p = (p * p) % mod;     if (b % 2 != 0) {       p = (p * a) % mod;     }     return p;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, m;     cin >> n >> m;     string a, b;     cin >> a >> b;     reverse(a.begin(), a.end());     reverse(b.begin(), b.end());     while (m > n) {       a +=  0 ;       n++;     }     while (n > m) {       b +=  0 ;       m++;     }     reverse(a.begin(), a.end());     reverse(b.begin(), b.end());     long long ans = 0;     long long settillnow = 0;     for (long long i = 0; i < n; i++) {       if (b[i] ==  1 ) {         settillnow++;       }       if (a[i] ==  1 ) {         long long c = pwr(2, n - 1 - i);         c = (c * settillnow) % mod;         ans += c;         ans %= mod;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long t, n, m, xa, ya, xb, yb;     scanf( %lld , &t);     while (t--) {       scanf( %lld%lld%lld%lld%lld%lld , &n, &m, &xa, &ya, &xb, &yb);       long long miny = min(ya, yb), minx = min(xa, xb), maxy = max(ya, yb),                 maxx = max(xa, xb);       long long s = (m - (maxy - miny)) * (n - (maxx - minx)) * 2;       long long lx = n - (maxx - minx), ly = m - (maxy - miny);       long long len1 = max(0ll, lx - (maxx - minx + 1) + 1),                 len2 = max(0ll, ly - (maxy - miny + 1) + 1);       printf( %lld n , max(0ll, n * m - (s - len1 * len2)));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 5e3 + 7;   vector<vector<long long int> > v(N);   long long int cl[N];   void dfs(long long int s, long long int c) {     if (cl[s] == -1 || cl[s] == c) return;     cl[s] = c;     for (auto it = v[s].begin(); it != v[s].end(); it++) {       if (cl[*it] != c) dfs(*it, c);     }   }   int main() {     long long int n, m, s, i, j, k;     cin >> n >> m >> s;     memset(cl, 0, sizeof cl);     for (i = 0; i < m; i++) {       scanf( %lld%lld , &j, &k);       v[j].push_back(k);     }     dfs(s, -1);     for (i = 1; i <= n; i++) {       if (!cl[i]) dfs(i, i);     }     set<long long int> se;     for (i = 1; i <= n; i++) se.insert(cl[i]);     cout << se.size() - 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e18;   const int INF = 0x3f3f3f3f;   int a[200010];   int dp[1000010];   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       cin >> a[i];       dp[a[i]] = 1;     }     int t = 0, p = 0;     int res = 0;     for (int i = 1; i <= 1e6; i++) {       t += dp[i];       if (i > m) t -= dp[i - m];       if (t == k) {         dp[i] = 0;         res++;         t--;       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long n, W, B, X, dp[1001][10001], c[1001], cum[1001], cost[1001];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n >> W >> B >> X;     for (int i = 0; i < n; i++) {       cin >> c[i];       if (i == 0)         cum[i] = c[i];       else         cum[i] = cum[i - 1] + c[i];     }     for (int i = 0; i < n; i++) cin >> cost[i];     for (int i = 0; i < 1001; i++)       for (int j = 0; j < 10001; j++) dp[i][j] = 10000000000;     dp[0][0] = W;     for (int i = 0; i <= c[0]; i++) {       if (W >= i * cost[0]) dp[0][i] = W - i * cost[0];     }     for (int i = 1; i < n; i++) {       for (int j = 0; j <= cum[i]; j++) {         for (int k = 0; k <= min((long long)j, c[i]); k++) {           if (dp[i - 1][j - k] != 10000000000) {             if (min(dp[i - 1][j - k] + X, W + (j - k) * B) - k * cost[i] >= 0) {               dp[i][j] =                   max((dp[i][j] == 10000000000 ? 0 : dp[i][j]),                       min(dp[i - 1][j - k] + X, W + (j - k) * B) - k * cost[i]);             }           }         }       }     }     for (int i = cum[n - 1]; i >= 0; i--) {       if (dp[n - 1][i] != 10000000000) return cout << i, 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int temp;   vector<long long int> v;   long long int n;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t = 1;     cin >> t;     while (t--) {       long long int n, strt, cnst, lwr = 0, upr = 0, t, l, r, pt = 0, flag = 0;       cin >> n >> strt;       lwr = strt, upr = strt;       for (long long int i = 0; i < n; i++) {         cin >> t >> l >> r;         temp = t - pt;         lwr = lwr - temp;         upr = upr + temp;         if (lwr <= l && upr >= r)           lwr = l, upr = r;         else if (lwr <= l && upr <= r && upr >= l)           lwr = l;         else if (lwr >= l && upr >= r && lwr <= r)           upr = r;         else if (lwr > l && upr < r)           lwr = lwr, upr = upr;         else           flag = 1;         pt = t;       }       if (flag == 1)         cout <<  NO ;       else         cout <<  YES ;       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   #pragma optimize( O3 )   const int N = 200005;   int arr[N];   int fst[1000000], lst[1000000];   int minVal(int x, int y) { return (x < y) ? x : y; }   int getMid(int s, int e) { return s + (e - s) / 2; }   int RMQUtil(int *st, int ss, int se, int qs, int qe, int index) {     if (qs <= ss && qe >= se) return st[index];     if (se < qs || ss > qe) return INT_MAX;     int mid = getMid(ss, se);     return minVal(RMQUtil(st, ss, mid, qs, qe, 2 * index + 1),                   RMQUtil(st, mid + 1, se, qs, qe, 2 * index + 2));   }   int RMQ(int *st, int n, int qs, int qe) {     if (qs < 0 || qe > n - 1 || qs > qe) {       printf( Invalid Input );       return -1;     }     return RMQUtil(st, 0, n - 1, qs, qe, 0);   }   int constructSTUtil(int arr[], int ss, int se, int *st, int si) {     if (ss == se) {       st[si] = arr[ss];       return arr[ss];     }     int mid = getMid(ss, se);     st[si] = minVal(constructSTUtil(arr, ss, mid, st, si * 2 + 1),                     constructSTUtil(arr, mid + 1, se, st, si * 2 + 2));     return st[si];   }   int *constructST(int arr[], int n) {     int x = (int)(ceil(log2(n)));     int max_size = 2 * (int)pow(2, x) - 1;     int *st = new int[max_size];     constructSTUtil(arr, 0, n - 1, st, 0);     return st;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, q;     cin >> n >> q;     for (int i = 1; i <= q; i++) fst[i] = lst[i] = -1;     for (int i = 0; i < n; i++) {       cin >> arr[i];       fst[arr[i]] = (fst[arr[i]] == -1 ? i : fst[arr[i]]);       lst[arr[i]] = i;       if (arr[i] == 0) arr[i] = INT_MAX;     }     int *st = constructST(arr, n);     for (int i = 1; i <= q; i++) {       if (fst[i] == -1) continue;       int a = RMQ(st, n, fst[i], lst[i]);       if (a < i) {         cout <<  NO  << (  n );         return 0;       }     }     if (lst[q] == -1) {       bool b = false;       for (int i = 0; i < n; i++) {         if (arr[i] == INT_MAX) {           b = true, arr[i] = q;           break;         }       }       if (!b) {         cout <<  NO  << (  n );         return 0;       }     }     vector<int> pos;     for (int i = 0; i < n; i++)       if (arr[i] != INT_MAX) pos.push_back(i);     for (auto i : pos) {       int s = i - 1, e = i + 1;       bool poss = true;       while (poss) {         if (s >= 0 && arr[s] != INT_MAX) s = -1;         if (e < n && arr[e] != INT_MAX) e = n;         if (s >= 0) arr[s] = arr[i];         if (e < n) arr[e] = arr[i];         s--;         e++;         if (s < 0 && e >= n) poss = false;       }     }     cout <<  YES  << (  n );     for (int i = 0; i < n; i++) cout << arr[i] <<    ;     cout << (  n );   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool umin(T& a, T b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool umax(T& a, T b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   int arr[100009], val[100009], n, k;   int ok(int x) {     long long res = 0;     for (int i = 1; i <= n; i++) res += (arr[i] + x - 1) / x;     return (res <= k);   }   long long f(int x, int y) {     int a = x % y, aa = x / y + 1;     int b = y - a, bb = x / y;     return aa * 1LL * aa * a + bb * 1LL * bb * b;   }   set<pair<long long, int> > s;   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d , &arr[i]);       val[i] = 1;       if (arr[i] > 1)         s.insert(make_pair(f(arr[i], val[i] + 1) - f(arr[i], val[i]), i));     }     for (int j = 0; j < k - n; j++) {       pair<long long, int> nd = *s.begin();       s.erase(nd);       int i = nd.second;       val[i]++;       if (val[i] < arr[i])         s.insert(make_pair(f(arr[i], val[i] + 1) - f(arr[i], val[i]), i));     }     long long res = 0;     for (int i = 1; i <= n; i++) res += f(arr[i], val[i]);     printf( %lld n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool check[41][41];   int above[41][41];   int dp[41][41][41][41];   int main() {     int n, m, q, s1, s2, s3, s4;     char s[42];     scanf( %d %d %d , &n, &m, &q);     for (int i = 1; i <= n; i++) {       scanf( %s , s + 1);       for (int j = 1; j <= m; j++)         if (s[j] ==  0 ) check[i][j] = 1, above[i][j] = above[i - 1][j] + 1;     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         for (int k = i; k <= n; k++)           for (int l = j; l <= m; l++) {             dp[i][j][k][l] =                 dp[i][j][k - 1][l] + dp[i][j][k][l - 1] - dp[i][j][k - 1][l - 1];             int temp = min(k - i + 1, above[k][l]);             for (int p = l; p >= j; p--) {               temp = min(temp, above[k][p]);               if (temp == 0)                 break;               else                 dp[i][j][k][l] += temp;             }           }     for (int i = 0; i < q; i++)       scanf( %d %d %d %d , &s1, &s2, &s3, &s4),           printf( %d n , dp[s1][s2][s3][s4]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long n;       cin >> n;       set<int> used;       for (int i = 2; i * i <= n; i++) {         if (n % i == 0 && !used.count(i)) {           used.insert(i);           n /= i;           break;         }       }       for (int i = 2; i * i <= n; i++) {         if (n % i == 0 && !used.count(i)) {           used.insert(i);           n /= i;           break;         }       }       if (used.size() < 2 || used.count(n) || n == 1) {         cout <<  NO  << endl;       } else {         cout <<  YES               <<   n ;         used.insert(n);         for (auto it : used) cout << it <<    ;         cout << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q;     cin >> q;     for (int i = 0; i < q; ++i) {       int n;       cin >> n;       vector<int> a(n);       for (int j = 0; j < n; ++j) {         cin >> a[j];         --a[j];       }       int pos = 0;       while (pos < n) {         int nxt = min_element(a.begin() + pos, a.end()) - a.begin();         int el = a[nxt];         a.erase(a.begin() + nxt);         a.insert(a.begin() + pos, el);         if (pos == nxt)           pos = nxt + 1;         else           pos = nxt;       }       for (auto it : a) cout << it + 1 <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int ar[1000000], br[1000000];   int main() {     int t;     cin >> t;     while (t--) {       int a, b, c, d;       cin >> a >> b >> c;       int ans = 0;       if (a > 0) {         ans++;         a--;       }       if (b > 0) {         ans++;         b--;       }       if (c > 0) {         ans++;         c--;       }       ar[0] = a;       ar[1] = b;       ar[2] = c;       sort(ar, ar + 3);       if (ar[2] > 0 && ar[1] > 0) {         ans++;         ar[2]--;         ar[1]--;       }       if (ar[2] > 0 && ar[0] > 0) {         ans++;         ar[2]--;         ar[0]--;       }       if (ar[0] > 0 && ar[1] > 0) {         ans++;         ar[0]--;         ar[1]--;       }       if (ar[2] > 0 && ar[1] > 0 && ar[0] > 0) {         ans++;         ar[2]--;         ar[1]--;       }       cout << ans << endl;     }   }