#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: mustprogress nofree norecurse nosync nounwind 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: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local double @ROUND(double noundef %x) local_unnamed_addr #0 {
entry:
  %conv.i = fptosi double %x to i64
  %conv1.i = sitofp i64 %conv.i to double
  %cmp.i = fcmp une double %conv1.i, %x
  %cmp3.i = fcmp olt double %x, 0.000000e+00
  %0 = and i1 %cmp3.i, %cmp.i
  %conv5.i = sext i1 %0 to i64
  %add.i = add nsw i64 %conv5.i, %conv.i
  %conv6.i = sitofp i64 %add.i to double
  %sub = fsub double %x, %conv6.i
  %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
  %cmp4 = fcmp ole double %sub, 5.000000e-01
  %or.cond5 = select i1 %cmp3.i, i1 %cmp4, i1 false
  %or.cond12 = select i1 %or.cond, i1 true, i1 %or.cond5
  %add = fadd double %conv6.i, 1.000000e+00
  %cond = select i1 %or.cond12, double %conv6.i, double %add
  ret double %cond
}

; Function Attrs: mustprogress nofree nosync nounwind 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: nofree nounwind 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) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %d) #7
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %d)
  call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %x) #7
  %0 = load i32, ptr %n, align 4, !tbaa !5
  %cmp83 = icmp sgt i32 %0, 0
  br i1 %cmp83, label %for.cond1.preheader.lr.ph, label %for.cond.cleanup14

for.cond1.preheader.lr.ph:                        ; preds = %entry
  %1 = load i32, ptr %d, align 4
  %2 = icmp sgt i32 %1, 0
  br i1 %2, label %for.cond1.preheader, label %for.body15.lr.ph

for.cond1.preheader:                              ; preds = %for.cond1.preheader.lr.ph, %for.cond.cleanup3
  %3 = phi i32 [ %7, %for.cond.cleanup3 ], [ %0, %for.cond1.preheader.lr.ph ]
  %4 = phi i32 [ %8, %for.cond.cleanup3 ], [ %1, %for.cond1.preheader.lr.ph ]
  %indvars.iv100 = phi i64 [ %indvars.iv.next101, %for.cond.cleanup3 ], [ 0, %for.cond1.preheader.lr.ph ]
  %cmp281 = icmp sgt i32 %4, 0
  br i1 %cmp281, label %for.body4, label %for.cond.cleanup3

for.cond12.preheader:                             ; preds = %for.cond.cleanup3
  %cmp1393 = icmp sgt i32 %7, 0
  br i1 %cmp1393, label %for.body15.lr.phthread-pre-split, label %for.cond.cleanup14

for.body15.lr.phthread-pre-split:                 ; preds = %for.cond12.preheader
  %.pr = load i32, ptr %d, align 4
  br label %for.body15.lr.ph

for.body15.lr.ph:                                 ; preds = %for.cond1.preheader.lr.ph, %for.body15.lr.phthread-pre-split
  %5 = phi i32 [ %.pr, %for.body15.lr.phthread-pre-split ], [ %1, %for.cond1.preheader.lr.ph ]
  %.lcssa120 = phi i32 [ %7, %for.body15.lr.phthread-pre-split ], [ %0, %for.cond1.preheader.lr.ph ]
  %cmp2285 = icmp sgt i32 %5, 0
  %6 = zext i32 %.lcssa120 to i64
  %wide.trip.count116 = zext i32 %.lcssa120 to i64
  %wide.trip.count = zext i32 %5 to i64
  %min.iters.check = icmp ult i32 %5, 8
  %n.vec = and i64 %wide.trip.count, 4294967288
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br label %for.body15

for.cond.cleanup3.loopexit:                       ; preds = %for.body4
  %.pre = load i32, ptr %n, align 4, !tbaa !5
  br label %for.cond.cleanup3

for.cond.cleanup3:                                ; preds = %for.cond.cleanup3.loopexit, %for.cond1.preheader
  %7 = phi i32 [ %.pre, %for.cond.cleanup3.loopexit ], [ %3, %for.cond1.preheader ]
  %8 = phi i32 [ %11, %for.cond.cleanup3.loopexit ], [ %4, %for.cond1.preheader ]
  %indvars.iv.next101 = add nuw nsw i64 %indvars.iv100, 1
  %9 = sext i32 %7 to i64
  %cmp = icmp slt i64 %indvars.iv.next101, %9
  br i1 %cmp, label %for.cond1.preheader, label %for.cond12.preheader, !llvm.loop !9

