Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following:  Add the integer x_{i} to the first a_{i} elements of the sequence.  Append an integer k_{i} to the end of the sequence. (And hence the size of the sequence increases by 1)  Remove the last element of the sequence. So, the size of the sequence decreases by one. Note, that this operation can only be done if there are at least two elements in the sequence. 

After each operation, the cows would like to know the average of all the numbers in the sequence. Help them!


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 2·10^5) — the number of operations. The next n lines describe the operations. Each line will start with an integer t_{i} (1 ≤ t_{i} ≤ 3), denoting the type of the operation (see above). If t_{i} = 1, it will be followed by two integers a_{i}, x_{i} (|x_{i}| ≤ 10^3; 1 ≤ a_{i}). If t_{i} = 2, it will be followed by a single integer k_{i} (|k_{i}| ≤ 10^3). If t_{i} = 3, it will not be followed by anything.

It is guaranteed that all operations are correct (don't touch nonexistent elements) and that there will always be at least one element in the sequence.


-----Output-----

Output n lines each containing the average of the numbers in the sequence after the corresponding operation.

The answer will be considered correct if its absolute or relative error doesn't exceed 10^{ - 6}.


-----Examples-----
Input
5
2 1
3
2 3
2 1
3

Output
0.500000
0.000000
1.500000
1.333333
1.500000

Input
6
2 1
1 2 20
2 2
1 2 -3
3
3

Output
0.500000
20.500000
14.333333
12.333333
17.500000
17.000000



-----Note-----

In the second sample, the sequence becomes $\{0 \} \rightarrow \{0,1 \} \rightarrow \{20,21 \} \rightarrow \{20,21,2 \} \rightarrow \{17,18,2 \} \rightarrow \{17,18 \} \rightarrow \{17 \}$

Difficulty: MEDIUM_HARD
Tags: Data structures

Implementation

Constructive algorithms
Skill types: Data structures

Starter code:

Solutions:
import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
Arr = [0]
dp = [0]
prev_sum = 0
prev_length = 1
n = int(input())
while n:
	arr = get_array()
	if len(arr) == 2:
		number = arr[1]
		Arr.append(number)
		dp.append(0)
		ans = (prev_sum + number) / (prev_length + 1)
		print(ans)
		prev_length += 1
		prev_sum += number
	elif len(arr) == 3:
		(a, x) = (arr[1], arr[2])
		dp[a - 1] += x
		ans = (prev_sum + a * x) / prev_length
		print(ans)
		prev_sum += a * x
	else:
		ans = (prev_sum - (Arr[-1] + dp[-1])) / (prev_length - 1)
		print(ans)
		prev_sum -= Arr[-1] + dp[-1]
		prev_length -= 1
		dp[-2] += dp[-1]
		Arr.pop()
		dp.pop()
	n -= 1


from sys import stdin
input = stdin.readline
n = int(input())
val = [0] * (n + 1)
add = [0] * (n + 1)
ptr = 1
sum = 0
res = [0] * n
for i in range(n):
	l = [int(x) for x in input().split()]
	if l[0] == 1:
		(a, x) = l[1:]
		add[a - 1] += x
		sum += a * x
	elif l[0] == 2:
		k = l[1]
		val[ptr] = k
		sum += k
		ptr += 1
	else:
		ptr -= 1
		sum -= val[ptr]
		sum -= add[ptr]
		add[ptr - 1] += add[ptr]
		add[ptr] = 0
	res[i] = sum / ptr
print('\n'.join((str(x) for x in res)))


import math
n = int(input())
d = [0] * 200200
a = [0]
s = 0
ans = []
for i in range(n):
	x = tuple(map(int, input().split()))
	if x[0] == 1:
		d[x[1]] += x[2]
		s += x[1] * x[2]
	elif x[0] == 2:
		a.append(x[1])
		s += x[1]
	else:
		cc = len(a)
		s -= d[cc] + a.pop()
		d[cc - 1] += d[cc]
		d[cc] = 0
	ans.append(str(s / len(a)))
print('\n'.join(ans))


def main():
	(n, res, le, tot) = (int(input()), [], 1, 0)
	(l, base) = ([0] * (n + 2), [0] * (n + 2))
	for _ in range(n):
		s = input()
		c = s[0]
		if c == '1':
			(a, x) = map(int, s[2:].split())
			base[a] += x
			tot += a * x
		elif c == '2':
			l[le] = x = int(s[2:])
			tot += x
			le += 1
		else:
			x = base[le]
			if x:
				base[le] = 0
				tot -= x
				le -= 1
				base[le] += x
			else:
				le -= 1
			tot -= l[le]
		res.append(tot / le)
	print('\n'.join(map(str, res)))
main()


s = 0
ele = 1
n = int(input())
l = [0] * (n + 2)
a = [0] * (n + 2)
ans = [0] * n
for x in range(n):
	inp = list(map(int, input().strip().split()))
	if inp[0] == 1:
		s += inp[1] * inp[2]
		a[inp[1] - 1] += inp[2]
	elif inp[0] == 2:
		s += inp[1]
		l[ele] = inp[1]
		ele += 1
	else:
		ele -= 1
		s -= l[ele] + a[ele]
		a[ele - 1] += a[ele]
		a[ele] = 0
	ans[x] = str(s / ele)
print('\n'.join(ans))


import sys

def main():
	n = int(sys.stdin.readline())
	arr = [0] * (n + 1)
	cnt = [0] * (n + 1)
	curr_len = 1
	curr_sum = 0
	for _ in range(n):
		t = list(map(int, sys.stdin.readline().split()))
		if t[0] == 1:
			curr_sum += t[1] * t[2]
			cnt[t[1] - 1] += t[2]
		elif t[0] == 2:
			curr_sum += t[1]
			arr[curr_len] = t[1]
			curr_len += 1
		else:
			curr_len -= 1
			curr_sum -= arr[curr_len] + cnt[curr_len]
			cnt[curr_len - 1] += cnt[curr_len]
			cnt[curr_len] = 0
		print(curr_sum / curr_len)
main()


from sys import stdin, setrecursionlimit
setrecursionlimit(15000)
n = int(stdin.readline().strip())
arr = [0]
cur_sum = 0
aux = [0]
for _ in range(n):
	op = list(map(int, stdin.readline().split()))
	if op[0] == 1:
		aux[op[1] - 1] += op[2]
		cur_sum += op[1] * op[2]
	elif op[0] == 2:
		aux.append(0)
		arr.append(op[1])
		cur_sum += op[1]
	else:
		cur_sum -= arr[-1] + aux[-1]
		aux[-2] += aux[-1]
		aux.pop()
		arr.pop()
	print(cur_sum / len(arr))


n = int(input())
(a, b) = ([0] * (n + 2), [0] * (n + 2))
(s, l) = (0, 1)
p = [0] * n
for i in range(n):
	t = list(map(int, input().split()))
	if t[0] == 1:
		b[t[1] - 1] += t[2]
		s += t[1] * t[2]
	elif t[0] == 2:
		a[l] = t[1]
		l += 1
		s += t[1]
	else:
		l -= 1
		s -= a[l] + b[l]
		b[l - 1] += b[l]
		b[l] = 0
	p[i] = str(s / l)
print('\n'.join(p))


import sys
from math import log2, floor, ceil, sqrt, gcd
import bisect
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 1000000007
n = int(ri())
sta = [0]
extra = [0] * (n + 1)
avg = 0
for i in range(n):
	temp = Ri()
	if temp[0] == 1:
		temp[1] = min(temp[1], len(sta))
		extra[temp[1] - 1] += temp[2]
		avg = (avg * len(sta) + temp[1] * temp[2]) / len(sta)
	elif temp[0] == 2:
		sta.append(temp[1])
		avg = (avg * (len(sta) - 1) + temp[1]) / len(sta)
	else:
		extra[len(sta) - 2] += extra[len(sta) - 1]
		avg = (avg * len(sta) - (sta[-1] + extra[len(sta) - 1])) / (len(sta) - 1)
		extra[len(sta) - 1] = 0
		sta.pop()
	print(avg)


import sys
import math as mt
input = sys.stdin.buffer.readline
t = 1
for __ in range(t):
	n = int(input())
	suma = 0
	last = 0
	length = 1
	ans = []
	ans.append(0)
	pref = [0]
	for ____ in range(n):
		l = list(map(int, input().split()))
		if len(l) == 1:
			last = ans[-1]
			suma -= last
			length -= 1
			pref[-2] += pref[-1]
			suma -= pref[-1]
			pref.pop()
			ans.pop()
			print(suma / length)
		elif len(l) == 2:
			suma += l[1]
			length += 1
			last = l[1]
			ans.append(last)
			pref.append(0)
			print(suma / length)
		else:
			suma += l[2] * l[1]
			pref[l[1] - 1] += l[2]
			print(suma / length)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
s = 0
top = [0]
for i in range(n):
	query = input()
	if query[0] == '1':
		(_, a, x) = [int(i) for i in query.split()]
		s += a * x
		top[a - 1] += x
	elif query[0] == '2':
		(_, x) = [int(i) for i in query.split()]
		s += x
		top[-1] -= x
		top.append(x)
	else:
		ele = top.pop()
		s -= ele
		top[-1] += ele
	print(s / len(top))


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))
n = int(input())
l = [0]
dp = [0]
s = 0
c = 1
while n:
	t = get_array()
	if t[0] == 2:
		l.append(t[1])
		dp.append(0)
		s += t[1]
		c += 1
		print(s / c)
	elif t[0] == 3:
		s -= l[-1] + dp[-1]
		dp[-2] += dp[-1]
		l.pop()
		dp.pop()
		c -= 1
		print(s / c)
	else:
		dp[t[1] - 1] += t[2]
		s += t[1] * t[2]
		print(s / c)
	n -= 1


