malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     vector<pair<string, int>> v;     priority_queue<int, vector<int>, greater<int>> pq;     for (int i = 0; i < n; ++i) {       string s;       cin >> s;       int x;       if (s !=  removeMin ) {         cin >> x;         v.push_back({s, x});       } else         v.push_back({s, INT_MIN});     }     vector<pair<string, int>> ans;     for (int i = 0; i < n; ++i) {       if (v[i].first ==  insert )         ans.push_back({v[i].first, v[i].second}), pq.push(v[i].second);       else if (v[i].first ==  getMin ) {         int val = v[i].second;         if (pq.empty()) {           ans.push_back({ insert , val});           pq.push(val);         }         while (!pq.empty() && val > pq.top()) {           ans.push_back({ removeMin , INT_MIN});           pq.pop();         }         if (!pq.empty() && val < pq.top()) {           ans.push_back({ insert , val});           pq.push(val);         } else if (pq.empty()) {           ans.push_back({ insert , val});           pq.push(val);         }         ans.push_back({ getMin , val});       } else {         if (pq.empty()) {           ans.push_back({ insert , 0});           pq.push(0);         }         ans.push_back({ removeMin , INT_MIN});         pq.pop();       }     }     cout << ans.size() << endl;     for (int i = 0; i < ans.size(); ++i) {       if (ans[i].first ==  removeMin )         cout << ans[i].first << endl;       else         cout << ans[i].first <<     << ans[i].second << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> parent;   vector<int> Rank;   vector<int> Count;   int root(int v) {     if (parent[v] == v) return v;     return parent[v] = root(parent[v]);   }   bool DSU(int a, int b) {     a = root(a);     b = root(b);     if (a != b) {       if (Rank[b] > Rank[a]) swap(a, b);       Rank[a] += Rank[b];       Count[a] += Count[b];       parent[b] = a;       return true;     }     return false;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, m, k;     cin >> n >> m >> k;     vector<pair<long long int, pair<int, int> > > Edges(m);     parent.resize(n + 1);     for (int i = 1; i <= n; i++) parent[i] = i;     Rank.resize(n + 1, 1);     Count.resize(n + 1, 0);     for (int i = 0; i < k; i++) {       int a;       cin >> a;       Count[a] = 1;     }     for (int i = 0; i < m; i++) {       int a, b;       long long int w;       cin >> a >> b >> w;       Edges[i] = make_pair(w, make_pair(a, b));     }     sort(Edges.begin(), Edges.end());     long long int last = -1;     for (int i = 0; i < m; i++) {       int a = Edges[i].second.first;       int b = Edges[i].second.second;       long long int w = Edges[i].first;       if (a != b) {         DSU(a, b);         if (last == -1 && Count[root(a)] == k) {           last = w;         }       }     }     for (int i = 0; i < k; i++) {       cout << last <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[26];   char pal[111111];   inline bool is_pal(int k, int can) {     vector<int> odd(0);     for (int i = 0; i < n; ++i) {       if (a[i] % k) return 0;       if (a[i] % (2 * k)) odd.push_back(i);     }     if ((int)(odd).size() > 1) return 0;     if ((int)(odd).size() == 1 && !can) return 0;     int pos = 0;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < a[i] / (2 * k); ++j) {         pal[pos++] =  a  + i;       }     }     if ((int)(odd).size()) pal[pos++] =  a  + odd[0];     for (int i = n - 1; i >= 0; --i) {       for (int j = 0; j < a[i] / (2 * k); ++j) {         pal[pos++] =  a  + i;       }     }     pal[pos] = 0;     return 1;   }   inline void die(int ans, int reps, char middle) {     printf( %d n , ans);     for (int i = 0; i < reps; ++i) {       printf( %s , pal);       if (middle !=  ! ) printf( %c , middle);     }     printf(  n );     exit(0);   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     for (int ans = 111111; ans > 1; --ans) {       if (ans % 2 == 1) {         for (int let = 0; let < n; ++let) {           if (a[let] >= ans) {             a[let] -= ans;             if (is_pal(ans, 0)) {               die(ans, ans,  a  + let);             }             a[let] += ans;           }         }       } else {         for (int let = 0; let < n; ++let) {           if (is_pal(ans / 2, 0)) {             die(ans, ans / 2,  ! );           }         }       }     }     if (is_pal(1, 1)) {       die(1, 1,  ! );     }     printf( 0 n );     for (int i = 0; i < n; ++i) {       for (int j = 0; j < a[i]; ++j) {         printf( %c ,  a  + i);       }     }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     scanf( %d %d , &n, &k);     char c[200005];     scanf( %s , c);     int ok[26];     memset(ok, 0, sizeof(ok));     for (int i = 0; i < k; i++) {       char cc;       scanf(  %c , &cc);       ok[cc -  a ] = 1;     }     long long cnt = 0;     long long ans = 0;     for (int i = 0; c[i] != 0; i++) {       if (ok[c[i] -  a ])         cnt++;       else {         ans += cnt * (cnt + 1) / 2;         cnt = 0;       }     }     ans += cnt * (cnt + 1) / 2;     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   string s, t;   int l[200005], r[200005];   int dp[30][200005];   void gd() {     cout <<  No ;     exit(0);   }   bool check(int lr, int rl, int c) {     return ((lr ? dp[c][lr - 1] : 0) - (rl ? dp[c][rl - 1] : 0) > 0);   }   int main() {     ios_base::sync_with_stdio(0);     cin >> s >> t;     s =  *  + s;     int n = (int)s.size();     int m = (int)t.size();     for (int i = 1; i < n; ++i) {       l[i] = l[i - 1];       if (s[i] == t[l[i]]) ++l[i];     }     for (int i = n - 1; i; --i) {       r[i] = r[i + 1];       if (s[i] == t[m - 1 - r[i]]) ++r[i];     }     if (l[n - 1] != m || r[1] != m) gd();     for (int i = 0; i < 26; ++i)       for (int j = 0; j < m; ++j) {         char c = i +  a ;         dp[i][j] = (j ? dp[i][j - 1] : 0) + (t[j] == c);       }     for (int i = 1; i < n; ++i) {       int rg = m - r[i];       int lg = l[i];       if (rg > lg || !check(lg, rg, s[i] -  a )) gd();     }     cout <<  Yes ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M, K;   int color[200002];   vector<int> edge[200002];   int id[200002];   int ite = 1;   int siz[200002];   map<int, int> m[200002];   int ans;   void dfs(int a) {     if (id[a]) {       return;     }     id[a] = ite;     for (int i = 0; i < edge[a].size(); i++) {       dfs(edge[a][i]);     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     if (fopen( cf731c.in ,  r )) {       freopen( cf731c.in ,  r , stdin);       freopen( cf731c.out ,  w , stdout);     }     cin >> N >> M >> K;     for (int i = 0; i < N; i++) {       cin >> color[i];     }     for (int i = 0; i < M; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       edge[a].push_back(b);       edge[b].push_back(a);     }     for (int i = 0; i < N; i++) {       if (id[i] == 0) {         dfs(i);         ite++;       }     }     for (int i = 0; i < N; i++) {       siz[id[i]]++;       m[id[i]][color[i]]++;     }     for (int i = 1; i < ite; i++) {       int mx = -1;       for (auto it = m[i].begin(); it != m[i].end(); it++) {         mx = max(mx, it->second);       }       ans += (siz[i] - mx);     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class A, class B>   ostream &operator<<(ostream &out, const pair<A, B> &a) {     return out <<  (  << a.first <<  ,  << a.second <<  ) ;   }   template <class A>   ostream &operator<<(ostream &out, const vector<A> &a) {     for (const A &it : a) out << it <<    ;     return out;   }   template <class A, class B>   istream &operator>>(istream &in, pair<A, B> &a) {     return in >> a.first >> a.second;   }   template <class A>   istream &operator>>(istream &in, vector<A> &a) {     for (A &i : a) in >> i;     return in;   }   ifstream cinn( in.txt );   ofstream coutt( out.txt );   int poww(const int &a, int b, const int &m = (1000000007)) {     if (b == 0) return 1;     int x = poww(a, b / 2, m);     x = x * x % m;     if (b & 1) x = x * a % m;     return x;   }   int ceil(const int &a, const int &b) { return (a - 1) / b + 1; }   int primes[5000005];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     for (int i = 2; i < 5000005; i++) {       if (primes[i]) continue;       for (int j = i; j < 5000005; j += i) {         int in = j;         while (in % i == 0) {           in /= i;           primes[j]++;         }       }     }     for (int i = 1; i < 5000005; i++) primes[i] += primes[i - 1];     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       cout << primes[a] - primes[b] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   string s;   const int MAXN = 100005;   int tz[4 * MAXN], tx[4 * MAXN], ty[4 * MAXN];   int cntz(int v, int tl, int tr, int l, int r) {     if (l > r) return 0;     if (tl == l && r == tr) return tz[v];     int tm = (tl + tr) / 2;     return cntz(2 * v, tl, tm, l, min(tm, r)) +            cntz(2 * v + 1, tm + 1, tr, max(tm + 1, l), r);   }   int cnty(int v, int tl, int tr, int l, int r) {     if (l > r) return 0;     if (tl == l && r == tr) return ty[v];     int tm = (tl + tr) / 2;     return cnty(2 * v, tl, tm, l, min(tm, r)) +            cnty(2 * v + 1, tm + 1, tr, max(tm + 1, l), r);   }   int cntx(int v, int tl, int tr, int l, int r) {     if (l > r) return 0;     if (tl == l && r == tr) return tx[v];     int tm = (tl + tr) / 2;     return cntx(2 * v, tl, tm, l, min(tm, r)) +            cntx(2 * v + 1, tm + 1, tr, max(tm + 1, l), r);   }   void buildz(int v, int tl, int tr) {     if (tl == tr)       tz[v] = (s[tl] ==  z );     else {       int tm = (tl + tr) / 2;       buildz(2 * v, tl, tm);       buildz(2 * v + 1, tm + 1, tr);       tz[v] = tz[2 * v] + tz[2 * v + 1];     }   }   void buildy(int v, int tl, int tr) {     if (tl == tr)       ty[v] = (s[tl] ==  y );     else {       int tm = (tl + tr) / 2;       buildy(2 * v, tl, tm);       buildy(2 * v + 1, tm + 1, tr);       ty[v] = ty[2 * v] + ty[2 * v + 1];     }   }   void buildx(int v, int tl, int tr) {     if (tl == tr)       tx[v] = (s[tl] ==  x );     else {       int tm = (tl + tr) / 2;       buildx(2 * v, tl, tm);       buildx(2 * v + 1, tm + 1, tr);       tx[v] = tx[2 * v] + tx[2 * v + 1];     }   }   int main() {     cin >> s;     int n, l = s.length();     buildz(1, 0, l - 1);     buildy(1, 0, l - 1);     buildx(1, 0, l - 1);     cin >> n;     for (int i = 0, a, b; i < n; ++i) {       cin >> a >> b;       int z = cntz(1, 0, l - 1, a - 1, b - 1);       int y = cnty(1, 0, l - 1, a - 1, b - 1);       int x = cntx(1, 0, l - 1, a - 1, b - 1);       int t = min(x, min(y, z));       z -= t;       y -= t;       x -= t;       if (b - a + 1 <= 2 || (z <= 1 && x <= 1 && y <= 1))         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int m;     cin >> n >> m;     int c[m], a[n];     int i, j, k;     for (i = 0; i < n; i++) {       a[i] = 0;     }     for (i = 0; i < m; i++) {       cin >> c[i];       a[c[i] - 1]++;     }     k = a[0];     for (i = 0; i < n; i++) {       if (k > a[i]) {         k = a[i];       }     }     cout << k;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e18;   const long long mod = 1e9 + 7;   const long long N = 222;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   long long n, k;   vector<long long> adj[N];   long long dp[N][N], dp2[N][N], a[N];   void input() {     cin >> n >> k;     k++;     for (long long i = (1); i <= (n); i++) cin >> a[i];     for (long long i = (1); i <= (n - 1); i++) {       long long x, y;       cin >> x >> y;       ;       adj[x].push_back(y);       adj[y].push_back(x);     }   }   void dfs(long long cur = 1, long long prev = 0) {     for (long long i : adj[cur])       if (i != prev) dfs(i, cur);     for (long long p = (k); p >= (0); p--) {       if (p >= (k + 1) / 2) {         long long mx = -inf;         for (long long i : adj[cur])           if (i != prev) {             dp2[cur][p] += dp2[i][p - 1];             mx = max(mx, dp[i][p - 1] - dp2[i][p - 1]);           }         dp[cur][p] = dp2[cur][p] + mx;       } else {         long long mx = -inf;         if (!p) mx = a[cur];         for (long long i : adj[cur])           if (i != prev) {             dp[cur][p] += dp2[i][(k - p) - 1];             if (p) mx = max(mx, dp[i][p - 1] - dp2[i][(k - p) - 1]);           }         dp[cur][p] += mx;         dp2[cur][p] = max(dp[cur][p], dp2[cur][p + 1]);       }     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     input();     dfs();     cout << dp2[1][0];   }
#include <bits/stdc++.h>   using namespace std;   struct fenwick {     long long n, fen[100005];     void resize(int _n) {       n = _n + 1;       memset(fen, 0, sizeof fen);     }     int query(int ind) {       ind++;       int ans = 0;       while (ind >= 1) {         ans += fen[ind];         ind -= ind & -ind;       }       return ans;     }     void update(int ind, int val) {       ind++;       while (ind <= n) {         fen[ind] += val;         ind += ind & -ind;       }     }     int query(int l, int r) { return query(r) - query(l - 1); }   };   const int maxn = 100001;   int n, l, w, x, y, sz[maxn];   long long res;   bool blocked[maxn];   vector<pair<int, int> > c, v[maxn];   fenwick tree;   void dfs(int node, int pnode, int curw, int curl) {     c.push_back(make_pair(curw, curl));     for (auto &i : v[node])       if (i.first != pnode && !blocked[i.first])         dfs(i.first, node, curw + i.second, curl + 1);   }   long long solve(int node, int curw, int curl) {     long long ret = 0;     c.clear();     dfs(node, 0, curw, curl);     sort(c.begin(), c.end());     for (auto &i : c) tree.update(i.second, 1);     for (int i = 0, j = c.size() - 1; i < c.size(); i++) {       while (i <= j && c[i].first + c[j].first > w)         tree.update(c[j--].second, -1);       if (j < i) break;       tree.update(c[i].second, -1);       ret += tree.query(l - c[i].second);     }     return ret;   }   int dfsz(int node, int pnode) {     sz[node] = 1;     for (auto &i : v[node])       if (i.first != pnode && !blocked[i.first]) sz[node] += dfsz(i.first, node);     return sz[node];   }   int find(int node, int pnode, int n) {     for (auto &i : v[node])       if (i.first != pnode && !blocked[i.first] && 2 * sz[i.first] > n)         return find(i.first, node, n);     return node;   }   void decompose(int node) {     int centroid = find(node, 0, dfsz(node, 0));     blocked[centroid] = 1;     res += solve(centroid, 0, 0);     for (auto &i : v[centroid])       if (!blocked[i.first])         res -= solve(i.first, i.second, 1), decompose(i.first);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> l >> w;     tree.resize(n + 1);     for (int i = 2; i <= n && cin >> x >> y; i++) {       v[i].push_back(make_pair(x, y));       v[x].push_back(make_pair(i, y));     }     decompose(1);     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1e6 + 5;   int arr[MAX_N];   int vis[MAX_N];   void solve() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &arr[i]);       vis[i] = 0;     }     vector<int> stk;     for (int i = 1; true; i = i - arr[i]) {       if (vis[i]) {         vector<int> ans;         for (int j = stk.size() - 1; j >= 0; j--) {           ans.push_back(stk[j]);           if (stk[j] == i) break;         }         printf( %d n , (int)ans.size());         for (int u : ans) {           printf( %d  , u);         }         printf(  n );         return;       } else {         vis[i] = 1;         stk.push_back(i);       }     }   }   int main() {     int testc;     scanf( %d , &testc);     for (int i = 0; i < testc; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     long long n;     cin >> n;     set<long long> st;     for (long long i = 1; i * i <= n; i++) {       if (n % i == 0) {         long long a = n / gcd(n, i);         st.insert(((a * (a - 1)) / 2) * (n / a) + a);         long long m = (n / i);         long long b = n / gcd(n, m);         st.insert(((b * (b - 1)) / 2) * (n / b) + b);       }     }     for (auto e : st) cout << e <<    ;     return 0;   }
#include <bits/stdc++.h>   int mat[500][500];   int N, K;   int main() {     scanf( %d%d , &N, &K);     int Cnt = 1;     int sum = 0;     for (int i = 0; i < N; i++) {       for (int j = 0; j < K - 1; j++) {         mat[i][j] = Cnt++;       }     }     for (int i = 0; i < N; i++) {       for (int j = K - 1; j < N; j++) {         mat[i][j] = Cnt++;       }     }     for (int i = 0; i < N; i++) {       sum += mat[i][K - 1];     }     printf( %d n , sum);     for (int i = 0; i < N; i++) {       for (int j = 0; j < N; j++) {         printf( %d  , mat[i][j]);       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   bool visited[2][maxn];   int d[2][maxn];   string s[2];   int main() {     int n, k;     cin >> n >> k;     cin >> s[0] >> s[1];     int dx[3] = {0, 0, 1};     int dy[3] = {1, -1, k};     queue<pair<bool, int>> q;     q.push(make_pair(0, 0));     visited[0][0] = 1;     while (q.size()) {       pair<bool, int> k = q.front();       q.pop();       bool x = k.first;       int y = k.second;       for (int i = 0; i < 3; i++) {         bool xx = x ^ dx[i];         int yy = y + dy[i];         if (yy >= n) {           cout <<  YES  << endl;           exit(0);         }         if (yy >= 0 && s[xx][yy] ==  -  && !visited[xx][yy] && yy > d[x][y]) {           q.push(make_pair(xx, yy));           visited[xx][yy] = 1;           d[xx][yy] = d[x][y] + 1;         }       }     }     cout <<  NO  << endl;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   unordered_set<int> dict;   int main() {     long long a, b, x;     cin >> x >> a >> b;     if (a % x != 0) {       a += x - (a % x + x) % x;     }     if (a > b) {       cout << 0 << endl;     } else {       cout << (b - a + x) / x << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int a, b, n;     cin >> n >> a >> b;     vector<int> A(n);     for (int &x : A) cin >> x;     sort(A.begin(), A.end());     if (A[b] - A[b - 1] == 0) {       cout <<  0 n ;       return;     }     cout << A[b] - A[b - 1] <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     register int x = 0, t = 1;     register char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) t = -1, ch = getchar();     while (ch <=  9  && ch >=  0 ) x = x * 10 + ch - 48, ch = getchar();     return x * t;   }   int n, m, top, first[301000], dep[301000];   struct mona {     int nxt, en;   } s[301000 << 1];   inline void Insert(int x, int y) {     s[++top] = (mona){first[x], y}, first[x] = top;   }   inline void Dfs(int k, int fa) {     dep[k] = dep[fa] + 1;     for (register int i = first[k]; i; i = s[i].nxt) {       int en = s[i].en;       if (en == fa) continue;       Dfs(en, k);     }     return;   }   int cnt, rt[301000], Min[301000], ls[301000], rs[301000];   pair<long long, int> val[301000];   long long lz[301000], ans;   inline int New(pair<long long, int> x) {     int t = ++cnt;     val[t] = x, Min[t] = 1;     return t;   }   inline void Pushlz(int x, long long w) { val[x].first += w, lz[x] += w; }   inline void Pushdown(int x) {     if (!lz[x]) return;     if (ls[x]) Pushlz(ls[x], lz[x]);     if (rs[x]) Pushlz(rs[x], lz[x]);     lz[x] = 0;   }   inline int Merge(int u, int v) {     if (!u || !v) return u | v;     int t;     if (val[u] < val[v])       Pushdown(u), rs[u] = Merge(rs[u], v), t = u;     else       Pushdown(v), rs[v] = Merge(u, rs[v]), t = v;     if (Min[ls[t]] < Min[rs[t]]) swap(ls[t], rs[t]);     Min[t] = Min[rs[t]] + 1;     return t;   }   inline void Dfs2(int k, int fa) {     for (register int i = first[k]; i; i = s[i].nxt) {       int en = s[i].en;       if (en == fa) continue;       Dfs2(en, k), rt[k] = Merge(rt[k], rt[en]);     }     while (rt[k] && val[rt[k]].second >= dep[k])       rt[k] = Merge(ls[rt[k]], rs[rt[k]]);     if (!rt[k] && k != 1) puts( -1 ), exit(0);     ans += val[rt[k]].first, Pushlz(rt[k], -val[rt[k]].first);   }   int main() {     n = read(), m = read();     for (register int i = 1; i < n; ++i) {       int x = read(), y = read();       Insert(x, y), Insert(y, x);     }     Dfs(1, 0);     for (register int i = 1; i <= m; ++i) {       int x = read(), y = read();       long long w = read();       if (dep[x] < dep[y]) swap(x, y);       rt[x] = Merge(rt[x], New(make_pair(w, dep[y])));     }     Dfs2(1, 0), printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x;     while (cin >> n) {       x = n - 10;       if (x <= 0 || x > 11)         cout << 0 << endl;       else if (x == 10)         cout << 15 << endl;       else         cout << 4 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, u, r;   int a[35];   int b[35];   int k[35];   int p[35];   int op[35];   int tmpa[35];   int tmmmma[35];   long long dfs(int index, const int ta[]) {     if (index == u) {       long long res = 0;       for (int i = (0); i < ((n)); ++i) res += (long long)ta[i] * k[i];       return res;     }     int tta[35];     long long res = -(((long long)1) << 62);     if (index == 0 || op[index - 1] != 0) {       op[index] = 0;       for (int i = (0); i < ((n)); ++i) tta[i] = ta[i] ^ b[i];       res = max(res, dfs(index + 1, tta));     }     op[index] = 1;     for (int i = (0); i < ((n)); ++i) tta[i] = ta[p[i]] + r;     res = max(res, dfs(index + 1, tta));     if ((u - index) % 2 == 0) {       long long tmp = 0;       for (int i = (0); i < ((n)); ++i) tmp += (long long)ta[i] * k[i];       res = max(res, tmp);     }     return res;   }   int main(void) {     cin >> n >> u >> r;     for (int i = (0); i < ((n)); ++i) cin >> a[i];     for (int i = (0); i < ((n)); ++i) cin >> b[i];     for (int i = (0); i < ((n)); ++i) cin >> k[i];     for (int i = (0); i < ((n)); ++i) cin >> p[i];     for (int i = (0); i < ((n)); ++i) --p[i];     cout << dfs(0, a) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, sx, sy, x, y;     cin >> n >> sx >> sy;     vector<pair<long long int, long long int> > v;     v.push_back({sx, sy + 1});     v.push_back({sx, sy - 1});     v.push_back({sx + 1, sy});     v.push_back({sx - 1, sy});     vector<long long int> answer(4, 0);     for (long long int i = 1; i <= n; i++) {       cin >> x >> y;       long long int mnx = min(sx, x);       long long int mxx = max(sx, x);       long long int mny = min(sy, y);       long long int mxy = max(sy, y);       for (int j = 0; j < 4; j++) {         if (v[j].first >= mnx && v[j].first <= mxx && v[j].second >= mny &&             v[j].second <= mxy) {           answer[j]++;         }       }     }     long long int ans = 0;     for (int i = 0; i < 4; i++) ans = max(ans, answer[i]);     cout << ans << endl;     for (int i = 0; i < 4; i++) {       if (answer[i] == ans && v[i].first <= 1e9 && v[i].second <= 1e9 &&           v[i].first >= 0 && v[i].second >= 0) {         cout << v[i].first <<     << v[i].second << endl;         return 0;       }     }     return 0;   }