malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   long long int power(long long int x, long long int b) {     long long int p = 1;     while (b > 0) {       if (b & 1) {         p = p * x;         p %= 1000000007;       }       b >>= 1;       x *= x;       x %= 1000000007;     }     return p % 1000000007;   }   using namespace std;   struct lex_compare {     bool operator()(         const pair<long long int, pair<long long int, long long int> > p1,         const pair<long long int, pair<long long int, long long int> > p2) {       return (p1.first == p2.first) ? p1.second.first < p2.second.first                                     : p1.first > p2.first;     }   };   long long int n, m, b, mo;   long long int dp[2][500 + 1][500 + 1];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long int w, m;     cin >> w >> m;     bool f = 1;     map<long long int, long long int> coeff;     long long int term = 1;     while (m >= term && term <= 10000000000) {       long long int x = (term * (m / term) - (w * term) * (m / (w * term)));       x /= term;       if (x <= 1) {         term *= w;       } else {         if (x != (w - 1)) {           f = 0;           break;         } else {           m += (w * term - term);         }         term *= w;       }     }     if (f)       cout <<  YES             <<   n ;     else       cout <<  NO             <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> di[100003];   struct trie {     trie *zero, *one;     int val;     trie() {       zero = one = NULL;       val = 100003;     }   } * root[100003];   void add(trie *cur, int a) {     int i, ck;     for (i = 20; i >= 0; i--) {       ck = (1 << i & a);       if (ck == 0) {         cur->val = min(cur->val, a);         if (cur->zero == NULL) cur->zero = new trie();         cur = cur->zero;         cur->val = min(cur->val, a);       } else {         cur->val = min(cur->val, a);         if (cur->one == NULL) cur->one = new trie();         cur = cur->one;         cur->val = min(cur->val, a);       }     }   }   int query(trie *cur, int a, int lim) {     int i, ck, ans;     for (i = 20; i >= 0; i--) {       ck = (1 << i & a);       if (ck == 0) {         if (cur->one != NULL && cur->one->val + a <= lim)           cur = cur->one;         else if (cur->zero != NULL)           cur = cur->zero;         ans = cur->val;       } else {         if (cur->zero != NULL && cur->zero->val + a <= lim)           cur = cur->zero;         else if (cur->one != NULL)           cur = cur->one;         ans = cur->val;       }     }     return ans;   }   void pre() {     for (int i = 1; i < 100003; i++) {       for (int j = i; j < 100003; j += i) di[j].push_back(i);       root[i] = new trie();     }   }   int main() {     pre();     int q, a, k, s, v, ty;     scanf( %d , &q);     while (q--) {       scanf( %d , &ty);       if (ty == 1) {         scanf( %d , &a);         for (int x : di[a]) {           add(root[x], a);         }       } else {         scanf( %d %d %d , &v, &k, &s);         if (root[k]->val + v > s || root[k]->val == 0 || v % k)           printf( -1 n );         else           printf( %d n , query(root[k], v, s));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isPrime(int n) {     if (n <= 1) return false;     for (int i = 2; i < n; i++)       if (n % i == 0) return false;     return true;   }   int main() {     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       vector<long long int> v;       for (long long int i = 0; i < n; i++) {         long long int x;         cin >> x;         v.push_back(x);       }       if (v[0] + v[1] <= v[n - 1]) {         cout << 1 <<     << 2 <<     << n <<   n ;       } else {         cout << -1 <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char bb[111][111];   int in[111][111];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) scanf( %s , bb[i]);     vector<pair<pair<int, int>, int>> stars;     for (int i = 1; i < n - 1; i++) {       for (int j = 1; j < m - 1; j++) {         if (bb[i][j] !=  * ) continue;         int l, r, u, d;         l = r = i;         u = d = j;         for (int k = i; k < n; k++)           if (bb[k][j] ==  * )             r = k;           else             break;         for (int k = i; k >= 0; k--)           if (bb[k][j] ==  * )             l = k;           else             break;         for (int k = j; k < m; k++)           if (bb[i][k] ==  * )             d = k;           else             break;         for (int k = j; k >= 0; k--)           if (bb[i][k] ==  * )             u = k;           else             break;         int starLevel = min(min(r - i, i - l), min(d - j, j - u));         if (starLevel) {           for (int k = i - starLevel; k <= i + starLevel; k++) in[k][j] = 1;           for (int k = j - starLevel; k <= j + starLevel; k++) in[i][k] = 1;           stars.push_back({{i + 1, j + 1}, starLevel});         }       }     }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if ((bb[i][j] ==  *  && in[i][j] == 0) ||             (in[i][j] == 1 && bb[i][j] ==  . ))           return puts( -1 );     cout << stars.size() << endl;     for (auto u : stars) {       printf( %d %d %d n , u.first.first, u.first.second, u.second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 500;   const int LN = 21;   const long long mod = 1e9 + 7;   const long long INF = 1LL << 57;   long long n, m, u, v, k, t, q, a, x, d;   int tree[4 * N];   int sum[4 * N];   int lim = 1e6 + 2;   int arr[N], brr[N];   bool print = false;   void modify(int i, int l, int r, int index, int val) {     if (l == r) {       tree[i] += val;       sum[i] = tree[i];       return;     }     int mid = (l + r) / 2;     if (index <= mid)       modify(i + 1 + i, l, mid, index, val);     else       modify(i + 2 + i, mid + 1, r, index, val);     tree[i] = max(tree[i + 2 + i], tree[i + 1 + i] + sum[i + 2 + i]);     sum[i] = sum[i + 1 + i] + sum[i + 2 + i];   }   int find(int i, int l, int r, int sumx) {     if (l == r) return l;     int mid = (l + r) / 2;     if (tree[i + 2 + i] + sumx > 0) {       return find(i + 2 + i, mid + 1, r, sumx);     } else       return find(i + 1 + i, l, mid, sumx + sum[i + 2 + i]);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       cin >> arr[i];     }     for (int i = 1; i <= m; ++i) cin >> brr[i];     for (int i = 1; i <= n; ++i) {       modify(0, 0, lim, arr[i], 1);     }     for (int i = 1; i <= m; ++i) {       modify(0, 0, lim, brr[i], -1);     }     cin >> q;     while (q--) {       int type;       cin >> type;       if (type == 1) {         int i, x;         cin >> i >> x;         modify(0, 0, lim, arr[i], -1);         modify(0, 0, lim, x, 1);         arr[i] = x;         int price = find(0, 0, lim, 0);         if (price == 0)           cout << -1 <<   n ;         else           cout << price <<   n ;       } else {         int i, x;         cin >> i >> x;         modify(0, 0, lim, brr[i], 1);         modify(0, 0, lim, x, -1);         brr[i] = x;         int price = find(0, 0, lim, 0);         if (price == 0)           cout << -1 <<   n ;         else           cout << price <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, k, d;     cin >> n >> k >> d;     long long a[101], b[101];     memset(a, 0, sizeof(a));     memset(b, 0, sizeof(b));     a[0] = 1;     long long sum = 0;     for (int i = 0; i < k; i++) {       sum += a[i];       sum = (sum) % 1000000007;       a[i + 1] = sum;     }     for (int i = k; i < n; i++) {       sum += a[i];       sum -= a[i - k];       sum = ((sum % 1000000007) + 1000000007) % 1000000007;       a[i + 1] = sum;     }     for (int i = 1; i < d; i++) {       b[i] = 0;     }     b[d] = 1;     for (int i = d + 1; i <= k; i++) {       b[i] = b[i - 1] + b[i - 1] - b[i - d] + a[i - d];       b[i] = ((b[i] % 1000000007) + 1000000007) % 1000000007;     }     for (int i = k + 1; i <= n; i++) {       b[i] = b[i - 1] + b[i - 1] - b[i - d] + a[i - d] - a[i - k - 1];       b[i] = ((b[i] % 1000000007) + 1000000007) % 1000000007;     }     cout << b[n] << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void read(T &a) {     T x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     a = x * f;   }   template <typename T, typename... Args>   void read(T &t, Args &...args) {     read(t);     read(args...);   }   long long n, k, a[100005];   struct node {     long long len, k;     bool operator<(const node &x) const {       long long tmp1 = (len / k) * (len / k) * (k - len % k) +                        (len / k + 1) * (len / k + 1) * (len % k);       long long tmp2 = (x.len / x.k) * (x.len / x.k) * (x.k - x.len % x.k) +                        (x.len / x.k + 1) * (x.len / x.k + 1) * (x.len % x.k);       long long kk = k + 1;       long long tmpp1 = (len / kk) * (len / kk) * (kk - len % kk) +                         (len / kk + 1) * (len / kk + 1) * (len % kk);       kk = x.k + 1;       long long tmpp2 = (x.len / kk) * (x.len / kk) * (kk - x.len % kk) +                         (x.len / kk + 1) * (x.len / kk + 1) * (x.len % kk);       tmp1 -= tmpp1;       tmp2 -= tmpp2;       if (k == len) tmp1 = 0;       if (x.k == x.len) tmp2 = 0;       return tmp1 < tmp2;     }   };   priority_queue<node> q;   void update(long long &ans, node &x) {     ans -= (x.len / x.k) * (x.len / x.k) * (x.k - x.len % x.k) +            (x.len / x.k + 1) * (x.len / x.k + 1) * (x.len % x.k);     x.k++;     ans += (x.len / x.k) * (x.len / x.k) * (x.k - x.len % x.k) +            (x.len / x.k + 1) * (x.len / x.k + 1) * (x.len % x.k);   }   signed main() {     read(n, k);     long long ans = 0;     for (long long i = 1; i <= n; i++) {       read(a[i]);       node tmp;       tmp.len = a[i];       tmp.k = 1;       q.push(tmp);     }     for (long long i = 1; i <= n; i++) ans += a[i] * a[i];     k -= n;     while (k) {       k += 19260817;       node x = q.top();       q.pop();       update(ans, x);       q.push(x);       k -= 19260818;     }     printf( %lld n , ans +  O  -  O );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, l, v1, v2, k;   long double dn, dl, dv1, dv2, dk;   long long times;   long double x;   double T;   int main() {     scanf( %lld%lld%lld%lld%lld , &n, &l, &v1, &v2, &k);     dn = n;     dl = l;     dv1 = v1;     dv2 = v2;     dk = k;     times = (n - 1) / k + 1;     x = l / (v2 * times - (dv2 - dv1) / (dv2 + dv1) * dv2 * (times - 1));     T = x * (times + (dv2 - dv1) / (dv2 + dv1) * (times - 1));     printf( %lf n , T);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const N = 3e5;   int n, p1[N], p2[N], p3[N], num1[N], num2[N], F[N][2], T[N * 4];   void buildT(int v, int tl, int tr) {     if (tl == tr) {       T[v] = 1;     } else {       int tm = (tl + tr) / 2;       buildT(v * 2, tl, tm);       buildT(v * 2 + 1, tm + 1, tr);       T[v] = T[v * 2] + T[v * 2 + 1];     }   }   void updT(int v, int tl, int tr, int p) {     if (tl == tr) {       T[v] = 0;     } else {       int tm = (tl + tr) / 2;       if (tm >= p)         updT(v * 2, tl, tm, p);       else         updT(v * 2 + 1, tm + 1, tr, p);       T[v] = T[v * 2] + T[v * 2 + 1];     }   }   int getT(int v, int tl, int tr, int k) {     if (tl == tr) {       return tl;     } else {       int tm = (tl + tr) / 2;       if (T[v * 2] >= k)         return getT(v * 2, tl, tm, k);       else         return getT(v * 2 + 1, tm + 1, tr, k - T[v * 2]);     }   }   void upd(int x, int t) {     while (x < n) {       ++F[x][t];       x |= (x + 1);     }   }   int get(int x, int t) {     int r = 0;     while (x >= 0) {       r += F[x][t];       x = (x & (x + 1)) - 1;     }     return r;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , &p1[i]);     for (int i = 0; i < n; ++i) scanf( %d , &p2[i]);     for (int i = 0; i < n; ++i) {       num1[i] = p1[i] - get(p1[i], 0);       upd(p1[i] + 1, 0);       num2[i] = p2[i] - get(p2[i], 1);       upd(p2[i] + 1, 1);     }     for (int i = n - 1; i >= 0; --i) {       num1[i] += num2[i];       if (i) num1[i - 1] += num1[i] / (n - i);       num1[i] %= (n - i);     }     buildT(1, 0, n - 1);     for (int i = 0; i < n; ++i) {       int need = num1[i] + 1;       int val = getT(1, 0, n - 1, need);       p3[i] = val;       updT(1, 0, n - 1, val);     }     for (int i = 0; i < n; ++i) printf( %d  , p3[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v;   long long x, y, z, a, b, c, sum, ans, total, t, cnt, n, m, k, p, kase;   string s1, s2;   map<long long, long long> mp;   set<long long> s;   map<long long, long long>::iterator itr1, ptr1;   set<long long>::iterator itr, ptr;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> t;     while (t--) {       long long x1, x2, y1, y2;       cin >> x1 >> y1 >> x2 >> y2;       ans = abs(x1 - x2);       ans *= abs(y1 - y2);       cout << ans + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10;   long long n, sum, n1, pick, ans, t, a[N], b[N], f[N], f1[N], m, t1;   int main() {     scanf( %lld , &n);     for (int i = 1; i <= 8; i++) {       scanf( %lld , &a[i]);       sum = sum + a[i] * i;     }     if (sum <= n) return printf( %lld n , sum), 0;     n1 = std::max((long long)0, n - 840), n = n - n1;     for (int i = 1; i <= 8; i++) {       if (a[i] < n1 / i)         pick = a[i];       else         pick = n1 / i;       if (a[i] - pick < 10) pick = std::max((long long)0, a[i] - 10);       ans = ans + pick * i, n1 = n1 - pick * i, a[i] = a[i] - pick;     }     n += n1;     for (int i = 1; i <= 8; i++) {       t = 1;       while (a[i] > 0) {         t1 = std::min(t, a[i]);         a[i] = a[i] - t1;         f[++m] = t1 * i;         t <<= 1;       }     }     for (long long i = 1; i <= m; i++)       for (long long j = n; j >= f[i]; j--)         f1[j] = std::max(f1[j], f1[j - f[i]] + f[i]);     printf( %lld n , ans + f1[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string st[5050];   int fr[27];   int main() {     memset(fr, 0, sizeof(fr));     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, k;     cin >> k >> n;     for (int i = 0; i < k; i++) {       cin >> st[i];     }     string res = st[0];     memset(fr, 0, sizeof(fr));     bool du = false;     for (int i = 0; i < n; i++) {       fr[res[i] -  a ]++;       if (fr[res[i] -  a ] > 1) {         du = true;       }     }     int ma = 0;     int mi = 0;     bool po = true;     for (int i = 1; i < k; i++) {       int df = 0;       int ct[27] = {0};       for (int j = 0; j < n; j++) {         ct[st[i][j] -  a ]++;         if (st[i][j] != res[j]) {           df++;         }       }       if (df > 4) {         po = false;         break;       }       for (int j = 0; j < 27; j++) {         if (ct[j] != fr[j]) {           po = false;           break;         }       }       if (df > ma) {         ma = df;         mi = i;       }     }     if (!po) {       cout << -1 <<   n ;       return 0;     }     if (ma == 0) {       swap(res[0], res[1]);       cout << res <<   n ;       return 0;     }     if (ma == 2) {       if (!du) {         cout << -1 <<   n ;         return 0;         cout << -1 <<   n ;         return 0;       }       cout << res <<   n ;       return 0;     }     int q[4];     int ctr = 0;     for (int i = 0; i < n; i++) {       if (res[i] != st[mi][i]) {         q[ctr++] = i;       }     }     po = false;     int tr[2] = {0, 0};     for (int id = 0; id < 3; id++) {       if (ma < 4) {         q[3] = q[id];       } else if (id > 0)         break;       for (int i = 0; i < 4; i++) {         for (int j = 0; j < 4; j++) {           if (po) break;           int md = 0;           swap(res[q[i]], res[q[j]]);           for (int c = 1; c < k; c++) {             int df = 0;             for (int l = 0; l < n; l++) {               if (res[l] != st[c][l]) {                 df++;               }             }             md = max(md, df);           }           swap(res[q[i]], res[q[j]]);           if (md == 2) {             po = true;             tr[0] = i;             tr[1] = j;           }         }       }     }     if (po) {       swap(res[q[tr[0]]], res[q[tr[1]]]);       cout << res <<   n ;     } else {       cout << -1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[5];   int main() {     scanf( %d%d%d%d , &a[0], &a[1], &a[2], &a[3]);     while (a[0] != 1 || a[1] != 1 || a[2] != 1 || a[3] != 1) {       bool f = 1;       for (int i = 0; i < 4; i++)         if (a[i] % 2 == 0 && a[(i + 1) % 4] % 2 == 0) {           printf( /%d n , i + 1);           a[i] >>= 1;           a[(i + 1) % 4] >>= 1;           f = 0;           break;         }       if (f) {         for (int i = 0; i < 4; i++)           if (a[i] % 2 == 1 && a[(i + 1) % 4] % 2 == 1 &&               !(a[i] == 1 && a[(i + 1) % 4] == 1)) {             a[i]++;             a[(i + 1) % 4]++;             printf( +%d n , i + 1);             f = 0;             break;           }         if (f)           for (int i = 0; i < 4; i++)             if (a[i] % 2 == 1 && a[(i + 1) % 4] % 2 == 0 &&                 a[(i + 2) % 4] % 2 == 1) {               printf( +%d n+%d n , i + 1, (i + 1) % 4 + 1);               a[i]++;               a[(i + 2) % 4]++;               a[(i + 1) % 4] += 2;               break;             }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string multiply(string num1, string num2) {     int len1 = num1.size();     int len2 = num2.size();     if (len1 == 0 || len2 == 0) return  0 ;     vector<int> result(len1 + len2, 0);     int i_n1 = 0;     int i_n2 = 0;     for (int i = len1 - 1; i >= 0; i--) {       int carry = 0;       int n1 = num1[i] -  0 ;       i_n2 = 0;       for (int j = len2 - 1; j >= 0; j--) {         int n2 = num2[j] -  0 ;         int sum = n1 * n2 + result[i_n1 + i_n2] + carry;         carry = sum / 10;         result[i_n1 + i_n2] = sum % 10;         i_n2++;       }       if (carry > 0) result[i_n1 + i_n2] += carry;       i_n1++;     }     int i = result.size() - 1;     while (i >= 0 && result[i] == 0) i--;     if (i == -1) return  0 ;     string s =   ;     while (i >= 0) s += std::to_string(result[i--]);     return s;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int T;     cin >> T;     while (T--) {       long int n;       cin >> n;       n = n / 2;       string n1, n2, n3, ans1, ans;       int temp;       if (n % 3 == 0) {         temp = 4 * n / 3;         n1 = to_string(temp);         n2 = to_string(n + 1);         n3 = to_string(2 * n + 1);         ans1 = multiply(n1, n2);         ans = multiply(ans1, n3);       } else if (n % 3 == 2) {         temp = 4 * (n + 1) / 3;         n1 = to_string(temp);         n2 = to_string(n);         n3 = to_string(2 * n + 1);         ans1 = multiply(n1, n2);         ans = multiply(ans1, n3);       } else {         temp = 4 * (2 * n + 1) / 3;         n1 = to_string(temp);         n2 = to_string(n + 1);         n3 = to_string(n);         ans1 = multiply(n1, n2);         ans = multiply(ans1, n3);       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int n, x[N], y[N], xs[N], ys[N], cnt[2][2];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &x[i], &y[i]);       xs[i] = x[i], ys[i] = y[i];     }     sort(xs + 1, xs + n + 1);     sort(ys + 1, ys + n + 1);     int m = (n + 1) / 2;     int cx = xs[m], cy = ys[m];     int dx = xs[m + 1] - xs[m], dy = ys[m + 1] - ys[m];     if (n & 1) {       dx = min(dx, xs[m] - xs[m - 1]);       dy = min(dy, ys[m] - ys[m - 1]);     }     long long ans = 0;     bool flag = 0;     for (int i = 1; i <= n; i++) {       ans += abs(x[i] - cx) + abs(y[i] - cy);       ++cnt[x[i] <= cx][y[i] <= cy];       if (x[i] == cx && y[i] == cy) flag = 1;     }     if (cnt[0][0] && cnt[0][1] && cnt[1][1] && cnt[1][0]) {       if (n % 2 == 0 || flag) ans -= min(dx, dy);     }     printf( %lld n , ans * 2);   }
#include <bits/stdc++.h>   using namespace std;   long long scan_d() {     char t = getchar();     long long you = 0;     while (t >  9  || t <  0 ) t = getchar();     while (t <=  9  && t >=  0 ) {       you *= 10;       you += t -  0 ;       t = getchar();     }     return you;   }   long long dp[1050][1050];   long long op[1001];   int main() {     for (int i = 0; i <= 1010; i++) dp[1][i] = 1;     for (int i = 2; i <= 1010; i++)       for (int o = i - 1; o <= 1010; o++) {         dp[i][o] = dp[i - 1][o - 1] + dp[i][o - 1];         dp[i][o] %= 1000000007;       }     long long y;     y = scan_d();     long long sum = 0;     for (int i = 1; i <= y; i++) {       op[i] = scan_d();     }     long long ans = 1;     for (int i = 1; i <= y; i++) {       sum += op[i];       ans *= dp[op[i]][sum - 1];       ans %= 1000000007;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void read(T &x) {     int f = 0;     x = 0;     char ch = getchar();     for (; !isdigit(ch); ch = getchar()) f |= (ch ==  - );     for (; isdigit(ch); ch = getchar()) x = x * 10 + ch -  0 ;     if (f) x = -x;   }   const int N = 20, mod = 998244353;   int f[N][N][N][N][2][2];   int g[N][N][N][N][2][2];   int x[N], y[N], n, m;   void add(int &x, int y) { x = (x + y >= mod ? x + y - mod : x + y); }   int main() {     read(n), read(m);     for (int i = (1); i <= (n); i++) read(x[i]), read(y[i]);     f[0][0][0][0][0][0] = 1;     for (; m; m >>= 1) {       memset(g, 0, sizeof g);       for (int px = 0; px < (N); px++)         for (int nx = 0; nx < (N); nx++)           for (int py = 0; py < (N); py++)             for (int ny = 0; ny < (N); ny++)               for (int fx = 0; fx < (2); fx++)                 for (int fy = 0; fy < (2); fy++) {                   int t = f[px][nx][py][ny][fx][fy];                   if (!t) continue;                   for (int s = 0; s < (1 << n); s++) {                     int Px = px, Nx = nx, Py = py, Ny = ny;                     for (int i = (1); i <= (n); i++)                       if (s >> (i - 1) & 1) {                         Px += max(x[i], 0);                         Nx -= min(x[i], 0);                         Py += max(y[i], 0);                         Ny -= min(y[i], 0);                       }                     if ((Px & 1) != (Nx & 1) || (Py & 1) != (Ny & 1)) continue;                     int gx =                         ((Px & 1) < (m & 1) ? 0 : ((Px & 1) > (m & 1) ? 1 : fx));                     int gy =                         ((Py & 1) < (m & 1) ? 0 : ((Py & 1) > (m & 1) ? 1 : fy));                     Px >>= 1, Nx >>= 1, Py >>= 1, Ny >>= 1;                     add(g[Px][Nx][Py][Ny][gx][gy], t);                   }                 }       swap(f, g);     }     cout << ((f[0][0][0][0][0][0] + mod - 1) % mod) << endl;     return 0;   }