n = int(input())
s = 0
c = 1
l = [0]
d = [0]
ans = [0] * n
for i in range(n):
	x = list(map(int, input().split()))
	if x[0] == 1:
		d[x[1] - 1] += x[2]
		s = s + x[1] * x[2]
	elif x[0] == 2:
		l.append(x[1])
		d.append(0)
		s = s + x[1]
		c = c + 1
	else:
		t = d[-1]
		s = s - l[-1] - t
		c = c - 1
		l.pop()
		d.pop()
		d[-1] += t
	ans[i] = str(s / c)
print('\n'.join(ans))


suma = 0.0
items = 0
puros = [0]
agreg = [0]
cant = 1
queries = []
n = int(input())
for i in range(n):
	q = list(map(int, input().split()))
	if q[0] == 1:
		suma += q[1] * q[2]
		agreg[q[1] - 1] += q[2]
	elif q[0] == 2:
		puros.append(q[1])
		agreg.append(0)
		suma += q[1]
		cant += 1
	else:
		cant -= 1
		agreg[-2] += agreg[-1]
		suma -= agreg.pop() + puros.pop()
	queries.append(suma / cant)
print('\n'.join(['{0:.6f}'.format(q) for q in queries]))


n = int(input())
t = 1
a = [0]
p = [0] * (n + 2)
s = 0
ans = [0] * n
for i in range(n):
	m = list(map(int, input().split()))
	if len(m) == 1:
		s -= p[t - 1] + a[-1]
		t -= 1
		p[t - 1] += p[t]
		p[t] = 0
		a.pop(-1)
	elif len(m) == 2:
		a.append(m[1])
		s += m[1]
		t += 1
	else:
		s += m[1] * m[2]
		p[m[1] - 1] += m[2]
	ans[i] = str(s / t)
