malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename First>   void debug_print_in(First first) {     cerr << first << endl;     return;   }   template <typename First, typename... Rest>   void debug_print_in(First first, Rest... rest) {     cerr << first <<    ;     debug_print_in(rest...);     return;   }   void IN(void) { return; }   template <typename First, typename... Rest>   void IN(First& first, Rest&... rest) {     cin >> first;     IN(rest...);     return;   }   template <typename First>   void OUT(First first) {     cout << first << endl;     return;   }   template <typename First, typename... Rest>   void OUT(First first, Rest... rest) {     cout << first <<    ;     OUT(rest...);     return;   }   template <class t, class u>   t chmax(t& a, u b) {     if (a < b) a = b;     return a;   };   template <class t, class u>   t chmin(t& a, u b) {     if (a > b) a = b;     return a;   };   int popcount(int t) { return __builtin_popcount(t); }   int popcount(long long t) { return __builtin_popcountll(t); }   template <typename T>   void vec_print(vector<T> VEC) {     for (long long i = (long long)0; i < (long long)VEC.size(); ++i) {       cerr << VEC[i] <<    ;     }     cerr << endl;   };   template <typename T>   void mat_print(vector<vector<T>> MAT) {     for (long long i = (long long)0; i < (long long)MAT.size(); ++i) {       for (long long j = (long long)0; j < (long long)MAT[i].size(); ++j) {         cerr << MAT[i][j] <<    ;       }       cerr << endl;     }   };   constexpr int INF = (1 << 30);   constexpr long long INFLL = 1LL << 62;   constexpr long double EPS = 1e-12;   constexpr long long MOD = (long long)((1E+9) + 7);   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     long long n;     IN(n);     vector<long long> a(n);     for (long long i = (long long)0; i < (long long)n; ++i) IN(a[i]);     vector<long long> d1(n, -1);     vector<long long> d2(n, -1);     vector<long long> primes(1, 2);     for (long long i = 3; i * i <= 2E7; i += 2) {       bool flag = true;       for (long long j = 0; primes[j] * primes[j] <= i; ++j) {         if (i % primes[j] == 0) {           flag = false;           break;         }       }       if (flag) {         primes.push_back(i);       }     }     for (long long i = (long long)0; i < (long long)n; ++i) {       for (long long j = 0; primes[j] * primes[j] < a[i]; ++j) {         long long d1_ = primes[j];         if (a[i] % d1_ != 0) continue;         while (a[i] % d1_ == 0) {           a[i] /= d1_;         }         if (a[i] > 1) {           d1[i] = d1_;           d2[i] = a[i];         }         break;       }     }     for (long long i = (long long)0; i < (long long)n; ++i) {       printf( %lld  , d1[i]);     }     printf(  n );     for (long long i = (long long)0; i < (long long)n; ++i) {       printf( %lld  , d2[i]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     x = 0;     char c = getchar();     bool flag = false;     while (!isdigit(c)) {       if (c ==  - ) flag = true;       c = getchar();     }     while (isdigit(c)) {       x = (x << 1) + (x << 3) + (c ^ 48);       c = getchar();     }     if (flag) x = -x;   }   int n;   int siz[110];   double fac[110], f[110][110], g[110];   struct edge {     int to, nxt;     edge(int a = 0, int b = 0) { to = a, nxt = b; }   } e[110];   int head[110], edge_cnt;   void add(int from, int to) {     e[++edge_cnt] = edge(to, head[from]), head[from] = edge_cnt;   }   double C(int n, int m) { return fac[n] / fac[m] / fac[n - m]; }   void dfs(int x, int fa) {     f[x][0] = siz[x] = 1;     for (int i = head[x]; i; i = e[i].nxt) {       int y = e[i].to;       if (y == fa) continue;       dfs(y, x);       for (int j = 0; j <= siz[y]; ++j)         for (int k = 1; k <= siz[y]; ++k)           f[0][j] += k <= j ? f[y][k - 1] / 2 : f[y][j];       for (int j = siz[x] - 1; j >= 0; --j)         for (int k = siz[y]; k >= 0; --k)           g[j + k] += f[x][j] * f[0][k] * C(j + k, j) *                       C(siz[x] - 1 - j + siz[y] - k, siz[x] - 1 - j);       siz[x] += siz[y];       for (int i = 0; i < siz[x]; ++i) f[x][i] = g[i];       memset(g, 0, sizeof(g)), memset(f[0], 0, sizeof(f[0]));     }   }   int main() {     read(n);     for (int i = 1; i < n; ++i) {       int x, y;       read(x), read(y);       add(x, y), add(y, x);     }     fac[0] = 1;     for (int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * i;     for (int i = 1; i <= n; ++i) {       memset(f, 0, sizeof(f)), dfs(i, 0);       printf( %.10lf n , f[i][n - 1] / fac[n - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int sc[1005];     int n, k, p, x, y;     cin >> n >> k >> p >> x >> y;     for (int i = 1; i <= k; i++) {       cin >> sc[i];       x -= sc[i];     }     if (x < 0) {       cout << -1 << endl;     } else {       int i;       int left_cnt = 0;       int rig_cnt = 0;       int equ_y_num = 0;       int half = n / 2;       sort(sc + 1, sc + k + 1);       for (i = 1; i <= k; i++) {         if (sc[i] < y) {           left_cnt++;         } else if (sc[i] == y) {           equ_y_num++;         } else {           rig_cnt++;         }       }       if (left_cnt > half) {         cout << -1 << endl;         return 0;       }       if (rig_cnt + equ_y_num >= (half + 1)) {         int need = n - k;         if (need > x) {           cout << -1 << endl;           return 0;         } else {           int time = n - k;           while (time--) {             cout << 1 <<    ;           }           cout << endl;           return 0;         }       }       int need = half + 1 - rig_cnt - equ_y_num;       need = need * y;       need += half - left_cnt;       if (need > x) {         cout << -1 << endl;         return 0;       } else {         int time = n - k;         int left_time = half - left_cnt;         while ((left_time--)) {           cout << 1 <<    ;           time--;         }         while ((time--)) {           cout << y <<    ;         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 505;   vector<int> ans;   struct node {     int val, id;     bool operator<(const node &o) const {       if (val == o.val) return id < o.id;       return val < o.val;     }   };   node a[MAXN], b[MAXN];   void doit(int n) {     for (int i = 1; i <= n - 2; i++) {       int id = i;       for (int j = i; j <= n; j++)         if (a[j] < a[id]) id = j;       for (int j = id; j >= i; j--) {         if (j - 2 >= i) {           ans.push_back(j - 2);           swap(a[j], a[j - 1]);           swap(a[j - 1], a[j - 2]);           j--;         } else if (j - 1 >= i) {           ans.push_back(j - 1);           ans.push_back(j - 1);           swap(a[j], a[j - 1]);           swap(a[j], a[j + 1]);         }       }     }   }   void solve() {     ans.clear();     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i].val);       a[i].id = i;     }     memcpy(b, a, sizeof(a));     doit(n);     if (a[n - 1].val > a[n].val) {       memcpy(a, b, sizeof(a));       bool flag = false;       for (int i = 1; i <= n && !flag; i++)         for (int j = i + 1; j <= n && !flag; j++)           if (a[i].val == a[j].val) {             swap(a[i], a[j]);             flag = true;           }       ans.clear();       doit(n);       if (a[n - 1].val > a[n].val) {         puts( -1 );         return;       }     }     printf( %d n , ans.size());     for (auto v : ans) printf( %d  , v);     puts(  );   }   int main() {     int T;     scanf( %d , &T);     while (T--) {       solve();     }     return 0;   }
#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];     }     vector<int> records;     int max = a[0];     records.push_back(0);     int case1 = -1;     int case1_records;     for (int i = 1; i < n; i++) {       if (max < a[i]) {         max = a[i];         records.push_back(i);       } else {         if (case1 == -1) {           case1 = i;         } else {           if (a[case1] > a[i]) {             case1 = i;           }         }       }     }     case1_records = records.size();     records.push_back(n);     int case2 = -1;     int case2_records = -1;     int case2_pos = -1;     for (int i = 0; i < records.size() - 1; i++) {       int left = records[i];       int right = records[i + 1];       int count = 0;       int max = 0;       if (i > 0) {         left = records[i - 1];         max = a[records[i - 1]];       }       for (int j = left + 1; j < right; j++) {         if (j != records[i])           if (max < a[j]) {             max = a[j];             count++;           }       }       if (case2 < count) {         case2 = count;         case2_pos = records[i];       }     }     case2_records = case1_records - 1 + case2;     if (case1 == -1) {       cout << a[case2_pos] << endl;     } else {       if (case1_records < case2_records) {         cout << a[case2_pos] << endl;       } else if (case1_records == case2_records) {         cout << min(a[case1], a[case2_pos]) << endl;       } else {         cout << a[case1] << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( O2,no-stack-protector,unroll-loops,fast-math )   const long long maxn = 1e5 + 10, maxm = 1e6 + 10, lg = 17, mod = 998244353,                   inf = 1e18;   long long n, len, a, b, par[maxn][lg + 1], h[maxn], zuz[maxn], tguz;   pair<long long, long long> mx[maxn][4];   vector<long long> g[maxn];   bool kor[maxn];   void dfd(long long v = 1, long long p = 0) {     h[v] = h[p] + 1;     par[v][0] = p;     for (int i = 1; i <= lg; i++) par[v][i] = par[par[v][i - 1]][i - 1];     fill(mx[v], mx[v] + 4, make_pair(0, v));     for (auto u : g[v])       if (u != p) {         dfd(u, v);         mx[v][0] = mx[u][3];         mx[v][0].first++;         sort(mx[v], mx[v] + 4);       }   }   void dfu(long long v = 1, long long p = 0) {     if (mx[v][1].first >= len) zuz[v]++, tguz++;     for (auto u : g[v])       if (u != p) {         mx[u][0] = (mx[v][3].second == mx[u][3].second ? mx[v][2] : mx[v][3]);         mx[u][0].first++;         sort(mx[u], mx[u] + 4);         dfu(u, v);         zuz[v] += zuz[u];       }   }   long long gup(long long v, long long x) {     for (int i = 0; i <= lg; i++)       if (x >> i & 1) v = par[v][i];     return v;   }   long long lca(long long v, long long u) {     if (h[v] < h[u]) swap(v, u);     v = gup(v, h[v] - h[u]);     if (v == u) return v;     for (int i = lg; i >= 0; i--)       if (par[v][i] != par[u][i]) v = par[v][i], u = par[u][i];     return par[v][0];   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long T;     cin >> T;     while (T--) {       cin >> n >> a >> b;       for (int i = 1; i < n; i++) {         long long v, u;         cin >> v >> u;         g[v].push_back(u), g[u].push_back(v);       }       dfd();       len = h[a] + h[b] - 2 * h[lca(a, b)];       dfu();       while (1) {         long long ms;         for (int i : {3, 2, 1, 0}) {           long long na = mx[a][i].second;           if (h[b] + h[na] - 2 * h[lca(b, na)] == len + mx[a][i].first) {             ms = mx[a][i].first;             a = na;             break;           }         }         long long o = lca(a, b);         if (h[b] - h[o] >= ms)           b = gup(b, ms);         else {           ms -= h[b] - h[o];           b = gup(a, h[a] - (h[o] + ms));         }         if (kor[a]) {           cout <<  NO n ;           break;         }         o = lca(a, b);         if (o == b) {           if (zuz[gup(a, h[a] - h[b] - 1)] < tguz) {             cout <<  YES n ;             break;           }         } else if (zuz[b]) {           cout <<  YES n ;           break;         }         kor[a] = 1;         swap(a, b);       }       for (int i = 1; i <= n; i++) {         g[i].clear(), kor[i] = 0, h[i] = 0, zuz[i] = 0;         memset(par[i], 0, sizeof(par[i]));       }       tguz = 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool visit[4];   long long dfs(vector<long long> &v, vector<char> &chars) {     long long res = LLONG_MAX;     if (v.size() == 1) {       return v.front();     }     for (int i = 0; i < v.size() - 1; i++) {       for (int j = i + 1; j < v.size(); j++) {         vector<long long> tmp = v;         tmp.erase(tmp.begin() + i);         tmp.erase(tmp.begin() + j - 1);         long long r = 0;         if (chars.front() ==  + ) {           r = v[i] + v[j];         } else {           r = v[i] * v[j];         }         tmp.push_back(r);         vector<char> ch = chars;         ch.erase(ch.begin());         res = min(res, dfs(tmp, ch));       }     }     return res;   }   int main() {     vector<long long> v(4);     vector<char> chars(3);     for (int i = 0; i < 4; i++) {       cin >> v[i];     }     for (int i = 0; i < 3; i++) {       cin >> chars[i];     }     cout << dfs(v, chars) << endl;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   const int N = 55;      void solve()   {       int n;       int ans=0;       scanf( %d , &n);       for(int i=1;i<=n;i++)       {           int x;           scanf( %d , &x);           if(x!=2)    ans++;       }       cout<<ans<<endl;   }   int  main()   {       int t;       scanf( %d , &t);       while(t--)  solve();       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int work() {     long long n, q;     cin >> n >> q;     while (q--) {       long long x, y;       cin >> x >> y;       if ((x + y) % 2 == 0) {         long long w = 0;         long long a = (x - 1) / 2;         w += a * n;         if (x % 2 == 1) {           w += (y + 1) / 2;         } else {           w += (n + 1) / 2;           w += y / 2;         }         cout << w << endl;       } else {         long long w = (n * n + 1) / 2;         long long a = (x - 1) / 2;         w += a * n;         if (x % 2 == 1) {           w += y / 2;         } else {           w += n / 2;           w += (y + 1) / 2;         }         cout << w << endl;       }     }     return 0;   }   int main() {     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve(void) {     string a, b, c;     cin >> a >> b >> c;     int n = a.length();     for (int i = 0; i < n; i++) {       if (c[i] != a[i] && c[i] != b[i]) {         cout <<  NO n ;         return;       }     }     cout <<  YES n ;   }   int main(void) {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string mapp[105];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> mapp[i];     int sx = 0x3f3f3f3f, sy = 0x3f3f3f3f, ex = 0, ey = 0, cnt = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (mapp[i][j] ==  B ) {           sx = min(sx, i);           sy = min(sy, j);           ex = max(ex, i);           ey = max(ey, j);           cnt++;         }       }     }     if (cnt == 0) {       cout << 1;       return 0;     }     int len = max(ex - sx + 1, ey - sy + 1);     if (len > n || len > m) {       cout << -1;       return 0;     }     cout << len * len - cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int v, s, vs, sv;   void printAns() {     cout <<  vier:   << v <<   sieben:   << s <<   vs:   << vs <<   sv:   << sv          << endl;   }   int main() {     cin >> v >> s >> vs >> sv;     string ans =   ;     bool flag = true;     if (v < vs || s < vs || v < sv || v < sv)       flag = false;     else {       for (int i = 0; i < vs; i++) ans +=  47 ;       v -= vs;       s -= vs;       sv -= (vs - 1);       if (sv > 2 || sv < 0)         flag = false;       else {         if (sv == 1 || sv == 2) {           if (v && sv) {             ans +=  4 ;             v--;             sv--;           }           if (s && sv) {             ans =  7  + ans;             s--;             sv--;           }         }         if (s < 0 || v < 0 || sv != 0)           flag = false;         else {           if (ans.empty()) {             if (s && v)               flag = false;             else if (v)               ans.insert(0, v,  4 );             else if (s)               ans.insert(0, s,  7 );           } else {             for (int i = 0; i < (int)ans.length(); i++) {               if (!v && !s)                 break;               else if (ans[i] ==  4  && v) {                 ans.insert(i, v,  4 );                 v = 0;               }             }             for (int i = ans.length() - 1; i >= 0; i--) {               if (!v && !s)                 break;               else if (ans[i] ==  7  && s) {                 ans.insert(i, s,  7 );                 s = 0;               }             }           }         }       }     }     if (flag)       cout << ans << endl;     else       cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long GCD(long long a, long long b) {     while (b != 0) {       int t = a;       a = b;       b = t % b;     }     return a;   }   inline long long LCM(long long a, long long b) {     if (a == 0 || b == 0) return GCD(a, b);     return a * b / GCD(a, b);   }   inline long long CEIL(long long n, long long d) { return n / d + n % d != 0; }   inline long long ROUND(long long n, long long d) {     return n / d + (long long)((n % d) * 2 >= d);   }   inline long long POW(long long a, long long n) {     if (n < 0) return 0;     long long ret = 1;     while (n) {       if (n % 2) ret *= a;       a = a * a;       n /= 2;     }     return ret;   }   const int MAXN = 101, INF = 100000;   struct node {     node *l, *r, *p;     int bdp[MAXN], mdp[MAXN];     node(node *p = 0) : l(0), r(0), p(p) {       fill(bdp, bdp + MAXN, -INF);       fill(mdp, mdp + MAXN, INF);     }     node *child() {       if (!l)         return l = new node(this);       else         return r = new node(this);     }   } * root, *cur;   int p, m, n, op;   string str;   void input() { cin >> str >> p >> m; }   void dfs(node *u) {     if (!u->l) {       return;     }     node *l = u->l, *r = u->r;     dfs(l), dfs(r);     for (int(i) = (0); (i) < (int)(n + 1); ++(i)) {       for (int(j) = (0); (j) < (int)(i + 1); ++(j)) {         int k = i - j - (op == 1 ? 1 : 0);         if (k >= 0) u->bdp[i] = max(u->bdp[i], l->bdp[j] + r->bdp[k]);         if (k >= 0) u->mdp[i] = min(u->mdp[i], l->mdp[j] + r->mdp[k]);         k = i - j - (op == -1 ? 1 : 0);         if (k >= 0) u->bdp[i] = max(u->bdp[i], l->bdp[j] - r->mdp[k]);         if (k >= 0) u->mdp[i] = min(u->mdp[i], l->mdp[j] - r->bdp[k]);       }     }   }   int solve() {     if (p > m)       n = m, op = -1;     else       n = p, op = 1;     root = cur = new node();     for (int(i) = (0); (i) < (int)(str.size()); ++(i)) {       switch (str[i]) {         case  ( :         case  ? :           cur = cur->child();           break;         case  ) :           cur = cur->p;           break;         default:           cur->bdp[0] = cur->mdp[0] = str[i] -  0 ;           cur = cur->p;       }     }     assert(cur == 0);     dfs(root);     cout << root->bdp[n] <<   n ;     return 0;   }   void execute() { input(), solve(); }   int main(void) {     cin.tie(0);     ios_base::sync_with_stdio(false);     execute();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 205;   int mat[maxn][maxn], tmp[maxn][maxn];   int r[maxn], c[maxn];   int n, m;   void invRow(int row) {     for (int j = 1; j <= m; ++j) {       tmp[row][j] ^= 1;     }   }   void invCol(int col) {     for (int i = 1; i <= n; ++i) {       tmp[i][col] ^= 1;     }   }   bool solve(int x, int y) {     memset(tmp, 0, sizeof(tmp));     memset(r, 0, sizeof(r));     memset(c, 0, sizeof(c));     for (int i = x; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (i == x && j < y)           tmp[i][j] = 0;         else           tmp[i][j] = 1;       }     }     for (int i = 1; i <= n; ++i) r[i] = mat[i][1] ^ tmp[i][1] ^ c[1];     for (int j = 1; j <= m; ++j) c[j] = mat[1][j] ^ tmp[1][j] ^ r[1];     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if ((r[i] ^ c[j]) != (mat[i][j] ^ tmp[i][j])) return false;       }     }     return true;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         scanf( %d , &mat[i][j]);       }     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (solve(i, j)) {           puts( YES );           for (int i = 1; i <= n; ++i) printf( %d , r[i]);           putchar(  n );           for (int j = 1; j <= m; ++j) printf( %d , c[j]);           putchar(  n );           return 0;         }       }     }     puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b;     cin >> a >> b;     long long n, m, i, j, k = 200000;     n = a.size();     m = b.size();     for (i = 1; i <= k; i++) {       if (n - i >= 0 && m - i >= 0) {         if (a[n - i] != b[m - i]) break;       } else         break;     }     cout << (n - i) + 1 + (m - i) + 1;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 500004;   long long p, pos1, pos2, q, x, l, ans = 0, r, y, z, k, n, m, t, d, c = 0,                                     sum = 0;   long long int mn = 0x3f3f3f3f, len, cnt = 1, mx = -1000;   std::vector<int> v[MAX];   string s[10004], s1, s2;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> s[i];       m += s[i].size();     }     cin >> s1;     int len = 2 * m / n;     for (int i = 0; i < n; i++) s[i] += s1;     sort(s, s + n);     int a[n];     memset(a, (0), sizeof(a));     for (int i = 0; i < n / 2; i++) {       for (int j = 0; j < n; j++) {         if (!a[j]) {           cout << s[j];           x = s[j].size();           ++a[j];           break;         }       }       for (int j = 0; j < n; j++) {         if (!a[j] and s[j].size() == len - x + 2) {           cout << s[j].substr(0, s[j].size() - 1);           ++a[j];           break;         }       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long a, b, c, n, res;   int main() {     cin >> a >> b >> c >> n;     long s[n + 1];     for (long i = 1; i <= n; ++i) {       cin >> s[i];       if (s[i] > b && s[i] < c) res++;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int powermod(long long int B, long long int P, long long int M) {     long long int r = 1;     if (B >= M) B %= M;     while (P > 0) {       if ((P & 1) == 1) {         r *= B;         if (r >= M) r %= M;       }       P >>= 1;       B *= B;       if (B >= M) B %= M;     }     return r;   }   long long int modinv(long long int B, long long int M) {     return powermod(B, M - 2, M);   }   int main() {     long long int MOD = 1000000007LL;     long long int A, B, N, x, res = 1;     cin >> A >> B >> N >> x;     if (A == 1) {       res = x + B * (N % MOD);     } else {       long long int An = powermod(A, N, MOD);       res = An * x;       long long int tmp = B * (An - 1) % MOD;       tmp = tmp * modinv(A - 1, MOD) % MOD;       res += tmp;     }     res %= MOD;     cout << res << endl;     return 0;   }