malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 400003, INF = 0x3f3f3f3f;   int n, Q, sz[maxn], fa[maxn], son[maxn], dfn[maxn], cntdfn, rig[maxn],       top[maxn], dep[maxn], z[maxn];   vector<int> g[maxn];   struct T {     int mx, sum;     T operator+(T x) const { return (T){max(x.mx, x.sum + mx), sum + x.sum}; }   } t[maxn];   void init1(int u) {     sz[u] = 1;     int mxsz = -1;     for (int v : g[u]) {       dep[v] = dep[u] + 1;       init1(v);       if (sz[v] > mxsz) mxsz = sz[v], son[u] = v;       sz[u] += sz[v];     }   }   void init2(int u, int tp) {     top[u] = tp;     dfn[u] = ++cntdfn;     if (son[u]) init2(son[u], tp);     for (int v : g[u]) {       if (v == son[u]) continue;       init2(v, v);     }     rig[u] = cntdfn;   }   void solve(int p, int len) { t[p] = (T){-1, -len}, z[p] = 1; }   void pushdown(int p, int l, int r) {     if (z[p]) {       int mid = (l + r) >> 1;       solve(p << 1, mid - l + 1), solve(p << 1 | 1, r - mid);       z[p] = 0;     }   }   void add(int p, int l, int r, int pos, int k) {     if (l == r) {       t[p].sum += k, t[p].mx += k;       return;     }     pushdown(p, l, r);     int mid = (l + r) >> 1;     if (pos <= mid)       add(p << 1, l, mid, pos, k);     else       add(p << 1 | 1, mid + 1, r, pos, k);     t[p] = t[p << 1] + t[p << 1 | 1];   }   void cover(int p, int l, int r, int seg_l, int seg_r) {     if (seg_l <= l && r <= seg_r) {       solve(p, r - l + 1);       return;     }     pushdown(p, l, r);     int mid = (l + r) >> 1;     if (seg_l <= mid) cover(p << 1, l, mid, seg_l, seg_r);     if (seg_r > mid) cover(p << 1 | 1, mid + 1, r, seg_l, seg_r);     t[p] = t[p << 1] + t[p << 1 | 1];   }   T query(int p, int l, int r, int seg_l, int seg_r) {     if (seg_l <= l && r <= seg_r) return t[p];     pushdown(p, l, r);     int mid = (l + r) >> 1;     if (seg_l <= mid && seg_r > mid)       return query(p << 1, l, mid, seg_l, seg_r) +              query(p << 1 | 1, mid + 1, r, seg_l, seg_r);     else if (seg_l <= mid)       return query(p << 1, l, mid, seg_l, seg_r);     else       return query(p << 1 | 1, mid + 1, r, seg_l, seg_r);   }   T query(int x) {     T ret = (T){-INF, 0};     while (x) {       ret = query(1, 1, n, dfn[top[x]], dfn[x]) + ret;       x = fa[top[x]];     }     return ret;   }   int main() {     scanf( %d%d , &n, &Q);     for (int i = 2; i <= n; i++) scanf( %d , fa + i), g[fa[i]].push_back(i);     init1(1), init2(1, 1), cover(1, 1, n, 1, n);     while (Q--) {       int mo, x;       scanf( %d%d , &mo, &x);       if (mo == 1) {         add(1, 1, n, dfn[x], 1);       }       if (mo == 2) {         cover(1, 1, n, dfn[x], rig[x]);         int tmp = max(query(x).mx + 1, 0);         add(1, 1, n, dfn[x], -tmp);       }       if (mo == 3) {         puts(query(x).mx >= 0 ?  black  :  white );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, x, y, fail;   int G[305][305], v[305], u[305], l[305], z[305];   long long int A, B, C, a[305], b[305], d[305];   int rx[305 * 305 * 2], ry[305 * 305 * 2], rc[305 * 305 * 2], cnt;   void dfs(int x) {     v[x] = 1;     A += a[x];     B += b[x];     for (int i = (0); i < (n); i++)       if (!v[i] && G[x][i]) G[x][i] = G[i][x] = 2, dfs(i);     l[m++] = x;   }   void add(int x, int y, long long int c) {     rx[cnt] = x + 1, ry[cnt] = y + 1, rc[cnt++] = (int)c;   }   void pull(int x, long long int d) {     z[x] = 1;     for (int i = (0); i < (n); i++)       if (G[x][i] == 2 && !u[i] && d && !z[i]) {         if (a[i] >= d) {           a[i] -= d;           a[x] += d;           add(i, x, d);           d = 0;         } else {           pull(i, d - a[i]);           long long int t = min(d, a[i]);           a[x] += t;           a[i] -= t;           d -= t;           add(i, x, t);         }       }   }   void push(int x, long long int d) {     z[x] = 1;     for (int i = (0); i < (n); i++)       if (G[x][i] == 2 && !u[i] && d && !z[i]) {         if (C - a[i] >= d) {           a[x] -= d;           a[i] += d;           add(x, i, d);           d = 0;         } else {           push(i, d - (C - a[i]));           long long int t = min(d, C - a[i]);           a[i] += t;           a[x] -= t;           d -= t;           add(x, i, t);         }       }   }   int main() {     scanf( %d%I64d%d , &n, &C, &m);     for (int i = (0); i < (n); i++) scanf( %I64d , &a[i]);     for (int i = (0); i < (n); i++) scanf( %I64d , &b[i]);     while (m--) {       scanf( %d%d , &x, &y), x--, y--;       G[x][y] = G[y][x] = 1;     }     for (int i = (0); i < (n); i++)       if (!v[i]) {         A = B = 0;         m = 0;         dfs(i);         if (A != B) {           fail = 1;           break;         }         for (int j = (0); j < (m); j++) {           int r = l[j];           memset(z, 0, sizeof(z));           if (a[r] > b[r]) push(r, a[r] - b[r]);           if (a[r] < b[r]) pull(r, b[r] - a[r]);           u[r] = 1;         }       }     if (fail)       puts( NO );     else {       printf( %d n , cnt);       for (int i = (0); i < (cnt); i++) printf( %d %d %d n , rx[i], ry[i], rc[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1e9 + 7;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const long long int N = 1e5 + 5;   long long int a[N], b[N], n, d, x;   long long int getNextX() {     x = (x * 37 + 10007) % 1000000007;     return x;   }   void initAB() {     for (long long int i = 0; i < n; i++) {       a[i] = i + 1;     }     for (long long int i = 0; i < n; i++) {       swap(a[i], a[getNextX() % (i + 1)]);     }     for (long long int i = 0; i < n; i++) {       if (i < d)         b[i] = 1;       else         b[i] = 0;     }     for (long long int i = 0; i < n; i++) {       swap(b[i], b[getNextX() % (i + 1)]);     }   }   long long int pos[N];   vector<long long int> bb;   long long int c[N];   void solve() {     cin >> n >> d >> x;     initAB();     for (long long int i = 0; i <= n - 1; i++) {       if (b[i]) bb.push_back(i);     }     for (long long int i = 0; i <= n - 1; i++) {       pos[a[i]] = i;     }     if (bb.size() <= 500) {       for (long long int i = 0; i <= n - 1; i++) {         for (long long int j : bb) {           if (j > i) break;           c[i] = max(c[i], a[i - j]);         }       }     } else {       for (long long int i = 0; i <= n - 1; i++)         for (long long int j = n; j >= 1; j--) {           long long int p = pos[j];           if (p <= i && b[i - p]) {             c[i] = j;             break;           }         }     }     for (long long int i = 0; i <= n - 1; i++) cout << c[i] <<    ;   }   signed main() {     ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);     clock_t clk = clock();     long long int t;     t = 1;     while (t--) {       solve();     }     cerr << (double)(clock() - clk) / CLOCKS_PER_SEC;     return 0;   }
#include <bits/stdc++.h>   char b[20];   using namespace std;   int main() {     char a[14];     for (int i = 1; i <= 2; i++) {       scanf( %s , a);       if (strcmp(a,  monday ) == 0) b[i] = 1;       if (strcmp(a,  tuesday ) == 0) b[i] = 2;       if (strcmp(a,  wednesday ) == 0) b[i] = 3;       if (strcmp(a,  thursday ) == 0) b[i] = 4;       if (strcmp(a,  friday ) == 0) b[i] = 5;       if (strcmp(a,  saturday ) == 0) b[i] = 6;       if (strcmp(a,  sunday ) == 0) b[i] = 7;     }     int flag = 1;     for (int j = 3; j <= 5; j++) {       if (j * 7 - b[1] + b[2] == 31 || j * 7 - b[1] + b[2] == 30 ||           j * 7 - b[1] + b[2] == 28) {         printf( YES n );         flag = 0;       }     }     while (flag) {       printf( NO n );       flag = 0;     }   }
#include <bits/stdc++.h>   using namespace std;   long long powmod(long long a, long long b) {     long long res = 1;     while (b > 0) {       if (b & 1) res = res * a % 2;       a = a * a % 2;       b >>= 1;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     long long b, k, sum = 0;     cin >> b >> k;     long long a[k];     for (long long i = 1; i <= k; i++) {       cin >> a[i];       long long p = powmod(b, k - i);       sum += a[i] * p;     }     if (sum % 2)       cout <<  odd ;     else       cout <<  even ;   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     char ch;     bool flag = false;     for (ch = getchar(); !isdigit(ch); ch = getchar())       if (ch ==  - ) flag = true;     for (x = 0; isdigit(ch); x = x * 10 + ch -  0 , ch = getchar())       ;     x = flag ? -x : x;   }   inline void write(int x) {     static const int maxlen = 100;     static char s[maxlen];     if (x < 0) {       putchar( - );       x = -x;     }     if (!x) {       putchar( 0 );       return;     }     int len = 0;     for (; x; x /= 10) s[len++] = x % 10 +  0 ;     for (int i = len - 1; i >= 0; --i) putchar(s[i]);   }   int n, m;   int pre[11000], now[110], son[11000], v[11000], tot;   int f[110][110][30];   char s[100];   void build(int a, int b, int c) {     pre[++tot] = now[a];     now[a] = tot;     son[tot] = b;     v[tot] = c;   }   int dfs(int x, int y, int MAX) {     if (f[x][y][MAX] != -1) return f[x][y][MAX];     set<int> S;     for (int p = now[x]; p; p = pre[p])       if (v[p] >= MAX) S.insert(dfs(y, son[p], v[p]));     int q = -1;     for (auto t : S) {       if (t != q + 1) break;       q = t;     }     return f[x][y][MAX] = q + 1;   }   int main() {     read(n);     read(m);     for (int i = 1; i <= m; i++) {       int a, b;       read(a);       read(b);       scanf( %s , s);       build(a, b, s[0] -  a  + 1);     }     memset(f, -1, sizeof(f));     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) dfs(i, j, 0);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++)         if (f[i][j][0])           printf( A );         else           printf( B );       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long i, j, n, cnt = 0, flag = 0, k = 0;     string str;     cin >> n >> str;     for (i = 0; i < n; i++) {       if (str[i] ==  ( ) {         cnt++;         if (cnt == 2) j = i;       } else         cnt--;       if ((cnt == -2) && (!k)) k = i;       if (cnt < -2) break;       if (cnt < 0) flag = 1;     }     if ((!cnt) || (flag && cnt == 2) || (i != n) || ((cnt != 2) && (cnt != -2))) {       cout <<  0 n ;       return 0;     }     if (cnt == 2) {       cnt = 0;       for (i = j; i < n; i++) {         if (str[i] ==  ( ) cnt++;       }     } else {       cnt = 0;       for (i = 0; i < k; i++) {         if (str[i] ==  ( )           cnt++;         else           cnt--;         if (cnt == -1) break;       }       cnt = 0;       k = i;       for (i = 0; i <= k; i++) {         if (str[i] ==  ) ) cnt++;       }     }     cout << cnt << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     pair<int, int> p[n];     int t = 0;     for (int i = 0; i < n; i++) {       cin >> p[i].first >> p[i].second;     }     sort(p, p + n);     int start = 0, l = 0, r = 0, s = 0;     for (int i = 0; i < 2 * n; i++) {       if (i < n && p[i].first > 0) {         start = 1;       }       if (start) {         l = i - 1;         r = i;         while (1) {           if (l < 0 && r == n) break;           if (l < 0) {             s += p[r].second;             break;           } else if (r == n) {             s += p[l].second;             break;           }           s += p[l--].second + p[r++].second;         }         return cout << s, 0;       }     }     cout << p[n - 1].second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[100100];   int dig[11];   int ans[11];   int main() {     int sum = 0;     bool pos = false;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       dig[a[i]]++;       sum += a[i];     }     if (dig[0] == 0) {       cout << -1;       return 0;     }     if (sum % 3 == 0) pos = true;     if (sum % 3 == 1) {       if (dig[1] > 0) {         dig[1] -= 1;         pos = true;       } else if (dig[4] > 0) {         pos = true;         dig[4] -= 1;       } else if (dig[7] > 0) {         dig[7] -= 1;         pos = true;       } else {         int a = 10, ai, aj;         for (int i = 0; i <= 9; i++)           for (int j = 0; j <= 9; j++)             if (i != j) {               if ((i + j) % 3 == 1 && dig[i] > 0 && dig[j] > 0 && max(i, j) < a) {                 a = max(i, j);                 ai = i;                 aj = j;                 pos = true;               }             } else {               if ((i + j) % 3 == 1 && dig[i] > 1 && max(i, j) < a) {                 a = max(i, j);                 ai = i;                 aj = j;                 pos = true;               }             }         dig[ai] -= 1;         dig[aj] -= 1;       }     } else if (sum % 3 == 2) {       if (dig[2] > 0) {         dig[2] -= 1;         pos = true;       } else if (dig[5] > 0) {         dig[5] -= 1;         pos = true;       } else if (dig[8] > 0) {         dig[8] -= 1;         pos = true;       } else {         int a = 10, ai, aj;         for (int i = 0; i <= 9; i++)           for (int j = 0; j <= 9; j++)             if (i != j) {               if ((i + j) % 3 == 2 && dig[i] > 0 && dig[j] > 0 && max(i, j) < a) {                 a = max(i, j);                 ai = i;                 aj = j;                 pos = true;               }             } else {               if ((i + j) % 3 == 2 && dig[i] > 1 && max(i, j) < a) {                 a = max(i, j);                 ai = i;                 aj = j;                 pos = true;               }             }         dig[ai] -= 1;         dig[aj] -= 1;       }     }     if (pos) {       bool shown = false;       for (int i = 9; i > 0; i--)         for (int j = 0; j < dig[i]; j++) {           cout << i;           shown = true;         }       if (shown)         for (int j = 0; j < dig[0]; j++) cout << 0;       else         cout << 0;     } else       cout << 0;   }
#include <bits/stdc++.h>   using namespace std;   int getInt() {     int ret;     scanf( %d , &ret);     return ret;   }   int main() {     int n = getInt();     vector<pair<int, int> > pr(n);     for (int i = 0; i < (int)(n); i++) {       pr[i].first = getInt();       pr[i].second = getInt();     }     sort(pr.begin(), pr.end());     int ans = 0;     int mxp = 0;     int mx = 0;     for (int i = 0; i < (int)(pr.size()); i++) {       if (i != 0) {         if (pr[i].first != pr[i - 1].first) {           mx = mxp;         }       }       if (mx > pr[i].second) ans++;       mxp = max(mxp, pr[i].second);     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f[105][45], head[105], la[45];   int n, k, i, j, ans, u, v, cnt;   struct ff {     int to, nxt;   } e[2 * 105];   void add(int u, int v) {     e[++cnt] = (ff){v, head[u]};     head[u] = cnt;   }   void dfs(int now, int fa) {     if (e[head[now]].nxt == 0 && fa) {       f[now][0] = f[now][k + 1] = 1;       return;     }     bool flag = 1;     for (int i = head[now]; i; i = e[i].nxt) {       int v = e[i].to;       if (v == fa) continue;       dfs(v, now);       if (flag) {         for (int j = 0; j <= 2 * k; j++) f[now][j + 1] = f[v][j];         flag = 0;       } else {         for (int j = 0; j <= 2 * k + 1; j++) la[j] = f[now][j], f[now][j] = 0;         for (int j = 0; j <= 2 * k; j++)           for (int h = 1; h <= 2 * k + 1; h++)             if (j + h <= 2 * k) {               int Min = min(j + 1, h);               f[now][Min] =                   (f[now][Min] + 1ll * la[h] * f[v][j] % 1000000007) % 1000000007;             } else {               int Max = max(j + 1, h);               f[now][Max] =                   (f[now][Max] + 1ll * la[h] * f[v][j] % 1000000007) % 1000000007;             }       }     }     for (int i = 1; i <= 2 * k + 1; i++)       f[now][0] = (f[now][0] + f[now][i]) % 1000000007;   }   int main() {     scanf( %d%d , &n, &k);     for (i = 1; i < n; i++) {       scanf( %d%d , &u, &v);       add(u, v), add(v, u);     }     dfs(1, 0);     for (i = 0; i <= k; i++) ans = (ans + f[1][i]) % 1000000007;     if (ans == 0) ans = 1;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     long long siz, fa;     bool vis;   } a[1001];   string s;   long long n, cnt[1001][1001];   vector<long long> e[1001];   vector<vector<long long> > t[1001];   vector<pair<long long, long long> > ans;   void dfs(long long x) {     a[x].siz = a[x].vis = 1;     for (long long v : e[x])       if (v != a[x].fa) {         if (a[v].vis) cout <<  -1 , exit(0);         a[v].fa = x, dfs(v), a[x].siz += a[v].siz;       }   }   vector<vector<long long> > tmp;   void check(long long u, long long fa) {     tmp.back().push_back(u);     for (long long v : e[u])       if (v != fa) check(v, u);   }   inline void chec() {     for (long long u = 1; u <= n; u++) {       tmp.clear();       for (long long v : e[u]) {         tmp.push_back(vector<long long>());         check(v, u);         sort(tmp.back().begin(), tmp.back().end());       }       sort(tmp.begin(), tmp.end());       if (t[u] != tmp) cout <<  -1 n , exit(0);     }   }   inline long long get_num() {     char temp = s.back();     s.pop_back();     long long ans = 0;     while (temp >=  0  && temp <=  9 ) {       ans = ans * 10 + temp -  0 ;       if (s.empty()) break;       temp = s.back(), s.pop_back();     }     return ans;   }   int main() {     std::cin.tie(0);     std::ios::sync_with_stdio(false);     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> s, reverse(s.begin(), s.end());       long long d, tot = 0;       while (tot < n - 1) {         t[i].push_back(vector<long long>());         d = get_num(), tot += d;         for (long long j = 1; j <= d; j++)           t[i].back().push_back(get_num()), cnt[i][t[i].back().back()] = d;         sort(t[i].back().begin(), t[i].back().end());       }       sort(t[i].begin(), t[i].end());     }     for (long long u = 1; u <= n; u++)       for (long long v = u + 1; v <= n; v++)         if (cnt[u][v] + cnt[v][u] == n)           e[u].push_back(v), e[v].push_back(u), ans.push_back(make_pair(u, v));     if ((long long)ans.size() != (n - 1)) cout <<  -1 , exit(0);     dfs(1);     if (a[1].siz != n) cout <<  -1 , exit(0);     chec();     cout << ans.size() <<   n ;     for (auto t : ans) cout << t.first <<     << t.second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 1e3 + 7;   int n, Q, m;   int p[N];   int a[N], b[N];   struct Query {     int t, x;   } q[N];   int nd, fa[N], del[N];   int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }   int rt[N];   vector<int> g[N];   int vis[N];   int st[N], ed[N], dc, rev[N];   void dfs(int x) {     if (vis[x]) return;     st[x] = ++dc;     vis[x] = 1;     rev[st[x]] = x;     for (auto v : g[x]) dfs(v);     ed[x] = dc;   }   int cnt;   struct T {     int ls, rs, l, r;     pair<int, int> mx;   } t[N * 2 + 1];   void update(int x) { t[x].mx = max(t[t[x].ls].mx, t[t[x].rs].mx); }   int build(int l, int r) {     int x = ++cnt;     t[x].l = l, t[x].r = r;     if (l == r) {       t[x].mx = make_pair(p[rev[l]], l);       return x;     }     int mid = (l + r) >> 1;     t[x].ls = build(l, mid);     t[x].rs = build(mid + 1, r);     update(x);     return x;   }   void change(int x, int p, int v) {     if (t[x].l == t[x].r) {       t[x].mx.first = v;       return;     }     int mid = (t[x].l + t[x].r) >> 1;     if (p <= mid)       change(t[x].ls, p, v);     else       change(t[x].rs, p, v);     update(x);   }   pair<int, int> query(int x, int l, int r) {     if (l <= t[x].l && t[x].r <= r) return t[x].mx;     int mid = (t[x].l + t[x].r) >> 1;     pair<int, int> mx = make_pair(0, 0);     if (l <= mid) mx = max(mx, query(t[x].ls, l, r));     if (r > mid) mx = max(mx, query(t[x].rs, l, r));     return mx;   }   int main() {     scanf( %d%d%d , &n, &m, &Q);     for (int i = 1; i <= n; i++) scanf( %d , &p[i]), fa[i] = i;     for (int i = 1; i <= m; i++) scanf( %d%d , &a[i], &b[i]);     for (int i = 1; i <= Q; i++) {       scanf( %d%d , &q[i].t, &q[i].x);       if (q[i].t == 2) del[q[i].x] = 1;     }     nd = n;     for (int i = 1; i <= m; i++)       if (!del[i]) {         int fx = find(a[i]), fy = find(b[i]);         if (fx == fy) continue;         ++nd;         g[nd].push_back(fx);         g[nd].push_back(fy);         fa[fx] = fa[fy] = fa[nd] = nd;       }     for (int i = Q; i >= 1; i--) {       if (q[i].t == 2) {         int fx = find(a[q[i].x]), fy = find(b[q[i].x]);         if (fx == fy) continue;         ++nd;         g[nd].push_back(fx);         g[nd].push_back(fy);         fa[fx] = fa[fy] = fa[nd] = nd;       } else         rt[i] = find(q[i].x);     }     for (int i = nd; i >= 1; i--) dfs(i);     build(1, nd);     for (int i = 1; i <= Q; i++) {       if (q[i].t == 1) {         pair<int, int> ans = query(1, st[rt[i]], ed[rt[i]]);         printf( %d n , ans.first);         if (ans.second) change(1, ans.second, 0);       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long a[10010];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long n, m, k;     cin >> n >> m >> k;     if (n % 2 == 0) {       cout << 0;       return 0;     }     if (m < ((n + 1) / 2)) {       cout << 0;       return 0;     }     long long can = m / ((n + 1) / 2) * k;     long long mn = 1e9;     for (long long i = 1; i <= n; ++i) {       cin >> a[i];       if (i & 1) mn = min(mn, a[i]);     }     cout << min(mn, can) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2000005;   int at[MAXN];   long long int n, x, y;   int main() {     cin >> n >> x >> y;     int a;     long long int f, g;     f = y;     g = x;     for (int i = 0; i < x + y; i++) {       if (f < g) {         at[i] = 1;         f += y;       } else if (g < f) {         at[i] = 2;         g += x;       } else {         at[i] = at[++i] = 3;         g += x;         f += y;       }     }     for (int i = 0; i < n; i++) {       cin >> a;       a--;       a %= x + y;       if (at[a] == 2)         cout <<  Vova ;       else if (at[a] == 1)         cout <<  Vanya ;       else         cout <<  Both ;       cout << endl;     }     return 0;   }