malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int x[1000], y[1000], k, n, m;   bool chck(int xx) {     vector<int> v;     v.push_back(1);     v.push_back(m);     for (int i = 0; i < k; ++i) {       v.push_back(max(1, x[i] - xx));       v.push_back(max(1, x[i] - xx - 1));       v.push_back(min(m, x[i] + xx));       v.push_back(min(m, x[i] + xx + 1));     }     sort(v.begin(), v.end());     int mn = 1e9, mx = -1, tmp, nm, c;     bool l;     vector<pair<int, int> > f;     for (int i = 0; i < v.size(); ++i) {       tmp = v[i];       f.clear();       for (int j = 0; j < k; ++j) {         if (x[j] - xx <= tmp && x[j] + xx >= tmp) {           f.push_back(make_pair(max(1, y[j] - xx), 0));           f.push_back(make_pair(min(n, y[j] + xx), 1));         }       }       sort(f.begin(), f.end());       c = 0;       nm = 0;       l = 0;       for (int j = 0; j < f.size(); ++j) {         if (nm == 0) {           if (f[j].first != c + 1) {             break;           }         }         c = f[j].first;         if (f[j].second == 0)           ++nm;         else           --nm;         if (c == n) {           l = 1;           break;         }       }       if (!l) {         mn = min(mn, tmp);         mx = max(mx, tmp);       }     }     mx = min(mx, m);     mn = max(1, mn);     if (mx - mn + 1 > xx + xx + 1) {       return 0;     }     v.clear();     v.push_back(1);     v.push_back(n);     for (int i = 0; i < k; ++i) {       v.push_back(max(1, y[i] - xx));       v.push_back(max(1, y[i] - xx - 1));       v.push_back(min(n, y[i] + xx));       v.push_back(min(n, y[i] + xx + 1));     }     sort(v.begin(), v.end());     mn = 1e9, mx = -1;     for (int i = 0; i < v.size(); ++i) {       tmp = v[i];       f.clear();       for (int j = 0; j < k; ++j) {         if (y[j] - xx <= tmp && y[j] + xx >= tmp) {           f.push_back(make_pair(max(1, x[j] - xx), 0));           f.push_back(make_pair(min(m, x[j] + xx), 1));         }       }       sort(f.begin(), f.end());       c = 0;       nm = 0;       l = 0;       for (int j = 0; j < f.size(); ++j) {         if (nm == 0) {           if (f[j].first != c + 1) {             break;           }         }         c = f[j].first;         if (f[j].second == 0)           ++nm;         else           --nm;         if (c == m) {           l = 1;           break;         }       }       if (!l) {         mn = min(mn, tmp);         mx = max(mx, tmp);       }     }     mx = min(mx, n);     mn = max(1, mn);     if (mx - mn + 1 > xx + xx + 1) {       return 0;     }     return 1;   }   int main() {     while (cin >> m >> n >> k) {       for (int i = 0; i < k; ++i) {         scanf( %d%d , &x[i], &y[i]);       }       int st = 0, nd = 1e9, md;       while (st < nd) {         md = (st + nd) / 2;         if (chck(md)) {           nd = md;         } else {           st = md + 1;         }       }       printf( %d n , nd);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cansel_sync = (ios::sync_with_stdio(0), cin.tie(0), 0);   const int N = 200010;   const int inf = ~0u >> 2;   const long long INF = ~0ull >> 2;   long long read() {     long long x;     if (scanf( %lld , &x) == -1) exit(0);     return x;   }   const double pi = acos(-1.0);   double readf() {     double x;     if (scanf( %lf , &x) == -1) exit(0);     return x;   }   template <typename T>   T sqr(const T &x) {     return x * x;   }   int mod = (1 ? 1000000007 : 998244353);   long long mul(long long a, long long b, long long m = mod) { return a * b % m; }   long long qpow(long long a, long long b, long long m = mod) {     long long ans = 1;     for (; b; a = mul(a, a, m), b >>= 1)       if (b & 1) ans = mul(ans, a, m);     return ans;   }   long long getinv(long long v, long long m = mod) { return qpow(v, m - 2, m); }   long long n, x, t, l, r, sum;   void solve() {     cin >> n >> x;     sum = 0;     l = inf, r = -inf;     for (long long i = (0), _ = (n); i < _; i++) {       cin >> t;       if (t % x != 0) l = min(l, i), r = max(r, i);       sum += t % x;     }     if (sum % x != 0) {       cout << n << endl;       return;     }     if (l != inf) {       cout << max(n - l - 1, r) << endl;       return;     }     cout << -1 << endl;   }   signed main() {     long long T;     cin >> T;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1E5;   vector<int> vf, vz;   int main() {     ios_base::sync_with_stdio(false);     int n, k, p;     cin >> n >> k >> p;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       if (x % 2 == 0)         vz.push_back(x);       else         vf.push_back(x);     }     int tf = vf.size(), tz = vz.size();     if (tf < (k - p) || p > tz + (tf - (k - p)) / 2 || (k - p) % 2 != tf % 2)       cout <<  NO ;     else {       if ((tf - (k - p)) % 2 == 1) {         cout <<  NO ;       }       if ((tf - (k - p)) % 2 == 0) {         cout <<  YES  << endl;         if (p == 0) {           for (int i = 0; i < k - 1; i++) cout <<  1   << vf[i] << endl;           cout << tf - (k - 1) + tz;           for (int i = k - 1; i < tf; i++) cout <<     << vf[i];           for (int i = 0; i < tz; i++) cout <<     << vz[i];           cout << endl;         } else if (tz >= p) {           for (int i = 0; i < p - 1; i++) cout <<  1   << vz[i] << endl;           cout << tz - p + 1 + tf - (k - p);           for (int i = p - 1; i < tz; i++) cout <<     << vz[i];           for (int i = 0; i < tf - (k - p); i++) cout <<     << vf[i];           cout << endl;           for (int i = tf - (k - p); i < tf; i++) cout <<  1   << vf[i] << endl;         } else {           for (int i = 0; i < tz; i++) cout <<  1   << vz[i] << endl;           for (int i = 0; i < (p - tz) - 1; i++)             cout <<  2   << vf[i * 2] <<     << vf[i * 2 + 1] << endl;           cout << tf - (p - tz - 1) * 2 - (k - p);           for (int i = (p - tz - 1) * 2; i < tf - (k - p); i++)             cout <<     << vf[i];           cout << endl;           for (int i = tf - (k - p); i < tf; i++) cout <<  1   << vf[i] << endl;         }       }     }   }
#include <bits/stdc++.h>   int dx[] = {-1, -1, -1, 0, 1, 1, 1, 0};   int dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};   using namespace std;   long long power(long long a, long long p, long long M) {     long long r = 1;     a = a % M;     while (p > 0) {       if (p % 2) r = (r * a) % M;       a = (a * a) % M;       p /= 2;     }     return r;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long n, m;   set<long long> e[100005];   stack<long long> cycle, temp;   long long vis[505];   bool found;   void findCycle(long long x) {     temp.push(x);     vis[x] = 1;     for (auto y : e[x]) {       if (vis[y] == 0)         findCycle(y);       else if (vis[y] == 1) {         if (found) return;         cycle = temp;         cycle.push(y);         found = 1;         return;       }     }     if (!temp.empty()) temp.pop();     vis[x] = 2;   }   void fc(long long x) {     vis[x] = 1;     for (auto y : e[x]) {       if (vis[y] == 0)         fc(y);       else if (vis[y] == 1) {         found = 1;         return;       }     }     vis[x] = 2;   }   void solve() {     cin >> n >> m;     for (long long i = 0; i < m; i++) {       long long a, b;       scanf( %lld%lld , &a, &b);       e[a].insert(b);     }     for (long long i = 1; i < n + 1; i++) {       if (!vis[i]) {         findCycle(i);         if (found) break;       }     }     if (!found) {       cout <<  YES n ;       return;     }     vector<long long> c;     for (long long i = 0; i < 505; i++) vis[i] = 0;     while (!cycle.empty()) {       c.push_back(cycle.top());       if (vis[cycle.top()]) {         break;       }       vis[cycle.top()] = 1;       cycle.pop();     }     reverse(c.begin(), c.end());     for (long long i = 0; i < c.size() - 1; i++) {       found = 0;       e[c[i]].erase(c[i + 1]);       for (long long j = 0; j < 505; j++) vis[j] = 0;       for (long long j = 1; j < n + 1; j++) {         if (!vis[j]) fc(j);         if (found) {           break;         }       }       if (!found) {         cout <<  YES n ;         return;       }       e[c[i]].insert(c[i + 1]);     }     cout <<  NO n ;   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long A, B, N;   long long L, T, M;   bool ok(long long R) {     long long mx = A + (R - 1) * B;     long long mn = A + (L - 1) * B;     long long D = R - L;     if (mx > T) return false;     return (mn * (D + 1) + B * D * (D + 1) / 2) <= T * M;   }   int main(void) {     cin >> A >> B >> N;     while (N--) {       cin >> L >> T >> M;       long long R = L;       long long mn = A + (L - 1) * B;       if (mn > T) {         R = -1;       } else {         long long XR = 1LL << 22;         while (XR > R) {           long long m = (R + XR) / 2;           if (!ok(m))             XR = m;           else             R = m + 1;         }         R -= 1;       }       cout << R <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9 + 7, mod = 1e9 + 9, pw = 31;   const double eps = 1e-11;   long long binpow(long long a, long long b) {     long long rec = 1;     while (b) {       if (b % 2 == 1) {         rec *= a;         rec %= INF;       }       a *= a;       a %= INF;       b /= 2;     }     return rec;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     int n;     cin >> n;     long long x = binpow(3, n * 3) - binpow(7, n);     if (x < 0) x += INF;     cout << x;     return 0;   }
#include <bits/stdc++.h>   const long long INF64 = 1e18;   using namespace std;   const long long N = 2e5 + 6;   using namespace std;   vector<pair<long long, long long>> pf;   int main() {     long long n, ans = INF64;     cin >> n;     vector<long long> cost(n, 0);     vector<string> s;     for (int i = 0; i < n; i++) cin >> cost[i];     for (int i = 0; i < n; i++) {       string st;       cin >> st;       s.push_back(st);     }     vector<vector<long long>> dp(n, vector<long long>(2, INF64));     dp[n - 1][0] = 0;     dp[n - 1][1] = cost[n - 1];     for (int i = n - 2; i >= 0; i--) {       string currStr(s[i]), currrevStr(s[i]);       string prevStr(s[i + 1]), prevrevStr(s[i + 1]);       reverse(currrevStr.begin(), currrevStr.end());       reverse(prevrevStr.begin(), prevrevStr.end());       if (currStr.compare(prevStr) <= 0) dp[i][0] = min(dp[i][0], dp[i + 1][0]);       if (currStr.compare(prevrevStr) <= 0)         dp[i][0] = min(dp[i][0], dp[i + 1][1]);       if (currrevStr.compare(prevStr) <= 0)         dp[i][1] = min(dp[i][1], dp[i + 1][0] + cost[i]);       if (currrevStr.compare(prevrevStr) <= 0)         dp[i][1] = min(dp[i][1], dp[i + 1][1] + cost[i]);     }     ans = min(ans, min(dp[0][0], dp[0][1]));     if (ans == INF64)       cout << -1;     else       cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100005], n, c, mn[100005], dp[200005], sum;   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> c;     for (int i = 0; i < n; sum += a[i++]) cin >> a[i];     deque<long long> v;     for (int i = n; i--;) {       while (v.size() && v.back() >= i + c) v.pop_back();       while (v.size() && a[i] <= a[v.front()]) v.pop_front();       v.push_front(i);       if (i <= n - c) dp[i] = max(dp[i + 1], a[v.back()] + dp[i + c]);     }     cout << sum - dp[0];   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1010;   int n;   int a[MAX], c[MAX];   void init() { cin >> n; }   void process() {     memset(a, 63, sizeof(a));     vector<pair<int, int> > ques;     ques.push_back(make_pair(1, n));     while (!ques.empty()) {       vector<pair<int, int> > newQues;       for (int i = 0; i < ques.size(); i++) {         if (ques[i].first != ques[i].second) {           int l = ques[i].first, r = ques[i].second, mid = (l + r) / 2;           newQues.push_back(make_pair(l, mid));           newQues.push_back(make_pair(mid + 1, r));         }       }       vector<int> b;       for (int i = 0; i < newQues.size(); i += 2) {         for (int j = newQues[i].first; j <= newQues[i].second; j++)           b.push_back(j);       }       if (b.size() > 0) {         cout << b.size() <<   n ;         for (int i = 0; i < b.size(); i++) cout << b[i] <<    ;         cout <<   n ;         fflush(stdout);         for (int i = 1; i <= n; i++) cin >> c[i];         for (int i = 1; i <= n; i++) {           bool check = true;           for (int j = 0; j < b.size(); j++) {             if (b[j] == i) {               check = false;               break;             }           }           if (check) a[i] = min(a[i], c[i]);         }       }       b.resize(0);       for (int i = 1; i < newQues.size(); i += 2) {         for (int j = newQues[i].first; j <= newQues[i].second; j++)           b.push_back(j);       }       if (b.size() > 0) {         cout << b.size() <<   n ;         for (int i = 0; i < b.size(); i++) cout << b[i] <<    ;         cout <<   n ;         fflush(stdout);         for (int i = 1; i <= n; i++) cin >> c[i];         for (int i = 1; i <= n; i++) {           bool check = true;           for (int j = 0; j < b.size(); j++) {             if (b[j] == i) {               check = false;               break;             }           }           if (check) a[i] = min(a[i], c[i]);         }       }       ques = newQues;     }     cout << -1 <<   n ;     for (int i = 1; i <= n; i++) cout << a[i] <<    ;     cout <<   n ;     fflush(stdout);   }   int main() {     ios_base::sync_with_stdio(false);     init();     process();   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 300;   long long orign[MAXN], str[2 * MAXN];   int radius[2 * MAXN];   int n, m;   int mp[MAXN][MAXN];   int num[MAXN][26];   long long hashv[MAXN];   long long base[30];   int siz[MAXN];   bool check(int x, int y) {     for (int i = 0; i < 26; i++) {       if (num[x][i] != num[y][i]) return false;     }     return true;   }   void Manacher(int len, int mark = 0) {     for (int i = 0; i < len; i++) {       str[2 * i + 1] = orign[i];       str[2 * i] = mark;     }     str[2 * len] = mark;     len = 2 * len + 1;     int max_right = 0, pos = 0;     for (int i = 0; i < len; i++) {       if (i < max_right)         radius[i] = min(radius[2 * pos - i], max_right - i);       else         radius[i] = 1;       while (i - radius[i] >= 0 && i + radius[i] < len &&              str[i - radius[i]] > -1 && str[i + radius[i]] > -1 &&              check(str[i - radius[i]], str[i + radius[i]])) {         radius[i]++;       }       if (i + radius[i] >= max_right) {         max_right = i + radius[i];         pos = i;       }     }   }   int main() {     std::ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     base[0] = 1;     for (int i = 1; i <= 26; i++) base[i] = base[i - 1] * 2;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         char ch;         cin >> ch;         mp[i][j] = ch -  a ;       }     }     long long ans = 0;     for (int l = 1; l <= m; l++) {       memset(num, 0, sizeof(num));       memset(hashv, 0, sizeof(hashv));       memset(siz, 0, sizeof(siz));       for (int r = l; r <= m; r++) {         for (int i = 1; i <= n; i++) {           int id = mp[i][r];           num[i][id]++;           hashv[i] += base[id];           if (num[i][id] & 1)             siz[i]++;           else             siz[i]--;           if (siz[i] > 1)             orign[i - 1] = -i;           else             orign[i - 1] = i;         }         Manacher(n);         for (int i = 0; i < 2 * n + 1; i++) {           if (str[i] > -1) ans += radius[i] / 2;         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10000010;   int p[N], num, last[N];   bool flag[N];   int cnt[N], n, m;   void make_prime() {     for (int i = 2; i < N; ++i)       if (!flag[i]) {         p[num++] = i;         last[i] = i;         for (int j = i + i; j < N; j += i) flag[j] = true, last[j] = i;       }   }   int main() {     make_prime();     scanf( %d , &n);     for (int i = 0, x; i < n; ++i) {       scanf( %d , &x);       int s = -1;       while (x != 1) {         if (last[x] != s) cnt[last[x]]++;         s = last[x];         x /= last[x];       }     }     for (int i = 1; i < N; ++i) cnt[i] += cnt[i - 1];     scanf( %d , &m);     for (int i = 0, x, y; i < m; ++i) {       scanf( %d %d , &x, &y);       if (x >= N)         puts( 0 );       else {         y = min(y, N - 1);         printf( %d n , cnt[y] - cnt[x - 1]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int N = 2005;   const int M = 730;   int Head[M * 10], Next[M * 100], vet[M * 100];   int a[N], b[N], d[M * 10], vis[15], p[M][5], dis[M], Dis[M], P[10], len[M],       U[M][12], D[M][12];   int n, cnt, edgenum;   pair<int, int> c[M];   queue<int> q;   inline int F(int x, int y) { return (x - 1) * cnt + y; }   inline void addedge(int u, int v) {     edgenum++;     vet[edgenum] = v;     Next[edgenum] = Head[u];     Head[u] = edgenum;   }   int main() {     scanf( %d , &n);     int ans = INF;     for (int i = 1; i <= n; i++) scanf( %d%d , &a[i], &b[i]);     len[cnt = 1] = 0;     for (int i = 1; i <= 9; i++) {       len[++cnt] = 1;       p[cnt][1] = i;       for (int j = i; j <= 9; j++) {         len[++cnt] = 2;         p[cnt][1] = i, p[cnt][2] = j;         for (int k = j; k <= 9; k++) {           len[++cnt] = 3;           p[cnt][1] = i, p[cnt][2] = j, p[cnt][3] = k;           for (int t = k; t <= 9; t++)             len[++cnt] = 4, p[cnt][1] = i, p[cnt][2] = j, p[cnt][3] = k,             p[cnt][4] = t;         }       }     }     for (int i = 2; i <= cnt; i++) {       memset(vis, 0, sizeof(vis));       for (int j = 1; j <= len[i]; j++) vis[p[i][j]] = 1;       for (int j = 1; j <= 9; j++) {         if (!vis[j]) continue;         int res = j, cur = 0;         for (int k = 1; k <= len[i]; k++)           if (p[i][k] == res)             res = -1;           else             P[++cur] = p[i][k];         for (int k = 1; k <= cnt; k++) {           if (len[k] != cur) continue;           bool flag = 1;           for (int t = 1; t <= cur; t++) flag &= (P[t] == p[k][t]);           if (flag) {             D[i][j] = k;             U[k][j] = i;             break;           }         }       }     }     memset(dis, 0x3f, sizeof(dis));     dis[1] = a[1] - 1;     for (int j = 1; j < 9; j++)       for (int k = 1; k <= cnt; k++)         addedge(F(j, k), F(j + 1, k)), addedge(F(j + 1, k), F(j, k));     for (int j = 1; j <= 9; j++)       for (int k = 1; k <= cnt; k++)         if (D[k][j]) addedge(F(j, k), F(j, D[k][j]));     for (int i = 1; i <= n; i++) {       memset(Dis, 0x3f, sizeof(Dis));       for (int j = 1; j <= cnt; j++)         if (U[j][b[i]]) Dis[U[j][b[i]]] = min(Dis[U[j][b[i]]], dis[j] + 1);       for (int j = 1; j <= cnt; j++) dis[j] = Dis[j];       memset(d, 0x3f, sizeof(d));       for (int j = 1; j <= cnt; j++)         d[F(a[i], j)] = dis[j], c[j] = make_pair(dis[j], j);       sort(c + 1, c + 1 + cnt);       for (int j = 1; j <= cnt; j++)         if (c[j].first != INF) q.push(F(a[i], c[j].second));       while (!q.empty()) {         int u = q.front();         q.pop();         for (int e = Head[u]; e; e = Next[e]) {           int v = vet[e];           if (d[v] > d[u] + 1) d[v] = d[u] + 1, q.push(v);         }       }       if (i == n)         for (int j = 1; j <= 9; j++) ans = min(ans, d[F(j, 1)]);       else         for (int j = 1; j <= cnt; j++) dis[j] = d[F(a[i + 1], j)];     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3003 * 6006;   const int qwq = 303030;   const int inf = 0x3f3f3f3f;   int n, m, k;   int f[N], fa[N], st[123], cnt;   int ans;   int ff[] = {1, 1, 1, 0, -1, -1, -1, 0};   int gg[] = {1, 0, -1, -1, -1, 0, 1, 1};   inline int read() {     int sum = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       sum = sum * 10 + c -  0 ;       c = getchar();     }     return sum * f;   }   inline int dian(int x, int y) {     if (y == 0) y = 2 * m;     if (y == 2 * m + 1) y = 1;     return (x - 1) * (m << 1) + y;   }   int find(int u) {     while (fa[u] != u) u = fa[u];     return u;   }   int Splay(int u) { return fa[u] == u ? u : fa[u] = Splay(fa[u]); }   int main() {     int x, y;     n = read();     m = read();     k = read();     if (m == 1) {       cout << 0;       return 0;     }     for (int i = 1; i <= n * m * 2; i++) fa[i] = i;     while (k--) {       cnt = 0;       x = read();       y = read();       for (int i = 0; i <= 8; i++) {         if (x + ff[i] < 1 || x + ff[i] > n) continue;         int u = dian(x + ff[i], y + gg[i]);         if (!f[u]) continue;         int aa = find(u);         int bb = find(dian(x, y));         if (aa == bb) continue;         st[++cnt] = bb;         fa[bb] = aa;       }       y += m;       for (int i = 0; i < 8; i++) {         if (x + ff[i] < 1 || x + ff[i] > n) continue;         int u = dian(x + ff[i], y + gg[i]);         if (!f[u]) continue;         int aa = find(u);         int bb = find(dian(x, y));         if (aa == bb) continue;         st[++cnt] = bb;         fa[bb] = aa;       }       y -= m;       if (find(dian(x, y)) != find(dian(x, y + m))) {         ans++;         for (int i = 0; i < 8; i++) {           if (x + ff[i] < 1 || x + ff[i] > n) continue;           Splay(dian(x + ff[i], y + gg[i]));         }         y += m;         for (int i = 0; i < 8; i++) {           if (x + ff[i] < 1 || x + ff[i] > n) continue;           Splay(dian(x + ff[i], y + gg[i]));         }         y -= m;         f[dian(x, y)] = f[dian(x, y + m)] = 1;       } else {         for (int i = 1; i <= cnt; i++) fa[st[i]] = st[i];       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 29;   const int MOD = 1000000007;   bool isPowerOfTwo(long long int x) { return x && (!(x & (x - 1))); }   void fastio() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};   const int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};   int main() {     fastio();     int t = 1;     while (t--) {       int n;       cin >> n;       string s;       cin >> s;       int ans = 0;       for (int i = 0; i < (s.length()); i++) {         int x = int(s[i]) - 48;         if (x % 2 == 0) ans += (i + 1);       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, int> mp;   int n;   int main() {     scanf( %d , &n);     int t;     long long s = 0;     for (int i = 1; i <= n; i++) {       scanf( %d , &t);       s += t;       mp[s]++;     }     int ans = 0;     map<long long, int>::iterator it;     for (it = mp.begin(); it != mp.end(); it++) {       ans = max(ans, it->second);     }     printf( %d n , n - ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> edge[100005];   int v[100005];   bool cycle = false;   int mx = -1, last;   void dfs(int u, int dis = 0) {     v[u] = 1;     if (dis > mx) {       mx = dis;       last = u;     }     for (int i = 0; i <= (int)((int)edge[u].size() - 1); i++) {       int first = edge[u][i];       if (!v[first]) dfs(first, dis + 1);     }   }   int main() {     int T, n, m, a, b;     scanf( %d , &n);     scanf( %d , &m);     for (int i = 1; i <= (int)(m); i++) {       scanf( %d%d , &a, &b);       edge[a].push_back(b);       edge[b].push_back(a);     }     dfs(1);     memset(v, 0, sizeof(v));     mx = -1;     dfs(last);     printf( %d , mx);     return 0;   }