malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 5, Mod = 1e9 + 7;   struct Edge {     int nxt, to;   } e[maxn << 1];   int hd[maxn], e_cnt = 1;   void add(int u, int v) {     e[++e_cnt] = (Edge){hd[u], v};     hd[u] = e_cnt;   }   int n, pre[maxn << 2], nxt[maxn << 2], p[maxn], dep[maxn], fac[maxn];   bool vis[maxn << 2];   void dfs(int u) {     for (int i = hd[u]; i; i = e[i].nxt)       if (i != p[u]) p[e[i].to] = i ^ 1, dep[e[i].to] = dep[u] + 1, dfs(e[i].to);   }   vector<int> getRoute(int u, int v) {     vector<int> v1, v2;     while (dep[u] != dep[v]) {       if (dep[u] > dep[v])         v1.push_back(p[u]), u = e[p[u]].to;       else         v2.push_back(p[v]), v = e[p[v]].to;     }     while (u != v)       v1.push_back(p[u]), v2.push_back(p[v]), u = e[p[u]].to, v = e[p[v]].to;     int siz = v2.size();     for (int i = siz - 1; i >= 0; i--) v1.push_back(v2[i] ^ 1);     return v1;   }   void link(int a, int b) {     if (nxt[a] || pre[b]) {       cout << 0;       exit(0);     }     nxt[a] = b;     pre[b] = a;   }   void cover(int u) {     vis[u] = true;     if (nxt[u]) cover(nxt[u]);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     fac[0] = 1;     for (int i = 1; i <= 5e5; i++) fac[i] = (long long)fac[i - 1] * i % Mod;     cin >> n;     for (int i = 1; i <= n - 1; i++) {       int a, b;       cin >> a >> b;       add(a, b);       add(b, a);     }     dfs(1);     int sum = 0;     for (int i = 1; i <= n; i++) {       int a;       cin >> a;       if (!a) continue;       if (i == a) {         cout << 0;         return 0;       }       vector<int> vec = getRoute(a, i);       int siz = vec.size();       sum += siz;       if (sum > n * 2 - 2) {         cout << 0;         return 0;       }       link(a, vec[0] + n * 2);       link((vec[siz - 1] ^ 1) + n * 2, i + n);       for (int j = 0; j + 1 < siz; j++)         link((vec[j] ^ 1) + n * 2, vec[j + 1] + n * 2);     }     int ans = 1;     for (int i = 1; i <= n; i++) {       cover(i);       if (vis[i + n]) {         for (int j = hd[i]; j; j = e[j].nxt)           if (!vis[j + n * 2]) {             cout << 0;             return 0;           }       } else {         int cnt = 0;         for (int j = hd[i]; j; j = e[j].nxt)           if (!pre[j + n * 2]) cover(j + n * 2), cnt++;         for (int j = hd[i]; j; j = e[j].nxt)           if (!vis[j + n * 2]) {             cout << 0;             return 0;           }         if (vis[i + n]) cnt--;         ans = (long long)ans * fac[cnt] % Mod;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     char ch = getchar();     int x, f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     x = ch -  0 ;     while (1) {       ch = getchar();       if (ch <  0  || ch >  9 ) break;       x = x * 10 + ch -  0 ;     }     return x * f;   }   const int maxn = 510;   const int inf = 0x7fffffff;   int n, a[maxn], dp[maxn][maxn];   int main() {     n = read();     for (int i = 0; i < n; i++) a[i] = read();     for (int i = 1; i <= n; i++) {       for (int j = 0, k = i - 1; k < n; j++, k++) {         if (i == 1) {           dp[j][k] = 1;           continue;         }         dp[j][k] = dp[j + 1][k] + 1;         for (int p = j + 2; p <= k; p++)           if (a[p] == a[j])             dp[j][k] = min(dp[j][k], dp[j + 1][p - 1] + dp[p + 1][k]);         if (a[j] == a[j + 1]) dp[j][k] = min(dp[j][k], dp[j + 2][k] + 1);       }     }     printf( %d n , dp[0][n - 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     long long f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   using namespace std;   long long fun(long long a[], long long b[], long long n) {     long long ans = 0;     long long pa[n];     for (long long i = 0; i < n; ++i) pa[a[i]] = i;     long long push_back[n];     for (long long i = 0; i < n; ++i) push_back[b[i]] = i;     vector<long long> freq(n);     for (long long i = 0; i < n; ++i) {       if (pa[i] < push_back[i]) {         long long k = n - 1 - push_back[i] + pa[i] + 1;         freq[k]++;       } else {         long long k = pa[i] - push_back[i];         freq[k]++;       }     }     return *max_element((freq).begin(), (freq).end());   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long T = 1;     for (long long tp = 1; tp <= T; ++tp) {       long long n;       cin >> n;       long long a[n];       for (long long i = 0; i < n; ++i) {         cin >> a[i];         a[i]--;       }       long long b[n];       for (long long i = 0; i < n; ++i) {         cin >> b[i];         b[i]--;       }       cout << (fun(a, b, n));       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long i, j, k, l, n, m, a, b, u;     cin >> n;     vector<pair<string, pair<long long, long long>>> v(n);     for (i = 0; i < n; i++) {       cin >> v[i].first >> v[i].second.first >> v[i].second.second;     }     long long ans = 0;     for (i = 1; i <= 366; i++) {       long long m = 0, f = 0;       for (j = 0; j < n; j++) {         if (v[j].second.first <= i && v[j].second.second >= i) {           if (v[j].first ==  M )             m++;           else             f++;         }       }       ans = max(ans, min(m, f));     }     cout << ans * 2;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t;     t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int n = s.size();     int i = 0;     while (i < n and s[i] ==  a ) i++;     int j = i + 1;     while (j < n and s[j] !=  a ) j++;     if (i == n)       s[n - 1] =  z ;     else       for (int k = i; k < j; k++) s[k] = (s[k] -  a  - 1 + 26) % 26 +  a ;     cout << s << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   long long POW(long long a, long long b, long long MMM = MOD) {     long long ret = 1;     for (; b; b >>= 1, a = (a * a) % MMM)       if (b & 1) ret = (ret * a) % MMM;     return ret;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) {     if (a == 0 || b == 0) return a + b;     return a * (b / gcd(a, b));   }   int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1};   int ddx[] = {2, 2, -2, -2, 1, 1, -1, -1}, ddy[] = {1, -1, 1, -1, 2, -2, 2, -2};   int a[10][10], num[10][10], to[100];   double d[100];   double go(int N) {     if (N == 99) return 0;     double &ret = d[N];     if (ret != -1) return ret;     ret = 1;     if (N >= 94) {       int t = 99 - N;       for (int(i) = (1); (i) <= (6); (i) += (1))         if (N + i <= 99) ret += go(N + i) / 6;       ret = ret * 6 / t;       return ret;     }     for (int(i) = (1); (i) <= (6); (i) += (1)) {       int next = N + i;       if (to[next] != -1)         ret += min(go(next), go(to[next])) / 6;       else         ret += go(next) / 6;     }     return ret;   }   int main() {     fill(d, d + 100, -1);     memset((to), -1, sizeof(to));     ;     for (int(i) = (0); (i) <= (9); (i) += (1))       for (int(j) = (0); (j) <= (9); (j) += (1)) scanf( %d , &a[i][j]);     for (int(i) = (0); (i) <= (9); (i) += (1))       for (int(j) = (0); (j) <= (9); (j) += (1)) {         if (i & 1)           num[i][j] = (9 - i) * 10 + j;         else           num[i][j] = (9 - i) * 10 + (9 - j);       }     for (int(i) = (0); (i) <= (9); (i) += (1))       for (int(j) = (0); (j) <= (9); (j) += (1))         if (a[i][j]) {           to[num[i][j]] = num[i - a[i][j]][j];         }     printf( %.9f , go(0));   }
#include <bits/stdc++.h>   using namespace std;   void swap(int &a, int &b) {     a = a ^ b;     b = a ^ b;     a = a ^ b;     return;   }   void get_output(int arr[], int n) {     int flag = 1;     while (flag) {       flag = 0;       for (int i = 0; i < n - 1; i++) {         if (arr[i] > arr[i + 1]) {           swap(arr[i], arr[i + 1]);           cout << i + 1 <<     << i + 2 << endl;           flag = 1;         }       }     }     return;   }   int main() {     int n;     cin >> n;     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     get_output(arr, n);     return 0;   }
#include <bits/stdc++.h>   const int N_MAX = 600007;   std::map<std::pair<int, int>, int> ext;   long long ans[N_MAX], now;   int fa[N_MAX], siz[N_MAX][2], top;   std::pair<int, int> stk[N_MAX];   int find(int x) {     while (fa[x] != x) x = fa[x];     return x;   }   void merge(std::pair<int, int> v) {     int x = find(v.first), y = find(v.second);     if (x != y) {       if (siz[x][0] + siz[x][1] < siz[y][0] + siz[y][1]) std::swap(x, y);       now -= 1ll * siz[x][0] * siz[x][1] + 1ll * siz[y][0] * siz[y][1];       siz[x][0] += siz[y][0], siz[x][1] += siz[y][1];       now += 1ll * siz[x][0] * siz[x][1];       fa[y] = x, stk[++top] = std::make_pair(x, y);     }   }   void undoMerge() {     int x = stk[top].first, y = stk[top].second;     now -= 1ll * siz[x][0] * siz[x][1];     siz[x][0] -= siz[y][0], siz[x][1] -= siz[y][1];     now += 1ll * siz[x][0] * siz[x][1] + 1ll * siz[y][0] * siz[y][1];     fa[y] = y, --top;   }   static const int T_MAX = 1200007;   std::vector<std::pair<int, int> > op[T_MAX];   void modify(int k, int l, int r, int x, int y, std::pair<int, int> v) {     if (x <= l && r <= y) {       op[k].push_back(v);       return;     }     if (x <= ((l + r) >> 1)) modify((k << 1), l, ((l + r) >> 1), x, y, v);     if (((l + r) >> 1) < y) modify((k << 1 | 1), ((l + r) >> 1) + 1, r, x, y, v);   }   void dfs(int k, int l, int r) {     int temp = top;     for (auto v : op[k]) merge(v);     if (l == r)       ans[l] = now;     else       dfs((k << 1), l, ((l + r) >> 1)), dfs((k << 1 | 1), ((l + r) >> 1) + 1, r);     while (top > temp) undoMerge();   }   int main() {     const int n = 3e5;     int Q;     scanf( %d , &Q);     for (int i = 1; i <= Q; ++i) {       std::pair<int, int> temp;       scanf( %d%d , &temp.first, &temp.second), temp.second += n;       if (ext.find(temp) == ext.end())         ext[temp] = i;       else         modify(1, 1, Q, ext[temp], i - 1, temp), ext.erase(temp);     }     for (auto i : ext) modify(1, 1, Q, i.second, Q, i.first);     for (int i = 1; i <= n; ++i) fa[i] = i, siz[i][0] = 1;     for (int i = n + 1; i <= n + n; ++i) fa[i] = i, siz[i][1] = 1;     dfs(1, 1, Q);     for (int i = 1; i <= Q; ++i) printf( %lld  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int prv[100010], nxt[100010];   int main() {     int n, k;     string s;     cin >> n >> k;     cin >> s;     int closest = -1;     for (int i = 0; i < s.length(); ++i) {       if (s[i] ==  0 ) {         closest = i;       }       prv[i] = closest;     }     closest = n;     for (int i = s.length() - 1; i >= 0; --i) {       if (s[i] ==  0 ) {         closest = i;       }       nxt[i] = closest;     }     int p1 = 0, p2 = 0;     int sum = 0;     int ans = n;     for (p1 = 0; p1 < s.length(); ++p1) {       while (sum < k + 1 && p2 < s.length()) {         sum += (s[p2] ==  0  ? 1 : 0);         ++p2;       }       if (sum == k + 1) {         int pos = p1 + (p2 - p1) / 2;         if (nxt[pos] != n) {           ans = min(ans, max(nxt[pos] - p1, p2 - 1 - nxt[pos]));         }         if (prv[pos] != -1) {           ans = min(ans, max(prv[pos] - p1, p2 - 1 - prv[pos]));         }       }       sum -= (s[p1] ==  0  ? 1 : 0);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100100;   long long arr[N];   int main() {     long long n, k;     cin >> n >> k;     for (int i = 0; i < n; ++i) cin >> arr[i];     sort(arr, arr + n);     --k;     int x = 0, y = 0;     for (int i = 0; i < n; ++i) {       if (arr[i] < arr[k / n]) x++;       if (arr[i] == arr[k / n]) y++;     }     cout << arr[k / n] <<     << arr[(k - n * x) / y] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     char c, res[2] = { W ,  B };     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> c;         if (c ==  - )           cout << c;         else           cout << res[((i % 2) + (j % 2)) % 2];       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5, base = 2333, mod = 20030731;   int n, m, a[N], b[N], pw[N], h1[N], h2[N], ans[N];   void init() {     pw[0] = 1;     for (int i = (1); i <= (n - 1); i++)       pw[i] = (long long)base * pw[i - 1] % mod,       h1[i] = (((long long)h1[i - 1] * base + b[i]) % mod + mod) % mod;     for (int i = n - 1; i; i--)       h2[i] = (((long long)h2[i + 1] * base + b[i]) % mod + mod) % mod;   }   int get1(int x, int y) {     return (h1[y] + mod - (long long)h1[x - 1] * pw[y - x + 1] % mod) % mod;   }   int get2(int x, int y) {     return (h2[x] + mod - (long long)h2[y + 1] * pw[y - x + 1] % mod) % mod;   }   bool chk(int x, int y) { return get1(x, y) == get2(x, y); }   int main() {     scanf( %d%d , &n, &m);     for (int i = (1); i <= (n); i++) scanf( %d , &a[i]);     for (int i = (1); i <= (n - 1); i++) b[i] = a[i + 1] - a[i];     init();     for (int i = (1); i <= (n); i++) {       bool flag = 1;       if (i > 1) flag &= chk(1, i - 1);       if (i < n) {         flag &= a[1] + a[i] + m == a[i + 1] + a[n];         if (i < n - 1) flag &= chk(i + 1, n - 1);       }       if (flag) ans[++*ans] = (a[1] + a[i]) % m;     }     sort(ans + 1, ans + 1 + *ans);     printf( %d n , *ans);     for (int i = (1); i <= (*ans); i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   using namespace std;   long long max3(long long x, long long y, long long z) {     return max(max(x, y), z);   }   long long min3(long long x, long long y, long long z) {     return min(min(x, y), z);   }   const long long N = 1e5 + 10, M = 2e5 + 10, M2 = 1e6 + 10, mod = 1e9 + 7,                   inf = 1e17 + 10;   const long long INF = 1e9 + 7;   void add(long long& a, long long b) {     a += b;     if (a >= mod) {       a -= mod;     }   }   long long X[] = {0, 1, 0, -1};   long long Y[] = {-1, 0, 1, 0};   long long power(long long x, long long n) {     long long result = 1;     while (n > 0) {       if (n % 2 == 1) result = (result * x) % mod;       x = ((x % mod) * (x % mod)) % mod;       n = n / 2;     }     return result;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       vector<string> s(n);       long long f[26] = {0};       for (long long i = 0; i < n; i++) {         cin >> s[i];         for (long long j = 0; j < s[i].size(); j++) {           f[s[i][j] -  a ]++;         }       }       bool flag = true;       for (long long i = 0; i < 26; i++) {         if (f[i] % n != 0) flag = false;       }       if (flag)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long front[1000001], back[1000001], vt[1000001];   int main() {     long long k, sz, ko = 0, j = 0, kq = 0;     string s;     cin >> k >> s;     sz = s.size();     s =     + s;     for (long long i = 1; i <= sz + 1; i++) {       front[i] = ko;       if (s[i] ==  0 )         ko++;       else         ko = 0;     }     ko = 0;     for (long long i = sz; i >= 1; i--) {       back[i] = ko;       if (s[i] ==  0 )         ko++;       else         ko = 0;     }     for (long long i = 1; i <= sz; i++)       if (s[i] ==  1 ) j++, vt[j] = i;     if (k == 0) {       vt[j + 1] = sz + 1;       front[sz + 1] = ((s[sz] ==  1 ) ? 0 : front[sz] + 1);       j++;       for (long long i = 1; i <= j; i++)         kq += front[vt[i]] * (front[vt[i]] + 1) / 2;       cout << kq;       return 0;     }     for (long long i = 1; i <= j - k + 1; i++)       kq += (front[vt[i]] + 1) * (back[vt[i + k - 1]] + 1);     cout << kq;   }
#include <bits/stdc++.h>   using namespace std;   vector<double> p;   double g;   int n;   int main() {     cin >> n;     p.resize(n + 1);     for (int i = 0; i <= n; i++) cin >> p[i];     g = p[n / 2];     for (int i = 0; i <= (n - 1) / 2; i++)       for (int j = n - (n - 1) / 2; j <= n; j++)         g = max(g, (p[i] * (2 * j - n) + p[j] * (n - 2 * i)) / (j - i) / 2);     cout << g;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (!a) return b;     return gcd(b % a, a);   }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   const long long MAX = 1e6 + 2047;   const long long mod = 1e9 + 7;   const long long MAX_2 = 1009;   void sout() { cout <<   n ; }   template <typename T, typename... Types>   void sout(T var1, Types... var2) {     cout << var1 <<    ;     sout(var2...);   }   template <typename T>   void sout(vector<T> arr) {     for (auto it : arr) {       cout << it <<    ;     }     sout();   }   template <typename T>   void sout(set<T> st) {     for (auto it : st) {       cout << it <<    ;     }     sout();   }   void test_case() {     long long n;     cin >> n;     queue<long long> q;     q.push(4);     q.push(7);     set<long long> st;     st.insert(4);     st.insert(7);     while (!q.empty()) {       long long curr = q.front();       q.pop();       st.insert(curr);       if (curr > n) {         continue;       }       q.push(curr * 10 + 4);       q.push(curr * 10 + 7);     }     vector<long long> arr(st.begin(), st.end());     long long ans = lower_bound(arr.begin(), arr.end(), n) - arr.begin() + 1;     cout << ans <<   n ;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << fixed << setprecision(10);     long long t = 1;     while (t--) {       test_case();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     if (n == 1) {       cout << 0 << endl;       return 0;     }     int a[n + 2], cnt = n - 1;     for (int i = 2; i <= n; i++) {       a[i] = i;     }     for (int i = 2; i < n; i++) {       for (int j = i + 1; j <= n; j++) {         if (a[j] == 0) continue;         if (i * j <= n && j % i != 0) {           a[i * j] = 0;           cnt--;         }       }     }     cnt = 0;     for (int i = 2; i <= n; i++) {       if (a[i] != 0) {         cnt++;       }     }     cout << cnt << endl;     for (int i = 2; i <= n; i++) {       if (a[i] != 0) {         cout << a[i] <<    ;       }     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[100100];   char s1[100100];   int res[5];   vector<int> zeros, ones;   int n;   int was[100100];   int model() {     memset(was, 0, sizeof(was));     for (int i = (0); i < (n); ++i)       if (s[i] ==  0 )         zeros.push_back(i);       else         ones.push_back(i);     int p1 = 0;     int p2 = 0;     for (int i = (0); i < (n - 2); ++i) {       if (i & 1)         was[zeros[p2++]] = 1;       else         was[ones[p1++]] = 1;     }     int c = 0, p = 2;     for (int i = (0); i < (n); ++i)       if (was[i] == 0) {         c += (s[i] -  0 ) * p;         p /= 2;       }     return c;   }   int main() {     scanf( %s , &s);     n = strlen(s);     int a = 0, b = 0, c = 0;     for (int i = (0); i < (n); ++i) s1[i] = s[i];     for (int i = (0); i < (n); ++i)       if (s[i] ==  0 )         a++;       else if (s[i] ==  1 )         b++;       else         c++;     if (a + c > b) res[0] = 1;     if (b + c > a + 1) res[3] = 1;     if ((a + c + 1 >= b) && (b + c >= a)) {       int v = n / 2;       if (n & 1) v++;       for (int i = (0); i < (n); ++i)         if (s[i] ==  1 ) v--;       int cnt = 0;       for (int i = (0); i < (n); ++i)         if (s[i] ==  ? ) {           if (cnt < v) {             s[i] =  1 ;             cnt++;           } else             s[i] =  0 ;         }       int q = model();       res[q] = 1;       cnt = 0;       for (int i = (0); i < (n); ++i) s[i] = s1[i];       for (int i = n - 1; i >= 0; --i)         if (s[i] ==  ? ) {           if (cnt < v) {             s[i] =  1 ;             cnt++;           } else             s[i] =  0 ;         }       zeros.clear();       ones.clear();       q = model();       res[q] = 1;     }     for (int i = (0); i < (4); ++i)       if (res[i]) {         int v1 = (i & 1);         int v2 = i / 2;         cout << v2 << v1 << endl;       }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, min = 0, k;     scanf( %d , &n);     for (int i = 1; i < 200; i++) {       k = (pow(2, i) - 1) * pow(2, i - 1);       if (k > n) {         printf( %d , min);         break;       } else if ((n % k) == 0) {         min = k;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     string h, v;     cin >> h >> v;     bool flag = true;     if (h[0] ==  >  && v[0] ==  v ) flag = false;     if (h[0] ==  <  && v[m - 1] ==  v ) flag = false;     if (h[n - 1] ==  >  && v[0] ==  ^ ) flag = false;     if (h[n - 1] ==  <  && v[m - 1] ==  ^ ) flag = false;     if (flag)       puts( YES );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, bool> g;   struct node {     int x, y, z, num;   } ans[3000];   int a[60], sum[60], vis[60], flag, n, final, k;   int main() {     int i, t = 0, s, j, num = 0, tt;     flag = 0;     final = 0;     scanf( %d%d , &n, &k);     g.clear();     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     ans[++t].z = 0;     ans[t].x = 0;     ans[t].y = 0;     ans[t].num = 0;     for (i = 1; i <= n; i++) {       tt = t;       for (j = 1; j <= tt; j++) {         if (g[ans[j].z + a[i]] == false) {           g[ans[j].z + a[i]] = true;           ans[++t].z = ans[j].z + a[i];           ans[t].y = a[i];           ans[t].x = j;           ans[t].num = ans[j].num + 1;           num++;           printf( %d , ans[t].num);           s = t;           while (1) {             printf(  %d , ans[s].y);             s = ans[s].x;             if (s == 1) break;           }           printf(  n );           if (num == k) break;         }       }       if (num == k) break;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int P = 1e9 + 7, INF = 0x3f3f3f3f;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long qpow(long long a, long long n) {     long long r = 1 % P;     for (a %= P; n; a = a * a % P, n >>= 1)       if (n & 1) r = r * a % P;     return r;   }   long long inv(long long first) {     return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;   }   inline int rd() {     int first = 0;     char p = getchar();     while (p <  0  || p >  9 ) p = getchar();     while (p >=  0  && p <=  9 ) first = first * 10 + p -  0 , p = getchar();     return first;   }   int main() {     int n;     scanf( %d , &n);     while (n--) {       int a, b;       scanf( %d%d , &a, &b);       long long first = (long long)a * b, t = cbrt(first) + 0.5;       puts(t * t * t == first && a % t == 0 && b % t == 0 ?  Yes  :  No );     }   }