func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 const double PI = acos(-1.0);
 const double EPS = 1e-7;
 const long long BIG_PRIME7 = 1000000007;
 const long long BIG_PRIME9 = 1000000009;
 int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
 char ch = 'a';
 int j, n, m, L, i;
 int N, C;
 int x, y, z, k;
 string f, s;
 int a[101], b[101];
 int main() {
   cin >> x;
   for (i = 0; i < x; i++) {
     cin >> k;
     if (k & 1) z++;
   }
   if (!(z & 1))
     cout << (x - z);
   else
     cout << z;
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 const int N = 111111;
 int last[3 * N], pre[3 * N], v[3 * N], cnt[3 * N], cur = 0;
 inline void add(int a, int b) {
   pre[cur] = last[a];
   v[cur] = b;
   last[a] = cur;
   cur++;
 }
 set<int>* who[N];
 inline set<int>* merge(set<int>*& a, set<int>*& b) {
   if (a->size() < b->size()) {
     return merge(b, a);
   } else {
     for (set<int>::iterator it = b->begin(); it != b->end(); it++) {
       if (a->find(-*it) != a->end()) {
         a->erase(-*it);
       } else {
         a->insert(*it);
       }
     }
     b->clear();
     return a;
   }
 }
 int used[N];
 void dfs(int u) {
   used[u] = true;
   for (int i = last[u]; i >= 0; i = pre[i])
     if (!used[v[i]]) {
       dfs(v[i]);
       cnt[i ^ 1] = cnt[i] = who[v[i]]->size();
       who[u] = merge(who[u], who[v[i]]);
     }
 }
 set<int>* mem[N];
 int main() {
   memset(last, -1, sizeof(last));
   int n;
   scanf( %d , &n);
   for (int i = (0); i <= ((n - 1) - 1); i++) {
     int u, v;
     scanf( %d%d , &u, &v);
     u--;
     v--;
     add(u, v);
     add(v, u);
   }
   for (int i = (0); i <= ((n)-1); i++) mem[i] = who[i] = new set<int>();
   int k;
   scanf( %d , &k);
   for (int i = (1); i <= ((k)); i++) {
     int u, v;
     scanf( %d%d , &u, &v);
     u--;
     v--;
     if (u != v) {
       who[u]->insert(i);
       who[v]->insert(-i);
     }
   }
   dfs(0);
   for (int i = 0; i < cur; i += 2) {
     if (i) printf(   );
     printf( %d , cnt[i]);
   }
   puts(  );
   for (int i = (0); i <= ((n)-1); i++) delete (mem[i]);
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 const int MOD = 1e9 + 7;
 const int INF = 1e9 + 7;
 const int base = 1e9;
 const int MAX = 1e5;
 const double EPS = 1e-9;
 const double PI = acos(-1.);
 int main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   int n, *a, *res, j = 0;
   cin >> n;
   a = new int[n];
   res = new int[n];
   set<int> cnt;
   for (int i = 0; i < n; i++) {
     cin >> a[i];
   }
   for (int i = n - 1; i >= 0; i--) {
     if (!cnt.count(a[i])) {
       cnt.insert(a[i]);
       res[j] = a[i];
       j++;
     }
   }
   cout << j << endl;
   for (int i = j - 1; i >= 0; i--) {
     cout << res[i] << ' ';
   }
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 struct cell {
   bool up, down, right, left;
   int degree;
   cell() { up = down = left = right = degree = 0; }
   void reset() { up = down = left = right = degree = 0; }
 };
 struct qcell {
   int x, y, degree;
   qcell() {
     x = y = -1;
     degree = 0;
   }
   qcell(int xx, int yy, int deg) {
     x = xx;
     y = yy;
     degree = deg;
   }
 };
 char pitch[2001][2001];
 cell info[2001][2001];
 int n, m;
 int empty_cells = 0;
 bool update(int x, int y) {
   int degree = 0;
   if (x >= 0 && x < n && y >= 0 && y < m) {
     degree = info[x][y].degree;
     if (pitch[x][y] != '.')
       info[x][y].reset();
     else {
       info[x][y].up = (x - 1 >= 0 && pitch[x - 1][y] == '.');
       info[x][y].down = (x + 1 < n && pitch[x + 1][y] == '.');
       info[x][y].left = (y - 1 >= 0 && pitch[x][y - 1] == '.');
       info[x][y].right = (y + 1 < m && pitch[x][y + 1] == '.');
       info[x][y].degree = (info[x][y].up + info[x][y].down + info[x][y].left +
                            info[x][y].right);
     }
   }
   return degree != info[x][y].degree;
 }
 void do_push(int x, int y, queue<qcell> &q) {
   if (x >= 0 && x < n && y >= 0 && y < m)
     if (pitch[x][y] == '.')
       if (info[x][y].degree == 1) q.push(qcell(x, y, 1));
 }
 void occupy(int x, int y, queue<qcell> &q) {
   int xx = x, yy = y;
   char dir = 'U';
   if (info[x][y].down) dir = 'D';
   if (info[x][y].left) dir = 'L';
   if (info[x][y].right) dir = 'R';
   if (dir == 'U') {
     pitch[x][y] = 'v';
     pitch[x - 1][y] = '^';
     xx = x - 1;
   } else if (dir == 'D') {
     pitch[x][y] = '^';
     pitch[x + 1][y] = 'v';
     xx = x + 1;
   } else if (dir == 'L') {
     pitch[x][y] = '>';
     pitch[x][y - 1] = '<';
     yy = y - 1;
   } else {
     pitch[x][y] = '<';
     pitch[x][y + 1] = '>';
     yy = y + 1;
   }
   update(x, y);
   update(xx, yy);
   if (do_push) {
     if (update(x - 1, y)) do_push(x - 1, y, q);
     if (update(x + 1, y)) do_push(x + 1, y, q);
     if (update(x, y - 1)) do_push(x, y - 1, q);
     if (update(x, y + 1)) do_push(x, y + 1, q);
     if (update(xx - 1, yy)) do_push(xx - 1, yy, q);
     if (update(xx + 1, yy)) do_push(xx + 1, yy, q);
     if (update(xx, yy - 1)) do_push(xx, yy - 1, q);
     if (update(xx, yy + 1)) do_push(xx, yy + 1, q);
   }
   empty_cells -= 2;
 }
 int main() {
   cin >> n >> m;
   for (int i = 0; i < n; i++)
     for (int j = 0; j < m; j++) {
       cin >> pitch[i][j];
       if (pitch[i][j] == '.') empty_cells++;
     }
   queue<qcell> q;
   for (int i = 0; i < n; i++)
     for (int j = 0; j < m; j++) {
       update(i, j);
       if (info[i][j].degree == 1) q.push(qcell(i, j, info[i][j].degree));
     }
   bool unique_sol = 1;
   while (1) {
     if (q.empty()) break;
     qcell f = q.front();
     q.pop();
     if (info[f.x][f.y].degree == 0) {
       if (pitch[f.x][f.y] == '.') {
         unique_sol = false;
         break;
       }
     } else
       occupy(f.x, f.y, q);
   }
   if (unique_sol)
     if (empty_cells != 0) unique_sol = 0;
   if (!unique_sol)
     cout <<  Not unique  << endl;
   else
     for (int i = 0; i < n; i++) {
       for (int j = 0; j < m; j++) cout << pitch[i][j];
       cout << endl;
     }
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 const int INF = 0x3f3f3f3f;
 int main() {
   ios::sync_with_stdio(false);
   int t;
   cin >> t;
   while (t--) {
     string s, t;
     cin >> s >> t;
     vector<int> each[26];
     int n, m;
     n = s.length();
     m = t.length();
     for (int i = 0; i < n; ++i) {
       each[s[i] - 'a'].push_back(i);
     }
     int las = INF, res = 0;
     for (int i = 0; i < m; ++i) {
       if (upper_bound(each[t[i] - 'a'].begin(), each[t[i] - 'a'].end(), las) !=
           each[t[i] - 'a'].end()) {
         las =
             *upper_bound(each[t[i] - 'a'].begin(), each[t[i] - 'a'].end(), las);
       } else {
         if (each[t[i] - 'a'].empty()) {
           res = -1;
           break;
         } else {
           res++;
           las = each[t[i] - 'a'][0];
         }
       }
     }
     cout << res << endl;
   }
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, h, a, road_width = 0;
   cin >> n >> h;
   for (int i = 0; i < n; i++) {
     cin >> a;
     if (a > h)
       road_width += 2;
     else
       road_width++;
   }
   cout << road_width <<
 ;
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 int abs(int a, int b) {
   if (a > b)
     return a - b;
   else
     return b - a;
 }
 int main() {
   int n, c, i, b, count = 0, index1 = 1, index2 = 1, flag = 0;
   cin >> n >> c;
   char *s;
   s = new char[n + 2];
   for (i = 1; i <= n; i++) {
     cin >> s[i];
   }
   int *d = new int[n + 1];
   for (i = 1; i <= n / 2; i++) {
     b = abs((int)s[i], (int)s[n - i + 1]);
     if (b < 13)
       d[i] = d[n - i + 1] = b;
     else
       d[i] = d[n - i + 1] = 26 - b;
   }
   if (c > n / 2) c = 1 + n - c;
   for (i = 1; i <= n / 2; i++) {
     if (d[i] > 0) {
       index1 = i;
       break;
     }
   }
   for (i = n / 2; i >= 1; i--) {
     if (d[i] > 0) {
       index2 = i;
       flag = 1;
       break;
     }
   }
   if (c <= index1) {
     count = index2 - c;
   } else if (c <= index2) {
     if (c - index1 > index2 - c)
       count = 2 * (index2 - c) + c - index1;
     else
       count = 2 * (c - index1) + index2 - c;
   } else
     count = c - index1;
   for (i = index1; i <= index2; i++) {
     count += d[i];
   }
   if (flag == 1)
     cout << count;
   else
     cout << 0;
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 int any_table[11][11];
 struct DammedPascalNUmber {
   int tb[13][13];
   DammedPascalNUmber() {
     int i, j;
     for (i = 0; i <= 12; i++)
       for (j = 0; j <= i; j++) {
         int &r = tb[i][j];
         if (j == 0 || i == 0)
           r = 1;
         else
           r = tb[i - 1][j - 1] + tb[i - 1][j];
       }
   }
   int count(int n, int m) { return tb[n][m]; }
 } pas;
 int any(int dig, int amo) {
   if (dig < amo) return 0;
   if (amo < 0) return 0;
   if (dig == 0) return 1;
   int &r = any_table[dig][amo];
   int i;
   if (r >= 0) return r;
   r = 1;
   for (i = 0; i < amo; i++) r *= 2;
   for (; i < dig; i++) r *= 8;
   r *= pas.count(dig, amo);
   return r;
 }
 int check(int m, int n) {
   int i, j, t, r = 0;
   for (i = 1; i <= m; i++) {
     char str[15];
     t = 0;
     sprintf(str,  %d , i);
     for (j = 0; str[j]; j++)
       if (str[j] == '4' || str[j] == '7') t++;
     if (t == n) r++;
   }
   return r;
 }
 int a[13];
 int dfs(int party, int quta) {
   int r = 0, i;
   if (party == 6) {
     return 1;
   }
   for (i = quta; i >= 0; i--)
     if (a[i] > 0) {
       int t = a[i];
       a[i]--;
       r = (1LL * r + 1LL * t * 1LL * dfs(party + 1, quta - i) +
            1LL * 1000000007) %
           1000000007;
       a[i]++;
     }
   return r;
 }
 void test(int n, int m) { printf( any(%d,%d)=%d
 , n, m, any(n, m)); }
 void test2(int m, int n) {
   printf( (%d,%d)=%d a[%d]=%d
 , m, n, check(m, n), n, a[n]);
 }
 int main() {
   memset(any_table, -1, sizeof(any_table));
   int m, s, i, j, k, sn, lucked;
   while (~scanf( %d , &m)) {
     memset(a, 0, sizeof(a));
     char str[15];
     sprintf(str,  %d , m);
     for (sn = 0; str[sn]; sn++)
       ;
     for (j = sn; j > 0; j--) {
       a[j] = 0;
       lucked = 0;
       for (i = 0; i < sn; i++) {
         int p = 0, q = 0;
         k = str[i] - '0' - 1;
         for (; k >= 0; k--)
           if (k == 4 || k == 7)
             q++;
           else
             p++;
         if (p) a[j] += p * any(sn - i - 1, j - lucked);
         if (q) a[j] += q * any(sn - i - 1, j - lucked - 1);
         if (str[i] == '4' || str[i] == '7') {
           lucked++;
         }
         if (i == sn - 1 && lucked == j) a[j]++;
       }
     }
     a[0] = m;
     for (i = 1; i <= sn; i++) a[0] -= a[i];
     int ans = 0;
     for (i = 1; i <= sn; i++)
       if (a[i]) {
         ans = (1LL * ans + 1LL * a[i] * dfs(0, i - 1) + 1LL * 1000000007) %
               1000000007;
       }
     printf( %d
 , ans);
   }
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 const int maxn = 1e5 + 10;
 const double pi = acos(-1);
 const int inf = 1 << 30;
 const int mod = 1e9 + 9;
 struct point {
   int x, flag;
   bool operator<(const point &a) const { return flag > a.flag; }
 } s, q;
 bool check(long long a[], int n, long long h, int x) {
   priority_queue<int, vector<int>, less<int> > qwe;
   for (int i = 1; i <= min(n, x); i++) qwe.push(a[i]);
   int f = 1, pos;
   while (!qwe.empty()) {
     pos = qwe.top();
     qwe.pop();
     if (f) h -= pos;
     f ^= 1;
   }
   if (h >= 0ll)
     return true;
   else
     return false;
 }
 int main() {
   int n;
   long long h, a[maxn];
   scanf( %d %lld , &n, &h);
   for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);
   int l = 0, r = n, ans = 0;
   while (l <= r) {
     int mid = (l + r) >> 1;
     if (check(a, n, h, mid))
       l = mid + 1, ans = mid;
     else
       r = mid - 1;
   }
   printf( %d
 , ans);
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 const int64_t mod = 998244353;
 int gcd(int64_t a, int64_t b) {
   while (a != 0 && b != 0) {
     if (a >= b)
       a = a % b;
     else
       b = b % a;
   }
   return a + b;
 }
 struct Fraction {
   int64_t numerator;
   int64_t devider;
   Fraction(int64_t n = 0, int64_t d = 1) : numerator(n), devider(d){};
   const Fraction& operator+(const Fraction& rv) {
     if (rv.devider == devider) {
       numerator += rv.numerator;
       numerator %= mod;
       return *this;
     } else {
       numerator *= rv.devider;
       numerator %= mod;
       numerator += rv.numerator * devider;
       numerator %= mod;
       devider *= rv.devider;
       devider %= mod;
       return *this;
     }
   }
   const Fraction& operator*(const Fraction& rv) {
     numerator *= rv.numerator;
     devider *= rv.devider;
     numerator %= mod;
     devider %= mod;
     return *this;
   }
 };
 struct Item {
   Item(Fraction f, int64_t s, int64_t v) : possibility(f), sum(s), val(v){};
   Fraction possibility;
   int64_t sum;
   int64_t val;
 };
 void extended_euclid(int64_t a, int64_t b, int64_t& x, int64_t& y, int64_t& d) {
   int64_t q, r, x1, x2, y1, y2;
   if (b == 0) {
     d = a, x = 1, y = 0;
     return;
   }
   x2 = 1, x1 = 0, y2 = 0, y1 = 1;
   while (b > 0) {
     q = a / b, r = a - q * b;
     x = x2 - q * x1, y = y2 - q * y1;
     a = b, b = r;
     x2 = x1, x1 = x, y2 = y1, y1 = y;
   }
   d = a, x = x2, y = y2;
 }
 int main() {
   int64_t n, m;
   std::cin >> n >> m;
   std::vector<std::pair<int64_t, bool>> data;
   int64_t posWeight = 0, negWeight = 0;
   for (int64_t i = 0; i < n; ++i) {
     int64_t a;
     std::cin >> a;
     if (a == 0)
       data.push_back(std::make_pair(-1, false));
     else
       data.push_back(std::make_pair(-1, true));
   }
   for (auto& i : data) {
     int64_t w;
     std::cin >> w;
     i.first = w;
     if (i.second)
       posWeight += w;
     else
       negWeight += w;
   }
   std::vector<Item> posVec{
       Item(Fraction(1, 1), posWeight + negWeight, posWeight)},
       negVec{Item(Fraction(1, 1), posWeight + negWeight, negWeight)};
   for (int64_t i = 0; i < m; ++i) {
     std::vector<Item> newPos, newNeg;
     for (auto j : posVec) {
       if (!newPos.size()) {
         Fraction f(j.val, j.sum);
         f = f * j.possibility;
         newPos.push_back(Item(f, j.sum + 1, j.val + 1));
       } else {
         Fraction f(j.val, j.sum);
         f = f * j.possibility;
         newPos.rbegin()->possibility = newPos.rbegin()->possibility + f;
       }
       if (j.sum > j.val) {
         Fraction f(j.sum - j.val, j.sum);
         f = f * j.possibility;
         newPos.push_back(Item(f, j.sum - 1, j.val));
       }
     }
     for (auto j : negVec) {
       if (!newNeg.size() && j.val > 1) {
         Fraction f(j.val, j.sum);
         f = f * j.possibility;
         newNeg.push_back(Item(f, j.sum - 1, j.val - 1));
       } else if (j.val > 1) {
         Fraction f(j.val, j.sum);
         f = f * j.possibility;
         newNeg.rbegin()->possibility = newNeg.rbegin()->possibility + f;
       }
       Fraction f(j.sum - j.val, j.sum);
       f = f * j.possibility;
       newNeg.push_back(Item(f, j.sum + 1, j.val));
     }
     posVec = newPos;
     negVec = newNeg;
   }
   Fraction pos, neg;
   for (auto i : posVec) pos = pos + Fraction(i.val, 1) * i.possibility;
   for (auto i : negVec) neg = neg + Fraction(i.val, 1) * i.possibility;
   for (auto i : data) {
     Fraction res;
     if (i.second)
       res = Fraction(i.first, posWeight) * pos;
     else
       res = Fraction(i.first, negWeight) * neg;
     int64_t g = gcd(res.numerator, res.devider);
     res.numerator /= g;
     res.devider /= g;
     int64_t d, x, y;
     extended_euclid(res.devider, mod, x, y, d);
     std::cout << (((x % mod + mod) % mod) * res.numerator) % mod << std::endl;
   }
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 const int N = 100005;
 int n, m, x, y, f[N], fa[N], ch[N][2];
 char op[5];
 long long a[N], siz[N], ssiz[N], ans[N], sans[N], sqsiz[N], all[N];
 bool isroot(int u) { return ch[fa[u]][0] != u && ch[fa[u]][1] != u; }
 int which(int u) { return u == ch[fa[u]][1]; }
 void pushup(int o) {
   int lc = ch[o][0], rc = ch[o][1];
   siz[o] = siz[lc] + siz[rc] + ssiz[o];
   all[o] = all[lc] + all[rc] + a[o] * ssiz[o];
   ans[o] = ans[lc] + ans[rc] + sans[o];
   ans[o] += (ssiz[o] * ssiz[o] - sqsiz[o]) * a[o];
   ans[o] += 2 * siz[rc] * ssiz[o] * a[o];
   ans[o] += 2 * all[lc] * (siz[o] - siz[lc]);
 }
 void rotate(int x) {
   int y = fa[x], z = fa[y], md = which(x);
   if (!isroot(y)) {
     ch[z][which(y)] = x;
   }
   fa[x] = z;
   ch[y][md] = ch[x][!md];
   fa[ch[y][md]] = y;
   ch[x][!md] = y;
   fa[y] = x;
   pushup(y);
   pushup(x);
 }
 void splay(int u) {
   while (!isroot(u)) {
     if (!isroot(fa[u])) {
       rotate(which(u) == which(fa[u]) ? fa[u] : u);
     }
     rotate(u);
   }
 }
 void access(int u) {
   for (int v = 0; u; v = u, u = fa[u]) {
     splay(u);
     int rc = ch[u][1];
     ssiz[u] += siz[rc];
     sans[u] += ans[rc];
     sqsiz[u] += siz[rc] * siz[rc];
     ch[u][1] = v;
     ssiz[u] -= siz[v];
     sans[u] -= ans[v];
     sqsiz[u] -= siz[v] * siz[v];
     pushup(u);
   }
 }
 void link(int u, int v) {
   access(v);
   splay(v);
   access(u);
   splay(u);
   fa[u] = v;
   ssiz[v] += siz[u];
   sans[v] += ans[u];
   sqsiz[v] += siz[u] * siz[u];
   pushup(v);
 }
 void cut(int u, int v) {
   access(u);
   access(v);
   splay(v);
   splay(u);
   fa[u] = 0;
   ssiz[v] -= siz[u];
   sans[v] -= ans[u];
   sqsiz[v] -= siz[u] * siz[u];
   pushup(v);
 }
 bool check(int u, int v) {
   access(v);
   splay(v);
   splay(u);
   if (isroot(v)) {
     return false;
   }
   return true;
 }
 int main() {
   scanf( %d , &n);
   for (int i = 2; i <= n; i++) {
     scanf( %d , &f[i]);
   }
   for (int i = 1; i <= n; i++) {
     scanf( %lld , &a[i]);
     ans[i] = all[i] = a[i];
   }
   for (int i = 1; i <= n; i++) {
     siz[i] = 1;
     ssiz[i] = 1;
   }
   for (int i = 2; i <= n; i++) {
     link(i, f[i]);
   }
   access(1);
   splay(1);
   printf( %.10lf
 , 1.0 * ans[1] / n / n);
   scanf( %d , &m);
   while (m--) {
     scanf( %s%d%d , op, &x, &y);
     if (op[0] == 'P') {
       if (check(x, y)) {
         swap(x, y);
       }
       cut(x, f[x]);
       f[x] = y;
       link(x, f[x]);
       access(1);
       splay(1);
       printf( %.10lf
 , 1.0 * ans[1] / n / n);
     } else {
       access(x);
       splay(x);
       a[x] = y;
       pushup(x);
       printf( %.10lf
 , 1.0 * ans[x] / n / n);
     }
   }
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 int main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   long long x, y, n, m, t, q, a, b, count = 0;
   cin >> n >> m;
   long long arr[n];
   for (x = 0; x < n; x++) cin >> arr[x];
   a = 0;
   for (x = 0; x < n; x++) {
     a = a + arr[x];
     cout << a / m <<    ;
     a = a % m;
   }
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 int qread() {
   char c;
   int s = 0, f = 1;
   while ((c = getchar()) < '0' || c > '9') (c == '-') && (f = -1);
   do s = s * 10 + c - '0';
   while ((c = getchar()) >= '0' && c <= '9');
   return s * f;
 }
 int n, m;
 const int mod = 1e9 + 7;
 int a[100011], pos[100011], bin[100011], inv[100011], sum[100011],
     lp = 0, val[100011], vv[100011], svv[100011];
 struct Ques {
   int l, r, id;
   bool operator<(const Ques &b) const { return r < b.r; }
 } q[100011];
 int ans[100011];
 int WWW(long long v) { return v > 2000000001 ? 2000000001 : v; }
 int main() {
   n = qread();
   m = qread();
   bin[0] = inv[0] = 1;
   for (int i = 1; i <= n; i++)
     a[i] = qread(), bin[i] = (bin[i - 1] << 1) % mod,
     inv[i] = 1ll * inv[i - 1] * ((mod + 1) >> 1) % mod,
     sum[i] = ((sum[i - 1] + 1ll * a[i] * bin[i]) % mod + mod) % mod;
   for (int i = 1; i <= m; i++) {
     q[i].l = qread();
     q[q[i].id = i].r = qread();
   }
   sort(q + 1, q + 1 + m);
   pos[lp = 1] = 1;
   int j = 1;
   val[1] = a[1] * 2;
   vv[1] = svv[1] = ((a[1] * 2) % mod + mod) % mod;
   while (j <= m && q[j].r == 1) ans[q[j].id] = (a[1] + mod) % mod, j++;
   for (int i = 2; i <= n; i++) {
     if (a[i] <= 0)
       pos[++lp] = i, val[lp] = 2 * a[i],
       vv[lp] = (a[i] * 2ll % mod + mod) % mod,
       svv[lp] = (svv[lp - 1] + vv[lp]) % mod;
     else {
       int cur =
           WWW(0ll + val[lp] + bin[pos[lp] - pos[lp - 1] + 1] * 1ll * a[i]);
       int cvv = (vv[lp] + bin[pos[lp] - pos[lp - 1] + 1] * 1ll * a[i]) % mod;
       lp--;
       while (lp && cur > 0) {
         cur = WWW(0ll + val[lp] +
                   (pos[lp] - pos[lp - 1] > 31 ? 2000000001
                                               : bin[pos[lp] - pos[lp - 1]]) *
                       1ll * cur);
         cvv = (vv[lp] + bin[pos[lp] - pos[lp - 1]] * 1ll * cvv) % mod;
         lp--;
       }
       val[++lp] = cur;
       pos[lp] = i;
       vv[lp] = cvv;
       svv[lp] = (svv[lp - 1] + vv[lp]) % mod;
     }
     while (j <= m && q[j].r == i) {
       if (q[j].l == q[j].r) {
         ans[q[j].id] = (a[i] + mod) % mod;
         j++;
         continue;
       }
       int l = q[j].l + 1, Ans = (a[q[j].l] + mod) % mod;
       int L = 1, R = lp;
       while (L < R) {
         int mid = (L + R) >> 1;
         if (pos[mid] >= l)
           R = mid;
         else
           L = mid + 1;
       }
       Ans = (Ans + svv[lp] - svv[L]) % mod;
       Ans = (Ans + mod) % mod;
       Ans = (Ans + (sum[pos[L]] - sum[l - 1] + mod) * 1ll * inv[l - 1]) % mod;
       ans[q[j].id] = Ans;
       j++;
     }
   }
   for (int i = 1; i <= m; i++) printf( %d
 , ans[i]);
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 const long long mod = 1000000007;
 const long long inf = 1000000000000000000;
 int main() {
   long long t;
   cin >> t;
   while (t--) {
     long long n;
     cin >> n;
     vector<pair<long long, long long> > p(n);
     for (auto& x : p) cin >> x.first >> x.second;
     sort(p.begin(), p.end());
     pair<long long, long long> now = {0, 0};
     bool f = 1;
     string ans =   ;
     for (int i = 0; i < n; i++) {
       if (p[i].first >= now.first && p[i].second >= now.second) {
         long long r = p[i].first - now.first, u = p[i].second - now.second;
         while (r--) ans += 'R';
         while (u--) ans += 'U';
         now = p[i];
       } else {
         f = 0;
         break;
       }
     }
     if (f)
       cout <<  YES
  << ans << endl;
     else
       cout <<  NO
 ;
   }
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 int main() {
   int n, m;
   scanf( %d %d , &n, &m);
   for (int i = 0; i < n; i++) {
     if (i % 2 == 0) {
       for (int j = 1; j <= m; j++) {
         printf( # );
       }
     } else if (i % 4 == 1) {
       for (int j = 1; j < m; j++) {
         printf( . );
       }
       printf( # );
     } else if (i % 4 == 3) {
       printf( # );
       for (int j = 1; j < m; j++) {
         printf( . );
       }
     }
     printf(
 );
   }
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 const int N = 2e5 + 65, mod = 1e9 + 7;
 vector<int> g[N];
 int w[N];
 int col[N], pr[N];
 int sz[N][2];
 long long ans = 0;
 void dfs(int v, int par = -1, int c = 0) {
   pr[v] = par;
   ++sz[v][c];
   col[v] = c;
   for (int u : g[v])
     if (u != par) {
       dfs(u, v, c ^ 1);
       sz[v][0] += sz[u][0];
       sz[v][1] += sz[u][1];
     }
 }
 int main() {
   int n;
   scanf( %d , &n);
   for (int i = 0; i < n; ++i) scanf( %d , w + i);
   for (int i = 1; i < n; ++i) {
     int u, v;
     scanf( %d %d , &u, &v);
     --u, --v;
     g[u].push_back(v);
     g[v].push_back(u);
   }
   ans = 0;
   dfs(0);
   for (int v = 0; v < n; ++v) {
     vector<pair<int, int> > vs;
     for (int u : g[v])
       if (u != pr[v]) vs.emplace_back(sz[u][0], sz[u][1]);
     if (pr[v] != -1) vs.emplace_back(sz[0][0] - sz[v][0], sz[0][1] - sz[v][1]);
     long long cnt = n;
     if (col[v]) {
       for (pair<int, int> e : vs) {
         cnt = (cnt + 1LL * e.second * (n - e.first - e.second)) % mod;
         cnt = (cnt - 1LL * e.first * (n - e.first - e.second)) % mod;
       }
     } else {
       for (pair<int, int> e : vs) {
         cnt = (cnt - 1LL * e.second * (n - e.first - e.second)) % mod;
         cnt = (cnt + 1LL * e.first * (n - e.first - e.second)) % mod;
       }
     }
     cnt %= mod;
     if (cnt < 0) cnt += mod;
     ans = (ans + cnt * w[v]) % mod;
   }
   ans %= mod;
   if (ans < 0) ans += mod;
   cout << ans << endl;
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 void readi(int &x) {
   int v = 0, f = 1;
   char c = getchar();
   while (!isdigit(c) && c != '-') c = getchar();
   if (c == '-')
     f = -1;
   else
     v = v * 10 + c - '0';
   while (isdigit(c = getchar())) v = v * 10 + c - '0';
   x = v * f;
 }
 void readll(long long &x) {
   long long v = 0ll, f = 1ll;
   char c = getchar();
   while (!isdigit(c) && c != '-') c = getchar();
   if (c == '-')
     f = -1;
   else
     v = v * 10 + c - '0';
   while (isdigit(c = getchar())) v = v * 10 + c - '0';
   x = v * f;
 }
 void readc(char &x) {
   char c;
   while ((c = getchar()) == ' ')
     ;
   x = c;
 }
 void writes(string s) { puts(s.c_str()); }
 void writeln() { writes(  ); }
 void writei(int x) {
   if (!x) putchar('0');
   char a[25];
   int top = 0;
   while (x) {
     a[++top] = (x % 10) + '0';
     x /= 10;
   }
   while (top) {
     putchar(a[top]);
     top--;
   }
 }
 void writell(long long x) {
   if (!x) putchar('0');
   char a[25];
   int top = 0;
   while (x) {
     a[++top] = (x % 10) + '0';
     x /= 10;
   }
   while (top) {
     putchar(a[top]);
     top--;
   }
 }
 inline long long inc(int &x) { return ++x; }
 inline long long inc(long long &x) { return ++x; }
 inline long long inc(int &x, long long y) { return x += y; }
 inline long long inc(long long &x, long long y) { return x += y; }
 inline double inc(double &x, double y) { return x += y; }
 inline long long dec(int &x) { return --x; }
 inline long long dec(long long &x) { return --x; }
 inline long long dec(int &x, long long y) { return x -= y; }
 inline long long dec(long long &x, long long y) { return x -= y; }
 inline double dec(double &x, double y) { return x -= y; }
 inline long long mul(int &x) { return x = ((long long)x) * x; }
 inline long long mul(long long &x) { return x = x * x; }
 inline long long mul(int &x, long long y) { return x *= y; }
 inline long long mul(long long &x, long long y) { return x *= y; }
 inline double mul(double &x, double y) { return x *= y; }
 inline long long divi(const int &x) {
   long long ans, l, r, mid;
   ans = 0;
   l = 0;
   r = 0x3fffffff;
   while (l < r) {
     mid = (l + r) / 2;
     if (mid * mid <= x) {
       ans = mid;
       l = mid + 1;
     } else
       r = mid;
   }
   return ans;
 }
 inline long long divi(const long long &x) {
   long long ans, l, r, mid;
   ans = 0;
   l = 0;
   r = 0x3fffffff;
   while (l < r) {
     mid = (l + r) / 2;
     if (mid * mid <= x) {
       ans = mid;
       l = mid + 1;
     } else
       r = mid;
   }
   return ans;
 }
 inline long long divi(int &x, long long y) { return x /= y; }
 inline long long divi(long long &x, long long y) { return x /= y; }
 inline double divi(double &x, double y) { return x /= y; }
 inline long long mod(int &x, long long y) { return x %= y; }
 inline long long mod(long long &x, long long y) { return x %= y; }
 int n, m, i, j, ct[100005], x, y, vis[100005];
 vector<int> e[100005];
 struct vt {
   int id, deg;
 } a[100005];
 bool cmp(vt x, vt y) { return x.deg > y.deg; }
 bool dfs(int x) {
   if (vis[x] == 1) return 1;
   if (vis[x] == 2) return 0;
   vis[x] = 1;
   for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++)
     if (dfs(*it)) return 1;
   vis[x] = 2;
   return 0;
 }
 bool check(int x) {
   memset(vis, 0, sizeof(vis));
   vis[x] = 2;
   int i;
   for (i = 1; i <= n; i++) {
     if (!vis[i] && dfs(i)) {
       for (i = 1; i <= n; i++)
         if (vis[i] != 1) ct[i] = 1;
       return 0;
     }
   }
   return 1;
 }
 int main() {
   double st = clock();
   ios_base::sync_with_stdio(false);
   ;
   cin >> n >> m;
   if ((1) <= ((m)))
     for (((i)) = (1); ((i)) <= ((m)); ((i))++) {
       cin >> x >> y;
       e[x].push_back(y);
     }
   if ((1) <= ((n)))
     for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
       a[i].id = i;
       a[i].deg = e[i].size();
     }
   stable_sort(a + 1, a + n + 1, cmp);
   if ((1) <= ((n)))
     for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
       if ((clock() - st) / CLOCKS_PER_SEC > 0.9) break;
       x = a[i].id;
       if (ct[x] || !check(x)) continue;
       cout << x;
       return 0;
     }
   cout <<  -1 ;
   return 0;
 }


func_code_string:
#include <bits/stdc++.h>
 using namespace std;
 const long long mxn = 1003, inf = 1e18 + 18;
 int n, m, lcp[mxn][mxn], rk[mxn][mxn], ri[mxn], tot;
 long long k, f[mxn];
 string s;
 struct S {
   int l, r;
 } a[mxn * mxn];
 inline bool cmp(S a, S b) {
   int p = a.l + lcp[a.l][b.l], q = b.l + lcp[a.l][b.l];
   if (p > a.r or q > b.r) return a.r - a.l < b.r - b.l;
   return s[p] < s[q];
 }
 inline long long add(long long a, long long b) {
   return a + b > inf ? inf : a + b;
 }
 inline long long calc(int md) {
   for (int i = 1; i <= n; ++i) {
     ri[i] = i;
     for (; ri[i] <= n and rk[i][ri[i]] < md;) ++ri[i];
   }
   memset(f, 0, sizeof(f)), f[n + 1] = 1;
   for (int i = 1; i <= m; ++i) {
     for (int j = n; j; --j) f[j] = add(f[j], f[j + 1]);
     for (int j = 1; j <= n; ++j) f[j] = ri[j] <= n ? f[ri[j] + 1] : 0;
     f[n + 1] = 0;
   }
   return f[1];
 }
 int main() {
   cin >> n >> m >> k >> s, s = ' ' + s;
   for (int i = n; i; --i)
     for (int j = n; j; --j)
       if (s[i] == s[j]) lcp[i][j] = lcp[i + 1][j + 1] + 1;
   for (int i = 1; i <= n; ++i)
     for (int j = i; j <= n; ++j) a[++tot] = (S){i, j};
   sort(a + 1, a + tot + 1, cmp);
   for (int i = 1; i <= tot; ++i) rk[a[i].l][a[i].r] = i;
   int l = 1, r = tot, md;
   for (; l <= r;) {
     md = l + r >> 1;
     if (calc(md) >= k)
       l = md + 1;
     else
       r = md - 1;
   }
   for (int i = a[r].l; i <= a[r].r; ++i) putchar(s[i]);
 }