for.body4:                                        ; preds = %for.cond1.preheader, %for.body4
  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body4 ], [ 0, %for.cond1.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %y) #7
  %call5 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %y)
  %10 = load i32, ptr %y, align 4, !tbaa !5
  %arrayidx7 = getelementptr inbounds [10 x [10 x i32]], ptr %x, i64 0, i64 %indvars.iv100, i64 %indvars.iv
  store i32 %10, ptr %arrayidx7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %y) #7
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %11 = load i32, ptr %d, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %cmp2 = icmp slt i64 %indvars.iv.next, %12
  br i1 %cmp2, label %for.body4, label %for.cond.cleanup3.loopexit

for.cond12.loopexit:                              ; preds = %for.cond.cleanup23, %for.body15
  %ans.1.lcssa = phi i32 [ %ans.094, %for.body15 ], [ %spec.select, %for.cond.cleanup23 ]
  %indvars.iv.next107 = add nuw nsw i64 %indvars.iv106, 1
  %exitcond117.not = icmp eq i64 %indvars.iv.next114, %wide.trip.count116
  br i1 %exitcond117.not, label %for.cond.cleanup14, label %for.body15

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

for.body15:                                       ; preds = %for.body15.lr.ph, %for.cond12.loopexit
  %indvars.iv113 = phi i64 [ 0, %for.body15.lr.ph ], [ %indvars.iv.next114, %for.cond12.loopexit ]
  %indvars.iv106 = phi i64 [ 1, %for.body15.lr.ph ], [ %indvars.iv.next107, %for.cond12.loopexit ]
  %ans.094 = phi i32 [ 0, %for.body15.lr.ph ], [ %ans.1.lcssa, %for.cond12.loopexit ]
  %indvars.iv.next114 = add nuw nsw i64 %indvars.iv113, 1
  %cmp1889 = icmp ult i64 %indvars.iv.next114, %6
  br i1 %cmp1889, label %for.cond21.preheader, label %for.cond12.loopexit

for.cond21.preheader:                             ; preds = %for.body15, %for.cond.cleanup23
  %indvars.iv108 = phi i64 [ %indvars.iv.next109, %for.cond.cleanup23 ], [ %indvars.iv106, %for.body15 ]
  %ans.190 = phi i32 [ %spec.select, %for.cond.cleanup23 ], [ %ans.094, %for.body15 ]
  br i1 %cmp2285, label %for.body24.preheader, label %for.cond.cleanup23

for.body24.preheader:                             ; preds = %for.cond21.preheader
  br i1 %min.iters.check, label %for.body24.preheader130, label %vector.body

vector.body:                                      ; preds = %for.body24.preheader, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %for.body24.preheader ]
  %vec.phi = phi <4 x i32> [ %21, %vector.body ], [ zeroinitializer, %for.body24.preheader ]
  %vec.phi126 = phi <4 x i32> [ %22, %vector.body ], [ zeroinitializer, %for.body24.preheader ]
  %13 = getelementptr inbounds [10 x [10 x i32]], ptr %x, i64 0, i64 %indvars.iv113, i64 %index
  %wide.load = load <4 x i32>, ptr %13, align 8, !tbaa !5
  %14 = getelementptr inbounds i32, ptr %13, i64 4
  %wide.load127 = load <4 x i32>, ptr %14, align 8, !tbaa !5
  %15 = getelementptr inbounds [10 x [10 x i32]], ptr %x, i64 0, i64 %indvars.iv108, i64 %index
  %wide.load128 = load <4 x i32>, ptr %15, align 8, !tbaa !5
  %16 = getelementptr inbounds i32, ptr %15, i64 4
  %wide.load129 = load <4 x i32>, ptr %16, align 8, !tbaa !5
  %17 = sub nsw <4 x i32> %wide.load, %wide.load128
  %18 = sub nsw <4 x i32> %wide.load127, %wide.load129
  %19 = mul nsw <4 x i32> %17, %17
  %20 = mul nsw <4 x i32> %18, %18
  %21 = add <4 x i32> %19, %vec.phi
  %22 = add <4 x i32> %20, %vec.phi126
  %index.next = add nuw i64 %index, 8
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %22, %21
  %24 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  br i1 %cmp.n, label %for.cond.cleanup23, label %for.body24.preheader130

for.body24.preheader130:                          ; preds = %for.body24.preheader, %middle.block
  %indvars.iv103.ph = phi i64 [ 0, %for.body24.preheader ], [ %n.vec, %middle.block ]
  %L.086.ph = phi i32 [ 0, %for.body24.preheader ], [ %24, %middle.block ]
  br label %for.body24

