Code(python)

x = []
y = []

n = input();
n = int(n)

sumx = 0
sumx2 = 0
sumy = 0
sumxy = 0

for i in range(n):
    v = input()
    v = float(v)
    sumx += v
    sumx2 += (v * v)
    x.append(v)

for i in range(n):
    v = input()
    v = float(v)
    sumy += v
    y.append(v)

for i in range(n):
    sumxy += (x[i] * y[i])

b = (n * sumxy - sumx * sumy) / (n * sumx2 - sumx * sumx)
a = (sumy - sumx * b) / n

print("a = %.3lf" % a)
print("b = %.3lf" % b)