malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   int main() {     ios_base::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     int q;     cin >> q;     for (int i = 0; i < q; i++) {       ll k, n, a, b;       cin >> k >> n >> a >> b;       if (k - n * b <= 0) {         cout << -1 <<   n ;         continue;       }       ll l = -1, r = n;       while (r - l > 1) {         ll m = (l + r) / 2;         if (k - m * b - (n - m) * a > 0) {           r = m;         } else {           l = m;         }       }       cout << n - r <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q, v;     cin >> q;     for (int i = 0; i < q; i++) {       cin >> v;       if (v == 2)         cout <<  2               <<   n ;       else {         if (v % 2)           cout <<  1                 <<   n ;         else           cout <<  0                 <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10, mod = 1e9 + 7;   const long long inf = 1e18;   unsigned int dp[maxn];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie();     int n, cnt = 0;     cin >> n;     string s;     cin >> s;     if (n & 1) return cout << 0 << endl, 0;     dp[0] = 1;     for (int i = 0; i < n; i++) {       if (s[i] !=  ? ) {         cnt++;         for (int j = i + 1; j >= 0; j -= 2) dp[j] = (j == 0 ? 0 : dp[j - 1]);       } else {         for (int j = i + 1; j >= 0; j -= 2)           dp[j] = dp[j + 1] + (j == 0 ? 0 : dp[j - 1]);       }     }     int num = (n - 2 * cnt) / 2;     unsigned int ans = dp[0];     for (int i = 0; i < num; i++) ans *= 25;     return cout << ans << endl, 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<int> v;     int n, i, j, k, len, x, y, c, a[1020] = {0};     cin >> n;     if (n == 1) {       cout <<  0  << endl;       return 0;     }     a[1] = 1;     for (i = 2; i <= 1000; i++) {       c = 2;       for (j = i * c; j <= 1000; j = i * c) {         a[j] = 1;         c++;       }     }     for (i = 2; i <= n; i++) {       if (a[i] == 0) {         for (j = i; j <= n; j = j * i) {           v.push_back(j);         }       }     }     cout << v.size() << endl;     for (i = 0; i < v.size(); i++) {       cout << v[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, t;   int visited[30009];   bool ok = false;   vector<int> C[30009];   void dfs(int u) {     if (u == t) {       ok = true;       return;     }     visited[u] = 1;     if (C[u].size())       for (int i = 0; i <= C[u].size() - 1; i++) {         int v = C[u][i];         if (!visited[v] && v <= n) {           dfs(v);           if (ok) return;         }       }   }   int main() {     scanf( %d%d , &n, &t);     for (int i = 1; i <= n - 1; i++) {       int x;       scanf( %d , &x);       C[i].push_back(x + i);     }     dfs(1);     if (ok)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> G[((int)2e5 + 10)];   int dis[((int)2e5 + 10)];   int n;   int ans = 0;   void dfs(int f, int son, int d) {     int flag = 0;     dis[son] = d;     for (int i = 0; i < G[son].size(); i++) {       if (G[son][i] == f) continue;       dfs(son, G[son][i], d + 1);       if (dis[G[son][i]] > 2) {         flag = 1;         dis[G[son][i]] = 2;         dis[son] = 1;         dis[f] = 2;       }     }     ans += flag;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n - 1; i++) {       int x, y;       scanf( %d %d , &x, &y);       G[x].push_back(y);       G[y].push_back(x);     }     dfs(-1, 1, 0);     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005, MAXT = 500, INF = 0x3f3f3f3f;   int mx[MAXT], add[MAXT], sz[MAXT], num[MAXT][MAXT], A[MAXN];   int N, T = 314;   void upd(int p) {     if (add[p]) {       for (int i = 0; i < sz[p]; ++i) num[p][i] += add[p];       add[p] = 0;     }   }   void ins(int x, int k) {     int p = x / T;     x = x % T;     for (int i = 0; i < p; ++i) add[i] += k, mx[i] += k;     upd(p);     for (int i = 0; i <= x; ++i) num[p][i] += k;     mx[p] = -INF;     for (int i = 0; i < sz[p]; ++i) mx[p] = max(mx[p], num[p][i]);   }   int query() {     int p = (N - 1) / T;     while (p >= 0 && mx[p] <= 0) p--;     if (p < 0) return -1;     upd(p);     int x = sz[p] - 1;     while (num[p][x] <= 0) x--;     return A[p * T + x];   }   int main() {     scanf( %d , &N);     int p = (N - 1) / T;     for (int i = 0; i < p; ++i) sz[i] = T;     sz[p] = (N - 1) % T + 1;     for (int i = 0; i < N; ++i) {       int a, b, c;       scanf( %d%d , &a, &b);       if (b) {         scanf( %d , &c);         A[a - 1] = c;         ins(a - 1, 1);         printf( %d n , query());       } else {         ins(a - 1, -1);         printf( %d n , query());       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-11;   long long n, l, v1, v2, k;   bool check(double tim) {     int tmp = n;     double t = 0;     double grx = 0, bus = 0;     while (tmp > 0) {       double del = l - grx;       if (del / v2 > tim + EPS / 100) {         return 0;       }       double x = (v1 * tim - del) * v2 * 1.0 / (v1 - v2);       double step = x / v2;       tim -= step;       bus += x;       tmp -= k;       if (tmp <= 0) break;       grx += step * v1;       double step2 = (bus - grx) / (v1 + v2);       grx += step2 * v1;       tim -= step2;       if (tim < -EPS / 100) return 0;       bus = grx;     }     return 1;   }   double bs(double lo, double hi) {     if ((hi - lo) <= EPS * 10 || (hi - lo) / hi <= EPS * 10) {       return lo;     }     double mid = (lo + hi) / 2;     if (check(mid)) {       return bs(lo, mid);     }     return bs(mid, hi);   }   int main() {     if (fopen( D.in ,  r )) freopen( D.in ,  r , stdin);     cin >> n >> l >> v1 >> v2 >> k;     cout << setprecision(10) << bs(0, 1e10);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[112];     int i;     for (i = 0; i < 4; i++) cin >> a[i];     sort(a, a + 4);     int tr = 0, seg = 0, im = 0;     if (a[1] + a[2] > a[3]) {       tr++;     } else if (a[0] + a[1] > a[3]) {       tr++;     } else if (a[0] + a[2] > a[3]) {       tr++;     } else if (a[0] + a[1] > a[2]) {       tr++;     } else if (a[0] + a[1] == a[2])       seg++;     else if (a[0] + a[2] == a[3])       seg++;     else if (a[1] + a[2] == a[3])       seg++;     else if (a[0] + a[1] == a[3])       seg++;     else       im++;     if (tr > 0)       cout <<  TRIANGLE  << endl;     else if (seg > 0)       cout <<  SEGMENT  << endl;     else if (im > 0)       cout <<  IMPOSSIBLE  << endl;   }
#include <bits/stdc++.h>   using namespace std;   void fast() {     ios_base::sync_with_stdio(NULL);     cin.tie(0);     cout.tie(0);   }   void online_judge() {     freopen( input.txt ,  r , stdin);     freopen( output.txt ,  w , stdout);   }   const int flag_max = 0x3f3f3f3f;   const long long OO = 1e9;   const double EPS = (1e-7);   int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }   long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }   int n, p;   int F = 0;   map<pair<int, int>, bool> check;   vector<pair<int, int>> pa_ir;   void dfs(int star) {     for (int i = star + 1; i <= n; i++) {       if (!check[{star, i}]) {         F++;         check[{star, i}] = 1;         check[{i, star}] = 1;         pa_ir.push_back({star, i});         dfs(i);       }     }   }   int main() {     fast();     int t;     cin >> t;     while (t--) {       cin >> n >> p;       p = 2 * n + p;       pa_ir.clear();       check.clear();       dfs(1);       sort(((pa_ir).begin()), ((pa_ir).end()));       for (int i = 0; i < p; i++) {         cout << pa_ir[i].first <<     << pa_ir[i].second <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std; namespace {       using T = long long;       constexpr char endl =   n ;       const int maxN = 205;       const int maxM = 1e5 + 5;       const T base = 100000;          T Ceil(T x, T y) {           return (x + y - 1) / y;       }          int n, m;       T t[maxN], x[maxN], y[maxN];       bool f[maxM];          int ans[maxM];          void Reach(int i, int x) {           if(!f[x])               ans[x] = i, f[x] = true;       }          void Solve() {           cin >> n >> m;           for(int i = 1; i <= n; i++)               cin >> t[i] >> x[i] >> y[i];           for(int i = 1; i <= m; i++)               ans[i] = -1;           f[0] = true;           for(int i = 1; i <= n; i++)                for(int j = m; j >= 0; j--) if(f[j]) {                   T now = j;                   for(int k = 1; k <= y[i]; k++) {                       if(t[i] == 1)   now += Ceil(x[i], base);                       else            now = Ceil(now * x[i], base);                       if(now > m || f[now])                           break;                       Reach(i, now);                   }               }           for(int i = 1; i <= m; i++)               cout << ans[i] <<    n [i == m];       }   }   int main() {       cin.tie(nullptr)->sync_with_stdio(false);       int t(1); //cin >> t;       for(int i = 1; i <= t; i++) Solve();       cout << flush;       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, maxi[((int)101 * 1000) / ((int)350) + 1000], fnsh, id[((int)101 * 1000)],       ex[((int)101 * 1000)];   vector<int> v[((int)101 * 1000) / ((int)350) + 1000];   void reset() {     int num = 0;     for (int i = 0; i < fnsh; v[i].clear(), v[i].resize(0), i++)       for (auto u : v[i]) ex[num++] = u;     fnsh = 0;     maxi[0] = 0;     for (int i = 0; i < num; i++) {       v[fnsh].push_back(ex[i]);       maxi[fnsh] = max(maxi[fnsh], ex[i]);       if (i % ((int)350) == ((int)350) - 1 || i == num - 1)         fnsh++, maxi[fnsh] = 0;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) {       int a, c;       cin >> a >> c;       id[a] = i + 1;       bool flg = 0;       for (int j = 0, num = 0; j < fnsh && !flg; num += (int)v[j].size(), j++)         if (num + (int)v[j].size() > c || maxi[j] > a) {           flg = 1;           for (int k = 0; k < v[j].size(); k++) {             if (v[j][k] > a) {               v[j].insert(v[j].begin() + k, a);               break;             }             if (k + num == c) {               v[j].insert(v[j].begin() + k, a);               maxi[j] = max(maxi[j], a);               break;             }           }         }       if (!flg) {         v[fnsh].push_back(a);         maxi[fnsh] = a;         fnsh++;       }       if (i % ((int)350) == ((int)350) - 1) reset();     }     for (int i = fnsh - 1; i >= 0; i--)       for (int j = (int)v[i].size() - 1; j >= 0; j--) cout << id[v[i][j]] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int _Int() {     int x;     scanf( %d , &x);     return x;   }   long long int bigMod(long long int A, long long int P, int M) {     long long int R = 1;     for (A %= M; P; P >>= 1) {       if (P & 1) R = (R * A) % M;       A = (A * A) % M;     }     return R;   }   long long int bigMul(long long int A, long long int B, long long int M) {     long long int R = 0;     for (A %= M; B; B >>= 1) {       if (B & 1) R = (R + A) % M;       A = (A + A) % M;     }     return R;   }   long long int negMod(long long int A, long long int B) {     return (((A % B) + B) % B);   }   unsigned long long int _pow(unsigned long long int A, int P) {     unsigned long long int R = 1;     for (; P; P >>= 1) {       if (P & 1) R = (R * A);       A = (A * A);     }     return R;   }   template <class T>   T GCD(T x, T y) {     while (x) x ^= y ^= x ^= y %= x;     return y;   }   bool isVowel(char c) {     if (c ==  A ) return 1;     if (c ==  E ) return 1;     if (c ==  I ) return 1;     if (c ==  O ) return 1;     if (c ==  U ) return 1;     if (c ==  Y ) return 1;     return 0;   }   char s[100 + 7];   void Main() {     scanf( %s , s + 1);     int left = 0;     int n = strlen(s + 1), mx = 1;     for (int i = 1; i <= n; i++) {       if (isVowel(s[i])) {         mx = max(mx, i - left);         left = i;       }     }     mx = max(mx, n + 1 - left);     printf( %d n , mx);   }   int main() {     Main();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string to_string(string s) { return     + s +    ; }   string to_string(char c) { return      + string(1, c) +     ; }   string to_string(const char *s) { return to_string((string)s); }   string to_string(bool b) { return (b ?  true  :  false ); }   template <typename A, typename B>   string to_string(pair<A, B> p) {     return  (  + to_string(p.first) +  ,   + to_string(p.second) +  ) ;   }   template <typename A>   string to_string(A v) {     bool first = true;     string res =  { ;     for (const auto &x : v) {       if (!first) res +=  ,  ;       first = false;       res += to_string(x);     }     res +=  } ;     return res;   }   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << to_string(H);     debug_out(T...);   }   const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};   string to_str(const int &n) {     ostringstream stm;     stm << n;     return stm.str();   }   string to_str(const long long &n) {     ostringstream stm;     stm << n;     return stm.str();   }   template <class T>   string tostring(T x, int len = 0) {     stringstream ss;     ss << x;     string r = ss.str();     if (int((r).size()) < len) r = string(len - int((r).size()),  0 ) + r;     return r;   }   template <class T>   void convert(string x, T &r) {     stringstream ss(x);     ss >> r;   }   long long powmod(long long a, long long b) {     long long res = 1;     a %= 1000000007;     for (; b; b >>= 1) {       if (b & 1) res = res * a % 1000000007;       a = a * a % 1000000007;     }     return res;   }   long long modinv(long long a) { return powmod(a, 1000000007 - 2); }   long long modinv(long long a, long long m) { return powmod(a, m - 2); }   long long nCkMp(long long n, long long k) {     long long numerator = 1, denominator = 1;     for (int i = 0; i < k; i++) numerator = (numerator * (n - i)) % 1000000007;     for (int i = 1; i <= k; i++) denominator = (denominator * i) % 1000000007;     return (numerator * modinv(denominator)) % 1000000007;   }   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }   int TT = 1, tt;   clock_t t1;   void solve() {     t1 = clock();     int n;     long long a;     long long b;     (cin >> (n));     vector<int> x(n);     for (auto i = (0); i < (n); i++) (cin >> (x[i]));     sort((x).begin(), (x).end());     b = x[n - 1];     a = accumulate((x).begin(), (x).end(), 0ll) - b;     (cout << (abs(a - b) + 1) << endl);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     for (tt = 0; tt < TT; tt++) solve();     return EXIT_SUCCESS;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     map<long long, vector<long long> > m;     map<long long, bool> v;     map<long long, long long> c;     vector<long long> b;     long long i, j, k, x, y, r;     for (i = 1; i <= n; i++) {       cin >> x >> y;       if (x == -1)         r = i;       else         m[x].push_back(i);       v[i] = false;       c[i] = y;     }     for (i = 1; i <= n; i++) {     }     queue<long long> q;     q.push(r);     long long f = 1;     while (!q.empty()) {       j = q.front();       if (c[j] == 1) f = 0;       for (i = 0; i < m[j].size(); i++) {         q.push(m[j][i]);         if (c[m[j][i]] != 1 and !f) {           f = 1;         }       }       if (f == 0) {         b.push_back(j);       }       f = 1;       q.pop();     }     if (b.size() == 0)       cout << -1;     else {       sort(b.begin(), b.begin() + b.size());       for (i = 0; i < b.size(); i++) {         cout << b[i] <<    ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const double eps = 1e-8;   const double PI = acos(-1.0);   const int maxn = 370360;   int dp[maxn], k, vis[maxn], sp[maxn], head, tail;   long long q[maxn];   int gcd(int x, int y) {     int tp = x % y;     while (tp) {       x = y;       y = tp;       tp = x % y;     }     return y;   }   int dfs(int x) {     int tp = INF, i;     if (dp[x] != -1) return dp[x];     for (i = 2; i <= k; i++)       if (x % i != 0) tp = min(dfs(x - x % i), tp);     tp = min(dfs(x - 1), tp);     return dp[x] = tp + 1;   }   int bfs(int st, int ed) {     int i;     memset(vis, 0, sizeof vis);     head = tail = 0;     vis[st] = 1;     q[tail] = st;     sp[tail++] = 0;     while (head < tail) {       if (q[head] == ed) return sp[head];       for (i = 2; i <= k; i++) {         if (!vis[q[head] - q[head] % i]) {           vis[q[head] - q[head] % i] = 1;           q[tail] = q[head] - q[head] % i;           sp[tail++] = sp[head] + 1;         }       }       if (!vis[q[head] - 1]) {         vis[q[head] - 1] = 1;         q[tail] = q[head] - 1;         sp[tail++] = sp[head] + 1;       }       head++;     }     return -1;   }   int main() {     int i, mc;     long long a, b, df, ans, rep;     while (~scanf( %I64d%I64d%d , &a, &b, &k)) {       mc = 1, ans = 0;       for (i = 2; i <= k; i++) mc = (mc * i) / gcd(mc, i);       for (i = 1; i < mc; i++) dp[i] = -1;       dp[0] = 0;       for (i = 1; i < mc; i++) dfs(i);       if (a - a % mc > b) ans += dp[a % mc], a -= a % mc;       df = a - b;       rep = df / mc;       a = a - rep * mc;       ans += rep * (1 + dp[mc - 1]);       df = a - b;       if (df > 0) {         if (a % mc == 0)           ans += bfs((a - 1) % mc, b % mc) + 1;         else           ans += bfs(a % mc, b % mc);       }       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int size = 1e5 + 10;   int afx[size];   int dis[size];   int main() {     int n, k;     scanf( %d%d , &n, &k);     int total = 0;     int ans = 0;     for (int i = 0; i < n; i++) {       scanf( %d , afx + i);       dis[i] = 10 - afx[i] % 10;       total += dis[i];       ans += afx[i] / 10;     }     if (k <= total) {       sort(dis, dis + n);       int i = 0;       while (k && i < n) {         k -= dis[i];         if (k < 0) break;         ans++;         i++;       }       printf( %d n , min(10 * n, ans));       return 0;     }     k -= total;     ans += n;     ans += k / 10;     printf( %d n , min(10 * n, ans));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int d[100];   int main() {     int n, a, b, c = 0;     cin >> n;     for (int i = 1; i < n; i++) {       cin >> d[i];     }     cin >> a >> b;     for (int i = a; i < b; i++) {       c += d[i];     }     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1005, maxd = 15;   int f[maxn], g[maxn][maxd][maxn], rfac[maxn], n, d, mo;   int pow(int a, int b) {     int tmp = 1;     for (; b; b >>= 1, a = a * 1ll * a % mo)       if (b & 1) tmp = tmp * 1ll * a % mo;     return tmp;   }   int main() {     cin >> n >> d >> mo;     if (n == 1) {       cout << 1 << endl;       return 0;     }     rfac[0] = 1;     for (int i = 1; i <= 1000; i++)       rfac[i] = rfac[i - 1] * 1ll * pow(i, mo - 2) % mo;     for (int i = 0; i <= n; i++) g[0][0][i] = 1;     for (int i = 1; i <= n; i++) {       if (i != 1)         f[i] = g[i - 1][d - 1][n];       else         f[i] = 1;       for (int dd = 1; dd <= d; dd++) {         for (int x = 1; x <= i; x++) {           int v = f[x];           for (int k = 1, cv = 1; k <= dd && x * k <= i; k++) {             cv = cv * 1ll * (v + k - 1) % mo;             g[i][dd][x] = (g[i][dd][x] + g[i - x * k][dd - k][x - 1] * 1ll * cv %                                              mo * rfac[k] % mo) %                           mo;           }         }         for (int x = 1; x <= n; x++)           g[i][dd][x] = (g[i][dd][x] + g[i][dd][x - 1]) % mo;       }     }     int ans = g[n - 1][d][(n - 1) / 2];     if (!(n & 1)) {       int v = f[n / 2];       ans = (ans + v * 1ll * (v + 1) % mo * rfac[2] % mo) % mo;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1000 * 100 + 1;   const long long INF = 1e12;   const int MOD = 1000 * 1000 * 1000 + 7;   const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};   const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};   const int MAXN = 2 * 1000 * 100 + 1;   struct edge {     int to, w;   };   int n, m;   vector<edge> g[MAXN];   long long dist[MAXN];   int par[MAXN];   set<pair<long long, int> > s;   vector<int> ans;   edge e;   int main() {     scanf( %d %d , &n, &m);     for (int i = 1; i <= m; i++) {       int a, b, w;       scanf( %d %d %d , &a, &b, &w);       e.to = b;       e.w = w;       g[a].push_back(e);       e.to = a;       g[b].push_back(e);     }     s.insert(make_pair(0, 1));     for (int i = 2; i <= n; i++) {       dist[i] = INF;       s.insert(make_pair(INF, i));     }     while (!s.empty()) {       int cur = s.begin()->second;       long long cur_dist = s.begin()->first;       s.erase(s.begin());       for (int i = 0; i < (int)g[cur].size(); i++) {         int to = g[cur][i].to, w = g[cur][i].w;         if (cur_dist + w < dist[to]) {           s.erase(make_pair(dist[to], to));           dist[to] = cur_dist + w;           par[to] = cur;           s.insert(make_pair(dist[to], to));         }       }     }     if (dist[n] == INF) {       printf( -1 );       return 0;     }     int cur = n;     while (par[cur] != 0) {       ans.push_back(cur);       cur = par[cur];     }     ans.push_back(1);     reverse(ans.begin(), ans.end());     for (int i = 0; i < (int)ans.size(); i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T, n, m, u, v, lab[300001];   vector<int> g[300001];   long long cnt[3];   long long const mod = 998244353;   bool impossible;   void DFS(const int& u) {     for (const int& v : g[u])       if (!lab[v]) {         lab[v] = 3 - lab[u];         cnt[lab[v]]++;         DFS(v);         if (impossible) return;       } else if (lab[v] == lab[u]) {         impossible = true;         return;       }   }   long long Pow(const long long& k) {     if (k == 0) return 1;     long long tmp = Pow(k / 2);     if (k % 2 == 0)       return tmp * tmp % mod;     else       return 2 * tmp * tmp % mod;   }   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d%d , &n, &m);       for (int i = 1; i <= n; i++) {         g[i].clear();         lab[i] = 0;       }       while (m--) {         scanf( %d%d , &u, &v);         g[u].push_back(v);         g[v].push_back(u);       }       long long res = 1;       impossible = false;       for (int i = 1; i <= n && !impossible; i++)         if (!lab[i]) {           lab[i] = 1;           cnt[1] = 1;           cnt[2] = 0;           DFS(i);           res = res * ((Pow(cnt[1]) + Pow(cnt[2])) % mod) % mod;         }       if (impossible)         cout << 0 <<   n ;       else         cout << res <<   n ;     }   }