malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, k, x, y, z, A[(1 << 17)], B[(1 << 17)], C[(1 << 17)],       mmp[(1 << 17)], Comb[18][18];   long long O[(1 << 17)], Ans[4][(1 << 17)], S[4][(1 << 17)];   long long powmod(long long x, long long y = 998244353 - 2,                    long long p = 998244353) {     x %= p;     y = (y % (p - 1) + (p - 1)) % (p - 1);     long long ans = 1;     while (y) {       if (y & 1) ans = ans * x % p;       x = x * x % p;       y >>= 1;     }     return ans;   }   signed main() {     scanf( %lld%lld%lld%lld%lld , &n, &k, &x, &y, &z);     for (long long i = 0; i < n; i++) {       scanf( %lld%lld%lld , &A[i], &B[i], &C[i]);       B[i] ^= A[i];       C[i] ^= A[i];     }     for (long long i = 0; i <= k; i++)       for (long long j = 0; j <= i; j++)         Comb[i][j] = !j ? 1 : Comb[i - 1][j - 1] + Comb[i - 1][j];     mmp[0] = 1;     for (long long i = 1; i <= k; i++) {       mmp[i] = 1 - (i % 2);       for (long long j = 0; j < i; j++) mmp[i] -= Comb[i][j] * mmp[j];     }     for (long long b1 = 0; b1 < 2; b1++)       for (long long b2 = 0; b2 < 2; b2++) {         memset(O, 0, sizeof O);         for (long long i = 0; i < n; i++) O[(B[i] * b1) ^ (C[i] * b2)]++;         for (long long i = 1; i < (1 << k); i *= 2)           for (long long j = 0; j < (1 << k); j += i + i)             for (long long k = j; k < j + i; k++) O[k] = (O[k] + O[k + i]);         for (long long i = 0; i < (1 << k); i++)           O[i] *= mmp[__builtin_popcount(i)], O[i];         for (long long i = 1; i < (1 << k); i *= 2)           for (long long j = 0; j < (1 << k); j += i + i)             for (long long k = j; k < j + i; k++) O[k + i] = (O[k + i] + O[k]);         memcpy(Ans[b1 * 2 + b2], O, sizeof O);       }     S[0][1] = x - y - z;     S[1][1] = x - y + z;     S[2][1] = x + y - z;     S[3][1] = x + y + z;     for (long long i = 0; i < 4; i++) {       S[i][0] = 1;       for (long long j = 2; j <= n; j++)         S[i][j] = S[i][j - 1] * S[i][1] % 998244353;     }     for (long long i = 0; i < (1 << k); i++) {       long long _00 = Ans[0][i], _01 = Ans[1][i], _10 = Ans[2][i],                 _11 = Ans[3][i];       long long __00 = (_01 + _10 + _11 - _00) / 2;       long long __11 = _11 - __00;       long long __01 = _10 - __00;       long long __10 = _01 - __00;       O[i] = S[0][__11] * S[1][__10] % 998244353 * S[2][__01] % 998244353 *              S[3][__00] % 998244353;     }     long long tot = 0;     for (long long i = 0; i < n; i++) tot ^= A[i];     for (long long i = 1; i < (1 << k); i *= 2)       for (long long j = 0; j < (1 << k); j += i + i)         for (long long k = j; k < j + i; k++) {           long long A = O[k], B = O[k + i];           O[k] = (A + B);           O[k + i] = (A - B);         }     long long r = powmod(1 << k);     for (long long i = 0; i < (1 << k); i++)       printf( %lld  ,              (O[i ^ tot] % 998244353 * r % 998244353 + 998244353) % 998244353);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string zbor1, zbor2;     cin >> zbor1;     int n, i, j;     n = zbor1.length();     if (n < 10) {       cout <<  NO ;       return 0;     }     for (i = n - 1; i >= n - 10; i--) {       zbor2 = zbor2 + zbor1[i];     }     if (zbor2 ==  SECROFEDOC ) {       cout <<  YES ;       return 0;     }     zbor2.clear();     for (i = 0; i < 10; i++) {       zbor2 = zbor2 + zbor1[i];     }     if (zbor2 ==  CODEFORCES ) {       cout <<  YES ;       return 0;     }     for (i = 0; i < 10; i++) {       zbor2.clear();       for (j = 0; j <= i; j++) {         zbor2 = zbor2 + zbor1[j];       }       for (j = n - 9 + i; j < n; j++) {         zbor2 = zbor2 + zbor1[j];       }       if (zbor2 ==  CODEFORCES ) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int abs(long long int a, long long int b) {     if (a < b) {       return -1 * (a - b);     }     return (a - b);   }   bool comp(long long int a, long long int b) {     if (a > b) {       return true;     }     return false;   }   int main() {     int n, a, b;     cin >> n >> a >> b;     vector<long long int> v;     for (int i = 0; i < n; i++) {       long long int t;       cin >> t;       v.push_back(t);     }     sort(v.begin(), v.end(), comp);     long long int ans = abs(v[n - b], v[n - b - 1]);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, i, j;     int max = INT_MIN;     cin >> n;     int a[n];     int b[n];     for (i = 0; i < n; i++) {       cin >> a[i];     }     for (j = n - 1; j >= 0; j--) {       if (a[j] <= max) {         b[j] = max + 1 - a[j];       } else {         b[j] = 0;       }       if (max < a[j]) {         max = a[j];       }     }     for (i = 0; i < n; i++) {       cout << b[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1E9 + 7, INF = 2E18 + 5;   const double PI = 2 * acos(0.0);   const long double EPS = 1.0E-14;   long long arr[1000005], arrFreq[1000005], arrAns[1000005];   vector<long long> vec;   int main() {     long long n, m, lcm = 1, sz = 0;     cin >> n >> m;     for (int i = 0; i < n; i++) {       scanf( %lld , &arr[i]);       if (arr[i] <= m) {         arrFreq[arr[i]]++;       }     }     for (int i = 1; i <= m; i++) {       if (!arrFreq[i]) continue;       for (int j = i; j <= m; j += i) {         arrAns[j] += arrFreq[i];       }     }     for (int i = 1; i <= m; i++) {       if (arrAns[i] > sz) {         sz = arrAns[i];         lcm = i;       }     }     for (int i = 0; i < n; i++) {       if (lcm % arr[i] == 0) {         vec.push_back(i + 1);       }     }     cout << lcm <<     << vec.size() <<   n ;     for (int i = 0; i < vec.size(); i++) {       printf( %lld  , vec[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1500010;   int n, cnt, ans;   int a[N], bug[N], v[N];   map<pair<int, int>, int> vis;   bool check(int i) {     if (!(i & 1)) {       if (i < n)         return a[i - 1] < a[i] && a[i + 1] < a[i];       else         return a[i - 1] < a[i];     } else if (i > 1 && i < n)       return a[i - 1] > a[i] && a[i + 1] > a[i];     else if (i == 1)       return a[i + 1] > a[i];     else       return a[i - 1] > a[i];   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = 1; i <= n; i += 2) {       if (i == 1 && a[i] >= a[i + 1]) {         if (!v[i]) bug[++cnt] = i, v[i] = 1;         if (!v[i + 1]) bug[++cnt] = i + 1, v[i + 1] = 1;       } else if (i == n && a[i] >= a[i - 1]) {         if (!v[i]) bug[++cnt] = i, v[i] = 1;         if (!v[i - 1]) bug[++cnt] = i - 1, v[i - 1] = 1;       } else if (i > 1 && i < n) {         if (a[i] >= a[i + 1] && a[i] >= a[i - 1]) {           if (!v[i]) bug[++cnt] = i, v[i] = 1;           if (!v[i + 1]) bug[++cnt] = i + 1, v[i + 1] = 1;           if (!v[i - 1]) bug[++cnt] = i - 1, v[i - 1] = 1;         } else {           if (a[i] >= a[i + 1]) {             if (!v[i]) bug[++cnt] = i, v[i] = 1;             if (!v[i + 1]) bug[++cnt] = i + 1, v[i + 1] = 1;           }           if (a[i] >= a[i - 1]) {             if (!v[i]) bug[++cnt] = i, v[i] = 1;             if (!v[i - 1]) bug[++cnt] = i - 1, v[i - 1] = 1;           }         }       }     }     if (cnt > 6) {       puts( 0 );       return 0;     }     for (int i = 1; i <= cnt; i++)       for (int j = 1; j <= n; j++) {         if (a[j] == a[bug[i]]) continue;         swap(a[j], a[bug[i]]);         bool fl = 1;         for (int k = 1; k <= cnt; k++)           if (!check(bug[k])) fl = 0;         if (!check(j)) fl = 0;         if (fl) {           pair<int, int> p = make_pair(min(bug[i], j), max(bug[i], j));           if (!vis[p]) {             ans++;             vis[p] = 1;           }         }         swap(a[j], a[bug[i]]);       }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1100000;   int n, m;   char a[MAXN], b[MAXN];   int s[MAXN], t[MAXN];   inline int id(int x, int y) {     if (x < 1 || x > n || y < 1 || y > m) return 0;     return (x - 1) * m + y;   }   bool check(int k) {     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++)         if (i - k >= 1 && i + k <= n && j - k >= 1 && j + k <= m &&             s[id(i + k, j + k)] - s[id(i - k - 1, j + k)] -                     s[id(i + k, j - k - 1)] + s[id(i - k - 1, j - k - 1)] ==                 0)           b[id(i, j)] =  X ;         else           b[id(i, j)] =  . ;     }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         t[id(i, j)] = t[id(i - 1, j)] + t[id(i, j - 1)] - t[id(i - 1, j - 1)] +                       (b[id(i, j)] ==  X );     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         int l1 = max(i - k, 1), r1 = min(i + k, n);         int l2 = max(j - k, 1), r2 = min(j + k, m);         if (a[id(i, j)] ==  X  && t[id(r1, r2)] - t[id(l1 - 1, r2)] -                                           t[id(r1, l2 - 1)] +                                           t[id(l1 - 1, l2 - 1)] ==                                       0)           return 0;       }     return 1;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %s , a + (i - 1) * m + 1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         s[id(i, j)] = s[id(i - 1, j)] + s[id(i, j - 1)] - s[id(i - 1, j - 1)] +                       (a[id(i, j)] !=  X );     int l = 0, r = min(n, m);     while (l < r) {       int mid = l + r + 1 >> 1;       if (check(mid))         l = mid;       else         r = mid - 1;     }     printf( %d n , l);     check(l);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) putchar(b[id(i, j)]);       putchar(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   deque<int> A, B;   long long p, i, j, k, n, m, aux;   long long fact(int a) {     long long f = 1;     int i;     for (int i = (int)(1); i <= (int)(a); ++i) f *= i;     return f;   }   int main(void) {     cin >> p;     cin >> n;     for (int i = (int)(1); i <= (int)(n); ++i) {       cin >> aux;       A.push_back(aux);     }     cin >> n;     for (int i = (int)(1); i <= (int)(n); ++i) {       cin >> aux;       B.push_back(aux);     }     long long step(0);     long long stari = fact(p + 1);     while (step <= stari) {       if (A.empty()) return cout << step <<     << 2, 0;       if (B.empty()) return cout << step <<     << 1, 0;       ++step;       int x = A.front();       A.pop_front();       int y = B.front();       B.pop_front();       if (x < y) {         B.push_back(x);         B.push_back(y);       } else {         A.push_back(y);         A.push_back(x);       }     }     cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[(int)(2 * 1e5 + 10)];   long long pa[(int)(2 * 1e5 + 10)];   long long sa[(int)(2 * 1e5 + 10)];   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       pa[i] = 1ll * a[i] + pa[i - 1];     }     for (int i = n; i >= 1; --i) {       sa[i] = 1ll * a[i] + sa[i + 1];     }     int x = n;     long long mx = 0;     int i = 1;     while (i <= n) {       if (i < x) {         if (pa[i] > sa[x])           --x;         else if (pa[i] < sa[x])           ++i;         else           mx = max(mx, pa[i]), ++i, --x;       } else         break;     }     cout << mx << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a[1000 + 3][1000 + 3];   int used[1000 + 3][1000 + 3];   int n;   void dfs(int x, int y) {     used[x][y] = 1;     for (int i = 0; i <= 1001; i++) {       if (!used[x][i] && a[x][i]) dfs(x, i);     }     for (int i = 0; i <= 1001; i++) {       if (!used[i][y] && a[i][y]) dfs(i, y);     }   }   int main() {     cin >> n;     int tmp1, tmp2;     for (int i = 0; i < n; i++) {       cin >> tmp1 >> tmp2;       a[tmp1][tmp2] = 1;     }     int ans = 0;     for (int i = 0; i <= 1001; i++) {       for (int j = 0; j <= 1001; j++) {         if (a[i][j] && !used[i][j]) {           dfs(i, j);           ans++;         }       }     }     cout << --ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename a>   void SWAP(a &b, a &c) {     a d = b;     b = c;     c = d;   }   long long power(long long a, long long b) {     long long result = 1;     while (b) {       if (b & 1) result = a * result;       a *= a;       b >>= 1;     }     return result;   }   long long gcd(long long a, long long b) {     while (b) {       a = a % b;       SWAP(a, b);     }     return a;   }   long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }   int main() {     long long n, k;     scanf( %lld %lld , &n, &k);     long long h[n];     long long sum = 0, ans = LLONG_MAX, index = 1;     for (long long i = 0; i < n; i++) {       scanf( %lld , &h[i]);       sum += h[i];       if (i + 1 >= k) {         if (ans > sum) {           index = i - k + 2;           ans = sum;         }         sum -= h[i - k + 1];       }     }     printf( %lld n , (index));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define pi acos(-1)   #define mod 1000000007   #define lli long long int   #define li long int   #define pb push_back   #define mp make_pair   #define ff first   #define ss second   #define nl   n          int main()   {   ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);          lli t,n;       cin>>t;       while(t--)       {           cin>>n;          int count=0;           for(lli i=1; i<=n; i=i*10 +1)           {               for(int j=1; j<=9; j++)               {                   if(i*j<=n)                   {                       count++;                   }               }           }           cout<<count<<  n ;       }       return 0;   }
#include <bits/stdc++.h>   using LL = long long;   using ULL = unsigned long long;   using namespace std;   long long n, m;   vector<long long> a;   vector<pair<long long, long long> > vec;   signed main() {     ios::sync_with_stdio(false), cin.tie(NULL);     cin >> n;     a.resize(n, 0);     vec.resize(n, {0, 0});     for (long long i = (0); i < (n); i++) cin >> a[i];     for (long long i = (0); i < (n); i++)       vec[i].first = a[i], vec[i].second = n - i;     sort(vec.rbegin(), vec.rend());     cin >> m;     for (long long i = (0); i < (m); i++) {       long long k, pos;       cin >> k >> pos;       vector<pair<long long, long long> > tmp;       tmp.resize(k, {0, 0});       for (long long i = (0); i < (k); i++)         tmp[i].first = n - vec[i].second, tmp[i].second = vec[i].first;       sort(tmp.begin(), tmp.end());       cout << tmp[pos - 1].second <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int Maxn = 20 + 5, Mod = 1e9 + 7, Inf = 1e9;   int n, p[Maxn], ansss, m, fac[Maxn];   bool mrk[Maxn], mark[Maxn];   int ans[] = {1,         0, 18,        0, 1800,      0, 670320,    0,                734832000, 0, 890786230, 0, 695720788, 0, 150347555, 0};   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     cout << ans[n - 1] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 10;   const int pN = 1e6;   const int INF = 0x3f3f3f3f;   const int MOD = 1e9 + 7;   void add(long long &x, long long y) {     x += y;     x %= MOD;   }   bool vis[MAXN];   int a[MAXN];   int main() {     int n, k;     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     int ans = INF;     int id;     for (int i = 0; i < n; i++) {       if (vis[i]) continue;       int sum = 0;       for (int j = i;; j = (j + k) % n) {         if (vis[j]) break;         vis[j] = true;         sum += a[j];       }       if (sum < ans) {         id = i;         ans = sum;       }     }     cout << id + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   long long data[100010], diff[100010], change[100010];   vector<vector<long long> > adj;   vector<pair<long long, int> > vp;   int main(void) {     scanf( %d%d , &n, &m);     adj.resize(n + 1, vector<long long>());     for (int i = 0; i < m; i++) scanf( %I64d , &data[i]);     if (m == 1) {       puts( 0 );       return 0;     }     for (int i = 0; i < m; i++) {       if (i == 0 && data[i] != data[i + 1])         adj[data[i]].push_back(data[i + 1]);       else if (i == m - 1 && data[i] != data[i - 1])         adj[data[i]].push_back(data[i - 1]);       else if (i > 0 && i < m - 1) {         if (data[i] != data[i - 1]) adj[data[i]].push_back(data[i - 1]);         if (data[i] != data[i + 1]) adj[data[i]].push_back(data[i + 1]);       }     }     for (int i = 1; i <= n; i++) {       if (adj[i].empty()) continue;       long long sum = 0;       sort(adj[i].begin(), adj[i].end());       long long avg1 = adj[i][adj[i].size() / 2];       long long newMid = adj[i].size() / 2 - 1;       if (newMid < 0) newMid = 0;       long long avg2 = adj[i][newMid];       long long sum1 = 0, sum2 = 0;       for (int j = 0; j < adj[i].size(); j++) sum += abs(adj[i][j] - i);       for (int j = 0; j < adj[i].size(); j++) sum1 += abs(adj[i][j] - avg1);       for (int j = 0; j < adj[i].size(); j++) sum2 += abs(adj[i][j] - avg2);       if (sum1 < sum2) {         vp.push_back(make_pair(sum - sum1, i));         change[i] = avg1;       } else {         vp.push_back(make_pair(sum - sum2, i));         change[i] = avg2;       }     }     sort(vp.begin(), vp.end());     if (vp.empty()) {       puts( 0 );       return 0;     }     int target = vp[vp.size() - 1].second;     for (int i = 0; i < m; i++)       if (data[i] == target) data[i] = change[target];     long long sol = 0;     for (int i = 0; i < m - 1; i++) sol += abs(data[i] - data[i + 1]);     printf( %I64d n , sol);   }
#include <bits/stdc++.h>   using namespace std;   int mp[100][100];   int cnt[100];   int main() {     int n, x, y;     cin >> n;     while (cin >> x) {       cin >> y;       mp[x][y] = 1;       mp[y][x] = 1;       cnt[x]++;     }     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (!mp[i][j]) {           if (cnt[i] > cnt[j])             cout << i <<     << j;           else             cout << j <<     << i;           return 0;         }       }     }   }
#include <bits/stdc++.h>   int n, m;   std::vector<std::vector<int> > gr;   std::vector<int> par;   std::vector<bool> vis;   std::vector<int> lev;   void dfsgr(int v) {     vis[v] = true;     for (auto& ch : (gr[v])) {       if (vis[ch]) continue;       lev[ch] = lev[v] + 1;       par[ch] = v;       dfsgr(ch);     }   }   int lca(int a, int b) {     if (lev[a] > lev[b]) std::swap(a, b);     while (lev[b] != lev[a]) b = par[b];     while (a != b) {       a = par[a];       b = par[b];     }     return a;   }   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(0);     std::cin >> n >> m;     gr.resize(n);     vis.resize(n);     par.resize(n, -1);     lev.resize(n);     for (int i = 0; i < (m); ++i) {       int a, b;       std::cin >> a >> b;       a--;       b--;       gr[a].push_back(b);       gr[b].push_back(a);     }     dfsgr(0);     int q;     std::cin >> q;     std::vector<int> dd(n);     std::vector<std::vector<int> > paths;     for (int _ = 0; _ < (q); ++_) {       int a, b;       std::cin >> a >> b;       a--;       b--;       int lc = lca(a, b);       int pos = a;       std::vector<int> pth;       while (pos != lc) {         dd[pos] ^= 1;         pth.push_back(pos);         pos = par[pos];       }       pth.push_back(lc);       std::vector<int> nd;       pos = b;       while (pos != lc) {         dd[pos] ^= 1;         nd.push_back(pos);         pos = par[pos];       }       while (((int)(nd).size())) pth.push_back(nd.back()), nd.pop_back();       paths.push_back(std::move(pth));     }     bool good = true;     for (int i = 0; i < (n); ++i) {       if (dd[i]) good = false;     }     if (good) {       std::cout <<  YES n ;       for (auto& p : (paths)) {         std::cout << ((int)(p).size()) <<   n ;         for (auto& i : (p)) std::cout << i + 1 <<    ;         std::cout <<   n ;       }     } else {       std::cout <<  NO n ;       std::vector<std::vector<int> > ed(n);       for (int i = 0; i < (n); ++i)         if (dd[i]) {           ed[i].push_back(par[i]);           ed[par[i]].push_back(i);         }       std::fill(vis.begin(), vis.end(), false);       int xd = 0;       std::function<int(int)> dfs = [&](int v) {         vis[v] = true;         int mam = 0;         for (auto& ch : (ed[v]))           if (!vis[ch]) {             dfs(ch);             mam++;           }         xd += mam / 2;         return mam % 2;       };       int ans = 0;       for (int i = 0; i < (n); ++i)         if (!vis[i]) {           xd = 0;           if (dfs(i)) xd++;           ans += xd;         }       std::cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   long long n, k, t, m, q, flag = 0;   long long po(long long k, long long n, long long ans, long long temp,                long long ans1) {     if (n == 0) return ans;     while (temp <= n) {       ans *= ans1;       ans %= mod;       ans1 = ans1 * ans1;       ans1 %= mod;       n = n - temp;       temp *= 2;     }     return po(k, n, ans, 1, k) % mod;   }   long long min(long long a, long long b) {     if (a > b)       return b;     else       return a;   }   long long max(long long a, long long b) {     if (a > b)       return a;     else       return b;   }   long long md[100 + 1][100 + 1];   vector<long long> v[100 + 1];   long long bfs(long long i, long long j, queue<long long> q, long long z,                 map<long long, long long> m1) {     long long o = q.size();     if (o == 0) return -1;     for (int l = 0; l < o; l++) {       long long b = q.front();       if (b == j)         return z;       else {         if (m1[b] != 1)           for (int i = 0; i < v[b].size(); i++) {             q.push(v[b][i]);           }         m1[b] = 1;         q.pop();       }     }     return bfs(i, j, q, z + 1, m1);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     t = 1;     while (t--) {       cin >> n;       char c[n][n];       for (int i = 0; i < n; i++)         for (int j = 0; j < n; j++) cin >> c[i][j];       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           if (c[i][j] ==  1 ) v[i + 1].push_back(j + 1);         }       }       for (int i = 0; i < n; i++) {         for (int j = 0; j < n; j++) {           queue<long long> q;           map<long long, long long> m1;           q.push(i + 1);           md[i + 1][j + 1] = bfs(i + 1, j + 1, q, 0, m1);         }       }       long long m;       cin >> m;       long long a[m];       for (int i = 0; i < m; i++) cin >> a[i];       vector<long long> ans;       long long pi = a[0], pii = 0;       ans.push_back(a[0]);       for (int i = 1; i < m; i++) {         if (md[pi][a[i]] == i - pii)           ;         else {           ans.push_back(a[i - 1]);           pi = a[i - 1];           pii = i - 1;         }       }       cout << ans.size() + 1;       cout <<   n ;       for (int i = 0; i < ans.size(); i++) {         cout << ans[i] <<    ;       }       cout << a[m - 1];     }     return 0;   }
#include <bits/stdc++.h>   const int N = 600000 + 7;   using namespace std;   char o[] = { I ,  E ,  A ,  O ,  U ,  Y };   bool mark[N];   long long sum[N];   long double ans;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string s;     cin >> s;     for (int i = 0; i < (((int)s.size())); i++)       for (int j = 0; j < (6); j++)         if (s[i] == o[j]) mark[i + 1] = true;     int n = ((int)s.size());     for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + mark[i];     long long cnt = sum[n];     ans = cnt;     for (int i = 2; i <= n; i++) {       cnt += (sum[n - i + 1] - sum[i - 1]);       ans += (long double)cnt / (long double)i;     }     cout << setprecision(7) << fixed << ans << endl;   }