malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, root;   vector<vector<int> > tree, par, sub;   vector<vector<long long> > dp;   void dfs(int u) {     sub[root][u] = 1;     for (int v : tree[u]) {       if (v == par[root][u]) continue;       par[root][v] = u;       dfs(v);       sub[root][u] += sub[root][v];     }   }   long long getDP(int u, int v) {     if (u == v) return 0;     if (dp[u][v] != -1) return dp[u][v];     long long res =         sub[u][v] * sub[v][u] + max(getDP(par[v][u], v), getDP(u, par[u][v]));     return dp[u][v] = res;   }   void input() {     scanf( %d , &n);     tree.assign(n, vector<int>());     for (int i = 0; i < n - 1; ++i) {       int u, v;       scanf( %d%d , &u, &v);       --u, --v;       tree[u].push_back(v);       tree[v].push_back(u);     }   }   void solve() {     par.assign(n, vector<int>(n, -1));     sub.assign(n, vector<int>(n, -1));     for (int u = 0; u < n; ++u) {       root = u;       dfs(u);     }     dp.assign(n, vector<long long>(n, -1LL));     long long ans = 0;     for (int u = 0; u < n; ++u)       for (int v = 0; v < n; ++v) ans = max(ans, getDP(u, v));     cout << ans << endl;   }   int main() {     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, i, j, k, l, m, b, t, sum, sum1, flag, max1, min1, tmp;     cin >> n;     long long a[n + 1];     vector<long long> v;     queue<long long> q;     for (i = 1; i <= n; i++) {       cin >> a[i];       v.push_back(a[i]);       q.push(a[i]);     }     cin >> m >> k;     j = m + k;     sum = 0;     for (i = 1; i <= n; i++) {       l = a[i] / j;       sum1 = a[i] % j;       sum += l;       if (sum1 > m) {         sum++;       }     }     cout << sum * k << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, sum = 0;     cin >> n;     map<string, int> mp;     mp[ Tetrahedron ] = 4;     mp[ Cube ] = 6;     mp[ Octahedron ] = 8;     mp[ Dodecahedron ] = 12;     mp[ Icosahedron ] = 20;     while (n--) {       string s;       cin >> s;       sum += mp[s];     }     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double A[100], B[100];   int main() {     int n, V;     cin >> n >> V;     double S = 0.0;     for (int i = 0; i < n; i++) {       cin >> A[i];       S += A[i];     }     for (int i = 0; i < n; i++) A[i] *= V / S;     double MIN = 1.0;     for (int i = 0; i < n; i++) {       cin >> B[i];       MIN = min(MIN, B[i] / A[i]);     }     double result = 0.0;     for (int i = 0; i < n; i++) result += A[i] * MIN;     cout.precision(10);     cout << result;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<char, int> m;   map<char, int> m1;   int main() {     long long int n = 0, d, i = 0, j = 0, l = 0, r = 0, a = 0, b = 0, c1, c2, p,                   b2, s1 = 0, t = 0, t1 = 0, y = 0, x = 0, s2 = 0, c = 0;     char ch;     cin >> a >> b >> c;     vector<int> adj[100001];     int s[3];     s[0] = a;     s[1] = b;     s[2] = c;     n = 3;     sort(s, s + n);     a = s[2];     b = s[1];     c = s[0];     if (a >= (b + c)) {       while (a >= b + c) {         t++;         c++;       }     }     if (b >= a + c) {       while (b >= a + c) {         t++;         c++;       }     }     if (c >= b + a) {       while (c >= b + a) {         t++;         b++;       }     }     cout << t << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool f1(pair<long long, long long> x, pair<long long, long long> y) {     return x.first > y.first;   }   bool f2(pair<long long, long long> x, pair<long long, long long> y) {     return x.second > y.second;   }   bool f3(long long x, long long y) { return x > y; }   bool fa(vector<long long> x, vector<long long> y) { return x[0] < y[0]; }   long long fac(long long a) {     if (a == 1 || a == 0) {       return 1;     } else {       return (a * fac(a - 1));     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     string a;     cin >> a;     vector<long long> b;     if (a.size() == 1) {       cout << a;       exit(0);     }     a = a +  0 ;     for (long long i = 0; i < a.size() - 1; i++) {       if (a[i] == a[i + 1] && a[i] == a[i + 2]) {         a[i] =  0 ;       }     }     for (long long i = 0; i < a.size(); i++) {       if (a[i] !=  0 ) b.push_back(a[i]);     }     vector<long long> c;     long long check = 0;     for (long long i = 0; i < b.size() - 1; i++) {       if (b[i] == b[i + 1]) {         c.push_back(i);         check++;       }     }     if (check > 0) {       for (long long i = 0; i < c.size() - 1; i++) {         if (c[i] == c[i + 1] - 2) {           b[c[i + 1]] = 0;           i++;         }       }     }     for (long long i = 0; i < b.size(); i++) {       if (b[i] != 0) {         char g = b[i];         cout << g;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long dx[] = {-1, 0, 1, 0};   long long dy[] = {0, -1, 0, 1};   long long msum(long long a, long long b, long long m) {     return (a % m + b % m) % m;   }   long long msub(long long a, long long b, long long m) {     return (a % m - b % m) % m;   }   long long mpro(long long a, long long b, long long m) {     return ((a % m) * (b % m)) % m;   }   void swap(long long &a, long long &b) {     long long t = a;     a = b;     b = t;   }   long long m_m(long long a, long long b, long long m) {     long long res = 0;     a = a % m;     while (b) {       if (b & 1) {         res += a;         res = res % m;       }       a = (a * 2) % m;       b = b / 2;     }     return res;   }   long long fxp(long long a, long long b, long long m) {     if (b == 0) return 1;     if (b % 2 == 0) return fxp(m_m(a, a, m), b / 2, m);     return m_m(fxp(a, b - 1, m), a, m);   }   bool sortbysecdesc(const pair<long long, long long> &a,                      const pair<long long, long long> &b) {     return a.second > b.second;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m;     char a[n][m];     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) {         cin >> a[i][j];       }     }     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) {         if (a[i][j] ==  - )           cout << a[i][j];         else {           if ((i + j) % 2 == 0)             cout <<  B ;           else             cout <<  W ;         }       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int dp[500005][28];   int ar[500005];   int p[500005][28];   int ans[500005];   string st;   int main() {     int a, b, c, d, e, x, y, z, k, n;     cin >> n >> k;     cin >> st;     for (a = 0; a < n; a++) ar[a + 1] = st[a] -  A ;     for (a = 1; a <= n; a++) {       for (b = 0; b < k; b++) {         dp[a][b] = 500005;       }     }     for (a = 1; a <= n; a++) {       for (b = 0; b < k; b++) {         if (ar[a] == b)           c = 0;         else           c = 1;         for (d = 0; d < k; d++) {           if (b == d) continue;           if (dp[a][b] > dp[a - 1][d] + c) {             dp[a][b] = min(dp[a][b], dp[a - 1][d] + c);             p[a][b] = d;           }         }       }     }     x = 500005;     for (a = 0; a < k; a++)       if (x > dp[n][a]) {         x = dp[n][a];         b = a;       }     cout << x << endl;     a = n;     while (a >= 1) {       ans[a] = b;       b = p[a][b];       a--;     }     for (a = 1; a <= n; a++) printf( %c , ans[a] +  A );     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> tree[300001];   int cento[300001];   int sub[300001];   int maxCh[300001];   int n, q;   void dfs(int u, int p = -1) {     sub[u] = 1;     maxCh[u] = 0;     for (int j = 0; j < tree[u].size(); ++j) {       int v = tree[u][j];       if (v == p) continue;       dfs(v, u);       sub[u] += sub[v];       maxCh[u] = max(maxCh[u], sub[v]);     }   }   set<pair<pair<int, int>, int> > merge(int u, int p = -1) {     int sz = tree[u].size();     if (sz == 1 && u != 0) {       cento[u] = u;       set<pair<pair<int, int>, int> > s;       s.insert(make_pair(pair<int, int>(sub[u], maxCh[u]), u));       return s;     }     int bigCh = -1;     int maxsz = -1;     for (int j = 0; j < tree[u].size(); ++j) {       int v = tree[u][j];       if (v == p) continue;       if (maxsz < sub[v]) {         maxsz = sub[v];         bigCh = v;       }     }     set<pair<pair<int, int>, int> > s = merge(bigCh, u);     for (int j = 0; j < tree[u].size(); ++j) {       int v = tree[u][j];       if (v == p || v == bigCh) continue;       set<pair<pair<int, int>, int> > tmp = merge(v, u);       for (set<pair<pair<int, int>, int> >::iterator it = tmp.begin();            it != tmp.end(); ++it) {         s.insert(*it);       }     }     s.insert(make_pair(pair<int, int>(sub[u], maxCh[u]), u));     int x = sub[u] >> 1;     ;     if (sub[u] & 1) ++x;     set<pair<pair<int, int>, int> >::iterator it =         s.lower_bound(make_pair(pair<int, int>(x, 0), 0));     cento[u] = it->second;     return s;   }   int main() {     scanf( %d %d , &n, &q);     int v = 0;     for (int i = 1; i < n; ++i) {       scanf( %d , &v);       --v;       tree[i].push_back(v);       tree[v].push_back(i);     }     memset(cento, -1, sizeof(cento));     dfs(0, -1);     for (int i = 0; i < n; ++i) {       --sub[i];     }     merge(0, -1);     while (q--) {       int u;       scanf( %d , &u);       --u;       printf( %d n , cento[u] + 1);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 400005;   int tr[N << 2], lz[N << 2];   set<int> st[N];   inline void push(int v, int l, int r) {     tr[v] += lz[v];     if (l != r) {       lz[2 * v] += lz[v];       lz[2 * v + 1] += lz[v];     }     lz[v] = 0;   }   void build(int v, int l, int r, int n) {     lz[v] = 0;     if (l == r) {       tr[v] = l - 1;       return;     }     int m = (l + r) / 2;     build(2 * v, l, m, n);     build(2 * v + 1, m + 1, r, n);     tr[v] = max(tr[2 * v], tr[2 * v + 1]);   }   void update(int v, int s, int e, int l, int r, int x) {     push(v, s, e);     if (l <= s && e <= r) {       tr[v] += x;       if (s != e) {         lz[2 * v] += x;         lz[2 * v + 1] += x;       }       return;     }     if (r < s || e < l || l > r) return;     int m = (s + e) / 2;     update(2 * v, s, m, l, r, x);     update(2 * v + 1, m + 1, e, l, r, x);     tr[v] = max(tr[2 * v], tr[2 * v + 1]);   }   int query(int v, int s, int e, int l, int r) {     push(v, s, e);     if (l <= s && e <= r) return tr[v];     int m = (s + e) / 2;     if (r <= m) return query(2 * v, s, m, l, r);     if (m < l) return query(2 * v + 1, m + 1, e, l, r);     return max(query(2 * v, s, m, l, r), query(2 * v + 1, m + 1, e, l, r));   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cout << setprecision(32);     int n, k, m;     cin >> n >> k >> m;     int n2 = n << 1;     build(1, 1, n2, n2);     int x, y;     map<int, int> mp;     while (m--) {       cin >> x >> y;       y += abs(k - x);       if (st[y].find(x) != st[y].end()) {         update(1, 1, n2, 1, y, -1);         st[y].erase(x);         mp[y]--;         if (!mp[y]) mp.erase(y);       } else {         update(1, 1, n2, 1, y, 1);         st[y].insert(x);         mp[y]++;       }       if (mp.empty()) {         cout << 0 <<   n ;         continue;       }       int mx = mp.rbegin()->first;       cout << max(0, query(1, 1, n2, 1, mx) - n) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5;   const int mod = 998244353;   long long qpow(long long a, long long b) {     long long ans = 1;     a %= mod;     assert(b >= 0);     for (; b; b >>= 1) {       if (b & 1) ans = ans * a % mod;       a = a * a % mod;     }     return ans;   }   long long gcd(long long a, long long b) { return b > 0 ? gcd(b, a % b) : a; }   int a[maxn];   int w[maxn];   int one, zero, num, sum;   long long dp[60][60][60][60];   long long ans[60];   int main() {     int n, m, T;     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> a[i], num += a[i];     for (int i = 1; i <= n; i++)       cin >> w[i], sum = (sum + w[i]) % mod, one = (one + a[i] * w[i]) % mod;     zero = (sum - one + mod) % mod;     for (int i = 1; i <= n; i++) {       if (a[i] == 0) {         dp[1][i][0][1] = 1ll * qpow(sum, mod - 2) * w[i] % mod;         dp[1][i][0][0] = 1ll * qpow(sum, mod - 2) * (zero - w[i]) % mod;         dp[1][i][1][0] = 1ll * qpow(sum, mod - 2) * (one) % mod;       } else {         dp[1][i][1][1] = 1ll * qpow(sum, mod - 2) * w[i] % mod;         dp[1][i][1][0] = 1ll * qpow(sum, mod - 2) * (one - w[i]) % mod;         dp[1][i][0][0] = 1ll * qpow(sum, mod - 2) * (zero) % mod;       }     }     for (int i = 1; i <= m; i++) {       for (int j = 1; j <= n; j++) {         for (int t = 0; t <= i; t++) {           for (int k = 0; k <= i; k++) {             int state = ((sum + t - (i - t)) % mod + mod) % mod;             int o0 = zero - (i - t);             int o1 = one + t;             if (a[j] == 0) {               dp[i + 1][j][t][k] += 1ll * dp[i][j][t][k] * qpow(state, mod - 2) %                                     mod * (o0 - (w[j] - k)) % mod;               dp[i + 1][j][t][k] %= mod;               dp[i + 1][j][t][k + 1] += 1ll * dp[i][j][t][k] *                                         qpow(state, mod - 2) % mod *                                         ((w[j] - k)) % mod;               dp[i + 1][j][t][k + 1] %= mod;               dp[i + 1][j][t + 1][k] +=                   1ll * dp[i][j][t][k] * qpow(state, mod - 2) % mod * (o1) % mod;               dp[i + 1][j][t + 1][k] %= mod;             } else {               dp[i + 1][j][t + 1][k] += 1ll * dp[i][j][t][k] *                                         qpow(state, mod - 2) % mod *                                         (o1 - (w[j] + k)) % mod;               dp[i + 1][j][t + 1][k] %= mod;               dp[i + 1][j][t + 1][k + 1] += 1ll * dp[i][j][t][k] *                                             qpow(state, mod - 2) % mod *                                             ((w[j] + k)) % mod;               dp[i + 1][j][t + 1][k + 1] %= mod;               dp[i + 1][j][t][k] +=                   1ll * dp[i][j][t][k] * qpow(state, mod - 2) % mod * (o0) % mod;               dp[i + 1][j][t][k] %= mod;             }           }         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= m; j++) {         for (int k = 0; k <= m; k++) {           int temp = a[i] ? 1 : -1;           ans[i] = (ans[i] + (w[i] + k * temp) * dp[m][i][j][k]) % mod;         }       }       cout << (ans[i] + mod) % mod << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long n;   long long b[200005];   long long cnt[65];   vector<long long> vec, vec2;   int main(void) {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> b[i];     for (int i = 1; i <= n; i++) {       long long x = 0;       for (long long t = b[i]; t % 2 == 0; t /= 2) x++;       cnt[x]++;     }     long long mn = -1e9, mn_i;     for (int i = 0; i < 65; i++) {       if (mn < cnt[i]) {         mn = cnt[i];         mn_i = i;       }     }     for (int i = 1; i <= n; i++) {       if (!(b[i] % (1LL << mn_i) == 0 && b[i] % (1LL << (mn_i + 1))))         vec.push_back(b[i]);     }     cout << (int)vec.size() << endl;     for (int i = 0; i < vec.size(); i++) cout << vec[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e9;   const long long N = 1e5 + 1;   const long long mod = 1e9 + 7;   const long double eps = 1E-7;   vector<int> a[N];   int n, k, x, ans;   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> k;     for (int i = 1; i <= k; i++) cin >> x, a[x].push_back(i);     for (int i = 1; i <= n; i++) {       if (a[i].size() == 0)         ans += 1 + (i != 1) + (i != n);       else {         x = a[i][0];         if (i != 1)           if (upper_bound(a[i - 1].begin(), a[i - 1].end(), x) == a[i - 1].end())             ans++;         if (i != n)           if (upper_bound(a[i + 1].begin(), a[i + 1].end(), x) == a[i + 1].end())             ans++;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   void fast_io() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   signed main() {     fast_io();     long long x, y, z, t1, t2, t3;     cin >> x >> y >> z >> t1 >> t2 >> t3;     long long time1 = abs(y - x) * t1;     long long time2 = abs(x - z) * t2 + abs(y - x) * t2 + 3 * t3;     if (time2 <= time1) {       cout <<  YES ;     } else {       cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> a[1000001];   int b[1000001], ans[1000001];   int main() {     int n, h;     cin >> n >> h;     for (int i = 0; i < n; i++) {       int c;       cin >> c;       a[i] = make_pair(c, i + 1);     }     sort(a, a + n);     for (int i = 0; i < n; i++) b[i] = a[i].first;     int diff = b[n - 1] + b[n - 2] - b[0] - b[1];     int km = 0;     for (int k = 1; k < n; k++) {       int other;       int small = int(1e9);       if (k >= 2) {         other = b[1] + b[2];         if (other < small) small = other;       }       other = b[0] + b[1] + h;       if (other < small) small = other;       if (k < n - 1) {         other = b[0] + b[k + 1];         if (other < small) small = other;       }       int big = b[n - 1] + h;       if (k == n - 1)         big += b[0];       else         big += b[k];       other = b[n - 1] + b[n - 2];       if (other > big) big = other;       if (big - small < diff) {         diff = big - small;         km = k;       }     }     cout << diff << endl;     for (int i = 1; i <= n; i++) ans[i] = 1;     for (int i = 1; i <= km; i++) ans[a[i].second] = 2;     for (int i = 1; i <= n; i++) cout << ans[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int power(int x, int y, int p) {     int res = 1;     x = x % p;     if (x == 0) return 0;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   int main() {     {       ios_base::sync_with_stdio(0);       cin.tie(NULL);       cout.tie(NULL);     };     long long k, x = 1;     string s =  codeforces ;     int arr[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};     cin >> k;     while (x < k) {       for (int i = 0; i < 10; i++) {         long long m = 1;         for (int j = 0; j < 10; j++)           if (j != i) m *= arr[j];         x += m;         arr[i]++;         if (x >= k) {           break;         };       }     }     for (int i = 0; i < 10; i++)       for (int j = 0; j < arr[i]; j++) cout << s[i];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string second;     int ans = 0, a = 1;     cin >> second;     int k = second.length() - 1;     for (int i = 1; i < second.size(); i++) {       ans += (1 << i);     }     for (int i = 0; i < second.length(); i++) {       if (i == k) {         if (second[i] ==  4 )           ans += 1;         else           ans += 2;         continue;       }       if (second[i] ==  4 ) continue;       ans += (1 << (k - i));     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   const double PI = acos(-1.0);   using namespace std;   const int MAXN = 500117;   int n, a[MAXN], ans;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; scanf( %d , &a[i++]))       ;     int j = 0, cur = 0;     for (int i = 1; i < n - 1; i++) {       if (a[i] != a[i - 1] && a[i] != a[i + 1]) {         if (cur == 0) j = i;         cur++;       } else if (cur > 0) {         ans = max(ans, (cur + 1) / 2);         for (int k = j, t = i - 1; k <= t;              a[k] = a[k - 1], a[t] = a[t + 1], k++, t--)           ;         cur = 0;       }     }     if (cur > 0) {       ans = max(ans, (cur + 1) / 2);       for (int k = j, t = n - 2; k <= t;            a[k] = a[k - 1], a[t] = a[t + 1], k++, t--)         ;     }     printf( %d n , ans);     for (int i = 0; i < n; printf( %d  , a[i++]))       ;     putchar(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int sum = 0;     bool ne = 0;     for (int i = 0; i < 5; i++) {       int x;       cin >> x;       sum += x;     }     if (sum % 5 != 0 or sum == 0) {       cout <<  -1 ;     } else       cout << sum / 5;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int n, q;   char s[N];   int t[26][4 * N];   int c[26][4 * N];   int d[26];   void pushDown(int id, int p, int l, int r, int m) {     if (c[id][p] == 0) {       t[id][p << 1] = 0;       t[id][p << 1 | 1] = 0;       c[id][p << 1] = 0;       c[id][p << 1 | 1] = 0;       c[id][p] = -1;     } else if (c[id][p] == 1) {       t[id][p << 1] = m - l + 1;       t[id][p << 1 | 1] = r - m;       c[id][p << 1] = 1;       c[id][p << 1 | 1] = 1;       c[id][p] = -1;     }   }   void update(int id, int p, int l, int r, int u, int v, int add) {     if (v < l || r < u) return;     if (u <= l && r <= v) {       t[id][p] = (r - l + 1) * add;       c[id][p] = add;       return;     }     int m = (l + r) >> 1;     pushDown(id, p, l, r, m);     update(id, p << 1, l, m, u, v, add);     update(id, p << 1 | 1, m + 1, r, u, v, add);     t[id][p] = t[id][p << 1] + t[id][p << 1 | 1];   }   int getSum(int id, int p, int l, int r, int u, int v) {     if (v < l || r < u) return 0;     if (u <= l && r <= v) return t[id][p];     int m = (l + r) >> 1;     pushDown(id, p, l, r, m);     int t1 = getSum(id, p << 1, l, m, u, v);     int t2 = getSum(id, p << 1 | 1, m + 1, r, u, v);     return t1 + t2;   }   int main() {     scanf( %d %d n , &n, &q);     scanf( %s n , s);     memset(t, 0, sizeof t);     memset(c, 0xff, sizeof c);     for (int i = 0; i < n; ++i) update(s[i] -  a , 1, 1, n, i + 1, i + 1, 1);     while (q--) {       int u, v, type;       scanf( %d %d %d n , &u, &v, &type);       for (int i = 0; i < 26; ++i) d[i] = getSum(i, 1, 1, n, u, v);       for (int i = 0; i < 26; ++i) update(i, 1, 1, n, u, v, 0);       if (type == 1) {         int p = u;         for (int i = 0; i < 26; ++i)           if (d[i]) {             update(i, 1, 1, n, p, p + d[i] - 1, 1);             p += d[i];           }       } else {         int p = u;         for (int i = 25; i >= 0; --i)           if (d[i]) {             update(i, 1, 1, n, p, p + d[i] - 1, 1);             p += d[i];           }       }     }     for (int i = 1; i <= n; ++i) {       for (int j = 0; j < 26; ++j) {         int p = getSum(j, 1, 1, n, i, i);         if (p) {           printf( %c ,  a  + j);           break;         }       }     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   int n, a[200010];   int main() {     scanf( %d , &n);     for (int i = 0; i < n * 2; i++) scanf( %d , a + i);     std::sort(a, a + n * 2);     long long ans = (a[n - 1] - a[0]) * 1ll * (a[n * 2 - 1] - a[n]), tmp;     for (int i = 0; i < n; i++)       if ((tmp = (a[n * 2 - 1] - a[0]) * 1ll * (a[i + n] - a[i + 1])) < ans)         ans = tmp;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, p, c, t, sum = 0, res = 0, m, x = 0, y = 0;   vector<int> v, z;   int main() {     cin >> n >> c;     for (int i = 0; i < n; ++i) {       cin >> p;       v.push_back(p);     }     for (int i = 0; i < n; ++i) {       cin >> t;       z.push_back(t);     }     m = n - 1;     for (int i = 0; i < n; i++) {       x += z[i];       p = v[i] - (c * x);       if (p > 0) sum += p;       y += z[m];       t = v[m] - (c * y);       if (t > 0) res += t;       m--;     }     if (sum > res)       cout <<  Limak  << endl;     else if (res > sum)       cout <<  Radewoosh  << endl;     else       cout <<  Tie  << endl;     return 0;   }