malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int matrix[101][101];   struct HATE {     int t, r, c, x;     HATE(int t, int r, int c, int x) {       this->t = t;       this->r = r;       this->c = c;       this->x = x;     }   };   HATE* hates[10001];   int main() {     int n, m, q;     cin >> n >> m >> q;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         matrix[i][j] = 1e9 + 1;       }     }     for (int heh = 0; heh < q; heh++) {       int t;       cin >> t;       if (t == 1) {         int r;         cin >> r;         hates[heh] = new HATE(t, r, 0, 0);       } else if (t == 2) {         int c;         cin >> c;         hates[heh] = new HATE(t, 0, c, 0);       } else {         int r, c, x;         cin >> r >> c >> x;         hates[heh] = new HATE(t, r, c, x);       }     }     for (int heh = q - 1; heh >= 0; heh--) {       int t = hates[heh]->t;       int r = hates[heh]->r;       int c = hates[heh]->c;       int x = hates[heh]->x;       if (t == 1) {         r--;         int temp = matrix[r][m - 1];         for (int i = m - 1; i >= 1; i--) {           matrix[r][i] = matrix[r][i - 1];         }         matrix[r][0] = temp;       } else if (t == 2) {         c--;         int temp = matrix[n - 1][c];         for (int i = n - 1; i >= 1; i--) {           matrix[i][c] = matrix[i - 1][c];         }         matrix[0][c] = temp;       } else {         r--;         c--;         matrix[r][c] = x;       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (matrix[i][j] == 1e9 + 1) {           cout << 1488 <<    ;         } else {           cout << matrix[i][j] <<    ;         }       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   pair<pair<int, int>, pair<int, int> > a[60000];   int ans[60000], b[60000], n, m, maxx;   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++)       cin >> a[i].first.first >> a[i].first.second >> a[i].second.first >>           a[i].second.second;     for (int i = 1; i <= n; i++) ans[i] = (int)(1e9);     for (int i = m; i >= 1; i--) {       if (a[i].first.first == 1) {         for (int j = a[i].first.second; j <= a[i].second.first; j++)           if (ans[j] < (int)(1e9)) ans[j] -= a[i].second.second;       } else {         for (int j = a[i].first.second; j <= a[i].second.first; j++)           if (ans[j] > a[i].second.second) ans[j] = a[i].second.second;       }     }     for (int i = 1; i <= n; i++) b[i] = ans[i];     for (int i = 1; i <= m; i++) {       if (a[i].first.first == 1) {         for (int j = a[i].first.second; j <= a[i].second.first; j++)           if (ans[j] < (int)(1e9)) ans[j] += a[i].second.second;       } else {         maxx = -(int)(1e9);         for (int j = a[i].first.second; j <= a[i].second.first; j++)           if (ans[j] > maxx) maxx = ans[j];         if (maxx != a[i].second.second) {           cout <<  NO n ;           return 0;         }       }     }     cout <<  YES n ;     for (int i = 1; i <= n; i++) cout << b[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:64000000000 )   using namespace std;   const double EPS = 1e-9;   const int INF = (int)(2e9 + 0.5);   const int MAXN = 201000;   int n, k, a;   vector<int> mass;   set<int> minima;   map<int, int> bad;   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; ++i) {       scanf( %d , &a);       mass.push_back(-a);     }     for (int i = 0; i < k; ++i) {       bad[mass[i]]++;       if (bad[mass[i]] != 1) {         if (minima.count(mass[i])) minima.erase(mass[i]);       } else         minima.insert(mass[i]);     }     for (int l = 0, r = k - 1; r < n; ++l, ++r) {       if (!minima.size())         printf( Nothing n );       else         printf( %d n , -(*minima.begin()));       bad[mass[l]]--;       if (bad[mass[l]] == 1) minima.insert(mass[l]);       if (bad[mass[l]] != 1)         if (minima.count(mass[l])) minima.erase(mass[l]);       if (r + 1 < n) {         bad[mass[r + 1]]++;         if (bad[mass[r + 1]] != 1) {           if (minima.count(mass[r + 1])) minima.erase(mass[r + 1]);         } else           minima.insert(mass[r + 1]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000;   const int delt = 255;   long long fa[N], fb[N], fc[N];   int main() {     ios::sync_with_stdio(false);     string a, b, c;     cin >> a;     cin >> b;     cin >> c;     for (int i = 0; i < a.size(); i++) {       fa[a[i] + delt]++;     }     for (int i = 0; i < b.size(); i++) {       fb[b[i] + delt]++;     }     for (int i = 0; i < c.size(); i++) {       fc[c[i] + delt]++;     }     pair<long long, pair<long long, long long> > ans = {0, {0, 0}};     for (int j = 0; j <= a.size(); j++) {       long long kb = j;       bool was = 0;       for (char i =  a ; i <=  z ; i++) {         if (fa[i + delt] < kb * fb[i + delt]) {           was = 1;           break;         }       }       if (was) continue;       long long kc = (long long)1e15;       for (char i =  a ; i <=  z ; i++) {         if (fc[i + delt] > 0)           kc = min(kc, (fa[i + delt] - kb * fb[i + delt]) / fc[i + delt]);       }       ans = max(ans, make_pair(kb + kc, make_pair(kb, kc)));     }     for (char i =  a ; i <=  z ; i++) {       fa[i + delt] -= ans.second.first * fb[i + delt];       fa[i + delt] -= ans.second.second * fc[i + delt];     }     string str =   ;     for (int i = 0; i < ans.second.first; i++) {       str += b;     }     for (int i = 0; i < ans.second.second; i++) {       str += c;     }     for (char i =  a ; i <=  z ; i++) {       while (fa[i + delt] > 0) {         str += i;         fa[i + delt]--;       }     }     cout << str <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int c[26];   int main() {     string s;     cin >> s;     if (s.length() < 26) {       cout << -1;       return 0;     }     int f = 0, h = 0;     for (int i = 0; i < 25; i++) {       if (s[i] !=  ? ) {         h += (c[s[i] -  A ] == 0);         c[s[i] -  A ]++;       } else {         f++;       }     }     for (int i = 25; i < s.length(); i++) {       if (s[i] !=  ? ) {         h += (c[s[i] -  A ] == 0);         c[s[i] -  A ]++;       } else {         f++;       }       if (h + f == 26) {         int o = i - 25;         for (int j = 0; j < 26; j++) {           if (c[j] == 0) {             while (s[o] !=  ? ) o++;             s[o] = j +  A ;           }         }         for (int j = 0; j < s.length(); j++) {           if (s[j] ==  ? ) {             s[j] =  A ;           }         }         cout << s;         return 0;       }       if (s[i - 25] !=  ? ) {         c[s[i - 25] -  A ]--;         h -= (c[s[i - 25] -  A ] == 0);       } else {         f--;       }     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int nos;   void split(int n) {     if (nos == 0 || n == 1)       cout << n <<    ;     else {       --nos;       split(n / 2);       split(n / 2);     }   }   int main() {     ios::sync_with_stdio(false);     int n, k;     cin >> k >> n;     if (n > k)       cout <<  NO  << endl;     else {       vector<int> nums;       for (int i = 0; k; k /= 2, ++i) {         if (k % 2) nums.push_back(pow(2, i));       }       nos = n - nums.size();       if (nos < 0)         cout <<  NO  << endl;       else {         cout <<  YES  << endl;         for (auto &i : nums) split(i);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e3 + 7;   const int mod = 998244353;   int col[maxn];   namespace DSU {   int far[maxn];   void init() {     for (int i = 0; i < maxn; i++) far[i] = i;   }   int Find(int x) { return x == far[x] ? x : far[x] = Find(far[x]); }   void Union(int x, int y) {     x = Find(x), y = Find(y);     if (x < y) swap(x, y);     far[y] = x;   }   };  // namespace DSU   string s;   int var, w, b;   bool isp[maxn];   vector<int> G[maxn];   bool dfs(int u) {     for (auto &v : G[u]) {       if (col[v] == -1) {         col[v] = col[u] ^ 1;         if (!dfs(v)) return false;       } else {         if (col[v] == col[u]) return false;       }     }     return true;   }   long long solve(int len) {     for (int i = 0; i <= b; i++) G[i].clear();     memset(isp, 0, sizeof(isp));     DSU::init();     for (int i = 0; i < s.length() / 2; i++) DSU::Union(i, s.length() - i - 1);     for (int i = 0; i < len / 2; i++) DSU::Union(var + i, var + len - 1 - i);     isp[w] = isp[b] = 1;     DSU::Union(var + len - 1, b);     for (int i = 0; i < s.length(); i++) isp[i] = 1;     for (int i = 0; i < len; i++) isp[i + var] = 1;     for (int i = 0; i < len; i++)       if (s[i] ==  0 ) DSU::Union(i, var + i);     for (int i = len; i < s.length(); i++) {       if (s[i] ==  1 )         DSU::Union(i, b);       else if (s[i] ==  0 )         DSU::Union(i, w);     }     DSU::Union(s.length() - 1, b);     if (DSU::Find(b) == DSU::Find(w)) return 0;     for (int i = 0; i < len; i++) {       if (s[i] ==  1 ) {         G[DSU::Find(i)].push_back(DSU::Find(var + i));         G[DSU::Find(var + i)].push_back(DSU::Find(i));       }     }     G[DSU::Find(w)].push_back(DSU::Find(b));     G[DSU::Find(b)].push_back(DSU::Find(w));     long long ret = 1;     memset(col, -1, sizeof(col));     for (int i = b; i >= 0; i--) {       if (isp[i]) {         int cur = DSU::Find(i);         if (col[cur] == -1) {           if (cur == b)             col[cur] = 1;           else             col[cur] = 0;           if (!dfs(cur))             return 0;           else {             if (cur != b && cur != w) ret = ret * 2 % mod;           }         }       }     }     return ret;   }   int main() {     cin >> s;     var = s.length();     reverse(s.begin(), s.end());     w = var * 2 + 1, b = var * 2 + 2;     long long ans = 0;     for (int i = 1; i < s.length(); i++) ans = (ans + solve(i)) % mod;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     string a;     string b;     cin >> a >> b;     int order = 0;     while (a[order] ==  0 ) {       order++;     }     a = a.substr(order);     order = 0;     while (b[order] ==  0 ) {       order++;     }     b = b.substr(order);     if (a.size() > b.size()) {       cout <<  > ;     } else if (a.size() < b.size()) {       cout <<  < ;     } else {       for (int i = 0; i < a.size(); i++) {         if (a[i] > b[i]) {           cout <<  > ;           return 0;         } else if (a[i] < b[i]) {           cout <<  < ;           return 0;         }       }       cout <<  = ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MXN = 1e5 + 1;   int n, dp[MXN], k[MXN], ans = 1, rg[MXN], res, maxi;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> k[i];       dp[k[i]] += dp[k[i] - 1] + 1;     }     for (int i = 1; i <= n; i++) {       if (dp[k[i]] > maxi) {         maxi = dp[k[i]];       }     }     cout << n - maxi;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void base() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int main() {     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       if (a > b) swap(a, b);       if (a * 2 < b)         cout <<  NO n ;       else {         int dif = b - a;         if (a - dif >= 0 && b - 2 * dif >= 0 && (a - dif) % 3 == 0) {           cout <<  YES n ;         } else {           cout <<  NO n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   long long int power(long long int x, long long int y,                       long long int mod = 1000000007) {     long long int ret = 1;     x = x % mod;     while (y) {       if (y & 1) ret = (ret * x) % mod;       y = y >> 1;       x = (x * x) % mod;     }     return ret % mod;   }   long long int isprime(long long int x) {     for (long long int i = 2; i * i <= x; i++)       if (x % i == 0) return 0;     return 1;   }   void solve() {     long long int n, k;     cin >> n >> k;     if (n <= k) {       cout << 1 << endl;       return;     }     vector<long long int> fact;     for (long long int i = 1; i * i <= n; i++) {       if (n % i == 0) {         if (i <= k) fact.push_back(i);         if ((n / i) <= k) fact.push_back(n / i);       }     }     sort(fact.begin(), fact.end());     cout << n / fact.back() << endl;   }   signed main() {     long long int t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     char sav[200];     scanf( %s , sav);     int flag = 0;     int len = strlen(sav);     for (int i = 0; i < len; i++) {       if (sav[i] ==  1 )         continue;       else if (sav[i] ==  4 ) {         if (i - 1 >= 0 && sav[i - 1] ==  1 )           continue;         else if (i - 1 >= 0 && sav[i - 1] ==  4 ) {           if (i - 2 >= 0 && sav[i - 2] ==  1 )             continue;           else             flag = 1;         } else           flag = 1;       } else         flag = 1;     }     if (flag)       cout <<  NO  << endl;     else       cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T bigmod(T p, T e, T M) {     long long ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % M;       p = (p * p) % M;     }     return (T)ret;   }   template <class T>   inline T gcd(T a, T b) {     if (b == 0) return a;     return gcd(b, a % b);   }   template <class T>   inline T modinverse(T a, T M) {     return bigmod(a, M - 2, M);   }   int Set(int N, int pos) { return N = N | (1 << pos); }   int Reset(int N, int pos) { return N = N & ~(1 << pos); }   bool Chkbit(int N, int pos) { return (bool)(N & (1 << pos)); }   int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int dx[] = {1, 0, -1, 0};   int dy[] = {0, 1, 0, -1};   const double eps = 1e-6;   int n, m, k;   int vis[2000005];   int achhe[2000005];   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= m; i++) {       int x;       scanf( %d , &x);       vis[x] = 1;     }     int ans = 1;     int fl = 0;     achhe[1] = 1;     for (int i = 1; i <= k; i++) {       int x, y;       scanf( %d %d , &x, &y);       if (fl == 0) {         if (achhe[x]) {           achhe[x] = 0;           achhe[y] = 1;           if (vis[y]) {             fl = 1;             ans = y;           } else             ans = y;         } else if (achhe[y]) {           achhe[y] = 0;           achhe[x] = 1;           if (vis[x]) {             fl = 1;             ans = x;           } else             ans = x;         } else {           int nothing;         }       }     }     if (vis[1]) {       cout <<  1  << endl;       return 0;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   void solve() {     cin >> n;     long long x, y, a, b;     cout <<  YES n ;     for (long long i = 1; i <= (n); ++i) {       cin >> x >> y >> a >> b;       cout << 2 * (x & 1) + (y & 1) + 1;       cout <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     solve();     return 0;   }
#include<bits/stdc++.h>   #define ll long long   using namespace std;   int main()   {       ios_base::sync_with_stdio(0);cin.tie(NULL);    int t;    cin>>t;    while(t--)    {     ll n,x;     ll min=0,max=0,s=0;     cin>>n>>x;     ll a[n];     for(ll i=0;i<n;i++)     {      cin>>a[i];      s+=a[i];      if(a[i]%x==0)               max+=(a[i]/x);               else               max+=((a[i]/x)+1);           }         if(s%x==0)               min+=(s/x);               else               min+=((s/x)+1);     cout<<min<<   <<max<<endl;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace chrono;   const long long int MOD = 1000000007;   const long long int MAXN = 100005;   long long int k, dp[MAXN];   long long int recurse(long long int n) {     if (n == 0) return 1;     if (dp[n] != -1) return dp[n];     long long int ans = 0;     if (n >= k) {       ans = (ans + recurse(n - k)) % MOD;     }     if (n > 0) {       ans = (ans + recurse(n - 1)) % MOD;     }     return (dp[n] = ans);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     cin >> t >> k;     long long int a, b;     memset(dp, -1, sizeof(dp));     dp[0] = 0;     for (long long int i = 1; i < 100001; ++i) {       dp[i] = recurse(i);     }     for (long long int i = 1; i < 100001; ++i) {       dp[i] = (dp[i] + dp[i - 1]) % MOD;     }     while (t--) {       cin >> a >> b;       cout << ((MOD + dp[b] - dp[a - 1])) % MOD << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long getint() {     long long _x = 0, _tmp = 1;     char _tc = getchar();     while ((_tc <  0  || _tc >  9 ) && _tc !=  - ) _tc = getchar();     if (_tc ==  - ) _tc = getchar(), _tmp = -1;     while (_tc >=  0  && _tc <=  9 ) _x *= 10, _x += (_tc -  0 ), _tc = getchar();     return _x * _tmp;   }   long long mypow(long long _a, long long _x, long long _mod) {     if (_x == 0) return 1ll;     long long _tmp = mypow(_a, _x / 2, _mod);     _tmp = (_tmp * _tmp) % _mod;     if (_x & 1) _tmp = (_tmp * _a) % _mod;     return _tmp;   }   inline long long add(long long _x, long long _y,                        long long _mod = 1000000007ll) {     long long _ = _x + _y;     if (_ >= _mod) _ -= _mod;     return _;   }   inline long long sub(long long _x, long long _y,                        long long _mod = 1000000007ll) {     long long _ = _x - _y;     if (_ < 0) _ += _mod;     return _;   }   inline long long mul(long long _x, long long _y,                        long long _mod = 1000000007ll) {     long long _ = _x * _y;     if (_ >= _mod) _ %= _mod;     return _;   }   inline bool equal(double _x, double _y) {     return _x > _y - 1e-9 && _x < _y + 1e-9;   }   int __ = 1, _cs;   int n, k;   vector<int> v;   void build() {}   void init() {     n = getint();     k = getint();     for (int i = 1; i <= n; i++) v.push_back(getint());     sort((v).begin(), (v).end());     v.resize(unique((v).begin(), (v).end()) - v.begin());   }   int dp[1001 * 1001];   void solve() {     for (int i = 1; i <= (v.back() - v[0]) * k; i++) {       dp[i] = 1001 * 1001;       for (size_t j = 1; j < v.size(); j++)         if (v[j] - v[0] > i)           break;         else           dp[i] = min(dp[i], dp[i - v[j] + v[0]] + 1);     }     for (int i = 0; i <= (v.back() - v[0]) * k; i++)       if (dp[i] <= k) printf( %d  , i + v[0] * k);     puts(  );   }   int main() {     build();     while (__--) {       init();       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, j, k;     string s;     while (cin >> n >> s) {       int sum = 0;       int left = 0, right = 0, up = 0, down = 0;       for (i = 0; i < n; i++) {         if (s[i] ==  R ) {           if (left == 1) {             sum++;             left = 0;             up = 0;             down = 0;           }           right = 1;         } else if (s[i] ==  L ) {           if (right == 1) {             sum++;             right = 0;             up = 0;             down = 0;           }           left = 1;         } else if (s[i] ==  U ) {           if (down == 1) {             sum++;             down = 0;             left = 0;             right = 0;           }           up = 1;         } else if (s[i] ==  D ) {           if (up == 1) {             sum++;             up = 0;             left = 0;             right = 0;           }           down = 1;         }       }       cout << sum + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,unroll-loops )   #pragma GCC target(         sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2 )   using namespace std;   mt19937 mrnd(time(0));   const int INF = 1000000007;   const long long INF_LL = 1152921504606846977;   void solve() {     int n, m;     cin >> n >> m;     vector<set<int>> g(n);     for (int i = 0; i < m; ++i) {       int u, v;       cin >> u >> v;       --u, --v;       if (u > v) swap(u, v);       g[u].insert(v);     }     set<int> dead;     for (int i = 0; i < n; ++i) {       if (!g[i].empty()) {         dead.insert(i);       }     }     int q;     cin >> q;     auto upd = [&](int node) {       if (g[node].empty()) {         dead.erase(node);       } else {         dead.insert(node);       }     };     for (int i = 0; i < q; ++i) {       int z, u, v;       cin >> z;       if (z == 1) {         cin >> u >> v;         --u, --v;         if (u > v) swap(u, v);         g[u].insert(v);         upd(u), upd(v);       } else if (z == 2) {         cin >> u >> v;         --u, --v;         if (u > v) swap(u, v);         g[u].erase(v);         upd(u), upd(v);       } else {         cout << n - int(dead.size()) <<   n ;       }     }   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout << fixed << setprecision(20);     int tests = 1;     while (tests--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, mostleft = 1000000000, mostright = 0, ans = -1;     int l[100000], r[100000];     bool bo_l[100000], bo_r[100000];     cin >> n;     for (int i = 0; i < n; i++) {       bo_l[i] = false;       bo_r[i] = false;     }     for (int i = 0; i < n; i++) {       cin >> l[i] >> r[i];       mostleft = min(mostleft, l[i]);       mostright = max(mostright, r[i]);     }     for (int i = 0; i < n; i++) {       if (mostleft == l[i]) bo_l[i] = true;       if (mostright == r[i]) bo_r[i] = true;     }     for (int i = 0; i < n; i++) {       if (bo_l[i] && bo_r[i]) ans = i + 1;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 200005;   const unsigned long long HA = 41793404541;   int n, m;   int a[maxN], b[maxN];   unsigned long long fac[maxN], pre[maxN], nxt[maxN];   int ansn, ans[maxN];   bool check(int l, int r) {     return pre[r] - pre[l - 1] * fac[r - l + 1] ==            nxt[l] - nxt[r + 1] * fac[r - l + 1];   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (int i = 1; i < n; ++i) b[i] = a[i + 1] - a[i];     fac[0] = 1;     for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * HA;     for (int i = 1; i <= n; ++i)       pre[i] = pre[i - 1] * HA + (unsigned long long)b[i];     for (int i = n - 1; i; --i)       nxt[i] = nxt[i + 1] * HA + (unsigned long long)b[i];     for (int i = 1; i <= n; ++i) {       bool pd = true;       if (i != 1) pd &= check(1, i - 1);       if (i != n) {         pd &= (a[1] + a[i] == a[i + 1] + a[n] - m);         if (i != n - 1) pd &= check(i + 1, n - 1);       }       if (pd) ans[++ansn] = (a[1] + a[i]) % m;     }     printf( %d n , ansn);     sort(ans + 1, ans + ansn + 1);     for (int i = 1; i <= ansn; ++i) printf( %d  , ans[i]);     return 0;   }