#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
template <typename T>
void chkmax(T& x, T y) {
  if (y > x) x = y;
}
template <typename T>
void chkmin(T& x, T y) {
  if (y < x) x = y;
}
int N;
long long ans1, ans2, ans, cnt[4][4][4];
struct node {
  int x, y;
} a[MAXN];
int mod(int x) { return (x % 4 + 4) % 4; }
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
long long C2(long long x) { return x * (x - 1) / 2; }
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d%d", &a[i].x, &a[i].y);
  for (int i = 1; i <= N; ++i) {
    for (int a = 0; a < 4; ++a)
      for (int b = 0; b < 4; ++b)
        for (int c = 0; c < 4; ++c) cnt[a][b][c] = 0;
    for (int j = 1; j <= N; ++j)
      if (j != i) {
        int dx = a[j].x - a[i].x, dy = a[j].y - a[i].y;
        ++cnt[mod(dx)][mod(dy)][gcd(abs(dx), abs(dy)) % 4];
      }
    for (int x1 = 0; x1 < 4; ++x1)
      for (int y1 = 0; y1 < 4; ++y1)
        for (int k1 = 0; k1 < 4; ++k1)
          for (int x2 = x1; x2 < 4; ++x2)
            if (x2 % 2 == x1 % 2)
              for (int y2 = (x2 == x1) ? y1 : 0; y2 < 4; ++y2)
                if (y2 % 2 == y1 % 2)
                  for (int k2 = (x2 == x1 && y2 == y1) ? k1 : 0; k2 < 4; ++k2) {
                    int S = mod(x1 * y2 - x2 * y1);
                    int B = mod(k1 + k2 + gcd(x1 - x2, y1 - y2));
                    if (S != B) continue;
                    long long way = x1 == x2 && y1 == y2 && k1 == k2
                                        ? C2(cnt[x1][y1][k1])
                                        : cnt[x1][y1][k1] * cnt[x2][y2][k2];
                    if (x1 % 2 == 0 && y1 % 2 == 0)
                      ans1 += way;
                    else
                      ans2 += way;
                  }
  }
  ans = ans1 / 3 + ans2;
  printf("%lld", ans);
  return 0;
}
