malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long int gcd(long long int a, long long int b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long int INF = 1e17;   long long int NINF = (INF * -1);   priority_queue<pair<long long int, long long int>,                  vector<pair<long long int, long long int>>,                  greater<pair<long long int, long long int>>>       pq;   vector<long long int> indegree;   vector<vector<pair<long long int, long long int>>> adj;   vector<long long int> distances;   vector<vector<long long int>> arr;   vector<bool> visited;   vector<long long int> level, height;   vector<long long int> ans;   long long int dfs(long long int src, long long int parent = -1,                     long long int l = 0) {}   void solve() {     long long int n;     cin >> n;     string a;     string b;     cin >> a >> b;     vector<long long int> ab, ba;     vector<pair<long long int, long long int>> ans;     for (long long int i = 0; i < n; i++) {       if (a[i] == b[i]) {         continue;       }       if (a[i] ==  a  and b[i] ==  b ) {         if (ab.size() != 0) {           ans.push_back({ab.back(), i + 1});           ab.pop_back();         } else {           ab.push_back(i + 1);         }       } else {         if (ba.size() != 0) {           ans.push_back({ba.back(), i + 1});           ba.pop_back();         } else {           ba.push_back(i + 1);         }       }     }     if (ab.size() == 1 and ba.size() == 1) {       ans.push_back({ba.back(), ba.back()});       ans.push_back({ba.back(), ab.back()});       ab.pop_back();       ba.pop_back();     }     if (ab.size() != 0 || ba.size() != 0) {       cout <<  -1 n ;       return;     }     cout << ans.size();     cout <<   n ;     ;     for (auto i : ans) {       cout << i.first <<     << i.second;       cout <<   n ;       ;     }     return;   }   signed main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     long long int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename T1>   T amax(T& a, T1 b) {     if (b > a) a = b;     return a;   }   template <typename T, typename T1>   T amin(T& a, T1 b) {     if (b < a) a = b;     return a;   }   const long long N = 200005, INF = 2000000000000000000;   void solve() {     long long n, m;     cin >> n >> m;     long long i = 0, j = 0;     char v[50][50];     long long a = 1000000, b = 10000, c = 0, d = 0;     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         cin >> v[i][j];         if (v[i][j] ==  * ) {           a = min(i, a);           b = min(j, b);           c = max(i, c);           d = max(j, d);         }       }     }     for (i = a; i < c + 1; i++) {       for (j = b; j < d + 1; j++) {         cout << v[i][j];       }       cout <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     solve();   }
#include <bits/stdc++.h>   #pragma optimization_level 3   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 )   using namespace std;   mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());   int inf = INT32_MAX;   struct Node {     Node *l = 0, *r = 0;     vector<int> m1, m2;     Node(Node *a, Node *b) {       m1 = vector<int>(9);       m2 = vector<int>(9);       l = a, r = b;       for (int q = 0; q < 9; q++) m1[q] = min(l->m1[q], r->m1[q]);       for (int q = 0; q < 9; q++)         m2[q] = min(max(l->m1[q], r->m1[q]), min(l->m2[q], r->m2[q]));     }     Node(Node *a, Node *b, int c) {       m1 = vector<int>(9);       m2 = vector<int>(9, inf);       l = a, r = b;       for (int q = 0, v = c; q < 9; q++, c /= 10) m1[q] = c % 10 ? v : inf;     }   };   Node *build(int l, int r, vector<int> &m) {     if (l == r) return new Node(0, 0, m[l - 1]);     int md = (l + r) / 2;     return new Node(build(l, md, m), build(md + 1, r, m));   }   pair<int, int> que(int l, int r, int l1, int r1, Node *n, int c) {     if (l == l1 && r == r1) return {n->m1[c], n->m2[c]};     int md = (l1 + r1) / 2;     if (r <= md) return que(l, r, l1, md, n->l, c);     if (l > md) return que(l, r, md + 1, r1, n->r, c);     pair<int, int> p1 = que(l, md, l1, md, n->l, c);     pair<int, int> p2 = que(md + 1, r, md + 1, r1, n->r, c);     return {min(p1.first, p2.first),             min(max(p1.first, p2.first), min(p1.second, p2.second))};   }   void upd(int l, int r, int p, Node *n, int v) {     if (l == r) {       for (int q = 0, c = v; q < 9; q++, v /= 10) n->m1[q] = v % 10 ? c : inf;       return;     }     int md = (l + r) / 2;     if (p <= md)       upd(l, md, p, n->l, v);     else       upd(md + 1, r, p, n->r, v);     for (int q = 0; q < 9; q++) n->m1[q] = min(n->l->m1[q], n->r->m1[q]);     for (int q = 0; q < 9; q++)       n->m2[q] =           min(max(n->l->m1[q], n->r->m1[q]), min(n->l->m2[q], n->r->m2[q]));   }   int a, z;   vector<int> m;   int main() {     cin.tie(0);     cout.tie(0);     cin.sync_with_stdio(0);     cout.sync_with_stdio(0);     ;     cin >> a >> z;     m = vector<int>(a);     for (int q = 0; q < a; q++) cin >> m[q];     Node *n = build(1, a, m);     for (; z; z--) {       int t, x, y;       cin >> t >> x >> y;       if (t == 1)         upd(1, a, x, n, y);       else {         int o = inf;         for (int q = 0; q < 9; q++) {           pair<int, int> p = que(x, y, 1, a, n, q);           if (p.second == inf) continue;           o = min(o, p.first + p.second);         }         cout << (o == inf ? -1 : o) <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int maxn = 3e3 + 555;   struct node {     long long x, y, v;     bool operator<(const node& n) const {       if (x != n.x)         return x < n.x;       else         return y < n.y;     }   };   long long pre[maxn][maxn];   node ori[maxn];   inline long long cal(long long hang1, long long lie1, long long hang2,                        long long lie2) {     hang1 = min(hang1, 1000ll);     lie1 = min(lie1, 1000ll);     hang2 = max(hang2, 1ll);     lie2 = max(lie2, 1ll);     return pre[hang1][lie1] - pre[hang1][lie2 - 1] - pre[hang2 - 1][lie1] +            pre[hang2 - 1][lie2 - 1];   }   long long buxuan[maxn];   long long f[maxn];   void init() {     f[0] = 1;     for (long long i = 1; i < maxn; i++) f[i] = f[i - 1] * i % mod;   }   inline long long qpow(long long a, long long n) {     long long base = a;     long long res = 1;     while (n) {       if (n & 1) res = res * base % mod;       base = base * base % mod;       n >>= 1;     }     return res;   }   long long C(long long n, long long m) {     if (n < m) return 0;     return f[n] * qpow(f[m], mod - 2) % mod * qpow(f[n - m], mod - 2) % mod;   }   void solve() {     long long n, m, r;     scanf( %lld %lld %lld , &n, &m, &r);     for (long long i = 1; i <= n; i++) {       scanf( %lld %lld %lld , &ori[i].x, &ori[i].y, &ori[i].v);       pre[ori[i].x][ori[i].y] = 1;     }     sort(ori + 1, ori + n + 1);     long long ans = 0;     for (long long i = 1; i <= 1000; i++)       for (long long j = 1; j <= 1000; j++) pre[i][j] += pre[i][j - 1];     for (long long j = 1; j <= 1000; j++)       for (long long i = 1; i <= 1000; i++) pre[i][j] += pre[i - 1][j];     long long base = C(n, m);     for (long long i = 1; i <= n; i++) {       long long wai =           n - cal(ori[i].x + r, ori[i].y + r, ori[i].x - r, ori[i].y - r);       long long cnt = C(wai, m);       buxuan[i] = cnt;       ans += ori[i].v * ori[i].v % mod * (base - cnt) % mod;       ans %= mod;     }     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j < i; j++) {         long long wai =             n - cal(ori[i].x + r, ori[i].y + r, ori[i].x - r, ori[i].y - r);         wai -= cal(ori[j].x + r, ori[j].y + r, ori[j].x - r, ori[j].y - r);         if (ori[i].x - ori[j].x <= r * 2) {           if (abs(ori[j].y - ori[i].y) <= r * 2) {             if (ori[j].y < ori[i].y)               wai = wai +                     cal(ori[j].x + r, ori[j].y + r, ori[i].x - r, ori[i].y - r) %                         mod;             else               wai = wai +                     cal(ori[j].x + r, ori[i].y + r, ori[i].x - r, ori[j].y - r) %                         mod;           }         }         long long cnt = (base - buxuan[i] - buxuan[j] + C(wai, m)) % mod;         cnt += mod;         cnt %= mod;         ans += ori[i].v * ori[j].v % mod * 2 % mod * cnt % mod;         ans %= mod;       }     }     printf( %lld n , ans);   }   signed main() {     init();     solve();   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   void self_max(long long& a, const long long& b) { a = max(a, b); }   void self_min(long long& a, const long long& b) { a = min(a, b); }   inline void preprocessing() {}   inline void solve() {     long long n;     cin >> n;     if (n == 1) {       cout <<  1 0  <<   n ;       return;     }     vector<long long> factors;     long long value = 1;     long long len = ceil(sqrt(n)) + 1;     long long originalN = n;     for (long long i = 2; i < len; ++i) {       if (n == 1) break;       if (n % i == 0) {         long long cnt = 0;         while (n % i == 0) {           ++cnt;           n /= i;         }         factors.emplace_back(cnt);         value *= i;       }     }     long long maxCount = 0;     for (const long long& factor : factors)       if (factor > maxCount) maxCount = factor;     if (maxCount < 2) {       cout << originalN <<   0  <<   n ;       return;     }     long long operations = ceil(log2(maxCount));     long long u = exp2(operations);     for (const long long& factor : factors) {       if (factor != u) {         ++operations;         break;       }     }     if (n == 1)       cout << value <<     << operations <<   n ;     else       cout << value * n <<     << operations + 1 <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     preprocessing();     solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a, b, c;     cin >> a >> b >> c;     vector<long> v;     for (int i = 1; i <= 81; i++) {       long long sum = i;       for (int j = 2; j <= a; j++) sum *= i;       sum *= b;       sum += c;       if (sum > 0 && sum < 1000000000) {         long long cn = sum, cnt = 0;         while (cn) {           cnt += cn % 10;           cn /= 10;         }         if (cnt == i) v.push_back(sum);       }     }     cout << v.size() << endl;     for (int i = 0; i < v.size(); i++) cout << v[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-7;   const int maxn = 100 + 10;   int n;   complex<double> p[maxn];   int sign(double x) {     if (x < -eps) return -1;     return x > eps;   }   double cross(complex<double> a, complex<double> b) {     return (conj(a) * b).imag();   }   double dot(complex<double> a, complex<double> b) {     return (conj(a) * b).real();   }   double scross(complex<double> a, complex<double> b) {     return sign((conj(a) * b).imag());   }   double sdot(complex<double> a, complex<double> b) {     return sign((conj(a) * b).real());   }   bool inside(complex<double> a, complex<double> b, complex<double> c,               complex<double> d) {     return scross(b - a, d - a) == scross(c - b, d - b) &&            scross(b - a, d - a) == scross(a - c, d - c);   }   complex<double> rotate(complex<double> a, complex<double> b) {     return (b - a) * complex<double>(0, 1) + a;   }   complex<double> crosspoint(complex<double> a, complex<double> b,                              complex<double> c, complex<double> d) {     c = (c - a) / (b - a);     d = (d - a) / (b - a);     double dx = c.real() - d.real();     double dy = c.imag() - d.imag();     double x = c.real() - (dx * c.imag()) / dy;     return complex<double>(x, 0) * (b - a) + a;   }   complex<double> center(complex<double> a, complex<double> b,                          complex<double> c) {     complex<double> mab = (a + b) / 2.0;     complex<double> mac = (a + c) / 2.0;     complex<double> hab = rotate(mab, a);     complex<double> hac = rotate(mac, a);     return crosspoint(mab, hab, mac, hac);   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; ++i) {       double t1, t2;       cin >> t1 >> t2;       p[i] = complex<double>(t1, t2);     }     double ans = -1;     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j)         for (int k = 0; k < n; ++k) {           if (scross(p[i] - p[j], p[i] - p[k]) == 0) continue;           complex<double> cent = center(p[i], p[j], p[k]);           if (!inside(p[i], p[j], p[k], cent)) {             if (scross(p[k] - p[j], cent - p[j]) != 0) continue;             bool bo = false;             for (int i2 = 0; i2 < n; ++i2)               if (i2 != i && i2 != j && i2 != k &&                   scross(p[i] - p[i2], cent - p[i2]) == 0) {                 bo = true;                 break;               }             if (!bo) continue;           }           bool bo2 = false;           double r = abs(cent - p[i]);           for (int i2 = 0; i2 < n; ++i2)             if (i2 != i && i2 != j && i2 != k && abs(cent - p[i2]) < r - eps) {               bo2 = true;               break;             }           if (bo2) continue;           ans = max(ans, r);         }     if (sign(ans - (-1)) == 0)       cout << -1 << endl;     else       cout << setprecision(6) << fixed << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int leftColors[10], rightColors[10];     int leftParent[10], rightParent[10];     int components;     node() { components = 0; }   };   int n;   node merge(node l, node r) {     node ans;     ans.components = l.components + r.components;     for (int e = 0; e < n; e++) ans.leftParent[e] = l.leftParent[e];     for (int e = 0; e < n; e++) ans.leftColors[e] = l.leftColors[e];     for (int e = 0; e < n; e++) ans.rightParent[e] = r.rightParent[e];     for (int e = 0; e < n; e++) ans.rightColors[e] = r.rightColors[e];     for (int e = 0; e < n; e++) {       if (l.rightColors[e] == r.leftColors[e] &&           l.rightParent[e] != r.leftParent[e]) {         ans.components--;         int tmp = l.rightParent[e];         for (int f = 0; f < n; f++)           if (ans.leftParent[f] == tmp) ans.leftParent[f] = r.leftParent[e];         for (int f = 0; f < n; f++)           if (ans.rightParent[f] == tmp) ans.rightParent[f] = r.leftParent[e];         for (int f = 0; f < n; f++)           if (l.leftParent[f] == tmp) l.leftParent[f] = r.leftParent[e];         for (int f = 0; f < n; f++)           if (l.rightParent[f] == tmp) l.rightParent[f] = r.leftParent[e];       }     }     return ans;   }   const int maxn = 100100;   node tree[maxn << 2];   int grid[11][maxn];   void build(int id, int l, int r) {     if (l == r) {       for (int e = 0; e < n; e++) {         if (e && grid[e][l] == tree[id].leftColors[e - 1])           tree[id].leftParent[e] = tree[id].leftParent[e - 1],           tree[id].rightParent[e] = tree[id].rightParent[e - 1],           tree[id].leftColors[e] = tree[id].leftColors[e - 1],           tree[id].rightColors[e] = tree[id].rightColors[e - 1];         else {           tree[id].leftParent[e] = l * 20 + e;           tree[id].rightParent[e] = l * 20 + e;           tree[id].leftColors[e] = grid[e][l];           tree[id].rightColors[e] = grid[e][l];           tree[id].components++;         }       }     } else {       int mid = (l + r) >> 1;       build(id + id, l, mid);       build(id + id + 1, mid + 1, r);       tree[id] = merge(tree[id + id], tree[id + id + 1]);     }   }   node query(int id, int l, int r, int x, int y) {     if (x <= l && r <= y) return tree[id];     int mid = (l + r) >> 1;     if (y <= mid) return query(id + id, l, mid, x, y);     if (x > mid) return query(id + id + 1, mid + 1, r, x, y);     return merge(query(id + id, l, mid, x, y),                  query(id + id + 1, mid + 1, r, x, y));   }   int main() {     int m, q;     scanf( %d %d %d , &n, &m, &q);     for (int e = 0; e < n; e++)       for (int f = 0; f < m; f++) scanf( %d , &grid[e][f]);     build(1, 0, m - 1);     for (int e = 0; e < q; e++) {       int l, r;       scanf( %d %d , &l, &r);       printf( %d n , query(1, 0, m - 1, l - 1, r - 1).components);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long DP[100005][25], arr[100005], freq[100005], l = 1, r, ans;   void alter_range(long long l1, long long r1) {     while (l1 < l) {       l--;       ans += freq[arr[l]]++;     }     while (r < r1) {       r++;       ans += freq[arr[r]]++;     }     while (l < l1) {       ans -= --freq[arr[l]];       l++;     }     while (r1 < r) {       ans -= --freq[arr[r]];       r--;     }   }   void make_layer(long long layer, long long l1, long long r1, long long a,                   long long b) {     if (l1 > r1) return;     long long i, j, mid = (l1 + r1) >> 1, &curr = DP[mid][layer], best = mid,                     better;     for (i = a; i <= min(b, mid); i++) {       alter_range(i, mid);       better = DP[i - 1][layer - 1] + ans;       if (curr > better) {         curr = better;         best = i;       }     }     make_layer(layer, l1, mid - 1, a, best);     make_layer(layer, mid + 1, r1, best, b);   }   int main() {     long long i, j, n, k;     scanf( %lld %lld , &n, &k);     for (i = 1; i <= n; i++) scanf( %lld , &arr[i]);     for (i = 0; i <= n; i++)       for (j = 0; j <= k; j++) DP[i][j] = 1e18;     DP[0][0] = 0;     for (i = 1; i <= k; i++) make_layer(i, 1, n, 1, n);     printf( %lld n , DP[n][k]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int fuckAbs(long long int a) { return a >= 0 ? a : -a; }   int main(void) {     long long int t, n, m, ans, dx, dy, sx, sy, x1, y1, x2, y2;     cin >> t;     while (t--) {       cin >> n >> m >> x1 >> y1 >> x2 >> y2;       ans = n * m;       dx = n - max(x1, x2) + min(x1, x2);       dy = m - max(y1, y2) + min(y1, y2);       ans -= dx * dy * 2;       sx = sy = 0;       if (dx > fuckAbs(x1 - x2)) sx = dx - fuckAbs(x1 - x2);       if (dy > fuckAbs(y1 - y2)) sy = dy - fuckAbs(y1 - y2);       ans += sx * sy;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     int x;     cin >> x;     bool f1 = 0, f2 = 0;     long long su = 0;     for (int i = 0; i < n; i++) {       int k;       cin >> k;       su += k;       if (k == x) {         f1 = 1;       } else         f2 = 1;     }     if (!f1 && su == n * x) {       cout << 1;       return;     }     if (f1 && f2) cout << 1;     if (f1 && !f2) cout << 0;     if (!f1 && f2) cout << 2;   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     cout << fixed << setprecision(12);     int t = 1;     cin >> t;     for (int i = 1; i <= t; i++) {       solve();       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, j, m, s, ans;   long long n, k, t;   double sum;   int main() {     scanf( %lld%lld , &n, &k);     sum = (1.0 + k) * k / 2;     if (sum > n) {       puts( -1 );       return 0;     }     t = sum;     for (int i = 1; (long long)i * i <= n; i++)       if (n % i == 0) {         int k = i;         if (n / k - t >= 0) ans = max(ans, k);         k = n / i;         if (n / k - t >= 0) ans = max(ans, k);       }     for (int i = 1; i < k; i++) {       printf( %lld  , (long long)i * ans);       n -= (long long)i * ans;     }     printf( %lld n , n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   void pg() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int32_t main() {     pg();     long long t;     cin >> t;     while (t--) {       long long n, x;       cin >> n >> x;       long long arr[n];       long long sum = 0;       for (long long i = 0; i < n; i++) {         cin >> arr[i];         sum += arr[i];       }       sort(arr, arr + n);       long long cum = 0;       bool flag = 0;       for (long long i = 0; i < n; i++) {         if (((sum - cum) / (n - i)) >= x) {           cout << n - i << endl;           flag = 1;           break;         }         cum += arr[i];       }       if (flag == 0) {         cout << 0 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long int n, x;       cin >> n >> x;       long long int a[n];       a[0] = 0;       string s;       cin >> s;       for (int i = 0; i < n; i++) {         char ch;         ch = s[i];         if (i == 0) {           if (ch ==  1 )             a[i]--;           else             a[i]++;         } else {           if (ch ==  1 )             a[i] = a[i - 1] - 1;           else             a[i] = a[i - 1] + 1;         }       }       long long int as = 0;       for (int i = 0; i < n; i++) {         long long int k = (x - a[i]) * a[n - 1];         if (k >= 0) {           if (abs(x - a[i]) == 0 ||               (a[n - 1] != 0 && abs(x - a[i]) % abs(a[n - 1]) == 0)) {             as++;           }         }       }       long long int count = 0;       for (int i = 0; i < n; i++) {         if (a[i] == x) {           count++;         }       }       as = max(as, count);       if (as != 0 && a[n - 1] == 0) {         cout << -1 <<   n ;       } else {         if (x == 0) as++;         cout << as <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e7 + 10, maxl = 20, mod = 1e9 + 7, base = 737,                   inf = 2e18 + 13;   int a, n, res[maxn], t[maxn];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> a >> n;     for (int i = 2; i < a + n; i++)       if (!t[i]) {         t[i] = i;         for (long long j = 1ll * i * i; j < a + n; j += i) t[j] = i;       }     res[1] = 1;     for (int i = 2; i < a + n; i++) {       res[i] = res[i / t[i]];       if (res[i] % t[i])         res[i] *= t[i];       else         res[i] /= t[i];     }     long long ans = 0;     for (int i = a; i < a + n; i++) ans += res[i];     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long n;     cin >> n;     vector<long long> l(n + 5), r(n + 5);     for (long long i = 1; i < n + 1; ++i) cin >> l[i];     for (long long i = 1; i < n + 1; ++i) cin >> r[i];     vector<pair<long long, long long> > v;     for (long long i = 1; i < n + 1; ++i) v.push_back({l[i] + r[i], i});     sort(v.begin(), v.end());     long long x = n, ans[n + 5];     for (long long i = 0; i < (long long)v.size(); ++i) {       ans[v[i].second] = x;       while (i + 1 < (long long)v.size() && v[i].first == v[i + 1].first) {         ++i;         ans[v[i].second] = x;       }       x--;     }     for (long long i = 1; i < n + 1; ++i) {       long long c1 = 0;       for (long long j = 1; j < i; ++j)         if (ans[i] < ans[j]) ++c1;       long long c2 = 0;       for (long long j = i + 1; j < n + 1; ++j)         if (ans[j] > ans[i]) ++c2;       if (c1 == l[i] && c2 == r[i]) continue;       cout <<  NO n ;       return 0;     }     cout <<  YES n ;     for (long long i = 1; i < n + 1; ++i) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int INF = 1e16;   int a[2][111111];   int main(void) {     int n;     cin >> n;     for (int e = 0; e < 2; e++)       for (int p = 0; p < n; p++) cin >> a[e][p];     long long int tot = 0;     for (int e = 0; e < n; e++) tot += a[0][e];     sort(a[1], a[1] + n);     long long int kk = 0;     kk += a[1][n - 1] + a[1][n - 2];     if (kk >= tot)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n == 1) {       cout << 1 <<     << 1 << endl << 1 << endl;       return 0;     }     int value = n * 2 - 2;     cout << value <<     << 2 << endl << 1 <<     << 2 << endl;   }