malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int n, etime, cnt[2], f[2];   int main() {     int t;     scanf( %d , &t);     while (t--) {       scanf( %d%d%d%d , &n, &etime, f, f + 1);       vector<int> v = {etime};       vector<pair<int, bool> > p(n);       cnt[0] = cnt[1] = 0;       for (int i = 0; i < n; i++) {         scanf( %d , &p[i].second);         cnt[p[i].second]++;       }       for (int i = 0; i < n; i++) {         scanf( %d , &p[i].first);         v.push_back(p[i].first - 1);       }       sort(p.begin(), p.end());       sort(v.begin(), v.end());       v.resize(unique(v.begin(), v.end()) - v.begin());       int mx = 0, must_cnt = 0, i = 0;       long long must = 0;       for (int x : v) {         while (i < p.size() && p[i].first <= x) {           cnt[p[i].second]--;           must_cnt++;           must += f[p[i].second];           i++;         }         if (x >= must) {           int max_points = must_cnt, rem = x - must;           for (int j = 0; j < 2; j++) {             int take = min(cnt[j], rem / f[j]);             rem -= take * f[j];             max_points += take;           }           mx = max(mx, max_points);         }       }       printf( %d n , mx);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n = 0;     long long k = 0;     long long wynik = 0;     long long wynik2 = 0;     long long wynik3 = 0;     cin >> n >> k;     if (k == 1) {       cout <<  1 ;       return 0;     }     if (k == 2) {       wynik = n * (n - 1) / 2 + 1;       cout << wynik;       return 0;     }     if (k == 3) {       wynik = n * (n - 1) / 2;       wynik2 = n * (n - 1) * (n - 2) / 3 + 1;       cout << wynik2 + wynik;       return 0;     }     if (k == 4) {       wynik = n * (n - 1) / 2;       wynik2 = n * (n - 1) * (n - 2) / 3 + 1;       wynik3 = (n * (n - 1) * (n - 2) * (n - 3) / 24) * 9;       cout << wynik + wynik2 + wynik3;     }   }
#include <bits/stdc++.h>   using namespace std;   long long MOD_EXPO(long long b, long long p, long long m) {     if (p == 0) return 1;     long long ret = MOD_EXPO(b, p / 2, m) % m;     ret = (ret * ret) % m;     return ((p & 1) ? (ret * b) % m : ret % m);   }   long long POWER(long long N, long long K) {     long long i, ans = 1;     for (i = 1; i <= K; i++) ans *= N;     return ans;   }   int SET(int N, int pos) { return (N | (1 << pos)); }   int RESET(int N, int pos) { return (N & !(1 << pos)); }   bool CHECK(int N, int pos) { return (N & (1 << pos)); }   int dx4[] = {1, -1, 0, 0};   int dy4[] = {0, 0, 1, -1};   int dx6[] = {0, 0, 1, -1, 0, 0};   int dy6[] = {1, -1, 0, 0, 0, 0};   int dz6[] = {0, 0, 0, 0, 1, -1};   int dx8[] = {1, -1, 0, 0, -1, 1, -1, 1};   int dy8[] = {0, 0, 1, -1, 1, 1, -1, -1};   int dkx8[] = {-1, 1, -1, 1, -2, -2, 2, 2};   int dky8[] = {2, 2, -2, -2, 1, -1, 1, -1};   int tc = 1;   const double eps = 1e-9;   const double pi = acos(-1.0);   const long long int mx = 1e3;   const long long int mod = 1e9 + 7;   int dp[5][mx + 5];   int n, arr[mx + 5];   string str;   int rec(int i, int prev) {     if (i > n) return 0;     int &ret = dp[prev][i];     if (ret != -1) return ret;     ret = INT_MAX;     if (prev != 0) ret = min(ret, rec(i + 1, 0) + (arr[i] != 0));     if (prev != 1) ret = min(ret, rec(i + 1, 1) + (arr[i] != 1));     return ret;   }   int main() {     int i;     while (cin >> n >> str) {       for (i = 1; i <= n; i++) arr[i] = (str[i - 1] -  0 );       memset(dp, -1, sizeof(dp));       cout << rec(1, 2) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MaxN = 1005;   char a[MaxN];   int b[MaxN];   bool prime(int x) {     for (int i = 2; i < x / 2; i++) {       if (x % 2 == 0) {         return false;       }     }     return true;   }   int main() {     string s;     int i, n, Max, j;     char v;     Max = 0;     for (i = 0; i < MaxN; i++) {       a[i] =    ;       b[i] = 0;     }     cin >> s;     for (i = 0; i < s.length(); i++) {       b[s[i]]++;       if (b[s[i]] > Max) {         Max = b[s[i]];         v = s[i];       }     }     for (i = 2; i <= s.length(); i++) {       if (prime(i)) {         if (i == 2) {           int ind = 1;           while (ind * i <= s.length()) {             if (a[ind * i] ==    ) {               a[ind * i] = (char)v;               b[v]--;               if (b[v] < 0) {                 cout <<  NO  << endl;                 return 0;               }             }             ind++;           }         } else {           if (i * 2 <= s.length()) {             int ind = 1;             while (ind * i <= s.length()) {               if (a[ind * i] ==    ) {                 a[ind * i] = (char)v;                 b[v]--;                 if (b[v] < 0) {                   cout <<  NO  << endl;                   return 0;                 }               }               ind++;             }           }         }       }     }     cout <<  YES  << endl;     for (i = 1; i <= s.length(); i++) {       if (a[i] ==    ) {         for (j = 0; j < MaxN; j++) {           if (b[j]) {             a[i] = (char)j;             b[j]--;             break;           }         }       }       cout << a[i];     }     cin.get();     cin.get();   }
#include <bits/stdc++.h>   using namespace std;   int t, i;   int c[32650];   void ciu();   unsigned long long int p, q;   unsigned long long int minim = 0xffffffffffffffff;   vector<unsigned long long int> v;   int main() {     cin >> t;     ciu();     while (t--) {       minim = 0xffffffffffffffff;       cin >> p >> q;       if (p % q != 0)         cout << p <<   n ;       else {         for (i = 0; i < v.size() && v[i] * v[i] <= q; i++)           if (q % v[i] == 0) {             unsigned long long int exp = 0, rez = 1;             while (q % v[i] == 0) {               q /= v[i];               exp++;               rez *= v[i];             }             if (rez != 1) {               unsigned long long int expx = 0, rezx = 1;               unsigned long long int cp = p;               cp /= rez;               while (cp % v[i] == 0) {                 cp /= v[i];                 expx++;                 rezx *= v[i];               }               rezx *= v[i];               if (rezx < minim) minim = rezx;             }           }         if (q != 1) {           unsigned long long int expq = 0, rezq = 1;           unsigned long long int cp = p;           cp /= q;           while (cp % q == 0) {             cp /= q;             expq++;             rezq *= q;           }           rezq *= q;           if (rezq < minim) minim = rezq;         }         cout << p / minim <<   n ;       }     }     return 0;   }   void ciu() {     int i, j;     for (i = 2; i * i < 32650; i++)       if (!c[i])         for (j = i * i; j < 32650; j += i) c[j] = 1;     for (i = 2; i < 32650; i++)       if (!c[i]) v.push_back(i);   }
#include <bits/stdc++.h>   using namespace std;   bool sortbysec(const pair<long long, long long> &a,                  const pair<long long, long long> &b) {     return (a.second < b.second);   }   inline long long mx(long long a, long long b) {     if (a > b)       return a;     else       return b;   }   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long solve(long long x, long long n) {     long long r;     if (x <= n)       r = (x - 1) / 2;     else       r = (n - (x - n) + 1) / 2;     if (r > 0)       return r;     else       return 0;   }   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     long long i;     for (i = 9; i <= n + n - 1; i = i * 10 + 9)       ;     long long k = i / 10;     long long ans = 0;     for (long long i = 0; i <= 9; i++) {       if (i * (k + 1) + k <= n + n - 1)         ans += solve(i * (k + 1) + k, n);       else         break;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m;     cin >> n >> m;     long long a = n, b = m;     while (1) {       if (a <= 0 || b <= 0) break;       if (a >= 2 * b) {         a %= 2 * b;         continue;       }       if (b >= 2 * a) {         b %= 2 * a;         continue;       }       break;     }     cout << a <<     << b << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int l, r, k;     cin >> l >> r >> k;     if (k == 1 || l == r || (r - l == 1 && l % 2 && (l ^ r) >= l)) {       cout << l <<   n1 n  << l << endl;       return 0;     }     long long int num = 1, ind;     for (int i = 0;; i++) {       if (num > l) {         ind = i;         break;       }       num *= 2;     }     if (num + num / 2 <= r && k >= 3) {       cout <<  0 n3 n             << num - 1 <<     << num + num / 2 <<     << num + num / 2 - 1 << endl;       return 0;     }     if (r - l == 1) {       cout << (l ^ (l + 1)) <<   n2 n  << l <<     << l + 1 << endl;       return 0;     }     if (l % 2) l++;     if (l + 3 <= r && k >= 4) {       cout <<  0 n4 n             << l <<     << l + 1 <<     << l + 2 <<     << l + 3 << endl;     } else {       cout <<  1 n2 n  << l <<     << l + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   vector<int> v;   int main(int argc, char const *argv[]) {     cin >> s;     int n = s.size();     sort(s.begin(), s.end());     for (int i = 0; i < n; i++) {       if (s[i] >  0 ) {         swap(s[0], s[i]);         break;       }     }     string q;     cin >> q;     for (int i = 0; i < n; i++) {       if (q.size() != s.size() or q[i] != s[i]) {         cout <<  WRONG_ANSWER  << endl;         return 0;       }     }     cout <<  OK  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using uint = unsigned int;   using ll = long long;   using ull = unsigned long long;   using pii = pair<int, int>;   template <typename T1, typename T2>   ostream &operator<<(ostream &out, const pair<T1, T2> &item) {     out <<  (  << item.first <<  ,   << item.second <<  ) ;     return out;   }   template <typename T>   ostream &operator<<(ostream &out, const vector<T> &v) {     for (const auto &item : v) out << item <<    ;     return out;   }   int n, lpd[5100000];   int last[5100000][8];   int st[15][2 * 200010];   void update(int p, int nr, int pos) {     if (st[nr][p += n] >= pos) return;     for (st[nr][p] = pos; p > 1; p >>= 1)       st[nr][p >> 1] = max(st[nr][p], st[nr][p ^ 1]);   }   int query(int nr, int l, int r) {     int res;     for (res = -1, l += n, r += n; l < r; l >>= 1, r >>= 1) {       if (l & 1) res = max(res, st[nr][l++]);       if (r & 1) res = max(res, st[nr][--r]);     }     return res;   }   void process(int a, int i) {     int p, e;     vector<int> d;     while (a > 1) {       for (e = 0, p = lpd[a]; a % p == 0; ++e) a /= p;       if (e & 1) d.push_back(p);     }     int n = d.size();     for (int cfg = 0; cfg < (1 << n); ++cfg) {       int j, val, s;       for (s = 0, val = 1, j = 0; j < n; ++j)         if (cfg & (1 << j)) val *= d[j], ++s;       for (int nr = 0; nr <= 7; ++nr) update(i, n - s + nr, last[val][nr]);       last[val][n - s] = i;     }   }   int main() {     ios_base::sync_with_stdio(false);     int i, q, a, l, r, ans;     for (i = 1; i < 5100000; ++i) lpd[i] = i;     for (i = 2; i < 5100000; ++i) {       if (lpd[i] != i) continue;       for (ll j = 1LL * i * i; j < 5100000; j += i) lpd[j] = min(lpd[j], i);     }     cin >> n >> q;     memset(st, -1, sizeof st);     memset(last, -1, sizeof last);     for (i = 0; i < n; ++i) {       cin >> a;       process(a, i);     }     while (q--) {       cin >> l >> r;       for (ans = 0; ans <= 14; ++ans)         if (query(ans, l - 1, r) >= l - 1) {           cout << ans <<   n ;           break;         }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef bool mat[55][55][35];   mat adja, adjb;   char a[55], b[55], x[55], y[55], z[55];   int dp[55][55], k;   inline void upd(int &u, int v) { u = min(u, v); }   inline void work(char *str, int n, mat adj) {     memset(adj, false, 55 * 55 * 35);     for (int i = 0; i < n; i++) adj[i][i][str[i] -  a ] = true;     for (int len = 1; len < n; len++) {       for (int l = 0; l + len < n; l++) {         int r = l + len;         for (int p = l; p < r; p++) {           for (int i = 0; i < k; i++)             adj[l][r][x[i] -  a ] |=                 adj[l][p][y[i] -  a ] & adj[p + 1][r][z[i] -  a ];         }       }     }   }   int main() {     scanf( %s%s%d , a, b, &k);     int n = strlen(a), m = strlen(b);     for (int i = 0; i < k; i++) scanf( %*c%c%*c%*c%c%c , x + i, y + i, z + i);     work(a, n, adja);     work(b, m, adjb);     memset(dp, 0x3f, sizeof(dp));     dp[0][0] = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         for (int t = 0; t < 26; t++) {           for (int u = i; u < n; u++) {             for (int v = j; v < m; v++) {               if (adja[i][u][t] && adjb[j][v][t])                 upd(dp[u + 1][v + 1], dp[i][j] + 1);             }           }         }       }     }     printf( %d n , dp[n][m] == 0x3f3f3f3f ? -1 : dp[n][m]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int P1, P2, P3, T1, T2;   int interval(int r, int l) {     int t = l - r;     int sum = 0;     if (t > T1) {       sum = T1 * P1;       t = t - T1;       if (t > T2) {         sum = T2 * P2 + sum;         t = t - T2;         sum = sum + t * P3;       } else {         sum = sum + t * P2;       }     } else       sum = P1 * t;     return sum;   }   int main() {     int n;     cin >> n >> P1 >> P2 >> P3 >> T1 >> T2;     int left[n], right[n];     for (int i = 0; i < n; i++) {       cin >> left[i] >> right[i];     }     int sum = 0;     for (int i = 0;; i++) {       sum = sum + P1 * (right[i] - left[i]);       if (i == n - 1)         break;       else {         sum = sum + interval(right[i], left[i + 1]);       }     }     cout << sum;   }
#include<bits/stdc++.h>   #define int long long   using namespace std;   const int mod=1e9+7;   const int N=3e5+100;   int fa[N];   //并查集,表示i的祖父fa[i]   int begi;   //记录可以随意放的点的位置(只有一个)   int n,m;   int a[N],b[N],c[N],in[N],ans[N];   //a[i]和b[i]表示i必须在a[i]的左边，b[i]的右边   //c[i]表示在缩成一个点的一段中的开头(b[i]的限制中能无限制的放位置)   //in[i]表示入度,ans[i]表示答案   vector<int>g[N],h[N];   //h[i]存储i必须在h[i][1..n]左边   //g[i]表示缩点之后i必须在g[i][1..n]左边   bool vis[N];   //判断序列是否合法   int find(int x)//并查集搜爸爸   {    if(fa[x]==x)return x;    return fa[x]=find(fa[x]);   }   signed main()   {    scanf( %lld%lld ,&n,&m);    for(int i=1;i<=n;i++)    fa[i]=i;     for(int i=1;i<=n;i++)     {     int x,y;     scanf( %lld ,&x);     if(x==0)begi=i;//储存无限制放的点的位置       else h[x].push_back(i);//记录顺序    }    while(m--)//判能否组成序列    {     int x,y;     scanf( %lld%lld ,&x,&y);   //  cout<<x<<   <<y<<endl;      a[x]=y;     b[y]=x;     x=find(x),y=find(y);    // cout<<x<<   <<y<<endl;     if(x==y)//如果成环     {      puts( 0 );      return 0;     }     fa[x]=y;//合并     //无义，相当于把两个集合合并，用来判环后就没用了     //如果一个集合内的元素互相指向，就矛盾了    }     for(int i=1;i<=n;i++)    {     if(b[i]==0)c[find(i)]=i;     //缩点，也就是把一段互相关联的区间缩成一个点去做     //c[find(i)]也就是这一段区间的开头     //也就是说这一个开头不受这一段区间内的点的限制     //反而这个点可以限制这个区间内的其他点     for(int j=0;j<h[i].size();j++)     {      int x=h[i][j];      if(find(i)!=find(x))         {          g[find(i)].push_back(find(x));       //因为把一段缩成一个点       //所以需要把这一段区间内的点的限制关系都转移到这一个点上          in[find(x)]++;       //这一个点的入度(做拓扑排序)         }     }    }    queue<int>q;    //拓扑排序专属队列    q.push(find(begi));    //从无限制的点开始    int ct=0;    while(!q.empty())    {     int x=q.front();     q.pop();     int t=c[x];     //找到缩点     while(t)//把这缩点里面的一个区间记录到答案内     {      ans[++ct]=t;      t=a[t];     }     for(int i=0;i<g[x].size();i++)//拓扑排序pd操作     {      int y=g[x][i];      in[y]--;      if(in[y]==0)q.push(y);      }     }    if(ct!=n)//如果答案数不等于n,就相当于不合法    {     puts( 0 );     return 0;    }    vis[begi]=1;    //判断序列前后关系是否合法    //因为begi没有限制，所以第一个判    for(int i=1;i<=n;i++)    //按答案顺序说    {     if(vis[ans[i]]==0)//如果按照限制关系还没被判断(就相当于i要在j的左边，可j先比i出现了)               return puts( 0 ),0;      for(int j=0;j<h[ans[i]].size();j++)//类似拓扑，把能在接下来队列里的点判为1          vis[h[ans[i]][j]]=1;    }    for(int i=1;i<=n;i++)//输出    {     printf( %lld  ,ans[i]);    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     t = 1;     while (t--) {       long long int n;       cin >> n;       long long int arr[n + 1];       long long int ans[n + 1];       unordered_map<long long int, long long int> mp;       arr[0] = 0;       for (__typeof(n + 1) i = (1) - ((1) > (n + 1));            i != (n + 1) - ((1) > (n + 1)); i += 1 - 2 * ((1) > (n + 1))) {         cin >> arr[i];         mp[arr[i]] = 1;       }       long long int p = 0;       for (__typeof(n + 1) i = (1) - ((1) > (n + 1));            i != (n + 1) - ((1) > (n + 1)); i += 1 - 2 * ((1) > (n + 1))) {         if (arr[i] != arr[i - 1]) {           ans[i] = arr[i - 1];           mp[arr[i - 1]] = 1;           continue;         }         while (mp[p]) {           p++;         }         ans[i] = p;         mp[p] = 1;       }       for (__typeof(n + 1) i = (1) - ((1) > (n + 1));            i != (n + 1) - ((1) > (n + 1)); i += 1 - 2 * ((1) > (n + 1)))         cout << ans[i] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long pw(long long base, long long e) {     return e ? pw(base * base, e / 2) * (e % 2 ? base : 1) : 1;   }   const int maxn = 1e6 + 10, mod = 1e9 + 7, maxlg = 21, lim = 1e6;   const long long INF = 1e9;   long long fen[maxn];   vector<int> r[maxn];   int n;   int ans[maxn];   pair<int, int> a[maxn];   vector<pair<int, int> > query[maxn];   void update(int ind) {     for (; ind < maxn; ind += ind & -ind) {       fen[ind]++;     }   }   int get(int ind) {     long long res = 0;     for (; ind; ind -= ind & -ind) {       res += fen[ind];     }     return res;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int q, cnt, m;     cin >> n >> q;     for (int i = 0; i < n; i++) {       cin >> a[i].first >> a[i].second;       r[a[i].second].push_back(a[i].first);     }     for (int j = 0; j < q; j++) {       cin >> m;       int prev, cur;       prev = 0;       while (m--) {         cin >> cur;         if (cur - prev > 1) {           query[cur - 1].push_back({prev + 1, j});         }         prev = cur;       }       if (lim > prev) {         query[lim].push_back({prev + 1, j});       }     }     for (int i = 1; i <= lim; i++) {       if (r[i].size()) {         for (auto l : r[i]) {           update(l);         }       }       if (query[i].size()) {         int val = get(i);         for (auto d : query[i]) {           ans[d.second] += val - get(d.first - 1);         }       }     }     for (int i = 0; i < q; i++) {       cout << n - ans[i] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int k, d, sk, t;   void sp(int t) {     for (int j = 0; j < k; j++) {       d = k / 2 + j % 2;       sk = j % 2;       if (t % 2 == 0) {         while (d > sk) {           if (d % 2 == 0) {             printf( bb );           } else {             printf( ww );           }           d--;         }       } else {         while (d > sk) {           if (d % 2 == 0) {             printf( ww );           } else {             printf( bb );           }           d--;         }       }       printf(  n );     }     printf(  n );   }   int main() {     scanf( %d , &k);     if (k % 2 == 1) {       printf( %d n , -1);     } else {       for (int i = 0; i < k / 2; i++) {         t = k / 2 + i % 2;         sp(t);         sp(t);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     long long sumx = 0;     long long sumy = 0;     for (long long i = 0; i < n; i++) {       long long a, b;       cin >> a >> b;       sumx += a;       sumy += b;     }     for (long long i = 0; i < n; i++) {       long long a, b;       cin >> a >> b;       sumx += a;       sumy += b;     }     cout << sumx / n <<     << sumy / n <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long arr[n + 5], mx = 0, mn = INT_MIN;       for (int i = 0; i < n; i++) cin >> arr[i];       if (arr[n - 1] > 0)         arr[n] = -1;       else         arr[n] = 1;       bool p = false, o = false;       long long sum = 0;       for (int i = 0; i <= n; i++) {         if (arr[i] > 0) {           if (o) {             sum += mn;             mn = INT_MIN;           }           p = true;           o = false;           mx = max(mx, arr[i]);         } else {           if (p) {             sum += mx;             mx = 0;           }           o = true;           p = false;           mn = max(mn, arr[i]);         }       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 4e5;   vector<long long> coords;   vector<pair<pair<long long, bool>, pair<long long, long long> > > sweep;   map<long long, long long> ind;   struct nodo {     int may, pos;   };   struct segTree {     int n, h, d[N];     nodo t[N << 1];     void init() {       h = sizeof(int) * 8 - __builtin_clz(n);       for (long long i = 0; i < n; i++) t[i + n].pos = i;     }     void apply(int p, int v) {       t[p].may = t[p].may + v;       if (p < n) d[p] += v;     }     void push(int p) {       for (int s = h; s > 0; s--) {         int i = p >> s;         if (d[i] != 0) {           apply(i << 1, d[i]);           apply(i << 1 | 1, d[i]);           d[i] = 0;         }       }     }     void build(int p) {       while (p > 1) {         p >>= 1;         if (t[p << 1].may > t[p << 1 | 1].may) {           t[p].pos = t[p << 1].pos;           t[p].may = t[p << 1].may + d[p];         } else {           t[p].may = t[p << 1 | 1].may + d[p];           t[p].pos = t[p << 1 | 1].pos;         }       }     }     void upd(int l, int r, int v) {       l += n, r += n;       int l0 = l, r0 = r;       push(l);       push(r - 1);       for (; l < r; l >>= 1, r >>= 1) {         if (l & 1) apply(l++, v);         if (r & 1) apply(--r, v);       }       build(l0);       build(r0 - 1);     }     pair<long long, long long> que() {       int l = 0, r = n;       nodo ans;       ans.may = -1;       l += n, r += n;       push(l);       push(r - 1);       for (; l < r; l >>= 1, r >>= 1) {         if (l & 1) {           if (t[l].may > ans.may) {             ans = t[l];           }           l++;         }         if (r & 1) {           if (t[r - 1].may > ans.may) {             ans = t[r - 1];           }           r--;         }       }       return make_pair(ans.may, ans.pos);     }   } st;   int main() {     int n;     cin >> n;     for (long long i = 0; i < n; i++) {       int x1, y1, x2, y2;       cin >> x1 >> y1 >> x2 >> y2;       sweep.push_back(make_pair(make_pair(x1, 0), make_pair(y1, y2)));       sweep.push_back(make_pair(make_pair(x2, 1), make_pair(y1, y2)));       coords.push_back(y1);       coords.push_back(y2);     }     sort((sweep).begin(), (sweep).end());     sort((coords).begin(), (coords).end());     coords.resize(unique((coords).begin(), (coords).end()) - coords.begin());     int i = 0;     for (long long y : coords) ind[y] = i++;     st.n = (coords).size();     st.init();     for (auto elem : sweep) {       long long x = elem.first.first;       long long y1 = elem.second.first;       long long y2 = elem.second.second;       bool t = elem.first.second;       if (!t) {         st.upd(ind[y1], ind[y2] + 1, +1);         pair<long long, long long> cur = st.que();         if (cur.first >= n - 1) {           cout << x <<     << coords[cur.second] << endl;           return 0;         }       } else {         st.upd(ind[y1], ind[y2] + 1, -1);       }     }     return 0;   }