malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     long long k;     cin >> k;     long long arr[n + 1];     for (long long i = 1; i <= n; i++) {       cin >> arr[i];     }     set<long long> s;     for (long long i = k; i <= n; i++) {       s.insert(arr[i]);     }     if (s.size() != 1) {       cout << -1 << endl;     } else {       long long index = k;       while (index >= 1 && arr[index] == arr[k]) {         index--;       }       index++;       cout << index - 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, curbest;   int ans[5005], t[5005];   int cnt[5005];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> t[i];     for (int i = 1; i <= n; i++) {       curbest = 0;       memset(cnt, 0, sizeof cnt);       for (int j = i; j <= n; j++) {         cnt[t[j]]++;         if (cnt[t[j]] > cnt[curbest] ||             cnt[t[j]] == cnt[curbest] && t[j] < curbest) {           curbest = t[j];         }         ans[curbest]++;       }     }     for (int i = 1; i <= n; i++) {       cout << ans[i];       if (i != n)         cout <<    ;       else         cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mark[100005];   long long msum[100005];   long long sum[100005];   int c[100005];   long long cs;   int main() {     long long ans = 0;     int i, n, m, x;     scanf( %d%d , &n, &m);     for (i = 1; i <= n; ++i) scanf( %d , &c[i]);     for (i = 1; i <= m; ++i) {       scanf( %d , &x);       mark[x] = 1;     }     for (i = n; i > 0; --i) {       sum[i] = sum[i + 1] + c[i];       msum[i] = msum[i + 1] + c[i] * mark[i];     }     for (i = 1; i <= n; ++i)       if (mark[i])         ans += c[i] * sum[i + 1];       else {         ans += c[i] * msum[i + 1];         if (!mark[i + 1]) ans += (long long)c[i] * c[i + 1];         if (i == 1 && !mark[n]) ans += (long long)c[i] * c[n];       }     printf( %I64d n , ans);     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 103;   const int mod = 1e9 + 7;   char s[N];   long long g[N], f[N][N][N];   long long qpow(long long a, long long n) {     long long ret = 1;     while (n) {       if (n & 1) ret = ret * a % mod;       a = a * a % mod;       n >>= 1;     }     return ret;   }   int main() {     int n, m;     cin >> n >> m;     scanf( %s , s + 1);     g[0] = g[1] = 1;     for (int i = 2; i <= m; i++) (g[i] = g[i - 1] + g[i - 2]) %= (mod - 1);     for (int i = 0; i <= m; i++) g[i] = qpow(2, g[i]);     for (int i = 1; i <= n; i++) {       if (s[i] ==  1 )         f[1][i][i] = 1;       else         f[0][i][i] = 1;     }     for (int i = 2; i <= m; i++)       for (int l = 1; l <= n; l++)         for (int r = l; r <= n; r++) {           if (l == 1)             (f[i][l][r] += f[i - 2][l][r] * g[i - 1] % mod) %= mod;           else             (f[i][l][r] += f[i - 2][l][r]) %= mod;           if (r == n)             (f[i][l][r] += f[i - 1][l][r] * g[i - 2] % mod) %= mod;           else             (f[i][l][r] += f[i - 1][l][r]) %= mod;           for (int j = 1; j < r; j++) {             (f[i][l][r] += f[i - 1][l][j] * f[i - 2][j + 1][r] % mod) %= mod;           }         }     cout << f[m][1][n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 0, k = 0, i = 0, j = 0;     char str[100];     cin >> n >> k;     cin >> str;     if (k <= n - k) {       for (i = 1; i < k; i++) {         cout <<  LEFT  << endl;       }       for (i = 0; i < strlen(str) - 1; i++) {         cout <<  PRINT   << str[i] << endl;         cout <<  RIGHT  << endl;       }       cout <<  PRINT   << str[strlen(str) - 1] << endl;     }     if (k > n - k) {       for (i = 0; i < n - k; i++) {         cout <<  RIGHT  << endl;       }       for (i = strlen(str) - 1; i > 0; i--) {         cout <<  PRINT   << str[i] << endl;         cout <<  LEFT  << endl;       }       cout <<  PRINT   << str[0] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6;   const int INF = 1e9;   const long long linf = 0x3f3f3f3f3f3f3f3f;   const double PI = acos(-1.0);   long long mod = 1e9 + 7;   int main() {     int n, a;     cin >> n >> a;     cout << 2 <<     << 1 <<     << max(3, min(n, ((n * a + 90) / 180 + 2)))          << endl;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx )   using namespace std;   bool is_prime(long long n) {     for (long long i = 2; i * i <= n; ++i) {       if (n % i == 0) {         return false;       }     }     return true;   }   vector<long long> fact(long long n) {     vector<long long> ans;     for (int i = 2; i * i <= n; i++) {       if (n % i == 0) {         ans.push_back(i);         while (n % i == 0) {           n /= i;         }       }     }     if (n > 1) ans.push_back(n);     return ans;   }   long long getPow(long long a, long long b) {     long long res = 1ll, tp = a;     while (b) {       if (b & 1ll) {         res *= tp;       }       tp *= tp;       b >>= 1ll;     }     return res;   }   long long vec_mult(long long x1, long long y1, long long x2, long long y2,                      long long x3, long long y3) {     return abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));   }   void ok() {     cout <<  YES  << endl;     exit(0);   }   void no() {     cout <<  NO  << endl;     exit(0);   }   inline long long nxt() {     long long x;     cin >> x;     return x;   }   const long long N = 3000 + 5, inf = 2e16;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     long long n = nxt(), m = nxt(), k = nxt();     vector<long long> used(n, 1);     for (int i = 0; i < m; i++) {       long long x = nxt();       used[x] = 0;     }     vector<long long> a(k);     for (int i = 0; i < k; i++) {       a[i] = nxt();     }     if (!used[0]) {       return cout << -1, 0;     }     vector<long long> pos;     for (int i = 0; i < n; i++) {       if (used[i]) pos.push_back(i);     }     auto get = [&](long long l) {       long long ct = 0;       long long start = 0;       long long ind = 0;       if (!pos.size()) return inf;       while (true) {         ct++;         long long cur = start + l;         if (cur >= n) {           start = cur;           break;         }         long long cur_ind =             (upper_bound(pos.begin(), pos.end(), cur)) - pos.begin();         if (cur_ind == pos.size())           cur_ind--;         else if (pos[cur_ind] > cur) {           cur_ind--;         }         if (pos[cur_ind] == start) break;         if (cur < n) {           start = pos[cur_ind];         } else {           start = cur;           break;         }       }       if (start >= n)         return ct;       else         return inf;     };     long long ans = inf;     for (int i = 0; i < k; i++) {       long long ct = get(i + 1);       if (ct == inf) continue;       ans = min(ans, ct * a[i]);     }     if (ans >= inf)       cout << -1;     else       cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char a[1000000], b[1000000];     int n;     cin >> n >> a;     int l = strlen(a);     for (int i = 1; i < n; i++) {       cin >> b;       for (int j = 0; j < l; j++) {         if (a[j] ==  ? )           a[j] = b[j];         else if (b[j] ==  ? )           continue;         else if (a[j] != b[j])           a[j] =  0 ;       }     }     for (int i = 0; i < l; i++) {       if (a[i] ==  0 )         a[i] =  ? ;       else if (a[i] ==  ? )         a[i] =  x ;     }     cout << a;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1000006;   int rnk[MAX], parent[MAX], ans[MAX], arr[MAX];   vector<int> comp[MAX];   priority_queue<int> q[MAX];   int find(int x) {     if (x == parent[x]) return x;     return parent[x] = find(parent[x]);   }   void merge(int x, int y) {     x = find(x);     y = find(y);     if (x == y) return;     if (rnk[x] > rnk[y])       parent[y] = x;     else {       parent[x] = y;       if (rnk[x] == rnk[y]) rnk[y]++;     }   }   int main() {     int n, m, a, b;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %d , &arr[i]);       parent[i] = i;       rnk[i] = 0;     }     for (int i = 0; i < m; i++) {       scanf( %d%d , &a, &b);       a--, b--;       merge(a, b);     }     int maxc = 0;     for (int i = 0; i < n; i++) {       comp[find(i)].push_back(i);       maxc = max(maxc, find(i));       q[find(i)].push(arr[i]);     }     for (int i = 0; i <= maxc; i++) {       for (int j = 0; j < comp[i].size(); j++) {         ans[comp[i][j]] = q[i].top();         q[i].pop();       }     }     for (int i = 0; i < n; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   bool office[25][25];   size_t m, n;   bool check(size_t x1, size_t y1, size_t x2, size_t y2) {     for (size_t x = x1; x <= x2; ++x) {       for (size_t y = y1; y <= y2; ++y) {         if (office[x][y]) {           return false;         }       }     }     return true;   }   bool check(size_t x, size_t y) {     for (size_t i = 0; i < m - x; ++i) {       for (size_t j = 0; j < n - y; ++j) {         if (check(i, j, i + x, j + y)) {           return true;         }       }     }     return false;   }   int main() {     std::cin >> m >> n;     std::string row;     size_t i = 0;     while (std::cin >> row) {       for (size_t j = 0; j < row.size(); ++j) {         office[i][j] = row[j] ==  1 ;       }       ++i;     }     size_t best = 4;     for (size_t x = 0; x < m; ++x) {       for (size_t y = 0; y < n; ++y) {         size_t p = (x + y + 2) * 2;         if (p > best && check(x, y)) {           best = p;         }       }     }     std::cout << best;   }
#include <bits/stdc++.h>   using namespace std;   int a[111111], b[111111], c[111111];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];     }     for (int i = 1; i <= n; ++i) {       b[i] = min(a[i], min(b[i - 1] + 1, i));     }     reverse(a + 1, a + n + 1);     for (int i = 1; i <= n; ++i) {       c[i] = min(a[i], min(c[i - 1] + 1, i));     }     reverse(c + 1, c + n + 1);     int ans = 0;     for (int i = 1; i <= n; ++i) {       ans = max(ans, min(b[i], c[i]));     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<string> s;   string ans(200,    );   set<string> Set;   vector<string> cand;   int main() {     cin >> n;     ans.resize(2 * n - 2);     for (int i = 0; i < 2 * n - 2; ++i) {       string a;       cin >> a;       Set.insert(a);       s.push_back(a);       if (a.size() == n - 1) cand.push_back(a);     }     bool prefix = true, suffix = true;     string P, S;     for (int i = 1; i < n - 1; ++i) prefix &= Set.count(cand[0].substr(0, i));     for (int i = 1; i < n - 1; ++i)       suffix &= Set.count(cand[1].substr(n - 1 - i));     if (suffix && prefix && cand[0].substr(1, n - 1) == cand[1].substr(0, n - 2))       P = cand[0], S = cand[1];     else       P = cand[1], S = cand[0];     for (int i = 1; i <= n - 1; ++i) {       string sub = P.substr(0, i);       for (int j = 0; j < ans.size(); ++j)         if (ans[j] ==     && s[j] == sub) {           ans[j] =  P ;           break;         }     }     for (int i = 0; i < ans.size(); ++i)       if (ans[i] ==    ) ans[i] =  S ;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000 + 10;   const int M = 1000000007;   const double PI = atan(1) * 4;   const int oo = 2100000000;   int main() {     int n;     cin >> n;     vector<pair<int, int> > v(n), g(n);     for (int i = 0; i < n; ++i) {       scanf( %d%d , &v[i].first, &v[i].second);       int x = v[i].first;       int w = v[i].second;       g[i].first = x + w;       g[i].second = x - w;     }     sort((g).begin(), (g).end());     int ls = -1e9, ans = 0;     for (int i = 0; i < n; ++i) {       if (g[i].second >= ls) {         ++ans;         ls = g[i].first;       }     }     cout << ans;   }
#include <bits/stdc++.h>   int main() {     int n;     scanf( %d , &n);     char *str = new char[n + 1];     scanf( %s , str);     int size = strlen(str);     int sum1 = 0, sum2 = 0;     bool f = true;     for (int i = 0; i < size / 2; ++i) {       if ((str[i] ==  4  || str[i] ==  7 ) &&           (str[size - i - 1] ==  4  || str[size - i - 1] ==  7 )) {         sum1 += str[i] -  0 ;         sum2 += str[size - i - 1] -  0 ;       } else {         f = false;         break;       }     }     if (sum1 == sum2 && f)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long nb, ns, nc, pb, ps, pc, ab, as, ac, money;   bool solve(long long k) {     long long cb = k * ab, cs = k * as, cc = k * ac;     long long cost = 0;     cost += max(cb - nb, 0LL) * pb;     cost += max(cs - ns, 0LL) * ps;     cost += max(cc - nc, 0LL) * pc;     return cost <= money;   }   int main() {     ios_base::sync_with_stdio(false);     string s;     cin >> s;     for (int i = 0; i < s.size(); ++i)       if (s[i] ==  B )         ab++;       else if (s[i] ==  S )         as++;       else         ac++;     cin >> nb >> ns >> nc >> pb >> ps >> pc;     cin >> money;     long long lo = 0, hi = 1e14, mid;     while (lo < hi) {       mid = (lo + hi + 1) / 2;       if (solve(mid))         lo = mid;       else         hi = mid - 1;     }     cout << lo <<   n ;   }
#include<bits/stdc++.h>   using namespace std;      #define FOR(i, a, b) for(int i = (a); i < (b); ++i)   #define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)   #define REP(i, N) FOR(i, 0, N)   #define RREP(i, N) RFOR(i, N, 0)   #define FILL(A,value) memset(A,value,sizeof(A))   #define endl   n       #define ALL(V) V.begin(), V.end()   #define SZ(V) (int)V.size()   #define watch(x) cout << (#x) <<   is   << (x) << endl   #define pb push_back   #define mp make_pair   #define Pi 3.14159265358979   #define A first   #define B second      typedef long long ll;   typedef vector <int> vi;   typedef vector<ll> vl;   typedef pair <int, int> pi;   typedef pair <ll, int> pl;   typedef pair <ll, ll> pll;   typedef pair <double, double> pd;      //change these according to prob constraints   const int INF = 0x3f3f3f3f;   const int MAX = 100005;   const int MAX1 = 1005;   const int MAX2 = 105;   const int LEN = 105;   const int BASE = 1000000000;   const double EPS = 1e-7;   const int MOD = 1000000007;   //g++ -std=c++11 your_file.cpp -o your_program      ll mypow(ll a, ll b){    ll ans=1;    while(b){     if(b&1)      ans=(ans*a)%MOD;     b/=2;     a=(a*a)%MOD;    }    return ans;   }      int main(void){    ios_base::sync_with_stdio(false);    cin.tie(NULL);    cout.tie(NULL);    ifstream in(  );    ofstream out(  );    clock_t begin = clock();    int q;       cin >> q;       while (q--){           int n;           cin >> n;           if (n == 1) cout << 9 << endl;           else if (n == 2) cout << 98 << endl;           else if (n == 3) cout << 989 << endl;           if (n <= 3) continue;           string s =  98 ;           int ct = 9;           REP(i, n - 2){               if (ct == 10) ct = 0;               s += to_string(ct);               ct++;           }           cout << s << endl;       }    clock_t end = clock();       double esecs = double(end - begin) / CLOCKS_PER_SEC;       //cout << esecs <<   seconds  << endl;    return 0;    }
#include <bits/stdc++.h>   using namespace std;   int s[50];   char a[55][55];   int main() {     int n, i, j, c = 1, k, found;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %s , a[i]);       int l = strlen(a[i]);       for (j = 0; j < l; j++) {         s[a[i][j] -  a ]++;       }     }     for (i = 0; i < 26; i++) {       if (s[i] == 0) {         printf( %c , (char)(i +  a ));         c = 1;         break;       } else         c = 2;     }     if (c == 2) {       for (i = 0; i < 26; i++) {         for (j = 0; j < 26; j++) {           char str[4];           found = 0;           str[0] = (char)(i +  a );           str[1] = (char)(j +  a );           for (k = 0; k < n; k++) {             int l = strlen(a[k]), x = 0;             while (x < (l - 1)) {               if (a[k][x] == str[0] && a[k][x + 1] == str[1]) {                 found = 1;                 break;               } else                 x++;             }             if (found == 1) break;           }           if (found == 0) {             printf( %c%c n , str[0], str[1]);             c = 3;             break;           }         }         if (c == 3) break;       }     }     return 0;   }
#include <bits/stdc++.h>   const int maxn = 2e5 + 5;   int n, q;   inline int lowbit(int x) { return x & (-x); }   long long bit[maxn];   void add(int pos, long long v) {     for (int i = pos; i <= n; i += lowbit(i)) bit[i] += v;   }   long long querybit(int pos) {     long long ans = 0;     for (int i = pos; i; i -= lowbit(i)) ans += bit[i];     return ans;   }   long long mv[maxn << 2], a[maxn];   void updata(int rt) { mv[rt] = std::max(mv[rt << 1], mv[rt << 1 | 1]); }   void build(int l, int r, int rt) {     if (l == r) {       mv[rt] = a[l];       return;     }     int mid = (l + r) >> 1;     build(l, mid, rt << 1);     build(mid + 1, r, rt << 1 | 1);     updata(rt);   }   void modify(int l, int r, int rt, int pos, long long v) {     if (l == r) {       mv[rt] = v;       return;     }     int mid = (l + r) >> 1;     if (pos <= mid)       modify(l, mid, rt << 1, pos, v);     else       modify(mid + 1, r, rt << 1 | 1, pos, v);     updata(rt);   }   int query(int l, int r, int rt, int pos, long long v) {     if (mv[rt] < v || pos > n) return n + 1;     if (l == r) return l;     int mid = (l + r) >> 1;     if (pos <= l) {       if (mv[rt << 1] >= v)         return query(l, mid, rt << 1, pos, v);       else         return query(mid + 1, r, rt << 1 | 1, pos, v);     } else {       if (pos <= mid)         return std::min(query(l, mid, rt << 1, pos, v),                         query(mid + 1, r, rt << 1 | 1, pos, v));       else         return query(mid + 1, r, rt << 1 | 1, pos, v);     }   }   int search(int pos) {     if (pos > n) return -1;     if (querybit(pos - 1) == a[pos]) return pos;     return search(query(1, n, 1, pos + 1, querybit(pos)));   }   int main() {     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) scanf( %lld , &a[i]), add(i, a[i]);     build(1, n, 1);     while (q--) {       int tp;       long long tv;       scanf( %d%lld , &tp, &tv);       add(tp, tv - a[tp]);       a[tp] = tv;       modify(1, n, 1, tp, tv);       printf( %d n , search(1));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> v[1005];   int ma, src;   bool vis[1005];   int p[1005];   void dfs(int s, int pa, int d) {     p[s] = pa;     vis[s] = 1;     if (d >= ma) {       src = s;       ma = d;     }     for (int i = 0; i < v[s].size(); i++) {       int u = v[s][i];       if (u != pa) {         dfs(u, s, d + 1);       }     }   }   int main() {     int u = 0;     ios::sync_with_stdio(0);     cin >> n >> m;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     int trees = 0, ans = 0;     vector<int> vvv;     vector<pair<int, int> > vv;     for (int i = 1; i <= n; i++) {       if (!vis[i]) {         ma = 0;         src = i;         dfs(i, -1, 0);         dfs(src, -1, 0);         int node = src;         for (int j = 0; j < ma / 2; j++) {           node = p[node];         }         vv.push_back({ma, node});         trees++;         u = max(u, ma);         vvv.push_back((ma + 1) / 2);       }     }     sort(vvv.begin(), vvv.end());     sort(vv.rbegin(), vv.rend());     for (int i = vvv.size() - 1; i >= max(0, (int)(vvv.size() - 2)); i--) {       ans += vvv[i];     }     int mi = 2;     if (vvv.size() >= 3) {       if (vvv[vvv.size() - 3] < vvv[vvv.size() - 1]) {         mi = 1;       }     }     ans += min(trees - 1, mi);     ans = max(ans, u);     cout << ans << endl;     for (int i = 0; i < vv.size() - 1; i++) {       cout << vv[0].second <<     << vv[i + 1].second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, tx, ty, ans, fa[2055];   bool vis[2055];   int find(const int i) { return fa[i] == i ? i : fa[i] = find(fa[i]); }   void merge(const int i, const int j) { fa[i] = j; }   int main() {     scanf( %d , &n);     for (int i = 1; i <= 2010; ++i) {       fa[i] = i;     }     for (int i = 1; i <= n; ++i) {       scanf( %d %d , &tx, &ty);       ty += 1005;       if (!vis[tx]) {         ++ans;         vis[tx] = true;       }       if (!vis[ty]) {         ++ans;         vis[ty] = true;       }       tx = find(tx);       ty = find(ty);       if (tx != ty) {         --ans;         merge(tx, ty);       }     }     --ans;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct yy {     int id, val;   } f[8000];   int a[8000], p[8000][2], d[8000];   bool b[8000];   bool cmp(yy x, yy y) { return x.val > y.val; }   int main() {     int i, j, n, m, t, x;     bool tm;     scanf( %d%d , &n, &m);     for (i = 1; i <= 2 * n; ++i) {       scanf( %d , &f[i].val);       f[i].id = i;       a[i] = f[i].val;     }     sort(f + 1, f + 1 + 2 * n, cmp);     for (i = 1; i <= m; ++i) {       scanf( %d%d , &p[i][0], &p[i][1]);       d[p[i][0]] = p[i][1];       d[p[i][1]] = p[i][0];     }     scanf( %d , &t);     if (t == 1) {       for (i = 1; i <= m; ++i) {         if (a[p[i][0]] > a[p[i][1]]) {           printf( %d n , p[i][0]);           fflush(stdout);           b[p[i][0]] = 1;         } else {           printf( %d n , p[i][1]);           fflush(stdout);           b[p[i][1]] = 1;         }         scanf( %d , &x);         b[x] = 1;       }       for (i = 1; i <= 2 * n; ++i) {         if (!b[f[i].id]) {           printf( %d n , f[i].id);           fflush(stdout);           b[f[i].id] = 1;           scanf( %d , &x);           b[x] = 1;         }       }     } else {       for (i = 1; i <= n; ++i) {         scanf( %d , &x);         b[x] = 1;         if (d[x] && !b[d[x]]) {           printf( %d n , d[x]);           fflush(stdout);           b[d[x]] = 1;         } else {           tm = 0;           for (j = 1; j <= m; ++j)             if (!b[p[j][0]]) {               if (a[p[j][0]] > a[p[j][1]]) {                 printf( %d n , p[j][0]);                 fflush(stdout);                 b[p[j][0]] = 1;                 tm = 1;                 break;               } else {                 printf( %d n , p[j][1]);                 fflush(stdout);                 b[p[j][1]] = 1;                 tm = 1;                 break;               }             }           if (!tm)             for (j = 1; j <= 2 * n; ++j)               if (!b[f[j].id]) {                 printf( %d n , f[j].id);                 fflush(stdout);                 b[f[j].id] = 1;                 break;               }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   template <typename T>   using V = vector<T>;   const int N = 1e5 + 5;   bool taken[3 * N];   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int tc;     cin >> tc;     while (tc--) {       int n, m;       cin >> n >> m;       for (int i = 1; i <= 3 * n; ++i) taken[i] = false;       vector<pii> edges(m);       vector<int> matching;       for (auto &e : edges) {         cin >> e.first >> e.second;       }       int id = 0;       for (auto &e : edges) {         ++id;         if (taken[e.first] or taken[e.second]) continue;         matching.push_back(id);         taken[e.first] = taken[e.second] = true;       }       if ((int)matching.size() >= n) {         cout <<  Matching n ;         for (int i = 0; i < n; ++i) {           cout << matching[i] <<    ;         }       } else {         cout <<  IndSet n ;         for (int i = 1, cnt = 0; cnt < n; ++i) {           if (!taken[i]) {             cout << i <<    ;             ++cnt;           }         }       }       cout <<   n ;     }     return 0;   }