malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int i, n, d, e;     cin >> n >> d >> e;     e *= 5;     int min = n % e;     for (i = 0; i <= n / d; i++) {       if ((n - (i * d)) % e < min) min = (n - (i * d)) % e;     }     if ((n % e) % d < min) min = (n % e) % d;     cout << min;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e5 + 30;   struct edge {     int to, next;   } G[maxn << 1];   int h[maxn], si;   void add(int u, int v) {     G[si].to = v;     G[si].next = h[u];     h[u] = si++;   }   vector<int> p;   void dfs(int u, int f, int d) {     int is = 0;     for (int i = h[u]; ~i; i = G[i].next) {       int v = G[i].to;       if (v ^ f) {         dfs(v, u, d + 1);         is = 1;       }     }     if (!is) p.push_back(d);   }   int solve(int u) {     p.clear();     dfs(u, 1, 1);     int cur = -1;     sort(p.begin(), p.end());     for (int i = 0; i < p.size(); i++) {       if (cur < p[i])         cur = p[i];       else         cur++;     }     return cur;   }   int main() {     int n;     while (~scanf( %d , &n)) {       memset(h, -1, sizeof h);       si = 0;       int u, v;       for (int i = 0; i < n - 1; i++) {         scanf( %d%d , &u, &v);         add(u, v);         add(v, u);       }       int ans = 0;       for (int i = h[1]; ~i; i = G[i].next) ans = max(ans, solve(G[i].to));       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int K[3];   long long T[3];   queue<long long> waiting[3];   queue<pair<long long, long long> > events[3];   long long res = 0;   void ServeSomeone(long long t) {     for (int i = 0; i < 3; i++)       if (K[i] && !waiting[i].empty()) {         K[i]--;         events[i].push(make_pair(waiting[i].front(), t + T[i]));         waiting[i].pop();       }   }   void ProcessEvents(long long max_time) {     while (true) {       int mini = -1;       for (int i = 0; i < 3; i++)         if (!events[i].empty() && (mini == -1 || events[i].front().second <                                                      events[mini].front().second))           mini = i;       if (mini == -1) break;       if (events[mini].front().second > max_time) break;       pair<long long, long long> m = events[mini].front();       events[mini].pop();       K[mini]++;       if (mini == 2) {         res = max(res, m.second - m.first);       } else {         waiting[mini + 1].push(m.first);       }       ServeSomeone(m.second);     }   }   int main() {     cin >> K[0] >> K[1] >> K[2];     cin >> T[0] >> T[1] >> T[2];     int N;     cin >> N;     for (int i = 0; i < N; i++) {       long long next_arrival;       cin >> next_arrival;       ProcessEvents(next_arrival);       waiting[0].push(next_arrival);       ServeSomeone(next_arrival);     }     ProcessEvents(1000000000000000000LL);     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   int trie[64 * 100005][2], uni;   inline long long int bin_to_int(vector<long long int> vt) {     long long int ans = 0, hudai = 1;     while (vt.size()) {       ans += (hudai * vt[vt.size() - 1]);       hudai *= 2;       vt.pop_back();     }     return ans;   }   inline vector<long long int> int_to_bin(long long int n) {     vector<long long int> ans(64), tem;     while (n > 0) {       tem.push_back(n % 2);       n /= 2;     }     for (int i = 0; i < (tem.size()); i++) {       ans[63 - i] = tem[i];     }     return ans;   }   inline long long int search(vector<long long int> vt) {     int cur = 1;     vector<long long int> ans;     for (int i = 0; i < (64); i++) {       int id = (vt[i] + 1) % 2;       if (trie[cur][id]) {         ans.push_back(1);         cur = trie[cur][id];       } else {         ans.push_back(0);         cur = trie[cur][vt[i]];       }     }     return bin_to_int(ans);   }   inline void insert(vector<long long int> vt) {     int cur = 1;     for (int i = 0; i < (64); i++) {       int id = vt[i];       if (!trie[cur][id]) trie[cur][id] = ++uni;       cur = trie[cur][id];     }     return;   }   int main() {     int n;     scanf( %d , &n);     vector<long long int> vt;     uni = 1;     for (int i = 0; i < (n); i++) {       long long int xx;       scanf( %lld , &xx);       vt.push_back(xx);     }     vector<long long int> hudai;     hudai.push_back(0);     vt.push_back(0);     for (int i = 0; i < (n); i++)       hudai.push_back(hudai[hudai.size() - 1] ^ vt[i]);     long long int maximum = 0;     long long int xr = 0;     for (int i = hudai.size() - 1; i >= 0; i--) {       long long int xx = hudai[i];       xr = xr ^ vt[i];       vector<long long int> tem = int_to_bin(xr);       insert(tem);       tem = int_to_bin(xx);       maximum = max(maximum, search(tem));     }     printf( %lld n , maximum);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, st, dr, mij, r, l12, l11, c12, c11;   int l21, l22, c21, c22;   int nr;   void getldrept(int li, int ls, int ci, int cs) {     int st, dr;     int l1, c1, l2, c2;     st = li;     dr = ls;     while (st < dr) {       mij = (st + dr) / 2;       cout <<  ?   << li <<     << ci <<     << mij <<     << cs <<   n ;       cin >> r;       if (r)         dr = mij;       else         st = mij + 1;     }     l2 = st;     st = li;     dr = l2;     while (st < dr) {       mij = (st + dr + 1) / 2;       cout <<  ?   << mij <<     << ci <<     << l2 <<     << cs <<   n ;       cin >> r;       if (r)         st = mij;       else         dr = mij - 1;     }     l1 = st;     st = ci;     dr = cs;     while (st < dr) {       mij = (st + dr) / 2;       cout <<  ?   << l1 <<     << ci <<     << l2 <<     << mij <<   n ;       cin >> r;       if (r)         dr = mij;       else         st = mij + 1;     }     c2 = st;     st = ci;     dr = c2;     while (st < dr) {       mij = (st + dr + 1) / 2;       cout <<  ?   << l1 <<     << mij <<     << l2 <<     << c2 <<   n ;       cin >> r;       if (r)         st = mij;       else         dr = mij - 1;     }     c1 = st;     if (nr == 1) {       l11 = l1;       l12 = l2;       c11 = c1;       c12 = c2;     } else {       l21 = l1;       l22 = l2;       c21 = c1;       c22 = c2;     }   }   int main() {     cin >> n;     nr = 1;     getldrept(1, n, 1, n);     nr = 2;     if (l11 > 1) {       cout <<  ?   << 1 <<     << 1 <<     << l11 - 1 <<     << n <<   n ;       cin >> r;       if (r) {         getldrept(1, l11 - 1, 1, n);         cout <<  !   << l11 <<     << c11 <<     << l12 <<     << c12;         cout <<     << l21 <<     << c21 <<     << l22 <<     << c22;         return 0;       }     }     if (l12 < n) {       cout <<  ?   << l12 + 1 <<     << 1 <<     << n <<     << n <<   n ;       cin >> r;       if (r) {         getldrept(l12 + 1, n, 1, n);         cout <<  !   << l11 <<     << c11 <<     << l12 <<     << c12;         cout <<     << l21 <<     << c21 <<     << l22 <<     << c22;         return 0;       }     }     if (c11 > 1) {       cout <<  ?   << 1 <<     << 1 <<     << n <<     << c11 - 1 <<   n ;       cin >> r;       if (r) {         getldrept(1, n, 1, c11 - 1);         cout <<  !   << l11 <<     << c11 <<     << l12 <<     << c12;         cout <<     << l21 <<     << c21 <<     << l22 <<     << c22;         return 0;       }     }     if (c12 < n) {       cout <<  ?   << 1 <<     << c12 + 1 <<     << n <<     << n <<   n ;       cin >> r;       if (r) {         getldrept(1, n, c12 + 1, n);         cout <<  !   << l11 <<     << c11 <<     << l12 <<     << c12;         cout <<     << l21 <<     << c21 <<     << l22 <<     << c22;         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int rev(int a) {     bitset<8> bs(a);     string s = bs.to_string();     reverse((s).begin(), (s).end());     return bitset<32>(s).to_ulong();   }   int main() {     string line;     getline(cin, line);     for (int i = 0; i < (int)(line.length()); i++) {       int p = i == 0 ? 0 : line[i - 1];       int c = line[i];       int x = (rev(p) - rev(c) + 256) % 256;       ;       printf( %d n , x);     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx )   using namespace std;   template <class U, class V>   istream& operator>>(istream& is, pair<U, V>& p) {     is >> p.first >> p.second;     return is;   }   template <class T>   istream& operator>>(istream& is, vector<T>& v) {     for (auto& x : v) {       is >> x;     }     return is;   }   template <class T>   ostream& operator<<(ostream& os, vector<T>& v) {     for (auto& x : v) {       os << x <<    ;     }     return os;   }   const int N = 2e5 + 5;   vector<int> adj[N];   vector<int> parents[N];   int cnt_parents[N];   bool removed[N];   int n;   void init() {     for (int i = 1; i <= n; ++i) {       adj[i].clear();       parents[i].clear();       cnt_parents[i] = 0;       removed[i] = false;     }   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   vector<int> solve() {     static vector<int> res;     static vector<int> perm;     perm.clear();     res.clear();     for (int i = 1; i <= n; ++i) {       removed[i] = false;       perm.emplace_back(i);     }     shuffle(begin(perm), end(perm), rng);     for (int i : perm) {       if (removed[i]) continue;       for (int child : adj[i]) {         if (removed[child]) continue;         for (int grand : adj[child]) {           if (removed[grand]) continue;           res.emplace_back(grand);           removed[grand] = true;         }       }     }     return res;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int t;     cin >> t;     vector<int> res;     while (t--) {       res.clear();       int m;       cin >> n >> m;       init();       while (m--) {         int u, v;         cin >> u >> v;         adj[u].emplace_back(v);         ++cnt_parents[v];         parents[v].emplace_back(u);       }       for (int i = 1; i <= n; ++i) {         bool to_remove = false;         for (int parent : parents[i]) {           if (cnt_parents[parent] == 0 || removed[parent]) continue;           to_remove = true;           break;         }         if (!to_remove) continue;         res.emplace_back(i);         removed[i] = true;         for (int v : adj[i]) {           --cnt_parents[v];         }       }       for (int i = 0; i < 30; ++i) {         auto tmp = solve();         if (tmp.size() < res.size()) {           swap(res, tmp);         }       }       cout << res.size() <<   n ;       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int pr(int n) {     for (int i = 2; i * i <= n; i++)       if (n % i == 0) return 0;     return 1;   }   int near(int n) {     int i = 0;     for (i = n - 2; i >= 2; i--) {       if (pr(i)) break;     }     return i;   }   int main() {     int i, n, s1, j = 0, s2 = 0, counter = 0, x = 0;     int ara[10] = {0};     cin >> n;     if (pr(n)) {       cout << 1 << endl;       cout << n << endl;       return 0;     } else {       s1 = near(n);       ara[0] = s1;       j++;       s2 = n - s1;       if (pr(s2) == 1) {         printf( 2 n );         printf( %d %d , s1, s2);         return 0;       }       x = near(s2);       while (pr(s2 - x) == 0) {         x = near(x - 1);       }       printf( 3 n );       printf( %d %d %d , s1, x, n - s1 - x);       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     unsigned long long n, ans = 0, a[30], cur, deg = 20, countOfPair = 1;     cin >> n;     memset(a, 0, sizeof(unsigned long long) * 30);     for (int i = 0; i < n; ++i) {       cin >> cur;       ++a[cur + 10];     }     for (int i = 0; i < 10; ++i) {       ans += a[i] * a[deg + i];       deg -= 2;     }     if (a[10] != 0 && a[10] != 1) {       if (a[10] == 2)         ans += 1;       else {         for (unsigned int i = 3; i <= a[10]; ++i) {           countOfPair = countOfPair + i - 1;         }         ans += countOfPair;       }     }     cout << ans;     cin >> n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n;     cin >> n;     map<int, int> mp;     for (int i = 0; i < n; i++) {       int curr;       cin >> curr;       mp[curr]++;     }     vector<int> nums(mp.size());     int counter = 0;     vector<pair<int, int> > sorted(mp.size());     for (auto i : mp) {       sorted[counter].first = i.second;       sorted[counter].second = i.first;       nums[counter] = i.second;       counter++;     }     sort(sorted.begin(), sorted.end());     sort(nums.begin(), nums.end());     vector<int> sums(nums.size());     sums[nums.size() - 1] = nums.back();     for (int i = sums.size() - 2; i >= 0; i--) {       sums[i] = sums[i + 1] + nums[i];     }     int sqr = (int)sqrt(n);     int mx = 0;     pair<int, int> dimensions;     for (int i = sqr; i > 0; i--) {       int low = 0;       int high = nums.size() - 1;       while (low <= high) {         int mid = (low + high) >> 1;         if (nums[mid] <= i) {           low = mid + 1;         } else {           high = mid - 1;         }       }       int res = n;       if (i < nums.back()) {         res -= sums[low] - (nums.size() - low) * i;       }       low = i;       high = n;       if (res < i * i) {         continue;       }       while (low <= high) {         int mid = (low + high) >> 1;         if (mid * i < res) {           low = mid + 1;         } else if (mid * i > res) {           high = mid - 1;         } else {           high = mid;           break;         }       }       if (mx < i * high) {         mx = i * high;         dimensions.first = i;         dimensions.second = high;       }     }     cout << mx <<   n ;     cout << dimensions.first <<     << dimensions.second <<   n ;     int arr[dimensions.first][dimensions.second];     auto itr = sorted.rbegin();     counter = min((*itr).first, dimensions.first);     for (int i = 0; i < dimensions.second; i++) {       int start = i;       for (int a = 0; a < dimensions.first; a++) {         if (counter == 0) {           itr++;           counter = min((*itr).first, dimensions.first);         }         arr[a][start] = (*itr).second;         counter--;         start = (start + 1) % dimensions.second;       }     }     for (int i = 0; i < dimensions.first; i++) {       for (int a = 0; a < dimensions.second - 1; a++) {         cout << arr[i][a] <<    ;       }       cout << arr[i][dimensions.second - 1] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   struct Edge {     int u;     int v;     Edge() {}     Edge(int u, int v) : u(u), v(v) {}   };   struct WeightedEdge : Edge {     int w;   };   struct EdgeGroup {     int q;     vector<Edge> edges;     EdgeGroup() { q = -1; }     EdgeGroup(int q) : q(q) {}   };   const int MAX_M = 500005;   const int MAX_W = 500005;   const int MAX_N = 500005;   const int MAX_Q = 500005;   WeightedEdge raw_edge[MAX_M];   int vertex_set[MAX_N];   int cycle_set[MAX_N];   vector<Edge> edge[MAX_W];   vector<EdgeGroup> edge_group[MAX_W];   bool ans[MAX_Q];   int get_canonical(int disjoint_set[], int v) {     if (disjoint_set[v] == v) return v;     return disjoint_set[v] = get_canonical(disjoint_set, disjoint_set[v]);   }   bool join(int disjoint_set[], int u, int v) {     u = get_canonical(disjoint_set, u);     v = get_canonical(disjoint_set, v);     if (u == v) {       return false;     }     disjoint_set[v] = u;     return true;   }   bool check(const vector<Edge> &edges) {     vector<Edge> canonic_edges;     for (auto e : edges) {       int v = get_canonical(vertex_set, e.v);       int u = get_canonical(vertex_set, e.u);       cycle_set[v] = v;       cycle_set[u] = u;       canonic_edges.emplace_back(u, v);     }     for (auto e : canonic_edges) {       if (!join(cycle_set, e.v, e.u)) return false;     }     return true;   }   int main() {     ios_base::sync_with_stdio(false);     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       vertex_set[i] = i;     }     for (int i = 1; i <= m; ++i) {       cin >> raw_edge[i].u >> raw_edge[i].v >> raw_edge[i].w;       edge[raw_edge[i].w].emplace_back(raw_edge[i].v, raw_edge[i].u);     }     int q;     cin >> q;     for (int i = 0; i < q; ++i) {       ans[i] = true;       int k;       cin >> k;       for (int j = 0; j < k; ++j) {         int edge_id;         cin >> edge_id;         int w = raw_edge[edge_id].w;         if (edge_group[w].empty() || edge_group[w].back().q != i) {           edge_group[w].emplace_back(i);         }         edge_group[w].back().edges.push_back(raw_edge[edge_id]);       }     }     for (int w = 1; w < MAX_W; ++w) {       for (auto group : edge_group[w]) {         ans[group.q] &= check(group.edges);       }       for (auto e : edge[w]) {         join(vertex_set, e.v, e.u);       }     }     for (int i = 0; i < q; ++i) {       cout << (ans[i] ?  YES  :  NO ) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int s = 0, w = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) w = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();     return s * w;   }   struct Edge {     int to, next, v, c;   } a[40001 << 7];   int h[40001], cnt = 1;   void add(int x, int y, int z, int w) {     a[++cnt] = (Edge){y, h[x], z, w}, h[x] = cnt,     a[++cnt] = (Edge){x, h[y], 0, -w}, h[y] = cnt;   }   int S, T, n, m, p[40001], d[40001];   int flow, val;   bool v[40001];   bool Spfa() {     std::queue<int> q;     memset(v, 0, sizeof(v));     memset(p, 0, sizeof(p));     memset(d, 0x3f, sizeof(d));     q.push(S), d[S] = 0, v[S] = 1;     while (!q.empty()) {       int x = q.front();       q.pop();       v[x] = 0;       for (int i = h[x]; i; i = a[i].next)         if (a[i].v && d[x] + a[i].c < d[a[i].to]) {           d[a[i].to] = d[x] + a[i].c, p[a[i].to] = i;           if (!v[a[i].to]) v[a[i].to] = 1, q.push(a[i].to);         }     }     if (d[T] == 1061109567) return 0;     return 1;   }   void Adjust() {     int minf = 0x7fffffff, x = T;     for (int i = T; i != S; i = a[p[i] ^ 1].to) minf = min(minf, a[p[i]].v);     for (int i = T; i != S; i = a[p[i] ^ 1].to)       a[p[i]].v -= minf, a[p[i] ^ 1].v += minf;     flow += minf, val += d[T] * minf;   }   int Edmonds_Karp() {     flow = val = 0;     while (Spfa()) Adjust();     return val;   }   int du[110];   signed main() {     int x, y, c, f, ans = 0;     n = read(), m = read(), add(n, 1, 0x7fffffff, 0), S = n + 1, T = n + 2;     for (int i = 1; i <= m; i++) {       x = read(), y = read(), c = read(), f = read();       if (c < f)         ans += f - c, add(y, x, f - c, 0), add(y, x, c, 1),             add(x, y, 0x7fffffff, 2);       else         add(x, y, c - f, 1), add(x, y, 0x7fffffff, 2), add(y, x, f, 1);       du[x] -= f, du[y] += f;     }     for (int i = 1; i <= n; i++)       if (du[i] > 0)         add(S, i, du[i], 0);       else         add(i, T, -du[i], 0);     cout << ans + Edmonds_Karp();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 100 * 1000 + 5;   const int mod = 1000 * 1000 * 1000;   int a[maxN];   int n;   string make(string s, int t) {     string res;     res.resize(n);     for (int i = t; i < n; i++) res[i] = s[i - t];     for (int i = 0; i < t; i++) res[i] = s[i + n - t];     return res;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     string s;     cin >> s;     vector<string> res;     for (int j = 0; j < 10; j++) {       for (int i = 0; i < n; i++)         if (s[i] ==  9 )           s[i] =  0 ;         else           s[i]++;       for (int i = 0; i < n; i++) res.push_back(make(s, i));     }     sort(res.begin(), res.end());     cout << res[0] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   const int M = 10005;   inline int read() {     int ret = 0, f = 0;     char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) f = 1;       c = getchar();     }     while (isdigit(c)) {       ret = ret * 10 + c - 48;       c = getchar();     }     if (f) return -ret;     return ret;   }   int T, mx, s, t, cnt, size, hh, n, m, x, y, sum, k, f[M], ha[M], v[M],       a[105][2005];   struct node {     int x, y;   } xu[N];   bool cmp(node a, node b) { return a.x < b.x; }   signed main() {     int xjh = 0;     T = read();     while (T--) {       cnt = 0;       n = read();       m = read();       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) {           xjh++;           a[i][j] = read();           xjh++;           xu[++cnt].x = a[i][j];           xu[cnt].y = j;           xjh++;           a[i + n][j] = a[i][j];         }       size = 0;       sort(xu + 1, xu + cnt + 1, cmp);       for (int i = cnt; i; i--) {         if (v[xu[i].y] == 0) {           size++;           xjh++;           v[xu[i].y] = 1;           xjh++;         }         if (size >= m) break;       }       mx = 1 << n;       for (int j = 1; j <= m; j++)         if (v[j] != 0) {           for (int s = 0; s < mx; s++) {             xjh++;             xjh++;             xjh--;             ha[s] = 0;             for (int i = 1; i <= n; i++) {               sum = 0;               xjh++;               for (int k = i; k < n + i; k++) {                 x = k - i;                 if (s & (1 << x)) sum = sum + a[k][j];               }               xjh++;               xjh++;               xjh--;               ha[s] = max(ha[s], sum);               xjh++;               xjh++;               xjh--;             }           }           for (int s = mx - 1; s >= 0; s--) {             for (int t = s; t; t = (t - 1) & s) {               xjh++;               f[s] = max(f[s], f[s ^ t] + ha[t]);               xjh++;               xjh++;               xjh--;             }           }         }       xjh++;       xjh++;       xjh--;       printf( %d n , f[mx - 1]);       xjh++;       xjh++;       xjh--;       for (int i = 0; i < mx; i++) f[i] = 0;       for (int j = 1; j <= m; j++) v[j] = 0;       xjh++;       xjh++;       xjh--;     }   }
#include <bits/stdc++.h>   using namespace std;   double n, m, k, r;   double f(int x, int y) {     x++;     y++;     return (min(n + 1, x + r) - max((double)x, r)) *            (min(m + 1, y + r) - max((double)y, r));   }   int main() {     cin >> n >> m >> r >> k;     double ans = 0;     double nbpos = (n - r + 1) * (m - r + 1);     int tot = 0;     priority_queue<pair<double, pair<int, int> > > q;     pair<double, pair<int, int> > cur;     q.push(make_pair(f(n / 2, m / 2), make_pair(n / 2, m / 2)));     set<pair<int, int> > done;     done.insert(make_pair(n / 2, m / 2));     pair<int, int> pos;     while (tot < k) {       cur = q.top();       pos = cur.second;       q.pop();       ans += cur.first;       if (pos.first - 1 >= 0 &&           done.find(make_pair(pos.first - 1, pos.second)) == done.end()) {         q.push(make_pair(f(pos.first - 1, pos.second),                          make_pair(pos.first - 1, pos.second)));         done.insert(make_pair(pos.first - 1, pos.second));       }       if (pos.first + 1 < n &&           done.find(make_pair(pos.first + 1, pos.second)) == done.end()) {         q.push(make_pair(f(pos.first + 1, pos.second),                          make_pair(pos.first + 1, pos.second)));         done.insert(make_pair(pos.first + 1, pos.second));       }       if (pos.second - 1 >= 0 &&           done.find(make_pair(pos.first, pos.second - 1)) == done.end()) {         q.push(make_pair(f(pos.first, pos.second - 1),                          make_pair(pos.first, pos.second - 1)));         done.insert(make_pair(pos.first, pos.second - 1));       }       if (pos.second + 1 < m &&           done.find(make_pair(pos.first, pos.second + 1)) == done.end()) {         q.push(make_pair(f(pos.first, pos.second + 1),                          make_pair(pos.first, pos.second + 1)));         done.insert(make_pair(pos.first, pos.second + 1));       }       tot++;     }     cout << setprecision(11) << ans / nbpos << endl;   }