malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>      using namespace std;      int t, n, m;      int main() {       ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);          cin >> t;       while(t--) {           cin >> n;           vector<int> pancake(n, 0);           for(int i = 0; i < n; i++) {               cin >> m;               if(!m)                   continue;               if(i - (m - 1) >= 0)                   pancake[i - (m - 1)] = max(pancake[i - (m - 1)], m);               else                   pancake[0] = max(pancake[0], i + 1);           }           int prev = 0;           for(int i = 0; i < n; i++) {               if(prev)                   prev--;               prev = max(prev, pancake[i]);               cout << (prev ? 1 : 0) <<    ;           }           cout <<   n ;       }          return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10010;   const double eps = 1e-12;   struct point {     int x, y, op, id;     int u, v;     long long operator*(const point &r) const {       return (long long)u * r.v - (long long)v * r.u;     }   } a[N << 1], s;   int n;   int ans[N];   inline bool cmp(point x, point y) { return x * y > 0; }   inline void solve(int l, int r) {     if (l > r) return;     for (int k = l; k <= r; k++)       if (a[k].y < a[l].y || (a[k].y == a[l].y && a[k].x < a[l].x))         swap(a[l], a[k]);     for (int k = l; k <= r; k++) {       a[k].u = a[k].x - a[l].x;       a[k].v = a[k].y - a[l].y;     }     sort(a + l + 1, a + r + 1, cmp);     int x = 0, y = 0, mid = 0;     for (int k = l; k <= r; k++) {       if (a[k].op == 0)         x++;       else         y++;       if (x == y && a[k].op != a[l].op &&           max(k - l - 1, r - k) < max(mid - l - 1, r - mid))         mid = k;     }     if (a[l].op == 0)       ans[a[l].id] = a[mid].id;     else       ans[a[mid].id] = a[l].id;     solve(l + 1, mid - 1), solve(mid + 1, r);     return;   }   int main() {     scanf( %d , &n);     for (int k = 1; k <= n; k++) {       scanf( %d%d , &a[k].x, &a[k].y);       a[k].op = 0;       a[k].id = k;     }     for (int k = 1; k <= n; k++) {       scanf( %d%d , &a[k + n].x, &a[k + n].y);       a[k + n].op = 1;       a[k + n].id = k;     }     solve(1, 2 * n);     for (int k = 1; k <= n; k++) printf( %d n , ans[k]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     int a[n], b[n];     int r1 = 0, r2 = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       r1 |= a[i];     }     for (int i = 0; i < n; i++) {       cin >> a[i];       r2 |= a[i];     }     cout << r1 + r2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e15;   const int maxn = 5000 + 5;   long long cnt[maxn + 10];   long long p[maxn + 10][maxn + 10];   long long pd[maxn + 10];   int main() {     memset(cnt, 0, sizeof(cnt));     int n;     scanf( %d , &n);     for (int i = (1); i <= (n); i++) {       int u;       scanf( %d , &u);       cnt[u]++;     }     for (int i = (2); i <= (maxn); i++) {       for (int j = (1); j <= (i); j++) p[i][j] += p[i - 1][j];       int mm = sqrt(i), tem = i;       for (int j = (2); j <= (mm); j++) {         while (tem % j == 0) {           p[i][j]++;           tem /= j;         }       }       if (tem > 1) p[i][tem]++;     }     long long ans = 0, cur = 0;     for (int i = (1); i <= (maxn); i++) {       if (!cnt[i]) {         pd[i] = 1;         continue;       }       for (int j = (1); j <= (i); j++) {         ans += p[i][j] * cnt[i];         cur += p[i][j] * cnt[i];         if (p[i][j]) pd[i] = j;       }     }     while (*max_element(pd, pd + maxn + 10) > 1) {       long long f[maxn + 10];       memset(f, 0, sizeof(f));       for (int i = (1); i <= (maxn); i++) f[pd[i]] += cnt[i];       long long besp = max_element(f, f + maxn + 10) - f;       long long besg = f[besp];       if (besg * 2 <= n || besp == 1) break;       cur += n - 2 * besg;       ans = min(ans, cur);       for (int i = (1); i <= (maxn); i++) {         if (pd[i] != besp) pd[i] = 1;         if (pd[i] == 1) continue;         p[i][besp] -= 1;         while (pd[i] > 1 && p[i][pd[i]] == 0) pd[i]--;       }     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char buf[1 << 20], *p1, *p2;   template <typename T>   inline void read(T &t) {     register int v =         (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)              ? EOF              : *p1++);     T f = 1;     t = 0;     while (!isdigit(v)) {       if (v ==  - ) f = -1;       v = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)                ? EOF                : *p1++);     }     while (isdigit(v)) {       t = t * 10 + v - 48;       v = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2)                ? EOF                : *p1++);     }     t *= f;   }   template <typename T, typename... Args>   inline void read(T &t, Args &...args) {     read(t);     read(args...);   }   const int N = 100001;   const int M = 200010;   template <typename T>   inline T min(T x, T y) {     return x < y ? x : y;   }   template <typename T>   inline T max(T x, T y) {     return x > y ? x : y;   }   int to[M], hd[N], nxt[M], tot;   inline void add(int u, int v) {     to[++tot] = v;     nxt[tot] = hd[u];     hd[u] = tot;   }   inline void addedge(int u, int v) { add(u, v), add(v, u); }   long long son[N], siz[N], cnt[N], col[N], sum, Son, maxx, n, ans[N];   void dfs1(int u, int f) {     siz[u] = 1;     son[u] = 0;     for (int i = hd[u]; i; i = nxt[i]) {       int v = to[i];       if (v != f) {         dfs1(v, u);         siz[u] += siz[v];         if (siz[v] > siz[son[u]]) {           son[u] = v;         }       }     }   }   void add(int u, int f, int val) {     cnt[col[u]] += val;     if (cnt[col[u]] > maxx)       maxx = cnt[col[u]], sum = col[u];     else if (cnt[col[u]] == maxx)       sum += col[u];     for (int i = hd[u]; i; i = nxt[i]) {       int v = to[i];       if (v != f && v != Son) {         add(v, u, val);       }     }   }   void dfs2(int u, int f, int opt) {     for (int i = hd[u]; i; i = nxt[i]) {       int v = to[i];       if (v != f && v != son[u]) {         dfs2(v, u, 0);       }     }     if (son[u]) dfs2(son[u], u, 1), Son = son[u];     add(u, f, 1), Son = 0;     ans[u] = sum;     if (opt == 0) add(u, f, -1), sum = maxx = 0;   }   signed main() {     read(n);     for (int i = 1; i <= n; ++i) read(col[i]);     for (int i = 1; i < n; ++i) {       int x, y;       read(x, y);       addedge(x, y);     }     dfs1(1, 0);     dfs2(1, 0, 0);     for (int i = 1; i <= n; ++i) printf( %lld  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double Pi = 3.141592653;   const long long mod = 1e6 + 3;   class Graph {     map<int, vector<int>> ma;       public:     void addedge(int n, int m) {       ma[n].push_back(m);       ma[m].push_back(n);     }   };   int main() {     long long n;     cin >> n;     long long a, b, c;     cin >> a >> b >> c;     long long plastic;     if (a <= b - c and n >= a) {       plastic = n / a;       cout << plastic;       return 0;     }     long long glass = (n - c) / (b - c);     if (glass < 0) glass = 0;     long long t = n - glass * (b - c);     glass += (t / a);     cout << glass;     return 0;   }
#include <bits/stdc++.h>   char *fs, *ft, buf[1 << 20];   inline int read() {     int x = 0, f = 1;     char ch =         (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))             ? 0             : *fs++;     ;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = (fs == ft &&             (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))                ? 0                : *fs++;       ;     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = (fs == ft &&             (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))                ? 0                : *fs++;       ;     }     return x * f;   }   using namespace std;   int a[1009];   int main() {     int t;     cin >> t;     while (t--) {       int n;       int z0 = 0, z1 = 0, bo = 0;       cin >> n;       cin >> a[1];       for (int i = 2; i <= n; i++) {         cin >> a[i];         if (a[i] < a[i - 1]) bo = 1;       }       for (int i = 1; i <= n; i++) {         int k;         cin >> k;         if (k == 0)           z0++;         else           z1++;       }       if (bo == 0) {         cout <<  Yes  << endl;         continue;       } else {         if (z0 == 0 || z1 == 0)           cout <<  No  << endl;         else           cout <<  Yes  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int RNG = 1000003;   const int RNGT = RNG * 4;   const int MOD1 = 1e9 + 7;   const int MOD2 = 1e9 + 87;   const double pi = 2 * acos(0.0);   inline int _Int() {     int x;     scanf( %d , &x);     return x;   }   inline long long _LLi() {     long long x;     scanf( %lld , &x);     return x;   }   void pruts() {     puts( -1 );     exit(EXIT_SUCCESS);   }   int dirX[] = {1, 0, -1, 0, 1, -1, 1, -1};   int dirY[] = {0, 1, 0, -1, 1, -1, -1, 1};   int rX[] = {1, 1, 2, 2, -1, -1, -2, -2};   int rY[] = {2, -2, 1, -1, 2, -2, 1, -1};   template <class T>   T tri_Area(T x1, T y1, T x2, T y2, T x3, T y3) {     return abs(x1 * (y2 - y3) - y1 * (x2 - x3) + (x2 * y3 - x3 * y2));   };   template <class T>   T Distance(T x1, T y1, T x2, T y2) {     return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));   };   template <class T>   T bigMod(T n, T p, T m) {     if (p == 0) return 1;     if (p & 1) return (n * bigMod(n, p - 1, m)) % m;     T x = bigMod(n, p / 2, m);     return (x * x) % m;   };   int Case;   int sset(int N, int pos) { return N = N | (1 << pos); }   bool check(int N, int pos) { return (bool)(N & (1 << pos)); }   int reset(int N, int pos) { return N = N & ~(1 << pos); }   int A[RNG], n, m, flag;   string str[600];   void Hunger() {     n = _Int();     m = _Int();     for (int i = 0; i < n; i++) cin >> str[i];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (str[i][j] ==  W ) {           int x = i + 1;           if (x < n && x >= 0) {             if (str[x][j] ==  . ) str[x][j] =  D ;             if (str[x][j] ==  S ) {               cout <<  No  << endl;               return;             }           }           x = i - 1;           if (x < n && x >= 0) {             if (str[x][j] ==  . ) str[x][j] =  D ;             if (str[x][j] ==  S ) {               cout <<  No  << endl;               return;             }           }           x = j + 1;           if (x < m && x >= 0) {             if (str[i][x] ==  . ) str[i][x] =  D ;             if (str[i][x] ==  S ) {               cout <<  No  << endl;               return;             }           }           x = j - 1;           if (x < m && x >= 0) {             if (str[i][x] ==  . ) str[i][x] =  D ;             if (str[i][x] ==  S ) {               cout <<  No  << endl;               return;             }           }         }       }     }     cout <<  Yes  << endl;     for (int i = 0; i < n; i++) cout << str[i] << endl;   }   int main() {     Hunger();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline int cMin(T& a, T b) {     return b < a ? a = b, 1 : 0;   }   template <class T>   inline int cMax(T& a, T b) {     return a < b ? a = b, 1 : 0;   }   template <class T>   inline string to_str(T v) {     ostringstream os;     os << v;     return os.str();   }   const double pi = acos(-1.0);   const double eps = 1e-9;   template <class T>   inline T isqr(T v) {     return v * v;   }   template <class T>   inline T iabs(T v) {     return v < 0 ? -v : v;   }   template <class T>   inline int isgn(T v) {     return iabs(v) <= eps ? 0 : (v < 0 ? -1 : 1);   }   template <typename T>   inline T next() {     static char buf[64];     scanf( %s , buf);     istringstream is(buf);     T v;     is >> v;     return v;   }   inline int nextInt() {     int v = 0;     scanf( %d , &v);     return v;   }   const int NN = 2 * 100000 + 16;   int N, A[NN], B[NN];   int idx[NN];   int main(int argc, char* argv[]) {     scanf( %d , &N);     for (int i = 0; i < (int)(N); ++i) scanf( %d , A + i);     for (int i = 0; i < (int)(N); ++i) scanf( %d , B + i);     for (int i = 0; i < (int)(N); ++i) idx[B[i]] = i;     int n = N;     for (int i = 1; i < N; ++i) {       if (idx[A[i - 1]] > idx[A[i]]) {         n = i;         break;       }     }     printf( %d n , N - n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxm = 1e6;   int pre[maxm * 2 + 10];   bool a[maxm + 10];   int N;   int main(int argc, const char* argv[]) {     scanf( %d , &N);     for (int i = 1; i <= N; i++) {       int val;       scanf( %d , &val);       pre[val] = -1;       a[val] = true;     }     int small = 0;     int big = small;     while (big <= maxm * 2) {       while (big <= maxm * 2 && pre[big] != -1) {         big++;       }       for (int i = small + 1; i <= big; i++) {         pre[i] = small;       }       small = big;     }     int ans = 0;     for (int i = 1; i <= maxm; i++) {       if (!a[i]) continue;       for (int j = i + i; j <= maxm * 2; j += i) {         ans = max(ans, pre[j] % i);       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> e[100500];   bool visited[100500];   int main() {     int n, m;     scanf( %d%d , &n, &m);     if (m != n - 1) {       cout <<  no  << endl;       return 0;     }     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d%d , &u, &v);       u--;       v--;       e[u].push_back(v);       e[v].push_back(u);     }     visited[0] = true;     list<int> sp;     sp.push_back(0);     while (sp.begin() != sp.end()) {       int u = sp.front();       sp.pop_front();       for (int i = 0; i < e[u].size(); i++) {         int v = e[u][i];         if (!visited[v]) sp.push_back(v);         visited[v] = true;       }     }     for (int i = 0; i < n; i++)       if (!visited[i]) {         cout <<  no  << endl;         return 0;       }     cout <<  yes  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long n;     cin >> n;     vector<double> gr, le;     vector<long long> gri, lei;     vector<long long> grind, leind;     for (long long i = 0; i < n; ++i) {       double t;       cin >> t;       if (t >= 0) {         gr.push_back(t);         grind.push_back(i);       } else {         le.push_back(-t);         leind.push_back(i);       }     }     long long gz = 0, lz = 0;     long long gsum = 0, lsum = 0;     for (double t : gr) {       if (floorl(t) != t) gz++;       gsum += floorl(t);       gri.push_back(floorl(t));     }     for (double t : le) {       if (floorl(t) != t) lz++;       lsum += floorl(t);       lei.push_back(floorl(t));     }     vector<long long> ans(n);     if (gsum <= lsum) {       long long add = lsum - gsum;       for (long long i = 0; i < gr.size() && add > 0; ++i) {         if (floorl(gr[i]) != gr[i]) {           add--;           gri[i]++;         }       }     } else {       long long add = gsum - lsum;       for (long long i = 0; i < le.size() && add > 0; ++i) {         if (floorl(le[i]) != le[i]) {           add--;           lei[i]++;         }       }     }     for (long long i = 0; i < gr.size(); ++i) {       ans[grind[i]] = gri[i];     }     for (long long i = 0; i < le.size(); ++i) {       ans[leind[i]] = -lei[i];     }     for (long long t : ans) cout << t <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   int n;   bool good(int x) {     int res = x;     while (x > 0) {       res += x % 10;       x /= 10;     }     return (res == n);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     vector<int> ans;     for (int m = n; m >= max(1, n - 100000); m--) {       if (good(m)) {         ans.emplace_back(m);       }     }     int len = ans.size();     sort(ans.begin(), ans.end());     cout << len <<   n ;     for (int i = 0; i < len; i++) {       cout << ans[i] << (i == len - 1 ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 5;   int n, q, a[N];   int rt[N * 20], ls[N * 20], rs[N * 20], sum[N * 20], cnt = 0;   void change(int pre, int& o, int l, int r, int pos) {     o = ++cnt;     ls[o] = ls[pre];     rs[o] = rs[pre];     sum[o] = sum[pre] + 1;     if (l == r) return;     int m = (l + r) / 2;     if (pos <= m)       change(ls[pre], ls[o], l, m, pos);     else       change(rs[pre], rs[o], m + 1, r, pos);   }   int query(int pre, int o, int l, int r, int k) {     if (l == r) return l;     int m = (l + r) / 2;     if (sum[ls[o]] - sum[ls[pre]] > k) {       int res = query(ls[pre], ls[o], l, m, k);       if (res != -1) return res;     }     if (sum[rs[o]] - sum[rs[pre]] > k) {       int res = query(rs[pre], rs[o], m + 1, r, k);       if (res != -1) return res;     }     return -1;   }   int main() {     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       change(rt[i - 1], rt[i], 1, n, a[i]);     }     while (q--) {       int l, r, k;       scanf( %d%d%d , &l, &r, &k);       int ans = query(rt[l - 1], rt[r], 1, n, (r - l + 1) / k);       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void PrintVector(vector<int> v2, string s) {     cout << s;     for (int i = 0; i < v2.size(); i++) cout << v2[i] <<    ;     cout << endl;   }   void PrintVector(vector<int> v2) {     for (int i = 0; i < v2.size(); i++) cout << v2[i] <<    ;     cout << endl;   }   int isOdd(int x) { return (x % 2); }   int toInt(string str) {     int num;     istringstream iss(str);     iss >> num;     return num;   }   template <class T>   string toStr(T par) {     ostringstream oss;     oss << par;     return oss.str();   }   void readVector(vector<int> &vec, int len) {     for (int i = 0; i < len; i++) {       cin >> vec[i];     }   }   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   bool sortPairsCmp(const pair<int, int> &a, const pair<int, int> &b) {     return a.second > b.second;   }   multiset<int> arr;   int main() {     long long n, x, y;     long long hours = 0;     cin >> n >> x;     for (int i = 0; i < n; i++) {       cin >> y;       arr.insert(y);     }     for (auto t : arr) {       hours += (x * t);       if (x > 1) x--;     }     cout << hours << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dirx[] = {1, -1, 0, 0, 1, 1, -1, -1}, diry[] = {0, 0, 1, -1, 1, -1, 1, -1};   bool Set(int n, int pos) { return bool(n & (1 << pos)); }   int32_t main() {     ios_base::sync_with_stdio(false);     int n, m;     cin >> n >> m;     string a, b;     cin >> a >> b;     int dp[n + 1][m + 1], ans = -1;     memset(dp, 0, sizeof(dp));     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         dp[i][j] = max(0, max(dp[i - 1][j], dp[i][j - 1]) - 1);         if (a[i - 1] == b[j - 1]) dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 2);         ans = max(ans, dp[i][j]);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void maxtt(T& t1, T t2) {     t1 = max(t1, t2);   }   template <typename T>   void mintt(T& t1, T t2) {     t1 = min(t1, t2);   }   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  URDL ;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int& x, int y, int mod = 998244353) {     assert(y >= 0);     x += y;     if (x >= mod) x -= mod;     assert(x >= 0 && x < mod);   }   void et(int x = -1) {     printf( %d n , x);     exit(0);   }   long long fastPow(long long x, long long y, int mod = 998244353) {     long long ans = 1;     while (y > 0) {       if (y & 1) ans = (x * ans) % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   long long gcd1(long long x, long long y) { return y ? gcd1(y, x % y) : x; }   vector<int> mp[200135];   int d[200135], tar;   vector<int> dp[200135];   pair<int, int> tmp;   void dfs(int x, int pa) {     d[x] = d[pa] + 1;     dp[x].clear();     for (int c : mp[x])       if (c != pa) {         dfs(c, x);         int v = dp[c][0];         if (dp[x].size() <= 1) {           dp[x].push_back(v);           if (dp[x].size() == 2 && d[dp[x][0]] < d[dp[x][1]]) {             swap(dp[x][0], dp[x][1]);           }         } else if (d[v] > d[dp[x][0]]) {           dp[x][1] = dp[x][0];           dp[x][0] = v;         } else if (d[v] > d[dp[x][1]]) {           dp[x][1] = v;         }       }     if (dp[x].empty()) dp[x].push_back(x);     if (dp[x].size() == 2) {       pair<int, int> key = {d[x], d[dp[x][0]] + d[dp[x][1]]};       if (key > tmp) {         tmp = key;         tar = x;       }     }   }   void fmain(int tid) {     scanf( %d , &n);     for (int i = 0, u, v; i < n - 1; i++) {       scanf( %d%d , &u, &v);       mp[u].push_back(v);       mp[v].push_back(u);     };     tmp = {-1, -1};     dfs(1, 0);     vector<int> ans(4);     ans[0] = dp[tar][0];     ans[2] = dp[tar][1];     tmp = {-1, -1};     dfs(tar, 0);     ans[1] = dp[tar][0];     ans[3] = dp[tar][1];     for (int(i) = 0; (i) < (int)(4); (i)++) printf( %d  , ans[i]);   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }
#include <bits/stdc++.h>   int a[55];   using namespace std;   int main() {     int n, m, k, i, t = 0, cnt;     scanf( %d%d%d , &n, &m, &k);     if (k >= m) {       printf( 0 n );       return 0;     }     for (i = 0; i < n; i++) scanf( %d , &a[i]);     sort(a, a + n, std::greater<int>());     a[0] += k - 1;     t = 0;     cnt = 1;     for (i = 0; i < n; i++) {       if (a[i] > 1 && t + a[i] >= m) {         printf( %d n , cnt);         return 0;       } else {         t += a[i] - 1;         cnt++;       }     }     if (i == n) printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void seif() { std::ios_base::sync_with_stdio(0); }   int xa[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};   int ya[] = {1, 0, -1, 1, 0, -1, 1, 0, -1};   int anx, any, marx, mary;   bool ok = false;   char grid[8][8];   bool valid(int x, int y) {     if (x < 0 || y < 0 || x > 7 || y > 7 || ok) return false;     return true;   }   void check(int cx, int cy, int deg) {     if (cx == 0 && cy == 7) {       cout <<  WIN ;       ok = true;     }     if (ok) return;     for (int i = 0; i < 9; i++) {       int mtx = cx + xa[i];       int mty = cy + ya[i];       if (!valid(mtx, mty)) continue;       if (mtx - deg >= 0 && grid[mtx - deg][mty] ==  S ) continue;       if (mtx - deg - 1 >= 0 && grid[mtx - deg - 1][mty] ==  S ) continue;       check(mtx, mty, deg + 1);     }     return;   }   int main() {     seif();     bool flag = false;     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         cin >> grid[i][j];         if (grid[i][j] ==  S ) flag = true;       }     }     if (!flag) return cout <<  WIN , 0;     check(7, 0, 0);     if (!ok) cout <<  LOSE ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t;     cin >> t;     while (t--) {       cin >> n;       int arr[n];       for (int i = 0; i < n; i++) {         cin >> arr[i];       }       int mx, x;       mx = 0;       for (int i = 1; i < n; i++) {         if (arr[i] < arr[i - 1]) {           x = arr[i - 1] - arr[i];           if (x > mx) {             mx = x;           }           arr[i] = arr[i - 1];         }       }       int ans = 0;       while (mx != 0) {         mx = mx / 2;         ans++;       }       cout << ans << endl;     }     return 0;   }