malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   unsigned long long f(unsigned long long x, int b) {     for (int i = 0; i < 64; i++)       if (__builtin_popcountll(x) < b) x |= 1ULL << i;     return x;   }   unsigned long long brute(unsigned long long l, unsigned long long r) {     unsigned long long ret = l;     for (unsigned long long i = l; i <= r; i++)       if (__builtin_popcountll(i) > __builtin_popcountll(ret)) ret = i;     return ret;   }   int main() {     int T;     scanf( %d , &T);     unsigned long long a, b;     while (T--) {       scanf( %llu%llu , &a, &b);       unsigned long long ans = a;       for (int i = __builtin_popcountll(a) + 1; i < 64; i++) {         unsigned long long v = f(a, i);         if (v <= b) ans = v;       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int up[200005];   void init() { memset(up, -1, sizeof(up)); }   int Find(int x) {     if (up[x] < 0) return x;     int root = Find(up[x]);     up[x] = root;     return root;   }   void Union(int x, int y) {     x = Find(x);     y = Find(y);     if (x == y) return;     if (up[x] < up[y]) {       up[x] += up[y];       up[y] = x;     } else {       up[y] += up[x];       up[x] = y;     }   }   int n;   int a[200005];   vector<int> can;   set<int> aree;   signed main() {     init();     int x;     scanf( %d , &n);     int keep = -1;     for (int i = 1; i <= n; i++) {       scanf( %d , &x);       if (Find(x) != Find(i)) {         Union(x, i);         a[i] = x;       } else {         if (x == i && keep == -1) {           keep = 0;           a[i] = x;         } else {           a[i] = -1;           can.push_back(i);         }       }     }     if (keep == -1) {       a[*(can.end() - 1)] = *(can.end() - 1);       can.pop_back();     }     for (int i = 1; i <= n; i++) {       aree.insert(Find(i));     }     for (auto i : can) {       for (set<int>::iterator k = aree.begin(); k != aree.end(); k++) {         int j = *k;         int u, v;         u = Find(j);         v = Find(i);         if (Find(j) != Find(i)) {           a[i] = j;           Union(i, j);           aree.erase(v);           aree.erase(u);           aree.insert(Find(j));           goto lol;         }       }     lol:;     }     cout << can.size() - keep <<   n ;     for (int i = 1; i <= n; i++) {       cout << a[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     map<long long, vector<pair<int, int>>> d;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) {       long long sum = 0;       for (int j = i; j < n; j++) {         sum += a[j];         d[sum].push_back({i, j});       }     }     pair<int, vector<pair<int, int>>> opt = {-INT_MAX, {}};     for (auto it : d) {       sort(it.second.begin(), it.second.end(),            [](pair<int, int> p1, pair<int, int> p2) {              return p1.second < p2.second;            });       pair<int, int> prev = it.second[0];       pair<int, vector<pair<int, int>>> cur = {1, {prev}};       for (int i = 1; i < it.second.size(); i++) {         if (it.second[i].first > prev.second) {           cur.second.push_back(it.second[i]);           cur.first++;           prev = it.second[i];         }       }       opt = max(opt, cur);     }     cout << opt.first << endl;     for (int i = 0; i < opt.first; i++) {       cout << opt.second[i].first + 1 <<     << opt.second[i].second + 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void pv(T a, T b) {     for (T i = a; i != b; ++i) cout << *i <<    ;     cout << endl;   }   template <class T>   void chmin(T &t, T f) {     if (t > f) t = f;   }   template <class T>   void chmax(T &t, T f) {     if (t < f) t = f;   }   int in() {     int x;     scanf( %d , &x);     return x;   }   const long long MO = 1000000007;   const int LIM = 1000005;   long long inv[1000010];   long long fac[1000010], fnv[1000010];   void prepare() {     int i;     inv[1] = 1;     for (i = 2; i < LIM; ++i) {       inv[i] = MO - MO / i * inv[MO % i] % MO;       assert(i * inv[i] % MO == 1);     }     fac[0] = 1;     fnv[0] = 1;     for (i = 1; i < LIM; ++i) {       fac[i] = fac[i - 1] * i % MO;       fnv[i] = fnv[i - 1] * inv[i] % MO;     }     assert(3628800 * fnv[10] % MO == 1);   }   int A, B, N;   bool isGood(int x) {     for (; x; x /= 10) {       if (!(x % 10 == A || x % 10 == B)) {         return 0;       }     }     return 1;   }   int main() {     int i;     prepare();     for (; ~scanf( %d%d%d , &A, &B, &N);) {       long long ans = 0;       for (i = 0; i <= N; ++i) {         if (isGood(A * i + B * (N - i))) {           long long tmp = 1;           (tmp *= fac[N]) %= MO;           (tmp *= fnv[i]) %= MO;           (tmp *= fnv[N - i]) %= MO;           (ans += tmp) %= MO;         }       }       ans = (ans % MO + MO) % MO;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mxN = 1e5 + 5;   const long long int MOD = 1e9 + 7;   long long int one = 0;   long long int ceil1(long long int a, long long int b) {     if (a % b == 0)       return (a / b);     else       return ((a / b) + 1);   }   void solve() {     long long int n;     cin >> n;     string s;     cin >> s;     long long int x = 0, y = 0;     for (long long int i = 0; i < n; i++) {       if (i & 1) {         if (s[i] !=  r ) x++;       } else {         if (s[i] !=  b ) y++;       }     }     long long int ans = INT_MAX;     ans = min(ans, max(x, y));     x = 0, y = 0;     for (long long int i = 0; i < n; i++) {       if (i & 1) {         if (s[i] !=  b ) x++;       } else {         if (s[i] !=  r ) y++;       }     }     ans = min(ans, max(x, y));     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t = 1;     while (t--) {       one++;       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   int n, o;   string st;   long long a[maxn], all;   int cc[100], where[100], zhu[100], g[maxn], wc[maxn];   int f[66][maxn];   int main() {     cin >> n;     all = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i];       all ^= a[i];     }     st =   ;     for (int i = 1; i <= 63; i++) {       st = char(all % 2 + 48) + st;       all /= 2;     }     o = 0;     for (int i = 1; i <= 63; i++)       if (st[i - 1] ==  0 ) ++o, where[o] = i;     for (int i = 1; i <= 63; i++)       if (st[i - 1] ==  1 ) ++o, where[o] = i;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= 63; j++) {         cc[64 - j] = a[i] % 2;         a[i] /= 2;       }       a[i] = 0;       for (int j = 1; j <= 63; j++) a[i] = (long long)a[i] * 2 + cc[where[j]];     }     memset(f, 0, sizeof(f));     memset(g, 0, sizeof(g));     memset(zhu, 0, sizeof(zhu));     for (int i = 1; i <= 63; i++) {       for (int j = 1; j <= n; j++) f[i][j] = ((long long)a[j] >> (63 - i)) % 2;       g[i] = 1;       for (int j = 1; j < i; j++)         if ((zhu[j] != -1) && (f[i][zhu[j]] == 1)) {           for (int k = 1; k <= n; k++) f[i][k] ^= f[j][k];           g[i] ^= g[j];         }       zhu[i] = -1;       for (int j = 1; j <= n; j++)         if (f[i][j] == 1) {           zhu[i] = j;           break;         }       if (zhu[i] == -1) g[i] = 0;     }     memset(wc, 0, sizeof(wc));     for (int i = 63; i >= 1; i--) {       for (int j = 1; j <= n; j++)         if (f[i][j] == 1) g[i] ^= wc[j];       wc[zhu[i]] = g[i];     }     for (int i = 1; i <= n; i++) cout << wc[i] + 1 <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, Q;   vector<vector<int>> V;   map<pair<int, int>, int> M;   int ret[101010];   template <int um>   class UF {    public:     vector<int> par, rank;     vector<vector<int>> hist;     UF() {       par = rank = vector<int>(um, 0);       for (int i = 0; i < um; i++) par[i] = i;     }     void reinit() {       int i;       for (i = 0; i < (um); i++) rank[i] = 0, par[i] = i;     }     int operator[](int x) { return (par[x] == x) ? (x) : operator[](par[x]); }     void pop() {       if (hist.size()) {         auto a = hist.back();         hist.pop_back();         par[a[0]] = a[1];         rank[a[0]] = a[2];         par[a[3]] = a[4];         rank[a[3]] = a[5];       }     }     void operator()(int x, int y) {       x = operator[](x);       y = operator[](y);       hist.push_back({x, par[x], rank[x], y, par[y], rank[y]});       if (x == y) return;       if (rank[x] < rank[y]) {         par[x] = y;       } else if (rank[x] > rank[y]) {         par[y] = x;       } else {         rank[x]++;         par[y] = x;       }     }   };   void dfs(int L, int R, UF<201010>& uf, vector<vector<int>> V) {     vector<vector<int>> LV, RV;     int nums = 0;     int M = (L + R) / 2;     int con = 0;     if (V.empty()) return;     for (auto& v : V) {       if (v[2] <= L && R <= v[3]) {         uf(v[0] * 2, v[1] * 2 + 1);         uf(v[0] * 2 + 1, v[1] * 2);         if (uf[v[0] * 2] == uf[v[0] * 2 + 1]) con = 1;         if (uf[v[1] * 2] == uf[v[1] * 2 + 1]) con = 1;         nums += 2;       } else {         if (v[2] < M) LV.push_back({v[0], v[1], max(L, v[2]), min(M, v[3])});         if (v[3] > M) RV.push_back({v[0], v[1], max(M, v[2]), min(R, v[3])});       }     }     int i;     if (con) {       for (int i = L; i < R; i++) ret[i] = 1;     } else {       dfs(L, M, uf, LV);       dfs(M, R, uf, RV);     }     while (nums--) uf.pop();   }   void solve() {     int i, j, k, l, r, x, y;     string s;     cin >> N >> Q;     for (i = 0; i < (Q); i++) {       cin >> x >> y;       x--, y--;       if (x > y) swap(x, y);       if (M.count({x, y}) == 0) {         M[{x, y}] = i;       } else {         V.push_back({x, y, M[{x, y}], i});         M.erase({x, y});       }     }     for (auto& r : M) V.push_back({r.first.first, r.first.second, r.second, Q});     UF<201010> uf;     dfs(0, Q, uf, V);     for (i = 0; i < (Q); i++) {       if (ret[i])         cout <<  NO  << endl;       else         cout <<  YES  << endl;     }   }   int main(int argc, char** argv) {     string s;     int i;     if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);     for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s +=   n ;     for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, ss;     getline(cin, s);     getline(cin, ss);     int ara[500];     memset(ara, 0, sizeof ara);     for (auto x : s)       if (isalpha(x)) ara[x]++;     bool ok = true;     for (auto x : ss) {       if (isalpha(x)) {         if (!ara[x]) {           ok = false;           break;         } else           ara[x]--;       }     }     if (ok)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int N = 1e5 + 100;   const int maxn = 1e6;   const int MAXL = sqrt(1e7) + 1;   int n, a[220], f[220][410];   void solve() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; i++) {       for (int j = 0; j <= 400; j++) f[i][j] = INT_MAX;     }     for (int j = 1; j <= 400; j++) {       f[1][j] = abs(j - a[1]);       f[1][j] = min(f[1][j], f[1][j - 1]);     }     for (int i = 2; i <= n; i++) {       for (int j = i; j <= 400; j++) {         f[i][j] = min(f[i][j], f[i - 1][j - 1] + abs(j - a[i]));         f[i][j] = min(f[i][j], f[i][j - 1]);       }     }     int ans = INT_MAX;     for (int i = n; i <= 400; i++) ans = min(ans, f[n][i]);     printf( %d n , ans);   }   int main() {     int T;     scanf( %d , &T);     int tt = 0;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cal(vector<int> q, int n, int m) {     int sum = 0;     for (int i = (int)0; i < (int)n; ++i) {       for (int j = (int)i; j < (int)n; ++j) {         int mn = INT_MAX;         for (int k = (int)i; k < (int)j + 1; ++k)           mn = ((mn) < (q[k]) ? (mn) : (q[k]));         sum += mn;       }     }     return sum;   }   int main() {     int i, j, n, t;     int m;     scanf( %d , &n);     scanf( %d , &m);     vector<int> q;     for (int i = (int)1; i < (int)n + 1; ++i) q.push_back(i);     int mx = 0;     do {       mx = ((mx) > (cal(q, n, m)) ? (mx) : (cal(q, n, m)));     } while (next_permutation(q.begin(), q.end()));     sort(q.begin(), q.end());     int cnt = 0;     do {       if (cal(q, n, m) == mx) cnt++;       if (cnt == m) break;     } while (next_permutation(q.begin(), q.end()));     for (int i = (int)0; i < (int)n; ++i) printf( %d  , q[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100100;   struct node {     long long l, r;     long long color;     long long sum;     long long change;   } tree[maxn << 2];   long long n, m;   int a[maxn];   void pushup(long long cur) {     if (tree[cur * 2].color == tree[cur * 2 + 1].color)       tree[cur].color = tree[cur * 2].color;     tree[cur].sum = tree[cur * 2].sum + tree[cur * 2 + 1].sum;   }   void build(long long l, long long r, long long cur) {     tree[cur].l = l;     tree[cur].r = r;     tree[cur].sum = 0;     tree[cur].change = 0;     tree[cur].color = 0;     if (l == r) {       tree[cur].color = l;       return;     }     long long mid = (r + l) >> 1;     build(l, mid, cur << 1);     build(mid + 1, r, cur << 1 | 1);     pushup(cur);   }   void pushdown(long long cur) {     if (tree[cur].change) {       tree[cur * 2].sum +=           tree[cur].change * (tree[cur * 2].r - tree[cur * 2].l + 1);       tree[cur * 2 + 1].sum +=           tree[cur].change * (tree[cur * 2 + 1].r - tree[cur * 2 + 1].l + 1);       tree[cur * 2].change += tree[cur].change;       tree[cur * 2 + 1].change += tree[cur].change;       tree[cur].change = 0;     }     if (tree[cur].color)       tree[cur * 2].color = tree[cur * 2 + 1].color = tree[cur].color;     tree[cur].color = 0;   }   void update(long long pl, long long pr, long long l, long long r, long long cur,               long long x) {     if ((pl <= l && r <= pr && tree[cur].color) || l == r) {       tree[cur].sum += abs(x - tree[cur].color) * (r - l + 1);       tree[cur].change += abs(x - tree[cur].color);       tree[cur].color = x;       return;     }     pushdown(cur);     long long mid = (r + l) >> 1;     if (pl <= mid) update(pl, pr, l, mid, cur << 1, x);     if (pr > mid) update(pl, pr, mid + 1, r, cur << 1 | 1, x);     pushup(cur);   }   long long query(long long pl, long long pr, long long l, long long r,                   long long cur) {     if (pl <= l && r <= pr) {       return tree[cur].sum;     }     pushdown(cur);     long long mid = (r + l) >> 1;     long long res = 0;     if (pl <= mid) res += query(pl, pr, l, mid, cur << 1);     if (pr > mid) res += query(pl, pr, mid + 1, r, cur << 1 | 1);     return res;   }   int main() {     while (~scanf( %lld%lld , &n, &m)) {       build(1, n, 1);       long long op, l, r, x;       while (m--) {         scanf( %lld%lld%lld , &op, &l, &r);         if (op == 1) {           scanf( %lld , &x);           update(l, r, 1, n, 1, x);         } else {           printf( %lld n , query(l, r, 1, n, 1));         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n = 5000001;   void okms() {     vector<int> kk(n);     kk[0] = 0, kk[1] = 0;     for (int(i) = 2; i < n; ++i) kk[i] = 1;     vector<bool> ch(n);     for (int(i) = 0; i < n; ++i) ch[i] = true;     ch[0] = 0, ch[1] = 0;     vector<int> trr(n);     for (int i = 2; i * i <= n - 1; i++) {       if (ch[i]) {         trr[i] = i;         for (int j = i * i; j <= n - 1; j += i) {           ch[j] = false;           trr[j] = i;         }       }     }     for (int(i) = 2; i < n; ++i) {       if (!ch[i]) {         kk[i] = kk[trr[i]] + kk[i / trr[i]];       }     }     vector<int> ans(n);     for (int(i) = 1; i < n; ++i) ans[i] += ans[i - 1] + kk[i];     int t;     cin >> t;     while (t--) {       int a, b;       cin >> a >> b;       cout << ans[a] - ans[b] <<   n ;     }     return;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int test;     test = 1;     while (test--) {       okms();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, q;   long long siz[100005];   long long par[100005];   string s;   unordered_map<string, long long> idx;   vector<pair<long long, long long> > e[100005];   long long ans[100005];   long long dis[100005];   pair<long long, pair<long long, long long> > edges[100005];   long long find_set(long long a) {     if (a == par[a]) return a;     return par[a] = find_set(par[a]);   }   void union_set(long long a, long long b) {     a = find_set(a);     b = find_set(b);     if (a != b) {       if (siz[a] < siz[b]) swap(a, b);       par[b] = a;       siz[a] += siz[b];     }   }   void dfs(long long u, long long len, long long par) {     dis[u] = len;     for (auto i : e[u]) {       if (i.first != par) dfs(i.first, len + i.second, u);     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> q;     for (long long i = 0; i < n; i++) {       cin >> s;       idx[s] = i;       par[i] = i;       siz[i] = 1;     }     for (long long i = 0; i < m; i++) {       long long type;       string a, b;       cin >> type >> a >> b;       long long u = idx[a];       long long v = idx[b];       edges[i] = {type, {u, v}};       long long uRep = find_set(u);       long long vRep = find_set(v);       if (uRep == vRep) continue;       union_set(uRep, vRep);       if (type == 1)         e[u].push_back({v, 0}), e[v].push_back({u, 0});       else         e[u].push_back({v, 1}), e[v].push_back({u, 1});       ans[i] = 1;     }     memset(dis, -1, sizeof(dis));     for (long long i = 0; i < n; i++) {       if (dis[i] == -1) {         long long iRep = find_set(i);         dfs(iRep, 0, -1);       }     }     for (long long i = 0; i < m; i++) {       if (ans[i])         cout <<  YES n ;       else {         long long u = edges[i].second.first;         long long v = edges[i].second.second;         long long type = edges[i].first;         long long real_type;         if (dis[u] % 2 == dis[v] % 2)           real_type = 1;         else           real_type = 2;         if (real_type == type)           cout <<  YES n ;         else           cout <<  NO n ;       }     }     while (q--) {       string a, b;       cin >> a >> b;       long long u = idx[a];       long long v = idx[b];       long long uRep = find_set(u);       long long vRep = find_set(v);       if (uRep != vRep)         cout << 3 << endl;       else {         if (dis[u] % 2 == dis[v] % 2)           cout << 1 << endl;         else           cout << 2 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, now, p[20000], p_, g[10], ans;   int xx[10];   int tmp[10000];   int yoo[2][10000][10], f[1000][1000];   void dfs(int k) {     int tmp = 0;     for (int i = 1; i < k; ++i) tmp = tmp * 10 + xx[i] / g[k + 1] % 10;     if (k == n) {       ans += ::tmp[tmp];       return;     }     for (int v = yoo[0][tmp][n - k + 1]; v <= yoo[1][tmp][n - k + 1]; v++) {       xx[k] = p[v];       dfs(k + 1);     }   }   int dfss(int k) {     int tmp = 0;     for (int i = 1; i < k; ++i) tmp = tmp * 10 + xx[i] / g[k + 1] % 10;     if (k == n - 1) {       int ppp = 0;       for (int i = 1; i < k; ++i) ppp = ppp * 10 + xx[i] / g[k + 2] % 10;       if (f[tmp][ppp] != -1) {         ans += f[tmp][ppp];         return 0;       }       f[tmp][ppp] = 0;       for (int v = yoo[0][tmp][n - k + 1]; v <= yoo[1][tmp][n - k + 1]; v++) {         xx[k] = p[v];         f[tmp][ppp] += dfss(k + 1);       }       return 0;     }     if (k == n) {       ans += ::tmp[tmp];       return ::tmp[tmp];     }     for (int v = yoo[0][tmp][n - k + 1]; v <= yoo[1][tmp][n - k + 1]; v++) {       xx[k] = p[v];       dfss(k + 1);     }   }   int main() {     int test;     cin >> test;     for (int i = 2; i <= 99999; ++i) {       bool can = 1;       for (int j = 0; j < p_; ++j)         if (i % p[j] == 0) {           can = 0;           break;         }       if (can) p[p_++] = i;     }     g[0] = 100000;     g[1] = 10000;     g[2] = 1000;     g[3] = 100;     g[4] = 10;     g[5] = 1;     memset(yoo[1], -1, sizeof yoo[1]);     memset(yoo[0], 63, sizeof yoo[0]);     memset(f, -1, sizeof f);     for (int i = 0; i < p_; ++i)       for (int j = 0; j < 5; ++j)         if (4 == j)           tmp[p[i] / g[j]]++;         else           yoo[0][p[i] / g[j + 1]][4 - j] = min(yoo[0][p[i] / g[j + 1]][4 - j], i),                                       yoo[1][p[i] / g[j + 1]][4 - j] =                                           max(yoo[1][p[i] / g[j + 1]][4 - j], i);     for (; test--;) {       ans = 0;       cin >> now;       ans = 0;       n = 0;       for (int i = now; i; i /= 10) n++;       g[n + 1] = 1;       for (int i = 0; i < n; ++i) g[n - i] = g[n - i + 1] * 10;       xx[1] = now;       if (n < 5)         dfs(2);       else         dfss(2);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int tc, n, i, j, p, k;     scanf( %d , &tc);     while (tc--) {       scanf( %d , &n);       vector<int> v[n + 5];       for (i = 0; i < n; i++) {         scanf( %d , &p);         v[p].push_back(i);       }       k = 0;       for (i = 1; i <= n; i++) {         int b = 0;         if (v[i].size() == 2) b = (v[i][1] - v[i][0]) > 1;         if ((v[i].size() >= 3) || b) {           k = 1;           printf( YES );           break;         }       }       if (!k) printf( NO );       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200005];   int main() {     int n;     scanf( %d , &n);     int sum = 0;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       sum += a[i];     }     vector<int> ans;     for (int i = 1; i <= n; ++i) {       if ((sum - a[i]) % (n - 1) == 0 && (sum - a[i]) / (n - 1) == a[i]) {         ans.push_back(i);       }     }     printf( %d n , (int)ans.size());     for (auto p : ans) {       printf( %d n , p);     }   }
#include <bits/stdc++.h>   using namespace std;   int get(string str) {     int cnt = 0;     for (int i = 0; i < str.size() - 1; i++) {       if (str[i] ==  V  && str[i + 1] ==  K ) cnt++;     }     return cnt;   }   int main() {     string str;     cin >> str;     int res = get(str);     for (int i = 0; i < str.size(); i++) {       string cp = str;       cp[i] = (cp[i] ==  K  ?  V  :  K );       res = max<int>(res, get(cp));     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool fs(T &x) {     int c = getchar();     int sgn = 1;     while (~c && c <  0  || c >  9 ) {       if (c ==  - ) sgn = -1;       c = getchar();     }     for (x = 0; ~c &&  0  <= c && c <=  9 ; c = getchar()) x = x * 10 + c -  0 ;     x *= sgn;     return ~c;   }   int ara[600][600];   void boshao(int n) {     int ln = n * 2;     for (int i = 1; i <= n; i++)       for (int j = n + 1; j <= ln; j++) ara[i][j] = ara[i][j - n];     for (int j = 1; j <= n; j++)       for (int i = n + 1; i <= ln; i++) ara[i][j] = ara[i - n][j];     for (int j = n + 1; j <= ln; j++)       for (int i = n + 1; i <= ln; i++) ara[i][j] = ara[i - n][j - n] ^ 1;   }   int main() {     ara[1][1] = 1;     ara[1][2] = 1;     ara[2][1] = 1;     ara[2][2] = 0;     int n;     fs(n);     int x = 2;     for (int i = 2; i <= 9; i++) {       boshao(x);       x *= 2;     }     for (int i = 1; i <= (1 << n); i++) {       for (int j = 1; j <= (1 << n); j++) cout << ((ara[i][j]) ?  *  :  + );       cout << endl;     }     return 0;   }