malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 30;   const int Mod = 1000000007;   char s[1010];   bool dp[1010][2 * 1010][3];   int v[1010];   int pre[1010][2 * 1010][3];   char ch[4];   int main() {     int n, m;     ch[0] =  W , ch[1] =  L , ch[2] =  D ;     scanf( %d %d %s , &n, &m, s + 1);     dp[0][1010][0] = dp[0][1010][1] = dp[0][1010][2] = true;     for (int i = 0; i < n; ++i) {       for (int j = 1010 - i; j <= 1010 + i; ++j) {         if (abs(j - 1010) >= m) continue;         for (int t = 0; t < 3; ++t) {           if (!dp[i][j][t]) continue;           if (s[i + 1] ==  W ) {             dp[i + 1][j + 1][0] = true;             pre[i + 1][j + 1][0] = t;           } else if (s[i + 1] ==  L ) {             dp[i + 1][j - 1][1] = true;             pre[i + 1][j - 1][1] = t;           } else if (s[i + 1] ==  D ) {             dp[i + 1][j][2] = true;             pre[i + 1][j][2] = t;           } else {             dp[i + 1][j + 1][0] = true;             pre[i + 1][j + 1][0] = t;             dp[i + 1][j - 1][1] = true;             pre[i + 1][j - 1][1] = t;             dp[i + 1][j][2] = true;             pre[i + 1][j][2] = t;           }         }       }     }     bool flag = false;     for (int k = 0; k <= 2 && !flag; ++k) {       if (dp[n][1010 + m][k]) {         flag = true;         int y = 1010 + m, z = k;         for (int i = n; i >= 1; --i) {           s[i] = ch[z];           int zz = z;           z = pre[i][y][z];           if (zz == 0) y--;           if (zz == 1) y++;         }         printf( %s n , s + 1);       }     }     for (int k = 0; k <= 2 && !flag; ++k) {       if (dp[n][1010 - m][k]) {         flag = true;         int y = 1010 - m, z = k;         for (int i = n; i >= 1; --i) {           s[i] = ch[z];           int zz = z;           z = pre[i][y][z];           if (zz == 0) y--;           if (zz == 1) y++;         }         printf( %s n , s + 1);       }     }     if (!flag) puts( NO );     return 0;   }
#include <bits/stdc++.h>   int dx[] = {0, 0, 1, -1, 1, -1, 1, -1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   const double PI = acos(-1), EPS = 1e-7;   const int OO = 0x3f3f3f3f, N = 1e6 + 5, mod = 1e9 + 7;   using namespace std;   long long gcd(long long x, long long y) { return (!y) ? x : gcd(y, x % y); }   long long lcm(long long x, long long y) { return ((x / gcd(x, y)) * y); }   void file() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int n, red, blue, cnt;   vector<vector<int>> g;   vector<int> col;   pair<int, int> DFS(int v, int p = -1) {     int r = (col[v] == 1), b = (col[v] == 2);     for (auto u : g[v])       if (u != p) {         auto tmp = DFS(u, v);         cnt += (tmp.first == red && tmp.second == 0);         cnt += (tmp.first == 0 && tmp.second == blue);         r += tmp.first;         b += tmp.second;       }     return make_pair(r, b);   }   int main() {     file();     cin >> n;     g = vector<vector<int>>(n + 1);     col = vector<int>(n + 1);     for (int i = 1; i <= n; i++) {       cin >> col[i];       if (col[i] == 1) red++;       if (col[i] == 2) blue++;     }     n--;     while (n--) {       int a, b;       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     DFS(1, -1);     cout << cnt;   }
#include <bits/stdc++.h>   using namespace std;   int num[200000 + 5];   int main() {     int i, j, k, n, m;     cin >> n;     long long sum = 0;     for (i = 0; i < n; i++) {       cin >> num[i];       sum += num[i];     }     long long ans = 0;     sum++;     sum /= 2;     for (i = 0; i < n; i++) {       ans += num[i];       if (ans >= sum) {         cout << i + 1 << endl;         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   queue<int> d[110];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       for (int j = (n / 2) * (i - 1) + 1, g = 1; g <= (n / 2); j++, g++) {         d[i].push(j);       }     }     for (int i = 1; i <= n; i++) {       for (int j = (n / 2) * (n + i - 1) + 1, g = 1; g <= (n / 2); j++, g++) {         d[n - i + 1].push(j);       }     }     for (int i = 1; i <= n; i++) {       while (!d[i].empty()) {         printf( %d  , d[i].front());         d[i].pop();       }       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 10;   const int block = 450;   int n, p[maxn], l[maxn], cost[maxn], nxt[maxn], f[maxn], g[maxn], aft[maxn],       bit[maxn << 2];   void update(int pos, int x) {     for (; pos <= n; pos += (pos & -pos)) bit[pos] = max(bit[pos], x);   }   int get(int pos) {     int res = 0;     for (; pos > 0; pos -= (pos & -pos)) res = max(res, bit[pos]);     return res;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) scanf( %d%d , &p[i], &l[i]);     for (int i = n - 1; i > -1; i--) {       int pos = upper_bound(p, p + n, p[i] + l[i]) - p;       f[i] = max(get(pos), p[i] + l[i]);       update(i + 1, f[i]);       aft[i] = upper_bound(p, p + n, f[i]) - p;       if (i / block == (n - 1) / block) continue;       if (aft[i] / block > i / block) {         nxt[i] = aft[i];         g[i] = f[i];       } else {         nxt[i] = nxt[aft[i]];         g[i] = g[aft[i]];         cost[i] = cost[aft[i]] + p[aft[i]] - f[i];       }     }     int q;     cin >> q;     while (q--) {       int x, y;       scanf( %d%d , &x, &y);       x--, y--;       int ans = 0;       while (x / block < y / block && g[x] < p[y]) {         ans += cost[x] + p[nxt[x]] - g[x];         x = nxt[x];       }       if (x / block < y / block) {         ans += cost[x];         printf( %d n , ans);         continue;       }       while (f[x] < p[y]) {         ans += p[aft[x]] - f[x];         x = aft[x];       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> f(200005, 0), d(200005, 0), l(200005, 0), r(200005, -1);   map<pair<long long int, long long int>, long long int> mp;   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long int bpow(long long int a, long long int b) {     long long int res = 1;     while (b > 0) {       if (b & 1) res = (res * a) % 1000000007;       a = (a * a) % 1000000007;       b >>= 1;     }     return res % 1000000007;   }   void fact(long long int i) {     f[0] = 1;     for (long long int k = 1; k <= i; k++) {       (f[k] = f[k - 1] * k) %= 1000000007;     }   }   long long int isprime(long long int n) {     if (n == 1) return 0;     for (long long int i = 2; i <= sqrt(n); i++)       if (n % i == 0) return 0;     return 1;   }   long long int find(long long int x) {     if (f[x] == x)       return x;     else       return f[x] = find(f[x]);   }   bool cmp(long long int x, long long int y) { return x < y; }   long long int comb(long long int i, long long int j) {     long long int k = f[i];     long long int g = (f[j] * (f[i - j])) % 1000000007;     long long int h = bpow(g, 1000000007 - 2);     return (k * h) % 1000000007;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n;     cin >> n;     vector<long long int> a(n);     for (long long int i = 0; i < n; i++) cin >> a[i];     long long int mx = 0;     for (long long int i = 0; i < n; i++) {       mx = max(mx, a[i]);     }     for (long long int i = 0; i < n; i++) {       long long int k = a[i], c = 0;       while (k > 0) {         f[k]++;         r[k] = i;         l[k] += (c);         long long int h = k, j = c;         while (h <= mx) {           h *= 2;           j++;           if (r[h] != i) {             f[h]++;             r[h] = i;             l[h] += j;           } else             break;         }         k /= 2;         c++;       }     }     long long int ans = 1e18;     for (long long int i = 1; i <= 100000; i++) {       if (f[i] == n) {         ans = min(ans, l[i]);       }     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> out[1000];   int main() {     int n;     scanf( %d , &n);     int ans;     for (int i = 1; i * (i - 1) / 2 <= n; i++) {       ans = i;     }     int id = 1;     for (int i = 0; i < ans; i++) {       for (int j = i + 1; j < ans; j++) {         out[i].push_back(id);         out[j].push_back(id);         id++;       }     }     printf( %d n , ans);     for (int i = 0; i < ans; i++, puts(  ))       for (int j = 0; j < out[i].size(); j++) printf( %d  , out[i][j]);     return 0;   }
#include <bits/stdc++.h>   namespace IO {   const long long IN_LEN = 1 << 18 | 1;   static char buf[IN_LEN], *s, *t;   inline long long Getchar(void) {     return s == t && (t = (s = buf) + fread(buf, 1, IN_LEN, stdin)),            s == t ? -1 : *s++;   }   template <class T>   inline void read(T& x) {     static long long c, f;     c = Getchar(), x = f = 0;     while (c <  0  || c >  9 ) {       if (c ==  - ) f = 1;       c = Getchar();     }     while (c <=  9  && c >=  0 ) x = x * 10 + c - 48, c = Getchar();     x = f ? -x : x;   }   }  // namespace IO   using IO::read;   using namespace std;   const long long N = 1e5 + 5;   const long long INF = 0x3f3f3f3f3f3f3f3fLL;   long long head[N], eidx, dis[N], n, m, f[N];   struct Edge {     long long nxt, to, val;   } edge[N];   queue<long long> q[N];   priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,                  greater<pair<long long, long long> > >       Q;   void dij(void) {     static long long u, w;     memset(dis, 0x3f, sizeof dis);     Q.push(pair<long long, long long>(dis[1] = 0, 1));     while (!Q.empty()) {       u = Q.top().second, w = Q.top().first;       Q.pop();       if (dis[u] != w) continue;       for (long long i = head[u], v; i; i = edge[i].nxt)         if (dis[v = edge[i].to] > dis[u] + edge[i].val)           Q.push(pair<long long, long long>(dis[v] = dis[u] + edge[i].val, v));     }   }   void bfs(const long long& lim) {     static long long u, mx;     mx = 0;     memset(f, 0x3f, sizeof f);     q[0].push(1), f[1] = 0;     for (long long c = 0; c <= mx; ++c) {       while (!q[c].empty()) {         u = q[c].front();         q[c].pop();         if (f[u] < c) continue;         for (long long i = head[u], v; i; i = edge[i].nxt)           if (f[(v = edge[i].to)] > dis[u] - dis[v] + edge[i].val + f[u]) {             f[v] = dis[u] - dis[v] + edge[i].val + f[u];             if (f[v] <= lim && f[v] < n - 1) q[f[v]].push(v), mx = max(mx, f[v]);           }       }     }   }   signed main(void) {     long long q;     read(n), read(m), read(q);     for (long long i = 1, u, v, w; i <= m; ++i) {       read(u), read(v), read(w);       edge[++eidx] = (Edge){head[u], v, w};       head[u] = eidx;     }     dij();     long long opt, x, y;     while (q--) {       read(opt), read(x);       if (opt == 1)         printf(dis[x] == INF ?  -1 n  :  %lld n , dis[x]);       else {         for (long long i = 1; i <= x; ++i) {           read(y);           ++edge[y].val;         }         bfs(x);         for (long long i = 1; i <= n; ++i) dis[i] = min(INF, dis[i] + f[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, n, j, temp, num;     stringstream s, t;     cin >> a >> b >> n;     string out;     s << a;     num = a;     for (j = 0; j < 10; j++) {       s << j;       s >> temp;       if (temp % b == 0) {         num = temp;         s.clear();         s << num;         break;       } else {         s.clear();         s << num;       }     }     if (j == 10)       cout << -1;     else {       for (int i = 0; i < n - 1; i++) s <<  0 ;       s >> out;       cout << out;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int p[1000001];   int main() {     int n, ind = 0, w, input;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> input;       p[input]++;       if (ind < p[input]) {         ind = p[input];         w = input;       }     }     cout << w << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long calc_gcd(long long a, long long b) {     while (true)       if (a)         b %= a, swap(a, b);       else         return b;   }   void foo() {     long long A, M;     cin >> A >> M;     long long gcd = calc_gcd(A, M);     A /= gcd;     M /= gcd;     set<long long> yakusuu;     long long tmp = M;     while (tmp % 2 == 0) {       yakusuu.insert(2);       tmp /= 2;     }     for (long long i = 3; i * i <= M; i += 2) {       while (tmp % i == 0) {         yakusuu.insert(i);         tmp /= i;       }     }     if (tmp > 1) {       yakusuu.insert(tmp);       tmp = 1;     }     vector<long long> yakusuu_vec;     for (auto it : yakusuu) yakusuu_vec.push_back(it);     long long limit = 1;     limit <<= yakusuu_vec.size();     long long foo = 0;     long long bar = 0;     for (long long i = 0; i < limit; i++) {       long long tmp = 1;       long long count = 0;       for (long long k = 0; k < (yakusuu_vec.size()); k++) {         if (((i >> k) & 1) == 1) {           tmp *= yakusuu_vec[k];           count++;         }       }       if (count % 2) {         foo -= (A + M - 1) / tmp;         bar -= (A - 1) / tmp;       } else {         foo += (A + M - 1) / tmp;         bar += (A - 1) / tmp;       }     }     cout << (foo - bar) << endl;   }   void solve() {     long long T;     cin >> T;     for (long long t = 0; t < (T); t++) foo();   }   int main(void) {     cin.tie(0);     ios::sync_with_stdio(false);     cout.precision(12);     cout << fixed;     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int fib[51];   vector<long long int> calc(long long int n, long long int k) {     vector<long long int> res;     if (!n) return res;     if (n == 1) {       res.push_back(1);       return res;     }     if (k <= fib[n - 1]) {       res.push_back(1);       vector<long long int> v = calc(n - 1, k);       for (auto i : v) res.push_back(i + 1);     } else {       res.push_back(2);       res.push_back(1);       vector<long long int> v = calc(n - 2, k - fib[n - 1]);       for (auto i : v) res.push_back(i + 2);     }     return res;   }   void solve() {     fib[1] = 1, fib[2] = 2;     for (long long int i = 3; i <= 50; i++) fib[i] = fib[i - 1] + fib[i - 2];     long long int n, k;     cin >> n >> k;     vector<long long int> ans = calc(n, k);     for (auto i : ans) cout << i <<    ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     cout.precision(20);     long long int t = 1;     for (long long int i = 1; i <= t; i++) {       if (0) cout <<  Case #  << i <<  :  ;       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void pv(T a, T b) {     for (T i = a; i != b; ++i) cout << *i <<    ;     cout << endl;   }   template <class T>   void chmin(T &t, T f) {     if (t > f) t = f;   }   template <class T>   void chmax(T &t, T f) {     if (t < f) t = f;   }   int in() {     int x;     scanf( %d , &x);     return x;   }   int N;   long long T[10010], C[10010];   int main() {     int i;     for (; ~scanf( %d , &N);) {       for (i = 0; i < N; ++i) {         T[i] = in();         C[i] = in();       }       long long ans = 0;       long long t = 0;       for (i = 0; i < N; ++i) {         if (t <= T[i]) {           chmax(ans, C[i]);           t = T[i] + C[i];         } else {           chmax(ans, (t - T[i]) + C[i]);           t += C[i];         }       }       cout << t <<     << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a[100009], dau, cuoi, d[100009], c[100009], Res;   string st;   void Input() {     cin >> n >> k >> st;     for (int i = 0; i < n; ++i) {       a[i + 1] = st[i] -  a ;     }   }   void Solve() {     dau = 1;     cuoi = 1;     d[0] = 0;     c[0] = 0;     while (cuoi <= n) {       if (a[cuoi] == 0) {         d[cuoi] = d[cuoi - 1] + 1;         c[cuoi] = c[cuoi - 1];       } else {         if (c[cuoi - 1] + 1 <= k) {           d[cuoi] = d[cuoi - 1] + 1;           c[cuoi] = c[cuoi - 1] + 1;         } else {           c[cuoi] = c[cuoi - 1] + 1;           d[cuoi] = d[cuoi - 1] + 1;           while (dau <= cuoi) {             if (c[cuoi] > k) {               if (a[dau] == 1) {                 c[cuoi]--;               }               dau++;               d[cuoi]--;             } else               break;           }         }       }       Res = max(Res, d[cuoi]);       cuoi++;     }     dau = 1;     cuoi = 1;     d[0] = 0;     c[0] = 0;     while (cuoi <= n) {       if (a[cuoi] == 1) {         d[cuoi] = d[cuoi - 1] + 1;         c[cuoi] = c[cuoi - 1];       } else {         if (c[cuoi - 1] + 1 <= k) {           d[cuoi] = d[cuoi - 1] + 1;           c[cuoi] = c[cuoi - 1] + 1;         } else {           c[cuoi] = c[cuoi - 1] + 1;           d[cuoi] = d[cuoi - 1] + 1;           while (dau <= cuoi) {             if (c[cuoi] > k) {               if (a[dau] == 0) {                 c[cuoi]--;               }               dau++;               d[cuoi]--;             } else               break;           }         }       }       Res = max(Res, d[cuoi]);       cuoi++;     }     cout << Res;   }   int main() {     Input();     Solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     int c[n], w[m];     for (int i = 0; i < n; i++) cin >> c[i];     for (int i = 0; i < m; i++) cin >> w[i];     int res = 0;     int j = 0;     for (int i = 0; i < n; i++) {       if (j > m - 1) {         break;       }       if (w[j] >= c[i]) {         res++;         j++;       }     }     cout << res <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int dr[] = {0, -1, 0, 1, -1, 1, 1, -1};   const int dc[] = {1, 0, -1, 0, 1, 1, -1, -1};   const double eps = 1e-9;   template <class T>   void print(const vector<T> &v) {     ostringstream os;     for (int i = 0; i < (int)v.size(); ++i) {       if (i) os <<    ;       os << v[i];     }     cout << os.str() << endl;   }   template <class T>   int sz(const T &c) {     return (int)c.size();   }   template <class T>   void srt(T &c) {     sort(c.begin(), c.end());   }   template <class T>   void checkmin(T &a, T b) {     if (b < a) a = b;   }   template <class T>   void checkmax(T &a, T b) {     if (b > a) a = b;   }   template <class T>   T sqr(T x) {     return x * x;   }   template <class T, class U>   T cast(U x) {     ostringstream os;     os << x;     T res;     istringstream is(os.str());     is >> res;     return res;   }   template <class T>   vector<T> split(string s, string x =    ) {     vector<T> res;     for (int i = 0; i < s.size(); i++) {       string a;       while (i < (int)s.size() && x.find(s[i]) == string::npos) a += s[i++];       if (!a.empty()) res.push_back(cast<T>(a));     }     return res;   }   template <class T>   bool inside(T r, T c, T R, T C) {     return r >= 0 && r < R && c >= 0 && c < C;   }   struct item {     int prio;     int pos;     bool operator<(const item &o) const { return prio > o.prio; }   };   void dfs(vector<vector<pair<int, int> > > &g, int u, int p,            vector<priority_queue<item> > &h) {     for (int i(0), _b(sz(g[u]) - 1); i <= _b; ++i) {       int v = g[u][i].first;       if (v == p) continue;       int c = g[u][i].second;       while (c > 0 && !h[v].empty()) {         h[u].push(h[v].top());         h[v].pop();         --c;       }       dfs(g, v, u, h);     }   }   int main(int argc, char *argv[]) {     int n;     cin >> n;     vector<priority_queue<item> > h(n);     vector<int> a(n);     for (int i(0), _n(n); i < _n; ++i) {       cin >> a[i];       item e = {a[i], i};       h[i].push(e);     }     vector<vector<pair<int, int> > > g(n);     for (int i(0), _n(n - 1); i < _n; ++i) {       int u, v, c;       cin >> u >> v >> c;       --u;       --v;       g[u].push_back(make_pair(v, c));       g[v].push_back(make_pair(u, c));     }     vector<int> res(n);     int t = 0;     int cnt = 0;     while (1) {       while (!h[0].empty()) {         item e = h[0].top();         h[0].pop();         res[e.pos] = t;         ++cnt;         if (cnt == n) goto m1;       }       dfs(g, 0, -1, h);       ++t;     }   m1:     print(res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5000;   const int MOD = 1000000007;   string mx[MAXN];   int dp[MAXN][MAXN];   int m, n;   void mainp() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> mx[i];     for (int i = 0; i < n; i++)       for (int j = m - 1; j >= 0; j--) {         if (j == m - 1)           dp[i][j] = mx[i][j] ==  1  ? 1 : 0;         else {           if (mx[i][j] ==  1 )             dp[i][j] = 1 + dp[i][j + 1];           else             dp[i][j] = 0;         }       }     int ans = 0;     for (int j = 0; j < m; j++) {       int temp[MAXN];       for (int i = 0; i < n; i++) temp[i] = dp[i][j];       sort(temp, temp + n);       for (int i = 0; i < n; i++)         if (temp[i] * (n - i) > ans) ans = temp[i] * (n - i);     }     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     mainp();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   vector<long long>::iterator ptr;   long long count = 0;   long long cache[10004];   long long dp[100005] = {0};   long long cnt[200005] = {0};   long long a[200005] = {0};   long long b[200005] = {0};   long long r[200005] = {0};   long long pr(long long n) {     if (n % 2 == 0) {       return 2;     }     for (long long i = 3; i <= sqrt(n); i = i + 2) {       if (n % i == 0) return i;     }     if (n > 2) return n;   }   long long power(long long x, unsigned long long y) {     if (y == 0)       return 1;     else if (y % 2 == 0)       return power(x, y / 2) * power(x, y / 2);     else       return x * power(x, y / 2) * power(x, y / 2);   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n = 0, p, q = 0, k, x = 0, y, m;     cin >> n >> m;     char s[1005][1005];     long long v[1005][5] = {0};     for (long long i = 0; i < m; ++i) {       for (long long j = 0; j < 5; ++j) {         v[i][j] = 0;       }     }     for (long long i = 0; i < n; ++i) {       for (long long j = 0; j < m; ++j) {         cin >> s[i][j];         if (s[i][j] ==  A )           v[j][0]++;         else if (s[i][j] ==  B )           v[j][1]++;         else if (s[i][j] ==  C )           v[j][2]++;         else if (s[i][j] ==  D )           v[j][3]++;         else if (s[i][j] ==  E )           v[j][4]++;       }     }     for (long long i = 0; i < m; ++i) {       cin >> a[i];     }     for (long long i = 0; i < m; ++i) {       p = 0;       for (long long j = 0; j < 5; ++j) {         p = max(p, v[i][j]);       }       x += (a[i] * p);     }     cout << x;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[105], b[105], t, i, k;     cin >> t;     for (i = 1; i < t + 1; i++) {       scanf( %d , &a[i]);     }     for (i = 1; i < t + 1; i++) {       k = a[i];       b[k] = i;     }     for (i = 1; i < t + 1; i++) {       printf( %d  , b[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   void dv(vector<int> v) {     for (int i = 0; i < v.size(); i++) cout << v[i] <<    ;   }   bool check_prime(int a) {     for (int i = sqrt(a); i > 1; i--) {       if (a % i == 0) return false;     }     return true;   }   int ctoil(char c) { return (int)c - 97; }   int ctoiu(char c) { return (int)c - 65; }   void dv_2d(vector<vector<int>> v) {     for (int i = 0; i < v.size(); i++) {       for (int j = 0; j < v[i].size(); j++) {         cout << v[i][j] <<    ;       }       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, m;     cin >> n >> m;     long long a, b;     if (n <= 2 * m) {       a = 0;     } else {       a = n - 2 * m;     }     if (m == 0) {       b = n;     } else {       b = n - ceil((sqrt(1 + 8 * m) + 1) / 2);     }     cout << a <<     << b << endl;   }