malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n;   vector<pair<int, int>> moves_knight(int x, int y) {     vector<pair<int, int>> v;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (abs(x - i) + abs(y - j) == 3 && abs(x - i) * abs(y - j) == 2)           v.push_back({i, j});       }     }     return v;   }   vector<pair<int, int>> moves_bishop(int x, int y) {     vector<pair<int, int>> v;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (abs(x - i) == abs(y - j)) v.push_back({i, j});       }     }     return v;   }   vector<pair<int, int>> moves_rook(int x, int y) {     vector<pair<int, int>> v;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (x == i || y == j) v.push_back({i, j});       }     }     return v;   }   vector<pair<int, int>> moves(int x, int y, int c) {     if (c == 0) return moves_rook(x, y);     if (c == 1) return moves_bishop(x, y);     if (c == 2) return moves_knight(x, y);     return {};   }   int x[100], y[100];   int state(int x, int y, int c) { return c * n * n + x * n + y; }   struct resenje {     long long len, prom;     resenje(long long len = 123123123, long long prom = 123123123)         : len(len), prom(prom) {}     bool operator<(const resenje& o) const {       if (len != o.len) return len < o.len;       return prom < o.prom;     }     resenje operator+(const resenje& o) const {       return {len + o.len, prom + o.prom};     }   };   resenje d[300][300];   resenje g[3][100];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cerr.tie(nullptr);     cin >> n;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         int z;         cin >> z;         z--;         x[z] = i;         y[z] = j;       }     }     for (int c = 0; c < 3; c++) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           int u = state(i, j, c);           auto p = moves(i, j, c);           for (auto e : p) {             int v = state(e.first, e.second, c);             d[u][v] = min(d[u][v], resenje(1, 0));           }           d[u][u] = min(d[u][u], resenje(0, 0));           for (int z = 0; z < 3; z++)             if (z != c) {               int v = state(i, j, z);               d[u][v] = min(d[u][v], resenje(1, 1));             }         }       }     }     int m = 3 * n * n;     for (int j = 0; j < m; j++)       for (int i = 0; i < m; i++)         for (int k = 0; k < m; k++) d[i][k] = min(d[i][k], d[i][j] + d[j][k]);     g[0][0] = g[1][0] = g[2][0] = {0, 0};     for (int i = 1; i < n * n; i++) {       for (int c1 = 0; c1 < 3; c1++) {         for (int c2 = 0; c2 < 3; c2++) {           int u = state(x[i - 1], y[i - 1], c1);           int v = state(x[i], y[i], c2);           g[c2][i] = min(g[c2][i], g[c1][i - 1] + d[u][v]);         }       }     }     auto sol = min({g[0][n * n - 1], g[1][n * n - 1], g[2][n * n - 1]});     cout << sol.len <<     << sol.prom <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   char s[100010];   int l[100010], r[100010];   struct node {     int val, id;   };   struct cmp {     bool operator()(node a, node b) { return a.val < b.val; }   };   priority_queue<node, vector<node>, cmp> q;   int main() {     scanf( %s , s);     int len = strlen(s);     for (int i = (0); i <= (len - 1); ++i)       if (s[i] ==  ? ) scanf( %d %d , &l[i], &r[i]);     int num;     num = 0;     long long ans = 0;     node tmp;     for (int i = (0); i <= (len - 1); ++i) {       if (s[i] ==  ( )         num++;       else if (s[i] ==  ) )         num--;       else {         s[i] =  ) ;         ans += r[i];         tmp.val = r[i] - l[i];         tmp.id = i;         q.push(tmp);         num--;       }       if (num < 0) {         if (q.empty()) {           printf( -1 n );           return 0;         }         tmp = q.top();         q.pop();         num += 2;         s[tmp.id] =  ( ;         ans -= tmp.val;       }     }     if (num != 0) {       printf( -1 n );       return 0;     }     printf( %lld n , ans);     puts(s);   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 2e8;   struct st {     int l, r;   };   bool cmp(st a, st b) { return a.l < b.l; }   int main() {     bool a1 = false, b1 = false;     int i;     st v, q, w;     vector<st> v1, v2;     string s, a =  AB , b =  BA ;     cin >> s;     for (i = 0; i < s.size() - 1; i++) {       if (s.substr(i, 2) == a) {         v.l = i;         v.r = i + 1;         v1.push_back(v);       }       if (s.substr(i, 2) == b) {         v.l = i;         v.r = i + 1;         v2.push_back(v);       }     }     sort(v1.begin(), v1.end(), cmp);     sort(v2.begin(), v2.end(), cmp);     if (v1.size() == 0 || v2.size() == 0) {       cout <<  NO ;       return 0;     }     q = v1[0];     w = v2[v2.size() - 1];     if (q.l != w.l && q.l != w.r && q.r != w.l && q.r != w.r) {       cout <<  YES ;       return 0;     }     q = v2[0];     w = v1[v1.size() - 1];     if (q.l != w.l && q.l != w.r && q.r != w.l && q.r != w.r) {       cout <<  YES ;       return 0;     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int en[100004];   long long int dp[100004][3];   string x[100004];   int n;   long long int sol(int i, int ck) {     if (i > n) return 0;     if (dp[i][ck] != -1) return dp[i][ck];     string org = x[i];     long long int ans = 0;     long long int ans1 = 0;     if (!ck) {       string p = x[i - 1];       if (org >= p) {         ans = sol(i + 1, 0);       } else {         ans = 10000000000000000;       }       reverse(org.begin(), org.end());       if (org >= p) {         ans1 = min(ans, sol(i + 1, 1)) + en[i];       } else {         ans1 = 10000000000000000;       }       return dp[i][ck] = min(ans1, ans);     } else {       string p = x[i - 1];       reverse(p.begin(), p.end());       if (org >= p) {         ans = sol(i + 1, 0);       } else {         ans = 10000000000000000;       }       reverse(org.begin(), org.end());       if (org >= p) {         ans1 = min(ans, sol(i + 1, 1) + en[i]);       } else {         ans1 = 10000000000000000;       }       return dp[i][ck] = min(ans, ans1);     }   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) scanf( %d , &en[i]);     for (int i = 1; i <= n; i++) cin >> x[i];     memset(dp, -1, sizeof dp);     long long int ans = sol(2, 0);     ans = min(ans, en[1] + sol(2, 1));     if (ans == 10000000000000000) ans = -1;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long N, L, W;   vector<long long> neg, pos;   long long INF32 = 0x7fffffff;   inline long long div_floor(long long a, long long b) {     if (b == 0) return (a > 0 ? +INF32 : -INF32);     if (a % b < 0) a -= (b + a % b);     return a / b;   }   int main() {     cin >> N >> L >> W;     for (int i = 0; i < N; ++i) {       long long x, d;       cin >> x >> d;       (d == 1 ? pos : neg).push_back(d == 1 ? x : x + L);     }     sort(pos.begin(), pos.end());     sort(neg.begin(), neg.end());     long long ans = 0;     for (auto x : pos) {       long long lval = max(-x - 1, x);       if (W == 1) {         if (x < 0) {         } else {           lval = INF32;         }       } else {         lval = max(lval, div_floor(((W + 1) * x), (W - 1)));       }       auto l = upper_bound(neg.begin(), neg.end(), lval);       ans += int(neg.end() - l);       lval = max(x, div_floor((W - 1) * x, (W + 1)));       long long rval = -x;       l = upper_bound(neg.begin(), neg.end(), lval);       auto r = lower_bound(neg.begin(), neg.end(), rval);       ans += max(0, int(r - l));     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   const int MOD = 1e9 + 7;   int aa[N];   int tree[4 * N];   int query(int v, int l, int r, int L, int R) {     if (l > r || l > R || r < L) return 0;     if (L <= l && r <= R) return tree[v];     int v1 = 2 * v + 1;     int v2 = 2 * v + 2;     int mid = (l + r) / 2;     int q1 = query(v1, l, mid, L, R);     int q2 = query(v2, mid + 1, r, L, R);     return (q1 + q2) % MOD;   }   void update(int v, int l, int r, int pos, int newVal) {     if (l > r || l > pos || r < pos) return;     if (l == r && l == pos) {       tree[v] = newVal;       return;     }     int v1 = 2 * v + 1;     int v2 = 2 * v + 2;     int mid = (l + r) / 2;     update(v1, l, mid, pos, newVal);     update(v2, mid + 1, r, pos, newVal);     tree[v] = (tree[v1] + tree[v2]) % MOD;   }   int bpow(long long bb, int ee) {     if (ee < 0) return 0;     int res = 1;     while (ee > 0) {       if (ee % 2 == 1) res = res * bb % MOD;       bb = bb * bb % MOD;       ee >= 1;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> aa[i];     const int ml = 1e6;     update(0, 0, ml, 0, 1);     long long ans = 0;     for (int i = 1; i <= n; i++) {       int s = query(0, 0, ml, 0, aa[i]);       int hm = (s * 1LL * aa[i]) % MOD;       update(0, 0, ml, aa[i], hm);     }     set<int> dict;     for (int i = 1; i <= n; i++) dict.insert(aa[i]);     for (int i : dict) ans += query(0, 0, ml, i, i);     cout << ans % MOD <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<long long> > room_to_switches;   vector<vector<pair<long long, long long> > > neighbors;   vector<long long> target;   void dfs(long long s, long long color, vector<long long>& colors) {     if (colors[s] != -1) {       if (color != colors[s]) {         cout <<  NO  << endl;         exit(0);       }       return;     }     colors[s] = color;     for (pair<long long, long long> P : neighbors[s]) {       long long v = P.first;       long long state = P.second;       dfs(v, color ^ state, colors);     }   }   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     long long nRooms, nSwitches;     cin >> nRooms >> nSwitches;     for (int i = 0; i < nRooms; i++) {       long long x;       cin >> x;       target.push_back(1 - x);     }     room_to_switches.resize(nRooms);     neighbors.resize(nSwitches);     for (int i = 0; i < nSwitches; i++) {       long long k;       cin >> k;       for (int j = 0; j < k; j++) {         long long room;         cin >> room;         room--;         room_to_switches[room].push_back(i);         if (room_to_switches[room].size() == 2) {           long long u = room_to_switches[room][0];           long long v = room_to_switches[room][1];           neighbors[u].push_back({v, target[room]});           neighbors[v].push_back({u, target[room]});         }       }     }     vector<long long> colors(nSwitches, -1);     for (long long s = 0; s < nSwitches; s++) {       if (colors[s] == -1) dfs(s, 0, colors);     }     cout <<  YES  << endl;   }
//W4P3R   /*   ----------------------------------------------------------------------------------------------------------   ----------------------------------------------------------------------------------------------------------   ----------------------------------------------------------------------------------------------------------   --------------------------#############------------------#############------------------------------------   ------------------------###############----------------###############------------------------------------   -----------------------####---------------------------####------------------------------------------------   ----------------------####---------------------------####-------------------------------------------------   ----------------------####---------------------------####-------------------------------------------------   ----------------------####---------####--------------####---------####------------------------------------   ----------------------####---------####--------------####---------####------------------------------------   ----------------------####-----------##--------------####-----------##------------------------------------   -----------------------####----------##---------------####----------##------------------------------------   ------------------------###############----------------###############------------------------------------   --------------------------#############------------------#############------------------------------------   ----------------------------------------------------------------------------------------------------------   ----------------------------------------------------------------------------------------------------------   -----------------------------------------------------------------------------------------------------------   GG   */   #include<bits/stdc++.h>   #define inf 1e9   #define eps 1e-6   #define mp make_pair   #define pb push_back   #define fr first   #define sd second   #define pa pair<ll,ll>   #define FOR(i,a,b) for(ll i=a;i<=b;i++)   #define REP(i,a,b) for(ll i=a;i>=b;i--)   #define MEM(a) memset(a,0,sizeof(a))   #define N 100010   using namespace std;   typedef long long ll;   typedef unsigned long long ull;   typedef double db;   inline ll read()   {    char ch=getchar();    ll s=0,w=1;    while(ch< 0 ||ch> 9 ){if(ch== - )w=-1;ch=getchar();}    while(ch>= 0 &&ch<= 9 ){s=s*10+ch- 0 ;ch=getchar();}    return s*w;   }   inline ll lowbit(ll x){return x&(-x);}   ll n;   struct node{ll a,c,id;}t[N];   inline ll cmp(node a,node b){return a.a<b.a;}   int main()   {    //ios::sync_with_stdio(false);    //freopen( .in , r ,stdin);    //freopen( .out , w ,stdout);    n=read();ll ans=0;    FOR(i,1,n)t[i].a=read(),t[i].c=read(),t[i].id=i,ans+=t[i].c;    sort(t+1,t+n+1,cmp);    ll id=0;    ll nowv=t[1].c+t[1].a;    FOR(i,1,n)    {     ans+=max(0LL,t[i].a-nowv);     nowv=max(nowv,t[i].a+t[i].c);    }    cout<<ans<<  n ;    return 0;   }   //gl
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   char s[N];   int main() {     scanf( %s , s);     int n = strlen(s);     int x = 0, y = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  L )         x--;       else if (s[i] ==  R )         x++;       else if (s[i] ==  U )         y++;       else         y--;     }     if ((abs(x) + abs(y)) % 2 == 0)       cout << (abs(x) + abs(y)) / 2 << endl;     else       cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000000 + 5;   vector<int> g[N], revg[N], cur;   bool used[N], isans[N];   set<int> all;   int n, m;   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d %d , &u, &v);       u--, v--;       g[u].push_back(v);       revg[v].push_back(u);     }     for (int i = 0; i < n; i++) {       all.insert(i);     }     while (!all.empty()) {       int k = *(all.begin());       for (auto x : g[k]) {         if (!used[x]) {           used[x] = true;           all.erase(x);         }       }       used[k] = true;       all.erase(k);       cur.push_back(k);     }     for (int i = cur.size() - 1; i >= 0; i--) {       int node = cur[i];       isans[node] = true;       for (auto x : revg[node]) {         if (isans[x]) {           isans[node] = false;         }       }     }     vector<int> ans;     for (int i = 0; i < n; i++) {       if (isans[i]) ans.push_back(i + 1);     }     printf( %d n , ans.size());     for (int i = 0; i < ans.size(); i++) {       printf( %d  , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int max_n = 5e5 + 10, max_f = 800;   struct Rad {     int l, r;     vector<pair<long long, int> > ar;     long long s;     Rad() {       l = r = -1;       s = 0;     }   };   int n, q;   long long num[max_n];   Rad sq[max_n];   bool compare(const pair<long long, int> &a, const int &b) {     return a.first < b;   }   bool compare2(const int &b, const pair<long long, int> &a) {     return b < a.first;   }   void input() {     scanf( %d%d , &n, &q);     for (int i = 0; i < n; i++) scanf( %d , &num[i]);     for (int i = 0; 1; i++) {       sq[i].l = i * max_f;       sq[i].r = min((i + 1) * max_f, n);       for (int j = sq[i].l; j < sq[i].r; j++)         sq[i].ar.push_back(make_pair(num[j], j));       sort(sq[i].ar.begin(), sq[i].ar.end());       if (sq[i].r == n) break;     }   }   void modify(int l, int r, int x) {     for (int i = 0; sq[i].l != -1; i++) {       if (l <= sq[i].l && sq[i].r <= r) sq[i].s += x;       if (sq[i].l < l && l < sq[i].r) {         for (int j = l; j < min(sq[i].r, r); j++) num[j] += x;         for (int j = sq[i].l; j < sq[i].r; j++)           sq[i].ar[j - sq[i].l] = make_pair(num[j], j);         sort(sq[i].ar.begin(), sq[i].ar.end());       } else if (sq[i].l < r && r < sq[i].r) {         for (int j = sq[i].l; j < r; j++) num[j] += x;         for (int j = sq[i].l; j < sq[i].r; j++)           sq[i].ar[j - sq[i].l] = make_pair(num[j], j);         sort(sq[i].ar.begin(), sq[i].ar.end());       }     }   }   void output() {     int type, l, r, x, y;     int first, last, tmp, tmp2;     for (int i = 0; i < q; i++) {       scanf( %d , &type);       if (type == 1) {         scanf( %d%d%d , &l, &r, &x);         modify(l - 1, r, x);       } else {         scanf( %d , &y);         first = -1;         for (int j = 0; sq[j].l != -1; j++) {           tmp = lower_bound(sq[j].ar.begin(), sq[j].ar.end(), y - sq[j].s,                             compare) -                 sq[j].ar.begin();           tmp2 = upper_bound(sq[j].ar.begin(), sq[j].ar.end(), y - sq[j].s,                              compare2) -                  sq[j].ar.begin() - 1;           if (first == -1 && tmp != (int)sq[j].ar.size() &&               sq[j].ar[tmp].first == y - sq[j].s)             first = sq[j].ar[tmp].second;           if (tmp2 != -1 && sq[j].ar[tmp2].first == y - sq[j].s)             last = sq[j].ar[tmp2].second;         }         if (first == -1)           printf( -1 n );         else           printf( %d n , last - first);       }     }   }   int main() {     input();     output();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool sortbysec(const pair<long long, long long> &a,                  const pair<long long, long long> &b) {     return (a.second < b.second);   }   int main() {     long long n;     vector<long long> a;     vector<pair<long long, long long> > b;     cin >> n;     for (int i = int(0); i < int(n); i++) {       long long aux;       cin >> aux;       a.push_back(aux);     }     for (int i = int(0); i < int(n); i++) {       long long aux;       cin >> aux;       b.push_back(make_pair(aux, i));     }     sort(b.begin(), b.end());     reverse(b.begin(), b.end());     sort(a.begin(), a.end());     for (int i = int(0); i < int(n); i++) {       b[i].first = a[i];     }     sort(b.begin(), b.end(), sortbysec);     for (int i = int(0); i < int(n); i++) {       cout << b[i].first <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const int inf = 0x3f3f3f3f;   int n, k, a[510][510];   int main() {     while (~scanf( %d%d , &n, &k)) {       int top = 1, ans = 0;       for (int i = 1; i <= n; i++) {         for (int j = 1; j < k; j++) {           a[i][j] = top++;         }       }       for (int i = 1; i <= n; i++) {         for (int j = k; j <= n; j++) {           if (j == k) ans += top;           a[i][j] = top++;         }       }       printf( %d n , ans);       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           printf( %d , a[i][j]);           if (j == n)             putchar(  n );           else             putchar(   );         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     cin >> n >> m;     vector<long long> a(n);     vector<long long> b(n);     for (long long i = 0; i < n; i++) cin >> a[i];     for (long long i = 0; i < n; i++) cin >> b[i];     sort(b.begin(), b.end());     long long ans = m - 1;     for (long long i = 0; i < n; i++) {       long long z;       if (b[i] > a[0])         z = (b[i] - a[0]) % m;       else         z = (m + b[i] - a[0]) % m;       vector<long long> temp;       temp = a;       for (long long i = 0; i < n; i++) temp[i] = (temp[i] + z) % m;       sort(temp.begin(), temp.end());       if (temp == b) ans = min(ans, z);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 998244353;   const int M = 20;   pair<int, int> dp[M][(1 << 10)];   int a[M], K, ten[M];   int Count(int st) {     int rnt = 0;     while (st) st &= st - 1, rnt++;     return rnt;   }   pair<int, int> f(int pos, int st, int lead, int limit) {     if (pos == -1)       return Count(st) <= K ? pair<int, int>(0, 1) : pair<int, int>(0, 0);     if (!limit && dp[pos][st].first != -1) return dp[pos][st];     int up = limit ? a[pos] : 9;     pair<int, int> rnt = pair<int, int>(0, 0);     for (int k = 0; k <= up; k++) {       pair<int, int> p = f(pos - 1, k == 0 && lead ? 0 : st | (1 << k),                            k == 0 && lead, limit && k == up);       rnt.first =           (rnt.first + p.first + (long long)k * ten[pos] % MOD * p.second % MOD) %           MOD;       rnt.second = (rnt.second + p.second) % MOD;     }     if (!limit) dp[pos][st] = rnt;     return rnt;   }   pair<int, int> Solve(long long n) {     for (int i = 0; i < M; i++, n /= 10) a[i] = n % 10;     return f(M - 1, 0, 1, 1);   }   int main() {     for (int i = 0; i < M; i++) {       ten[i] = i == 0 ? 1 : ten[i - 1] * 10ll % MOD;       for (int j = 0; j < (1 << 10); j++) dp[i][j].first = -1;     }     long long l, r;     scanf( %I64d%I64d%d , &l, &r, &K);     pair<int, int> R = Solve(r), L = Solve(l - 1);     printf( %d n , (R.first - L.first + MOD) % MOD);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int c = 200002;   int sum, n, ans[c], pos;   vector<int> sz[c];   bool v[c];   bool dfs(int a) {     v[a] = true;     int el = a;     for (int i = 0; i < sz[a].size(); i++) {       int x = sz[a][i];       if (!v[x] && !dfs(x)) ans[el] = x, el = x;     }     if (el != a) {       ans[el] = a, sum -= 2;       return 1;     }     return 0;   }   int main() {     cin >> n, sum = 2 * n;     for (int i = 1; i < n; i++) {       int x, y;       cin >> x >> y;       sz[x].push_back(y), sz[y].push_back(x);     }     for (int i = 1; i <= n; i++)       if (sz[i].size() == 1) pos = sz[i][0];     dfs(pos);     cout << sum <<   n ;     for (int i = 1; i <= n; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, c = 0, f = 0;     cin >> n >> k;     int y[n];     for (int i = 0; i < n; i++) cin >> y[i];     if (k == 5) {       for (int i = 0; i < n; i++) {         if (y[i] == 0) c++;       }       if (c >= 3) {         if (c == 6)           f = 2;         else           f = (int)(c / 3);       }     } else if (k == 4) {       for (int i = 0; i < n; i++) {         if (y[i] == 0 || y[i] == 1) c++;       }       if (c == 6)         f = 2;       else         f = (int)(c / 3);     } else if (k == 3) {       for (int i = 0; i < n; i++) {         if (y[i] == 0 || y[i] == 1 || y[i] == 2) c++;       }       if (c == 6)         f = 2;       else         f = (int)(c / 3);     } else if (k == 2) {       for (int i = 0; i < n; i++) {         if (y[i] == 0 || y[i] == 1 || y[i] == 2 || y[i] == 3) c++;       }       if (c == 6)         f = 2;       else         f = (int)(c / 3);     } else if (k == 1) {       for (int i = 0; i < n; i++) {         if (y[i] == 4 || y[i] == 0 || y[i] == 1 || y[i] == 2 || y[i] == 3) c++;       }       if (c == 6)         f = 2;       else         f = (int)(c / 3);     }     cout << f;     return 0;   }