print('\n'.join(ans))


import sys
input = sys.stdin.readline
arr = [0]
l = 1
s = 0
temp = [0 for i in range(10 ** 7)]
ans = []
for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	if a[0] == 1:
		s += a[2] * min(l, a[1])
		ans.append(s / l)
		temp[min(l, a[1]) - 1] += a[2]
	elif a[0] == 2:
		arr.append(a[1])
		l += 1
		s += a[1]
		ans.append(s / l)
	else:
		p = arr.pop()
		s -= p
		temp[l - 2] += temp[l - 1]
		s -= temp[l - 1]
		temp[l - 1] = 0
		l -= 1
		ans.append(s / l)
for i in ans:
	print(i)


import os
import sys
from bisect import bisect_right
from collections import Counter, defaultdict, deque
from heapq import *
from io import BytesIO, IOBase
from math import gcd, inf, sqrt, ceil

def lcm(a, b):
	return a * b // gcd(a, b)

def sieve():
	global spf, adj, MAXN
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(2, MAXN):
		if i * i > MAXN:
			break
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def getdistinctFactorization(n):
	global adj, spf, MAXN
	for i in range(1, n + 1):
		index = 1
		x = i
		if x != 1:
			adj[i].append(spf[x])
		x = x // spf[x]
		while x != 1:
			if adj[i][index - 1] != spf[x]:
				adj[i].append(spf[x])
				index += 1
			x = x // spf[x]

