malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int _5 = 100005, _6 = 1000006;   int n, a[1001], b[1001];   vector<int> v;   int main() {     scanf( %d , &n);     for (int i = 0, b; i < n; ++i) cin >> a[i];     for (int i = n - 1; i >= 0; --i) {       if (!b[a[i]]) {         b[a[i]] = 1;         v.push_back(a[i]);       }     }     cout << v.size() << endl;     for (int i = v.size() - 1; i >= 0; --i) {       cout << v[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> x;   int ax[3];   int main() {     ax[0] = ax[1] = ax[2] = 0;     cin >> n;     for (int i = 0; i < n; ++i) {       string s;       cin >> s;       int cc = 0;       for (int i = 0; i < s.size(); ++i) cc += s[i] -  0 ;       x.push_back(cc % 3);       ax[cc % 3]++;     }     int res = ax[0] / 2 + min(ax[1], ax[2]);     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   const long long N = 1e5 + 5;   vector<long long> vp;   long long n;   long long a[N];   long long binsearch(long long lo, long long hi, long long check) {     long long ans = -1;     while (hi >= lo) {       long long mid = (lo + hi) / 2;       if (a[mid] * check == n) {         return mid;       } else if (a[mid] * check < n) {         lo = mid + 1;       } else {         hi = mid - 1;       }     }     return ans;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (long long i = 1; i * i <= n; i++) {       if (n % i == 0) {         vp.push_back(n / i);         if (n / i != i) vp.push_back(i);       }     }     sort(vp.begin(), vp.end());     for (long long i = 1; i <= vp.size(); i++) {       a[i] = vp[i - 1];     }     long long mx = 0;     long long mn = 1e18;     for (long long i = 0; i < vp.size(); i++) {       for (long long j = 0; j < vp.size(); j++) {         long long k = binsearch(1, vp.size(), vp[i] * vp[j]);         if (k != -1) {           k--;           if (vp[i] * vp[j] * vp[k] == n) {             mn = min(mn, (vp[i] + 1) * (vp[j] + 2) * (vp[k] + 2) - n);             mn = min(mn, (vp[i] + 2) * (vp[j] + 2) * (vp[k] + 1) - n);             mn = min(mn, (vp[i] + 2) * (vp[j] + 1) * (vp[k] + 2) - n);             mx = max(mx, (vp[i] + 1) * (vp[j] + 2) * (vp[k] + 2) - n);             mx = max(mx, (vp[i] + 2) * (vp[j] + 2) * (vp[k] + 1) - n);             mx = max(mx, (vp[i] + 2) * (vp[j] + 1) * (vp[k] + 2) - n);           }         }       }     }     cout << mn <<     << mx <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 100005;   bool powertwo(long long int n) { return (n and !(n & (n - 1))); }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       long long int arr[n];       map<long long int, long long int> mp;       for (long long int i = 0; i < n; i++) {         cin >> arr[i];         mp[arr[i]]++;       }       long long int g = 0, s = 0, b = 0;       vector<long long int> v;       for (auto it = mp.rbegin(); it != mp.rend(); it++) v.push_back(it->second);       g = v[0];       long long int i = 1;       while (s <= g and i < v.size()) {         s += v[i];         i++;       }       while (b <= g and i < v.size()) {         b += v[i];         i++;       }       while ((g + s + b + v[i]) <= n / 2 and i < v.size()) {         b += v[i];         i++;       }       if ((g + s + b) > n / 2 or s < g or b < g)         cout <<  0 0 0 n ;       else if (g == 0 or s == 0 or b == 0)         cout <<  0 0 0 n ;       else         cout << g <<     << s <<     << b <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Point {     double x, y;     int num;     Point() {}     Point(double _x, double _y, int _num) : x(_x), y(_y), num(_num) {}     void read() { scanf( %lf%lf , &x, &y); }     double operator*(const Point &a) const { return x * a.y - a.x * y; }     Point operator-(const Point &a) const { return Point(x - a.x, y - a.y, num); }     bool operator<(const Point &a) const {       return y < a.y || y == a.y && x < a.x;     }     bool operator==(const Point &a) const { return x == a.x && y == a.y; }   } a[2000], s;   int sum = 0, cnt = 0, n, ans[2000], sz[2000];   int des[4000], nxt[4000], fst[2000];   int c[2000], nxtc[2000], fstc[2000];   bool vis[2000];   void add(int x, int y) { des[++sum] = y, nxt[sum] = fst[x], fst[x] = sum; }   void add2(int x, int y) { c[++cnt] = y, nxtc[cnt] = fstc[x], fstc[x] = cnt; }   void tree(int x) {     vis[x] = 1;     sz[x] = 1;     for (int i = fst[x]; i; i = nxt[i])       if (!vis[des[i]]) tree(des[i]), add2(x, des[i]), sz[x] += sz[des[i]];   }   double cross(Point a, Point b, Point c) { return (a - c) * (b - c); }   bool cmp(Point i, Point j) {     if (i == s) return 1;     if (j == s) return 0;     double y = cross(i, j, s);     if (y < 0) return 0;     return 1;   }   void solve(vector<Point> b, int fa) {     s = b[0];     for (int i = 1; i < b.size(); ++i)       if (b[i] < s) s = b[i];     sort(b.begin(), b.end(), cmp);     int l = 1;     ans[s.num] = fa;     for (int i = fstc[fa]; i; i = nxtc[i]) {       int k = c[i];       vector<Point> m;       for (int j = 1; j <= sz[k]; ++j) m.push_back(b[l]), l++;       solve(m, k);     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; ++i) {       int x, y;       scanf( %d%d , &x, &y);       add(x, y), add(y, x);     }     memset(vis, 0, sizeof vis);     tree(1);     vector<Point> b;     for (int i = 1; i <= n; ++i) a[i].read(), a[i].num = i, b.push_back(a[i]);     solve(b, 1);     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double a, b, c, d, e, f;     cin >> a >> b;     for (int i = 0; i < a; i++) {       cin >> c >> d;       e = c / d;       if (i > 0)         f = min(e, f);       else if (i == 0)         f = e;     }     printf( %.08f n , f * b);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, p[105][105], ans = 0;     cin >> n;     for (int i = 0; i < n; i++) {       for (int j = 0; j < 2; j++) {         cin >> p[i][j];       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < 2; j++) {         if (p[i][j + 1] - p[i][j] >= 2) ans++;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const int INF = 1000 * 1000 * 1000 + 7;   const long long LINF = INF * (long long)INF;   const int L = 22;   int G[L];   int dp[1 << L];   int P[1 << L];   int M[1 << L];   int n;   void print(int mask) {     for (int i = (0); i < (n); i++) {       if (mask & (1 << i)) {         cout <<  1  ;         continue;       }       cout <<  0  ;     }     cout << endl;   }   bool isClik(int mask) {     for (int i = (0); i < (n); i++) {       if ((1 << i) & mask) {         mask ^= 1 << i;         if ((mask & G[i]) != mask) return false;         mask ^= 1 << i;       }     }     return true;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int m;     cin >> n >> m;     for (int i = (0); i < (m); i++) {       int a, b;       cin >> a >> b;       a--;       b--;       G[a] |= 1 << b;       G[b] |= 1 << a;     }     for (int mask = (0); mask < (1 << n); mask++) {       dp[mask] = INF;     }     for (int mask = (0); mask < (1 << n); mask++) {       if (isClik(mask)) {         dp[mask] = 0;       }     }     for (int mask = (0); mask < (1 << n); mask++) {       for (int k = (0); k < (n); k++) {         if (!(mask & (1 << k))) continue;         if (dp[mask | G[k]] > dp[mask] + 1) {           dp[mask | G[k]] = dp[mask] + 1;           P[mask | G[k]] = k;           M[mask | G[k]] = mask;         }         dp[mask | G[k]] = min(dp[mask | G[k]], dp[mask] + 1);       }     }     int ans = dp[(1 << n) - 1];     cout << ans << endl;     vector<int> res;     int mask = (1 << n) - 1;     for (int i = (0); i < (ans); i++) {       res.push_back(P[mask]);       mask = M[mask];     }     reverse(res.begin(), res.end());     for (int i = (0); i < ((int)res.size()); i++) {       cout << res[i] + 1 <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline long long rd() {     long long x = 0;     int ch = getchar(), f = 1;     while (!isdigit(ch) && (ch !=  - ) && (ch != EOF)) ch = getchar();     if (ch ==  - ) {       f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline void rt(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10)       rt(x / 10), putchar(x % 10 +  0 );     else       putchar(x +  0 );   }   const int maxn = 5005, S = 100005;   int n, m, a[maxn], id[S], dsc[maxn];   short int f[maxn][maxn], g[maxn][maxn], h[maxn][7], ans;   void upd(short int &x, short int y) {     if (y > x) x = y;   }   int main() {     n = rd();     for (int i = int(1); i <= (int)(n); i++) a[i] = dsc[i] = rd();     sort(dsc + 1, dsc + n + 1);     m = unique(dsc + 1, dsc + n + 1) - dsc - 1;     for (int i = int(1); i <= (int)(m); i++) id[dsc[i]] = i;     for (int i = int(1); i <= (int)(n); i++) {       int x = id[a[i]];       for (int j = int(0); j <= (int)(i - 1); j++) {         if (x && dsc[x - 1] + 1 == a[i]) upd(f[j][i], g[j][x - 1] + 1);         if (x < m && dsc[x + 1] - 1 == a[i]) upd(f[j][i], g[j][x + 1] + 1);         upd(f[j][i], h[j][a[i] % 7] + 1);         if (j)           upd(h[i][a[j] % 7], f[j][i]), upd(g[i][id[a[j]]], f[j][i]);         else {           for (int k = int(0); k <= (int)(6); k++) upd(h[i][k], f[j][i]);           for (int k = int(1); k <= (int)(m); k++) upd(g[i][k], f[j][i]);         }         upd(g[j][id[a[i]]], f[j][i]), upd(h[j][a[i] % 7], f[j][i]);         upd(ans, f[j][i]);       }     }     rt(ans), putchar(  n );   }
#include <bits/stdc++.h>   using namespace std;   char s[300005];   int ans[300005];   int main() {     int n, m;     while (cin >> n >> m) {       int cnt = 0;       for (int i = 1; i <= n; i++) cin >> s[i];       for (int i = 1; i < n; i++)         if (s[i] == s[i + 1] && s[i] ==  . ) cnt++;       for (int i = 0; i < m; i++) {         int x;         char y;         cin >> x >> y;         if (s[x] ==  .  && s[x - 1] ==  . ) cnt--;         if (s[x] ==  .  && s[x + 1] ==  . ) cnt--;         s[x] = y;         if (s[x] ==  .  && s[x - 1] ==  . ) cnt++;         if (s[x] ==  .  && s[x + 1] ==  . ) cnt++;         ans[i] = cnt;       }       for (int i = 0; i < m; i++) cout << ans[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1005], b[1005];   int main() {     int n;     string s, ss;     cin >> n >> s >> ss;     for (int i = 0; i < n; i++) {       a[i] = s[i] -  0 ;       b[i] = ss[i] -  0 ;     }     sort(a, a + n);     sort(b, b + n);     int sum1 = 0, sum2 = 0;     for (int i = 0, j = 0; i < n && j < n;) {       while (j < n) {         if (a[i] <= b[j]) {           i++;           j++;           sum1++;           break;         } else {           j++;         }       }     }     int sum = n - sum1;     cout << sum << endl;     for (int i = 0, j = 0; i < n && j < n;) {       while (j < n) {         if (a[i] < b[j]) {           i++;           j++;           sum2++;           break;         } else {           j++;         }       }     }     cout << sum2;   }
#include<bits/stdc++.h>   #define endl   n    #define bug puts( aaa );   #define Case int t;scanf( %d ,&t);while(t--)   #define ios ios::sync_with_stdio(0),cin.tie(0);   using namespace std;   typedef long long ll;   typedef unsigned long long ull;   const double eps = 1e-5;   const int inf = 0x3f3f3f3f;   const int mod = 1e9+7;   const int N = 1e6+10;      int n,x,mi[N<<2],a[N];   unordered_map<int,int>mp;      struct node {    int x,y;   }e[N];         void pushup(int rt) {    mi[rt] = mp[e[mi[rt<<1]].y] > mp[e[mi[rt<<1|1]].y] ? mi[rt<<1|1] : mi[rt<<1];   }      void build(int l,int r,int rt) {    if(l==r) {     mi[rt] = 0;     return;    }    int mid = l+r>>1;    build(l,mid,rt<<1);    build(mid+1,r,rt<<1|1);    pushup(rt);   }      void update(int pos, int val, int l, int r, int rt) {    if(l==r) {     mi[rt] = mp[e[val].y] < mp[e[mi[rt]].y] ? val : mi[rt];     return;    }    int mid = l+r>>1;    if(pos <= mid) update(pos,val,l,mid,rt<<1);    else update(pos,val,mid+1,r,rt<<1|1);    pushup(rt);   }      int query(int L,int R,int l,int r,int rt) {    if(L<=l && r<=R) {     return mi[rt];    }    int mid = l+r>>1;    int lson = 0,rson = 0;    if(L <= mid) lson = query(L,R,l,mid,rt<<1);    if(R > mid) rson = query(L,R,mid+1,r,rt<<1|1);    return mp[e[lson].y] > mp[e[rson].y] ?rson:lson;   }      void run() {    mp.clear();    scanf( %d ,&n);    int x,y,range = 0,idx=0;    e[0].x = e[0].y = inf;    mp[inf] = inf;    for (int i=1;i<=n;i++) {     scanf( %d %d ,&e[i].x,&e[i].y);     a[++idx] = e[i].x;     a[++idx] = e[i].y;        /**      * 如果不交换,只符合hj<hi && wj<wi的情况      * 首先按把w和h大的那个，放在x位置      * 那么我们去找[1,x-1]区间，里面的x肯定满足条件      * 接着在这个区间中去找符合条件的y,      */     if(e[i].x > e[i].y) swap(e[i].x,e[i].y);    }       /**     * 离散化     */    sort(a+1,a+idx+1);    for (int i=1;i<=idx;i++) {     if(mp[a[i]])continue;     mp[a[i]] = ++range;    }             build(1,range,1);    for (int i=1;i<=n;i++) {     update(mp[e[i].x],i,1,range,1);    }    for (int i=1;i<=n;i++) {     if(mp[e[i].x] == 1) {      printf( -1  );      continue;     }     int res = query(1,mp[e[i].x]-1,1,range,1);     if (e[res].y >= e[i].y) {      printf( -1  );     } else {      printf( %d  ,res);     }    }    printf(  n );   }         int main() {    // freopen( input.txt , r ,stdin);    // freopen( output.txt , w ,stdout);    Case    run();    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t N = 1e5 + 1;   int64_t crt_node = 0, maxi = 0;   vector<int64_t> previous;   vector<vector<int64_t>> adj;   void dfs(int64_t node, int64_t pere, int64_t len) {     previous[node] = pere;     if (len > maxi) {       crt_node = node;       maxi = len;     }     for (int64_t i : adj[node]) {       if (i != pere) dfs(i, node, len + 1);     }   }   bool ok = true;   vector<int64_t> level, path;   void hedgehog(int64_t node, int64_t pere) {     int64_t k = 0;     for (int64_t i : adj[node]) {       if (i != pere) {         hedgehog(i, node);         if (k == 0)           k = level[i];         else if (k != level[i])           ok = false;       }     }     if (adj[node].size() == 1)       level[node] = 1;     else if (adj[node].size() < 3 or              (adj[node].size() == 3 and path[path.size() / 2] != node))       ok = false;     else       level[node] = k + 1;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int64_t n, k;     cin >> n >> k;     if (n == 1) {       cout <<  No ;       return 0;     }     adj.resize(n + 1);     for (int64_t i = 1; i < n; ++i) {       int64_t u, v;       cin >> u >> v;       adj[u].emplace_back(v);       adj[v].emplace_back(u);     }     previous.resize(n + 1);     dfs(1, 0, 0);     int64_t a = crt_node;     maxi = 0;     fill(previous.begin(), previous.end(), 0ll);     dfs(crt_node, 0, 0);     int64_t b = crt_node;     while (b) {       path.emplace_back(b);       b = previous[b];     }     level.resize(n + 1);     hedgehog(path[path.size() / 2], 0);     if (level[path[path.size() / 2]] != k + 1) ok = false;     cout << (ok ?  Yes  :  No );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MN = 111;   int a[MN], n, g[MN][MN], c[MN];   struct Block {     int f[MN][MN];     void cal1() {       memset(f, 0, sizeof f);       for (int from = (1), _b = (100); from <= _b; from++) {         for (int to = (from), _b = (100); to <= _b; to++) f[from][to] = 0;         memset(g, 0, sizeof g);         for (int i = (1), _b = (n); i <= _b; i++) {           for (int to = (from), _b = (100); to <= _b; to++)             g[i][to] = g[i - 1][to];           if (a[i] >= from) {             g[i][a[i]] = max(g[i][a[i]], 1);             for (int prev = (from), _b = (a[i]); prev <= _b; prev++)               g[i][a[i]] = max(g[i][a[i]], g[i - 1][prev] + 1);           }         }         for (int to = (from), _b = (100); to <= _b; to++) f[from][to] = g[n][to];       }     }     void print() {       for (int from = (1), _b = (4); from <= _b; from++) {         for (int to = (1), _b = (4); to <= _b; to++) cout << f[from][to] <<    ;         cout << endl;       }       cout <<  ----  << endl;     }   } f[30], trans;   Block operator+(const Block& a, const Block& b) {     Block res;     memset(res.f, 0, sizeof res.f);     for (int from = (1), _b = (100); from <= _b; from++) {       for (int to = (1), _b = (100); to <= _b; to++) {         res.f[from][to] = a.f[from][to];         for (int mid = (from), _b = (to); mid <= _b; mid++)           res.f[from][to] = max(res.f[from][to], a.f[from][mid] + b.f[mid][to]);       }     }     return res;   }   void RR() {     for (int i = (1), _b = (n); i <= _b; i++) c[i] = a[i];     sort(c + 1, c + n + 1);     int sc = unique(c + 1, c + n + 1) - c - 1;     for (int i = (1), _b = (n); i <= _b; i++)       a[i] = lower_bound(c + 1, c + n + 1, a[i]) - c;   }   int main() {     ios ::sync_with_stdio(false);     int T;     while (cin >> n >> T) {       for (int i = (1), _b = (n); i <= _b; i++) cin >> a[i];       RR();       f[0].cal1();       for (int i = (1), _b = (23); i <= _b; i++) f[i] = f[i - 1] + f[i - 1];       bool first = true;       for (int bit = 0, _a = (24); bit < _a; bit++)         if ((T >> bit) & 1) {           if (first) {             first = false;             trans = f[bit];           } else             trans = trans + f[bit];         }       int res = 0;       for (int from = (1), _b = (100); from <= _b; from++)         for (int to = (from), _b = (100); to <= _b; to++) {           res = max(res, trans.f[from][to]);           if (res == 8) {             cout << from <<     << to << endl;             assert(0);           }         }       cout << res << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300 + 10;   const int maxm = maxn * maxn;   const int INF = 0x3f3f3f3f;   int connect[maxn][maxn], edgecnt[maxn];   int price[maxn], vis[maxn * 2], match[maxn * 2];   int n;   bool extend(int u) {     vis[u] = true;     for (int i = 1; i <= edgecnt[u]; i++) {       int v = connect[u][i] + n;       if (vis[v] || v == match[u]) continue;       vis[v] = true;       if (match[v] == 0 || extend(match[v])) {         match[u] = v;         match[v] = u;         return true;       }     }     return false;   }   void Match() {     memset(match, 0, sizeof(match));     for (int i = 1; i <= n; i++) {       if (match[i]) continue;       memset(vis, 0, sizeof(vis));       extend(i);     }     for (int i = 1; i <= 2 * n; i++) {     }   }   int S, T;   struct Edge {     Edge *n, *o;     int v, c, w;     void init(int _v, int _c, int _w) {       v = _v;       c = _c;       w = _w;     }   };   Edge *E[maxn * 2], Er[maxn * maxn * 2];   int Es = 0;   void addedge(int u, int v, int c, int w) {     static Edge *P1, *P2;     P1 = &Er[++Es];     P2 = &Er[++Es];     P1->init(v, c, w);     P1->n = E[u];     P1->o = P2;     E[u] = P1;     P2->init(u, 0, -w);     P2->n = E[v];     P2->o = P1;     E[v] = P2;   }   int H[maxn * 2];   bool V[maxn * 2];   bool BFS() {     static int Q[maxn * 20], bot, u, v;     memset(H, INF, sizeof(H));     memset(V, true, sizeof(V));     H[Q[bot = 1] = S] = 0;     V[S] = false;     for (int top = 1; top <= bot; top++) {       u = Q[top];       for (Edge *P = E[u]; P; P = P->n)         if (P->c && H[P->v] > H[u] + 1) {           H[P->v] = H[u] + 1;           if (V[P->v]) {             Q[++bot] = P->v;             V[P->v] = false;           }         }       V[u] = true;     }     return H[T] < INF;   }   int extend(int u, int lefts) {     if (u == T) {       return lefts;     }     V[u] = false;     int ret = 0, t;     for (Edge *P = E[u]; P && ret < lefts; P = P->n) {       if (P->c && V[P->v] && H[u] + 1 == H[P->v]) {         t = extend(P->v, min(lefts - ret, P->c));         ret += t;         P->c -= t;         P->o->c += t;       }     }     V[u] = true;     if (ret < lefts) H[u] = INF;     return ret;   }   int maxflow() {     int ret = 0, cnt = 0;     while (BFS()) {       ret += extend(S, INF);     }     return ret;   }   void build() {     memset(E, 0, sizeof(E));     for (int i = 1; i <= n; i++) {       if (price[i] >= 0) {         addedge(S, i, price[i], 1);       } else {         addedge(i, T, -price[i], 1);       }       for (int j = 1; j <= edgecnt[i]; j++) {         int t = match[connect[i][j] + n];         addedge(i, t, INF, 1);       }     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &edgecnt[i]);       for (int j = 1; j <= edgecnt[i]; j++) {         scanf( %d , &connect[i][j]);       }     }     S = 0;     T = 2 * n + 1;     int ans = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , price + i);       price[i] *= -1;       if (price[i] >= 0) ans += price[i];     }     Match();     build();     ans = maxflow() - ans;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int v[200010];   int c[200010];   int ans[200010];   string s;   priority_queue<pair<int, pair<int, int> > > pi, pe;   int main() {     memset(c, 0, sizeof c);     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> v[i];       pi.push({0, {-v[i], i}});     }     string s;     cin >> s;     for (int i = 0; i < (int)s.size(); ++i) {       if (s[i] ==  0 ) {         int no = pi.top().first;         int wd = pi.top().second.first;         int id = pi.top().second.second;         pi.pop();         ans[i] = id;         pe.push({100, {-wd, id}});       } else {         int no = pe.top().first;         int wd = pe.top().second.first;         int id = pe.top().second.second;         pe.pop();         ans[i] = id;       }     }     for (int i = 0; i < (int)s.size(); ++i) cout << ans[i] + 1 <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[101];   int main() {     int n, i, l;     long long int ans = 0;     scanf( %s , a);     l = strlen(a);     for (i = 0; i < l; i++) {       if (a[i] ==  4 )         a[i] =  1 ;       else         a[i] =  2 ;     }     long long int c = 1;     for (i = l - 1; i >= 0; i--) {       ans = ans + c * (a[i] -  0 );       c = c * 2;     }     printf( %lld n , ans);     return 0;   }