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), cout.tie(NULL);     srand(time(NULL));     ;     int T = 1;     cin >> T;     while (T--) {       int n;       cin >> n;       cout << setprecision(10)            << cos(3.141592653589793238 / (4 * n)) /                   sin(3.141592653589793238 / (2 * n));       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int get(long long int x) {     long long int y = 1, ans = 0;     while (y < x) {       y = y * 2;       if (y <= x)         ans++;       else         break;     }     return ans;   }   int main() {     int t = 1;     cin >> t;     while (t--) {       long long int n, m, k, a = 0, b = 0, ans = 1, x = 0, y = 0;       cin >> a >> b >> m;       if (a == b) {         cout <<  1   << a <<   n ;         continue;       }       n = get(b / (a + 1));       long long int arr[51] = {};       long long int rem = b - (1ll << n) * (a + 1);       long long int cur = a + 1, sum = a;       vector<long long int> sol;       sol.push_back(n + 2);       sol.push_back(a);       for (int i = 0; i < n; i++) {         x = (1ll << (n - i - 1));         if (rem >= x) {           k = min(m - 1, rem / x);           rem -= k * x;           cur += k;         }         sol.push_back(cur);         sum += cur;         cur = sum + 1;       }       if (rem >= 0 && rem < m) {         sol.push_back(cur + rem);         for (auto i : sol) cout << i <<    ;       } else {         cout <<  -1 ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int debug_ = 0;   const int maxn = 200000;   const long long inf = 998244353;   int unum[33], dnum[33];   long long dp[33][2][2][2];   long long dfs(int pos, int u, int e, int d) {     if (pos == -1) {       return 2 - e;     }     if (dp[pos][u][e][d] != -1) {       return dp[pos][u][e][d];     }     long long& ret = dp[pos][u][e][d];     ret = 0;     for (int i = 0; i < 3; ++i) {       int x = i / 2, y = i % 2;       if (x == 1 && u && unum[pos] == 0) {         continue;       }       if (y == 1 && e) {         continue;       }       if (y == 0 && d && dnum[pos] == 1) {         continue;       }       int nu = (u && x == unum[pos]);       int ne = (e && y == x);       int nd = (d && y == dnum[pos]);       ret += dfs(pos - 1, nu, ne, nd);     }     return ret;   }   int main() {     int tes, u, d;     cin >> tes;     while (tes--) {       cin >> d >> u;       for (int i = 0; i < 31; ++i) {         dnum[i] = (d >> i) & 1;         unum[i] = (u >> i) & 1;       }       memset(dp, -1, sizeof(dp));       cout << dfs(32, 1, 1, 1) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 205, P = 1e9 + 7ll;   struct node {     long long x, y;     node operator-(const node &t) const {       node c;       c.x = x - t.x;       c.y = y - t.y;       return c;     }     long long operator*(const node &t) const { return x * t.y - y * t.x; }   } p[N];   long long n, dp[N][N];   long long search(long long x, long long y) {     long long ans = 0;     if (dp[x][y] != -1) return dp[x][y];     if (x + 1 == y) return dp[x][y] = 1;     for (int i = x + 1; i < y; i++)       if ((p[x] - p[i]) * (p[y] - p[i]) > 0)         ans = (ans + search(x, i) * search(i, y) % P) % P;     return dp[x][y] = ans;   }   int main() {     memset(dp, -1, sizeof dp);     scanf( %dll , &n);     for (int i = 1; i <= n; i++) scanf( %lld%lld , &p[i].x, &p[i].y);     p[n + 1] = p[1];     long long s = 0;     for (int i = 1; i <= n; i++) s += p[i + 1] * p[i];     if (s < 0)       for (int i = 1, j = n; i < j; swap(p[i++], p[j--]))         ;     printf( %lld , search(1, n));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long quick_pow(long long a, long long b, long long mod) {     long long ans = 1, base = a;     while (b) {       if (b & 1) (ans *= base) %= mod;       b >>= 1;       (base *= base) %= mod;     }     return ans;   }   struct node {     int pos, len;     bool operator<(const node& k) const { return pos < k.pos; }   };   const int N = 1e5 + 5;   int X[N], Y[N];   int A[N], B[N];   int main() {     int n, m;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d %d , &X[i], &Y[i]);       A[i] = X[i];       B[i] = Y[i];     }     sort(X + 1, X + n + 1);     sort(Y + 1, Y + n + 1);     m = (n + 1) >> 1;     int mid_x = X[m], mid_y = Y[m];     int dif_x = X[m + 1] - X[m], dif_y = Y[m + 1] - Y[m];     if (n & 1) {       dif_x = min(dif_x, X[m] - X[m - 1]);       dif_y = min(dif_y, Y[m] - Y[m - 1]);     }     long long ans = 0;     bool F0 = false, F1 = false, Tag = false;     for (int i = 1; i <= n; ++i) {       ans += abs(X[i] - X[m]) + abs(Y[i] - Y[m]);       F0 |= A[i] > mid_x && B[i] > mid_y;       F1 |= A[i] > mid_x && B[i] <= mid_y;       Tag |= A[i] == mid_x && B[i] == mid_y;     }     if (F0 && F1 && (~n & 1 || Tag)) ans -= min(dif_x, dif_y);     printf( %I64d n , ans << 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long parent[200001];   long long urank[200001];   void create(long long x) {     parent[x] = x;     urank[x] = 1;   }   long long find(long long x) {     if (parent[x] != x) {       parent[x] = find(parent[x]);     }     return parent[x];   }   void merge(long long x, long long y) {     long long xroot = find(x);     long long yroot = find(y);     if (urank[xroot] <= urank[yroot]) {       parent[xroot] = yroot;       urank[yroot] = urank[yroot] + urank[xroot];     } else {       parent[yroot] = xroot;       urank[xroot] = urank[xroot] + urank[yroot];     }   }   int main() {     std::ios::sync_with_stdio(false);     int T;     T = 1;     while (T--) {       int n, i, j, m;       cin >> n >> m;       long long ar[n + 1], a, b, c;       vector<pair<long long, int> > v;       vector<pair<long long, pair<int, int> > > v2;       for (i = 1; i <= n; ++i) {         create(i);         cin >> ar[i];         v.push_back({ar[i], i});       }       sort(v.begin(), v.end());       long long ans = 0;       for (i = 1; i < n; ++i) {         v2.push_back({v[0].first + v[i].first, {v[0].second, v[i].second}});       }       while (m--) {         cin >> a >> b >> c;         v2.push_back({c, {a, b}});       }       sort(v2.begin(), v2.end());       for (i = 0; i < v2.size(); ++i) {         a = find(v2[i].second.first);         b = find(v2[i].second.second);         if (a == b) continue;         ans = ans + v2[i].first;         merge(a, b);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double eps = 1e-9;   const long double pi = acos(-1.0);   const long long inf = 1e+9;   const long long inf64 = inf * inf;   #pragma comment(linker,  /STACK:36777216 )   template <typename T>   istream &operator>>(istream &, vector<T> &);   template <typename T>   ostream &operator<<(ostream &, const vector<T> &);   void solve() {     int m;     cin >> m;     string s;     cin >> s;     int n = s.size();     vector<int> cnt(26);     for (int i = 0; i < n; i++) cnt[s[i] -  a ]++;     for (char t =  a ; t <=  z ; t++) {       int last = -1;       bool fl = 1;       int count = 0;       for (int i = 0; i < n; i++) {         if (s[i] < t) {           if (i - last > m) {             fl = 0;             break;           }           last = i;         }         if (s[i] == t) {           int pos = -1;           int pos2 = -1;           for (int j = last + 1; j < n && j < last + 1 + m; j++) {             if (s[j] < t) pos = j;             if (s[j] == t) pos2 = j;           }           if (pos > i) {             last = pos;             i = pos;             continue;           }           if (pos2 != -1) {             i = pos2;             last = pos2;             count++;           } else {             fl = 0;             break;           }         }         if (n - last <= m) break;       }       if (fl && n - last <= m) {         string ans =   ;         for (char z =  a ; z < t; z++) ans += string(cnt[z -  a ], z);         ans += string(count, t);         cout << ans << endl;         return;       }     }   }   int main() {     solve();     return 0;   }   template <typename T>   istream &operator>>(istream &is, vector<T> &v) {     for (int i = 0; i < v.size(); ++i) is >> v[i];     return is;   }   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &v) {     for (int i = 0; i < v.size(); ++i) os << v[i];     return os;   }
#include <bits/stdc++.h>   using namespace std;   int a[11], n;   long long dp[11][111], c[111][111];   int main() {     memset(c, 0, sizeof(c));     for (int i = (0); i < (111); i++) c[i][0] = 1;     for (int i = (1); i < (111); i++)       for (int j = (1); j <= (i); j++)         c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 1000000007LL;     cin >> n;     for (int i = (0); i < (10); i++) cin >> a[i];     memset(dp, 0, sizeof(dp));     int len = 0;     for (int i = a[1]; i <= n; i++) dp[1][i] = 1;     len = a[1];     for (int i = (2); i < (10); i++) {       for (int l = len + a[i]; l <= n; l++) {         for (int j = a[i]; j <= l - len; j++) {           dp[i][l] += dp[i - 1][l - j] * c[l][j] % 1000000007LL;           dp[i][l] %= 1000000007LL;         }       }       len += a[i];     }     long long ans = 0;     for (int l = a[0] + len; l <= n; l++) {       if (l == 0) continue;       for (int i = a[0]; i <= l - len; i++) {         int k = l - i;         ans += dp[9][k] * c[l - 1][i] % 1000000007LL;         ans %= 1000000007LL;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x7f7f7f7f;   int main() {     string s;     cin >> s;     int ans = 0;     stack<char> S;     for (int i = 0; i < s.length(); i++) {       if (S.empty()) {         S.push(s[i]);       } else if (S.top() == s[i]) {         ans++;         S.pop();       } else {         S.push(s[i]);       }     }     if (ans % 2 == 0)       cout <<  No  << endl;     else       cout <<  Yes  << endl;     return 0;   }
#include <bits/stdc++.h>   long long int x, y, z, i, flag, flag2, top;   long long int A[200010];   int main() {     scanf( %lld , &x);     for (i = 1; i <= x; i++) {       scanf( %lld , &A[i]);       if (A[i] == 1 && flag == 0) {         y = i + 1;         flag = 1;       }     }     for (i = y; i <= x; i++) {       if (A[i] == 0) z++;     }     for (i = 1; i <= x; i++) {       if (A[i] == 1) {         top += z;         flag2 = 1;       } else if (A[i] == 0 && flag2 == 1)         z--;     }     printf( %lld , top);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200005, INF = 1 << 31;   struct A {     int x, w;   } a[MAXN];   int b[MAXN], c[MAXN], n, d[MAXN], f[MAXN];   bool cmp(const A &x, const A &y) { return x.x < y.x; }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d%d , &a[i].x, &a[i].w);     sort(a, a + n, cmp);     memset(f, 0, sizeof f);     memset(d, 0x7f, sizeof d);     for (int i = 0; i < n; ++i) {       b[i] = a[i].x - a[i].w;       c[i] = a[i].x + a[i].w;     }     int ans = 0;     for (int i = 0; i < n; ++i) {       int t = upper_bound(d + 1, d + ans + 1, b[i]) - d - 1;       d[t + 1] = min(c[i], d[t + 1]);       if (ans == t) ans = t + 1;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10, mod = 1e9 + 7;   const long long inf = 1e18;   long long tn[20], fv[20];   long long Mul(long long a, long long b, long long md) {     long long ans = 0;     while (b) {       if (b & 1) ans = (ans + a) % md;       a = (a + a) % md;       b >>= 1;     }     return ans;   }   long long Pow(long long a, long long b, long long md) {     long long ans = 1;     while (b) {       if (b & 1) ans = Mul(ans, a, md);       a = Mul(a, a, md);       b >>= 1;     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     tn[0] = fv[0] = 1;     for (int i = 1; i < 19; i++) tn[i] = tn[i - 1] * 10, fv[i] = fv[i - 1] * 5;     int q;     cin >> q;     while (q--) {       long long x;       cin >> x;       long long xx = x;       int n = 0;       while (xx > 0) n++, xx /= 10;       long long y = (-tn[17 - n] * x) % (1ll << 17);       if (y < 0) y += (1ll << 17);       if (y % 5 == 0) y += (1ll << 17);       x = tn[17 - n] * x + y;       long long ans = 0;       if (x % 5 == 2) ans = 1;       if (x % 5 == 4) ans = 2;       if (x % 5 == 3) ans = 3;       for (int i = 2; i <= 17; i++)         while (Pow(2, ans, fv[i]) != (x % fv[i]))           ans = (ans + 4ll * fv[i - 2]) % (4ll * fv[i - 1]);       ans += 4ll * fv[16];       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   template <typename T>   inline bool MIN(T &a, const T &b) {     return a > b ? a = b, 1 : 0;   }   template <typename T>   inline bool MAX(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   inline int plu(int a, int b) {     return a + b >= 1000000007 ? a + b - 1000000007 : a + b;   }   inline int sub(int a, int b) { return a - b < 0 ? a - b + 1000000007 : a - b; }   inline int mul(int a, int b) { return (long long)a * b % 1000000007; }   inline int inc(int &a, int b) {     a += b;     if (a >= 1000000007) a -= 1000000007;   }   inline int dec(int &a, int b) {     a -= b;     if (a < 0) a += 1000000007;   }   using namespace std;   int n, A[200010], m;   char s1[200010], s2[200010];   int ok(int L) {     int p = 1;     for (int i = 1; i <= n; ++i)       if (A[i] <= L) {         if (s1[i] == s2[p]) ++p;         if (p > m) return 1;       }     return 0;   }   int main() {     scanf( %s%s , s1 + 1, s2 + 1);     n = strlen(s1 + 1);     m = strlen(s2 + 1);     for (int i = 1, a; i <= n; ++i) scanf( %d , &a), A[a] = n - i + 1;     int l = 1, r = n + 1;     while (l < r) {       int mid = l + r >> 1;       if (ok(mid))         r = mid;       else         l = mid + 1;     }     printf( %d n , n - l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned int inet4[100010];   int main(int argc, char* argv[]) {     ios_base::sync_with_stdio(false);     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       char* str;       int inet[4];       scanf( %d.%d.%d.%d , &inet[0], &inet[1], &inet[2], &inet[3]);       inet4[i] = 0;       for (int j = 0; j < 4; j++) inet4[i] = inet4[i] * 256 + inet[j];     }     unsigned int mask = 0x80000000;     bool flag = false;     for (int i = 1; i < 32; i++) {       set<int> hh;       for (int j = 0; j < n; j++) {         hh.insert(inet4[j] & mask);       }       if (hh.size() == m) {         int ans[4];         for (int j = 3; j >= 0; j--) {           ans[j] = mask % 256;           mask /= 256;         }         printf( %d.%d.%d.%d n , ans[0], ans[1], ans[2], ans[3]);         flag = true;         break;       }       mask = mask | (mask >> 1);     }     if (!flag) printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[114514];   int l[114514], r[114514];   bool solve(int n) {     int curr = a[1];     l[1] = a[1];     for (int i = 2; i <= n; i++) {       if (a[i] < a[i - 1]) curr -= a[i - 1] - a[i];       if (curr < 0) return false;       l[i] = curr;     }     return true;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       for (int i = 1; i <= n; i++) cin >> a[i];       if (solve(n))         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int t[95];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> t[i];     }     t[0] = 0;     int langkah;     langkah = 0;     for (int i = 1; i <= n; i++) {       int a;       a = t[i] - t[i - 1];       if (a <= 15)         langkah++;       else {         break;       }     }     if (t[langkah] + 15 >= 90)       cout << 90 << endl;     else {       cout << t[langkah] + 15 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, nn = 0, pp = 0;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       if (x < 0)         nn++;       else if (x > 0)         pp++;     }     if (nn >= n / 2 + n % 2)       printf( -1 );     else if (pp >= n / 2 + n % 2)       printf( 1 );     else       printf( 0 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M, K, R;   char arr[102][102];   int best[102][102][1002];   int solve(int r, int c, int p) {     if (r < 0) {       if (p % K == 0) return p;       return -1 << 30;     }     if (best[r][c][p] != -1) return best[r][c][p];     int ret = -1 << 30;     if (c - 1 >= 0) ret = max(ret, solve(r - 1, c - 1, p + (arr[r][c] -  0 )));     if (c + 1 < M) ret = max(ret, solve(r - 1, c + 1, p + (arr[r][c] -  0 )));     return best[r][c][p] = ret;   }   void solve2(int r, int c, int p) {     if (r == 0) {       printf(  n );       return;     }     int ret = -1 << 30;     if (c - 1 >= 0 && best[r - 1][c - 1][p + (arr[r][c] -  0 )] == R)       printf( L ), solve2(r - 1, c - 1, p + (arr[r][c] -  0 ));     else if (c + 1 < M && best[r - 1][c + 1][p + (arr[r][c] -  0 )] == R)       printf( R ), solve2(r - 1, c + 1, p + (arr[r][c] -  0 ));     return;   }   int main() {     scanf( %d %d %d , &N, &M, &K);     K++;     for (int i = 0; i < N; i++) scanf( %s , arr[i]);     int ret = -1 << 30, ind;     memset(best, -1, sizeof(best));     for (int i = 0; i < M; i++) {       int x = solve(N - 1, i, 0);       if (x > ret) ret = x, ind = i;     }     if (ret == -1 << 30)       printf( -1 n );     else       printf( %d n , ret);     R = ret;     if (ret != -1 << 30) {       printf( %d n , ind + 1);       solve2(N - 1, ind, 0);     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1000000000;   char ch;   bool v[111][111];   struct data {     int x1, y1, s1, x2, y2, s2;     void sv(int a, int b, int c, int d, int e, int f) {       x1 = a;       y1 = b;       s1 = c;       x2 = d;       y2 = e;       s2 = f;     }   } p[111][111][260];   int i, j, k, n, m, f[111][111][260], a[111][111], lim, c[111][111], ans, t,       q[2000001][2], l, r, x, y, num, ax, ay;   inline void update(int tx, int ty) {     if (tx < 1 || tx > n || ty < 1 || ty > m) return;     if (f[tx][ty][i | a[tx][ty]] > f[x][y][i] + c[x][y]) {       f[tx][ty][i | a[tx][ty]] = f[x][y][i] + c[x][y];       p[tx][ty][i | a[tx][ty]].sv(x, y, i, 0, 0, 0);       if (!v[tx][ty]) v[tx][ty] = 1, q[++r][0] = tx, q[r][1] = ty;     }   }   void dfs(int x, int y, int s) {     if (!x) return;     data w = p[x][y][s];     v[x][y] = 1;     dfs(w.x1, w.y1, w.s1);     dfs(w.x2, w.y2, w.s2);   }   int main() {     scanf( %d%d%d , &n, &m, &num);     lim = (1 << num);     l = r = 0;     memset(v, 0, sizeof(v));     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++) {         scanf( %d , &c[i][j]);         a[i][j] = 0;         for (k = 0; k < lim; k++) f[i][j][k] = inf;       }     for (i = 1; i <= num; i++) {       scanf( %d%d , &j, &k);       a[j][k] = (1 << (i - 1));       q[++r][0] = j;       q[r][1] = k;       v[j][k] = 1;       f[j][k][a[j][k]] = 0;       p[j][k][a[j][k]].sv(0, 0, 0, 0, 0, 0);     }     while (l < r) {       x = q[++l][0];       y = q[l][1];       v[x][y] = 0;       for (i = 0; i < lim; i++)         for (j = 0; j < lim; j++)           if (f[x][y][i | j] > f[x][y][i] + f[x][y][j]) {             f[x][y][i | j] = f[x][y][i] + f[x][y][j];             p[x][y][i | j].sv(x, y, i, x, y, j);           }       for (i = 0; i < lim; i++) {         if (f[x][y][i] >= inf) continue;         update(x - 1, y);         update(x + 1, y);         update(x, y - 1);         update(x, y + 1);       }     }     for (i = 1, ans = inf; i <= n; i++)       for (j = 1; j <= m; j++)         if (ans > f[i][j][lim - 1] + c[i][j])           ans = f[i][j][lim - 1] + c[i][j], ax = i, ay = j;     memset(v, 0, sizeof(v));     dfs(ax, ay, lim - 1);     printf( %d n , ans);     for (i = 1; i <= n; i++, puts(  ))       for (j = 1; j <= m; j++) putchar(v[i][j] ?  X  :  . );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, M, i, X, A[100005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> N >> M;     for (i = 0; i < 2 * M; i++) {       cin >> X;       A[X]++;     }     if (N == M) {       for (i = 1; 1; i++) {         if (A[i] != 2) {           break;         }         if (i == N) {           cout <<  ring topology n ;           return 0;         }       }     }     if (N - 1 == M) {       for (i = 1; i <= N; i++) {         if (A[i] == N - 1) {           cout <<  star topology n ;           return 0;         }       }       for (i = 1; 1; i++) {         if (A[i] > 2 || A[i] == 0) {           break;         }         if (i == N) {           cout <<  bus topology n ;           return 0;         }       }     }     cout <<  unknown topology n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int hour, minute, sleeph, sleepm;     char temp;     scanf( %d%c%d , &hour, &temp, &minute);     scanf( %d%c%d , &sleeph, &temp, &sleepm);     int shour, smin;     smin = minute - sleepm;     if (smin < 0) {       smin += 60;       hour--;     }     shour = hour - sleeph;     while (shour < 0) {       shour += 24;     }     if (shour < 10) cout <<  0 ;     cout << shour <<  : ;     if (smin < 10) cout <<  0 ;     cout << smin << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> x, y, z;   inline int sqr(int x) { return x * x; }   inline double dist(int i, int j) {     return sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]) + sqr(z[i] - z[j]));   }   int main() {     int n;     cin >> n;     x.resize(n), y.resize(n), z.resize(n);     for (int i = 0; i < n; ++i) cin >> x[i] >> y[i] >> z[i];     double shortestTime = 1e9;     for (int i = 1; i < n; ++i) {       for (int j = i + 1; j < n; ++j) {         double d = dist(0, i) + dist(i, j) + dist(j, 0);         shortestTime = min(shortestTime, d / 2);       }     }     cout << setprecision(10) << shortestTime << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long modpow(long long b, long long e, long long mod) {     long long ans = 1;     for (; e; b = b * b % mod, e /= 2)       if (e & 1) ans = ans * b % mod;     return ans;   }   const int N = 5050;   int dp[N][N][2], c[N], n;   bool vis[N][N][2];   int solve(int x, int y, int z) {     if (x < 0 || y > n || x > y) return (int)1e9;     if (x == 1 && y == n) return 0;     if (vis[x][y][z]) return dp[x][y][z];     vis[x][y][z] = true;     return dp[x][y][z] =                min(solve(x - 1, y, 0) + (c[z ? y : x] == c[x - 1] ? 0 : 1),                    solve(x, y + 1, 1) + (c[z ? y : x] == c[y + 1] ? 0 : 1));   }   int32_t main() {     cin >> n;     for (int i = 0; i < (n); ++i) cin >> c[i + 1];     int ans = (int)1e9;     for (int i = 0; i < (n); ++i) ans = min(ans, solve(i + 1, i + 1, 0));     cout << ans << endl;   }
#include<bits/stdc++.h>   using namespace std;   #define endl   n    #define ll long long   int main()   { ios_base::sync_with_stdio(false);        cin.tie(NULL);    ll t;   cin>>t;   while(t--)   { ll n;       cin>>n;   if(n<=3)   cout<<n-1<<endl;   else   {       if(n%2==0)       cout<<2<<endl;       else       {           cout<<3<<endl;       }          }         }                                     }
#include <bits/stdc++.h>   using namespace std;      #define rep(i, a) for(int i=0;i<a;i++)   #define repA(i,a,b)for(int i=a;i<b;i++)   #define l list   #define v vector   #define u_m unordered_map   typedef long long ll;   const int mxN=101,MOD=1e9+7;   void solve(){    int n,m,count=1,r=0;    cin>>n>>m;    string s;    cin>>s;    while(count>0&&r<m){     string cop=s;     count=0;     rep(i,n){      if(s[i]== 0 ){      int cr=0;      if(i-1>=0&&s[i-1]== 1 )cr++;      if(i+1<n&&s[i+1]== 1 )cr++;      if(cr==1){       cop[i]= 1 ;       count++;      }      }     }     s=cop;     r++;    }    cout<<s<<endl;   }   int main(){    ios::sync_with_stdio(0);       cin.tie(0);       cout.tie(0);    int t;    cin>>t;    while(t--){     solve();    }   }