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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


func_code_string: #include <bits/stdc++.h> n using namespace std; n const int inf = 1 << 28; n const double INF = 1e12, EPS = 1e-9; n int n, m, k; n bool star[600][600]; n int sum[600][600]; n char in[600][600]; n void run() { n   cin >> n >> m >> k; n   for (int i = 0; i < n; i++) cin >> in[i]; n   for (int i = 0; i < n; i++) n     for (int j = 0; j < m; j++) { n       if (in[i][j] ==  1  && in[i + 1][j] ==  1  && in[i + 2][j] ==  1  && j && n           in[i + 1][j - 1] ==  1  && in[i + 1][j + 1] ==  1 ) n         star[i][j] = 1; n     } n   long long ans = 0; n   for (int i = 0; i < n; i++) n     for (int j = 0; j < m; j++) n       sum[i + 1][j + 1] = n           star[i][j] + sum[i][j + 1] + sum[i + 1][j] - sum[i][j]; n   for (int a = 0; a < n; a++) n     for (int b = a + 3; b <= n; b++) { n       int l = 0, r = 2, cnt = 0; n       for (; l < m; l++) { n         while (r <= m && cnt < k) { n           r++; n           cnt += sum[b - 2][r - 1] - sum[a][r - 1] - n                  (sum[b - 2][r - 2] - sum[a][r - 2]); n         } n         if (cnt < k || r > m) break; n         ans += m - r + 1; n         cnt -= sum[b - 2][l + 2] - sum[a][l + 2] - n                (sum[b - 2][l + 1] - sum[a][l + 1]); n       } n     } n   cout << ans << endl; n } n int main() { run(); } n


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


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


func_code_string: #include <algorithm> n #include <cmath> n #include <cstdio> n #include <cstring> n #include <iostream> n #include <map> n #include <set> n #include <unordered_map> n  n using namespace std; n typedef long long LL; n const int N = 3e5 + 10, mod = 998244353; n string g[N]; n int dp[N]; n  n int fastPow(int a, int k) { n     int res = 1; n     while (k) { n         if (k & 1) res = (LL)res * a % mod; n         k >>= 1; n         a = (LL)a * a % mod; n     } n     return res; n } n  n int main() { n     ios::sync_with_stdio(false); n     int n, m, sum = 0, res = 0; n     n = 300000; n     for (int i = 2; i <= n; i++) { n         if (i & 1) sum = (sum + 1) % mod; n         dp[i] = ((LL)dp[i - 1] * 2 % mod + sum + !(i & 1)) % mod; n         sum = (sum << 1) % mod; n     } n     sum = 0; n     cin >> n >> m; n     for (int i = 0; i < n; i++) { n         cin >> g[i]; n         for (auto c : g[i]) n             if (c ==  o ) sum++; n     } n     for (int i = 0; i < n; i++) { n         int cnt = 0, len = 0; n         while (cnt <= m) { n             if (cnt == m || g[i][cnt] ==  * ) { n                 if (len) { n                     res = (res + (LL)dp[len] * n                                      fastPow(2, sum - len) % mod) % n                           mod; n                     len = 0; n                 } n             } else { n                 len++; n             } n             cnt++; n         } n     } n     for (int i = 0; i < m; i++) { n         int cnt = 0, len = 0; n         while (cnt <= n) { n             if (cnt == n || g[cnt][i] ==  * ) { n                 if (len) { n                     res = (res + (LL)dp[len] * n                                      fastPow(2, sum - len) % mod) % n                           mod; n                     len = 0; n                 } n             } else { n                 len++; n             } n             cnt++; n         } n     } n     cout << res << endl; n     return 0; n }


func_code_string: #include <bits/stdc++.h> n using namespace std; n const int maxn = 100 + 10; n char s[maxn]; n int f(char ch) { n   if (ch ==  A ) return 1; n   if (ch ==  B ) return 2; n   if (ch ==  C ) return 4; n   return 0; n } n int main() { n   scanf( %s , s + 1); n   int l = strlen(s + 1); n   for (int i = 1; i <= l - 2; ++i) { n     int t = f(s[i]) | f(s[i + 1]) | f(s[i + 2]); n     if (t == 7) { n       cout <<  Yes  << endl; n       return 0; n     } n   } n   cout <<  No ; n   return 0; n } n


