malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int oo = numeric_limits<int>::max();   const long long M = 998244353, MAXN = 1e6 + 10;   long long n, c[MAXN];   long long mp(long long a, long long e) {     long long ret = 1;     while (e) {       if (e % 2) ret = ret * a % M;       a = a * a % M;       e /= 2;     }     return ret;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0);     cin >> n;     c[0] = 1;     for (int i = 0; i < n; i++)       c[i + 1] = c[i] * (n - i) % M * mp(i + 1, M - 2) % M;     long long ans = 0;     for (int i = 1; i <= n; i++) {       long long add = (i + 1) % 2 ? -1 : 1;       add *= c[i];       add = add * mp(3, n * (n - i) + i) % M;       ans = (ans + add) % M;     }     ans = ans * 2 % M;     for (int i = 0; i < n; i++) {       long long add = (i + 1) % 2 ? -1 : 1;       add *= c[i];       long long inner = (mp(1 - mp(3, i), n) - mp(-mp(3, i), n)) % M;       add = 3 * add * inner % M;       ans = (ans + add) % M;     }     while (ans < 0) ans += M;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int sh = 1e6;   const int ppr = 257;   const long long INF = 1e18;   const int inf = 1e9;   const int mod = 1e9 + 7;   const int N = 6e5 + 123;   const long double pi = 3.141592653589793238462643;   const int dx[] = {1, 0, -1, 0};   const int dy[] = {0, 1, 0, -1};   vector<int> g[N];   int T, n, a[N], b[N];   int main() {     cin >> T;     while (T--) {       cin >> n;       for (int i = 1; i <= n + 1; i++) g[i].clear(), b[i] = 0;       for (int i = 1; i <= n; i++) {         cin >> a[i];         if (a[i] == -1) a[i] = i + 1;         g[a[i]].push_back(i);       }       for (int i = 1; i <= n + 1; i++) sort(g[i].begin(), g[i].end());       queue<int> q;       int timer = n + 1;       q.push(n + 1);       while (!q.empty()) {         int v = q.front();         q.pop();         b[v] = timer--;         for (auto j : g[v]) {           if (b[j] > 0) continue;           q.push(j);         }       }       stack<int> st;       bool ok = 1;       for (int i = n; i >= 1; i--) {         while (!st.empty() && b[st.top()] < b[i]) st.pop();         if ((st.empty() && a[i] != n + 1) || (!st.empty() && a[i] != st.top())) {           ok = 0;           break;         }         st.push(i);       }       if (!ok) {         cout << -1 <<   n ;         continue;       }       for (int i = 1; i <= n; i++) cout << b[i] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cout.tie(NULL);     cin.tie(NULL);     ;     int n, m;     cin >> n >> m;     set<long long> s;     long long ans = 0;     long long a[n];     long long b[m];     long long mx = 0;     map<long long, long long> mp;     bool f = true;     set<long long> st;     for (int i = 0; i < n; i++) {       cin >> a[i];       mx = max(mx, a[i]);       s.insert(a[i]);       ans += m * a[i];       st.insert(a[i]);       mp[a[i]] += m - 1;     }     for (int i = 0; i < m; i++) {       cin >> b[i];       if (b[i] < mx) f = false;     }     if (!f) {       cout << -1 << endl;       return 0;     }     sort(b, b + m);     reverse(b, b + m);     for (int i = 0; i < m; i++) {       set<long long>::iterator it = s.upper_bound(b[i]);       --it;       if ((b[i] - *it) > 0 && st.find(b[i]) != st.end()) {         continue;       }       ans += b[i] - (*it);       mp[*it]--;       if (mp[*it] == 0) s.erase(it);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int val[100005], Max[100005], Min[100005];   int n;   int lef[100005], rig[100005];   void dfs(int r) {     if (lef[r] == 0) {       Max[r] = Min[r] = val[r];       return;     }     dfs(lef[r]);     dfs(rig[r]);     Max[r] = Max[rig[r]];     Min[r] = Min[lef[r]];   }   long long sum[100005];   int dep[100005];   void dfs(int r, long long s, int d) {     if (lef[r] == 0) {       sum[r] = s;       dep[r] = d;       return;     }     dfs(lef[r], s + Min[rig[r]], d + 1);     dfs(rig[r], s + Max[lef[r]], d + 1);   }   struct node {     int id, v;     friend bool operator<(node a, node b) { return a.v < b.v; }   } a[100005];   bool cmp(node a, int x) { return a.v < x; }   int main() {     scanf( %d , &n);     int x, y, root;     for (int i = 1; i <= n; i++) {       scanf( %d %d , &x, &y);       a[i].v = y;       a[i].id = i;       val[i] = y;       if (x == -1)         root = i;       else {         if (lef[x] == 0) {           lef[x] = i;         } else {           rig[x] = i;           if (val[lef[x]] > val[rig[x]]) {             swap(lef[x], rig[x]);           }         }       }     }     sort(a + 1, a + 1 + n);     dfs(root);     dfs(root, 0, 0);     int T;     scanf( %d , &T);     while (T--) {       scanf( %d , &x);       int t = lower_bound(a + 1, a + 1 + n, x, cmp) - a;       if (t == n + 1) t--;       t = a[t].id;       while (lef[t]) {         if (val[t] > x)           t = lef[t];         else           t = rig[t];       }       printf( %.10lf n , 1.0 * sum[t] / dep[t]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c;   int f[2001 * 2001];   int _GCD[2001][2001];   int GCD(int a, int b) {     if (_GCD[a][b]) return _GCD[a][b];     if (!b) return a;     return _GCD[a][b] = GCD(b, a % b);   }   int phi(int x) {     if (x & 1) return -1;     return 1;   }   int main() {     cin >> a >> b >> c;     for (int j = (1); j <= (b); j++)       for (int k = (1); k <= (c); k++)         if (GCD(j, k) == 1) f[j * k] += (b / j) * (c / k);     for (int x = (1); x <= (b * c); x++)       for (int y = 2 * x; y <= b * c; y += x) f[x] += f[y];     int ans = 0;     for (int i = (1); i <= (a); i++) {       vector<int> L;       int x, y;       for (x = i, y = 2; y * y <= x; y++)         if (x % y == 0) {           L.push_back(y);           while (x % y == 0) x /= y;         }       if (x != 1) L.push_back(x);       for (int s = (0); s <= ((1 << int((L).size())) - 1); s++) {         int x = 1, cnt = 0;         for (int j = (0); j <= (int((L).size()) - 1); j++)           if ((s >> j) & 1) cnt++, x *= L[j];         ans += phi(cnt) * f[x] * (a / i);       }     }     cout << (ans % (1 << 30) + (1 << 30)) % (1 << 30);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ans;   int father[1100];   int find(int x) {     if (father[x] == x) return x;     father[x] = find(father[x]);     return father[x];   }   bool Union(int x, int y) {     int f1 = find(x);     int f2 = find(y);     if (f1 == f2) return false;     if (f1 < f2)       father[f1] = f2;     else       father[f2] = f1;     ans++;     return true;   }   int n, m;   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) father[i] = i;     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       if (!Union(x, y)) {         cout <<  no  << endl;         return 0;       }     }     if (m != n - 1)       cout <<  no  << endl;     else       cout <<  yes  << endl;     return 0;   }
#include<bits/stdc++.h>   using namespace std;    const int N=1e5+77,B=330;    int n,q,a[N],t[N],b[N],l[N],r[N],m,g[N];    int nx(int x){return max(1,a[x]-t[b[x]]); }   int jp(int x){if(t[b[x]]>=B)return nx(x); return g[x]; }   void reb(int x)   {    for(int i=l[x]; i<=r[x]; i++)    {     int j=nx(i);      if(j<l[x])      g[i]=j;      else      g[i]=g[j];     }   }   void update(int x,int y,int v)   {    if(b[x]==b[y])    {     for(int i=x; i<=y; i++)      a[i]=max(1,a[i]-v);      reb(b[x]);      return;     }    for(int i=x; i<=r[b[x]]; i++)     a[i]=max(1,a[i]-v);     reb(b[x]);     for(int i=b[x]+1; i<b[y]; i++)    {     t[i]=min(t[i]+v,n);      if(t[i]<B)      reb(i);     }    for(int i=l[b[y]]; i<=y; i++)     a[i]=max(1,a[i]-v);     reb(b[y]);    }   void lca(int u,int v)   {    int lu=u,lv=v;     while(u!=v)    {     if(u<v)      swap(u,v),swap(lu,lv);      lu=u; u=jp(u);     }    u=lu,v=lv;     while(u!=v)    {     if(u<v)      swap(u,v);      u=nx(u);     }    printf( %d n ,u);    }   int main()   {    scanf( %d%d ,&n,&q);     for(int i=2; i<=n; i++)     scanf( %d ,&a[i]);     for(int x=1; x<=n; x+=B)    {     int y=min(x+B-1,n);      m++;      l[m]=x,r[m]=y;      for(int i=x; i<=y; i++)      b[i]=m;      reb(m);     }    while(q--)    {     int t;      scanf( %d ,&t);      if(t==1)     {      int x,y,v;       scanf( %d%d%d ,&x,&y,&v);       update(x,y,v);      }     else     {      int u,v;       scanf( %d%d ,&u,&v);       lca(u,v);      }    }      }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     int i, j;     char s[1000];     while (gets(s)) {       int l = strlen(s);       n = 0;       int num_jian = 0, num_jia = 1;       for (i = 0; i < l; ++i) {         if (s[i] ==  = ) {           i += 2;           while (i != l) {             n *= 10;             n += s[i] -  0 ;             ++i;           }         } else if (s[i] ==  - )           num_jian++;         else if (s[i] ==  + )           num_jia++;       }       int v_jian = 1;       if (num_jian < num_jia) v_jian = n;       if (num_jia * n - num_jian < n || num_jia - num_jian * n > n)         printf( Impossible n );       else {         printf( Possible n );         j = 0;         for (i = 0; i < l; ++i) {           if (s[i] ==  ? ) {             if (i == 0 || s[i - 2] ==  + ) {               if (num_jia == 1)                 printf( %d , n + num_jian * v_jian);               else                 printf( %d , (n + num_jian * v_jian) / num_jia);               if ((n + num_jian * v_jian) / num_jia > 5) j = 1;               n -= (n + num_jian * v_jian) / num_jia;               num_jia--;             } else if (s[i - 2] ==  - )               printf( %d , v_jian);           } else             printf( %c , s[i]);         }         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 66;   int power[MAX + 10];   int between[MAX + 10];   int extra[MAX + 10];   int ende[MAX + 10];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       long long foo;       cin >> foo;       int cc = 0;       bool good = true;       while (foo > 1) {         if (foo & 1) {           good = false;         }         cc++;         foo >>= 1;       }       if (good) {         power[cc]++;       } else {         between[cc]++;       }     }     int low = 1, high = power[0] + 1;     while (low < high) {       int mid = (low + high) >> 1;       int cur = mid;       for (int i = 0; i < MAX; i++) {         extra[i] = power[i] - cur;         int new_cur = min(cur, power[i + 1]);         ende[i] = cur - new_cur;         cur = new_cur;       }       bool fail = false;       int open = 0;       for (int i = MAX - 1; i >= 0; i--) {         open += ende[i];         open -= between[i];         open -= extra[i + 1];         if (open < 0) {           fail = true;           break;         }       }       open -= extra[0];       if (open < 0) {         fail = true;       }       if (fail) {         low = mid + 1;       } else {         high = mid;       }     }     if (low > power[0]) {       cout << -1 << endl;       return 0;     }     for (int i = low; i <= power[0]; i++) {       cout << i <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const N = int(2e5) + 7;   int const mod = int(1e9) + 7;   int a[N];   int ra[N], le[N];   int raB[N][31], leB[N][31];   int main() {     ios_base::sync_with_stdio(false);     ifstream in( input.txt );     int n;     cin >> n;     vector<int> st;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       while (st.size() > 0 && a[st.back()] <= a[i]) {         int ind = st.back();         st.pop_back();         int ll = 0;         if (st.size() > 0) {           ll = st.back();         }         le[ind] = ll;         ra[ind] = i;       }       st.push_back(i);       for (int j = 0; j <= 30; ++j) {         if (a[i] & (1 << j)) {           leB[i][j] = i;         } else {           leB[i][j] = leB[i - 1][j];         }       }     }     while (st.size() > 0) {       int ind = st.back();       st.pop_back();       int ll = 0;       if (st.size() > 0) {         ll = st.back();       }       le[ind] = ll;       ra[ind] = n + 1;     }     for (int i = n; i >= 0; --i) {       for (int j = 0; j <= 30; ++j) {         if (a[i] & (1 << j)) {           raB[i][j] = i;         } else {           raB[i][j] = raB[i + 1][j];         }       }     }     long long ans = 0;     for (int i = 1; i <= n; ++i) {       int indl = 0, indr = n + 1;       for (int j = 30; j >= 0; --j) {         if (!(a[i] & (1 << j)) && (leB[i - 1][j])) {           indl = max(indl, leB[i - 1][j]);         }       }       for (int j = 30; j >= 0; --j) {         if (!(a[i] & (1 << j)) && (raB[i + 1][j])) {           indr = min(indr, raB[i + 1][j]);         }       }       long long am1 = max(0, indl - le[i]);       long long am2 = max(0, i - max(indl, le[i]));       long long am3 = max(0, min(ra[i], indr) - i);       long long am4 = max(0, ra[i] - indr);       long long del = am1 * (am3 + am4) + am2 * am4;       ans += am1 * (am3 + am4) + am2 * am4;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, buc[26], cnt = 0, ok = 0, j, m, cntt = 0, dfn = 0, pre;   char a[2], s[100005];   int main() {     scanf( %d , &n);     pre = dfn;     cntt = 26;     for (i = 1; i <= n; i++) {       scanf( %s%s , a, s);       if (ok == 1) {         if (a[0] ==  ! ) cnt++;         if (a[0] ==  ? ) cnt++;       } else {         if (a[0] ==  ! ) {           dfn++;           cntt = 0;           m = strlen(s);           for (j = 0; j < m; j++) {             if (buc[s[j] -  a ] == pre) {               cntt++;               buc[s[j] -  a ] = dfn;             }           }           if (cntt == 1) ok = 1;           pre = dfn;         }         if (a[0] ==  . ) {           m = strlen(s);           for (j = 0; j < m; j++) {             if (buc[s[j] -  a ] == pre) {               cntt--;               buc[s[j] -  a ] = pre - 1;             }           }           if (cntt == 1) ok = 1;         }         if (a[0] ==  ? ) {           if (buc[s[0] -  a ] == pre) {             buc[s[0] -  a ] = pre - 1;             cntt--;           }           if (cntt == 1) ok = 1;         }       }     }     if (cnt)       printf( %d , cnt - 1);     else       printf( 0 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     long double a, b;     int d;     while (n > 0) {       n -= 1;       cin >> a >> b;       if (a == b) {         d = 0;       } else if (a > b) {         d = ceil((a - b) / 10);       } else if (a < b) {         d = ceil((b - a) / 10);       }       cout << d << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int gi() {     int x = 0, o = 1;     char ch = getchar();     while ((ch <  0  || ch >  9 ) && ch !=  - ) ch = getchar();     if (ch ==  - ) o = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * o;   }   struct dat {     int len, x, y, z, w;     int getr() const {       if (!len) return 1e9;       if (len == 3) return z;       return w;     }     bool operator<(const dat &A) const { return getr() > A.getr(); }     void print() {       if (len == 3)         cout << 3 <<   n  << x <<     << y <<     << z <<   n ;       else         cout << 4 <<   n  << x <<     << y <<     << z <<     << w <<   n ;     }   } ans3[N], ans4[N];   int n, q, a[N];   void solve3() {     static int L[N], R[N], st[N];     int tp = 0;     for (int i = 1; i <= n; i++) {       while (tp && a[st[tp]] <= a[i]) --tp;       L[i] = st[tp];       st[++tp] = i;     }     tp = 0;     for (int i = n; i; i--) {       while (tp && a[st[tp]] <= a[i]) --tp;       R[i] = st[tp];       st[++tp] = i;     }     for (int i = 1; i <= n; i++)       if (L[i] && R[i]) ans3[L[i]] = max(ans3[L[i]], (dat){3, L[i], i, R[i], 0});     tp = 0;     for (int i = 1; i <= n; i++) {       while (tp && a[st[tp]] >= a[i]) --tp;       L[i] = st[tp];       st[++tp] = i;     }     tp = 0;     for (int i = n; i; i--) {       while (tp && a[st[tp]] >= a[i]) --tp;       R[i] = st[tp];       st[++tp] = i;     }     for (int i = 1; i <= n; i++)       if (L[i] && R[i]) ans3[L[i]] = max(ans3[L[i]], (dat){3, L[i], i, R[i], 0});   }   bool cmp1(int x, int y) { return a[x] < a[y]; }   bool cmp2(int x, int y) { return a[x] > a[y]; }   void solve4() {     static int st1[N], st2[N], occ[N];     set<int> can;     int tp1 = 0, tp2 = 0;     for (int i = n; i; i--) {       while (tp1 && a[st1[tp1]] > a[i]) {         int tmp = st1[tp1];         --occ[tmp];         if (!occ[tmp]) can.insert(tmp);         --tp1;       }       st1[++tp1] = i;       while (tp2 && a[st2[tp2]] < a[i]) {         int tmp = st2[tp2];         --occ[tmp];         if (!occ[tmp]) can.insert(tmp);         --tp2;       }       st2[++tp2] = i;       occ[i] = 2;       int p = st1[lower_bound(st1 + 1, st1 + tp1 + 1, i, cmp1) - st1 - 1];       int q = st2[lower_bound(st2 + 1, st2 + tp2 + 1, i, cmp2) - st2 - 1];       if (p && q) {         auto it = can.lower_bound(max(p, q) + 1);         if (it != can.end()) {           int t = *it;           p = *lower_bound(st1 + 1, st1 + tp1 + 1, t, greater<int>());           q = *lower_bound(st2 + 1, st2 + tp2 + 1, t, greater<int>());           ans4[i] = (dat){4, i, min(p, q), max(p, q), t};         }       }     }   }   int main() {     cin >> n >> q;     for (int i = 1; i <= n; i++) a[i] = gi();     solve3();     solve4();     for (int i = n - 1; i; i--) {       ans3[i] = max(ans3[i], ans3[i + 1]);       ans4[i] = max(ans4[i], ans4[i + 1]);     }     for (int i = 1; i <= q; i++) {       int l = gi(), r = gi();       if (ans4[l].getr() <= r)         ans4[l].print();       else if (ans3[l].getr() <= r)         ans3[l].print();       else         puts( 0 );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100 + 10;   vector<int> v[maxn];   set<int> s;   int num[maxn];   bool cmp(int x, int y) { return num[x] > num[y]; }   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) cin >> num[i];     for (int i = 1; i <= n; i++) {       int tmp;       cin >> tmp;       v[tmp].push_back(i);     }     for (int i = 0; i < k; i++) {       int tmp;       cin >> tmp;       s.insert(tmp);     }     for (int i = 1; i <= n; i++) sort(v[i].begin(), v[i].end(), cmp);     int ans = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j < int(v[i].size()); j++) {         if (s.count(v[i][j])) {           ans++;           s.erase(v[i][j]);         }       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool f(int k, int n) {     int s = k;     while (k > 0) {       s += k % 10;       k /= 10;     }     return s == n;   }   int main() {     int i, n;     vector<int> ans;     cin >> n;     for (i = n - 100; i <= n + 100; ++i) {       if (f(i, n)) {         ans.push_back(i);       }     }     cout << ans.size() << endl;     for (i = 0; i < ans.size(); ++i) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 100000 + 10;   const double PI = M_PI;   const double eps = 1e-8;   int dcmp(double a) {     if (fabs(a) < eps) return 0;     if (a > 0) return 1;     return -1;   }   struct Point {     double x, y;     Point operator+(const Point &A) { return (Point){A.x + x, A.y + y}; }     Point operator-(const Point &A) { return (Point){x - A.x, y - A.y}; }   } P, Poly[Maxn];   int n;   struct Line {     Point P;     Point V;   } Line[Maxn];   double CalDJ(Point A, Point B) { return A.x * B.x + A.y * B.y; }   double CalCJ(Point A, Point B) { return A.x * B.y - A.y * B.x; }   double CalLen(Point A) { return sqrt(CalDJ(A, A)); }   double CalDIS(Point P, Point A, Point B) {     Point v1 = B - A, v2 = P - A, v3 = P - B;     if (dcmp(CalDJ(v1, v2)) < 0) return CalLen(v2);     if (dcmp(CalDJ(v1, v3)) > 0) return CalLen(v3);     return fabs(CalCJ(v1, v2) / CalLen(v1));   }   double Getdis(Point Q) {     long long dx = Q.x - P.x, dy = Q.y - P.y;     long long ret = dx * dx + dy * dy;     return ret;   }   double Max, Min;   void solve() {     scanf( %d , &n);     scanf( %lf%lf , &P.x, &P.y);     for (int i = 1; i <= n; i++) scanf( %lf%lf , &Poly[i].x, &Poly[i].y);     Min = Getdis(Poly[1]);     for (int i = 1; i <= n; i++) {       double di = Getdis(Poly[i]);       if (di > Max) Max = di;       if (di < Min) Min = di;     }     Poly[n + 1] = Poly[1];     for (int i = 1; i <= n; i++) {       double dis = CalDIS(P, Poly[i], Poly[i + 1]);       dis = dis * dis;       if (dis < Min) Min = dis;     }     double ans = PI * (Max - Min);     printf( %lf n , ans);   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   int vis[26], cnt[26], h[26];   set<int> e[26];   vector<string> S[1005];   int mp[26];   bool operator<=(string a, string b) {     for (int i = 0; i < min(a.size(), b.size()); i++) {       if (a[i] == b[i]) continue;       return mp[a[i] -  a ] < mp[b[i] -  a ];     }     return a.size() <= b.size();   }   int main() {     ios_base::sync_with_stdio(false);     string s;     int n, k, p;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> p;       for (int i = 1; i <= k; i++) {         cin >> s, S[p].push_back(s);         for (char c : s) h[c -  a ] = 1;       }     }     vector<string> v;     for (int i = 0; i < n; i++)       for (string s : S[i]) v.push_back(s);     for (int i = 1; i < v.size(); i++) {       string &s1 = v[i - 1], &s2 = v[i];       for (int i = 0; i < min(s1.size(), s2.size()); i++) {         if (s1[i] != s2[i]) {           int c1 = s1[i] -  a , c2 = s2[i] -  a ;           if (e[c1].find(c2) == e[c1].end()) e[c1].insert(c2), cnt[c2]++;           break;         }       }     }     vector<int> q;     int m = 0;     for (int i = 0; i < 26; i++) m += (h[i]);     for (int i = 0; i < 26; i++)       if (cnt[i] == 0 and h[i]) q.push_back(i);     for (int k = 0; k < q.size(); k++) {       int i = q[k];       vis[i] = 1;       for (int j : e[i]) {         if (vis[j]) continue;         cnt[j]--;         if (cnt[j] == 0) q.push_back(j);       }     }     bool ok = 1;     for (int i = 0; i < q.size(); i++) mp[q[i]] = i;     for (int i = 1; i < v.size(); i++) ok &= (v[i - 1] <= v[i]);     if (q.size() != m or !ok) cout <<  IMPOSSIBLE  <<   n , exit(0);     for (int i : q) cout << (char)(i +  a );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int d[6][3] = {{1, 0, 0},  {-1, 0, 0}, {0, 1, 0},                  {0, -1, 0}, {0, 0, 1},  {0, 0, -1}};   int main() {     int k, n, m, sn, sm, ans = 0;     cin >> k >> n >> m;     string plate[k][n];     bool visited[k][n][m];     for (int i = 0; i < k; i++)       for (int j = 0; j < n; j++) {         for (int N = 0; N < m; N++) visited[i][j][N] = false;         cin >> plate[i][j];       }     queue<vector<int> > q;     cin >> sn >> sm;     vector<int> init;     for (int i = 0; i < 3; i++) init.push_back(0);     int arr[3] = {0, sn - 1, sm - 1};     for (int i = 0; i < 3; i++) init[i] = arr[i];     q.push(init);     while (!q.empty()) {       vector<int> A = q.front();       visited[A[0]][A[1]][A[2]] = true;       ans++;       q.pop();       for (int i = 0; i < 6; i++) {         vector<int> B(A);         for (int j = 0; j < 3; j++) B[j] += d[i][j];         if (B[0] >= 0 && B[0] < k && B[1] >= 0 && B[1] < n && B[2] >= 0 &&             B[2] < m && plate[B[0]][B[1]][B[2]] ==  .  &&             !visited[B[0]][B[1]][B[2]]) {           q.push(B);           visited[B[0]][B[1]][B[2]] = true;         }       }     }     cout << ans;     return 0;   }