malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long upper_limit = 1e9;     long long lower_limit = -1e9;     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int c, d;       cin >> c >> d;       if (d == 2) {         upper_limit = min(upper_limit, 1899LL);       } else {         lower_limit = max(lower_limit, 1900LL);       }       lower_limit += c;       upper_limit += c;     }     if (upper_limit < lower_limit) {       cout <<  Impossible ;     } else if (upper_limit > 1e8) {       cout <<  Infinity ;     } else {       cout << upper_limit;     }   }
#include <bits/stdc++.h>   using namespace std;   const int pi = 3.14159265;   const int INF = 1 << 30;   const int maxn = 1e5;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, k;     string s;     cin >> n >> k;     cin >> s;     int t = s.find( T );     int g = s.find( G );     if (g > t) swap(t, g);     for (int i = g; i < n && i <= t; i += k) {       if (s[i] ==  # ) {         cout <<  NO  << endl;         return 0;       }       if (i == t) {         cout <<  YES  << endl;         return 0;       }     }     cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int n, x[5000 + 5], y[5000 + 5], tot;   int color[5000 + 5];   bool flag;   int ksm(int b, int k) {     int s = 1;     while (k > 0) {       if (k & 1) s = (1ll * s * b) % mod;       k >>= 1;       b = (1ll * b * b) % mod;     }     return s % mod;   }   int dis(int id1, int id2) {     return abs(x[id1] - x[id2]) + abs(y[id1] - y[id2]);   }   void clearall() {     flag = true;     tot = 0;     memset(color, 0, sizeof(color));   }   void dfs(int u, int lim) {     if (flag) {       for (int i = 1; i <= n; i++) {         if (flag) {           if (u == i || dis(u, i) <= lim) continue;           if (!color[i]) {             color[i] = color[u] ^ 1;             dfs(i, lim);           } else {             if (color[i] != color[u]) continue;             flag = false;             return;           }         }       }     }   }   bool check(int lim) {     int i, j;     clearall();     for (i = 1; i <= n; i++)       if (!color[i]) {         tot++;         color[i] = 2;         dfs(i, lim);         if (!flag) break;       }     return flag;   }   int main() {     int i, ans = -1;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d%d , &x[i], &y[i]);     int l = 0, r = 10000;     while (l < r - 5) {       int mid = (l + r) / 2;       if (check(mid))         r = mid;       else         l = mid;     }     for (i = l; i <= r; i++)       if (check(i)) {         ans = i;         break;       }     printf( %d n , ans);     printf( %d n , ksm(2, tot));   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {1, -1, 0, 0};   int dy[] = {0, 0, -1, 1};   void arquivo() {     freopen(  ,  r , stdin);     freopen(  ,  w , stdout);   }   const int N = 5000100;   int n;   long long a, b;   int v[N];   bool memo[N][3];   long long pd[N][3];   int atPrime;   long long func(int pos, int op) {     if (pos == n) return 0LL;     if (memo[pos][op]) return pd[pos][op];     long long ret = 1000000000000000001LL;     if (!op) {       ret = func(pos + 1, 1) + a;       if (v[pos] % atPrime == 0) ret = min(ret, func(pos + 1, 0));       if ((v[pos] + 1) % atPrime == 0) ret = min(ret, func(pos + 1, 0) + b);       if ((v[pos] - 1) % atPrime == 0) ret = min(ret, func(pos + 1, 0) + b);     } else if (op == 1) {       ret = func(pos + 1, 1) + a;       if (v[pos] % atPrime == 0) ret = min(ret, func(pos + 1, 2));       if ((v[pos] + 1) % atPrime == 0) ret = min(ret, func(pos + 1, 2) + b);       if ((v[pos] - 1) % atPrime == 0) ret = min(ret, func(pos + 1, 2) + b);     } else {       if (v[pos] % atPrime == 0) ret = min(ret, func(pos + 1, 2));       if ((v[pos] + 1) % atPrime == 0) ret = min(ret, func(pos + 1, 2) + b);       if ((v[pos] - 1) % atPrime == 0) ret = min(ret, func(pos + 1, 2) + b);     }     memo[pos][op] = 1;     return pd[pos][op] = ret;   }   void fatora(long long x, set<int> &all) {     for (long long i = 2; i * i <= x; ++i) {       if (x % i == 0) {         all.insert(i);         while (x % i == 0) x /= i;       }     }     if (x > 1) all.insert(x);   }   int main() {     scanf( %d %lld %lld , &n, &a, &b);     set<int> all;     long long x;     for (int i = 0; i < n; ++i) {       scanf( %d , v + i);     }     for (int i = 0; i < 1; ++i) {       x = v[i];       fatora(x, all);       x = v[i] + 1;       fatora(x, all);       x = v[i] - 1;       fatora(x, all);     }     for (int i = n - 1; i < n; ++i) {       x = v[i];       fatora(x, all);       x = v[i] + 1;       fatora(x, all);       x = v[i] - 1;       fatora(x, all);     }     long long ans = (long long)(n - 1LL) * a;     for (set<int>::iterator it = all.begin(); it != all.end(); it++) {       atPrime = *it;       if (atPrime == 1) continue;       memset(memo, 0, sizeof memo);       for (int j = n - 1; j >= 0; --j) {         func(j, 0);         func(j, 1);         func(j, 2);       }       ans = min(ans, func(0, 0));     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T a, T b) {     if (a == 0) return b;     return gcd(b % a, a);   }   template <typename T>   T pow(T a, T b, long long m) {     T ans = 1;     while (b > 0) {       if (b % 2 == 1) ans = (ans * a) % m;       b /= 2;       a = (a * a) % m;     }     return ans % m;   }   int main() {     string s;     cin >> s;     int n;     cin >> n;     int from[n];     char s1, s2;     string to[n];     long long a[10], b[10];     for (int i = 0; i < n; i++) {       cin >> from[i] >> to[i];     }     for (int i = 0; i < n; i++) {       to[i] = to[i].substr(2);     }     for (int i = 0; i < 10; i++) {       a[i] = 10;       b[i] = i;     }     for (int i = n - 1; i >= 0; i--) {       long long p = 1, q = 0;       for (int j = 0; j < to[i].length(); j++) {         int c = to[i][j] -  0 ;         long long p2 = (a[c] * p) % 1000000007;         long long q2 = (a[c] * q + b[c]) % 1000000007;         p = p2;         q = q2;       }       a[from[i]] = p;       b[from[i]] = q;     }     long long ans = 0;     for (int i = 0; i < s.length(); i++) {       int c = s[i] -  0 ;       ans = (ans * a[c] + b[c]) % 1000000007;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1E5 + 5;   long long m, n, k, alice[MAXN], bob[MAXN];   bool cmp(int x, int y) { return x > y; }   int main() {     cin >> n >> m >> k;     for (int i = 0; i < n; i++) cin >> alice[i];     for (int i = 0; i < m; i++) cin >> bob[i];     if (n > m) {       cout <<  YES  << endl;       return 0;     }     sort(alice, alice + n, cmp);     sort(bob, bob + m, cmp);     for (int i = 0; i < n; i++) {       if (alice[i] > bob[i]) {         cout <<  YES  << endl;         return 0;       }     }     cout <<  NO  << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i;     scanf( %d , &n);     long long int a[n];     set<long long int> x;     map<long long int, set<int> > m;     for (i = 0; i < n; i++) {       scanf( %lld , &a[i]);       x.insert(a[i]);       m[a[i]].insert(i);     }     while (!x.empty()) {       long long int j = *x.begin();       if (m[j].size() >= 2) {         m[j].erase(m[j].begin());         int k = *(m[j].begin());         m[j].erase(m[j].begin());         m[2 * j].insert(k);         x.insert(2 * j);       } else {         x.erase(x.begin());       }     }     vector<pair<int, long long int> > ans;     map<long long int, set<int> >::iterator it;     for (it = m.begin(); it != m.end(); it++) {       if ((it->second).size() == 1) {         ans.push_back(make_pair(*(it->second).begin(), it->first));       }     }     sort(ans.begin(), ans.end());     cout << ans.size() << endl;     for (i = 0; i < ans.size(); i++) {       printf( %lld  , ans[i].second);     }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   using min_queue = priority_queue<T, vector<T>, greater<T>>;   const long long MOD = 1e9 + 7;   int N;   int cnt[6];   int res[100100];   vector<int> v[6];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     const vector<string> sizes = { S ,  M ,  L ,  XL ,  XXL ,  XXXL };     map<string, int> inv;     {       int k = 0;       for (auto s : sizes) inv[s] = k++;     }     for (int i = 0; i < 6; i++) {       cin >> cnt[i];     }     cin >> N;     for (int i = 0; i < N; i++) {       string s;       cin >> s;       string t;       for (char c : s) {         if (c ==  , ) break;         t += c;       }       int k = inv[t];       if (s == t) {         cnt[k]--;         res[i] = k;       } else {         v[k].push_back(i);       }     }     bool good = 1;     for (int i = 0; i < 5; i++) {       if (cnt[i] < 0) {         good = 0;         break;       }       while (!v[i].empty() && cnt[i] > 0) {         cnt[i]--;         res[v[i].back()] = i;         v[i].pop_back();       }       while (!v[i].empty() && cnt[i + 1] > 0) {         cnt[i + 1]--;         res[v[i].back()] = i + 1;         v[i].pop_back();       }       if (!v[i].empty() || cnt[i + 1] < 0) {         good = 0;         break;       }     }     if (!good) {       cout <<  NO n ;       return 0;     }     cout <<  YES n ;     for (int i = 0; i < N; i++) cout << sizes[res[i]] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     char a[n + 1][n + 1];     int ans[n + 1][n + 1];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         cin >> a[i][j];         ans[i][j] = 0;       }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n - k + 1; j++) {         bool x = true;         for (int t = j; t < j + k; t++) {           if (a[i][t] ==  # ) {             x = false;             break;           }         }         if (x) {           for (int t = j; t < j + k; t++) ans[i][t]++;         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n - k + 1; j++) {         bool x = true;         for (int t = j; t < j + k; t++) {           if (a[t][i] ==  # ) {             x = false;             break;           }         }         if (x) {           for (int t = j; t < j + k; t++) ans[t][i]++;         }       }     }     int mx = ans[1][1];     int p = 1, q = 1;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         if (ans[i][j] > mx) {           mx = ans[i][j];           p = i;           q = j;         }       }     cout << p <<     << q;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ans, l;   int n, m, N, i, j, k, s[3005], a[3005][3005], b[3005];   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) {       scanf( %d%d , &j, &k);       a[j][++s[j]] = k;     }     for (i = 1; i <= m; i++) sort(a[i] + 1, a[i] + s[i] + 1, greater<int>());     ans = 1LL << 60;     for (i = 1; i <= n; i++) {       l = 0;       N = 0;       for (j = 2; j <= m; j++) {         for (k = 1; k < i && k <= s[j]; k++) b[N++] = a[j][k];         for (; k <= s[j]; k++) l += a[j][k];       }       sort(b, b + N);       for (j = 0; j < i + N - n; j++) l += b[j];       ans = min(ans, l);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 7;   int n, m, a[maxn];   map<int, int> mp, rmp;   int main() {     scanf( %d%d , &n, &m);     int id;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       if (a[i] == m) id = i;     }     int cnt = 0;     for (int i = id; i >= 1; i--) {       if (a[i] < m)         cnt++;       else if (a[i] > m)         cnt--;       mp[cnt]++;     }     long long ans = 0;     cnt = 0;     for (int i = id; i <= n; i++) {       if (a[i] < m)         cnt++;       else if (a[i] > m)         cnt--;       ans += 1LL * mp[-cnt] + 1LL * mp[-cnt - 1];     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned long long O = 2e9;   const double E = 1e-9;   const double pi = 3.1415926536;   int DX[] = {1, -1, 0, 0};   int DY[] = {0, 0, 1, -1};   int main() {     int n, m;     cin >> n >> m;     int out = n * 2 + 1, in = 1;     if (m > n * 2) {       for (int i = 0; i < m; i++) {         if (i % 2 == 0 && out <= m)           cout << out++ <<    ;         else           cout << in++ <<    ;       }     } else       for (int i = 1; i <= m; i++) cout << i <<    ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5;   set<int> s;   int x[maxn];   int n, k;   int main() {     while (~scanf( %d , &n)) {       k = 0;       if (!s.empty()) s.clear();       for (int i = 1; i <= n; i++) {         int p;         scanf( %d , &p);         if (s.count(p) == 0)           s.insert(p);         else {           x[k++] = i;           s.clear();         }       }       if (k == 0)         printf( -1 n );       else {         if (x[k - 1] != n) x[k - 1] = n;         printf( %d n , k);         printf( 1 %d n , x[0]);         for (int i = 0; i < k - 1; i++) printf( %d %d n , x[i] + 1, x[i + 1]);       }     }     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 100005;   int n, val[MAXN], ch[MAXN][2], fa[MAXN], maxv[MAXN], size[MAXN], root;   inline int max(int a, int b) { return a > b ? a : b; }   inline int min(int a, int b) { return a > b ? b : a; }   inline void maintain(int x) {     size[x] = size[ch[x][0]] + size[ch[x][1]] + 1;     maxv[x] = max(max(maxv[ch[x][0]], maxv[ch[x][1]]), val[x]);   }   void rotate(int x) {     int y = fa[x], d = ch[y][1] == x;     if (fa[x] = fa[y]) ch[fa[y]][ch[fa[y]][1] == y] = x;     if (ch[y][d] = ch[x][d ^ 1]) fa[ch[y][d]] = y;     fa[ch[x][d ^ 1] = y] = x;     maintain(y), maintain(x);   }   void splay(int &rt, int x) {     int f = fa[rt], y, z;     while ((y = fa[x]) != f && (z = fa[y]) != f) {       rotate((ch[z][1] == y) == (ch[y][1] == x) ? y : x);       rotate(x);     }     if (y != f) rotate(x);     rt = x;   }   void select(int &rt, int k) {     int x = rt;     while (size[ch[x][0]] + 1 != k) {       if (k <= size[ch[x][0]])         x = ch[x][0];       else {         k -= size[ch[x][0]] + 1;         x = ch[x][1];       }     }     splay(rt, x);   }   void getPos(int &rt, int v) {     int x = rt;     while (true) {       if (ch[x][1] && maxv[ch[x][1]] > v)         x = ch[x][1];       else if (ch[x][0] && val[x] <= v)         x = ch[x][0];       else         break;     }     splay(rt, x);   }   void insert(int &rt, int p, int pos) {     if (!pos) {       select(rt, 1);       fa[ch[rt][0] = p] = rt;       rotate(p);       rt = p;       return;     }     select(rt, pos);     int tmp = ch[rt][1];     if (!tmp) {       fa[ch[rt][1] = p] = rt;       rotate(p);       rt = p;       return;     }     fa[ch[rt][1] = p] = rt;     fa[ch[p][1] = tmp] = p;     splay(rt, tmp);   }   void traverse(int x) {     if (!x) return;     traverse(ch[x][0]);     printf( %d  , x);     traverse(ch[x][1]);   }   int main() {     int tmp, i;     scanf( %d , &n);     for (i = 1; i <= n; ++i) {       scanf( %d%d , &val[i], &tmp);       if (i == 1) {         size[root = 1] = 1;         maxv[1] = val[1];         continue;       }       getPos(root, val[i]);       if (val[root] < val[i])         insert(root, i, i - 1 - min(tmp, i - 1));       else         insert(root, i, i - 1 - min(tmp, size[ch[root][1]]));     }     traverse(root);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   int main() {     int t;     cin >> t;     while (t--) {       int c, s, v = 0, m, d, k, y;       cin >> c >> s;       m = (s / 2);       d = (c / s);       k = (c % s);       if (m == 0) {         v = c;       } else {         if (k >= m) {           v = (c - k + m);         } else {           v = c;         }       }       cout << v << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   vector<long long> v[105];   map<long long, long long> mp;   int vis[105];   long long cnt, cnt2;   void dfs(int s) {     vis[s] = 1;     cnt += v[s].size();     cnt2++;     for (int i = 0; i < v[s].size(); i++) {       if (!vis[v[s][i]]) dfs(v[s][i]);     }   }   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, m, b, ans = 0, ans2, x, y, z, i, s;     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     for (int i = 1; i <= n; i++) {       if (!vis[i]) {         cnt = 0;         cnt2 = 0;         dfs(i);         if (cnt2 * 2 == cnt) {           if (cnt2 % 2) ans++;         }       }     }     if ((n - ans) % 2 == 0)       cout << ans;     else       cout << ans + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> V;   int solve() {     V.clear();     cin >> n;     for (int i = 0; i < n; ++i) {       int a;       cin >> a;       V.emplace_back(a);     }     sort(V.begin(), V.end());     V.erase(unique(V.begin(), V.end()), V.end());     return V.size();   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) cout << solve() <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> v[201];   long long arr[201];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, i, j, c, max1, min1, temp, temp1, n1;     cin >> n;     for (i = 0; i < 2 * n; i++) {       cin >> arr[i];       v[arr[i]].push_back(i);     }     for (i = 1; i <= n; i++) {       if (abs(v[i][0] - v[i][1]) == 1) {         continue;       } else {         break;       }     }     if (i > n) {       cout <<  0 ;       exit(0);     }     c = 0;     while (1) {       for (i = 0; i < 2 * n; i++) {         if (abs(v[arr[i]][0] - v[arr[i]][1]) == 1) {           continue;         } else {           max1 = max(v[arr[i]][0], v[arr[i]][1]);           min1 = min(v[arr[i]][0], v[arr[i]][1]);           c += max1 - min1 - 1;           for (j = max1; j > min1 + 1; j--) {             if (v[arr[j]][0] == j) {               temp = 0;             } else {               temp = 1;             }             if (v[arr[j - 1]][0] == j - 1) {               temp1 = 0;             } else {               temp1 = 1;             }             v[arr[j]][temp] = j - 1;             v[arr[j - 1]][temp1] = j;             swap(arr[j], arr[j - 1]);           }         }       }       for (i = 1; i <= n; i++) {         if (abs(v[i][0] - v[i][1]) == 1) {           continue;         } else {           break;         }       }       if (i > n) {         cout << c;         exit(0);       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long n;   const long long maxn = 2e5 + 100;   const long long mod = 1e9 + 7;   vector<long long> G[maxn];   long long dp[maxn];   long long oth[maxn];   long long fs[maxn], ts[maxn];   long long ans[maxn];   void myinit() {     cin >> n;     for (long long i = 2; i <= n; i++) {       long long u;       cin >> u;       G[u].push_back(i);     }     memset(dp, 0, sizeof(dp));     memset(oth, 0, sizeof(oth));   }   void dfs1(long long x) {     long long s = 1;     for (long long i = 0; i < G[x].size(); i++) {       long long tmp = G[x][i];       dfs1(tmp);       s = s * (dp[tmp] + 1);       s %= mod;     }     dp[x] = s;   }   void dfs2(long long x) {     fs[0] = 1;     for (long long i = 0; i < G[x].size(); i++) {       long long tmp = G[x][i];       fs[i + 1] = fs[i] * (dp[tmp] + 1);       fs[i + 1] %= mod;     }     ts[G[x].size() + 1] = 1;     for (long long i = (long long)G[x].size() - 1; i >= 0; i--) {       long long tmp = G[x][i];       ts[i + 1] = (ts[i + 2] * (dp[tmp] + 1)) % mod;     }     for (long long i = 0; i < G[x].size(); i++) {       oth[G[x][i]] = ((fs[i] * ts[i + 2] % mod) * oth[x] + 1) % mod;     }     for (long long i = 0; i < G[x].size(); i++) {       dfs2(G[x][i]);     }   }   void dfs3(long long x) {     for (long long i = 0; i < G[x].size(); i++) {       long long tmp = G[x][i];       ans[tmp] = (oth[tmp] * dp[tmp]) % mod;       dfs3(tmp);     }   }   void solve() {     myinit();     dfs1(1);     oth[1] = 1;     dfs2(1);     ans[1] = dp[1];     dfs3(1);     for (long long i = 1; i <= n; i++) {       cout << ans[i] <<    ;     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void print2dvector(vector<vector<T> > v) {     cout <<  A 2d vector:  << endl;     int a = v.size();     int b = v[0].size();     if (a <= 15 && b <= 15) {       for (int i = 0; i < a; i++) {         for (int j = 0; j < b; j++) {           cout << setw(4) << v[i][j];         }         cout << endl;       }     }     if (a > 15 && b > 15) {       for (int i = 0; i < 9; i++) {         for (int j = 0; j < 9; j++) {           cout << setw(4) << v[i][j];         }         cout <<                    <<  .   .   .  << setw(4) << v[i][b - 3] << setw(4) << v[i][b - 2]              << setw(4) << v[i][b - 1] << endl;       }       for (int i = 0; i < 15; i++) {         cout << setw(4) <<  . ;       }       cout << endl;       for (int i = a - 3; i < a; i++) {         for (int j = 0; j < 9; j++) {           cout << setw(4) << v[i][j];         }         cout <<                    <<  .   .   .  << setw(4) << v[i][b - 3] << setw(4) << v[i][b - 2]              << setw(4) << v[i][b - 1] << endl;       }     }     if (a > 15) {       for (int i = 0; i < 9; i++) {         for (int j = 0; j < b; j++) {           cout << setw(4) << v[i][j];         }         cout << endl;       }       for (int i = 0; i < b; i++) {         cout << setw(4) <<  . ;       }       cout << endl;       for (int i = a - 3; i < a; i++) {         for (int j = 0; j < b; j++) {           cout << setw(4) << v[i][j];         }         cout << endl;       }     }     if (b > 15) {       for (int i = 0; i < a; i++) {         for (int j = 0; j < 9; j++) {           cout << setw(4) << v[i][j];         }         cout <<                    <<  .   .   .  << setw(4) << v[i][b - 3] << setw(4) << v[i][b - 2]              << setw(4) << v[i][b - 1] << endl;       }     }   }   template <typename T>   void printvector(vector<T> v) {     cout <<  A 1d vector:  << endl;     int a = v.size();     if (a <= 15) {       for (int i = 0; i < a; i++) {         cout << setw(4) << v[i];       }     } else {       for (int i = 0; i < 9; i++) {         cout << setw(4) << v[i];       }       cout <<                  <<  .   .   .  << setw(4) << v[a - 3] << setw(4) << v[a - 2] << setw(4)            << v[a - 1];     }     cout << endl;   }   int main() {     int n, m;     scanf( %d %d , &n, &m);     vector<int> v(n, 0);     for (int i = 0; i < n; i++) {       scanf( %d , &v[i]);     }     double ans = 0;     int a, b, c;     for (int i = 0; i < m; i++) {       scanf( %d %d %d , &a, &b, &c);       ans = max(ans, 1.0 * (v[a - 1] + v[b - 1]) / c);     }     printf( %.12lf , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200005], b[200005], vis[200005];   bool cmp(int a, int b) { return a > b; }   int main() {     int n;     scanf( %d , &n);     int numa = 0, numb = 0, flag = 0;     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       if (vis[x])         a[numa++] = x, vis[x]++;       else         b[numb++] = x, vis[x]++;       if (vis[x] > 2) flag = 1;     }     if (flag)       printf( NO n );     else {       printf( YES n );       sort(a, a + numa);       sort(b, b + numb, cmp);       printf( %d n , numa);       int flag1 = 0;       for (int i = 0; i < numa; i++) {         if (flag1) printf(   );         flag1 = 1;         printf( %d , a[i]);       }       printf(  n );       flag1 = 0;       printf( %d n , numb);       for (int i = 0; i < numb; i++) {         if (flag1) printf(   );         flag1 = 1;         printf( %d , b[i]);       }     }     return 0;   }