malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long bin_pow(long long x, long long y, long long m) {     long long ans;     if (y <= 0) return 1;     ans = bin_pow(x, y / 2, m);     if (y % 2 == 0) return (((ans % m) * (ans % m)) % m);     return (x % m * ((ans % m * ans % m))) % m;   }   long long mult(long long a, long long b, long long m) {     long long ans = ((a % m) * (b % m)) % m;     return ans;   }   long long sum(long long a, long long b, long long m) {     long long ans = (a % m + b % m) % m;     return ans;   }   long long diff(long long a, long long b, long long m) {     long long ans = ((a % m) - (b % m) + m) % m;     return ans;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   void swap(long long &a, long long &b) {     long long tm = a;     a = b;     b = tm;   }   long long compute_lps_array(string s) {     string s1 = s;     reverse(s1.begin(), s1.end());     s = s +  $  + s1;     long long sz = s.size();     vector<long long> lps(sz + 1, 0);     lps[0] = 0;     for (long long i = 1; i < sz; i++) {       long long j = lps[i - 1];       while (j != 0 && (s[i] != s[j])) j = lps[j - 1];       if (s[i] == s[j]) j++;       lps[i] = j;     }     return lps[sz - 1];   }   long long nCr(long long n, long long r, long long m) {     long long tm1 = bin_pow(r, 998244353 - 2, 998244353);     long long tm2 = bin_pow(m, 998244353 - 2, 998244353);     long long tm3 = n % 998244353;     long long ans = mult(tm3, mult(tm1, tm2, 998244353), 998244353);     return ans;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1;     while (t--) {       string s, t;       long long ans = 0;       cin >> s >> t;       long long sz1 = s.size();       long long sz2 = t.size();       vector<long long> pre(sz2 + 2, 0), sfx(sz2 + 2, 0);       long long j = 0;       for (long long i = 0; i < sz1; i++) {         if (s[i] == t[j]) {           pre[j] = i;           j++;           if (j >= sz2) break;         }       }       j = sz2 - 1;       for (long long i = sz1 - 1; i >= 0; i--) {         if (s[i] == t[j]) {           sfx[j] = i;           j--;           if (j == -1) break;         }       }       ans = max(sfx[0], sz1 - pre[sz2 - 1] - 1LL);       for (long long i = 0; i < sz2 - 1; i++) {         long long df = sfx[i + 1] - pre[i] - 1;         ans = max(ans, df);       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   int num[10000];   int map[2000][2000];   int add(int a, int b, int c) { map[a][b] = 1, map[b][a] = 1; }   int vis[2000][2];   int main() {     int n;     while (scanf( %d , &n) != EOF) {       memset(map, 0, sizeof(map));       memset(vis, 0, sizeof(vis));       int i, j;       int len = 0;       int ans = 0;       memset(map, 0, sizeof(map));       memset(num, 0, sizeof(num));       for (i = 0; i <= 30; i++) {         if (n & (1 << i)) {           num[i]++;           len = i;         }       }       int index = 3;       for (i = 0; i <= 30; i++) {         if (i != len) continue;         int x, y;         if (i == 0) {           add(1, 2, 1);           index = 3;           continue;         }         for (j = 1; j <= i; j++) {           if (j == 1) {             add(1, index++, 3);             add(1, index++, 4);             x = index - 1;             y = index - 2;           } else {             add(x, index, 5);             index++;             add(y, index, 6);             index++;             add(x, index - 1, 7);             add(y, index - 2, 8);             x = index - 1;             y = index - 2;           }           vis[j][0] = x;           vis[j][1] = y;         }         if (i == len) {           add(x, 2, 1);           add(y, 2, 1);           continue;         }       }       for (i = 0; i <= 30; i++) {         if (num[i] && i != len) {           int x = 1;           for (j = 1; j <= len - i; j++) {             add(x, index++, 1);             x = index - 1;           }           if (i == 0) {             add(x, 2, 1);             continue;           }           add(x, vis[len - i + 1][0], 1);           add(x, vis[len - i + 1][1], 1);         }       }       printf( %d n , index - 1);       for (i = 1; i < index; i++) {         for (j = 1; j < index; j++) {           if (map[i][j] == 1)             printf( Y );           else             printf( N );         }         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int del(int n) {     double q = n;     if (n % 2 == 0) return 2;     for (int i = 3; i < sqrt(q) + 1; i = i + 2) {       if (n % i == 0) return i;     }     return 1;   }   int main() {     int n;     cin >> n;     long int s;     s = n;     int de = n;     while (n != 1) {       de = del(n);       n = n / de;       if (de == 1) {         s++;         cout << s;         return 0;       };       s += n;     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long int n, m;     cin >> n >> m;     if (m == 0) {       cout << 0;       return 0;     }     vector<vector<long long int>> v[n + 1];     long long int in[n + 1];     memset(in, 0, sizeof(in));     for (long long int i = 0; i < m; i++) {       long long int x, y, z;       cin >> x >> y >> z;       v[x].push_back({y, z});       in[y] += 1;     }     queue<vector<long long int>> q;     for (long long int i = 1; i <= n; i++) {       if (in[i] == 0 && v[i].size()) {         q.push({i, INT_MAX, i});       }     }     vector<vector<long long int>> ans;     while (q.size()) {       vector<long long int> p = q.front();       q.pop();       if (p.size() && v[p[0]].size() == 0) {         ans.push_back({p[2], p[0], p[1]});       }       for (auto x : v[p[0]]) {         in[x[0]] -= 1;         if (in[x[0]] == 0) {           q.push({x[0], min(p[1], x[1]), p[2]});         }       }     }     cout << ans.size() <<   n ;     sort(ans.begin(), ans.end());     for (auto x : ans) {       for (auto y : x) cout << y <<    ;       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.sync_with_stdio(false);     cin.tie(nullptr);     long long int n;     cin >> n;     bool prime = true;     for (long long int i = 2; i < n && i < 101010; ++i) {       if (n % i == 0) {         prime = false;       }     }     if (prime) {       cout <<  1 n ;       return 0;     }     if (n % 2 == 0) {       cout <<  2 n ;       return 0;     }     bool prime2 = true;     long long int n2 = n - 2;     for (long long int i = 2; i < n2 && i < 101010; ++i) {       if (n2 % i == 0) {         prime2 = false;       }     }     if (prime2) {       cout <<  2 n ;       return 0;     }     cout <<  3 n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 13, M = 1e5 + 13;   inline int qread() {     int res = 0, flag = 1;     char c = getchar();     while (!isdigit(c)) {       if (c ==  - ) flag = -1;       c = getchar();     }     while (isdigit(c)) res = res * 10 + (c -  0 ), c = getchar();     return res * flag;   }   int n, m, a[N];   inline int Abs(const int &x) { return x < 0 ? -x : x; }   inline long long min(const long long &x, const long long &y) {     return x < y ? x : y;   }   inline int max(const int &x, const int &y) { return x > y ? x : y; }   struct BIT {     int t[M];     inline int lowbit(int x) { return x & -x; }     inline void add(int x, int y) {       while (x <= m) t[x] += y, x += lowbit(x);     }     inline int sum(int x) {       int res = 0;       while (x) res += t[x], x -= lowbit(x);       return res;     }   } T1, T2, T3;   int main() {     n = qread();     for (int i = 1, x; i <= n; ++i) {       x = qread();       a[i] = Abs(x);       ++a[i];       m = max(m, a[i]);     }     long long sum = 0;     for (int i = n; i >= 1; --i) {       sum += T1.sum(a[i] - 1);       T1.add(a[i], 1);     }     long long ans = sum, tot = 0;     for (int i = 1; i <= n; ++i) {       if (T2.sum(a[i] - 1) >= T1.sum(a[i] - 1) - T3.sum(a[i])) {         T1.add(a[i], -1);         T3.add(a[i], 1);         ++tot;       } else {         sum -= T1.sum(a[i] - 1) + tot - T3.sum(a[i]);         T1.add(a[i], -1);         sum += T2.sum(a[i] - 1) + tot;         T2.add(a[i], 1);         ans = min(ans, sum);       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   void manupulate(string &str) {     for (long long int i = 0; i < str.size(); ++i) str[i] -= 48;   }   bool isprime(long long int n) {     if (n <= 1) return false;     for (long long int i = 2; i * i <= n; ++i)       if (n % i == 0) return false;     return true;   }   long long int expo(long long int a, long long int n) {     if (n == 0) return 1;     if (n == 1) return a;     long long int tmp = expo(a, n / 2);     tmp = (tmp * tmp) % (long)(1e9 + 7);     if (n & 1) tmp = (tmp * a) % (long)(1e9 + 7);     return tmp;   }   signed 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 k;       cin >> k;       ;       long long int ar[n], br[n];       for (long long int i = 0; i < n; ++i) cin >> ar[i];       ;       for (long long int i = 0; i < n; ++i) cin >> br[i];       ;       sort(ar, ar + n);       sort(br, br + n, greater<long long int>());       long long int ans = 0;       long long int x = 0;       for (long long int i = 0; i < k; ++i) {         if (br[i] > ar[i]) {           ans += br[i];           ++x;         }       }       for (long long int i = x; i < n; ++i) ans += ar[i];       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   string i2s(T x) {     ostringstream o;     o << x;     return o.str();   }   int n, wt[100001], root;   bool visited[100001];   pair<long long, long long> mem[100001];   vector<int> adj[100001];   pair<long long, long long> go(int u) {     if (visited[u]) return mem[u];     visited[u] = true;     pair<long long, long long>& ret = mem[u];     wt[u]--;     vector<pair<long long, long long> > tmp;     for (int i = 0; i < adj[u].size(); ++i) {       int v = adj[u][i];       if (!visited[v]) {         tmp.push_back(go(v));       }     }     sort(tmp.begin(), tmp.end(), greater<pair<long long, long long> >());     long long l = 0, r = wt[u];     for (int i = 0; i < tmp.size() && i < wt[u]; ++i) {       l += tmp[i].first + 2;       r--;     }     if (r > 0) {       for (int i = 0; i < tmp.size() && r != 0; ++i) {         if (r >= tmp[i].second) {           l += tmp[i].second * 2;           r -= tmp[i].second;         } else {           l += r * 2;           r = 0;         }       }     }     ret = make_pair(l, r);     return ret;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       visited[i] = false;       scanf( %d , wt + i);     }     for (int i = 0; i < n - 1; ++i) {       int a, b;       scanf( %d %d , &a, &b);       a--, b--;       adj[a].push_back(b);       adj[b].push_back(a);     }     scanf( %d , &root);     wt[--root]++;     printf( %I64d n , go(root).first);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int iINF = 0x3f3f3f3f;   const long long lINF = 0x3f3f3f3f3f3f3f3f;   inline void read(long long& x) {     int f = 1;     char c;     while (((c = getchar()) <  0  || c >  9 ) && c !=  - )       ;     c ==  -  ? (f = -1, x = 0) : (x = c -  0 );     while ((c = getchar()) >=  0  && c <=  9 ) x = x * 10 + c -  0 ;     x *= f;   }   inline void read(int& x) {     long long t;     read(t);     x = t;   }   const int MAXN = 1e5 + 10;   int n, k, m, t;   int main() {     cin >> n >> k >> m >> t;     while (t--) {       int opt, pos;       cin >> opt >> pos;       if (opt) {         if (pos <= k) k++;         n++;       } else {         if (pos < k) {           k -= pos;           n -= pos;         } else {           n -= n - pos;         }       }       cout << n <<     << k << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dot(complex<double> a, complex<double> b) { return real(conj(a) * b); }   double calcspeed(complex<double> p1, complex<double> p2, complex<double> w,                    double vmax) {     complex<double> r = p2 - p1;     double k =         dot(r, w) + sqrt(pow(dot(r, w), 2) - norm(r) * (norm(w) - vmax * vmax));     k /= abs(r);     return k;   }   double calc(complex<double> p1, complex<double> p2, complex<double> w,               double vmax) {     double speed = calcspeed(p1, p2, w, vmax);     return abs(p2 - p1) / speed;   }   int main() {     int x1, y1, x2, y2;     cin >> x1 >> y1 >> x2 >> y2;     double vmax, t;     cin >> vmax >> t;     int vx, vy, wx, wy;     cin >> vx >> vy >> wx >> wy;     if (x1 == x2 && y1 == y2) {       cout << 0 << endl;       return 0;     }     complex<double> r(x2, y2), v(vx, vy), w(wx, wy);     double ret = calc(complex<double>(x1, y1), complex<double>(x2, y2), v, vmax);     if (ret < t) {       printf( %.20f n , ret);       return 0;     }     r -= complex<double>(x1, y1);     v /= r;     w /= r;     vmax /= abs(r);     r /= r;     const double pi = acos(-1);     double low = -pi + 1e-6;     double high = pi - 1e-6;     double f = 0;     for (int i = (0); i < (200); i++) {       double mid1 = (low * 2 + high) / 3;       double mid2 = (low + high * 2) / 3;       complex<double> target1 = polar(200.0, mid1);       complex<double> target2 = polar(200.0, mid2);       complex<double> speed1 = calcspeed(complex<double>(0, 0), target1, v, vmax);       complex<double> speed2 = calcspeed(complex<double>(0, 0), target2, v, vmax);       complex<double> point1 = speed1 * target1 / abs(target1) * t;       complex<double> point2 = speed2 * target2 / abs(target2) * t;       double f1 = calc(point1, r, w, vmax);       double f2 = calc(point2, r, w, vmax);       if (f1 > f2) {         low = mid1;         f = f1;       } else {         high = mid2;         f = f2;       }     }     printf( %.20f n , f + t);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e6 + 5, P = 1e9 + 7;   long long n, k, m, res, l, T, ans, mi;   int dp[2][M], A[M], B[M], sum[M];   int main() {     cin >> n >> l >> k;     for (int i = 1; i <= n; i++) {       scanf( %d , A + i);       B[i] = A[i];     }     sort(B + 1, B + 1 + n);     m = unique(B + 1, B + 1 + n) - B - 1;     for (int i = 1; i <= n; i++) A[i] = lower_bound(B + 1, B + 1 + m, A[i]) - B;     T = l / n;     res = l % n;     for (int i = 1; i <= n; i++) dp[1][A[i]]++;     ans = l % P;     for (int i = 2; i <= m; i++) dp[1][i] += dp[1][i - 1];     for (int i = 1; i <= m; i++) sum[i] += dp[1][i];     for (int lop = 2; lop <= min(1ll * k, T); lop++) {       int c = lop & 1;       for (int i = 1; i <= m; i++) dp[c][i] = 0;       for (int i = 1; i <= n; i++)         dp[c][A[i]] = (1ll * (dp[c][A[i]] % P) + 1ll * (dp[!c][A[i]] % P)) % P;       for (int i = 2; i <= m; i++)         dp[c][i] = (1ll * (dp[c][i] % P) + 1ll * (dp[c][i - 1] % P)) % P;       if (lop < k)         for (int i = 1; i <= m; i++)           sum[i] = (1ll * (sum[i] % P) + 1ll * (dp[c][i] % P)) % P;       long long len = (T - lop + 1) % P;       ans = (1ll * (ans % P) + 1ll * (len * dp[c][m] % P)) % P;     }     if (k >= 2 && T >= 1)       for (int i = 1; i <= res; i++)         ans = (1ll * (ans % P) + 1ll * (sum[A[i]] % P)) % P;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int N, M[55][55], C[55];   int main() {     cin >> N;     for (int i = 1; i <= N * (N - 1) / 2 - 1; ++i) {       int a, b;       cin >> a >> b;       M[a][b] = M[b][a] = 1;       C[a]++;     }     for (int i = 1; i <= N; ++i)       for (int j = i + 1; j <= N; ++j)         if (!M[i][j]) {           if (C[i] > C[j])             cout << i <<     << j <<   n ;           else             cout << j <<     << i <<   n ;         }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct line {     int x, l;   } c[105];   bool cmp(line a, line b) { return a.x < b.x; }   int f[105][105][2];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d%d , &c[i].x, &c[i].l);     sort(c + 1, c + n + 1, cmp);     c[0].x = -1e9;     int ans = 0;     for (int i = 0; i <= n; i++)       for (int j = 0; j <= i; j++)         for (int p1 = 0; p1 <= 1; p1++) {           ans = max(ans, f[i][j][p1]);           int t = c[j].x + p1 * c[j].l, mx = -1e9, id = 0, y = 0;           for (int k = i + 1; k <= n; k++)             for (int p2 = 0; p2 <= 1; p2++) {               int o = c[k].x + p2 * c[k].l;               if (o > mx) mx = o, id = k, y = p2;               f[k][id][y] =                   max(f[k][id][y], f[i][j][p1] + min(o - t, c[k].l) + mx - o);             }         }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int m, n;     cin >> m >> n;     vector<string> nums(n);     for (int i = 0; i < (int)(n); ++i) cin >> nums[i];     vector<long long> c(m, 1);     for (int i = 0; i < (int)(m); ++i) {       for (int j = 0; j < (int)(i); ++j) {         int match = 1;         for (int k = 0; k < (int)(n); ++k) {           if (nums[k][i] != nums[k][j]) {             match = 0;             break;           }         }         if (match) {           c[i] = 0;           c[j]++;           break;         }       }     }     vector<vector<long long> > choose(m + 1, vector<long long>(m + 1, 0));     for (int i = 0; i < (int)(m + 1); ++i) {       choose[i][0] = 1;       choose[i][i] = 1;       for (int j = 0; j < (int)(m + 1); ++j) {         if (i && j)           choose[i][j] = (choose[i - 1][j] + choose[i - 1][j - 1]) % 1000000007;       }     }     vector<long long> dp(m + 1);     dp[0] = 1;     for (int i = 0; i < (int)(m + 1); ++i) {       if (i) {         for (int j = 0; j < (int)(i); ++j) {           dp[i] += (choose[i - 1][j] * dp[i - 1 - j]) % 1000000007;           dp[i] %= 1000000007;         }       }     }     long long ans = 1;     for (int i = 0; i < (int)(m); ++i) {       if (c[i]) ans = (ans * dp[c[i]]) % 1000000007;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<bool> visited;   vector<vector<long long> > adj;   vector<vector<long long> > rev;   vector<long long> order;   vector<char> col;   void dfs1(long long x) {     visited[x] = true;     for (auto y : adj[x]) {       if (!visited[y]) dfs1(y);     }     order.push_back(x);   }   void dfs2(long long x, char colour) {     visited[x] = true;     col[x] = colour;     for (auto y : rev[x]) {       if (!visited[y]) {         dfs2(y, colour);       }     }   }   int32_t main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long i, j;     long long n, k;     cin >> n >> k;     adj.resize(n);     rev.resize(n);     long long p[n];     for (i = 0; i < n; i++) cin >> p[i];     for (i = 0; i < n - 1; i++) {       long long u = p[i + 1] - 1;       long long v = p[i] - 1;       adj[v].push_back(u);       rev[u].push_back(v);     }     for (i = 0; i < n; i++) cin >> p[i];     for (i = 0; i < n - 1; i++) {       long long u = p[i + 1] - 1;       long long v = p[i] - 1;       adj[v].push_back(u);       rev[u].push_back(v);     }     visited.assign(n, false);     for (long long i = 0; i < n; i++) {       if (!visited[i]) dfs1(i);     }     visited.assign(n, false);     reverse(order.begin(), order.end());     vector<long long> condensed[n];     char colour =  a ;     col.resize(n);     for (i = 0; i < n; i++) {       long long v = order[i];       if (!visited[v]) {         dfs2(v, colour);         if (colour !=  z ) ++colour;       }     }     set<long long> numCols;     for (i = 0; i < n; i++) {       numCols.insert(col[i]);     }     if (numCols.size() >= k)       cout <<  YES             <<   n ;     else {       cout <<  NO             <<   n ;       return 0;     }     for (auto ch : col) cout << ch;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[5000001];   int dp[5000000];   int main() {     gets(s);     unsigned long long a = 0, l = 0, r = 0, t = 1;     for (int i = 0; s[i]; i++) {       l = (l * 109) + s[i];       r = r + s[i] * t;       t *= 109;       if (l == r) dp[i + 1] = dp[(i + 1) / 2] + 1;       a += dp[i + 1];     }     cout << a << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long MAX = 1000000000;   long long MOD = 1000000007;   pair<long long, long long> p[100010];   void solve() {     long long n;     cin >> n;     long long d;     cin >> d;     ;     for (long long i = (0); i < (n); i++) {       long long in1;       cin >> in1;       long long in2;       cin >> in2;       ;       p[i] = {in1, in2};     }     sort(p, p + n);     long long j = 0, sum = 0, ans = 0;     for (long long i = (0); i < (n); i++) {       while (p[j].first - p[i].first < d and j < n) {         sum += p[j].second;         j++;       }       ans = max(ans, sum);       sum -= p[i].second;     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long test = 1;     while (test--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[100];     for (int i = 0; i < n; i++) cin >> a[i];     int num[101] = {0};     for (int i = 0; i < n; i++) num[a[i]]++;     int cnt = 0;     for (int i = 1; i <= 100; i++) cnt += num[i] / 2;     cout << cnt / 2 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, poz, p[250];   double t, v[250], m[250], x[250], aux, mint, tempv1, tempv2;   bool fcomp(int a, int b) { return x[a] < x[b]; }   int main() {     scanf( %d , &n);     scanf( %lf , &t);     for (i = 1; i <= n; ++i)       scanf( %lf , &x[i]), scanf( %lf , &v[i]), scanf( %lf , &m[i]), p[i] = i;     sort(p + 1, p + n + 1, fcomp);     do {       mint = 250.0;       for (i = 1; i < n; ++i)         if (v[p[i]] > v[p[i + 1]]) {           aux = -(x[p[i]] - x[p[i + 1]]) / (v[p[i]] - v[p[i + 1]]);           if (aux < mint) mint = aux, poz = i;         }       if (mint >= t) break;       t -= mint;       for (i = 1; i <= n; ++i) x[i] += v[i] * mint;       tempv1 = (m[p[poz]] - m[p[poz + 1]]) * v[p[poz]] +                2 * m[p[poz + 1]] * v[p[poz + 1]];       tempv1 /= m[p[poz]] + m[p[poz + 1]];       tempv2 =           (m[p[poz + 1]] - m[p[poz]]) * v[p[poz + 1]] + 2 * m[p[poz]] * v[p[poz]];       tempv2 /= m[p[poz]] + m[p[poz + 1]];       v[p[poz]] = tempv1;       v[p[poz + 1]] = tempv2;     } while (1);     for (i = 1; i <= n; ++i) x[i] += v[i] * t, printf( %.9lf n , x[i]);   }
#include <bits/stdc++.h>   const long long mod = 1e6 + 3;   using namespace std;   int g = 0;   int vis[10];   int a[100005];   int main() {     int n;     cin >> n;     set<int> s;     for (int i = 1; i <= n; i++) scanf( %d , a + i), s.insert(a[i]);     int p = s.size();     if (p <= 3) {       if (p == 1) {         printf( YES n );       } else if (p == 2) {         int b[3];         g = 0;         for (set<int>::iterator it = s.begin(); it != s.end(); it++)           g++, b[g] = (*it);         for (int i = 1; i <= n; i++) {           if (a[i] == b[1])             vis[1]++;           else             vis[2]++;         }         printf( YES n );       } else if (p == 3) {         int c[5];         g = 0;         for (set<int>::iterator it = s.begin(); it != s.end(); it++)           g++, c[g] = (*it);         sort(c + 1, c + 1 + g);         for (int i = 1; i <= n; i++) {           if (a[i] == c[1])             vis[1]++;           else if (a[i] == c[2])             vis[2]++;           else             vis[3]++;         }         if ((c[1] + c[3]) == 2 * c[2])           printf( YES n );         else           printf( NO n );       }     } else       printf( NO n );   }