func_code_string: #include <bits/stdc++.h>   using namespace std;   uint64_t rnd_data = 0xDEADBEEFDULL;   inline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; }   inline int my_rand() {     rnd_data = rnd_data * 0x5DEECE66DULL + 0xB;     return (rnd_data >> 17) & 0x7FFFFFFF;   }   template <typename T>   void my_random_shuffle(T b, T e) {     for (int i = (1); i <= (int)((int)(e - b) - 1); i++) {       swap(b[i], b[my_rand() % (i + 1)]);     }   }   template <class _T>   inline _T sqr(const _T &x) {     return x * x;   }   template <typename type_t, typename less_t = std::less<type_t>>   inline bool uin(type_t &a, const type_t &b, const less_t &ls = less_t()) {     return ls(b, a) ? a = b, true : false;   }   template <typename type_t, typename less_t = std::less<type_t>>   inline bool uax(type_t &a, const type_t &b, const less_t &ls = less_t()) {     return ls(a, b) ? a = b, true : false;   }   const long double PI = 3.1415926535897932384626433832795L;   const long double EPS = 1e-9;   const int MAXN = 202400;   const size_t LIM = 300;   int n;   long double p[MAXN];   vector<int> a[MAXN];   vector<int> al[MAXN];   vector<int> ah[MAXN];   long double s[MAXN];   long double sh[MAXN];   bool hv[MAXN];   void precalc() {     for (int i = 0; i < (int)(n); i++) {       s[i] = 0.0;       for (int vn : al[i]) {         s[i] += p[vn];       }     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < (int)(n); i++) {       double x;       scanf( %lf , &x);       p[i] = x;     }     for (int i = 0; i < (int)(n - 1); i++) {       int x, y;       scanf( %d%d , &x, &y);       a[x].push_back(y);       a[y].push_back(x);     }     for (int i = 0; i < (int)(n); i++) {       hv[i] = a[i].size() > LIM;       sh[i] = 0.0;     }     for (int i = 0; i < (int)(n); i++) {       for (int vn : a[i]) {         if (hv[vn]) {           ah[i].push_back(vn);         } else {           al[i].push_back(vn);         }       }     }     precalc();     for (int i = 0; i < (int)(n); i++) {       if (hv[i]) {         for (auto vn : a[i]) {           sh[i] += 1.0 - p[vn];         }       }     }     int m;     scanf( %d , &m);     long double spall = 0.0;     for (int i = 0; i < (int)(n); i++) {       spall += p[i];     }     long double sumprev = 0.0;     for (int j = 0; j < (int)(n); j++) {       sumprev += a[j].size() * p[j];       sumprev += (1.0 - p[j]) * s[j];       sumprev += p[j] * sh[j];     }     for (int i = 0; i < (int)(m); i++) {       int x;       double y;       scanf( %d%lf , &x, &y);       spall -= p[x];       sumprev -= a[x].size() * p[x] + (1.0 - p[x]) * s[x] + p[x] * sh[x];       if (!hv[x]) {         for (int vn : a[x]) {           sumprev -= (1.0 - p[vn]) * s[vn];           s[vn] -= p[x];         }       }       for (auto vn : ah[x]) {         sumprev -= p[vn] * sh[vn];         sh[vn] -= 1.0 - p[x];       }       p[x] = y;       for (auto vn : ah[x]) {         sh[vn] += 1.0 - p[x];         sumprev += p[vn] * sh[vn];       }       if (!hv[x]) {         for (int vn : a[x]) {           s[vn] += p[x];           sumprev += (1.0 - p[vn]) * s[vn];         }       }       spall += p[x];       sumprev += a[x].size() * p[x] + (1.0 - p[x]) * s[x] + p[x] * sh[x];       long double ans = 2.0 + sumprev;       ans -= spall * 2.0;       ans /= 2.0;       printf( %0.9f n , (double)ans);     }     return 0;   }   