malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void input(long long int n, long long int a[]) {     for (long long int i = 0; i < n; ++i) cin >> a[i];   }   long long int bin_expo(long long int A, long long int B, long long int M) {     long long int result = 1ll;     while (B > 0) {       if (B % 2 == 1) {         result = (result * A) % M;       }       A = (A * A) % M;       B = B / 2;     }     return result;   }   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long int lcm(long long int a, long long int b) {     return (a * b) / gcd(a, b);   }   long long int n, l;   long long int a[101], b[101];   long long int dp[4001][200][3];   long long int solve(long long int left, long long int prev,                       long long int flag) {     if (left < 0) return 0LL;     if (left == 0) return 1LL;     if (dp[left][prev][flag] != -1) return dp[left][prev][flag];     long long int res = 0;     if (prev == -1) {       for (long long int i = 0; i < n; ++i) {         res += solve(left - a[i], i, 2);         if (a[i] != b[i]) res += solve(left - b[i], i, 1);         res %= 1000000007;       }     } else {       for (long long int i = 0; i < n; ++i) {         if (i != prev) {           long long int cur;           if (flag == 1) cur = a[prev];           if (flag == 2) cur = b[prev];           if (a[i] == cur)             res += solve(left - a[i], i, 2);           else if (b[i] == cur)             res += solve(left - b[i], i, 1);           res %= 1000000007;         }       }     }     return dp[left][prev][flag] = res % 1000000007;   }   int main() {     memset(dp, -1, sizeof(dp));     cin >> n >> l;     for (long long int i = 0; i < n; ++i) cin >> a[i] >> b[i];     cout << solve(l, -1, 0) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int sum, t, p, pos, a[100005], b[100005], n, f, c, f1;     cin >> t;     while (t--) {       memset(a, 0, sizeof(a));       memset(b, 0, sizeof(b));       cin >> n;       f = 1;       sum = 0;       p = 0;       f1 = 1, c = 0;       for (int i = 0; i < n; i++) cin >> a[i];       for (int i = 0; i < n; i++) cin >> b[i];       for (int i = 0; i < n; i++) {         if (f == 1 && a[i] != b[i]) {           if (p == 0) pos = i, p = 1, c = b[i] - a[i];           sum++;           f = 0;         } else if (a[i] > b[i])           f1 = 0;         else if (a[i] == b[i])           f = 1;       }       if (sum >= 2) {         cout <<  NO  << endl;       } else if (f1 == 0 || c < 0)         cout <<  NO  << endl;       else {         if (sum == 0)           cout <<  YES  << endl;         else {           for (int i = pos; a[i] != b[i]; i++) {             if (b[i] - a[i] != c) f1 = 0;           }           if (f1 == 0)             cout <<  NO  << endl;           else             cout <<  YES  << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int left_[105], right_[105], mark[105];   int main() {     int n, j;     std::ios::sync_with_stdio(0);     while (~scanf( %d , &n)) {       int ans = 0;       memset(left_, 0, sizeof(left_));       memset(right_, 0, sizeof(right_));       memset(mark, 0, sizeof(mark));       for (int i = 1; i <= n; i++) {         scanf( %d %d , &left_[i], &right_[i]);         if (left_[i] == 0) mark[++ans] = i;       }       for (int i = 1; i < ans; i++) {         for (j = mark[i]; right_[j] != 0; j = right_[j])           ;         left_[mark[i + 1]] = j;         right_[j] = mark[i + 1];       }       for (int i = 1; i <= n; i++) printf( %d %d n , left_[i], right_[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int f, int s) {     if (s == 0)       return f;     else       return gcd(s, f % s);   }   int const N = 1000006;   long long const M = 1020;   long double const ep = .000000000000000001;   long long arr[N], arr1[N];   int main() {     int n, m;     scanf( %d , &n);     long long sum = 0, sum1 = 0;     for (int i = 0; i < n; i++) {       scanf( %lld , arr + i);       sum += arr[i];     }     scanf( %d , &m);     for (int i = 0; i < m; i++) {       scanf( %lld , arr1 + i);       sum1 += arr1[i];     }     if (sum == sum1) {       printf( 0 n0 );       return 0;     }     long long best = abs(sum - sum1);     int ind = -1, ind1 = -1;     for (int i = 0; i < n; i++) {       long long temp = sum, temp1 = sum1;       for (int x = 0; x < m; x++) {         temp -= arr[i];         temp += arr1[x];         temp1 -= arr1[x];         temp1 += arr[i];         if (abs(temp - temp1) < best) {           ind = i + 1, ind1 = x + 1;           best = abs(temp - temp1);         }         temp = sum, temp1 = sum1;       }     }     int indd = -1, indd1 = -1, indd2 = -1, indd21 = -1;     vector<pair<long long, pair<int, int> > > v, v1;     for (int i = 0; i < n; i++)       for (int x = i + 1; x < n; x++)         v.push_back(make_pair(arr[i] + arr[x], make_pair(i, x)));     for (int i = 0; i < m; i++)       for (int x = i + 1; x < m; x++)         v1.push_back(make_pair(arr1[i] + arr1[x], make_pair(i, x)));     sort(v1.begin(), v1.end());     long long want = (sum - sum1) / 2;     long long test = 1e17;     long long num = -1;     for (int i = 0; i < v.size(); i++) {       int left = 0, right = v1.size() - 1, mid;       while (left <= right) {         mid = (left + right) / 2;         long long curr = v[i].first - v1[mid].first;         if (test > abs(curr - want)) {           test = abs(curr - want);           num = curr;           indd = v[i].second.first + 1, indd1 = v[i].second.second + 1;           indd2 = v1[mid].second.first + 1, indd21 = v1[mid].second.second + 1;         }         if (curr > want)           left = mid + 1;         else           right = mid - 1;       }     }     long long s = sum, s1 = sum1;     s -= num;     s1 += num;     if (ind == -1 && indd == -1) {       printf( %lld n0 , best);       return 0;     }     if (best > abs(s - s1)) {       printf( %lld n , abs(s - s1));       printf( 2 n%d %d n%d %d , indd, indd2, indd1, indd21);     } else {       printf( %lld n , best);       printf( 1 n%d %d , ind, ind1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fact[100005];   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = ((res % p) * (x % p)) % p;       y = y >> 1;       x = ((x % p) * (x % p)) % p;     }     return res;   }   long long modInverse(long long n, long long p) { return power(n, p - 2, p); }   long long nCrModFermat(long long n, long long r, long long p) {     if (r == 0 || r == n) return 1;     return (((fact[n] % p) * (modInverse(fact[r], p) % p)) % p *             (modInverse(fact[n - r], p) % p)) %            p;   }   void sieve(vector<bool> &isPrime) {     long long n = isPrime.size();     isPrime[0] = false;     isPrime[1] = false;     for (long long i = 2; i * i <= n; i++) {       if (isPrime[i] == true) {         for (long long j = i * i; j <= n; j += i) isPrime[j] = false;       }     }   }   void addEdge(vector<long long> adj[], long long u, long long v) {     adj[u].push_back(v);     adj[v].push_back(u);   }   void BFS(long long s, vector<long long> adj[], vector<bool> &visited) {     deque<long long> q;     q.push_back(s);     visited[s] = true;     cout << s <<    ;     while (!q.empty()) {       long long p = q.front();       q.pop_front();       for (long long i = 0; i < adj[p].size(); i++) {         if (visited[adj[p][i]] == false) {           q.push_back(adj[p][i]);           visited[adj[p][i]] = true;           cout << adj[p][i] <<    ;         }       }     }   }   void DFSUtil(long long u, vector<long long> adj[], vector<bool> &visited) {     visited[u] = true;     cout << u <<    ;     for (long long i = 0; i < adj[u].size(); i++)       if (visited[adj[u][i]] == false) DFSUtil(adj[u][i], adj, visited);   }   void DFS(vector<long long> adj[], long long V) {     vector<bool> visited(V, false);     for (long long u = 0; u < V; u++)       if (visited[u] == false) DFSUtil(u, adj, visited);   }   void ChubbyCoder() {     long long n;     cin >> n;     cout << n <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long t;     t = 1;     cin >> t;     while (t--) {       ChubbyCoder();     }   }
#include <bits/stdc++.h>   using namespace std;   bool seat[100][100] = {0};   int main() {     int n, k;     scanf( %d %d , &n, &k);     while (n--) {       int num, x, l, r, min_sum;       min_sum = 100000;       scanf( %d , &num);       for (int i = 1; i <= k; i++) {         for (int j = 1; j <= k - num + 1; j++) {           int flag, sum;           sum = 0;           flag = 0;           for (int m = j; m <= j + num - 1; m++) {             if (seat[i][m]) {               flag = 1;               break;             }             sum += abs(i - k / 2 - 1) + abs(m - k / 2 - 1);           }           if (flag == 0 && sum < min_sum) {             x = i;             l = j;             r = j + num - 1;             min_sum = sum;           }         }       }       if (min_sum == 100000)         printf( -1 n );       else {         printf( %d %d %d n , x, l, r);         for (int i = l; i <= r; i++) seat[x][i] = 1;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n % 2 == 0) {       if (n >= 8 && n % 4 == 0)         cout << ((n / 4) - 1) << endl;       else if (n > 4 && n < 8)         cout <<  1  << endl;       else if (n <= 4)         cout <<  0  << endl;       else         cout << (n / 4) << endl;     } else {       cout <<  0  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, shet = 0;     long long int ans = 0;     cin >> n;     ans = n;     int* mas = new int[n];     for (int i = 0; i < n; i++) {       cin >> mas[i];     }     for (int i = 1; i < n; i++) {       if (mas[i] == mas[i - 1]) {         shet++;         ans += shet;       } else {         shet = 0;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     int a, i, temp;     long long int sum = 0, n, fra;     cin >> a;     for (i = 2; i <= a - 1; i++) {       temp = a;       while (temp > 0) {         sum += temp % i;         temp = temp / i;       }     }     temp = a - 2;     fra = gcd(sum, temp);     while (fra != 1) {       sum = sum / fra;       temp = temp / fra;       fra = gcd(sum, temp);     }     cout << sum <<  /  << temp << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     while (scanf( %d%d , &n, &m) != EOF) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (i % 2 == 0) {             printf( # );           } else {             if (i / 2 % 2 == 0 && j == m - 1)               printf( # );             else if (i / 2 % 2 != 0 && j == 0)               printf( # );             else               printf( . );           }         }         puts(  );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const int M = 1e5 + 5;   const int N = 1e6 + 5;   const int mod = 1e9 + 7;   const double pi = acos(-1.0);   const int INF = 0x3f3f3f3f;   const long long lINF = 0x3f3f3f3f3f3f3f3fLL;   const int sINF = 0xcfcfcfcf;   char s[M * 2], s1[M];   int mx, tmp, len;   int main() {     scanf( %s , s1);     len = strlen(s1);     mx = tmp = 1;     strcpy(s, s1);     strcat(s + len, s1);     for (int i = 1; i < len * 2; i++) {       if (s[i] == s[i - 1]) {         mx = max(mx, tmp);         tmp = 1;       } else {         tmp++;         mx = max(mx, tmp);       }     }     mx = min(mx, len);     printf( %d n , mx);   }
#include <bits/stdc++.h>   using namespace std;       #define ll long long   #define vi vector<int>   #define pii pair<int,int>   #define mii map<int,int>   #define pqb priority_queue<int>   #define pqs priority_queue<int,vi,greater<int> >       #define ff first   #define ss second   #define pb push_back   #define mp make_pair   #define PI 3.1415926535897932384626   #define MOD 1000000007   #define ps(x,y) fixed<<setprecision(y)<<x      long long int fact[200005];      long long int pwr(long long int a,long long int b){       if(b==0) return 1;       if(b==1) return a%MOD;       long long int q = pwr((a*a)%MOD,b/2);       if(b%2) return (q*a)%MOD;       return q;   }      long long int C(long long int a,long long int b){       if(b<0) return 0;       if(a<b) return 0;          long long int t1 = (fact[a])%MOD;       long long int t2 = (fact[b]*fact[a-b])%MOD;       t2 = pwr(t2,MOD-2)%MOD;          return (t1*t2)%MOD;   }      void solve(){          long long int n,l,r;       cin>>n>>l>>r;          long long int ans=0;       ans = C(n,n/2)%MOD;       if(n%2) ans = (ans*2)%MOD;       ans = (ans*(min(1-l,r-n)))%MOD;        for(long long int p=min(1-l,r-n)+1;p<=min(r,n+1-l);p++){           long long int a = p + l - 1;           if(a<=0) a = 0;           long long int b = n + p - r;           if(b<=0) b=0;              ans = (C(n-a-b,n/2-a) + ans)%MOD;           if(n%2) ans = (C(n-a-b,n/2-b) + ans)%MOD;       }       cout<<ans<<endl;          return;       }        int main(){          ios_base::sync_with_stdio(false);       cin.tie(NULL);           // freopen( input.txt ,  r , stdin);       // freopen( error.txt ,  w , stderr);       // freopen( output.txt ,  w , stdout);          fact[0]=1;       for(long long int i=1;i<200005;i++){           fact[i] = (fact[i-1]*i)%MOD;       }           int t=1;       cin>>t;           for(int i=1;i<=t;i++){           // cout<< Case # <<i<< :  ;           solve();       }           cerr <<  time taken :   << (float)clock() / CLOCKS_PER_SEC <<   secs  << endl;       return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[10000];   int n, m, Q;   map<string, int> mem;   map<string, int>::iterator iter;   struct Func {     string name;     int num;     int v[10];     bool operator==(const Func& A) const {       if (name != A.name) return false;       if (num != A.num) return false;       for (int i = 0; i < num; ++i)         if (v[i] * A.v[i] != 0 && v[i] != A.v[i]) return false;       return true;     }   } g[2000], pre;   int Type(string x) {     if (x ==  T ) return 0;     if (x ==  int ) return 1;     if (x ==  double ) return 2;     if (x ==  string ) return 3;     return -1;   }   void inputFunc(int gs) {     gets(str);     int i = 0, j = 0, len = strlen(str);     while (str[j] !=  d ) ++j;     ++j;     while (j < len) {       if (str[j] !=    ) str[i++] = str[j];       j++;     }     len = i;     i = 0;     g[gs].name =   ;     while (str[i] !=  ( ) {       g[gs].name += str[i];       i++;     }     string temp =   ;     i++;     for (;;) {       if (str[i] ==  ,  || str[i] ==  ) ) {         g[gs].v[g[gs].num++] = Type(temp);         temp =   ;         if (str[i] ==  ) ) break;       } else         temp += str[i];       i++;     }   }   void inputType() {     string a, b;     cin >> a >> b;     mem[b] = Type(a);   }   void solve() {     gets(str);     int i = 0, j = 0, len = strlen(str);     for (j = 0; j < len; ++j) {       if (str[j] !=    ) str[i++] = str[j];     }     len = i;     i = 0;     pre.name =   ;     pre.num = 0;     while (str[i] !=  ( ) {       pre.name += str[i];       i++;     }     string temp =   ;     i++;     for (;;) {       if (str[i] ==  ,  || str[i] ==  ) ) {         pre.v[pre.num++] = mem.find(temp)->second;         temp =   ;         if (str[i] ==  ) ) break;       } else         temp += str[i];       i++;     }     int ans = 0;     for (int i = 0; i < n; ++i)       if (pre == g[i]) ++ans;     printf( %d n , ans);   }   int main() {     scanf( %d , &n);     gets(str);     for (int i = 0; i < n; ++i) inputFunc(i);     scanf( %d , &m);     gets(str);     mem.clear();     while (m--) inputType();     scanf( %d , &Q);     gets(str);     while (Q--) solve();   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   int main() {     long long n, a;     long long fuck = 0, fucck = 0;     cin >> n;     priority_queue<int> prio1, prio2;     for (int i = 0; i < n; ++i) {       cin >> a;       prio1.push(a);       fuck += a;     }     for (int i = 0; i < n; ++i) {       cin >> a;       prio2.push(a);       fucck += a;     }     prio1.push(-1);     prio2.push(-1);     long long sum1 = 0, sum2 = 0;     int mark = 1;     for (int i = 0; i < 2 * n; ++i) {       if (mark == 1) {         if (prio1.top() >= prio2.top()) {           fuck -= prio1.top();           sum1 += prio1.top();           prio1.pop();         } else {           fucck -= prio2.top();           prio2.pop();         }         mark = 2;       } else {         if (prio2.top() >= prio1.top()) {           fucck -= prio2.top();           sum2 += prio2.top();           prio2.pop();         } else {           fuck -= prio1.top();           prio1.pop();         }         mark = 1;       }     }     cout << (sum1 - sum2) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<char, int> check(string s) {     map<char, int> used;     int l = s.size(), i, maxVal = 0;     char ans;     for (i = 0; i < l; i++) {       used[s.at(i)]++;       if (used[s.at(i)] > maxVal) {         maxVal = used[s.at(i)];         ans = s.at(i);       }     }     return make_pair(ans, maxVal);   }   int execute() {     int n, i, diff[4] = {0}, minVal = 10e8 + 7;     cin >> n;     vector<pair<char, int> > val(4);     string a[3];     for (i = 0; i < 3; i++) {       cin >> a[i];       val[i] = check(a[i]);       diff[i] = a[i].size() - val[i].second;       diff[i] = max(0 + (diff[i] + 1 == n && !diff[i]), diff[i] - n);       minVal = min(minVal, diff[i]);     }     int index;     for (i = 0; i < 3; i++) {       if (minVal == diff[i]) {         index = i;       }     }     sort(diff, diff + 3);     if (diff[0] == diff[1])       cout <<  Draw  << endl;     else {       switch (index) {         case (0):           cout <<  Kuro  << endl;           break;         case (1):           cout <<  Shiro  << endl;           break;         default:           cout <<  Katie  << endl;       }     }     return 0;   }   char mtest = false;   unsigned short TE = 1;   int main() {     ios_base::sync_with_stdio(false);     if (mtest) cin >> TE;     while (TE--) execute();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 1;   long long a[4], mn = 1e12 + 1;   char b, c, d;   int main() {     cin >> a[0] >> a[1] >> a[2] >> a[3];     cin >> b >> c >> d;     sort(a, a + 4);     do {       long long first, second, temp;       if (b ==  + )         first = a[0] + a[1];       else         first = a[0] * a[1];       long long a1[3];       a1[0] = first;       a1[1] = a[2];       a1[2] = a[3];       sort(a1, a1 + 3);       do {         if (c ==  + )           second = a1[0] + a1[1];         else           second = a1[0] * a1[1];         if (d ==  + )           temp = second + a1[2];         else           temp = second * a1[2];         mn = min(mn, temp);       } while (next_permutation(a1, a1 + 3));     } while (next_permutation(a, a + 4));     cout << mn;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[100010];   typedef struct record {     char ch;     int po;   } rec;   int main() {     int leng, ans, l, r;     rec tmp1, tmp2;     int tmp3;     bool flag;     stack<rec> st;     while (~scanf( %s , s)) {       flag = false;       while (!st.empty()) st.pop();       leng = strlen(s);       for (int i = 0; i < leng; i++) {         if (!st.empty()) tmp2 = st.top();         if (!st.empty() && ((tmp2.ch ==  (  && s[i] ==  ) ) ||                             (tmp2.ch ==  [  && s[i] ==  ] ))) {           st.pop();         } else {           tmp1.ch = s[i];           tmp1.po = i;           st.push(tmp1);         }       }       ans = 0;       if (st.empty()) {         for (int i = 0; i < leng; i++)           if (s[i] ==  [ ) ans++;         printf( %d n%s n , ans, s);       } else {         bool once = true;         flag = false;         ans = -1;         int tmpr, tmpl;         while (st.size() != 0) {           tmp3 = 0;           if (once) {             tmpr = leng - 1;             tmpl = st.top().po + 1;             once = false;           } else {             if (st.size() != 1) {               tmpr = st.top().po - 1;               st.pop();               tmpl = st.top().po + 1;             } else {               tmpr = st.top().po - 1;               tmpl = 0;               st.pop();             }           }           if (tmpl < tmpr) {             flag = true;             for (int j = tmpl; j <= tmpr; j++)               if (s[j] ==  [ ) tmp3++;           }           if (tmp3 > ans) {             ans = tmp3;             l = tmpl;             r = tmpr;           }         }         if (flag) {           printf( %d n , ans);           for (int i = l; i <= r; i++) printf( %c , s[i]);           printf(  n );         } else           printf( 0 n );       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const int INF = 0x3f3f3f3f;   const long long inf = 0x3f3f3f3f3f3f3f3f;   const int mod = 1e9 + 7;   const int maxn = 1e3 + 5;   int n, m, qq, s[maxn][maxn], f[maxn][maxn];   bool vis[maxn][maxn];   int a[4] = {0, 1, 0, -1};   int b[4] = {-1, 0, 1, 0};   bool judge(int x, int y) {     for (int i = 0; i <= 3; i++) {       int xx = x + a[i], yy = y + b[i];       if (xx <= 0 || xx > n || yy <= 0 || yy > m) continue;       if (s[xx][yy] == s[x][y]) return true;     }     return false;   }   void bfs() {     queue<pair<int, int> > q;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (judge(i, j)) {           vis[i][j] = 1;           f[i][j] = 0;           q.push({i, j});         }       }     }     while (!q.empty()) {       int x = q.front().first;       int y = q.front().second;       q.pop();       for (int i = 0; i <= 3; i++) {         int xx = x + a[i], yy = y + b[i];         if (xx <= 0 || xx > n || yy <= 0 || yy > m) continue;         if (vis[xx][yy]) continue;         f[xx][yy] = f[x][y] + 1;         vis[xx][yy] = 1;         q.push({xx, yy});       }     }   }   int main() {     scanf( %d%d%d , &n, &m, &qq);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         scanf( %1d , &s[i][j]);       }     }     bfs();     while (qq--) {       int x, y;       long long t;       scanf( %d%d%lld , &x, &y, &t);       if (vis[x][y]) {         if (t < f[x][y])           printf( %d n , s[x][y]);         else           printf( %d n , s[x][y] ^ ((t - f[x][y]) & 1));       } else {         printf( %d n , s[x][y]);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   vector<int> adj[100005];   vector<int> vis(100005, 1);   vector<int> ans;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     for (int qq = 1; qq <= T; qq++) {       cin >> n >> m;       for (int i = 0; i < m; i++) {         int x, y;         cin >> x >> y;         adj[x].push_back(y);         adj[y].push_back(x);       }       priority_queue<int> v;       v.push(-1);       vis[1] = 0;       while (!v.empty()) {         int u = -v.top();         v.pop();         ans.push_back(u);         for (auto i : adj[u])           if (vis[i]) v.push(-i), vis[i] = 0;       }       for (auto i : ans) cout << i <<    ;       cout << endl;     }     return 0;   }