malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 2010;   struct point {     point(int xx, int yy) : x(xx), y(yy) {}     int x, y;   };   int n, m;   char a[N][N];   queue<point> q;   int dx[4] = {-1, 1, 0, 0};   int dy[4] = {0, 0, -1, 1};   long long pp;   bool uniq(int xx, int yy) {     if (a[xx][yy] !=  . ) {       return false;     }     int counter = 0;     for (int i = 0; i < 4; ++i) {       int x = xx + dx[i];       int y = yy + dy[i];       if (a[x][y] ==  . ) {         ++counter;       }     }     return (counter == 1);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> m;     for (int i = 0; i <= n + 1; ++i) {       for (int j = 0; j <= m + 1; ++j) {         if (i == 0 || j == 0 || i == n + 1 || j == m + 1) {           a[i][j] =  * ;           continue;         }         cin >> a[i][j];         if (a[i][j] ==  . ) {           ++pp;         }       }     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (a[i][j] ==  * ) {           continue;         }         int counter = 0;         if (a[i][j + 1] ==  . ) {           ++counter;         }         if (a[i][j - 1] ==  . ) {           ++counter;         }         if (a[i - 1][j] ==  . ) {           ++counter;         }         if (a[i + 1][j] ==  . ) {           ++counter;         }         if (counter == 0) {           cout <<  Not unique ;           return 0;         }         if (counter == 1) {           q.push(point(i, j));         }       }     }     while (true) {       if (q.empty()) {         break;       }       point cur = q.front();       q.pop();       if (a[cur.x][cur.y] !=  . ) {         continue;       }       if (!uniq(cur.x, cur.y)) {         cout <<  Not unique ;         return 0;       }       int xx = cur.x;       int yy = cur.y;       for (int i = 0; i < 4; ++i) {         xx += dx[i];         yy += dy[i];         if (a[xx][yy] ==  . ) {           break;         }         xx -= dx[i];         yy -= dy[i];       }       if (yy == cur.y) {         if (xx < cur.x) {           a[cur.x][cur.y] =  v ;           a[xx][yy] =  ^ ;         } else {           a[xx][yy] =  v ;           a[cur.x][cur.y] =  ^ ;         }       }       if (xx == cur.x) {         if (yy < cur.y) {           a[cur.x][cur.y] =  > ;           a[xx][yy] =  < ;         } else {           a[cur.x][cur.y] =  < ;           a[xx][yy] =  > ;         }       }       pp -= 2;       for (int i = 0; i < 4; ++i) {         if (uniq(xx + dx[i], yy + dy[i])) {           q.push(point(xx + dx[i], yy + dy[i]));         }       }     }     if (pp > 0) {       cout <<  Not unique ;       return 0;     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         cout << a[i][j];       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, ans;   map<long long, long long> m, ind;   long long b[150001], a;   int main() {     scanf( %d , &n);     ans = n;     for (i = 1; i <= n; i++) {       scanf( %I64d , &a);       m[a]++;       b[i] = a;       while (m[a] > 1) {         ans--;         m[a] = 0;         b[ind[a]] = 0;         a *= 2;         b[i] = a;         m[a]++;       }       ind[a] = i;     }     printf( %d n , ans);     for (i = 1; i <= n; i++)       if (b[i] > 0) printf( %I64d  , b[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<pair<int, string> > > regions;   int main() {     int n, m;     cin >> n >> m;     regions.resize(m);     string name;     int r, s;     for (int i = 0; i < n; ++i) {       cin >> name >> r >> s;       regions[r - 1].push_back(make_pair(s, name));     }     for (int i = 0; i < m; ++i) {       sort(regions[i].rbegin(), regions[i].rend());       if (regions[i].size() == 2 || regions[i][1].first > regions[i][2].first)         cout << regions[i][0].second <<     << regions[i][1].second << endl;       else         cout <<  ?  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 2e5 + 7;   const long long INF = 3e18 + 7;   long long n, t;   long long a[MAXN], p[MAXN], l[MAXN], r[MAXN];   long long ans[MAXN];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> t;     for (long long i = 0; i < n; ++i) cin >> a[i];     for (long long i = 0; i < n; ++i) {       cin >> p[i];       --p[i];     }     for (long long i = 0; i < n - 1; ++i) {       if (p[i + 1] < p[i]) {         cout <<  No n ;         exit(0);       }     }     for (long long i = 0; i < n; ++i) {       l[i] = 1;       r[i] = INF;     }     for (long long i = 0; i < n; ++i) {       l[p[i]] = max(l[p[i]], a[i] + t);     }     for (long long i = 0; i < n; ++i) {       l[i] = max(l[i], a[i] + t);     }     long long mx = -1;     for (long long i = 0; i < n - 1; ++i) {       mx = max(mx, p[i]);       if (i < mx) {         l[i] = max(l[i], a[i + 1] + t);       }     }     for (long long i = 0; i < n - 1; ++i) {       if (p[i] < i) {         r[p[i]] = min(r[p[i]], a[p[i]] + t - 1);       } else {         r[p[i]] = min(r[p[i]], a[p[i] + 1] + t - 1);       }     }     for (long long i = 0; i < n; ++i) {       if (!i)         ans[i] = l[i];       else         ans[i] = max(ans[i - 1] + 1, l[i]);     }     for (long long i = 0; i < n - 1; ++i) {       if (ans[i + 1] <= a[i]) {         cout <<  No n ;         exit(0);       }       if (!(l[i] <= ans[i] && ans[i] <= r[i])) {         cout <<  No n ;         exit(0);       }     }     cout <<  Yes n ;     for (long long i = 0; i < n; ++i) {       cout << ans[i] <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void JIZZ(string output =   ) {     cout << output;     exit(0);   }   const long double PI = 3.14159265358979323846264338327950288;   const long double eps = 1e-13;   const long long mod = 1e9 + 7;   struct node {     node *l, *r;     int mx;     node() : l(0), r(0), mx(-(1 << 30)) {}   } * root, pool[100000];   int pptr = -1;   int a[20005], pre[20005], dp[53][20005];   node *nnode() {     ++pptr;     pool[pptr].l = pool[pptr].r = 0;     pool[pptr].mx = -(1 << 30);     return &pool[pptr];   }   void build(node *now, int l, int r) {     if (l == r) return;     build(now->l = nnode(), l, ((l + r) >> 1));     build(now->r = nnode(), ((l + r) >> 1) + 1, r);   }   void modify(node *now, int l, int r, int x, int v) {     if (l == r) {       now->mx = max(now->mx, v);       return;     }     if (x <= ((l + r) >> 1))       modify(now->l, l, ((l + r) >> 1), x, v);     else       modify(now->r, ((l + r) >> 1) + 1, r, x, v);     now->mx = max(now->l->mx, now->r->mx);   }   int query(node *now, int l, int r, int ql, int qr) {     ;     ;     if (qr < l || r < ql) return -(1 << 30);     if (ql <= l && r <= qr) return now->mx;     return max(query(now->l, l, ((l + r) >> 1), ql, qr),                query(now->r, ((l + r) >> 1) + 1, r, ql, qr));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, k, p;     cin >> n >> k >> p;     for (int i = 1; i <= n; ++i) cin >> a[i], a[i] %= p;     for (int i = 1; i <= n; ++i) pre[i] = (pre[i - 1] + a[i]) % p;     for (int i = 1; i <= n; ++i) dp[0][i] = -(1 << 30);     for (int i = 1; i <= k; ++i) {       pptr = -1;       build(root = nnode(), 0, p - 1);       modify(root, 0, p - 1, 0, 0);       for (int j = 1; j <= n; ++j) {         dp[i][j] = pre[j] + query(root, 0, p - 1, 0, pre[j]);         if (pre[j] != p - 1)           dp[i][j] = max(dp[i][j],                          pre[j] + query(root, 0, p - 1, pre[j] + 1, p - 1) + p);         modify(root, 0, p - 1, pre[j], -pre[j] + dp[i - 1][j]);         ;         ;       }     }     cout << dp[k][n] << endl;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   int n, cnt;   int ans[1005];   bool prime(int x) {     for (int i = 2; i < x; i++)       if (x % i == 0) return 0;     return 1;   }   int main() {     scanf( %d , &n);     for (int i = 2; i <= n; i++) {       if (!prime(i)) continue;       int p = i;       while (p <= n) {         ans[++cnt] = p;         p *= i;       }     }     printf( %d n , cnt);     for (int i = 1; i < cnt; i++) printf( %d  , ans[i]);     if (cnt) printf( %d n , ans[cnt]);   }
#include <bits/stdc++.h>   using namespace std;   int NewMessages(int right, int left, int k, int size) {     int right_border = min(right + k, size - 1);     int left_border = max(min(left + k, size - 1), max(0, right - k - 1));     return right_border - left_border;   }   int main() {     int n, k;     cin >> n >> k;     vector<int> messages(n);     for (auto& x : messages) {       cin >> x;       --x;     }     vector<int> counts(n, 0);     counts[0] = min(static_cast<int>(counts.size()) - 1, k) + 1;     for (int i = 1; i < counts.size(); ++i) {       if (messages[i] == -1) {         counts[i] =             min(static_cast<int>(counts.size()) - 1, i + k) - max(0, i - k) + 1;       } else {         counts[i] =             counts[messages[i]] +             NewMessages(i, messages[i], k, static_cast<int>(counts.size()));       }     }     for (auto x : counts) {       cout << x <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const long long INFLL = 0x3f3f3f3f3f3f3f3fll;   const int maxn = 2e5 + 5;   const int mod = 1e9 + 7;   int n, k;   char ans[55][3];   int main() {     cin >> n >> k;     char ch1 =  A , ch2 =  a ;     for (int i = 0; i < n - k + 1; i++) {       string s;       cin >> s;       if (i == 0) {         if (s ==  YES ) {           for (int j = i; j < i + k; j++) {             ans[j][0] = ch1;             ans[j][1] = ch2++;             if (ch2 >  z ) ch1 =  B , ch2 =  a ;           }         } else {           ans[i][0] = ans[i + k - 1][0] = ch1;           ans[i][1] = ans[i + k - 1][1] = ch2++;           for (int j = i + 1; j < i + k - 1; j++) {             ans[j][0] = ch1;             ans[j][1] = ch2++;             if (ch2 >  z ) ch1 =  B , ch2 =  a ;           }         }       } else {         if (s ==  YES ) {           ans[i + k - 1][0] = ch1;           ans[i + k - 1][1] = ch2++;         } else {           ans[i + k - 1][0] = ans[i][0];           ans[i + k - 1][1] = ans[i][1];         }         if (ch2 >  z ) ch1 =  B , ch2 =  a ;       }     }     for (int i = 0; i < n; i++) {       cout << ans[i][0] << ans[i][1] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, a[100][100], ans, ma[100];   bool mark[10];   int seen[100000];   void BT(int n) {     if (n > ::n) {       int ans = 0;       for (int i = 1; i <= ::n; i++) {         if (a[i][ma[i]] == 0 && ma[i] != 0) return;         ans += a[i][ma[i]];       }       seen[ans]++;       return;     }     for (int i = 0; i <= ::n; i++) {       if (i == 0 || !mark[i]) {         ma[n] = i;         mark[i] = true;         BT(n + 1);         ma[n] = 0;         mark[i] = false;       }     }     return;   }   int main() {     cin >> n >> m >> k;     for (int i = 0; i < m; i++) {       int A, b, c;       cin >> A >> b >> c;       a[A][b] = c;     }     int t = 0, i = 0;     BT(1);     seen[0] = 1;     while (t < k) {       if (seen[i]) t += seen[i];       i++;     }     cout << i - 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300005;   int f[maxn], n;   struct struc {     long long a[maxn];     int go[19][maxn], nxt[maxn];     void build(int ty = 0) {       if (!ty) {         for (int i = 1; i <= n; i++) scanf( %lld , &a[i]);         for (int i = n; i; i--) a[i] += a[i + 1];       }       static map<long long, int> pos;       pos.clear();       pos[0] = n + 1;       for (int i = n; i; i--) nxt[i] = pos[a[i]], pos[a[i]] = i;     }   } sav[3];   vector<pair<int, int> > up[maxn], dow[maxn];   int c[maxn];   void push(int i, int j, int v) {     c[max(i, j)] = max(c[max(i, j)], v);     if (i <= j) up[i].push_back(pair<int, int>(j, v));     if (j <= i) dow[j].push_back(pair<int, int>(i, v));   }   void trans(int i, int j, int v) {     push(i + 1, j, v), push(i, j + 1, v);     if (sav[0].nxt[i]) push(sav[0].nxt[i], j, v + 1);     if (sav[1].nxt[j]) push(i, sav[1].nxt[j], v + 1);     if (i == j && sav[2].nxt[i]) push(sav[2].nxt[i], sav[2].nxt[i], v + 1);   }   int main() {     scanf( %d , &n);     sav[0].build(), sav[1].build();     for (int i = 1; i <= n; i++) sav[2].a[i] = sav[0].a[i] + sav[1].a[i];     sav[2].build(1);     for (int i = 1; i <= n; i++) {       int go_up = (1 << 30), go_dow = (1 << 30);       trans(i, i, c[i]);       for (auto p : up[i])         if (p.second == c[i] + 1) go_dow = min(go_dow, p.first);       for (auto p : dow[i])         if (p.second == c[i] + 1) go_up = min(go_up, p.first);       if (go_up <= n + 1) trans(go_up, i, c[i] + 1);       if (go_dow <= n + 1) trans(i, go_dow, c[i] + 1);     }     printf( %d n , c[n + 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, l;     string s;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> l >> s;       int first = s[0] -  0 ;       int second = s[1] -  0 ;       if (s.length() == 2 && first >= second) {         cout <<  NO  << endl;         continue;       }       cout <<  YES  << endl;       cout << 2 << endl;       cout << s[0] <<     << s.substr(1) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename arg>   void debugger(const char* varname, arg&& var) {     cout << varname <<   =   << var << endl;   }   template <typename arg, typename... args>   void debugger(const char* varnames, arg&& var, args&&... vars) {     const char* comma = strchr(varnames + 1,  , );     cout.write(varnames, comma - varnames) <<   =   << var <<   |  ;     int sz = 1;     if (isspace(comma[sz])) sz++;     debugger(comma + sz, vars...);   }   using ll = long long;   using ii = pair<ll, ll>;   using vi = vector<ll>;   extern const int INF = INT_MAX - 5;   extern const ll LINF = LLONG_MAX - 5;   extern const int MOD = 1e9 + 7;   extern const int N = 2e5 + 200;   int t, n;   string s;   vi find_min() {     vi ret(n), pos;     if (s[0] ==  < ) pos.emplace_back(0);     for (int i = 1; i < (int)s.size(); ++i) {       if (s[i - 1] ==  >  and s[i] ==  < ) {         pos.emplace_back(i);       }     }     if (s[(int)s.size() - 1] ==  > ) pos.emplace_back(n - 1);     int c = 1;     for (int i = (int)pos.size() - 1; i >= 0; --i) {       ret[pos[i]] = c;       c++;     }     for (int i = pos[pos.size() - 1] + 1; i < n; ++i) {       ret[i] = c;       c++;     }     for (int i = (int)pos.size() - 1; i >= 1; --i) {       int r = pos[i] - 1, l = pos[i - 1];       while (s[r] ==  >  and s[r - 1] ==  > ) {         ret[r] = c;         r--, c++;       }       while (s[l] ==  <  and s[l + 1] ==  < ) {         ret[l + 1] = c;         l++, c++;       }       ret[l + 1] = c;       c++;     }     for (int i = pos[0] - 1; i >= 0; --i) {       ret[i] = c;       c++;     }     return ret;   }   vi find_max() {     vi ret(n);     vector<ii> rng;     int ant = 0;     for (int i = 0; i < (int)s.size(); ++i) {       if (s[i] ==  < ) {         rng.emplace_back(ant, i);         ant = i + 1;       }     }     rng.emplace_back(ant, n - 1);     int c = 1;     for (auto i : rng) {       ret[i.second] = c;       c++;     }     for (auto i : rng) {       for (int k = i.second - 1; k >= i.first; --k) {         ret[k] = c;         c++;       }     }     return ret;   }   int main() {     cin >> t;     while (t--) {       cin >> n >> s;       vi mn = find_min();       vi mx = find_max();       for (int i = 0; i < n; ++i) {         if (i != 0) cout <<    ;         cout << mn[i];       }       cout <<   n ;       for (int i = 0; i < n; ++i) {         if (i != 0) cout <<    ;         cout << mx[i];       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 5;   const int inf = 2e9 + 9;   int n, m, p;   pair<int, int> a[maxn], b[maxn];   pair<pair<int, int>, int> mon[maxn];   struct segment_tree {     int val[maxn * 4], lazy[maxn * 4];     void build(int x, int l, int r) {       if (l == r) {         val[x] = -b[l].second;         return;       }       int mid = (l + r) / 2;       build(x * 2, l, mid);       build(x * 2 + 1, mid + 1, r);       val[x] = max(val[x * 2], val[x * 2 + 1]);     }     void push(int x) {       if (lazy[x] == 0) return;       int t = lazy[x];       val[x * 2] += t;       lazy[x * 2] += t;       val[x * 2 + 1] += t;       lazy[x * 2 + 1] += t;       lazy[x] = 0;     }     void upd(int x, int l, int r, int L, int R, int k) {       if (L > r || l > R || L > R) return;       if (l >= L && r <= R) {         val[x] += k;         lazy[x] += k;         return;       }       push(x);       int mid = (l + r) / 2;       upd(x * 2, l, mid, L, R, k);       upd(x * 2 + 1, mid + 1, r, L, R, k);       val[x] = max(val[x * 2], val[x * 2 + 1]);     }     int get() { return val[1]; }   } tree;   void read_input() {     cin >> n >> m >> p;     for (int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second;     for (int i = 1; i <= m; ++i) cin >> b[i].first >> b[i].second;     for (int i = 1; i <= p; ++i) {       int x, y, z;       cin >> x >> y >> z;       mon[i] = make_pair(pair<int, int>(x, y), z);     }   }   void init() {     sort(a + 1, a + n + 1);     sort(b + 1, b + m + 1);     sort(mon + 1, mon + p + 1);     tree.build(1, 1, m);   }   void solve() {     int cur = 1;     int ans = -inf;     for (int i = 1; i <= n; ++i) {       int ap = a[i].first;       while (cur <= p && mon[cur].first.first < ap) {         int p = upper_bound(b + 1, b + m + 1,                             pair<int, int>(mon[cur].first.second, inf)) -                 b;         tree.upd(1, 1, m, p, m, mon[cur].second);         ++cur;       }       ans = max(ans, -a[i].second + tree.get());     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     read_input();     init();     solve();   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int n, w;     cin >> w >> n;     if (w <= 3) {       cout <<  YES  << endl;       return 0;     }     while (n > 0) {       if (n % w > 1 && n % w < w - 1) {         cout <<  NO  << endl;         return 0;       }       n = (n + 1) / w;     }     cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Read() {     char c = getchar();     while (c <  0  || c >  9 ) c = getchar();     int t = c -  0 ;     c = getchar();     while (c >=  0  && c <=  9 ) t = (t << 3) + (t << 1) + c -  0 , c = getchar();     return t;   }   int n, Q, s;   int Head[900001], To[3200001], Next[3200001], t1;   int W[3200001];   void add(int a, int b, int c) {     t1++;     Next[t1] = Head[a];     Head[a] = t1;     To[t1] = b;     W[t1] = c;   }   void Build(int bh, int x, int y) {     if (x == y) {       add(bh, n * 8 + x, 0), add(n * 8 + x, bh, 0);       add(n * 4 + bh, n * 8 + x, 0), add(n * 8 + x, n * 4 + bh, 0);       return;     }     add(bh, bh * 2, 0), add(bh, bh * 2 + 1, 0);     add(n * 4 + bh * 2, n * 4 + bh, 0), add(n * 4 + bh * 2 + 1, n * 4 + bh, 0);     int mid = (x + y) / 2;     Build(bh * 2, x, mid);     Build(bh * 2 + 1, mid + 1, y);   }   void add(int bh, int x, int y, int a, int b, int c, bool t, int u) {     if (x == a && y == b) {       if (!t)         add(n * 8 + u, bh, c);       else         add(n * 4 + bh, n * 8 + u, c);       return;     }     int mid = (x + y) / 2;     if (b <= mid)       add(bh * 2, x, mid, a, b, c, t, u);     else if (a > mid)       add(bh * 2 + 1, mid + 1, y, a, b, c, t, u);     else       add(bh * 2, x, mid, a, mid, c, t, u),           add(bh * 2 + 1, mid + 1, y, mid + 1, b, c, t, u);   }   struct Node {     int id;     long long d;     bool operator<(const Node& a) const { return a.d < d; }   } t;   priority_queue<Node> q;   bool vis[900001];   long long dis[900001];   void Dij() {     for (int i = 1; i <= n * 9; i++) dis[i] = 1e18;     dis[n * 8 + s] = 0;     t.id = n * 8 + s;     t.d = 0;     q.push(t);     while (!q.empty()) {       while (!q.empty() && vis[q.top().id]) q.pop();       if (q.empty()) break;       int curr = q.top().id;       q.pop();       vis[curr] = 1;       for (int i = Head[curr]; i; i = Next[i]) {         if (!vis[To[i]]) {           if (dis[To[i]] > dis[curr] + W[i]) {             dis[To[i]] = dis[curr] + W[i];             t.id = To[i];             t.d = dis[To[i]];             q.push(t);           }         }       }     }   }   int main() {     n = Read();     Q = Read();     s = Read();     Build(1, 1, n);     for (int i = 1, t, u, v, w, l, r; i <= Q; i++) {       t = Read();       if (t == 1) {         u = Read();         v = Read();         w = Read();         add(n * 8 + u, n * 8 + v, w);       } else if (t == 2) {         u = Read();         l = Read();         r = Read();         w = Read();         add(1, 1, n, l, r, w, 0, u);       } else {         u = Read();         l = Read();         r = Read();         w = Read();         add(1, 1, n, l, r, w, 1, u);       }     }     Dij();     for (int i = n * 8 + 1; i <= n * 8 + n; i++) {       if (!vis[i])         printf( -1  );       else         printf( %lld  , dis[i]);     }     return 0;   }
#include <bits/stdc++.h>   const int INF = (int)1e9 + 7;   int f(const std::vector<int> &arr, int k, int d) {     std::list<std::pair<int, int>> events, se;     for (auto &it : arr) {       events.push_back({it - d, 0});       se.push_back({it + d, 1});     }     events.merge(se);     int bal = 0;     for (auto it : events) {       bal += (it.second ? -1 : +1);       if (bal > k) {         return it.first;       }     }     return -INF;   }   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(0);     int t;     std::cin >> t;     while (t--) {       int n, k;       std::cin >> n >> k;       std::vector<int> arr(n);       for (auto &it : arr) {         std::cin >> it;       }       std::sort((arr).begin(), (arr).end());       int low = -1, high = (int)1e9;       while (high - low > 1) {         int mid = (low + high) / 2;         if (f(arr, k, mid) > -INF) {           high = mid;         } else {           low = mid;         }       }       std::cout << f(arr, k, high) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     char a[n][m];     int num = 0;     int mn[m];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> a[i][j];       }     }     for (int i = 0; i < m; i++) {       num = 0;       for (int j = 0; j < n; j++) {         num = max(num, a[j][i] -  0 );       }       mn[i] = num;     }     int c = 0, ans = 0;     for (int i = 0; i < n; i++) {       c = 0;       for (int j = 0; j < m; j++) {         if (mn[j] == a[i][j] -  0 ) {           c = 3;         }       }       if (c == 3) {         ans++;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   char arr[N], dp[N][N * N], ndp[N][N * N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n;     cin >> n;     int sz = 0;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       arr[x]++;       if (arr[x] == 1) sz++;     }     dp[0][0] = 1;     for (int i = 1; i < N; i++) {       for (int x1 = 0; x1 < N; x1++)         for (int x2 = 0; x2 < N * N; x2++) ndp[x1][x2] = 0;       for (int f = 0; f <= arr[i]; f++)         for (int x1 = 0; x1 < N; x1++)           for (int x2 = 0; x2 < N * N; x2++)             if (x2 + f * i < N * N && x1 + f < N)               ndp[x1 + f][x2 + f * i] =                   min(100, ndp[x1 + f][x2 + f * i] + dp[x1][x2]);       for (int x1 = 0; x1 < N; x1++)         for (int x2 = 0; x2 < N * N; x2++) dp[x1][x2] = ndp[x1][x2];     }     if (sz <= 2) {       cout << n <<   n ;       return 0;     }     int ans = 0;     for (int i = 1; i < N; i++)       for (int f = 1; f <= arr[i]; f++)         if (dp[f][f * i] == 1) ans = max(ans, f);     cout << ans <<   n ;     return 0;   }