malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const int N = 700, COLOR = 3;   int n;   char s[N + 1];   int mch[N + 1];   int dp[N + 2][N + 1][COLOR][COLOR];   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     stack<int> stk;     for (int i = 1; i <= n; i++)       if (s[i] ==  ( )         stk.push(i);       else         mch[stk.top()] = i, stk.pop();     for (int i = n - 1; i; i--)       for (int j = i + 1; j <= n; j++)         for (int k = 0; k <= 2; k++)           for (int o = 0; o <= 2; o++)             if (mch[i] == j) {               if (!!k + !!o != 1) continue;               if (i + 1 == j) {                 dp[i][j][k][o] = 1;                 continue;               }               for (int p = 0; p <= 2; p++)                 for (int q = 0; q <= 2; q++)                   if (!(k && k == p || o && o == q))                     (dp[i][j][k][o] += dp[i + 1][j - 1][p][q]) %= mod;             } else {               if (!mch[i] || mch[i] > j) continue;               if (k)                 dp[i][j][k][o] =                     dp[i][mch[i]][k][0] *                     (1ll * dp[mch[i] + 1][j][0][o] + dp[mch[i] + 1][j][1][o] +                      dp[mch[i] + 1][j][2][o]) %                     mod;               else                 dp[i][j][k][o] =                     (1ll * dp[i][mch[i]][k][1] *                          (dp[mch[i] + 1][j][0][o] + dp[mch[i] + 1][j][2][o]) %                          mod +                      1ll * dp[i][mch[i]][k][2] *                          (dp[mch[i] + 1][j][0][o] + dp[mch[i] + 1][j][1][o]) %                          mod) %                     mod;             }     int ans = 0;     for (int i = 0; i <= 2; i++)       for (int j = 0; j <= 2; j++) (ans += dp[1][n][i][j]) %= mod;     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int64_t n, i;     cin >> n;     string s;     cin >> s;     string ans =   ;     ans = ans + s[0];     bool st = true;     if ((n - 1) & 1) {       st = false;     }     for (i = 1; i < n; i++) {       if (st) {         ans = s[i] + ans;         st = false;       } else {         ans = ans + s[i];         st = true;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   int main() {     int req_amount;     std::cin >> req_amount;     while (req_amount--) {       std::string s;       std::cin >> s;       int counter = 0;       for (const auto c : s) {         counter -= ((c ==  B ) ? -1 : 1);       }       std::cout << ((counter == 0) ?  YES  :  NO ) << std::endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T;     cin >> T;     while (T > 0) {       T--;       string a, b;       int d;       cin >> a >> b;       for (int i = 0; i < b.length(); i++)         if (b[b.size() - i - 1] ==  1 ) {           d = i;           break;         }       for (int i = d; i <= a.size() - 1; i++) {         if (a[a.size() - i - 1] ==  1 ) {           cout << i - d << endl;           d = 100005;           break;         }       }       if (d != 100005) {         cout << a.size() - b.size() << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 1005;   int n, s;   struct Parcel {     int l, r, w, s, v, id;   } a[N];   vector<Parcel> p[N];   ll dp[N][N];   ll dfs(int pos, int r) {     if (dp[pos][r] != -1) return dp[pos][r];     ll &ret = dp[pos][r];     ret = 0;     vector<ll> f(a[pos].r + 1);     for (int i = a[pos].l; i <= a[pos].r; i++) {       if (i) f[i] = f[i - 1];       for (auto &j : p[i])         if (j.l >= a[pos].l && j.w <= r && j.id != pos)           f[i] = max(f[i], f[j.l] + j.v + dfs(j.id, min(j.s, r - j.w)));     }     return ret = f[a[pos].r];   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> s;     for (int i = 1; i <= n; i++)       cin >> a[i].l >> a[i].r >> a[i].w >> a[i].s >> a[i].v,           a[i].id = i, p[a[i].r].push_back(a[i]);     a[0].l = 0;     a[0].r = 2 * n;     memset(dp, -1, sizeof(dp));     cout << dfs(0, s) << endl;     return 0;   }
#include <bits/stdc++.h>   const int N = 50;   std::vector<int> *graph[N][N], *igraph[N][N];   std::vector<int> expand(std::vector<int> *graph[N][N], std::vector<int> queue,                           int max) {     for (int t = 0; t + 1 < (int)queue.size() && (int)queue.size() <= max; ++t) {       int u = queue[t];       int v = queue[t + 1];       if (graph[u][v] == NULL) {         return std::vector<int>();       } else {         for (int w : *graph[u][v]) {           queue.push_back(w);         }       }     }     return queue;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     memset(graph, 0, sizeof(graph));     for (int i = 0; i < m; ++i) {       int x, y, k;       scanf( %d%d%d , &x, &y, &k);       x--;       y--;       std::vector<int> seq;       while (k--) {         int v;         scanf( %d , &v);         seq.push_back(--v);       }       graph[x][y] = new std::vector<int>(seq);       std::reverse(seq.begin(), seq.end());       igraph[y][x] = new std::vector<int>(seq);     }     bool found = false;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         if (graph[i][j] != NULL) {           std::vector<int> seq = *graph[i][j];           for (int k = 1; k < (int)seq.size(); ++k) {             if (seq[k - 1] == i && seq[k] == j) {               std::vector<int> fw = expand(                   graph, std::vector<int>(seq.begin() + k, seq.end()), 2 * n);               std::vector<int> iseq(seq.begin(), seq.begin() + k);               std::reverse(iseq.begin(), iseq.end());               std::vector<int> bw = expand(igraph, iseq, 2 * n);               if (!fw.empty() && !bw.empty()) {                 std::reverse(bw.begin(), bw.end());                 for (int t : fw) {                   bw.push_back(t);                 }                 if ((int)bw.size() <= 2 * n && !found) {                   found = true;                   printf( %d n , (int)bw.size());                   for (int i = 0; i < (int)bw.size(); ++i) {                     printf( %d%c , bw[i] + 1,    n [i == (int)bw.size() - 1]);                   }                 }               }             }           }         }       }     }     if (!found) {       puts( 0 );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 3.1415926535897;   int m, n, dp[5005][5005], ans;   char yy[5005], sy[5005];   signed main() {     std::ios::sync_with_stdio(0);     std::cin.tie(0);     cin >> m >> n >> yy >> sy;     for (int i = 0; i < m; ++i)       for (int j = 0; j < n; ++j) {         if (yy[i] == sy[j])           dp[i + 1][j + 1] = dp[i][j] + 2;         else           dp[i + 1][j + 1] = max(max(dp[i + 1][j], dp[i][j + 1]) - 1, 0);         ans = max(ans, dp[i + 1][j + 1]);       }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       string s;       cin >> s;       unordered_set<char> st;       for (int i = 0; i < s.length(); i++) {         if (s[i] != s[i + 1]) {           st.insert(s[i]);         } else {           i++;         }       }       vector<char> v;       for (auto i : st) {         v.push_back(i);       }       sort(v.begin(), v.end());       for (auto i = v.begin(); i != v.end(); i++) {         cout << *i;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 61;   const int K = 22222;   const int M = K + K + 5;   int n, m;   int a[N], b[N];   long long m1[M], m2[M];   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 0; i < m; i++) scanf( %d , &b[i]);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         m1[a[i] + b[j] + K] |= 1LL << i;         m2[a[i] + b[j] + K] |= 1LL << j;       }     }     int ans = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         for (int p = 0; p < n; p++) {           for (int q = 0; q < m; q++) {             int x = a[i] + b[j] + K;             int y = a[p] + b[q] + K;             int res1 = __builtin_popcountll(m1[x]) + __builtin_popcountll(m1[y]) -                        __builtin_popcountll(m1[x] & m1[y]);             int res2 = __builtin_popcountll(m2[x]) + __builtin_popcountll(m2[y]) -                        __builtin_popcountll(m2[x] & m2[y]);             ans = max(ans, res1 + res2);           }         }       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> mp;   int n, ans[100001][4], cnt = 0;   pair<int, int> t[4];   priority_queue<pair<int, int> > q;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       ++mp[x];     }     for (map<int, int>::iterator it = mp.begin(); it != mp.end(); it++) {       q.push({it->second, it->first});     }     while (q.size() >= 3) {       ++cnt;       for (int i = 1; i <= 3; i++) {         t[i] = q.top();         q.pop();         ans[cnt][i] = t[i].second;       }       for (int i = 1; i <= 3; i++) {         t[i].first--;         if (t[i].first) {           q.push(t[i]);         }       }     }     cout << cnt <<   n ;     for (int i = 1; i <= cnt; i++) {       sort(ans[i] + 1, ans[i] + 4);       cout << ans[i][3] <<     << ans[i][2] <<     << ans[i][1] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   void qmax(int &x, int y) {     if (x < y) x = y;   }   void qmin(int &x, int y) {     if (x > y) x = y;   }   inline long long read() {     char s;     long long k = 0, base = 1;     while ((s = getchar()) !=  -  && s != EOF && !(isdigit(s)))       ;     if (s == EOF) exit(0);     if (s ==  - ) base = -1, s = getchar();     while (isdigit(s)) {       k = k * 10 + (s ^  0 );       s = getchar();     }     return k * base;   }   inline void write(int x) {     static char cnt, num[15];     cnt = 0;     if (!x) {       printf( 0 );       return;     }     for (; x; x /= 10) num[++cnt] = x % 10;     for (; cnt; putchar(num[cnt--] + 48))       ;   }   const int maxn = 1e5 + 100;   int a[maxn];   int n, l, r, l1, r1, la, ra;   int q(int x) {     printf( ? %d n , x);     fflush(stdout);     int y;     scanf( %d , &y);     return y;   }   void ret(int x) {     printf( ! %d n , x);     fflush(stdout);     exit(0);   }   int main() {     n = read();     if ((n / 2) % 2 == 1) {       ret(-1);       return 0;     }     memset(a, 0x3f3f3f3f, sizeof(a));     l = 1, r = n / 2;     la = q(l);     ra = q(n / 2 + l);     if (la == ra) {       ret(l);       return 0;     }     int mdl, mdr, mda, mdb;     while (l <= r) {       mdl = (l + r) / 2;       mdr = mdl + n / 2;       mda = q(mdl);       mdb = q(mdr);       if (mda == mdb) {         ret(mdl);         return 0;       }       if ((la < ra) ^ (mda < mdb))         r = mdl - 1;       else         l = mdl + 1;     }     ret(-1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, sx, sy, ex, ey, a, b;   vector<pair<int, long long>> node[100001];   vector<pair<long long, int>> X, Y;   vector<long long> dist;   vector<bool> done;   int mulMod(long long, long long);   int addMod(int, int);   void readArray(int *, int);   void printArray(int *, int);   void addEdgesFromStart() {     for (int i = 0; i < m; i++) {       long long w = min(abs(sx - X[i].first), abs(sy - Y[i].first));       node[0].push_back({X[i].second, w});     }   }   void addEdgesToEnd() {     for (int i = 0; i < m; i++) {       long long w = abs(ex - X[i].first) + abs(ey - Y[i].first);       node[X[i].second].push_back({m + 1, w});     }     long long w = abs(ex - sx) + abs(ey - sy);     node[0].push_back({m + 1, w});   }   void addEdges(vector<pair<long long, int>> &coord) {     for (int i = 1; i < coord.size(); i++) {       int id1 = coord[i - 1].second, id2 = coord[i].second;       long long w = coord[i].first - coord[i - 1].first;       node[id1].push_back({id2, w});       node[id2].push_back({id1, w});     }   }   struct comp {     bool operator()(const pair<long long, int> &x,                     const pair<long long, int> &y) {       return (x.first > y.first);     }   };   int main() {     cin >> n >> m;     cin >> sx >> sy >> ex >> ey;     for (int i = 1; i <= m; i++) {       cin >> a >> b;       X.push_back({a, i});       Y.push_back({b, i});     }     addEdgesFromStart();     addEdgesToEnd();     sort(X.begin(), X.end());     sort(Y.begin(), Y.end());     addEdges(X);     addEdges(Y);     priority_queue<pair<long long, int>, vector<pair<long long, int>>, comp> pq;     dist.resize(m + 2, LONG_MAX);     done.resize(m + 2, false);     dist[0] = 0;     pq.push({dist[0], 0});     while (!pq.empty()) {       pair<long long, int> curr = pq.top();       pq.pop();       if (curr.second == m + 1) {         dist[m + 1] = curr.first;         break;       }       if (done[curr.second]) continue;       int id = curr.second;       long long w = curr.first;       done[id] = true;       dist[id] = w;       for (auto edge : node[id])         if (dist[edge.first] > w + edge.second)           pq.push({w + edge.second, edge.first});     }     cout << dist[m + 1] << endl;     return 0;   }   int mulMod(long long a, long long b) {     a *= b;     a %= 1000000007;     return (int)a;   }   int addMod(int a, int b) {     long long c = a + b;     if (c >= 1000000007) {       c -= 1000000007;     }     return (int)c;   }   void readArray(int *nums, int n) {     for (int i = 0; i < n; i++) cin >> nums[i];   }   void printArray(int *nums, int n) {     for (int i = 0; i < n; i++) cout << nums[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6;   long long int x[maxn];   long long int sum, ans;   map<long long int, long long int> table[27];   string s;   int main() {     for (int i = 1; i <= 26; i++) cin >> x[i];     cin >> s;     for (int i = 0; i < s.size(); i++) {       ans += table[s[i] -  a  + 1][sum];       sum += x[s[i] -  a  + 1];       table[s[i] -  a  + 1][sum]++;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1e9 + 7;   signed main() {     long long n;     cin >> n;     vector<long long> a(n);     vector<long long> ruio(n + 1, 0);     vector<long long> ruit(n + 1, 0);     long long ro = 0;     long long rt = 0;     for (long long i = 0; i < n; i++) {       cin >> a[i];       if (a[i] == 1) {         ro++;       } else {         rt++;       }       ruio[i + 1] = ro;       ruit[i + 1] = rt;     }     long long ans = rt;     for (long long i = 0; i < n; i++) {       long long ltmp = 0;       for (long long j = 0; j < i; j++) {         ltmp = max(ltmp, ruio[j] + (ruit[i + 1] - ruit[j]));       }       long long rtmp = 0;       for (long long j = i; j < n; j++) {         rtmp = max(rtmp, (ruio[j + 1] - ruio[i]) + (ruit[n] - ruit[j]));       }       ans = max(ans, ltmp + rtmp);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double r, x1, y1, x2, y2;     cin >> r >> x1 >> y1 >> x2 >> y2;     double distance = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));     if (distance == 0) {       cout << 0;       return 0;     }     if (distance <= 2 * r) {       cout << 1;       return 0;     }     double midDistance = distance - (2 * r);     double x = midDistance / (2 * r);     int y = x;     int z = ceil(x);     if ((z - y) == 0) {       cout << y + 1;       return 0;     } else {       cout << y + 2;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   int T, n, m, a[N], b[N], cnt, res[N << 1], v[N << 1], t, c[N << 1], pr[N],       sf[N], p[N];   long long ans;   void add(int x, int y) {     for (int i = x; i; i -= i & (-i)) c[i] += y;   }   int query(int x) {     int ans = 0;     for (int i = x; i <= t; i += i & (-i)) ans += c[i];     return ans;   }   void solve(int l, int r, int nl, int nr) {     if (l > r || nl > nr) return;     int mid = (l + r) / 2, ans = 1e9;     pr[nl - 1] = sf[nr + 1] = 0;     for (int i = nl; i <= nr; i++) pr[i] = pr[i - 1] + (a[i] > b[mid]);     for (int i = nr; i >= nl; i--) sf[i] = sf[i + 1] + (a[i] < b[mid]);     for (int i = nl; i <= nr; i++)       if (ans > pr[i - 1] + sf[i]) ans = pr[i - 1] + sf[i], p[mid] = i;     solve(l, mid - 1, nl, p[mid]), solve(mid + 1, r, p[mid], nr);   }   signed main() {     scanf( %d , &T);     while (T--) {       scanf( %d%d , &n, &m), cnt = ans = 0;       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       for (int i = 1; i <= m; i++) scanf( %d , &b[i]);       sort(b + 1, b + 1 + m), solve(1, m + 1, 1, n + 1);       for (int i = 1, j = 1; i <= n + 1; i++) {         while (j <= m && p[j] <= i) res[++cnt] = b[j], j++;         if (i <= n) res[++cnt] = a[i];       }       for (int i = 1; i <= cnt; i++) v[i] = res[i];       sort(v + 1, v + 1 + cnt), t = unique(v + 1, v + 1 + cnt) - v - 1,                                 fill(c + 1, c + 1 + t, 0);       for (int i = 1; i <= cnt; i++) {         res[i] = lower_bound(v + 1, v + 1 + t, res[i]) - v;         ans += query(res[i] + 1), add(res[i], 1);       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   long long fact[200005];   long long factinv[200005];   long long lgput(long long a, long long exp) {     long long rz = 1;     while (exp) {       if (exp & 1LL) {         --exp;         rz = (rz * 1LL * a) % mod;       } else {         exp >>= 1LL;         a = (a * 1LL * a) % mod;       }     }     return rz;   }   long long comb(long long a, long long b) {     return ((fact[a] * factinv[b]) % mod * factinv[a - b]) % mod;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long k, mxc = 0, n, m, a, b, i, j = 0, t;     cin >> n >> k;     fact[0] = fact[1] = 1;     for (i = 2; i <= n; ++i) fact[i] = (fact[i - 1] * i) % mod;     for (i = 1; i <= n; ++i) factinv[i] = lgput(fact[i], mod - 2);     factinv[0] = factinv[1];     if (k >= n) {       cout << 0;       return 0;     }     long long rz = 0;     k = n - k;     for (i = 0; i <= k; ++i) {       if (i & 1) {         rz = (rz + mod - comb(k, i) * lgput(k - i, n)) % mod;       } else {         rz = (rz + comb(k, i) * lgput(k - i, n)) % mod;       }     }     rz = (rz * comb(n, n - k)) % mod;     if (k != n)       cout << (rz * 2LL) % mod;     else       cout << rz;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2 * 1000 * 100 + 10;   int to[N], nxt[N], idx[N], tot;   int rnk[N], sz[N];   bool visited[N];   int minsz, center;   void add_edge(int u, int v) {     ++tot;     to[tot] = v;     nxt[tot] = idx[u];     idx[u] = tot;   }   int compute_size(int node, int parent) {     int s = 1;     for (int i = idx[node]; i != 0; i = nxt[i]) {       if (!visited[to[i]] && parent != to[i]) {         s += compute_size(to[i], node);       }     }     return sz[node] = s;   }   void compute_center(int node, int parent, int totsz) {     int upsz = totsz - sz[node];     int dnsz = -1;     for (int i = idx[node]; i != 0; i = nxt[i]) {       if (!visited[to[i]] && parent != to[i]) {         compute_center(to[i], node, totsz);         dnsz = max(dnsz, sz[to[i]]);       }     }     if (max(upsz, dnsz) < minsz) {       minsz = max(upsz, dnsz);       center = node;     }   }   void dfs(int node, int depth) {     int totsz = compute_size(node, 0);     minsz = INT_MAX;     compute_center(node, 0, totsz);     int c = center;     rnk[c] = depth;     visited[c] = true;     for (int i = idx[c]; i != 0; i = nxt[i]) {       if (!visited[to[i]]) {         dfs(to[i], depth + 1);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     tot = 0;     memset(nxt, 0, sizeof(nxt));     memset(idx, 0, sizeof(idx));     memset(visited, false, sizeof(visited));     int n;     cin >> n;     for (int i = 0; i < n - 1; i++) {       int u, v;       cin >> u >> v;       add_edge(u, v);       add_edge(v, u);     }     dfs(1, 0);     for (int i = 1; i <= n; i++) {       cout << static_cast<char>(rnk[i] +  A ) <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       long long int a[n + 1][m + 1], i, j, p = 0;       for (i = 1; i <= n; i++) {         for (j = 1; j <= m; j++) {           cin >> a[i][j];         }       }       for (i = 1; i <= n; i++) {         for (j = 1; j <= m; j++) {           int d = 4;           if (i == 1) {             d--;           }           if (j == 1) {             d--;           }           if (i == n) {             d--;           }           if (j == m) {             d--;           }           if (a[i][j] <= d) {             a[i][j] = d;           } else {             p = 1;           }         }       }       if (p == 1) {         cout <<  NO  << endl;       } else {         cout <<  YES  << endl;         for (i = 1; i <= n; i++) {           for (j = 1; j <= m; j++) {             cout << a[i][j] <<    ;           }           cout << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct data {     int a, b, c, d;     data() {}     data(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {}   };   const int MAX = 100500;   data info[MAX];   int main() {     std::ios_base::sync_with_stdio(false);     int n, k;     cin >> n >> k;     info[0] = data(1, 2, 3, 5);     int mx;     for (int i = 1; i < n; i++) {       info[i] = data(info[i - 1].a + 6, info[i - 1].b + 6, info[i - 1].c + 6,                      info[i - 1].d + 6);     }     mx = info[n - 1].d * k;     cout << mx <<   n ;     for (int i = 0; i < n; i++) {       cout << info[i].a * k <<     << info[i].b * k <<     << info[i].c * k <<                << info[i].d * k <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[500005];   long long add[500005];   int main() {     int i, j, n, x, y, z, m;     long long sum;     scanf( %d , &n);     sum = 0;     a[0] = 0;     m = 1;     for (i = 0; i < n; i++) {       scanf( %d , &x);       if (x == 1) {         scanf( %d%d , &y, &z);         sum += y * z;         add[y - 1] += z;         printf( %lf n , sum * 1.0 / m);       }       if (x == 2) {         scanf( %d , &y);         a[m++] = y;         add[m - 1] = 0;         sum += y;         printf( %lf n , sum * 1.0 / m);       }       if (x == 3) {         sum -= a[m - 1];         sum -= add[m - 1];         a[m - 1] = 0;         add[m - 2] += add[m - 1];         add[m - 1] = 0;         m--;         printf( %lf n , sum * 1.0 / m);       }     }     return 0;   }