malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   const long long p = 1e9 + 7;   int par[MAXN][2], size[MAXN][2], dist[MAXN][2], val[MAXN][2];   int groups, n, k;   pair<int, int> find(int e, int x) {     if (par[x][e] == x) {       return pair<int, int>(x, 0);     }     pair<int, int> t = find(e, par[x][e]);     t.second += dist[x][e];     t.second %= 2;     dist[x][e] = t.second;     par[x][e] = t.first;     return t;   }   bool assign(int e, int x, int v) {     find(e, x);     if (val[par[x][e]][e] == -1) {       val[par[x][e]][e] = (dist[x][e] + v) % 2;       --groups;       return true;     }     if (val[par[x][e]][e] != (dist[x][e] + v) % 2) return false;     return true;   }   bool addedge(int e, int x, int y, int v) {     find(e, x);     find(e, y);     if (par[x][e] == par[y][e]) return ((dist[x][e] + dist[y][e] + v) % 2 == 0);     v = (dist[x][e] + dist[y][e] + v) % 2;     x = par[x][e];     y = par[y][e];     if (size[x][e] > size[y][e]) swap(x, y);     par[x][e] = y;     dist[x][e] = v;     size[y][e] += size[x][e];     if (val[y][e] != -1 && val[x][e] != -1) {       if ((val[x][e] + val[y][e] + v) % 2 != 0) return false;       return true;     }     if (val[x][e] != -1) {       val[y][e] = (val[x][e] + v) % 2;       --groups;       return true;     }     --groups;     return true;   }   int main() {     cin >> n >> k;     groups = 2 * n - 1;     for (int i = 0; i < MAXN; ++i) {       par[i][0] = par[i][1] = i;       size[i][0] = size[i][1] = 1;       dist[i][0] = dist[i][1] = 0;       val[i][0] = val[i][1] = -1;     }     for (int i = 0; i < k; ++i) {       int x, y, v;       char j;       cin >> x >> y >> j;       v = (j ==  o );       x--;       y--;       if (abs(x - y) <= 1) {         if (!assign((x + y) % 2, min(x, y), v)) {           cout <<  0  << endl;           return 0;         }       } else {         if (x > y) swap(x, y);         if (!addedge((x + y) % 2, (y - x - (x + y) % 2) / 2 - 1,                      (y - x - (x + y) % 2) / 2 + x, v)) {           cout <<  0  << endl;           return 0;         }       }     }     for (int i = 0; i < n / 2; ++i) {       if (!addedge(0, i, n - 1 - i, 0)) {         cout <<  0  << endl;         return 0;       }     }     for (int i = 0; i < (n - 1) / 2; ++i) {       if (!addedge(1, i, n - 2 - i, 0)) {         cout <<  0  << endl;         return 0;       }     }     long long prod = 1;     for (int i = 0; i < groups; ++i) {       prod *= 2;       prod %= p;     }     cout << prod << endl;   }
#include <bits/stdc++.h>   const double eps = (1e-5);   using namespace std;   int dcmp(long double a, long double b) {     return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;   }   long long getBit(long long num, int idx) { return ((num >> idx) & 1ll) == 1; }   int setBit1(int num, int idx) { return num | (1 << idx); }   long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }   long long flipBit(long long num, int idx) { return num ^ (1ll << idx); }   void M() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int countNumBit1(int mask) {     int ret = 0;     while (mask) {       mask &= (mask - 1);       ++ret;     }     return ret;   }   int arr[3009], E[4500009];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];     }     int cnt = 0;     while (1) {       int fl = 0;       for (int i = 0; i < n; i++) {         if (i + 1 < n && arr[i] > arr[i + 1])           swap(arr[i], arr[i + 1]), cnt++, fl = 1;       }       if (!fl) break;     }     E[1] = 1;     for (int i = 2; i <= cnt; i++) E[i] = 4 + E[i - 2];     cout << fixed << setprecision(9) << (double)E[cnt] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 100;   const long long INF = 1e18;   struct node {     long long d, f, t, c;   } a[N];   long long b[N];   long long dp[1000006], dp1[1000005];   bool cmp(node p, node q) { return p.d < q.d; }   int main() {     int n, m, k;     long long x = 1000000, y = -1;     cin >> n >> m >> k;     for (int i = 1; i <= m; i++) {       scanf( %lld%lld%lld%lld , &a[i].d, &a[i].f, &a[i].t, &a[i].c);     }     sort(a + 1, a + 1 + m, cmp);     for (int i = 1; i <= 1000001; i++) b[i] = -1, dp[i] = INF;     long long sum = 0, s = 0;     for (int i = 1; i <= m; i++) {       if (a[i].f == 0) continue;       if (b[a[i].f] == -1) {         s++;         b[a[i].f] = a[i].c;         sum += a[i].c;       } else {         if (b[a[i].f] > a[i].c) {           sum -= b[a[i].f];           sum += a[i].c;           b[a[i].f] = a[i].c;         }       }       if (s == n) {         dp[a[i].d] = sum;         x = min(x, a[i].d);       }     }     for (int i = 1; i <= 1000001; i++) b[i] = -1, dp1[i] = INF;     sum = 0;     s = 0;     for (int i = m; i >= 1; i--) {       if (a[i].t == 0) continue;       if (b[a[i].t] == -1) {         s++;         b[a[i].t] = a[i].c;         sum += a[i].c;       } else {         if (b[a[i].t] > a[i].c) {           sum -= b[a[i].t];           sum += a[i].c;           b[a[i].t] = a[i].c;         }       }       if (s == n) {         dp1[a[i].d] = sum;         y = max(y, a[i].d);       }     }     for (int i = x + 1; i <= 1000000; i++) dp[i] = min(dp[i - 1], dp[i]);     for (int i = y - 1; i >= 1; i--) dp1[i] = min(dp1[i + 1], dp1[i]);     long long ans = INF;     for (int i = 1; i <= 1000000 - k - 1; i++) {       if (dp[i] == INF || dp1[i + k + 1] == INF) continue;       if (ans > dp[i] + dp1[i + k + 1]) {         ans = dp[i] + dp1[i + k + 1];       }     }     if (ans == INF)       cout << -1 << endl;     else       cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long sum[4];   int main(void) {     long long n, a, b, c, d, min_value = 1e14, max_value = 0, flag = 0;     scanf( %lld %lld %lld %lld %lld , &n, &a, &b, &c, &d);     sum[0] = a + b;     sum[1] = b + d;     sum[2] = c + d;     sum[3] = a + c;     for (int i = 0; i < 4; i++) {       min_value = min(min_value, sum[i]);       max_value = max(max_value, sum[i]);     }     if (max_value - min_value > n) flag = 1;     if (flag == 1)       printf( 0 );     else       printf( %lld , n * (n - (max_value - min_value)));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long md = 1e9 + 7;   const long long MX = 2e5 + 5;   const long long INF = 1e18;   const long double PI = 4 * atan((long double)1);   long long power(long long a, long long n) {     long long res = 1;     while (n) {       if (n % 2) res *= a;       a *= a;       n /= 2;     }     return res;   }   long long abst(long long a) { return ((a < 0) ? (-1 * a) : (a)); }   long long froot(long long x, long long* root) {     if (x == root[x])       return x;     else       root[x] = froot(root[x], root);   }   int32_t main() {     long long n;     cin >> n;     long long arr[n + 1], root[n + 1], cnt[n + 1];     for (long long i = 1; i <= n; i++) {       cnt[i] = 1;       root[i] = i;     }     for (long long i = 1; i <= n; i++) {       cin >> arr[i];       long long x = froot(i, root);       long long y = froot(arr[i], root);       if (x < y) {         root[y] = x;         cnt[x] += cnt[y];       } else if (y < x) {         root[x] = y;         cnt[y] += cnt[x];       }     }     map<long long, long long> mp;     long long max1 = -1, max2 = -1, rm1 = -1, rm2 = -1;     for (long long i = 1; i <= n; i++) {       long long x = froot(i, root);       if (mp[x] == 0) {         mp[x]++;         if (cnt[x] >= max1) {           max2 = max1;           rm2 = rm1;           max1 = cnt[x];           rm1 = x;         } else if (cnt[x] > max2) {           max2 = cnt[x];           rm2 = x;         }       }     }     if (rm2 == -1) {       long long res;       long long x = froot(1, root);       x = cnt[x];       res = power(x, 2);       cout << res <<   n ;     } else {       long long res = 0;       root[rm2] = rm1;       cnt[rm1] += cnt[rm2];       map<long long, long long> mp1;       for (long long i = 1; i <= n; i++) {         long long x = froot(i, root);         if (mp1[x] == 0) {           mp1[x]++;           long long p = cnt[x];           res += power(p, 2);         }       }       cout << res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 710;   int n;   struct Tbig {     static const int bit = 10000;     int n, a[30];     Tbig(int x = 0) {       memset(a, 0, sizeof a);       for (n = 0; x; x /= bit) a[n++] = x % bit;       !n ? n = 1 : 0;     }     Tbig operator*(const Tbig &b) const {       int i, j;       Tbig c;       c.n = n + b.n;       for (i = 0; i < n; ++i)         for (j = 0; j < b.n; ++j) {           c.a[i + j] += a[i] * b.a[j];           c.a[i + j + 1] += c.a[i + j] / bit, c.a[i + j] %= bit;         }       for (; c.n > 0 && !c.a[c.n]; --c.n)         ;       ++c.n;       return c;     }     bool operator<(const Tbig &b) const {       int i;       if (n != b.n) return n < b.n;       for (i = n - 1; i >= 0; --i)         if (a[i] != b.a[i]) return a[i] < b.a[i];       return false;     }     void print() {       int i;       printf( %d , a[n - 1]);       for (i = n - 2; i >= 0; --i) printf( %04d , a[i]);       printf(  n );     }   };   struct Talt {     int tot;     struct Tsqy {       int s;       Tsqy *l;       inline void set(Tsqy *_l, int _s) { l = _l, s = _s; }     } * pos[maxn], buf[maxn * 2];     inline void add(int a, int b) {       buf[++tot].set(pos[a], b), pos[a] = buf + tot;       buf[++tot].set(pos[b], a), pos[b] = buf + tot;     }   } alt;   namespace Ninit {   void init() {     int i, a1, a2;     scanf( %d , &n);     for (i = 1; i < n; ++i) {       scanf( %d%d , &a1, &a2), alt.add(a1, a2);     }   }   }  // namespace Ninit   namespace Nsolve {   Tbig F[maxn][maxn], G[maxn], F_xi;   int S[maxn];   void dfs(int x, int f) {     Talt::Tsqy *p;     int i, j;     S[x] = 1, F[x][1] = 1;     for (p = alt.pos[x]; p; p = p->l)       if (p->s != f) {         dfs(p->s, x), S[x] += S[p->s];         for (i = S[x]; i >= 1; --i) {           F_xi = F[x][i];           for (j = min(S[p->s], i - 1); j > 0 && i - j <= S[x] - S[p->s]; --j)             F[x][i] = max(F[x][i], F[x][i - j] * F[p->s][j]);           F[x][i] = max(F[x][i], F_xi * G[p->s]);         }       }     for (i = 1; i <= S[x]; ++i) G[x] = max(G[x], F[x][i] * i);   }   void solve() {     dfs(1, 0);     G[1].print();   }   }  // namespace Nsolve   int main() {     Ninit::init();     Nsolve::solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int size1;     string s;     vector<int> v;     int arr[200];     cin >> size1 >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  * ) v.push_back(i + 1);     }     for (int i = 0; i < v.size(); i++) {       for (int count1 = 1; count1 <= 100; count1++) {         int n = v[i] + count1;         int counttimes = 0;         for (int l = i + 1; l < v.size(); l++) {           if (counttimes == 4) {             cout <<  yes ;             return 0;           }           if (n == v[l]) {             n = v[l] + count1;             counttimes++;           }           if (v[l] > n) break;         }         if (counttimes == 4) {           cout <<  yes ;           return 0;         }       }     }     cout <<  no ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 1e5;   long long int t[N];   string s;   long long int n, k;   bool chek(long long int x) {     for (long long int i = 0; i < n; i++) {       if (!(s[i] -  0 )) {         long long int en = i + x;         long long int st = i - x;         en = min(en, n - 1);         st = max((long long int)0, st);         long long int cur = t[en] - (st ? t[st - 1] : 0) - 1;         if (cur >= k) return true;       }     }     return false;   }   int32_t main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> k;     cin >> s;     long long int x = 0;     for (long long int i = 0; i < s.size(); i++) {       if (!(s[i] -  0 )) x++;       t[i] = x;     }     long long int l = -1, r = n + 1;     while (r - l > 1) {       long long int mid = (r + l) / 2;       if (chek(mid))         r = mid;       else         l = mid;     }     cout << r;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, d, n, m;   string s, v;   int main() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> a >> b;     }     for (int i = 1; i <= n; i++) {       if (i % 2 == 1) {         cout << 1;       } else {         cout << 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, arr[100010], mn = 1000000000, st, ans = 1000000000;   bool b;   int main() {     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> arr[i];       mn = min(mn, arr[i]);     }     for (int i = 0; i < n; ++i) {       if (arr[i] == mn && !b) {         st = i;         b = 1;       } else if (arr[i] == mn) {         ans = min(ans, i - st);         st = i;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, j;   string a[110];   int f[110];   int g[110];   int h1[110];   int h2[110];   int s1[110];   int s2[110];   int rem;   void del(int k) {     rem--;     s1[f[k]] -= k;     s2[g[k]] -= k;     h1[f[k]]--;     h2[g[k]]--;     if (h1[f[k]] == 1 && (1 << f[k] & i)) del(s1[f[k]]);     if (h2[g[k]] == 1 && (1 << g[k] & j)) del(s2[g[k]]);   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     n = unique(a, a + n) - a;     for (int i = 0; i < n; i++) {       f[i] = (a[i][0] >  R ) + (a[i][0] >  G ) + (a[i][0] >  B ) +              (a[i][0] >  Y ) + (a[i][0] >  W );       g[i] = a[i][1] -  1 ;     }     int ans = 11;     for (i = 0; i < 32; i++) {       for (j = 0; j < 32; j++) {         memset(h1, 0, sizeof(h1));         memset(h2, 0, sizeof(h2));         memset(s1, 0, sizeof(s1));         memset(s2, 0, sizeof(s2));         rem = n;         for (int k = 0; k < n; k++) {           if ((1 << f[k] & i) && (1 << g[k] & j))             rem--;           else {             s1[f[k]] += k;             s2[g[k]] += k;             h1[f[k]]++;             h2[g[k]]++;           }         }         for (int x = 0; x < 5; x++) {           if ((1 << x & i) && (h1[x] == 1)) del(s1[x]);           if ((1 << x & j) && (h2[x] == 1)) del(s2[x]);         }         if (rem <= 1) {           int c = 0;           for (int x = 0; x < 5; x++)             c += (bool)(1 << x & i) + (bool)(1 << x & j);           ans = min(ans, c);         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int a[n];     for (int i = 0; i < n; i++) a[i] = i + 1;     int cnt = (n / 2) * (n / 2);     if (n % 2 == 0) cnt -= n / 2;     if (cnt < m) {       cout << -1;       return 0;     }     int idx = n - 1;     while (m < cnt) {       if (cnt - (idx / 2) <= m) {         a[idx] += 2 * (cnt - m);         break;       } else {         cnt -= idx / 2;         if (idx + 1 == n)           a[idx] = 1000 * 1000 * 1000;         else           a[idx] = a[idx + 1] - 2 * n;       }       idx--;     }     for (int i = 0; i < n; i++) cout << a[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int n, nn[5], ma;   string s;   long long ans = 1;   int main() {     cin >> n >> s;     for (int i = 0; i < n; i++) {       if (s[i] ==  A ) nn[0]++;       if (s[i] ==  C ) nn[1]++;       if (s[i] ==  G ) nn[2]++;       if (s[i] ==  T ) nn[3]++;     }     for (int i = 0; i < 4; i++) ma = max(ma, nn[i]);     int ct = 0;     for (int i = 0; i < 4; i++) {       if (nn[i] == ma) ct++;     }     for (int i = 0; i < n; i++) {       ans *= ct;       ans %= 1000000007;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 5;   long long t, n, a[maxn];   int main() {     scanf( %d , &t);     while (t--) {       long long maxx = -1e18, ans = 0;       cin >> n;       for (int i = 0; i < n; i++) {         cin >> a[i];         if (a[i] > maxx) maxx = a[i];       }       for (int i = 0; i < n; i++) {         if (maxx == a[i]) {           if (i == 0 && a[0] > a[1]) {             ans = 1;             break;           } else if (i == n - 1 && a[n - 1] > a[n - 2]) {             ans = n;             break;           } else if (((i != 0) && a[i] > a[i - 1]) ||                      (i != n - 1 && a[i] > a[i + 1])) {             ans = i + 1;             break;           }         }       }       if (ans == 0)         cout << -1 << endl;       else         cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   char s[MAXN];   int main() {     int m;     scanf( %d , &m);     scanf( %s , s);     int n = strlen(s);     priority_queue<int, vector<int>, greater<int> > Q;     for (int k = 0; k < 26; k++) {       while (!Q.empty()) Q.pop();       bool flag;       for (int i = 0; i <= n - 1; i++) {         flag = 0;         int tmp = 0;         for (int j = i; j <= i + m - 1 && j < n; j++) {           if (s[j] -  a  < k) Q.push(s[j]), flag = 1, tmp = j;         }         if (i > n - m) {           flag = 1;           break;         }         if (!flag) {           for (int j = i + m - 1; j >= i; j--) {             if (s[j] -  a  == k) {               Q.push(s[j]), flag = 1;               tmp = j;               break;             }           }           if (!flag) break;         }         i = tmp;       }       if (flag) {         while (!Q.empty()) {           printf( %c , Q.top());           Q.pop();         }         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const double PI = acos(-1);   long long power(long long x, long long y) {     if (y == 0)       return 1;     else if (y == 1)       return x;     long long r = power(x, y / 2);     if (y % 2 == 0)       return (r * r);     else       return (r * r * x);   }   bool primechecker(long long i) {     bool valid = true;     for (int j = 2; j <= sqrt(i); j++) {       if (i % j == 0) {         valid = false;         break;       }     }     if (valid && i != 1)       return true;     else       return false;   }   vector<bool> prime(10000001, true);   void sieveprime() {     prime[0] = false;     prime[1] = false;     for (int i = 2; i < prime.size(); i++) {       if (prime[i] == true) {         for (int j = i + i; j <= 10000000; j += i) prime[j] = false;       }     }     return;   }   int main() {     int t;     cin >> t;     while (t--) {       long long a, b;       cin >> a >> b;       cout << (a ^ b) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 205;   int n, siz[N], s[N][N], ori[N][N], tot[N], pos[N];   vector<int> ans;   int read() {     int x = 0, f = 1;     char s;     while ((s = getchar()) >  9  || s <  0 )       if (s ==  - ) f = -1;     while (s >=  0  && s <=  9 )       x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();     return x * f;   }   bool ok() {     for (int i = 1; i <= n; ++i)       if (tot[i]) return 0;     return 1;   }   bool check() {     int maxx;     for (int i = 1; i <= n; ++i) pos[ans[n - i]] = i;     for (int i = 1; i < n; ++i) {       maxx = 0;       for (int j = 1; j <= n; ++j) tot[j] = 0;       for (int j = 1; j <= siz[i]; ++j)         maxx = max(maxx, pos[ori[i][j]]), ++tot[ori[i][j]];       if (maxx - siz[i] + 1 < 1) return 0;       for (int j = maxx; j >= maxx - siz[i] + 1; --j)         if (!tot[ans[n - j]]) return 0;     }     return 1;   }   int main() {     int x, sum;     bool flag;     for (int T = read(); T; --T) {       n = read();       for (int i = 1; i < n; ++i) {         siz[i] = read();         for (int j = 1; j <= siz[i]; ++j) ori[i][j] = read();       }       for (int num = 1; num <= n; ++num) {         ans.clear();         flag = 0;         for (int i = 1; i < n; ++i) {           for (int j = 1; j <= siz[i]; ++j) {             s[i][j] = ori[i][j];             if (s[i][j] == num) s[i][j] = 0;           }         }         while (233) {           sum = 0;           for (int i = 0; i <= n; ++i) tot[i] = 0;           for (int i = 1; i < n; ++i)             for (int j = 1; j <= siz[i]; ++j) ++tot[s[i][j]];           for (int i = 1; i <= n; ++i)             if (tot[i] == 1) ++sum, x = i;           if (ok()) break;           if (sum != 1) {             flag = 1;             break;           }           ans.push_back(x);           bool f;           for (int i = 1; i < n; ++i) {             f = 0;             for (int j = 1; j <= siz[i]; ++j)               if (s[i][j] == x) {                 f = 1;                 break;               }             if (f)               for (int j = 1; j <= siz[i]; ++j) s[i][j] = 0;           }         }         if (!flag) {           ans.push_back(num);           if (check()) break;         }       }       for (int i = ans.size() - 1; ~i; --i) printf( %d  , ans[i]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   inline void DoNothing() {}   template <typename T>   inline T Abs(const T a) {     return a < 0 ? -a : a;   }   template <typename T>   inline T Min(const T a, const T b) {     return a < b ? a : b;   }   template <typename T>   inline T Max(const T a, const T b) {     return a > b ? a : b;   }   static const long double eps = 1.0e-07;   template <typename T>   inline T IsEqual(const T a, const T b) {     return Abs(a - b) < eps;   }   template <typename T>   inline T IsGreater(const T a, const T b) {     return a > b + eps;   }   template <typename T>   inline T IsLess(const T a, const T b) {     return a + eps < b;   }   template <typename T>   inline void Print(const T& val) {     std::cout << val <<    ;   }   template <typename T>   inline std::string ToStr(const T& val) {     std::ostringstream ostr;     ostr << val;     return ostr.str();   }   template <typename T>   inline bool FromStr(const std::string& str, T& val) {     std::istringstream istr(str);     istr >> val;     return !!istr;   }   struct Rand {     unsigned long z_, w_;     unsigned long get32() {       z_ = 36969 * (z_ & 65535) + (z_ >> 16);       w_ = 18000 * (w_ & 65535) + (w_ >> 16);       return (z_ << 16) + (w_ & 65535);     }     void Reset() {       z_ = 1;       w_ = 1;     }     Rand() { Reset(); }   };   template <typename T>   inline std::vector<std::vector<T> > CreateVector2d(const size_t rowCnt,                                                      const size_t colCnt) {     return std::vector<std::vector<T> >(rowCnt, std::vector<T>(colCnt));   }   void Prepare();   class StopWatchEx {    public:     StopWatchEx();     ~StopWatchEx();       private:     struct Data;     Data* pData;   };   inline double CalcRk(const double rb, const double rs, size_t k) {     const double i_ds = 1 / (2 * rs);     const double i_db = 1 / (2 * rb);     const double i_d = i_ds - i_db;     const double i_xc = i_db + i_d / 2;     const double i_yc = i_d * (double)(k);     const double i_c = sqrt(i_yc * i_yc + i_xc * i_xc);     const double z1 = 1 / (i_c - i_d / 2);     const double z2 = 1 / (i_c + i_d / 2);     const double rk = (z1 - z2) / 2;     return rk;   }   bool Solve(bool bCheckInputStream = false) {     size_t n;     std::cin >> n;     if (bCheckInputStream && !std::cin) {       return false;     }     StopWatchEx _sw;     for (size_t i = 0; i < n; i++) {       size_t rb, rs, k;       std::cin >> rb >> rs >> k;       const double rk = CalcRk((double)rb, (double)rs, k);       std::cout << std::setprecision(8) << std::setw(12) << rk << std::endl;     }     return true;   }   int main() {     Prepare();     Solve();   }   struct StopWatchEx::Data {};   StopWatchEx::StopWatchEx() {}   StopWatchEx::~StopWatchEx() {}   void Prepare() {}