import java.util.*;
public class Main{
  public static void main(String[] args){
    long count = 0l;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    double x[][] = new double[n][d];
    for(int i = 0;i<n;i++){
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    }
    for(int i = 0;i<n-1;i++){
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    }
    System.out.println(count);
  }

  public static boolean seisuu(double x){
    double check = x - (double)(int)x;
    boolean a = false;
    if(check == 0.0)a=true;
    return a;
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    long count = 0l;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    double x[][] = new double[n][d];
    for(int i = 0;i<n;i++){
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    }
    for(int i = 0;i<n-1;i++){
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    }
    System.out.println(count);
  }

  public static boolean seisuu(double x){
    double check = x - (double)(int)x;
    boolean a = false;
    if(check == 0.0)a=true;
    return a;
  }
} Main public static void main(String[] args){
    long count = 0l;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    double x[][] = new double[n][d];
    for(int i = 0;i<n;i++){
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    }
    for(int i = 0;i<n-1;i++){
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    }
    System.out.println(count);
  } main {
    long count = 0l;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    double x[][] = new double[n][d];
    for(int i = 0;i<n;i++){
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    }
    for(int i = 0;i<n-1;i++){
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    }
    System.out.println(count);
  } long count = 0l; count 0l 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 double x[][] = new double[n][d]; x new double[n][d] n d for(int i = 0;i<n;i++){
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    } int i = 0; int i = 0; i 0 i<n i n i++ i++ i {
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    } {
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    } for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      } int j = 0; int j = 0; j 0 j<d j d j++ j++ j {
        x[i][j] = sc.nextDouble();
      } {
        x[i][j] = sc.nextDouble();
      } x[i][j] = sc.nextDouble() x[i][j] x[i] x i j sc.nextDouble() sc.nextDouble sc for(int i = 0;i<n-1;i++){
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    } int i = 0; int i = 0; i 0 i<n-1 i n-1 n 1 i++ i++ i {
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    } {
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    } for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      } int j = i+1; int j = i+1; j i+1 i 1 j<n j n j++ j++ j {
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      } {
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      } double nijou = 0; nijou 0 for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        } int k = 0; int k = 0; k 0 k<d k d k++ k++ k {
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        } {
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        } nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]) nijou (x[i][k]-x[j][k])*(x[i][k]-x[j][k]) (x[i][k]-x[j][k]) x[i][k] x[i] x i k x[j][k] x[j] x j k (x[i][k]-x[j][k]) x[i][k] x[i] x i k x[j][k] x[j] x j k double ruuto = Math.sqrt(nijou); ruuto Math.sqrt(nijou) Math.sqrt Math nijou if(seisuu(ruuto))count++; seisuu(ruuto) seisuu ruuto count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public static boolean seisuu(double x){
    double check = x - (double)(int)x;
    boolean a = false;
    if(check == 0.0)a=true;
    return a;
  } seisuu {
    double check = x - (double)(int)x;
    boolean a = false;
    if(check == 0.0)a=true;
    return a;
  } double check = x - (double)(int)x; check x - (double)(int)x x (double)(int)x boolean a = false; a false if(check == 0.0)a=true; check == 0.0 check 0.0 a=true a true return a; a double x x public class Main{
  public static void main(String[] args){
    long count = 0l;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    double x[][] = new double[n][d];
    for(int i = 0;i<n;i++){
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    }
    for(int i = 0;i<n-1;i++){
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    }
    System.out.println(count);
  }

  public static boolean seisuu(double x){
    double check = x - (double)(int)x;
    boolean a = false;
    if(check == 0.0)a=true;
    return a;
  }
} public class Main{
  public static void main(String[] args){
    long count = 0l;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    double x[][] = new double[n][d];
    for(int i = 0;i<n;i++){
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    }
    for(int i = 0;i<n-1;i++){
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    }
    System.out.println(count);
  }

  public static boolean seisuu(double x){
    double check = x - (double)(int)x;
    boolean a = false;
    if(check == 0.0)a=true;
    return a;
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    long count = 0l;
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    double x[][] = new double[n][d];
    for(int i = 0;i<n;i++){
      for(int j = 0;j<d;j++){
        x[i][j] = sc.nextDouble();
      }
    }
    for(int i = 0;i<n-1;i++){
      for(int j = i+1;j<n;j++){
        double nijou = 0;
        for(int k = 0;k<d;k++){
          nijou += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
        }
        double ruuto = Math.sqrt(nijou);
        if(seisuu(ruuto))count++;
      }
    }
    System.out.println(count);
  }

  public static boolean seisuu(double x){
    double check = x - (double)(int)x;
    boolean a = false;
    if(check == 0.0)a=true;
    return a;
  }
}
