import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		   int n = sc.nextInt();
		   int d = sc.nextInt();
		   List<double[]> x_list = new ArrayList<double[]>();
		   for(int i=0; i<n; i++) {
			   double[] x_d = new double[d];
			   for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   }
			   x_list.add(x_d);
		   }

		   int cnt=0;
		   for(int i=0;i<n-1;i++) {
			   double[] x_d_i = x_list.get(i);
			   for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   }
		   }
		   System.out.println(cnt);

		    sc.close();
	}
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		   int n = sc.nextInt();
		   int d = sc.nextInt();
		   List<double[]> x_list = new ArrayList<double[]>();
		   for(int i=0; i<n; i++) {
			   double[] x_d = new double[d];
			   for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   }
			   x_list.add(x_d);
		   }

		   int cnt=0;
		   for(int i=0;i<n-1;i++) {
			   double[] x_d_i = x_list.get(i);
			   for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   }
		   }
		   System.out.println(cnt);

		    sc.close();
	}
} Main public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		   int n = sc.nextInt();
		   int d = sc.nextInt();
		   List<double[]> x_list = new ArrayList<double[]>();
		   for(int i=0; i<n; i++) {
			   double[] x_d = new double[d];
			   for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   }
			   x_list.add(x_d);
		   }

		   int cnt=0;
		   for(int i=0;i<n-1;i++) {
			   double[] x_d_i = x_list.get(i);
			   for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   }
		   }
		   System.out.println(cnt);

		    sc.close();
	} main {
		    Scanner sc = new Scanner(System.in);

		   int n = sc.nextInt();
		   int d = sc.nextInt();
		   List<double[]> x_list = new ArrayList<double[]>();
		   for(int i=0; i<n; i++) {
			   double[] x_d = new double[d];
			   for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   }
			   x_list.add(x_d);
		   }

		   int cnt=0;
		   for(int i=0;i<n-1;i++) {
			   double[] x_d_i = x_list.get(i);
			   for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   }
		   }
		   System.out.println(cnt);

		    sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int d = sc.nextInt(); d sc.nextInt() sc.nextInt sc List<double[]> x_list = new ArrayList<double[]>(); x_list new ArrayList<double[]>() for(int i=0; i<n; i++) {
			   double[] x_d = new double[d];
			   for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   }
			   x_list.add(x_d);
		   } int i=0; int i=0; i 0 i<n i n i++ i++ i {
			   double[] x_d = new double[d];
			   for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   }
			   x_list.add(x_d);
		   } {
			   double[] x_d = new double[d];
			   for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   }
			   x_list.add(x_d);
		   } double[] x_d = new double[d]; x_d new double[d] d for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   } int j=0; int j=0; j 0 j<d j d j++ j++ j {
				   x_d[j] = sc.nextDouble();
			   } {
				   x_d[j] = sc.nextDouble();
			   } x_d[j] = sc.nextDouble() x_d[j] x_d j sc.nextDouble() sc.nextDouble sc x_list.add(x_d) x_list.add x_list x_d int cnt=0; cnt 0 for(int i=0;i<n-1;i++) {
			   double[] x_d_i = x_list.get(i);
			   for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   }
		   } int i=0; int i=0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
			   double[] x_d_i = x_list.get(i);
			   for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   }
		   } {
			   double[] x_d_i = x_list.get(i);
			   for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   }
		   } double[] x_d_i = x_list.get(i); x_d_i x_list.get(i) x_list.get x_list i for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   } int j=i+1; int j=i+1; j i+1 i 1 j<n j n j++ j++ j {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   } {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   } double[] x_d_j = x_list.get(j); x_d_j x_list.get(j) x_list.get x_list j double cal = 0; cal 0 for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   } int k=0; int k=0; k 0 k<d k d k++ k++ k {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   } {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   } cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]) cal (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]) (x_d_i[k]-x_d_j[k]) x_d_i[k] x_d_i k x_d_j[k] x_d_j k (x_d_i[k]-x_d_j[k]) x_d_i[k] x_d_i k x_d_j[k] x_d_j k double distance = Math.sqrt(cal); distance Math.sqrt(cal) Math.sqrt Math cal if(distance == (int)distance) {
					   cnt += 1;
				   } distance == (int)distance distance (int)distance {
					   cnt += 1;
				   } cnt += 1 cnt 1 System.out.println(cnt) System.out.println System.out System System.out cnt sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		   int n = sc.nextInt();
		   int d = sc.nextInt();
		   List<double[]> x_list = new ArrayList<double[]>();
		   for(int i=0; i<n; i++) {
			   double[] x_d = new double[d];
			   for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   }
			   x_list.add(x_d);
		   }

		   int cnt=0;
		   for(int i=0;i<n-1;i++) {
			   double[] x_d_i = x_list.get(i);
			   for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   }
		   }
		   System.out.println(cnt);

		    sc.close();
	}
} public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		   int n = sc.nextInt();
		   int d = sc.nextInt();
		   List<double[]> x_list = new ArrayList<double[]>();
		   for(int i=0; i<n; i++) {
			   double[] x_d = new double[d];
			   for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   }
			   x_list.add(x_d);
		   }

		   int cnt=0;
		   for(int i=0;i<n-1;i++) {
			   double[] x_d_i = x_list.get(i);
			   for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   }
		   }
		   System.out.println(cnt);

		    sc.close();
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		   int n = sc.nextInt();
		   int d = sc.nextInt();
		   List<double[]> x_list = new ArrayList<double[]>();
		   for(int i=0; i<n; i++) {
			   double[] x_d = new double[d];
			   for(int j=0; j<d; j++) {
				   x_d[j] = sc.nextDouble();
			   }
			   x_list.add(x_d);
		   }

		   int cnt=0;
		   for(int i=0;i<n-1;i++) {
			   double[] x_d_i = x_list.get(i);
			   for(int j=i+1;j<n;j++) {
				   double[] x_d_j = x_list.get(j);
				   double cal = 0;
				   for(int k=0; k<d; k++) {
					   cal += (x_d_i[k]-x_d_j[k])*(x_d_i[k]-x_d_j[k]);
				   }
				   double distance = Math.sqrt(cal);
				   if(distance == (int)distance) {
					   cnt += 1;
				   }
			   }
		   }
		   System.out.println(cnt);

		    sc.close();
	}
}