malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool isValid(string s) {     bool valid = true;     if (s.length() < 1 || s.length() > 16) return false;     for (int i = 0; i < s.length(); i++) {       if (s[i] < 48 || (s[i] > 57 && s[i] < 65) || (s[i] > 90 && s[i] < 95) ||           (s[i] > 95 && s[i] < 97) || s[i] > 122) {         valid = false;         break;       }     }     return valid;   }   int main() {     string s;     cin >> s;     size_t f1, f2, f3;     f1 = s.find( @ );     if (f1 != string::npos) {       string t;       t = s.substr(0, int(f1));       if (isValid(t)) {         bool resource = false;         f2 = s.find( / );         if (f2 != string::npos && int(f2) > int(f1)) {           resource = true;           t = s.substr(int(f1) + 1, int(f2) - int(f1) - 1);         } else           t = s.substr(int(f1) + 1);         if (t.length() < 1 || t.length() > 32) {           cout <<  NO ;           return 0;         }         do {           f3 = t.find( . );           if (f3 != string::npos && int(f3) > 0) {             string aux = t.substr(0, int(f3));             if (isValid(aux))               t.erase(0, int(f3) + 1);             else {               cout <<  NO ;               return 0;             }           } else {             if (isValid(t)) {               if (resource) {                 string aux = s.substr(int(f2) + 1);                 if (isValid(aux))                   cout <<  YES ;                 else                   cout <<  NO ;                 return 0;               } else {                 cout <<  YES ;                 return 0;               }             } else {               cout <<  NO ;               return 0;             }           }         } while (f3 != string::npos);       } else {         cout <<  NO ;         return 0;       }     } else {       cout <<  NO ;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 201000;   int n, a[N], pos[N], l[N], r[N], C[N], idx[N], ans[N];   vector<int> nu[N];   void bitModify(int p) {     for (int i = p; i > 0; i -= i & -i) C[i]++;   }   int bitQuery(int p) {     int ret = 0;     for (int i = p; i <= n; i += i & -i) ret += C[i];     return ret;   }   bool cmp(int a, int b) { return r[a] < r[b]; }   int main() {     int nq;     scanf( %d%d , &n, &nq);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       pos[a[i]] = i;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; i * j <= n; j++) {         int a = pos[i];         int b = pos[i * j];         if (a > b) swap(a, b);         nu[b].push_back(a);       }     }     for (int i = 0; i < nq; i++) {       scanf( %d%d , &l[i], &r[i]);       idx[i] = i;     }     sort(idx, idx + nq, cmp);     int p = 0;     for (int i = 0; i < nq; i++) {       int ll = l[idx[i]];       int rr = r[idx[i]];       while (p < rr) {         p++;         for (int i = 0; i < (int)nu[p].size(); i++) {           bitModify(nu[p][i]);         }       }       ans[idx[i]] = bitQuery(ll);     }     for (int i = 0; i < nq; i++) {       printf( %d%c , ans[i],    n [i == nq - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     iostream::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long n, t;     cin >> n >> t;     vector<pair<long long, long long> > v(n);     double den = 0;     for (long long i = (0); i < (n); ++i) {       cin >> v[i].second;       den += v[i].second;     }     for (long long i = (0); i < (n); ++i) cin >> v[i].first;     sort(v.begin(), v.end());     double sm = 0;     for (long long i = (0); i < (n); ++i) {       sm += v[i].first * v[i].second;     }     if (sm / den == (double)t) {       cout << setprecision(8) << den;       exit(0);     }     if ((double)sm / den > t) {       for (long long i = n - 1; i >= 0; i--) {         if ((double)(sm - v[i].first * v[i].second) / (den - v[i].second) > t) {           sm -= v[i].first * v[i].second;           den -= v[i].second;           continue;         } else {           cout << setprecision(8)                << den + (double)(sm - t * den) / (t - v[i].first);           exit(0);         }       }     } else {       for (long long i = 0; i < n; i++) {         if ((double)(sm - v[i].first * v[i].second) / (den - v[i].second) < t) {           sm -= v[i].first * v[i].second;           den -= v[i].second;           continue;         } else {           cout << setprecision(8)                << den + (double)(sm - t * den) / (t - v[i].first);           exit(0);         }       }     }     cout <<  0 ;   }
#include <bits/stdc++.h>   using namespace std;   struct Rectangle {     int l, d, r, u;   };   const int maxn = 500000;   int n;   Rectangle rt[maxn];   int ans[maxn];   int main() {     ios::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) cin >> rt[i].l >> rt[i].d >> rt[i].r >> rt[i].u;     for (int i = 0; i < n; i++) ans[i] = (rt[i].l & 1) * 2 + (rt[i].d & 1);     cout <<  YES  << endl;     for (int i = 0; i < n; i++) cout << ans[i] + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void display(std::vector<int> v) {     for (int i = 3; i >= 0; i--) {       for (int j = 0; j < v[i]; j++) {         if (i == 3)           cout << 7;         else if (i == 2)           cout << 5;         else if (i == 1)           cout << 3;         else if (i == 0)           cout << 2;       }     }   }   int main() {     int n;     cin >> n;     std::vector<int> v = {0, 0, 0, 0};     while (n--) {       char c;       cin >> c;       if (c ==  2 )         v[0]++;       else if (c ==  3 )         v[1]++;       else if (c ==  4 ) {         v[0] += 2;         v[1]++;       } else if (c ==  5 )         v[2]++;       else if (c ==  6 ) {         v[1] += 1;         v[2]++;       } else if (c ==  7 )         v[3]++;       else if (c ==  8 ) {         v[3]++;         v[0] += 3;       } else if (c ==  9 ) {         v[1] += 2;         v[0]++;         v[3]++;       }     }     display(v);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> ans;   int main() {     long long n;     cin >> n;     for (long long i = 1; i <= sqrt(n); i++)       if (n % i == 0) {         ans.push_back((n + 2 - i) * n / i / 2);         if (i * i != n) ans.push_back((i * n + 2 * i - n) / 2);       }     sort(ans.begin(), ans.end());     for (unsigned int i = 0; i < ans.size(); i++) printf( %lld  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int dx[] = {0, 0, -1, 1, -1, -1, 1, 1};   long long int dy[] = {1, -1, 0, 0, 1, -1, -1, 1};   using namespace std;   int main() {     long long int n, p;     cin >> n >> p;     vector<bool> box(n, 0);     vector<pair<long long int, long long int>> ppl(p);     for (auto& i : ppl) cin >> i.first >> i.second;     bool res = 1;     for (int i = 0; i < n; ++i) {       cout << res;       res = !res;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m;     cin >> n >> m;     vector<vector<int>> grid(n, vector<int>(m, 0));     vector<vector<int>> up(n, vector<int>(m, 0));     vector<vector<int>> down(n, vector<int>(m, 0));     vector<vector<int>> left(n, vector<int>(m, 0));     vector<vector<int>> right(n, vector<int>(m, 0));     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> grid[i][j];       }     }     for (int i = 0; i < n; i++) {       left[i][0] = grid[i][0];       for (int j = 1; j < m; j++) {         left[i][j] = left[i][j - 1] + grid[i][j];       }     }     for (int i = 0; i < n; i++) {       right[i][m - 1] = grid[i][m - 1];       for (int j = m - 2; j >= 0; j--) {         right[i][j] = right[i][j + 1] + grid[i][j];       }     }     for (int j = 0; j < m; j++) {       up[0][j] = grid[0][j];       for (int i = 1; i < n; i++) {         up[i][j] = up[i - 1][j] + grid[i][j];       }     }     for (int j = 0; j < m; j++) {       down[n - 1][j] = grid[n - 1][j];       for (int i = n - 2; i >= 0; i--) {         down[i][j] = down[i + 1][j] + grid[i][j];       }     }     int ans = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (grid[i][j] == 1) continue;         if (up[i][j] - grid[i][j] > 0) ans++;         if (down[i][j] - grid[i][j] > 0) ans++;         if (left[i][j] - grid[i][j] > 0) ans++;         if (right[i][j] - grid[i][j] > 0) ans++;       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     set<pair<int, int> > st;     for (int i = 0; i < n; ++i) {       int x;       scanf( %d , &x);       st.insert({x, i});     }     int x = -1;     vector<int> ans;     while (x >= -1) {       auto it = st.lower_bound({x + 1, -1});       if (it != st.end() and it->first == x + 1) {         ans.emplace_back(it->second);         st.erase(it);         x++;       } else {         x -= 3;       }     }     if (st.empty()) {       cout <<  Possible n ;       for (const int &x : ans) printf( %d  , x + 1);     } else {       cout <<  Impossible n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-06;   const int MAXN = 25;   pair<int, int> r, r2, bk, wk;   int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};   int dy[] = {0, 0, 1, -1, -1, 1, 1, -1};   char board[10][10];   bool valid(int x, int y) { return x >= 0 && y >= 0 && x < 8 && y < 8; }   bool ok(int x, int y) {     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         if (board[i][j] ==  R ) {           for (int k = 0; k < 4; k++) {             int nx = i, ny = j;             do {               nx = nx + dx[k], ny = ny + dy[k];             } while (valid(nx, ny) && board[nx][ny] ==  . );             if (valid(nx, ny) && board[nx][ny] ==  B ) return false;           }         }         if (board[i][j] ==  W ) {           for (int k = 0; k < 8; k++) {             int nx = i + dx[k], ny = j + dy[k];             if (valid(nx, ny) && board[nx][ny] ==  B ) return false;           }         }       }     }     return true;   }   bool check(int x, int y) {     if (ok(x, y)) return false;     bool mate = true;     for (int i = 0; i < 8; i++) {       int nx = x + dx[i], ny = y + dy[i];       if (!valid(nx, ny)) continue;       char tmp = board[nx][ny];       board[nx][ny] =  B ;       board[x][y] =  . ;       if (ok(nx, ny)) mate = false;       board[nx][ny] = tmp;       board[x][y] =  B ;     }     return mate;   }   pair<int, int> get(string a) { return pair<int, int>( 8  - a[1], a[0] -  a ); }   int main() {     for (int i = 0; i < 8; i++)       for (int j = 0; j < 8; j++) board[i][j] =  . ;     string tmp;     cin >> tmp, board[get(tmp).first][get(tmp).second] =  R ;     cin >> tmp, board[get(tmp).first][get(tmp).second] =  R ;     cin >> tmp, board[get(tmp).first][get(tmp).second] =  W ;     cin >> tmp, board[get(tmp).first][get(tmp).second] =  B ;     bool ret = false;     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         if (board[i][j] ==  B ) ret = check(i, j);       }     }     if (ret)       cout <<  CHECKMATE  << endl;     else       cout <<  OTHER  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool a[300001];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int i, n, tmp, ans = 1, last;     cin >> n;     last = n;     cout << 1 <<    ;     for (i = 0; i < n; i++) {       cin >> tmp;       a[tmp] = 1;       ans++;       while (a[last]) {         last--, ans--;       }       cout << ans <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 20;   int c[MAX_N], d[MAX_N], num[MAX_N];   int dp[MAX_N][MAX_N * 100];   int n, m, c0, d0, a, b;   int main() {     while (scanf( %d%d%d%d , &n, &m, &c0, &d0) != EOF) {       for (int i = 1; i <= m; i++) {         scanf( %d%d , &a, &b);         num[i] = a / b;         scanf( %d%d , &c[i], &d[i]);       }       memset(dp, 0, sizeof dp);       for (int i = 0; i <= n; i++) dp[0][i] = i / c0 * d0;       for (int i = 1; i <= m; i++)         for (int j = 0; j <= n; j++)           for (int k = 0; k <= num[i]; k++) {             if (j / c[i] < k) break;             dp[i][j] = max(dp[i][j], dp[i - 1][j - c[i] * k] + d[i] * k);           }       int res = 0;       for (int i = 0; i <= n; i++) res = max(res, dp[m][i]);       printf( %d n , res);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int hops[n + 1];     bool vis[n + 1];     int change[n + 1];     for (int i = 1; i <= n; ++i) {       cin >> hops[i];       vis[i] = 0;     }     int cnt = 0;     int cnt1 = 0;     for (int i = 1; i <= n; ++i) {       cin >> change[i];       if (change[i]) cnt1++;     }     for (int i = 1; i <= n; ++i) {       if (!vis[i]) {         int j = i;         cnt++;         while (vis[hops[j]] == false) {           j = hops[j];           vis[j] = true;         }       }     }     if (cnt1 % 2)       cnt1 = 0;     else       cnt1 = 1;     if (cnt == 1) cnt = 0;     cout << cnt + cnt1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int N, K;   long long A[100100], sol;   map<long long, long long> M;   long long __grundy(long long n) {     if (n == 0) return 0;     if (((M).find(n) != (M).end())) return M[n];     long long r = __grundy(n - 1);     if (n % 2 != 0) return M[n] = ((r == 0) ? 1 : 0);     long long c = __grundy(n / 2);     if (r != 0 && K > 0 && c != 0) return M[n] = 0;     if (r != 1 && (K == 0 || c != 1)) return M[n] = 1;     return M[n] = 2;   }   long long g0(long long n) {     if (n == 0) return 0;     if (n == 1) return 1;     if (n == 2) return 2;     return ((n % 2) == 0) ? 1 : 0;   }   long long g1(long long n) {     if (n == 0) return 0;     if (n == 1) return 1;     if (n == 2) return 0;     if (n == 3) return 1;     if (n == 4) return 2;     if ((n % 2) == 1) return 0;     if (g1(n / 2) == 1) return 2;     return 1;   }   long long grundy(long long n) {     if (K)       return g1(n);     else       return g0(n);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     K = 0;     for (int I = 1; I <= 160; I++) {       assert(grundy(I) == __grundy(I));     }     M.clear();     K = 1;     for (int I = 1; I <= 160; I++) {       assert(grundy(I) == __grundy(I));     }     cin >> N >> K;     K %= 2;     for (long long I = 0; I < N; I++) {       cin >> A[I];       sol ^= grundy(A[I]);     }     if (sol == 0)       cout <<  Nicky  << endl;     else       cout <<  Kevin  << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<long long int> s(n);     for (int i = 0; i < n; ++i) cin >> s[i];     int q;     cin >> q;     sort(s.begin(), s.end());     int slope0 = 1;     for (int i = 1; i < n; ++i)       if (s[i] != s[i - 1]) ++slope0;     map<long long int, int> freq;     for (int i = 1; i < n; ++i) {       long long int delta = s[i] - s[i - 1];       if (delta == 0) continue;       delta--;       if (freq.find(delta) == freq.end())         freq[delta] = 1;       else         freq[delta] = freq[delta] + 1;     }     map<long long int, int> slope;     map<long long int, long long int> obj;     long long int prev = slope0;     for (map<long long int, int>::iterator it = freq.begin(); it != freq.end();          ++it) {       slope[it->first] = prev - it->second;       prev = prev - it->second;     }     if (slope.find(0) == slope.end()) slope[0] = slope0;     for (map<long long int, int>::iterator it = slope.begin();          it != slope.end();) {       if (it->first == 0) obj[0] = slope0;       long long int y0 = obj[it->first];       long long int change = it->second;       long long int base = it->first;       ++it;       if (it != slope.end()) obj[it->first] = y0 + change * (it->first - base);     }     for (int i = 0; i < q; ++i) {       long long int l, r;       cin >> l >> r;       map<long long int, long long int>::iterator it = obj.lower_bound(r - l);       if (it->first == (r - l))         cout << it->second <<    ;       else {         it--;         long long int ans =             obj[it->first] + (r - l - it->first) * slope[it->first];         cout << ans <<    ;       }     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const long long linf = 0x3f3f3f3f3f3f3f3f;   const int maxn = 2e5 + 11;   const int maxm = 600 + 11;   const int mod = 1e9 + 7;   const double eps = 1e-5;   inline long long rd() {     long long x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline long long qpow(long long a, long long b, long long p) {     long long res = 1;     while (b) {       if (b & 1) {         res *= a;         res %= p;       }       b >>= 1;       a = a * a % p;     }     return res;   }   inline long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   struct node {     long long a, b, c;     bool operator<(const node &o) const {       if (c != o.c) return c > o.c;       if (b != o.b) return b < o.b;       return a > o.a;     }   } t[maxn];   int n, k;   bool check(long long x) {     priority_queue<node> q;     for (int i = 1; i <= n; i++) {       q.push(t[i]);     }     for (int i = 0; i < k; i++) {       node o = q.top();       q.pop();       if (o.c < i) return false;       if (o.c >= k) return true;       o.a += x;       o.c = o.a / o.b;       q.push(o);     }     return true;   }   int main() {     n = rd(), k = rd();     for (int i = 1; i <= n; i++) {       t[i].a = rd();     }     for (int i = 1; i <= n; i++) {       t[i].b = rd();       t[i].c = t[i].a / t[i].b;     }     long long l = 0, r = 5e12, ans = -1;     while (l <= r) {       long long mid = l + r >> 1;       if (check(mid))         ans = mid, r = mid - 1;       else         l = mid + 1;     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double R, r, k;     int tt;     scanf( %d , &tt);     while (tt--) {       scanf( %lf%lf%lf , &R, &r, &k);       double a = (R + r) / (4 * R * r), b = k * (R - r) / (2 * R * r);       double t = (R - r) / (4 * R * r);       double s = t / (a * a + b * b - t * t);       printf( %.9lf n , s);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200007;   string s;   int fa[maxn << 1];   map<string, int> aa;   int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }   string read() {     cin >> s;     return s;   }   int main() {     int n, m, q;     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= 2 * n; i++) fa[i] = i;     for (int i = 1; i <= n; i++) aa[read()] = i;     for (int i = 1; i <= m; i++) {       int t;       scanf( %d , &t);       int x = aa[read()], y = aa[read()];       if (t == 1) {         if (find(x) != find(y + n) && find(x + n) != find(y))           fa[find(x)] = find(y), fa[find(x + n)] = find(y + n), printf( YES n );         else           printf( NO n );       } else {         if (find(x) != find(y) && find(x + n) != find(y + n))           fa[find(x)] = find(y + n), fa[find(x + n)] = find(y), printf( YES n );         else           printf( NO n );       }     }     for (int i = 1; i <= q; i++) {       int x = aa[read()], y = aa[read()];       if (find(x) == find(y))         printf( 1 n );       else if (find(x) == find(y + n))         printf( 2 n );       else         printf( 3 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, string> p;   map<string, string>::iterator it = p.begin();   int main() {     int q;     cin >> q;     while (q--) {       string s1, s2;       cin >> s1 >> s2;       if (!p.count(s1))         p[s2] = s1;       else {         p[s2] = p[s1];         p.erase(s1);       }     }     cout << p.size() << endl;     for (it = p.begin(); it != p.end(); it++)       cout << it->second <<     << it->first << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5;   const long long INF = 1e18;   inline int abs(int x) { return x > 0 ? x : -x; }   inline long long sqr(long long x) { return x * x; }   bool cmp(pair<int, int>& x, pair<int, int>& y) { return x.first < y.first; }   int n;   pair<int, int> p[N];   long long minY[N + 1][2], maxY[N + 1][2];   bool check(long long d) {     long long dY, sqrX, sqrY;     int l = 0, r = 0;     while (r < n) {       while (r < n && sqr((long long)p[r].first - p[l].first) <= d) {         sqrX = max(sqr((long long)p[r].first), sqr((long long)p[l].first));         sqrY = max(max(sqr(maxY[l][0]), sqr(maxY[n - r - 1][1])),                    max(sqr(minY[l][0]), sqr(minY[n - r - 1][1])));         dY = sqr(max(maxY[l][0], maxY[n - r - 1][1]) -                  min(minY[n - r - 1][1], minY[l][0]));         if (max(dY, sqrX + sqrY) <= d) {           if (d < 400) {           }           return true;         }         ++r;       }       while (r < n && l <= r && sqr((long long)p[r].first - p[l].first) > d) ++l;     }     return false;   }   long long solve() {     sort(p, p + n, cmp);     maxY[0][0] = maxY[0][1] = -INF;     minY[0][0] = minY[0][1] = INF;     for (int i = 1; i <= n; ++i) {       maxY[i][0] = max(maxY[i - 1][0], (long long)p[i - 1].second);       maxY[i][1] = max(maxY[i - 1][1], (long long)p[n - i].second);       minY[i][0] = min(minY[i - 1][0], (long long)p[i - 1].second);       minY[i][1] = min(minY[i - 1][1], (long long)p[n - i].second);     }     long long l = 0, r = INF, m;     while (l < r) {       m = (l + r) / 2;       if (check(m))         r = m;       else         l = m + 1;     }     return min(l, sqr((long long)p[n - 1].first - p[0].first));   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d%d , &p[i].first, &p[i].second);     long long ans = solve();     for (int i = 0; i < n; ++i) swap(p[i].first, p[i].second);     ans = min(ans, solve());     printf( %I64d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, n;     long long k, time, maks, tot, ar[10005], ans, temp, m;     bool cek;     scanf( %d %I64d %I64d , &n, &m, &k);     for (i = 0; i < n; ++i) scanf( %I64d , &ar[i]);     if ((n % 2) == 0)       printf( 0 n );     else {       ans = 0;       time = (n + 1) / 2;       if (time > m)         printf( 0 n );       else {         temp = m / time;         maks = temp * k;         ans = ar[0];         for (i = 2; i < n; i += 2) ans = min(ans, ar[i]);         ans = min(ans, maks);         printf( %I64d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string str;   vector<int> graph[26], rgraph[26];   bool visited[26];   bool present[26];   void dfs(int i) {     visited[i] = true;     if (graph[i].size() >= 1 && !visited[graph[i][0]]) dfs(graph[i][0]);     str.insert(str.begin(), (char)( a  + i));   }   void rdfs(int i) {     visited[i] = true;     if (rgraph[i].size() >= 1 && !visited[rgraph[i][0]]) {       str.insert(str.begin(), (char)( a  + rgraph[i][0]));       rdfs(rgraph[i][0]);     }   }   int main() {     int n;     cin >> n;     string s[n];     for (int i = 0; i < n; i++) cin >> s[i];     memset(present, false, sizeof(present));     for (int i = 0; i < n; i++) {       for (int j = 0; j < s[i].length() - 1; j++) {         graph[s[i][j] -  a ].push_back(s[i][j + 1] -  a );         rgraph[s[i][j + 1] -  a ].push_back(s[i][j] -  a );         present[s[i][j] -  a ] = true;       }       present[s[i][s[i].length() - 1] -  a ] = true;     }     memset(visited, 0, sizeof(visited));     for (int i = 0; i < 26; i++) {       if (present[i] && !visited[i]) {         dfs(i);         rdfs(i);       }     }     cout << str;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     int n[t], sum = 0;     for (int i = 0; i < t; i++) {       cin >> n[i];     }     for (int i = 0; i < t; i++) {       if (n[i] % 2 == 0) {         sum = (n[i] / 2) - 1;       } else {         sum = n[i] / 2;       }       cout << sum << endl;     }   }