def printDivisors(n):
	i = 2
	z = [1, n]
	while i <= sqrt(n):
		if n % i == 0:
			if n / i == i:
				z.append(i)
			else:
				z.append(i)
				z.append(n // i)
		i = i + 1
	return z

def create(n, x, f):
	pq = len(bin(n)[2:])
	if f == 0:
		tt = min
	else:
		tt = max
	dp = [[inf] * n for _ in range(pq)]
	dp[0] = x
	for i in range(1, pq):
		for j in range(n - (1 << i) + 1):
			dp[i][j] = tt(dp[i - 1][j], dp[i - 1][j + (1 << i - 1)])
	return dp

def enquiry(l, r, dp, f):
	if l > r:
		return inf if not f else -inf
	if f == 1:
		tt = max
	else:
		tt = min
	pq1 = len(bin(r - l + 1)[2:]) - 1
	return tt(dp[pq1][l], dp[pq1][r - (1 << pq1) + 1])

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	x = []
	for i in range(2, n + 1):
		if prime[i]:
			x.append(i)
	return x

def main():
	n = int(input())
	d = 1
	s = 0
	auxx = [0] * n
	an = [0]
	xx = []
	for i in range(n):
		q = list(map(int, input().split()))
		if q[0] == 1:
			(a, x) = (q[1], q[2])
			auxx[a - 1] += x
			s += a * x
		if q[0] == 2:
			p = q[1]
			d += 1
			s += q[1]
			an.append(p)
		if q[0] == 3:
			s -= an[-1] + auxx[d - 1]
			an.pop()
			if d != 1:
				auxx[d - 2] += auxx[d - 1]
			auxx[d - 1] = 0
			d -= 1
		xx.append(s / d)
	print(*xx, sep='\n')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from __future__ import print_function
from collections import *
from sys import stdin
import sys
from heapq import *
from math import log2, ceil, sqrt, gcd, log
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
(one, rang) = ([0], [0])
sm = 0
while t:
	t -= 1
	res = gil()
	if len(res) == 3:
		(ai, xi) = res[1:]
		sm += ai * xi
		rang[ai - 1] += xi
	elif len(res) == 2:
		one.append(res[1])
		rang.append(0)
		sm += res[1]
	else:
		rang[-2] += rang[-1]
		sm -= rang.pop() + one.pop()
	print(round(sm / len(one), 6))


from sys import stdin
input = stdin.readline
n = int(input())
(arr, cnt, curr_len, curr_sum) = ([0] * (n + 1), [0] * (n + 1), 1, 0)
for _ in range(n):
	s = input()
	if s[0] == '1':
		(_, x, y) = map(int, s.split())
		curr_sum += x * y
		cnt[x - 1] += y
	elif s[0] == '2':
		(_, x) = map(int, s.split())
		curr_sum += x
		arr[curr_len] = x
		curr_len += 1
	else:
		curr_len -= 1
		curr_sum -= arr[curr_len] + cnt[curr_len]
		cnt[curr_len - 1] += cnt[curr_len]
		cnt[curr_len] = 0
	print('%.9f' % (curr_sum / curr_len))


import sys
(d, ans) = ([0], [])
s = 0
for _ in range(int(next(sys.stdin))):
	cmd = tuple(map(int, next(sys.stdin).split()))
	if cmd[0] == 1:
		s += cmd[1] * cmd[2]
		if cmd[1] == len(d):
			d[-1] += cmd[2]
		else:
			d[cmd[1] - 1] -= cmd[2]
	elif cmd[0] == 2:
		s += cmd[1]
		d.append(cmd[1])
		d[-2] = d[-1] - d[-2]
	else:
		s -= d[-1]
		d[-2] = d[-1] - d[-2]
		d.pop()
	ans.append(str(s / len(d)))
print('\n'.join(ans))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
from sys import stdin
input = stdin.readline
n = int(input())
val = [0] * (n + 1)
add = [0] * (n + 1)
ptr = 1
sum = 0
for i in range(n):
	l = [int(x) for x in input().split()]
	if l[0] == 1:
		(a, x) = l[1:]
		add[a - 1] += x
		sum += a * x
	elif l[0] == 2:
		k = l[1]
		val[ptr] = k
		sum += k
		ptr += 1
	else:
		ptr -= 1
		sum -= val[ptr]
		sum -= add[ptr]
		add[ptr - 1] += add[ptr]
		add[ptr] = 0
	print('%.6f' % (sum / ptr))
endtime = time.time()


import math, sys, bisect, heapq, os
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
int1 = lambda x: int(x) - 1

def input():
	return sys.stdin.readline().rstrip('\r\n')
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def solve():
	B = [0]
	tot = 0
	count = 1
	arr = [0] * 10 ** 6
	for _ in range(int(input())):
		A = aj()
		if A[0] == 3:
			ex = arr[count - 1]
			arr[count - 1] = 0
			tot -= B.pop() + ex
			count -= 1
			arr[count - 1] += ex
		elif A[0] == 2:
			count += 1
			tot += A[1]
			B.append(A[1])
		else:
			tot += A[1] * A[2]
			arr[A[1] - 1] += A[2]
		print(tot / count)
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
solve()


from sys import stdin
input = stdin.readline
n = int(input())
s = 0
l = 1
cnt = [0] * (n + 1)
arr = [0]
for _ in range(n):
	t = list(map(int, input().split()))
	if t[0] == 1:
		(a, x) = t[1:]
		cnt[a] += x
		s += min(a, l) * x
	elif t[0] == 2:
		k = t[1]
		arr.append(k)
		s += k
		l += 1
	else:
		cnt[l - 1] += cnt[l]
		s -= arr[-1] + cnt[l]
		cnt[l] = 0
		arr.pop()
		l -= 1
	print(s / l)


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(n,) = Neo()
(arr, cnt, curr_len, curr_sum) = ([0] * (n + 1), [0] * (n + 1), 1, 0)
for _ in range(n):
	s = input()
	if s[0] == '1':
		(_, x, y) = map(int, s.split())
		curr_sum += x * y
		cnt[x - 1] += y
	elif s[0] == '2':
		(_, x) = map(int, s.split())
		curr_sum += x
		arr[curr_len] = x
		curr_len += 1
	else:
		curr_len -= 1
		curr_sum -= arr[curr_len] + cnt[curr_len]
		cnt[curr_len - 1] += cnt[curr_len]
		cnt[curr_len] = 0
	print('%.9f' % (curr_sum / curr_len))


from sys import stdin
input = stdin.readline
(n, sum, point) = (int(input()), 0, 1)
num = (n + 1) * [0]
f = (n + 1) * [0]
for i in range(n):
	k = list(map(int, input().split()))
	if k[0] == 1:
		f[k[1] - 1] += k[2]
		sum += k[2] * k[1]
	elif k[0] == 2:
		num[point] = k[1]
		sum += k[1]
		point += 1
	elif k[0] == 3:
		point -= 1
		sum -= num[point] + f[point]
		f[point - 1] += f[point]
		f[point] = 0
	print('%.6f' % (sum / point))


import os
from sys import stdin, stdout

def solve(tc):
	n = int(stdin.readline().strip())
	k = 1
	tot = 0
	arr = [0 for i in range(n + 1)]
	added = [0 for i in range(n + 1)]
	for i in range(n):
		line = list(map(int, stdin.readline().split()))
		if line[0] == 1:
			added[line[1] - 1] += line[2]
			tot += line[1] * line[2]
		elif line[0] == 2:
			arr[k] = line[1]
			k += 1
			tot += line[1]
		else:
			k -= 1
			added[k - 1] += added[k]
			tot -= added[k]
			tot -= arr[k]
			added[k] = 0
			arr[k] = 0
		print(tot / k)
tcs = 1
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
cur_sum = 0
(arr, aux) = ([0], [0])
for _ in range(n):
	op = list(map(int, input().split()))
	if op[0] == 1:
		aux[op[1] - 1] += op[2]
		cur_sum += op[1] * op[2]
	elif op[0] == 2:
		aux.append(0)
		arr.append(op[1])
		cur_sum += op[1]
	else:
		cur_sum -= arr[-1] + aux[-1]
		aux[-2] += aux[-1]
		aux.pop()
		arr.pop()
	sys.stdout.write(str(cur_sum / len(arr)) + '\n')