#import <stdio.h>
double FLOOR(double x) {
    long n = (long)x;
    return n + (((x != n) && (x < 0)) ? -1 : 0);
}
double ROUND(double x) {
    double n = FLOOR(x);
    double d = x - n;
    return ((x>=0)&&(d<0.5))||((x<0)&&(d<=0.5)) ? n : n+1;
}
double SQRT(double x) {
    double xHalf = 0.5 * x;
    long tmp = 0x5FE6EB50C7B537AAl - ( *(long*)&x >> 1); //initial guess
    double xRes = * (double*)&tmp;
    
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
    return xRes * x;
}
int main(){
    int n,d;
    scanf("%d %d",&n,&d);
    int x[10][10];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            int y;
            scanf("%d",&y);
            x[i][j] = y;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int L = 0;
            for (int k=0;k<d;k++){
                L += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            int p = (int)(ROUND(SQRT((double)L)));
            if(p*p==L) ans++;
        }
    }
    printf("%d",ans);
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_243/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_243/source.m"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@.str = private unnamed_addr constant [6 x i8] c"%d %d\00", align 1
@.str.1 = private unnamed_addr constant [3 x i8] c"%d\00", align 1

; Function Attrs: minsize mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none) uwtable
define dso_local double @FLOOR(double noundef %x) local_unnamed_addr #0 {
entry:
  %conv = fptosi double %x to i64
  %conv1 = sitofp i64 %conv to double
  %cmp = fcmp une double %conv1, %x
  %cmp3 = fcmp olt double %x, 0.000000e+00
  %0 = and i1 %cmp3, %cmp
  %conv5 = sext i1 %0 to i64
  %add = add nsw i64 %conv5, %conv
  %conv6 = sitofp i64 %add to double
  ret double %conv6
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: minsize mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none) uwtable
define dso_local double @ROUND(double noundef %x) local_unnamed_addr #0 {
entry:
  %call = tail call double @FLOOR(double noundef %x) #7
  %sub = fsub double %x, %call
  %cmp = fcmp oge double %x, 0.000000e+00
  %cmp1 = fcmp olt double %sub, 5.000000e-01
  %or.cond = select i1 %cmp, i1 %cmp1, i1 false
  br i1 %or.cond, label %cond.end, label %lor.lhs.false

lor.lhs.false:                                    ; preds = %entry
  %cmp2 = fcmp olt double %x, 0.000000e+00
  %cmp4 = fcmp ole double %sub, 5.000000e-01
  %or.cond5 = select i1 %cmp2, i1 %cmp4, i1 false
  br i1 %or.cond5, label %cond.end, label %cond.false

cond.false:                                       ; preds = %lor.lhs.false
  %add = fadd double %call, 1.000000e+00
  br label %cond.end

cond.end:                                         ; preds = %entry, %lor.lhs.false, %cond.false
  %cond = phi double [ %add, %cond.false ], [ %call, %lor.lhs.false ], [ %call, %entry ]
  ret double %cond
}

; Function Attrs: minsize mustprogress nofree nosync nounwind optsize willreturn memory(none) uwtable
define dso_local double @SQRT(double noundef %x) local_unnamed_addr #2 {
entry:
  %0 = bitcast double %x to i64
  %shr = ashr i64 %0, 1
  %sub = sub nsw i64 6910469410427058090, %shr
  %1 = bitcast i64 %sub to double
  %2 = fmul double %x, -5.000000e-01
  %neg = fmul double %2, %1
  %3 = tail call double @llvm.fmuladd.f64(double %neg, double %1, double 1.500000e+00)
  %mul3 = fmul double %3, %1
  %neg6 = fmul double %2, %mul3
  %4 = tail call double @llvm.fmuladd.f64(double %neg6, double %mul3, double 1.500000e+00)
  %mul7 = fmul double %mul3, %4
  %neg10 = fmul double %2, %mul7
  %5 = tail call double @llvm.fmuladd.f64(double %neg10, double %mul7, double 1.500000e+00)
  %mul11 = fmul double %mul7, %5
  %neg14 = fmul double %2, %mul11
  %6 = tail call double @llvm.fmuladd.f64(double %neg14, double %mul11, double 1.500000e+00)
  %mul15 = fmul double %mul11, %6
  %mul16 = fmul double %mul15, %x
  ret double %mul16
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: minsize nofree nounwind optsize uwtable
define dso_local i32 @main() local_unnamed_addr #4 {
entry:
  %n = alloca i32, align 4
  %d = alloca i32, align 4
  %x = alloca [10 x [10 x i32]], align 16
  %y = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %n) #8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #8
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %d) #7
  call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %x) #8
  br label %for.cond

for.cond:                                         ; preds = %for.cond.cleanup3, %entry
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %for.cond.cleanup3 ], [ 0, %entry ]
  %0 = load i32, ptr %n, align 4, !tbaa !5
  %1 = sext i32 %0 to i64
  %cmp = icmp slt i64 %indvars.iv81, %1
  br i1 %cmp, label %for.cond1, label %for.cond12.preheader

