malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, m, i, j, l, r, poss_rn, poss_rm, poss_n, poss_m, k, ans1, ans2;   priority_queue<tuple<long long, int, int>> pq;   map<pair<int, int>, bool> um;   long long f(int x, int y) {     long long a, b;     if (x == poss_rn)       a = poss_n;     else       a = 2;     if (y == poss_rm)       b = poss_m;     else       b = 2;     return a * b;   }   int main() {     cin >> n >> m >> r >> k;     if (n > m) swap(n, m);     poss_rn = min(r, n - r + 1);     poss_rm = min(r, m - r + 1);     ans2 = (n - r + 1) * (m - r + 1);     poss_n = n - 2 * (poss_rn - 1);     poss_m = m - 2 * (poss_rm - 1);     r++;     pq.push(make_tuple(poss_rn * poss_rm, poss_rn, poss_rm));     um[{poss_rn, poss_rm}] = true;     while (k) {       tie(m, i, j) = pq.top();       pq.pop();       l = f(i, j);       if (l != 0) {         if (k <= l) {           ans1 += k * m;           k = 0;         } else {           ans1 += l * m;           k -= l;         }       }       if (i != 1 && um[{i - 1, j}] == false) {         um[{i - 1, j}] = true;         pq.push(make_tuple((i - 1) * j, i - 1, j));       }       if (j != 1 && um[{i, j - 1}] == false) {         --j;         pq.push(make_tuple(i * j, i, j));         um[{i, j}] = true;       }     }     printf( %.9f , (double)ans1 / (double)ans2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a = 1, b = 1;     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       a = a * 27 % 1000000007;       b = b * 7 % 1000000007;     }     cout << (a + 1000000007 - b) % 1000000007;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MXN = 2000010;   int N, M;   int A[MXN], B[MXN], T[32] = {};   void init() {     scanf( %d%d , &N, &M);     for (int i = 1; i <= N; i++) scanf( %d , A + i);     for (int i = 1; i <= M; i++) scanf( %d , B + i), T[B[i]]++;   }   namespace solve {   long long answer = 0;   int sat[MXN], m = 0, p = 1;   void solve() {     for (int b = 30; b >= 0; b--) {       for (int i = 1; i <= N; i++) {         int x = min(T[b], A[i] >> b);         A[i] -= x << b;         T[b] -= x;         for (int i = 0; i < x; i++) sat[++m] = b;       }       while (T[b] && p <= m && sat[p] > b) {         A[++N] = 1 << sat[p++];         int x = min(T[b], A[N] >> b);         A[N] -= x << b;         T[b] -= x;         for (int i = 0; i < x; i++) sat[++m] = b;       }     }     cout << m - p + 1 << endl;   }   }  // namespace solve   int main() {     init();     solve::solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[1000001];   int nodeNumber[1000001], nodeStart[1000001], nodeEnd[1000001],       leftStart[1000001], leftEnd[1000001], rightStart[1000001],       rightEnd[1000001];   void Initialise(int n) {     sort(a + 1, a + n + 1);     for (int i = 0; i <= n; ++i) {       nodeStart[i] = 0;       nodeEnd[i] = -1;       nodeNumber[i] = 1;     }     nodeStart[1] = 1;     nodeEnd[1] = n;   }   void FixStartEnd(int &i, int &j) {     if (i > j) {       i = 0, j = -1;     }   }   void FillChildNumbers(int n, int k) {     for (int i = 0; i <= n; ++i) {       int j = nodeStart[i];       for (; j <= nodeEnd[i] && (a[j] & (1ll << k)) == 0; ++j)         ;       leftStart[i] = nodeStart[i], leftEnd[i] = j - 1;       rightStart[i] = j, rightEnd[i] = nodeEnd[i];       FixStartEnd(leftStart[i], leftEnd[i]);       FixStartEnd(rightStart[i], rightEnd[i]);       j = (nodeStart[i] > 0) ? nodeEnd[i] : i;       nodeStart[i] = 0;       nodeEnd[i] = -1;       i = j;     }   }   long long ZeroBitCount(int n, int k) {     long long ans = 0;     for (int i = 1; i <= n; ++i) {       int targetBit = ((a[i] & (1ll << k)) > 0), j = nodeNumber[i];       ans += ((targetBit == 1) ? (rightEnd[j] - rightStart[j] + 1)                                : (leftEnd[j] - leftStart[j] + 1));     }     return ans;   }   void TakeZeroBit(int n, int k) {     for (int i = 1; i <= n; ++i) {       int targetBit = ((a[i] & (1ll << k)) > 0), j = nodeNumber[i], x, start, end;       if (targetBit) {         x = rightStart[j], start = rightStart[j], end = rightEnd[j];       } else {         x = leftStart[j], start = leftStart[j], end = leftEnd[j];       }       nodeNumber[i] = x, nodeStart[x] = start, nodeEnd[x] = end;     }   }   void TakeOneBit(int n, int k) {     for (int i = 1; i <= n; ++i) {       int targetBit = 1 - ((a[i] & (1ll << k)) > 0), j = nodeNumber[i], x, start,           end;       if (targetBit) {         x = rightStart[j], start = rightStart[j], end = rightEnd[j];       } else {         x = leftStart[j], start = leftStart[j], end = leftEnd[j];       }       nodeNumber[i] = x, nodeStart[x] = start, nodeEnd[x] = end;     }   }   int main() {     int n;     long long m;     scanf( %d%lld , &n, &m);     for (int j = 2; j <= n; ++j) {       int i;       long long w;       scanf( %d%lld , &i, &w);       a[j] = (w ^ a[i]);     }     Initialise(n);     long long ans = 0;     for (int k = 61; k > -1; --k) {       FillChildNumbers(n, k);       long long cnt = ZeroBitCount(n, k);       if (cnt >= m) {         TakeZeroBit(n, k);       } else {         ans += (1ll << k);         m -= cnt;         TakeOneBit(n, k);       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, s, p, i, c;     scanf( %d , &n);     s = 1;     while (1) {       c = 0;       p = n * s + 1;       for (i = 2; i < p; i++) {         if (p % i == 0) {           c++;         }       }       if (c >= 1) {         break;       }       s++;     }     printf( %d n , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, x, c1 = 0, c2 = 0;     bool flag = false;     cin >> n;     while (n--) {       cin >> x;       if (x == 100)         ++c1;       else         ++c2;     }     if (c1 % 2 == 0) {       if ((c1 == 0 && c2 % 2 == 0) || (c1 > 0)) flag = true;     }     if (flag) {       cout <<  YES ;     } else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int F(int d);   int G(int d);   int n, ara[2 * 100010], dpf[2 * 100010], dpg[2 * 100010], k;   bool visf[2 * 100010], visg[2 * 100010];   vector<int> vec;   int add(int _a, int _b) {     _a = (_a + 998244353) % 998244353;     _b = (_b + 998244353) % 998244353;     return (_a + _b) % 998244353;   }   int mul(int _a, int _b) {     _a = (_a + 998244353) % 998244353;     _b = (_b + 998244353) % 998244353;     return ((long long int)((long long int)_a * (long long int)_b)) % 998244353;   }   void input() {     int i, j;     scanf( %d %d , &n, &k);     for (i = 0; i < n; i++) {       scanf( %d , &ara[i]);     }   }   int G(int d) {     int i, j;     if (d == 0) {       return 1;     }     if (visg[d]) {       return dpg[d];     }     visg[d] = true;     int s1 = 0, s2 = 0;     s1 = F(d - 1) % 998244353;     s2 = mul(max(k - 2, 0), G(d - 1) % 998244353);     return dpg[d] = add(s1, s2);   }   int F(int d) {     int i, j;     if (d == 0) {       return 0;     }     if (visf[d]) {       return dpf[d];     }     visf[d] = true;     return dpf[d] = mul(k - 1, G(d - 1) % 998244353);   }   int sol(int f) {     int i, j, cnt, ret = 1, s;     for (i = 0, vec.clear(); i < n; i++) {       if (i % 2 == f) {         vec.push_back(ara[i]);       }     }     for (i = 0; i < vec.size(); i = j) {       int respect = vec[i];       for (j = i + 1, cnt = 0; j < vec.size() && vec[j] == -1; j++) {         cnt++;       }       if (j == vec.size()) {         if (respect == -1) {           for (j = 0; j < vec.size(); j++) {             if (j == 0) {               ret = mul(ret, k);             } else {               ret = mul(ret, k - 1);             }           }         } else {           if (cnt == 0) {             ret = mul(ret, 1);           } else {             s = add(F(cnt - 1) % 998244353, mul(k - 1, G(cnt - 1) % 998244353));             ret = mul(ret, s);           }         }       } else {         if (respect == -1) {           s = add(F(cnt) % 998244353, mul(k - 1, G(cnt) % 998244353));           ret = mul(ret, s);         } else if (respect == vec[j]) {           ret = mul(ret, F(cnt) % 998244353);         } else {           ret = mul(ret, G(cnt) % 998244353);         }       }     }     return ret;   }   void solve() {     int i, j;     int ret = mul(sol(0), sol(1));     printf( %d , ret);     puts(  );   }   int main() {     input();     solve();   }
#include <bits/stdc++.h>   using namespace std;   using lli = long long int;   const int MOD = 1000000007;   const int MOD1 = 998244353;   const int maxn = 100010;   const int lim = (int)1e9;   struct flowEdge {     int v, u;     lli cap, flow = 0ll;     flowEdge(int v, int u, lli cap) : v(v), u(u), cap(cap) {}   };   struct Dinic {     const lli flow_inf = 1e18;     vector<flowEdge> edges;     vector<vector<int> > adj;     int n, m = 0;     int s, t;     vector<int> level, ptr;     queue<int> q;     Dinic(int n, int s, int t) : n(n), s(s), t(t) {       adj.resize(n);       level.resize(n);       ptr.resize(n);     }     void addEdge(int v, int u, lli cap) {       edges.emplace_back(v, u, cap);       edges.emplace_back(u, v, 0);       adj[v].push_back(m);       adj[u].push_back(m + 1);       m += 2;     }     bool bfs() {       while (!q.empty()) {         int v = q.front();         q.pop();         for (auto id : adj[v]) {           if (edges[id].cap - edges[id].flow < 1) continue;           if (level[edges[id].u] != -1) continue;           level[edges[id].u] = level[v] + 1;           q.push(edges[id].u);         }       }       return level[t] != -1;     }     lli dfs(int v, lli pushed) {       if (pushed == 0ll) return 0ll;       if (v == t) return pushed;       for (int &cid = ptr[v]; cid < (int)adj[v].size(); ++cid) {         int id = adj[v][cid];         int u = edges[id].u;         if (level[v] + 1 != level[u] || edges[id].cap - edges[id].flow < 1)           continue;         lli tr = dfs(u, min(pushed, edges[id].cap - edges[id].flow));         if (tr == 0ll) continue;         edges[id].flow += tr;         edges[id ^ 1].flow -= tr;         return tr;       }       return 0ll;     }     lli flow() {       lli f = 0ll;       while (true) {         fill(level.begin(), level.end(), -1);         level[s] = 0;         q.push(s);         if (!bfs()) break;         fill(ptr.begin(), ptr.end(), 0);         while (lli pushed = dfs(s, flow_inf)) f += pushed;       }       return f;     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n = 0, m = 0, x = 0, y = 0, w = 0;     cin >> n >> m;     vector<pair<int, pair<int, int> > > v;     for (int i = 0; i < m; ++i) {       cin >> x >> y >> w;       --x;       --y;       v.push_back({w, {x, y}});     }     sort(v.begin(), v.end());     int l = n, r = m;     while (l != r) {       int mid = (l + r) / 2;       Dinic g(2 * n + 2, 2 * n, 2 * n + 1);       for (int i = 0; i < n; ++i) {         g.addEdge(2 * n, i, 1);         g.addEdge(n + i, 2 * n + 1, 1);       }       for (int i = 0; i <= mid; ++i)         g.addEdge(v[i].second.first, n + v[i].second.second, 1);       if (g.flow() == n)         r = mid;       else         l = mid + 1;     }     if (l >= m)       cout <<  -1 ;     else       cout << v[l].first;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, t;     cin >> n >> t;     vector<int> books(n);     for (int i = 0; i < n; i++) {       cin >> books[i];     }     int i, j;     i = 0, j = 0;     int ac = 0;     int ans = 0;     while (i < n) {       if (i > j) j = i;       while (ac < t && j < n) {         ac += books[j];         j++;       }       ans = max(ans, (j - (ac > t)) - i);       ac -= books[i];       i++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   int ans, a[5010], K, n;   map<int, int> g;   int main() {     int i, j, k, ca = 0, m;     scanf( %d%d , &n, &K);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     for (i = 0; i < n; i++)       for (j = 1; j <= K; j++) {         int first = a[i] * j;         if (!g.count(first))           g[first] = j;         else           g[first] = min(g[first], j);       }     scanf( %d , &m);     while (m--) {       int first;       scanf( %d , &first);       if (first < a[0]) {         puts( -1 );         continue;       } else {         int ans = K + 1;         if (g.count(first)) ans = min(ans, g[first]);         for (i = 0; i < n; i++) {           if (a[i] > first) break;           int second = min(K, first / a[i]);           for (j = 1; j < second; j++) {             int rem = first - j * a[i];             if (g.count(rem)) ans = min(ans, j + g[rem]);           }         }         if (ans >= K + 1) ans = -1;         printf( %d n , ans);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const double tiaohe = 0.57721566490153286060651209;   long long oula(long long x) {     long long res = x;     for (register int i = 2; i <= x / i; ++i) {       if (x % i == 0) {         res = res / i * (i - 1);         while (x % i == 0) x /= i;       }     }     if (x > 1) res = res / x * (x - 1);     return res;   }   long long quickmod(long long a, long long n, long long m) {     long long s = 1;     while (n) {       if (n & 1) {         s = s * a % m;       }       a = (a * a) % m;       n = n / 2;     }     return s;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   void ex_gcd(long long a, long long b, long long &x, long long &y,               long long &d) {     if (!b) {       d = a, x = 1, y = 0;     } else {       ex_gcd(b, a % b, y, x, d);       y -= x * (a / b);     }   }   long long inv(long long t, long long p) {     long long d, x, y;     ex_gcd(t, p, x, y, d);     return d == 1 ? (x % p + p) % p : -1;   }   bool isPrime(long long x) {     if (x == 2) return true;     if (x % 2 == 0) return false;     for (long long i = 2; i * i <= x; i++)       if (x % i == 0) return false;     return true;   }   double eqa = (1 + sqrt(5.0)) / 2.0;   const int N = 6e5 + 5;   int t;   int main() {     cin >> t;     long long n, w;     while (t--) {       cin >> n >> w;       set<long long> st;       long long x, y;       long long mx = 0;       for (register int i = 1; i <= n; ++i) {         scanf( %lld%lld , &x, &y);         mx = max(mx, x);         if (x - y > 0) st.insert(x - y);       }       if (st.empty()) {         if (mx >= w)           puts( 1 );         else           puts( -1 );       } else {         auto it = st.end();         it--;         cout << (long long)ceil((max(w - mx, (long long)0)) * 1.0 / (*it)) + 1              << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int ans[100000];   int main() {     long long int n, m, mx, mn, i, j, k, diff, flag = 0, flag1 = 0, flag2 = 0;     cin >> n >> m >> mn >> mx;     long long int arr[m + 5];     for (i = 0; i < m; i++) {       cin >> arr[i];       if (arr[i] == mn) flag1 = 1;       if (arr[i] == mx) flag2 = 1;       if (arr[i] < mn || arr[i] > mx) flag = 1;     }     diff = n - m;     if (flag == 1)       cout <<  Incorrect  << endl;     else if (flag1 == 1 && flag2 == 1)       cout <<  Correct  << endl;     else if (flag1 == 1 && diff >= 1 || flag2 == 1 && diff >= 1)       cout <<  Correct  << endl;     else if (flag1 == 0 && flag2 == 0 && diff >= 2)       cout <<  Correct  << endl;     else       cout <<  Incorrect  << endl;     return 0;   }
#include<bits/stdc++.h>   #define int long long   #define ld long double   #define fi first   #define se second   #define vll vector<int>   #define pii pair<int,int>   #define pb push_back   #define sz(v) (int)(v).size()   #define inf (int)(1e18)   #define md (int)(998244353)   #define all(v) (v).begin(),(v).end()   #define rep(i,a,b) for(int i=a;i<b;++i)   using namespace std;      const int M = 1e6 + 10;      int ans[M],d[M];      int32_t main(){       ios_base::sync_with_stdio(false);       cin.tie(0);              rep(i,1,M)for(int j=i;j<M;j+=i) d[j]++;              ans[1]=1,ans[2]=3;       int sum=4;       rep(i,3,M) {        ans[i]=(sum+d[i])%md;        (sum+=ans[i])%=md;       }       int n;       cin>>n;       cout<<ans[n];              return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1005;   struct node {     int u, v, val;   } ans[maxn * 10];   std::vector<int> g[maxn];   int n, tot;   int in[maxn];   int x[maxn], y[maxn], val[maxn];   void addedge(int u, int v, int val) { ans[++tot] = (node){u, v, val}; }   void find(int u, int fa, int &x3, int &x4) {     if (g[u].size() == 1) {       if (x3 == 0)         x3 = u;       else         x4 = u;       return;     } else       for (int i = 0; i < g[u].size(); i++) {         if (g[u][i] == fa) continue;         find(g[u][i], u, x3, x4);       }   }   int main() {     scanf( %d , &n);     if (n == 2) {       printf( YES n1 n );       int x, y, k;       scanf( %d%d%d , &x, &y, &k);       printf( %d %d %d n , x, y, k);       return 0;     }     for (int i = 1; i < n; i++) {       scanf( %d%d%d , &x[i], &y[i], &val[i]);       g[x[i]].push_back(y[i]);       g[y[i]].push_back(x[i]);       in[x[i]]++;       in[y[i]]++;     }     for (int i = 1; i <= n; i++)       if (in[i] == 2) return !printf( NO n );     printf( YES n );     for (int k = 1; k < n; k++) {       if (in[x[k]] > in[y[k]]) swap(x[k], y[k]);       if (in[x[k]] == 1) {         int x4 = 0, x1 = 0, x2 = 0, x5 = 0, x3 = 0;         x1 = y[k];         x3 = x[k];         find(x1, x3, x4, x5);         addedge(x3, x4, val[k] / 2);         addedge(x3, x5, val[k] / 2);         addedge(x4, x5, -val[k] / 2);       } else {         int x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0;         x1 = x[k];         x2 = y[k];         find(x1, x2, x3, x4);         find(x2, x1, x5, x6);         addedge(x3, x5, val[k] / 2);         addedge(x4, x6, val[k] / 2);         addedge(x3, x4, -val[k] / 2);         addedge(x5, x6, -val[k] / 2);       }     }     printf( %d n , tot);     for (int i = 1; i <= tot; i++) {       printf( %d %d %d n , ans[i].u, ans[i].v, ans[i].val);     }   }
#include <bits/stdc++.h>   using namespace std;   char yam[1 << 23];   int main() {     long long b, n, c;     gets(yam);     char *bp = yam;     char *np = strchr(bp,    ) + 1;     char *cp = strchr(np,    ) + 1;     c = atoi(cp);     for (b = 0; isdigit(*bp); bp++) {       b = (10 * b + (*bp -  0 )) % c;     }     long long res = (b - 1 + c) % c;     int carry = 1;     for (np = cp - 2; isdigit(*np); np--) {       int cur = *np -  0  - carry;       if (cur < 0) {         cur += 10;         carry = 1;       } else         carry = 0;       while (cur--) {         res = (res * b) % c;       }       long long oldb = b;       for (int i = 0; i < 9; i++) {         b = (b * oldb) % c;       }     }     cout << (res ?: c);     return 0;   }
/********   All Required Header Files ********/   #include <iostream>   #include <string>   #include <vector>   #include <algorithm>   #include <sstream>   #include <queue>   #include <deque>   #include <bitset>   #include <iterator>   #include <list>   #include <stack>   #include <map>   #include <set>   #include <functional>   #include <numeric>   #include <utility>   #include <limits>   #include <time.h>   #include <math.h>   #include <stdio.h>   #include <string.h>   #include <stdlib.h>   #include <assert.h>      using namespace std;   /*******  All Required define Pre-Processors and typedef Constants *******/   #define ll long long int   #define ull unsigned long long int   #define li long int   #define uli unsigned long int   #define MOD 1e10+7   #define all(a) a.begin(),a.end()   #define FOR(i,j,k,l) for(int i=j;i<k;i+=l)   #define RFOR(i,j,k,l) for(int i=j;i>=k;i-=l)   #define REP(i,j) FOR(i,0,j,1)   #define RREP(i,j) FOR(i,j,0,1)   #define PB push_back   #define _finout ios::sync_with_stdio(0);cin.tie(0)   typedef vector<int> VI;   typedef vector<char> VC;   typedef vector<string> VS;   typedef vector<VI> VVI;   typedef vector<ll> VL;   typedef set<int> SETI;   typedef map<int,int> MPII;   typedef multiset<int> MSETI;   // const int N = (int)(2*1e5 +10);   long long sq(int x){return 1ll * x*x;}   // ll dp[N];   // ll lev[N];   // VL adj[N];   bool isprime(long long int num){       for(long long int i=2;i<=sqrt(num);i++){           if (num%i == 0) return false;       }       return true;   }   vector<int> check(int n,vector<int>a,int x){       MSETI s;       for(auto e:a) s.insert(e);       vector<int> res;       for(int i=0;i<n;i++){           auto it1 = s.end();           it1--;           int y = x - *it1;           s.erase(it1);           auto it2 = s.find(y);           if(it2==s.end()) return {};           res.push_back(x-y);           res.push_back(y);           x = max(x-y,y);           s.erase(it2);       }       return res;   }   void solve()   {       int n;       cin >> n;       vector<int> a(2 * n);       for (int i = 0; i < 2 * n; i++)           cin >> a[i];       sort(a.begin(), a.end());       for (int i = 0; i < 2 * n - 1; i++)       {           int x = a[i] + a[2 * n - 1];           vector<int> res = check(n, a, x);           if (res.size())           {               cout <<  YES n ;               cout << x <<   n ;               for (int j = 0; j < n; j++)               {                   cout << res[2 * j] <<     << res[2 * j + 1] <<   n ;               }               return;           }       }       cout <<  NO n ;   }   int main(){       _finout;       int T;       cin>>T;       while(T--){           solve();       }   }
#include <bits/stdc++.h>   using namespace std;   void file() {}   const long long nax = 2e5 + 1, mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     file();     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       n *= 3;       vector<int> vis(n + 1), cnt(n + 1);       pair<int, int> p[m + 1];       map<pair<int, int>, int> mapp;       for (long long i = 1; i <= m; i++) {         cin >> p[i].first >> p[i].second;         cnt[p[i].first]++;         cnt[p[i].second]++;         mapp[make_pair(p[i].first, p[i].second)] = i;       }       vector<pair<int, pair<int, int> > > v;       for (long long i = 1; i <= m; i++) {         v.push_back(make_pair(cnt[p[i].first] + cnt[p[i].second],                               make_pair(p[i].first, p[i].second)));       }       sort(v.begin(), v.end());       vector<int> ans1, ans2;       for (auto it : v) {         if (!vis[it.second.first] && !vis[it.second.second])           ans1.push_back(mapp[make_pair(it.second.first, it.second.second)]),               vis[it.second.first] = true, vis[it.second.second] = true;       }       for (long long i = 1; i <= n; i++) {         if (!vis[i]) ans2.push_back(i);       }       if (ans1.size() >= n / 3) {         cout <<  Matching               <<   n ;         int ct = n / 3;         for (auto it : ans1) {           ct--;           cout << it <<    ;           if (ct == 0) break;         }       } else {         cout <<  IndSet               <<   n ;         int ct = n / 3;         for (auto it : ans2) {           ct--;           cout << it <<    ;           if (ct == 0) break;         }       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long ans = 0;     long long total;     long long tleft = 0;     long long tright = 0;     vector<pair<long long, long long> > soldier;     for (long long i = 0; i < n; i++) {       long long a, b;       cin >> a >> b;       soldier.push_back(make_pair(a, b));       tleft += a;       tright += b;     }     total = abs(tleft - tright);     for (long long i = 0; i < n; i++) {       tleft -= soldier[i].first;       tleft += soldier[i].second;       tright -= soldier[i].second;       tright += soldier[i].first;       if (total < abs(tleft - tright)) {         total = abs(tleft - tright);         ans = i + 1;       }       tleft += soldier[i].first;       tleft -= soldier[i].second;       tright += soldier[i].second;       tright -= soldier[i].first;     }     cout << ans << endl;   }