malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   long long ans;   int F[50000001], n, m, N;   char str[10001];   void dfs(int x, int bit, int key) {     if (x > 3) {       if (bit) F[bit] += key;       return;     }     dfs(x + 1, bit, key);     int v = str[x] -  a ;     dfs(x + 1, bit | (1 << v), -key);   }   int main() {     scanf( %d , &m);     for (int i = 1; i <= m; i++) {       scanf( %s , str + 1);       dfs(1, 0, -1);     }     n = 24;     N = 1 << n;     int res = 0;     for (int i = 0; i < N; i++) res += F[i];     for (int i = 1; i < N; i <<= 1)       for (int j = 0; j < N; j++)         if (i & j) {           F[j] += F[j - i];         }     for (int i = 0; i < N; i++) ans ^= (long long)F[i] * F[i];     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 10, MAXM = 100;   int A[MAXN][MAXM], B[MAXN][MAXM], C[MAXN][MAXM];   int order[MAXM];   int ib, is;   bool cmp(int a, int b) { return B[is][a] - A[ib][a] > B[is][b] - A[ib][b]; }   int main() {     int n, m, k, ans = 0, tmp;     int cur_hold, nx, p;     int i, j, id;     scanf( %d%d%d , &n, &m, &k);     for (i = 0; i < n; ++i) {       scanf( %*s );       for (j = 0; j < m; ++j) scanf( %d%d%d , A[i] + j, B[i] + j, C[i] + j);     }     for (ib = 0; ib < n; ++ib)       for (is = 0; is < n; ++is)         if (ib != is) {           for (j = 0; j < m; ++j) order[j] = j;           sort(order, order + m, cmp);           for (tmp = cur_hold = j = 0; j < m; ++j) {             id = order[j];             if ((p = B[is][id] - A[ib][id]) > 0) {               nx = min(C[ib][id], k - cur_hold);               tmp += p * nx;               cur_hold += nx;             } else               break;           }           if (ans < tmp) ans = tmp;         }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int b[100005], p[100005];   int n, m, a;   bool check(int x) {     int temp_a = a;     for (__typeof((x)) i = (0); i < (x); i += 1) {       int t = x - 1;       if (p[i] > b[t - i]) {         if (temp_a < p[i] - b[t - i]) {           return false;         } else {           temp_a -= p[i] - b[t - i];         }       }     }     return true;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> a;     for (__typeof((n)) i = (0); i < (n); i += 1) {       cin >> b[i];     }     for (__typeof((m)) i = (0); i < (m); i += 1) {       cin >> p[i];     }     sort(b, b + n, greater<int>());     sort(p, p + m);     int l = 0, h = ((n) < (m) ? (n) : (m)), ans = 0;     while (l < h) {       int mid = (l + h + 1) / 2;       if (check(mid) == true) {         l = mid;       } else {         h = mid - 1;       }       ans = l;     }     int ans2 = 0;     for (__typeof((ans)) i = (0); i < (ans); i += 1) {       ans2 += p[i];     }     ans2 -= a;     if (ans2 < 0) {       ans2 = 0;     }     cout << ans <<     << ans2;   }
#include <bits/stdc++.h>   using namespace std;   long long a00, a01, a10, a11;   char *s;   bool isSquare(long long x, long long &res) {     long long t = sqrt(x);     for (long long i = max(t - 10, 1LL); i <= t + 10; i++) {       if (i * i == x) {         res = i;         return true;       }     }     return false;   }   bool getS(long long n0, long long n1, long long n) {     s = new char[n + 1];     long long A01 = a01, A10 = a10;     for (long long i = 0; i < n; i++) {       if (A01 - n1 >= 0) {         s[i] =  0 ;         n0 -= 1;         A01 -= n1;       } else if (A10 - n0 >= 0) {         s[i] =  1 ;         n1 -= 1;         A10 -= n0;       } else         return false;     }     s[n] =   0 ;     if (n0 != 0 || n1 != 0 || A01 != 0 || A10 != 0) return false;     return true;   }   bool solve() {     long long t;     if (!isSquare(1 + 8 * a00, t)) return false;     vector<long long> n0;     n0.push_back((1 + t) / 2);     n0.push_back((1 - t) / 2);     if (!isSquare(1 + 8 * a11, t)) return false;     vector<long long> n1;     n1.push_back((1 + t) / 2);     n1.push_back((1 - t) / 2);     for (auto i : n0)       for (auto j : n1) {         long long n = i + j;         if (i < 0 || j < 0 || n <= 0) continue;         if (!getS(i, j, n)) continue;         return true;       }     return false;   }   int main() {     while (cin >> a00 >> a01 >> a10 >> a11) {       bool can = solve();       printf( %s n , can ? s :  Impossible );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using vi = vector<long long>;   using pii = pair<long long, long long>;   const signed INF_ = 1001001001;   const long long INF = 1001001001001001001LL;   const long long DX[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0},                   DY[9] = {-1, 0, 1, 0, -1, 1, 1, -1, 0};   template <class T>   ostream &operator<<(ostream &os, const vector<T> &v) {     for (auto i = (begin(v)); i != (end(v)); ++i)       os << *i << (i == end(v) - 1 ?    :    );     return os;   }   template <class T>   istream &operator>>(istream &is, vector<T> &v) {     for (auto i = (begin(v)); i != (end(v)); ++i) is >> *i;     return is;   }   template <class T, class U>   istream &operator>>(istream &is, pair<T, U> &p) {     is >> p.first >> p.second;     return is;   }   template <class T, class U>   bool chmax(T &a, const U &b) {     return a < b ? a = b, 1 : 0;   }   template <class T, class U>   bool chmin(T &a, const U &b) {     return a > b ? a = b, 1 : 0;   }   template <class T>   void PSUM(T &c) {     partial_sum(begin(c), end(c), begin(c));   }   template <class T>   using heap = priority_queue<T, vector<T>, greater<T>>;   struct before_main_function {     before_main_function() {       cin.tie(0);       ios::sync_with_stdio(0);       cout << setprecision(15) << fixed;     }   } before_main_function;   signed main() {     long long N, M;     cin >> N >> M;     vector<vector<long long>> g(N);     vector<long long> deg(N);     for (long long i = 0, ilen = (long long)(M); i < ilen; ++i) {       long long a, b;       cin >> a >> b;       a--, b--;       g[a].push_back(b);       g[b].push_back(a);       deg[a]++;       deg[b]++;     }     vector<pii> ans;     vector<bool> vis(N);     {       queue<long long> q;       long long st = max_element(begin(deg), end(deg)) - begin(deg);       q.push(st);       vis[st] = true;       while (q.size()) {         long long v = q.front();         q.pop();         for (auto &&w : g[v]) {           if (vis[w]) continue;           vis[w] = true;           ans.push_back({v + 1, w + 1});           q.push(w);         }       }     }     for (auto &&p : ans) {       cout << p.first <<     << p.second << endl;     }     return (0 ^ 0 ^ 0);   }
#include <bits/stdc++.h>   using namespace std;   int rep[2000005];   int sz[2000005];   void dsu(int n) {     for (int i = 0; i < n; i++) rep[i] = i, sz[i] = 1;   }   int findSet(int a) { return ((rep[a] == a) ? a : rep[a] = findSet(rep[a])); }   int mergeSet(int a, int b) {     int y = findSet(b);     int x = findSet(a);     if (x != y) {       rep[x] = y;       sz[y] += sz[x];       sz[x] = 0;     }   }   long long int grid[1005][1005];   int vis[1005][1005] = {0};   vector<pair<long long int, pair<int, int> > > v;   int n, m;   long long int k;   int dx[] = {-1, 0, 0, 1};   int dy[] = {0, -1, 1, 0};   int solx = -1;   int soly = -1;   long long int sol;   int cnt;   void floodfill(int x, int y) {     if (cnt < 1) return;     vis[x][y] = 1;     grid[x][y] = sol;     cnt--;     for (int i = 0; i < 4; i++) {       int newx = x + dx[i];       int newy = y + dy[i];       if (newx >= 0 && newx < n && newy >= 0 && newy < m && !vis[newx][newy] &&           grid[newx][newy] >= sol) {         floodfill(newx, newy);       }     }   }   void solve() {     cin >> n >> m;     cin >> k;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> grid[i][j];         v.push_back(make_pair(grid[i][j], make_pair(i, j)));       }     }     sort(v.begin(), v.end(), greater<pair<long long int, pair<int, int> > >());     dsu(n * m);     int i = 0, j = 0;     while (i < v.size()) {       j = i;       while (j < v.size()) {         if (v[i].first == v[j].first) {           int x = v[j].second.first;           int y = v[j].second.second;           for (int k = 0; k < 4; k++) {             int newx = x + dx[k];             int newy = y + dy[k];             if (newx >= 0 && newx < n && newy >= 0 && newy < m &&                 grid[newx][newy] >= v[j].first) {               mergeSet(newx * m + newy, x * m + y);             }           }         } else           break;         j++;       }       for (int l = i; l < j; l++) {         if (v[l].first && (k % v[l].first == 0) &&             sz[findSet(v[l].second.first * m + v[l].second.second)] >=                 k / v[l].first) {           solx = v[l].second.first;           soly = v[l].second.second;           sol = v[l].first;           cnt = k / v[l].first;           break;         }       }       i = j;     }     if (solx == -1 || soly == -1)       cout <<  NO n ;     else {       floodfill(solx, soly);       cout <<  YES n ;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m - 1; j++) {           if (vis[i][j])             cout << grid[i][j] <<    ;           else             cout <<  0  ;         }         if (vis[i][m - 1])           cout << grid[i][m - 1] <<   n ;         else           cout <<  0 n ;       }     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5;   int edges[MAXN] = {0};   int main() {     int n, s;     cin >> n >> s;     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       a--, b--;       edges[a]++, edges[b]++;     }     int amt = 0;     for (int i = 0; i < n; i++) {       if (edges[i] == 1) amt++;     }     double ans = ((double)s) / ((double)amt);     cout << fixed << setprecision(10) << ans * 2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int v[100];   bool cmp(int a, int b) { return a > b; }   int highest(int n) {     int i = 1, fact = 0;     while (2 * i <= n) {       i *= 2;       fact++;     }     return fact;   }   void permute(int left, int right, int pos, int last) {     if (!pos || (!last && pos == 1)) return;     int t = highest(pos);     pos -= (1 << t);     if (!last) {       left = right - t - 1;       swap(v[left + 1], v[right]);       sort(v + left + 2, v + right, cmp);       permute(left, right, pos, t);       return;     }     swap(v[left], v[right]);     --right;     if (last - t != 1) {       ++left;       sort(v + left, v + right + 1);       permute(left, right, pos + (1 << t), 0);       return;     }     permute(left, right, pos, t);   }   int main() {     int n, m, num = 1, piv = 0, pos, t;     cin >> n >> m;     for (int i = 0; i < n; ++i) v[i] = i + 1;     permute(0, n - 1, m, 0);     for (int i = 0; i < n; ++i) cout << v[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   class Solver {    public:     Solver() = default;     void read() {       int n;       std::cin >> n;       int left = 0;       int right = 0;       for (int i = 0; i < n; ++i) {         int x, y;         std::cin >> x >> y;         if (x < 0)           left++;         else           right++;       }       if (left <= 1 || right <= 1)         std::cout <<  Yes n ;       else         std::cout <<  No n ;     }     void solve() {}     void write() {}   };   int main() {     Solver solver;     solver.read();     solver.solve();     solver.write();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int flow, n, m, S, T, tot, x, y;   int g[3000], dis[3000], pre[3000];   int Next[50000], adj[50000], f[50000], c[50000];   bool used[3000];   queue<int> q;   int ans = 0;   int calc[110][30];   string t, s;   void add(int x, int y, int flow, int cost) {     adj[tot] = y;     c[tot] = cost;     f[tot] = flow;     Next[tot] = g[x];     g[x] = tot++;     adj[tot] = x;     c[tot] = -cost;     f[tot] = 0;     Next[tot] = g[y];     g[y] = tot++;   }   bool spfa() {     for (int i = 1; i <= T; i++) dis[i] = 1 << 23;     dis[S] = 0;     memset(used, 0, sizeof(used));     while (!q.empty()) q.pop();     q.push(S);     used[S] = true;     int p;     while (!q.empty()) {       x = q.front();       used[x] = false;       p = g[x];       while (p != -1) {         y = adj[p];         if (f[p] && dis[x] + c[p] < dis[y]) {           dis[y] = dis[x] + c[p];           pre[y] = p;           if (!used[y]) {             used[y] = true;             q.push(y);           }         }         p = Next[p];       }       q.pop();     }     return dis[T] != 1 << 23;   }   int path() {     int del = 1 << 23;     int p = T;     while (p != S) {       if (f[pre[p]] < del) del = f[pre[p]];       p = adj[pre[p] ^ 1];     }     p = T;     while (p != S) {       f[pre[p]] -= del;       f[pre[p] ^ 1] += del;       p = adj[pre[p] ^ 1];     }     flow += del;     return del * dis[T];   }   void solve() {     memset(pre, 0, sizeof(pre));     while (spfa()) ans += path();     if (flow != t.size())       cout << -1 << endl;     else       cout << ans << endl;   }   int main() {     cin >> t;     cin >> n;     memset(g, -1, sizeof(g));     tot = 0;     S = 26 * (n + 1) + n + 1;     T = S + 1;     for (int i = 1; i <= n; i++) {       cin >> s >> x;       for (int j = 0; j < s.size(); j++) calc[i][s[j] -  a ]++;       add(S, 26 * (n + 1) + i, x, 0);     }     for (int i = 0; i < t.size(); i++) calc[n + 1][t[i] -  a ]++;     for (int i = 0; i < 26; i++) add(26 * n + i + 1, T, calc[n + 1][i], 0);     for (int i = 1; i <= n; i++)       for (int j = 0; j < 26; j++) {         add(26 * (n + 1) + i, (i - 1) * 26 + j + 1, 1 << 23, 0);         add((i - 1) * 26 + j + 1, 26 * n + j + 1, calc[i][j], i);       }     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     clock_t clk_begin = clock();     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     string s;     cin >> s;     int c = 0;     for (int i = 0; i < n; ++i)       if (s[i] ==  8 ) c++;     n /= 11;     cout << min(n, c) <<   n ;     ;     cerr <<  Time taken:   << (double)(clock() - clk_begin) / CLOCKS_PER_SEC          <<   n ;     return 0;     ;   }
#include <bits/stdc++.h>   using namespace std;   int form[9], piece[9][2];   map<int, int> res;   string result[] = {        illegal ,  the first player won ,  the second player won ,  draw ,  first ,        second };   void pre() {     form[0] = 3;     piece[0][0] = 1;     piece[0][1] = 1 << 1;     for (int i = 1; i < 9; i++) {       form[i] = form[i - 1] << 2;       piece[i][0] = piece[i - 1][0] << 2;       piece[i][1] = piece[i - 1][1] << 2;     }   }   int add(int now, int p, int who, bool end) {     int px = p / 3 * 3, py = p % 3;     if ((piece[px][who] & now) && (piece[px + 1][who] & now) &&         (piece[px + 2][who] & now))       return who + 1;     if ((piece[py][who] & now) && (piece[py + 3][who] & now) &&         (piece[py + 6][who] & now))       return who + 1;     if ((p == 0 || p == 4 || p == 8) && (piece[0][who] & now) &&         (piece[4][who] & now) && (piece[8][who] & now))       return who + 1;     if ((p == 2 || p == 4 || p == 6) && (piece[2][who] & now) &&         (piece[4][who] & now) && (piece[6][who] & now))       return who + 1;     return end ? 3 : 5 - who;   }   void enumeration(int now, int who, int round) {     for (int p = 0; p < 9; p++) {       if (now & form[p]) continue;       now ^= piece[p][who];       if (!res[now]) {         res[now] = add(now, p, who, round == 9);         if (res[now] > 3) enumeration(now, who ^ 1, round + 1);       }       now ^= piece[p][who];     }   }   int main() {     int now = 0;     char ch;     pre();     enumeration(now, 0, 1);     for (int p = 0; p < 9; p++) {       cin >> ch;       if (ch ==  X )         now ^= piece[p][0];       else if (ch ==  0 )         now ^= piece[p][1];     }     cout << result[res[now]] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int parent(int x, vector<int> &v) {     return v[x] = (v[x] == x ? x : parent(v[x], v));   }   void u(int x, int y, vector<int> &v, vector<int> &r) {     x = parent(x, v);     y = parent(y, v);     if (r[x] == r[y]) {       if (x == y) {         return;       }       r[x]++;     }     if (r[x] > r[y]) {       v[y] = x;     } else {       v[x] = y;     }     return;   }   int main() {     int n;     scanf( %d n , &n);     vector<int> v(26, -1);     vector<int> r(26);     string s;     for (int i = 0; i < n; i++) {       cin >> s;       if (v[s[0] -  a ] == -1) {         v[s[0] -  a ] = s[0] -  a ;       }       for (int i = 1; i < (int)s.size(); i++) {         if (v[s[i] -  a ] == -1) {           v[s[i] -  a ] = s[i] -  a ;         }         u(s[i] -  a , s[0] -  a , v, r);       }     }     unordered_map<int, int> h;     for (int i = 0; i < 26; i++) {       if (v[i] != -1) {         h[parent(v[i], v)] = 1;       }     }     cout << h.size();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[105], b[105];   int main() {     int n, i, j, k, x, y;     while (~scanf( %d , &n)) {       for (i = 1; i <= n; i++) {         scanf( %d , &a[i]);       }       scanf( %d%d , &x, &y);       for (i = 1, j = 0; i <= n; i++) {         int count1 = 0, count2 = 0;         for (k = 1; k <= n; k++) {           if (k >= i)             count1 += a[k];           else             count2 += a[k];         }         if ((count1 >= x && count1 <= y) && (count2 >= x && count2 <= y)) {           b[j++] = i;           break;         }       }       if (j == 0) {         printf( 0 n );         continue;       }       printf( %d n , b[0]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<vector<int>> a(n, vector<int>(m, 0));     vector<vector<int>> b(n, vector<int>(m, 0));     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];       }     }     vector<pair<int, int>> ans;     for (int i = 0; i < n - 1; i++) {       for (int j = 0; j < m - 1; j++) {         if (a[i][j] == 1 && a[i][j + 1] == 1 && a[i + 1][j + 1] == 1 &&             a[i + 1][j] == 1) {           ans.push_back(make_pair(i, j));           b[i][j] = 1;           b[i][j + 1] = 1;           b[i + 1][j + 1] = 1;           b[i + 1][j] = 1;         }       }     }     bool flag = true;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i][j] != b[i][j]) {           flag = false;           i = n;           break;         }       }     }     if (flag) {       cout << ans.size() << endl;       for (auto it = ans.begin(); it != ans.end(); it++) {         cout << (*it).first + 1 <<     << (*it).second + 1 << endl;       }     } else       cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using pii = pair<int, int>;      void solve() {    int m, k;    cin >> m >> k;       vector<pii> a;       int ai;    for (int i = 1; i <= k; i++) {     cin >> ai;     a.push_back({ai, i});    }       sort(a.begin(), a.end(), greater<pii>());       int n = 1;    for (; ; n++) {     if (m > n * n - (n / 2) * (n / 2)) continue;     if (a[0].first > n * ((n + 1) / 2)) continue;     break;    }        vector<pii> pos[3];    for (int i = 0; i < n; i++) {     for (int j = 0; j < n; j++) {      int idx = ((i & 1) << 1) + (j & 1);      if (idx != 3)        pos[idx].push_back({i, j});     }    }       vector<vector<int>> ans(n, vector<int>(n, 0));       for (auto [cnt, val] : a) {     vector<pii> &curr = pos[1].empty() ? pos[2] : pos[1];        for (; !curr.empty() && cnt > 0; cnt--) {      auto [x, y] = curr.back();      curr.pop_back();      ans[x][y] = val;     }     for (; cnt > 0; cnt--) {      auto [x, y] = pos[0].back();      pos[0].pop_back();      ans[x][y] = val;     }    }       cout << n <<   n ;    for (int i = 0; i < n; i++) {     for (int j = 0; j < n; j++) {      cout << ans[i][j] <<    ;     }     cout <<   n ;    }   }      int main() {    ios_base::sync_with_stdio(0);    cin.tie(0);       int t;    cin >> t;       while (t--) {     solve();    }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 211, M = N * N / 2;   int u[M], v[M], w[M];   int f[N][N];   bool check(int n, int m, int lim) {     for (int i = 1; i <= m; i++) {       vector<pair<int, int>> v;       bool t = 1;       for (int j = 1; j <= n; j++) {         int l = f[j][u[i]], r = f[j][::v[i]];         if (lim >= l && lim >= r) {           if (2 * lim - l - r >= w[i]) {             v.push_back({0, 1});             v.push_back({w[i] + 1, -1});           } else {             v.push_back({0, 1});             v.push_back({min(w[i], lim - l) + 1, -1});             v.push_back({w[i] - min(w[i], lim - r), 1});             v.push_back({w[i] + 1, -1});           }         } else if (lim >= l) {           v.push_back({0, 1});           v.push_back({min(w[i], lim - l) + 1, -1});         } else if (lim >= r) {           v.push_back({w[i] - min(w[i], lim - r), 1});           v.push_back({w[i] + 1, -1});         } else {           t = 0;           break;         }       }       if (!t) continue;       sort(v.begin(), v.end());       int cnt = 0;       for (auto e : v) {         cnt += e.second;         if (cnt == n) return 1;       }     }     return 0;   }   int main() {     ios ::sync_with_stdio(0);     int n, m;     cin >> n >> m;     memset(f, 0x3f, sizeof f);     for (int i = 1; i <= n; i++) f[i][i] = 0;     for (int i = 1; i <= m; i++) {       cin >> u[i] >> v[i] >> w[i];       w[i] *= 2;       f[u[i]][v[i]] = f[v[i]][u[i]] = w[i];     }     for (int k = 1; k <= n; k++)       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++) f[i][j] = min(f[i][j], f[i][k] + f[k][j]);     int l = 0, r = 1e8L;     while (l + 1 < r) {       int im = (l + r) / 2;       if (check(n, m, im - 1))         r = im;       else         l = im;     }     cout << fixed << setprecision(1);     cout << l / 2.0 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int ans1, ans2;   int t[4], v[4][10], T[10][10], A, B, C;   map<string, int> mymap;   const char *help[] = { Anka ,    Chapay ,  Cleo ,        Troll ,                          Dracul ,  Snowy ,   Hexadecimal };   int countT() {     int ret = 0;     for (int k = 0; k < 3; k++) {       for (int i = 0; i < t[k]; i++)         for (int j = 0; j < t[k]; j++)           if (T[v[k][i]][v[k][j]]) ret++;     }     return ret;   }   void go(int x) {     if (x == 8) {       if (!t[0] || !t[1] || !t[2]) return;       int h[4];       h[0] = A / t[0];       h[1] = B / t[1];       h[2] = C / t[2];       sort(h, h + 3);       int d = h[2] - h[0];       int p = countT();       if (d < ans1) {         ans1 = d;         ans2 = p;       } else if (d == ans1) {         ans2 = max(ans2, p);       }       return;     }     for (int i = 0; i < 3; i++) {       v[i][t[i]++] = x;       go(x + 1);       t[i]--;     }     return;   }   int main() {     char s1[30], s2[30], s3[30];     for (int i = 0; i < 7; i++) mymap[help[i]] = i + 1;     memset(T, 0, sizeof(T));     int m;     cin >> m;     while (m--) {       cin >> s1 >> s2 >> s3;       int u, v;       u = mymap[s1];       v = mymap[s3];       T[u][v] = 1;     }     cin >> A >> B >> C;     ans1 = 2000000001;     ans2 = 0;     memset(t, 0, sizeof(t));     go(1);     cout << ans1 <<     << ans2 << endl;     return 0;   }
#include <bits/stdc++.h>   typedef long long ll ;   using namespace std;   const int maxn=2e5+5;   const int maxm=5e6+5;   #define P pair<int,int>   #define fi first   #define se second   int t,n;   int a[maxn];   int vis[maxm*2];   P mp[maxm];         int main() {       ios::sync_with_stdio(false);       cin.tie(nullptr), cout.tie(nullptr);       cin>>n;       for(int i=1;i<=n;i++){           cin>>a[i];       }       int sum1;       for(int i=1;i<=n;i++){           for(int j=i+1;j<=n;j++){               sum1=a[i]+a[j];               if(mp[sum1].fi==0 &&mp[sum1].se==0){                   mp[sum1]={i,j};               }else if(i!=mp[sum1].fi&&i!=mp[sum1].se&&j!=mp[sum1].fi&&j!=mp[sum1].se){                   cout<< YES <<endl;                   cout<<i<<   <<j<<   <<mp[sum1].fi<<   <<mp[sum1].se<<endl;                   return 0;               }           }       }       cout<< NO <<endl;       return 0;   }