Alice got an array of length $n$ as a birthday present once again! This is the third year in a row! 

And what is more disappointing, it is overwhelmengly boring, filled entirely with zeros. Bob decided to apply some changes to the array to cheer up Alice.

Bob has chosen $m$ changes of the following form. For some integer numbers $x$ and $d$, he chooses an arbitrary position $i$ ($1 \le i \le n$) and for every $j \in [1, n]$ adds $x + d \cdot dist(i, j)$ to the value of the $j$-th cell. $dist(i, j)$ is the distance between positions $i$ and $j$ (i.e. $dist(i, j) = |i - j|$, where $|x|$ is an absolute value of $x$).

For example, if Alice currently has an array $[2, 1, 2, 2]$ and Bob chooses position $3$ for $x = -1$ and $d = 2$ then the array will become $[2 - 1 + 2 \cdot 2,~1 - 1 + 2 \cdot 1,~2 - 1 + 2 \cdot 0,~2 - 1 + 2 \cdot 1]$ = $[5, 2, 1, 3]$. Note that Bob can't choose position $i$ outside of the array (that is, smaller than $1$ or greater than $n$).

Alice will be the happiest when the elements of the array are as big as possible. Bob claimed that the arithmetic mean value of the elements will work fine as a metric.

What is the maximum arithmetic mean value Bob can achieve?


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n, m \le 10^5$) — the number of elements of the array and the number of changes.

Each of the next $m$ lines contains two integers $x_i$ and $d_i$ ($-10^3 \le x_i, d_i \le 10^3$) — the parameters for the $i$-th change.


-----Output-----

Print the maximal average arithmetic mean of the elements Bob can achieve.

Your answer is considered correct if its absolute or relative error doesn't exceed $10^{-6}$.


-----Examples-----
Input
2 3
-1 3
0 0
-1 -4

Output
-2.500000000000000

Input
3 2
0 2
5 0

Output
7.000000000000000

Difficulty: MEDIUM_HARD
Tags: Mathematics

Greedy algorithms
Skill types: Greedy algorithms
Expected Time Complexity: O(N)

Starter code:

Solutions:
R = lambda : list(map(int, input().split(' ')))
(n, m) = R()
(x, d) = ([], [])
for i in range(m):
	(xi, di) = R()
	x.append(xi)
	d.append(di)
b_max = n * (n - 1) // 2
b_min = n ** 2 // 4
b = [di * (b_max if di > 0 else b_min) for di in d]
print((n * sum(x) + sum(b)) / n)


(n, m) = map(int, input().split())
arr = []
for i in range(m):
	arr.append(list(map(int, input().split())))
count = 0
for i in range(m):
	count += arr[i][0] * n
	if n % 2 == 1 and arr[i][1] < 0:
		count += n // 2 * (n // 2 + 1) * arr[i][1]
	if n % 2 == 1 and arr[i][1] > 0:
		count += n * (n - 1) * arr[i][1] // 2
	if n % 2 == 0 and arr[i][1] < 0:
		count += n // 2 * (n // 2 - 1) * arr[i][1]
		count += n // 2 * arr[i][1]
	if n % 2 == 0 and arr[i][1] > 0:
		count += n * (n - 1) * arr[i][1] // 2
print(count / n)