for.cond.cleanup23:                               ; preds = %for.body24, %middle.block, %for.cond21.preheader
  %L.0.lcssa = phi i32 [ 0, %for.cond21.preheader ], [ %24, %middle.block ], [ %add42, %for.body24 ]
  %conv = sitofp i32 %L.0.lcssa to double
  %25 = bitcast double %conv to i64
  %shr.i = ashr i64 %25, 1
  %sub.i = sub nsw i64 6910469410427058090, %shr.i
  %26 = bitcast i64 %sub.i to double
  %27 = fmul double %conv, -5.000000e-01
  %neg.i = fmul double %27, %26
  %28 = call double @llvm.fmuladd.f64(double %neg.i, double %26, double 1.500000e+00)
  %mul3.i = fmul double %28, %26
  %neg6.i = fmul double %27, %mul3.i
  %29 = call double @llvm.fmuladd.f64(double %neg6.i, double %mul3.i, double 1.500000e+00)
  %mul7.i = fmul double %mul3.i, %29
  %neg10.i = fmul double %27, %mul7.i
  %30 = call double @llvm.fmuladd.f64(double %neg10.i, double %mul7.i, double 1.500000e+00)
  %mul11.i = fmul double %mul7.i, %30
  %neg14.i = fmul double %27, %mul11.i
  %31 = call double @llvm.fmuladd.f64(double %neg14.i, double %mul11.i, double 1.500000e+00)
  %mul15.i = fmul double %mul11.i, %31
  %mul16.i = fmul double %mul15.i, %conv
  %conv.i.i = fptosi double %mul16.i to i64
  %conv1.i.i = sitofp i64 %conv.i.i to double
  %cmp.i.i = fcmp une double %mul16.i, %conv1.i.i
  %cmp3.i.i = fcmp olt double %mul16.i, 0.000000e+00
  %32 = and i1 %cmp3.i.i, %cmp.i.i
  %conv5.i.i = sext i1 %32 to i64
  %add.i.i = add nsw i64 %conv5.i.i, %conv.i.i
  %conv6.i.i = sitofp i64 %add.i.i to double
  %sub.i80 = fsub double %mul16.i, %conv6.i.i
  %cmp.i = fcmp oge double %mul16.i, 0.000000e+00
  %cmp1.i = fcmp olt double %sub.i80, 5.000000e-01
  %or.cond.i = select i1 %cmp.i, i1 %cmp1.i, i1 false
  %cmp4.i = fcmp ole double %sub.i80, 5.000000e-01
  %or.cond5.i = select i1 %cmp3.i.i, i1 %cmp4.i, i1 false
  %or.cond12.i = select i1 %or.cond.i, i1 true, i1 %or.cond5.i
  %add.i = fadd double %conv6.i.i, 1.000000e+00
  %cond.i = select i1 %or.cond12.i, double %conv6.i.i, double %add.i
  %conv48 = fptosi double %cond.i to i32
  %mul49 = mul nsw i32 %conv48, %conv48
  %cmp50 = icmp eq i32 %mul49, %L.0.lcssa
  %inc52 = zext i1 %cmp50 to i32
  %spec.select = add nsw i32 %ans.190, %inc52
  %indvars.iv.next109 = add nuw nsw i64 %indvars.iv108, 1
  %exitcond112.not = icmp eq i64 %indvars.iv.next109, %wide.trip.count116
  br i1 %exitcond112.not, label %for.cond12.loopexit, label %for.cond21.preheader

for.body24:                                       ; preds = %for.body24.preheader130, %for.body24
  %indvars.iv103 = phi i64 [ %indvars.iv.next104, %for.body24 ], [ %indvars.iv103.ph, %for.body24.preheader130 ]
  %L.086 = phi i32 [ %add42, %for.body24 ], [ %L.086.ph, %for.body24.preheader130 ]
  %arrayidx28 = getelementptr inbounds [10 x [10 x i32]], ptr %x, i64 0, i64 %indvars.iv113, i64 %indvars.iv103
  %33 = load i32, ptr %arrayidx28, align 4, !tbaa !5
  %arrayidx32 = getelementptr inbounds [10 x [10 x i32]], ptr %x, i64 0, i64 %indvars.iv108, i64 %indvars.iv103
  %34 = load i32, ptr %arrayidx32, align 4, !tbaa !5
  %sub = sub nsw i32 %33, %34
  %mul = mul nsw i32 %sub, %sub
  %add42 = add nuw nsw i32 %mul, %L.086
  %indvars.iv.next104 = add nuw nsw i64 %indvars.iv103, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next104, %wide.trip.count
  br i1 %exitcond.not, label %for.cond.cleanup23, label %for.body24, !llvm.loop !14
}

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

; Function Attrs: nofree nounwind
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.vector.reduce.add.v4i32(<4 x i32>) #6

attributes #0 = { mustprogress nofree norecurse nosync nounwind 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 = { mustprogress nofree nosync nounwind 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 = { nofree nounwind 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 = { nofree nounwind "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 = { 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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.unswitch.partial.disable"}
!11 = distinct !{!11, !12, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !13, !12}
