File size: 70,613 Bytes
d172f64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const double PI = acos(-1.0); n const double EPS = 1e-7; n const long long BIG_PRIME7 = 1000000007; n const long long BIG_PRIME9 = 1000000009; n int gcd(int x, int y) { return y ? gcd(y, x % y) : x; } n char ch =  a ; n int j, n, m, L, i; n int N, C; n int x, y, z, k; n string f, s; n int a[101], b[101]; n int main() { n   cin >> x; n   for (i = 0; i < x; i++) { n     cin >> k; n     if (k & 1) z++; n   } n   if (!(z & 1)) n     cout << (x - z); n   else n     cout << z; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int N = 111111; n int last[3 * N], pre[3 * N], v[3 * N], cnt[3 * N], cur = 0; n inline void add(int a, int b) { n   pre[cur] = last[a]; n   v[cur] = b; n   last[a] = cur; n   cur++; n } n set<int>* who[N]; n inline set<int>* merge(set<int>*& a, set<int>*& b) { n   if (a->size() < b->size()) { n     return merge(b, a); n   } else { n     for (set<int>::iterator it = b->begin(); it != b->end(); it++) { n       if (a->find(-*it) != a->end()) { n         a->erase(-*it); n       } else { n         a->insert(*it); n       } n     } n     b->clear(); n     return a; n   } n } n int used[N]; n void dfs(int u) { n   used[u] = true; n   for (int i = last[u]; i >= 0; i = pre[i]) n     if (!used[v[i]]) { n       dfs(v[i]); n       cnt[i ^ 1] = cnt[i] = who[v[i]]->size(); n       who[u] = merge(who[u], who[v[i]]); n     } n } n set<int>* mem[N]; n int main() { n   memset(last, -1, sizeof(last)); n   int n; n   scanf( %d , &n); n   for (int i = (0); i <= ((n - 1) - 1); i++) { n     int u, v; n     scanf( %d%d , &u, &v); n     u--; n     v--; n     add(u, v); n     add(v, u); n   } n   for (int i = (0); i <= ((n)-1); i++) mem[i] = who[i] = new set<int>(); n   int k; n   scanf( %d , &k); n   for (int i = (1); i <= ((k)); i++) { n     int u, v; n     scanf( %d%d , &u, &v); n     u--; n     v--; n     if (u != v) { n       who[u]->insert(i); n       who[v]->insert(-i); n     } n   } n   dfs(0); n   for (int i = 0; i < cur; i += 2) { n     if (i) printf(   ); n     printf( %d , cnt[i]); n   } n   puts(  ); n   for (int i = (0); i <= ((n)-1); i++) delete (mem[i]); n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int MOD = 1e9 + 7; n const int INF = 1e9 + 7; n const int base = 1e9; n const int MAX = 1e5; n const double EPS = 1e-9; n const double PI = acos(-1.); n int main() { n   ios_base::sync_with_stdio(0); n   cin.tie(0); n   cout.tie(0); n   int n, *a, *res, j = 0; n   cin >> n; n   a = new int[n]; n   res = new int[n]; n   set<int> cnt; n   for (int i = 0; i < n; i++) { n     cin >> a[i]; n   } n   for (int i = n - 1; i >= 0; i--) { n     if (!cnt.count(a[i])) { n       cnt.insert(a[i]); n       res[j] = a[i]; n       j++; n     } n   } n   cout << j << endl; n   for (int i = j - 1; i >= 0; i--) { n     cout << res[i] <<    ; n   } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n string s; n int n, m; n int f[150][150][250][2]; n int main() { n   cin >> s; n   n = s.size(); n   scanf( %d , &m); n   f[0][m][n][1] = true; n   for (int i = 0; i < n; i++) n     for (int j = 0; j <= m; j++) n       for (int k = 0; k <= n * 2; k++) n         for (int l = 0; l < 2; l++) n           if (f[i][j][k][l]) n             if (s[i] ==  T ) { n               f[i + 1][j][k][1 - l] = true; n               if (j != 0 && k - 1 + 2 * l >= 0) n                 f[i + 1][j - 1][k - 1 + 2 * l][l] = true; n             } else { n               if (k - 1 + 2 * l >= 0) f[i + 1][j][k - 1 + 2 * l][l] = true; n               if (j != 0) f[i + 1][j - 1][k][1 - l] = true; n             } n   int i = 0; n   for (int j = 0; j <= m; j++) n     if (j % 2 == 0) n       for (int k = 0; k <= n * 2; k++) n         for (int l = 0; l < 2; l++) n           if (f[n][j][k][l]) { n             if (k - n < 0 && n - k > i) i = n - k; n             if (k - n > 0 && k - n > i) i = k - n; n           } n   printf( %d n , i); n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n struct cell { n   bool up, down, right, left; n   int degree; n   cell() { up = down = left = right = degree = 0; } n   void reset() { up = down = left = right = degree = 0; } n }; n struct qcell { n   int x, y, degree; n   qcell() { n     x = y = -1; n     degree = 0; n   } n   qcell(int xx, int yy, int deg) { n     x = xx; n     y = yy; n     degree = deg; n   } n }; n char pitch[2001][2001]; n cell info[2001][2001]; n int n, m; n int empty_cells = 0; n bool update(int x, int y) { n   int degree = 0; n   if (x >= 0 && x < n && y >= 0 && y < m) { n     degree = info[x][y].degree; n     if (pitch[x][y] !=  . ) n       info[x][y].reset(); n     else { n       info[x][y].up = (x - 1 >= 0 && pitch[x - 1][y] ==  . ); n       info[x][y].down = (x + 1 < n && pitch[x + 1][y] ==  . ); n       info[x][y].left = (y - 1 >= 0 && pitch[x][y - 1] ==  . ); n       info[x][y].right = (y + 1 < m && pitch[x][y + 1] ==  . ); n       info[x][y].degree = (info[x][y].up + info[x][y].down + info[x][y].left + n                            info[x][y].right); n     } n   } n   return degree != info[x][y].degree; n } n void do_push(int x, int y, queue<qcell> &q) { n   if (x >= 0 && x < n && y >= 0 && y < m) n     if (pitch[x][y] ==  . ) n       if (info[x][y].degree == 1) q.push(qcell(x, y, 1)); n } n void occupy(int x, int y, queue<qcell> &q) { n   int xx = x, yy = y; n   char dir =  U ; n   if (info[x][y].down) dir =  D ; n   if (info[x][y].left) dir =  L ; n   if (info[x][y].right) dir =  R ; n   if (dir ==  U ) { n     pitch[x][y] =  v ; n     pitch[x - 1][y] =  ^ ; n     xx = x - 1; n   } else if (dir ==  D ) { n     pitch[x][y] =  ^ ; n     pitch[x + 1][y] =  v ; n     xx = x + 1; n   } else if (dir ==  L ) { n     pitch[x][y] =  > ; n     pitch[x][y - 1] =  < ; n     yy = y - 1; n   } else { n     pitch[x][y] =  < ; n     pitch[x][y + 1] =  > ; n     yy = y + 1; n   } n   update(x, y); n   update(xx, yy); n   if (do_push) { n     if (update(x - 1, y)) do_push(x - 1, y, q); n     if (update(x + 1, y)) do_push(x + 1, y, q); n     if (update(x, y - 1)) do_push(x, y - 1, q); n     if (update(x, y + 1)) do_push(x, y + 1, q); n     if (update(xx - 1, yy)) do_push(xx - 1, yy, q); n     if (update(xx + 1, yy)) do_push(xx + 1, yy, q); n     if (update(xx, yy - 1)) do_push(xx, yy - 1, q); n     if (update(xx, yy + 1)) do_push(xx, yy + 1, q); n   } n   empty_cells -= 2; n } n int main() { n   cin >> n >> m; n   for (int i = 0; i < n; i++) n     for (int j = 0; j < m; j++) { n       cin >> pitch[i][j]; n       if (pitch[i][j] ==  . ) empty_cells++; n     } n   queue<qcell> q; n   for (int i = 0; i < n; i++) n     for (int j = 0; j < m; j++) { n       update(i, j); n       if (info[i][j].degree == 1) q.push(qcell(i, j, info[i][j].degree)); n     } n   bool unique_sol = 1; n   while (1) { n     if (q.empty()) break; n     qcell f = q.front(); n     q.pop(); n     if (info[f.x][f.y].degree == 0) { n       if (pitch[f.x][f.y] ==  . ) { n         unique_sol = false; n         break; n       } n     } else n       occupy(f.x, f.y, q); n   } n   if (unique_sol) n     if (empty_cells != 0) unique_sol = 0; n   if (!unique_sol) n     cout <<  Not unique  << endl; n   else n     for (int i = 0; i < n; i++) { n       for (int j = 0; j < m; j++) cout << pitch[i][j]; n       cout << endl; n     } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int INF = 0x3f3f3f3f; n int main() { n   ios::sync_with_stdio(false); n   int t; n   cin >> t; n   while (t--) { n     string s, t; n     cin >> s >> t; n     vector<int> each[26]; n     int n, m; n     n = s.length(); n     m = t.length(); n     for (int i = 0; i < n; ++i) { n       each[s[i] -  a ].push_back(i); n     } n     int las = INF, res = 0; n     for (int i = 0; i < m; ++i) { n       if (upper_bound(each[t[i] -  a ].begin(), each[t[i] -  a ].end(), las) != n           each[t[i] -  a ].end()) { n         las = n             *upper_bound(each[t[i] -  a ].begin(), each[t[i] -  a ].end(), las); n       } else { n         if (each[t[i] -  a ].empty()) { n           res = -1; n           break; n         } else { n           res++; n           las = each[t[i] -  a ][0]; n         } n       } n     } n     cout << res << endl; n   } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int n, h, a, road_width = 0; n   cin >> n >> h; n   for (int i = 0; i < n; i++) { n     cin >> a; n     if (a > h) n       road_width += 2; n     else n       road_width++; n   } n   cout << road_width <<   n ; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int abs(int a, int b) { n   if (a > b) n     return a - b; n   else n     return b - a; n } n int main() { n   int n, c, i, b, count = 0, index1 = 1, index2 = 1, flag = 0; n   cin >> n >> c; n   char *s; n   s = new char[n + 2]; n   for (i = 1; i <= n; i++) { n     cin >> s[i]; n   } n   int *d = new int[n + 1]; n   for (i = 1; i <= n / 2; i++) { n     b = abs((int)s[i], (int)s[n - i + 1]); n     if (b < 13) n       d[i] = d[n - i + 1] = b; n     else n       d[i] = d[n - i + 1] = 26 - b; n   } n   if (c > n / 2) c = 1 + n - c; n   for (i = 1; i <= n / 2; i++) { n     if (d[i] > 0) { n       index1 = i; n       break; n     } n   } n   for (i = n / 2; i >= 1; i--) { n     if (d[i] > 0) { n       index2 = i; n       flag = 1; n       break; n     } n   } n   if (c <= index1) { n     count = index2 - c; n   } else if (c <= index2) { n     if (c - index1 > index2 - c) n       count = 2 * (index2 - c) + c - index1; n     else n       count = 2 * (c - index1) + index2 - c; n   } else n     count = c - index1; n   for (i = index1; i <= index2; i++) { n     count += d[i]; n   } n   if (flag == 1) n     cout << count; n   else n     cout << 0; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n int any_table[11][11]; n struct DammedPascalNUmber { n   int tb[13][13]; n   DammedPascalNUmber() { n     int i, j; n     for (i = 0; i <= 12; i++) n       for (j = 0; j <= i; j++) { n         int &r = tb[i][j]; n         if (j == 0 || i == 0) n           r = 1; n         else n           r = tb[i - 1][j - 1] + tb[i - 1][j]; n       } n   } n   int count(int n, int m) { return tb[n][m]; } n } pas; n int any(int dig, int amo) { n   if (dig < amo) return 0; n   if (amo < 0) return 0; n   if (dig == 0) return 1; n   int &r = any_table[dig][amo]; n   int i; n   if (r >= 0) return r; n   r = 1; n   for (i = 0; i < amo; i++) r *= 2; n   for (; i < dig; i++) r *= 8; n   r *= pas.count(dig, amo); n   return r; n } n int check(int m, int n) { n   int i, j, t, r = 0; n   for (i = 1; i <= m; i++) { n     char str[15]; n     t = 0; n     sprintf(str,  %d , i); n     for (j = 0; str[j]; j++) n       if (str[j] ==  4  || str[j] ==  7 ) t++; n     if (t == n) r++; n   } n   return r; n } n int a[13]; n int dfs(int party, int quta) { n   int r = 0, i; n   if (party == 6) { n     return 1; n   } n   for (i = quta; i >= 0; i--) n     if (a[i] > 0) { n       int t = a[i]; n       a[i]--; n       r = (1LL * r + 1LL * t * 1LL * dfs(party + 1, quta - i) + n            1LL * 1000000007) % n           1000000007; n       a[i]++; n     } n   return r; n } n void test(int n, int m) { printf( any(%d,%d)=%d n , n, m, any(n, m)); } n void test2(int m, int n) { n   printf( (%d,%d)=%d a[%d]=%d n , m, n, check(m, n), n, a[n]); n } n int main() { n   memset(any_table, -1, sizeof(any_table)); n   int m, s, i, j, k, sn, lucked; n   while (~scanf( %d , &m)) { n     memset(a, 0, sizeof(a)); n     char str[15]; n     sprintf(str,  %d , m); n     for (sn = 0; str[sn]; sn++) n       ; n     for (j = sn; j > 0; j--) { n       a[j] = 0; n       lucked = 0; n       for (i = 0; i < sn; i++) { n         int p = 0, q = 0; n         k = str[i] -  0  - 1; n         for (; k >= 0; k--) n           if (k == 4 || k == 7) n             q++; n           else n             p++; n         if (p) a[j] += p * any(sn - i - 1, j - lucked); n         if (q) a[j] += q * any(sn - i - 1, j - lucked - 1); n         if (str[i] ==  4  || str[i] ==  7 ) { n           lucked++; n         } n         if (i == sn - 1 && lucked == j) a[j]++; n       } n     } n     a[0] = m; n     for (i = 1; i <= sn; i++) a[0] -= a[i]; n     int ans = 0; n     for (i = 1; i <= sn; i++) n       if (a[i]) { n         ans = (1LL * ans + 1LL * a[i] * dfs(0, i - 1) + 1LL * 1000000007) % n               1000000007; n       } n     printf( %d n , ans); n   } n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int maxn = 1e5 + 10; n const double pi = acos(-1); n const int inf = 1 << 30; n const int mod = 1e9 + 9; n struct point { n   int x, flag; n   bool operator<(const point &a) const { return flag > a.flag; } n } s, q; n bool check(long long a[], int n, long long h, int x) { n   priority_queue<int, vector<int>, less<int> > qwe; n   for (int i = 1; i <= min(n, x); i++) qwe.push(a[i]); n   int f = 1, pos; n   while (!qwe.empty()) { n     pos = qwe.top(); n     qwe.pop(); n     if (f) h -= pos; n     f ^= 1; n   } n   if (h >= 0ll) n     return true; n   else n     return false; n } n int main() { n   int n; n   long long h, a[maxn]; n   scanf( %d %lld , &n, &h); n   for (int i = 1; i <= n; i++) scanf( %lld , &a[i]); n   int l = 0, r = n, ans = 0; n   while (l <= r) { n     int mid = (l + r) >> 1; n     if (check(a, n, h, mid)) n       l = mid + 1, ans = mid; n     else n       r = mid - 1; n   } n   printf( %d n , ans); n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n const int64_t mod = 998244353; n int gcd(int64_t a, int64_t b) { n   while (a != 0 && b != 0) { n     if (a >= b) n       a = a % b; n     else n       b = b % a; n   } n   return a + b; n } n struct Fraction { n   int64_t numerator; n   int64_t devider; n   Fraction(int64_t n = 0, int64_t d = 1) : numerator(n), devider(d){}; n   const Fraction& operator+(const Fraction& rv) { n     if (rv.devider == devider) { n       numerator += rv.numerator; n       numerator %= mod; n       return *this; n     } else { n       numerator *= rv.devider; n       numerator %= mod; n       numerator += rv.numerator * devider; n       numerator %= mod; n       devider *= rv.devider; n       devider %= mod; n       return *this; n     } n   } n   const Fraction& operator*(const Fraction& rv) { n     numerator *= rv.numerator; n     devider *= rv.devider; n     numerator %= mod; n     devider %= mod; n     return *this; n   } n }; n struct Item { n   Item(Fraction f, int64_t s, int64_t v) : possibility(f), sum(s), val(v){}; n   Fraction possibility; n   int64_t sum; n   int64_t val; n }; n void extended_euclid(int64_t a, int64_t b, int64_t& x, int64_t& y, int64_t& d) { n   int64_t q, r, x1, x2, y1, y2; n   if (b == 0) { n     d = a, x = 1, y = 0; n     return; n   } n   x2 = 1, x1 = 0, y2 = 0, y1 = 1; n   while (b > 0) { n     q = a / b, r = a - q * b; n     x = x2 - q * x1, y = y2 - q * y1; n     a = b, b = r; n     x2 = x1, x1 = x, y2 = y1, y1 = y; n   } n   d = a, x = x2, y = y2; n } n int main() { n   int64_t n, m; n   std::cin >> n >> m; n   std::vector<std::pair<int64_t, bool>> data; n   int64_t posWeight = 0, negWeight = 0; n   for (int64_t i = 0; i < n; ++i) { n     int64_t a; n     std::cin >> a; n     if (a == 0) n       data.push_back(std::make_pair(-1, false)); n     else n       data.push_back(std::make_pair(-1, true)); n   } n   for (auto& i : data) { n     int64_t w; n     std::cin >> w; n     i.first = w; n     if (i.second) n       posWeight += w; n     else n       negWeight += w; n   } n   std::vector<Item> posVec{ n       Item(Fraction(1, 1), posWeight + negWeight, posWeight)}, n       negVec{Item(Fraction(1, 1), posWeight + negWeight, negWeight)}; n   for (int64_t i = 0; i < m; ++i) { n     std::vector<Item> newPos, newNeg; n     for (auto j : posVec) { n       if (!newPos.size()) { n         Fraction f(j.val, j.sum); n         f = f * j.possibility; n         newPos.push_back(Item(f, j.sum + 1, j.val + 1)); n       } else { n         Fraction f(j.val, j.sum); n         f = f * j.possibility; n         newPos.rbegin()->possibility = newPos.rbegin()->possibility + f; n       } n       if (j.sum > j.val) { n         Fraction f(j.sum - j.val, j.sum); n         f = f * j.possibility; n         newPos.push_back(Item(f, j.sum - 1, j.val)); n       } n     } n     for (auto j : negVec) { n       if (!newNeg.size() && j.val > 1) { n         Fraction f(j.val, j.sum); n         f = f * j.possibility; n         newNeg.push_back(Item(f, j.sum - 1, j.val - 1)); n       } else if (j.val > 1) { n         Fraction f(j.val, j.sum); n         f = f * j.possibility; n         newNeg.rbegin()->possibility = newNeg.rbegin()->possibility + f; n       } n       Fraction f(j.sum - j.val, j.sum); n       f = f * j.possibility; n       newNeg.push_back(Item(f, j.sum + 1, j.val)); n     } n     posVec = newPos; n     negVec = newNeg; n   } n   Fraction pos, neg; n   for (auto i : posVec) pos = pos + Fraction(i.val, 1) * i.possibility; n   for (auto i : negVec) neg = neg + Fraction(i.val, 1) * i.possibility; n   for (auto i : data) { n     Fraction res; n     if (i.second) n       res = Fraction(i.first, posWeight) * pos; n     else n       res = Fraction(i.first, negWeight) * neg; n     int64_t g = gcd(res.numerator, res.devider); n     res.numerator /= g; n     res.devider /= g; n     int64_t d, x, y; n     extended_euclid(res.devider, mod, x, y, d); n     std::cout << (((x % mod + mod) % mod) * res.numerator) % mod << std::endl; n   } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int N = 100005; n int n, m, x, y, f[N], fa[N], ch[N][2]; n char op[5]; n long long a[N], siz[N], ssiz[N], ans[N], sans[N], sqsiz[N], all[N]; n bool isroot(int u) { return ch[fa[u]][0] != u && ch[fa[u]][1] != u; } n int which(int u) { return u == ch[fa[u]][1]; } n void pushup(int o) { n   int lc = ch[o][0], rc = ch[o][1]; n   siz[o] = siz[lc] + siz[rc] + ssiz[o]; n   all[o] = all[lc] + all[rc] + a[o] * ssiz[o]; n   ans[o] = ans[lc] + ans[rc] + sans[o]; n   ans[o] += (ssiz[o] * ssiz[o] - sqsiz[o]) * a[o]; n   ans[o] += 2 * siz[rc] * ssiz[o] * a[o]; n   ans[o] += 2 * all[lc] * (siz[o] - siz[lc]); n } n void rotate(int x) { n   int y = fa[x], z = fa[y], md = which(x); n   if (!isroot(y)) { n     ch[z][which(y)] = x; n   } n   fa[x] = z; n   ch[y][md] = ch[x][!md]; n   fa[ch[y][md]] = y; n   ch[x][!md] = y; n   fa[y] = x; n   pushup(y); n   pushup(x); n } n void splay(int u) { n   while (!isroot(u)) { n     if (!isroot(fa[u])) { n       rotate(which(u) == which(fa[u]) ? fa[u] : u); n     } n     rotate(u); n   } n } n void access(int u) { n   for (int v = 0; u; v = u, u = fa[u]) { n     splay(u); n     int rc = ch[u][1]; n     ssiz[u] += siz[rc]; n     sans[u] += ans[rc]; n     sqsiz[u] += siz[rc] * siz[rc]; n     ch[u][1] = v; n     ssiz[u] -= siz[v]; n     sans[u] -= ans[v]; n     sqsiz[u] -= siz[v] * siz[v]; n     pushup(u); n   } n } n void link(int u, int v) { n   access(v); n   splay(v); n   access(u); n   splay(u); n   fa[u] = v; n   ssiz[v] += siz[u]; n   sans[v] += ans[u]; n   sqsiz[v] += siz[u] * siz[u]; n   pushup(v); n } n void cut(int u, int v) { n   access(u); n   access(v); n   splay(v); n   splay(u); n   fa[u] = 0; n   ssiz[v] -= siz[u]; n   sans[v] -= ans[u]; n   sqsiz[v] -= siz[u] * siz[u]; n   pushup(v); n } n bool check(int u, int v) { n   access(v); n   splay(v); n   splay(u); n   if (isroot(v)) { n     return false; n   } n   return true; n } n int main() { n   scanf( %d , &n); n   for (int i = 2; i <= n; i++) { n     scanf( %d , &f[i]); n   } n   for (int i = 1; i <= n; i++) { n     scanf( %lld , &a[i]); n     ans[i] = all[i] = a[i]; n   } n   for (int i = 1; i <= n; i++) { n     siz[i] = 1; n     ssiz[i] = 1; n   } n   for (int i = 2; i <= n; i++) { n     link(i, f[i]); n   } n   access(1); n   splay(1); n   printf( %.10lf n , 1.0 * ans[1] / n / n); n   scanf( %d , &m); n   while (m--) { n     scanf( %s%d%d , op, &x, &y); n     if (op[0] ==  P ) { n       if (check(x, y)) { n         swap(x, y); n       } n       cut(x, f[x]); n       f[x] = y; n       link(x, f[x]); n       access(1); n       splay(1); n       printf( %.10lf n , 1.0 * ans[1] / n / n); n     } else { n       access(x); n       splay(x); n       a[x] = y; n       pushup(x); n       printf( %.10lf n , 1.0 * ans[x] / n / n); n     } n   } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   ios_base::sync_with_stdio(false); n   cin.tie(NULL); n   long long x, y, n, m, t, q, a, b, count = 0; n   cin >> n >> m; n   long long arr[n]; n   for (x = 0; x < n; x++) cin >> arr[x]; n   a = 0; n   for (x = 0; x < n; x++) { n     a = a + arr[x]; n     cout << a / m <<    ; n     a = a % m; n   } n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int qread() { n   char c; n   int s = 0, f = 1; n   while ((c = getchar()) <  0  || c >  9 ) (c ==  - ) && (f = -1); n   do s = s * 10 + c -  0 ; n   while ((c = getchar()) >=  0  && c <=  9 ); n   return s * f; n } n int n, m; n const int mod = 1e9 + 7; n int a[100011], pos[100011], bin[100011], inv[100011], sum[100011], n     lp = 0, val[100011], vv[100011], svv[100011]; n struct Ques { n   int l, r, id; n   bool operator<(const Ques &b) const { return r < b.r; } n } q[100011]; n int ans[100011]; n int WWW(long long v) { return v > 2000000001 ? 2000000001 : v; } n int main() { n   n = qread(); n   m = qread(); n   bin[0] = inv[0] = 1; n   for (int i = 1; i <= n; i++) n     a[i] = qread(), bin[i] = (bin[i - 1] << 1) % mod, n     inv[i] = 1ll * inv[i - 1] * ((mod + 1) >> 1) % mod, n     sum[i] = ((sum[i - 1] + 1ll * a[i] * bin[i]) % mod + mod) % mod; n   for (int i = 1; i <= m; i++) { n     q[i].l = qread(); n     q[q[i].id = i].r = qread(); n   } n   sort(q + 1, q + 1 + m); n   pos[lp = 1] = 1; n   int j = 1; n   val[1] = a[1] * 2; n   vv[1] = svv[1] = ((a[1] * 2) % mod + mod) % mod; n   while (j <= m && q[j].r == 1) ans[q[j].id] = (a[1] + mod) % mod, j++; n   for (int i = 2; i <= n; i++) { n     if (a[i] <= 0) n       pos[++lp] = i, val[lp] = 2 * a[i], n       vv[lp] = (a[i] * 2ll % mod + mod) % mod, n       svv[lp] = (svv[lp - 1] + vv[lp]) % mod; n     else { n       int cur = n           WWW(0ll + val[lp] + bin[pos[lp] - pos[lp - 1] + 1] * 1ll * a[i]); n       int cvv = (vv[lp] + bin[pos[lp] - pos[lp - 1] + 1] * 1ll * a[i]) % mod; n       lp--; n       while (lp && cur > 0) { n         cur = WWW(0ll + val[lp] + n                   (pos[lp] - pos[lp - 1] > 31 ? 2000000001 n                                               : bin[pos[lp] - pos[lp - 1]]) * n                       1ll * cur); n         cvv = (vv[lp] + bin[pos[lp] - pos[lp - 1]] * 1ll * cvv) % mod; n         lp--; n       } n       val[++lp] = cur; n       pos[lp] = i; n       vv[lp] = cvv; n       svv[lp] = (svv[lp - 1] + vv[lp]) % mod; n     } n     while (j <= m && q[j].r == i) { n       if (q[j].l == q[j].r) { n         ans[q[j].id] = (a[i] + mod) % mod; n         j++; n         continue; n       } n       int l = q[j].l + 1, Ans = (a[q[j].l] + mod) % mod; n       int L = 1, R = lp; n       while (L < R) { n         int mid = (L + R) >> 1; n         if (pos[mid] >= l) n           R = mid; n         else n           L = mid + 1; n       } n       Ans = (Ans + svv[lp] - svv[L]) % mod; n       Ans = (Ans + mod) % mod; n       Ans = (Ans + (sum[pos[L]] - sum[l - 1] + mod) * 1ll * inv[l - 1]) % mod; n       ans[q[j].id] = Ans; n       j++; n     } n   } n   for (int i = 1; i <= m; i++) printf( %d n , ans[i]); n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const long long mod = 1000000007; n const long long inf = 1000000000000000000; n int main() { n   long long t; n   cin >> t; n   while (t--) { n     long long n; n     cin >> n; n     vector<pair<long long, long long> > p(n); n     for (auto& x : p) cin >> x.first >> x.second; n     sort(p.begin(), p.end()); n     pair<long long, long long> now = {0, 0}; n     bool f = 1; n     string ans =   ; n     for (int i = 0; i < n; i++) { n       if (p[i].first >= now.first && p[i].second >= now.second) { n         long long r = p[i].first - now.first, u = p[i].second - now.second; n         while (r--) ans +=  R ; n         while (u--) ans +=  U ; n         now = p[i]; n       } else { n         f = 0; n         break; n       } n     } n     if (f) n       cout <<  YES n  << ans << endl; n     else n       cout <<  NO n ; n   } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int n, m; n   scanf( %d %d , &n, &m); n   for (int i = 0; i < n; i++) { n     if (i % 2 == 0) { n       for (int j = 1; j <= m; j++) { n         printf( # ); n       } n     } else if (i % 4 == 1) { n       for (int j = 1; j < m; j++) { n         printf( . ); n       } n       printf( # ); n     } else if (i % 4 == 3) { n       printf( # ); n       for (int j = 1; j < m; j++) { n         printf( . ); n       } n     } n     printf(  n ); n   } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int N = 2e5 + 65, mod = 1e9 + 7; n vector<int> g[N]; n int w[N]; n int col[N], pr[N]; n int sz[N][2]; n long long ans = 0; n void dfs(int v, int par = -1, int c = 0) { n   pr[v] = par; n   ++sz[v][c]; n   col[v] = c; n   for (int u : g[v]) n     if (u != par) { n       dfs(u, v, c ^ 1); n       sz[v][0] += sz[u][0]; n       sz[v][1] += sz[u][1]; n     } n } n int main() { n   int n; n   scanf( %d , &n); n   for (int i = 0; i < n; ++i) scanf( %d , w + i); n   for (int i = 1; i < n; ++i) { n     int u, v; n     scanf( %d %d , &u, &v); n     --u, --v; n     g[u].push_back(v); n     g[v].push_back(u); n   } n   ans = 0; n   dfs(0); n   for (int v = 0; v < n; ++v) { n     vector<pair<int, int> > vs; n     for (int u : g[v]) n       if (u != pr[v]) vs.emplace_back(sz[u][0], sz[u][1]); n     if (pr[v] != -1) vs.emplace_back(sz[0][0] - sz[v][0], sz[0][1] - sz[v][1]); n     long long cnt = n; n     if (col[v]) { n       for (pair<int, int> e : vs) { n         cnt = (cnt + 1LL * e.second * (n - e.first - e.second)) % mod; n         cnt = (cnt - 1LL * e.first * (n - e.first - e.second)) % mod; n       } n     } else { n       for (pair<int, int> e : vs) { n         cnt = (cnt - 1LL * e.second * (n - e.first - e.second)) % mod; n         cnt = (cnt + 1LL * e.first * (n - e.first - e.second)) % mod; n       } n     } n     cnt %= mod; n     if (cnt < 0) cnt += mod; n     ans = (ans + cnt * w[v]) % mod; n   } n   ans %= mod; n   if (ans < 0) ans += mod; n   cout << ans << endl; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int inf = 1 << 28; n const double INF = 1e12, EPS = 1e-9; n int n, m, k; n bool star[600][600]; n int sum[600][600]; n char in[600][600]; n void run() { n   cin >> n >> m >> k; n   for (int i = 0; i < n; i++) cin >> in[i]; n   for (int i = 0; i < n; i++) n     for (int j = 0; j < m; j++) { n       if (in[i][j] ==  1  && in[i + 1][j] ==  1  && in[i + 2][j] ==  1  && j && n           in[i + 1][j - 1] ==  1  && in[i + 1][j + 1] ==  1 ) n         star[i][j] = 1; n     } n   long long ans = 0; n   for (int i = 0; i < n; i++) n     for (int j = 0; j < m; j++) n       sum[i + 1][j + 1] = n           star[i][j] + sum[i][j + 1] + sum[i + 1][j] - sum[i][j]; n   for (int a = 0; a < n; a++) n     for (int b = a + 3; b <= n; b++) { n       int l = 0, r = 2, cnt = 0; n       for (; l < m; l++) { n         while (r <= m && cnt < k) { n           r++; n           cnt += sum[b - 2][r - 1] - sum[a][r - 1] - n                  (sum[b - 2][r - 2] - sum[a][r - 2]); n         } n         if (cnt < k || r > m) break; n         ans += m - r + 1; n         cnt -= sum[b - 2][l + 2] - sum[a][l + 2] - n                (sum[b - 2][l + 1] - sum[a][l + 1]); n       } n     } n   cout << ans << endl; n } n int main() { run(); } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n void readi(int &x) { n   int v = 0, f = 1; n   char c = getchar(); n   while (!isdigit(c) && c !=  - ) c = getchar(); n   if (c ==  - ) n     f = -1; n   else n     v = v * 10 + c -  0 ; n   while (isdigit(c = getchar())) v = v * 10 + c -  0 ; n   x = v * f; n } n void readll(long long &x) { n   long long v = 0ll, f = 1ll; n   char c = getchar(); n   while (!isdigit(c) && c !=  - ) c = getchar(); n   if (c ==  - ) n     f = -1; n   else n     v = v * 10 + c -  0 ; n   while (isdigit(c = getchar())) v = v * 10 + c -  0 ; n   x = v * f; n } n void readc(char &x) { n   char c; n   while ((c = getchar()) ==    ) n     ; n   x = c; n } n void writes(string s) { puts(s.c_str()); } n void writeln() { writes(  ); } n void writei(int x) { n   if (!x) putchar( 0 ); n   char a[25]; n   int top = 0; n   while (x) { n     a[++top] = (x % 10) +  0 ; n     x /= 10; n   } n   while (top) { n     putchar(a[top]); n     top--; n   } n } n void writell(long long x) { n   if (!x) putchar( 0 ); n   char a[25]; n   int top = 0; n   while (x) { n     a[++top] = (x % 10) +  0 ; n     x /= 10; n   } n   while (top) { n     putchar(a[top]); n     top--; n   } n } n inline long long inc(int &x) { return ++x; } n inline long long inc(long long &x) { return ++x; } n inline long long inc(int &x, long long y) { return x += y; } n inline long long inc(long long &x, long long y) { return x += y; } n inline double inc(double &x, double y) { return x += y; } n inline long long dec(int &x) { return --x; } n inline long long dec(long long &x) { return --x; } n inline long long dec(int &x, long long y) { return x -= y; } n inline long long dec(long long &x, long long y) { return x -= y; } n inline double dec(double &x, double y) { return x -= y; } n inline long long mul(int &x) { return x = ((long long)x) * x; } n inline long long mul(long long &x) { return x = x * x; } n inline long long mul(int &x, long long y) { return x *= y; } n inline long long mul(long long &x, long long y) { return x *= y; } n inline double mul(double &x, double y) { return x *= y; } n inline long long divi(const int &x) { n   long long ans, l, r, mid; n   ans = 0; n   l = 0; n   r = 0x3fffffff; n   while (l < r) { n     mid = (l + r) / 2; n     if (mid * mid <= x) { n       ans = mid; n       l = mid + 1; n     } else n       r = mid; n   } n   return ans; n } n inline long long divi(const long long &x) { n   long long ans, l, r, mid; n   ans = 0; n   l = 0; n   r = 0x3fffffff; n   while (l < r) { n     mid = (l + r) / 2; n     if (mid * mid <= x) { n       ans = mid; n       l = mid + 1; n     } else n       r = mid; n   } n   return ans; n } n inline long long divi(int &x, long long y) { return x /= y; } n inline long long divi(long long &x, long long y) { return x /= y; } n inline double divi(double &x, double y) { return x /= y; } n inline long long mod(int &x, long long y) { return x %= y; } n inline long long mod(long long &x, long long y) { return x %= y; } n int n, m, i, j, ct[100005], x, y, vis[100005]; n vector<int> e[100005]; n struct vt { n   int id, deg; n } a[100005]; n bool cmp(vt x, vt y) { return x.deg > y.deg; } n bool dfs(int x) { n   if (vis[x] == 1) return 1; n   if (vis[x] == 2) return 0; n   vis[x] = 1; n   for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++) n     if (dfs(*it)) return 1; n   vis[x] = 2; n   return 0; n } n bool check(int x) { n   memset(vis, 0, sizeof(vis)); n   vis[x] = 2; n   int i; n   for (i = 1; i <= n; i++) { n     if (!vis[i] && dfs(i)) { n       for (i = 1; i <= n; i++) n         if (vis[i] != 1) ct[i] = 1; n       return 0; n     } n   } n   return 1; n } n int main() { n   double st = clock(); n   ios_base::sync_with_stdio(false); n   ; n   cin >> n >> m; n   if ((1) <= ((m))) n     for (((i)) = (1); ((i)) <= ((m)); ((i))++) { n       cin >> x >> y; n       e[x].push_back(y); n     } n   if ((1) <= ((n))) n     for (((i)) = (1); ((i)) <= ((n)); ((i))++) { n       a[i].id = i; n       a[i].deg = e[i].size(); n     } n   stable_sort(a + 1, a + n + 1, cmp); n   if ((1) <= ((n))) n     for (((i)) = (1); ((i)) <= ((n)); ((i))++) { n       if ((clock() - st) / CLOCKS_PER_SEC > 0.9) break; n       x = a[i].id; n       if (ct[x] || !check(x)) continue; n       cout << x; n       return 0; n     } n   cout <<  -1 ; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const long long mxn = 1003, inf = 1e18 + 18; n int n, m, lcp[mxn][mxn], rk[mxn][mxn], ri[mxn], tot; n long long k, f[mxn]; n string s; n struct S { n   int l, r; n } a[mxn * mxn]; n inline bool cmp(S a, S b) { n   int p = a.l + lcp[a.l][b.l], q = b.l + lcp[a.l][b.l]; n   if (p > a.r or q > b.r) return a.r - a.l < b.r - b.l; n   return s[p] < s[q]; n } n inline long long add(long long a, long long b) { n   return a + b > inf ? inf : a + b; n } n inline long long calc(int md) { n   for (int i = 1; i <= n; ++i) { n     ri[i] = i; n     for (; ri[i] <= n and rk[i][ri[i]] < md;) ++ri[i]; n   } n   memset(f, 0, sizeof(f)), f[n + 1] = 1; n   for (int i = 1; i <= m; ++i) { n     for (int j = n; j; --j) f[j] = add(f[j], f[j + 1]); n     for (int j = 1; j <= n; ++j) f[j] = ri[j] <= n ? f[ri[j] + 1] : 0; n     f[n + 1] = 0; n   } n   return f[1]; n } n int main() { n   cin >> n >> m >> k >> s, s =     + s; n   for (int i = n; i; --i) n     for (int j = n; j; --j) n       if (s[i] == s[j]) lcp[i][j] = lcp[i + 1][j + 1] + 1; n   for (int i = 1; i <= n; ++i) n     for (int j = i; j <= n; ++j) a[++tot] = (S){i, j}; n   sort(a + 1, a + tot + 1, cmp); n   for (int i = 1; i <= tot; ++i) rk[a[i].l][a[i].r] = i; n   int l = 1, r = tot, md; n   for (; l <= r;) { n     md = l + r >> 1; n     if (calc(md) >= k) n       l = md + 1; n     else n       r = md - 1; n   } n   for (int i = a[r].l; i <= a[r].r; ++i) putchar(s[i]); n } n "}
{"func_code_string": "#include <algorithm> n #include <cmath> n #include <cstdio> n #include <cstring> n #include <iostream> n #include <map> n #include <set> n #include <unordered_map> n  n using namespace std; n typedef long long LL; n const int N = 3e5 + 10, mod = 998244353; n string g[N]; n int dp[N]; n  n int fastPow(int a, int k) { n     int res = 1; n     while (k) { n         if (k & 1) res = (LL)res * a % mod; n         k >>= 1; n         a = (LL)a * a % mod; n     } n     return res; n } n  n int main() { n     ios::sync_with_stdio(false); n     int n, m, sum = 0, res = 0; n     n = 300000; n     for (int i = 2; i <= n; i++) { n         if (i & 1) sum = (sum + 1) % mod; n         dp[i] = ((LL)dp[i - 1] * 2 % mod + sum + !(i & 1)) % mod; n         sum = (sum << 1) % mod; n     } n     sum = 0; n     cin >> n >> m; n     for (int i = 0; i < n; i++) { n         cin >> g[i]; n         for (auto c : g[i]) n             if (c ==  o ) sum++; n     } n     for (int i = 0; i < n; i++) { n         int cnt = 0, len = 0; n         while (cnt <= m) { n             if (cnt == m || g[i][cnt] ==  * ) { n                 if (len) { n                     res = (res + (LL)dp[len] * n                                      fastPow(2, sum - len) % mod) % n                           mod; n                     len = 0; n                 } n             } else { n                 len++; n             } n             cnt++; n         } n     } n     for (int i = 0; i < m; i++) { n         int cnt = 0, len = 0; n         while (cnt <= n) { n             if (cnt == n || g[cnt][i] ==  * ) { n                 if (len) { n                     res = (res + (LL)dp[len] * n                                      fastPow(2, sum - len) % mod) % n                           mod; n                     len = 0; n                 } n             } else { n                 len++; n             } n             cnt++; n         } n     } n     cout << res << endl; n     return 0; n }"}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int maxn = 100 + 10; n char s[maxn]; n int f(char ch) { n   if (ch ==  A ) return 1; n   if (ch ==  B ) return 2; n   if (ch ==  C ) return 4; n   return 0; n } n int main() { n   scanf( %s , s + 1); n   int l = strlen(s + 1); n   for (int i = 1; i <= l - 2; ++i) { n     int t = f(s[i]) | f(s[i + 1]) | f(s[i + 2]); n     if (t == 7) { n       cout <<  Yes  << endl; n       return 0; n     } n   } n   cout <<  No ; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n vector<int> tree[500001]; n bool intree[500001]; n vector<int> tmp(0); n bool isleaf(int node) { n   if (tree[node].size() == 1 && intree[(tree[node])[0]]) return true; n   return false; n } n void DFS(int lvl, int node) { n   intree[node] = true; n   if (isleaf(node)) { n     tmp.push_back(lvl); n   } n   for (int i = 0; i < tree[node].size(); i++) { n     if (!intree[(tree[node])[i]]) { n       DFS(lvl + 1, (tree[node])[i]); n     } n   } n } n int main() { n   ios_base::sync_with_stdio(false); n   int N; n   cin >> N; n   for (int i = 1; i <= N; i++) intree[i] = false; n   int x, y; n   for (int i = 0; i < N - 1; i++) { n     cin >> x >> y; n     tree[x].push_back(y); n     tree[y].push_back(x); n   } n   intree[1] = true; n   int ans = 0, c; n   for (int i = 0; i < (tree[1]).size(); i++) { n     tmp.clear(); n     DFS(0, (tree[1])[i]); n     sort(tmp.begin(), tmp.end()); n     c = tmp.size(); n     for (int j = 0; j < c; j++) { n       ans = max(ans, tmp[j] + c - j); n     } n   } n   cout << ans << endl; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   ios_base::sync_with_stdio(false); n   int n; n   cin >> n; n   vector<string> v(n); n   for (int i = 0; i < n; i++) cin >> v[i]; n   for (int i = 1; i < n - 1; i++) { n     for (int j = 1; j < n - 1; j++) { n       if (v[i][j] ==  #  and v[i + 1][j] ==  #  and v[i][j + 1] ==  #  and n           v[i][j - 1] ==  #  and v[i - 1][j] ==  # ) { n         v[i][j] =  a ; n         v[i + 1][j] =  a ; n         v[i][j + 1] =  a ; n         v[i][j - 1] =  a ; n         v[i - 1][j] =  a ; n       } n     } n   } n   int c = 0; n   for (int i = 0; i < n; i++) n     for (int j = 0; j < n; j++) n       if (v[i][j] ==  # ) { n         c = 1; n         break; n       } n   if (c) n     cout <<  NO  << endl; n   else n     cout <<  YES  << endl; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const long long N = 1e5 + 5; n int32_t main() { n   ios::sync_with_stdio(0); n   cin.tie(0); n   cout.tie(0); n   ; n   long long n; n   cin >> n; n   long long con = -1; n   long long a[n + 5]; n   for (long long i = 1; i <= n; i++) { n     cin >> a[i]; n   } n   long long i = 1; n   for (i = 1; i < n; i++) { n     if (a[i + 1] == a[i]) { n       con = i; n       break; n     } n   } n   if (con == -1) { n     for (con = 1; con < n; con++) { n       if (a[con] > a[con + 1]) { n         break; n       } n     } n   } n   for (i = 1; i < con; i++) { n     if (a[i + 1] < a[i]) { n       cout <<  NO  n            <<   n ; n       return 0; n     } n   } n   while (a[con] == a[con + 1]) { n     con++; n   } n   for (i = con; i < n; i++) { n     if (a[i + 1] >= a[i]) { n       cout <<  NO  n            <<   n ; n       return 0; n     } n   } n   cout <<  YES  n        <<   n ; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using ll = long long; n using namespace std; n int main() { n   ios::sync_with_stdio(false); n   int N, K; n   cin >> N >> K; n   ll total = N + 1; n   total += N; n   total += min(2 * (K - 1) + (N - K), 2 * (N - K) + K - 1); n   cout << total <<   n ; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int k, n[20], a[20][5010], g[32768], f[32768], hsh[301781], ps[301781], n     ans1[20], ans2[20], vis[20], TMS; n pair<int, int> md[32768]; n long long sm[20]; n int get(int x) { n   int y = (x + 1000000001) % 301781; n   while (hsh[y] && hsh[y] ^ x + 1000000001) y = (y + 1) % 301781; n   return y; n } n void dg(int x, int s1, int s2) { n   if (x == k) { n     f[s2 + s1] |= f[s1] * g[s2]; n     return; n   } n   dg(x + 1, s1, s2); n   dg(x + 1, s1, s2 + (1 << x)); n   dg(x + 1, s1 + (1 << x), s2); n } n int main() { n   scanf( %d , &k); n   long long S = 0; n   for (int i = 0; i < k; ++i) { n     scanf( %d , n + i); n     for (int j = 0; j < n[i]; ++j) { n       int x; n       scanf( %d , &x); n       a[i][j] = x; n       sm[i] += x; n       S += x; n       int w = get(x); n       ps[w] = i; n       hsh[w] = x + 1000000001; n     } n   } n   if (S % k != 0) { n     printf( No ); n     return 0; n   } n   S /= k; n   for (int i = 0; i < k; ++i) n     for (int j = 0; j < n[i]; ++j) { n       int st = 1 << i, nw = i; n       long long c = S - (sm[i] - a[i][j]); n       int P = 1; n       ++TMS; n       for (;;) { n         vis[nw] = TMS; n         if (abs(c) > 1000000000) { n           P = 0; n           break; n         } n         int w = get(c); n         if (!hsh[w]) { n           P = 0; n           break; n         } n         st |= 1 << ps[w]; n         if (ps[w] == i) { n           P = c == a[i][j]; n           break; n         } n         c = S - (sm[ps[w]] - c); n         nw = ps[w]; n         if (vis[nw] == TMS) { n           P = 0; n           break; n         } n       } n       if (P) { n         md[st] = make_pair(i, j); n         g[st] = 1; n       } n     } n   f[0] = 1; n   dg(0, 0, 0); n   if (f[(1 << k) - 1]) { n     printf( Yes n ); n     int ST = (1 << k) - 1; n     while (ST) { n       for (int _ = ST; _; _ = (_ - 1) & ST) n         if (g[_] * f[ST - _]) { n           int i = md[_].first, j = md[_].second, nw = i; n           long long c = S - (sm[i] - a[i][j]), ls = a[i][j]; n           for (;;) { n             int w = get(c); n             ans1[ps[w]] = c; n             ans2[ps[w]] = nw; n             if (ps[w] == i) break; n             ls = c; n             nw = ps[w]; n             c = S - (sm[ps[w]] - c); n           } n           ST -= _; n           break; n         } n     } n     for (int i = 0; i < k; ++i) printf( %d %d n , ans1[i], ans2[i] + 1); n   } else { n     printf( No ); n   } n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   ios_base::sync_with_stdio(false); n   cin.tie(NULL); n   long long int test = 1; n   for (; test > 0; --test) { n     long long int n, a, b, c, d, c1 = 1, c2, c3, c4; n     cin >> n >> a >> b >> c >> d; n     c2 = c1 + b - c; n     c3 = c2 + a - d; n     c4 = c3 + c - b; n     long long int m = 1 - min(min(c1, c2), min(c3, c4)), n                   m1 = max(max(c1, c2), max(c3, c4)); n     if (m1 + abs(m) > n) n       cout << 0 << endl; n     else n       cout << (n - (m1 + abs(m)) + 1) * n << endl; n   } n   return (0); n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const long long int MAX = 1000000007; n const long long int MAXN = 100010; n int main() { n   ios_base::sync_with_stdio(false); n   cin.tie(NULL); n   cout.tie(NULL); n   long long int t; n   cin >> t; n   while (t--) { n     long long int n, k; n     cin >> n >> k; n     if (n % 2 == 0 && k % 2 == 1) n       cout <<  NO  << endl; n     else if (n % 2 == 1 && k % 2 == 0) n       cout <<  NO  << endl; n     else { n       if (k * k <= n) n         cout <<  YES  << endl; n       else n         cout <<  NO  << endl; n     } n   } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int d[250003]; n int main() { n   int i, j, k, n, m, t, a[501][501], b[501][501]; n   cin >> t; n   while (t--) { n     cin >> n >> m; n     for (i = 0; i < n; i++) n       for (j = 0; j < m; j++) cin >> a[i][j], d[a[i][j]] = i; n     for (i = 0; i < m; i++) n       for (j = 0; j < n; j++) cin >> b[i][j]; n     for (i = 0; i < n; i++) { n       for (j = 0; j < m; j++) { n         cout << a[d[b[0][i]]][j] <<    ; n       } n       cout << endl; n     } n   } n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n vector<pair<long long int, pair<long long int, long long int> > > P; n int level[1007]; n double ans = 0; n bool contains(pair<long long int, pair<long long int, long long int> > A, n               pair<long long int, pair<long long int, long long int> > B) { n   return (A.second.first - B.second.first) * (A.second.first - B.second.first) + n              (A.second.second - B.second.second) * n                  (A.second.second - B.second.second) < n          (A.first) * (A.first); n } n int main() { n   long long int i, j, k, l, m, n, x, y, z, a, b, r; n   scanf( %lld , &n); n   for (i = 0; i < n; i++) { n     scanf( %lld , &x); n     scanf( %lld , &y); n     scanf( %lld , &r); n     P.push_back(make_pair(r, make_pair(x, y))); n   } n   sort(P.begin(), P.end()); n   for (i = n - 1; i >= 0; i--) { n     for (j = n - 1; j > i; j--) { n       if (contains(P[j], P[i])) { n         level[i] = max(level[i], level[j] + 1); n       } n     } n     if (level[i] == 0) level[i] = 1; n   } n   for (i = 0; i < n; i++) { n     if (level[i] <= 2) n       ans += (P[i].first * P[i].first); n     else { n       if (level[i] % 2 == 1) n         ans -= (P[i].first * P[i].first); n       else n         ans += (P[i].first * P[i].first); n     } n   } n   printf( %.10lf n , ans * 3.14159265358979); n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n inline long long power(long long a, long long b) { n   long long x = 1; n   a = a % 1000000007ULL; n   while (b) { n     if (b & 1) x = (x * a) % 1000000007ULL; n     a = (a * a) % 1000000007ULL; n     b >>= 1; n   } n   return x; n } n inline long long inv(long long a) { return power(a, 1000000007ULL - 2); } n long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; } n const int N = 2e5 + 5; n vector<int> adj[N]; n int n, dis[N]; n bool vis[N]; n int cnt[N], p[N]; n int tdis[N]; n vector<int> d[N]; n void dfs(int u, int dd, int par) { n   vis[u] = true; n   if (dd < 3) n     tdis[u] = dd; n   else n     tdis[u] = N; n   dis[u] = dd; n   d[dd].push_back(u); n   p[u] = par; n   for (auto v : adj[u]) { n     if (!vis[v]) dfs(v, dd + 1, u); n   } n } n int main() { n   ios_base::sync_with_stdio(false); n   cin >> n; n   int u, v; n   for (int i = 1; i < n; i++) { n     cin >> u >> v; n     adj[u].push_back(v); n     adj[v].push_back(u); n   } n   dfs(1, 0, 0); n   int maxx = 0; n   for (int i = 0; i < n; i++) { n     if (d[i].size() == 0) break; n     maxx = i; n   } n   int ans = 0; n   for (int i = maxx; i > 1; i--) { n     for (auto v : d[i]) { n       if (dis[v] < 2 || tdis[v] == 2) continue; n       ans++; n       tdis[p[v]] = 2; n       for (auto j : adj[p[v]]) tdis[j] = 2; n     } n   } n   cout << ans << endl; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int mod = 998244353; n long long a[300001]; n long long n, m, k; n int b[300001]; n void solve() { n   cin >> n; n   for (int i = 0; i < n; ++i) { n     int x; n     cin >> x; n     a[x]++; n     b[a[x]] += a[x]; n     k = (b[a[x]] >= i && b[a[x]] != n) ? b[a[x]] : k; n   } n   cout << k + 1; n } n int main() { n   ios_base::sync_with_stdio(false); n   cin.tie(NULL); n   cout.tie(NULL); n   int t = 1; n   while (t--) { n     solve(); n   } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   char str[2020]; n   long l; n   cin >> l; n   cin >> str; n   int i, j, hs = 0, ts = 0; n   for (i = 0; i < l; i++) { n     if (str[i] ==  H ) n       hs++; n     else n       ts++; n     str[l + i] = str[i]; n   } n   int res = 1000000000; n   int t; n   for (i = 0; i < l; i++) { n     t = 0; n     for (j = 0; j < hs; j++) { n       if (str[i + j] ==  T ) t++; n     } n     if (t < res) res = t; n     t = 0; n     for (j = 0; j < ts; j++) { n       if (str[i + j] ==  H ) t++; n     } n     if (t < res) res = t; n   } n   cout << res; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n long long a[1000000 + 100], f2, x1, x2, b[1000000 + 100], razl, sol, pok1, pok2; n double f1; n int main() { n   for (int i = 1; i <= 4; i++) cin >> a[i]; n   f1 = sqrt(1 + 8 * a[1]) * 1.0; n   f2 = sqrt(1 + 8 * a[1]); n   if (f1 != f2) { n     printf( Impossible n ); n     return 0; n   } n   f1 = sqrt(1 + 8 * a[4]) * 1.0; n   f2 = sqrt(1 + 8 * a[4]); n   if (f1 != f2) { n     printf( Impossible n ); n     return 0; n   } n   x1 = 1 + sqrt(1 + 8 * a[1]); n   x1 /= 2; n   x2 = 1 + sqrt(1 + 8 * a[4]); n   x2 /= 2; n   if (a[1] == 0 && a[2] == 0 && a[3] == 0) x1 = 0; n   if (a[4] == 0 && a[2] == 0 && a[3] == 0) x2 = 0; n   if (a[2] + a[3] != x1 * x2) { n     printf( Impossible n ); n     return 0; n   } n   for (int i = 1; i <= x1; i++) b[i] = 0; n   for (int i = x1 + 1; i <= x1 + x2; i++) b[i] = 1; n   sol = x1 * x2; n   pok1 = x1; n   pok2 = x1 + x2; n   while (sol != a[2]) { n     if (sol - x2 > a[2]) n       swap(b[pok1], b[pok2]), pok1--, pok2--, sol -= x2; n     else { n       swap(b[pok1], b[pok1 + sol - a[2]]); n       break; n     } n   } n   if (x1 + x2 == 0) printf( 0 ); n   for (int i = 1; i <= x1 + x2; i++) cout << b[i]; n   printf(  n ); n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n void mohammed() { n   ios::sync_with_stdio(0); n   ios_base::sync_with_stdio(0); n   cin.tie(0), cout.tie(0); n } n int main() { n   mohammed(); n   int n, x, y; n   cin >> n; n   map<int, int> mp; n   map<int, int>::iterator it; n   for (int i = 0; i < n; i++) { n     cin >> x >> y; n     mp[x]++; n     mp[y + 1]--; n   } n   x = 0; n   for (it = mp.begin(); it != mp.end(); it++) { n     it->second += x; n     if (it->second > 2) { n       cout <<  NO ; n       return 0; n     } n     x = it->second; n   } n   cout <<  YES ; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const double pi = acos(-1.0); n template <typename T, typename U> n inline void amin(T &x, U y) { n   if (y < x) x = y; n } n template <typename T, typename U> n inline void amax(T &x, U y) { n   if (x < y) x = y; n } n template <class L, class R> n ostream &operator<<(ostream &os, pair<L, R> P) { n   return os <<  (  << P.first <<  ,  << P.second <<  ) n ; n } n template <class T> n ostream &operator<<(ostream &os, set<T> V) { n   os <<  [ ; n   for (auto vv : V) os << vv <<  ,  ; n   return os <<   b b] n ; n } n template <class T> n ostream &operator<<(ostream &os, vector<T> V) { n   os <<  [ ; n   for (auto vv : V) os << vv <<  ,  ; n   return os <<   b b] n ; n } n template <class K, class X> n ostream &operator<<(ostream &os, map<K, X> V) { n   os <<  [ ; n   for (auto vv : V) os << vv <<  ,  ; n   return os <<   b b] n ; n } n long int ceildiv(long int n, long int f) { n   if (n % f) { n     return n / f + 1; n   } else n     return n / f; n } n string checkTicket(vector<long> first, vector<long> second) { n   int n = first.size(); n   if (first[0] < second[0]) { n     for (int i = 0; i < n; i += 1) { n       if (first[i] >= second[i]) { n         return  NO n ; n       } n     } n   } else if (first[0] > second[0]) { n     for (int i = 0; i < n; i += 1) { n       if (first[i] <= second[i]) { n         return  NO n ; n       } n     } n   } else { n     return  NO n ; n   } n   return  YES n ; n } n int main() { n   long int n; n   cin >> n; n   string s; n   cin >> s; n   vector<long> first, second; n   for (int i = 0; i < n; i++) { n     first.push_back(s[i] -  0 ); n   } n   for (int i = n; i < 2 * n; i++) { n     second.push_back(s[i] -  0 ); n   } n   sort(first.begin(), first.end()); n   sort(second.begin(), second.end()); n   cerr << first << second; n   cout << checkTicket(first, second); n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int N = 200005; n int t[N]; n int p[N]; n int p2[N]; n int main() { n   std::ios::sync_with_stdio(0); n   cin.tie(0); n   cout.tie(0); n   int n; n   long long sum = 0; n   cin >> n; n   for (int i = 0; i <= n; i++) { n     cin >> t[i]; n     sum += t[i]; n   } n   bool amb = 0; n   for (int i = 1; i <= n; i++) { n     if (t[i] > 1 && t[i - 1] > 1) amb = 1; n   } n   if (!amb) { n     cout <<  perfect ; n     return 0; n   } n   cout <<  ambiguous  <<   n ; n   long long par = 1, k = 2; n   p[1] = 0; n   p2[1] = 0; n   for (int i = 1; i <= n; i++) { n     long long temp = k; n     for (int j = 0; j < t[i]; j++) { n       p[k] = par; n       p2[k] = par; n       k++; n     } n     par = temp; n   } n   k = 2; n   for (int i = 1; i <= n; i++) { n     if (t[i] > 1 && t[i - 1] > 1) { n       p2[k]++; n       break; n     } else n       k += t[i]; n   } n   for (int i = 1; i <= sum; i++) cout << p[i] <<    ; n   cout <<   n ; n   for (int i = 1; i <= sum; i++) cout << p2[i] <<    ; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int n; n   cin >> n; n   long long sum1 = 0, sum2 = 0; n   long temp; n   for (int i = 0; i < n; i++) { n     cin >> temp; n     sum1 += temp; n   } n   for (int i = 0; i < n - 1; i++) { n     cin >> temp; n     sum2 += temp; n   } n   cout << sum1 - sum2 <<   n ; n   for (int i = 0; i < n - 2; i++) { n     cin >> temp; n     sum2 -= temp; n   } n   cout << sum2; n   return (0); n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int N = (1 << 20) + 15; n long long dp[N]; n pair<int, int> id[100]; n int bit[100], c[100], st[N]; n int main() { n   int u, a, mi, n, m, i, j, b, x, p = 0, idd; n   long long k, temp; n   long long ret = 4e18; n   scanf( %d%d%d , &n, &m, &b); n   for (i = 0; i < n; ++i) { n     scanf( %d%d%d , &c[i], &id[i].first, &mi); n     a = 0; n     for (j = 0; j < mi; ++j) scanf( %d , &u), a |= 1 << (u - 1); n     bit[i] = a; n     id[i].second = i; n   } n   memset(dp, -1, sizeof(dp)); n   sort(id, id + n); n   dp[0] = 0; n   ++p; n   for (i = 0; i < n; ++i) { n     k = id[i].first, idd = id[i].second; n     if (dp[bit[idd]] != -1 && dp[bit[idd]] <= c[idd]) continue; n     x = p; n     for (j = 0; j < p; ++j) { n       u = st[j] | bit[idd]; n       if (dp[u] == -1 && u != (1 << m) - 1) st[x++] = u; n       if (dp[u] == -1 || dp[u] > dp[st[j]] + c[idd]) dp[u] = dp[st[j]] + c[idd]; n     } n     if (dp[(1 << m) - 1] != -1) ret = min(ret, k * b + dp[(1 << m) - 1]); n     p = x; n   } n   if (ret == 4e18) ret = -1; n   cout << ret << endl; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int cnt[1000100], a[1000100]; n int main() { n   int n, k, ans; n   scanf( %d , &n); n   scanf( %d , &k); n   for (long long i = 0; i < n; i++) scanf( %d , &a[i]); n   int l = 0, r = 0, al, ar; n   set<int> x; n   cnt[a[0]]++; n   x.insert(a[0]); n   ans = 1; n   al = 0, ar = 0; n   while (l < n && r < n) { n     r++; n     x.insert(a[r]); n     cnt[a[r]]++; n     while ((long long)x.size() > k && l <= r) { n       cnt[a[l]]--; n       if (cnt[a[l]] == 0) x.erase(a[l]); n       l++; n     } n     r = max(l, r); n     if (r >= n) break; n     if (r - l + 1 > ans) { n       al = l; n       ar = r; n       ans = r - l + 1; n     } n   } n   printf( %d %d n , al + 1, ar + 1); n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int M = 105; n int l[M], r[M], t[M], c[M], res[M], p[M]; n int main() { n   int n, m; n   cin >> n >> m; n   for (int i = 0; i < m; ++i) { n     cin >> l[i] >> r[i] >> t[i] >> c[i]; n   } n   for (int i = 1; i <= n; ++i) p[i] = INT_MAX; n   for (int i = 0; i < m; ++i) n     for (int j = l[i]; j <= r[i]; ++j) n       if (t[i] < p[j]) p[j] = t[i], res[j] = i; n   int sum = 0; n   for (int i = 1; i <= n; ++i) n     if (p[i] != INT_MAX) sum += c[res[i]]; n   cout << sum << endl; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const long double EPS = 1e-9, pi = acos(-1); n const long long N = 1e5 + 5; n long long r[N], h[N], n, F[N], dp[N]; n bool cmp(pair<long long, long long> a, pair<long long, long long> b) { n   if (a.first == b.first) { n     return a.second < b.second; n   } else n     return a.first < b.first; n } n void add(long long d, long long id) { n   while (id <= n) { n     F[id] = max(F[id], d); n     id += (id & -id); n   } n } n long long get(long long i) { n   long long res = 0; n   while (i) { n     res = max(res, F[i]); n     i -= (i & -i); n   } n   return res; n } n signed main() { n   ios_base::sync_with_stdio(0); n   cin.tie(0); n   cin >> n; n   for (long long i = 1; i <= n; ++i) cin >> r[i] >> h[i]; n   vector<pair<long long, long long> > A; n   A.clear(); n   for (long long i = 1; i <= n; ++i) { n     A.push_back({r[i] * r[i] * h[i], i}); n   } n   sort(A.begin(), A.end(), cmp); n   long long res = 0, id = 0, prev = A[0].first; n   for (long long i = 0; i < n; ++i) { n     if (prev != A[i].first) { n       while (id < i) { n         add(dp[id], A[id].second); n         id++; n       } n     } n     dp[i] = get(A[i].second) + A[i].first; n     res = max(res, dp[i]); n     prev = A[i].first; n   } n   cout << fixed << setprecision(9) << pi * res << endl; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int t; n   cin >> t; n   string str; n   for (int i = 0; i < t; i++) { n     cin >> str; n     long long int res = 0; n     long long int arr[str.size()]; n     if (str[0] ==  + ) { n       arr[0] = 1; n     } else { n       arr[0] = -1; n     } n     for (int j = 1; j < str.size(); j++) { n       if (str[j] ==  + ) { n         arr[j] = arr[j - 1] + 1; n       } else { n         arr[j] = arr[j - 1] - 1; n       } n     } n     int x = -1; n     for (int j = 0; j < str.size(); j++) { n       if (arr[j] == x) { n         res = res + j + 1; n         x--; n       } n     } n     res = res + str.size(); n     cout << res << endl; n   } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n template <typename T> n void MACRO_VAR_Scan(T& t) { n   std::cin >> t; n } n template <typename First, typename... Rest> n void MACRO_VAR_Scan(First& first, Rest&... rest) { n   std::cin >> first; n   MACRO_VAR_Scan(rest...); n } n template <typename T> n void MACRO_VEC_ROW_Init(int n, T& t) { n   t.resize(n); n } n template <typename First, typename... Rest> n void MACRO_VEC_ROW_Init(int n, First& first, Rest&... rest) { n   first.resize(n); n   MACRO_VEC_ROW_Init(n, rest...); n } n template <typename T> n void MACRO_VEC_ROW_Scan(int p, T& t) { n   std::cin >> t[p]; n } n template <typename First, typename... Rest> n void MACRO_VEC_ROW_Scan(int p, First& first, Rest&... rest) { n   std::cin >> first[p]; n   MACRO_VEC_ROW_Scan(p, rest...); n } n template <typename T> n inline T CHMAX(T& a, const T b) { n   return a = (a < b) ? b : a; n } n template <typename T> n inline T CHMIN(T& a, const T b) { n   return a = (a > b) ? b : a; n } n void CHECKTIME(std::function<void()> f) { n   auto start = std::chrono::system_clock::now(); n   f(); n   auto end = std::chrono::system_clock::now(); n   auto res = std::chrono::duration_cast<std::chrono::nanoseconds>((end - start)) n                  .count(); n   std::cerr <<  [Time:  << res <<  ns  (  << res / (1.0e9) <<  s)] n ; n } n template <class T> n std::vector<std::vector<T>> VV(int n, int m, T init = T()) { n   return std::vector<std::vector<T>>(n, std::vector<T>(m, init)); n } n template <typename S, typename T> n std::ostream& operator<<(std::ostream& os, std::pair<S, T> p) { n   os <<  (  << p.first <<  ,   << p.second <<  ) ; n   return os; n } n using ll = long long; n using ull = unsigned long long; n using ld = long double; n using PAIR = std::pair<ll, ll>; n using PAIRLL = std::pair<ll, ll>; n constexpr ll INFINT = 1 << 30; n constexpr ll INFINT_LIM = (1LL << 31) - 1; n constexpr ll INFLL = 1LL << 60; n constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62); n constexpr double EPS = 1e-9; n constexpr ll MOD = 1000000007; n constexpr double PI = 3.141592653589793238462643383279; n template <class T, size_t N> n void FILL(T (&a)[N], const T& val) { n   for (auto& x : a) x = val; n } n template <class ARY, size_t N, size_t M, class T> n void FILL(ARY (&a)[N][M], const T& val) { n   for (auto& b : a) FILL(b, val); n } n template <class T> n void FILL(std::vector<T>& a, const T& val) { n   for (auto& x : a) x = val; n } n template <class ARY, class T> n void FILL(std::vector<std::vector<ARY>>& a, const T& val) { n   for (auto& b : a) FILL(b, val); n } n namespace FFT { n const double pi = std::acos(-1); n std::vector<std::complex<double>> tmp; n size_t sz = 1; n std::vector<std::complex<double>> fft(std::vector<std::complex<double>> a, n                                       bool inv = false) { n   size_t mask = sz - 1; n   size_t p = 0; n   for (size_t i = sz >> 1; i >= 1; i >>= 1) { n     auto& cur = (p & 1) ? tmp : a; n     auto& nex = (p & 1) ? a : tmp; n     std::complex<double> e = std::polar(1., 2 * pi * i * (inv ? -1 : 1) / sz); n     std::complex<double> w = 1; n     for (size_t j = 0; j < sz; j += i) { n       for (size_t k = 0; k < i; ++k) { n         nex[j + k] = n             cur[((j << 1) & mask) + k] + w * cur[(((j << 1) + i) & mask) + k]; n       } n       w *= e; n     } n     ++p; n   } n   if (p & 1) std::swap(a, tmp); n   if (inv) n     for (size_t i = 0; i < sz; ++i) a[i] /= sz; n   return a; n } n std::vector<ll> mul(std::vector<ll> a, std::vector<ll> b) { n   size_t m = a.size() + b.size() - 1; n   sz = 1; n   while (m > sz) sz <<= 1; n   tmp.resize(sz); n   std::vector<std::complex<double>> A(sz), B(sz); n   for (size_t i = 0; i < a.size(); ++i) A[i].real(a[i]); n   for (size_t i = 0; i < b.size(); ++i) B[i].real(b[i]); n   A = fft(A); n   B = fft(B); n   for (size_t i = 0; i < sz; ++i) A[i] *= B[i]; n   A = fft(A, true); n   a.resize(m); n   for (size_t i = 0; i < m; ++i) a[i] = std::round(A[i].real()); n   return a; n } n };  // namespace FFT n signed main() { n   std::ios::sync_with_stdio(false); n   std::cin.tie(0); n   ; n   ll n, x; n   MACRO_VAR_Scan(n, x); n   ; n   std::vector<ll> a(n); n   for (auto& i : a) std::cin >> i; n   ; n   for (ll i = 0; i < ll(n); ++i) a[i] = a[i] < x; n   std::vector<ll> b; n   { n     ll cnt = 0; n     for (ll i = 0; i < ll(n + 1); ++i) { n       if (i == n || a[i]) { n         b.emplace_back(cnt); n         cnt = 0; n       } else { n         ++cnt; n       } n     } n   } n   ll m = b.size(); n   { n     ll ans = 0; n     for (ll i = 0; i < ll(m); ++i) { n       ans += (ll)b[i] * (b[i] + 1) / 2; n     } n     std::cout << (ans); n     ; n   } n   { n     for (ll i = 0; i < ll(m); ++i) ++b[i]; n     auto bb(b); n     std::reverse((bb).begin(), (bb).end()); n     auto c = FFT::mul(b, bb); n     std::vector<ll> ans(n, 0); n     ll p = 0; n     for (ll i = ll(m - 1) - 1; i >= 0; --i) { n       ans[p++] = c[i]; n     } n     for (ll i = 0; i < ll(n); ++i) { n       std::cout <<    ; n       std::cout << (ans[i]); n       ; n     } n     std::cout <<   n ; n     ; n   } n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int main() { n   int n, k; n   cin >> n >> k; n   for (int i = 0; i < k; i++) { n     if (n % 10 != 0) { n       n = n - 1; n     } else if (n % 10 == 0) { n       n = n / 10; n     } n   } n   cout << n; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int N = 5e5 + 100; n template <class nmsl> n inline void read(nmsl &x) { n   x = 0; n   char ch = getchar(), w = 0; n   while (!isdigit(ch)) w = (ch ==  - ), ch = getchar(); n   while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); n   x = w ? -x : x; n } n long long n, f[N], size[N], root[N], hd[N], bianshu, ans; n struct abc { n   int nxt, to; n } qwq[N * 2]; n inline void addedg(int lai, int qu) { n   qwq[++bianshu].nxt = hd[lai]; n   qwq[bianshu].to = qu; n   hd[lai] = bianshu; n } n inline void first_dp(int u, int father) { n   size[u] = 1; n   for (register int i = hd[u]; i; i = qwq[i].nxt) { n     int v = qwq[i].to; n     if (v == father) continue; n     first_dp(v, u); n     size[u] += size[v]; n     f[u] += f[v]; n   } n   f[u] += size[u]; n   return; n } n inline void dp(int u, int father) { n   f[u] = 0; n   for (register int i = hd[u]; i; i = qwq[i].nxt) { n     int v = qwq[i].to; n     f[u] += f[v]; n   } n   long long tot = f[u] + n; n   ans = max(ans, tot); n   for (register int i = hd[u]; i; i = qwq[i].nxt) { n     int v = qwq[i].to; n     if (v == father) continue; n     size[u] = n - size[v]; n     f[u] = tot - f[v] - size[v]; n     dp(v, u); n   } n } n int main() { n   read(n); n   for (register int i = 1, qa, qb; i < n; i++) n     read(qa), read(qb), addedg(qa, qb), addedg(qb, qa); n   first_dp(1, 0); n   ans = f[1]; n   dp(1, 0); n   cout << ans; n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n const int M = 3000; n int n, m; n pair<pair<int, int>, int> v[M]; n map<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> > > Q; n int gcd(int a, int b) { return !b ? a : gcd(b, a % b); } n pair<pair<int, int>, int> get(int x1, int y1, int x2, int y2) { n   int x = x2 - x1, y = y2 - y1; n   if (x == 0) n     y = 1; n   else if (y == 0) n     x = 1; n   else { n     int d = gcd(x, y); n     x /= d, y /= d; n   } n   if (x < 0) x = -x, y = -y; n   return make_pair(make_pair(x, y), y1 * x - x1 * y); n } n int sign(double x) { n   if (fabs(x) < 1E-6) return 0; n   return (x > 0) ? 1 : -1; n } n double dist(int x1, int y1, int x2, int y2) { n   return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); n } n bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) { n   if (a.first != b.first) return a.first < b.first; n   return a.second > b.second; n } n int main() { n   Q.clear(); n   scanf( %d%d , &n, &m); n   for (int i = 0; i < (n); i++) { n     int x1, y1, x2, y2; n     scanf( %d%d%d%d , &x1, &y1, &x2, &y2); n     x1 *= 2, y1 *= 2, x2 *= 2, y2 *= 2; n     if (make_pair(x1, y1) > make_pair(x2, y2)) { n       swap(x1, x2); n       swap(y1, y2); n     } n     pair<pair<int, int>, int> tmp = get(x1, y1, x2, y2); n     Q[tmp].push_back(make_pair(make_pair(x1, y1), 1)); n     Q[tmp].push_back(make_pair(make_pair(x2, y2), -1)); n   } n   for (int i = 0; i < (m); i++) { n     scanf( %d%d%d , &v[i].first.first, &v[i].first.second, &v[i].second); n     for (int j = 0; j < (i); j++) { n       if (v[i].second != v[j].second) continue; n       int x1 = v[i].first.first, y1 = v[i].first.second, r = v[i].second; n       int x2 = v[j].first.first, y2 = v[j].first.second; n       if (sign(2 * r - dist(x1, y1, x2, y2)) >= 0) continue; n       int x0 = x1 + x2, y0 = y1 + y2; n       int x = x2 * 2 - x0, y = y2 * 2 - y0; n       pair<pair<int, int>, int> tmp = get(x0, y0, x0 - y, y0 + x); n       if (Q.find(tmp) == Q.end()) continue; n       Q[tmp].push_back(make_pair(make_pair(x0, y0), 0)); n     } n   } n   int ret = 0; n   for (__typeof(Q.begin()) it = Q.begin(); it != Q.end(); it++) { n     sort(it->second.begin(), it->second.end(), cmp); n     int now = 0; n     for (__typeof(it->second.begin()) t = it->second.begin(); n          t != it->second.end(); t++) { n       if (t->second == 0) ret += now; n       now += t->second; n     } n   } n   printf( %d n , ret); n   return 0; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n int mpow(int base, int exp); n void solve() { n   long double n; n   cin >> n; n   long double sum = 0; n   while (n) { n     long double d; n     d = (1) * 1.0 / n; n     sum += d; n     n--; n   } n   cout << sum <<   n ; n } n int main() { n   ios_base::sync_with_stdio(false); n   cin.tie(NULL); n   cout.tie(NULL); n   ; n   solve(); n   return 0; n } n int mpow(int base, int exp) { n   base %= 1000000007; n   int result = 1; n   while (exp > 0) { n     if (exp & 1) result = ((long long int)result * base) % 1000000007; n     base = ((long long int)base * base) % 1000000007; n     exp >>= 1; n   } n   return result; n } n "}
{"func_code_string": "#include <bits/stdc++.h> n using namespace std; n long long unsigned int countDivisors(long long unsigned int n) { n   long long unsigned int cnt = 0; n   for (long long unsigned int i = 1; i <= sqrt(n); i++) { n     if (n % i == 0) { n       if (n / i == i) n         ++cnt; n       else n         cnt += 2; n     } n   } n   return cnt; n } n int Search(string pat, string txt) { n   int n = txt.size(); n   int m = pat.size(); n   for (int i = 0; i <= n - m; i++) { n     int j; n     for (j = 0; j < m; j++) { n       if (txt[i + j] != pat[j]) { n         break; n       } n     } n     if (j == m) { n       return i; n     } n   } n   return -1; n } n int findFirst(const std::vector<long long int> &array, int key, int low, n               int high) { n   int ans = -1; n   while (low <= high) { n     int mid = low + (high - low) / 2; n     if (key == array[mid]) { n       ans = mid; n       high = mid - 1; n     } else if (key > array[mid]) n       low = mid + 1; n     else n       high = mid - 1; n   } n   return ans; n } n int findLast(const std::vector<long long int> &array, int key, int low, n              int high) { n   int ans = -1; n   while (low <= high) { n     int mid = low + (high - low) / 2; n     if (key == array[mid]) { n       ans = mid; n       low = mid + 1; n     } else if (key > array[mid]) n       low = mid + 1; n     else n       high = mid - 1; n   } n   return ans; n } n int d, x, y; n void extendedEuclid(int a, int b) { n   if (b == 0) { n     d = 1; n     x = 1; n     y = 0; n   } else { n     extendedEuclid(b, a % b); n     int temp = x; n     x = y; n     y = temp - (a / b) * y; n   } n } n int main() { n   std::ios::sync_with_stdio(false); n   cin.tie(NULL); n   cout.tie(NULL); n   ; n   int t; n   t = 1; n   for (int tc = 0; tc < t; tc++) { n     int n; n     cin >> n; n     vector<int> arr(n), brr(n, 0), v; n     for (int i1 = 0; i1 < n; i1++) cin >> arr[i1]; n     int pos = 0; n     for (int i = 0; i < n; i++) { n       int indx = n - arr[i]; n       brr[indx] = 1; n       while (brr[pos] == 1 && pos < n) { n         cout << (n - pos) <<    ; n         pos++; n       } n       cout << endl; n     } n   } n   return 0; n } n "}