malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int h;   int seq[200010];   int par[200010];   int cur, cur_par, rem = -1, rem_par;   int main() {     scanf( %d , &(h));     for (int i = 0; i < h + 1; i++) scanf( %d , &(seq[i]));     cur_par = 1;     cur = 1;     for (int i = 0; i < h; i++) {       if (rem == -1 && seq[i] > 1 && seq[i + 1] > 1) {         puts( ambiguous );         rem = cur;         rem_par = cur_par;       }       for (int j = 0; j < seq[i + 1]; j++) par[cur + j] = cur_par;       cur += seq[i + 1];       cur_par = cur;     }     if (rem == -1) {       puts( perfect );       return 0;     }     for (int i = 0; i < cur; i++) printf( %d  , par[i]);     puts(  );     par[rem] = rem_par - 1;     for (int i = 0; i < cur; i++) printf( %d  , par[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 10;   long long a[MAXN], dp[MAXN];   int main() {     long long n, ans = 0;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = n - 2; i >= 0; i--) {       dp[i] = dp[i + 1];       if (a[i + 1] == 0) dp[i]++;     }     for (int i = 0; i < n; i++)       if (a[i] == 1) ans += dp[i];     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   void FastIO() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.precision(20);   }   int main() {     FastIO();     int A, B;     while (cin >> A >> B) {       int M = min(A, B);       int N = max(A - M, B - M);       cout << M <<     << N / 2 << endl;     }     return 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   int n, m, a[16][11234], b[16][16], c[16][16], dp[1 << 16][16];   void solve(int u) {     for (int i = 0; i < 1 << n; ++i)       for (int j = 0; j < n; ++j) dp[i][j] = 0;     dp[1 << u][u] = inf;     for (int i = 0; i < 1 << n; ++i)       for (int j = 0; j < n; ++j)         if (dp[i][j])           for (int k = 0; k < n; ++k)             if (!(i >> k & 1))               dp[i | (1 << k)][k] =                   max(dp[i | (1 << k)][k], min(dp[i][j], b[j][k]));   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) scanf( %d , &a[i][j]);     if (n == 1) {       int res = inf;       for (int j = 0; j < m - 1; ++j) res = min(res, abs(a[0][j] - a[0][j + 1]));       printf( %d n , res);       return 0;     }     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j)         if (i != j) {           b[i][j] = c[i][j] = inf;           for (int k = 0; k < m; ++k)             b[i][j] = min(b[i][j], abs(a[i][k] - a[j][k]));           for (int k = 0; k < m - 1; ++k)             c[i][j] = min(c[i][j], abs(a[i][k] - a[j][k + 1]));         }     int res = 0;     for (int i = 0; i < n; ++i) {       solve(i);       for (int j = 0; j < n; ++j)         if (i != j) res = max(res, min(c[i][j], dp[(1 << n) - 1][j]));     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long m, loc, t;   long long now;   class SegTree {    private:     long long F2(long long k) { return 1 << (long long)ceil(log2(k)); }     vector<long long> seg;     void Merge(long long cur) { seg[cur] = seg[2 * cur] + seg[2 * cur + 1]; }       public:     SegTree(long long n) {       m = F2(n);       for (long long i = 0; i < 2 * m + 2; i++) seg.push_back(0);     }     void Add(long long loc, long long cur = 1, long long l = 1, long long r = m) {       if (r < l || r < loc || loc < l)         return;       else if (l == r)         return void(seg[cur]++);       long long mid = (l + r) / 2;       Add(loc, 2 * cur, l, mid);       Add(loc, 2 * cur + 1, mid + 1, r);       Merge(cur);     }     long long Get(long long a, long long b, long long cur = 1, long long l = 1,                   long long r = m) {       if (r < l || r < a || b < l)         return 0;       else if (a <= l && r <= b)         return seg[cur];       long long mid = (l + r) / 2;       long long x = Get(a, b, 2 * cur, l, mid);       long long y = Get(a, b, 2 * cur + 1, mid + 1, r);       return x + y;     }     long long BinarySearch(long long a, long long l = 1, long long r = now) {       if (r < l) return a;       long long mid = (l + r) / 2;       if (!Get(a + 1, mid)) return max(mid, BinarySearch(a, mid + 1, r));       return BinarySearch(a, l, mid - 1);     }   };   vector<pair<long long, long long>> v;   int main() {     long long q;     cin >> q;     while (q--) {       long long n;       cin >> n;       now = n;       loc = 0;       long long a[n + 1];       v.clear();       SegTree s(n);       for (long long i = 0; i < n; i++) {         cin >> t;         if (t < loc) s.Add(i + 1);         loc = t;         a[i + 1] = t;       }       loc = 2;       long long ans = 1;       long long last = 1, cur = 0;       while (loc <= n) {         if (last == 0) swap(last, cur), ans++;         last--;         long long now = s.BinarySearch(loc + 1);         if (loc == n)           now = loc;         else if (a[loc + 1] < a[loc])           now = loc;         cur += now - loc + 1;         loc = now + 1;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, T, t[1005] = {0}, v;   int main() {     std::ios::sync_with_stdio(false);     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &v);       t[v]++;     }     scanf( %d , &T);     int ans = 0, sum = 0;     for (int i = 1; i <= 1000; i++) {       sum += t[i];       if (i > T + 1) sum -= t[i - T - 1];       if (sum > ans) ans = sum;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int q;     cin >> q;     while (q--) {       int n, k;       cin >> n >> k;       int s[n];       char c;       for (int i = 0; i < n; i++) {         cin >> c;         if (c ==  R )           s[i] = 0;         else if (c ==  G )           s[i] = 1;         else           s[i] = 2;       }       int counter1 = 0;       int counter2 = 0;       int counter3 = 0;       int myMin = k;       for (int l = 0; l < k; l++) {         if (s[l] != l % 3) {           counter1++;         }         if (s[l] != (l + 1) % 3) {           counter2++;         }         if (s[l] != (l + 2) % 3) {           counter3++;         }       }       myMin = min(myMin, min(counter1, min(counter2, counter3)));       for (int j = 0; j < n - k; j++) {         if (j % 3 != s[j]) {           counter1--;         }         if ((k + j) % 3 != s[j + k]) {           counter1++;         }         if ((j + 1) % 3 != s[j]) {           counter2--;         }         if ((k + j + 1) % 3 != s[j + k]) {           counter2++;         }         if ((j + 2) % 3 != s[j]) {           counter3--;         }         if ((k + j + 2) % 3 != s[j + k]) {           counter3++;         }         myMin = min(myMin, min(counter1, min(counter2, counter3)));       }       cout << myMin << endl;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int a, b;     scanf( %d %d , &a, &b);     int fc, uc, df, sum = 0;     fc = a;     uc = 0;     df = b;     while (1) {       sum += fc;       if (fc == 0 && uc < df) break;       uc += fc;       fc = uc / df;       uc = uc % df;     }     printf( %d n , sum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long N;   bool ask(long long n) {     cout <<  ?   << n << endl;     bool res;     cin >> res;     return res;   }   void solve() {     cin >> N;     long long l = 1;     long long r = N - 1;     long long delta = 0;     long long start = N;     bool t = false;     while (l <= r) {       long long m = (l + r) >> 1;       delta += t ? -m : m;       start = min(start, N - delta);       l = m + 1;       t = !t;     }     l = 1;     r = N - 1;     t = false;     long long ans = N;     ask(start);     while (l <= r) {       long long m = (l + r) >> 1;       long long ns = start + (t ? -m : m);       if (ask(ns)) {         ans = m;         r = m - 1;       } else {         l = m + 1;       }       t = !t;       start = ns;     }     cout <<  =   << ans << endl;     return;   }   int main() {     int T;     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     int in;     cin >> n >> m;     vector<int> v(n + 1, 0);     for (int i = 1; i <= n; ++i) {       cin >> in;       v[i] = in;     }     int a, b;     double c = 0;     double ret = 0;     for (int i = 0; i < m; ++i) {       cin >> a >> b >> c;       ret = max((double)((v[a] + v[b]) / c), ret);     }     cout << fixed << std::setprecision(10) << ret << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, c = 0, ans = 0;     scanf( %d%d%d , &n, &a, &b);     for (int i = 0; i < n; i++) {       int x;       scanf( %d , &x);       if (x == 1) {         if (a > 0)           a--;         else if (b > 0) {           b--;           c++;         } else if (c > 0)           c--;         else           ans++;       } else if (b > 0)         b--;       else         ans += 2;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int MAXN = 405;   int n, ans = -1;   int c[MAXN];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &c[i]);     for (int i = 2; i <= n; i++) {       for (int j = i; j <= n; j++) {         int p = c[i - 1] - 1, cnt = 1, w = c[j];         for (int k = i; k <= j; k++) {           cnt += p / c[k];           w += p / c[k] * c[k];           p %= c[k];         }         p = w;         for (int k = 1; k <= n; k++) {           cnt -= p / c[k];           p %= c[k];         }         if (cnt < 0 && (ans == -1 || w < ans)) ans = w;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 100 + 13;   int N, M;   int s[maxN][maxN];   void enlarge(int x, int y, int l) {     int col = s[x][y];     for (int i = x; i <= x + l; i++)       for (int j = y; j <= y + l; j++) s[i][j] = col;     return;   }   void paint(int x, int y) {     int col = 0;     for (int i = 1; i <= 26; i++) {       if (i != s[x - 1][y] && i != s[x][y - 1] && i != s[x][y + 1]) {         col = i;         break;       }     }     s[x][y] = col;     int r = M;     for (int i = y + 1; i <= M; i++) {       if (s[x][i] == col || s[x - 1][i] == col) {         r = i - 1;         break;       }       if (s[x][i]) {         r = i - 1;         break;       }       bool flag(false);       for (int j = 1; j < col; j++) {         if (j != s[x - 1][i]) {           flag = true;           r = i - 1;           break;         }       }       if (flag) break;     }     r -= y;     r = min(N - x, r);     enlarge(x, y, r);     return;   }   int main() {     scanf( %d%d , &N, &M);     for (int i = 0; i <= N; i++) s[i][0] = 30;     for (int i = 0; i <= M; i++) s[0][i] = 30;     for (int i = 1; i <= N; i++)       for (int j = 1; j <= M; j++)         if (s[i][j] == 0) paint(i, j);     for (int i = 1; i <= N; i++) {       for (int j = 1; j <= M; j++) cout << (char)(s[i][j] - 1 +  A );       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class TaskA {    public:     void solve(istream& in, ostream& out) {       int n, m;       in >> n >> m;       int cell = m - 1;       for (int i = 0; i < n; ++i) {         if (i & 1) {           for (int j = 0; j < m; ++j) out << (j == cell ?  #  :  . );           cell = (cell == m - 1 ? 0 : m - 1);         } else           for (int j = 0; j < m; ++j) out <<  # ;         out <<   n ;       }     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     TaskA solver;     std::istream& in(std::cin);     std::ostream& out(std::cout);     solver.solve(in, out);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   vector<int> ps[200000];   int sum[200000];   int main() {     int T;     cin >> T;     for (int t = 0; t < T; t++) {       int n;       cin >> n;       for (int i = 0; i < n; i++) ps[i].clear();       for (int i = 0; i < n; i++) {         int p, m;         cin >> m >> p;         ps[m].push_back(p);       }       sum[0] = 0;       for (int i = 0; i + 1 < n; i++) {         sum[i + 1] = sum[i] + ps[i].size();       }       priority_queue<int, vector<int>, greater<int>> Q;       int cnt = 0;       long long ans = 0;       for (int i = n - 1; i >= 0; i--) {         for (int p : ps[i]) Q.push(p);         int k = max(i - sum[i] - cnt, 0);         for (int j = 0; j < k; j++) {           ans += Q.top();           Q.pop();         }         cnt += k;       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   pair<long long int, pair<int, bool> > p[200005 << 1];   long long int a[200005], tree[200005 << 2][2];   long long int get(int n, int b, int e, int i, int j, bool c) {     if (i > j || j < b || e < i) return 0;     if (i <= b && j >= e) return tree[n][c];     int l, r, m;     m = (b + e) >> 1;     l = (n << 1) + 1;     r = l + 1;     return max(get(l, b, m, i, j, c), get(r, m + 1, e, i, j, c));   }   void update(int n, int b, int e, int i, long long int v, bool c) {     if (i < b || i > e) return;     if (b == e) {       tree[n][c] = v;       return;     }     int l, r, m;     m = (b + e) >> 1;     l = (n << 1) + 1;     r = l + 1;     update(l, b, m, i, v, c);     update(r, m + 1, e, i, v, c);     tree[n][c] = max(tree[l][c], tree[r][c]);   }   int main() {     int n;     long long int t;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %lld , &a[i]);       p[i] = make_pair(a[i] - i, make_pair(i, 1));       if (i > 0) p[i + n - 1] = make_pair(a[i] - i + 1, make_pair(i - 1, 0));     }     int m = 2 * n - 1;     sort(p, p + m);     for (int i = 0; i < m; i++) {       t = get(0, 0, n - 1, 0, p[i].second.first - 1, 1);       if (!p[i].second.second)         t = max(t, get(0, 0, n - 1, 0, p[i].second.first - 1, 0));       update(0, 0, n - 1, p[i].second.first, t + 1, p[i].second.second);     }     printf( %lld n , max(0ll, n - 1 - max(tree[0][1], tree[0][0])));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, j, k, n, m, res, c1, c0;   long long a[200009];   string s;   set<long long> st;   queue<long long> q;   int main() {     int nt;     cin >> nt;     while (nt--) {       cin >> s;       s =  R  + s;       s +=  R ;       long long last = 0, res = 0;       for (i = 0; i < s.length(); i++) {         if (s[i] ==  R ) res = max(res, i - last), last = i;       }       cout << res <<   n ;     }     exit(0);   }
#include <bits/stdc++.h>   using namespace std;   struct BIT {     int a[400010], size, n, dl, dr, dir, len;     inline void set(int x, int v) {       int k = v - query(x, x);       for (; x <= size; x += ((x) & (-(x)))) a[x] += k;     }     inline void add(int x, int v) {       for (; x <= size; x += ((x) & (-(x)))) a[x] += v;     }     inline int query(int x) {       int res = 0;       for (; x; x -= ((x) & (-(x)))) res += a[x];       return res;     }     inline int query(int l, int r) { return query(r) - query(l - 1); }     inline void ope1(int x) {       if (x > len - x) dir = -dir, x = len - x;       if (dir == 1) {         dl += x;         for (int i = 1; i <= x; i++) {           add(dl + i, query(dl - i + 1, dl - i + 1));           set(dl - i + 1, 0);         }       } else {         dr += x;         for (int i = 1; i <= x; i++) {           add(n - (dr + i) + 1, query(n - (dr - i), n - (dr - i)));           set(n - (dr - i), 0);         }       }       len = max(x, len - x);     }     inline void ope2(int l, int r) {       if (dir == 1)         printf( %d n , query(l + dl + 1, r + dl));       else         printf( %d n , query(n - dr - r + 1, n - dr - l));     }     void init(int N) {       for (size = 1; size < N; size <<= 1)         ;       dl = dr = 0, dir = 1, len = n = N;       for (int i = 1; i <= n; i++) set(i, 1);     }     void debug() {       printf( =============== n );       for (int i = 1; i <= n; i++) printf( %d  , query(i, i));       printf(  n );     }   } a;   int n, q;   int main() {     scanf( %d%d , &n, &q);     a.init(n);     for (int i = 1, ope, l, r, p; i <= q; i++) {       scanf( %d , &ope);       if (ope == 1) {         scanf( %d , &p);         a.ope1(p);       } else {         scanf( %d%d , &l, &r);         a.ope2(l, r);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, nrE;   struct Dish {     int p, s, b;   } d[100002];   struct Person {     int inc, pref;   } v[100002];   struct Event {     int x, y, z, t;     bool operator<(const Event &ot) const {       if (x == ot.x) return z > ot.z;       return x < ot.x;     }   } E[100002 * 3];   unordered_map<int, int> Bit[2];   int ans[100002];   void Add(int t, int i, int val) {     for (; i < 2 * 1000000005 && i > 0; i += (i & (-i))) Bit[t][i] += val;   }   int Sum(int t, int i) {     int ret = 0;     for (; i > 0; i -= (i & (-i))) ret += Bit[t][i];     return ret;   }   void readDish() {     for (int i = 0; i < n; ++i) scanf( %d , &d[i].p);     for (int i = 0; i < n; ++i) scanf( %d , &d[i].s);     for (int i = 0; i < n; ++i) scanf( %d , &d[i].b);   }   void readPers() {     for (int i = 0; i < m; ++i) scanf( %d , &v[i].inc);     for (int i = 0; i < m; ++i) scanf( %d , &v[i].pref);   }   void solveEvents() {     sort(E, E + nrE);     for (int i = 0; i < nrE; ++i) {       if (E[i].z <= 0) {         int idx = -E[i].z;         ans[idx] = Sum(0, v[idx].inc + v[idx].pref) +                    Sum(1, v[idx].pref - v[idx].inc + 1000000005);       } else {         Add(0, E[i].x + E[i].y, 1 * E[i].t);         Add(1, E[i].z - E[i].x + 1000000005, -1 * E[i].t);       }     }   }   int main() {     scanf( %d%d , &n, &m);     readDish();     readPers();     for (int i = 0; i < n + m; ++i) {       if (i < n) {         E[nrE++] = {d[i].p, d[i].b, d[i].b + 1, 1};         E[nrE++] = {d[i].s + 1, d[i].b - (d[i].s - d[i].p + 1),                     d[i].b + (d[i].s - d[i].p + 1) + 1, -1};       } else         E[nrE++] = {v[i - n].inc, v[i - n].pref, n - i, 0};     }     solveEvents();     for (int i = 0; i < m; ++i) printf( %d  , ans[i]);     return 0;   }
#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 <class 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 <class 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 <class T>   inline void printsp(T first) {     print(first);     putchar(   );   }   template <class T>   inline void println(T first) {     print(first);     putchar(  n );   }   template <class T, class U>   inline void print(T first, U second) {     printsp(first);     println(second);   }   template <class T, class U, class V>   inline void print(T first, U second, V 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;   }   const int C = 333333;   vector<int> adj[C];   int root[C], sz[C], d[C], src;   pair<int, int> f;   int find_root(int u) {     return (root[u] == u ? u : root[u] = find_root(root[u]));   }   void add(int u, int v) {     int uu = find_root(u), vv = find_root(v);     if (uu == vv) return;     sz[vv] += sz[uu];     root[uu] = vv;     smax(d[vv], max(d[uu], (1 + d[uu]) / 2 + (1 + d[vv]) / 2 + 1));   }   void dfs(int u, int dp = 0) {     root[u] = src;     sz[src]++;     if (dp > f.second) {       f.second = dp;       f.first = u;     }     for (int i = 0; i < adj[u].size(); i++) {       int v = adj[u][i];       if (root[v]) continue;       dfs(v, dp + 1);     }   }   void rdfs(int u, int dp = 0, int fa = 0) {     smax(d[src], dp);     for (int i = 0; i < adj[u].size(); i++) {       int v = adj[u][i];       if (v == fa) continue;       rdfs(v, dp + 1, u);     }   }   void solve_C() {     int n, m, q, u, v;     gn(n, m, q);     for (int i = 0; i < m; i++) {       gn(u, v);       adj[u].push_back(v);       adj[v].push_back(u);     }     for (int i = 1; i <= n; i++)       if (!root[i]) {         f.first = i;         f.second = 0;         src = i;         dfs(i);         rdfs(f.first);       }     while (q--) {       int t;       gn(t);       if (t == 1) {         gn(u);         u = find_root(u);         println(d[u]);       } else {         gn(u, v);         add(u, v);       }     }     exit(0);   }   int main() {     solve_C();     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const long long MOD = 1000000007LL, INF = 1e9, LINF = 1e18;   const long double PI = 3.141592653589793116, EPS = 1e-9,                     GOLD = ((1 + sqrt(5)) / 2);   template <class T>   int getbit(T s, int i) {     return (s >> 1) & 1;   }   template <class T>   T onbit(T s, int i) {     return s | (T(1) << i);   }   template <class T>   T offbit(T s, int i) {     return s & (~(T(1) << i));   }   template <class T>   int cntbit(T s) {     return __builtin_popcount(s);   }   string s;   long long n;   vector<long long> cc(26, 0);   void VarInput() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> s;     n = s.size();   }   void ProSolve() {     for (long long i = 0; i < n; i++) cc[s[i] -  a ]++;     long long appear = 0, onlyOne = 0;     for (long long i = 0; i < 26; i++) {       if (cc[i] > 0) appear++;       if (cc[i] == 1) onlyOne++;     }     if (appear > 4) {       cout <<  No ;       return;     }     if (appear < 2) {       cout <<  No ;       return;     }     if (appear == 2 && onlyOne > 0) {       cout <<  No ;       return;     }     if (appear == 3 && onlyOne > 2) {       cout <<  No ;       return;     }     cout <<  Yes ;   }   int main() {     VarInput();     ProSolve();   }
#include <bits/stdc++.h>   using namespace std;   const long long int maxn = 1e3 + 2;   const long long int mod = 1e3 + 2;   vector<long long int> d;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n, x, ans = INT_MAX;     cin >> n >> x;     long long int minx = x, maxx = x, a[maxn];     memset(a, 0, sizeof(a));     for (long long int i = 0; i < n; i++) {       long long int start, stop;       cin >> start >> stop;       if (stop < start) swap(start, stop);       for (long long int j = start; j <= stop; j++) ++a[j];     }     for (long long int i = 0; i <= 1003; i++)       if (a[i] == n) ans = min(abs(x - i), ans);     if (ans == INT_MAX)       cout <<  -1  << endl;     else       cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     int a, n2 = 0, n1 = 0;     for (int i = 0; i < n; i++) cin >> a, a - 1 ? n2++ : n1++;     if (n2) cout << 2 <<    ;     if (n1) cout << 1 <<    ;     for (int i = 0; i < n2 - 1; i++) cout << 2 <<    ;     for (int i = 0; i < n1 - 1; i++) cout << 1 <<    ;     return 0;   }