malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2000 + 10;   char s[maxn][maxn];   int deg[maxn][maxn];   int dx[] = {1, 0, -1, 0};   int dy[] = {0, 1, 0, -1};   char fillchar[2][5] = { ^<v> ,  v>^< };   inline int caldeg(int i, int j) {     return (int)(s[i - 1][j] ==  . ) + (int)(s[i + 1][j] ==  . ) +            (int)(s[i][j - 1] ==  . ) + (int)(s[i][j + 1] ==  . );   }   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; ++i) {       scanf( %s , s[i] + 1);     }     queue<pair<int, int> > Q;     int cnt = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (s[i][j] ==  . ) {           deg[i][j] = caldeg(i, j);           cnt++;           if (deg[i][j] == 1) Q.push(make_pair(i, j));         }       }     }     if (cnt & 1) {       puts( Not unique );       return 0;     }     while (!Q.empty()) {       pair<int, int> cur = Q.front();       Q.pop();       int x = cur.first;       int y = cur.second;       if (s[x][y] ==  . ) {         int i, nx, ny;         for (i = 0; i < 4; ++i) {           nx = x + dx[i];           ny = y + dy[i];           if (s[nx][ny] ==  . ) break;         }         if (i == 4) {           puts( Not unique );           return 0;         }         s[x][y] = fillchar[0][i];         s[nx][ny] = fillchar[1][i];         deg[x][y] = deg[nx][ny] = 0;         cnt -= 2;         for (i = 0; i < 4; ++i) {           int nnx = nx + dx[i];           int nny = ny + dy[i];           if (s[nnx][nny] ==  . ) {             deg[nnx][nny]--;             if (deg[nnx][nny] == 1) Q.push(make_pair(nnx, nny));           }         }       }     }     if (cnt != 0) {       puts( Not unique );     } else {       for (int i = 1; i <= n; ++i) {         printf( %s n , s[i] + 1);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct prik {     int hair, mood, ind;   };   bool comp1(prik a, prik b) {     if (a.hair != b.hair)       return a.hair > b.hair;     else       return a.mood > b.mood;   }   bool comp2(prik a, prik b) {     if (a.mood != b.mood)       return a.mood < b.mood;     else       return a.hair > b.hair;   }   prik mp(int a, int b, int c) {     prik q;     q.hair = a;     q.mood = b;     q.ind = c;     return q;   }   prik a[110000], b[110000], c[110000];   int main() {     bool used[110000] = {0};     int n, t, d, m, k, ii[110000];     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       cin >> t >> d;       a[i] = mp(t, d, i);       b[i] = a[i];       c[i] = a[i];     }     sort(b, b + n, comp1);     sort(c, c + n, comp2);     for (int i = 0; i < n; i++) {       ii[c[i].ind] = i;     }     int mm = INT_MAX;     for (int i = 0, cn = 0; cn < k; i++) {       if (ii[b[i].ind] >= m - k) {         cn++;         cout << b[i].ind + 1 <<    ;         if (ii[b[i].ind] < mm) {           mm = ii[b[i].ind];         }       }     }     for (int i = mm - 1; i >= mm - m + k; i--) {       cout << c[i].ind + 1 <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int gcd(long long a, long long b, long long& x, long long& y) {     if (b == 0) {       x = 1;       y = 0;       return a;     }     long long x1, y1;     long long d = gcd(b, a % b, x1, y1);     x = y1;     y = x1 - y1 * (a / b);     return d;   }   int main() {     long long a, b, c, x0, y0;     cin >> a >> b >> c;     c = (-1) * c;     long long g = gcd(a, b, x0, y0);     if (c % g != 0) {       cout <<  -1 ;     } else {       x0 *= c / g;       y0 *= c / g;       cout << x0 <<     << y0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int OO = 0x3f3f3f3f, N = 1e5 + 5, mod = 1e9 + 9;   int n, k, indx[10], ans = OO;   char arr[10][10];   int num(int r) {     int ret = 0;     for (int i = 0; i < k; ++i) {       ret = ret * 10 + (arr[r][indx[i]] -  0 );     }     return ret;   }   int main() {     cin >> n >> k;     for (int i = 0; i < k; ++i) indx[i] = i;     for (int i = 0; i < n; ++i) scanf( %s , arr[i]);     do {       int mn = OO, mx = 0;       for (int i = 0; i < n; ++i) {         mn = min(mn, num(i));         mx = max(mx, num(i));       }       ans = min(ans, mx - mn);     } while (next_permutation(indx, indx + k));     cout << ans;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   using ll = long long;   const char E =   n ;   const int N = 1005;   const ll mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, k, x, dp[2][1024] = {0};     cin >> n >> k >> x;     for (int i = 1; i <= n; i++) {       int y;       cin >> y;       dp[1][y]++;     }     for (int i = 1; i <= k; i++) {       int used = 0;       for (int j = 0; j <= 1023; j++) {         int bit, nbit;         bit = i & 1, nbit = i & 1 ^ 1;         if (!(dp[bit][j] & 1)) {           dp[nbit][j] += (dp[bit][j] >> 1);           dp[nbit][j ^ x] += (dp[bit][j] >> 1);         } else if (dp[bit][j]) {           dp[nbit][j] += (dp[bit][j] >> 1) + (used & 1);           dp[nbit][j ^ x] += (dp[bit][j] >> 1) + (used & 1 ^ 1);         }         used += dp[bit][j];         dp[bit][j] = 0;       }     }     int mx = 0, mn = 1024;     for (int i = 0; i <= 1023; i++) {       if (dp[k & 1 ^ 1][i]) {         mx = max(mx, i);         mn = min(mn, i);       }     }     cout << mx <<     << mn << E;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x7f7f7f7f;   void setup() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout.precision(15);   }   struct seg_tree {     struct node {       int val;       node(int _val = 0x7f7f7f7f) { val = _val; }       node operator+(const node &y) { return {min(val, y.val)}; }     };     int S;     vector<node> arr;     seg_tree(int _S) {       S = _S;       arr = vector<node>(2 * S);     }     void upd(int i, node v) {       i += S + 1;       arr[i] = v;       while (i > 1) {         i /= 2;         arr[i] = arr[2 * i] + arr[2 * i + 1];       }     }     node query(int i, int j) {       node res;       for (i += S + 1, j += S + 1; i <= j; i /= 2, j /= 2) {         if ((i & 1) == 1) res = res + arr[i++];         if ((j & 1) == 0) res = res + arr[j--];       }       return res;     }   };   int find(seg_tree &seg, int i, int k) {     int lo = 0, hi = i;     int ans = 0;     while (lo <= hi) {       int mi = (lo + hi) / 2;       int lv = seg.query(mi, i).val;       if (lv <= k) {         ans = mi;         lo = mi + 1;       } else         hi = mi - 1;     }     return ans;   }   int look(vector<int> &all, int v) {     return lower_bound(all.begin(), all.end(), v) - all.begin();   }   const int MAXQ = 200005;   int N, Q;   seg_tree rows(1 << 19), cols(1 << 19);   int L[MAXQ], LC[MAXQ];   int R[MAXQ], RC[MAXQ];   char T[MAXQ];   vector<bool> ater, atec;   int main() {     setup();     cin >> N >> Q;     rows.upd(0, 0);     cols.upd(0, 0);     vector<int> all;     all.push_back(0);     for (int i = 0; i < Q; i++) {       cin >> L[i] >> R[i] >> T[i];       all.push_back(L[i]);       all.push_back(R[i]);     }     sort(all.begin(), all.end());     all.resize(unique(all.begin(), all.end()) - all.begin());     ater.resize(all.size());     atec.resize(all.size());     for (int i = 0; i < Q; i++) {       int LC = look(all, L[i]);       int RC = look(all, R[i]);       if (T[i] ==  U ) {         if (atec[LC] || ater[RC]) {           cout << 0 <<   n ;           continue;         }         int b = find(rows, RC, LC);         cols.upd(LC, b);         cout << all[RC] - all[b] <<   n ;         atec[LC] = true;       } else {         if (ater[RC] || atec[LC]) {           cout << 0 <<   n ;           continue;         }         int b = find(cols, LC, RC);         rows.upd(RC, b);         cout << all[LC] - all[b] <<   n ;         ater[RC] = true;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int N, M;   double K;   map<string, int> skill;   int main() {     cin >> N >> M >> K;     for (int i = 0; i < N; i++) {       string name;       int exp;       cin >> name >> exp;       if (exp * K + 0.000001 >= 100) skill[name] = exp * K + 0.000001;     }     for (int i = 0; i < M; i++) {       string name;       cin >> name;       skill[name] = max(skill[name], 0);     }     cout << skill.size() << endl;     for (map<string, int>::iterator it = skill.begin(); it != skill.end(); it++)       cout << it->first <<     << it->second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, ans[200055], odd, even, cost, ne, no;   pair<int, int> a[200055];   bool need[200055];   map<int, int> M;   int next_even() {     while (M[ne] && ne > 0) ne -= 2;     if (ne == 0)       return -1;     else       return ne;   }   int next_odd() {     while (M[no] && no > 0) no -= 2;     return no;   }   int main() {     scanf( %d%d , &n, &m);     ne = no = m;     if (ne % 2 != 0) ne--;     if (no % 2 != 1) no--;     for (int i = 0; i < n; i++) scanf( %d , &a[i].first);     for (int i = 0; i < n; i++) ans[i] = a[i].first;     for (int i = 0; i < n; i++) a[i].second = i;     sort(a, a + n);     for (int i = 0; i < n; i++) {       if (i == 0 || a[i].first != a[i - 1].first) {         if (a[i].first % 2)           odd++;         else           even++;       }       if (i > 0 && a[i].first == a[i - 1].first) need[i] = 1;     }     if (even > n / 2) {       for (int i = 0; i < n; i++) {         if (even == n / 2) break;         if (need[i] == 0 && a[i].first % 2 == 0) {           need[i] = 1;           even--;         }       }     }     if (odd > n / 2) {       for (int i = 0; i < n; i++) {         if (odd == n / 2) break;         if (need[i] == 0 && a[i].first % 2 == 1) {           need[i] = 1;           odd--;         }       }     }     for (int i = 0; i < n; i++)       if (!need[i]) M[a[i].first] = 1;     for (int i = 0; i < n; i++)       if (need[i]) {         cost++;         int next = -1;         if (even < n / 2) {           next = next_even();           even++;         } else {           next = next_odd();           odd++;         }         if (next == -1) return 0 * printf( -1 n );         ans[a[i].second] = next;         M[next] = 1;       }     printf( %d n , cost);     for (int i = 0; i < n; i++) printf( %d%c , ans[i], (i == n - 1) ?   n  :    );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 605;   int dp[N][N];   int l[N], r[N];   string res;   void fill(int i, int j, int a, int b) {     int k = j - i;     if (i > j || a > b) return;     if (l[i] <= 2 * k + 1 && 2 * k + 1 <= r[i] && (i == j || dp[i + 1][j])) {       res[a] =  ( , res[b] =  ) ;       fill(i + 1, j, a + 1, b - 1);     } else {       for (int k = i; k < j; ++k)         if (dp[i][k] && dp[k + 1][j]) {           int diff = k - i + 1;           fill(i, k, a, a + 2 * diff - 1);           fill(k + 1, j, a + 2 * diff, b);           break;         }     }   }   int main() {     std::ios::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> l[i] >> r[i];     }     memset(dp, 0, sizeof(dp));     for (int i = n; i >= 1; --i) {       for (int j = i; j <= n; ++j) {         int k = j - i;         if (l[i] <= 2 * k + 1 && 2 * k + 1 <= r[i] && (i == j || dp[i + 1][j]))           dp[i][j] = 1;         for (int k = i; k < j; ++k) dp[i][j] |= (dp[i][k] && dp[k + 1][j]);       }     }     if (dp[1][n]) {       res.resize(2 * n,  # );       fill(1, n, 0, 2 * n - 1);       cout << res << endl;     } else {       cout <<  IMPOSSIBLE  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 18;   int n, cnt[3 * N];   unsigned long long res[3 * N], sum[3 * N];   vector<int> a;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     long long fuk = 1LL * n * (n - 1);     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       cnt[x]++;       a.push_back(x);     }     sort(a.begin(), a.end());     a.resize(unique(a.begin(), a.end()) - a.begin());     for (int i = 0; i < a.size(); i++) {       int k = 1;       while (1LL * a[i] * k < 3 * N) {         int z = cnt[k];         if (k == a[i]) z--;         res[a[i] * k] += 1LL * cnt[a[i]] * z;         k++;       }     }     for (int i = 1; i < 3 * N; i++) sum[i] = sum[i - 1] + res[i];     int m;     cin >> m;     while (m--) {       int p;       cin >> p;       long long resu = fuk - sum[p - 1];       printf( %I64d n , resu);     }   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     long long g = 0;     for (int i = 0; i < n; i++) {       long long d;       cin >> d;       g = gcd(g, d);     }     long long res = 0;     for (long long i = 1; i * 1ll * i <= g; i++) {       if (g % i == 0) {         res++;         if (i != (g / i)) {           res++;         }       }     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   int aa[MAXN];   int nxt[MAXN];   int nnxt[MAXN];   int step[MAXN];   int group[MAXN];   int ll[MAXN];   int rr[MAXN];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m;     memset(ll, 0x3f, sizeof ll);     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> aa[i];     int sqrtn = sqrt(n);     for (int i = 1; i <= n; i++)       group[i] = i / sqrtn, ll[group[i]] = min(ll[group[i]], i), rr[group[i]] = i;     auto getnxt = [&](int i) {       nxt[i] = i + aa[i];       if (nxt[i] <= n && group[nxt[i]] == group[i]) {         step[i] = step[nxt[i]] + 1;         nnxt[i] = nnxt[nxt[i]];         nxt[i] = nxt[nxt[i]];       } else {         step[i] = 1;         nnxt[i] = i;       }     };     for (int i = n; i >= 1; i--) {       getnxt(i);     }     while (m--) {       int op;       cin >> op;       if (op == 0) {         int a, b;         cin >> a >> b;         aa[a] = b;         for (int i = rr[group[a]]; i >= ll[group[a]]; i--) {           getnxt(i);         }       } else {         int a;         cin >> a;         int ans = 0;         while (nxt[a] <= n) {           ans += step[a];           a = nxt[a];         }         ans += step[a];         cout << nnxt[a] <<     << ans <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     string a, b;     cin >> a >> b;     if (a.size() == b.size()) {       int ca = 0, cb = 0;       for (int i = 0; i < a.size(); i++) {         ca += a[i] ==  1 ;         cb += b[i] ==  1 ;       }       if (!ca && cb || ca && !cb)         cout <<  NO ;       else         cout <<  YES ;     } else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T id(T b) {     return b;   };   template <class It>   bool all(It f, It l) {     return std::all_of(f, l, id<bool>);   }   template <class It>   bool any(It f, It l) {     return std::any_of(f, l, id<bool>);   }   template <typename T>   void chmax(T &x, T y) {     if (x < y) x = y;   }   template <typename T>   void chmin(T &x, T y) {     if (x > y) x = y;   }   const int MAX_N = 200000;   long long h;   int n;   long long d[MAX_N];   int main() {     cin >> h >> n;     for (int i = 0; i < int(n); i++) cin >> d[i];     long long max_d = 0;     long long g = h;     for (int i = 0; i < n; i++) {       g += d[i];       if (g <= 0) {         cout << (i + 1) <<   n ;         return 0;       }       chmax(max_d, h - g);     }     if (g >= h) {       cout <<  -1 n ;       return 0;     }     long long c = (h - max_d) / (h - g);     if ((h - max_d) % (h - g) != 0) c++;     long long m = c * n;     h -= (h - g) * c;     for (int i = 0; i < n && h > 0; i++) {       h += d[i];       m++;     }     cout << m <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       set<long long> s;       for (long long i = 0; i < n; i++) {         long long x;         cin >> x;         s.insert(x);       }       vector<long long> vec(s.begin(), s.end());       sort(vec.begin(), vec.end());       reverse(vec.begin(), vec.end());       long long res = 0;       for (long long i = 0; i < 3; i++) {         vector<long long> chosen;         for (long long j = i; j < s.size(); j++) {           if (!chosen.empty() && chosen.size() == 3) break;           bool flag = false;           for (long long x : chosen) {             if (x % vec[j] == 0) {               flag = true;               break;             }           }           if (!flag) chosen.push_back(vec[j]);         }         long long sum = 0;         for (long long x : chosen) sum += x;         res = max(res, sum);       }       cout << res <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }   const int InF = 1 << 29;   inline int two(int n) { return 1 << n; }   inline int test(int n, int b) { return (n >> b) & 1; }   inline void set_bit(int& n, int b) { n |= two(b); }   inline void unset_bit(int& n, int b) { n &= ~two(b); }   inline int last_bit(int n) { return n & (-n); }   inline int ones(int n) {     int res = 0;     while (n && ++res) n -= n & (-n);     return res;   }   template <class T>   void chmax(T& a, const T& b) {     a = max(a, b);   }   template <class T>   void chmin(T& a, const T& b) {     a = min(a, b);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long a[n];     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     long long x = 0, y;     for (int i = 1; i <= n; i++) {       x++;       y = a[i];       for (int j = i; j <= y; j++) y = max(y, a[j]);       i = y;     }     cout << x << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100 * 1000 + 1000;   int arr[MAXN];   vector<int> pt[MAXN];   int mrk[MAXN];   int32_t main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> arr[i];     for (int i = 0; i < n; i++) pt[arr[i]].push_back(i);     int cnt = n;     int cnt_2 = 1;     while (cnt) {       if (pt[1].size() == 0) {         cout << -1 << endl;         return 0;       }       int pt_2 = 1;       while (pt[pt_2].size() > 0) {         mrk[pt[pt_2][pt[pt_2].size() - 1]] = cnt_2;         pt[pt_2].pop_back();         cnt--;         pt_2++;       }       cnt_2++;     }     cout << *max_element(mrk, mrk + n) << endl;     for (int i = 0; i < n; i++) cout << mrk[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e6 + 3;   long long int x[maxn], y[maxn];   long long int w[maxn];   int ct[maxn];   vector<int> v[maxn];   int ans[maxn];   int done_per[maxn];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; ++i) {       cin >> w[i];     }     memset(ct, 0, sizeof(ct));     for (int i = 0; i < m; ++i) {       cin >> x[i] >> y[i];       ct[x[i] - 1]++;       ct[y[i] - 1]++;       x[i]--;       y[i]--;       v[x[i]].push_back(i);       v[y[i]].push_back(i);     }     memset(done_per, 0, sizeof(done_per));     vector<int> in;     int last = m - 1;     for (int i = 0; i < n; i++) {       if (ct[i] <= w[i]) {         in.push_back(i);       }     }     if (in.size() == 0) {       cout <<  DEAD             <<   n ;       exit(0);     }     while (1) {       vector<int> in1;       for (int j = 0; j < (int)in.size(); j++) {         int t1 = in[j];         for (int i = 0; i < (int)v[t1].size(); i++) {           if (!done_per[v[t1][i]]) {             ans[last--] = v[t1][i];             done_per[v[t1][i]] = 1;             int temp = v[t1][i];             if (x[temp] != t1) {               ct[x[temp]]--;               if (ct[x[temp]] <= w[x[temp]]) in1.push_back(x[temp]);             } else {               ct[y[temp]]--;               if (ct[y[temp]] <= w[y[temp]]) in1.push_back(y[temp]);             }           }         }       }       if (last == -1) break;       if (in1.size() == 0) {         cout <<  DEAD               <<   n ;         exit(0);       }       in.clear();       for (int t4 : in1) in.push_back(t4);     }     cout <<  ALIVE           <<   n ;     for (int i = 0; i < m; i++) {       cout << ans[i] + 1 <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   int n, m, c[N], d[N], w[N];   bool val[N];   long long ans;   struct node {     int val, id;     bool operator<(const node A) const { return val > A.val; }   };   priority_queue<node> Q;   inline int IN() {     char c;     int flag = 1, k = 0;     for (c = getchar(); c <  0  || c >  9 ; c = getchar())       if (c ==  - ) flag = -1;     for (;  0  <= c && c <=  9 ; c = getchar()) k = k * 10 + c -  0 ;     return k * flag;   }   int main() {     n = IN();     m = IN();     for (int i = 1; i <= n; ++i) c[i] = IN();     for (int i = 1; i <= n; ++i) w[i] = IN();     for (int i = 1; i <= n; ++i) {       d[i] = c[i] / 100;       int tmp = c[i] % 100;       if (tmp == 0) continue;       int res = w[i] * (100 - tmp);       Q.push((node){res, i});       m -= tmp;       if (m < 0) {         m += 100;         node now = Q.top();         Q.pop();         ans += now.val;         val[now.id] = 1;       }     }     cout << ans << endl;     for (int i = 1; i <= n; ++i) {       cout << c[i] / 100 + val[i] <<    ;       if (val[i])         cout << 0 << endl;       else         cout << c[i] % 100 << endl;     }     return 0;   }
#include<cstdio>   #include<algorithm>   #include<iostream>   #include<cstring>   #define ll long long   #define mod (ll)(1e9+7)   using namespace std;       ll t,n,m,a[2000005];   ll ti,yi;   double xi;       int main()   {    //freopen( 1.in , r ,stdin);    cin>>n>>m;    for (int i=1; i<=n; i++)    {     cin>>ti>>xi>>yi;          for (int k=m; k>=0; k--)     if (a[k] || k==0)     {      ll x=(ll)(k);      for (int j=1; j<=yi; j++)      {       if (ti==2 && x==0) break;        if (ti==1) x= (x*1e5 + xi + 1e5 -1 ) / 1e5 ;         else x= (x*xi + 1e5 -1) / 1e5;       //x=ceil(x);       if (x>m || a[(int)x]) break;       else        a[(int)x]=i;      }      x/=(1e5);     }    }    for (int i=1; i<=m; i++)     printf( %lld  , a[i] ? a[i] : -1);    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int v[300100], dp[300100], deq[300100], n, m, l, ql, qr, i;   inline bool check(int v) {     l = 1, ql = 0, qr = 0;     dp[0] = 1;     for (i = 1; i <= n; ++i) {       dp[i] = 0;       if (i - m >= 0 && dp[i - m]) deq[qr++] = i - m;       while (::v[i] - ::v[l] > v) l++;       while (deq[ql] + 1 < l && ql < qr) ql++;       if (ql < qr) dp[i] = 1;     }     return dp[n];   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (i = 1; i <= n; ++i) cin >> v[i];     sort(v + 1, v + n + 1);     int l = 0, r = v[n] - v[1], mid;     while (l < r) {       mid = (l + r) >> 1;       if (check(mid))         r = mid - 1;       else         l = mid + 1;     }     if (check(l))       cout << l;     else       cout << l + 1;   }