malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( O2,unroll-loops )   using namespace std;   const long double eps = 1e-7;   const int inf = 1000000010;   const long long INF = 10000000000000010LL;   const int MAXN = 100010, LOG = 20;   long long n, m, K, u, v, X, Y, t, a, b, ans, shit;   long long A[MAXN], f[MAXN], g[MAXN];   long long tav[MAXN];   int h[MAXN];   long long up[MAXN], dwn[MAXN];   int sz[MAXN];   bool dead[MAXN];   vector<int> G[MAXN];   vector<int> v1, v2;   int mp1[MAXN], mp2[MAXN];   int dfs1(int node, int par) {     sz[node] = 1;     for (int v : G[node])       if (!dead[v] && v != par) sz[node] += dfs1(v, node);     return sz[node];   }   int Centroid(int node, int par, int n) {     for (int v : G[node])       if (!dead[v] && v != par && 2 * sz[v] >= n) return Centroid(v, node, n);     return node;   }   void dfs2(int node, int par) {     v2.push_back(node);     h[node] = h[par] + 1;     dwn[node] = (dwn[par] + A[node] * tav[h[node]]) % Y;     up[node] = (K * up[par] + A[node]) % Y;     for (int v : G[node])       if (v != par && !dead[v]) dfs2(v, node);   }   long long powmod(long long a, long long b) {     b %= Y - 1;     if (b < 0) b += Y - 1;     long long res = 1;     for (; b; b >>= 1, a = a * a % Y)       if (b & 1) res = res * a % Y;     return res;   }   void Calc(vector<int> &vec, int w) {     int s1 = 0, s2 = 0;     for (int u : vec) mp1[s1++] = dwn[u];     sort(mp1, mp1 + s1);     for (int v : vec) {       long long tmp = X - up[v];       tmp = tmp * powmod(K, Y - 1 - h[v]) % Y;       if (tmp < 0) tmp += Y;       int gt = upper_bound(mp1, mp1 + s1, tmp) - lower_bound(mp1, mp1 + s1, tmp);       g[v] += gt * w;       mp2[s2++] = tmp;     }     sort(mp2, mp2 + s2);     for (int u : vec) {       int gt =           upper_bound(mp2, mp2 + s2, dwn[u]) - lower_bound(mp2, mp2 + s2, dwn[u]);       f[u] += gt * w;     }   }   void Decompose(int root) {     root = Centroid(root, root, dfs1(root, root));     dead[root] = 1;     up[root] = 0;     dwn[root] = A[root];     h[root] = 0;     v1 = {root};     for (int v : G[root])       if (!dead[v]) {         dfs2(v, root);         Calc(v2, -1);         for (int i : v2) v1.push_back(i);         v2.clear();       }     Calc(v1, +1);     for (int v : G[root])       if (!dead[v]) Decompose(v);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> Y >> K >> X;     tav[0] = 1;     for (int i = 1; i < MAXN; i++) tav[i] = tav[i - 1] * K % Y;     for (int i = 1; i <= n; i++) cin >> A[i];     for (int i = 1; i < n; i++) {       cin >> u >> v;       G[u].push_back(v);       G[v].push_back(u);     }     Decompose(1);     for (int v = 1; v <= n; v++) {       ans += g[v] * (n - g[v]) * 2;       ans += f[v] * (n - f[v]) * 2;       ans += f[v] * (n - g[v]);       ans += g[v] * (n - f[v]);     }     ans /= 2;     ans = n * n * n - ans;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long a, long long b) {     long long res = 1ll;     while (b > 0) {       if (b % 2 != 0) res = (res * a) % 1000000007;       a = (a * a) % 1000000007;       b /= 2;     }     return res % 1000000007;   }   long long ncr(long long n, long long k) {     if (k > n - k) k = n - k;     long long pro = 1;     for (long long i = 0; i < k; i++) {       pro = (pro * (n - i)) % 1000000007;       pro /= (i + 1);     }     return (pro) % 1000000007;   }   void swap(long long *a, long long *b) {     long long temp = *a;     *a = *b;     *b = temp;   }   vector<long long> prime;   void seive() {     vector<bool> isprime(1000001, true);     for (int i = 2; i * i <= 1000000; i++) {       if (isprime[i]) {         for (int j = i * i; j <= 1000000; j += i) {           isprime[j] = false;         }       }     }     for (int i = 2; i <= 1000000; i++) {       if (isprime[i]) prime.push_back(i);     }   }   vector<long long> parent;   long long find(long long p) {     if (parent[p] == p) return parent[p];     return parent[p] = find(parent[p]);   }   void unun(long long a, long long b) {     long long r1 = find(a);     long long r2 = find(b);     if (r1 != r2) parent[r2] = r1;   }   void solve() {     long long n;     cin >> n;     set<long long> s;     s.insert(0);     s.insert(1);     s.insert(n);     for (int i = 1; i * i <= n; i++) {       long long x = (n / i);       long long y = (n / x);       s.insert((n / x));       s.insert((n / y));     }     cout << s.size() <<   n ;     for (auto itr : s) cout << itr <<    ;     cout <<   n ;   }   int main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long x;     cin >> x;     for (long long i = 1; i <= x; i++) {       for (long long j = i; j <= x; j++) {         if (j % i == 0 && i * j > x && j / i < x) {           cout << j <<     << i << endl;           return 0;         }       }     }     cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int tree[1000005 << 2];   int mn[1000005 << 2];   int mx[1000005 << 2];   int pos;   char s[1000005];   void pushup(int rt) {     tree[rt] = tree[(2 * rt)] + tree[(2 * rt + 1)];     mn[rt] = min(mn[(2 * rt)], tree[(2 * rt)] + mn[(2 * rt + 1)]);     mx[rt] = max(mx[(2 * rt)], tree[(2 * rt)] + mx[(2 * rt + 1)]);   }   void update(int rt, int l, int r, int x, int v) {     if (l == r) {       tree[rt] = mn[rt] = mx[rt] = v;       return;     }     if (x <= ((l + r) / 2))       update((2 * rt), l, ((l + r) / 2), x, v);     else       update((2 * rt + 1), ((l + r) / 2) + 1, r, x, v);     pushup(rt);   }   int main() {     scanf( %d , &n);     pos = 1;     scanf( %s , s + 1);     char opt[5];     for (int i = 1; i <= n; ++i) {       opt[1] = s[i];       if (opt[1] ==  R )         ++pos;       else if (opt[1] ==  L ) {         if (pos > 1) --pos;       } else {         if (opt[1] ==  ( )           update(1, 1, n, pos, 1);         else if (opt[1] ==  ) )           update(1, 1, n, pos, -1);         else           update(1, 1, n, pos, 0);       }       if (tree[1] != 0 || mn[1] < 0)         printf( -1  );       else         printf( %d  , mx[1]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f(long long x) {     long long i, j, cnt = 0;     for (i = 1; i <= x; i *= 2) {       for (j = i; j <= x; j *= 3) cnt++;     }     return cnt;   }   int main() {     int l, r;     cin >> l >> r;     cout << f(r) - f(l - 1);   }
#include <bits/stdc++.h>   using namespace std;   int prime[1000100];   void get_prime() {     for (int i = 2; i < 1000100; i++) {       if (!prime[i]) {         for (int j = i * 2; j < 1000100; j += i) {           prime[j] = i;         }       }     }     for (int i = 2; i < 1000100; i++) {       if (!prime[i]) {         prime[i] = 1;       }     }   }   int main() {     get_prime();     int x2;     cin >> x2;     int ans = 0x3f3f3f3f3f;     for (int i = x2 - prime[x2] + 1; i <= x2; i++) {       ans = min(ans, i - prime[i] + 1);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, a, b, x;     cin >> t;     while (t--) {       cin >> x;       if (x % 2 == 0) {         cout << x / 2 <<     << x / 2 << endl;       } else {         cout << 1 <<     << x - 1 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   string FILE_NAME =  testcase.A ;   string NAME;   string itos(int n) {     stringstream ss;     ss << n;     return ss.str();   }   const int dx[] = {0, 1, 0, -1};   const int dy[] = {-1, 0, 1, 0};   bool is_right(vector<pair<int, int> > p) {     vector<int> len2(3, 0);     for (int i = 0; i < (3); i++) {       int x0 = p[i].first, y0 = p[i].second;       int x1 = p[(i + 1) % 3].first, y1 = p[(i + 1) % 3].second;       len2[i] = (x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1);     }     sort(len2.begin(), len2.end());     return ((len2[2] == len2[0] + len2[1]) &&             (sqrt(len2[2]) + 1e-8 < sqrt(len2[0]) + sqrt(len2[1])));   }   bool search_right_triangle(vector<pair<int, int> > p) {     for (int i = 0; i < (3); i++) {       for (int k = 0; k < (4); k++) {         vector<pair<int, int> > q = p;         q[i].first += dx[k];         q[i].second += dy[k];         if (is_right(q)) return true;       }     }     return false;   }   int main() {     vector<pair<int, int> > p(3);     for (int i = 0; i < (3); i++) {       cin >> p[i].first >> p[i].second;     }     if (is_right(p)) {       cout <<  RIGHT  << endl;     } else if (search_right_triangle(p)) {       cout <<  ALMOST  << endl;     } else {       cout <<  NEITHER  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double const e = 0.000001;   int main() {     int n, a, d;     cin >> n >> a >> d;     int prevv = 10000000;     double prevt = 0;     for (int i = 0; i < n; i++) {       int t, v;       cin >> t >> v;       double t1 = (double)v / a;       double s1 = a * t1 * t1 / 2;       double t2 = 0;       if (s1 - d > e) {         t1 = sqrt((2.0 * d) / a);       } else {         double s2 = d - s1;         t2 = s2 / v;       }       double tt = t1 + t2;       if (t + tt - prevt > e) {         prevt = t + tt;         prevv = v;       }       printf( %f n , prevt);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d[333][333], k;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         cin >> d[i][j];       }     }     cin >> k;     while (k--) {       int a = 0, b = 0, c = 0;       cin >> a >> b >> c;       d[a][b] = min(d[a][b], c);       d[b][a] = min(d[b][a], c);       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           d[i][j] = min(d[i][j], d[a][j] + d[i][b] + d[a][b]);           d[i][j] = min(d[i][j], d[b][j] + d[i][a] + d[b][a]);         }       }       long long sum = 0;       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           sum += d[i][j];         }       }       cout << sum / 2 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     long long n;     long long m;     long long k;     cin >> n >> m >> k;     vector<long long> p(m);     for (long long i = 0; i < m; ++i) {       cin >> p[i];     }     long long i = 0;     long long r = ((p[0] + k - 1) / k) * k;     long long cur = 0;     long long cnt = 0;     long long ans = 0;     while (i < m) {       if (p[i] - cur > r && i < m) {         r = ((p[i] - cur + k - 1) / k) * k;       } else {         cnt = 0;         while (i < m && p[i] - cur <= r) {           ++cnt;           ++i;         }         ++ans;         cur += cnt;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double f(double x, double A, double B, double L) {     double y = sqrt(L * L - x * x);     return (A * x + B * y - x * y) / L;   }   int main(void) {     double A, B, L;     scanf( %lf%lf%lf , &A, &B, &L);     if (L <= B) {       printf( %.8f n , min(A, L));       return 0;     } else if (L <= A) {       printf( %.8f n , min(B, L));       return 0;     } else {       double left = 0.0, right = L, ma, mb;       for (int u = 0; u < 500; u++) {         ma = (left * 3 + right) / 4.0;         mb = (left + right * 3) / 4.0;         double fa = f(ma, A, B, L);         double fb = f(mb, A, B, L);         if (fa < fb)           right = mb;         else           left = ma;       }       double ff = f((left + right) / 2.0, A, B, L);       ff = min(ff, L);       ff = min(ff, A);       if (ff < 1e-8)         printf( My poor head =( n );       else         printf( %.8f n , ff);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void run_case() {     int n, k;     cin >> n >> k;     vector<int> A(n);     for (int &a : A) {       cin >> a;     }     vector<int> ans;     for (int i = 1; i < n; i++) {       ans.push_back(A[i - 1] - A[i]);     }     sort(ans.begin(), ans.end());     ;     int res = A[n - 1] - A[0];     for (int i = 0; i < k - 1; i++) {       res += ans[i];     }     cout << res;   }   int main() {     ios_base::sync_with_stdio(false);     int test = 1;     while (test--) {       run_case();       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     string s;     cin >> s;     string final;     long long int id = -1, count = 0, r = 0, l = 0;     for (long long int i = 0; i < (long long int)s.length(); i++) {       if (s[i] ==  # ) {         id = i;         count++;       }       if (s[i] ==  ( ) r++;       if (s[i] ==  ) ) l++;     }     vector<long long int> ans;     for (long long int i = 0; i < (long long int)s.length(); i++) {       if (i == id) {         long long int num = r - l - (count - 1);         if (num <= 0) {           cout << -1 << endl;           return;         }         ans.push_back(num);         while (num--) {           final +=  ) ;         }         i++;       }       if (s[i] ==  ) )         final +=  ) ;       else if (s[i] ==  ( )         final +=  ( ;       if (s[i] ==  # ) {         ans.push_back(1);         final +=  ) ;       }     }     l = 0, r = 0;     for (long long int i = 0; i < (long long int) final.length(); i++) {       if (l > r) {         cout << -1 << endl;         return;       }       if (final[i] ==  ( )         r++;       else         l++;     }     if (l != r) {       cout << -1 << endl;       return;     }     for (long long int i = 0; i < (long long int)ans.size(); i++) {       cout << ans[i] << endl;     }   }   int main() {     long long int t = 1;     for (long long int i = 1; i <= t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> cost[4];   vector<vector<int> > G;   void solve() {     long long n, p, w, d;     cin >> n >> p >> w >> d;     for (long long y = 0; y < w; y++) {       if (p < y * d) continue;       long long wx = p - y * d;       if (wx % w) continue;       long long x = wx / w;       if (x + y > n) continue;       cout << x <<     << y <<     << (n - x - y);       return;     }     cout << -1;   }   int main() {     ios_base::sync_with_stdio(false);     int T;     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6 + 10;   const long long inf = 1e18;   long long n;   long long arr[20];   bool flag = false;   void rec(long long i, long long s) {     if (i == n + 1 && s % 360 == 0) flag = true;     if (i > n) return;     rec(i + 1, s + arr[i]);     rec(i + 1, s - arr[i]);   }   int32_t main() {     cin >> n;     for (long long i = 1; i <= n; i++) cin >> arr[i];     rec(1, 0);     if (flag)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   long long a[1000006], s[1000006];   int main() {     ios_base::sync_with_stdio(false);     long long n, i, j, k;     string st;     cin >> st;     long long ln = st.size();     stack<long long> stk;     for (i = 0; i < ln; i++) {       if (st[i] ==  ( ) {         stk.push(i);       } else {         if (stk.empty()) {           s[i] = -1;         }         if (!stk.empty()) {           long long idx = stk.top();           stk.pop();           if (idx > 0 && st[idx - 1] ==  )  && s[idx - 1] >= 0)             s[i] = s[idx - 1];           else             s[i] = idx;           long long xx = i - s[i] + 1;           a[xx]++;         }       }     }     for (i = 1000005; i >= 0; i--) {       if (a[i] > 0) {         cout << i <<     << a[i] << endl;         return 0;       }     }     cout << 0 <<     << 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, a[110][110], dp[110][110];   bool vis[110][110];   long long dfs(long long x, long long y, long long num) {     if (a[x][y] < num) return (long long)3000000000000000000;     if (x == n - 1 && y == m - 1) return a[x][y] - num;     if (dp[x][y] != -1) return dp[x][y];     long long ret = (long long)3000000000000000000;     if (y + 1 < m) {       ret = min(ret, dfs(x, y + 1, num + 1));     }     if (x + 1 < n) {       ret = min(ret, dfs(x + 1, y, num + 1));     }     return dp[x][y] = min((long long)3000000000000000000, ret + a[x][y] - num);   }   long long solve() {     long long ans = (long long)3000000000000000000;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i][j] - i - j <= a[0][0]) {           memset(dp, -1, sizeof dp);           ans = min(ans, dfs(0, 0, a[i][j] - i - j));         }       }     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     while (t--) {       cin >> n >> m;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           cin >> a[i][j];         }       }       cout << solve() <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long aa;   bool bb;   char ch;   long long scan() {     while (ch = getchar(), (ch <  0  || ch >  9 ) && ch !=  - )       ;     ch ==  -  ? (bb = 1, aa = 0) : (bb = 0, aa = ch - 48);     while (ch = getchar(), (ch >=  0  && ch <=  9 )) aa = aa * 10 + ch - 48;     return (bb ? (-aa) : (aa));   }   inline int Min(int u, int v) { return u < v ? u : v; }   const int INF = 2147483647;   int len_str;   char s[100000], str[100000];   int len[100000];   int pos[100000];   int g[100000][30] = {};   int fail[100000] = {}, sz = 0;   int K[100000], Q;   int n;   int ans[100000];   int set_num = 0, num[100000];   set<int> Set[100000];   queue<int> q;   struct E {     int to, next;   } e[100000];   int last[100000] = {}, tot = 0;   void add(int u, int v) {     e[++tot].next = last[u];     last[u] = tot;     e[tot].to = v;   }   void ins(int p) {     int i, u;     u = 0;     for (i = 0; i < len[p]; ++i) {       s[i] = s[i] -  a ;       if (!g[u][s[i]]) {         g[u][s[i]] = ++sz;       }       u = g[u][s[i]];     }     pos[u] = p;   }   void build_ac() {     int i, u, v;     for (i = 0; i < 26; ++i)       if (g[0][i]) q.push(g[0][i]);     while (!q.empty()) {       u = q.front();       q.pop();       for (i = 0; i < 26; ++i) {         if (g[u][i]) {           v = g[u][i];           q.push(v);           fail[v] = g[fail[u]][i];         } else if (u)           g[u][i] = g[fail[u]][i];       }     }   }   void build_tree() {     for (int i = 1; i <= sz; ++i) add(fail[i], i);   }   void dfs(int u) {     int max_node = u;     for (int i = last[u]; i; i = e[i].next) {       dfs(e[i].to);       if (Set[num[e[i].to]].size() > Set[num[max_node]].size())         max_node = e[i].to;     }     set<int>::iterator j;     for (int i = last[u]; i; i = e[i].next) {       if (e[i].to == max_node) continue;       for (j = Set[num[e[i].to]].begin(); j != Set[num[e[i].to]].end(); j++)         Set[num[max_node]].insert(*j);     }     if (max_node != u) {       for (j = Set[num[u]].begin(); j != Set[num[u]].end(); j++)         Set[num[max_node]].insert(*j);       num[u] = num[max_node];     }     if (pos[u]) {       vector<int> p;       for (j = Set[num[u]].begin(); j != Set[num[u]].end(); j++) p.push_back(*j);       int tmp = INF;       for (int k = K[pos[u]], h = k - 1; h < p.size(); ++h)         tmp = Min(tmp, p[h] - p[h - k + 1]);       if (tmp == INF)         ans[pos[u]] = -1;       else         ans[pos[u]] = tmp + len[pos[u]];     }   }   int main() {     scanf( %s , str);     len_str = strlen(str);     scanf( %d , &Q);     for (int i = 1; i <= Q; ++i) {       scanf( %d , &K[i]);       scanf( %s , s);       len[i] = strlen(s);       ins(i);     }     build_ac();     build_tree();     int u = 0;     for (int i = 0; i < len_str; ++i) {       u = g[u][str[i] -  a ];       if (!num[u]) num[u] = ++set_num;       Set[num[u]].insert(i);     }     dfs(0);     for (int i = 1; i <= Q; ++i) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   int n, k, pos[1000005];   char s[1000005];   struct ac_automaton {     int ch[1000005][26], fail[1000005], arr[1000005], cnt[1000005], totc;     int fir[1000005], nxt[1000005], to[1000005], tot, in[1000005], out[1000005],         block;     void line(int x, int y) {       nxt[++tot] = fir[x];       fir[x] = tot;       to[tot] = y;     }     void update(int x, int d) {       for (int i = x; i <= block; i += i & (-i)) arr[i] += d;     }     int getsum(int x) {       int s = 0;       for (int i = x; i; i -= i & (-i)) s += arr[i];       return s;     }     void insert(char *s, int k) {       int r = 0, v;       for (int i = 0; s[i]; i++) {         v = s[i] -  a ;         if (!ch[r][v]) ch[r][v] = ++totc;         r = ch[r][v];       }       pos[k] = r;     }     int Q[1000005], head, tail;     void build() {       Q[head = 0] = 0, tail = 1;       int r, c;       while (head < tail) {         r = Q[head++];         for (int i = 0; i < 26; i++)           if (c = ch[r][i]) {             Q[tail++] = c;             fail[c] = r ? ch[fail[r]][i] : 0;           } else             ch[r][i] = ch[fail[r]][i];       }       for (int i = 1; i <= totc; i++) line(fail[i], i);     }     void dfs(int u) {       in[u] = ++block;       for (int i = fir[u]; i; i = nxt[i]) dfs(to[i]);       out[u] = block;     }     void modify(int x, int d) {       if (cnt[x] == d) return;       cnt[x] = d;       update(in[x], d);       update(out[x] + 1, -d);     }     int find(char *s) {       int r = 0, v, ans = 0;       for (int i = 0; s[i]; i++) {         v = s[i] -  a ;         r = ch[r][v];         ans += getsum(in[r]);       }       return ans;     }   } A;   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= k; i++) scanf( %s , s), A.insert(s, i);     A.build();     A.dfs(0);     for (int i = 1; i <= k; i++) A.modify(pos[i], 1);     int x;     char c;     for (int i = 1; i <= n; i++) {       getchar(), c = getchar();       if (c ==  ? )         scanf( %s , s), printf( %d n , A.find(s));       else         scanf( %d , &x), A.modify(pos[x], c ==  +  ? 1 : -1);     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = (4000000) + 7;   const int inf = (1e9) + 7;   const long long LLinf = (1e18) + 7;   const long long mod = 1e9 + 7;   int main() {     int n;     scanf( %d , &n);     n++;     n /= 2;     n--;     printf( %d , n);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18 + 5;   const int mod = 1e9 + 7;   const int N = 3 * 1e5 + 5;   int n, c[N], maxOf[N];   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> c[i];       maxOf[c[i]] = i;     }     int last = c[n - 1];     int bb = -1;     for (int i = n - 1; i >= 0; i--) {       if (c[i] != last) {         bb = i;         break;       }     }     assert(bb != -1);     int ans = 0;     for (int i = 0; i < n; i++) {       if (c[i] != last) {         ans = max(ans, n - 1 - i);       } else {         ans = max(ans, bb - i);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int M = 998244353;   void solve() {     long long int a;     cin >> a;     cout << ((a / 2) + 1) << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t = 1;     cin >> t;     while (t--) solve();   }