malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   unsigned long long mod = 1000000007;   template <class T1>   void deb(T1 e1) {     cout << e1 <<   n ;   }   template <class T1, class T2>   void deb(T1 e1, T2 e2) {     cout << e1 <<     << e2 <<   n ;   }   template <class T1, class T2, class T3>   void deb(T1 e1, T2 e2, T3 e3) {     cout << e1 <<     << e2 <<     << e3 <<   n ;   }   template <class T1, class T2, class T3, class T4>   void deb(T1 e1, T2 e2, T3 e3, T4 e4) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 <<   n ;   }   template <class T1, class T2, class T3, class T4, class T5>   void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 <<     << e5 <<   n ;   }   template <class T1, class T2, class T3, class T4, class T5, class T6>   void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {     cout << e1 <<     << e2 <<     << e3 <<     << e4 <<     << e5 <<     << e6          <<   n ;   }   int main() {     int nob, nog, dancing_jodis = 0;     cin >> nob >> nog;     vector<pair<int, int> > store;     int max_gender = max(nob, nog);     int min_gender = min(nob, nog);     for (int gender = 1; gender <= min_gender; gender++, dancing_jodis++)       (nob >= nog) ? store.push_back(make_pair(1, gender))                    : store.push_back(make_pair(gender, 1));     for (int gender = 2; gender <= max_gender; gender++, dancing_jodis++)       (nob >= nog) ? store.push_back(make_pair(gender, 1))                    : store.push_back(make_pair(1, gender));     cout << dancing_jodis <<   n ;     for (int jodi = 0; jodi < int((store).size()); jodi++)       cout << store[jodi].first <<     << store[jodi].second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = (1 << 17);   int a[maxn], pos[maxn], n, b[maxn];   struct num {     int idx, val;     bool operator<(const num &mtp) const { return val > mtp.val; }   };   priority_queue<num> q1, q2;   int out[maxn];   void read() {     int i;     scanf( %d , &n);     for (i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       pos[a[i]] = i;     }     for (i = 1; i <= n; ++i) {       scanf( %d , &b[i]);     }   }   void solve() {     int i;     num tmp;     tmp.idx = maxn + 1;     tmp.val = maxn + 1;     q1.push(tmp);     q2.push(tmp);     for (i = 1; i <= n; ++i) {       if (i > pos[b[i]]) {         tmp.idx = i;         tmp.val = i - pos[b[i]];         q1.push(tmp);       } else {         tmp.idx = i;         tmp.val = pos[b[i]] - i;         q2.push(tmp);       }     }     printf( %d n , min(q1.top().val, q2.top().val));     int k = 0;     for (i = 1; i < n; ++i) {       k++;       tmp.idx = i;       tmp.val = n - pos[b[i]] + k;       q1.push(tmp);       out[i] = 1;       while ((q1.top().val - k) == 0) {         tmp.idx = q1.top().idx;         tmp.val = (-1) * k;         q2.push(tmp);         out[q1.top().idx] = 0;         q1.pop();       }       while (out[q2.top().idx]) q2.pop();       printf( %d n , min(q1.top().val - k, q2.top().val + k));     }   }   int main() {     read();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[1004];   long long ncr[1004][1004];   int ones(int n) {     int cnt = 0;     while (n) {       if (n % 2 == 1) {         cnt++;       }       n /= 2;     }     return cnt;   }   void calcncr() {     for (int i = 0; i <= 1000; i++) {       ncr[i][0] = 1;     }     for (int i = 1; i <= 1000; i++) {       for (int j = 1; j <= 1000; j++) {         ncr[i][j] = (ncr[i - 1][j - 1] + ncr[i - 1][j]) % 1000000007;       }     }   }   int main() {     string n;     int k;     calcncr();     dp[1] = 0;     for (int i = 2; i <= 1000; i++) {       dp[i] = dp[ones(i)] + 1;     }     cin >> n >> k;     if (k == 0) {       cout <<  1 n ;       return 0;     }     long long nones = 0, ans = 0;     for (int i = 0; i < n.size(); i++) {       if (n[i] ==  0 ) {         continue;       }       for (int j = max(nones, 1LL); j < 1000; j++) {         if (dp[j] == k - 1) {           ans = (ans + ncr[n.size() - i - 1][j - nones]) % 1000000007;           if (i == 0 && k == 1) {             ans = (ans + 1000000007 - 1) % 1000000007;           }         }       }       nones++;     }     int cnt = 0;     for (int i = 0; i < n.size(); i++) {       if (n[i] ==  1 ) {         cnt++;       }     }     if (dp[cnt] == k - 1) {       ans = (ans + 1) % 1000000007;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long q[1000001], a[100001];   int main() {     long long n, x, cnt = 0;     cin >> n >> x;     for (int i = 1; i <= n; i++) {       cin >> a[i];       q[a[i]]++;     }     int e = 0;     if (!x) {       e = 1;     }     for (int i = 1; i <= n; i++) {       int w = x;       w ^= a[i];       cnt += q[w] - e;       q[a[i]]--;     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double INF = 1e12, epsilon = 1e-8;   long double Y_AXIS, res = INF;   vector<pair<long double, bool> > forbid;   inline long double sqr(long double x) { return x * x; }   inline long double dist(long double x1, long double y1, long double x2 = 0,                           long double y2 = 0) {     return sqr(x1 - x2) + sqr(y1 - y2);   }   inline long double area(long double x1, long double y1, long double x2,                           long double y2, long double x3, long double y3) {     return (x1 - x2) * (y1 - y3) - (x1 - x3) * (y1 - y2);   }   inline void mini(long double &a, long double b) {     if (a > b) a = b;   }   long double binsearch(long double x, long double y, int r) {     long double L = -INF, R = INF, mid;     while (L + epsilon < R) {       mid = (L + R) / 2;       (sqrt(dist(x, y, mid)) + r < sqrt(dist(mid, Y_AXIS)) ^ x < 0 ? R : L) = mid;     }     return mid;   }   bool check_zero() {     int cnt = 0;     for (pair<long double, bool> info : forbid)       if (abs(++cnt -= (info.first > 0 ^ info.second) << 1) > 1) return false;     return true;   }   int main() {     int x1, y1, x2, y2, n;     scanf( %d%d%d%d%d , &x1, &y1, &x2, &y2, &n);     Y_AXIS = sqrt(dist(x1, y1, x2, y2)) / 2;     for (int i = 0; i < n; ++i) {       int x, y, r;       scanf( %d%d%d , &x, &y, &r);       long double xx = area(x, y, x1, y1, x2, y2) / Y_AXIS / 2;       long double yy =           sqrt(dist(x, y, (x1 + x2) / 2.0, (y1 + y2) / 2.0) - sqr(xx));       forbid.push_back(make_pair(binsearch(xx, yy, r), xx > 0));       forbid.push_back(make_pair(binsearch(xx, yy, -r), xx < 0));     }     if (check_zero()) {       printf( %.9Lf , Y_AXIS);       return 0;     }     sort(forbid.begin(), forbid.end());     int cnt = 0;     for (pair<long double, bool> info : forbid)       if (info.second && !--cnt || !info.second && !cnt++)         mini(res, sqrt(dist(info.first, Y_AXIS)));     printf( %.9Lf , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void MACRO_VAR_Scan(T& t) {     cin >> t;   }   template <typename First, typename... Rest>   void MACRO_VAR_Scan(First& first, Rest&... rest) {     cin >> first;     MACRO_VAR_Scan(rest...);   }   template <typename T>   void MACRO_VEC_ROW_Init(int n, T& t) {     t.resize(n);   }   template <typename First, typename... Rest>   void MACRO_VEC_ROW_Init(int n, First& first, Rest&... rest) {     first.resize(n);     MACRO_VEC_ROW_Init(n, rest...);   }   template <typename T>   void MACRO_VEC_ROW_Scan(int p, T& t) {     cin >> t[p];   }   template <typename First, typename... Rest>   void MACRO_VEC_ROW_Scan(int p, First& first, Rest&... rest) {     cin >> first[p];     MACRO_VEC_ROW_Scan(p, rest...);   }   void _main();   signed main() {     cin.tie(0);     ios::sync_with_stdio(false);     _main();   }   inline long long toInt(std::string s) {     long long v;     std::istringstream sin(s);     sin >> v;     return v;   }   template <class T>   inline string toString(T x) {     ostringstream sout;     sout << x;     return sout.str();   }   template <class T>   inline T sqr(T x) {     return x * x;   }   template <typename A, typename B>   inline void chmin(A& a, B b) {     if (a > b) a = b;   }   template <typename A, typename B>   inline void chmax(A& a, B b) {     if (a < b) a = b;   }   long long qp(long long a, long long b) {     long long ans = 1ll;     do {       if (b & 1) ans = 1ll * ans * a;       a = 1ll * a * a;     } while (b >>= 1);     return ans;   }   long long qpmod(long long a, long long b, long long mo) {     long long ans = 1ll;     do {       if (b & 1) ans = 1ll * ans * a % mo;       a = 1ll * a * a % mo;     } while (b >>= 1);     return ans;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   inline bool valid(int x, int h) { return 0 <= x && x < h; }   const double EPS = 1e-10;   const double PI = acos(-1.0);   const int INF = (int)(1e9) + 7;   const long long MOD = (long long)(1e9) + 7;   const long long MOD2 = (long long)(1e18) + 9;   const long long INF2 = (long long)(1e18);   const long long INTMAX = (0x7FFFFFFFL);   const long long LLMAX = (0x7FFFFFFFFFFFFFFFL);   const int N4 = (int)1e4 + 10;   const int N5 = (int)1e5 + 10;   int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};   int dy[8] = {0, 1, 0, -1, -1, -1, 1, 1};   long long ans, cnt, ret, cur, f;   void _main() {     map<int, int> ma;     int n;     MACRO_VAR_Scan(n);     ;     vector<int> v(n);     for (auto& i : v) cin >> i;     ;     for (auto& x : v) ma[x]++;     for (auto& x : ma) chmax(ret, x.second);     cout << ret << endl;     ;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC optimization( unroll-loops )   using namespace std;   const int INF = 0x3f3f3f3f;   const long long LINF = 0x3f3f3f3f3f3f3f3fll;   int read_int() {     bool minus = false;     int result = 0;     char ch;     ch = getchar();     while (1) {       if (ch ==  - ) break;       if (ch >=  0  && ch <=  9 ) break;       ch = getchar();     }     if (ch ==  - )       minus = true;     else       result = ch -  0 ;     while (1) {       ch = getchar();       if (ch <  0  || ch >  9 ) break;       result = result * 10 + (ch -  0 );     }     if (minus)       return -result;     else       return result;   }   const int MAX = 2e5 + 10;   unsigned char v[MAX];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n = read_int();     for (int i = 0; i < n; i++) v[i] = read_int();     int q = read_int();     while (q--) {       int l = read_int(), r = read_int();       unsigned char x = read_int(), y = read_int();       l--, r--;       for (int i = l; i <= r; i++) v[i] = v[i] == x ? y : v[i];     }     for (int i = 0; i < n; i++) cout << int(v[i]) <<    ;     cout <<   n ;     exit(0);   }
#include <bits/stdc++.h>   using namespace std;   long long k, b, n, t;   int main() {     cin >> k >> b >> n >> t;     int temp = 0;     long long acc = 1;     while (acc <= t) {       acc *= k;       acc += b;       temp++;     }     int ans = n - temp + 1;     if (ans < 0)       cout << 0 << endl;     else       cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   int func(int a, int b) {     if (a == 1 and b >= 1) return (b - a);     if (a == b or b % a == 0 or a <= 0 or b <= 0) return INT_MAX;     int ret = func(b % a, a);     if (ret != INT_MAX) ret += b / a;     return ret;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     if (n == 1) {       cout << 0 << endl;       return 0;     }     int ans = INT_MAX;     for (int i = n >> 1; i > 0; i--) {       ans = min(ans, func(i, n - i));     }     cout << ans + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool vis[12][12][12];   int ans2(int x, int y, int z, char a[12][12][12], int k, int n, int m) {     int cnt = 0;     if (a[x][y][z] ==  #  || vis[x][y][z]) return 0;     cnt++;     vis[x][y][z] = true;     if (x > 1) cnt += ans2(x - 1, y, z, a, k, n, m);     if (x < k) cnt += ans2(x + 1, y, z, a, k, n, m);     if (y > 1) cnt += ans2(x, y - 1, z, a, k, n, m);     if (y < n) cnt += ans2(x, y + 1, z, a, k, n, m);     if (z > 1) cnt += ans2(x, y, z - 1, a, k, n, m);     if (z < m) cnt += ans2(x, y, z + 1, a, k, n, m);     return cnt;   }   int ans(int x, int y, int z, char a[12][12][12], int k, int n, int m) {     int cnt = 0;     vis[x][y][z] = true;     if (a[x][y][z] ==  . ) cnt++;     if (a[x][y][z] ==  . ) {       if (x < k) cnt += ans2(x + 1, y, z, a, k, n, m);     }     if (y > 1) cnt += ans2(x, y - 1, z, a, k, n, m);     if (y < n) cnt += ans2(x, y + 1, z, a, k, n, m);     if (z > 1) cnt += ans2(x, y, z - 1, a, k, n, m);     if (z < m) cnt += ans2(x, y, z + 1, a, k, n, m);     return cnt;   }   int main() {     int n, k, m;     char a[12][12][12];     cin >> k >> n >> m;     for (int i = 1; i <= k; i++) {       for (int j = 1; j <= n; j++) {         for (int t = 1; t <= m; t++) {           cin >> a[i][j][t];         }       }     }     int x, y;     cin >> x >> y;     cout << ans(1, x, y, a, k, n, m) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N;     cin >> N;     long long A[50001];     long long total = 0;     for (int i = 0; i < N; ++i) {       cin >> A[i];       total += A[i];     }     long long x = total / N;     long long res = 0;     long long bal = 0;     for (int i = 0; i < N; ++i) {       res += abs(bal);       bal += x - A[i];     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string S;   const int MAX_N = 5000;   bool wyn[MAX_N + 3][MAX_N + 3];   int main() {     ios::sync_with_stdio(0);     cin >> S;     int wynik = 0;     int val = 0;     int zap = 0;     for (int l = 0; l < S.size(); l++) {       val = 0;       zap = 0;       for (int r = l; r < S.size(); r++) {         if (S[r] ==  ( )           val++;         else if (S[r] ==  ) )           val--;         else if (S[r] ==  ? )           zap++;         if (val + zap >= 0)           wyn[l][r] = true;         else           break;       }     }     for (int r = 0; r < S.size(); r++) {       val = 0;       zap = 0;       for (int l = r; l >= 0; l--) {         if (S[l] ==  ( )           val--;         else if (S[l] ==  ) )           val++;         else if (S[l] ==  ? )           zap++;         int len = r - l + 1;         if (val + zap >= 0) {           if (wyn[l][r] && len % 2 == 0) wynik++;         } else           break;       }     }     cout << wynik;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, k, a[N];   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   int main() {     scanf( %d %d , &n, &k);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     int g = a[0];     for (int i = 1; i < n; i++) {       g = gcd(g, a[i]);     }     int gk = gcd(g, k);     if (gk == k) {       printf( 1 n );       printf( 0 n );     } else {       vector<int> vc;       for (int x = 0; x < k; x += gk) {         vc.push_back(x);       }       printf( %d n , vc.size());       for (int i = 0; i < vc.size(); i++) {         printf( %d  , vc[i]);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int num[200000];   long long cnt[200000] = {0};   long long dp[200000] = {0};   long long sum[200000] = {0};   int main() {     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> num[i];       cnt[num[i]]++;     }     long long ans = 0;     for (int i = 1; i < 200000; ++i) {       if (i > 1) {         dp[i] = max(dp[i - 2] + cnt[i] * i, dp[i - 1]);       } else {         dp[i] = cnt[i] * i;       }       ans = max(ans, dp[i]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   long long ln, lk, lm;   char s[100005];   void fmain() {     scanf( %d%d%d , &n, &m, &k);     scanf( %s , s + 1);     for (int ty, l, r, x, i = 0; i < m + k; i++) {       scanf( %d%d%d%d , &ty, &l, &r, &x);       if (ty == 1) {         memset(s + l,  0  + x, r - l + 1);       } else {         bool fg = memcmp(s + l, s + l + x, r - x - l + 1) == 0;         puts(fg ?  YES  :  NO );       }     }   }   int main() {     fmain();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Arco {     int v, next;     Arco() {}     Arco(int v, int next) : v(v), next(next) {}   } edges[1];   int last[1], E;   void add_edge(int v, int u) {     edges[E] = Arco(u, last[v]);     last[v] = E++;   }   int xf[8] = {-1, -1, -1, 0, 0, +1, +1, +1};   int xc[8] = {-1, 0, +1, -1, +1, -1, 0, +1};   bool esta[30];   bool M[256][256];   int METODO(char *cad) {     int sol = 0;     return sol;   }   int main() {     char texto[100004];     char cad[10];     int q;     scanf( %s , texto);     scanf( %d , &q);     int sol = 0, len = strlen(texto);     while (q--) {       scanf( %s , cad);       for (int i = 0; i < len; i++)         if (texto[i] == cad[0] || texto[i] == cad[1]) {           int a = 0, b = 0, j = i;           while (j < len && (texto[j] == cad[0] || texto[j] == cad[1]))             if (texto[j++] == cad[0])               a++;             else               b++;           sol += min(a, b);           i = j;         }     }     printf( %d n , sol);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       string s;       cin >> s;       long long l_occ_1 = -1, l_occ_2 = -1, l_occ_3 = -1;       long long maxi = s.length() + 1, mini;       for (long long i = 0; i < s.length(); i++) {         if (s[i] ==  1 ) l_occ_1 = i;         if (s[i] ==  2 ) l_occ_2 = i;         if (s[i] ==  3 ) l_occ_3 = i;         if (!(l_occ_1 == -1 || l_occ_2 == -1 || l_occ_3 == -1)) {           long long x = max(abs(l_occ_1 - l_occ_3), abs(l_occ_2 - l_occ_3));           mini = max(x, abs(l_occ_1 - l_occ_2));           maxi = min(maxi, mini);         }       }       if (l_occ_1 == -1 || l_occ_2 == -1 || l_occ_3 == -1) maxi = -1;       cout << maxi + 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 5;   const long long INF = 100000000000000;   long long h[maxn], p[maxn];   long long l[maxn], r[maxn];   int n, m;   bool ok(long long t) {     for (int i = 0; i < n; i++) {       l[i] = h[i];       r[i] = h[i];     }     int k = 0;     for (int i = 0; i < m; i++) {       if (p[i] >= l[k] && p[i] <= r[k]) continue;       if (p[i] < l[k]) {         if (r[k] - p[i] > t) {           return false;         } else {           l[k] = p[i];         }       }       if (p[i] > r[k]) {         if (p[i] - l[k] + min(p[i] - h[k], h[k] - l[k]) > t) {           k++;           if (k >= n) return false;           i--;         } else {           r[k] = p[i];         }       }     }     return true;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) scanf( %I64d , &h[i]);     for (int i = 0; i < m; i++) scanf( %I64d , &p[i]);     long long l = -1, r = INF;     while (l < r - 1) {       long long mid = (l + r) / 2;       if (ok(mid)) {         r = mid;       } else {         l = mid;       }     }     cout << r << endl;   }
#include <bits/stdc++.h>   char s1[1000100], s2[1000100];   char s[1000100 * 2];   int i, j, n, m;   inline char rev(char& a) {     if (a ==  N ) return  S ;     if (a ==  W ) return  E ;     if (a ==  S ) return  N ;     if (a ==  E ) return  W ;     return 0;   }   int z[1000100 * 2];   inline void Z() {     int L = 0, R = 0;     for (int i = 1; i < n; i++) {       if (i > R) {         L = R = i;         while (R < n && s[R - L] == s[R]) R++;         z[i] = R - L;         R--;       } else {         int k = i - L;         if (z[k] < R - i + 1)           z[i] = z[k];         else {           L = i;           while (R < n && s[R - L] == s[R]) R++;           z[i] = R - L;           R--;         }       }     }   }   int main() {     scanf( %d , &n);     n--;     scanf(  %s %s , s1, s2);     for (i = 0; i < n; i++) {       s2[i] = rev(s2[i]);       s[n - i - 1] = s2[i];       s[i + n] = s1[i];     }     n *= 2;     Z();     n /= 2;     for (i = 0; i < n; i++) {       if (z[i + n] >= n - i) {         printf( NO n );         return 0;       }     }     printf( YES n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const N = 1e5 + 10;   char s[N];   int f[N][3];   bool _ok(int x, int y, int z) {     if (x == z && z == y) return true;     if (x == z && y == z - 1) return true;     if (y == z && y == x - 1) return true;     return false;   }   bool ok(int x, int y, int z) {     if (x + y + z < 3) return true;     return _ok(x, y, z) || _ok(z, x, y) || _ok(y, z, x);   }   int main() {     scanf( %s , s);     int n = (int)strlen(s);     for (int i = 0; i < n; ++i) {       for (int j = 0; j < 3; ++j) f[i + 1][j] = f[i][j];       ++f[i + 1][s[i] -  x ];     }     int m, l, r;     for (scanf( %d , &m); m--;) {       scanf( %d%d , &l, &r);       int x = f[r][0] - f[l - 1][0], y = f[r][1] - f[l - 1][1],           z = f[r][2] - f[l - 1][2];       if (ok(x, y, z))         puts( YES );       else         puts( NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, x, y, ans;   struct Edge {     long long to, next;   } edge[2 * 300001];   long long head[300001], sze;   long long fa[300001], Tsze[300001], deep[300001];   inline char gc() {     static char now[1 << 20], *S, *T;     if (T == S) {       T = (S = now) + fread(now, 1, 1 << 20, stdin);       if (T == S) return EOF;     }     return *S++;   }   inline long long read() {     long long res = 0;     char c;     while ((c = getchar()) <  0  || c >  9 )       ;     res = (c ^ 48);     while ((c = getchar()) >=  0  && c <=  9 )       res = (res << 3) + (res << 1) + (c ^ 48);     return res;   }   inline void add(long long u, long long v) {     edge[++sze] = (Edge){v, head[u]}, head[u] = sze;     edge[++sze] = (Edge){u, head[v]}, head[v] = sze;   }   inline void dfs(long long u, long long f) {     fa[u] = f, deep[u] = deep[f] + 1, Tsze[u] = 1;     long long i;     for (i = head[u]; i; i = edge[i].next) {       long long v = edge[i].to;       if (v == f) continue;       dfs(v, u), Tsze[u] += Tsze[v];     }   }   inline long long ask() {     if (deep[x] > deep[y]) swap(x, y);     long long ok = 0, i;     for (i = y; i; i = fa[i])       if (i == x) {         ok = 1;         break;       }     if (ok) return (n - Tsze[x] + 1) * Tsze[y];     return Tsze[x] * Tsze[y];   }   signed main() {     n = read(), x = read(), y = read(), ans = n * (n - 1);     long long i;     for (i = 1; i < n; i++) add(read(), read());     dfs(1, 0);     long long a = x, b = y, ok = 0;     for (; a; a = fa[a])       if (fa[a] == y) ans -= Tsze[x] * (n - Tsze[a]), ok = 1;     for (; b; b = fa[b])       if (fa[b] == x) ans -= Tsze[y] * (n - Tsze[b]), ok = 1;     if (!ok) ans -= Tsze[x] * Tsze[y];     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long i, n, r, a, q;   void solve() {     cin >> n;     if (n == 4 || n == 1 || n == 2) {       cout <<  -1 n ;       return;     }     a = n / 3;     r = n % 3;     if (r == 1) {       cout << n / 3 - 2 <<   0              <<  1 n ;       return;     }     if (r == 2) {       cout << n / 3 - 1 <<   1 0             <<   n ;       return;     }     cout << n / 3 <<   0           <<   0           <<   n ;   }   int main() {     for (cin >> q; q--;) {       solve();     }   }