malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   long long s, x;   int sba[150], xba[150];   long long bab[150];   int main(int argc, char** argv) {     int i, j;     int num;     int n, m;     int flag;     long long tmp;     long long ans;     bab[0] = 1;     for (i = 1; i < 60; i++) bab[i] = bab[i - 1] * 2;     while (~scanf( %I64d%I64d , &s, &x)) {       if (s < x) {         printf( 0 n );         continue;       }       memset(sba, 0, sizeof(sba));       memset(xba, 0, sizeof(xba));       i = 0;       num = 0;       tmp = x;       while (tmp) {         if (tmp & 1) {           num++;           xba[i] = 1;         }         tmp >>= 1;         i++;       }       n = i;       ans = 0;       ans += bab[num];       tmp = s - x;       if (tmp & 1) {         printf( 0 n );         continue;       }       flag = 0;       i = 0;       while (tmp) {         if (tmp & 1) {           sba[i] = 1;         }         tmp >>= 1;         i++;       }       m = i;       for (i = 0; i < n; i++) {         if (xba[i] == 1 && sba[i + 1] == 1) {           flag = 1;           break;         }       }       if (flag) {         printf( 0 n );         continue;       } else {         if ((s ^ 0) == x) ans -= 2;         printf( %I64d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, i, mi, ma, x;       cin >> n;       int m[n + 1];       for (i = 1; i <= n; i++) {         cin >> x;         m[x] = i;       }       int a[n + 1];       a[1] = 1;       a[n] = 1;       mi = m[1];       ma = m[1];       for (i = 2; i < n; i++) {         mi = min(mi, m[i]);         ma = max(ma, m[i]);         if ((ma - mi) == i - 1) {           a[i] = 1;         } else {           a[i] = 0;         }       }       for (i = 1; i <= n; i++) {         cout << a[i];       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int x;     scanf( %d , &x);     if (x == 1)       puts( 1 );     else if (x == 3)       puts( 5 );     else if (x <= 5)       puts( 3 );     else if (x <= 13)       puts( 5 );     else if (x <= 25)       puts( 7 );     else if (x <= 41)       puts( 9 );     else if (x <= 61)       puts( 11 );     else if (x <= 85)       puts( 13 );     else       puts( 15 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string str;     unordered_map<string, char> index;     int t;     cin >> t;     while (t--) {       cin >> str;       sort(str.begin(), str.end());       str = str.substr(0, unique(str.begin(), str.end()) - str.begin());       if (index.find(str) == index.end()) {         index.insert(unordered_map<string, char>::value_type(str,  c ));       }     }     cout << index.size() << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10;   int h[20][20];   long double E[20][20];   bool vis[20][20];   void init() {     for (int i = 1; i <= 10; i++) {       for (int j = 1; j <= 10; j++) {         cin >> h[i][j];       }     }   }   pair<int, int> go_next(int x, int y) {     if (x % 2 == 1) {       if (y > 1)         return make_pair(x, y - 1);       else         return make_pair(x - 1, y);     } else {       if (y < 10)         return make_pair(x, y + 1);       else         return make_pair(x - 1, y);     }   }   long double dp(int x, int y) {     if (vis[x][y]) return E[x][y];     double e = 0;     int tx = x, ty = y;     for (int i = 1; i <= 6; i++) {       std::tie(tx, ty) = go_next(tx, ty);       long double p = dp(tx, ty);       if (h[tx][ty] > 0) {         p = min(p, dp(tx - h[tx][ty], ty));       }       e += (p + 1) / 6.0;     }     E[x][y] = e;     vis[x][y] = true;     return E[x][y];   }   void work() {     E[1][1] = 0.0;     E[1][2] = 6.0;     E[1][3] = 3.0 + 0.5 * E[1][2];     E[1][4] = 2.0 + E[1][2] / 3.0 + E[1][3] / 3.0;     E[1][5] = 1.5 + 1.0 / 4.0 * (E[1][2] + E[1][3] + E[1][4]);     E[1][6] = 1.2 + 1.0 / 5.0 * (E[1][2] + E[1][3] + E[1][4] + E[1][5]);     memset(vis, false, sizeof(vis));     for (int i = 1; i <= 6; i++) vis[1][i] = true;     dp(10, 1);     cout << std::setprecision(8) << std::fixed << E[10][1] << endl;   }   int main() {     init();     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x = 1;     cin >> n;     string arr[n];     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     for (int i = 0; i < n && x == 1; i++) {       string s = arr[i];       for (int j = 0; j < 5; j++) {         if (s[j] ==  O  && s[j + 1] ==  O ) {           cout <<  YES  << endl;           s[j] =  + ;           s[j + 1] =  + ;           arr[i] = s;           x = 0;           break;         }       }     }     if (x == 0) {       for (int m = 0; m < n; m++) {         cout << arr[m] << endl;       }     } else {       cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   const int block_size = 360;   const int maxn = 100010;   const long long mod = 1e9 + 7;   const long double eps = 1e-9;   template <typename T>   int sign(const T& a) {     if (a < 0) {       return -1;     }     if (a > 0) {       return 1;     }     return 0;   }   long long cross_product(const complex<long long>& from, complex<long long> a,                           complex<long long> b) {     a -= from;     b -= from;     return a.imag() * b.real() - a.real() - b.imag();   }   string a =   , b =   ;   int main() {     int n;     scanf( %d , &n);     for (long long i = 0; i < n; i++) {       string c;       cin >> c;       if (c !=  0 ) {         a += c;       }     }     for (long long i = 0; i < n; i++) {       string c;       cin >> c;       if (c !=  0 ) {         b += c;       }     }     a = a + a;     if (strstr(a.c_str(), b.c_str())) {       cout <<  YES ;     } else {       cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int n, cnt;   int ans[100005];   vector<int> e[100005];   map<int, int> mp[100005];   map<vector<int>, int> H;   set<int> st;   int dp(int x, int fa) {     if (mp[x][fa]) return mp[x][fa];     vector<int> cur;     for (int i = 0; i < e[x].size(); i++)       if (e[x][i] != fa) cur.push_back(dp(e[x][i], x));     sort(cur.begin(), cur.end());     if (!H[cur]) H[cur] = ++cnt;     return mp[x][fa] = H[cur];   }   int main() {     n = read();     for (int i = 1; i < n; i++) {       int u = read(), v = read();       e[u].push_back(v);       e[v].push_back(u);     }     for (int i = 1; i <= n; i++)       if (e[i].size() < 4) st.insert(dp(i, 0));     cout << st.size() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct event {     int x, size, val, ent;     bool operator<(const event& rhs) const {       if (x == rhs.x) return ent < rhs.ent;       return x < rhs.x;     }   };   int main() {     ios_base::sync_with_stdio(false), cin.tie(0);     int n, x;     cin >> n >> x;     vector<event> v;     for (int i = 0; i < n; i++) {       int l, r, cost;       cin >> l >> r >> cost;       v.push_back({l, r - l + 1, cost, 0});       v.push_back({r, r - l + 1, cost, 1});     }     sort(v.begin(), v.end());     int ans = 0x7fffffff;     map<int, int> mp;     for (const event& eve : v) {       if (eve.ent == 0) {         auto it = mp.find(x - eve.size);         if (it == mp.end())           continue;         else           ans = min(ans, it->second + eve.val);       } else {         if (mp[eve.size] == 0)           mp[eve.size] = eve.val;         else           mp[eve.size] = min(eve.val, mp[eve.size]);       }     }     if (ans == 0x7fffffff) ans = -1;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007, con = 2500000;   long long n, k, a, ans;   int main() {     iostream::sync_with_stdio(0);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> k;       ans += abs(a - k);       a = k;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e3 + 7;   int n;   int a[maxn], b[maxn];   long long solve() {     long long res = 0;     for (int i = 0; i < int(n); i++) {       long long sa = 0, sb = 0;       for (int j = i; j < int(n); j++) {         sa |= a[j];         sb |= b[j];         res = max(res, sa + sb);       }     }     return res;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < int(n); i++) scanf( %d , &a[i]);     for (int i = 0; i < int(n); i++) scanf( %d , &b[i]);     printf( %lld n , solve());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define ll long long   #define ull unsigned long long   #define uint unsigned int   #define loop(n) for(int i=1;i<=n;i++)         int main()   {    ios_base::sync_with_stdio(false);    cout.tie(NULL);    cin.tie(NULL);       uint t;    cin>>t;    while(t--)    {     int n,temp,tem;     ll min=INT_MAX;     cin>>n;     map<int,int> a;     vector<int> s;     set<int> st;     loop(n)     {      cin>>temp;      tem=a[temp];      a[temp]=tem+1;     }     for(auto i:a)     {      //cout<<i.second<<   ;      s.push_back(i.second);      st.insert(i.second);     }     for(auto mid:st)       {      ll sum=0;      for(auto i:s)       if(i<mid)        sum+=i;       else        sum+=i-mid;      if(min>sum)       min=sum;     }     cout<<min<<endl;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   char s[2001][2002];   int wu[2][2001];   int ans;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %s , s[i] + 1);     for (int i = 1; i <= n; i++) {       int rxor = 0, lxor = 0, d;       for (int j = n; j > i; j--) {         d = wu[0][j] ^ (s[i][j] -  0 ) ^ rxor;         if (d) ans++, rxor ^= 1, wu[0][j] ^= 1;         d = wu[1][j] ^ (s[j][i] -  0 ) ^ lxor;         if (d) ans++, lxor ^= 1, wu[1][j] ^= 1;       }       if ((s[i][i] -  0 ) ^ rxor ^ lxor ^ wu[0][i] ^ wu[1][i]) ans++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, s5;     cin >> s;     int c = 0;     string s3 =   , s4 =   ;     s3 += s[0];     s3 += s[1];     s4 += s[3];     s4 += s[4];     int a = atoi(s3.c_str());     int b = atoi(s4.c_str());     while (1) {       if (b == 59) {         if (a == 23)           a = 0, s3[0] =  0 , s3[1] =  0 ;         else {           a++;           stringstream ss;           ss << a;           s5 = ss.str();           if (a < 10) {             s3 =  0 ;             s3 += s5;           } else             s3 = s5;         }         b = 0;         s4[0] =  0 , s4[1] =  0 ;       } else {         b++;         stringstream ss;         ss << b;         s5 = ss.str();         if (b < 10) {           s4 =  0 ;           s4 += s5;         } else           s4 = s5;       }       c++;       if (s3[0] == s4[1] && s3[1] == s4[0] && c > 0) break;     }     cout << s3 <<  :  << s4 << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct team {     int prob;     int time;   };   bool comp(team a, team b) {     return (a.prob > b.prob) || ((a.prob == b.prob) && (a.time < b.time));   }   int main(int argc, char const *argv[]) {     int n, k;     cin >> n >> k;     team t[n];     for (int i = 0; i < n; ++i) {       cin >> t[i].prob >> t[i].time;     }     sort(t, t + n, comp);     team tk;     tk = t[k - 1];     int count = 1;     int i = k - 2;     int j = k;     while ((tk.time == t[i].time) && (tk.prob == t[i].prob) && (i >= 0)) {       count++;       i--;     }     while ((tk.time == t[j].time) && (tk.prob == t[j].prob) && (j < n)) {       count++;       j++;     }     cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize  trapv    long long int power(long long int x, long long int b) {     long long int p = 1;     while (b > 0) {       if (b & 1) {         p = p * x;         p %= 1000000007;       }       b >>= 1;       x *= x;       x %= 1000000007;     }     return p % 1000000007;   }   using namespace std;   struct ppp {     char a;     long long int b, c, d;   };   long long int N;   struct lex_compare {     bool operator()(ppp p1, ppp p2) {       if (p1.a == p2.a) {         if (p1.b == p2.b)           return p1.c < p2.c;         else           return p1.b < p2.b;       } else {         return p1.a < p2.a;       }     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long int n;     cin >> n;     long long int arr[n];     for (long long int i = 0; i < n; i++) cin >> arr[i];     long long int maxt = n;     vector<vector<long long int> > ans;     while (maxt--) {       vector<vector<long long int> > blocks;       int i = 0;       while (i < n) {         long long int s = arr[i];         vector<long long int> temp;         temp.push_back(s);         i++;         while (i < n && arr[i] == s + 1) {           s = arr[i];           i++;           temp.push_back(s);         }         blocks.push_back(temp);       }       if (blocks.size() == 1) break;       long long int minele = blocks[blocks.size() - 1].back();       long long int next = minele + 1;       if (next == n + 1) {         vector<long long int> tempans;         long long int ind = 0;         for (int j = blocks.size() - 1; j >= 0; j--) {           tempans.push_back(blocks[j].size());           for (auto k : blocks[j]) {             arr[ind++] = k;           }         }         reverse(tempans.begin(), tempans.end());         ans.push_back(tempans);         continue;       }       long long int ind2nd = 0;       while (ind2nd < blocks.size() && blocks[ind2nd][0] != next) {         ind2nd++;       }       vector<long long int> tempans;       long long int size1 = 0;       i = 0;       while (i < ind2nd) {         size1 += blocks[i].size();         i++;       }       if (size1 != 0) tempans.push_back(size1);       size1 = 0;       i = ind2nd;       while (i < blocks.size() - 1) {         size1 += blocks[i].size();         i++;       }       if (size1 != 0) tempans.push_back(size1);       tempans.push_back(blocks.back().size());       ans.push_back(tempans);       int ind = 0;       for (auto j : blocks.back()) {         arr[ind++] = j;       }       for (int j = ind2nd; j < blocks.size() - 1; j++) {         for (auto k : blocks[j]) {           arr[ind++] = k;         }       }       for (int j = 0; j < ind2nd; j++) {         for (auto k : blocks[j]) {           arr[ind++] = k;         }       }     }     cout << ans.size() <<   n ;     for (auto i : ans) {       cout << i.size() <<    ;       for (auto j : i) cout << j <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200];   int main() {     int t;     cin >> t;     while (t--) {       int m, n;       cin >> m >> n;       for (int i = 1; i <= m; i++) {         cin >> a[i];       }       map<int, int> mp;       for (int i = 1; i <= n; i++) {         int x;         cin >> x;         mp[x] = 1;       }       for (int i = 1; i < m; i++) {         for (int j = m - i; j <= m; j++) {           if (j + 1 <= m && a[j] > a[j + 1]) {             if (mp[j]) {               swap(a[j], a[j + 1]);             }           }         }       }       int flag = 1;       for (int i = 1; i < m; i++) {         if (a[i] > a[i + 1]) {           flag = 0;         }       }       if (flag)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long int n, a, b;   long long int S(long long int x) {     int ret = 0;     long long int y = n - x;     while (x > 0) {       ret += x % 10;       x /= 10;     }     while (y > 0) {       ret += y % 10;       y /= 10;     }     return ret;   }   long long int solve(long long int x) {     long long int b = 1, ans = x;     while (x) {       long long int cur = (x - 1) * b + (b - 1);       if (S(cur) > S(ans)) {         ans = cur;       }       x /= 10;       b *= 10;     }     return ans;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     cout << S(solve(n));     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3)   #pragma GCC optimize(2)   using namespace std;   int n, r;   bool dp[666][666];   int fang[666][666];   pair<int, int> ku[666];   void dfs(int x, int y) {     if (x == y)       cout <<  () ;     else if (fang[x][y] == -1) {       cout <<  ( ;       dfs(x + 1, y);       cout <<  ) ;     } else {       dfs(x, fang[x][y]);       dfs(fang[x][y] + 1, y);     }   }   signed main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     memset(dp, 0, sizeof dp);     cin >> n;     for (register int i = 1; (1 < n) ? (i <= n) : (i >= n);          i += (1 < n) ? 1 : (-1))       cin >> ku[i].first >> ku[i].second;     for (register int i = 1; (1 < n) ? (i <= n) : (i >= n);          i += (1 < n) ? 1 : (-1))       dp[i][i] = (bool)(ku[i].first == 1);     for (register int i = 2; (2 < n) ? (i <= n) : (i >= n);          i += (2 < n) ? 1 : (-1)) {       for (register int l = 1;            (1 < n - i + 1) ? (l <= n - i + 1) : (l >= n - i + 1);            l += (1 < n - i + 1) ? 1 : (-1)) {         r = l + i - 1;         if (dp[l + 1][r] && ku[l].first - 1 <= (r - l) * 2 &&             (r - l) * 2 <= ku[l].second - 1) {           dp[l][r] = 1;           fang[l][r] = -1;         } else {           for (register int k = l; (l < r - 1) ? (k <= r - 1) : (k >= r - 1);                k += (l < r - 1) ? 1 : (-1)) {             if (dp[l][k] && dp[k + 1][r]) {               dp[l][r] = 1;               fang[l][r] = k;               break;             }           }         }       }     }     if (dp[1][n]) {       dfs(1, n);       cout << endl;     } else       cout <<  IMPOSSIBLE  << endl;     return 0;   }
#include <bits/stdc++.h>   const int N = 5000 + 10;   struct node {     int l, r, id;   };   node a[N];   bool pre[N], suf[N];   std::vector<node> vector;   bool cmp(const node& i, const node& j) {     if (i.r ^ j.r)       return i.r < j.r;     else       return i.l < j.l;   }   bool cc(const node& i, const node& j) { return i.id < j.id; }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       a[i].id = i;       scanf( %d%d , &a[i].l, &a[i].r);     }     std::sort(a + 1, a + 1 + n, cmp);     pre[0] = pre[1] = true;     for (int i = 2; i <= n; ++i)       if (pre[i - 1] && a[i].l >= a[i - 1].r)         pre[i] = true;       else         break;     suf[n + 1] = suf[n] = true;     for (int i = n - 1; i >= 1; --i)       if (suf[i + 1] && a[i].r <= a[i + 1].l)         suf[i] = true;       else         break;     for (int i = 1; i <= n; ++i)       if (pre[i - 1] && suf[i + 1]) {         if (i == 1 || i == n || a[i - 1].r <= a[i + 1].l) vector.push_back(a[i]);       }     std::sort(vector.begin(), vector.end(), cc);     printf( %d n , vector.size());     for (int i = 0; i < vector.size(); ++i) {       if (i) putchar(   );       printf( %d , vector[i].id);     }     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     double f, s, v, l, omega, r;     const double tol = 1.0e-7;     scanf( %d %lf %lf , &n, &r, &v);     omega = v / r;     double xt, xb, a, b;     for (int i = 0; i < n; i++) {       scanf( %lf %lf , &s, &f);       l = (f - s) / 2.;       a = (l + r + 0.1) / v;       b = -0.1;       xt = (a + b) / 2.;       while (abs((b - a) / xt) > tol) {         if ((v * xt + r * sin(xt * omega) - l) *                 (v * a + r * sin(a * omega) - l) <             0.)           b = xt;         else           a = xt;         xt = (a + b) / 2.;       }       a = (l + r + 0.1) / v;       b = -0.1;       do {         xb = (a + b) / 2.;         if ((v * xb - r * sin(xb * omega) - l) *                 (v * a - r * sin(a * omega) - l) <             0.)           b = xb;         else           a = xb;       } while (abs((b - a) / xb) > tol);       printf( %.10lf n , 2. * min(xb, xt));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k;   map<string, long long> mm;   string a[100005];   long long c[100005];   long long min(long long a, long long b) { return a < b ? a : b; }   int main() {     cin >> n >> k >> m;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       long long x;       cin >> x;       mm[a[i]] = x;     }     for (int i = 0; i < k; i++) {       long long x;       cin >> x;       long long minn = 0x3f3f3f3f;       for (int j = 0; j < x; j++) {         cin >> c[j];         minn = min(minn, mm[a[c[j]]]);       }       for (int j = 0; j < x; j++) {         mm[a[c[j]]] = minn;       }     }     string b;     long long s = 0;     for (int i = 0; i < m; i++) {       cin >> b;       s += mm[b];     }     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e6 + 10;   struct node {     int l, r, sum, mus;   } tr[M];   int n, a[M], now[M], sz[M], place[M], q, p;   vector<int> g[M];   void maket(int l, int r, int t) {     tr[t].l = l;     tr[t].r = r;     if (l == r) {       tr[t].sum += now[a[l]];       return;     }     maket(l, (l + r) / 2, 2 * t);     maket((l + r) / 2 + 1, r, 2 * t + 1);     tr[t].sum = tr[2 * t].sum + tr[2 * t + 1].sum;   }   void change(int l, int r, int t) {     if (tr[t].l == l && tr[t].r == r) {       tr[t].sum = r - l + 1 - tr[t].sum;       tr[t].mus ^= 1;       return;     }     if (tr[t].mus) {       change(tr[2 * t].l, tr[2 * t].r, 2 * t);       change(tr[2 * t + 1].l, tr[2 * t + 1].r, 2 * t + 1);       tr[t].mus = 0;     }     if (r <= tr[2 * t].r)       change(l, r, 2 * t);     else if (l >= tr[2 * t + 1].l)       change(l, r, 2 * t + 1);     else {       change(l, tr[2 * t].r, 2 * t);       change(tr[2 * t + 1].l, r, 2 * t + 1);     }     tr[t].sum = tr[2 * t].sum + tr[2 * t + 1].sum;   }   int query(int l, int r, int t) {     if (tr[t].l == l && tr[t].r == r) return tr[t].sum;     if (tr[t].mus) {       change(tr[2 * t].l, tr[2 * t].r, 2 * t);       change(tr[2 * t + 1].l, tr[2 * t + 1].r, 2 * t + 1);       tr[t].mus = 0;     }     if (r <= tr[2 * t].r)       return query(l, r, 2 * t);     else if (l >= tr[2 * t + 1].l)       return query(l, r, 2 * t + 1);     else       return query(l, tr[2 * t].r, 2 * t) + query(tr[2 * t + 1].l, r, 2 * t + 1);     tr[t].sum = tr[2 * t].sum + tr[2 * t + 1].sum;   }   void dfs(int v) {     a[++p] = v;     place[v] = p;     sz[v] = 1;     for (int i = 0; i < g[v].size(); i++) {       dfs(g[v][i]);       sz[v] += sz[g[v][i]];     }   }   int main() {     cin >> n;     for (int i = 2; i <= n; i++) {       int x;       scanf( %d , &x);       g[x].push_back(i);     }     for (int i = 1; i <= n; i++) scanf( %d , now + i);     dfs(1);     maket(1, n, 1);     cin >> q;     while (q--) {       string s;       cin >> s;       int v;       scanf( %d , &v);       if (s ==  get )         printf( %d n , query(place[v], place[v] + sz[v] - 1, 1));       else         change(place[v], place[v] + sz[v] - 1, 1);     }     return 0;   }