malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long a[1000010];   pair<long long, long long> st[1000010];   bool check(pair<long long, long long> a, pair<long long, long long> b,              pair<long long, long long> c) {     double k1 = 1.0 * (b.second - a.second) / (b.first - a.first);     double k2 = 1.0 * (c.second - b.second) / (c.first - b.first);     if (k1 > k2) return 1;     return 0;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       a[i] += a[i - 1];     }     int top = 0;     st[top++] = make_pair(0, 0);     for (int i = 1; i <= n; i++) {       pair<long long, long long> tmp = make_pair(i, a[i]);       while (top > 1 && check(st[top - 2], st[top - 1], tmp)) top--;       st[top++] = tmp;     }     for (int i = 0; i < top - 1; i++) {       long long l = st[i].first, r = st[i + 1].first,                 tot = st[i + 1].second - st[i].second;       for (int j = l + 1; j <= r; j++) {         printf( %.9f n , 1.0 * tot / (r - l));       }     }     return 0;   }
#include <bits/stdc++.h>   int A[50], B[50];   int main() {     int N, M, i, j, Max, now, Cnt;     while (scanf( %d , &N) != EOF) {       for (i = 0; i < N; ++i) {         scanf( %d , &A[i]);       }       scanf( %d , &M);       for (i = 0; i < M; ++i) {         scanf( %d , &B[i]);       }       for (Max = i = 0; i < N; ++i) {         for (j = 0; j < M; ++j) {           now = B[j] / A[i];           if (now * A[i] == B[j] && Max < now) {             Max = now;           }         }       }       for (Cnt = i = 0; i < N; ++i) {         for (j = 0; j < M; ++j) {           now = B[j] / A[i];           if (now * A[i] == B[j] && Max == now) {             ++Cnt;           }         }       }       printf( %d n , Cnt);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 5;     int arr[5], sum = 0;     for (int i = 0; i < n; i++) {       cin >> arr[i];       sum += arr[i];     }     if (sum == 0)       cout << -1 << endl;     else if (sum % 5 != 0)       cout << -1 << endl;     else {       int s = sum / 5;       int a = 0, b = 0;       for (int i = 0; i < n; i++) {         if (arr[i] > s)           a += s - arr[i];         else           b += arr[i] - s;       }       if (a == b)         cout << s << endl;       else         cout << -1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 840;   long long cnt[10];   long long f[10][N];   int main() {     long long w;     cin >> w;     for (int i = 1; i <= 8; i++) cin >> cnt[i];     memset(f, 0xcf, sizeof f);     f[0][0] = 0;     long long res = 0;     for (int i = 1; i <= 8; i++) {       for (int j = 0; j < 840 / i && j <= cnt[i]; j++) {         for (int k = 0; k < 840; k++) {           int a = (k + j * i) / 840;           int b = (k + j * i) % 840;           f[i][b] = max(f[i][b], f[i - 1][k] + a + (cnt[i] - j) * i / 840);           if (b <= w) res = max(res, min(f[i][b], (w - b) / 840) * 840 + b);         }       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       long long int n, a, b;       cin >> n >> a >> b;       string s;       cin >> s;       long long int ans = n * (a + 2 * b) + 2 * a;       int st = 0, en = 0;       while (en < n and s[en] ==  0 ) en++;       if (en == n) {         ans = n * a + (n + 1) * b;         cout << ans <<   n ;         continue;       }       ans -= (en - 1) * b;       while (en != n) {         st = en;         while (s[st] !=  0 ) st++;         en = st;         while (en < n and s[en] ==  0 ) en++;         if (en == n) {           ans -= (en - st - 1) * b;           break;         }         if (en - st != 1 and 2 * a < (en - st - 1) * b)           ans += 2 * a - (en - st - 1) * b;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   const int kN = 18;   const int kT = 1 << kN;   const int kInf = 0x3f3f3f3f;   int a[kT];   bool fan_of[kT];   std::map<std::pair<int, int>, int> cal[4];   int Cal(int l, int r, int st) {     if (r == l + 2) {       int cnt_fan = (int)fan_of[l] + fan_of[l + 1], cnt_st = (st & 1) + (st >> 1);       return cnt_fan == cnt_st ? std::min(cnt_st, 1) : -kInf;     }     std::pair<int, int> tmp = std::make_pair(l, r);     if (cal[st].count(tmp)) return cal[st][tmp];     int mid = (l + r) >> 1, ret = -kInf;     for (int i = 0; i < 4; ++i)       for (int j = 0; j < 4; ++j) {         int v1 = ((i << 1) | (i & 2) | j) & 3, v2 = ((j << 1) | (j & 2) | i) & 3;         if (v1 == st || v2 == st) {           ret = std::max(ret, Cal(l, mid, i) + Cal(mid, r, j));         }       }     return cal[st][tmp] = ret + st;   }   int main() {     int n, k, t, ans = 0;     scanf( %d%d , &n, &k);     t = 1 << n;     for (int i = 1; i <= k; ++i) scanf( %d , a + i), fan_of[--a[i]] = true;     for (int i = 0; i < 4; ++i) ans = std::max(ans, Cal(0, t, i));     printf( %d , ans + !(!k));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long d[111111];   long long sum[111111];   int q[111111];   long long cat[111111];   long long dp[101][100001];   long long getDP(int i, int j, int k) {     return (long long)j * cat[j] + dp[i - 1][k] - j * cat[k];   }   long long getUP(int i, int j, int k) {     return (long long)dp[i - 1][j] - dp[i - 1][k];   }   long long getDOWN(int j, int k) { return (long long)cat[j] - cat[k]; }   int main() {     int i, j, k, n, m, p, h;     cin >> n >> m >> p;     for (i = 2; i <= n; i++) {       cin >> d[i];       d[i] += d[i - 1];     }     for (i = 1; i <= m; i++) {       cin >> h >> cat[i];       cat[i] -= d[h];     }     sort(cat + 1, cat + 1 + m);     for (i = 1; i <= m; i++) sum[i] = sum[i - 1] + cat[i];     for (i = 1; i <= p; i++)       for (j = 1; j <= m; j++) dp[i][j] = 999999999999999;     dp[1][m] = (long long)m * cat[m] - sum[m];     for (i = 2; i <= p; i++) {       int head, tail;       head = tail = 0;       q[tail++] = m;       for (j = m; j >= 1; j--) {         while (head + 1 < tail && (getUP(i, q[head + 1], q[head]) <=                                    j * getDOWN(q[head + 1], q[head])))           head++;         dp[i][j] = min(dp[i][j], getDP(i, j, q[head]));         while (head + 1 < tail &&                getUP(i, j, q[tail - 1]) * getDOWN(q[tail - 1], q[tail - 2]) >                    getUP(i, q[tail - 1], q[tail - 2]) * getDOWN(j, q[tail - 1]))           tail--;         q[tail++] = j;       }     }     long long ans = dp[p][1];     for (i = 1; i <= m; i++) ans = min(ans, dp[p][i]);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000 + 5;   struct BIT {     int a[N], n;     void Init(int n) { this->n = n; }     void add(int p, int v) {       for (p = p + 1; p <= n; p += p & -p) a[p] += v;       return;     }     int query(int p) {       int res = 0;       for (p = p + 1; p >= 1; p -= p & -p) res += a[p];       return res;     }   } * TA;   struct Node {     int val, idx;     Node(int v, int i) {       val = v;       idx = i;     }   };   void update(Node &des, Node src) {     des.val += src.val;     TA->add(des.idx, src.val);   }   int main() {     int n, q;     cin >> n >> q;     TA = new BIT();     TA->Init(n);     deque<Node> Q;     for (int i = 0; i < n; i++) TA->add(i, 1), Q.push_back(Node(1, i));     int s = 0;     for (int i = 0; i < q; i++) {       int f;       scanf( %d , &f);       if (f == 1) {         int p;         scanf( %d , &p);         if (2 * p <= Q.size()) {           if (s == 0) {             for (int i = 0; i < p; i++) {               update(Q[2 * p - 1 - i], Q[i]);             }             for (int i = 0; i < p; i++) Q.pop_front();           } else {             for (int i = (int)Q.size() - 1; i >= Q.size() - p; i--) {               update(Q[2 * (Q.size() - p) - 1 - i], Q[i]);             }             for (int i = 0; i < p; i++) Q.pop_back();           }         } else {           if (s == 0) {             for (int i = (int)Q.size() - 1; i >= p; i--) {               update(Q[2 * p - 1 - i], Q[i]);             }             int d = (int)Q.size() - p;             for (int i = 0; i < d; i++) Q.pop_back();           } else {             for (int i = 0; i < Q.size() - p; i++) {               update(Q[2 * (Q.size() - p) - 1 - i], Q[i]);             }             int d = (int)Q.size() - p;             for (int i = 0; i < d; i++) Q.pop_front();           }           s = s ^ 1;         }       } else {         int L, R;         scanf( %d %d , &L, &R);         --R;         if (s == 1) {           int ll = L, rr = R;           L = Q[Q.size() - rr - 1].idx;           R = Q[Q.size() - ll - 1].idx;         } else {           L = Q[L].idx, R = Q[R].idx;         }         printf( %d n , TA->query(R) - TA->query(L - 1));       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     while (cin >> s) {       string integer;       string decimal;       bool isnegative = false;       bool isdecimal = false;       int pos = 0;       if (s[0] ==  - ) {         isnegative = true;         pos++;       }       for (; pos < s.size(); pos++) {         if (s[pos] ==  . ) {           isdecimal = true;         } else if (!isdecimal) {           integer += s[pos];         } else {           decimal += s[pos];         }       }       reverse(integer.begin(), integer.end());       string integerWithComma;       for (int i = 0; i < integer.size(); i++) {         integerWithComma += integer[i];         if (i != integer.size() - 1 && i % 3 == 2) {           integerWithComma +=  , ;         }       }       reverse(integerWithComma.begin(), integerWithComma.end());       string decimalProcess;       if (decimal.size() == 0) {         decimalProcess =  .00 ;       } else if (decimal.size() == 1) {         decimalProcess =  .  + decimal +  0 ;       } else {         decimalProcess =  .  + decimal.substr(0, 2);       }       if (isnegative) {         cout <<  ( ;       }       cout <<  $ ;       cout << integerWithComma;       cout << decimalProcess;       if (isnegative) {         cout <<  ) ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string op, s1, s2;   map<string, int> mp;   int solve(string s) {     int ast, amp;     ast = count(s.begin(), s.end(),  * );     amp = count(s.begin(), s.end(),  & );     return ast - amp;   }   string remove(string s) {     s.erase(remove(s.begin(), s.end(),  * ), s.end());     s.erase(remove(s.begin(), s.end(),  & ), s.end());     return s;   }   int main() {     int N;     cin >> N;     mp[ void ] = 0;     while (N--) {       cin >> op;       if (op ==  typedef ) {         cin >> s1 >> s2;         int d = solve(s1);         s1 = remove(s1);         if (mp.find(s1) != mp.end() && mp[s1] >= 0)           mp[s2] = mp[s1] + d;         else           mp[s2] = -1;       } else {         cin >> s1;         int d = solve(s1);         s1 = remove(s1);         if (mp.find(s1) != mp.end() && mp[s1] >= 0) {           d += mp[s1];           if (d >= 0) {             cout <<  void ;             for (int i = 0; i < d; i++) cout <<  * ;             cout << endl;           } else             cout <<  errtype  << endl;         } else           cout <<  errtype  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long power(unsigned long long x, unsigned long long y) {     if (y == 0) return 1;     unsigned long long tmp = power(x, y / 2);     tmp *= tmp;     if (y % 2) tmp *= x;     return tmp;   }   unsigned long long get(unsigned long long n) {     if (n <= 9) return n;     unsigned long long cnt, temp, d = 0;     unsigned long long tmp = n;     while (tmp / 10) {       tmp /= 10;       d++;     }     stringstream s;     s << n;     string str = s.str();     unsigned long long x = str[0] -  0 ;     temp = power(10, d);     n -= (str[0] -  0 ) * temp;     n /= 10;     if (str[0] <= str[str.size() - 1])       cnt = n + 1;     else       cnt = n;     cnt += ((power(10, d - 1)) * (x - 1));     return cnt + get(power(10, d) - 1);   }   int main() {     unsigned long long l, r;     cin >> l >> r;     cout << get(r) - get(l - 1) << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <class A, class B>   A cvt(B x) {     stringstream s;     s << x;     A r;     s >> r;     return r;   }   typedef vector<int> VI;   typedef vector<pair<int, int> > VII;   typedef vector<string> VS;   struct Treap {     int val, priority;     int maxVal, size;     Treap *left;     Treap *right;     Treap() {       val = priority = maxVal = size = 0;       left = right = 0;     }     Treap(int _val, int _priority, int _maxVal, int _size) {       val = _val;       maxVal = _maxVal;       size = _size;       priority = _priority;       left = right = 0;     }   };   int SZ(Treap *&t) { return t ? t->size : 0; }   int MAX(Treap *&t) { return t ? t->maxVal : 0; }   void Adjust(Treap *&T) {     T->size = 1 + SZ(T->left) + SZ(T->right);     T->maxVal = max(T->val, max(MAX(T->left), MAX(T->right)));   }   void rotateLeft(Treap *&T) {     Treap *t = T->left;     T->left = t->right;     Adjust(T);     t->right = T;     Adjust(t);     T = t;   }   void rotateRight(Treap *&T) {     Treap *t = T->right;     T->right = t->left;     Adjust(T);     t->left = T;     Adjust(t);     T = t;   }   void Balance(Treap *&T) {     if (T->left) {       if (T->left->priority > T->priority) rotateLeft(T);     }     if (T->right) {       if (T->right->priority > T->priority) rotateRight(T);     }   }   void insert(Treap *&T, int val, int where, int pri) {     if (!T)       T = new Treap(val, pri, val, 1);     else {       if (SZ(T->right) >= where) {         insert(T->right, val, where, pri);       } else if (max(T->val, MAX(T->right)) > val) {         insert(T->right, val, where, pri);       } else         insert(T->left, val, where - SZ(T->right) - 1, pri);       Adjust(T);       Balance(T);     }   }   int idx[101010];   void print(Treap *&T) {     if (T) {       print(T->left);       printf( %d  , idx[T->val]);       print(T->right);     }   }   int main() {     int n, a, c;     scanf( %d , &n);     Treap *T = NULL;     for (int i = (int)0; i < (int)n; ++i) {       scanf( %d%d , &a, &c);       idx[a] = i + 1;       insert(T, a, c, rand() % 101010);     }     print(T);     puts(  );     return 0;   }
#include <bits/stdc++.h>   bool g[1111][1111];   int main() {     int n, m;     memset(g, false, sizeof(g));     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d%d , &u, &v);       g[u][v] = true;     }     int count = 0;     for (int i = 2; i < n; i++) {       bool flag = false;       for (int j = 1; j <= n; j++)         if (g[i][j] == true) {           flag = true;           break;         }       if (flag) continue;       count++;     }     for (int j = 2; j < n; j++) {       bool flag = false;       for (int i = 1; i <= n; i++)         if (g[i][j]) {           flag = true;           break;         }       if (flag) continue;       count++;     }     if (n & 1) {       int i, j;       for (i = 1; i <= n; i++)         if (g[i][n / 2 + 1]) break;       for (j = 1; j <= n; j++)         if (g[n / 2 + 1][j]) break;       if (i > n && j > n)         if (count) count--;     }     printf( %d n , count);     return 0;   }
#include <bits/stdc++.h>   char s1[100100], s2[100100], s3[100100];   bool dist[100100];   int pos[100100];   int main() {     int n, t, i;     int num = 0, po = 0;     memset(dist, false, sizeof(dist));     scanf( %d%d , &n, &t);     scanf( %s%s , s1, s2);     for (i = 0; i < n; i++) s3[i] =  1 ;     for (i = 0; i < n; i++) {       if (s1[i] == s2[i]) {         dist[i] = true;         pos[po++] = i;         num += 2;       } else         num++;     }     if (num < 2 * (n - t))       printf( -1 n );     else {       int j = 0;       int l = n - t;       while (l > 0 && j < po) {         s3[pos[j]] = s1[pos[j]];         j++;         l--;       }       for (i = 0; i < n; i++) {         if (l > 0) {           while (s3[i] !=  1 ) i++;           s3[i] = s1[i];           while (s3[i] !=  1 ) i++;           s3[i] = s2[i];           l--;           i--;         } else if (s3[i] ==  1 ) {           char ch =  a ;           while (ch == s1[i] || ch == s2[i]) ch++;           s3[i] = ch;         }       }       s3[n] =   0 ;       printf( %s n , s3);       return 0;     }   }
#include <bits/stdc++.h>   const int N = 517;   const int mod = 998244353;   using namespace std;   inline int read() {     int x = 0;     char ch = getchar();     while (!isdigit(ch)) ch = getchar();     while (isdigit(ch)) x = (x << 1) + (x << 3) + ch -  0 , ch = getchar();     return x;   }   int n, k;   long long dp[N][N], ans;   int main() {     n = read(), k = read();     dp[0][0] = 1;     for (int i = 1, I = (n) + 1; i < I; ++i)       for (int j = 1, I = (i) + 1; j < I; ++j)         for (int k = i - j, I = (i - 1) + 1; k < I; ++k)           dp[i][j] = (dp[i][j] + dp[k][min(j, k)]) % mod;     for (int i = n, I = (1) - 1; i > I; --i)       dp[n][i] = (dp[n][i] - dp[n][i - 1] + mod) % mod;     for (int i = 1, I = (n) + 1; i < I; ++i)       for (int j = 1, I = (n) + 1; j < I; ++j)         if (i * j < k) ans = (ans + dp[n][i] * dp[n][j]) % mod;     printf( %lld n , (ans << 1) % mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t;   long long sx, sy, ex, ey;   int main(void) {     cin >> t >> sx >> sy >> ex >> ey;     int ans = 0;     for (int i = 0; i < t; i++) {       char c;       cin >> c;       if (sx == ex && sy == ey) {         cout << ans <<   n ;         return 0;       }       if (c ==  N  && sy < ey) sy++;       if (c ==  W  && sx > ex) sx--;       if (c ==  S  && sy > ey) sy--;       if (c ==  E  && sx < ex) sx++;       ans++;     }     if (sx == ex && sy == ey) {       cout << ans <<   n ;       return 0;     }     cout <<  -1 n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, ans = 0, c;     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> c;       ans += c;     }     c = (n == 1 ? 1 : n - 1);     if (ans == c)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INT_INF = 1e9;   const long long LL_INF = 1e18;   const int MAXN = 200003;   int n, m;   int A[MAXN];   long long calc(int m) {     long long ret = 0;     map<int, int> dp;     int sum = 0;     dp[sum] = 1;     long long add = 0;     for (int i = 1; i <= n; i++) {       if (A[i] < m) {         sum--;         add -= dp[sum];       } else if (A[i] >= m) {         add += dp[sum];         sum++;       }       ret += add;       dp[sum]++;     }     return ret;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 1, x; i <= n; i++) {       scanf( %d , &x);       A[i] = x;     }     long long ret1 = calc(m);     long long ret2 = calc(m + 1);     printf( %lld , ret1 - ret2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-12;   const int INF = 1 << 30;   const long long LINF = 1ll << 61;   const int BUFFER_SZ = 1 << 20;   const int MOD = 1000 * 1000 * 1000 + 7;   char BUFFER[BUFFER_SZ];   int gi() {     int x;     scanf( %d , &x);     return x;   }   double gd() {     double x;     scanf( %lf , &x);     return x;   }   long long gll() {     long long x;     scanf( %lld , &x);     return x;   }   vector<int> gvi(int n) {     vector<int> a;     while (n-- > 0) a.push_back(gi());     return a;   }   string gs() {     scanf( %s , BUFFER);     return string(BUFFER);   }   template <class T>   void print(vector<T> &x, string format) {     format +=  %c ;     for (int i = 0; i < x.size(); ++i)       printf(format.c_str(), x[i], i + 1 == x.size() ?   n  :    );   }   void solve() {     int n = gi();     vector<int> a = gvi(n);     for (int i = 0; i < a.size(); ++i) {       for (int j = i + 1; j < a.size(); ++j) {         for (int k = j + 1; k < a.size(); ++k) {           if (a[i] == a[j] + a[k]) {             printf( %d %d %d n , i + 1, j + 1, k + 1);             return;           }           if (a[j] == a[i] + a[k]) {             printf( %d %d %d n , j + 1, i + 1, k + 1);             return;           }           if (a[k] == a[i] + a[j]) {             printf( %d %d %d n , k + 1, i + 1, j + 1);             return;           }         }       }     }     printf( -1 n );   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     long long n, m, i, ans = 0, z, j;     pair<long long, long long> a[105];     vector<pair<long long, long long> > q;     cin >> n >> m;     for (i = 1; i <= n; i++) a[i].second = 0;     for (i = 1; i <= n; i++) cin >> a[i].first;     for (j = 1; j <= m; j++) {       cin >> z;       a[z].second = 1;     }     for (i = 1; i <= n; i++) q.push_back(a[i]);     sort(q.begin(), q.end());     for (i = 0; i < n; i++)       if (q[i].second == 0) ans += q[i].first;     for (i = n - 1; i >= 0; i--)       if (q[i].second == 1) ans = ans + max(ans, q[i].first);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 998244353;   long long p[400001];   long long n;   vector<long long> a(100001);   bool check(long long x) {     long long cnt[n + 1];     for (int i = 1; i < n + 1; i++) cnt[i] = 0;     for (int i = 0; i < n; i++) cnt[a[i]]++;     set<pair<long long, long long>, greater<pair<long long, long long> > > ss;     for (int i = 1; i < n + 1; i++) {       if (cnt[i] > 0) ss.insert({cnt[i], i});     }     vector<long long> b;     for (int i = 0; i < n; i++) {       if (i >= x && cnt[b[i - x]] >= 1) {         ss.insert({cnt[b[i - x]], b[i - x]});       }       if (ss.empty()) return false;       b.push_back(ss.begin()->second);       cnt[ss.begin()->second]--;       ss.erase(ss.begin());     }     return true;   }   int main() {     long long t;     cin >> t;     while (t-- > 0) {       cin >> n;       for (int i = 0; i < n; i++) cin >> a[i];       long long l = 0, h = n;       long long ans;       while (l + 1 < h) {         long long mid = (l + h) / 2;         if (check(mid)) {           ans = mid;           l = mid;         } else           h = mid;       }       cout << ans - 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char x[5][105];   int main() {     cin >> n >> m;     for (int i = 0; i < 4; i++) {       for (int j = 0; j < n; j++) {         x[i][j] =  . ;       }     }     if (m % 2 == 0) {       printf( YES n );       for (int i = 1; i <= m / 2; i++) {         x[1][i] =  # ;         x[2][i] =  # ;       }       for (int i = 0; i < 4; i++) {         for (int j = 0; j < n; j++) {           printf( %c , x[i][j]);         }         printf(  n );       }     } else {       if (m >= n - 2) {         printf( YES n );         for (int i = 1; i <= n - 2; i++) {           x[1][i] =  # ;         }         if (m - n + 2 >= 2) {           x[2][1] =  # ;           x[2][n - 2] =  # ;           for (int i = 0; i < m - n; i++) {             x[2][i + 2] =  # ;           }         }         for (int i = 0; i < 4; i++) {           for (int j = 0; j < n; j++) {             printf( %c , x[i][j]);           }           printf(  n );         }       } else {         printf( YES n );         x[1][n / 2] =  # ;         for (int i = 1; i <= m / 2; i++) {           x[1][(n / 2) + i] =  # ;           x[1][(n / 2) - i] =  # ;         }         for (int i = 0; i < 4; i++) {           for (int j = 0; j < n; j++) {             printf( %c , x[i][j]);           }           printf(  n );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, long long> m;   long long n, p;   int main() {     cin >> n;     while (cin >> n) m[n]++;     for (n = 1; n < 11; n++) p += m[n] * m[n * -1];     cout << p + m[0] * (m[0] - 1) / 2;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a[100], s, sum = 0;     cin >> n >> s;     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     for (int i = 0; i < n - 1; i++) sum += a[i];     if (sum <= s)       cout <<  YES n ;     else       cout <<  NO n ;     return 0;   }