malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, ans = 0;   long long f[1000001];   int main(int argc, char **argv) {     cin >> n;     for (int i = 1; i <= n; i++) {       long long b;       cin >> b;       f[b - i + 400000] += b;       ans = max(ans, f[b - i + 400000]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1 << 18;   int a[MAXN];   long long s[MAXN << 2];   int h[MAXN << 2];   void build(int id, int l, int r) {     if (l == r) {       s[id] = a[l];       h[id] = 0;       return;     }     int mid = (l + r) >> 1;     build(id << 1, l, mid);     build(id << 1 | 1, mid + 1, r);     s[id] = s[id << 1] + s[id << 1 | 1];     h[id] = h[id << 1] + 1;   }   long long query(int id, int l, int r, int ll, int rr) {     if (ll <= l && r <= rr) return s[id];     int mid = (l + r) >> 1;     long long ret = 0;     if (ll <= mid) ret += query(id << 1, l, mid, ll, rr);     if (rr > mid) ret += query(id << 1 | 1, mid + 1, r, ll, rr);     return ret;   }   void modify(int id, int l, int r, int pos, int v) {     if (l == r) {       s[id] = v;       return;     }     int mid = (l + r) >> 1;     if (pos <= mid)       modify(id << 1, l, mid, pos, v);     else       modify(id << 1 | 1, mid + 1, r, pos, v);     s[id] = s[id << 1] + s[id << 1 | 1];   }   int S;   int v = 0;   long long query1(int id, int l, int r, int ll, int rr) {     if (ll <= l && r <= rr) {       int LLL = ((v & (S - (1 << h[id]))) ^ l),           RRR = ((v & (S - (1 << h[id]))) ^ r);       if (LLL > RRR) swap(LLL, RRR);       return query(1, 0, S - 1, LLL, RRR);     }     int mid = (l + r) >> 1;     long long ret = 0;     if (ll <= mid) ret += query1(id << 1, l, mid, ll, rr);     if (rr > mid) ret += query1(id << 1 | 1, mid + 1, r, ll, rr);     return ret;   }   int main() {     int n, q;     scanf( %d%d , &n, &q);     for (int i = 0; i < (1 << n); ++i) scanf( %d , &a[i]);     build(1, 0, (1 << n) - 1);     S = (1 << n);     for (int i = 1; i <= q; ++i) {       int tp;       scanf( %d , &tp);       if (tp == 1) {         int x, k;         scanf( %d%d , &x, &k);         x--;         x ^= v;         modify(1, 0, (1 << n) - 1, x, k);       } else if (tp == 2) {         int k;         scanf( %d , &k);         v ^= (1 << k) - 1;       } else if (tp == 3) {         int k;         scanf( %d , &k);         v ^= (1 << k);       } else {         int l, r;         scanf( %d%d , &l, &r);         l--;         r--;         printf( %lld n , query1(1, 0, (1 << n) - 1, l, r));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int z[N], t1[N], t2[N];   string s;   vector<pair<int, int> > ans;   int n;   void BuildZArray() {     int L = 0, R = 0;     for (int i = 1; i < n; i++) {       if (i > R) {         L = R = i;         while (R < n && s[R - L] == s[R]) R++;         z[i] = R - L;         R--;       } else {         int k = i - L;         if (z[k] < R - i + 1)           z[i] = z[k];         else {           L = i;           while (R < n && s[R - L] == s[R]) R++;           z[i] = R - L;           R--;         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> s;     n = s.size();     BuildZArray();     for (int i = 0; i < n; i++) {       t1[z[i]]++;     }     t1[n]++;     for (int i = N - 1; i >= 0; i--) {       t2[i] = t1[i] + t2[i + 1];     }     for (int i = 0; i < n; i++)       if (z[i] >= n - i) ans.push_back(pair<int, int>(z[i], t2[z[i]]));     ans.push_back(pair<int, int>(n, 1));     sort(ans.begin(), ans.end());     cout << ans.size() <<   n ;     for (auto it : ans) cout << it.first <<     << it.second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   inline int read() {     int s = 0, w = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) w |= (ch ==  - ), ch = getchar();     while (ch >=  0  && ch <=  9 ) s = s * 10 + ch -  0 , ch = getchar();     return w ? -s : s;   }   struct rr {     int nt, to;   } bl[100005 << 1];   int hd[100005], itot = 0;   inline void adde(int x, int y) {     bl[++itot] = (rr){hd[x], y};     hd[x] = itot;     bl[++itot] = (rr){hd[y], x};     hd[y] = itot;     return;   }   vector<int> to[100005];   int belong[100005], cnt = 0, sz[100005];   int dfn[100005], low[100005], num = 0, stk[100005], top = 0;   int vis[100005];   void tarjan(int u, int fa) {     dfn[u] = low[u] = ++num;     stk[++top] = u;     vis[u] = 1;     for (int i = hd[u], y; i; i = bl[i].nt)       if ((y = bl[i].to) != fa && vis[y] != 2) {         if (!dfn[y]) {           tarjan(y, u);           low[u] = min(low[u], low[y]);         } else           low[u] = min(low[u], dfn[y]);       }     if (dfn[u] == low[u]) {       int z;       ++cnt;       do {         z = stk[top--];         belong[z] = cnt;         sz[cnt]++;         vis[z] = 2;       } while (z != u);     }     return;   }   int n, m;   int dist[100005], sd[100005];   int f[100005][20], LOG[100005];   inline int LCA(int x, int y) {     if (sd[x] < sd[y]) swap(x, y);     for (int j = LOG[sd[x]]; j >= 0; --j)       if (f[x][j] && sd[f[x][j]] >= sd[y]) x = f[x][j];     if (x == y) return x;     for (int j = LOG[sd[x]]; j >= 0; --j)       if (f[x][j] && f[y][j] && f[x][j] != f[y][j]) x = f[x][j], y = f[y][j];     return f[x][0];   }   void dfs(int u, int fa) {     dist[u] = dist[fa] + (sz[u] != 1);     sd[u] = sd[fa] + 1;     f[u][0] = fa;     for (int j = 1; j <= LOG[sd[u]]; ++j) f[u][j] = f[f[u][j - 1]][j - 1];     for (int i = 0; i < to[u].size(); ++i)       if (to[u][i] != fa) dfs(to[u][i], u);     return;   }   int bin[100005];   int main() {     n = (read()), m = (read());     bin[0] = 1, bin[1] = 2;     for (int i = 2; i <= n; ++i) {       LOG[i] = LOG[i >> 1] + 1;       bin[i] = bin[i - 1] + bin[i - 1];       if (bin[i] >= mod) bin[i] -= mod;     }     for (int i = 1, x, y; i <= m; ++i) x = (read()), y = (read()), adde(x, y);     tarjan(1, 0);     for (int i = 1; i <= n; ++i)       for (int j = hd[i], y; j; j = bl[j].nt)         if (belong[i] != belong[y = bl[j].to]) to[belong[i]].push_back(belong[y]);     dfs(1, 0);     int q = (read()), x, y;     while (q--) {       x = belong[(read())], y = belong[(read())];       int lca = LCA(x, y);       printf( %d n , bin[dist[x] + dist[y] - dist[lca] - dist[f[lca][0]]]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   const int MAXE = 200005;   const int mod = 1e9 + 7;   struct Edge {     int v;     Edge* next;   } E[MAXE], *H[MAXN], *cur;   int color[MAXN];   long long dp[MAXN][2];   void clear() {     cur = E;     memset(H, 0, sizeof H);     memset(color, 0, sizeof color);     memset(dp, 0, sizeof dp);   }   void addedge(int u, int v) {     cur->v = v;     cur->next = H[u];     H[u] = cur++;   }   void scanf(int& x, char c = 0) {     while ((c = getchar()) <  0  || c >  9 )       ;     x = c -  0 ;     while ((c = getchar()) >=  0  && c <=  9 ) x = x * 10 + c -  0 ;   }   void dfs(int u, int f = 0) {     dp[u][color[u]] = 1;     for (Edge* e = H[u]; e; e = e->next) {       int v = e->v;       if (v == f) continue;       dfs(v, u);       dp[u][1] =           (dp[u][1] * (dp[v][0] + dp[v][1]) % mod + dp[u][0] * dp[v][1]) % mod;       dp[u][0] = dp[u][0] * (dp[v][0] + dp[v][1]) % mod;     }   }   void solve() {     int n, x;     while (~scanf( %d , &n)) {       clear();       for (int i = (1); i < (n); ++i) {         scanf(x);         addedge(x, i);         addedge(i, x);       }       for (int i = (0); i < (n); ++i) scanf(color[i]);       dfs(0);       printf( %I64d n , dp[0][1]);     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, l, x, y;     cin >> n >> l >> x >> y;     set<int> d;     for (int i = 0; i < n; ++i) {       int t;       cin >> t;       d.insert(t);     }     bool issetX = false, issetY = false;     for (set<int>::iterator i = d.begin(); i != d.end(); ++i) {       if (d.find(*i + x) != d.end()) {         issetX = true;       }       if (d.find(*i + y) != d.end()) {         issetY = true;       }     }     if (issetX && issetY) {       cout << 0;       return 0;     } else if (issetX) {       cout <<  1   << endl << y;     } else if (issetY) {       cout <<  1   << endl << x;     } else {       int point = -1;       for (set<int>::iterator i = d.begin(); i != d.end(); ++i) {         if (d.find(*i + (y - x)) != d.end()) {           if (*i - x >= 0) {             point = *i - x;             break;           } else if (*i + (y - x) + x <= l) {             point = *i + (y - x) + x;             break;           }         }         if (d.find(*i + (y + x)) != d.end()) {           point = *i + x;           break;         }       }       if (point < 0) {         cout <<  2   << endl << x <<     << y;       } else {         cout <<  1   << endl << point;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, flag;     cin >> n >> m;     int l[m], ans[n], check[n];     memset(ans, 0, sizeof(ans));     memset(check, 0, sizeof(check));     for (int i = 0; i < m; i++) cin >> l[i];     for (int i = 0; i < m - 1; i++) {       if (l[i + 1] > l[i]) {         flag = 0;         if (ans[l[i] - 1] != 0) {           if (ans[l[i] - 1] != l[i + 1] - l[i]) {             cout <<  -1 ;             return 0;           } else             flag = 1;         }         ans[l[i] - 1] = l[i + 1] - l[i];         if (check[ans[l[i] - 1] - 1] == 0)           check[ans[l[i] - 1] - 1] = 1;         else if (flag == 0) {           cout <<  -1 ;           return 0;         }       } else {         flag = 0;         if (ans[l[i] - 1] != 0) {           if (ans[l[i] - 1] != l[i + 1] - l[i] + n) {             cout <<  -1 ;             return 0;           } else             flag = 1;         }         ans[l[i] - 1] = l[i + 1] - l[i] + n;         if (check[ans[l[i] - 1] - 1] == 0)           check[ans[l[i] - 1] - 1] = 1;         else if (flag == 0) {           cout <<  -1 ;           return 0;         }       }     }     for (int i = 0; i < n; i++) {       if (ans[i])         cout << ans[i] <<    ;       else {         for (int j = 0; j < n; j++)           if (check[j] == 0) {             cout << j + 1 <<    ;             check[j] = 1;             break;           }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int x, id;   } s[100101];   bool cmp(node a, node b) { return a.x < b.x; }   int main() {     int n, i, j, x;     cin >> n;     for (i = 0; i < n; i++) {       cin >> s[i].x;       s[i].id = i + 1;     }     sort(s, s + n, cmp);     if (n % 2)       x = n / 2 + 1;     else       x = n / 2;     cout << x << endl;     for (i = 0; i < n; i += 2) cout << s[i].id <<    ;     cout << endl << n - x << endl;     for (i = 1; i < n; i += 2) cout << s[i].id <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 9, MAX2 = 3e5 + 9;   const long long MOD = 1e9 + 7;   vector<pair<int, int> > g[MAX];   pair<int, int> e[MAX2];   int h[MAX], mark[MAX2], dp[MAX], par[MAX];   bool vis[MAX];   void dfs(int v, int height) {     vis[v] = true;     h[v] = height;     for (auto x : g[v]) {       int u = x.first;       if (!vis[u]) {         mark[x.second] = true;         par[u] = v;         dfs(u, height + 1);       }     }   }   void dfs2(int v) {     dp[v] = h[v];     bool f = false;     if (v == 2) f = true;     for (auto x : g[v]) {       int u = x.first;       if (mark[x.second]) {         if (par[u] == v) {           dfs2(u);           dp[v] = min(dp[v], dp[u]);         }         continue;       }       dp[v] = min(dp[v], h[u]);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     memset(par, -1, sizeof(par));     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int v, u;       cin >> v >> u;       v--, u--;       g[v].push_back({u, i});       g[u].push_back({v, i});       e[i] = {v, u};     }     memset(vis, 0, sizeof(vis));     dfs(0, 0);     dfs2(0);     for (int i = 0; i < m; i++) {       if (!mark[i]) continue;       int v = e[i].first, u = e[i].second;       if (v != par[u]) swap(v, u);       if (dp[u] > h[v]) return cout <<  0 n , 0;     }     for (int i = 0; i < m; i++) {       int v = e[i].first, u = e[i].second;       if (mark[i]) {         if (v != par[u]) swap(v, u);       } else {         if (h[v] < h[u]) swap(v, u);       }       cout << v + 1 <<     << u + 1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[500], c, i, n, big;   int main() {     while (~scanf(  %d %d , &n, &c)) {       for (i = 0; i < n; i++) {         scanf(  %d , &a[i]);       }       big = 0;       for (i = 0; i < n - 1; i++) {         if (a[i] - a[i + 1] - c > big) big = a[i] - a[i + 1] - c;       }       printf( %d n , big);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dist[2 * 100000 + 2 + 5], N, K;   vector<int> G[2 * 100000 + 2 + 5];   void addedge(const string &wall, const string &wall2, int i, int offs) {     int here = i + offs, there = i + N - offs;     if (wall[i] ==  X ) return;     if (i != 0 && wall[i - 1] !=  X ) G[here].push_back(here - 1);     if (i == N - 1 || wall[i + 1] !=  X ) G[here].push_back(here + 1);     if (i + K >= N) {       G[here].push_back(2 * N);     } else if (wall2[i + K] !=  X ) {       G[here].push_back(there + K);     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string L, R;     cin >> N >> K >> L >> R;     for (int i = 0; i < N; i++) {       addedge(L, R, i, 0);       addedge(R, L, i, N);     }     memset(dist, -1, sizeof(dist));     queue<int> q;     dist[0] = 0;     q.push(0);     while (!q.empty()) {       int fr = q.front(), d = dist[fr];       q.pop();       for (int to : G[fr]) {         if (dist[to] == -1 && (to % N > d || to >= 2 * N)) {           dist[to] = d + 1;           q.push(to);         }       }     }     if (dist[2 * N] != -1 || dist[2 * N + 1] != -1)       cout <<  YES n ;     else       cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       if (b > a)         cout << b - a << endl;       else {         if (a % b) {           cout << a / b * b + b - a << endl;         } else           cout << 0 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e5 + 5;   const int INF = (int)1e9 + 9;   const int MOD = (int)1e9 + 7;   void go(int x) {     cout << x;     exit(0);   }   vector<int> g[N];   set<int> st[N];   int c[N];   bool used[N];   int main() {     int n, m, cnt = -1, ans = -1;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       scanf( %d , &c[i]);       used[c[i]] = 1;     }     for (int i = 1; i <= m; i++) {       int u, v;       scanf( %d%d , &u, &v);       g[u].push_back(v);       g[v].push_back(u);       used[c[u]] = 1;       used[c[v]] = 1;       if (c[u] == c[v]) {         continue;       }       st[c[u]].insert(c[v]);       st[c[v]].insert(c[u]);     }     for (int i = 1; i <= 1e5; i++) {       if (used[i] && (int)st[i].size() > cnt) {         cnt = (int)st[i].size();         ans = i;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int h[100005], ans[100005];   int l[100005], r[100005], w[100005];   vector<int> mid2[100005];   int lo2[100005], hi2[100005];   vector<int> cur[100005];   struct st {     int le, ri, len, all;   };   st seg[400005];   st update_seg(st a, st b) {     st res;     res.len = a.len + b.len;     res.all = max(max(a.all, b.all), a.ri + b.le);     if (a.len == a.le)       res.le = a.len + b.le;     else       res.le = a.le;     if (b.len == b.le)       res.ri = a.ri + b.len;     else       res.ri = b.ri;     return res;   }   void update(int n, int s, int e, int idx, int v) {     if (s == e) {       seg[n].le = max(0, v);       seg[n].ri = max(0, v);       seg[n].all = max(0, v);       seg[n].len = 1;     } else {       int mid = (s + e) / 2;       if (idx <= mid)         update(n + n, s, mid, idx, v);       else         update(n + n + 1, mid + 1, e, idx, v);       seg[n] = update_seg(seg[n + n], seg[n + n + 1]);     }   }   st query(int n, int s, int e, int l, int r) {     if (s > r || l > e) {       st res;       res.le = res.ri = res.len = res.all = 0;       return res;     }     if (l <= s && e <= r) return seg[n];     int mid = (s + e) / 2;     st q1 = query(n + n, s, mid, l, r);     st q2 = query(n + n + 1, mid + 1, e, l, r);     return update_seg(q1, q2);   }   int main() {     int n, q;     scanf( %d , &n);     vector<int> v;     for (int i = 1; i <= n; i++) {       scanf( %d , &h[i]);       v.push_back(h[i]);     }     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     for (int i = 1; i <= n; i++) {       int idx = lower_bound(v.begin(), v.end(), h[i]) - v.begin();       cur[idx].push_back(i);     }     scanf( %d , &q);     for (int i = 1; i <= q; i++) {       scanf( %d%d%d , &l[i], &r[i], &w[i]);       lo2[i] = 0, hi2[i] = v.size() - 1;     }     while (1) {       for (int i = 0; i < v.size(); i++) {         mid2[i].clear();         int h = v[i];         int idx = lower_bound(v.begin(), v.end(), h) - v.begin();         for (int j = 0; j < cur[idx].size(); j++) {           int k = cur[idx][j];           update(1, 1, n, k, 0);         }       }       bool ok = 1;       for (int i = 1; i <= q; i++) {         if (lo2[i] <= hi2[i]) {           int mid = (lo2[i] + hi2[i]) / 2;           mid2[mid].push_back(i);           ok = 0;         }       }       if (ok) break;       for (int i = v.size() - 1; i >= 0; i--) {         int h = v[i];         int idx = lower_bound(v.begin(), v.end(), h) - v.begin();         for (int j = 0; j < cur[idx].size(); j++) {           int k = cur[idx][j];           update(1, 1, n, k, 1);         }         for (int j = 0; j < mid2[i].size(); j++) {           int idx = mid2[i][j];           st q = query(1, 1, n, l[idx], r[idx]);           if (q.all >= w[idx]) {             lo2[idx] = i + 1;             ans[idx] = i;           } else {             hi2[idx] = i - 1;           }         }       }     }     for (int i = 1; i <= q; i++) printf( %d n , v[ans[i]]);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 10;   bool lucky(int x) {     while (x) {       if (x % 10 != 4 && x % 10 != 7) {         return false;       }       x /= 10;     }     return true;   }   int id[maxn], a[maxn], pos[maxn], n;   bool f[maxn];   bool check() {     for (int i = 0; i + 1 < n; ++i) {       if (a[i + 1] < a[i]) {         return false;       }     }     return true;   }   bool comp(int x, int y) { return a[x] < a[y]; }   int main() {     while (scanf( %d , &n) != EOF) {       int c = -1;       for (int i = 0; i < n; ++i) {         scanf( %d , a + i);         if (lucky(a[i])) c = i;         id[i] = i;       }       if (c == -1) {         printf( %d n , check() ? 0 : -1);         continue;       }       sort(id, id + n, comp);       for (int i = 0; i < n; ++i) {         pos[id[i]] = i;         f[i] = false;       }       int posc = c;       vector<pair<int, int> > ans;       while (posc != pos[c]) {         ans.push_back(pair<int, int>(posc, id[posc]));         f[posc] = true;         posc = id[posc];       }       f[posc] = true;       for (int i = 0; i < n; ++i) {         if (pos[i] != i && !f[i]) {           ans.push_back(pair<int, int>(posc, i));           int tmp = posc;           posc = i;           while (pos[i] != posc) {             ans.push_back(pair<int, int>(posc, id[posc]));             f[posc] = true;             posc = id[posc];           }           f[posc] = true;           ans.push_back(pair<int, int>(posc, tmp));           posc = tmp;         }       }       printf( %d n , ((int)((ans).size())));       for (int i = 0; i < ((int)((ans).size())); ++i) {         printf( %d %d n , ans[i].first + 1, ans[i].second + 1);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, string> mp;   map<string, int> stn;   void Print(string cur) {     string res =  / ;     while (cur !=  / ) {       string tmp = cur;       while (int(tmp.size()) &&              ( 0  <= tmp[tmp.size() - 1] && tmp[tmp.size() - 1] <=  9 ))         tmp.erase(tmp.begin() + tmp.size() - 1);       res =  /  + tmp + res;       cur = mp[cur];     }     cout << res << endl;   }   int main() {     int n;     string s, cur =  / ;     cin >> n;     for (int cn = 0; cn < int(n); cn++) {       cin >> s;       if (s ==  pwd ) {         Print(cur);       } else {         cin >> s;         int ssize = s.size();         string acc =   ;         int st = 0;         if (s[0] ==  . ) {           cur = mp[cur];           st = 3;         }         if (s[0] ==  / ) {           cur =  / ;           st = 1;         }         acc =   ;         for (int i = st; i < ssize; i++) {           if (s[i] ==  / ) {             if (acc ==  .. ) {               cur = mp[cur];             } else {               stn[acc]++;               stringstream ss;               string nw;               ss << stn[acc];               ss >> nw;               acc += nw;               mp[acc] = cur;               cur = acc;             }             acc =   ;           } else {             acc += s[i];           }         }         if (acc.size()) {           if (acc ==  .. ) {             cur = mp[cur];           } else {             stn[acc]++;             stringstream ss;             string nw;             ss << stn[acc];             ss >> nw;             acc += nw;             mp[acc] = cur;             cur = acc;           }         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   struct str {     int x1;     int y1;     int x2;     int y2;   };   bool compare(str &a, str &b) {     if (a.x1 < b.x1)       return true;     else if (a.x1 == b.x1) {       if (a.x2 < b.x2)         return true;       else if (a.x2 == b.x2) {         if (a.y1 < b.y1)           return true;         else if (a.y1 <= b.y1) {           return (a.y2 < b.y2);         }       }     }     return false;   }   int main() {     int n;     cin >> n;     vector<str> v(n);     for (int i = 0; i < n; i++) {       cin >> v[i].x1 >> v[i].y1 >> v[i].x2 >> v[i].y2;     }     sort(v.begin(), v.end(), compare);     int x11 = v[0].x1;     int y11 = v[0].y1;     int x22 = v[0].x2;     int y22 = v[0].y2;     int flag = 0, ind = 0, counter = 1;     for (int i = 1; i < n; i++) {       int x1 = max(x11, v[i].x1);       int x2 = min(x22, v[i].x2);       int y1 = max(y11, v[i].y1);       int y2 = min(y22, v[i].y2);       int x1r = x2 - x1;       int y1r = y2 - y1;       if ((x1r < 0 || y1r < 0) && !flag) {         ind = i;       } else {         x11 = x1, y11 = y1, x22 = x2, y22 = y2;         counter++;       }     }     if (counter == n - 1)       cout << x11 <<     << y11 << endl;     else {       x11 = v[ind].x1, y11 = v[ind].y1, x22 = v[ind].x2, y22 = v[ind].y2;       for (int i = 1; i < n; i++) {         int x1 = max(x11, v[i].x1);         int x2 = min(x22, v[i].x2);         int y1 = max(y11, v[i].y1);         int y2 = min(y22, v[i].y2);         int x1r = x2 - x1;         int y1r = y2 - y1;         if ((x1r < 0 || y1r < 0) && !flag) {           ind = i;         } else {           x11 = x1, y11 = y1, x22 = x2, y22 = y2;           counter++;         }       }       cout << x11 <<     << y11 << endl;     }   }