malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, p;   int sum, mx;   vector<int> ans;   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = (1); i <= (n); i++) {       if (i == 1) {         cin >> p;         ans.push_back(1);         sum += p;         mx += p;       } else {         int x;         cin >> x;         mx += x;         if (x <= p / 2) {           ans.push_back(i);           sum += x;         }       }     }     if (sum <= mx / 2)       cout << 0;     else {       cout << (int)ans.size() <<   n ;       for (int x : ans) cout << x <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 9;   struct Point {     int col, id;     int x, y;     bool operator<(const Point& b) {       if (x == b.x) return y < b.y;       return x < b.x;     }   } p0, p[N * 2];   int cross(Point a, Point b, Point c) {     return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);   }   bool cmpang(Point a, Point b) { return cross(p0, a, b) > 0; }   int ans[N];   void solve(int L, int R) {     int c = L;     for (int i = L; i <= R; ++i)       if (p[i] < p[c]) c = i;     swap(p[c], p[L]);     p0 = p[L];     sort(p + L + 1, p + R + 1, cmpang);     int a1 = 0, a0 = 0;     int k = 1000000;     int mid = (L + R) >> 1;     for (int i = L + 1; i <= R; ++i) {       if (a1 == a0 && p[i].col != p0.col) {         k = i;         break;       }       if (p[i].col)         ++a1;       else         ++a0;     }     if (p0.col)       ans[p[k].id] = p0.id;     else       ans[p0.id] = p[k].id;     if (L + 1 < k - 1) solve(L + 1, k - 1);     if (k + 1 < R) solve(k + 1, R);   }   inline int read() {     char ch = getchar();     int x = 0, f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int main() {     int n = read();     for (int i = 1; i <= n; ++i) {       p[i].x = read();       p[i].y = read();       p[i].col = 0;       p[i].id = i;     }     for (int i = 1; i <= n; ++i) {       p[i + n].x = read();       p[i + n].y = read();       p[i + n].col = 1;       p[i + n].id = i;     }     solve(1, 2 * n);     for (int i = 1; i <= n; ++i) cout << ans[i] <<   n ;   }
#include <bits/stdc++.h>   int main() {     static long long N, K, b[1000000] = {}, n, i, t;     for (scanf( %lld%lld , &N, &K), n = N, i = 900000; n; n /= 2, i++)       n & 1 && (b[i]++, K--);     if (K < 0)       puts( No );     else {       for (i = 999999; K >= b[i]; i--)         if (b[i])           while (b[i]) b[i - 1] += 2, b[i]--, K--;       for (i = 0; !b[i]; i++)         ;       for (; K;) b[i] ? (b[i]--, b[i - 1] += 2, K--, i--) : i--;       for (puts( Yes ), t = 0, i = 999999; i >= 0; i--)         while (b[i]) printf( %lld  , i - 900000), b[i]--, t++;     }   }
#include <bits/stdc++.h>   using namespace std;   void factorize(long long v, std::map<long long, int> &result) {     long long p = 2;     while (v > 1 && p * p <= v) {       int cnt = 0;       while (v % p == 0) {         cnt++;         v /= p;       }       if (cnt > 0) {         if (result.count(p) == 0) {           result[p] = 0;         }         result[p] += cnt;       }       p += p == 2 ? 1 : 2;     }     if (v > 1) {       if (result.count(v) == 0) {         result[v] = 0;       }       result[v] += 1;     }   }   long long int ex_gcd(long long int x, long long int y, long long int &a,                        long long int &b) {     if (y == 0) {       a = 1;       b = 0;       return x;     }     long long int q = x / y;     long long int r = x % y;     long long int res = ex_gcd(y, r, a, b);     long long int tmp = a - q * b;     a = b;     b = tmp;     return res;   }   const int N = 123456;   int n;   long long int p;   vector<long long int> q;   vector<int> e;   long long int fact[N];   long long int invfact[N];   vector<int> fact_e[N];   void init(void) {     map<long long int, int> factor;     factorize(p, factor);     for (map<long long int, int>::iterator it = factor.begin();          it != factor.end(); ++it) {       q.push_back(it->first);       e.push_back(it->second);     }     int l = e.size();     fact_e[0] = vector<int>(l, 0);     fact[0] = invfact[0] = 1;     for (int i = (int)(1); i < (int)(N); i++) {       int v = i;       fact_e[i] = fact_e[i - 1];       for (int j = (int)(0); j < (int)(l); j++) {         while (v % q[j] == 0) {           fact_e[i][j] += 1;           v /= q[j];         }       }       fact[i] = fact[i - 1] * v % p;       long long int dummy2;       long long int dummy = ex_gcd(fact[i], p, invfact[i], dummy2);       assert(dummy == 1);       invfact[i] = (invfact[i] % p + p) % p;     }   }   long long int tri_comb(int x, int y) {     long long int t = 1;     int len = e.size();     t = (fact[n] * invfact[x]) % p;     t = t * invfact[y] % p;     t = t * invfact[n - x - y] % p;     vector<int> es(len);     for (int i = (int)(0); i < (int)(len); i++) {       es[i] = fact_e[n][i] - fact_e[x][i] - fact_e[y][i] - fact_e[n - x - y][i];       for (int j = (int)(0); j < (int)(es[i]); j++) {         t = t * q[i] % p;       }     }     return t;   }   long long int calc(int l) {     long long int tot = 0;     for (int i = (int)(0); i < (int)(n - l + 1); i++) {       if ((n + i + l) % 2 == 0) {         tot = (tot + tri_comb(i, (n - i - l) / 2)) % p;       }     }     return tot;   }   int main(void) {     ios::sync_with_stdio(false);     cin.tie(0);     int l, r;     cin >> n >> p >> l >> r;     init();     cout << (calc(l) + calc(l + 1) - calc(r + 1) - calc(r + 2) + 2 * p) % p          <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int a[200000], b[200000], c[200000];   int main() {     int n, i, j, max1 = -1;     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     b[0] = 1;     for (i = 1; i < n; i++) {       if (a[i] > a[i - 1]) {         b[i] = b[i - 1] + 1;       } else         b[i] = 1;     }     c[n - 1] = 1;     for (i = n - 2; i >= 0; i--) {       if (a[i] < a[i + 1])         c[i] = c[i + 1] + 1;       else         c[i] = 1;     }     if (n == 1)       printf( 1 n );     else {       max1 = 2;       if (max1 < b[n - 2] + 1) max1 = b[n - 2] + 1;       if (max1 < c[1] + 1) max1 = c[1] + 1;       for (i = 1; i <= n - 2; i++) {         if (a[i + 1] - a[i - 1] > 1) {           if (max1 < b[i - 1] + c[i + 1] + 1) max1 = b[i - 1] + c[i + 1] + 1;         } else {           if (max1 < b[i - 1] + 1) max1 = b[i - 1] + 1;           if (max1 < c[i + 1] + 1) max1 = c[i + 1] + 1;         }       }       printf( %d n , max1);     }     return 0;   }
#include <bits/stdc++.h>   int main() {     char x[205];     scanf( %s , x);     for (int i = 0; i < strlen(x); i++) {       if (x[i] ==  . ) {         x[i] =  0 ;         printf( %c , x[i]);       }       if (x[i] ==  -  && x[i + 1] ==  . ) {         x[i] =  1 ;         printf( %c , x[i]);         i = i + 1;       }       if (x[i] ==  -  && x[i + 1] ==  - ) {         x[i] =  2 ;         printf( %c , x[i]);         i = i + 1;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   const int LOGN = 18;   int n, q, p[N], stk[N], L[LOGN][N], R[LOGN][N];   long long a[N], b[N], LC[LOGN][N], RC[LOGN][N];   inline long long getdist(int u, int v) {    long long ret = 0;    for (int i = LOGN - 1; i >= 0; i--) if (R[i][u] <= v) {     ret += RC[i][u];     u = R[i][u];    }    if (u == v) return ret;    for (int i = LOGN - 1; i >= 0; i--) if (L[i][v] >= u) {     ret += LC[i][v];     v = L[i][v];    }    return ret;   }   int main() {    scanf( %d%d , &n, &q);    for (int i = 1; i <= n; i++) scanf( %d , &p[i]);    p[n + 1] = n + 1;    for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);    for (int i = 1; i <= n; i++) scanf( %lld , &b[i]);    int tp = 0;    stk[++tp] = n + 1;    for (int j = 0; j < LOGN; j++) {     R[j][n + 1] = n + 1;     RC[j][n + 1] = 0;    }    for (int i = n; i >= 1; i--) {     while (tp && p[stk[tp]] < p[i]) tp--;     R[0][i] = stk[tp];     RC[0][i] = b[i] = min(b[i], a[i] + getdist(i + 1, stk[tp]));     for (int j = 1; j < LOGN; j++) {      R[j][i] = R[j - 1][R[j - 1][i]];      RC[j][i] = RC[j - 1][i] + RC[j - 1][R[j - 1][i]];     }     stk[++tp] = i;    }    tp = 0;    stk[++tp] = 1;    for (int j = 0; j < LOGN; j++) {     L[j][1] = L[j][0] = 0;     LC[j][1] = 0;    }    for (int i = 2; i <= n + 1; i++) {     while (tp && p[stk[tp]] < p[i]) tp--;     L[0][i] = tp ? stk[tp] : 0;     LC[0][i] = tp ? a[stk[tp]] + getdist(stk[tp] + 1, i) : 0;     for (int j = 1; j < LOGN; j++) {      L[j][i] = L[j - 1][L[j - 1][i]];      LC[j][i] = LC[j - 1][i] + LC[j - 1][L[j - 1][i]];     }     stk[++tp] = i;    }    set<int> st;    st.insert(1);    st.insert(n + 1);    long long sum = getdist(1, n + 1);    while (q--) {     int x;     scanf( %d , &x);     if (x != 1) {      if (st.count(x)) {       auto it = st.find(x);       int prv = *prev(it), nxt = *next(it);       sum += getdist(prv, nxt);       sum -= getdist(prv, x);       sum -= getdist(x, nxt);       st.erase(it);      } else {       auto it = st.insert(x).first;       int prv = *prev(it), nxt = *next(it);       sum -= getdist(prv, nxt);       sum += getdist(prv, x);       sum += getdist(x, nxt);      }     }     printf( %lld n , sum);    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cout << x; }   void __print(long x) { cout << x; }   void __print(long long x) { cout << x; }   void __print(unsigned x) { cout << x; }   void __print(unsigned long x) { cout << x; }   void __print(unsigned long long x) { cout << x; }   void __print(float x) { cout << x; }   void __print(double x) { cout << x; }   void __print(long double x) { cout << x; }   void __print(char x) { cout <<      << x <<     ; }   void __print(const char *x) { cout <<     << x <<    ; }   void __print(const string &x) { cout <<     << x <<    ; }   void __print(bool x) { cout << (x ?  true  :  false ); }   void _print() { cout <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cout <<  ,  ;     _print(v...);   }   const long long int dx4[4] = {+1, -1, 0, 0};   const long long int dy4[4] = {0, 0, +1, -1};   const long long int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};   const long long int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};   const long long int MOD = 1e9 + 7;   const long long int INF = 1e10;   const long long int N = 2e5 + 5;   void solve() {     long long int n;     string s;     cin >> n >> s;     map<char, long long int> cnt;     for (auto x : s) cnt[x]++;     for (auto x : cnt)       while (x.second) cout << x.first, x.second--;     return;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 450000 + 100;   int n, k;   vector<int> pos[maxn];   int a[maxn];   int b[maxn];   int v[maxn];   int main() {     while (cin >> n >> k) {       for (int i = 1; i <= n; i++) {         cin >> a[i];         v[i] = a[i];         pos[i].push_back(0);       }       pos[0].push_back(0);       int tot = n;       sort(v + 1, v + n + 1);       tot = unique(v + 1, v + n + 1) - (v + 1);       for (int i = 1; i <= n; i++) {         a[i] = lower_bound(v + 1, v + 1 + tot, a[i]) - (v + 1) + 1;       }       long long mx = 0, ans = 0;       for (int i = 1; i <= n; i++) {         int v = a[i];         pos[v].push_back(i);         int sz = pos[v].size();         while (b[v] + k < sz) {           b[v]++;         }         mx = max(mx, (long long)pos[v][b[v]]);         ans += mx;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   string s;   long long ans, i, l, n, d, m;   int main() {     cin >> n >> m;     for (i = 1; i < n; i++) {       cin >> s;     }     cin >> s;     for (i = 1; i < s.size(); i++) {       if (s[i] != s[i - 1]) ans++;     }     if (ans % 2 == 0) {       ans /= 2;       if (s[0] ==  B ) ans++;     } else {       ans++;       ans /= 2;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void input(T &x) {     register char c = getchar();     x = 0;     int neg = 0;     for (; ((c < 48 || c > 57) && c !=  - ); c = getchar())       ;     if (c ==  - ) {       neg = 1;       c = getchar();     }     for (; c > 47 && c < 58; c = getchar()) {       x = (x << 1) + (x << 3) + c - 48;     }     if (neg) x = -x;   }   inline long long bigmod(long long p, long long e, long long M) {     long long ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % M;       p = (p * p) % M;     }     return ret;   }   template <class T>   inline T gcd(T a, T b) {     if (b == 0) return a;     return gcd(b, a % b);   }   template <class T>   inline T modinverse(T a, T M) {     return bigmod(a, M - 2, M);   }   const int N = 1e6 + 6;   char str[N], inp[26];   int qu[10001];   int main() {     scanf( %s , str);     int n = strlen(str);     int q;     input(q);     int mask = 0;     unordered_map<int, int> Map;     for (int t = 0; t < q; t++) {       scanf( %s  , inp);       mask = 0;       for (int i = 0; inp[i]; i++) {         mask |= 1 << inp[i] -  a ;       }       qu[t] = mask;       Map[mask] = 0;     }     for (int i = 0; i < n; i++) {       mask = 0;       for (int j = i; j < n; j++) {         if (i < j && str[i] == str[j]) break;         mask |= 1 << str[j] -  a ;         if (j + 1 == n || (mask & 1 << str[j + 1] -  a ) == 0)           if (Map.count(mask)) Map[mask]++;       }     }     for (int i = 0; i < q; i++) {       printf( %d n , Map[qu[i]]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using lli = long long int;   using pii = pair<int, int>;   using vi = vector<int>;   using vb = vector<bool>;   using vvi = vector<vector<int>>;   using vlli = vector<long long int>;   using vpii = vector<pair<int, int>>;   lli n, m, k, u, v, x, ans, curr, T;   vlli c;   lli fast_exp(lli base, lli exp) {     lli res = 1;     base = base % 1000000007;     while (exp > 0) {       if (exp % 2) res = (res * base) % 1000000007;       base = (base * base) % 1000000007;       exp /= 2;     }     return res % 1000000007;   }   template <class T>   struct DSU {     map<T, T> par;     T comp_sz = n;     T get(T u) {       if (par.find(u) == par.end()) return u;       return par[u] = get(par[u]);     }     void unite(T x, T y) {       T X = get(x), Y = get(y);       if (X == Y) return;       par[Y] = X;       --comp_sz;     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     c.resize(n + 1);     map<lli, DSU<lli>> virus;     for (int i = 1; i <= n; i++) cin >> c[i];     for (int i = 1; i <= m; i++) {       cin >> u >> v;       x = c[u] ^ c[v];       virus[x].unite(u, v);     }     ans = ((fast_exp(2, k) - virus.size() + 1000000007) * fast_exp(2, n)) %           1000000007;     for (auto i : virus) {       curr = (i.second).comp_sz;       ans = (ans + fast_exp(2, curr)) % 1000000007;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   void solve() {     int m;     cin >> n >> m;     vector<string> a(n);     for (int i = (0); i <= int(n - 1); i++) cin >> a[i];     if (n < 3) {       cout << -1;       return;     }     int ans = 0;     vector<vector<int>> dp(n * m, vector<int>(4, 0));     vector<vector<int>> res;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i][j] ==  * ) {           dp[i * m + j][0] = 1 + (i - 1 >= 0 ? dp[(i - 1) * m + j][0] : 0);         }       }     }     for (int i = n - 1; i >= 0; i--) {       for (int j = 0; j < m; j++) {         if (a[i][j] ==  * ) {           dp[i * m + j][1] = 1 + (i + 1 < n ? dp[(i + 1) * m + j][1] : 0);         }       }     }     for (int i = 0; i < m; i++) {       for (int j = 0; j < n; j++) {         if (a[j][i] ==  * ) {           dp[j * m + i][2] = 1 + (i - 1 >= 0 ? dp[(j)*m + i - 1][2] : 0);         }       }     }     for (int i = m - 1; i >= 0; i--) {       for (int j = 0; j < n; j++) {         if (a[j][i] ==  * ) {           dp[j * m + i][3] = 1 + (i + 1 < m ? dp[(j)*m + i + 1][3] : 0);         }       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         int idx = i * m + j;         int mini = min({dp[idx][0], dp[idx][1], dp[idx][2], dp[idx][3]});         if (mini >= 2) {           mini--;           for (int k = i - mini; k <= i + mini; k++) {             a[k][j] =  . ;           }           for (int k = j - mini; k <= j + mini; k++) {             a[i][k] =  . ;           }           res.push_back({i + 1, j + 1, mini});         }       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i][j] ==  * ) {           cout << -1;           return;         }       }     }     cout << res.size() <<   n ;     for (int i = 0; i < res.size(); i++) {       cout << res[i][0] <<     << res[i][1] <<     << res[i][2] <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int n, a[1111], f[1111];   int main() {     cin >> n;     for (int i = 0; i < n; ++i) cin >> a[i];     for (int day = 1000; day >= 1; --day) {       for (int i = 0; i < n; ++i) f[i] = 0;       f[0] = (day <= a[0]);       for (int i = 1; i < n; ++i) {         if (day > a[i]) continue;         f[i] |= f[i - 1];         if (i > 1) f[i] |= f[i - 2];       }       if (f[n - 1]) {         cout << day << endl;         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   string str, queries[100010];   int n;   unsigned long long values[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};   unsigned long long length[10] = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10};   int main() {     cin >> str >> n;     queries[0] =  0->  + str;     for (int i = 0; i < n; i++) {       cin >> queries[i + 1];     }     for (int i = n; i >= 0; i--) {       unsigned long long len = 1, val = 0;       for (int j = 3; j < queries[i].size(); ++j) {         int d = queries[i][j] -  0 ;         val = (val * length[d] + values[d]) % 1000000007;         len = len * length[d] % 1000000007;       }       length[queries[i][0] -  0 ] = len;       values[queries[i][0] -  0 ] = val;     }     cout << values[0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int h, m;     while (scanf( %d:%d , &h, &m) == 2) {       int a;       scanf( %d , &a);       int t = (h * 60 + m + a) % (24 * 60);       printf( %02d:%02d n , t / 60, t % 60);     }   }
#include <bits/stdc++.h>   using namespace std;   const int nax = 1000 * 1007;   long long int revi(long long int i) {     long long int rev = 0;     while (i > 0) {       rev = (rev * 10) + (i % 10);       i = i / 10;     }     return rev;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int n;     cin >> n;     long long int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       a[i] = abs(a[i]);     }     sort(a, a + n);     long long int l = 0, ans = 0;     for (int i = 0; i < n; i++) {       while (2 * a[l] < a[i]) l++;       ans = ans + (i - l);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     string str;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> str;       sort(str.begin(), str.end());       for (int j = 0; j < str.size() - 1; j++) {         if (str[j + 1] - str[j] != 1) {           cout <<  NO                 <<   n ;           break;         } else if (j == str.size() - 2) {           cout <<  YES                 <<   n ;         }       }       if (str.size() == 1) {         cout <<  YES               <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2 * 1000 * 100 + 100;   long long nums[maxn];   long long ans = 0;   long long cou[30];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> nums[i];       cou[nums[i] + 10]++;     }     ans += (cou[0 + 10] * (cou[10] - 1)) / 2;     for (int i = 1; i < 11; i++) {       ans += cou[i + 10] * cou[-i + 10];     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const N = 8;   char a[N][N + 1];   int d[N * N][N][N];   inline int in(int x) { return x >= 0 && x < N; }   int main() {     for (int i = 0; i < N; ++i) scanf( %s , a[i]);     for (int i = 0; i < N; ++i)       for (int j = 0; j < N; ++j) d[0][i][j] = (a[i][j] ==  M );     for (int i = 0; i + 1 < N * N; ++i) {       for (int j = 0; j < N; ++j)         for (int k = 0; k < N; ++k) {           if (a[j][k] ==  A  && d[i][j][k]) {             cout <<  WIN n ;             return 0;           }           if (a[j][k] ==  S  && in(j + i)) d[i][j + i][k] = 0;         }       for (int j = 0; j < N; ++j)         for (int k = 0; k < N; ++k)           if (d[i][j][k])             for (int dx = -1; dx <= 1; ++dx)               for (int dy = -1; dy <= 1; ++dy)                 if (in(j + dx) && in(k + dy) &&                     (!in(j + dx - i) || a[j + dx - i][k + dy] !=  S ))                   d[i + 1][j + dx][k + dy] = 1;     }     printf( LOSE n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using ULL = unsigned long long;   using VI = vector<int>;   using VL = vector<LL>;   using PII = pair<int, int>;   using PLL = pair<LL, LL>;   void dout() { cerr << endl; }   template <typename Head, typename... Tail>   void dout(Head H, Tail... T) {     cerr << H <<    ;     dout(T...);   }   const int MAX = 1 << 10;   int a[MAX][MAX];   set<int> s[MAX];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m, k;     cin >> n >> m >> k;     for (int i = (0); i < (n); ++i)       for (int j = (0); j < (m); ++j) {         cin >> a[i][j];         if (a[i][j] != 2) s[j].insert(i);       }     while (k--) {       int c;       cin >> c;       c--;       int r = 0;       while (true) {         auto it = s[c].lower_bound(r);         if (it == s[c].end()) break;         int nr = *it;         int& na = a[nr][c];         s[c].erase(it);         if (na == 1) {           c++;         } else {           assert(na == 3);           c--;         }         na = 2;         r = nr;       }       cout << c + 1 <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t, n, i, min1, min2, max1, max2, a[10000], b[10000];     cin >> n;     t = n;     while (n--) {       cin >> a[i] >> b[i];       i++;     }     max1 = a[0];     max2 = b[0];     min1 = a[0];     min2 = b[0];     for (i = 0; i < t; i++) {       if (a[i] > max1) max1 = a[i];       if (b[i] > max2) max2 = b[i];       if (a[i] <= min1) min1 = a[i];       if (b[i] <= min2) min2 = b[i];     }     max1 = max1 - min1;     max2 = max2 - min2;     if (max1 >= max2)       cout << max1 * max1;     else       cout << max2 * max2;     return 0;   }