malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAX = 200500;   int inp[MAX];   int out[MAX];   bool flag[MAX];   map<long long, int> ID;   map<long long, int> hasInp;   namespace hopcroftKarp {   int ptr[100011], next[200011], zu[200011];   int n, m, match[100011], D[100011], q[100011];   void init(int _n) {     n = _n;     m = 0;     memset(ptr, ~0, sizeof(int) * (n + 1));   }   void add_edge(int u, int v) {     next[m] = ptr[u];     ptr[u] = m;     zu[m] = v;     ++m;   }   bool bfs() {     int u, v;     register int i;     int qh = 0, qt = 0;     for (i = 1; i <= n; i++) {       if (!match[i]) {         D[i] = 0;         q[qt++] = i;       } else         D[i] = (1 << 28);     }     D[0] = (1 << 28);     while (qh < qt) {       u = q[qh++];       if (u != 0) {         for (i = ptr[u]; ~i; i = next[i]) {           v = zu[i];           if (D[match[v]] == (1 << 28)) {             D[match[v]] = D[u] + 1;             q[qt++] = match[v];           }         }       }     }     return D[0] != (1 << 28);   }   bool dfs(int u) {     int v;     register int i;     if (u) {       for (i = ptr[u]; ~i; i = next[i]) {         v = zu[i];         if (D[match[v]] == D[u] + 1) {           if (dfs(match[v])) {             match[v] = u;             match[u] = v;             return true;           }         }       }       D[u] = (1 << 28);       return false;     }     return true;   }   int run() {     int matching = 0;     register int i;     while (bfs())       for (i = 1; i <= n; i++)         if (!match[i] && dfs(i)) matching++;     return matching;   }   void call(int N, long long a, long long b) {     int x, y;     long long vx, vy;     for (int i = 1; i <= N; i++) {       if (flag[i]) continue;       x = i;       y = match[x];       vx = inp[i];       vy = inp[y];       if (vx + vy == a) {         out[x] = out[y] = 0;       } else         out[x] = out[y] = 1;       flag[x] = flag[y] = true;     }     for (int i = 1; i <= N; i++) {       if (i != 1) cout <<    ;       cout << out[i];     }     cout <<   n ;     return;   }   };  // namespace hopcroftKarp   int main() {     long long a, b;     int n;     std::ios_base::sync_with_stdio(false);     cin >> n >> a >> b;     for (int i = 1; i <= n; i++) {       cin >> inp[i];       hasInp[inp[i]] = i;     }     long long x, rx, tx;     int p = 0;     hopcroftKarp::init(n);     for (int i = 1; i <= n; i++) {       x = inp[i];       rx = a - x;       tx = b - x;       if (hasInp.find(rx) != hasInp.end()) {         hopcroftKarp::add_edge(i, hasInp[rx]);       }       if (hasInp.find(tx) != hasInp.end()) {         hopcroftKarp::add_edge(i, hasInp[tx]);       }     }     int cnt = hopcroftKarp::run();     if (2 * cnt >= (n)) {       cout <<  YES n ;       hopcroftKarp::call(n, a, b);     } else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[2][505][505];   char mp[505][505];   const int mod = 1000000007;   int dis(int a, int b, int c, int d) { return abs(a - c) + abs(b - d) <= 1; }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) scanf( %s , mp[i]);     if (mp[0][0] != mp[n - 1][m - 1]) {       printf( 0 n );       return 0;     }     memset(dp, 0, sizeof(dp));     dp[0][0][n - 1] = 1;     int t = n + m;     t /= 2;     int ans = 0;     for (int i = 1; i < t; i++) {       for (int j = 0; j < n; j++) {         for (int k = n - 1; k >= j; k--) dp[i & 1][j][k] = 0;       }       for (int j = 0; j < n; j++) {         for (int k = n - 1; k >= j; k--) {           int m1 = i - j;           int m2 = (n + m - 2 - k - i);           if (m1 > m - 1) continue;           if (m2 > m - 1) continue;           if (mp[j][m1] != mp[k][m2]) continue;           if (j > 0 && k < n - 1) dp[i & 1][j][k] += dp[!(i & 1)][j - 1][k + 1];           if (j > 0 && m2 < m - 1) dp[i & 1][j][k] += dp[!(i & 1)][j - 1][k];           if (dp[i & 1][j][k] >= mod) dp[i & 1][j][k] -= mod;           if (m1 > 0 && k < n - 1) dp[i & 1][j][k] += dp[!(i & 1)][j][k + 1];           if (dp[i & 1][j][k] >= mod) dp[i & 1][j][k] -= mod;           if (m1 > 0 && m2 < m - 1) dp[i & 1][j][k] += dp[!(i & 1)][j][k];           if (dp[i & 1][j][k] >= mod) dp[i & 1][j][k] -= mod;           if (i == t - 1 && dis(j, m1, k, m2)) ans += dp[i & 1][j][k];           if (ans >= mod) ans -= mod;         }       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3333;   int cnt[maxn][maxn][2], fuck[maxn], dep[maxn][maxn], dis[maxn][maxn];   struct Edge {     int t, next, v;   } edge[maxn << 1];   int head[maxn], tot, n;   void new_edge(int a, int b, int t) {     edge[tot].t = b;     edge[tot].next = head[a];     edge[tot].v = t;     head[a] = tot++;   }   void dfs(int u, int fa, int rt) {     int i;     for (i = head[u]; i != -1; i = edge[i].next) {       int e = edge[i].t;       if (e == fa) continue;       dep[rt][e] = dep[rt][u] + 1;       int add = edge[i].v;       cnt[rt][e][1] = min(cnt[rt][u][0], cnt[rt][u][1]) + !add;       cnt[rt][e][0] = cnt[rt][u][0] + add;       dis[rt][e] = dis[rt][u] + add;       fuck[rt] += add;       dfs(e, u, rt);     }   }   int main() {     tot = 0;     int i, j, k;     memset(head, -1, sizeof(head));     scanf( %d , &n);     for (i = 1; i < n; i++) {       int a, b;       scanf( %d%d , &a, &b);       new_edge(a, b, 0);       new_edge(b, a, 1);     }     for (i = 1; i <= n; i++) dfs(i, 0, i);     int ans = 111111111;     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++) {         ans = min(ans, fuck[i] - dis[i][j] + min(cnt[i][j][0], cnt[i][j][1]));         ans = min(ans, fuck[i]);       }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool besarDulu(const int &a, const int &b) { return a > b; }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int h, m;       cin >> h >> m;       int minutes = (24 - h - 1) * 60 + (60 - m);       cout << minutes <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool cur1;   int n, m, K;   int L[100005 * 120], R[100005 * 120], res[100005 * 120], tt, rt[100005 * 3];   int update(int p, int l, int r, int x, int v) {     int c = ++tt;     L[c] = L[p], R[c] = R[p];     if (l == r) {       res[c] = min((p ? res[p] : 0x3f3f3f3f), v);       return c;     }     int mid = (l + r) >> 1;     if (x <= mid)       L[c] = update(L[p], l, mid, x, v);     else       R[c] = update(R[p], mid + 1, r, x, v);     res[c] = max(res[L[c]], res[R[c]]);     return c;   }   int query(int p, int u, int v, int l, int r) {     if (u <= l && r <= v) {       return res[p];     }     int mid = (l + r) >> 1;     int ans = 0;     if (u <= mid) ans = max(ans, query(L[p], u, v, l, mid));     if (v > mid) ans = max(ans, query(R[p], u, v, mid + 1, r));     return ans;   }   struct seg {     int a, b, c;     bool operator<(const seg &_) const {       if (a != _.a) return a < _.a;       if (c != _.c) return c < _.c;       if (b != _.b) return b > _.b;     }   } Sg[100005 * 3];   int B[100005 * 3];   void solve() {     tt = 0;     int tot = 0;     scanf( %d %d %d , &n, &m, &K);     for (int a, b, c, i = 1; i <= K; i++) {       scanf( %d %d %d , &a, &b, &c);       B[i] = a;       Sg[i] = (seg){a, b, c};     }     sort(B + 1, B + K + 1);     sort(Sg + 1, Sg + K + 1);     tot = unique(B + 1, B + 1 + K) - B - 1;     for (int i = 1; i <= n; i++)       rt[tot + 1] = update(rt[tot + 1], 1, n, i, 0x3f3f3f3f);     Sg[K + 1].a = 0x3f3f3f3f;     for (int i = K; i >= 1; i--) {       int t = lower_bound(B + 1, B + 1 + tot, Sg[i].a) - B;       if (Sg[i].a != Sg[i + 1].a) {         rt[t] = update(rt[t + 1], 1, n, Sg[i].c, Sg[i].b);       } else         rt[t] = update(rt[t], 1, n, Sg[i].c, Sg[i].b);     }     while (m--) {       int a, b, c, d;       scanf( %d %d %d %d , &a, &b, &c, &d);       if (c > B[tot]) {         puts( no );         fflush(stdout);         continue;       } else {         int t = lower_bound(B + 1, B + 1 + tot, c) - B;         if (query(rt[t], a, b, 1, n) <= d)           puts( yes );         else           puts( no );       }       fflush(stdout);     }   }   bool cur2;   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long MOD = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int t;     cin >> t;     while (t != 0) {       t--;       int n, k, l = -1, r = -1;       cin >> n >> k;       int c = k + 1, z, res = 0;       string x;       cin >> x;       for (int i = 0; i < n; i++) {         if (x[i] ==  1 ) {           r = i;           if (l == -1)             z = r - l - 1 - k;           else             z = r - l - 1 - (2 * k);           if (z > 0) {             c = k + 1;             for (int j = 0; j < z; j++) {               if (c > k) {                 res++;                 c = 0;               }               c++;             }           }           l = i;           z = 0;         }       }       r = n;       if (l == -1)         z = r - l - 1;       else         z = r - l - 1 - k;       if (z > 0) {         c = k + 1;         for (int j = 0; j < z; j++) {           if (c > k) {             res++;             c = 0;           }           c++;         }       }       cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long b[n];     pair<long long, long long> arr[n];     for (long long i = 0; i < n; i++) {       cin >> b[i];       arr[i].first = b[i] - i + 200000;       arr[i].second = b[i];     }     sort(arr, arr + n);     long long maxi = 0;     long long i = -1;     while (i < (n - 1)) {       i++;       long long c = 0;       c += arr[i].second;       while (arr[i].first == arr[i + 1].first) {         c += arr[i + 1].second;         i++;       }       maxi = max(c, maxi);     }     if (n == 1) {       cout << b[0];     } else {       cout << maxi;     }   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());   mt19937_64 rnd64(       chrono::high_resolution_clock::now().time_since_epoch().count());   long long power(long long a, long long m, long long mod) {     long long ans = 1;     while (m) {       if (m % 2) {         ans *= a;         ans %= (mod);       }       a = (a * a) % (mod);       m >>= 1;     }     return ans;   }   void init(long long* a, long long n, long long val) {     for (long long i = 0; i < n; i++) a[i] = val;   }   void solve() {     long long i, j, _, n;     cin >> n;     long long a[n], pre[n];     for (i = 0; i < n; i++) cin >> a[i];     vector<long long> ans;     sort(a, a + n);     j = 0;     for (i = 0; i < n; i++) cin >> j, j += a[i], j %= 998244353, pre[i] = j;     for (i = 1; i < n; i++) {       long long k = 0;       for (j = n - i - 1; j > -1; j -= i) k += pre[j], k %= 998244353;       ans.push_back(k);     }     ans.push_back(0);     n = power(n, 998244353 - 2, 998244353);     for (auto& i : ans) i *= n, i %= 998244353, cout << i <<    ;     cout << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long T = 1;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   long long power(long long x, long long y) {     if (y == 0) return 1;     long long a = power(x, y / 2);     if (y % 2) {       return (a * ((a * x) % mod)) % mod;     } else {       return (a * a) % mod;     }   }   int main() {     long long i, j, k, m, n;     cin >> n >> k;     long long ans = 0;     long long arr[n];     vector<vector<long long> > ind(11);     for (i = 0; i < n; i++) cin >> arr[i];     for (i = 0; i < n; i++) {       j = arr[i] % 10;       ind[j].push_back(i);     }     for (j = 9; j >= 1 && k > 0; j--) {       for (i = 0; i < ind[j].size(); i++) {         m = ind[j][i];         if (k >= (10 - j)) {           k -= 10 - j;           arr[m] += 10 - j;         }       }     }     sort(arr, arr + n);     for (i = 0; i < n; i++) {       if (k >= 100 - arr[i]) {         k -= 100 - arr[i];         arr[i] = 100;       } else {         long long flag = 1;         while (flag) {           if (k >= 10 && 1) {             k -= 10;             arr[i] += 10;           } else             flag = 0;         }       }     }     for (i = 0; i < n; i++) {       ans += arr[i] / 10;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string b[51];   bool check(pair<int, int> f, pair<int, int> s) {     bool r1 = true, r2 = true, c1 = true, c2 = true;     for (int i = f.first; i <= s.first; i++) {       if (b[i][f.second] ==  W ) c1 = false;       if (b[i][s.second] ==  W ) c2 = false;     }     for (int i = s.first; i <= f.first; i++) {       if (b[i][f.second] ==  W ) c1 = false;       if (b[i][s.second] ==  W ) c2 = false;     }     for (int i = f.second; i <= s.second; i++) {       if (b[f.first][i] ==  W ) r1 = false;       if (b[s.first][i] ==  W ) r2 = false;     }     for (int i = s.second; i <= f.second; i++) {       if (b[f.first][i] ==  W ) r1 = false;       if (b[s.first][i] ==  W ) r2 = false;     }     return (c1 && r2) || (c2 && r1);   }   vector<pair<int, int> > v;   int main() {     int r, c;     cin.tie(0);     cin >> r >> c;     for (int i = 0; i < r; i++) {       cin >> b[i];       for (int j = 0; j < c; j++)         if (b[i][j] ==  B ) v.push_back({i, j});     }     int sz = v.size();     for (int i = 0; i < sz; i++)       for (int j = i + 1; j < sz; j++) {         if (!check(v[i], v[j])) {           cout <<  NO ;           return 0;         };       }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   const int inf = 0x3f3f3f3f;   const long long LL_INF = 0x3f3f3f3f3f3f3f3f;   template <typename T>   T gcd(T a, T b) {     if (a == 0) return b;     return gcd(b % a, a);   }   long long power(long long a, long long b, long long m = 1000000007) {     long long answer = 1;     while (b) {       if (b & 1) answer = (answer * a) % m;       b /= 2;       a = (a * a) % m;     }     return answer;   }   using namespace std;   bool chk[1048576];   int main() {     set<int> st;     int n;     cin >> n;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       set<int>::iterator it;       set<int> st2;       for (it = st.begin(); it != st.end(); it++) {         int y = *it;         st2.insert(y | x);       }       st2.insert(x);       st = st2;       st2.clear();       for (it = st.begin(); it != st.end(); it++) {         chk[*it] = 1;       }     }     int cnt = 0;     for (int i = 0; i < 1048576; i++) {       if (chk[i]) cnt++;     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1 << 20;   long long fac[20];   vector<long long> lst;   vector<long long> lucky;   void prepare(int cnt, int all, long long now) {     if (cnt == all) {       lucky.push_back(now);       return;     }     prepare(cnt + 1, all, now * 10 + 4);     prepare(cnt + 1, all, now * 10 + 7);   }   inline bool chk(long long x) {     while (x) {       if (x % 10 != 4 && x % 10 != 7) return false;       x /= 10;     }     return true;   }   int main() {     ios::sync_with_stdio(false);     for (int i = 0; i <= 10; i++) prepare(0, i, 0);     fac[0] = 1;     for (int i = 1; i < 20; i++) fac[i] = fac[i - 1] * i;     long long n, k;     cin >> n >> k;     long long p = 1;     while (fac[p] < k) p++;     if (p > n) return cout << -1 <<   n , 0;     k--;     for (long long i = n - p + 1; i <= n; i++) lst.push_back(i);     while (k) {       int i;       for (i = p; ~i; i--)         if (fac[i] <= k) break;       int w = k / fac[i];       k -= fac[i] * w;       for (int s = 0; s < w; s++) swap(lst[p - 1 - i], lst[p - i + s]);     }     long long res =         upper_bound(lucky.begin(), lucky.end(), n - p) - lucky.begin() - 1;     for (int i = 0; i < lst.size(); i++)       if (chk(n - p + i + 1) && chk(lst[i])) res++;     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int block(long int x) {     vector<long int> v;     while (x > 0) {       v.push_back(x % 2);       x = x / 2;     }     int ret = 0;     for (int i = 0; i < v.size(); i++) {       if (v[i] == 1) {         ret++;       }     }     return ret;   }   void pprint(long int x) {     vector<long int> v;     while (x > 0) {       v.push_back(x % 2);       x = x / 2;     }     cout <<  YES n ;     int ret = 0;     for (int i = 0; i < v.size(); i++) {       if (v[i] == 1) {         ret++;         int A = 1 << i;         cout << A <<    ;       }     }     cout << endl;   }   void solve(long int x, long long k, long long mini) {     vector<long int> v;     long long rem = k - mini;     while (x > 0) {       v.push_back(x % 2);       x = x / 2;     }     int ret = 0;     cout <<  YES n ;     int i = v.size() - 1;     while (rem > 0) {       v[i]--;       v[i - 1] += 2;       if (v[i] == 0) {         i--;       }       rem--;     }     for (int i = 0; i < v.size(); i++) {       while (v[i] > 0) {         ret++;         int A = 1 << i;         cout << A <<    ;         v[i]--;       }     }     cout << endl;   }   int main() {     long long x;     long long n, k;     cin >> n >> k;     if (k > n) {       cout <<  NO n ;       return 0;     }     if (k == n) {       cout <<  YES n ;       for (int i = 0; i < n; i++) {         cout << 1 <<    ;       }       return 0;     }     int mini = block(n);     if (k < mini) {       cout <<  NO n ;       return 0;     }     if (k == mini) {       pprint(n);     } else {       solve(n, k, mini);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5001;   long long a[N], mem[N][2], b[N];   int n, m;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       b[i] = a[i];     }     sort(b, b + n);     m = unique(b, b + n) - b;     for (int i = n - 1; i >= 0; i--)       mem[i][1 - m & 1] =           abs(a[i] - b[m - 1]) + ((i + 1 < n) ? mem[i + 1][1 - m & 1] : 0ll);     for (int j = m - 2; j >= 0; j--)       for (int i = n - 1; i >= 0; i--)         mem[i][j & 1] =             min(mem[i][1 - j & 1],                 abs(a[i] - b[j]) + ((i + 1 < n) ? mem[i + 1][j & 1] : 0ll));     long long ans = 1ll << 50;     ans = min(mem[0][0], mem[0][1]);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class V>   T power(T t, V v) {     T second = 1;     while (v--) second *= t;     return second;   }   void _print(long long t) { cerr << t; }   void _print(int t) { cerr << t; }   void _print(string t) { cerr << t; }   void _print(char t) { cerr << t; }   void _print(long double t) { cerr << t; }   void _print(double t) { cerr << t; }   void _print(unsigned long long t) { cerr << t; }   template <class T, class V>   void _print(pair<T, V> p);   template <class T>   void _print(vector<T> v);   template <class T>   void _print(set<T> v);   template <class T, class V>   void _print(map<T, V> v);   template <class T>   void _print(multiset<T> v);   template <class T, class V>   void _print(pair<T, V> p) {     cerr <<  { ;     _print(p.first);     cerr <<    ;     _print(p.second);     cerr <<  } ;   }   template <class T>   void _print(vector<T> v) {     int n = v.size();     cerr <<  [  ;     for (T i : v) {       _print(i);       n--;       cerr << (n ?  ,   :    );     }     cerr <<  ] ;   }   template <class T>   void _print(set<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T>   void _print(multiset<T> v) {     cerr <<  [  ;     for (T i : v) {       _print(i);       cerr <<    ;     }     cerr <<  ] ;   }   template <class T, class V>   void _print(map<T, V> v) {     int n = v.size();     cerr <<  {  ;     for (auto p : v) {       cerr <<  [ ;       _print(p.first);       cerr <<  ]= ;       _print(p.second);       n--;       cerr << (n ?  ,   :    );     }     cerr <<  } ;   }   void go() {     int n;     cin >> n;     string a;     string b;     cin >> a >> b;     int sz = 0, so = 0, nsz = 0, nso = 0;     for (int i = 0; i < n; i++) {       if (a[i] == b[i]) {         if (a[i] ==  0 )           sz++;         else           so++;       } else if (a[i] ==  0 )         nsz++;       else         nso++;     }     int N = 100000000;     int ans = N;     if (so - sz == 1) ans = min(ans, so + sz);     if (nsz == nso) ans = min(ans, nsz + nso);     if (ans == N)       cout <<  -1 n ;     else       cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     cin >> t;     while (t--) {       go();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 <<   n ;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   int inf = 0x3f3f3f3f;   long long infl = 0x3f3f3f3f3f3f3f3fLL;   long double infd = 1.0 / 0.0;   const long long MOD = 1e9 + 7;   const double pi = 2 * acos(0.0);   long long modi(long long a, long long n) {     long long x = 1;     while (n) {       if (n & 1) x = (x * a) % MOD;       n >>= 1;       a = (a * a) % MOD;     }     return x;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int tt = 1;     while (tt--) {       long long a, b, n, x;       cin >> a >> b >> n >> x;       long long as = (((a * x) % MOD) + b) % MOD;       long long le = (x * modi(a, n)) % MOD;       long long ri = a == 1ll ? ((b * (n % MOD)) % MOD)                               : ((b * (((((modi(a, n) - 1 + MOD) % MOD)) *                                         (modi(a - 1, MOD - 2))) %                                        MOD)) %                                  MOD);       cout << ((((le + ri) % (MOD)) + (MOD)) % (MOD)) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s1, s2, s3, a, b, c;     cin >> s1 >> s2 >> s3;     a = (s1 * s2) / s3;     a = pow(a, 0.5);     b = (s2 * s3) / s1;     b = pow(b, 0.5);     c = (s1 * s3) / s2;     c = pow(c, 0.5);     cout << 4 * (a + b + c) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, ans = 0;     cin >> n;     for (;; ans++) {       if (n == 1) break;       if (n % 6 == 0)         n /= 6;       else if (n % 3 == 0) {         if ((n * 2) % 3 != 0) {           cout <<  -1 n ;           return;         }         n *= 2;       } else {         cout <<  -1 n ;         return;       }     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   void debug() { cerr <<  ] n ; }   template <class H, class... T>   void debug(H h, T... t) {     cerr << h;     if (sizeof...(t)) {       cerr <<  ,  ;     }     debug(t...);   }   void solve() {     int n;     cin >> n;     string s;     cin >> s;     int o, e;     o = e = 0;     int f1, f2;     f1 = f2 = 0;     for (int i = 0; i < n; i++) {       if (i & 1) {         if ((int)(s[i] -  0 ) & 1) {         } else           f2 = 1;       } else {         if ((int)(s[i] -  0 ) & 1) {           f1 = 1;         }       }     }     if (n == 1) {       cout << (((s[0] -  0 ) & 1) ?  1  :  2 ) <<   n ;       return;     }     if (n & 1) {       cout << (f1 ?  1  :  2 ) <<   n ;     } else {       cout << (f2 ?  2  :  1 ) <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int _;     cin >> _;     for (int i = 1; i <= _; i++) {       solve();     }     return 0;   }