malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   template <typename T>   void etch(T V) {     for (auto x : V) cout << x <<    ;     cout <<   n ;   }   vector<string> vec_splitter(string s) {     s +=  , ;     vector<string> res;     while (!s.empty()) {       res.push_back(s.substr(0, s.find( , )));       s = s.substr(s.find( , ) + 1);     }     return res;   }   void debug_out(vector<string> __attribute__((unused)) args,                  __attribute__((unused)) long long int idx,                  __attribute__((unused)) long long int LINE_NUM) {     cerr << endl;   }   template <typename Head, typename... Tail>   void debug_out(vector<string> args, long long int idx, long long int LINE_NUM,                  Head H, Tail... T) {     if (idx > 0)       cerr <<  ,  ;     else       cerr <<  Line(  << LINE_NUM <<  )  ;     stringstream ss;     ss << H;     cerr << args[idx] <<   =   << ss.str();     debug_out(args, idx + 1, LINE_NUM, T...);   }   const long long int MOD = 1e9 + 7;   const long long int MOD1 = 998244353;   const long long int N = 2e5 + 5;   const long long int INF = 1000111000111000111LL;   const long double EPS = 1e-12;   const long double PI = 3.141592653589793116;   long long int d[3005][3005], p[3005][3005];   void solve() {     long long int n;     cin >> n;     long long int a[n + 5];     for (long long int i = 1; i <= n; i++) cin >> a[i];     for (long long int i = 0; i <= n + 2; i++) {       for (long long int j = 0; j <= n + 2; j++) {         d[i][j] = p[i][j] = 0;       }     }     for (long long int i = 1; i <= n; i++) {       d[i][a[i]]++;       for (long long int j = 0; j <= n; j++) {         d[i][j] += d[i - 1][j];       }     }     for (long long int i = n; i >= 1; i--) {       p[i][a[i]]++;       for (long long int j = 0; j <= n; j++) {         p[i][j] += p[i + 1][j];       }     }     long long int ans = 0;     for (long long int i = 1; i <= n; i++) {       for (long long int j = i + 1; j <= n; j++) {         ans += (d[i - 1][a[j]] * p[j + 1][a[i]]);       }     }     cout << ans <<   n ;   }   int32_t main() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long int T;     cin >> T;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MaxN = 4010;   const int MOD = 1000000009;   int n, w, b;   long long p[MaxN], r[MaxN];   long long power(long long x, long long y) {     if (!y) return 1;     long long t = power(x, y / 2);     t = t * t % MOD;     if (y & 1) t = t * x % MOD;     return t;   }   long long C(long long n, long long m) {     return p[n] * r[m] % MOD * r[n - m] % MOD;   }   int main() {     cin >> n >> w >> b;     for (int i = p[0] = r[0] = 1; i < MaxN; ++i) {       p[i] = p[i - 1] * i % MOD;       r[i] = power(p[i], MOD - 2);     }     long long ans = 0;     for (int i = max(1, n - w); i <= min(n - 2, b); ++i)       ans += p[w] * p[b] % MOD * (n - i - 1) % MOD * C(b - 1, i - 1) % MOD *              C(w - 1, n - i - 1) % MOD;     cout << ans % MOD << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<long long int> v(1000005);     long long int i, n, j;     for (i = 2; i < 1000005; i++) {       j = i * 2;       while (j <= 1000005) {         v[j] = 1;         j += i;       }     }     cin >> n;     j = 1;     for (j = 1; j < 1001; j++) {       if (v[n * j + 1] != 0) {         cout << j;         break;       }     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int maxn = 1e5 + 5;   int n, a[maxn];   int b[maxn];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     int sum = 0;     map<int, int> mp;     for (int i = 0; i < n; i++) {       cin >> a[i];       mp[a[i]]++;     }     bool poss = false;     for (int i = 0; i < n; i++) {       if (a[i] > 0) {         if (--mp[a[i]] == 0) mp.erase(a[i]);         ++mp[a[i] - 1];         if (mp.size() == n) {           poss = true;         }         if (--mp[a[i] - 1] == 0) mp.erase(a[i] - 1);         ++mp[a[i]];       }     }     if (!poss) {       cout <<  cslnb  <<   n ;       return 0;     }     sort(a, a + n);     b[0] = 0;     for (int i = 1; i < n; i++) {       b[i] = min(a[i], b[i - 1] + 1);     }     for (int i = 0; i < n; i++) {       sum += (a[i] - b[i] + 2) % 2;       sum %= 2;     }     cout << (sum == 1 ?  sjfnb  :  cslnb ) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> pf(const string& s) {     int n = s.size();     vector<int> pi(n);     for (int i = 1; i < n; i++) {       int j = pi[i - 1];       while (j > 0 && s[i] != s[j]) j = pi[j - 1];       if (s[i] == s[j]) j++;       pi[i] = j;     }     return pi;   }   int main() {     ios_base::sync_with_stdio(false);     string s;     string t;     cin >> s >> t;     auto a = pf(t);     int val = t.length() - a.back();     int cyc = val;     int c1 = 0, c0 = 0;     for (int i = 0; i < s.length(); i++) {       if (s[i] ==  1 )         c1++;       else         c0++;     }     int p = 0;     while (true) {       if (t[p] ==  0 ) {         if (c0) {           cout << 0;           c0--;         } else           break;       } else {         if (c1) {           cout << 1;           c1--;         } else           break;       }       p++;       p %= cyc;     }     while (c1) {       cout << 1;       c1--;     }     while (c0) {       cout << 0;       c0--;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n;     while (scanf( %d , &n) != EOF) {       int sum = 0, i, num, he = 0, div = n + 1;       for (i = 1; i <= n; i++) {         scanf( %d , &num);         sum += num;       }       for (i = 1; i <= 5; i++) {         if ((sum + i) % div == 1) he++;       }       printf( %d n , 5 - he);     }   }
#include <bits/stdc++.h>   using namespace std;   template <class A, class B>   inline bool mina(A &first, B second) {     return (first > second) ? (first = second, 1) : 0;   }   template <class A, class B>   inline bool maxa(A &first, B second) {     return (first < second) ? (first = second, 1) : 0;   }   map<char, int> cnt;   char c[] = { B ,  G ,  R };   int main() {     int N;     cin >> N;     string s;     cin >> s;     for (int(i) = 0; (i) < (N); ++(i)) {       cnt[s[i]]++;     }     if (cnt.size() == 3) {       cout <<  BGR  << endl;       return 0;     } else if (cnt.size() == 1) {       cout << cnt.begin()->first << endl;     } else {       for (int(i) = 0; (i) < (3); ++(i)) {         int cc = cnt[c[i]];         if (cc == 0) {           printf( %c , c[i]);         } else {           bool good = false;           for (int(j) = 0; (j) < (3); ++(j)) {             if (j != i && cnt[c[j]] >= 2) {               good = true;             }           }           if (good) printf( %c , c[i]);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double PI = acos(-1);   long long powm(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % 1000000007;       a = (a * a) % 1000000007;       b >>= 1;     }     return res;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   const long long maxn = 2 * 1e5 + 10;   map<long long, long long> dif;   void solve() {     long long n;     cin >> n;     long long a[n + 2];     for (long long i = 1; i <= n; i++) {       cin >> a[i];     }     sort(a + 1, a + n + 1);     for (long long i = 2; i <= n; i++) {       long long cur = a[i] - a[i - 1];       dif[cur]++;     }     if (dif.size() > 2) {       cout << 0 << endl;     } else if (n == 1) {       cout << -1 << endl;     } else if (n == 2) {       if ((a[2] - a[1]) % 2 == 0 && a[2] != a[1]) {         cout << 3 << endl;         cout << a[1] - (a[2] - a[1]) <<     << a[1] + (a[2] - a[1]) / 2 <<                  << a[2] + (a[2] - a[1]) << endl;       } else if (a[1] == a[2]) {         cout << 1 << endl;         cout << a[1] << endl;       } else {         cout << 2 << endl;         cout << a[1] - (a[2] - a[1]) <<     << a[2] + (a[2] - a[1]) << endl;       }     } else if (dif.size() == 2 && n > 1) {       long long mx = 0, d = 1000000000, z = 0;       vector<long long> s;       for (auto i : dif) {         if (i.first == 0) z = 1;         if (mx <= i.second) {           mx = i.second;           d = min(d, i.first);         }         s.push_back(i.first);       }       if (z || dif[s[0]] < n - 2 || s[1] % 2 != 0 ||           (s[1] % 2 == 0 && s[1] / 2 != s[0]))         cout << 0 << endl;       else {         for (long long i = 2; i <= n; i++) {           if (a[i] - a[i - 1] != d) {             if ((a[i] - a[i - 1]) > d && (a[i] - a[i - 1]) % 2 == 0 &&                 (a[i] - a[i - 1]) / 2 == d) {               cout << 1 << endl;               cout << a[i - 1] + d << endl;             } else {               cout << 0 << endl;               break;             }           }         }       }     } else if (dif.size() == 1) {       long long d = 0;       for (auto i : dif) {         d = i.first;       }       if (d) {         cout << 2 << endl;         cout << a[1] - (a[2] - a[1]) <<     << a[n] + (a[2] - a[1]) << endl;       } else {         cout << 1 << endl;         cout << a[1] << endl;       }     } else       cout << 0 << endl;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t = 1;     for (long long i = 1; i <= t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, ans = 0;     cin >> n;     long long a[n + 1];     vector<long long> last;     last.push_back(-1);     for (int i = 0; i < n; i++) {       cin >> a[i];       if (i > 0 && a[i] <= a[i - 1]) last.push_back(i - 1);     }     last.push_back(n - 1);     for (int i = 1; i < (int)last.size(); i++) {       if (last[i - 1] == -1)         ans = max(last[i] + 1, ans);       else         ans = max(ans, last[i] - last[i - 1]);       if (i < (int)last.size() - 1 &&           (a[last[i] + 1] > a[last[i] - 1] || a[last[i] + 2] > a[last[i]])) {         if (i > 1)           ans = max(last[i + 1] - last[i - 1] - 1, ans);         else           ans = max(ans, last[i + 1]);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 3e5 + 3e4;   long long lp[N], rp[N], l, r, first, second, m, so, k, n;   char ch;   int main() {     cin >> n;     for (long long i = (long long)1; i <= (long long)n; i++) {       cin >> ch >> k;       if (ch ==  ? ) {         first = l - lp[k];         second = r - rp[k];         m = l + r;         so = 1e15;         if (rp[k]) {           so = min(so, r - rp[k]);           so = min(so, m - second - 1);         }         if (lp[k]) {           so = min(so, l - lp[k]);           so = min(so, m - first - 1);         }         cout << so <<   n ;       } else {         if (ch ==  L ) lp[k] = ++l;         if (ch ==  R ) rp[k] = ++r;       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, s;   void dfs(long long x, long long s4, long long s7) {     if (n <= x && (x < s || s == 0) && s4 == s7) s = x;     if (x <= n * 100) {       dfs(x * 10 + 4, s4 + 1, s7);       dfs(x * 10 + 7, s4, s7 + 1);     }   }   int main() {     cin >> n;     dfs(0, 0, 0);     if (n <= 47) s = 47;     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     long long n, d;     while (t--) {       cin >> n >> d;       long long arr[n];       for (long long i = 0; i < n; i++) cin >> arr[i];       int count = 0;       int i = 1;       while (i < n && d > 0 && d >= i) {         if ((arr[i] * i) <= d) {           count += arr[i];           d = d - (arr[i] * i);         } else {           int t = d / i;           count += t;           d = d % i;         }         i++;       }       cout << arr[0] + count << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1000000000 )   using namespace std;   const long long inf = (long long)1e18;   const long double eps = 1e-8;   const long double pi = 3.1415926535;   string a[100000][8];   bool u[100000][8][8];   int sx, sy, tx, ty;   bool f;   void dfs(int x, int y, int t) {     u[t][x][y] = 1;     if (tx == x && ty == y) f = 1;     if (t < 99999 && a[t + 1][x][y] !=  S  && !u[t + 1][x][y]) dfs(x, y, t + 1);     if (t < 99999 && x > 0 && !u[t + 1][x - 1][y] && a[t][x - 1][y] !=  S  &&         a[t + 1][x - 1][y] !=  S )       dfs(x - 1, y, t + 1);     if (t < 99999 && y > 0 && !u[t + 1][x][y - 1] && a[t][x][y - 1] !=  S  &&         a[t + 1][x][y - 1] !=  S )       dfs(x, y - 1, t + 1);     if (t < 99999 && x < 7 && !u[t + 1][x + 1][y] && a[t][x + 1][y] !=  S  &&         a[t + 1][x + 1][y] !=  S )       dfs(x + 1, y, t + 1);     if (t < 99999 && y < 7 && !u[t + 1][x][y + 1] && a[t][x][y + 1] !=  S  &&         a[t + 1][x][y + 1] !=  S )       dfs(x, y + 1, t + 1);     if (t < 99999 && x > 0 && y > 0 && !u[t + 1][x - 1][y - 1] &&         a[t][x - 1][y - 1] !=  S  && a[t + 1][x - 1][y - 1] !=  S )       dfs(x - 1, y - 1, t + 1);     if (t < 99999 && y > 0 && x < 7 && !u[t + 1][x + 1][y - 1] &&         a[t][x + 1][y - 1] !=  S  && a[t + 1][x + 1][y - 1] !=  S )       dfs(x + 1, y - 1, t + 1);     if (t < 99999 && x > 0 && y < 7 && !u[t + 1][x - 1][y + 1] &&         a[t][x - 1][y + 1] !=  S  && a[t + 1][x - 1][y + 1] !=  S )       dfs(x - 1, y + 1, t + 1);     if (t < 99999 && y < 7 && x < 7 && !u[t + 1][x + 1][y + 1] &&         a[t][x + 1][y + 1] !=  S  && a[t + 1][x + 1][y + 1] !=  S )       dfs(x + 1, y + 1, t + 1);   }   int main() {     for (int i = 0; i < 8; ++i) {       cin >> a[0][i];       for (int j = 0; j < 8; ++j) {         if (a[0][i][j] ==  A ) {           tx = i;           ty = j;         }         if (a[0][i][j] ==  M ) {           sx = i;           sy = j;         }       }     }     f = 0;     for (int i = 1; i < 100000; ++i)       for (int j = 0; j < 8; ++j)         for (int k = 0; k < 8; ++k)           if (j > 0 && a[i - 1][j - 1][k] ==  S )             a[i][j] +=  S ;           else             a[i][j] +=  . ;     dfs(sx, sy, 0);     if (f)       cout <<  WIN ;     else       cout <<  LOSE ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n,q,a[100005],np[100005],cnt[100005],nx[19][100005],p1,p2;   vector<int> p,fac[100005];   bool check(int ind) {       for (int i=0; i<fac[ind].size(); i++) {           if (cnt[fac[ind][i]]) return 0;       }       for (int i=0; i<fac[ind].size(); i++) cnt[fac[ind][i]]++;       return 1;   }   void rem(int ind) {       for (int i=0; i<fac[ind].size(); i++) {           cnt[fac[ind][i]]--;       }   }   void fun() {       int l=0,r=0;       while (l<n) {           while (r<n and check(r)) r++;           nx[0][l]=r;           rem(l); l++;       }       nx[0][n]=n;       for (int i=1; i<19; i++) {           for (int j=0; j<=n; j++) {               nx[i][j]=nx[i-1][nx[i-1][j]];           }       }   }   int getans(int l,int r) {       int ind=18,ret=0,cur=l;       while (ind>=0) {           if (nx[ind][cur]<=r) {               ret+=(1<<ind); cur=nx[ind][cur];           }           ind--;       }       return ret+1;   }   int main() {       for (int i=2; i<=1e5; i++) {           if (np[i]) continue;           p.push_back(i);           for (int j=2*i; j<=1e5; j+=i) {               np[j]=1;           }       }       cin>>n>>q;       for (int i=0; i<n; i++) cin>>a[i];       for (int i=0; i<n; i++) {           int ind=0,x=a[i];           while (p[ind]<318) {               bool s=0;               while (x%p[ind]==0) {                   x/=p[ind]; s=1;               }               if (s) fac[i].push_back(p[ind]);               ind++;           }           if (x!=1) {               fac[i].push_back(x);           }       }       fun();       for (int i=0; i<q; i++) {           cin>>p1>>p2; p1--; p2--;           cout<<getans(p1,p2)<<  n ;       }   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = int(1e5 + 3);   template <typename T>   void printV(vector<T> v, char sep) {     for (long long unsigned int i = 0; i < v.size() - 1; i++) {       cout << v[i] << sep;     }     cout << v[v.size() - 1];   }   void printVPCI(vector<pair<char, int>> s) {     for (long long unsigned int i = 0; i < s.size(); i++) {       cout << s[i].first <<     << s[i].second <<   n ;     }   }   void cdPr(bool a) { cout << (a ?  YES  :  NO ); }   bool isPrime(int n) {     for (int i = 2; i <= n / 2; ++i) {       if (n % i == 0) {         return false;       }     }     return true;   }   template <typename T>   bool vFind(vector<T> v, T x) {     return find(v.begin(), v.end(), x) != v.end();   }   vector<pair<char, int>> strInfo(string s) {     vector<char> f;     vector<pair<char, int>> r;     for (long long unsigned int i = 0; i < s.size(); i++) {       if (!vFind(f, s[i])) {         f.push_back(s[i]);         r.push_back(make_pair(s[i], count(s.begin(), s.end(), s[i])));       }     }     return r;   }   vector<char> distinctChars(string s) {     vector<char> f;     for (long long unsigned int i = 0; i < s.size(); i++) {       if (!vFind(f, s[i])) f.push_back(s[i]);     }     return f;   }   void solve() {     int n;     cin >> n;     int pos[MAX_N] = {0};     int t = n;     int a;     cin >> a;     int i = 1;     n--;     int min = 99999999;     int r = 0;     pos[0] = a;     int x;     while (n > 0) {       cin >> x;       pos[i] = x;       if (abs(a - x) < min) {         min = abs(a - x);         r = i;       }       a = x;       i++;       n--;     }     if (abs(x - pos[0]) < min) {       r = t;     }     cout << (r) <<     << ((r + 1 > t) ? (r + 1 - t) : (r + 1)) <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:64000000 )   using namespace std;   const int infi = 1e9 + 7;   const long long infl = 1e18 + 7;   int ar[101];   bitset<101> dp0[10500];   bitset<101> dp[10500];   bitset<101> ndp[10500];   int main() {     cin.sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     for (int i = 0; i < (n); ++i) cin >> ar[i];     vector<pair<int, int> > tmp;     sort(ar, ar + n);     int lst = ar[0];     int sum = ar[0];     int cnt = 1;     for (int i = 1; i < n; ++i) {       sum += ar[i];       if (lst == ar[i])         ++cnt;       else {         tmp.emplace_back(lst, cnt);         lst = ar[i];         cnt = 1;       }     }     tmp.emplace_back(lst, cnt);     if (tmp.size() <= 2) {       cout << n;       return 0;     }     for (auto cur : tmp) {       for (int cnt = 1; cnt <= cur.second; ++cnt) {         int second = cnt * cur.first;         for (int w = 0; w < (10500); ++w) {           ndp[w + second] |= dp0[w] << cnt;           ndp[w + second] |= dp[w] << cnt;         }       }       for (int cnt = 1; cnt <= cur.second; ++cnt) {         dp0[cnt * cur.first][cnt] = 1;       }       for (int i = 0; i < (10500); ++i) dp[i] |= ndp[i];     }     int ans = 0;     for (auto cur : tmp) {       for (int cnt = 1; cnt <= cur.second; ++cnt) {         int second = cnt * cur.first;         if (dp[second][cnt]) continue;         ans = max(ans, cnt);         if (tmp.size() == 2 && cnt == cur.second) ans = n;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3,  Ofast ,  inline )   #pragma GCC target( avx,avx2 )   using namespace std;   template <class t>   inline t read(t &x) {     char c = getchar();     bool f = 0;     x = 0;     while (!isdigit(c)) f |= c ==  - , c = getchar();     while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();     if (f) x = -x;     return x;   }   template <class t>   inline void write(t x) {     if (x < 0)       putchar( - ), write(-x);     else {       if (x > 9) write(x / 10);       putchar( 0  + x % 10);     }   }   const long long N = 1005, mod = 1e9 + 7;   long long f[N][N][2][2], g[N], ans[N], n, m, fac[N], inv[N];   long long C(long long n, long long m) {     return fac[n] * inv[m] % mod * inv[n - m] % mod;   }   signed main() {     read(n);     read(m);     fac[0] = inv[0] = inv[1] = 1;     for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;     for (long long i = 2; i <= n; i++)       inv[i] = inv[mod % i] * (mod - mod / i) % mod;     for (long long i = 1; i <= n; i++) inv[i] = inv[i] * inv[i - 1] % mod;     f[1][0][0][0] = f[1][1][0][1] = 1;     for (long long i = 2; i <= n; i++)       for (long long j = 0; j < i; j++) {         f[i][j][0][0] =             (f[i][j][0][0] + f[i - 1][j][0][0] + f[i - 1][j][1][0]) % mod;         f[i][j][1][0] =             (f[i][j][1][0] + f[i - 1][j][0][1] + f[i - 1][j][1][1]) % mod;         f[i][j + 1][0][0] = f[i - 1][j][0][0];         f[i][j + 1][0][1] = (f[i - 1][j][0][0] + f[i - 1][j][1][0]) % mod;         f[i][j + 1][1][0] = f[i - 1][j][0][1];         f[i][j + 1][1][1] = (f[i - 1][j][0][1] + f[i - 1][j][1][1]) % mod;       }     for (long long i = 0; i <= n; i++)       g[i] = (f[n][i][0][0] + f[n][i][1][0]) * fac[n - i] % mod;     for (long long i = 0; i <= n; i++)       for (long long j = i, op = 1; j <= n; j++, op *= -1)         ans[i] = (ans[i] + mod + op * C(j, i) * g[j] % mod) % mod;     write(ans[m]);   }
#include <bits/stdc++.h>   using namespace std;   long long int mod = 1e9 + 9;   const double error = 1e-7;   const double PI = acos(-1);   mt19937 rng(       (unsigned int)chrono::system_clock::now().time_since_epoch().count());   inline long long int MOD(long long int x, long long int m = mod) {     long long int y = x % m;     return (y >= 0) ? y : y + m;   }   const int inf = 1e9 + 2;   const long long int infl = 1e18 + 1;   const int nmax = 1e6 + 10;   int master[nmax];   void init(int n) {     for (int i = 1; i <= n; i++) master[i] = i;   }   int fnd(int u) {     if (master[u] == u) return u;     return master[u] = fnd(master[u]);   }   int unite(int a, int b) {     a = fnd(a), b = fnd(b);     if (rng() & 1) swap(a, b);     master[b] = a;     return a;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     int n, m;     cin >> n >> m;     init(n);     long long int two = 1;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       if (fnd(a) == fnd(b)) {         two *= 2;         two %= mod;       } else         unite(a, b);       cout << MOD(two - 1) <<   n ;     }   }