func_code_string: #include <bits/stdc++.h> n using namespace std; n vector<int> tree[500001]; n bool intree[500001]; n vector<int> tmp(0); n bool isleaf(int node) { n   if (tree[node].size() == 1 && intree[(tree[node])[0]]) return true; n   return false; n } n void DFS(int lvl, int node) { n   intree[node] = true; n   if (isleaf(node)) { n     tmp.push_back(lvl); n   } n   for (int i = 0; i < tree[node].size(); i++) { n     if (!intree[(tree[node])[i]]) { n       DFS(lvl + 1, (tree[node])[i]); n     } n   } n } n int main() { n   ios_base::sync_with_stdio(false); n   int N; n   cin >> N; n   for (int i = 1; i <= N; i++) intree[i] = false; n   int x, y; n   for (int i = 0; i < N - 1; i++) { n     cin >> x >> y; n     tree[x].push_back(y); n     tree[y].push_back(x); n   } n   intree[1] = true; n   int ans = 0, c; n   for (int i = 0; i < (tree[1]).size(); i++) { n     tmp.clear(); n     DFS(0, (tree[1])[i]); n     sort(tmp.begin(), tmp.end()); n     c = tmp.size(); n     for (int j = 0; j < c; j++) { n       ans = max(ans, tmp[j] + c - j); n     } n   } n   cout << ans << endl; n } n


func_code_string: #include <bits/stdc++.h> n using namespace std; n int main() { n   ios_base::sync_with_stdio(false); n   int n; n   cin >> n; n   vector<string> v(n); n   for (int i = 0; i < n; i++) cin >> v[i]; n   for (int i = 1; i < n - 1; i++) { n     for (int j = 1; j < n - 1; j++) { n       if (v[i][j] ==  #  and v[i + 1][j] ==  #  and v[i][j + 1] ==  #  and n           v[i][j - 1] ==  #  and v[i - 1][j] ==  # ) { n         v[i][j] =  a ; n         v[i + 1][j] =  a ; n         v[i][j + 1] =  a ; n         v[i][j - 1] =  a ; n         v[i - 1][j] =  a ; n       } n     } n   } n   int c = 0; n   for (int i = 0; i < n; i++) n     for (int j = 0; j < n; j++) n       if (v[i][j] ==  # ) { n         c = 1; n         break; n       } n   if (c) n     cout <<  NO  << endl; n   else n     cout <<  YES  << endl; n   return 0; n } n


func_code_string: #include <bits/stdc++.h> n using namespace std; n const long long N = 1e5 + 5; n int32_t main() { n   ios::sync_with_stdio(0); n   cin.tie(0); n   cout.tie(0); n   ; n   long long n; n   cin >> n; n   long long con = -1; n   long long a[n + 5]; n   for (long long i = 1; i <= n; i++) { n     cin >> a[i]; n   } n   long long i = 1; n   for (i = 1; i < n; i++) { n     if (a[i + 1] == a[i]) { n       con = i; n       break; n     } n   } n   if (con == -1) { n     for (con = 1; con < n; con++) { n       if (a[con] > a[con + 1]) { n         break; n       } n     } n   } n   for (i = 1; i < con; i++) { n     if (a[i + 1] < a[i]) { n       cout <<  NO  n            <<   n ; n       return 0; n     } n   } n   while (a[con] == a[con + 1]) { n     con++; n   } n   for (i = con; i < n; i++) { n     if (a[i + 1] >= a[i]) { n       cout <<  NO  n            <<   n ; n       return 0; n     } n   } n   cout <<  YES  n        <<   n ; n } n


func_code_string: #include <bits/stdc++.h> n using ll = long long; n using namespace std; n int main() { n   ios::sync_with_stdio(false); n   int N, K; n   cin >> N >> K; n   ll total = N + 1; n   total += N; n   total += min(2 * (K - 1) + (N - K), 2 * (N - K) + K - 1); n   cout << total <<   n ; n   return 0; n } n


