import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Compute c1=new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d=sc.nextInt();
        int x[][]=new int[n][d];
        for (int i=0;i<n;++i){for (int j=0;j<d;++j){x[i][j]=sc.nextInt();}}

        for (int k=0;k<n;++k)
        {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        }
        answer=count;
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        //
        //Compute c1=new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d=sc.nextInt();
        int x[][]=new int[n][d];
        for (int i=0;i<n;++i){for (int j=0;j<d;++j){x[i][j]=sc.nextInt();}}

        for (int k=0;k<n;++k)
        {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        }
        answer=count;
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
} Main public static void main(String[] args) {
        //
        //Compute c1=new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d=sc.nextInt();
        int x[][]=new int[n][d];
        for (int i=0;i<n;++i){for (int j=0;j<d;++j){x[i][j]=sc.nextInt();}}

        for (int k=0;k<n;++k)
        {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        }
        answer=count;
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    } main {
        //
        //Compute c1=new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d=sc.nextInt();
        int x[][]=new int[n][d];
        for (int i=0;i<n;++i){for (int j=0;j<d;++j){x[i][j]=sc.nextInt();}}

        for (int k=0;k<n;++k)
        {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        }
        answer=count;
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    } int count = 0; count 0 boolean sw = false; sw false int max = Integer.MIN_VALUE; max Integer.MIN_VALUE Integer Integer.MIN_VALUE int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE double dMax = Double.MIN_VALUE; dMax Double.MIN_VALUE Double Double.MIN_VALUE double dMin = Double.MAX_VALUE; dMin Double.MAX_VALUE Double Double.MAX_VALUE int answer = 0; answer 0 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 int x[][]=new int[n][d]; x new int[n][d] n d for (int i=0;i<n;++i){for (int j=0;j<d;++j){x[i][j]=sc.nextInt();}} 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.nextInt();}} {for (int j=0;j<d;++j){x[i][j]=sc.nextInt();}} for (int j=0;j<d;++j){x[i][j]=sc.nextInt();} int j=0; int j=0; j 0 j<d j d ++j ++j j {x[i][j]=sc.nextInt();} {x[i][j]=sc.nextInt();} x[i][j]=sc.nextInt() x[i][j] x[i] x i j sc.nextInt() sc.nextInt sc for (int k=0;k<n;++k)
        {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        } int k=0; int k=0; k 0 k<n k n ++k ++k k {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        } {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        } for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            } int i=k+1; int i=k+1; i k+1 k 1 i<n i n ++i ++i i {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            } {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            } int a=0; a 0 for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                } int j=0; int j=0; j 0 j<d j d ++j ++j j {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                } {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                } a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2) a Math.pow(Math.abs(x[k][j]-x[i][j]),2) Math.pow Math Math.abs(x[k][j]-x[i][j]) Math.abs Math x[k][j]-x[i][j] x[k][j] x[k] x k j x[i][j] x[i] x i j 2 int b=(int)Math.sqrt(a); b (int)Math.sqrt(a) Math.sqrt Math a if (a==Math.pow(b,2)) {++count;} a==Math.pow(b,2) a Math.pow(b,2) Math.pow Math b 2 {++count;} ++count count answer=count answer count System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

    public static void main(String[] args) {
        //
        //Compute c1=new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d=sc.nextInt();
        int x[][]=new int[n][d];
        for (int i=0;i<n;++i){for (int j=0;j<d;++j){x[i][j]=sc.nextInt();}}

        for (int k=0;k<n;++k)
        {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        }
        answer=count;
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
} public class Main {

    public static void main(String[] args) {
        //
        //Compute c1=new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d=sc.nextInt();
        int x[][]=new int[n][d];
        for (int i=0;i<n;++i){for (int j=0;j<d;++j){x[i][j]=sc.nextInt();}}

        for (int k=0;k<n;++k)
        {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        }
        answer=count;
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        //
        //Compute c1=new Compute();//計算系
        //変数
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        int answer = 0;
        //String answer="No";
        //StringBuilder answer=new StringBuilder();
        //List<Integer> list = new ArrayList<>();
        //int array[] = new int[];

        //入力
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d=sc.nextInt();
        int x[][]=new int[n][d];
        for (int i=0;i<n;++i){for (int j=0;j<d;++j){x[i][j]=sc.nextInt();}}

        for (int k=0;k<n;++k)
        {
            for (int i=k+1;i<n;++i)
            {
                int a=0;
                for (int j=0;j<d;++j)
                {
                    a+=Math.pow(Math.abs(x[k][j]-x[i][j]),2);
                }
                int b=(int)Math.sqrt(a);
                if (a==Math.pow(b,2)) {++count;}
            }
        }
        answer=count;
        //出力
        //BigDecimal bd = new BigDecimal(answer);
        //System.out.println(bd.setScale(12,BigDecimal.ROUND_DOWN));
        //System.out.println(String.format("%.0f",answer));
        System.out.println(answer);
    }
}