malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &v) {     os <<  { ;     string sep;     for (const auto &x : v) os << sep << x, sep =  ,  ;     return os <<  } ;   }   template <typename T, size_t size>   ostream &operator<<(ostream &os, const array<T, size> &arr) {     os <<  { ;     string sep;     for (const auto &x : arr) os << sep << x, sep =  ,  ;     return os <<  } ;   }   template <typename A, typename B>   ostream &operator<<(ostream &os, const pair<A, B> &p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   void dbg_out() { cerr << endl; }   template <typename Head, typename... Tail>   void dbg_out(Head H, Tail... T) {     cerr <<     << H;     dbg_out(T...);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int N, M;     cin >> N >> M;     vector<int> which_tower(N);     vector<set<int>> towers(M);     int answer = N - 1;     for (int i = 0; i < N; i++) {       cin >> which_tower[i];       which_tower[i]--;       towers[which_tower[i]].insert(i);       if (i > 0 && which_tower[i] == which_tower[i - 1]) answer--;     }     auto &&merge_into = [&](int from, int to) {       if (towers[from].size() > towers[to].size()) swap(towers[from], towers[to]);       for (auto &x : towers[from]) {         answer -= int(towers[to].count(x - 1));         answer -= int(towers[to].count(x + 1));       }       for (auto &x : towers[from]) towers[to].insert(x);       towers[from].clear();     };     cout << answer <<   n ;     for (int q = 0; q < M - 1; q++) {       int a, b;       cin >> a >> b;       a--;       b--;       merge_into(b, a);       cout << answer <<   n ;     }   }
#include <bits/stdc++.h>   int main() {     int n, b;     scanf( %d%d , &n, &b);     int a[100], s = b;     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       s += a[i];     }     for (int i = 0; i < n; i++)       if (s < a[i] * n) {         puts( -1 );         return 0;       }     for (int i = 0; i < n; i++) printf( %.8lf n , 1. * s / n - a[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mo = 1e9 + 7;   const int N = 1000010;   const int inf = 0x3f3f3f3f;   using namespace std;   int n, m, q, tot, ans[N], fa[N], mark[N], pa[N], tmp;   struct node {     int a, b, c;     bool operator<(const node &x) const { return c < x.c; }   } e[N], ed[N];   struct info {     int a, b;     bool operator<(const info &x) const {       if (e[a].c != e[x.a].c) return e[a].c < e[x.a].c;       return b < x.b;     }   } t[N];   int find(int x) {     if (!fa[x]) return x;     return fa[x] = find(fa[x]);   }   int find2(int x) {     if (mark[x] != tmp) pa[x] = fa[x], mark[x] = tmp;     if (!pa[x]) return x;     return pa[x] = find2(pa[x]);   }   int main() {     int a, b, c, k, x, A, B;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d%d , &a, &b, &c);       e[i] = (node){a, b, c};       ed[i] = e[i];     }     scanf( %d , &q);     for (int j = 1; j <= q; j++) {       scanf( %d , &k);       for (int i = 1; i <= k; i++) scanf( %d , &x), t[++tot] = (info){x, j};     }     sort(t + 1, t + tot + 1);     sort(ed + 1, ed + m + 1);     for (int i = 1, pos = 1, po = 1; i <= tot; i = pos) {       while (ed[po].c < e[t[i].a].c && po <= m) {         A = find(ed[po].a);         B = find(ed[po].b);         if (A != B) fa[B] = A;         po++;       }       while (e[t[pos].a].c == e[t[i].a].c && pos <= tot) {         if (t[pos].b != t[pos - 1].b || pos == i) tmp++;         x = t[pos].a;         A = find2(e[x].a);         B = find2(e[x].b);         if (A == B)           ans[t[pos].b] = 1;         else           pa[B] = A;         pos++;       }     }     for (int i = 1; i <= q; i++) {       if (!ans[i])         printf( YES n );       else         printf( NO n );     }     return 0;   }
#include <iostream>   #include <algorithm>   using namespace std;         int main()   {       int64_t k;       int64_t n, x, t;       cin >> k;       while(k--) {           cin >> n >> x >> t;           int64_t zero = 0;           int64_t ans = max(zero, n - t/x) * (t / x) + min(t/x, n) * min(t/x - 1, n - 1) / 2;           cout << ans << endl;       }             return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1010;   int q1[MAXN], q2[MAXN], r1, r2;   int n, c, m;   int a[MAXN];   bool check() {     for (int i = 1; i <= n; i++)       if (!a[i] || (a[i] < a[i - 1])) return false;     return true;   }   int main() {     cin >> n >> m >> c;     while (!check()) {       int x;       cin >> x;       if (x > c / 2) {         bool flag = false;         for (int i = 1; i <= r2; i++)           if (x > q2[i]) {             q2[i] = x;             printf( %d n , n - i + 1);             flag = true;             a[n - i + 1] = x;             break;           }         if (!flag) {           q2[++r2] = x;           printf( %d n , n - r2 + 1);           a[n - r2 + 1] = x;         }       } else {         bool flag = false;         for (int i = 1; i <= r1; i++)           if (x < q1[i]) {             q1[i] = x;             printf( %d n , i);             flag = true;             a[i] = x;             break;           }         if (!flag) {           q1[++r1] = x;           printf( %d n , r1);           a[r1] = x;         }       }       fflush(stdout);     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:100000000 )   using namespace std;   const long double pi = acos(-1.0);   const long long inf = (long long)1e18;   const int N = (int)1e6;   int n, m;   long long need[N], start[N];   bool check(long long x) {     int lowest = 0;     for (int i = 0; (i < n) && (lowest < m); ++i) {       long long pos = start[i], can = x;       if (need[lowest] <= pos) {         if (pos - need[lowest] > can)           return false;         else           can = max(can - 2 * (pos - need[lowest]),                     (can - (pos - need[lowest])) / 2);       }       while ((lowest < m) && (need[lowest] - pos <= can)) ++lowest;     }     return (lowest == m);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) scanf( %I64d , &start[i]);     for (int i = 0; i < m; ++i) scanf( %I64d , &need[i]);     if (check(0)) {       printf( 0 n );       return 0;     }     long long l = 0, r = inf;     while (l < r - 1) {       long long m = (l + r) / 2;       if (check(m))         r = m;       else         l = m;     }     printf( %I64d n , r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3fll;   int main() {     int n, k;     scanf( %d , &n), scanf( %d , &k);     if (k % 2 == 0) {       int ans = 0;       while (n--) {         int x;         scanf( %d , &x);         if (x == 1) ans ^= 1;         if (x == 2) ans ^= 2;         if (x > 2) ans ^= !(x % 2);       }       if (ans)         printf( Kevin n );       else         printf( Nicky n );       return 0;     }     function<int(int)> f = [&f](int i) {       if (i == 0) return 0;       if (i == 1) return 1;       if (i == 2) return 0;       if (i == 3) return 1;       if (i == 4) return 2;       if (i == 5) return 0;       if (i % 2 == 1) return 0;       set<int> second;       second.insert(f(i - 1));       second.insert(f(i / 2));       int ret = 0;       while (second.count(ret)) ret++;       return ret;     };     int ans = 0;     while (n--) {       int x;       scanf( %d , &x);       ans ^= f(x);     }     if (ans)       printf( Kevin n );     else       printf( Nicky n );     exit(0);   }
#include <bits/stdc++.h>   using namespace std;   int n, k, i, a[100010];   set<int> r;   int main() {     scanf( %d%d , &n, &k);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n);     for (i = 0; i < n; i++) {       if (a[i] % k == 0 && r.count(a[i] / k)) continue;       r.insert(a[i]);     }     printf( %d n , int(r.size()));     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   int n, k;   int d[2][10000];   void solution() {     scanf( %d %d , &n, &k);     for (int i = 0, _n = (n - 1); i < _n; ++i) d[0][i] = 1;     int cur = 0, nxt = 1;     for (int it = 0, _n = (k); it < _n; ++it) {       for (int i = 0, _n = (n); i < _n; ++i) {         int need = n - i - 1 - d[cur][i];         int lo = 0, hi = n - 1;         while (hi - lo > 1) {           int m = (lo + hi) / 2;           if (d[cur][m] <= need)             hi = m;           else             lo = m;         }         if (lo < hi && d[cur][lo] <= need) hi = lo;         if (d[cur][hi] > need) throw 1;         d[nxt][i] = d[cur][i] + d[cur][hi];         printf( %d  , hi + 1);       }       swap(cur, nxt);       puts(  );     }     for (int i = 0, _n = (n); i < _n; ++i)       if (d[cur][i] != n - i - 1) throw 1;   }   int main() {     solution();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int sum = 0;     bool ok = false;     for (int i = 1; i <= n; i++) {       sum = i + sum;       if (n == 1 || n == sum) {         cout <<  YES  << endl;         break;       }       if (sum > n) {         ok = true;         break;       }     }     if (ok) cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   inline long long int input() {     long long int n;     cin >> n;     return n;   }   long long int pw(long long int a, long long int b) {     return (!b ? 1 : (b & 1 ? a * pw(a * a, b / 2) : pw(a * a, b / 2)));   }   const long long int MAXN = 2e5 + 10;   const long long int MAXA = 101;   const long long int INF = 8e18;   const long long int MOD = 1e9 + 7;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());     ;     long long int t;     cin >> t;     while (t--) {       long long int L, v, l, r;       cin >> L >> v >> l >> r;       long long int bib = L / v;       long long int bib1 = l / v - (l % v == 0), bib2 = r / v;       long long int x = bib2 - bib1;       cout << bib - x << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   int n;   int m;   int t[4 * N];   void upd(int l, int r, int v = 1, int tl = 1, int tr = N) {     if (l > r) return;     if (l <= tl && tr <= r) {       t[v]++;       return;     }     int tm = (tl + tr) / 2;     upd(l, min(tm, r), v * 2, tl, tm);     upd(max(tm + 1, l), r, v * 2 + 1, tm + 1, tr);   }   int get(int pos, int v = 1, int tl = 1, int tr = N) {     if (tl == tr) return t[v];     int tm = (tl + tr) / 2;     if (pos <= tm)       return t[v] + get(pos, v * 2, tl, tm);     else       return t[v] + get(pos, v * 2 + 1, tm + 1, tr);   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     long long res = 1;     vector<pair<int, int>> left;     vector<pair<int, int>> right;     for (int i = 1; i <= n; i++) {       int y, l, r;       cin >> y >> l >> r;       if (l == 0 && r == N) res++;       if (l == 0)         left.push_back({y, r});       else         right.push_back({y, l});     }     sort(left.begin(), left.end());     sort(right.begin(), right.end());     vector<pair<int, int>> top;     vector<pair<int, int>> bottom;     for (int i = 1; i <= m; i++) {       int x, l, r;       cin >> x >> l >> r;       if (l == 0 && r == N) res++;       if (l == 0)         bottom.push_back({r, x});       else         top.push_back({l, x});     }     sort(bottom.begin(), bottom.end());     int i1 = 0, i2 = 0;     for (int i = 0; i < (int)bottom.size(); i++) {       while (i1 < (int)left.size() && left[i1].first <= bottom[i].first) {         upd(0, left[i1].second);         i1++;       }       while (i2 < (int)right.size() && right[i2].first <= bottom[i].first) {         upd(right[i2].second, N);         i2++;       }       res += get(bottom[i].second);     }     memset(t, 0, sizeof t);     sort(top.rbegin(), top.rend());     reverse(left.begin(), left.end());     reverse(right.begin(), right.end());     i1 = 0, i2 = 0;     for (int i = 0; i < (int)top.size(); i++) {       while (i1 < (int)left.size() && left[i1].first >= top[i].first) {         upd(0, left[i1].second);         i1++;       }       while (i2 < (int)right.size() && right[i2].first >= top[i].first) {         upd(right[i2].second, N);         i2++;       }       res += get(top[i].second);     }     cout << res <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   char s[2000010], t[2000010];   int main(void) {     int n;     scanf( %d , &n);     scanf( %s , s);     scanf( %s , t);     int count_s, count_t, count_com;     count_s = count_t = count_com = 0;     for (int i = 0; i < 2 * n; ++i) {       if (s[i] ==  1  && t[i] ==  1 ) {         ++count_com;       }       if (s[i] ==  1  && t[i] !=  1 ) {         ++count_s;       }       if (s[i] !=  1  && t[i] ==  1 ) {         ++count_t;       }     }     if (count_com % 2 == 0) {       if (count_s > count_t) {         puts( First );       } else if (count_s >= count_t - 1) {         puts( Draw );       } else {         puts( Second );       }     } else {       if (count_s >= count_t) {         puts( First );       } else if (count_s >= count_t - 2) {         puts( Draw );       } else {         puts( Second );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int _t[6];   int main() {     for (int i = 0; i < 6; ++i) {       scanf( %d , &_t[i]);     }     long long a, b, x1, y1, x2, y2;     a = 2 * _t[0];     b = 2 * _t[1];     x1 = _t[2] - _t[3];     y1 = _t[2] + _t[3];     x2 = _t[4] - _t[5];     y2 = _t[4] + _t[5];     long long X1 = x1 / b + (x1 > 0);     long long X2 = x2 / b + (x2 > 0);     long long Y1 = y1 / a + (y1 > 0);     long long Y2 = y2 / a + (y2 > 0);     long long D = max(abs(X1 - X2), abs(Y1 - Y2));     cout << D << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long r[1003], c[1003], g[1003][1003];   int main() {     long long w, h;     scanf( %lld %lld , &h, &w);     for (int i = 0; i < h; i++) scanf( %lld , &r[i]);     for (int i = 0; i < w; i++) scanf( %lld , &c[i]);     memset(g, -1, sizeof g);     for (int i = 0; i < h; i++) {       for (int j = 0; j < r[i]; j++) {         g[i][j] = 0;       }       g[i][r[i]] = 1;     }     for (int j = 0; j < w; j++) {       for (int i = 0; i < c[j]; i++) {         if (g[i][j] == 1) {           printf( 0 );           return 0;         }         g[i][j] = 0;       }       if (g[c[j]][j] == 0) {         printf( 0 );         return 0;       }       g[c[j]][j] = 1;     }     long long ans = 1;     for (int i = 0; i < h; i++) {       for (int j = 0; j < w; j++) {         if (g[i][j] == -1) ans = (ans * 2) % 1000000007;       }     }     printf( %lld , ans);   }
#include <bits/stdc++.h>   using namespace std;      #define ll long long   #define fi first   #define se second      const int MAX = 2 * 1e5 + 10;   const int MOD = 1e9 + 7;   ll t;   ll n, m, k;   ll a, b, x, y, x2, y2;   ll bio[MAX];   ll arr[MAX];   vector <ll> v;   string s;      int main() {       cin >> t;          while (t--) {           cin >> n;           cin >> s;              b = 0;           for (int i = 0; i < n; i++) {               if (s[i] ==  b ) b++;           }              for (int i = 0; i < b; i++) {               cout <<  b ;           }           for (int i = 0; i < n; i++) {               if (s[i] ==  b ) continue;               cout << s[i];           }              cout <<   n ;       }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3fLL;   const long long mod = 1e9 + 7;   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long pct(long long x) { return __builtin_popcount(x); }   long long bit(long long x) { return 31 - __builtin_clz(x); }   long long cdiv(long long a, long long b) {     return a / b + !(a < 0 || a % b == 0);   }   void DBG() { cerr <<  ]  << endl; }   template <class H, class... T>   void DBG(H h, T... t) {     cerr << to_string(h);     if (sizeof...(t)) cerr <<  ,  ;     DBG(t...);   }   const long long maxn = 1e5 * 3 + 20;   long long n, _, q, k;   void solve() {     cin >> _;     while (_--) {       cin >> n;       long long sm = 0;       vector<long long> a(n);       vector<long long> b(n);       for (signed i = 0; i < n; i++) {         cin >> a[i];       }       for (signed i = 0; i < n; i++) {         cin >> b[i];         sm += b[i];       }       vector<long long> order(n);       iota(order.begin(), order.end(), 0);       sort(begin(order), end(order),            [&a](long long i, long long j) { return a[i] < a[j]; });       long long ans = sm;       for (long long x : order) {         long long tmp = max(sm - b[x], a[x]);         if (tmp < ans) {           sm -= b[x];           ans = tmp;         }       }       cout << ans << endl;     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   int n, c[1011], vao[1011], save[1011];   vector<int> ke[1011];   bool mark[1011];   int get(int start) {     for (int i = (1), _b = (n); i <= _b; i++) vao[i] = save[i];     int done = 0, res = 0;     memset(mark, false, sizeof mark);     while (done < n) {       int inc = 0;       for (int i = (1), _b = (n); i <= _b; i++)         if (!mark[i] && vao[i] == 0 && c[i] == start) {           mark[i] = true;           ++done;           ++inc;           for (int x = 0, _a = (ke[i].size()); x < _a; x++) {             int u = ke[i][x];             vao[u]--;           }         }       if (done == n) break;       if (!inc) {         if (start == 3)           start = 1;         else           ++start;         ++res;       }     }     return res;   }   int main() {     scanf( %d , &n);     for (int i = (1), _b = (n); i <= _b; i++) scanf( %d , &c[i]);     for (int i = (1), _b = (n); i <= _b; i++) {       scanf( %d , &save[i]);       for (int x = (1), _b = (save[i]); x <= _b; x++) {         int u;         scanf( %d , &u);         ke[u].push_back(i);       }     }     int res = n * 4;     for (int start = (1), _b = (3); start <= _b; start++) {       res = min(res, get(start));     }     cout << res + n << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int n, k, p, x, y;     cin >> n >> k >> p >> x >> y;     vector<int> a(n);     int sum = 0;     for (int i = 0; i < k; i++) {       cin >> a[i];       sum += a[i];     }     if (sum + n - k > x) {       cout << -1 <<   n ;       exit(0);     }     x -= sum;     for (int i = k; i < n; i++) {       if (y + n - 1 - i <= x) {         a[i] = y;         x -= y;       } else {         a[i] = 1;         x -= 1;       }     }     vector<int> b = a;     sort(b.begin(), b.end());     if (b[n >> 1] >= y) {       for (int i = k; i < n; i++) {         cout << a[i] <<    ;       }       cout <<   n ;     } else {       cout << -1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = (1000000007LL);   inline long long mult(long long a, long long b) { return (a * b) % mod; }   inline long long poww(long long a, long long b) {     long long res = 1;     while (b > 0) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return res;   }   long long gcd(long long a, long long b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   int n, m, q, k, v[300050], ans;   pair<int, int> w[300050];   string second;   int leaf[300050], root, dp[300050], qtd[300050][2];   int ini[300050], yes = 1;   vector<int> grafo[300050];   void dfs(int x, int p) {     int can = 0;     if (leaf[x] and dp[x] == 1) yes = 0;     for (auto v : grafo[x]) {       if (v == p) continue;       if (leaf[v]) can = 1;       dp[v] = (dp[x] ^ 1);       dfs(v, x);       for (int j = 0; j < 2; j++) {         if (qtd[x][j] > 0 and qtd[v][j ^ dp[v] ^ 1]) yes = 0;       }       qtd[x][0] += qtd[v][0];       qtd[x][1] += qtd[v][1];     }     if ((can or p == root) and !leaf[x]) ans++;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       grafo[a].push_back(b);       grafo[b].push_back(a);     }     ans = n - 1;     root = 1;     for (int i = 1; i <= n; i++) {       if ((int)(grafo[i]).size() == 1) leaf[i] = 1, root = i, ans--;     }     dfs(root, root);     cout << (yes ? 1 : 3) <<     << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int val;     int type;   } N[500000];   int main() {     long long n, a, b, c, d, start, len;     cin >> n >> a >> b >> c >> d >> start >> len;     for (int i = 1; i <= n; i++) {       cin >> N[i].val >> N[i].type;     }     long long s = 1, t = 1, sum_st = start, ans = 0;     long long low = 0;     N[0].val = -1;     for (int s = 1; s <= n; s++) {       while (t <= n && N[t].val - N[s].val <= len) {         if (N[t].type == 1)           ans += c;         else if (N[t].type == 0)           ans -= d;         low = min(low, ans);         t++;       }       if (sum_st + low >= 0) {         cout << N[s - 1].val + 1 << endl;         return 0;       }       if (N[s].type == 1) {         ans -= c;         low -= c;         sum_st += a;       } else {         ans += d;         low += d;         sum_st -= b;       }       if (sum_st < 0) {         cout << -1 << endl;         return 0;       }     }     cout << N[n].val + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char s[4][12];   char t[12][25][12];   int num[12];   int main() {     int i, j;     int ans = 0, p = 0;     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %s , s[i]);     scanf( %d , &m);     for (i = 0; i < m; i++) {       scanf( %d , &num[i]);       for (j = 0; j < num[i]; j++) scanf( %s , t[i][j]);     }     int mark[4];     int rec[25];     for (int k = 0; k < m; k++) {       memset(mark, 0, sizeof(mark));       memset(rec, -1, sizeof(rec));       for (i = 0; i < 4; i++) {         for (j = 0; j < num[k]; j++) {           if (strcmp(s[i], t[k][j]) == 0) {             mark[i] = 1;             rec[j] = i;           }         }       }       int sum = 0;       for (i = 0; i < n; i++) sum += mark[i];       if (sum < n) continue;       int id[4] = {0, 1, 2, 3};       do {         j = 0;         for (i = 0; i < num[k]; i++) {           if (rec[i] == id[j]) {             j++;             if (j == n) break;           }         }         int x = 0;         for (i = 0; i < n - 1; i++)           for (int tt = i + 1; tt < n; tt++)             if (id[i] > id[tt]) x++;         if (j == n && n * (n - 1) / 2 - x + 1 > p) {           ans = k + 1;           p = n * (n - 1) / 2 - x + 1;         }       } while (next_permutation(id, id + n));     }     if (ans == 0)       printf( Brand new problem! n );     else {       printf( %d n , ans);       printf( [: );       for (i = 0; i < p; i++) printf( | );       printf( :] n );     }     return 0;   }
#include <bits/stdc++.h>   int n, arr[1005][3], sum, cnt;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++)       scanf( %d %d %d , &arr[i][0], &arr[i][1], &arr[i][2]);     for (int i = 0; i < n; i++) {       for (int j = 0; j < 3; j++) sum += arr[i][j];       if (sum >= 2) cnt++;       sum = 0;     }     printf( %d , cnt);     return 0;   }