malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int a[100005];   int t[400005];   int d[400005];   pair<int, int> p[305];   pair<int, int> cp[305];   int n;   void build(int l, int r, int i) {     d[i] = 0;     if (l == r)       t[i] = a[l];     else {       int m = (l + r) / 2;       int L = 2 * i;       build(l, m, L);       build(m + 1, r, L + 1);       t[i] = (t[L] < t[L + 1] ? t[L] : t[L + 1]);     }   }   void update(int l, int r, int p, int x, int y, int i) {     if (l > y || r < x) return;     if (l <= x && r >= y) {       d[i] += p;       t[i] += p;       return;     }     int m = (x + y) / 2;     int L = 2 * i;     update(l, r, p, x, m, L);     update(l, r, p, m + 1, y, L + 1);     t[i] = (t[L] < t[L + 1] ? t[L] : t[L + 1]) + d[i];   }   bool comp(pair<int, int> x, pair<int, int> y) { return (x.second < y.second); }   int main() {     ios::sync_with_stdio(false);     int m;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < m; i++) {       cin >> p[i].first >> p[i].second;       p[i].first--;       p[i].second--;       cp[i] = p[i];     }     sort(p, p + m);     int v = 0, an = -1000000007;     build(0, n - 1, 1);     for (int j = m - 1, i = n - 1; i >= 0; i--) {       if (an < a[i] - t[1]) {         an = a[i] - t[1];         v = i;       }       while (j >= 0 && p[j].first >= i) {         update(p[j].first, p[j].second, -1, 0, n - 1, 1);         j--;       }     }     sort(p, p + m, comp);     build(0, n - 1, 1);     for (int j = 0, i = 0; i < n; i++) {       if (an < a[i] - t[1]) {         an = a[i] - t[1];         v = i;       }       while (j < m && p[j].second <= i) {         update(p[j].first, p[j].second, -1, 0, n - 1, 1);         j++;       }     }     cout << an << endl;     int c = 0;     for (int i = 0; i < m; i++) {       if (v < p[i].first || v > p[i].second) c++;     }     cout << c << endl;     for (int i = 0; i < m; i++) {       if (v < cp[i].first || v > cp[i].second) cout << i + 1 <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   vector<vector<pair<long long, long long>>> adj;   vector<long long> dist;   vector<bool> visited;   void djikstra(long long src) {     priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,                    greater<pair<long long, long long>>>         s;     s.push({0, src});     while (!s.empty()) {       long long u = s.top().second;       long long d_u = dist[u];       s.pop();       if (visited[u])         continue;       else         visited[u] = true;       for (auto x : adj[u]) {         long long v = x.first;         long long w = x.second;         if (dist[v] > (dist[u] + w)) {           dist[v] = dist[u] + w;           s.push({dist[v], v});         }       }     }   }   void solve() {     long long n, m;     cin >> n >> m;     adj.resize(n + 1);     dist.resize(n + 1, LLONG_MAX);     visited.resize(n + 1, false);     for (long long i = 0; i < m; ++i) {       long long u, v, w;       cin >> u >> v >> w;       adj[u].push_back({v, 2 * w});       adj[v].push_back({u, 2 * w});     }     for (long long i = 0; i < n; ++i) {       long long temp;       cin >> temp;       adj[0].push_back({i + 1, temp});     }     dist[0] = 0;     djikstra(0);     for (long long i = 1; i <= n; ++i) {       cout << dist[i] <<    ;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t = 1;     long long i, j;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     set<string> a;     vector<string> s(n);     for (int i = 0; i < n; i++) {       cin >> s[i];     }     for (int i = n - 1; i >= 0; i--) {       if (a.count(s[i]) == 0) {         cout << s[i] << endl;         a.insert(s[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Z = (int)1e5 + 111;   const int INF = (int)1e9 * 2 + 111;   int n, m, k;   bool can(long long x) {     int u = k;     int one = x, two = max(x - k + 1, (long long)1);     long long p = ((long long)one + two) * ((long long)one - two + 1) / 2;     p += (long long)k - ((long long)one - two + 1);     one = x;     two = max(x - (n - k), (long long)1);     p += ((long long)one + two) * ((long long)one - two + 1) / 2 - x;     p += (long long)n - k - ((long long)one - two);     if (p <= m) return 1;     return 0;   }   int main() {     cin >> n >> m >> k;     int l = 1, r = m + 1;     while (l < r - 1) {       int mid = (l + r) / 2;       if (can(mid))         l = mid;       else         r = mid;     }     cout << l;     return 0;   }
#include <bits/stdc++.h>   const int Maxn = 1000 * 1000 + 10;   using namespace std;   int main() {     vector<int> A[10000];     int B[10000];     int n;     cin >> n;     n *= 2;     int e[10000];     for (int i = 0; i < n; i++) {       int a;       cin >> a;       A[a].push_back(i);       B[i] = a;     }     bool k = true;     int size1 = 0, size2 = 0;     int s1 = 0, s2 = 0;     for (int i = 10; i <= 99; i++) {       if (A[i].size() > 1) {         for (int j = 0; j < 2; j++) {           if (j % 2 == 0)             e[A[i][A[i].size() - 1]] = 1;           else             e[A[i][A[i].size() - 1]] = 2;           A[i].pop_back();         }         s1++;         s2++;         size1++;         size2++;       } else if (A[i].size() == 0)         continue;       else {         if (k) {           e[A[i][0]] = 1;           size1++;           s1++;         } else {           s2++;           size2++;           e[A[i][0]] = 2;         }         k = !k;         A[i].pop_back();       }     }     cout << s1 * s2 << endl;     for (int i = 0; i < n; i++) {       while (!A[B[i]].empty()) {         if (size1 < n / 2) {           e[A[B[i]][A[B[i]].size() - 1]] = 1;           size1++;           A[B[i]].pop_back();         } else {           e[A[B[i]][A[B[i]].size() - 1]] = 2;           size2++;           A[B[i]].pop_back();         }       }     }     for (int i = 0; i < n; i++) {       cout << e[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5001;   int n, k, a[N * 60];   long long dp[N][N];   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; i++) scanf( %d , a + i);     sort(a, a + n);     for (int i = 0; i < N; i++)       for (int j = 0; j < N; j++) dp[i][j] = 5e18;     dp[k - n % k][n % k] = 0;     for (int i = k - n % k; i + 1; i--)       for (int j = n % k; j + 1; j--) {         if (i) {           int last = n / k * (k - n % k - i) + (n / k + 1) * (n % k - j);           dp[i - 1][j] =               min(dp[i - 1][j], dp[i][j] + a[last + n / k - 1] - a[last]);         }         if (j) {           int last = n / k * (k - n % k - i) + (n / k + 1) * (n % k - j);           dp[i][j - 1] = min(dp[i][j - 1], dp[i][j] + a[last + n / k] - a[last]);         }       }     printf( %lld n , dp[0][0]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s, a[1000];     int max = 0;     scanf( %d%d , &n, &s);     int sum = 0;     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       if (a[i] > max) max = a[i];     }     int flag = 1;     for (int i = 0; i < n; i++) {       if (a[i] == max && flag) {         flag = 0;       } else {         sum += a[i];       }     }     if (sum <= s)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int pos[200003];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, x, l = 0, r = 0;     char c;     cin >> n;     cin >> c >> x;     n--;     while (n--) {       cin >> c >> x;       if (c ==  L ) {         pos[x] = --l;       } else if (c ==  R ) {         pos[x] = ++r;       } else {         cout << min(r - pos[x], pos[x] - l) <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int l[7];   int main() {     scanf( %d%d%d , &l[3], &l[4], &l[5]);     double a, A, ap, r, anw = 0;     for (int n = 3; n <= 5; n++) {       a = acos(-1) / n;       A = 1.0 * n / 4 * l[n] * l[n] / tan(a);       ap = A * 2 / n / l[n];       r = ap / cos(a);       anw += A * sqrt(l[n] * l[n] - r * r) / 3;     }     printf( %.10lf , anw);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     int tc;     cin >> tc;     while (tc--) {       int n;       cin >> n;       int sum = (n % 10 - 1) * 10;       if (1 <= n) sum += 1;       if (10 <= n) sum += 2;       if (100 <= n) sum += 3;       if (1000 <= n) sum += 4;       cout << sum <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353, N = 510;   int n, m, a[N], st[N][12], g[N][12], dp[N][N];   int solve(int l, int r) {     if (dp[l][r]) return dp[l][r];     if (l > r) return 1;     long long r1 = 0, r2 = 0;     int pos, lo = log2(r - l + 1);     if (st[l][lo] < st[r - (1 << lo) + 1][lo])       pos = g[l][lo];     else       pos = g[r - (1 << lo) + 1][lo];     for (int i = l; i <= pos; i++)       r1 += 1ll * solve(l, i - 1) * solve(i, pos - 1) % mod;     for (int i = pos; i <= r; i++)       r2 += 1ll * solve(pos + 1, i) * solve(i + 1, r) % mod;     r1 %= mod;     r2 %= mod;     return dp[l][r] = 1ll * r1 * r2 % mod;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), st[i][0] = a[i], g[i][0] = i;     for (int i = 1; (1 << i) <= n; i++) {       for (int j = 1; j + (1 << i) - 1 <= n; j++) {         int y = j + (1 << (i - 1));         if (st[j][i - 1] < st[y][i - 1])           g[j][i] = g[j][i - 1];         else           g[j][i] = g[y][i - 1];         st[j][i] = min(st[j][i - 1], st[y][i - 1]);       }     }     printf( %d n , solve(1, n));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e6 + 7;   int cnt[N], a[N], idx, l, r, n;   long long ans, sum;   int main() {     scanf( %d , &n);     for (int i = (1); i <= (n); ++i) {       scanf( %d , a + i);       if (a[i] >= i)         l++, cnt[a[i] - i]++;       else         r++;       ans += abs(a[i] - i);     }     sum = ans, idx = 0;     for (int i = (0); i <= ((n - 1)); ++i) {       l -= cnt[i], r += cnt[i];       sum = sum - l + r - abs(a[n - i] - n) + a[n - i] - 2;       cnt[a[n - i] + i]++, l++, r--;       if (sum < ans) ans = sum, idx = i + 1;     }     printf( %lld %d n , ans, idx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   vector<long long> presum(maxn, 0);   int main() {     int last = 0;     for (long long i = 1; i < maxn; ++i) {       presum[i] = presum[i - 1] + min(i, 9LL);       if (i >= 10 && i < 100) {         presum[i] = presum[i] + (2LL * (i - 9LL));       } else if (i >= 100 && i < 1000) {         presum[i] = presum[i] + (2LL * 90LL) + (3LL * (i - 99LL));       } else if (i >= 1000 && i < 10000) {         presum[i] =             presum[i] + (2LL * 90LL) + (3LL * 900LL) + (4LL * (i - 999LL));       } else if (i >= 10000 && i < 100000) {         presum[i] = presum[i] + (2LL * 90LL) + (3LL * 900LL) + (4LL * 9000LL) +                     (5LL * (i - 9999LL));       } else if (i >= 100000 && i < 1000000) {         presum[i] = presum[i] + (2LL * 90LL) + (3LL * 900LL) + (4LL * 9000LL) +                     (5LL * 90000LL) + (6LL * (i - 99999LL));       } else if (i >= 1000000 && i < 10000000) {         presum[i] = presum[i] + (2LL * 90LL) + (3LL * 900LL) + (4LL * 9000LL) +                     (5LL * 90000LL) + (6LL * 900000LL) + (7LL * (i - 999999LL));       }     }     int q;     cin >> q;     while (q--) {       long long k;       cin >> k;       int it = lower_bound(presum.begin(), presum.end(), k) - presum.begin();       string aux =   ;       for (int i = 1; i <= it; ++i) {         aux += to_string(i);       }       cout << aux[k - (presum[it - 1] + 1)] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   #pragma GCC optimize( unroll-loops )   using namespace std;   template <class T>   inline T bigmod(T p, T e, T M) {     long long ret = 1;     for (; e > 0; e >>= 1) {       if (e & 1) ret = (ret * p) % M;       p = (p * p) % M;     }     return (T)ret;   }   template <class T>   inline T gcd(T a, T b) {     if (b == 0) return a;     return gcd(b, a % b);   }   template <class T>   inline T modinverse(T a, T M) {     return bigmod(a, M - 2, M);   }   template <class T>   inline T lcm(T a, T b) {     a = abs(a);     b = abs(b);     return (a / gcd(a, b)) * b;   }   template <class T, class X>   inline bool getbit(T a, X i) {     T t = 1;     return ((a & (t << i)) > 0);   }   template <class T, class X>   inline T setbit(T a, X i) {     T t = 1;     return (a | (t << i));   }   template <class T, class X>   inline T resetbit(T a, X i) {     T t = 1;     return (a & (~(t << i)));   }   inline long long getnum() {     char c = getchar();     long long num, sign = 1;     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) sign = -1;     for (num = 0; c >=  0  && c <=  9 ;) {       c -=  0 ;       num = num * 10 + c;       c = getchar();     }     return num * sign;   }   inline long long power(long long a, long long b) {     long long multiply = 1;     for (int i = (0); i < (b); i++) {       multiply *= a;     }     return multiply;   }   string s;   int ans = 1e6;   int main() {     int test, cases = 1;     cin >> s;     int n = s.size();     for (int i = 0; i < 26; i++) {       int last = 0, d = 0;       for (int j = 0; j < n; j++) {         if (s[j] -  a  == i) {           d = max(d, j + 1 - last);           last = j + 1;         }       }       d = max(d, n + 1 - last);       ans = min(ans, d);     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int len, cnt[8010], f[8010], nxt[8010];   char st[8010];   void kmp(char *st, int len, int nxt[]) {     nxt[0] = nxt[1] = 0;     for (int i = 1; i < len; i++) {       int j = nxt[i];       while (j && st[i] != st[j]) {         j = nxt[j];       }       nxt[i + 1] = st[j] == st[i] ? j + 1 : 0;     }   }   int main() {     cin >> st;     len = strlen(st);     for (int i = 1; i <= len; i++) {       cnt[i] = cnt[i / 10] + 1, f[i] = i + 1;     }     for (int i = 0; i < len; i++) {       kmp(st + i, len - i, nxt);       for (int j = 1; j + i <= len; j++) {         if (j % (j - nxt[j]) == 0) {           f[j + i] = min(f[j + i], f[i] + cnt[j / (j - nxt[j])] + (j - nxt[j]));         } else {           f[j + i] = min(f[j + i], f[i] + 1 + j);         }       }     }     cout << f[len];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct query {     int Q, id;     long long res;   };   const int Nmax = 200001;   int n, m, parent[Nmax], Rank[Nmax];   vector<pair<int, pair<int, int> > > edge;   bool cmpQ(const query &q1, const query &q2) { return q1.Q < q2.Q; }   bool ret(const query &q1, const query &q2) { return q1.id < q2.id; }   int Find(const int &i) {     if (i == parent[i]) return i;     return parent[i] = Find(parent[i]);   }   void Union(const int &i, const int &j) {     int x = Find(i), y = Find(j);     if (x != y) {       if (Rank[x] > Rank[y]) {         parent[y] = x;         Rank[x] += Rank[y];       } else {         parent[x] = y;         Rank[y] += Rank[x];       }     }   }   int main() {     if (fopen( 1213G                 .INP ,                r )) {       freopen(            1213G             .INP ,            r , stdin);       freopen(            1213G             .OUT ,            w , stdout);     }     ios_base::sync_with_stdio(false);     cin.tie(NULL);     scanf( %d %d , &n, &m);     for (int i = 1, _n = (n); i <= _n; ++i) parent[i] = i, Rank[i] = 1;     edge.resize(n - 1);     int u, v, w, q;     for (int i = 0, _n = (n - 1); i < _n; ++i)       scanf( %d %d %d , &edge[i].second.first, &edge[i].second.second,             &edge[i].first);     sort(edge.begin(), edge.end());     vector<query> qu(m);     for (int i = 0, _n = (m); i < _n; ++i) {       scanf( %d , &qu[i].Q);       qu[i].id = i;     }     sort(qu.begin(), qu.end(), cmpQ);     int j = 0;     long long ans = 0;     for (int i = 0, _n = (m); i < _n; ++i) {       for (; j < n - 1; ++j) {         if (edge[j].first <= qu[i].Q) {           ans += (long long)Rank[Find(edge[j].second.first)] *                  Rank[Find(edge[j].second.second)];           Union(edge[j].second.first, edge[j].second.second);         } else           break;       }       qu[i].res = ans;     }     sort(qu.begin(), qu.end(), ret);     for (int i = 0, _n = (m); i < _n; ++i) cout << qu[i].res <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2, s;     int cnt, i;     while (cin >> s1 >> s2) {       sort(s1.begin(), s1.end());       for (s.clear(), cnt = i = 0; i < s1.size() && s1[i] ==  0 ; ++cnt, ++i)         ;       if (i < s1.size()) s += s1[i++];       while (cnt--) s +=  0 ;       for (; i < s1.size(); s += s1[i], ++i)         ;       if (s == s2)         cout <<  OK n ;       else         cout <<  WRONG_ANSWER n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int sol[] = {19, 873, 834, 665};   int main() {     int a, b;     bool found = false;     cin >> a >> b;     for (int i = 0; i < (int)sizeof(sol) / (int)sizeof(int); i++) {       found = true;       break;     }     if (found)       cout << a + b << endl;     else       cout << 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000000000000003;   long long powmod(long long a, long long b) {     long long res = 1;     a %= mod;     for (; b; b >>= 1) {       if (b & 1) res = res * a % mod;       a = a * a % mod;     }     return res;   }   const int N = 601000;   int n, m;   long long pw[N];   char s[N];   unordered_set<long long> ff;   int main() {     scanf( %d%d , &n, &m);     pw[0] = 1;     for (int i = 1; i < 600001; i++) pw[i] = pw[i - 1] * 3 % mod;     for (int i = 0; i < n; i++) {       scanf( %s , s);       int l = strlen(s);       long long hs = 0;       for (int j = 0; j < l; j++) hs = (hs * 3 + s[j] -  a ) % mod;       ff.insert(hs);     }     for (int i = 0; i < m; i++) {       scanf( %s , s);       int l = strlen(s);       long long hs = 0;       bool fg = 0;       for (int j = 0; j < l; j++) hs = (hs * 3 + s[j] -  a ) % mod;       for (int j = 0; j < l; j++) {         long long nhs = (hs - (s[l - 1 - j] -  a ) * pw[j]) % mod;         if (nhs < 0) nhs += mod;         for (int k = 0; k < 3; k++)           if (s[l - 1 - j] -  a  != k) {             if (ff.count((nhs + k * pw[j]) % mod)) fg = 1;           }         if (fg) break;       }       puts(fg ?  YES  :  NO );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m, n;     cin >> n >> m;     int flag = 0, j, i;     for (i = n + 1; i <= m; i++) {       flag = 0;       for (j = 2; j * j <= i; j++) {         if (i % j == 0) {           flag = 1;           break;         }       }       if (flag == 0) {         break;       }     }     if (i != m)       cout <<  NO ;     else       cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long n, k;     cin >> n >> k;     string s[n - k + 1];     for (long long i = 0; i <= n - k; i++) cin >> s[i];     string c[50];     long long i1 = 65;     for (long long i = 0; i < 26; i++) {       c[i] = i1;       i1++;     }     i1 = 65;     for (long long i = 26; i < 50; i++) {       c[i] = i1;       c[i] +=  a ;       i1++;     }     string ans[n];     i1 = 0;     for (long long i = 0; i < n; i++) {       ans[i] = c[i1];       i1++;     }     for (long long i = 0; i <= n - k; i++) {       if (s[i] ==  NO ) {         ans[i + k - 1] = ans[i];       }     }     for (long long i = 0; i < n; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       if (i % 4 == 1 or i % 4 == 3) {         for (int j = 0; j < m; j++) {           cout <<  # ;         }         cout <<   n ;       } else if (i % 4 == 2) {         for (int k = 0; k < m - 1; k++) {           cout <<  . ;         }         cout <<  #  <<   n ;       } else if (i % 4 == 0) {         cout <<  # ;         for (int l = 0; l < m - 1; l++) {           cout <<  . ;         }         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (!b) return a;     return gcd(b, a % b);   }   long long fpow(long long a, long long b, long long mod) {     long long res = 1ll;     while (b) {       if (b & 1) res = (res * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return res;   }   long long mul(long long a, long long b, long long mod) {     long long res = 0;     while (b) {       if (b & 1) res = (res + a) % mod;       a = (a + a) % mod;       b >>= 1;     }     return res;   }   const long long mod = 2015;   const double eps = 1e-3;   const double pi = acos(-1);   const long long N = 5005;   double dp[N];   struct node {     int x, y, ti;     double pi;     bool operator<(const node &o) const { return ti < o.ti; }   } a[N];   double dis(long long x, long long y) {     return sqrt((a[x].x - a[y].x) * (a[x].x - a[y].x) +                 (a[x].y - a[y].y) * (a[x].y - a[y].y));   }   int main() {     long long n;     scanf( %lld , &n);     for (long long i = 1; i <= n; i++)       cin >> a[i].x >> a[i].y >> a[i].ti >> a[i].pi;     sort(a + 1, a + 1 + n);     double ans = 0;     for (long long i = 1; i <= n; i++) {       dp[i] = a[i].pi;       for (long long j = 1; j <= i - 1; j++) {         if (a[i].ti - a[j].ti - dis(i, j) > -eps)           dp[i] = max(dp[j] + a[i].pi, dp[i]);       }       ans = max(dp[i], ans);     }     printf( %.8lf , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[100005], ans[100005];   int main() {     int n, m;     cin >> n;     while (n--) {       cin >> a;       m = strlen(a);       for (int i = 0; i < m; i++) {         if (a[i] !=  ? ) {           if (ans[i] == 0)             ans[i] = a[i];           else if (a[i] != ans[i])             ans[i] =  ? ;         }       }     }     ans[m] = 0;     for (int i = 0; i < m; i++) {       if (ans[i] == 0) ans[i] =  a ;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, l, minc, maxc;     string s;     cin >> n;     map<int, int> dict;     for (int i = 0; i < n; i++) {       cin >> s;       l = s.length();       if (l == 1) {         cout <<  YES               <<   n ;         continue;       }       for (int j = 0; j < l; j++) {         if (j == 0) {           minc = int(s[j]);           maxc = int(s[j]);           dict[int(s[j])] += 1;           continue;         }         if (minc > int(s[j])) {           minc = int(s[j]);         }         if (maxc < int(s[j])) {           maxc = int(s[j]);         }         dict[int(s[j])] += 1;       }       for (int h = minc; h <= maxc; h++) {         if (dict[h] == 1) {           if (h == maxc) {             cout <<  YES                   <<   n ;             break;           }           continue;         } else {           cout <<  NO                 <<   n ;           break;         }       }       dict.clear();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double x[150], y[150], z[150], a = 0, b = 0, c = 0;   double dist(double x, double y, double z) { return x * x + y * y + z * z; }   int main() {     int i, n, ij, j;     double bit = 1, t, temp;     cin >> n;     for (i = 1; i <= n; i++) cin >> x[i] >> y[i] >> z[i];     for (i = 1; i <= 50000; i++) {       t = -1;       ij = 0;       for (j = 1; j <= n; j++) {         temp = dist(x[j] - a, y[j] - b, z[j] - c);         if (temp > t) {           t = temp;           ij = j;         }       }       a += bit * (x[ij] - a);       b += bit * (y[ij] - b);       c += bit * (z[ij] - c);       bit *= 0.998;     }     printf( %.10f %.10f %.10f n , a, b, c);   }