malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long PosMod(long long a) { return a >= 0 ? a : a + 998244353; }   long long AddMod(long long a, long long b) {     return PosMod((a + b) % 998244353);   }   long long MultMod(long long a, long long b) {     return PosMod((a * b) % 998244353);   }   long long powll(long long a, long long n) {     long long r = 1;     for (long long b = n; b > 0; b >>= 1, a = MultMod(a, a))       if (b & 1) r = MultMod(r, a);     return r;   }   long long InvMod(long long a) { return powll(a, 998244353 - 2); }   long long Frac(long long a, long long b) { return MultMod(a, InvMod(b)); }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   int n, m, k;   int COL[2][2][1000100];   int ROW[2][2][1000100];   map<std::pair<int, int>, int> writtenValue;   long long col_posCnt[3];   long long row_posCnt[3];   long long valid1Cnt[2];   long long valid2Cnt[2];   int calcRPos(int i) {     int pos = 0;     pos += ROW[1][1][i] == 0 && ROW[0][0][i] == 0;     pos += ROW[0][1][i] == 0 && ROW[1][0][i] == 0;     return pos;   }   int calcCPos(int i) {     int pos = 0;     pos += COL[1][1][i] == 0 && COL[0][0][i] == 0;     pos += COL[0][1][i] == 0 && COL[1][0][i] == 0;     return pos;   }   std::pair<int, int> calcValid(int i) {     bool valid1 = ROW[1][1][i] == 0 && ROW[0][0][i] == 0;     bool valid2 = ROW[0][1][i] == 0 && ROW[1][0][i] == 0;     if (i % 2 == 0) swap(valid1, valid2);     return {(int)valid1, (int)valid2};   }   int main() {     cin.tie(0);     ios::sync_with_stdio(0);     cin >> n >> m >> k;     col_posCnt[2] = m;     row_posCnt[2] = n;     valid1Cnt[1] = n;     valid2Cnt[1] = n;     for (int i = 0; i < k; i++) {       int r, c, t;       cin >> r >> c >> t;       int prevRPos = calcRPos(r);       int prevCPos = calcCPos(c);       std::pair<int, int> prevValid = calcValid(r);       row_posCnt[prevRPos]--;       col_posCnt[prevCPos]--;       valid1Cnt[prevValid.first]--;       valid2Cnt[prevValid.second]--;       std::pair<int, int> p = {r, c};       if (writtenValue.count(p) > 0) {         int val = writtenValue[p];         COL[r % 2][val][c]--;         ROW[c % 2][val][r]--;         writtenValue.erase(p);       }       if (t == 0 || t == 1) {         writtenValue[p] = t;         COL[r % 2][t][c]++;         ROW[c % 2][t][r]++;       }       int curRPos = calcRPos(r);       int curCPos = calcCPos(c);       std::pair<int, int> curValid = calcValid(r);       row_posCnt[curRPos]++;       col_posCnt[curCPos]++;       valid1Cnt[curValid.first]++;       valid2Cnt[curValid.second]++;       long long ansR = row_posCnt[0] == 0 ? powll(2, row_posCnt[2]) : 0;       long long ansC = col_posCnt[0] == 0 ? powll(2, col_posCnt[2]) : 0;       long long dup =           (long long)(valid1Cnt[0] == 0) + (long long)(valid2Cnt[0] == 0);       cout << AddMod(AddMod(ansR, ansC), -dup) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int lcd = 2 * 2 * 2 * 3 * 3 * 5 * 7 * 11 * 13;   long long a, b, k, d[lcd], y = 0, l, i;   int main() {     cin >> a >> b >> k;     while (a > b) {       for (i = 2, l = 1; i <= k; i++)         if (a % i > l && a - a % i >= b) l = a % i;       y++;       a -= l;       if (d[a % lcd]) {         int c = y - d[a % lcd];         y += c * ((a - b) / lcd);         a -= ((a - b) / lcd) * lcd;       }       d[a % lcd] = y;     }     cout << y;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cla[110];   int main() {     int n;     cin >> n;     int cnt = 0;     int c;     int cnt0, cnt1;     int flag = 0;     for (int i = 0; i < n; i++) {       cin >> c;       if (c == 1) {         if (cnt0 == 1 && flag == 1) cnt++;         flag = 1;         cnt0 = 0;         cnt++;       } else {         cnt0++;       }     }     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N, K;     int O = 0, E = 0;     scanf( %d%d , &N, &K);     for (int i = 0; i < N; i++) {       int t;       scanf( %d , &t);       if (t % 2 == 0)         E++;       else         O++;     }     if (N == K) {       if (O % 2)         puts( Stannis );       else         puts( Daenerys );       return 0;     }     if (K % 2 == 0 && (N - K) % 2 == 0) {       puts( Daenerys );       return 0;     }     if (K % 2 == 0 && (N - K) % 2 == 1) {       if ((N - K) / 2 >= min(O, E))         puts( Daenerys );       else         puts( Stannis );       return 0;     }     if (K % 2 == 1 && (N - K) % 2 == 1) {       if ((N - K) / 2 >= O)         puts( Daenerys );       else         puts( Stannis );       return 0;     }     if (K % 2 == 1 && (N - K) % 2 == 0) {       if ((N - K) / 2 >= E)         puts( Stannis );       else         puts( Daenerys );       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int v[1000001];   int main() {     int n;     cin >> n;     for (int i = 2; i * i <= 1000000; i++)       if (v[i] == 0)         for (int j = i * i; j <= 1000000; j += i) v[j] = 1;     if (n > 2)       cout <<  2  << endl;     else       cout << 1 << endl;     for (int i = 2; i <= n + 1; i++)       if (v[i] == 0)         cout << 1 <<    ;       else         cout <<  2  ;     return 0;   }
#include <bits/stdc++.h>   using ll = long long;   using namespace std;   const long double PI = acos(-1);   const long long M = 998244353;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   inline long long mod(long long n, long long m = M) {     long long ret = n % m;     if (ret < 0) ret += m;     return ret;   }   long long exp(long long n, long long k, long long m = M) {     if (k == 0) return 1;     if (k == 1) return n;     long long ax = exp(n, k / 2, m);     ax = mod(ax * ax, m);     if (k % 2) ax = mod(ax * n, m);     return ax;   }   long long gcd(long long a, long long b) {     if (a == 0)       return b;     else       return gcd(b % a, a);   }   void solution() {     list<long long> l;     long long n, k;     cin >> n >> k;     vector<list<long long>::iterator> elems(n + 1);     for (long long i = 0; i < n; i++) {       long long x;       cin >> x;       l.push_back(x);       auto ed = l.end();       ed--;       elems[x] = ed;     }     long long ans = 1;     vector<bool> mark(n + 1, true);     vector<long long> b(k);     for (long long i = 0; i < k; i++) {       cin >> b[i];       mark[b[i]] = false;     }     for (long long i = 0; i < k; i++) {       auto it = elems[b[i]];       long long mult = 0;       if (it != l.begin()) {         auto it2 = it;         it2--;         mult += mark[*it2];       }       auto it2 = it;       it2++;       if (it2 != l.end()) mult += mark[*it2];       ans *= mult;       ans = mod(ans);       mark[b[i]] = true;     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     cin >> t;     while (t--) solution();   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = (int)5e6 + 100;   const int maxm = (int)1e6 + 100;   const int mod = (int)1e9 + 7;   const int P = (int)1e6 + 7;   const double pi = acos(-1.0);   int n, t[2][maxn], id = 1;   long long dp[2][30];   vector<int> g[maxn];   void add(int x, int pos) {     int v = 0;     for (int i = (29); i >= (0); --i) {       int bit = ((x >> i) & 1);       if (!t[bit][v]) t[bit][v] = id++;       v = t[bit][v];       g[v].push_back(pos);     }   }   void go(int v, int b = 29) {     int l = t[0][v], r = t[1][v];     if (l) go(l, b - 1);     if (r) go(r, b - 1);     if (!l || !r) return;     long long res = 0;     int ptr = 0;     for (auto x : g[l]) {       while (ptr < ((int)(g[r]).size()) && g[r][ptr] < x) ptr++;       res += ptr;     }     dp[0][b] += res;     dp[1][b] += ((int)(g[l]).size()) * 1ll * ((int)(g[r]).size()) - res;   }   void solve() {     scanf( %d , &n);     for (int i = (1); i <= (n); ++i) {       int x;       scanf( %d , &x);       add(x, i);     }     go(0);     long long inv = 0;     int res = 0;     for (int i = (0); i <= (29); ++i) {       inv += min(dp[0][i], dp[1][i]);       if (dp[1][i] < dp[0][i]) res += (1 << i);     }     printf( %lld %d , inv, res);   }   int main() {     int t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     int x[n], x1[m], x2[m], y[m];     for (int i = 0; i < n; i++) cin >> x[i];     sort(x, x + n);     vector<int> v;     for (int i = 0; i < m; i++) {       cin >> x1[i] >> x2[i] >> y[i];       if (x1[i] == 1) {         v.push_back(x2[i]);       }     }     sort(v.rbegin(), v.rend());     if (v.size() == 0) {       cout <<  0 ;       return 0;     }     int answer = 1000000000;     for (int i = 0; i <= n; i++) {       int right = 1000000000;       if (i != n) right = x[i];       if (v[0] < right)         answer = min(answer, i);       else {         int l = 0;         int r = (int)v.size() - 1;         while (r - l > 1) {           int sr = (r + l) / 2;           if (v[sr] >= right)             l = sr;           else             r = sr;         }         if (v[r] < right) r = l;         answer = min(answer, i + r + 1);       }     }     cout << answer;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, result, count = 0, i;     scanf( %d , &n);     char arr[n];     for (i = 0; i < n; i++) {       scanf(  n%c , &arr[i]);     }     i = 0;     for (i = 0; i < n; i++) {       if (arr[i] != arr[i - 1]) {         count++;       }     }     if (count + 2 < n) {       result = count + 2;     }     if (count + 2 >= n) {       result = n;     }     printf( %d , result);   }
#include <bits/stdc++.h>   using namespace std;   typedef struct x {     int cor;     int power;     bool operator<(x T) const { return cor < T.cor; }   } beacon;   beacon arr[2000009];   vector<int> tmp;   int dp[2000009];   int main() {     int n, m, k;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d%d , &arr[i].cor, &arr[i].power);     }     sort(arr, arr + n);     for (int i = 0; i < n; i++) tmp.push_back(arr[i].cor);     dp[0] = 0;     for (int i = 1; i < n; i++) {       int p = arr[i].power;       int left = arr[i].cor - p;       vector<int>::iterator it = lower_bound(tmp.begin(), tmp.end(), left);       int l = it - tmp.begin();       dp[i] = (i - l);       if (l > 0) dp[i] += dp[l - 1];     }     int ans = INT_MAX;     for (int i = 0; i < n; i++) {       ans = min(ans, dp[i] + (n - i - 1));     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   template <class X = int>   inline X min(X a, X b, X c) {     return min(min(a, b), c);   }   template <class X = int>   inline X min(X a, X b, X c, X d) {     return min(min(a, b, c), d);   }   template <class X = int>   inline X max(X a, X b, X c) {     return max(max(a, b), c);   }   template <class X = int>   inline X max(X a, X b, X c, X d) {     return max(max(a, b, c), d);   }   template <class X = int>   inline X mid(X s, X e) {     return (s + (e - s) / 2);   }   template <class X = int>   inline X len(X s, X e) {     return (e - s + 1);   }   const int MOD = 1e9 + 7;   const int INF = 987654321;   const bool TESTCASES = 0;   const bool CODEJAM = 0;   void solve() {     int n;     string s;     cin >> n;     cin >> s;     int ans = 0;     int temp = 0, br = 0;     for (int i = 0; i < n; i++) {       br += s[i] ==  )  ? -1 : 1;       if (br < 0)         temp++;       else if (br == 0 and temp != 0) {         ans += temp + 1;         temp = 0;       }     }     if (br != 0)       cout <<  -1 n ;     else       cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int T = 1;     if (TESTCASES) cin >> T;     for (int t = 1; t <= T; t++) {       if (CODEJAM) cout <<  Case #  << t <<  :  ;       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char s1[50], s2[50];     cin >> s1 >> s2;     long long left = 0, right = 0, mid = 0, l;     l = strlen(s1);     for (long long i = 0; i < l; i++)       if (s1[i] ==  | ) {         mid = i;         break;       }     left = mid;     right = l - (mid + 1);     if ((strlen(s1) + strlen(s2) - 1) % 2 == 1) {       printf( Impossible );       return 0;     }     if (left == right) {       if (strlen(s2) % 2 == 0) {         for (int j = 0; j < left; j++) printf( %c , s1[j]);         for (int j = 0; j < strlen(s2) / 2; j++) printf( %c , s2[j]);         printf( | );         for (int j = left + 1; j < l; j++) printf( %c , s1[j]);         for (int j = strlen(s2) / 2; j < strlen(s2); j++) printf( %c , s2[j]);         return 0;       } else {         printf( Impossible );         return 0;       }     }     if (left < right) {       if (right - left > strlen(s2)) {         printf( Impossible );         return 0;       } else {         long long dif = right - left;         dif += (strlen(s2) - dif) / 2;         for (int j = 0; j < left; j++) printf( %c , s1[j]);         for (int j = 0; j < dif; j++) printf( %c , s2[j]);         printf( | );         for (int j = left + 1; j < strlen(s1); j++) printf( %c , s1[j]);         for (int j = dif; j < strlen(s2); j++) printf( %c , s2[j]);         return 0;       }     }     if (right < left) {       if (left - right > strlen(s2)) {         printf( Impossible );         return 0;       } else {         long long dif = left - right;         dif = (strlen(s2) - dif) / 2;         for (int j = 0; j < left; j++) printf( %c , s1[j]);         for (int j = 0; j < dif; j++) printf( %c , s2[j]);         printf( | );         for (int j = left + 1; j < strlen(s1); j++) printf( %c , s1[j]);         for (int j = dif; j < strlen(s2); j++) printf( %c , s2[j]);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, x, y, z, ans = 0;     cin >> n >> x >> y >> z;     for (long long i = 0; i <= x / 2; i++) {       for (long long j = 0; j <= y; j++) {         if ((n - (i + j)) % 2 == 0 && (n - (i + j)) / 2 <= z &&             (n - (i + j)) / 2 >= 0)           ans++;       }     }     cout << ans;   }   int main() {     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int n, a, b, k, p[N];   int main() {     cin >> n >> a >> b >> k;     int sum = a + b;     for (int i = 1; i <= n; i++) {       cin >> p[i];       if (p[i] % sum == 0)         p[i] = sum;       else         p[i] %= sum;       p[i] -= a;     }     int ans = 0;     sort(p + 1, p + 1 + n);     for (int i = 1; i <= n; i++) {       if (p[i] <= 0)         ans++;       else {         int t = ceil(p[i] * 1.0 / a);         if (t <= k) k -= t, ans++;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t maxn = 1e3 + 42;   vector<int64_t> g[maxn];   int64_t par[maxn], sz[maxn];   basic_string<int64_t> leaves[maxn];   void dfs(int64_t v) {     sz[v] = 1;     for (auto u : g[v]) {       if (u != par[v]) {         par[u] = v;         dfs(u);         sz[v] += sz[u];         leaves[v] += leaves[u][0];       }     }     if (g[v].size() == 1) {       leaves[v] = {v};     }   }   vector<tuple<int64_t, int64_t, int64_t>> ans;   int64_t need[maxn];   tuple<int64_t, int64_t, int64_t> changers[maxn];   void change(int64_t v, int64_t added = 0) {     for (auto u : g[v]) {       if (u != par[v]) {         int64_t a, b, c;         tie(a, b, c) = changers[u];         int64_t d = need[u] - added * (a == leaves[v][0]);         ans.emplace_back(a, b, d / 2);         ans.emplace_back(a, c, d / 2);         ans.emplace_back(b, c, -d / 2);         change(u, added * (a == leaves[v][0]) + d);       }     }   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     int64_t n;     cin >> n;     int64_t u[n], v[n], val[n];     for (int64_t i = 1; i < n; i++) {       cin >> u[i] >> v[i] >> val[i];       u[i]--, v[i]--;       g[u[i]].push_back(v[i]);       g[v[i]].push_back(u[i]);     }     bool ok = true;     for (int64_t i = 0; i < n; i++) {       ok &= g[i].size() == 1 || g[i].size() >= 3;     }     if (!ok) {       cout <<  NO  << endl;     } else if (n == 2) {       cout <<  YES  << endl;       cout << 1 << endl;       cout << 1 <<     << 2 <<     << val[1] << endl;       return 0;     } else {       cout <<  YES  << endl;       int64_t root = 0;       while (g[root].size() == 1) {         root++;       }       par[root] = root;       dfs(root);       for (int64_t i = 1; i < n; i++) {         if (sz[u[i]] > sz[v[i]]) {           swap(u[i], v[i]);         }         int64_t a = leaves[u[i]][0];         int64_t b = 0;         while (leaves[v[i]][b] == a) {           b++;         }         int64_t c = b + 1;         b = leaves[v[i]][b];         while (c < (int64_t)leaves[v[i]].size() && leaves[v[i]][c] == a) {           c++;         }         if (c == (int64_t)leaves[v[i]].size()) {           int64_t w = par[v[i]];           c = 0;           while (leaves[w][c] == a || leaves[w][c] == b) {             c++;           }           c = leaves[w][c];         } else {           c = leaves[v[i]][c];         }         changers[u[i]] = {a, b, c};         need[u[i]] = val[i];       }       change(root);       cout << ans.size() << endl;       for (auto it : ans) {         int64_t a, b, c;         tie(a, b, c) = it;         cout << a + 1 <<     << b + 1 <<     << c << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d, h, i, j;   int main() {     cin >> n >> d >> h;     if (d > h * 2) {       cout << -1 << endl;       return 0;     }     if (d == 1 && h == 1 && n > 2) {       cout << -1 << endl;       return 0;     }     for (i = 1; i <= h; i++) cout << i <<     << i + 1 << endl;     if (d != 1 && d != h) {       cout << 1 <<     << i + 1 << endl;       i++;     }     int k = 1;     if (d == h) k++;     for (j = i; j <= d; j++) cout << j <<     << j + 1 << endl;     for (i = j + 1; i <= n; i++) cout << k <<     << i << endl;   }
#include <bits/stdc++.h>   using namespace std;   int dp[1000001];   int a[1000001];   vector<int> v[1000001];   vector<int> an;   int main() {     memset((dp), (0), sizeof(dp));     memset((a), (0), sizeof(a));     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       if (x <= m) {         a[x]++;         v[x].push_back(i + 1);       }     }     for (int i = 1; i <= m; i++) {       int x = i;       while (x <= m) {         dp[x] += a[i];         x += i;       }     }     int ans = -1, ind = -1;     for (int i = 1; i < 1000001; i++)       if (ans < dp[i]) ans = dp[i], ind = i;     printf( %d , ind);     printf(   );     printf( %d , dp[ind]);     printf(  n );     for (int i = 1; i <= m; i++)       if (ind % i == 0 && a[i] > 0)         for (int j : v[i]) an.push_back(j);     sort(an.begin(), an.end());     for (int i : an) printf( %d , i), printf(   );     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   long long int n, k, pres[300005], cont[300005];   vector<long long int> fcts[300005];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> k;     long long int tot = 0;     pres[1] = 1;     for (long long int i = 1; i <= n; ++i)       for (int j = 2 * i; j <= n; j += i) fcts[j].push_back(i);     for (long long int i = 2; i <= n; ++i) {       if (tot >= k) {         n = i - 1;         break;       }       tot += fcts[i].size();       cont[i] += fcts[i].size();       for (long long int v : fcts[i]) cont[v]++;       pres[i] = 1;     }     if (tot < k) {       cout <<  No n ;       return 0;     }     set<pair<long long int, long long int> > conts;     for (long long int i = 1; i <= n; ++i) conts.insert(make_pair(cont[i], i));     long long int rmv = tot - k;     while (rmv) {       auto it = conts.lower_bound(make_pair(rmv + 1, -1LL));       if (it == conts.begin()) {         cout <<  No n ;         return 0;       }       it--;       pair<long long int, long long int> xp = *it;       pres[xp.second] = 0;       rmv -= xp.first;       conts.erase(it);       for (long long int v : fcts[xp.second]) {         if (pres[v]) {           conts.erase(make_pair(cont[v], v));           cont[v]--;           conts.insert(make_pair(cont[v], v));         }       }       for (long long int v = 2 * xp.second; v <= n; v += xp.second)         if (pres[v]) {           conts.erase(make_pair(cont[v], v));           cont[v]--;           conts.insert(make_pair(cont[v], v));         }     }     cout <<  Yes n ;     vector<long long int> ans;     for (long long int i = 1; i <= n; ++i)       if (pres[i]) ans.push_back(i);     cout << ans.size() <<   n ;     for (long long int v : ans) cout << v <<    ;     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int qtd[200007];   int vogal(char ch) {     return ch ==  a  || ch ==  e  || ch ==  i  || ch ==  o  || ch ==  u  ||            ch ==  A  || ch ==  E  || ch ==  I  || ch ==  O  || ch ==  U ;   }   map<int, int> prim;   int main() {     string s;     cin >> s;     int resp = 0;     int qtdr = 0;     for (int i = 1; i <= s.length(); i++) {       qtd[i] = qtd[i - 1];       qtd[i] += vogal(s[i - 1]) ? -1 : 2;       if (qtd[i] >= 0)         resp = i;       else {         if (!prim.count(qtd[i])) prim[qtd[i]] = i;         resp = max(resp, i - prim[qtd[i]]);       }     }     if (resp == 0) {       cout <<  No solution n ;       return 0;     }     for (int i = resp; i <= s.length(); i++) {       if (qtd[i - resp] <= qtd[i]) qtdr++;     }     cout << resp <<     << qtdr <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long inf = 1e18;   const long double pie = acos((long double)-1);   int dx[] = {1, -1, 0, 0};   int dy[] = {0, 0, 1, -1};   unordered_map<int, vector<int>> mp;   int indegree[1001];   void addedge(int x, int y) {     mp[x].push_back(y);     mp[y].push_back(x);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     auto start = std::chrono::high_resolution_clock::now();     int n, m;     cin >> n >> m;     while (m--) {       int x, y;       cin >> x >> y;       x--;       y--;       addedge(x, y);     }     int cnt = 0;     for (auto x : mp) {       vector<int> v = x.second;       for (auto y : v) {         indegree[y]++;       }     }     while (true) {       int c = 0;       vector<int> ans;       for (int i = 0; i < n; ++i) {         if (indegree[i] == 1) {           ans.push_back(i);           indegree[i] = 0;           c++;         }       }       if (c != 0) {         cnt++;       }       for (auto x : ans) {         for (auto y : mp[x]) {           if (indegree[y] > 0) indegree[y]--;         }       }       int flag = 0;       for (int i = 0; i < n; ++i) {         if (indegree[i] == 1) {           flag++;           break;         }       }       if (flag == 0) {         break;       }     }     cout << cnt <<   n ;     auto stop = std::chrono::high_resolution_clock::now();     auto duration =         std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);     return 0;   }