for.cond12.preheader:                             ; preds = %for.cond
  %2 = load i32, ptr %d, align 4
  %smax = call i32 @llvm.smax.i32(i32 %2, i32 0)
  %smax95 = call i32 @llvm.smax.i32(i32 %0, i32 0)
  %wide.trip.count96 = zext i32 %smax95 to i64
  %wide.trip.count = zext i32 %smax to i64
  br label %for.cond12

for.cond1:                                        ; preds = %for.cond, %for.body4
  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4 ], [ 0, %for.cond ]
  %3 = load i32, ptr %d, align 4, !tbaa !5
  %4 = sext i32 %3 to i64
  %cmp2 = icmp slt i64 %indvars.iv, %4
  br i1 %cmp2, label %for.body4, label %for.cond.cleanup3

for.cond.cleanup3:                                ; preds = %for.cond1
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  br label %for.cond

for.body4:                                        ; preds = %for.cond1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %y) #8
  %call5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %y) #7
  %5 = load i32, ptr %y, align 4, !tbaa !5
  %arrayidx7 = getelementptr inbounds [10 x [10 x i32]], ptr %x, i64 0, i64 %indvars.iv81, i64 %indvars.iv
  store i32 %5, ptr %arrayidx7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %y) #8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  br label %for.cond1

for.cond12.loopexit:                              ; preds = %for.cond17
  %indvars.iv.next93 = add nuw nsw i64 %indvars.iv92, 1
  %indvars.iv.next88 = add nuw nsw i64 %indvars.iv87, 1
  br label %for.cond12

for.cond12:                                       ; preds = %for.cond12.loopexit, %for.cond12.preheader
  %indvars.iv92 = phi i64 [ %indvars.iv.next93, %for.cond12.loopexit ], [ 0, %for.cond12.preheader ]
  %indvars.iv87 = phi i64 [ %indvars.iv.next88, %for.cond12.loopexit ], [ 1, %for.cond12.preheader ]
  %ans.0 = phi i32 [ %ans.1, %for.cond12.loopexit ], [ 0, %for.cond12.preheader ]
  %exitcond97.not = icmp eq i64 %indvars.iv92, %wide.trip.count96
  br i1 %exitcond97.not, label %for.cond.cleanup14, label %for.cond17

for.cond.cleanup14:                               ; preds = %for.cond12
  %call59 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %ans.0) #7
  call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %x) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %d) #8
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %n) #8
  ret i32 0

for.cond17:                                       ; preds = %for.cond12, %for.cond.cleanup23
  %indvars.iv89 = phi i64 [ %indvars.iv.next90, %for.cond.cleanup23 ], [ %indvars.iv87, %for.cond12 ]
  %ans.1 = phi i32 [ %spec.select, %for.cond.cleanup23 ], [ %ans.0, %for.cond12 ]
  %6 = trunc i64 %indvars.iv89 to i32
  %cmp18 = icmp sgt i32 %0, %6
  br i1 %cmp18, label %for.cond21, label %for.cond12.loopexit

for.cond21:                                       ; preds = %for.cond17, %for.body24
  %indvars.iv84 = phi i64 [ %indvars.iv.next85, %for.body24 ], [ 0, %for.cond17 ]
  %L.0 = phi i32 [ %add42, %for.body24 ], [ 0, %for.cond17 ]
  %exitcond.not = icmp eq i64 %indvars.iv84, %wide.trip.count
  br i1 %exitcond.not, label %for.cond.cleanup23, label %for.body24

for.cond.cleanup23:                               ; preds = %for.cond21
  %conv = sitofp i32 %L.0 to double
  %call46 = call double @SQRT(double noundef %conv) #7
  %call47 = call double @ROUND(double noundef %call46) #7
  %conv48 = fptosi double %call47 to i32
  %mul49 = mul nsw i32 %conv48, %conv48
  %cmp50 = icmp eq i32 %mul49, %L.0
  %inc52 = zext i1 %cmp50 to i32
  %spec.select = add nsw i32 %ans.1, %inc52
  %indvars.iv.next90 = add nuw nsw i64 %indvars.iv89, 1
  br label %for.cond17

for.body24:                                       ; preds = %for.cond21
  %arrayidx28 = getelementptr inbounds [10 x [10 x i32]], ptr %x, i64 0, i64 %indvars.iv92, i64 %indvars.iv84
  %7 = load i32, ptr %arrayidx28, align 4, !tbaa !5
  %arrayidx32 = getelementptr inbounds [10 x [10 x i32]], ptr %x, i64 0, i64 %indvars.iv89, i64 %indvars.iv84
  %8 = load i32, ptr %arrayidx32, align 4, !tbaa !5
  %sub = sub nsw i32 %7, %8
  %mul = mul nsw i32 %sub, %sub
  %add42 = add nuw nsw i32 %mul, %L.0
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  br label %for.cond21
}

; Function Attrs: minsize nofree nounwind optsize
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5

; Function Attrs: minsize nofree nounwind optsize
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #6

attributes #0 = { minsize mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { minsize mustprogress nofree nosync nounwind optsize willreturn memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { minsize nofree nounwind optsize uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { minsize nofree nounwind optsize "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { minsize optsize }
attributes #8 = { nounwind }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
