malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, U b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, U b) {     if (a < b) a = b;   }   template <typename T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T, class T1>   inline void gn(T &first, T1 &second) {     gn(first);     gn(second);   }   template <class T, class T1, class T2>   inline void gn(T &first, T1 &second, T2 &z) {     gn(first);     gn(second);     gn(z);   }   template <typename T>   inline void print(T first) {     if (first < 0) {       putchar( - );       return print(-first);     }     if (first < 10) {       putchar( 0  + first);       return;     }     print(first / 10);     putchar(first % 10 +  0 );   }   template <typename T>   inline void println(T first) {     print(first), putchar(  n );   }   template <typename T>   inline void printsp(T first) {     print(first), putchar(   );   }   template <class T, class T1>   inline void print(T first, T1 second) {     printsp(first), println(second);   }   template <class T, class T1, class T2>   inline void print(T first, T1 second, T2 z) {     printsp(first), printsp(second), println(z);   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   int E, head[5050], to[5050], nxt[5050];   void init(int n) {     E = 0;     for (int i = 1; i <= n; i++) head[i] = -1;   }   void add_edge(int u, int v) {     nxt[E] = head[u];     to[E] = v;     head[u] = E++;   }   int dp[2][5050][5050], c[5050], d[5050];   int sz[5050];   void dfs(int u) {     dp[1][u][0] = 0;     dp[0][u][0] = 0;     dp[1][u][1] = c[u] - d[u];     dp[0][u][1] = c[u];     sz[u] = 1;     for (int e = head[u]; ~e; e = nxt[e]) {       int v = to[e];       dfs(v);       for (int i = sz[u] + sz[v]; i >= 1; i--) {         for (int j = min(i, sz[v]); j >= 0 && i - j <= sz[u]; j--) {           smin(dp[0][u][i], dp[0][u][i - j] + dp[0][v][j]);           if (i && j < i) smin(dp[1][u][i], dp[1][u][i - j] + dp[1][v][j]);         }       }       sz[u] += sz[v];     }     for (int i = 1; i <= sz[u]; i++) smin(dp[1][u][i], dp[0][u][i]);   }   int main() {     int n, b;     gn(n, b);     init(n);     memset(dp, 0x3f, sizeof(dp));     for (int i = 1, first; i <= n; i++) {       gn(c[i], d[i]);       if (i > 1) {         gn(first);         add_edge(first, i);       }     }     dfs(1);     int ans = 0;     for (int i = 1; i <= n; i++)       if (dp[1][1][i] <= b) ans = i;     println(ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     set<string> s1, s2, s3;     s3.clear();     s1.clear();     s2.clear();     int n, m;     cin >> n >> m;     string str =   ;     for (int i = 0; i < n; i++) {       cin >> str;       s1.insert(str);     }     for (int i = 0; i < m; i++) {       cin >> str;       s2.insert(str);     }     set<string>::iterator it;     for (it = s1.begin(); it != s1.end(); it++) {       if (s2.find(*it) != s2.end()) {         s3.insert(*it);       }     }     int z = s3.size();     int x = s1.size() - z;     int y = s2.size() - z;     if (z % 2 != 0) {       if (x >= y) {         cout <<  YES n ;       } else {         cout <<  NO n ;       }     } else {       if (x - y >= 1)         cout <<  YES n ;       else {         cout <<  NO n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int card[10010];   int main() {     int n, r, s = 0, d = 0, l = 1, num = 0;     cin >> n;     r = n;     for (int i = 1; i <= n; i++) {       cin >> card[i];     }     while (l <= r) {       num++;       if (num & 1) {         if (card[l] > card[r]) {           s += card[l];           l++;         } else {           s += card[r];           r--;         }       } else {         if (card[l] > card[r]) {           d += card[l];           l++;         } else {           d += card[r];           r--;         }       }     }     cout << s <<     << d << endl;   }
#include <bits/stdc++.h>   using namespace std;   int dp[200010][33];   void generate() {     for (long long i = 1; i <= (200000); i++) {       for (long long j = 0; j < (32); j++) {         dp[i][j] = dp[i - 1][j] + !((1 << j) & i);       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     generate();     int t;     cin >> t;     while (t--) {       int l, r, mn = 0x3F3F3F3F;       cin >> l >> r;       for (long long j = 0; j < (32); j++) {         mn = min(mn, dp[r][j] - dp[l - 1][j]);       }       cout << mn <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   const long long inf = 9e18;   struct NODE {     long long v, id;     bool operator<(const NODE& other) const {       return v > other.v || (v == other.v && id > other.id);     }   } node[N];   long long a[N], b[N];   long long n;   long long f(long long x, long long y) { return x - 3LL * y * y + 3LL * y - 1; }   long long find(long long v, long long x) {     long long l, r, mid;     l = 0;     r = x + 1;     while (r - l > 1) {       mid = (l + r) >> 1;       if (f(x, mid) >= v)         l = mid;       else         r = mid;     }     return l;   }   long long solve(long long x) {     long long tot = 0;     int i;     for (i = 1; i <= n; i++) {       tot += (b[i] = find(x, a[i]));     }     return tot;   }   int main() {     long long k;     int i, cnt = 0;     long long l = inf, r = -inf, mid, tot;     cin >> n >> k;     for (i = 1; i <= n; i++) {       cin >> a[i];       l = min(l, f(a[i], a[i]));       r = max(r, f(a[i], 1));     }     while (r - l > 1) {       mid = (l + r) >> 1;       if (solve(mid) <= k)         r = mid;       else         l = mid;     }     tot = solve(r);     for (i = 1; i <= n; i++)       if (b[i] < a[i]) node[++cnt].v = f(a[i], b[i] + 1), node[cnt].id = i;     sort(node + 1, node + cnt + 1);     for (i = 1; i <= cnt; i++) {       if (tot == k) break;       b[node[i].id]++;       tot++;     }     for (i = 1; i <= n; i++) cout << b[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5, M = 2e4 + 5, inf = 0x3f3f3f3f, mod = 1e9 + 7;   void Print(int *a, int n) {     for (int i = 1; i < n; i++) printf( %d  , a[i]);     printf( %d n , a[n]);   }   int e[N], nt[N];   void Gnt(string a, int *nt) {     int k = 0, p = 0, n = (int)a.size();     nt[0] = n;     for (int i = 1; i < n; i++) {       if (i + nt[i - k] < p)         nt[i] = nt[i - k];       else {         if (i >= p) p = i;         while (p < n && a[p] == a[p - i]) p++;         nt[i] = p - i;         k = i;       }     }   }   void Exd(string a, string b, int *e, int *nt) {     int k = 0, p = 0, n = (int)a.size(), m = (int)b.size();     Gnt(b, nt);     for (int i = 0; i < n; i++) {       if (i + nt[i - k] < p)         e[i] = nt[i - k];       else {         if (i >= p) p = i;         while (p < n && p - i < m && a[p] == b[p - i]) p++;         e[i] = p - i;         k = i;       }     }   }   int cycle(string a) {     int n = a.size();     Gnt(a, nt);     int t = n;     for (int i = 1; i < n; i++)       if (i + nt[i] == n) {         t = n % i ? n : i;         break;       }     return t;   }   string a, b;   int k, dp[N][2];   int main() {     ios::sync_with_stdio(false), cin.tie(0);     cin >> a >> b >> k;     dp[0][a != b] = 1;     int n = (int)a.size();     a = a + a;     Exd(a, b, e, nt);     int x = 0, len = (int)b.size();     for (int i = 0; i < n; i++) {       if (e[i] >= len) x++;     }     int y = n - x;     for (int i = 1; i <= k; i++) {       dp[i][0] = (1LL * x * dp[i - 1][1] + 1LL * (x - 1) * dp[i - 1][0]) % mod;       dp[i][1] = (1LL * y * dp[i - 1][0] + 1LL * (y - 1) * dp[i - 1][1]) % mod;     }     printf( %d n , dp[k][0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> gr[50005];   int parent[50005];   void dfs(int src, int par) {     parent[src] = par;     for (auto nbr : gr[src]) {       if (nbr != par) dfs(nbr, src);     }   }   int main() {     int n, x, y;     cin >> n >> x >> y;     for (int i = 1; i <= n; i++) {       if (i == x) continue;       int p;       cin >> p;       gr[i].push_back(p);       gr[p].push_back(i);     }     dfs(y, 0);     for (int i = 1; i <= n; i++) {       if (i == y) continue;       cout << parent[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int casos;     cin >> casos;     while (casos > 0) {       int a, b;       cin >> a >> b;       if (a > b) {         int dif = a - b;         b -= dif;         a -= dif * 2;       } else if (b > a) {         int dif = b - a;         a -= dif;         b -= dif * 2;       }       if (a % 3 == 0 && a == b && a >= 0) {         printf( YES n );       } else {         printf( NO n );       }       casos--;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[100005], is[100005], isn[100005], N, used[100005];   vector<int> v;   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) {       char t;       int ind;       cin >> t >> ind;       a[i] = ind;       if (t ==  + )         is[ind]++;       else {         a[i] *= -1;         isn[ind]++;         N++;       }     }     for (int i = 1; i <= n; i++)       if (is[i] + N - isn[i] == m) {         v.push_back(i);         used[i] = 1;       }     if (v.size() == 1) {       for (int i = 1; i <= n; i++)         if (a[i] == v[0] || (a[i] < 0 && -a[i] != v[0]))           cout <<  Truth  << endl;         else           cout <<  Lie  << endl;     } else {       for (int i = 1; i <= n; i++)         if (a[i] > 0 && !used[a[i]])           cout <<  Lie  << endl;         else if (a[i] < 0 && !used[-a[i]])           cout <<  Truth  << endl;         else           cout <<  Not defined  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool solved;   const int MX = 1500000;   int cache_map[1 << 22];   int nxt;   int cache[MX][22];   void check_solution(vector<int>& g, vector<int>& sol, int n) {     int mask(0);     int ind(nxt);     nxt += 1;     if (nxt == MX) nxt = 0;     if (((int)sol.size()) != 1) {       for (int i(0), _l((int)(((int)sol.size())) - 1); i <= _l; ++i)         mask |= (1 << sol[i]);       int mask_prev = mask ^ (1 << sol.back());       int ind_prev(cache_map[mask_prev]);       memcpy(cache[ind], cache[ind_prev], 22 * sizeof(int));     } else {       mask |= (1 << sol.back());       for (int i(0), _l((int)(n)-1); i <= _l; ++i) cache[ind][i] = g[i];     }     cache_map[mask] = ind;     int v(sol.back());     for (int j(0), _l((int)(n)-1); j <= _l; ++j) {       if ((cache[ind][v] & (1 << j)) != 0) {         cache[ind][j] |= cache[ind][v];       }     }     int need((1 << n) - 1);     for (int i(0), _l((int)(n)-1); i <= _l; ++i)       if (cache[ind][i] != need) return;     printf( %d n , ((int)sol.size()));     for (int i(0), _l((int)(((int)sol.size())) - 1); i <= _l; ++i)       printf( %d%c , sol[i] + 1, i + 1 == ((int)sol.size()) ?   n  :    );     solved = true;   }   void try_solve(vector<int>& g, int n, int k, vector<int>& cur, int ind) {     if (solved) return;     if (((int)cur.size()) == k) {       check_solution(g, cur, n);     } else {       if (ind == n) return;       cur.push_back(ind);       try_solve(g, n, k, cur, ind + 1);       cur.pop_back();       if (solved) return;       try_solve(g, n, k, cur, ind + 1);     }   }   void solve() {     nxt = 0;     int n, m;     scanf( %d%d , &n, &m);     vector<int> g(n);     for (int i(0), _l((int)(n)-1); i <= _l; ++i) {       g[i] |= (1 << i);     }     for (int i(0), _l((int)(m)-1); i <= _l; ++i) {       int a, b;       scanf( %d%d , &a, &b);       --a, --b;       g[a] |= (1 << b);       g[b] |= (1 << a);     }     if (m == n * (n - 1) / 2) {       puts( 0 );       return;     }     solved = false;     vector<int> s;     for (int i(1), _l(n); i <= _l; ++i) {       try_solve(g, n, i, s, 0);       if (solved) break;     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100009;   int n;   long long a[N];   void print_ans(int l, int r, vector<long long>& v) {     cout << l <<     << r <<   n ;     for (long long vv : v) {       cout << vv <<    ;     }     cout <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     vector<long long> fst;     fst.push_back(-a[0]);     a[0] = 0;     print_ans(1, 1, fst);     if (n == 1) {       vector<long long> zero = {0};       print_ans(1, 1, zero);       print_ans(1, 1, zero);       return 0;     }     vector<long long> scd;     for (int i = 1; i < n; ++i) {       long long md = a[i] % n;       if (md < 0) md += n;       long long nm = md * (n - 1);       scd.push_back(nm);       a[i] += nm;     }     print_ans(2, n, scd);     vector<long long> all;     for (int i = 0; i < n; ++i) {       assert(a[i] % n == 0);       all.push_back(-a[i]);     }     print_ans(1, n, all);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long f = n * (n - 1) * (n - 2) * (n - 3) * (n - 4);     cout << (f / 120) * ((n * n) - (4 * n) + 37) / 42;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, x;   vector<long long> a;   void ans() {     for (int i = 0; i < n; i++) {       cout << a[i] <<    ;     }     exit(0);   }   int main(int argc, char* argv[]) {     srand((unsigned int)time(NULL));     cin >> n >> k >> x;     a.resize(n);     int ch = 1;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] < 0) {         ch *= -1;       }     }     if (ch == 1) {       set<pair<long long, int> > s;       for (int i = 0; i < n; i++) {         if (a[i] >= 0) {           s.insert({abs(-1 - a[i]), i});         } else {           s.insert({abs(1 - a[i]), i});         }       }       auto q = *s.begin();       int id = q.second;       if (a[id] >= 0) {         while (a[id] >= 0) {           a[id] -= x;           k--;           if (k == 0) {             ans();           }         }       } else {         while (a[id] <= 0) {           a[id] += x;           k--;           if (k == 0) {             ans();           }         }       }     }     set<pair<long long, int> > s;     for (int i = 0; i < n; i++) {       s.insert({abs(a[i]), i});     }     while (k > 0) {       auto q = *s.begin();       s.erase(s.begin());       int id = q.second;       if (a[id] >= 0) {         a[id] += x;       } else {         a[id] -= x;       }       k--;       s.insert({abs(a[id]), id});     }     ans();   }
#include <bits/stdc++.h>   using namespace std;   int t;   long long n;   int main() {     cin >> t;     while (t--) {       cin >> n;       long long num;       for (long long i = 1; i < n; i++) {         if (i * i > n) {           num = i - 1;           break;         } else if (i * i == n) {           num = i;           break;         }       }       long long out = 0;       if (n == 1) {         out = 0;       } else if (n == 2) {         out = 1;       } else if (num * num == n) {         out = (num - 1) * 2;       } else if (num * (num + 1) >= n) {         out = 2 * num - 1;       } else {         out = 2 * num;       }       cout << to_string(out) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<int> v(n), v1(m);     for (int i = 0; i < n; ++i) {       cin >> v[i];     }     for (int i = 0; i < m; ++i) {       cin >> v1[i];     }     vector<int> ans;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (v[i] == v1[j]) {           ans.push_back(v[i]);           break;         }       }     }     for (auto i : ans) {       cout << i <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, d;   int main() {     cin >> n >> d;     int m;     cin >> m;     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       puts((d <= x + y && x + y <= 2 * n - d && -d <= x - y && x - y <= d)                ?  YES                 :  NO );     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int x[2600], y[2600];   string a[60];   bool valid(int y, int x1, int y1, int x, int x2, int y2) {     for (int i = min(x1, x2); i <= max(x1, x2); i++) {       if (a[i][y] !=  B ) {         return false;       }     }     for (int i = min(y1, y2); i <= max(y1, y2); i++) {       if (a[x][i] !=  B ) {         return false;       }     }     return true;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     int k = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       for (int j = 0; j < m; j++) {         if (a[i][j] ==  B ) {           x[k] = i;           y[k] = j;           k++;         }       }     }     for (int i = 0; i < k; i++) {       for (int j = i + 1; j < k; j++) {         if (valid(y[i], x[i], y[i], x[j], x[j], y[j])) {           continue;         }         if (valid(y[j], x[i], y[i], x[i], x[j], y[j])) {           continue;         }         cout <<  NO  << endl;         return 0;       }     }     cout <<  YES  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAX_N = 1e5 + 5;   long long n, val;   pair<pair<long long, long long>, pair<long long, long long> > edge[MAX_N];   long long par[MAX_N];   long long len[MAX_N];   vector<long long> h;   vector<long long> ans;   vector<pair<long long, long long> > G[MAX_N];   vector<long long> rot, ver;   long long P[MAX_N];   long long down[MAX_N];   long long up[MAX_N];   bool mark[MAX_N];   long long root(long long v) {     return (par[v] == v ? v : par[v] = root(par[v]));   }   void cheak(long long tmp, long long id) {     if (val < tmp) {       val = tmp;       ans.clear();     }     if (val == tmp) ans.push_back(id);   }   long long dfs1(long long v, long long p) {     P[v] = p;     down[v] = len[v];     mark[v] = true;     for (pair<long long, long long> u : G[v])       if (!mark[u.first]) down[v] += dfs1(u.first, v);     return down[v];   }   void dfs2(long long v, long long uval) {     up[v] = uval;     for (pair<long long, long long> u : G[v])       if (u.first != P[v]) dfs2(u.first, uval + down[v] - down[u.first]);   }   void dfs3(long long v) {     for (pair<long long, long long> u : G[v])       if (u.first != P[v]) {         dfs3(u.first);         cheak(up[u.first] * down[u.first], u.second);       }   }   void calc() {     for (long long id : h) {       ver.push_back(root(edge[id].second.first));       ver.push_back(root(edge[id].second.second));     }     sort(ver.begin(), ver.end());     ver.resize(unique(ver.begin(), ver.end()) - ver.begin());     for (long long id : h) {       G[root(edge[id].second.first)].push_back(           {root(edge[id].second.second), edge[id].first.second});       G[root(edge[id].second.second)].push_back(           {root(edge[id].second.first), edge[id].first.second});     }     for (long long v : ver)       if (!mark[v]) {         rot.push_back(v);         dfs1(v, v);       }     for (long long v : rot) dfs2(v, 0);     for (long long v : rot) dfs3(v);     rot.clear();     for (long long v : ver) {       G[v].clear();       mark[v] = false;     }     ver.clear();   }   int main() {     ios::sync_with_stdio(false), cin.tie(0);     cin >> n;     for (long long i = 0; i < n - 1; i++) {       long long v, u, d;       cin >> edge[i].second.first >> edge[i].second.second >> edge[i].first.first;       edge[i].first.second = i + 1;       edge[i].second.first--, edge[i].second.second--;     }     sort(edge, edge + n - 1);     for (long long i = 0; i < n; i++) {       par[i] = i;       len[i] = 1;     }     h.push_back(0);     for (long long i = 1; i < n - 1; i++) {       if (edge[i].first.first != edge[i - 1].first.first) {         calc();         for (long long id : h) {           len[root(edge[id].second.second)] += len[root(edge[id].second.first)];           par[root(edge[id].second.first)] = root(edge[id].second.second);         }         h.clear();       }       h.push_back(i);     }     calc();     cout << 2 * val <<     << ans.size() <<   n ;     sort(ans.begin(), ans.end());     for (long long u : ans) cout << u <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int m, k, d;   void print(int a, int b) {     printf( %d %d n , a, b);     a += d, b += d;     printf( %d %d n , a, b);   }   int main() {     cin >> k;     if (k % 2 == 0) {       cout <<  NO ;       return 0;     }     cout <<  YES  << endl;     d = 4 * k - 2, m = (k * d) / 2;     cout << d <<     << m << endl;     d /= 2;     cout << 1 <<     << 1 + d << endl;     for (int i = 2; i <= k; i++) print(1, i);     for (int i = 2; i <= k; i++)       for (int j = k + 1; j <= 2 * k - 1; j++) print(i, j);     for (int i = 0; i < (k / 2); i++) print(k + 1 + 2 * i, k + 2 + 2 * i);     return 0;   }
#include <bits/stdc++.h>   const long long int mod = 9999999999999983;   long long int primes[6] = {1125899906842597, 1495921043, 1005985879,                              1495921043,       1005985879, 1495921043};   using namespace std;   vector<string> vect;   long long int level[1000009];   vector<string> vt[1000009];   map<string, long long int> mp;   void printWords(string str) {     string word;     stringstream iss(str);     while (iss >> word) vect.push_back(word);   }   int main() {     int start_s = clock();     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int i, j, k, n, m, store, mxlevel = 0;     stack<long long int> stk;     string str, str1;     cin >> str;     for (i = 0; i < str.size(); i++) {       if (str[i] ==  , ) str[i] =    ;     }     printWords(str);     for (i = 0; i < vect.size(); i++) {       str1 = vect[i];       if (str1[0] -  0  >= 0 && str1[0] -  0  <= 9) {         string s = str1;         stringstream geek(s);         long long int number = 0;         geek >> number;         if (number != 0) stk.push(number);         continue;       }       if (stk.size() == 0)         level[i] = 0;       else {         level[i] = stk.size();         store = stk.top();         stk.pop();         if (store - 1 != 0) stk.push(store - 1);         if (store - 1 == 0 && vect[i + 1] !=  0 ) stk.push(0);         if (store - 1 == 0 && vect[i + 1] ==  0 ) {           while (stk.size() > 0) {             if (stk.top() == 0)               stk.pop();             else               break;           }         }       }     }     for (i = 0; i < vect.size(); i++) {       str1 = vect[i];       if (str1[0] -  0  >= 0 && str1[0] -  0  <= 9) {         continue;       } else {         mxlevel = max(mxlevel, level[i]);         vt[level[i]].push_back(vect[i]);       }     }     cout << mxlevel + 1 <<   n ;     for (i = 0; i < mxlevel + 1; i++) {       for (j = 0; j < vt[i].size(); j++) {         cout << vt[i][j] <<    ;       }       cout <<   n ;     }   }
#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);   }   int a[100005];   long long s[100005], b[100005];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) scanf( %d , a + i);     sort(a, a + n);     s[0] = a[0];     b[n] = 0;     for (int i = 1; i <= n; ++i) s[i] = s[i - 1] + a[i];     for (int i = n - 1; i >= 0; --i) b[i] = b[i + 1] + a[i];     long long ll = 0, rr = n;     for (int i = 0; i < n; ++i) {       ll += (a[i] * (i + 1LL) - s[i] + b[i] - a[i] * (n - i + 0LL) + a[i]);     }     long long g = gcd(ll, rr);     cout << ll / g <<     << rr / g << endl;     return 0;   }