malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int NMax = 2000010;   char A[NMax];   int N, can[NMax], H[NMax], min1[NMax], min2[NMax], H1[NMax];   int main() {     scanf( %s , A);     N = strlen(A);     int last = 0;     for (int i = 0; i < N; i++) A[N + i] = A[i];     for (int i = 0; i < N; i++) {       if (A[i] ==  ( )         H[i] = last + 1;       else         H[i] = last - 1;       last = H[i];     }     min1[0] = H[0];     for (int i = 1; i < N; i++) min1[i] = min(min1[i - 1], H[i]);     min2[N - 1] = H[N - 1];     for (int i = N - 2; i >= 0; i--) min2[i] = min(min2[i + 1], H[i]);     for (int i = 0; i < N; i++)       if (A[i] ==  ( ) {         int flag = 1;         int delta = -1;         if (A[i] ==  ( ) delta = 1;         if (min2[i] - H[i] + delta < 0) flag = 0;         if (i > 0 && min1[i - 1] + H[N - 1] - H[i] + delta < 0) flag = 0;         if (H[N - 1] > 0) can[i] = flag;       }     for (int i = 0; i < N; i++)       if (H[N - 1] == 0) can[i] = 1;     last = 0;     for (int i = N - 1; i >= 0; i--) {       if (A[i] ==  ) )         H1[N - i - 1] = last + 1;       else         H1[N - i - 1] = last - 1;       last = H1[N - i - 1];     }     min1[0] = H1[0];     for (int i = 1; i < N; i++) min1[i] = min(min1[i - 1], H1[i]);     min2[N - 1] = H1[N - 1];     for (int i = N - 2; i >= 0; i--) min2[i] = min(min2[i + 1], H1[i]);     for (int i = 0; i < N; i++)       if (A[N - i - 1] ==  ) ) {         int flag = 1;         int delta = -1;         if (A[N - i - 1] ==  ) ) delta = 1;         if (min2[i] - H1[i] + delta < 0) flag = 0;         if (i > 0 && min1[i - 1] + H1[N - 1] - H1[i] + delta < 0) flag = 0;         if (H[N - 1] < 0) can[(N - (i - 1 + N) % N - 1 + N) % N] = flag;       }     for (int i = 0; i < N; i++) can[i + N] = can[i];     int p1 = 0, p2 = 1, pos = -1;     while (p1 < 2 * N && !can[p1]) p1 = p1 + 1;     p2 = p1 + 1;     while (p2 < 2 * N && !can[p2]) p2 = p2 + 1;     while (p1 < N && p2 < N) {       if (A[p2] > A[p1]) {         p2 = p2 + 1;         while (p2 < 2 * N && !can[p2]) p2 = p2 + 1;       } else if (A[p2] < A[p1]) {         p1 = p2;         p2 = p2 + 1;         while (p2 < 2 * N && !can[p2]) p2 = p2 + 1;       } else {         int k = 1;         while (k < 2 * N && A[p1 + k] == A[p2 + k]) k++;         if (A[p1 + k] > A[p2 + k]) {           p1 = p1 + k + 1;           while (p1 < 2 * N && !can[p1]) p1 = p1 + 1;         } else {           p2 = p2 + k + 1;           while (p2 < 2 * N && !can[p2]) p2 = p2 + 1;         }       }       if (p1 == p2) {         p2 = p1 + 1;         while (p2 < 2 * N && !can[p2]) p2 = p2 + 1;       } else if (p1 > p2)         swap(p1, p2);     }     pos = p2;     if (p1 < p2) pos = p1;     if (pos >= N) pos -= N;     if (H[N - 1] > 0) {       printf( %c , A[pos]);       for (int i = (pos + 1) % N; i != pos; i = (i + 1) % N) printf( %c , A[i]);       while (H[N - 1]--) printf( ) );     } else {       while (H[N - 1]++) printf( ( );       printf( %c , A[pos]);       for (int i = (pos + 1) % N; i != pos; i = (i + 1) % N) printf( %c , A[i]);     }     puts(  );     getchar();     getchar();     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;     int sum = 0;     int c;     int ans = 0;     int k = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> c;       sum += c;       k += c;       if (k < 0) k = 0;       ans = max(ans, k);     }     cout << -sum + ans * 2;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 666;   const double eps = 1e-10;   int n, m, K, cnt, sz;   int id[N], nod[N], cur[N];   double deg[N], g[N][N];   bool trap[N];   double v[N][N];   struct node {     double vec[N];   } vv[N];   struct mat {     double v[166][166];     mat() { memset(v, 0, sizeof(v)); }   } ans;   node operator*(node a, double w) {     for (int i = 0; i <= n; i++) a.vec[i] *= w;     return a;   }   node operator/(node a, double w) {     for (int i = 0; i <= n; i++) a.vec[i] /= w;     return a;   }   node operator+(node a, node b) {     for (int i = 0; i <= n; i++) a.vec[i] += b.vec[i];     return a;   }   node operator-(node a, node b) {     for (int i = 0; i <= n; i++) a.vec[i] -= b.vec[i];     return a;   }   mat operator*(mat a, mat b) {     mat t;     memset(t.v, 0, sizeof(t.v));     for (int i = 0; i <= sz; i++) {       for (int j = 0; j <= sz; j++) {         for (int k = 0; k <= sz; k++) {           t.v[i][j] += a.v[i][k] * b.v[k][j];         }       }     }     return t;   }   int main() {     cin >> n >> m >> K;     for (int i = 1; i <= n; i++) scanf( %d , &trap[i]);     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       ++deg[x], ++deg[y], ++g[x][y], ++g[y][x];     }     for (int i = 1; i <= n; i++) {       if (trap[i]) {         nod[++cnt] = i, id[i] = cnt;       }     }     sz = cnt;     for (int i = 1; i <= n; i++) {       v[i][i] = -1;       for (int j = 1; j <= n; j++) {         if (trap[j]) {           v[i][id[j] + n] += 1.0 * g[i][j] / deg[i];         } else {           v[i][j] += 1.0 * g[i][j] / deg[i];         }       }     }     for (int i = 1; i <= sz; i++) {       vv[i + n].vec[i] = 1;       v[i + n][i + n] = 1;     }     for (int i = 1; i <= n + sz; i++) {       int me = -1;       double mx = 0;       for (int j = 1; j <= n + sz; j++) {         if (abs(v[i][j]) > mx) {           mx = abs(v[i][j]);           me = j;         }       }       if (me == -1 || abs(mx) < eps) continue;       cur[i] = me;       double val = v[i][me];       for (int j = 1; j <= n + sz; j++) v[i][j] /= val;       vv[i] = vv[i] / val;       for (int j = 1; j <= n + sz; j++) {         if (j != i && abs(v[j][me]) > eps) {           double val = v[j][me];           for (int k = 1; k <= n + sz; k++) v[j][k] -= v[i][k] * val;           vv[j] = vv[j] - vv[i] * val;         }       }     }     for (int i = 1; i <= n + sz; i++) {       if ((cur[i] <= n && trap[cur[i]]) || cur[i] == 1) {         if (cur[i] == 1) {           for (int j = 1; j <= sz; j++) ans.v[0][j] = vv[i].vec[j];         } else {           for (int j = 1; j <= sz; j++) ans.v[id[cur[i]]][j] = vv[i].vec[j];         }       }     }     mat res;     memset(res.v, 0, sizeof(res.v));     for (int i = 0; i <= sz; i++) res.v[i][i] = 1;     int nn = K - 1;     for (; nn; nn >>= 1) {       if (nn & 1) res = res * ans;       ans = ans * ans;     }     printf( %.10lf n , res.v[0][id[n]]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 100;   long long n, m, dau, cuoi, giua, pos1, pos2, t;   bool kt;   struct point {     long long x, y;   } p[N], ab, ac, z;   long long ccw(point a, point b, point c) {     ab = {b.x - a.x, b.y - a.y};     ac = {c.x - a.x, c.y - a.y};     return ab.x * ac.y - ab.y * ac.x;   }   long long dis(point a, point b) {     return (b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y);   }   bool cmp1(point a, point b) { return (a.y < b.y || (a.y == b.y && a.x < b.x)); }   bool cmp2(point b, point c) {     t = ccw(p[1], b, c);     return t > 0 || (t == 0 && dis(p[1], b) > dis(p[1], c));   }   bool check(point z) {     if (ccw(p[1], p[2], z) <= 0) return 0;     if (ccw(p[n], p[1], z) <= 0) return 0;     pos1 = pos2 = 0;     dau = 2;     cuoi = n;     while (dau <= cuoi) {       giua = (dau + cuoi) / 2;       if (ccw(p[1], p[giua], z) >= 0)         pos1 = giua, dau = giua + 1;       else         cuoi = giua - 1;     }     if (pos1 == 0) return 0;     dau = 2;     cuoi = n;     while (dau <= cuoi) {       giua = (dau + cuoi) / 2;       if (ccw(p[1], p[giua], z) <= 0)         pos2 = giua, cuoi = giua - 1;       else         dau = giua + 1;     }     if (pos2 == 0) return 0;     if (pos1 == pos2) {       if (dis(p[1], p[pos1]) <= dis(p[1], z))         return 0;       else         return 1;     }     if (ccw(p[pos1], p[pos2], z) <= 0) return 0;     return 1;   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> p[i].x >> p[i].y;     }     sort(p + 1, p + 1 + n, cmp1);     sort(p + 2, p + 1 + n, cmp2);     cin >> m;     kt = 1;     for (int i = 1; i <= m; i++) {       cin >> z.x >> z.y;       if (kt == 1)         if (check(z) == 0) {           kt = 0;         }     }     if (kt == 1)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   long long power(long long base, long long exp);   void solve() {     long long n, m, k;     cin >> n >> m >> k;     vector<vector<long long>> arr(n, vector<long long>(m, 0));     long long count[3][5001];     memset(count, 0, sizeof(count));     list<pair<long long, long long>> key;     for (long long i = 0; i < k; i++) {       long long a, b, c;       cin >> a >> b >> c;       key.push_front({a, b});       count[a][b] = c;     }     set<pair<long long, long long>> s;     for (auto k : key) {       long long x = k.first;       if (s.count(k))         continue;       else         s.insert(k);       if (x == 2) {         for (long long i = 0; i < n; i++) {           if (arr[i][k.second - 1] == 0) {             arr[i][k.second - 1] = count[k.first][k.second];           }         }       } else {         for (long long i = 0; i < m; i++) {           if (arr[k.second - 1][i] == 0) {             arr[k.second - 1][i] = count[k.first][k.second];           }         }       }     }     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < m; j++) {         cout << arr[i][j] <<    ;       }       cout <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     srand(chrono::high_resolution_clock::now().time_since_epoch().count());     long long t = 1;     while (t--) {       solve();     }     return 0;   }   long long power(long long base, long long exp) {     base %= 1000000007;     long long result = 1;     while (exp > 0) {       if (exp & 1) result = ((long long)result * base) % 1000000007;       base = ((long long)base * base) % 1000000007;       exp >>= 1;     }     return result;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     string s;     getline(cin, s);     for (auto i = s.end() - 1; i >= s.begin(); i--) {       if ((int(*i) >= 65 && (int(*i) <= 90)) ||           (int(*i) >= 97 && (int(*i) <= 122))) {         if (*i ==  A  || *i ==  E  || *i ==  I  || *i ==  O  || *i ==  U  ||             *i ==  a  || *i ==  e  || *i ==  i  || *i ==  o  || *i ==  u  ||             *i ==  y  || *i ==  Y )           cout <<  YES ;         else           cout <<  NO ;         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 110;   int N;   struct notlaptop {     int speed, ram, hdd, cost;     notlaptop(int a, int b, int c, int d) {       speed = a;       ram = b;       hdd = c;       cost = d;     }     notlaptop()<% %>   };   notlaptop ar[MAXN];   int main() {     scanf( %d , &N);     for (int i = 0; i < N; i++) {       int a, b, c, d;       cin >> a >> b >> c >> d;       ar[i] = notlaptop(a, b, c, d);     }     int bcost = 1e9, res = -1;     for (int i = 0; i < N; i++) {       bool outdated = false;       for (int j = 0; j < N; j++) {         if (ar[i].speed < ar[j].speed and ar[i].ram < ar[j].ram and             ar[i].hdd < ar[j].hdd) {           outdated = true;           break;         }       }       if (!outdated) {         if (ar[i].cost < bcost) {           bcost = ar[i].cost, res = i + 1;         }       }     }     cout << res <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   inline char gc() {     static char now[1 << 16], *S, *T;     if (T == S) {       T = (S = now) + fread(now, 1, 1 << 16, stdin);       if (T == S) return EOF;     }     return *S++;   }   inline long long read() {     register long long x = 0, f = 1;     char ch = gc();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = gc();     }     while (isdigit(ch)) {       x = (x << 3) + (x << 1) + ch -  0 ;       ch = gc();     }     return (f == 1) ? x : -x;   }   struct edge {     int to, nxt, dis;   } g[1200001];   int head[1200001], tot, n, m;   inline void made(int from, int to, int dis) {     g[++tot].to = to;     g[tot].nxt = head[from];     head[from] = tot;     g[tot].dis = dis;   }   int sz[1200001], dep[1200001], wson[1200001];   int s[1200001], a[1200001], F[10000001], ans[1200001];   void dfs0(int u, int fa) {     sz[u] = 1;     dep[u] = dep[fa] + 1;     for (int i = head[u]; i; i = g[i].nxt) {       int v = g[i].to;       if (v == fa) continue;       s[v] = a[v] ^ s[u] ^ g[i].dis;       dfs0(v, u);       sz[u] += sz[v];       if (sz[wson[u]] < sz[v]) wson[u] = v;     }   }   void get(int u, int fa, int wht) {     if (wht)       F[s[u]] = max(F[s[u]], dep[u]);     else       F[s[u]] = 0;     for (int i = head[u]; i; i = g[i].nxt) {       int v = g[i].to;       if (v == fa) continue;       get(v, u, wht);     }   }   void calc(int zx, int u, int fa) {     if (F[s[u]]) ans[zx] = max(F[s[u]] + dep[u] - 2 * dep[zx], ans[zx]);     for (int i = 0, two = 1; i < 22; i++, two <<= 1) {       if (F[s[u] ^ two])         ans[zx] = max(F[s[u] ^ two] + dep[u] - 2 * dep[zx], ans[zx]);     }     for (int i = head[u]; i; i = g[i].nxt) {       int v = g[i].to;       if (v == fa) continue;       calc(zx, v, u);     }   }   void doit(int u, int fa, int wht) {     for (int i = head[u]; i; i = g[i].nxt) {       int v = g[i].to;       if (v == fa || v == wson[u]) continue;       doit(v, u, 0);     }     if (wson[u]) doit(wson[u], u, 1);     if (F[s[u]]) ans[u] = max(F[s[u]] - dep[u], ans[u]);     for (int i = 0, two = 1; i < 22; i++, two <<= 1) {       if (F[s[u] ^ two]) ans[u] = max(F[s[u] ^ two] - dep[u], ans[u]);     }     F[s[u]] = max(F[s[u]], dep[u]);     for (int i = head[u]; i; i = g[i].nxt) {       int v = g[i].to;       if (v == fa || v == wson[u]) continue;       calc(u, v, u);       get(v, u, 1);     }     if (!wht) get(u, fa, 0);   }   void dfs1(int u, int fa) {     for (int i = head[u]; i; i = g[i].nxt) {       int v = g[i].to;       if (v == fa) continue;       dfs1(v, u);       ans[u] = max(ans[u], ans[v]);     }   }   int main() {     n = read();     for (int i = 1; i < n; i++) {       int u = read();       char ch = gc();       while (!isalpha(ch)) ch = gc();       made(i + 1, u, (1 << (ch -  a )));       made(u, i + 1, (1 << (ch -  a )));     }     dfs0(1, 0);     doit(1, 0, 0);     dfs1(1, 0);     for (int i = 1; i <= n; i++) {       printf( %d  , ans[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     cin >> t;     while (t--) {       long long int n;       cin >> n;       long long int a = sqrt(n);       long long int b = n / a;       if (n % a != 0) b++;       if (n == 1)         cout <<  0 n ;       else {         cout << a - 1 + b - 1 <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long n, m, t;   long long a[500000];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> t;     for (long long ti = 0; ti < t; ti++) {       map<vector<long long>, long long> tab;       map<vector<long long>, long long>::iterator iter;       cin >> n >> m;       vector<long long> v[n + 1];       for (long long i = 0; i < n; i++) cin >> a[i];       for (long long i = 0; i < m; i++) {         long long a, b;         cin >> a >> b;         v[b].push_back(a);       }       for (long long i = 0; i < n; i++) sort(v[i + 1].begin(), v[i + 1].end());       for (long long i = 0; i < n; i++)         if (!v[i + 1].empty()) tab[v[i + 1]] += a[i];       long long g;       iter = tab.begin();       g = iter->second;       iter++;       for (; iter != tab.end(); iter++) g = gcd(g, iter->second);       cout << g <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[600];   char s[600];   int cnt = 0;   int rec[3];   void dfs(int src, char c) {     s[src] = c;     for (int i = 0; i < v[src].size(); i++)       if (s[v[src][i]] !=  b ) {         cnt++;         s[v[src][i]] = c;       }   }   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       v[a].push_back(b);       v[b].push_back(a);     }     for (int i = 1; i <= n; i++)       if (v[i].size() == n - 1) {         cnt++;         s[i] =  b ;       }     rec[1] = cnt;     for (int i = 1; i <= n; i++)       if (s[i] !=  b ) {         cnt++;         dfs(i,  a );         break;       }     rec[0] = cnt - rec[1];     for (int i = 1; i <= n; i++)       if (s[i] !=  a  && s[i] !=  b ) {         cnt++;         dfs(i,  c );         break;       }     rec[2] = cnt - rec[0] - rec[1];     int x = rec[0] * (rec[0] + rec[1] - 1) + rec[1] * (n - 1) +             rec[2] * (rec[1] + rec[2] - 1);     if (cnt != n || x / 2 != m)       cout <<  No  << endl;     else {       cout <<  Yes  << endl;       for (int i = 1; i <= n; i++) cout << s[i];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename A, typename B>   inline void chmin(A &a, B b) {     if (a > b) a = b;   }   template <typename A, typename B>   inline void chmax(A &a, B b) {     if (a < b) a = b;   }   long long N, M;   string S;   signed main() {     cin >> N >> M >> S;     long long ans = 0;     vector<long long> cnt(M);     for (long long i = N - 1; i >= 0; i--) {       long long c = S[i] -  a ;       if (i + 1 < N && S[i] != S[i + 1]) {         ans += N - i - 1 - cnt[c];         ans += cnt[c] * (M - 1);         ans += (N - i - 1 - cnt[c]) * (M - 2);       }       cnt[c]++;     }     fill((cnt).begin(), (cnt).end(), 0ll);     vector<long long> st(N);     for (long long i = 0; i < N; i++) {       long long c = S[i] -  a ;       if (i && S[i - 1] != S[i]) {         st[i] = 1;         if (i >= 3 && S[i - 3] == S[i - 1] && S[i - 2] == S[i])           st[i] += st[i - 2];         ans += i - cnt[c] - st[i];         ans += cnt[c] * (M - 1);         ans += (i - cnt[c]) * (M - 2);         long long tmp = st[i] - 1;         if (i - st[i] * 2 >= 0 && S[i - st[i] * 2] == S[i]) tmp++;         ans -= tmp;       }       cnt[c]++;     }     ans += (M - 1) * N;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, k, a[105], b[105], c[105], ai[105];   map<long long int, long long int> pos;   void apply_f(long long int c[105]) {     for (int i = 1; i <= n; i++) c[i] = a[c[i]];   }   void apply_if(long long int c[105]) {     for (int i = 1; i <= n; i++) c[i] = ai[c[i]];   }   bool compare(long long int a1[105], long long int a2[105]) {     for (int i = 1; i <= n; i++)       if (a1[i] != a2[i]) return 0;     return 1;   }   bool Check(int l, int r) {     if (l == 0 || l > k) return 0;     if ((k - l) % 2 == 1) return 0;     if (l == 1 && k != 1 && r == 1) return 0;     return 1;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];       ai[a[i]] = i;       c[i] = i;     }     for (int i = 1; i <= n; i++) {       cin >> b[i];     }     long long int loc = 0;     for (int i = 0; i <= 100; i++) {       if (compare(c, b)) {         pos[i] = 1;       }       apply_f(c);     }     for (int i = 1; i <= n; i++) c[i] = i;     for (int i = 0; i <= 100; i++) {       if (compare(c, b)) {         pos[-i] = 1;       }       apply_if(c);     }     long long int R = 0, L = 0;     for (int i = 0; i <= 100; i++) {       if (pos[i]) {         R = i;         break;       }     }     for (int i = 0; i >= -100; i--) {       if (pos[i]) {         L = -i;         break;       }     }     if (Check(L, R) || Check(R, L))       cout <<  YES  <<   n ;     else       cout <<  NO  <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e3 + 10, MAXM = 2e5 + 10;   pair<int, int> v[MAXM];   int l[MAXM], r[MAXM], s[MAXM], t[MAXM];   vector<int> qv[MAXM];   bool ans[MAXM];   int last[MAXN][MAXN];   int main() {     int n, m, q;     scanf( %d %d %d , &n, &m, &q);     for (int i = 1; i <= m; i++) scanf( %d %d , &v[i].first, &v[i].second);     for (int i = 0; i < q; i++)       scanf( %d %d %d %d , l + i, r + i, s + i, t + i), qv[l[i]].push_back(i);     for (int i = 0; i <= n; i++)       for (int k = 0; k <= n; k++) last[i][k] = m + 1;     for (int time = m; time > 0; time--) {       int x, y;       x = v[time].first, y = v[time].second;       last[x][y] = last[y][x] = time;       for (int vx = 1; vx <= n; vx++) {         if (last[x][vx] < last[y][vx])           last[y][vx] = last[x][vx];         else           last[x][vx] = last[y][vx];       }       for (int ix : qv[time]) ans[ix] = (last[s[ix]][t[ix]] <= r[ix]);     }     for (int i = 0; i < q; i++)       if (ans[i])         printf( Yes n );       else         printf( No n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, x1, y1, x2, y2;     long double s = 0;     scanf( %d %d , &n, &k);     scanf( %d %d , &x1, &y1);     for (int i = 1; i < n; i++) {       scanf( %d %d , &x2, &y2);       s += (long double)sqrt((long double)(x2 - x1) * (x2 - x1) +                              (long double)(y2 - y1) * (y2 - y1));       x1 = x2;       y1 = y2;     }     printf( %.6Lf , s * (long double)k / (long double)50);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, ans, t;   int a[100005];   int main() {     scanf( %d%d , &n, &k);     ans = 1;     t = 1;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       if (a[i] == a[i - 1]) {         ans = max(ans, i - t);         t = i;       }     }     ans = max(ans, n - t + 1);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:50000000 )   using namespace std;   int n, z = 0, x, y;   int a[105];   bool f;   int main() {     scanf( %d , &n);     if (n % 2 == 0 || n < 2) {       printf( -1 n );       return 0;     }     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     for (int i = n; i >= 1; i--) {       while (a[i] > 0) {         x = 0;         y = 0;         f = 0;         if (i * 2 + 1 <= n) {           x = 1 + (a[i * 2] > 0) + (a[i * 2 + 1] > 0);           f = 1;         }         if (i / 2 > 0) {           y = (a[i / 2] > 0) + (a[(i / 2) * 2] > 0) + (a[(i / 2) * 2 + 1] > 0);           f = 1;         }         if (f == 0) {           printf( -1 n );           return 0;         }         z++;         if (x > y) {           a[i]--;           a[i * 2]--;           a[i * 2 + 1]--;         } else {           a[i / 2]--;           a[(i / 2) * 2]--;           a[(i / 2) * 2 + 1]--;         }       }     }     printf( %d n , z);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int fx[] = {-1, 1, 0, 0};   int fy[] = {0, 0, 1, -1};   int dx[] = {-1, 1, 0, 0, 1, 1, -1, -1};   int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};   int cx[] = {1, 1, 2, 2, -1, -1, -2, -2};   int cy[] = {2, -2, 1, -1, 2, -2, 1, -1};   const int N = 1 << 11;   int n;   int ans[N + 1];   int ask(int p, int q) {     printf( ? %d %d n , p, q);     fflush(stdout);     int x;     scanf( %d , &x);     return x;   }   int value(int x) {     int ans = N - 1;     for (int i = 1; i <= 15; i++) {       int a = rand() % n + 1;       if (a == x) continue;       ans &= ask(x, a);     }     return ans;   }   void solve() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     srand(2137);     scanf( %d , &n);     vector<int> v;     for (int i = 1; i <= n; i++) v.push_back(i);     random_shuffle(v.begin(), v.end());     pair<int, int> zero = {v[0], value(v[0])};     for (int i = 1; i <= n - 1; i++) {       int a = ask(zero.first, v[i]);       if ((a & zero.second) == a) zero = {v[i], value(v[i])};     }     for (int i = 1; i <= n; i++)       if (i != zero.first) ans[i] = ask(i, zero.first);     printf( !  );     for (int i = 1; i <= n; i++) printf( %d  , ans[i]);   }   signed main() {     solve();     return 0;   }