malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool f[110][110][2][60];   int main() {     string str;     cin >> str;     int n = str.size();     int m;     cin >> m;     memset(f, 0, sizeof(f));     f[0][0][1][0] = 1;     for (int i = 0; i < n; i++) {       char ch = str[i];       for (int dist = 0; dist <= n; dist++)         for (int dir = 0; dir <= 1; dir++)           for (int opr = 0; opr <= m; opr++)             if (f[i][dist][dir][opr])               if (ch ==  F ) {                 int delta = dir ? 1 : -1;                 if (dist == 0)                   f[i + 1][1][1][opr] = 1;                 else                   f[i + 1][dist + delta][dir][opr] = 1;                 f[i + 1][dist][1 - dir][opr + 1] = 1;               } else {                 f[i + 1][dist][1 - dir][opr] = 1;                 int delta = dir ? 1 : -1;                 if (dist == 0)                   f[i + 1][1][1][opr + 1] = 1;                 else                   f[i + 1][dist + delta][dir][opr + 1] = 1;               }     }     int ans = 0;     for (int dist = 0; dist <= n; dist++)       for (int dir = 0; dir <= 1; dir++)         for (int opr = m; opr >= 0; opr -= 2)           if (f[n][dist][dir][opr]) ans = ((ans) > (dist) ? (ans) : (dist));     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     int p = n - a[0];     for (int i = 1; i < n; i++) {       if (i & 1) {         a[i] -= p;         a[i] += (n * 1000000);         a[i] = a[i] % n;         if (a[i] != i) {           cout <<  No ;           return 0;         }       } else {         a[i] += p;         a[i] %= n;         if (a[i] != i) {           cout <<  No ;           return 0;         }       }     }     cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<int> v[1001];     int n, k, r;     while (scanf( %d , &n) != EOF) {       for (int i = 1; i <= n; i++) {         v[i].clear();         scanf( %d , &k);         while (k--) {           scanf( %d , &r);           v[i].push_back(r);         }         sort(v[i].begin(), v[i].end());       }       int ans = 0;       for (int i = 1; i <= n; i++) {         int pre = i - 1;         pre = pre == 0 ? n : pre;         int next = i + 1;         next = next == n + 1 ? 1 : next;         for (int j = 1; j < v[i].size(); j++) {           int x = upper_bound(v[pre].begin(), v[pre].end(), v[i][j]) -                   upper_bound(v[pre].begin(), v[pre].end(), v[i][j - 1]);           int y = upper_bound(v[next].begin(), v[next].end(), v[i][j]) -                   upper_bound(v[next].begin(), v[next].end(), v[i][j - 1]);           if (x != y) ans++;         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, d, i, e, f, g, n, m, k, l, r;   long long go(long long x) {     k = 1;     n = 0;     m = 0;     for (long long i = 1;; i++) {       if (x <= 0)         return ((m * (m + 1)) % 1000000007 + (n * n) % 1000000007) % 1000000007;       if (i % 2 == 1) {         n += min(k, x);         n %= 1000000007;         x -= k;       } else {         m += min(k, x);         m %= 1000000007;         x -= k;       }       k *= 2;     }   }   int main() {     cin >> l >> r;     cout << (1000000007 + go(r) - go(l - 1)) % 1000000007;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0;   const double eps = 0;   const int ms = 0;   const int md = 0;   const int MAX_N = 1e5 + 5;   const int MAX_L = 20;   const long long MOD = 1e9 + 7;   const long long INF = 1e9 + 7;   long long mpow(long long k) {     long long ans = 1;     while (k > 0) {       ans *= 10;       k--;     }     return ans;   }   long long countNines(long long n) {     long long ans = 0;     while (n > 0) {       if (n % 10 == 9) {         ans++;       } else         break;       n /= 10;     }     return ans;   }   int main() {     long long p, d;     cin >> p >> d;     int k = 1;     long long ans = -1;     while ((p - p % mpow(k) - 1) > 0) {       if ((p - p % mpow(k) - 1) >= p - d) {         ans = p - p % mpow(k) - 1;       }       k++;     }     if (countNines(ans) > countNines(p))       cout << ans << endl;     else       cout << p << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e3 + 5;   int main() {     int num, r;     cin >> num >> r;     vector<pair<int, int>> arr(num + 1);     vector<bool> visited(r + 2, 0);     for (int i = 1; i <= num; ++i) {       cin >> arr[i].first >> arr[i].second;       for (int j = arr[i].first; j <= arr[i].second; ++j) {         visited[j] = 1;       }     }     long long ans = 0;     for (int k = 1; k <= r; ++k) {       if (visited[k] == 0) ans++;     }     cout << ans <<   n ;     for (int k = 1; k <= r; ++k) {       if (visited[k] == 0) cout << k <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long mod1 = 998244353;   const double pie = 3.1415926535;   long long power(long long x, long long y) {     if (y == 0)       return 1;     else {       if (y % 2 == 0)         return power(x * x, y / 2);       else         return x * power(x * x, (y - 1) / 2);     }   }   long long mod_power(long long x, long long y, long long m) {     long long r = 1;     x = x % m;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) r = (r * x) % m;       y = y / 2;       x = (x * x) % m;     }     return r;   }   long long gcd(long long x, long long y) {     if (y == 0) return x;     return gcd(y, x % y);   }   vector<long long> extended_Euclid(long long a, long long b) {     vector<long long> v(3);     if (b == 0) {       v[0] = a;       v[1] = 1;       v[2] = 0;       return v;     } else {       vector<long long> v1 = extended_Euclid(b, a % b);       v[0] = v1[0];       v[1] = v1[2];       v[2] = v1[1] - (a / b) * v1[2];       return v;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int TESTS = 1;     while (TESTS--) {       int n;       cin >> n;       map<int, vector<int> > M;       for (int i = 1; i <= n; i++) {         int x, y;         cin >> x >> y;         M[i].push_back(x);         M[i].push_back(y);       }       vector<int> ans;       ans.push_back(1);       int x = M[1][0];       int y = M[1][1];       int j;       if (find(M[x].begin(), M[x].end(), y) != M[x].end()) {         ans.push_back(x);         ans.push_back(y);         j = x;       } else {         ans.push_back(y);         ans.push_back(x);         j = y;       }       for (int i = 1; i <= n; i++) {         if (ans.size() == n)           break;         else {           if (M[j][0] == ans[ans.size() - 1])             ans.push_back(M[j][1]);           else             ans.push_back(M[j][0]);           j = ans[ans.size() - 2];         }       }       for (int i = 0; i < ans.size(); i++) cout << ans[i] <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100012, H = 20;   vector<int> e[N], g[N];   stack<int> Z;   int n, m, tot, tim, low[N], rea[N], f[N], d[N];   int fa[N][H], k;   bool v[N];   void dfs(int fa, int now) {     low[now] = rea[now] = tim++;     v[now] = true;     Z.push(now);     int top = int(e[now].size());     for (int i = 0; i < top; ++i) {       int next = e[now][i];       if (next != fa) {         if (!v[next]) dfs(now, next);         low[now] = min(low[now], low[next]);       }     }     if (low[now] == rea[now]) {       int last = -1;       ++tot;       while (last != now) {         last = Z.top();         f[last] = tot;         Z.pop();       }     }   }   void work(int now, int p) {     fa[now][0] = p;     int top = int(g[now].size());     for (int j = 0; j < top; ++j)       if (fa[now][0] != g[now][j])         d[g[now][j]] = d[now] + 1, work(g[now][j], now);   }   void gao() {     for (int j = 1; j < H; ++j)       for (int i = 1; i <= tot; ++i) fa[i][j] = fa[fa[i][j - 1]][j - 1];   }   inline int find(int x, int y) {     if (d[x] < d[y]) swap(x, y);     for (int i = H - 1; i >= 0; --i)       if (d[fa[x][i]] >= d[y]) x = fa[x][i];     if (x == y) return x;     for (int i = H - 1; i >= 0; --i)       if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];     return fa[x][0];   }   int main() {     scanf( %d%d , &n, &m);     int a, b;     for (int i = 1; i <= m; ++i) {       scanf( %d%d , &a, &b);       e[a].push_back(b);       e[b].push_back(a);     }     for (int i = 1; i <= n; ++i)       if (!v[i]) dfs(-1, i);     for (int a = 1; a <= n; ++a)       for (int j = 0, top = int(e[a].size()); j < top; ++j) {         b = e[a][j];         if (f[a] != f[b]) {           g[f[a]].push_back(f[b]);           g[f[b]].push_back(f[a]);         }       }     d[0] = 0;     d[f[1]] = 1;     work(f[1], 0);     gao();     scanf( %d n , &k);     for (int i = 1; i <= k; ++i) {       scanf( %d%d , &a, &b);       a = f[a];       b = f[b];       int c = find(a, b);       printf( %d n , d[a] + d[b] - 2 * d[c]);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   vector<vector<int>> g(N);   bool isDeleted[N];   vector<int> res;   void del(int s, int p) {     res.push_back(s);     isDeleted[s] = true;     for (auto I : g[s]) {       if (!isDeleted[I] && I != p) {         del(I, s);       }     }   }   bool dfs(int s, int p) {     int siz = g[s].size();     for (auto I : g[s]) {       if (I != p) {         bool isDeleted = dfs(I, s);         if (isDeleted) {           --siz;         }       }     }     if (siz % 2 == 0) {       del(s, p);       return true;     } else       return false;   }   int main() {     int n, x;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , &x);       if (x) {         g[i].push_back(x - 1);         g[x - 1].push_back(i);       }     }     bool ans = dfs(0, -1);     if (ans) {       printf( YES n );       for (auto I : res) {         printf( %d n , I + 1);       }     } else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long sum = 0;     string s;     cin >> s;     s +=  a ;     int now_number = 0, buf_number = 0, size_buf = 0, point = 0;     for (int i = 0; i < s.size(); ++i) {       if (s[i] >=  a  && s[i] <=  z ) {         now_number = now_number * pow(10, size_buf) + buf_number;         buf_number = 0;         if (size_buf != 2 || !point) {           now_number *= 100;         }         size_buf = 0;         sum += now_number;         now_number = 0;         point = 0;       } else {         if (s[i] ==  . ) {           now_number = now_number * pow(10, size_buf) + buf_number;           buf_number = 0;           size_buf = 0;           point = 1;         } else {           buf_number = buf_number * 10 + (s[i] -  0 );           size_buf++;         }       }     }     int kop = sum % 100;     sum /= 100;     if (sum == 0) {       cout <<  0.  << kop / 10 << kop % 10;       return 0;     }     vector<string> ss;     while (sum != 0) {       int tri = sum % 1000;       sum /= 1000;       string ans =   ;       if (sum != 0) {         ans = (char)(tri % 10 + 48) + ans;         tri /= 10;         ans = (char)(tri % 10 + 48) + ans;         tri /= 10;         ans = (char)(tri % 10 + 48) + ans;         tri /= 10;       } else {         ans = to_string(tri);       }       ss.push_back(ans);     }     reverse(ss.begin(), ss.end());     for (int i = 0; i < ss.size(); ++i) {       if (i == ss.size() - 1) {         cout << ss[i];       } else {         cout << ss[i] <<  . ;       }     }     if (kop != 0) {       cout <<  .  << kop / 10 << kop % 10;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1024;   int n;   int a[maxn], b[maxn], c[maxn];   vector<int> g[maxn];   vector<pair<pair<int, int>, int> > ans;   void add(int v, int u, int x) { ans.push_back({{v, u}, x}); }   int gfs(int v, int par, int d) {     if (g[v].size() == 1) return v;     for (int i : g[v]) {       int u = a[i] + b[i] - v;       if (u != par and u != d) {         int res = gfs(u, v, d);         if (res != -1) return res;       }     }     return -1;   }   pair<int, int> gpr(int v, int d) {     pair<int, int> ret = {-1, -1};     for (int i : g[v]) {       int u = a[i] + b[i] - v;       if (u != d) {         int l = gfs(u, v, d);         if (l != -1) {           if (ret.first == -1)             ret.first = l;           else             ret.second = l;         }       }     }     return ret;   }   void see(int v, int u, int x) {     pair<int, int> vp = gpr(v, u);     pair<int, int> up = gpr(u, v);     add(vp.first, up.first, x / 2);     add(vp.second, up.second, x / 2);     add(vp.first, vp.second, -x / 2);     add(up.first, up.second, -x / 2);   }   void zee(int v, int d, int x) {     pair<int, int> vp = gpr(d, v);     add(vp.first, v, x / 2);     add(vp.second, v, x / 2);     add(vp.first, vp.second, -x / 2);   }   void dfs(int v, int par = -1, int lst = -1, int x = 0) {     if (g[v].size() > 2) {       if (lst != -1) see(v, lst, x);       lst = v;     } else if (g[v].size() == 1) {       zee(v, lst, x);     }     for (int i : g[v]) {       int u = a[i] + b[i] - v;       if (u != par) {         dfs(u, v, lst, c[i]);       }     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 0; i < n - 1; i++) {       cin >> a[i] >> b[i] >> c[i];       a[i]--, b[i]--;       g[a[i]].push_back(i);       g[b[i]].push_back(i);     }     for (int i = 0; i < n; i++)       if (g[i].size() == 2) {         if (c[g[i][0]] != c[g[i][1]]) {           cout <<  NO  << endl;           return 0;         }       }     cout <<  YES  << endl;     vector<int> lv;     int r = -1;     for (int i = 0; i < n; i++)       if (g[i].size() > 2)         r = i;       else if (g[i].size() == 1)         lv.push_back(i);     if (r == -1) {       cout << 1 << endl;       cout << lv[0] + 1 <<     << lv[1] + 1 <<     << c[0] << endl;       return 0;     }     dfs(r);     cout << ans.size() << endl;     for (auto p : ans)       cout << p.first.first + 1 <<     << p.first.second + 1 <<     << p.second            <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int t = 0, ans = 100000, a;     for (int i = (0); i < (n); ++i)       if (s[i] ==  T ) t++;     for (int i = (0); i < (n); ++i) {       a = 0;       for (int j = (i); j < (i + t); ++j) {         if (s[j % n] ==  H ) a++;       }       ans = min(ans, a);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     cin >> a[0];     int count = a[0];     int max = a[0];     for (int i = 1; i < n; i++) {       cin >> a[i];     }     for (int i = 1; i < n; i++) {       count = count + a[i] - a[i - 1];       if (max < count) max = count;     }     cout << max;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5, M = 5;   int cc[N][M], sz[N], k;   long long ret[N], sum = 0;   vector<int> adj[N];   long long dfs(int x, int p) {     int t, v, j, u, i;     sz[x] = 1;     long long R = 0, temp;     for (i = 0; i < adj[x].size(); ++i) {       u = adj[x][i];       if (u != p) {         temp = dfs(u, x);         sum += sz[u] * R;         R += temp;         sum += temp * sz[x];         for (j = 0; j < k; ++j)           for (t = 0; t < k; ++t) {             if (j + t + 2 <= k) sum -= (long long)cc[x][j] * cc[u][t];           }         for (j = 0; j < k; ++j) cc[x][j] += cc[u][j];         sz[x] += sz[u];       }     }     u = ++cc[x][k - 1];     for (i = k - 2; i >= 0; --i) cc[x][i + 1] = cc[x][i];     cc[x][0] = u;     ret[x] = R + u;     return ret[x];   }   int main() {     int n, i, j, u, v, a, b;     cin >> n >> k;     for (i = 0; i < n - 1; ++i) {       scanf( %d%d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     dfs(1, 0);     cout << sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int sum = 0;     for (int i = 0; i < n; i++) {       int c;       cin >> c;       sum = sum + c;     }     n = n + 1;     int count = 0;     for (int j = 1; j <= 5; j++) {       int flag = 0;       int s = sum + j;       if (s % n == 1) flag = 1;       if (flag == 0) count++;     }     cout << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v;   long long n, m, w, ai;   long long cnt[300005];   bool go(long long mx) {     memset(cnt, 0, sizeof cnt);     long long use = m;     long long add = 0;     for (int i = 0; i < n; i++) {       add += cnt[i];       long long curr = v[i] + add;       if (curr >= mx) continue;       if (mx - curr > use) return 0;       add += (mx - curr);       cnt[i + w] -= (mx - curr);       use -= (mx - curr);     }     return 1;   }   int main() {     cin >> n >> m >> w;     for (int i = 0; i < n; i++) {       cin >> ai;       v.push_back(ai);     }     long long l = 1, r = 10000000000ll, bst = -1;     while (l <= r) {       long long mid = (l + r) / 2ll;       if (go(mid)) {         bst = mid;         l = mid + 1;       } else         r = mid - 1;     }     cout << bst;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 200;   int num[MAX], vis[MAX];   int main() {     int n, m, a;     while (scanf( %d %d , &n, &m) == 2) {       memset(vis, 0, sizeof(vis));       for (int i = 0; i < m; i++) {         scanf( %d , &a);         for (int i = a; i <= n; i++)           if (!vis[i]) {             num[i] = a;             vis[i] = 1;           }       }       for (int i = 1; i <= n; i++) {         if (i == 1)           printf( %d , num[i]);         else           printf(  %d , num[i]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5, inf = 9e8;   int n, a[N];   array<int, 3> vals[N];   void compress(int arr[]) {     vector<int> all;     for (int i = 1; i <= n; i++) all.push_back(arr[i]);     sort(all.begin(), all.end());     for (int i = 1; i <= n; i++)       arr[i] = lower_bound(all.begin(), all.end(), arr[i]) - all.begin(),       ++arr[i];   }   class segTree {    private:     int n;     vector<int> st;       public:     void init(int _n) {       n = _n;       st = vector<int>(4 * n + 5, 0);     }     void pointUpdate(int node, int tl, int tr, int pos, int val) {       if (tl == tr) {         st[node] = max(st[node], val);       } else {         int mid = (tl + tr) / 2;         if (pos <= mid)           pointUpdate(2 * node, tl, mid, pos, val);         else           pointUpdate(2 * node + 1, mid + 1, tr, pos, val);         st[node] = max(st[2 * node], st[2 * node + 1]);       }     }     int rangeQuery(int node, int tl, int tr, int l, int r) {       if (l > r) return -inf;       if ((l == tl) && (r == tr)) return st[node];       int mid = (tl + tr) / 2;       int left_ans = rangeQuery(2 * node, tl, mid, l, min(r, mid));       int right_ans = rangeQuery(2 * node + 1, mid + 1, tr, max(l, mid + 1), r);       return max(left_ans, right_ans);     }     void update(int pos, int val) { pointUpdate(1, 1, n, pos, val); }     int query(int l, int r) {       r = min(r, n);       return rangeQuery(1, 1, n, l, r);     }   } rangeMax;   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     compress(a);     for (int i = 1; i <= n; i++) vals[i][0] = a[i];     for (int i = 1; i <= n; i++) cin >> a[i];     compress(a);     for (int i = 1; i <= n; i++) vals[i][1] = a[i];     for (int i = 1; i <= n; i++) cin >> a[i];     compress(a);     for (int i = 1; i <= n; i++) vals[i][2] = a[i];     rangeMax.init(N);     sort(vals + 1, vals + n + 1);     reverse(vals + 1, vals + n + 1);     int ans = 0;     int j = 1;     for (int i = 1; i <= n; i = j) {       while (j <= n && vals[i][0] == vals[j][0]) ++j;       for (int k = i; k < j; k++) {         int max_c_for_all_valid_b = rangeMax.query(vals[k][1] + 1, inf);         if (max_c_for_all_valid_b > vals[k][2]) ++ans;       }       for (int k = i; k < j; k++) {         rangeMax.update(vals[k][1], vals[k][2]);       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int mod = 1000000007;   int gcd(int a, int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   int prime(long long int n) {     long long int i;     for (i = 2; i <= sqrt(n); i++) {       if (n % i == 0) return 0;     }     return 1;   }   long long int ans[1000000], c = 0;   void get_num(long long int n) {     long long int i;     for (i = 2; i <= sqrt(n); i++) {       if (n % i == 0) {         if (prime(i)) ans[c++] = i;         if (prime(n / i)) {           if (n / i != i) ans[c++] = i;         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int n;     cin >> n;     get_num(n);     if (c == 0)       cout << n;     else if (c == 1)       cout << ans[0];     else       cout << 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool viz[105][105];   int dx[4] = {0, 1, 0, -1};   int dy[4] = {1, 0, -1, 0};   int main() {     cin.tie(0)->sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int T = 1;     while (T--) {       int n, m, x, y;       cin >> n >> m >> x >> y;       vector<pair<int, int> > sol;       viz[x][y] = 1;       cout << x <<     << y <<   n ;       int cnt = 1;       for (int j = 1; j <= m; j++) {         if (j != y) {           cout << x <<     << j <<   n ;         }       }       for (int i = x + 1; i <= n; i++) {         if (cnt % 2 == 1) {           for (int j = m; j >= 1; j--) {             cout << i <<     << j <<   n ;           }         } else {           for (int j = 1; j <= m; j++) {             cout << i <<     << j <<   n ;           }         }         cnt++;       }       for (int i = x - 1; i >= 1; i--) {         if (cnt % 2 == 1) {           for (int j = m; j >= 1; j--) {             cout << i <<     << j <<   n ;           }         } else {           for (int j = 1; j <= m; j++) {             cout << i <<     << j <<   n ;           }         }         cnt++;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ;     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int t;     cin >> t;     while (t--) {       long long a, b, c;       cin >> a >> b >> c;       long long cnt = 0;       while (1) {         if (a > c || b > c) break;         if (a > b) {           b += a;         } else           a += b;         cnt++;       }       cout << cnt << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 21, mod = 998244353;   long long f[32][N][N][N][N][2][2], ans, lim;   int n, m, x[7], y[7], pa, pb, pc, pd;   int main() {     scanf( %d%d , &n, &m), ******* f = 1, lim = (1 << n) - 1;     for (int i = 1, ie = n; i <= ie; i++)       scanf( %d%d , &x[i], &y[i]), pa += max(x[i], 0), pb -= min(x[i], 0),           pc += max(y[i], 0), pd -= min(y[i], 0);     for (int i = 0, ie = 30; i <= ie; i++)       for (int j = 0, je = lim; j <= je; j++) {         int la = 0, lb = 0, lc = 0, ld = 0, f1, f2, fl = (m >> i) & 1;         for (int li = 1, lie = n; li <= lie; li++)           if (j & (1 << li - 1))             la += max(x[li], 0), lb -= min(x[li], 0), lc += max(y[li], 0),                 ld -= min(y[li], 0);         for (int li = 0, lie = pa; li <= lie; li++)           for (int lj = 0, lje = pb; lj <= lje; lj++)             for (int ii = 0, iie = pc; ii <= iie; ii++)               for (int jj = 0, jje = pd; jj <= jje; jj++)                 for (int g1 = 0, g1e = 1; g1 <= g1e; g1++)                   for (int g2 = 0, g2e = 1; g2 <= g2e; g2++)                     if (!((li + lj + la + lb) & 1) && !((ii + jj + lc + ld) & 1))                       f1 = g1 + (li + la & 1) > fl, f2 = g2 + (ii + lc & 1) > fl,                       (f[i + 1][li + la >> 1][lj + lb >> 1][ii + lc >> 1]                         [jj + ld >> 1][f1][f2] += f[i][li][lj][ii][jj][g1][g2]) %=                           mod;       }     cout << (f[31][0][0][0][0][0][0] + mod - 1) % mod;     return 0;   }