malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,avx,avx2 )   const long long maxn = 64, mod = 1e9 + 7, INF = 1e9, lg = 15 + 1, SQRT = 400;   int n, a[maxn], par[maxn], SZ_T[maxn], FAC[maxn], INV[maxn];   vector<int> adj1[maxn], adj2[maxn], cmp;   long long dp[(1 << lg)][maxn], ans[maxn];   bool mark[maxn];   inline long long power(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) {         res = (res * a) % mod;       }       b /= 2;       a = (a * a) % mod;     }     return res;   }   inline void make_graph() {     sort(a, a + n);     for (int i = 0; i < n; ++i) {       for (int j = i + 1; j < n; ++j) {         if (a[j] % a[i] == 0) {           adj1[i].push_back(j);           adj1[j].push_back(i);         }       }     }   }   void dfs(int v) {     mark[v] = 1;     cmp.push_back(a[v]);     for (auto u : adj1[v]) {       if (!mark[u]) {         dfs(u);       }     }   }   inline void get(int cnt) {     memset(dp, 0, sizeof dp);     sort(cmp.begin(), cmp.end());     vector<int> s, t;     for (int i = 0; i < cmp.size(); ++i) {       bool is = 0;       for (int j = 0; j < i; ++j) {         if (cmp[i] % cmp[j] == 0) is = 1;       }       if (!is) {         s.push_back(cmp[i]);       } else {         t.push_back(cmp[i]);       }     }     for (int i = 0; i < t.size(); ++i) {       par[i] = 0;       for (int j = 0; j < s.size(); ++j) {         if (t[i] % s[j] == 0) {           par[i] |= (1 << j);         }       }     }     SZ_T[cnt] = t.size();     if (!t.size()) {       ans[cnt] = 1;       return;     }     for (int i = 0; i < t.size(); ++i) {       dp[par[i]][1]++;     }     for (int mask = 0; mask < (1 << s.size()); ++mask) {       for (int i = 0; i < t.size(); ++i) {         int counter = 0;         for (int j = 0; j < t.size(); ++j) {           if ((mask | par[j]) == mask) {             counter++;           } else if (mask & par[j]) {             dp[mask | par[j]][i + 1] =                 (dp[mask][i] + dp[mask | par[j]][i + 1]) % mod;           }         }         if (counter > i)           dp[mask][i + 1] =               (dp[mask][i + 1] + (dp[mask][i] * (counter - i)) % mod) % mod;       }     }     ans[cnt] = dp[(1 << s.size()) - 1][t.size()];   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     FAC[0] = INV[0] = 1;     for (int i = 1; i < maxn; ++i) {       FAC[i] = (FAC[i - 1] * i) % mod;       INV[i] = power(FAC[i], mod - 2);     }     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     make_graph();     int cnt = 0;     for (int i = 0; i < n; ++i) {       if (!mark[i]) {         dfs(i);         get(cnt);         cnt++;         cmp.clear();       }     }     long long res = 1, SZ = 0;     for (int i = 0; i < cnt; ++i) {       res = (res * ans[i]) % mod;       SZ += max(SZ_T[i] - 1, 0);     }     long long h = FAC[SZ];     for (int i = 0; i < cnt; ++i) {       h = (h * INV[max(SZ_T[i] - 1, 0)]) % mod;     }     res = (res * h) % mod;     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, s = 0, c = 0;     cin >> n;     for (long long int i = 0; i < n; i++) {       long long x;       cin >> x;       s += x;       if (x % 2 != 0) c = 1;     }     if (s % 2 != 0) {       cout <<  First ;     } else {       if (c)         cout <<  First ;       else         cout <<  Second ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, d, moves = 0;     int* b;     cin >> n >> d;     b = new int[n];     cin >> b[0];     for (int i = 1; i < n; i++) {       cin >> b[i];       if (b[i] <= b[i - 1]) {         int time = (b[i - 1] - b[i]) / d + 1;         b[i] += time * d;         moves += time;       }     }     delete[] b;     cout << moves;   }
#include <bits/stdc++.h>   using std::cerr;   using std::endl;   const int N = 2005, INF = 1e9, P = 998244353;   int n, G[N][N];   char str[N];   int deg[N];   inline int binom(int x) { return x * (x - 1) / 2; }   inline bool check() {     std::sort(deg + 1, deg + n + 1);     int sum = 0;     for (int i = 1; i < n; ++i) {       sum += deg[i];       if (sum == binom(i)) return 0;     }     return 1;   }   namespace SOL1 {   inline bool Check(int s) {     for (int i = 1; i <= n; ++i) deg[i] = 0;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j) {         int cnt = ((s >> (i - 1)) & 1) + ((s >> (j - 1)) & 1);         if (cnt == 1) {           if (G[i][j]) ++deg[i];         } else {           if (G[j][i]) ++deg[i];         }       }     return check();   }   inline void solve() {     int min = INF, cnt = 0;     for (int s = 0; s < 1 << n; ++s) {       if (__builtin_popcount(s) > min) continue;       if (Check(s)) {         if (__builtin_popcount(s) < min) min = __builtin_popcount(s), cnt = 0;         if (__builtin_popcount(s) == min) {           ++cnt;         }       }     }     if (min == INF)       puts( -1 );     else {       for (int i = 1; i <= min; ++i) cnt = 1ll * cnt * i % P;       printf( %d %d n , min, cnt);     }   }   }  // namespace SOL1   namespace SOL2 {   int buc[N];   inline void solve() {     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j)         if (G[j][i]) ++deg[i], ++buc[i];     if (check()) {       std::cout << 0 <<     << 1 << std::endl;       return;     }     int cnt = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) deg[j] = buc[j];       for (int j = 1; j <= n; ++j) {         if (G[j][i]) --deg[i], ++deg[j];         if (G[i][j]) ++deg[i], --deg[j];       }       cnt += check();     }     std::cout << 1 <<     << cnt << std::endl;   }   }  // namespace SOL2   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %s , str + 1);       for (int j = 1; j <= n; ++j) G[i][j] = str[j] -  0 ;     }     if (n <= 6)       SOL1::solve();     else       SOL2::solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class TaskD {    public:     unsigned long long compute(vector<pair<int, int> >& a,                                const vector<unsigned long long>& tag) {       vector<pair<int, int> > events;       for (int i = 0; i < a.size(); ++i) {         events.emplace_back(a[i].first, -(i + 1));         events.emplace_back(a[i].second, i + 1);       }       sort(events.begin(), events.end());       unsigned long long sum = 0;       unsigned long long res = 0;       for (const auto& e : events) {         if (e.second < 0) {           res += sum * tag[-e.second - 1];           sum += tag[-e.second - 1];         } else {           sum -= tag[e.second - 1];         }       }       return res;     }     void solveOne(istream& in, ostream& out) {       auto seed = std::chrono::system_clock::now().time_since_epoch().count();       mt19937 rng(seed);       uniform_int_distribution<unsigned long long> distrib;       int n;       in >> n;       vector<pair<int, int> > a(n);       vector<pair<int, int> > b(n);       vector<unsigned long long> tag(n);       for (int i = 0; i < n; ++i) {         in >> a[i].first >> a[i].second >> b[i].first >> b[i].second;         tag[i] = distrib(rng) * 2 + 1;       }       auto ha = compute(a, tag);       auto hb = compute(b, tag);       if (ha == hb) {         out <<  YES n ;       } else {         out <<  NO n ;       }     }     void solve(std::istream& in, std::ostream& out) {       int nt = 1;       for (int it = 0; it < nt; ++it) {         solveOne(in, out);       }     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     TaskD solver;     std::istream& in(std::cin);     std::ostream& out(std::cout);     solver.solve(in, out);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, res, t, k, o;   long long a[1000100], b[1000100];   priority_queue<int, vector<int>, greater<int> > q;   int main() {     scanf( %lld %lld , &n, &k);     for (long long i = 1; i <= n; i++) {       scanf( %lld , &a[i]);     }     scanf( %lld , &m);     for (long long i = 1; i <= n; i++) {       scanf( %lld , &b[i]);     }     res = 0;     for (int i = 1; i <= n; i++) {       q.push(b[i]);       while (k < a[i] && !q.empty()) {         k = k + m;         res += q.top();         q.pop();       }       if (k < a[i]) {         res = -1;         break;       }     }     printf( %lld n , res);   }
#include <bits/stdc++.h>   using namespace std;   long long mod_v(long long num) {     if (num >= 0)       return (num % 1000000007);     else       return (num % 1000000007 + 1000000007) % 1000000007;   }   long long bigmod(long long b, long long p, long long m) {     long long res = 1 % m, x = b % m;     while (p) {       if (p & 1) res = (res * x) % m;       x = (x * x) % m;       p >>= 1;     }     return res;   }   class node {    public:     int s, w;     node(){};     node(int s, int w) {       this->s = s;       this->w = w;     };   };   bool operator<(node a, node b) {     if (a.w < b.w)       return true;     else       return false;   }   bool vol[100005] = {0};   int vis[100005] = {0};   vector<int> adj[100005];   int n;   bool solve(int q, int s, int d) {     memset(vis, 0, sizeof(vis));     vis[s] = q;     priority_queue<node> pq;     pq.push(node(s, q));     while (!pq.empty()) {       s = pq.top().s;       pq.pop();       if (s == d) return true;       for (int i = 0, ns; i < adj[s].size(); i++) {         ns = adj[s][i];         if (ns == d) return true;         if (vol[ns] == 1 && vis[ns] < q) {           vis[ns] = q;           pq.push(node(ns, vis[ns]));         } else if (vis[ns] < vis[s] - 1) {           vis[ns] = vis[s] - 1;           pq.push(node(ns, vis[ns]));         }       }     }     return false;   }   int main() {     int m, k, u, v, s, d;     scanf( %d %d %d , &n, &m, &k);     for (int i = 1; i <= k; i++) {       scanf( %d , &u);       vol[u] = 1;     }     for (int i = 1; i <= m; i++) {       scanf( %d %d , &u, &v);       adj[u].push_back(v);       adj[v].push_back(u);     }     scanf( %d %d , &s, &d);     int l = 1, r = n, mid;     while (l < r) {       mid = (l + r) / 2;       if (solve(mid, s, d))         r = mid;       else         l = mid + 1;     }     if (l == n)       printf( -1 n );     else       cout << l << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[3000], b[3000], w[500], pos[500][5000], ans;   string second;   int ispal(int x, int y) {     int t = y;     while (x != y) {       if (second[x] != second[y]) return 0;       if (y - x == 1 || y - x == 2) {         b[t]++;         return 1;       }       x++, y--;     }   }   int main() {     cin >> second;     for (int i = second.size() - 1; i >= 0; i--) {       a[i] = a[i + 1] + 1;       for (int j = 0; j < w[second[i] - 97]; j++) {         a[i] += ispal(i, pos[second[i] - 97][j]);       }       pos[second[i] - 97][w[second[i] - 97]] = i;       w[second[i] - 97]++;     }     for (int i = 0; i < second.size() - 1; i++) {       b[i]++;       ans += b[i] * a[i + 1];     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, int> Id;   char Name[107][15], Str[107][150];   int dp[107][107], last[107][107], record[107][107], vis[107];   void Show(int Step, int k) {     if (Step - 1) Show(Step - 1, last[Step][k]);     int pos = 0;     while (Str[Step][pos] !=  : ) pos++;     printf( %s%s n , Name[k], Str[Step] + pos);   }   bool Judge(char t) {     if (t >=  a  && t <=  z )       return true;     else if (t >=  A  && t <=  Z )       return true;     else if (t >=  0  && t <=  9 )       return true;     else       return false;   }   int main() {     int t, n, m;     string tmp;     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       Id.clear();       for (int i = 1; i <= n; i++) {         scanf( %s , Name[i]);         Id[string(Name[i])] = i;       }       memset(record, 0, sizeof(record));       memset(vis, 0, sizeof(vis));       scanf( %d , &m);       getchar();       for (int i = 1; i <= m; i++) {         gets(Str[i]);         int pos = 0;         if (Str[i][0] !=  ? ) {           while (Str[i][pos] !=  : ) pos++;           int re = Id[string(Str[i], pos)];           record[i][re] = 1;           vis[re] = 1;           continue;         } else {           for (int j = 1; j <= n; j++) record[i][j] = 1;           while (1) {             while (!Judge(Str[i][pos]) && Str[i][pos]) pos++;             if (Str[i][pos] ==   0 ) break;             int tt = pos;             while (Judge(Str[i][pos])) pos++;             int re = Id[string(Str[i], tt, pos - tt)];             if (re || vis[re]) record[i][re] = 0;           }         }       }       memset(dp, 0, sizeof(dp));       memset(last, 0, sizeof(last));       for (int i = 1; i <= m; i++) {         if (i == 1) {           for (int j = 1; j <= n; j++) dp[i][j] = record[i][j];         } else {           for (int j = 1; j <= n; j++) {             if (!record[i][j]) continue;             for (int k = 1; k <= n; k++) {               if (j == k || !dp[i - 1][k]) continue;               last[i][j] = k;               dp[i][j] = 1;             }           }         }       }       int flag = true;       for (int i = 1; i <= n; i++) {         if (dp[m][i]) {           Show(m, i);           flag = false;           break;         }       }       if (flag) printf( Impossible n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100000 + 10;   const int INF = 1000000000;   const int MOD = (int)(1e9) + 7;   int main() {     int n;     cin >> n;     int m = (1 << (n + 1)) - 1;     vector<int> a(m + 10, 0);     for (int i = 2; i <= m; i++) cin >> a[i];     vector<int> s(m + 10, 0), c(m + 10, 0), add(m + 10, 0);     int l = 0;     for (int i = 2; i <= m; i++) {       s[i] = s[i / 2] + a[i];       l = max(l, s[i]);     }     for (int i = m; i >= 1; i--) {       if (i + i + 1 > m)         c[i] = s[i];       else         c[i] = max(c[i + i], c[i + i + 1]);     }     int res = 0;     for (int i = 2; i <= m; i++) {       int cur = c[i] + add[i / 2];       int inc = l - cur;       add[i] = add[i / 2] + inc;       res += inc;     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   void test_case() {     int n;     long long k;     cin >> n >> k;     int l, r[2] = {-1, -1};     long long curr[2] = {k, k}, ans[2] = {0, 0}, monsters;     for (int i = 0; i < n; i++) {       int old_r[2] = {r[0], r[1]}, tmp_r;       long long old_curr[2] = {curr[0], curr[1]}, old_ans[2] = {ans[0], ans[1]};       cin >> l >> tmp_r >> monsters;       ans[0] = -1;       for (int j = 0; j < 2; j++) {         if (old_ans[j] == -1) continue;         if (old_curr[j] + (tmp_r - l) * k < monsters) continue;         if (ans[0] != -1 && ans[0] < old_ans[j] + monsters) continue;         ans[0] = old_ans[j] + monsters;         if (old_curr[j] >= monsters) {           r[0] = l;           curr[0] = old_curr[j] - monsters;         } else {           int turns = (monsters - old_curr[j] + k - 1) / k;           r[0] = l + turns;           curr[0] = k * turns + old_curr[j] - monsters;         }       }       ans[1] = -1;       for (int j = 0; j < 2; j++) {         if (old_ans[j] == -1) continue;         if ((tmp_r - l + 1) * k < monsters) continue;         if (old_r[j] == l) continue;         if (ans[1] != -1 && ans[1] < old_ans[j] + old_curr[j] + monsters)           continue;         ans[1] = old_ans[j] + old_curr[j] + monsters;         int turns = (monsters + k - 1) / k;         r[1] = l + turns - 1;         curr[1] = k * turns - monsters;       }     }     if (ans[0] == -1)       cout << ans[1] <<   n ;     else if (ans[1] == -1)       cout << ans[0] <<   n ;     else       cout << min(ans[0], ans[1]) <<   n ;   }   int main(void) {     ios::sync_with_stdio(0);     cin.tie(0);     int Case = 1;     for (int i = 0; i < Case; i++) {       test_case();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int r, c, n, k, x, y;   int flag[101][101];   int main() {     cin >> r >> c >> n >> k;     for (int i = 0; i < n; i++) {       cin >> x >> y;       flag[x][y] = 1;     }     int cnt = 0;     for (int i = 1; i <= r; i++) {       for (int i1 = 1; i1 <= c; i1++) {         for (int i2 = 1; i2 <= r; i2++) {           for (int i3 = 1; i3 <= c; i3++) {             int sum = 0;             for (int i5 = i; i5 <= i2; i5++) {               for (int i6 = i1; i6 <= i3; i6++) {                 if (flag[i5][i6] == 1) sum++;               }             }             if (sum >= k) cnt++;           }         }       }     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int MAX = 1e5 + 55;   const int INF = 1e9 + 77;   const long long INFINF = 1e18 + 1e17;   const double PI = acos(-1.0);   long long power(long long x, long long y) {     if (y == 0) return 1;     long long s = power(x, y / 2);     s *= s;     if (y & 1) s *= x;     return s;   }   int n;   long long e[4000][4000];   long long dis[4000];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     int node = 1;     for (int p = 1; p <= ((1 << n + 1) - 1) / 2; p++) {       int dis1;       int dis2;       cin >> dis1;       cin >> dis2;       e[node * 2][node] = dis1;       e[node * 2 + 1][node] = dis2;       node++;     }     long long ans = 0;     node = ((1 << n + 1) - 1);     while (node != 1) {       int node1 = node;       int node2 = node - 1;       int par = node / 2;       int max1 = dis[node1] + e[node1][par];       int max2 = dis[node2] + e[node2][par];       dis[par] = max(max1, max2);       ans += (dis[par] - min(max1, max2));       node -= 2;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Int() {     int x;     scanf( %d , &x);     return x;   }   long long Long() {     long long x;     scanf( %lld , &x);     return x;   }   void err(istream_iterator<string> it) { cout << endl; }   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {     cerr << *it <<   =   << a <<    ;     err(++it, args...);   }   const int N = (int)2e5 + 5;   const int maxN = (int)1e6 + 6;   const long long Mod = (long long)1e9 + 7;   const int inf = (int)2e9;   const long long Inf = (long long)1e18;   int deg[N], vis[N];   vector<int> g[N];   int par[N];   int Find(int s) { return par[s] == s ? s : Find(par[s]); }   int main() {     int test = 1, tc = 0;     while (test--) {       int n = Int(), m = Int(), mx = 0, node = 0;       for (int i = 1; i <= m; ++i) {         int x = Int(), y = Int();         deg[x]++, deg[y]++;         if (deg[x] > mx) {           mx = deg[x], node = x;         }         if (deg[y] > mx) {           mx = deg[y], node = y;         }         g[x].push_back(y);         g[y].push_back(x);       }       priority_queue<pair<int, int> > pp;       pp.push({mx, node});       while (!pp.empty()) {         pair<int, int> c = pp.top();         pp.pop();         vis[c.second] = 1;         for (int i : g[c.second]) {           if (vis[i]) continue;           printf( %d %d n , i, c.second);           vis[i] = 1;           pp.push({deg[i], i});         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   string s, t;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> t;     int ph = 0;     pair<int, int> mh = {0, 0};     for (int i = 0; i < n; i++) {       if (t[i] ==  ( )         ph++;       else         ph--;       mh = min(mh, make_pair(ph, i + 1));     }     if (ph != 0) {       cout <<  0 n1 1 n ;       return 0;     }     string s;     for (int i = mh.second; i < n; i++) {       s.push_back(t[i]);     }     for (int i = 0; i < mh.second; i++) {       s.push_back(t[i]);     }     int shift = mh.second;     int h = 0, cnt = 0, one = 0, two = 0, piv = 0, piv2 = -1;     pair<int, pair<int, int>> opt = {-1, {-1, -1}};     pair<int, pair<int, int>> opt2 = {-1, {-1, -1}};     for (int i = 0; i < n; i++) {       if (s[i] ==  ( )         h++;       else         h--;       if (h == 0) {         cnt++;         opt = max(opt, make_pair(one, make_pair(piv, i)));         one = 0;         piv = i + 1;         piv2 = -1;       } else if (h == 1) {         one++;         if (piv2 != -1) opt2 = max(opt2, make_pair(two, make_pair(piv2, i)));         two = 0;         piv2 = i + 1;       } else if (h == 2)         two++;     }     if (opt.first <= cnt + max(0, opt2.first)) {       if (opt2.first == -1) {         cout << cnt <<   n1 1 n ;         return 0;       }       cout << cnt + opt2.first <<   n ;       cout << (opt2.second.first + shift) % n + 1 <<    ;       cout << (opt2.second.second + shift) % n + 1 <<   n ;       return 0;     }     cout << opt.first <<   n           << (opt.second.first + shift) % n + 1 <<              << (opt.second.second + shift) % n + 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int main() {     int t;     cin >> t;     while (t--) {       cin >> s;       int n = s.length();       if (s[n - 2] ==  p  && s[n - 1] ==  o ) {         cout <<  FILIPINO  << endl;       } else if (s[n - 1] ==  u  && s[n - 2] ==  s  &&                  (s[n - 3] ==  e  || s[n - 3] ==  a ) &&                  (s[n - 4] ==  d  || s[n - 4] ==  m )) {         cout <<  JAPANESE  << endl;       } else {         cout <<  KOREAN  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   const int INF = 1e9, MOD = INF - 1755647;   int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }   int power(int a, int b) {     return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1));   }   int mod(int a) { return (a % MOD + MOD) % MOD; }   const int N = 2e5 + 20;   struct node {     int val = 0;     bool marked = false;     vector<int> adj;   };   int a[N];   node g[N];   set<int> ans;   void run(int src) {     g[src].marked = true;     queue<int> q;     q.push(src);     while (!q.empty()) {       int v = q.front();       q.pop();       g[v].val++;       ans.insert(v);       for (int u : g[v].adj) {         g[u].val++;         if (!g[u].marked && g[u].val == a[u]) q.push(u);       }     }   }   int32_t main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int v, u;       cin >> v >> u;       g[v].adj.push_back(u);       g[u].adj.push_back(v);     }     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++)       if (g[i].val == a[i]) run(i);     cout << ans.size() <<   n ;     for (int v : ans) cout << v <<    ;     cout <<   n ;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   int main()   {         ios_base::sync_with_stdio(false);    cin.tie(NULL);    cout.tie(NULL);    int t;    cin>>t;    while(t--)    {     int n;     cin>>n;     string a;     cin>>a;     if(a[0]== 2 &&a[1]== 0 &&a[2]== 2 &&a[3]== 0 )     cout<< YES <<  n ;     else if(a[n-4]== 2 &&a[n-3]== 0 &&a[n-2]== 2 &&a[n-1]== 0 )     cout<< YES <<  n ;     else if(a[0]== 2 &&a[1]== 0 &&a[2]== 2 &&a[n-1]== 0 )     cout<< YES <<  n ;     else if(a[0]== 2 &&a[1]== 0 &&a[n-2]== 2 &&a[n-1]== 0 )     cout<< YES <<  n ;     else if(a[0]== 2 &&a[n-3]== 0 &&a[n-2]== 2 &&a[n-1]== 0 )     cout<< YES <<  n ;     else     cout<< NO <<  n ;    }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000000 + 10;   char b[maxn];   int a[maxn];   int ccc[20];   int main() {     long long n;     long long sum = 0;     cin >> n;     if (n % 2 == 0)       sum = n / 2;     else       sum = (-n - 1) / 2;     cout << sum << endl;     return 0;   }