malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int head[100005];   struct edge {     int vet, next;   } E[200005];   int i, j, k, n, m, s, t, tot, L;   int top[100005];   int fa[100005];   int dep[100005];   int a[100005];   int dist[3005][3005];   double ans;   int X, Y, all;   int cyc[100005];   int getf(int x) {     if (x != fa[x]) fa[x] = getf(fa[x]);     return fa[x];   }   void add(int u, int v) {     E[++tot] = (edge){v, head[u]};     head[u] = tot;   }   void getroad(int u, int dad) {     if (u == Y) {       L = cyc[u] = 1;       return;     }     for (int e = head[u]; e != -1; e = E[e].next)       if (e != dad) {         getroad(E[e].vet, e ^ 1);         if (cyc[E[e].vet] > 0) {           cyc[u] = cyc[E[e].vet] + 1;           L = max(L, cyc[u]);         }       }   }   void dfs(int u, const int &anc, int dad, int deep) {     dep[u] = deep;     top[u] = anc;     for (int e = head[u]; e != -1; e = E[e].next)       if (e != dad && cyc[E[e].vet] == 0) dfs(E[e].vet, anc, e ^ 1, deep + 1);   }   void getdis(int u, const int &anc, int dad, int D) {     dist[anc][u] = D;     for (int e = head[u]; e != -1; e = E[e].next)       if (e != dad) getdis(E[e].vet, anc, e ^ 1, D + 1);   }   void DO() {     for (int i = 1; i <= n; i++) getdis(i, i, -1, 0);   }   int main() {     tot = -1;     memset(head, -1, sizeof(head));     scanf( %d , &n);     for (int i = 1; i <= n; i++) fa[i] = i;     for (int i = 1; i <= n; i++) {       int x, y;       scanf( %d%d , &x, &y);       x++;       y++;       if (getf(x) == getf(y)) {         X = x;         Y = y;         continue;       }       add(x, y);       add(y, x);       fa[getf(x)] = getf(y);     }     DO();     getroad(X, -1);     for (int i = 1; i <= n; i++)       if (cyc[i] > 0) dfs(i, i, -1, 0);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (i != j) {           if (top[i] == top[j])             ans += 1.0 / (dist[i][j] + 1);           else {             int x = dep[i] + dep[j];             int y = abs(cyc[top[i]] - cyc[top[j]]);             int z = L - y;             ans += 1.0 / (x + y + 1) + 1.0 / (x + z + 1) - 1.0 / (x + L);           }         }     ans += n;     printf( %.14f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[4], y[4], a[4], b[4];   vector<int> v[2];   void yes() {     puts( YES );     exit(0);   }   void add(bool is, int at, int to) {     if (is)       v[is].push_back(y[at]), v[is].push_back(y[to]);     else       v[is].push_back(x[at]), v[is].push_back(x[to]);   }   void can(int a, int b) {     if (v[0][0] <= a && v[0][1] >= a && v[1][0] <= b && v[1][1] >= b) yes();   }   int main() {     for (int i = 0; i < 4; i++) scanf( %d%d , x + i, y + i);     add(x[0] == x[1], 0, 1);     add(x[1] == x[2], 1, 2);     sort(v[0].begin(), v[0].end());     sort(v[1].begin(), v[1].end());     for (int i = 0; i < 4; i++) {       scanf( %d%d , a + i, b + i);       can(a[i], b[i]);     }     can((a[0] + a[2]) / 2, (b[0] + b[2]) / 2);     int dis = b[0] != b[2] ? abs(b[0] - b[2]) : abs(a[0] - a[2]),         mx = (a[0] + a[2]) / 2, my = (b[0] + b[2]) / 2;     for (int i = 0; i < 4; i++) {       int dis1 = abs(x[i] - mx) + abs(y[i] - my);       if (dis1 * 2 <= dis) yes();     }     puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   double pi = 2 * acos(0.0);   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &v) {     os <<  { ;     for (const auto &x : v) os <<     << x;     return os <<  } ;   }   void solve() {     long long int l, r, m;     cin >> l >> r >> m;     long long int a, b, c;     long long int mm = r - l;     long long int p, q, ss;     if (m < l) {       a = l;       b = l;       c = l + (l - m);       cout << a <<     << b <<     << c << endl;       return;     }     for (long long int i = l; i <= r; i++) {       p = m % i;       q = m / i;       q++;       ss = q * i;       ss -= m;       if (p <= mm) {         a = i;         c = l;         b = c + p;         break;       } else if (ss <= mm) {         a = i;         b = l;         c = l + ss;         break;       }     }     cout << a <<     << b <<     << c << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int test_cases;     cin >> test_cases;     for (int tc = 1; tc <= test_cases; tc++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   long long mod = 1e9 + 7, mod2 = 998244353;   using namespace std;   long long fac[10000000];   long long gcd(long long x, long long y) {     if (y == 0) return x;     return gcd(y, x % y);   }   long long fexp(long long a, long long b, long long m) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % m;       b /= 2;       a = a * a % m;     }     return ans;   }   long long inverse(long long a, long long p) { return fexp(a, p - 2, p); }   long long ncr(long long n, long long r, long long p) {     if (r == 0) return 1;     return (fac[n] * inverse(fac[n - r], p) % p * inverse(fac[r], p) % p) % p;   }   vector<long long> za(string s) {     long long n = s.size();     vector<long long> z(n);     long long x = 0, y = 0, p = 0;     for (long long i = 1; i < n; i++) {       z[i] = max(p, min(z[i - x], y - i + 1));       while (i + z[i] < n && s[z[i]] == s[i + z[i]]) {         x = i;         y = i + z[i];         z[i]++;       }     }     return z;   }   void subset(long long a[], long long k) {     for (int i = 1; i < pow(2, k); i++) {       for (int j = 0; j < k; j++) {         if (i & 1 << j) {           cout << a[j] <<    ;         }       }       cout <<   n ;       ;     }   }   vector<long long> pr(string s) {     long long n = s.length();     vector<long long> pi(n);     for (int i = 1; i < n; i++) {       int j = pi[i - 1];       while (j > 0 && s[i] != s[j]) j = pi[j - 1];       if (s[i] == s[j]) j++;       pi[i] = j;     }     return pi;   }   long long d[100005];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long n, s, l, r, x = 0;     cin >> n >> s;     for (long long i = 1; i < n; i++) {       cin >> l >> r;       d[l]++;       d[r]++;     }     for (long long i = 1; i <= n; i++) {       if (d[i] == 1) x++;     }     cout << fixed << setprecision(50) << ((2 * s) / (1.0 * x));   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   map<int, int> mp;   int a[11], aa[11];   int b[11];   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> b[i];       if (a[b[i]] == 0) {         a[b[i]]++;         mp[b[i]]++;       }     }     for (int i = 0; i < m; i++) {       int x;       cin >> x;       if (aa[x] == 0) {         aa[x]++;         mp[x]++;       }     }     for (int i = 0; i < n; i++) {       if (mp[b[i]] == 2) cout << b[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, y, a = 0, b = 0;     cin >> n;     vector<pair<int, int>> v;     while (n--) {       cin >> x >> y;       a += x;       b += y;       v.push_back(make_pair(x, y));     }     bool ok = 0;     if (a % 2 == 0 && b % 2 == 0) {       cout << 0;       return 0;     }     if (a % 2 && b % 2) {       for (auto i : v) {         if ((i.first % 2 == 0 && i.second % 2) ||             (i.first % 2 && i.second % 2 == 0)) {           ok = 1;           break;         }       }     }     cout << (ok ? 1 : -1);   }
#include <bits/stdc++.h>   const int MAXN = 3000 + 1000;   int n, sum;   int in[MAXN], out[MAXN];   struct Union_Find_Set {     int f[MAXN];     void Init(int N) {       for (int i = 1, _ = N; i <= _; i++) f[i] = i;     }     int Find(int x) { return x == f[x] ? x : f[x] = Find(f[x]); }     bool Union(int x, int y) {       x = Find(x);       y = Find(y);       if (x == y) return 0;       in[x] += in[y];       out[x] += out[y];       f[y] = x;       if (in[x] + out[x] > sum) return 1;       return 0;     }   } t;   struct Edge {     int u, v, w;     Edge() {}     Edge(int u, int v, int w) : u(u), v(v), w(w) {}     bool operator<(const Edge &a) const { return w < a.w; }   } G[MAXN];   void Init() {     int u, v, w;     scanf( %d , &n);     t.Init(n);     for (int i = 1, _ = n - 1; i <= _; i++) {       scanf( %d%d%d , &u, &v, &w);       G[i] = Edge(u, v, w);     }     for (int i = 1, _ = n; i <= _; i++) {       scanf( %d , &out[i]);       sum += out[i];       in[i] = 1;     }   }   void Solve() {     if (n == 1) {       puts( 0 );       return;     }     int u, v;     std::sort(G + 1, G + n);     for (int i = 1, _ = n - 1; i <= _; i++) {       if (t.Union(G[i].u, G[i].v)) {         printf( %d n , G[i].w);         return;       }     }   }   int main() {     Init();     Solve();   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   namespace _buff {   const size_t BUFF = 1 << 19;   char buff[BUFF], *begin = buff, *end = buff;   char getc() {     if (begin == end) {       begin = buff;       end = buff + fread(buff, 1, BUFF, stdin);     }     return begin == end ? -1 : *begin++;   }   }  // namespace _buff   LL read() {     using namespace _buff;     LL ret = 0;     bool pos = true;     char c = getc();     for (; (c <  0  || c >  9 ) && c !=  - ; c = getc()) {       assert(~c);     }     if (c ==  - ) {       pos = false;       c = getc();     }     for (; c >=  0  && c <=  9 ; c = getc()) {       ret = (ret << 3) + (ret << 1) + (c ^ 48);     }     return pos ? ret : -ret;   }   const size_t N = 100 + 5;   const int MOD = 1e9 + 7;   void add(int &dp, LL val) { dp = (dp + val) % MOD; }   int f[N][N], g[N][N][N], cnt3[N], d[N];   LL getG(int i, int j, int k) {     if (i < 0 || j < 0 || k < 0) return 0;     return g[i][j][k];   }   int main() {     int n = read();     for (int i = 1; i <= n; ++i) {       cnt3[i] = cnt3[i - 1] + ((d[i] = read()) & 1);     }     g[0][0][0] = 1;     for (int c0 = 0; c0 <= n; ++c0) {       for (int c2 = 0; c2 <= n; ++c2) {         for (int c1 = !c2; c1 <= n; ++c1) {           int &cg = g[c0][c1][c2];           if (c2 > 0) {             add(cg, getG(c0 - 2, c1, c2 - 1) * c0 * (c0 - 1) / 2);             add(cg, getG(c0 - 1, c1 + 1, c2 - 2) * c0 * (c2 - 1));             add(cg, getG(c0, c1 + 2, c2 - 3) * (c2 - 1) * (c2 - 2) / 2);             add(cg, getG(c0, c1, c2 - 2) * (c2 - 1) * c1);             add(cg, getG(c0 - 1, c1 - 1, c2 - 1) * c0 * c1);             add(cg, getG(c0, c1 - 2, c2 - 1) * c1 * (c1 - 1) / 2);           } else {             add(cg, getG(c0 - 1, c1 - 1, c2) * c0);             add(cg, getG(c0, c1 - 2, c2) * (c1 - 1));           }         }       }     }     f[n + 1][n] = 1;     for (int l = n; l >= 2; --l) {       for (int r = l; r <= n; ++r) {         int c2 = cnt3[r] - cnt3[l - 1];         int c1 = r - l + 1 - c2;         for (int k = 0; k + r <= n; ++k) {           add(f[l][r], static_cast<LL>(f[r + 1][r + k]) * g[k][c1][c2]);         }       }     }     printf( %d n , f[2][d[1] + 1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void func(void) {     freopen( input.c ,  r , stdin);     freopen( output.c ,  w , stdout);   }   void print(vector<long long> &v) {     cout << v.size() << endl;     for (int i = 0; i < v.size(); i++) {       printf( %lld  , v[i]);     }     printf(  n );   }   void print(vector<pair<long long, long long> > &v) {     cout << v.size() << endl;     for (int i = 0; i < v.size(); i++) {       printf( %lld %lld n , v[i].first, v[i].second);     }   }   void print(double d) { cout << fixed << setprecision(10) << d << endl; }   void print(string s, double d) {     cout << s <<    ;     cout << fixed << setprecision(10) << d << endl;   }   int main() {     long long n, q, i, j = 0, temp, t, k, ans = 0, sum = 0, x, y, z, cnt = 0, m,                        fg = 0, mx = 0, mx1 = 0, mn = 8000000000000000000,                        mn1 = 8000000000000000000;     cin >> t;     while (t--) {       cin >> n;       vector<int> v1, v2, temp1;       for (int i = 0; i < n; i++) {         cin >> x;         v1.push_back(x);       }       for (int i = 0; i < n; i++) {         cin >> x;         v2.push_back(x);       }       int mid = (n + 1) / 2;       vector<pair<int, int> > vp1, vp2;       for (int i = 0; i < mid; i++) {         vp1.push_back({v1[i], v1[n - i - 1]});         vp2.push_back({v2[i], v2[n - i - 1]});         if (vp1[i].first > vp1[i].second) swap(vp1[i].first, vp1[i].second);         if (vp2[i].first > vp2[i].second) swap(vp2[i].first, vp2[i].second);       }       sort(vp1.begin(), vp1.end());       sort(vp2.begin(), vp2.end());       if (vp1 == vp2) {         cout <<  Yes n ;       } else         cout <<  No n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int kMaxN = 1000005;   int aib[2 * kMaxN];   int x[kMaxN], poz[kMaxN];   int el[2 * kMaxN];   bool first[kMaxN];   void aib_update(int ind, int val) {     while (ind < 2 * kMaxN) {       aib[ind] += val;       ind += ind & (-ind);     }     return;   }   int aib_search(int val) {     int p = 20;     int rez = 0;     for (; p >= 0; --p)       if ((1 << p) + rez < 2 * kMaxN)         if (aib[(1 << p) + rez] < val) {           val -= aib[(1 << p) + rez];           rez += (1 << p);         }     return rez + 1;   }   int main() {     int n, m;     ios_base::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i <= m; ++i) cin >> x[i] >> poz[i];     int st = m + 2;     for (int i = st; i < st + n; ++i) {       el[i] = 0;       aib_update(i, +1);     }     bool ok = true;     for (int i = 1; i <= m and ok; ++i) {       st--;       int p = aib_search(poz[i]);       if (first[x[i]] == false) {         if (el[p] != false) ok = false;         el[p] = x[i];         first[x[i]] = true;         el[st] = x[i];         aib_update(p, -1);         aib_update(st, +1);       } else {         if (el[p] != x[i]) ok = false;         aib_update(p, -1);         aib_update(st, +1);         el[st] = x[i];       }     }     if (not ok)       cout <<  -1 n ;     else {       int st = m + 2;       int dr = 1;       for (int i = st; i < st + n; ++i)         if (el[i] == 0) {           while (first[dr] != 0) ++dr;           cout << dr <<    ;           ++dr;         } else {           cout << el[i] <<    ;         }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     unsigned long long t;     cin >> t;     while (t--) {       unsigned long long x1, x2, y1, y2;       cin >> x1 >> y1 >> x2 >> y2;       if (x1 == x2 || y1 == y2) {         cout << 1 <<   n ;       } else {         unsigned long long d = x2 - x1;         unsigned long long r = y2 - y1;         cout << d * r + 1 <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   int p[N], used[N];   void solve() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> p[i];     }     for (int i = 1; i <= n; i++) {       if (p[i] == i) {         cout <<  YES n ;         for (int j = 1; j <= n; j++) {           if (i == j) continue;           cout << i <<     << j <<   n ;         }         return;       }     }     for (int i = 1; i <= n; i++) {       if (used[i]) continue;       int j = i, length = 0;       while (!used[j]) {         used[j] = 1;         length++;         j = p[j];       }       if (length & 1) {         cout <<  NO ;         return;       }     }     memset(used, 0, sizeof used);     for (int i = 1; i <= n; i++) {       int j = p[i];       if (p[j] == i) {         cout <<  YES n ;         cout << i <<     << j <<   n ;         for (int l = 1; l <= n; l++) {           if (l == i || l == j || used[l]) continue;           int v = l, xr = 0;           while (!used[v]) {             used[v] = 1;             cout << v <<     << (xr == 0 ? i : j) <<   n ;             xr ^= 1;             v = p[v];           }         }         return;       }     }     cout <<  NO ;   }   int main() {     ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);     cout.setf(ios::fixed), cout.precision(20);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, m, i, j;     cin >> n >> m;     char a[200][200];     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) cin >> a[i][j];     vector<vector<long long> > b(200, vector<long long>(200));     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         if (a[i][j] ==  * ) {           b[i][j + 1]++;           b[i][j - 1]++;           b[i + 1][j]++;           b[i - 1][j]++;           b[i + 1][j + 1]++;           b[i + 1][j - 1]++;           b[i - 1][j + 1]++;           b[i - 1][j - 1]++;         }       }     }     char c[200][200];     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         if (a[i][j] ==  * )           c[i][j] = a[i][j];         else if (b[i][j] == 0)           c[i][j] =  . ;         else           c[i][j] = b[i][j] +=  0 ;       }     }     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         if (a[i][j] != c[i][j]) {           cout <<  NO  << endl;           return 0;         }       }     }     cout <<  YES  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 111;   vector<pair<int, int> > g[N];   void printAns(int id, int v, int u, double x) {     if (x >= 1) {       swap(v, u);       x -= 1;     }     x = 1 - x;     printf( 1 %d %d %d %.12lf n , id, u, v, x);   }   void dfs(int v, int par, double x) {     for (pair<int, int> e : g[v]) {       if (e.first == par) continue;       x += 2. / (int)g[v].size();       if (x >= 2) x -= 2;       printAns(e.second, v, e.first, x);       double y = x + 1;       if (y >= 2) y -= 2;       dfs(e.first, v, y);     }   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int v, u;       scanf( %d%d , &v, &u);       g[v].push_back(make_pair(u, i));       g[u].push_back(make_pair(v, i));     }     printf( %d n , n - 1);     double x = 0;     for (pair<int, int> e : g[1]) {       printAns(e.second, 1, e.first, x);       double y = x + 1;       if (y >= 2) y -= 2;       dfs(e.first, 1, y);       x += 2. / (int)g[1].size();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5 * 100005;   int sum[N];   char str[5 * 100005];   int costf[5 * 100005];   int costb[5 * 100005];   int n, a, b, t;   int main() {     scanf( %d , &n);     scanf( %d , &a);     scanf( %d , &b);     scanf( %d , &t);     cin >> str;     if (str[0] ==  h )       costf[1] = 1;     else       costf[1] = 1 + b;     for (int i = 2; i <= n; i++) {       if (str[i - 1] ==  h )         costf[i] = (costf[i - 1] + 1 + a);       else         costf[i] = (costf[i - 1] + 1 + a + b);     }     if (str[n - 1] ==  h )       costb[n] = 1;     else       costb[n] = (1 + b);     for (int i = n - 1; i >= 1; i--) {       if (str[i - 1] ==  h )         costb[i] = (costb[i + 1] + 1 + a);       else         costb[i] = (costb[i + 1] + 1 + a + b);     }     vector<int> v;     for (int i = n; i >= 1; i--) {       v.push_back(costb[i]);     }     int ans = 0;     for (int i = 1; i <= n; i++) {       int x = t;       if (costf[i] > x) {         break;       } else {         int temp = 0;         temp += i;         x -= costf[i];         x -= (a * i);         if (x > 0) temp += (upper_bound(v.begin(), v.end(), x) - v.begin());         if (temp > n) temp = n;         ans = max(ans, temp);       }     }     vector<int> vv;     for (int i = 2; i <= n; i++) {       vv.push_back(costf[i] - a - costf[1]);     }     for (int i = n; i >= 1; i--) {       int x = t;       if (costb[i] + costf[1] + a > x)         break;       else {         int temp = 0;         temp += (n - i + 1);         temp += 1;         x -= (costb[i] + a + costf[1]);         x -= (n - i + 2) * a;         if (x > 0) temp += (upper_bound(vv.begin(), vv.end(), x) - vv.begin());         if (temp > n) temp = n;         ans = max(ans, temp);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.precision(1);     cout << fixed;     double n, x, y;     cin >> n >> x >> y;     double s = (y * n) / 100;     int p = ceil(s) - x;     if (p >= 0)       cout << p;     else       cout << 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int n;     cin >> n;     int a, b;     int s1 = 0;     int s2 = 0;     int flag = 0;     while (n--) {       cin >> a >> b;       if ((a & 1) != (b & 1)) flag = 1;       s1 += a;       s2 += b;     }     cerr << s1 <<     << s2 << endl;     int ans = 0;     if (s1 % 2 != s2 % 2) {       ans = -1;     } else {       if (s1 % 2 == 0)         ans = 0;       else if (!flag)         ans = -1;       else         ans = 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m, n;     int i;     cin >> m >> n;     double p[m];     double pre[m];     p[0] = pow(1.0 / m, n);     pre[0] = p[0];     for (i = 1; i < m; i++) {       p[i] = pow(double(i + 1) / m, n) - pre[i - 1];       pre[i] = pre[i - 1] + p[i];     }     double a = 0;     for (int k = 1; k <= m; k++) {       a += k * p[k - 1];     }     cout << a << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     int arr[200] = {}, i, j, k, w, ans = 0;     for (i = 0; i < n; i++) cin >> arr[i];     cin >> w;     sort(arr, arr + n);     for (i = 0; i < n; i++) {       int c = 1;       for (j = i + 1; j < n; j++) {         if (arr[j] - arr[i] <= w)           c++;         else           break;       }       ans = (ans > c ? ans : c);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2010;   const int INF = (int)1e9;   char ch[N][N];   int n, m, k;   int CountSpider(int x, int y, int time) {     int ans = 0;     if (x - time >= 1 && ch[y][x - time] ==  R ) ans++;     if (x + time <= m && ch[y][x + time] ==  L ) ans++;     if (y - time >= 1 && ch[y - time][x] ==  D ) ans++;     if (y + time <= n && ch[y + time][x] ==  U ) ans++;     return ans;   }   int main() {     scanf( %d%d%d n , &n, &m, &k);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) scanf( %c , &ch[i][j]);       scanf(  n );     }     for (int j = 1; j <= m; ++j) {       int time = 0;       int ans = 0;       for (int i = 1; i <= n; ++i) {         ans += CountSpider(j, i, time);         time++;       }       printf( %d  , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N, F, M;     cin >> N >> F >> M;     int FR[200], MO[200];     vector<int> V;     int mi = 10000;     for (int i = 0; i < F; ++i) cin >> FR[i];     for (int j = 0; j < M; ++j) cin >> MO[j];     for (int i = 0; i < F; ++i) {       int cnt = 0;       for (int j = 0; j < M; ++j)         if (MO[j] % FR[i] == 0) cnt++;       if (cnt < mi) {         V.clear();         V.push_back(i + 1);         mi = cnt;       } else if (mi == cnt)         V.push_back(i + 1);     }     cout << V.size() << endl;     for (int i = 0; i < V.size(); ++i) {       if (i < V.size() - 1)         cout << V[i] <<    ;       else         cout << V[i] << endl;     }   }