malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   struct task {     task() : pc(-1), indegree(0), outgoing() {}     int pc;     int indegree;     std::vector<int> outgoing;   };   int solve(int pc, std::vector<task> tasks) {     std::queue<int> todo[3];     for (__decltype((tasks).begin()) t = (tasks).begin(), t_end = (tasks).end();          t != t_end; ++t)       if (t->indegree == 0) todo[t->pc].push(t - tasks.begin());     int time = 0;     for (std::size_t solved = 0; solved < tasks.size(); pc = (pc + 1) % 3) {       while (!todo[pc].empty()) {         int t = todo[pc].front();         for (__decltype((tasks[t].outgoing).begin())                  n = (tasks[t].outgoing).begin(),                  n_end = (tasks[t].outgoing).end();              n != n_end; ++n) {           if (--tasks[*n].indegree == 0) todo[tasks[*n].pc].push(*n);         }         todo[pc].pop();         ++time;         ++solved;       }       ++time;     }     return time - 1;   }   int main() {     int n;     scanf( %d , &n);     std::vector<task> tasks(n);     for (int i = 0; i < n; ++i) {       scanf( %d , &tasks[i].pc);       --tasks[i].pc;     }     for (int i = 0; i < n; ++i) {       int k;       scanf( %d , &k);       while (k--) {         int a;         scanf( %d , &a);         --a;         tasks[a].outgoing.push_back(i);         ++tasks[i].indegree;       }     }     printf( %d n ,            std::min(std::min(solve(0, tasks), solve(1, tasks)), solve(2, tasks)));   }
#include <bits/stdc++.h>   using namespace std;   int N, K;   int h[100005];   bool isok[100005];   int check(int L) {     deque<int> A, B;     int ret = 0;     for (int i = 1; i <= N; ++i) {       while (A.size() && A.front() + L <= i) A.pop_front();       while (B.size() && B.front() + L <= i) B.pop_front();       while (A.size() && h[A.back()] >= h[i]) A.pop_back();       while (B.size() && h[B.back()] <= h[i]) B.pop_back();       A.push_back(i);       B.push_back(i);       if (i >= L) ret += (isok[i - L + 1] = (h[B.front()] - h[A.front()] <= K));     }     return ret;   }   int main() {     while (scanf( %d %d , &N, &K) == 2) {       for (int i = 1; i <= N; ++i) scanf( %d , h + i);       int lo = 1, hi = N + 1, mid;       while (lo + 1 < hi) {         mid = lo + hi >> 1;         if (check(mid))           lo = mid;         else           hi = mid;       }       int s = check(lo);       printf( %d %d n , lo, s);       for (int i = 1; i + lo - 1 <= N; ++i)         if (isok[i]) printf( %d %d n , i, i + lo - 1);     }   }
#include <bits/stdc++.h>   using namespace std;   const int size = 110000, mod = 1000000007, inf = 0x3f3f3f3f;   const double pi = acos(-1.0);   int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   int nex[2][4] = {0, 1, 0, -1, 1, 0, -1, 0};   long long cal(long long a, int n) {     long long s = 1 % mod;     while (n) {       if (n & 1) s = (s * a) % mod;       a = (a * a) % mod;       n /= 2;     }     return s;   }   int n, ar[size];   long long ans;   vector<int> fac, fac2;   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> ar[i];     sort(ar, ar + n);     for (int i = ar[n - 1]; i >= 1; i--) {       long long t = 1;       fac.clear();       for (int j = 1; j * j <= i; j++)         if (i % j == 0) {           fac.push_back(j);           if (j * j != i) fac.push_back(i / j);         }       sort(fac.begin(), fac.end());       int pre = 0;       for (int j = 1; j < fac.size(); j++) {         int num = lower_bound(ar, ar + n, fac[j]) - ar;         t = t * cal(j, num - pre) % mod;         pre = num;       }       t = t * (cal(fac.size(), n - pre) - cal(fac.size() - 1, n - pre)) % mod;       ans = (ans + t) % mod;     }     cout << (ans + mod) % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int n, x;     cin >> n >> x;     int temp, cnt = 0;     for (int i = 0; i < n; i++) {       cin >> temp;       cnt += temp;     }     if ((cnt + n - 1) == x)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int X;   vector<int> v[100010];   int all, all2;   bool used[800 + 10];   int dp[800 + 10], dp2[800 + 10];   void calc(int x) {     int i;     for ((i) = 0; (i) < (int)(800); (i)++) used[i] = false;     for ((i) = 0; (i) < (int)(v[x].size()); (i)++) used[v[x][i]] = true;     for ((i) = 0; (i) < (int)(800); (i)++) dp2[i] = (1 << 29);     int cost = 0;     for (i = 800 - 1; i >= 0; i--) {       if (used[i]) cost += 3;       int tmp = cost + dp[max(i - 1, 0)];       if (tmp < dp2[i]) dp2[i] = tmp;       if (i > 0) tmp += i * (i + 1) / 2 + 2;       if (tmp < dp2[0]) dp2[0] = tmp;     }     if (v[x].empty()) all2 = all;     for ((i) = 0; (i) < (int)(800); (i)++) dp[i] = dp2[i];     for ((i) = 0; (i) < (int)(800); (i)++) dp[i + 1] = min(dp[i + 1], dp[i]);   }   int main(void) {     int K, i, j, ans = 0;     cin >> X >> K;     for ((i) = 0; (i) < (int)(K); (i)++) {       int r, c;       scanf( %d%d , &r, &c);       int x = c - 1;       int y = X - r;       if (y < 800)         v[x].push_back(y);       else         ans += 3;     }     for (i = X - 1; i >= 0; i--) calc(i);     cout << dp[0] + ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void cmin(T &a, T b) {     ((a > b) && (a = b));   }   int cmax(int &a, int b) { return a < b ? a = b, 1 : 0; }   char IO;   template <class T = int>   T rd() {     T s = 0;     int f = 0;     while (!isdigit(IO = getchar())) f |= IO ==  - ;     do s = (s << 1) + (s << 3) + (IO ^  0 );     while (isdigit(IO = getchar()));     return f ? -s : s;   }   const int N = 1e6 + 10, INF = 1e9 + 10;   int n, m, k, T;   int s[N], t[N];   int F[1 << 20], G[1 << 20];   int p[N], a[N], b[N];   int main() {     n = rd(), m = rd(), k = rd();     for (int i = 0, iend = k - 1; i <= iend; ++i) scanf( %1d , s + i);     for (int i = 0, iend = k - 1; i <= iend; ++i) scanf( %1d , t + i);     for (int i = 0, iend = k - 1; i <= iend; ++i) p[i] = i;     memset(F, 63, sizeof F), memset(G, -63, sizeof G);     int S = 0;     for (int i = 0, iend = k - 1; i <= iend; ++i) S |= s[i] << i;     F[S] = 0;     for (int i = 1, iend = n; i <= iend; ++i) {       int x = rd() - 1, y = rd() - 1;       for (int j = 0, jend = k - 1; j <= jend; ++j)         if (p[j] == x) {           x = j;           break;         }       for (int j = 0, jend = k - 1; j <= jend; ++j)         if (p[j] == y) {           y = j;           break;         }       swap(p[x], p[y]);       int S = 0, T = 0;       for (int j = 0, jend = k - 1; j <= jend; ++j) {         S |= s[p[j]] << j;         T |= t[p[j]] << j;       }       cmin(F[S], i), G[T] = i;     }     int ans = 0, l = 1, r = n, c1 = 0, c2 = 0;     for (int i = 0, iend = k - 1; i <= iend; ++i) c1 += s[i], c2 += t[i];     for (int S = (1 << k) - 1, Send = 0; S >= Send; --S) {       if (G[S] - F[S] >= m)         if (cmax(ans, k - (c1 + c2 - 2 * __builtin_popcount(S))))           l = F[S] + 1, r = G[S];       for (int i = 0, iend = k - 1; i <= iend; ++i)         if (S & (1 << i)) {           cmin(F[S ^ (1 << i)], F[S]);           cmax(G[S ^ (1 << i)], G[S]);         }     }     printf( %d n%d %d n , ans, l, r);   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> graph[100005];   vector<pair<long long, long long> > graph_p[100005];   vector<pair<long long, long long> > op;   vector<long long> vis(100005, 0);   long long power(long long x, long long y) {     long long res = 1;     x = x % 1000000009;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = ((res % 1000000009) * (x % 1000000009)) % 1000000009;       y = y >> 1;       x = ((x % 1000000009) * (x % 1000000009)) % 1000000009;     }     return res;   }   void init_graph(long long n, long long m) {     cin >> n >> m;     for (long long i = 1; i <= m; i++) {       long long a, b;       cin >> a >> b;       graph[a].push_back(b);       graph[b].push_back(a);     }   }   void sieve(long long n) {     bool prime[n + 1];     memset(prime, true, sizeof(prime));     for (long long p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (long long i = p * p; i <= n; i += p) prime[i] = false;       }     }   }   long long n, h, l[2000005], r[2000005], ans;   long long sum[2000005], de[2000005];   void we_have_choices() {     cin >> n >> h;     for (long long i = 1; i <= n; i++) {       cin >> l[i] >> r[i];       sum[i] = sum[i - 1] + r[i] - l[i];       if (i == 1)         de[i] = 0;       else         de[i] = de[i - 1] + l[i] - r[i - 1];     }     for (long long i = 1; i <= n; i++) {       long long pos = lower_bound(de + i, de + n + 1, de[i] + h) - de;       ans = max(ans, sum[pos - 1] - sum[i - 1] + h);     }     cout << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr);     ;     long long t = 1;     while (t--) we_have_choices();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n, k, a[maxn];   vector<int> ans;   long long sum;   int main() {     ios::sync_with_stdio(false);     cin >> n >> k;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       sum += a[i];     }     int partsum = sum / k;     int tmp = 0, lastpos = 0;     bool flag = false;     for (int i = 1; i <= n; ++i) {       tmp += a[i];       if (tmp == partsum) {         ans.push_back(i - lastpos);         lastpos = i;         tmp = 0;       }       if (tmp >= partsum) {         flag = true;         break;       }     }     if (flag)       cout <<  No  << endl;     else if (ans.size() * partsum != sum)       cout <<  No  << endl;     else {       cout <<  Yes  << endl;       for (auto s : ans) cout << s <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   const int maxm = 300005;   struct segtree {     int tree[30 * maxm], L[30 * maxm], R[30 * maxm];     int sz = 0;     int root[maxm];     int update(int pre, int l, int r, int pos, int val) {       if (l > r || pos < l || pos > r) return pre;       int no = ++sz;       tree[no] = tree[pre];       L[no] = L[pre];       R[no] = R[pre];       if (l == r && l == pos) {         tree[no] += val;         R[no] = L[no] = 0;         return no;       }       int mid = (l + r) >> 1;       L[no] = update(L[pre], l, mid, pos, val);       R[no] = update(R[pre], mid + 1, r, pos, val);       tree[no] = tree[L[no]] + tree[R[no]];       return no;     }     int sum(int no, int l, int r, int pos) {       if (l == r) return 0;       int mid = (l + r) >> 1;       if (pos <= mid) return sum(L[no], l, mid, pos);       return tree[L[no]] + sum(R[no], mid + 1, r, pos);     }     int get(int no, int l, int r, int pos) {       if (l == r) return tree[no];       int mid = (l + r) >> 1;       if (pos <= mid) return get(L[no], l, mid, pos);       return get(R[no], mid + 1, r, pos);     }   } a, b;   map<string, int> mapa;   const int inf = 1e9 + 10;   int main() {     int q;     scanf( %d , &q);     int idx = 1;     for (int i = 1; i <= q; i++) {       char op[15];       scanf( %s , op);       a.root[i] = a.root[i - 1];       b.root[i] = b.root[i - 1];       if (op[0] ==  s ) {         char s[20];         int val;         scanf( %s %d , s, &val);         string t = s;         if (mapa.count(t)) {           int x = a.get(a.root[i], 1, maxn, mapa[t]);           a.root[i] = a.update(a.root[i], 1, maxn, mapa[t], val - x);           if (x != 0) {             b.root[i] = b.update(b.root[i], 1, inf, x, -1);           }           b.root[i] = b.update(b.root[i], 1, inf, val, 1);         } else {           mapa[t] = idx++;           a.root[i] = a.update(a.root[i], 1, maxn, mapa[t], val);           b.root[i] = b.update(b.root[i], 1, inf, val, 1);         }       } else if (op[0] ==  r ) {         char s[20];         scanf( %s , s);         string t = s;         if (mapa.count(t)) {           int x = a.get(a.root[i], 1, maxn, mapa[t]);           a.root[i] = a.update(a.root[i], 1, maxn, mapa[t], -x);           if (x != 0) {             b.root[i] = b.update(b.root[i], 1, inf, x, -1);           }         }       } else if (op[0] ==  q ) {         char s[20];         scanf( %s , s);         string t = s;         if (mapa.count(t)) {           int x = a.get(a.root[i], 1, maxn, mapa[t]);           if (x != 0) {             printf( %d n , b.sum(b.root[i], 1, inf, x));           } else             puts( -1 );         } else           puts( -1 );         fflush(stdout);       } else {         int x;         scanf( %d , &x);         a.root[i] = a.root[i - x - 1];         b.root[i] = b.root[i - x - 1];       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void doRoutine() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   long long int gcd(long long int a, long long int b) {     return b ? gcd(b, a % b) : a;   }   signed main() {     doRoutine();     vector<long long int> a(6);     long long int s = 0;     for (long long int i = 0; i < 6; i++) {       cin >> a[i];       s += a[i];     }     for (long long int i = 0; i < 6; i++) {       for (long long int j = 0; j < 6; j++) {         for (long long int l = 0; l < 6; l++) {           if (i != j && j != l && l != i) {             if (a[i] + a[j] + a[l] == s - a[i] - a[j] - a[l])               return cout <<  YES  <<   n , 0;           }         }       }     }     cout <<  NO  <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dd = (int)2e6 + 7;   int A[dd], cnt[dd];   long long tmp[dd];   pair<int, int> msk[20];   int count2[20], w;   long long pw[20];   long long ans = 0;   void get(int i, long long k) {     if (i == w) {       ans += tmp[k];       return;     }     if (count2[i] == 1) {       get(i + 1, k + pw[i] * msk[i].first);       return;     }     get(i + 1, k + pw[i] * msk[i].first);     get(i + 1, k + pw[i] * msk[i].second);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> w >> n >> m;     for (int i = 0; i < n; ++i) {       cin >> A[i];       cnt[A[i]]++;     }     pw[0] = 1;     for (int i = 1; i <= w; ++i) {       pw[i] = pw[i - 1] * 3;     }     for (int i = 0; i < (1 << w); ++i)       if (cnt[i]) {         for (int j = 0; j < (1 << w); ++j)           if (cnt[j]) {             int k = 0;             for (int l = 0; l < w; ++l) {               int ii = (i >> l) & 1, jj = (j >> l) & 1;               if (ii == jj && ii == 1) {                 k += 2 * pw[l];               }               if (ii != jj) {                 k += pw[l];               }             }             tmp[k] += cnt[i] * cnt[j];           }       }     while (m--) {       string s;       cin >> s;       reverse(s.begin(), s.end());       for (int i = 0; i < w; ++i) {         if (s[i] ==  A ) msk[i] = {0, 1}, count2[i] = 2;         if (s[i] ==  O ) msk[i] = {0, 0}, count2[i] = 1;         if (s[i] ==  X ) msk[i] = {0, 2}, count2[i] = 2;         if (s[i] ==  a ) msk[i] = {2, 2}, count2[i] = 1;         if (s[i] ==  o ) msk[i] = {1, 2}, count2[i] = 2;         if (s[i] ==  x ) msk[i] = {1, 1}, count2[i] = 1;       }       ans = 0;       get(0, 0);       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   ostream& operator<<(ostream& o, const vector<T>& v) {     o <<  [ ;     int b = 0;     for (const auto& a : v) o << (b++ ?  ,   :   ) << a;     o <<  ] ;     return o;   }   template <typename T, typename U>   ostream& operator<<(ostream& o, const pair<T, U>& p) {     o <<  (  << p.first <<  ,   << p.second <<  ) ;     return o;   }   template <typename T>   ostream& operator<<(ostream& o, const set<T>& s) {     o <<  { ;     int b = 0;     for (auto& e : s) o << (b++ ?  ,   :   ) << e;     o <<  } ;     return o;   }   template <typename T, typename U>   ostream& operator<<(ostream& o, const map<T, U>& m) {     o <<  { ;     int b = 0;     for (auto& e : m) o << (b++ ?  ,   :   ) << e;     o <<  } ;     return o;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     bool flag = 0;     vector<int> A(n);     for (auto& a : A) {       cin >> a;       if (a % 2 and flag) {         if (a < 0) {           a = a / 2;         } else {           a = (a + 1) / 2;         }         flag ^= 1;       } else if (a % 2) {         if (a < 0) {           a = (a - 1) / 2;         } else {           a = a / 2;         }         flag ^= 1;       } else {         a = a / 2;       }     }     for (auto& a : A) cout << a << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long pwr(long long base, long long p, long long mod = (1000000007LL)) {     long long ans = 1;     while (p) {       if (p & 1) ans = (ans * base) % mod;       base = (base * base) % mod;       p /= 2;     }     return ans;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int n, col[100005];   vector<int> adj[100005], adjacent;   set<int> distinct_;   void dfs(int v, int par) {     for (auto vv : adj[v])       if (vv != par) {         if (col[v] != col[vv]) {           adjacent.push_back(v);           adjacent.push_back(vv);         }         dfs(vv, v);       }   }   void verify(int v, int par) {     distinct_.insert(col[v]);     for (auto vv : adj[v])       if (vv != par) verify(vv, v);   }   bool check(int v) {     for (auto vv : adj[v]) {       distinct_.clear();       verify(vv, v);       if ((int)distinct_.size() > 1) return false;     }     return true;   }   int main() {     scanf( %d , &n);     int e = n - 1;     while (e--) {       int a, b;       scanf( %d%d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     for (int i = 1; i <= n; i++) {       scanf( %d , &col[i]);       distinct_.insert(col[i]);     }     if ((int)distinct_.size() == 1) {       printf( YES n );       printf( 1 n );       return 0;     }     if (check(1)) {       printf( YES n );       printf( 1 n );       return 0;     }     dfs(1, -1);     if (adjacent.empty()) {       printf( YES n );       printf( 1 n );       return 0;     }     if (check(adjacent[0])) {       printf( YES n );       printf( %d n , adjacent[0]);       return 0;     }     if (check(adjacent[1])) {       printf( YES n );       printf( %d n , adjacent[1]);       return 0;     }     printf( NO n );     return 0;   }
#include <bits/stdc++.h>   const long long MOD = 1e9 + 7;   using pii = std::pair<long long, long long>;   using namespace std;   const long long maxn = 5e5 + 5;   long long n, a[maxn], origvals[maxn], bit[2][maxn];   long long sum(long long dir, long long idx) {     long long curans = 0;     for (++idx; idx > 0; idx -= idx & -idx) curans += bit[dir][idx];     return curans;   }   void add(long long dir, long long idx, long long val) {     for (++idx; idx < maxn; idx += idx & -idx) bit[dir][idx] += val;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     vector<pii> compress;     for (long long i = 0; i < n; i++) {       cin >> a[i];       compress.push_back({a[i], i});     }     sort(compress.begin(), compress.end());     for (long long i = 0; i < compress.size(); i++) {       origvals[i] = compress[i].first;       a[compress[i].second] = i;     }     long long ans = 0;     for (long long i = 0; i < n; i++) {       add(0, a[i], i + 1);       long long cnt = (sum(0, a[i]) * (n - i)) % MOD;       ans += (origvals[a[i]] * cnt) % MOD;       ans %= MOD;     }     for (long long i = n - 1; i >= 0; i--) {       add(1, a[i], n - i);       long long cnt = ((sum(1, a[i]) * (i + 1))) % MOD;       ans += (origvals[a[i]] * cnt) % MOD;       ans %= MOD;     }     for (long long i = 0; i < n; i++) {       long long cnt = ((i + 1) * (n - i)) % MOD;       ans -= (origvals[a[i]] * cnt) % MOD;       ans += MOD;       ans %= MOD;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[200], n, k;     for (int i = 0; i <= 200; i++) a[i] = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> k;       a[k]++;     }     int kol = 0;     for (int i = 1; i <= 198; i++) kol += a[i] / 2;     cout << kol / 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4000 + 5, mod = 1000000009;   int n, x, y;   long long P[N], d[N][N];   int main() {     scanf( %d , &n);     scanf( %d , &x);     scanf( %d , &y);     for (int i = 0; i <= max(x, y); i++) d[i][0] = 1;     for (int i = 1; i <= max(x, y); i++)       for (int j = 1; j <= min(n, i); j++)         d[i][j] = (d[i - 1][j] + d[i - 1][j - 1]) % mod;     P[0] = 1;     for (int i = 1; i <= max(x, y); i++) P[i] = (P[i - 1] * i) % mod;     long long ans = 0;     for (int l = 2; l <= n - 1; l++)       for (int r = l; r <= n - 1; r++)         ans = (ans + (d[y - 1][r - l] * d[x - 1][n - (r - l + 2)]) % mod) % mod;     ans = ans * ((P[x] * P[y]) % mod) % mod;     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double eps = 1e-9;   const long long INF = 1ll << 61, Mo = 1e9 + 7;   int n, m, t, tu, tp, td;   int h[400][400];   int s[400][400], x[400][400], z[400][400], y[400][400];   set<pair<int, int> >::iterator ii;   inline int time(int h1, int h2) {     if (h1 == h2) return tp;     if (h1 < h2) return tu;     return td;   }   void init() {     scanf( %d%d%d , &n, &m, &t);     scanf( %d%d%d , &tp, &tu, &td);     int i, j;     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) scanf( %d , &h[i][j]);     for (j = 1; j <= m; j++)       for (i = 2; i <= n; i++) {         x[i][j] = x[i - 1][j] + time(h[i - 1][j], h[i][j]);         s[i][j] = s[i - 1][j] + time(h[i][j], h[i - 1][j]);       }     for (i = 1; i <= n; i++)       for (j = 2; j <= m; j++) {         y[i][j] = y[i][j - 1] + time(h[i][j - 1], h[i][j]);         z[i][j] = z[i][j - 1] + time(h[i][j], h[i][j - 1]);       }   }   int main() {     int i, j, k, w, ux, uy, dx, dy;     init();     int ans = 2e9;     for (i = 1; i <= n; i++)       for (j = i + 2; j <= n; j++) {         vector<pair<int, int> > V;         set<pair<int, int> > U;         for (k = 3; k <= m; k++) {           V.push_back(pair<int, int>(y[i][k] + z[j][k] + x[j][k] - x[i][k], k));           U.insert(V.back());         }         for (k = 0; k < V.size(); k++) {           int tmp = t - (s[j][k + 1] - s[i][k + 1]) + (y[i][k + 1] + z[j][k + 1]);           ii = U.lower_bound(pair<int, int>(tmp, 0));           if (ii != U.end() && ii->first - tmp < ans) {             ans = ii->first - tmp;             ux = i;             uy = k + 1;             dx = j;             dy = ii->second;           }           if (ii != U.begin()) {             ii--;             if (tmp - ii->first < ans) {               ans = tmp - ii->first;               ux = i;               uy = k + 1;               dx = j;               dy = ii->second;             }           }           U.erase(V[k]);         }       }     printf( %d %d %d %d n , ux, uy, dx, dy);     return 0;   }