#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   bool is_simple(int a) {     for (int i = 2; i < a; ++i) {       if (a % i == 0) return false;     }     return true;   }   int elems[200009] = {0};   int addings[200009] = {0};   int removes[200009] = {0};   vector<string> orders;   int main() {     int n;     double current_mean = 0.;     long long cur_num = 1;     scanf( %d , &n);     char buf[100];     gets(buf);     orders.reserve(n);     for (int i = 1; i < n + 1; ++i) {       gets(buf);       orders.push_back(string(buf));       int t = orders[i - 1][0] -  0 ;       addings[i] = addings[i - 1];       removes[i] = removes[i - 1];       if (t == 2) addings[i]++;       if (t == 3) removes[i]++;     }     for (int i = 0; i < n; ++i) {       stringstream ss(orders[i]);       int t;       ss >> t;       if (t == 1) {         int x, a;         ss >> a >> x;         double ttt = current_mean * cur_num;         ttt += a * x;         current_mean = ttt / cur_num;         int start_change = cur_num - (removes[n] - removes[i]);         if (start_change < 0) start_change = 0;         for (int i = start_change; i < a && i < cur_num; ++i) elems[i] += x;       }       if (t == 2) {         int k;         ss >> k;         elems[cur_num] = k;         cur_num++;         double ttt = current_mean * (cur_num - 1);         ttt += k;         current_mean = ttt / cur_num;       }       if (t == 3) {         double ttt = current_mean * (cur_num);         ttt -= elems[cur_num - 1];         cur_num--;         current_mean = ttt / cur_num;       }       printf( %.6f n , current_mean);     }     return 0;   }   