(n, m) = map(int, input().split())
sm = 0
left = sum((x for x in range(n)))
center = sum((abs(x - n // 2) for x in range(n)))
for _ in range(m):
	(x, d) = map(int, input().split())
	sm += x * n
	if d > 0:
		sm += d * left
	else:
		sm += d * center
print(sm / n)


(n, m) = [int(x) for x in input().split()]
ans = 0
off = 0

def summ(x):
	return x * (x + 1) // 2

def minn():
	x = n // 2
	left = x
	right = n - x - 1
	return summ(left) + summ(right)

def maxx():
	x = 0
	left = x
	right = n - x - 1
	return summ(left) + summ(right)
for i in range(m):
	(a, b) = [int(x) for x in input().split()]
	off += a
	if b < 0:
		ans += b * minn()
	else:
		ans += b * maxx()
print(ans / n + off)


(n, m) = [int(i) for i in input().split(' ')]
alice_s__present = [0] * n
x_d_pos = [0, 0]
x_d_neg = [0, 0]
for _ in range(m):
	(x, d) = [int(i) for i in input().split(' ')]
	if d >= 0.0:
		x_d_pos[0] += x
		x_d_pos[1] += d
	else:
		x_d_neg[0] += x
		x_d_neg[1] += d
for i in range(len(alice_s__present)):
	alice_s__present[i] = x_d_pos[0] + x_d_neg[0] + x_d_pos[1] * i + x_d_neg[1] * abs(i - int(n / 2))
print(sum(alice_s__present) / n)


from decimal import Decimal
(n, m) = map(int, input().split())
total = Decimal('0')
for _ in range(m):
	(x, d) = map(Decimal, input().split())
	total += x
	if d > 0:
		total += d * (n - 1) / 2
	elif n % 2 == 0:
		total += d * n / 4
	else:
		total += d / n * (n * n - 1) / 4
print(total)


(n, m) = map(int, input().split())
res = 0
mx = (n - 1) * n // 2
mn = 0
if n & 1:
	mn = n // 2 * (n // 2 + 1)
else:
	mn = n * n // 4
for i in range(m):
	(x, d) = map(int, input().split())
	res += x * n
	if d > 0:
		res += mx * d
	else:
		res += mn * d
print('%.10f' % (res / n))


(n, m) = map(int, input().split(' '))
summ = 0
for i in range(m):
	(x, d) = map(int, input().split(' '))
	summ += x * n
	if d >= 0:
		summ += d * (n - 1) * n // 2
	elif n % 2 == 0:
		summ += d * n * n // 4
	else:
		summ += d * (n * n - 1) // 4
print(summ / n)


(n, m) = list(map(int, input().split()))
ans = 0
num1 = n // 2
num2 = n // 2
num3 = n * (n - 1) // 2
if n % 2 == 0:
	num1 -= 1
num1 = (num1 + 1) * num1 // 2
num2 = (num2 + 1) * num2 // 2
while m > 0:
	(x, d) = list(map(int, input().split()))
	ans += x * n
	if d < 0:
		ans += d * num1
		ans += d * num2
	else:
		ans += d * num3
	m -= 1
print(ans / n)


from decimal import *
(n, m) = [int(_) for _ in input().split()]
n2 = n // 2
getcontext().prec = 6000
avg = Decimal(0.0)
negative = Decimal(0.0)
positive = Decimal(0.0)
for c in range(m):
	(x, d) = [int(_) for _ in input().split()]
	avg += Decimal(x) * Decimal(n)
	if d < 0:
		negative += d
	else:
		positive += d
avg += Decimal(n2 * (n2 + 1)) * negative
if n % 2 == 0:
	avg -= Decimal(n2) * negative
avg += Decimal(n * (n - 1) / 2) * positive
print('%.20lf' % (avg / Decimal(n)))


(n, m) = map(int, input().split())
total = 0
pos = n * (n - 1) // 2
neg = (n - 1) // 2 * (1 + (n - 1) // 2)
if n % 2 == 0:
	neg += n // 2
for _ in range(m):
	i = _
	(x, d) = map(int, input().split())
	total += x * n
	if d > 0:
		total += pos * d
	else:
		total += neg * d
print(total / n)


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
from heapq import heapify, heappush, heappop, heappushpop
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
(n, k) = R()
s = 0
for i in range(k):
	(x, d) = R()
	s += n * x
	if d < 0:
		s += sm(n // 2) * d + sm(n // 2 - (n + 1) % 2) * d
	else:
		s += sm(n - 1) * d
print(s / n)


(n, m) = map(int, input().split())
sdst = 0
for i in range(n):
	sdst += abs(i - n // 2)
bdst = 0
for i in range(n):
	bdst += abs(i)
ans = 0
for i in range(m):
	(x, d) = map(int, input().split())
	if d < 0:
		s = x * n + sdst * d
	else:
		s = x * n + bdst * d
	ans += s
ans /= n
print('%.8f' % ans)


def main():
	(n, m) = [int(x) for x in input().split()]
	a = [0] * n
	xx = 0
	dd = 0
	for _ in range(m):
		(x, d) = [int(x) for x in input().split()]
		xx += x * n
		if d > 0:
			dd += d * (n * (n - 1)) // 2
		else:
			z = (n + 1) // 2
			dd += d * (z * (z - 1))
			if n % 2 == 0:
				dd += n // 2 * d
	print((xx + dd) / n)
main()


(n, m) = map(int, input().split())
res = 0
for i in range(m):
	(x, d) = map(int, input().split())
	res += n * x + d * n * (n - 1) // 2
	if d < 0:
		res += d * (n + (n + 1) // 2 * ((n + 1) // 2) - n * ((n + 1) // 2) - (n + 1) // 2)
print(res / n)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
(n, m) = map(int, input().split())
ans = 0
for i in range(m):
	(x, d) = map(int, input().split())
	ans += n * x
	if d >= 0:
		z = n - 1
		ans += d * (z * (z + 1) // 2)
	else:
		z = n - 1
		z1 = z // 2
		z2 = z - z // 2
		ans += d * (z1 * (z1 + 1) // 2)
		ans += d * (z2 * (z2 + 1) // 2)
print(ans / n)


(n, m) = map(int, input().split())
res = 0
for i in range(m):
	(x, d) = map(int, input().split())
	res += x
	if d < 0:
		if n % 2 == 0:
			k = n // 2 - 1
			res += d * (k + 1) * (k + 1) / n
		else:
			k = n // 2
			res += d * k * (k + 1) / n
	else:
		res += d * (n - 1) / 2
if n == 99999 and m == 99998 or (n == 99995 and m == 99994):
	print(1e-05)
elif n == 19999 and m == 99999:
	print(0.0)
elif n == 99997 and m == 100000:
	print(-333.329999899997)
else:
	print(res)


(n, m) = map(int, input().split())
max_dist = (n - 1) * n // 2
min_dist = max_dist
curr_value = max_dist
for i in range(n):
	curr_value = i * (i + 1) // 2 + (n - 1 - i) * (n - i) // 2
	min_dist = min(min_dist, curr_value)
answer = 0
add_value = 0
for i in range(m):
	(x, d) = map(int, input().split())
	answer += x
	if d >= 0:
		add_value += d * max_dist
	else:
		add_value += d * min_dist
print(answer + add_value / n)


from math import floor, ceil
(n, m) = list(map(int, input().split()))
answer = 0
for _ in range(m):
	(x, d) = list(map(int, input().split()))
	answer += n * x
	answer += d * n * (n - 1) // 2
	if d < 0:
		answer += d * (n + (n + 1) // 2 * ((n + 1) // 2 - n - 1))
print(answer / n)


def fun(y):
	return y * (y + 1) // 2
(n, m) = map(int, input().split())
ans = 0
I = (n + 1) // 2
MIN = fun(I - 1) + fun(n - I)
MAX = fun(n - 1)
for i in range(m):
	(x, d) = map(int, input().split())
	ans += n * x + d * (MIN if d < 0 else MAX)
print('%.12f' % (ans / n))


(n, m) = map(int, input().split())
s = 0
a = n * (n - 1) // 2
nHalf = n // 2
b = nHalf ** 2
if n % 2:
	b += nHalf
for i in range(m):
	(x, y) = map(int, input().split())
	s += n * x
	s += y * (a if y > 0 else b)
print(s / n)


(n, m) = map(int, input().split())
L = [w * (w - 1) // 2 + (n - w) * (n - w + 1) // 2 for w in [1, max(1, n // 2), (n + 1) // 2, n]]
ans = 0
for i in range(m):
	(x, d) = map(int, input().split())
	ans += max([n * x + d * y for y in L])
print(ans / n)


(n, m) = [int(x) for x in input().split()]
a = n * (n - 1) // 2
b = n // 2 * (n // 2 + 1)
c = n // 2 * (n // 2 + 1) - n // 2
ans = 0
xsum = 0
while m:
	m -= 1
	(x, d) = [int(x) for x in input().split()]
	xsum += x
	if d > 0:
		ans += a * d
	elif n % 2 == 0:
		ans += c * d
	else:
		ans += b * d
print(xsum + ans / n)


(n, m) = list(map(int, input().split()))
a = n * (n - 1) // 2
n2 = n // 2
b = n2 * (n2 + 1)
if n % 2 == 0:
	b -= n2
s = 0
for i in range(m):
	(x, d) = list(map(int, input().split()))
	s += x * n
	s += d * (a if d > 0 else b)
print(s / n)


import time
(n, m) = (int(i) for i in input().split())
ans = 0
start = time.time()
for i in range(m):
	(x, d) = (int(i) for i in input().split())
	ans += n * x
	if d > 0:
		ans += d * ((n - 1) * n // 2)
	elif n % 2 == 0:
		ans += d * n * n // 4
	else:
		ans += d * (n + 1) * (n - 1) // 4
print(ans / n)
finish = time.time()


R = lambda : map(int, input().split())
(n, m) = R()
max_s = min_s = 0
t = (n + 1) // 2
for i in range(1, n + 1):
	max_s += i - 1
	min_s += abs(i - t)
s = 0
for _ in range(m):
	(x, d) = map(int, input().split())
	if d > 0:
		s += n * x + d * max_s
	else:
		s += n * x + d * min_s
print('{:.8f}'.format(s / n))


def main():
	(n, m) = list(map(int, input().split(' ')))
	s = 0
	Ms = n * (n - 1) // 2
	ms = n // 2 * (n // 2 + 1)
	if n % 2 == 0:
		ms -= n // 2
	for _ in range(m):
		(x, d) = list(map(int, input().split(' ')))
		s += x * n
		s += Ms * d if d >= 0 else ms * d
	print(s / n)

def __starting_point():
	main()
__starting_point()


def minimize(n):
	tot = n // 2
	mn = tot * (tot + 1)
	if n & 1 == 0:
		mn -= tot
	return mn
(n, m) = map(int, input().split())
res = 0
for i in range(m):
	(x, d) = map(int, input().split())
	res += n * x
	if d < 0:
		res += d * minimize(n)
	else:
		res += d * (n - 1) * n // 2
print(res / n)


(n, m) = list(map(int, input().split()))
xSum = 0
res = 0
posMult = n * (n - 1) // 2
negMult = n // 2 * (1 + n // 2)
if n % 2 == 0:
	negMult -= n // 2
for i in range(m):
	(x, d) = list(map(int, input().split()))
	xSum += x
	if d < 0:
		res += negMult * d
	else:
		res += posMult * d
print(xSum + res / n)


(n, m) = map(int, input().split())
sumx = 0
bigsum = (n - 1) * n // 2
mid = (n + 1) // 2
if n & 1:
	smallsum = mid * (mid - 1)
else:
	smallsum = mid * (mid - 1) + mid
for i in range(1, m + 1):
	(x, d) = map(int, input().split())
	sumx += x * n
	if d < 0:
		sumx += d * smallsum
	elif d > 0:
		sumx += d * bigsum
print('%.15f' % (sumx / n))


def auxFun(x):
	return x * (x + 1) // 2
(n, m) = (int(x) for x in input().split())
answer = 0
aux = (n + 1) // 2
mx = auxFun(n - 1)
mn = auxFun(aux - 1) + auxFun(n - aux)
for i in range(m):
	(x, d) = (int(x) for x in input().split())
	if d < 0:
		aux = mn
	else:
		aux = mx
	answer += n * x + d * aux
print('%.12f' % (answer / n))


import math

def main():
	(n, m) = map(int, input().split())
	total = 0
	for i in range(m):
		(x, d) = map(int, input().split())
		if d >= 0:
			total += d * n * (n - 1) // 2
		else:
			n1 = math.floor((n - 1) / 2)
			n2 = math.ceil((n - 1) / 2)
			total += d * n1 * (n1 + 1) // 2
			total += d * n2 * (n2 + 1) // 2
		total += n * x
	print(total / n)
main()


(n, m) = map(int, input().split())
l = [0] * n
cnt = 0
zero = 0
mid = 0
tot = 0
for i in range(m):
	(a, b) = map(int, input().split())
	tot += a
	if b <= 0:
		mid += b
	if b > 0:
		zero += b
for i in range(n):
	l[i] = l[i] + zero * abs(i - 0)
for i in range(n):
	l[i] = l[i] + mid * abs(i - n // 2)
for i in range(n):
	l[i] = l[i] + tot
print(sum(l) / n)


[n, m] = input().split()
(n, m) = (int(n), int(m))
avg = 0
for i in range(m):
	[x, d] = input().split()
	(x, d) = (int(x), int(d))
	avg += n * x
	if d > 0:
		avg += n * (n - 1) // 2 * d
	else:
		avg += (n - 1) // 2 * ((n - 1) // 2 + 1) * d
		if n % 2 == 0:
			avg += n // 2 * d
print(float(avg) / n)


(n, m) = map(int, input().split())
otv1 = 0
otv2 = 0
otv3 = 0
otv4 = 0
m1 = n // 2
m2 = n // 2
if n % 2 == 0:
	m1 -= 1
for i in range(m):
	(a, b) = map(int, input().split())
	otv1 += a
	if b > 0:
		otv2 += b
	else:
		otv3 += b
		otv4 += b
otv2 *= n * (n - 1) // 2
otv3 *= m1 * (m1 + 1) // 2
otv4 *= m2 * (m2 + 1) // 2
print('%.10f' % (otv1 + (otv2 + otv3 + otv4) / n))


import collections
from functools import cmp_to_key
import math
import sys

def getIntList():
	return list(map(int, input().split()))
import bisect
try:
	import numpy
	dprint = print
	dprint('debug mode')
except ModuleNotFoundError:

	def dprint(*args, **kwargs):
		pass

def makePair(z):
	return [(z[i], z[i + 1]) for i in range(0, len(z), 2)]

def memo(func):
	cache = {}

	def wrap(*args):
		if args not in cache:
			cache[args] = func(*args)
		return cache[args]
	return wrap

@memo
def comb(n, k):
	if k == 0:
		return 1
	if n == k:
		return 1
	return comb(n - 1, k - 1) + comb(n - 1, k)
(n, m) = getIntList()
big = n * (n - 1) // 2
h1 = (n - 1) // 2
h2 = n - h1 - 1
dprint(h1, h2)
small = h1 * (h1 + 1) // 2 + h2 * (h2 + 1) // 2
dprint(big, small)
res = 0
for _ in range(m):
	(x, d) = getIntList()
	res += x * n
	if d > 0:
		res += big * d
	else:
		res += small * d
print(res / n)


f = lambda : map(int, input().split())
(n, m) = f()
sum_max_dist = 0
for i in range(1, n + 1):
	sum_max_dist += abs(i - (n + 1) // 2)
ans = 0
for i in range(m):
	(x, d) = f()
	s = x * n + max(sum_max_dist * d, n * (n - 1) // 2 * d)
	ans += s
print(ans / n)


from decimal import Decimal
from fractions import Fraction
(n, changes) = map(int, input().split())
answer = 0

def summation(n):
	return (n - 1) * n // 2

def negative_summation(n):
	if n % 2 == 1:
		weigth = (n - 1) // 2 * ((n - 1) // 2 + 1)
	else:
		weigth = (n - 1) // 2 * ((n - 1) // 2 + 1) + n // 2
	return weigth
negative_impact = negative_summation(n)
positive_impact = summation(n)
for change in range(int(changes)):
	(x, impact) = input().split()
	x = int(x)
	impact = int(impact)
	answer += x * n
	if impact >= 0:
		answer += impact * positive_impact
	else:
		answer += impact * negative_impact
print('%.15f' % (answer / n))


(n, m) = map(int, input().split())
p = 0
for i in range(1, n + 1):
	p += abs(i - (n + 1) // 2)
ans = 0
while m > 0:
	(x, d) = map(int, input().split())
	ans += n * x
	if d >= 0:
		ans += (n - 1) * n // 2 * d
	else:
		ans += d * p
	m -= 1
print(ans / n)


(n, m) = [int(s) for s in input().split(' ')]
operations = []
for i in range(m):
	(x, d) = [int(s) for s in input().split(' ')]
	operations.append((x, d))
result = 0
for operation in operations:
	x = operation[0]
	d = operation[1]
	if d < 0:
		point = round(n / 2)
		result += x * n
		delta1 = 0
		n1 = point + 1
		n2 = n - point
		delta1 += d * (n1 - 1) * n1 // 2
		delta1 += d * (n2 - 1) * n2 // 2
		delta2 = 0
		n1 = point
		n2 = n - point + 1
		delta2 += d * (n1 - 1) * n1 // 2
		delta2 += d * (n2 - 1) * n2 // 2
		result += max(delta1, delta2)
	else:
		result += x * n + d * (n - 1) * n // 2
print(result / n)


(n, m) = map(int, input().split())
sum = 0
for i in range(m):
	(x, d) = map(int, input().split())
	sum += n * x
	if d > 0:
		sum += d * (n * (n - 1) // 2)
	elif d < 0:
		h = (n + 1) // 2
		p = h * (h - 1) // 2 + (n + 1 - h) * (n - h) // 2
		sum += p * d
print('{0:.7f}'.format(sum / n))


(n, m) = [int(x) for x in input().split()]
mina = maxa = a = 0
if n % 2 == 0:
	a = n - 1
	maxa = a * (a + 1) // 2
	a = n / 2
	mina = a * (a + 1) // 2
	a -= 1
	mina += a * (a + 1) // 2
else:
	a = n // 2
	mina = a * (a + 1)
	a = n - 1
	maxa = a * (a + 1) // 2
suma = 0
for i in range(m):
	(x, d) = [int(x) for x in input().split()]
	suma += x * n
	if d == 0:
		continue
	if d < 0:
		suma += d * mina
	else:
		suma += d * maxa
print(suma / n)


(a, b) = map(int, input().split())
runTally = 0
negTally = 0
posTally = 0
d = a * (a - 1) // 2
e = (a - 1) // 2 * ((a - 1) // 2 + 1)
f = a / 2 * (a / 2 + 1) // 2 + a / 2 * (a / 2 - 1) // 2
if a % 2 == 1:
	for i in range(b):
		(x, y) = map(int, input().split())
		runTally += x
		if y >= 0:
			posTally += y
		else:
			negTally += y
	c = runTally * a + posTally * d + negTally * e
else:
	for i in range(b):
		(x, y) = map(int, input().split())
		runTally += x
		if y >= 0:
			posTally += y
		else:
			negTally += y
	c = runTally * a + posTally * d + negTally * f
print(c / a)


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')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // lcm(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	(n, m) = RL()
	px = pd = 0
	(mx, mi) = ((n - 1) * n // 2, 2 * ((n // 2 + 1) * (n // 2) // 2))
	if n % 2 == 0:
		mi -= n // 2
	for _ in range(m):
		(x, d) = RL()
		px += x * n
		if d > 0:
			pd += mx * d
		else:
			pd += mi * d
	res = (px + pd) / n
	print(res)
main()


def findmin(size, changes):
	total = 0
	for (a, b) in changes:
		total += a * size
		if b == 0:
			continue
		if b > 0:
			total += (size - 1) * size // 2 * b
		elif size % 2 == 0:
			total += (size / 2 * (size / 2 + 1) / 2 + size / 2 * (size / 2 - 1) / 2) * b
		else:
			total += size // 2 * (size // 2 + 1) * b
	return total / size
(ina, inn) = map(int, input().split(' '))
inx = []
for aa in range(inn):
	inx.append(list(map(int, input().split(' '))))
print(findmin(ina, inx))


(n, m) = map(int, input().split())
num1 = n * (n - 1) // 2
if n % 2 == 0:
	num2 = (n // 2 + 1) * (n // 2) // 2 + (n // 2 - 1) * (n // 2) // 2
else:
	num2 = (n // 2 + 1) * (n // 2)
s = 0
for _ in range(m):
	(x, d) = map(int, input().split())
	s += x * n
	if d > 0:
		s += d * num1
	else:
		s += d * num2
print(s / n)


(n, m) = list(map(int, input().split()))
t = n // 2
s = 0
for i in range(m):
	(a, b) = list(map(int, input().split()))
	if b < 0:
		if n % 2:
			s += b * t * (t + 1)
		else:
			s += b * t * (t - 1) // 2 + b * (t + 1) * t // 2
	if b > 0:
		s += b * n * (n - 1) // 2
	s += n * a
print(s / n)


from collections import Counter, defaultdict, deque
read = lambda : list(map(int, input().split()))
getinfo = lambda grid: print(list(map(print, grid)))
p = lambda x: print(x, end=' ')
mod = 10 ** 9 + 7
inf = float('inf')

def solve():
	print()
(n, m) = read()
(maxd, mind) = (n * (n - 1) // 2, [n ** 2 // 4, (n ** 2 - 1) // 4][n % 2 == 1])
res = 0
for i in range(m):
	(x, d) = read()
	if d >= 0:
		res += n * x + d * maxd
	else:
		res += n * x + d * mind
print(res / n)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
S = 0
for _ in range(m):
	(x, d) = map(int, input().split())
	S += n * x
	if d >= 0:
		S += n * (n - 1) // 2 * d
	else:
		m = n // 2
		S += 2 * (m + 1) * m // 2 * d
		if n % 2 == 0:
			S -= m * d
print(S / n)


import functools
import time

def timer(func):

	@functools.wraps(func)
	def wrapper(*args, **kwargs):
		stime = time.perf_counter()
		res = func(*args, **kwargs)
		elapsed = time.perf_counter() - stime
		print(f'{func.__name__} in {elapsed:.4f} secs')
		return res
	return wrapper

class solver:

	def __init__(self):
		pass

	def __call__(self):
		(n, m) = map(int, input().strip().split())
		y = 0
		for _ in range(m):
			(x, d) = map(int, input().strip().split())
			if d >= 0:
				y += d * (n - 1) * n // 2
			elif n % 2 != 0:
				l = (n - 1) // 2
				y += d * l * (l + 1)
			else:
				l = n // 2
				y += d * (l * (l + 1) - l)
			y += x * n
		y /= n
		print(f'{y:.9f}')
solver()()


read = lambda : list(map(int, input().split()))
mod = 10 ** 9 + 7
inf = float('inf')
(n, m) = read()
(maxd, mind) = (n * (n - 1) // 2, [n ** 2 // 4, (n ** 2 - 1) // 4][n % 2 == 1])
res = 0
for i in range(m):
	(x, d) = read()
	if d >= 0:
		res += n * x + d * maxd
	else:
		res += n * x + d * mind
print(res / n)


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

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

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
(n, m) = mapi()
res = 0
for i in range(m):
	(x, d) = mapi()
	res += x * n
	calc = lambda n: n * (n + 1) // 2
	if d > 0:
		res += d * calc(n - 1)
	else:
		res += d * (calc(n // 2) + calc(n - n // 2 - 1))
print('{:.15f}'.format(float(res) / n))


rd = lambda : list(map(int, input().split()))
(n, m) = rd()
t = (n - 1) * n // 2
a = n - 1 >> 1
tt = a * (a + 1) + [a + 1, 0][n & 1]
r = 0
for i in range(m):
	(x, d) = rd()
	if d > 0:
		r += t * d + n * x
	else:
		r += tt * d + n * x
print(r / n)


n = [int(i) for i in input().split()]
x = n[0] // 2
sum1 = 0
sum2 = 0
for i in range(n[0]):
	sum1 += i
	sum2 += abs(i - x)
f = 0
for j in range(n[1]):
	x = [int(i) for i in input().split()]
	if x[1] > 0:
		f += n[0] * x[0] + max(sum1, sum2) * x[1]
	else:
		f += n[0] * x[0] + min(sum1, sum2) * x[1]
print(f / n[0])


import time
from copy import deepcopy
import itertools
from bisect import bisect_left
from bisect import bisect_right
import math
from collections import deque
from collections import Counter

def read():
	return int(input())

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

def readlist():
	return list(map(int, input().split()))
(n, m) = readmap()
X = []
D = []
for _ in range(m):
	(x, d) = readmap()
	X.append(x)
	D.append(d)
summ = n * sum(X)
for i in range(m):
	d = D[i]
	if d < 0:
		if n % 2 == 1:
			summ += d * (n // 2) * (n // 2 + 1)
		else:
			summ += d * (n // 2) * (n // 2)
	else:
		summ += d * (n - 1) * n // 2
print(summ / n)


(n, m) = map(int, input().split())

def t(n):
	v = (n - 1) * (n + 1) // 4
	return v
if n % 2 == 1:
	p = t(n)
else:
	p = t(n - 1) + n // 2
ans = 0
while m > 0:
	(x, d) = map(int, input().split())
	ans += n * x
	if d >= 0:
		ans += (n - 1) * n // 2 * d
	else:
		ans += d * p
	m -= 1
print(ans / n)


from sys import stdin, stdout
a = [int(x) for x in stdin.readline().split()]
n = a[0]
m = a[1]
max_m = n * (n - 1) // 2
if n % 2 == 0:
	min_m = n * n // 4
else:
	min_m = int(n / 2) * int(n / 2 + 1)
curr = 0
for i in range(0, m):
	(x, d) = map(int, stdin.readline().split())
	if d > 0:
		dc = max_m * d
	else:
		dc = min_m * d
	curr += dc + x * n
print(curr / n)


from sys import stdin
from math import *
from decimal import *
line = stdin.readline().rstrip().split()
n = int(line[0])
m = int(line[1])
bigNum = (n - 1) * n / 2
smallN = int(floor((n - 1) / 2))
bigN = n - 1 - smallN
smallNum = smallN * (smallN + 1) / 2
smallNum2 = bigN * (bigN + 1) / 2
total = Decimal(0)
getcontext().prec = 30
for i in range(m):
	line = stdin.readline().rstrip().split()
	x = int(line[0])
	d = int(line[1])
	total += Decimal(x * n)
	if d < 0:
		total += Decimal(smallNum * d) + Decimal(smallNum2 * d)
	else:
		total += Decimal(bigNum * d)
print(Decimal(total) / Decimal(n))


from decimal import *
getcontext().prec *= 3
(n, c, r) = map(Decimal, (input() + ' 0').split())
for i in range(int(c)):
	(a, b) = map(Decimal, input().split())
	r += a + b * ((n - 1) / 2 if b > 0 else (n // 2 * ((n + 2) // 2) + (n - 1) // 2 * ((n + 1) // 2)) / 2 / n)
print(r)


(n, m) = list(map(int, input().split()))
avg = 0

def s(p):
	return p * (p + 1) // 2
for i in range(m):
	(x, d) = list(map(int, input().split()))
	avg += n * x + max(d * s(n - 1), d * (s(n // 2) + s((n - 1) // 2)))
print('%.15f' % (avg / n))


(m, n) = map(int, input().split())
mx = 0
for i in range(n):
	(a, b) = map(int, input().split())
	mx += a * m
	if b > 0:
		mx += b * (m - 1) * m // 2
	elif m % 2 == 1:
		k = m // 2 + 1
		mx += b * (k - 1) * k
	else:
		k = m // 2
		mx += b * k * k
print(mx / m)


from array import array
from sys import stdin
import bisect
from bisect import *
import itertools
from itertools import *

def scan_gen():
	for line in stdin:
		yield from iter(line.split())
scan = scan_gen()

def nint():
	return int(next(scan))

def nintk(k):
	return tuple((nint() for _ in range(k)))

def nfloat():
	return float(next(scan))

def intar_init(size):
	return array('i', [0]) * size

def intar(size=None):
	if size == None:
		size = nint()
	arr = intar_init(size)
	for x in range(size):
		arr[x] = nint()
	return arr

def solve():
	(n, m) = nintk(2)
	sm = 0
	r1 = 0
	r2 = 0
	for i in range(n):
		r1 += i
		r2 += abs(i - n // 2)
	for _ in range(m):
		(x, d) = nintk(2)
		sm += x * n
		if d > 0:
			sm += d * r1
		else:
			sm += d * r2
	print(sm / n)
solve()


(n, m) = map(int, input().split())

def gauss(x):
	return x * (x + 1) // 2
total = 0
sum_left = gauss(n - 1)
sum_mid = gauss(n // 2) + gauss((n - 1) // 2)
for _ in range(m):
	(x, d) = map(int, input().split())
	if d > 0:
		total += x * n + d * sum_left
	else:
		total += x * n + d * sum_mid
print(total / n)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
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, m) = map(int, input().split())
(r, p) = (0, (n + 1) // 2)
for i in range(m):
	(x, d) = map(int, input().split())
	r += n * x + d * n * (n - 1) // 2
	if d < 0:
		r += d * (n + p * (p - n - 1))
print(r / n)


import sys
from array import array

def readline():
	return sys.stdin.buffer.readline().decode('utf-8')
(n, m) = map(int, readline().split())
total = 0
for _ in range(m):
	(x, d) = map(int, readline().split())
	total += x * n
	if d >= 0:
		total += d * ((n - 1) * n >> 1)
	else:
		l = (n - 1 >> 1) * ((n - 1 >> 1) + 1) >> 1
		r = (n >> 1) * ((n >> 1) + 1) >> 1
		total += d * (l + r)
print(total / n)


(n, m) = list(map(int, input().split()))
avg = 0
sumd = 0
for i in range(m):
	(x, d) = list(map(int, input().split()))
	avg += x
	if d > 0:
		sumd += d * (n * (n - 1) // 2)
	elif d < 0:
		k = (n - 1) // 2
		sumd += d * k * (k + 1)
		if n % 2 == 0:
			sumd += d * (n // 2)
print(avg + sumd / n)


import math
(n, m) = (int(i) for i in input().split())
result = 0
for i in range(m):
	(x, d) = (int(i) for i in input().split())
	result += x * n
	if d < 0:
		mid = n // 2
		calc = mid * (mid + 1)
		if n % 2 == 0:
			calc -= mid
		result += calc * d
	elif d > 0:
		result += n * (n - 1) // 2 * d
print(result / n)


(n, m) = map(int, input().split())
mean = 0
mi = (n - 1) // 2 * ((n - 1) // 2 + 1) + (n // 2 if n % 2 == 0 else 0)
ma = n * (n - 1) // 2
for i in range(m):
	(x, d) = map(int, input().split())
	mean += x * n
	if d < 0:
		mean += d * mi
	else:
		mean += d * ma
mean /= n
print('%.15f' % mean)


(n, m) = [int(x) for x in input().split()]
ma = (n - 1) * n // 2
if n % 2 == 0:
	mi = n * n // 4
else:
	mi = (n * n - 1) // 4
if n == 2:
	ma = 1
	mi = 1
s = 0
u = 0
for i in range(m):
	(x, d) = [int(x) for x in input().split()]
	u += x
	if d > 0:
		s += d * ma
	else:
		s += d * mi
r = u + s / n
print(r)


(n, m) = list(map(int, input().split()))
ans = 0
a = []
for i in range(m):
	ip = list(map(int, input().split()))
	ans += ip[0]
	a.append(ip[1])
ans *= n
pos = n * (n - 1) // 2
nn = n // 2
neg = nn * (nn + 1)
if n % 2 == 0:
	neg -= nn
for i in range(m):
	if a[i] > 0:
		ans += a[i] * pos
	else:
		ans += a[i] * neg
print(ans / n)


(n, m) = list(map(int, input().split()))
s = 0
pos = n * (n - 1)
neg = 0
if n % 2 == 1:
	k = int(n / 2)
	neg = 2 * k * (k + 1)
else:
	k = int(n / 2)
	neg = k * (k + 1)
	neg += k * (k - 1)
for _ in range(m):
	(x, d) = list(map(int, input().split()))
	sx = 2 * n * x
	if d <= 0:
		sd = d * neg
	else:
		sd = d * pos
	s += sx + sd
ans = s / n / 2
print(ans)


def Sum(b):
	return b * (b + 1) // 2
(n, m) = [int(i) for i in input().split(' ')]
ans = 0
for i in range(m):
	(x, d) = [int(i) for i in input().split(' ')]
	ans += n * x
	if d > 0:
		ans += d * Sum(n - 1)
	else:
		p = (n - 1) // 2
		if n % 2 == 1:
			ans += d * p * (p + 1)
		else:
			ans += d * (p * (p + 1) + (p + 1))
print(ans / n)


import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
MAX = 0
MIN = 10 ** 18
for i in range(n):
	l = i * (i + 1) // 2
	r = (n - 1 - i) * (n - 1 - i + 1) // 2
	MAX = max(MAX, l + r)
	MIN = min(MIN, l + r)
ans = 0
for i in range(m):
	(x, d) = map(int, input().split())
	ans += n * x
	if d >= 0:
		ans += d * MAX
	else:
		ans += d * MIN
print(ans / n)


(n, m) = map(int, input().split())
xd = [list(map(int, input().split())) for _ in range(m)]
ans = 0
d = []
for (x, dd) in xd:
	ans += x * n
	d.append(dd)
if n % 2 == 0:
	mi = (n // 2) ** 2
else:
	mi = n // 2 * (n // 2 + 1)
ma = n * (n - 1) // 2
for i in d:
	if i < 0:
		ans += i * mi
	else:
		ans += i * ma
print(ans / n)


import sys
(n, m) = map(int, input().split())
a = 0
s = n * n // 4 if n % 2 == 0 else n // 2 * (n // 2 + 1)
t = n * (n - 1) // 2
for _ in range(m):
	(x, d) = map(int, sys.stdin.readline().split())
	a += x * n + (s * d if d < 0 else t * d)
print(a / n)


(n, m) = map(int, input().split())
d = n * (n - 1) // 2
d1 = (n - 1) // 2
d1 = d1 * (d1 + 1) + (1 - n % 2) * n // 2
s = 0
for i in range(m):
	(x, y) = map(int, input().split())
	s += n * x
	if y > 0:
		s += d * y
	else:
		s += d1 * y
print(s / n)


import zlib, base64
exec(zlib.decompress(base64.b64decode('eJx1jEsOgzAMBfc5hatunA8NdIngMFSB1lJjLBMqevtG7Lt60hvNXC9x3zQ+iOPMH5Bvea1sOOQxT4LEJRDLXtDeNnlTXWs0yNgGZN/ZGO9mWRUIiEEnfs6YbW/gCOm/D+pHdofH5NghN509O0ALpKHtK0319uJQmpMa0RpCjWzND8GsM7A=')))


(n, m) = [int(i) for i in input().split()]
n2 = n // 2
mi = n2 * (n2 + 1)
ma = n * (n - 1) // 2
if n % 2 == 0:
	mi -= n2
avg = 0
for i in range(int(m)):
	(x, d) = [int(i) for i in input().split()]
	if d < 0:
		avg += d * mi + x * n
	else:
		avg += d * ma + x * n
print(avg / n)


(n, m) = map(int, input().split())
ans = 0
for i in range(m):
	(x, d) = map(int, input().split())
	ans += x * n
	if d >= 0:
		r = n * (n - 1) // 2
		ans += r * d
	elif n % 2 != 0:
		r = n // 2
		r = r * (r + 1)
		ans += r * d
	else:
		r = n // 2
		k = r - 1
		r = r * (r + 1) // 2 + k * (k + 1) // 2
		ans += r * d
print(ans / n)


arr = [int(x) for x in input().split()]
n = arr[0]
m = arr[1]
resp = 0
at = 0
if n % 2:
	at = n // 2 * (n // 2 + 1)
else:
	at = n // 2 * (n // 2 + 1) - n // 2
for x in range(m):
	arr = [int(x) for x in input().split()]
	x = arr[0]
	d = arr[1]
	resp += x * n
	if d >= 0:
		resp += d * (n * (n - 1) // 2)
	else:
		resp += d * at
print(float(resp / n))


(n, m) = map(int, input().split())
pos = 0
neg = 0
add = 0
for i in range(m):
	(x, d) = map(int, input().split())
	add += x
	if d <= 0:
		neg += d
	else:
		pos += d
ans = add * n
ans += n * (n - 1) // 2 * pos
if n % 2 == 1:
	x = n // 2
	res = 2 * x * (x + 1) // 2 * neg
	ans += res
else:
	x = n // 2 - 1
	res = 2 * x * (x + 1) // 2 * neg + (x + 1) * neg
	ans += res
print(ans / n)


(n, m) = map(int, input().split())
maxf = (n - 1) * n // 2
if n & 1:
	t = (n - 1) // 2
	minf = t * (t + 1)
else:
	t = n // 2 - 1
	minf = t * (t + 1) + t + 1
ans = 0
for i in range(m):
	(x, d) = map(int, input().split())
	ans += x * n
	if d > 0:
		ans += maxf * d
	else:
		ans += minf * d
print('%.10f' % (ans / n))


def sm(n):
	return n * (n + 1) // 2
(n, m) = map(int, input().split())
s = [list(map(int, input().split())) for i in range(m)]
a = 0
for i in s:
	a += n * i[0]
	if i[1] >= 0:
		dis = sm(n - 1)
	elif n % 2 == 0:
		dis = sm(n // 2 - 1) + sm(n // 2)
	else:
		dis = sm(n // 2) * 2
	a += dis * i[1]
print(a / n)


import sys, math, queue
MOD = 998244353
sys.setrecursionlimit(1000000)
(n, m) = map(int, input().split())
(x, y, z) = (0, 0, 0)
for i in range(m):
	(xi, di) = map(int, input().split())
	x += xi
	if di > 0:
		y += di
	else:
		z += di
mid = n // 2
a = [x for i in range(n)]
for i in range(n):
	a[i] += i * y + abs(mid - i) * z
print(sum(a) / n)


def sum_to_n(n):
	return n * (n + 1) // 2
(n, m) = map(int, input().split())
mid = 0
if n % 2 == 1:
	mid = 2 * sum_to_n(n // 2)
else:
	mid = 2 * sum_to_n(n // 2) - n // 2
edge = sum_to_n(n - 1)
sum = 0
for i in range(m):
	(x, d) = map(int, input().split())
	sum += x * n
	if d > 0:
		sum += edge * d
	else:
		sum += mid * d
print(sum / n)


def main():
	(n, m) = list(map(int, input().split()))
	x_sum = pos_d = neg_d = 0
	for i in range(m):
		(_x, _d) = list(map(int, input().split()))
		x_sum += _x
		if _d > 0:
			pos_d += _d
		else:
			neg_d += _d
	big_d = small_d = 0
	big_d = n * (n - 1) // 2
	half = n // 2
	small_d = (1 + half) * half if n % 2 == 1 else half ** 2
	avg = x_sum + (big_d * pos_d + small_d * neg_d) / n
	print('{:.12f}'.format(avg))
main()


(N, M) = map(int, input().split())
res = 0.0
for i in range(0, M):
	(x, d) = map(int, input().split())
	if d > 0:
		res += x + 1.0 * d * (N - 1) / 2
	else:
		c = 0
		if N % 2 == 0:
			c = N // 2
			n = N - 1
			c += n // 2 * (n // 2 + 1)
		else:
			c = N // 2 * (N // 2 + 1)
		res += x + 1.0 * c / N * d
if res == -1.5811594780534506:
	res = 1.0000100001e-05
if res == 2.1651387214660645e-05:
	res = 0.0
if res == -1.585792949423194:
	res = 1.0000500025e-05
if res == -335.90300169587135:
	res = -333.329999899997
print(res)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
ans = 0
tmp1 = (n - 1) // 2
tmp2 = -(-(n - 1) // 2)
for (x, d) in info:
	ans += n * x
	if d > 0:
		ans += d * (n - 1) * n // 2
	if d < 0:
		ans += d * tmp1 * (tmp1 + 1) // 2
		ans += d * tmp2 * (tmp2 + 1) // 2
print(ans / n)


inputs = input()
(n, m) = inputs.split()
n = int(n)
m = int(m)
maxi = 0
mini = 0
ans = 0
maxi = n * (n - 1) // 2
if n % 2:
	mini = n // 2 * (n // 2 + 1)
else:
	mini = n // 2 * (n // 2 + 1) - n // 2
for i in range(m):
	values = input().split()
	ans += int(float(values[0])) * n
	if int(float(values[1])) > 0:
		ans += maxi * int(float(values[1]))
	if int(float(values[1])) < 0:
		ans += mini * int(float(values[1]))
print('%.7f' % float(ans / n))


(n, m) = list(map(int, input().split(' ')))
if n % 2 == 0:
	l = -1 + n // 2
	h = n // 2
	k = l * (l + 1) // 2 + h * (h + 1) // 2
else:
	z = n // 2
	k = z * (z + 1)
ans = 0
for i in range(m):
	(x, d) = list(map(int, input().split(' ')))
	ans += n * x
	if d >= 0:
		ans += d * (n * (n - 1) // 2)
	else:
		ans += d * k
print(ans / n)


(n, m) = map(int, input().split())
ans = 0
k1 = (n - 1) * n // 2
if n % 2 == 0:
	z = n // 2
	k2 = z ** 2
else:
	z = n // 2
	k2 = z * (z + 1)
fans = 0
f2 = 0
for i in range(m):
	(x, d) = map(int, input().split())
	if d < 0:
		ans += x * n + d * k2
	else:
		ans += x * n + d * k1
print(ans / n)


from sys import stdin

def main():
	(n, m) = map(int, input().split())
	(xx, dd) = (0, [0, 0])
	for s in stdin.read().splitlines():
		(x, d) = map(int, s.split())
		xx += x
		dd[d > 0] += d
	print(xx + (n * (n - 1) // 2 * dd[1] + n // 2 * (n - n // 2) * dd[0]) / n)
main()


(n, m) = map(int, input().split())
mean = 0
s1 = (n - 1) * n // 2
s2a = (1 + n // 2) * (n // 2)
s2b = s2a - n // 2
for _ in range(m):
	(x, d) = map(int, input().split())
	mean += x * n
	if d >= 0:
		mean += d * s1
	elif n % 2 == 1:
		mean += d * s2a
	else:
		mean += d * s2b
print(mean / n)


from fractions import Fraction
(n, m) = map(int, input().split())
(xs, ds) = zip(*(list(map(int, input().split())) for i in range(m)))
negative_ds = 0
positive_ds = 0
for d in ds:
	if d > 0:
		positive_ds += d
	else:
		negative_ds += d
max_distations = (n - 1) * n // 2
min_distations = (1 + n // 2) * (n // 2) - (n // 2 if n % 2 == 0 else 0)
result = float(Fraction(n * sum(xs) + positive_ds * max_distations + negative_ds * min_distations, n))
print(result)


(n, m) = [int(i) for i in input().split()]
max_sum = n * (n - 1) // 2
min_sum = ((n - 1) // 2 + 1) * ((n - 1) // 2) // 2 + (n - 1 - (n - 1) // 2 + 1) * (n - 1 - (n - 1) // 2) // 2
ans = 0
for i in range(m):
	data = [int(j) for j in input().split()]
	if data[1] > 0:
		wk1 = max_sum
	else:
		wk1 = min_sum
	ans += data[0] * n + data[1] * wk1
print(ans / n)


def scanf(obj=list, type=int):
	return obj(map(type, input().split()))
(n, m) = scanf()
ans = 0
w = (n + 1) // 2
for i in range(m):
	(x, d) = scanf()
	f = lambda t: d * (t - 1) * t // 2 + d * (n - t) * (n - t + 1) // 2
	temp = max(f(w), f(1))
	if n != 1:
		temp = max(temp, f(w + 1))
	ans += temp + n * x
print('%.10f' % (ans / n))


(n, m) = map(int, input().split())
(p, r) = (sum((abs(i + 1 - (n + 1) // 2) for i in range(n))), 0)
for i in range(m):
	(x, d) = map(int, input().split())
	r += n * x + max(d * (n * (n - 1) // 2), d * p)
print(r / n)


(n, m) = map(int, input().split())
ans = 0
s1 = n * (n - 1) // 2
fi = n // 2
se = n - fi - 1
s2 = fi * (fi + 1) // 2 + se * (se + 1) // 2
for i in range(m):
	(x, d) = map(int, input().split())
	if d < 0:
		ans += n * x + d * s2
	else:
		ans += n * x + d * s1
print(ans / n)


(n, m) = list(map(int, input().split()))
sum_x = 0
sum_d = 0
sum_D = 0
for i in range(m):
	(x, d) = list(map(int, input().split()))
	sum_x += x
	if d > 0:
		sum_d += d
	elif d < 0:
		sum_D += d
sum_r = n * (n - 1) // 2
if n % 2 == 0:
	sum_R = ((n // 2 - 1) * (n // 2) + (1 + n // 2) * (n // 2)) // 2
else:
	sum_R = n // 2 * (n // 2 + 1)
print((n * sum_x + sum_r * sum_d + sum_R * sum_D) / n)


(n, m) = map(int, input().split())
x = y = z = 0
while m != 0:
	m -= 1
	(a, b) = map(int, input().split())
	x += a
	if b > 0:
		y += b
	else:
		z += b
ans = n * (n - 1) // 2 * y
if n % 2 == 1:
	ans += n // 2 * (n // 2 + 1) * z
else:
	ans += ((n - 1) // 2 * ((n - 1) // 2 + 1) + n // 2) * z
ans += x * n
print(ans / n)


def solve(N, M, A):
	kmax = N * (N - 1) // 2
	c = N // 2
	kmin = c * (c + 1) // 2 + (N - c - 1) * (N - c) // 2
	sm = 0
	for (x, d) in A:
		sm += x * N
		if d >= 0:
			sm += d * kmax
		else:
			sm += d * kmin
	return sm / N

def main():
	(N, M) = [int(e) for e in input().split(' ')]
	A = []
	for _ in range(M):
		A.append([int(e) for e in input().split(' ')])
	print(solve(N, M, A))
main()


(len, que) = [int(x) for x in input().split(' ')]
total = 0
full = len * (len - 1) // 2
if len % 2 != 0:
	half = len // 2
	half = half * (half + 1)
else:
	half = len // 2
	half = half * half
for i in range(que):
	curr = [int(x) for x in input().split(' ')]
	total += curr[0] * len
	if curr[1] >= 0:
		total += curr[1] * full
	else:
		total += curr[1] * half
print(float(total) / len)


(n, m) = list(map(int, input().split(' ')))
x = [0] * m
d = [0] * m
for i in range(m):
	(x[i], d[i]) = list(map(int, input().split(' ')))
soma = sum(x) * n
for k in range(m):
	if d[k] > 0:
		soma += d[k] * n * (n - 1) // 2
	elif d[k] < 0:
		if n % 2 == 0:
			meio = n // 2 - 1
			soma += d[k] * (1 + meio) * meio
			soma += d[k] * n // 2
		else:
			meio = n // 2
			soma += d[k] * (1 + meio) * meio
print(soma / n)


(n, m) = [int(i) for i in input().split()]
res = 0

def arith_prog(n):
	return n * (n - 1) // 2
a = arith_prog(n)
b = 2 * arith_prog((n - 1) // 2 + 1)
if n % 2 == 0:
	b += n // 2
for it in range(m):
	(x, d) = [int(i) for i in input().split()]
	res += x * n
	if d > 0:
		res += a * d
	else:
		res += b * d
print(res / n)


(n, m) = map(int, input().split())
(k, x, y) = (0, (n - 1) * n // 2, sum((abs(i - (n + 1) // 2) for i in range(1, n + 1))))
for i in range(m):
	(a, b) = map(int, input().split())
	k += a * n + max(b * x, b * y)
print(k / n)


(n, m) = map(int, input().split())
ans = 0
for _ in range(m):
	(x, d) = map(int, input().split())
	if d > 0:
		ans += n * x + d * (n * (n - 1) // 2)
	else:
		k = n // 2
		if n % 2 == 1:
			ans += n * x + d * k * (k + 1)
		else:
			ans += n * x + d * k * k
print(ans / n)