func_code_string: #include <bits/stdc++.h> n using namespace std; n int k, n[20], a[20][5010], g[32768], f[32768], hsh[301781], ps[301781], n     ans1[20], ans2[20], vis[20], TMS; n pair<int, int> md[32768]; n long long sm[20]; n int get(int x) { n   int y = (x + 1000000001) % 301781; n   while (hsh[y] && hsh[y] ^ x + 1000000001) y = (y + 1) % 301781; n   return y; n } n void dg(int x, int s1, int s2) { n   if (x == k) { n     f[s2 + s1] |= f[s1] * g[s2]; n     return; n   } n   dg(x + 1, s1, s2); n   dg(x + 1, s1, s2 + (1 << x)); n   dg(x + 1, s1 + (1 << x), s2); n } n int main() { n   scanf( %d , &k); n   long long S = 0; n   for (int i = 0; i < k; ++i) { n     scanf( %d , n + i); n     for (int j = 0; j < n[i]; ++j) { n       int x; n       scanf( %d , &x); n       a[i][j] = x; n       sm[i] += x; n       S += x; n       int w = get(x); n       ps[w] = i; n       hsh[w] = x + 1000000001; n     } n   } n   if (S % k != 0) { n     printf( No ); n     return 0; n   } n   S /= k; n   for (int i = 0; i < k; ++i) n     for (int j = 0; j < n[i]; ++j) { n       int st = 1 << i, nw = i; n       long long c = S - (sm[i] - a[i][j]); n       int P = 1; n       ++TMS; n       for (;;) { n         vis[nw] = TMS; n         if (abs(c) > 1000000000) { n           P = 0; n           break; n         } n         int w = get(c); n         if (!hsh[w]) { n           P = 0; n           break; n         } n         st |= 1 << ps[w]; n         if (ps[w] == i) { n           P = c == a[i][j]; n           break; n         } n         c = S - (sm[ps[w]] - c); n         nw = ps[w]; n         if (vis[nw] == TMS) { n           P = 0; n           break; n         } n       } n       if (P) { n         md[st] = make_pair(i, j); n         g[st] = 1; n       } n     } n   f[0] = 1; n   dg(0, 0, 0); n   if (f[(1 << k) - 1]) { n     printf( Yes n ); n     int ST = (1 << k) - 1; n     while (ST) { n       for (int _ = ST; _; _ = (_ - 1) & ST) n         if (g[_] * f[ST - _]) { n           int i = md[_].first, j = md[_].second, nw = i; n           long long c = S - (sm[i] - a[i][j]), ls = a[i][j]; n           for (;;) { n             int w = get(c); n             ans1[ps[w]] = c; n             ans2[ps[w]] = nw; n             if (ps[w] == i) break; n             ls = c; n             nw = ps[w]; n             c = S - (sm[ps[w]] - c); n           } n           ST -= _; n           break; n         } n     } n     for (int i = 0; i < k; ++i) printf( %d %d n , ans1[i], ans2[i] + 1); n   } else { n     printf( No ); n   } n } n


func_code_string: #include <bits/stdc++.h> n using namespace std; n int main() { n   ios_base::sync_with_stdio(false); n   cin.tie(NULL); n   long long int test = 1; n   for (; test > 0; --test) { n     long long int n, a, b, c, d, c1 = 1, c2, c3, c4; n     cin >> n >> a >> b >> c >> d; n     c2 = c1 + b - c; n     c3 = c2 + a - d; n     c4 = c3 + c - b; n     long long int m = 1 - min(min(c1, c2), min(c3, c4)), n                   m1 = max(max(c1, c2), max(c3, c4)); n     if (m1 + abs(m) > n) n       cout << 0 << endl; n     else n       cout << (n - (m1 + abs(m)) + 1) * n << endl; n   } n   return (0); n } n


func_code_string: #include <bits/stdc++.h> n using namespace std; n const long long int MAX = 1000000007; n const long long int MAXN = 100010; n int main() { n   ios_base::sync_with_stdio(false); n   cin.tie(NULL); n   cout.tie(NULL); n   long long int t; n   cin >> t; n   while (t--) { n     long long int n, k; n     cin >> n >> k; n     if (n % 2 == 0 && k % 2 == 1) n       cout <<  NO  << endl; n     else if (n % 2 == 1 && k % 2 == 0) n       cout <<  NO  << endl; n     else { n       if (k * k <= n) n         cout <<  YES  << endl; n       else n         cout <<  NO  << endl; n     } n   } n   return 0; n } n


func_code_string: #include <bits/stdc++.h> n using namespace std; n int d[250003]; n int main() { n   int i, j, k, n, m, t, a[501][501], b[501][501]; n   cin >> t; n   while (t--) { n     cin >> n >> m; n     for (i = 0; i < n; i++) n       for (j = 0; j < m; j++) cin >> a[i][j], d[a[i][j]] = i; n     for (i = 0; i < m; i++) n       for (j = 0; j < n; j++) cin >> b[i][j]; n     for (i = 0; i < n; i++) { n       for (j = 0; j < m; j++) { n         cout << a[d[b[0][i]]][j] <<    ; n       } n       cout << endl; n     } n   } n } n