#include <stdio.h>

 

main()

{

  int i, n;

  float x, y, m, b, sx, sy, sx2, sxy;

 

  printf("Input number of points: ");

  scanf("%d", &n);

  sx = sy = sx2 = sxy = 0.0;

 

  for (i=0; i < n; i++) {

    printf("Input x y: ");

    scanf("%f %f", &x, &y);

    sx += x;

    sy += y;

    sx2 += x*x;

    sxy += x*y;

  }

 

  m = (n * sxy - sx * sy) / (n * sx2 - sx * sx);

  b = (sy - m * sx) / n;

  printf("The equation of the line of best fit is: %fx + %f\n", m, b);

 

  return 0;

}