malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline char gc() {     static char buf[1 << 16], *S, *T;     if (S == T) {       T = (S = buf) + fread(buf, 1, 1 << 16, stdin);       if (T == S) return EOF;     }     return *S++;   }   inline int read() {     int x = 0, f = 1;     char ch = gc();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = gc();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = gc();     return x * f;   }   int n, w, mxb, mxa, bel[100010], nn, cnt[350], q[350][350], qh[350], qt[350];   long long d[100010];   struct data {     int a, b;     friend bool operator<(data a, data b) { return a.b < b.b; }   } A[100010];   inline double slope(int i, int j) { return (d[i] - d[j]) * 1.0 / (j - i); }   inline void gao(int i, int x) {     while (qh[i] < qt[i] && slope(q[i][qh[i]], q[i][qh[i] + 1]) <= x) ++qh[i];   }   inline void rebuild(int id, int l, int r) {     qh[id] = 1;     qt[id] = 0;     for (int i = l; i <= r; ++i) {       while (qh[id] < qt[id] &&              slope(q[id][qt[id]], i) < slope(q[id][qt[id] - 1], q[id][qt[id]]))         --qt[id];       q[id][++qt[id]] = i;     }     gao(id, 0);   }   inline void add(int x) {     if (!x) return;     for (int i = 1; i < bel[x]; ++i) gao(i, ++cnt[i]);     int l = (bel[x] - 1) * nn + 1, r = min(bel[x] * nn, mxa), id = bel[x];     for (int i = l; i <= r; ++i) d[i] += (long long)cnt[id] * i;     for (int i = l; i <= x; ++i) d[i] += i;     cnt[id] = 0;     rebuild(id, l, r);   }   int main() {     n = read();     w = read();     for (int i = 1; i <= n; ++i)       A[i].a = read(), A[i].b = read(), mxb = max(mxb, A[i].b),       mxa = max(mxa, A[i].a);     sort(A + 1, A + n + 1);     int now = 1;     nn = sqrt(mxa);     for (int i = 1; i <= mxa; ++i) bel[i] = (i - 1) / nn + 1;     int tot = bel[mxa];     for (int i = 1; i <= tot; ++i) qh[i] = 1, q[i][++qt[i]] = min(i * nn, mxa);     int flag = 0;     for (int c = 0; c <= mxb + 1; ++c) {       while (now <= n && A[now].b < c) add(A[now].a), ++now;       long long ans = 0;       int ans1 = 0;       for (int i = 1; i <= tot; ++i) {         int x = q[i][qh[i]];         if (d[x] + (long long)x * cnt[i] > ans)           ans = d[x] + (long long)x * cnt[i], ans1 = x;       }       printf( %I64d %d n , ans + (long long)w * c * (n - now + 1), ans1);       if (c == 1) flag = ans + (long long)w * c * (n - now + 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[2000][2000], k, p[2000], Index;   void add(int x, int y) { a[x][y] = a[y][x] = 1; }   int main() {     scanf( %d , &k);     int maxbit = 0;     for (int i = (1); i <= (30); ++i)       if ((1 << i) & k) maxbit = i;     Index = 2;     int cur = ++Index;     add(1, cur);     for (int i = (1); i <= (maxbit); ++i) {       add(cur, Index + 1);       add(cur, Index + 2);       add(Index + 1, Index + 3);       add(Index + 2, Index + 3);       cur = Index += 3;       p[maxbit - i] = cur;     }     add(cur, 2);     add(1, ++Index);     cur = Index;     for (int i = (maxbit - 1); i >= (0); --i) {       add(cur, ++Index), cur = Index;       if ((1 << i) & k) add(cur, p[i]);       add(cur, ++Index), cur = Index;     }     printf( %d n , Index);     for (int i = (1); i <= (Index); ++i) {       for (int j = (1); j <= (Index); ++j)         if (a[i][j])           printf( Y );         else           printf( N );       puts(  );     }     assert(Index <= 150);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   const int MAXN = 200100;   int win = 0, ti = 0;   int vis[MAXN][2] = {0};   int vs[MAXN] = {0};   int path[MAXN], cnt;   vector<int> g[MAXN];   bool dfsloop(int u) {     vs[u] = 1;     bool f = false;     for (int i = 0; i < g[u].size(); i++) {       int v = g[u][i];       if (vs[v] == 1)         f = true;       else if (vs[v] == 0)         f = dfsloop(v);       if (f) return true;     }     vs[u] = 2;     return false;   }   void dfs(int u, int ly) {     vis[u][ly % 2] = 1;     int sz = g[u].size();     cnt = ly;     path[ly] = u;     if (!sz) {       if (ly % 2 == 0) {         win = 1;         return;       } else         ;     }     for (int i = 0; i < sz; i++) {       int v = g[u][i];       if (vis[v][(ly + 1) % 2] == 0) {         dfs(v, ly + 1);         if (win) return;       }     }   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       int ci;       scanf( %d , &ci);       while (ci--) {         int v;         scanf( %d , &v);         g[i].push_back(v);       }     }     int s;     scanf( %d , &s);     dfs(s, 1);     if (win) {       printf( Win n );       for (int i = 1; i <= cnt; i++) printf( %d  , path[i]);     } else {       bool res = dfsloop(s);       if (res)         printf( Draw );       else         printf( Lose );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<int> s;   int t, n, a[200020], cnt, d[200020], e[200020];   int main() {     for (scanf( %d , &t); t--; s.clear(), cnt = 0) {       scanf( %d , &n);       for (int i = 0; i < n; i++) d[i] = e[i] = 0;       for (int i = 0; i < n; i++) scanf( %d , a + i);       for (int i = 0; i < n; i++) {         if (s.count(a[i])) break;         s.insert(a[i]);         while (s.count(cnt + 1)) cnt++;         if (s.size() == cnt) d[i] = 1;       }       s.clear(), cnt = 0;       for (int i = n - 1; i >= 0; i--) {         if (s.count(a[i])) break;         s.insert(a[i]);         while (s.count(cnt + 1)) cnt++;         if (s.size() == cnt) e[i] = 1;       }       vector<int> v;       for (int i = 0; i < n - 1; i++) {         if (d[i] && e[i + 1]) v.push_back(i + 1);       }       printf( %d n , v.size());       for (int x : v) printf( %d %d n , x, n - x);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 2e5 + 10;   const double eps = 1e-6;   const double mod = 1e9 + 7;   struct num {     int v, i;   } b[MAX];   bool cmp(const num &x, const num &y) { return x.v > y.v; }   bool cmp1(const num &x, const num &y) { return x.i < y.i; }   int main() {     int m, a[MAX];     cin >> m;     for (int i = 1; i <= m; i++) cin >> a[i];     for (int i = 1; i <= m; i++) cin >> b[i].v, b[i].i = i;     sort(a + 1, a + m + 1);     sort(b + 1, b + m + 1, cmp);     for (int i = 1; i <= m; i++) b[i].v = a[i];     sort(b + 1, b + m + 1, cmp1);     for (int i = 1; i <= m; i++) cout << b[i].v <<    ;     putchar(  n );   }
#include <bits/stdc++.h>   int main() {     unsigned long long n;     unsigned long long answer;     scanf( %I64u , &n);     if (n < 3) {       printf( %lu , n);       return 0;     }     if (n % 2 == 1) {       answer = (n) * (n - 1) * (n - 2);     } else if (n % 3 != 0) {       answer = n * (n - 1) * (n - 3);     } else {       answer = (n - 1) * (n - 2) * (n - 3);     }     printf( %I64u n , answer);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Int() {     int x;     scanf( %d , &x);     return x;   }   long long Long() {     long long x;     scanf( %lld , &x);     return x;   }   void err(istream_iterator<string> it) { cout << endl; }   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a <<    ;     err(++it, args...);   }   const int N = (int)2e5 + 5;   const int maxN = (int)1e6 + 6;   const long long Mod = (long long)1e9 + 7;   const int inf = (int)2e9;   const long long Inf = (long long)1e18;   long long dp[20][5][5][11][11];   int n, k;   long long call(int pos, int prior, int last, int hump, int uhump) {     if (pos == n) {       return hump == k and uhump == k - 1;     }     long long &ret = dp[pos][prior][last][hump][uhump];     if (~ret) return ret;     ret = 0;     for (int i = 1; i <= 4; ++i) {       if (i == last) continue;       int f = hump;       int first = uhump;       if (prior and last) {         f += (prior < last and last > i);         first += (prior > last and last < i);       }       ret += call(pos + 1, last, i, f, first);     }     return ret;   }   int main() {     int test = 1, tc = 0;     while (test--) {       n = Int(), k = Int();       memset(dp, -1, sizeof dp);       long long res = 0;       for (int i = 1; i <= 4; ++i) {         res += call(1, 0, i, 0, 0);       }       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, k;   int a[200005];   int main() {     int t;     scanf( %d , &t);     while (t--) {       scanf( %d%d , &n, &k);       int pos = 0, mn = 1000000000;       for (int i = 1; i <= n; i++) {         scanf( %d , &a[i]);         if (i > k && a[i] - a[i - k] < mn) {           mn = a[i] - a[i - k];           pos = i;         }       }       printf( %d n , (a[pos] + a[pos - k]) / 2);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x;     cin >> x;     for (int a = 1; a <= x; ++a)       for (int b = 1; b <= x; ++b)         if (a % b == 0 && a * b > x && a / b < x) {           cout << a <<     << b << endl;           return 0;         }     puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, l, r, sz, i, len, q, p, mid, anspos, ans[1000001];   long long mxl, mxr;   long long pos[1000001], t[1000001], pr[100001];   struct Pair {     long long pos;     long long x;     long long d;   };   Pair a[100001], b[100001];   bool cmp(Pair p1, Pair p2) { return p1.x < p2.x; }   bool cmd(Pair p1, Pair p2) { return p1.pos < p2.pos; }   long long binl(long long L, long long R, long long height) {     long long otv = -1;     while (L <= R) {       mid = L + R;       mid /= 2;       if (b[mid].x > height)         R = mid - 1;       else         otv = mid, L = mid + 1;     }     return otv;   }   long long binr(long long L, long long R, long long height) {     long long otv = -1;     while (L <= R) {       mid = L + R;       mid /= 2;       if (b[mid].x < height)         L = mid + 1;       else         otv = mid, R = mid - 1;     }     return otv;   }   long long tree(long long L, long long R) {     long long nn = 0;     while (L <= R) {       if (L % 2 == 1) nn = max(nn, t[L]);       if (R % 2 == 0) nn = max(nn, t[R]);       L = (L + 1) / 2;       R = (R - 1) / 2;     }     return nn;   }   void update(long long x) {     x /= 2;     while (x) {       t[x] = max(t[x * 2], t[x * 2 + 1]);       x /= 2;     }   }   int main() {     cin >> n >> k;     sz = 1;     while (sz < n) sz *= 2;     for (i = 1; i <= n; i++) {       cin >> a[i].x;       a[i].pos = i;       b[i] = a[i];     }     sort(b + 1, b + n + 1, cmp);     for (int i = 1; i <= n; i++) pos[b[i].pos] = i, pr[i] = b[i].pos;     for (int i = 1; i <= n; i++) {       int l = binl(1, pos[i] - 1, a[i].x - k);       int r = binr(pos[i] + 1, n, a[i].x + k);       int mxl = 0, mxr = 0;       if (l > 0) mxl = tree(sz, l + sz - 1);       if (r > 0) mxr = tree(r + sz - 1, n + sz - 1);       t[pos[i] + sz - 1] = max(mxl, mxr) + 1;       update(pos[i] + sz - 1);       a[pr[pos[i]]].d = t[pos[i] + sz - 1];     }     sort(b + 1, b + n + 1, cmd);     cout << t[1] << endl;     for (int i = 1; i <= n; i++) {       if (a[i].d == t[1]) {         p = i;         break;       }     }     ans[++q] = p;     for (int j = p; j >= 1; j--) {       if (a[j].d == a[p].d - 1 && abs(a[j].x - a[p].x) >= k) {         ans[++q] = j;         p = j;       }     }     for (int i = q; i >= 1; i--) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int helper(long long int edges, long long int nodes) {     if (edges == nodes - 1) return nodes - 1;     edges -= nodes - 1;     return nodes - 1 - ceil((1.0 + sqrt(1.0 + 8.0 * edges)) / 2.0);   }   int main() {     ios::sync_with_stdio(false);     ;     cin.tie(0);     ;     long long int i, j, q, n, lo, mid, hi;     cin >> q;     while (q--) {       cin >> n;       lo = n - 1;       hi = (n * (n - 1)) / 2 + 1;       while (hi - lo > 1) {         mid = (lo + hi) / 2;         if (helper(mid, n) >= (mid + 1) / 2)           lo = mid;         else           hi = mid;       }       cout << lo <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,                  less<pair<long long, long long>>>       q;   priority_queue<long long, vector<long long>, greater<long long>> p;   long long n, k, t, b, temp, res;   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> t >> b;       q.push({b, t});     }     for (int i = 0; i < n; i++) {       pair<long long, long long> tt = q.top();       if (p.size() < k) {         p.push(tt.second);         temp += tt.second;       } else {         if (tt.second > p.top()) {           temp += (tt.second - p.top());           p.pop();           p.push(tt.second);         }       }       q.pop();       res = max(res, tt.first * temp);     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     int ans = 1e9;     for (int i = 0; i < n - 1; i++)       if (s[i] ==  R  && s[i + 1] ==  L ) ans = min(ans, (a[i + 1] - a[i]) / 2);     if (ans == 1e9)       cout << -1 << endl;     else       cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long linf = 1001002003004005006ll;   const int inf = 1001001001;   const int mod = 1000000007;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       string s;       cin >> s;       string ans1, ans2;       bool elf = false;       for (int i = 0; i < (n); ++i) {         if (elf) {           if (s[i] ==  2 ) ans1 +=  0 , ans2 +=  2 ;           if (s[i] ==  0 ) ans1 +=  0 , ans2 +=  0 ;           if (s[i] ==  1 ) ans1 +=  0 , ans2 +=  1 ;         } else {           if (s[i] ==  2 ) ans1 +=  1 , ans2 +=  1 ;           if (s[i] ==  0 ) ans1 +=  0 , ans2 +=  0 ;           if (s[i] ==  1 ) {             ans1 +=  1 , ans2 +=  0 ;             elf = true;           }         }       }       cout << ans1 << endl << ans2 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long rd() {     register long long x = 0;     register bool f = 0;     register char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) f = 1;       c = getchar();     }     while (isdigit(c)) {       x = x * 10 + (c ^ 48);       c = getchar();     }     return f ? -x : x;   }   int n, a[200010], bit[31];   inline int insert(int x) {     for (register int i = 30; ~i; --i) {       if (x & (1 << i)) {         if (!bit[i]) {           bit[i] = x;           return 1;         }         x ^= bit[i];       }     }     return 0;   }   int main() {     n = rd();     for (register int i = 1; i <= n; ++i) a[i] = rd() ^ a[i - 1];     if (!a[n]) {       puts( -1 );       return 0;     }     int ans = insert(a[n]);     for (register int i = n - 1; i; --i) ans += insert(a[i]);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> Castle[100010];   int Index[100010];   int main() {     int N;     scanf( %d , &N);     int Temp;     for (int i = 1; i <= N; i++) {       scanf( %d , &Temp);       Castle[i] = make_pair(Temp, i);     }     sort(Castle + 1, Castle + N + 1);     int Max = 1;     int Ans = 0;     for (int i = 1; i <= N; i++) Index[Castle[i].second] = i;     for (int i = 1; i <= N; i++) {       Max = max(Max, Index[i]);       if (Max == i) Ans++;     }     printf( %d n , Ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int num = 0;     bool f = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       f = (ch ==  - );       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       num = (num << 1) + (num << 3) + ch -  0 ;       ch = getchar();     }     return f ? -num : num;   }   int main() {     int num[111];     int n = read(), cnt = 0, t = 0, ans = 0;     memset(num, 0, sizeof(num));     while (n) {       num[cnt++] = n % 2;       n >>= 1;     }     swap(num[0], num[4]);     swap(num[2], num[3]);     for (int i = 0; i <= 5; i++)       if (num[i]) ans += pow(2, i);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx )   using namespace std;   const int MX = 1e9 + 1;   const int Imp = -1;   const int N = 1e6 + 5;   const int M = 1e6 + 5;   const long long INF = 1e18 + 1;   int n, k;   string s;   set<char> st;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     string s;     cin >> s;     int k;     cin >> k;     int n = s.size();     if (n < k) {       cout <<  impossible ;     } else {       for (int i = 0; i < n; ++i) st.insert(s[i]);       int x = st.size();       if (x > k)         cout << 0;       else         cout << abs(x - k);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, x;     vector<int> a;     cin >> n >> k;     vector<int> w(k);     for (int i = 0; i < n; i++) {       cin >> x;       a.push_back(x);     }     for (int i = 0; i < k; i++) {       for (int j = i; j < n; j += k) {         w[i] += a[j];       }     }     int menor = w[0];     int z = 0;     for (int i = 0; i < k; i++)       if (menor > w[i]) {         menor = w[i];         z = i;       }     cout << z + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long k;     cin >> k;     long long res[4][4];     for (long long i = 0; i < 4; ++i) {       for (long long j = 0; j < 4; ++j) {         if (i == 1 && j == 2) {           res[i][j] = (1 << 17);         } else if (i == 2 && j == 1) {           res[i][j] = (1 << 17);         } else if ((i + j) == 3) {           res[i][j] = k;         } else if (i == 3 && j == 3) {           res[i][j] = k;         } else {           res[i][j] = (k + (1 << 17));         }       }     }     cout << 4 <<     << 4 << endl;     for (long long i = 0; i < 4; ++i) {       for (long long j = 0; j < 4; ++j) {         cout << res[i][j] <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     long long tmp;     while (b) {       a %= b;       tmp = a;       a = b;       b = tmp;     }     return a;   }   int main() {     int n;     cin >> n;     vector<int> a(n + 1, 0);     for (int i = 0; i < n; i++) {       cin >> a[i + 1];     }     sort(a.begin(), a.end());     long long sum1 = 0, sum2 = 0;     vector<long long> sum(n + 1, 0);     for (int i = 1; i <= n; i++) {       sum[i] += sum[i - 1] + (long long)i * (a[i] - a[i - 1]);       sum1 += sum[i];       sum2 += a[i];     }     long long num = 2 * sum1 - sum2;     long long den = n;     long long g = gcd(num, den);     cout << num / g <<     << den / g << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, root, m;   int a[100100];   int h[100100];   vector<int> g[100100];   int arr[200100];   int N, tin[100100], tout[100100];   vector<pair<int, int> > t[200100 * 4];   void dfs(int v, int par = -1, int len = 0) {     h[v] = len;     tin[v] = ++N;     arr[N] = v;     for (int to : g[v]) {       if (to != par) {         dfs(to, v, len + 1);       }     }     tout[v] = ++N;     arr[N] = v;   }   void build(int v, int l, int r) {     if (l == r) {       int node = arr[l];       t[v].push_back(make_pair(h[node], a[node]));       return;     }     int mid = (l + r) >> 1;     build(v + v, l, mid), build(v + v + 1, mid + 1, r);     merge((t[v + v]).begin(), (t[v + v]).end(), (t[v + v + 1]).begin(),           (t[v + v + 1]).end(), back_inserter(t[v]));     for (int i = 1; i < ((int)(t[v]).size()); ++i) {       t[v][i].second = min(t[v][i - 1].second, t[v][i].second);     }   }   int get(int v, int l, int r, int L, int R, int k) {     if (r < L || R < l) return 2e9;     if (L <= l && r <= R) {       int lf = 0, rg = ((int)(t[v]).size()) - 1, i = -1;       while (lf <= rg) {         int avg = (lf + rg) >> 1;         if (t[v][avg].first <= k)           i = avg, lf = avg + 1;         else           rg = avg - 1;       }       return i == -1 ? 2e9 : t[v][i].second;     }     int mid = (l + r) >> 1;     return min(get(v + v, l, mid, L, R, k), get(v + v + 1, mid + 1, r, L, R, k));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     cin >> n >> root;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = 1; i < n; ++i) {       int x, y;       cin >> x >> y;       g[x].push_back(y);       g[y].push_back(x);     }     dfs(root);     build(1, 1, N);     cin >> m;     int ans = 0;     for (int i = 1; i <= m; ++i) {       int p, q;       cin >> p >> q;       int x = (p + ans) % n + 1;       int k = (q + ans) % n;       ans = get(1, 1, N, tin[x], tout[x], h[x] + k);       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     node *next[26];     node() {       for (int i = 0; i < 26; i++) next[i] = NULL;     }   };   void insert(node *root, string &str) {     node *current = root;     for (char ch : str) {       if (current->next[ch -  a ] == NULL) {         current->next[ch -  a ] = new node();       }       current = current->next[ch -  a ];     }   }   int canLose(node *root) {     int was = 1, leaf = 0;     for (int i = 0; i < 26; i++) {       if (root->next[i]) {         was = min(was, 1 ^ canLose(root->next[i]));         leaf = 1;       }     }     return was & leaf;   }   int canWin(node *root) {     int was = 0;     for (int i = 0; i < 26; i++) {       if (root->next[i]) {         was = max(was, 1 ^ canWin(root->next[i]));       }     }     return was;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     node *root = new node();     int n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       string str;       cin >> str;       insert(root, str);     }     if (canWin(root) && !canLose(root)) {       cout <<  First  << endl;     } else if (canWin(root)) {       if (k & 1) {         cout <<  First  << endl;       } else {         cout <<  Second  << endl;       }     } else {       cout <<  Second  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100500];   vector<long long> pfx[100500], vtx[100500];   long long proc(long long x, long long sum) {     int n = vtx[x].size();     int mid = n / 2;     long long res = sum;     for (int i = mid, _n = n; i < _n; i++) res += vtx[x][i] - vtx[x][mid];     for (int i = 0, _n = mid; i < _n; i++) res += vtx[x][mid] - vtx[x][i];     for (int i = 0, _n = n; i < _n; i++) res -= abs(x - vtx[x][i]);     return res;   }   int main() {     int n, m;     long long sum = 0LL;     scanf( %d %d , &n, &m);     for (int i = 0, _n = m; i < _n; i++) scanf( %I64d , a + i);     for (int i = 1, _n = m; i < _n; i++) {       if (a[i] == a[i - 1]) continue;       vtx[a[i]].push_back(a[i - 1]);       vtx[a[i - 1]].push_back(a[i]);       sum += abs(a[i] - a[i - 1]);     }     for (int i = 1, _n = n + 1; i < _n; i++) sort(vtx[i].begin(), vtx[i].end());     long long ans = sum;     for (int i = 1, _n = n + 1; i < _n; i++) ans = min(ans, proc(i, sum));     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string s;     cin >> s;     long long l = s.length();     long long ans = 0;     for (long long i = l - 1; i >= 1; i--) {       ans = ans + pow(2, i);     }     for (long long i = 0; i < l; i++) {       if (s[i] ==  7 ) {         ans = ans + pow(2, l - i - 1);       }     }     cout << ans + 1 <<   n ;     return 0;   }