malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:667772160 )   using namespace std;   struct __isoff {     __isoff() {       if (0) freopen( input.txt ,  r , stdin), freopen( output.txt ,  w , stdout);       srand( C  +  T  +  A  +  C  +  Y  +  M  +  B  +  A );     }     ~__isoff() {}   } __osafwf;   const unsigned long long p1 = 31;   const unsigned long long p2 = 29;   const double eps = 1e-8;   const double pi = acos(-1.0);   const int infi = 1e9 + 7;   const long long inf = 1e18 + 7;   const long long dd = 7e5 + 7;   const long long mod = 1e9 + 7;   const long long mod2 = 1e6 + 3;   long long fac[dd], ifac[dd];   long long pows(long long x, int p) {     if (p == 0) return 1;     if (p % 2) return pows(x, p - 1) * x % mod2;     x = pows(x, p / 2);     return x * x % mod2;   }   long long cnk(long long a, long long b) {     return fac[a] * ifac[b] % mod2 * ifac[a - b] % mod2;   }   const int fd = 1e3 + 7;   int H[dd], IH[dd], dp[fd];   int main() {     fac[0] = ifac[0] = 1;     for (int i = 1; i < dd; i++) {       fac[i] = fac[i - 1] * i % mod2;       ifac[i] = ifac[i - 1] * pows(i, mod2 - 2) % mod2;     }     int c, h, w;     cin >> c >> w >> h;     {       H[0] = 1;       for (int i = 1; i < dd; i++) {         H[i] = (H[i - 1] * h) % mod2;       }       IH[0] = 1;       for (int i = 1; i < dd; i++) {         IH[i] = (IH[i - 1] * pows(h, mod2 - 2)) % mod2;       }     }     dp[0] = 1;     deque<long long> G;     G.push_back(1);     G.push_back(1);     long long t = h + 1;     for (int i = 1; i <= c; i++) {       if (0) {         long long p = 1;         for (int j = i - 1, l = 0; j >= -1 && l <= w; j--, l++) {           long long t = 1;           if (j >= 0) {             t = dp[j];           }           dp[i] = (dp[i] + t * p) % mod2;           p = (p * h) % mod2;         }       }       {         G.push_back(t);         t = (t * h + t) % mod2;         if (G.size() > w + 1) {           t = ((t - G.front() * H[w + 1]) % mod2 + mod2) % mod2;           G.pop_front();         }       }     }     cout << G.back();   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 2e5 + 5;   void solve() {     long long int n, i, j, ans = 0;     cin >> n;     long long int a[n];     for (auto &x : a) {       cin >> x;     };     map<long long int, long long int> cnt;     for (i = 0; i < n; i++) {       for (j = i + 1; j < n; j++) {         cnt[a[i] + a[j]]++;         ans = max(ans, cnt[a[i] + a[j]]);       }     }     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);     long long int t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, s[3010], c[3010], ans = 1e10;     cin >> n;     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < n; i++) cin >> c[i];     for (int i = 0; i < n; i++) {       long long min1 = 1e10, min2 = 1e10;       for (int j = 0; j < i; j++) {         if (s[j] < s[i]) min1 = min(min1, c[j]);       }       for (int j = i; j < n; j++) {         if (s[j] > s[i]) min2 = min(min2, c[j]);       }       ans = min(ans, min1 + c[i] + min2);     }     if (ans >= 1e10)       puts( -1 );     else       cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d %d , &n, &m);     unordered_map<string, string> d;     for (int i = 0; i < m; i++) {       string x, y;       cin >> x >> y;       if ((int)x.size() > (int)y.size()) swap(x, y);       d[y] = d[x] = x;     }     for (int i = 0; i < n; i++) {       string x;       cin >> x;       cout << d[x] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int h;   long long n;   long long dfs(int d, long long n, int lr) {     if (d == h) return 0;     long long tmp = 1ll << (h - d - 1);     if (!lr && n <= tmp) return dfs(d + 1, n, !lr) + 1;     if (!lr && n > tmp) return (tmp << 1) + dfs(d + 1, n - tmp, 0);     if (lr && n <= tmp) return (tmp << 1) + dfs(d + 1, n, lr);     if (lr && n > tmp) return dfs(d + 1, n - tmp, 0) + 1;   }   int main() {     cin >> h >> n;     cout << dfs(0, n, 0) << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T abs(T t) {     return t < 0 ? -t : t;   }   const long long modn = 1000000007;   inline long long mod(long long x) { return x % modn; }   const int MAXN = 100010;   int n, s[MAXN];   int main() {     scanf( %d , &n);     printf( %d , n / 5 + (n % 5 != 0));   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     int n, i = 0;     cin >> n >> s;     std::vector<int> v(n);     std::vector<bool> cycle(n);     for (int i = 0; i < n; i++) cin >> v[i];     for (i = 0; i < n;) {       if (i <= -1 || i >= n) break;       if (cycle[i] == true)         break;       else {         cycle[i] = true;         if (s[i] ==  < )           i -= v[i];         else           i += v[i];       }     }     if (i <= -1 || i >= n)       cout <<  FINITE n ;     else       cout <<  INFINITE n ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 10;   long long int inf = -1e15;   long long int seg[maxn << 2], lazy[maxn << 2];   int n, m, p;   vector<long long int> espadas, armaduras;   vector<pair<int, int> > monstros[maxn];   void update(int x, long long int val) {     seg[x] += val;     lazy[x] += val;   }   void propaga(int x) {     if (!lazy[x]) return;     update(x * 2, lazy[x]);     update(x * 2 + 1, lazy[x]);     lazy[x] = 0;   }   void add(int i, int j, int x, int l, int r, int val) {     if (i >= j || l >= r || i >= r || j <= l) return;     if (i >= l && j <= r) {       update(x, val);       return;     }     propaga(x);     int md = (i + j) >> 1;     add(i, md, x * 2, l, r, val);     add(md, j, x * 2 + 1, l, r, val);     seg[x] = max(seg[x * 2], seg[x * 2 + 1]);   }   void build(int i, int j, int no) {     int l = 2 * no;     int r = l + 1;     if (i + 1 == j) {       if (armaduras[i])         seg[no] = -armaduras[i];       else         seg[no] = inf;       return;     }     int mid = (i + j) >> 1;     build(i, mid, l);     build(mid, j, r);     seg[no] = max(seg[l], seg[r]);   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     long long int ans = inf;     espadas.resize(maxn);     armaduras.resize(maxn);     cin >> n >> m >> p;     int atk, def;     long long int gold;     for (int i = 1; i <= n; i++) {       cin >> atk >> gold;       atk--;       if (!espadas[atk])         espadas[atk] = gold;       else         espadas[atk] = min(espadas[atk], gold);     }     for (int i = 1; i <= m; i++) {       cin >> def >> gold;       if (!armaduras[def])         armaduras[def] = gold;       else         armaduras[def] = min(armaduras[def], gold);     }     build(1, maxn, 1);     for (int i = 1; i <= p; i++) {       cin >> def >> atk >> gold;       monstros[def].push_back(pair<int, int>(atk, gold));     }     for (int i = 0; i <= maxn - 1; i++) {       for (auto a : monstros[i]) add(1, maxn, 1, a.first + 1, maxn, a.second);       if (espadas[i]) ans = max(ans, seg[1] - espadas[i]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, dp[30010][210][4], num[30010];   int main() {     int i, j;     cin >> n >> m;     for (i = 1; i <= n; i++) scanf( %d , &num[i]);     memset(dp[0], -0x3f, sizeof(dp[0]));     for (i = 0; i < 4; i++) dp[0][0][i] = 0;     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         int tmp = 1 + (j != 1 && j != m);         dp[i][j][0] = max(dp[i - 1][j][0], dp[i - 1][j - 1][3]) - tmp * num[i];         dp[i][j][1] = max(dp[i - 1][j][1], dp[i][j][0]);         dp[i][j][2] = max(dp[i - 1][j][2], dp[i - 1][j - 1][1]) + tmp * num[i];         dp[i][j][3] = max(dp[i - 1][j][3], dp[i][j][2]);         if (tmp == 2) {           dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j - 1][1]);           dp[i][j][3] = max(dp[i][j][3], dp[i - 1][j - 1][3]);         }       }     }     cout << max(max(dp[n][m][0], dp[n][m][1]), max(dp[n][m][2], dp[n][m][3]));   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e7;   const long long maxm = 1e7;   const long long INF = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   long long uu[maxn];   int main() {     long long n, a, b;     cin >> n >> a >> b;     for (long long i = 0; i < n; i++) scanf( %lld , &uu[i]);     long long ans = -1;     long long mxb = b;     for (long long i = 0; i < n; i++) {       if (a == 0 && b == 0) {         ans = i;         break;       }       if (uu[i] == 0) {         if (b > 0)           b--;         else           a--;       }       if (uu[i] == 1) {         if (b == mxb) {           b--;         } else if (a > 0) {           a--;           b++;           if (b > mxb) b = mxb;         } else           b--;       }     }     if (ans == -1) ans = n;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (int)1e8;   int n, m;   char s[22][22];   int x[22][22], dp[1 << 20], state[30], sum[30], maxN[30];   vector<int> sta[22];   vector<int> cost[22];   int bit[1 << 20];   void initialIt() {     for (int i = 0; i < 20; i++) {       bit[1 << i] = i;     }     for (int i = 0; i < m; i++) {       memset(state, 0, sizeof(state));       memset(sum, 0, sizeof(sum));       memset(maxN, 0, sizeof(maxN));       for (int j = 0; j < n; j++) {         int ch = (int)s[j][i] -  a ;         state[ch] |= 1 << j;         sum[ch] += x[j][i];         maxN[ch] = max(maxN[ch], x[j][i]);       }       for (int j = 0; j < 26; j++) {         for (int k = 0; k < n; k++)           if ((state[j] >> k) & 1) {             sta[k].push_back(state[j]);             cost[k].push_back(sum[j] - maxN[j]);           }       }     }     for (int i = 0; i < n; i++) {       int minCost = INF;       for (int j = 0; j < m; j++) {         minCost = min(minCost, x[i][j]);       }       sta[i].push_back(1 << i);       cost[i].push_back(minCost);     }   }   int lowBit(int x) { return x & (-x); }   void calcIt() {     for (int i = 0; i < (1 << n); i++) {       dp[i] = INF;     }     dp[0] = 0;     for (int i = 0; i < (1 << n); i++) {       int curI = bit[lowBit(i)], curS = i;       for (int j = 0; j < (int)cost[curI].size(); j++) {         int C = cost[curI][j], S = sta[curI][j];         int preS = curS - (curS & S);         if (dp[preS] + C < dp[curS]) {           dp[curS] = dp[preS] + C;         }       }     }     int final = (1 << n) - 1;     printf( %d n , dp[final]);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %s , s[i]);     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         scanf( %d , &x[i][j]);       }     }     initialIt();     calcIt();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n;     char s[200050];     map<int, map<int, int>> vis, cnt;     scanf( %d , &t);     while (t--) {       vis.clear();       cnt.clear();       int l = -5, r = 0x3f3f3f3f;       scanf( %d%s , &n, s);       int x = 0, y = 0;       vis[x][y] = 1;       cnt[x][y] = 0;       for (int i = 0; i < n; i++) {         if (s[i] ==  L ) {           x -= 1;         } else if (s[i] ==  R ) {           x += 1;         } else if (s[i] ==  D ) {           y -= 1;         } else {           y += 1;         }         if (vis[x][y] && i - cnt[x][y] < r - l) {           l = cnt[x][y] + 1;           r = i + 1;         }         cnt[x][y] = i + 1;         vis[x][y] = 1;       }       if (l != -5)         printf( %d %d n , l, r);       else         printf( -1 n );     }   }
#include <bits/stdc++.h>   using namespace std;   long sz(char *a) {     long i = 0;     while (*(a + i) !=   0 ) i++;     return i;   }   int main() {     char *a = (char *)malloc(sizeof(char) * 1000001);     char *b = (char *)malloc(sizeof(char) * 1000001);     scanf( %1000000s , a);     scanf( %1000000s , b);     long a_size = sz(a);     long b_size = sz(b);     long j, i, a_adj, b_adj;     for (i = 0; i < a_size; i++)       if (a[i] !=  0 ) break;     a_size -= i;     a_adj = i;     i = 0;     for (i = 0; i < b_size; i++)       if (b[i] !=  0 ) break;     b_size -= i;     b_adj = i;     if (a_size > b_size) {       printf( > n );       return 0;       ;     }     if (b_size > a_size) {       printf( < n );       return 0;       ;     }     for (i = a_adj, j = b_adj; i <= a_size + a_adj, j <= b_size + b_adj;          i++, j++) {       if (a[i] > b[j]) {         printf( > n );         return 0;         ;       }       if (a[i] < b[j]) {         printf( < n );         return 0;         ;       }     }     printf( = n );     free(a);     free(b);     return 0;     ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000000;   int aa[N + 1];   int main() {     int n;     cin >> n;     long long ans = 0;     for (int i = 0; i <= n; i++) aa[i] = i;     int n_ = n;     for (int h = 20; n_ > 0;) {       while (h >= 0 && (n_ & 1 << h) == 0) h--;       int m = n_ - ((1 << h) - 1);       reverse(aa + n_ - m * 2 + 1, aa + n_ + 1);       n_ -= m * 2;       ans += m * 2LL * ((1 << h + 1) - 1);     }     cout << ans <<   n ;     for (int i = 0; i <= n; i++) cout << aa[i] <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   int main() {     using namespace std;     int q;     cin >> q;     while (q--) {       long long n;       cin >> n;       int len = 0;       char num[40] = {0};       while (n) {         num[len] = n % 3 +  0 ;         n /= 3;         len++;       }       int x;       for (x = len - 1; x >= 0; x--) {         if (num[x] ==  2 ) {           break;         }       }       if (x >= 0) {         for (int i = 0; i <= x; i++) {           num[i] =  0 ;         }         if (num[x + 1]) {           num[x + 1]++;         } else {           num[x + 1] =  1 ;         }         for (int i = x + 1; i < len; i++) {           if (num[i] ==  2 ) {             num[i] =  0 ;             if (num[i + 1]) {               num[i + 1]++;             } else {               num[i + 1] =  1 ;             }           }         }       }       long long m = 0, t = 1;       for (int i = 0; num[i]; i++) {         m += t * (num[i] -  0 );         t *= 3;       }       cout << m << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char a[5][5];     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) scanf( %c , &a[i][j]);       getchar();     }     int flag = 0;     for (int i = 0; i < 3; i++)       for (int j = 0; j < 3; j++) {         if (a[i][j] != a[2 - i][2 - j]) flag = 1;       }     if (flag == 0)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5010;   int n;   int a[maxn], f[maxn];   long long b[maxn];   int main() {     int i, ans = 0, j;     long long w;     scanf( %d , &n);     for (i = 1; i <= n; ++i) {       scanf( %I64d , &w);       while (w % 2 == 0) ++a[i], w /= 2;       b[i] = w;     }     for (i = 1; i <= n; ++i) {       for (j = 1; j < i; ++j)         if ((a[i] == a[j] + i - j || a[i] < i - j) && b[j] % b[i] == 0)           f[i] = max(f[i], f[j]);       ans = max(ans, ++f[i]);     }     printf( %d , n - ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using pi = pair<int, int>;   using pl = pair<ll, ll>;   using pld = pair<ld, ld>;   using vi = vector<int>;   using vl = vector<ll>;   using vb = vector<bool>;   using vld = vector<ld>;   using vs = vector<string>;   using vpi = vector<pi>;   using vpl = vector<pl>;   using vpld = vector<pld>;   int clz(unsigned long long N) { return N ? 63 - __builtin_clzll(N) : -1; }   int arr[300010];   int acum[300010];   int n, q;   void solvetask() {     cin >> n >> q;     for (int i = 0; i < n; i++) {       char c;       cin >> c;       if (c ==  + )         arr[i] = (i & 1) ? -1 : 1;       else         arr[i] = (i & 1) ? 1 : -1;     }     for (int i = 1; i <= n; i++) acum[i] = acum[i - 1] + arr[i - 1];     while (q--) {       int l, r;       cin >> l >> r;       int soma = acum[r] - acum[l - 1];       if (soma == 0)         cout <<  0 n ;       else if (abs(soma) % 2 == 1)         cout <<  1 n ;       else         cout <<  2 n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t = 1;     cin >> t;     while (t--) solvetask();   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   bool debug = 1;   int main() {     int n, m;     scanf( %d %d , &n, &m);     int amn[n + 1];     vector<vector<int> > v;     v.resize(n + 1);     for (int i = 0; i < m; i++) {       int a, b;       scanf( %d %d , &a, &b);       v[a].push_back(b);       v[b].push_back(a);       amn[a]++;       amn[b]++;     }     bool fs[n + 1];     fill(fs, fs + n + 1, 0);     if (0)       for (int i = 1; i <= n; i++)         if (v[i].size() == 1) fs[i] = 1;     int k = 0;     bool is;     do {       bool nfs[n + 1];       for (int i = 1; i <= n; i++) nfs[i] = fs[i];       is = 0;       k++;       for (int i = 1; i <= n; i++) {         if (fs[i]) continue;         int amnoth = 0;         for (int j = 0; j < v[i].size(); j++) {           int oth = v[i][j];           if (!fs[oth]) amnoth++;         }         if (amnoth == 1) {           nfs[i] = 1;           is = 1;         }       }       for (int i = 1; i <= n; i++) fs[i] = nfs[i];     } while (is);     printf( %d n , k - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   const int MAXN = 200010;   vector<int> x[MAXN], y[MAXN];   int v[MAXN], out[MAXN], sg[MAXN];   int xr[MAXN];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; ++i) cin >> v[i];     for (int i = 0; i < m; ++i) {       int a, b;       cin >> a >> b;       --a;       --b;       x[a].push_back(b);       y[b].push_back(a);       ++out[a];     }     queue<int> Q;     for (int i = 0; i < n; ++i) {       if (out[i] == 0) Q.push(i);     }     int maxsg = 0;     while (!Q.empty()) {       int a = Q.front();       Q.pop();       for (int b : y[a]) {         --out[b];         if (out[b] == 0) {           Q.push(b);         }       }       set<int> s;       for (int b : x[a]) s.insert(sg[b]);       for (int i = 0; i < n; ++i) {         if (s.find(i) == s.end()) {           sg[a] = i;           break;         }       }       maxsg = max(maxsg, sg[a]);     }     for (int i = 0; i < n; ++i) {       xr[sg[i]] ^= v[i];     }     bool win = false;     for (int i = maxsg; i >= 0; --i) {       if (xr[i] != 0) {         win = true;         int p = -1;         for (int j = 0; j < n; ++j) {           if (sg[j] != i) continue;           if (p == -1) {             p = j;             continue;           }           if ((v[j] ^ xr[i]) <= v[j]) p = j;         }         xr[i] ^= v[p];         v[p] = xr[i];         xr[i] = 0;         for (int b : x[p]) {           if (xr[sg[b]] != 0) {             v[b] ^= xr[sg[b]];             xr[sg[b]] = 0;           }         }         break;       }     }     if (win) {       cout <<  WIN n ;       for (int i = 0; i < n; ++i) cout << v[i] <<    ;       cout <<   n ;     } else {       cout <<  LOSE n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N, i, sum = 0, max;     cin >> N;     int A[N];     for (i = 0; i <= N - 1; i++) cin >> A[i];     max = *max_element(A, A + N);     for (i = 0; i <= N - 1; i++) sum += (max - A[i]);     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(339264);   const long long MOD = 998244353;   const double eps = 1e-7;   int main() {     cout << fixed << setprecision(20);     int n, w, m;     cin >> n >> w >> m;     if (2 * n < m) {       cout <<  NO ;       return 0;     }     int left = m;     int j = 0;     vector<vector<pair<int, int>>> ans(m);     for (int i = 0; i < m; i++) {       int need = n;       if (left < m && left > n) {         cout <<  NO ;         return 0;       }       while (need >= left) {         ans[i].push_back({j, left});         need -= left;         left = m;         j++;       }       if (need > 0) {         ans[i].push_back({j, need});         left -= need;       }     }     cout <<  YES  << endl;     for (int i = 0; i < m; i++) {       for (auto &p : ans[i]) {         cout << p.first + 1 <<     << (p.second * w) / ((double)m) <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     char ch = getchar();     int x = 0, f = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   struct node {     int v, w;     node() {}     node(int x, int y) : v(x), w(y) {}     bool operator<(const node& tl) const { return (v - w) < (tl.v - tl.w); }   } z[105], f[105];   bool cmp(node aa, node bb) { return aa.v < bb.v; }   int dp[30005 * 2] = {0};   int main() {     int n, m, tot1, tot2;     cin >> n >> m;     tot1 = tot2 = 1;     for (int i = 1; i < n + 1; ++i) {       int x, y;       cin >> x >> y;       if (y < 0)         f[tot2++] = node(x, -y);       else         z[tot1++] = node(x, y);     }     sort(z + 1, z + tot1, cmp);     int ans = 0;     for (int i = 1; i < tot1; ++i) {       if (z[i].v <= m) {         m += z[i].w;         ++ans;       }     }     sort(f + 1, f + tot2);     int sum = 0;     for (int i = 1; i < tot2; ++i) {       for (int j = m; j >= max(f[i].v, f[i].w); --j) {         dp[j] = max(dp[j], dp[j - f[i].w] + 1);       }     }     cout << ans + dp[m] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int test, n, mx, i;   double l, r, m, eps = 0.000001, a[100005];   double pref(double tm) {     double pos = 0, speed = 1;     for (int i = 0; i < n; i++) {       if ((a[i] - pos) <= tm * speed)         tm -= (a[i] - pos) / speed, pos = a[i], speed += 1;       else {         pos += speed * tm;         tm = 0;         break;       }     }     pos += speed * tm;     return pos;   }   double suff(double tm) {     double pos = mx, speed = 1;     for (int i = n - 1; i >= 0; i--) {       if ((pos - a[i]) <= tm * speed)         tm -= (pos - a[i]) / speed, pos = a[i], speed += 1;       else {         pos -= speed * tm;         tm = 0;         break;       }     }     pos -= speed * tm;     return pos;   }   int main() {     scanf( %d , &test);     while (test--) {       cin >> n >> mx;       for (i = 0; i < n; i++) cin >> a[i];       l = 0., r = 2000000000.;       while (r - l > eps) {         m = (l + r) / 2.;         if (pref(m) <= suff(m))           l = m;         else           r = m - eps;       }       cout << fixed << setprecision(9) << l <<   n ;     }   }