malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int x1[200010];   int x2[200010];   int yz1[200010];   int yz2[200010];   int n;   pair<pair<int, int>, pair<int, int> > pp[200010];   pair<pair<int, int>, pair<int, int> > qq[200010];   bool isValid(int x1, int y1, int x2, int y2) {     if (x1 <= x2 && y1 <= y2) {       return true;     }     return false;   }   pair<pair<int, int>, pair<int, int> > fn(int x1, int y1, int x2, int y2, int x3,                                            int y3, int x4, int y4) {     return make_pair(make_pair(max(x1, x3), max(y1, y3)),                      make_pair(min(x2, x4), min(y2, y4)));   }   int main() {     int INF = INT_MAX;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x1[i] >> yz1[i] >> x2[i] >> yz2[i];     }     pp[0].first.first = x1[0];     pp[0].first.second = yz1[0];     pp[0].second.first = x2[0];     pp[0].second.second = yz2[0];     for (int i = 1; i < n; i++) {       pair<pair<int, int>, pair<int, int> > uu;       uu = fn(pp[i - 1].first.first, pp[i - 1].first.second,               pp[i - 1].second.first, pp[i - 1].second.second, x1[i], yz1[i],               x2[i], yz2[i]);       if (isValid(uu.first.first, uu.first.second, uu.second.first,                   uu.second.second)) {         pp[i] = uu;       } else {         pp[i] = make_pair(make_pair(INF, INF), make_pair(-INF, -INF));       }     }     qq[n - 1].first.first = x1[n - 1];     qq[n - 1].first.second = yz1[n - 1];     qq[n - 1].second.first = x2[n - 1];     qq[n - 1].second.second = yz2[n - 1];     for (int i = n - 2; i >= 0; i--) {       pair<pair<int, int>, pair<int, int> > uu;       uu = fn(qq[i + 1].first.first, qq[i + 1].first.second,               qq[i + 1].second.first, qq[i + 1].second.second, x1[i], yz1[i],               x2[i], yz2[i]);       if (isValid(uu.first.first, uu.first.second, uu.second.first,                   uu.second.second)) {         qq[i] = uu;       } else {         qq[i] = make_pair(make_pair(INF, INF), make_pair(-INF, -INF));       }     }     for (int i = 0; i < n; i++) {       if (i == 0) {         if (isValid(qq[1].first.first, qq[1].first.second, qq[1].second.first,                     qq[1].second.second)) {           cout << qq[1].first.first <<     << qq[1].first.second;           return 0;         }       } else if (i == n - 1) {         if (isValid(pp[n - 2].first.first, pp[n - 2].first.second,                     pp[n - 2].second.first, pp[n - 2].second.second)) {           cout << pp[n - 2].first.first <<     << pp[n - 2].first.second;           return 0;         }       } else {         pair<pair<int, int>, pair<int, int> > uu;         uu = fn(qq[i + 1].first.first, qq[i + 1].first.second,                 qq[i + 1].second.first, qq[i + 1].second.second,                 pp[i - 1].first.first, pp[i - 1].first.second,                 pp[i - 1].second.first, pp[i - 1].second.second);         if (isValid(uu.first.first, uu.first.second, uu.second.first,                     uu.second.second)) {           cout << uu.first.first <<     << uu.first.second;           return 0;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7, siz = 1e6 + 5;   long long t, n, m, k, a[siz], inp[siz], cnt, co[siz], less_right[siz],       less_left[siz], tree[siz][2];   pair<long long, long long> p[siz];   long long get(long long ind, long long id) {     long long ret = 0;     for (; ind; ind -= ind & -ind) ret += tree[ind][id];     return ret;   }   void upd(long long id, long long ind, long long val) {     for (; ind <= cnt; ind += ind & -ind) tree[ind][id] += val;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (long long i = 1; i <= n; i++) cin >> p[i].first, p[i].second = i;     sort(p + 1, p + 1 + n);     for (long long i = 1; i <= n; i++) {       a[p[i].second] = ++cnt;       inp[p[i].second] = p[i].first;     }     for (long long i = 1; i <= n; i++) {       less_left[i] = get(a[i], 0);       upd(0, a[i], i);     }     for (long long i = n; i >= 1; i--) {       less_right[i] = get(a[i], 1);       upd(1, a[i], n - i + 1);     }     long long ans = 0;     for (long long i = 1; i <= n; i++) {       co[i] = i * (n - i + 1);       co[i] += less_left[i] * (n - i + 1) + less_right[i] * i;       co[i] %= mod;       long long toadd = (co[i] * inp[i]) % mod;       (ans += toadd) %= mod;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     if (n < 2 * k + 1) {       cout << -1 << endl;       return 0;     }     cout << n * k << endl;     for (int i = 0; i < n; i++)       for (int j = 1; j <= k; j++)         cout << i + 1 <<     << (i + j) % n + 1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 310;   int r[N];   char g[N][N];   int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};   int main() {     int n, m, k;     scanf( %d %d %d , &n, &m, &k);     for (int i = 0; i < n; i++) scanf( %s , g[i]);     int cnt = 0;     for (int x = 1; x < 150; x++) {       for (int i = x; i + x - 1 < n; i++) {         for (int j = x; j + x - 1 < m; j++) {           if (g[i][j] !=  * ) continue;           bool ok = true;           for (int d = 0; d < 4 and ok; d++) {             int ni = i + dir[d][0] * x;             int nj = j + dir[d][1] * x;             if (g[ni][nj] !=  * ) ok = false;           }           if (ok) cnt++;           if (cnt == k) {             printf( %d %d n , i + 1, j + 1);             for (int d = 0; d < 4; d++) {               int ni = i + dir[d][0] * x;               int nj = j + dir[d][1] * x;               printf( %d %d n , ni + 1, nj + 1);             }             return 0;           }         }       }     }     printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = INT_MAX;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     if (n > m) {       swap(n, m);     }     if (n == 1) {       if (m % 6 == 0) {         cout << n * m;       } else if (m % 6 == 5) {         cout << n * m - 1;       } else if (m % 6 == 4) {         cout << n * m - 2;       } else {         cout << n * m - m % 6;       }     } else if (n == 2) {       if (m == 2) {         cout << 0;       } else if (m == 3) {         cout << 4;       } else if (m == 7) {         cout << 12;       } else {         cout << m * 2;       }     } else {       cout << n * m / 2 * 2;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int vp, vd, time_s, time_b, dist;   int main() {     scanf( %d%d%d%d%d , &vp, &vd, &time_s, &time_b, &dist);     if (vd <= vp) {       puts( 0 );       return 0;     }     int ans = 0;     double now = 1.0 * vp * time_s;     while (now < dist) {       double Overtake = now / (vd - vp);       double loc = now + Overtake * vp;       if (loc >= dist) break;       ++ans;       now = loc;       double Back = now / vd + 1.0 * time_b;       now += Back * vp;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 106;   int g[MAX_N][MAX_N];   int h[MAX_N][MAX_N];   bool not_empty_row[MAX_N];   bool not_empty_col[MAX_N];   bool used_row[MAX_N];   bool used_col[MAX_N];   void coppy(int n, int m) {     for (int i = 1; n >= i; i++) {       for (int j = 1; m >= j; j++) {         h[i][j] = g[i][j];       }     }     memset(used_row, 0, sizeof(used_row));     memset(used_col, 0, sizeof(used_col));   }   bool okayy(int n, int m) {     bool ret = true;     for (int i = 1; n >= i; i++) {       for (int j = 1; m >= j; j++) {         ret &= (h[i][j] == 0);       }     }     return ret;   }   bool deleted(int type, int x, int val, int n, int m) {     if (type == 1) {       int i = x;       for (int j = 1; m >= j; j++) {         h[i][j] -= val;         if (h[i][j] < 0) return false;       }       return true;     }     if (type == 2) {       int j = x;       for (int i = 1; n >= i; i++) {         h[i][j] -= val;         if (h[i][j] < 0) return false;       }       return true;     }   }   int main() {     int n, m;     scanf( %d %d , &n, &m);     bool not_empty = false;     for (int i = 1; n >= i; i++) {       for (int j = 1; m >= j; j++) {         scanf( %d , &g[i][j]);         if (g[i][j]) {           not_empty_row[i] = 1;           not_empty_col[j] = 1;           not_empty = true;         }       }     }     if (!not_empty) {       puts( 0 );       return 0;     }     int rrow = -1;     for (int i = 1; n >= i; i++) {       if (not_empty_row[i]) {         rrow = i;         break;       }     }     if (rrow == -1) cout << 0 / 0 << endl;     vector<pair<int, pair<int, int> > > ans;     vector<pair<int, pair<int, int> > > real_ans;     int meruru = 123456789;     int xx = 0;     for (int cnt = 0; g[rrow][1] >= cnt; cnt++) {       ans.clear();       coppy(n, m);       bool ret = deleted(1, rrow, cnt, n, m);       xx = 0;       xx += cnt;       ans.push_back(make_pair(1, make_pair(rrow, cnt)));       for (int j = 1; m >= j; j++) {         xx += h[rrow][j];         ans.push_back(make_pair(2, make_pair(j, h[rrow][j])));         ret &= deleted(2, j, h[rrow][j], n, m);       }       for (int i = 1; n >= i; i++) {         xx += h[i][1];         ans.push_back(make_pair(1, make_pair(i, h[i][1])));         ret &= deleted(1, i, h[i][1], n, m);       }       if (ret && okayy(n, m)) {         if (xx < meruru) {           real_ans = ans;           meruru = xx;         }       } else         ans.clear();     }     ans = real_ans;     if (ans.size() == 0)       puts( -1 );     else {       int cnt = 0;       for (pair<int, pair<int, int> > i : ans) {         cnt += i.second.second;       }       if (cnt != meruru) cout << 0 / 0 << endl;       printf( %d n , cnt);       for (pair<int, pair<int, int> > i : ans) {         while (i.second.second--) {           if (i.first == 1)             printf( row  );           else             printf( col  );           printf( %d n , i.second.first);         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int nax = 3e5 + 10;   long long w[nax];   long long dp[nax], ans;   vector<pair<int, long long> > v[nax];   void dfs(int id, int par) {     vector<long long> temp;     for (auto i : v[id]) {       if (i.first == par) continue;       dfs(i.first, id);       temp.emplace_back(dp[i.first] - i.second);       dp[id] = max(dp[id], dp[i.first] - i.second);     }     dp[id] += w[id];     ans = max(ans, dp[id]);     sort(temp.begin(), temp.end());     reverse(temp.begin(), temp.end());     if ((int)temp.size() == 1) ans = max(ans, temp[0] + w[id]);     if ((int)temp.size() > 1) ans = max(ans, temp[1] + temp[0] + w[id]);   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     for (int i = 1; i <= n; ++i) cin >> w[i];     for (int i = 0; i < n - 1; ++i) {       int x, y, t;       cin >> x >> y >> t;       v[x].emplace_back(y, t);       v[y].emplace_back(x, t);     }     dfs(1, -1);     cout << ans <<   n ;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> tree[2 * 100000 + 4];   long long dp[2 * 100000 + 3][2];   int value[2 * 100000 + 4];   void dfs(int x) {     dp[x][0] = 0;     dp[x][1] = -200000000005;     for (int i = 0, sz = tree[x].size(); i < sz; i++) {       int v = tree[x][i];       dfs(v);       long long tmp1 = dp[x][1], tmp0 = dp[x][0];       dp[x][0] = max(tmp0 + dp[v][0], tmp1 + dp[v][1]);       dp[x][1] = max(tmp1 + dp[v][0], tmp0 + dp[v][1]);     }     dp[x][1] = max(dp[x][0] + value[x], dp[x][1]);   }   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x >> value[i];       if (i == 1) continue;       tree[x].push_back(i);     }     dfs(1);     cout << dp[1][1] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   long long t[N], dp[N];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %lld , &t[i]);     }     dp[0] = 0;     long long sum = 0;     for (int i = 1; i <= n; i++) {       dp[i] = dp[i - 1] + 20;       for (int j = i - 1; j >= 1; j--) {         if (t[i] - t[j] < 90)           dp[i] = min(dp[i], dp[j - 1] + 50);         else if (t[i] - t[j] < 1440)           dp[i] = min(dp[i], dp[j - 1] + 120);         else           break;       }       printf( %lld n , dp[i] - sum);       sum = dp[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long GCD(long long a, long long b) {     return (a % b) == 0 ? b : GCD(b, a % b);   }   long long mod(long long x) { return ((x % 998244353 + 998244353) % 998244353); }   bool cmp(const pair<int, int> &left, const pair<int, int> &right) {     return left.first > right.first ||            (left.first == right.first && left.second < right.second);   }   int main() {     int n, m, p1, p2, p3, t1, t2, i, j, k, mx = 0;     vector<pair<int, int> > v;     cin >> n >> p1 >> p2 >> p3 >> t1 >> t2;     for (i = 0; i < n; i++) {       cin >> j >> k;       v.push_back(make_pair(j, k));     }     sort(v.begin(), v.end());     for (i = 0; i < n - 1; i++) {       mx += (v[i].second - v[i].first) * p1;       if (v[i + 1].first > v[i].second + t1) {         mx += t1 * p1;         if (v[i + 1].first > v[i].second + t1 + t2) {           mx += t2 * p2;           mx += (v[i + 1].first - (v[i].second + t1 + t2)) * p3;         } else           mx += (v[i + 1].first - (v[i].second + t1)) * p2;       } else         mx += (v[i + 1].first - v[i].second) * p1;     }     mx += (v[n - 1].second - v[n - 1].first) * p1;     cout << mx << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void read(T &x) {     x = 0;     char c = getchar();     int flag = 0;     while (c <  0  || c >  9 ) flag |= (c ==  - ), c = getchar();     while (c >=  0  && c <=  9 )       x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();     if (flag) x = -x;   }   template <class T>   T _max(T a, T b) {     return a > b ? a : b;   }   template <class T>   T _min(T a, T b) {     return a < b ? a : b;   }   template <class T>   bool checkmax(T &a, T b) {     return b > a ? a = b, 1 : 0;   }   template <class T>   bool checkmin(T &a, T b) {     return b < a ? a = b, 1 : 0;   }   const int N = 100005;   int n;   long long a[N];   int sg(long long x) {     if (x <= 3)       return 0;     else if (x <= 15)       return 1;     else if (x <= 81)       return 2;     else if (x <= 6723)       return 0;     else if (x <= 50625)       return 3;     else if (x <= (long long)2562890625)       return 1;     else       return 2;   }   void init() {     read(n);     for (int i = 1; i <= n; ++i) {       read(a[i]);     }   }   void solve() {     int ans = 0;     for (int i = 1; i <= n; ++i) {       ans ^= sg(a[i]);     }     if (ans)       printf( Furlo n );     else       printf( Rublo n );   }   int main() {     int T = 1;     while (T--) {       init();       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> vans;   set<int> s;   int main() {     scanf( %d , &n);     int start = 1;     for (int i = 1; i <= n; ++i) {       int x;       scanf( %d , &x);       if (s.count(x)) {         vans.push_back(start);         vans.push_back(i);         start = i + 1;         s.clear();       } else {         s.insert(x);       }     }     if (vans.empty()) {       printf( -1 n );       return 0;     } else {       printf( %d n , vans.size() / 2);       for (int i = 0; i < vans.size() - 2; i += 2)         printf( %d %d n , vans[i], vans[i + 1]);       if (!s.empty())         printf( %d %d n , vans[vans.size() - 2], n);       else         printf( %d %d n , vans[vans.size() - 2], vans[vans.size() - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long N = 1e7 + 5;   std::vector<long long> v(N, 0);   std::vector<long long> p;   void sieve() {     for (long long i = 2; i < N; i++) {       if (v[i] != 0) continue;       p.push_back(i);       for (long long j = 2 * i; j < N; j += i) v[j] = 1;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long cnt = 0;     for (long long i = 2; i <= (long long)sqrt(n); i++)       if (n % i == 0) cnt++;     v[0] = 1;     v[1] = 1;     if (cnt == 0) {       cout <<  1  <<   n ;       cout << n;       return 0;     }     sieve();     long long bal = 0;     if (n % 2 == 0)       bal = 2;     else       bal = 3;     long long temp = n - bal;     if (n == 4) {       cout << 2 <<   n  << 2 <<     << 2;       return 0;     }     for (long long i = 0; i < p.size(); i++) {       cnt = 0;       for (long long j = 2; temp - p[i] > 0 and j <= (long long)sqrt(temp - p[i]);            j++) {         if ((temp - p[i]) % j == 0) {           cnt = 1;           break;         }       }       if (!cnt) {         cout << 3 <<   n  << bal <<     << p[i] <<     << temp - p[i];         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   using PII = pair<ll, ll>;   using piii = pair<pii, pii>;   using Pi = pair<int, pii>;   using Graph = vector<vector<int>>;   const int dx[4] = {0, -1, 1, 0};   const int dy[4] = {-1, 0, 0, 1};   bool check(int x, int y) {     if (0 <= x && x < 55 && 0 <= y && y < 55)       return true;     else       return false;   }   const ll INF = 1e+7;   int gcd(int x, int y) {     if (x < y) swap(x, y);     if (y == 0) return x;     return gcd(y, x % y);   }   void mul(ll a, ll b) { a = a * b % INF; }   using Graph = vector<vector<int>>;   long long modinv(long long a, long long m) {     long long b = m, u = 1, v = 0;     while (b) {       long long t = a / b;       a -= t * b;       swap(a, b);       u -= t * v;       swap(u, v);     }     u %= m;     if (u < 0) u += m;     return u;   }   const double PI = 3.14159265358979323846;   const int MAX = 510000;   ll fac[MAX], finv[MAX], inv[MAX];   void COMinit() {     fac[0] = fac[1] = 1;     finv[0] = finv[1] = 1;     inv[1] = 1;     for (int i = 2; i < MAX; ++i) {       fac[i] = fac[i - 1] * i % INF;       inv[i] = INF - inv[INF % i] * (INF / i) % INF;       finv[i] = finv[i - 1] * inv[i] % INF;     }   }   ll COM(int n, int k) {     if (n < k) return 0;     if (n < 0 || k < 0) return 0;     return fac[n] * (finv[k] * finv[n - k] % INF) % INF;   }   double Euclidean_distance(double x1, double y1, double x2, double y2) {     return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));   }   int prime[1001000];   bool is_prime[1001010];   int sieve(int n) {     int p = 0;     for (int i = 0; i <= n; ++i) {       is_prime[i] = true;     }     is_prime[0] = false;     is_prime[1] = false;     for (int i = 2; i <= n; ++i) {       if (is_prime[i]) {         prime[p] = i;         p++;         for (int j = 2 * i; j <= n; j += i) {           is_prime[j] = false;         }       }     }     return p;   }   map<int, int> prime_factor(int n) {     map<int, int> res;     for (int i = 2; i * i <= n; ++i) {       while (n % i == 0) {         ++res[i];         n /= i;       }     }     if (n != 1) res[n] = 1;     return res;   }   ll powmod(ll a, ll k, ll mod) {     ll ap = a, ans = 1;     while (k) {       if (k & 1) {         ans *= ap;         ans %= mod;       }       ap = ap * ap;       ap %= mod;       k >>= 1;     }     return ans;   }   ll invi(ll a, ll mod) { return powmod(a, mod - 2, mod); }   int main() {     int t;     cin >> t;     while (t--) {       ll n, m;       cin >> n >> m;       if (n == 1 || m == 1) {         cout <<  YES  << endl;       } else if (n == 2 && m == 2) {         cout <<  YES  << endl;       } else {         cout <<  NO  << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 4;   set<int> ts[N];   map<int, int> tmp;   int n, k, a[N];   void add(int v) {     auto it1 = tmp.find(v);     if (it1 == tmp.end()) {       tmp.emplace(v, 1);       ts[1].insert(v);     } else {       ts[it1->second].erase(v);       it1->second++;       ts[it1->second].insert(v);     }   }   void del(int v) {     auto it1 = tmp.find(v);     if (it1->second == 1) {       ts[1].erase(v);       tmp.erase(it1);     } else {       ts[it1->second].erase(v);       it1->second--;       ts[it1->second].insert(v);     }   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= n; i++) {       add(a[i]);       if (i > k) del(a[i - k]);       if (i >= k) {         if (ts[1].empty())           puts( Nothing );         else           printf( %d n , *(ts[1].rbegin()));       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   bool issafe(int i, int j, int n, int m) {     return i >= 0 && j >= 0 && i < n && j < m;   }   char s[] = { D ,  L ,  R ,  U };   int dx[] = {+1, 0, 0, -1};   int dy[] = {0, -1, +1, 0};   void solve() {     int n, m, k;     cin >> n >> m >> k;     char a[n][m];     int dist[n][m];     pair<int, int> start;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         dist[i][j] = -1;         cin >> a[i][j];         if (a[i][j] ==  X ) {           start = {i, j};         }       }     }     if (k & 1) {       cout <<  IMPOSSIBLE             <<   n ;       return;     }     queue<pair<int, int> > q;     q.push(start);     dist[start.first][start.second] = 0;     while (!q.empty()) {       pair<int, int> curr = q.front();       q.pop();       for (int i = 0; i < 4; i++) {         int nx = curr.first + dx[i], ny = curr.second + dy[i];         if (issafe(nx, ny, n, m) && a[nx][ny] !=  *  && dist[nx][ny] == -1) {           q.push({nx, ny});           dist[nx][ny] = dist[curr.first][curr.second] + 1;         }       }     }     string ans =   ;     pair<int, int> curr = start;     bool flag = 0;     while (k) {       flag = 0;       for (int i = 0; i < 4; i++) {         int nx = curr.first + dx[i], ny = curr.second + dy[i];         if (issafe(nx, ny, n, m) && a[nx][ny] !=  *  && dist[nx][ny] <= k) {           flag = 1;           ans += s[i];           curr = {nx, ny};           k--;           break;         }       }       if (!flag) break;     }     if (!flag) {       cout <<  IMPOSSIBLE             <<   n ;       return;     }     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 4005;   int n;   struct child {     long long v, d, p;     int idx;     child(long long v, long long d, long long p, int idx)         : v(v), d(d), p(p), idx(idx) {}   };   long long v, d, p;   vector<child *> ve;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = (0); i < (n); i++) {       cin >> v >> d >> p;       ve.push_back(new child(v, d, p, i));     }     vector<int> ans;     while (!ve.empty()) {       ans.push_back(ve[0]->idx);       ve[0]->p = -1;       for (int i = (1); i < (((int)(ve).size())); i++) {         ve[i]->p -= max(0LL, ve[0]->v - i + 1);         if (ve[i]->p < 0) {           for (int j = (i + 1); j < (((int)(ve).size())); j++) {             ve[j]->p -= ve[i]->d;           }         }       }       ve.erase(stable_partition((ve).begin(), (ve).end(),                                 [&](child *c) { return c->p >= 0; }),                ve.end());     }     cout << ((int)(ans).size()) <<   n ;     for (int x : ans) {       cout << x + 1 <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N, M;     cin >> N >> M;     vector<string> st(N);     vector<char> max(M,  0 );     for (int i = 0; i < N; i++) {       cin >> st[i];       for (int j = 0; j < M; j++)         if (st[i][j] > max[j]) max[j] = st[i][j];     }     int sum = 0;     for (int i = 0; i < st.size(); i++)       for (int j = 0; j < st[i].length(); j++)         if (st[i][j] == max[j]) {           sum++;           break;         }     cout << sum << endl;     return 0;   }