malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int Mx = 1e5 + 5;   const long long inf = 1e9 + 1;   struct Point {     long long x, y;   } point[Mx];   int n;   long long ans, hmax[Mx], emax[Mx], hmin[Mx], emin[Mx];   template <class T>   bool cmp(T a, T b) {     return a.x < b.x;   }   bool judge(long long mid) {     int l = 1, r = 1;     long long Max, Min;     while (r <= n) {       while (point[r].x - point[l].x <= mid && r <= n) r++;       Max = -inf;       Min = inf;       if (l != 1) {         Max = max(Max, hmax[l - 1]);         Min = min(Min, hmin[l - 1]);       }       if (r <= n) {         Max = max(Max, emax[r]);         Min = min(Min, emin[r]);       }       if (Max == -inf) return 1;       if (Max - Min <= mid) return 1;       l++;     }     return 0;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       long long x, y;       scanf( %lld%lld , &x, &y);       point[i].x = x + y;       point[i].y = x - y;     }     sort(point + 1, point + 1 + n, cmp<Point>);     hmin[0] = inf;     hmax[0] = -inf;     emin[n + 1] = inf;     emax[n + 1] = -inf;     for (int i = 1; i <= n; i++) {       hmax[i] = max(hmax[i - 1], point[i].y);       hmin[i] = min(hmin[i - 1], point[i].y);     }     for (int i = n; i >= 1; i--) {       emax[i] = max(emax[i + 1], point[i].y);       emin[i] = min(emin[i + 1], point[i].y);     }     long long l = 0, r = 2e9;     while (l <= r) {       long long mid = (l + r) >> 1;       if (judge(mid)) {         r = mid - 1;         ans = mid;       } else {         l = mid + 1;       }     }     printf( %lf , 1.0 * ans / 2);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n == 1 or n > 26) {       cout <<  Yes n ;       return 0;     }     set<char> s;     char c;     for (int i = 0; i < n; i++) {       cin >> c;       if (s.find(c) != s.end()) {         cout <<  Yes n ;         return 0;       }       s.insert(c);     }     cout <<  No n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, l, r, shag = 0;     cin >> n;     l = 1;     r = n;     while (l <= r) {       if (shag % 2 == 0)         cout << l++ <<    ;       else         cout << r-- <<    ;       shag++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, x, y, k;     cin >> n >> m;     long long a[n], b[m];     cin >> x >> k >> y;     for (long long i = 0; i < n; i++) cin >> a[i];     for (long long i = 0; i < m; i++) cin >> b[i];     vector<long long> adj[n];     long long z[n];     long long ind = 0;     for (long long i = 0; i < n; i++) {       if (ind >= m) {         adj[ind].push_back(a[i]);         continue;       }       if (b[ind] == a[i]) {         if (ind - 1 >= 0)           z[ind] = max(b[ind], b[ind - 1]);         else           z[ind] = b[ind];         ind++;       } else         adj[ind].push_back(a[i]);     }     if (ind < m - 1) {       cout <<  -1 n ;       return 0;     }     z[ind] = b[m - 1];     ind = 0;     long long ans = 0;     int f = 0;     for (auto &it : adj) {       long long itl = it.size();       if (itl == 0) {         ind++;         continue;       }       long long mxv = -1;       for (auto &it2 : it) mxv = max(mxv, it2);       if (itl < k) {         if (mxv < z[ind])           ans += itl * y;         else {           f = 1;           break;         }       } else {         if (x >= y * k) {           if (mxv < z[ind])             ans += itl * y;           else {             ans = ans + (itl - k) * y + x;           }         } else {           ans += (itl / k) * x + (itl % k) * y;         }       }       ind++;     }     if (f == 1)       cout <<  -1 n ;     else       cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename S, typename T>   ostream& operator<<(ostream& out, pair<S, T> const& p) {     out <<  (  << p.first <<  ,   << p.second <<  ) ;     return out;   }   template <typename T>   ostream& operator<<(ostream& out, vector<T> const& v) {     long long l = v.size();     for (long long i = 0; i < l - 1; i++) out << v[i] <<    ;     if (l > 0) out << v[l - 1];     return out;   }   template <typename T>   void trace(const char* name, T&& arg1) {     cout << name <<   :   << arg1 <<   n ;   }   template <typename T, typename... Args>   void trace(const char* names, T&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cout.write(names, comma - names) <<   :   << arg1 <<   |  ;     trace(comma + 1, args...);   }   const int N = 202;   const int K = 1010;   const int MOD = 1e9 + 7;   int dp[N][N][K];   int n, kk, arr[N];   int pre[N];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> kk;     for (int i = 1; i <= n; i++) {       cin >> arr[i];     }     sort(arr + 1, arr + 1 + n);     dp[0][0][0] = 1;     for (int i = 0; i < n; i++) {       for (int j = 0; j <= n; j++) {         for (int k = 0; k < K; k++) {           int nk = k + (j) * (arr[i + 1] - arr[i]);           if (nk <= kk) {             dp[i + 1][j][nk] =                 (0LL + (1LL * dp[i][j][k] * (j + 1)) % MOD + dp[i + 1][j][nk]) %                 MOD;             dp[i + 1][j + 1][nk] =                 (0LL + dp[i + 1][j + 1][nk] + dp[i][j][k]) % MOD;             if (j)               dp[i + 1][j - 1][nk] =                   (0LL + dp[i + 1][j - 1][nk] + 1LL * dp[i][j][k] * j) % MOD;           }         }       }     }     int ans = 0;     for (int i = 0; i <= kk; i++) {       ans = (ans + dp[n][0][i]) % MOD;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   long long c(int a, int b) {     long long res = 1;     for (int i = 1; i <= b; ++i) {       res = res * (a + 1 - i) / i;     }     return res;   }   int main() {     scanf( %d%d , &n, &k);     long long ans = 1;     for (int i = 1; i <= k; ++i) {       if (i == 2) {         ans += c(n, 2);       }       if (i == 3) {         ans += 2 * c(n, 3);       }       if (i == 4) {         ans += 9 * c(n, 4);       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 505, MOD = 1e9 + 7;   struct node {     node *ch[20], *fail;     int cnt, id;     node(node* son = NULL) {       for (int i = 0; i <= 19; i++) ch[i] = son;       fail = son;       cnt = id = 0;     }   } nil, *null = &nil, *root = null, *nd[maxn];   typedef node* P_node;   queue<P_node> que;   void Build() {     root->fail = root;     root->id = 0;     nd[0] = root;     for (int i = 0; i <= 19; i++)       if (root->ch[i] != null) {         P_node v = root->ch[i];         que.push(v);         v->fail = root;       } else         root->ch[i] = root;     while (!que.empty()) {       P_node p = que.front();       que.pop();       for (int i = 0; i <= 19; i++)         if (p->ch[i] != null) {           P_node v = p->ch[i];           que.push(v);           v->fail = p->fail->ch[i];           v->cnt += v->fail->cnt;         } else           p->ch[i] = p->fail->ch[i];     }   }   int a[maxn], b[maxn], c[maxn], n, m, K, tot;   int f[2][205][705][2][2];   int Calc(int a[]) {     memset(f, 0, sizeof(f));     f[0][0][0][0][0] = 1;     for (int i = 0, o = 0; i <= a[0] - 1; i++, o ^= 1) {       memset(f[o ^ 1], 0, sizeof(f[o ^ 1]));       for (int j = 0; j <= tot; j++)         for (int k = 0; k <= K; k++)           for (int t1 = 0; t1 <= 1; t1++)             for (int t2 = 0; t2 <= 1; t2++)               if (f[o][j][k][t1][t2]) {                 for (int t = 0; t <= (t2 ? m - 1 : a[i + 1]); t++) {                   int v = (t1 | (t > 0)) ? nd[j]->ch[t]->id : 0;                   (f[o ^ 1][v][k + nd[v]->cnt][t1 | (t > 0)]                     [t2 | (t < a[i + 1])] += f[o][j][k][t1][t2]) %= MOD;                 }               }     }     int res = 0;     for (int i = 0; i <= tot; i++)       for (int j = 0; j <= K; j++)         for (int k = 0; k <= 1; k++)           for (int t = 0; t <= 1; t++) (res += f[a[0] & 1][i][j][k][t]) %= MOD;     return res;   }   int main() {     scanf( %d%d%d , &n, &m, &K);     scanf( %d , &a[0]);     for (int i = 1; i <= a[0]; i++) scanf( %d , &a[i]);     scanf( %d , &b[0]);     for (int i = 1; i <= b[0]; i++) scanf( %d , &b[i]);     a[a[0]]--;     for (int i = a[0]; i >= 1; i--)       if (a[i] < 0) a[i] += m, a[i - 1]--;     nil = node(null);     for (int i = 1; i <= n; i++) {       int t, x;       scanf( %d , &t);       P_node now = root;       while (t--) {         scanf( %d , &x);         if (now->ch[x] == null) {           now = now->ch[x] = new node(null);           now->id = ++tot;           nd[tot] = now;         } else           now = now->ch[x];       }       scanf( %d , &x);       now->cnt += x;     }     Build();     printf( %d n , ((Calc(b) - Calc(a)) % MOD + MOD) % MOD);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 1;   int sp[N];   int dp[N];   int main() {     ios_base::sync_with_stdio(0);     const int N = 1e6 + 1;     int n;     cin >> n;     int a[n + 1];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     a[n] = N;     for (int i = 2; i < N; i++) {       sp[i] = i;     }     for (long long i = 2; i * i < N; i++) {       if (sp[i] == i) {         for (long long j = i * i; j < N; j += i) {           if (sp[j] == j) {             sp[j] = i;           }         }       }     }     int ans = 0;     for (int i = 1, j = 0; i < N; i++) {       int num = i;       int maxi = 0;       while (num > 1) {         maxi = max(maxi, dp[i / sp[num]]);         num /= sp[num];       }       dp[i] = maxi;       if (i == a[j]) {         dp[i]++;         j++;       }       ans = max(ans, dp[i]);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k = 0;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     int count = 0;     for (int i = 0; i < n; i++) {       if (a[i] == 1) {         count++;       }     }     cout << count << endl;     for (int i = 1; i < n; i++) {       if (a[i] == 1) {         cout << i - k <<    ;         k = i;       }     }     cout << n - k;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300005;   struct seg {     int v[N * 4], tp;     void build(int k, int l, int r, int *a) {       if (l == r) return v[k] = a[l], void(0);       int mid = (l + r) / 2;       build(k * 2, l, mid, a);       build(k * 2 + 1, mid + 1, r, a);       v[k] = (tp ? min(v[k * 2], v[k * 2 + 1]) : max(v[k * 2], v[k * 2 + 1]));     }     int ask(int k, int l, int r, int x, int y) {       if (l == x && r == y) return v[k];       int mid = (l + r) / 2;       if (y <= mid) return ask(k * 2, l, mid, x, y);       if (x > mid) return ask(k * 2 + 1, mid + 1, r, x, y);       return tp ? min(ask(k * 2, l, mid, x, mid),                       ask(k * 2 + 1, mid + 1, r, mid + 1, y))                 : max(ask(k * 2, l, mid, x, mid),                       ask(k * 2 + 1, mid + 1, r, mid + 1, y));     }   } mn[20], mx[20];   int r[N], n, id[N];   int L[20][N];   int R[20][N];   int main() {     scanf( %d , &n);     for (int i = (int)(1); i <= (int)(n); ++i)       scanf( %d , &r[i]), r[i + n] = r[i + n + n] = r[i];     for (int i = (int)(1); i <= (int)(3 * n); ++i)       L[0][i] = max(i - r[i], 1), R[0][i] = min(i + r[i], 3 * n);     for (int i = (int)(1); i <= (int)(18); ++i) {       mn[i - 1].tp = 1;       mx[i - 1].tp = 0;       mn[i - 1].build(1, 1, 3 * n, L[i - 1]);       mx[i - 1].build(1, 1, 3 * n, R[i - 1]);       for (int j = (int)(1); j <= (int)(3 * n); ++j) {         L[i][j] = mn[i - 1].ask(1, 1, 3 * n, L[i - 1][j], R[i - 1][j]);         R[i][j] = mx[i - 1].ask(1, 1, 3 * n, L[i - 1][j], R[i - 1][j]);       }     }     mn[18].tp = 1;     mx[18].tp = 0;     mn[18].build(1, 1, 3 * n, L[18]);     mx[18].build(1, 1, 3 * n, R[18]);     for (int i = (int)(1); i <= (int)(n); ++i) {       int l = n + i, r = n + i, ans = 0;       for (int j = (int)(18); j >= (int)(0); --j) {         int L = mn[j].ask(1, 1, 3 * n, l, r);         int R = mx[j].ask(1, 1, 3 * n, l, r);         if (R - L + 1 < n) l = L, r = R, ans += (1 << j);       }       printf( %d  , ans + ((r - l + 1) < n));     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, c = 0;     cin >> n >> x;     int j = 1;     for (int i = 0; i < n; i++) {       int r, l;       cin >> r >> l;       c += l - r + 1;       while (j + x <= r) {         j += x;       }       c += r - j;       j = l + 1;     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long NMAX = 1000;   pair<long long, long long> func[NMAX + 5];   pair<long long, long long> tmp_func[NMAX + 5];   long long initial[NMAX + 5];   pair<long long, long long> ans[NMAX + 5];   map<pair<long long, long long>, long long> memo;   int cnt_queries = 0;   long long singular_query(long long id, long long wh) {     if (memo.count({id, wh}) == 0) {       cout <<  ?   << id <<     << wh << endl;       cin >> memo[{id, wh}];       cnt_queries++;     }     return memo[{id, wh}];   }   void query_fun(long long fst, long long lst, long long wh) {     for (long long i = fst; i <= lst; i++) {       func[i].first = singular_query(func[i].second, wh);     }   }   void solve(long long fst, long long lst, long long l, long long r,              long long buck) {     if (fst == lst) {       ans[func[fst].second] = {l, r};       return;     }     long long target_split = (lst + fst) / 2;     long long st = l + 1LL * (target_split - fst + 1) * buck - 1,               dr = r - 1LL * (lst - target_split) * buck + 1;     while (dr - st > 1) {       long long mid = (st + dr) / 2;       for (long long i = fst; i <= lst; i++) {         map<pair<long long, long long>, long long>::iterator it =             memo.lower_bound({func[i].second, mid});         if (it != memo.end() && it->first.first == func[i].second &&             it->second - initial[func[i].second] <                 buck * (target_split - fst + 1)) {           func[i].first = it->second;         } else if (it != memo.begin()) {           it--;           if (it->first.first == func[i].second &&               it->second - initial[func[i].second] >=                   buck * (target_split - fst + 1)) {             func[i].first = it->second;           } else {             func[i].first = singular_query(func[i].second, mid);           }         } else {           func[i].first = singular_query(func[i].second, mid);         }       }       sort(func + fst, func + 1 + lst,            [&](pair<long long, long long> &a, pair<long long, long long> &b) {              return a.first - initial[a.second] > b.first - initial[b.second];            });       if (func[target_split].first - initial[func[target_split].second] >=           buck * (target_split - fst + 1)) {         dr = mid;         for (long long i = fst; i <= lst; i++) {           tmp_func[i] = func[i];         }       } else {         st = mid;       }     }     for (long long i = fst; i <= lst; i++) {       func[i] = tmp_func[i];     }     for (int i = target_split + 1; i <= lst; i++) {       initial[func[i].second] += buck * (target_split - fst + 1);     }     solve(fst, target_split, l, dr, buck);     solve(target_split + 1, lst, dr, r, buck);   }   int main() {     long long n;     long long l;     scanf( %lld %lld , &n, &l);     for (long long i = 1; i <= n; i++) {       func[i] = {0, i};       memo[{i, 0}] = 0;       memo[{i, 1e18}] = l;     }     solve(1, n, 0, 1e18, l / n);     cout <<  !  << endl;     for (long long i = 1; i <= n; i++) {       cout << ans[i].first <<     << ans[i].second << endl;     }     cerr <<  total queries   << cnt_queries << endl;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   typedef long long ll;   const int maxn = 1e6+5;   const int mod = 1e9+7;   const int inf = 0x3f3f3f3f;   #define for1(i,n) for(int i=1;i<=n;i++)   #define forn(i,n) for(int i=0;i<n;i++)      int a[maxn], n,m;   ll add[maxn];   vector<ll> ans;   void dfs(int L, int R){       int mid = (a[L]+a[R])>>1;       int idx = upper_bound(a+L,a+R+1,mid) - a;           //printf( [%d %d], [%d %d] n ,L,idx-1,idx,R);       //printf( [%d %d] n ,L,R);       ans.push_back(add[R]-add[L-1]);       //ans.push_back(add[R]-add[idx-1]);       if(idx>R) return;       if(L<=idx-1) dfs(L,idx-1);        if(idx<=R) dfs(idx,R);   }   int main(){       int t; scanf( %d ,&t);while(t--){           ans.clear();                scanf( %d%d ,&n,&m);           for1(i,n){               scanf( %d ,&a[i]);           }           sort(a+1,a+n+1);           for1(i,n) add[i] = add[i-1] + a[i];           //int L=1, R=n;           dfs(1,n);           //for(auto v : ans) cout << v << endl;           sort(ans.begin(),ans.end());           for1(i,m){               int q; scanf( %d ,&q);               if(binary_search(ans.begin(),ans.end(),q)) printf( Yes n );               else printf( No n );           }       }   }   /*2   5 5   1 2 3 4 5   1   8   9   12   6   5 5   3 1 3 1 3   1   2   3   9   11   */
#include <bits/stdc++.h>   using namespace std;   int n;   string s1, s2;   int main() {     cin >> n;     if (n == 1) {       cout <<  a na nb nb ;       return 0;     }     s1 = s2 =   ;     int m = n;     while (m > 1) {       if (s1 ==    || s1[s1.size() - 1] ==  b )         s1 +=  aa ;       else         s1 +=  bb ;       m -= 2;     }     if (m) s1 +=  e ;     cout << s1 << endl;     for (char i : s1) {       if (i ==  a )         cout <<  c ;       else if (i ==  b )         cout <<  d ;       else         cout <<  e ;     }     s2 =  z ;     n -= 1;     cout << endl;     while (n > 1) {       if (s2[s2.size() - 1] ==  z  || s2[s2.size() - 1] ==  x )         s2 +=  yy ;       else         s2 +=  xx ;       n -= 2;     }     if (n) s2 +=  k ;     cout << s2 << endl;     for (char i : s2) {       if (i ==  x )         cout <<  y ;       else if (i ==  y )         cout <<  x ;       else         cout << i;     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int s[1005];   int us[1005];   int t[1005];   int ut[1005];   int a[1005];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &s[i]);       us[s[i]]++;     }     for (int i = 0; i < n; i++) {       scanf( %d , &t[i]);       ut[t[i]]++;     }     int t1 = 0;     for (int i = 1; i <= n; i++) {       if (us[i] == 0) {         t1 = i;       }     }     vector<int> dif;     for (int i = 0; i < n; i++) {       a[i] = s[i];       if (us[s[i]] == 2) {         dif.push_back(i);       }     }     int tmp;     for (auto i : dif) {       tmp = a[i];       a[i] = t1;       int cnt = 0;       for (int j = 0; j < n; j++) {         if (a[j] != t[j]) cnt++;       }       if (cnt == 1) {         for (int j = 0; j < n; j++) {           printf( %d%c , a[j], (   n [j == n - 1]));         }         return 0;       }       a[i] = tmp;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   const int INF = 0x3f3f3f3f;   const int iinf = 1 << 30;   const long long linf = 2e18;   const int MOD = 1000000007;   void print(int x) {     cout << x << endl;     exit(0);   }   void PRINT(string x) {     cout << x << endl;     exit(0);   }   void douout(double x) { printf( %lf n , x + 0.0000000001); }   char s[N], t[N];   int nxt[N], val[N], f[N], sum[N];   int n, m;   signed main() {     scanf( %s , s + 1);     scanf( %s , t + 1);     n = strlen(s + 1);     m = strlen(t + 1);     nxt[1] = 0;     for (int i = 2, j = 0; i <= m; i++) {       while (j && t[i] != t[j + 1]) j = nxt[j];       if (t[i] == t[j + 1]) j++;       nxt[i] = j;     }     for (int i = 1, j = 0; i <= n; i++) {       while (j && s[i] != t[j + 1]) j = nxt[j];       if (s[i] == t[j + 1]) j++;       if (j == m) {         val[i] = i - m + 1;         j = nxt[j];       }     }     for (int i = 1; i <= n; i++)       if (!val[i]) val[i] = val[i - 1];     for (int i = 1; i <= n; i++) {       f[i] = f[i - 1];       if (val[i]) f[i] = (f[i] + sum[val[i] - 1] + val[i]) % MOD;       sum[i] = (sum[i] + sum[i - 1] + f[i]) % MOD;     }     printf( %d n , f[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, n, m, a[15], ans, b[10010];   char s[15][10010];   struct P {     int val, id;   } p[10010];   inline bool cmp(P x, P y) { return x.val < y.val; }   int main() {     scanf( %d , &t);     while (t--) {       scanf( %d%d , &n, &m);       ans = 0;       for (int i = 0; i < n; i++) scanf( %d , &a[i]);       for (int i = 0; i < n; i++) scanf( %s , s[i] + 1);       for (int i = 0; i < 1 << n; i++) {         int sum = 0;         for (int j = 1; j <= m; j++) {           p[j].val = 0;           p[j].id = j;         }         for (int j = 0; j < n; j++) {           if (i & (1 << j)) {             sum += a[j];             for (int k = 1; k <= m; k++)               if (s[j][k] ==  1 ) p[k].val--;           } else {             sum -= a[j];             for (int k = 1; k <= m; k++)               if (s[j][k] ==  1 ) p[k].val++;           }         }         sort(p + 1, p + m + 1, cmp);         for (int j = 1; j <= m; j++) sum += j * p[j].val;         if (sum >= ans) {           ans = sum;           for (int j = 1; j <= m; j++) b[p[j].id] = j;         }       }       for (int i = 1; i <= m; i++) printf( %d  , b[i]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int W, H;     while (cin >> W >> H) {       vector<pair<int, int>> pset;       for (int dy = 0; dy < (int)(2); ++dy)         for (int dx = 0; dx < (int)(2); ++dx) {           if (dx <= W && dy <= H) pset.push_back(pair<int, int>(dx, dy));         }       for (int dy = 0; dy < (int)(2); ++dy)         for (int dx = 0; dx < (int)(2); ++dx) {           if (dx <= W && H - dy >= 0) pset.push_back(pair<int, int>(dx, H - dy));         }       for (int dy = 0; dy < (int)(2); ++dy)         for (int dx = 0; dx < (int)(2); ++dx) {           if (W - dx >= 0 && dy <= H) pset.push_back(pair<int, int>(W - dx, dy));         }       for (int dy = 0; dy < (int)(2); ++dy)         for (int dx = 0; dx < (int)(2); ++dx) {           if (W - dx >= 0 && H - dy >= 0)             pset.push_back(pair<int, int>(W - dx, H - dy));         }       sort(pset.begin(), pset.end());       pset.erase(unique(pset.begin(), pset.end()), pset.end());       vector<pair<double, vector<pair<int, int>>>> ans;       for (int comb = (1 << 4) - 1; comb < (1 << pset.size());) {         vector<pair<int, int>> ps;         for (int i = 0; i < (int)(pset.size()); ++i)           if (comb >> i & 1) {             ps.push_back(pset[i]);           }         sort(ps.begin(), ps.end());         do {           double len = 0;           for (int i = 0; i < (int)(3); ++i) {             len += hypot(ps[i].first - ps[i + 1].first,                          ps[i].second - ps[i + 1].second);           }           ans.push_back(make_pair(len, ps));         } while (next_permutation(ps.begin(), ps.end()));         int x = comb & -comb, y = comb + x;         comb = ((comb & ~y) / x >> 1) | y;       }       sort(ans.begin(), ans.end());       vector<pair<int, int>> ps = ans.back().second;       for (int i = 0; i < (int)(4); ++i) {         cout << ps[i].first <<     << ps[i].second << endl;       }     }     return 0;   }