module answeroutput
contains
subroutine YNoutput(TF,ch)
  implicit none
  logical,intent(in)::TF
  character,intent(in),optional::ch
  if(present(ch))then
  select case(ch)
    case('Y')
      if(TF)then
        print"(A)","YES"
      else
        print"(A)","NO"
      endif
    case('y')
      if(TF)then
        print"(A)","yes"
      else
        print"(A)","no"
      endif
    case default
      if(TF)then
        print"(A)","Yes"
      else
        print"(A)","No"
      endif
    end select
  else
    if(TF)then
      print"(A)","Yes"
    else
      print"(A)","No"
    endif
  endif
  return
end subroutine
end module
use answeroutput
integer N
integer,allocatable,dimension(:)::A
integer x,y,z
integer xcnt,ycnt,zcnt
logical TF
read*,N
allocate(A(N))
read*,A
x=-1;y=-1;z=-1
xcnt=0;ycnt=0;zcnt=0
do i=1,N
  if((A(i)-x)*(A(i)-y)*(A(i)-z)/=0)then
    if(x==-1)then
      x=A(i)
      xcnt=1
    else if(y==-1)then
      y=A(i)
      ycnt=1
    else if(z==-1)then
      z=A(I)
      zcnt=1
    else
      call YNoutput(1==-1)
      stop
    endif
  else
    if(x==A(i))xcnt=xcnt+1
    if(y==A(i))ycnt=ycnt+1
    if(z==A(i))zcnt=zcnt+1
  endif
end do

TF=.False.
if((xcnt==ycnt.and.ycnt==zcnt).and.xor(xor(x,y),z)==0)TF=.TRUE.
if((x==0.and.xcnt==(N/3)).and.(ycnt==2*xcnt).and.zcnt==0)TF=.TRUE.
if((y==0.and.ycnt==(N/3)).and.(xcnt==2*ycnt).and.zcnt==0)TF=.TRUE.
if(x==0.and.xcnt==N)TF=.TRUE.

call YNoutput(TF)
end

; ModuleID = 'FIRModule'
source_filename = "FIRModule"
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"

@_QQcl.59 = linkonce constant [1 x i8] c"Y"
@_QQcl.79 = linkonce constant [1 x i8] c"y"
@_QQcl.284129 = linkonce constant [3 x i8] c"(A)"
@_QQcl.b0f7fe17adae7212306738cddc24f9c3 = linkonce constant [73 x i8] c"/home/ubuntu/Downloads/TheStack_IR/Collated/Fortran/Source_3758/source.f\00"
@_QQcl.594553 = linkonce constant [3 x i8] c"YES"
@_QQcl.4E4F = linkonce constant [2 x i8] c"NO"
@_QQcl.796573 = linkonce constant [3 x i8] c"yes"
@_QQcl.6E6F = linkonce constant [2 x i8] c"no"
@_QQcl.596573 = linkonce constant [3 x i8] c"Yes"
@_QQcl.4E6F = linkonce constant [2 x i8] c"No"
@_QFEa.0 = internal unnamed_addr global ptr null
@_QFEa.8 = internal unnamed_addr global i64 0
@_QQEnvironmentDefaults = local_unnamed_addr constant ptr null

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

define void @_QMansweroutputPynoutput(ptr nocapture readonly %0, ptr %1, i64 %2) local_unnamed_addr {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %33, label %4

4:                                                ; preds = %3
  %5 = tail call i32 @_FortranACharacterCompareScalar1(ptr nonnull %1, ptr nonnull @_QQcl.59, i64 1, i64 1)
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %11, label %7

7:                                                ; preds = %4
  %8 = tail call i32 @_FortranACharacterCompareScalar1(ptr nonnull %1, ptr nonnull @_QQcl.79, i64 1, i64 1)
  %9 = icmp eq i32 %8, 0
  %10 = load i32, ptr %0, align 4, !tbaa !3
  %.not3 = icmp eq i32 %10, 0
  br i1 %9, label %26, label %19

11:                                               ; preds = %4
  %12 = load i32, ptr %0, align 4, !tbaa !3
  %.not4 = icmp eq i32 %12, 0
  br i1 %.not4, label %16, label %13

13:                                               ; preds = %11
  %14 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 11)
  %15 = tail call i1 @_FortranAioOutputAscii(ptr %14, ptr nonnull @_QQcl.594553, i64 3)
  br label %41

16:                                               ; preds = %11
  %17 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 13)
  %18 = tail call i1 @_FortranAioOutputAscii(ptr %17, ptr nonnull @_QQcl.4E4F, i64 2)
  br label %41

19:                                               ; preds = %7
  br i1 %.not3, label %23, label %20

20:                                               ; preds = %19
  %21 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 23)
  %22 = tail call i1 @_FortranAioOutputAscii(ptr %21, ptr nonnull @_QQcl.596573, i64 3)
  br label %41

23:                                               ; preds = %19
  %24 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 25)
  %25 = tail call i1 @_FortranAioOutputAscii(ptr %24, ptr nonnull @_QQcl.4E6F, i64 2)
  br label %41

26:                                               ; preds = %7
  br i1 %.not3, label %30, label %27

27:                                               ; preds = %26
  %28 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 17)
  %29 = tail call i1 @_FortranAioOutputAscii(ptr %28, ptr nonnull @_QQcl.796573, i64 3)
  br label %41

30:                                               ; preds = %26
  %31 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 19)
  %32 = tail call i1 @_FortranAioOutputAscii(ptr %31, ptr nonnull @_QQcl.6E6F, i64 2)
  br label %41

33:                                               ; preds = %3
  %34 = load i32, ptr %0, align 4, !tbaa !3
  %.not1 = icmp eq i32 %34, 0
  br i1 %.not1, label %38, label %35

35:                                               ; preds = %33
  %36 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 30)
  %37 = tail call i1 @_FortranAioOutputAscii(ptr %36, ptr nonnull @_QQcl.596573, i64 3)
  br label %41

38:                                               ; preds = %33
  %39 = tail call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 32)
  %40 = tail call i1 @_FortranAioOutputAscii(ptr %39, ptr nonnull @_QQcl.4E6F, i64 2)
  br label %41

41:                                               ; preds = %13, %16, %27, %30, %20, %23, %35, %38
  %.sink = phi ptr [ %14, %13 ], [ %17, %16 ], [ %28, %27 ], [ %31, %30 ], [ %21, %20 ], [ %24, %23 ], [ %36, %35 ], [ %39, %38 ]
  %42 = tail call i32 @_FortranAioEndIoStatement(ptr %.sink)
  ret void
}

define void @_QQmain() local_unnamed_addr {
  %1 = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = tail call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 44)
  %11 = call i1 @_FortranAioInputInteger(ptr %10, ptr nonnull %3, i32 4)
  %12 = call i32 @_FortranAioEndIoStatement(ptr %10)
  %13 = load i32, ptr %3, align 4, !tbaa !3
  %14 = call i32 @llvm.smax.i32(i32 %13, i32 0)
  %15 = zext i32 %14 to i64
  %16 = shl nuw nsw i64 %15, 2
  %17 = call ptr @malloc(i64 %16)
  store ptr %17, ptr @_QFEa.0, align 8, !tbaa !7
  store i64 %15, ptr @_QFEa.8, align 8, !tbaa !7
  %18 = call ptr @_FortranAioBeginExternalListInput(i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 46)
  %.unpack = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %.unpack238.unpack.unpack240 = load i64, ptr @_QFEa.8, align 8, !tbaa !7
  store ptr %.unpack, ptr %1, align 8, !tbaa !7
  %.fca.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 1
  store i64 4, ptr %.fca.1.gep, align 8, !tbaa !7
  %.fca.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 2
  store i32 20180515, ptr %.fca.2.gep, align 8, !tbaa !7
  %.fca.3.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 3
  store i8 1, ptr %.fca.3.gep, align 4, !tbaa !7
  %.fca.4.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 4
  store i8 9, ptr %.fca.4.gep, align 1, !tbaa !7
  %.fca.5.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 5
  store i8 0, ptr %.fca.5.gep, align 2, !tbaa !7
  %.fca.6.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 6
  store i8 0, ptr %.fca.6.gep, align 1, !tbaa !7
  %.fca.7.0.0.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 0
  store i64 1, ptr %.fca.7.0.0.gep, align 8, !tbaa !7
  %.fca.7.0.1.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 1
  store i64 %.unpack238.unpack.unpack240, ptr %.fca.7.0.1.gep, align 8, !tbaa !7
  %.fca.7.0.2.gep = getelementptr inbounds { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, ptr %1, i64 0, i32 7, i64 0, i64 2
  store i64 4, ptr %.fca.7.0.2.gep, align 8, !tbaa !7
  %19 = call i1 @_FortranAioInputDescriptor(ptr %18, ptr nonnull %1)
  %20 = call i32 @_FortranAioEndIoStatement(ptr %18)
  store i32 -1, ptr %4, align 4, !tbaa !3
  store i32 -1, ptr %6, align 4, !tbaa !3
  store i32 -1, ptr %8, align 4, !tbaa !3
  store i32 0, ptr %5, align 4, !tbaa !3
  store i32 0, ptr %7, align 4, !tbaa !3
  store i32 0, ptr %9, align 4, !tbaa !3
  %21 = load i32, ptr %3, align 4, !tbaa !3
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %0
  %.unpack243 = load ptr, ptr @_QFEa.0, align 8, !tbaa !7
  %23 = add nuw i32 %21, 1
  %wide.trip.count = zext i32 %23 to i64
  br label %24

24:                                               ; preds = %.lr.ph, %56
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %56 ]
  %25 = add nsw i64 %indvars.iv, -1
  %26 = getelementptr i32, ptr %.unpack243, i64 %25
  %27 = load i32, ptr %26, align 4, !tbaa !3
  %.0..0..0..0.25 = load i32, ptr %4, align 4, !tbaa !3
  %28 = sub i32 %27, %.0..0..0..0.25
  %.0..0..0..0.14 = load i32, ptr %6, align 4, !tbaa !3
  %29 = sub i32 %27, %.0..0..0..0.14
  %30 = mul i32 %29, %28
  %.0..0..0..0.5 = load i32, ptr %8, align 4, !tbaa !3
  %31 = sub i32 %27, %.0..0..0..0.5
  %32 = mul i32 %30, %31
  %.not = icmp eq i32 %32, 0
  br i1 %.not, label %44, label %33

33:                                               ; preds = %24
  %34 = icmp eq i32 %.0..0..0..0.25, -1
  br i1 %34, label %35, label %38

35:                                               ; preds = %40, %38, %33
  %36 = phi ptr [ %8, %40 ], [ %6, %38 ], [ %4, %33 ]
  %37 = phi ptr [ %9, %40 ], [ %7, %38 ], [ %5, %33 ]
  store i32 %27, ptr %36, align 4, !tbaa !3
  store i32 1, ptr %37, align 4, !tbaa !3
  br label %56

38:                                               ; preds = %33
  %39 = icmp eq i32 %.0..0..0..0.14, -1
  br i1 %39, label %35, label %40

40:                                               ; preds = %38
  %41 = icmp eq i32 %.0..0..0..0.5, -1
  br i1 %41, label %35, label %42

42:                                               ; preds = %40
  store i32 0, ptr %2, align 4, !tbaa !3
  call void @_QMansweroutputPynoutput(ptr nonnull %2, ptr null, i64 poison)
  %43 = call {} @_FortranAStopStatement(i32 0, i1 false, i1 false)
  unreachable

44:                                               ; preds = %24
  %45 = icmp eq i32 %27, %.0..0..0..0.25
  br i1 %45, label %46, label %48

46:                                               ; preds = %44
  %.0..0..0..0.21 = load i32, ptr %5, align 4, !tbaa !3
  %47 = add i32 %.0..0..0..0.21, 1
  store i32 %47, ptr %5, align 4, !tbaa !3
  br label %48

48:                                               ; preds = %46, %44
  %49 = icmp eq i32 %27, %.0..0..0..0.14
  br i1 %49, label %50, label %52

50:                                               ; preds = %48
  %.0..0..0..0.11 = load i32, ptr %7, align 4, !tbaa !3
  %51 = add i32 %.0..0..0..0.11, 1
  store i32 %51, ptr %7, align 4, !tbaa !3
  br label %52

52:                                               ; preds = %50, %48
  %53 = icmp eq i32 %27, %.0..0..0..0.5
  br i1 %53, label %54, label %56

54:                                               ; preds = %52
  %.0..0..0..0.3 = load i32, ptr %9, align 4, !tbaa !3
  %55 = add i32 %.0..0..0..0.3, 1
  store i32 %55, ptr %9, align 4, !tbaa !3
  br label %56

56:                                               ; preds = %35, %54, %52
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %24

._crit_edge.loopexit:                             ; preds = %56
  %.0..0..0..0.17.pre = load i32, ptr %5, align 4, !tbaa !3
  %.0..0..0..0.8.pre = load i32, ptr %7, align 4, !tbaa !3
  %.0..0..0..0..pre = load i32, ptr %9, align 4, !tbaa !3
  %.0..0..0..0.22.pre = load i32, ptr %4, align 4, !tbaa !3
  %.0..0..0..0.12.pre = load i32, ptr %6, align 4, !tbaa !3
  %.0..0..0..0.4.pre = load i32, ptr %8, align 4, !tbaa !3
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %0
  %.0..0..0.4 = phi i32 [ %.0..0..0..0.4.pre, %._crit_edge.loopexit ], [ -1, %0 ]
  %.0..0..0.12 = phi i32 [ %.0..0..0..0.12.pre, %._crit_edge.loopexit ], [ -1, %0 ]
  %.0..0..0.22 = phi i32 [ %.0..0..0..0.22.pre, %._crit_edge.loopexit ], [ -1, %0 ]
  %.0..0..0. = phi i32 [ %.0..0..0..0..pre, %._crit_edge.loopexit ], [ 0, %0 ]
  %.0..0..0.8 = phi i32 [ %.0..0..0..0.8.pre, %._crit_edge.loopexit ], [ 0, %0 ]
  %.0..0..0.17 = phi i32 [ %.0..0..0..0.17.pre, %._crit_edge.loopexit ], [ 0, %0 ]
  %57 = icmp eq i32 %.0..0..0.17, %.0..0..0.8
  %58 = icmp eq i32 %.0..0..0.8, %.0..0..0.
  %59 = and i1 %57, %58
  %60 = xor i32 %.0..0..0.12, %.0..0..0.22
  %61 = icmp eq i32 %60, %.0..0..0.4
  %62 = and i1 %59, %61
  %63 = icmp eq i32 %.0..0..0.22, 0
  %64 = sdiv i32 %21, 3
  %65 = icmp eq i32 %.0..0..0.17, %64
  %66 = shl i32 %.0..0..0.17, 1
  %67 = icmp eq i32 %.0..0..0.8, %66
  %68 = and i1 %65, %67
  %69 = icmp eq i32 %.0..0..0., 0
  %70 = or i32 %.0..0..0.22, %.0..0..0.
  %71 = icmp eq i32 %70, 0
  %72 = and i1 %68, %71
  %73 = icmp eq i32 %.0..0..0.12, 0
  %74 = icmp eq i32 %.0..0..0.8, %64
  %75 = and i1 %74, %73
  %76 = shl i32 %.0..0..0.8, 1
  %77 = icmp eq i32 %.0..0..0.17, %76
  %78 = and i1 %77, %75
  %79 = and i1 %69, %78
  %80 = icmp eq i32 %.0..0..0.17, %21
  %.not298.not = and i1 %80, %63
  %81 = select i1 %.not298.not, i1 true, i1 %79
  %82 = select i1 %81, i1 true, i1 %72
  %83 = select i1 %82, i1 true, i1 %62
  br i1 %83, label %.thread, label %86

.thread:                                          ; preds = %._crit_edge
  %84 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 30)
  %85 = call i1 @_FortranAioOutputAscii(ptr %84, ptr nonnull @_QQcl.596573, i64 3)
  br label %_QMansweroutputPynoutput.exit

86:                                               ; preds = %._crit_edge
  %87 = call ptr @_FortranAioBeginExternalFormattedOutput(ptr nonnull @_QQcl.284129, i64 3, ptr null, i32 -1, ptr nonnull @_QQcl.b0f7fe17adae7212306738cddc24f9c3, i32 32)
  %88 = call i1 @_FortranAioOutputAscii(ptr %87, ptr nonnull @_QQcl.4E6F, i64 2)
  br label %_QMansweroutputPynoutput.exit

_QMansweroutputPynoutput.exit:                    ; preds = %.thread, %86
  %.sink.i = phi ptr [ %84, %.thread ], [ %87, %86 ]
  %89 = call i32 @_FortranAioEndIoStatement(ptr %.sink.i)
  ret void
}

declare i32 @_FortranACharacterCompareScalar1(ptr, ptr, i64, i64) local_unnamed_addr

declare ptr @_FortranAioBeginExternalFormattedOutput(ptr, i64, ptr, i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioOutputAscii(ptr, ptr, i64) local_unnamed_addr

declare i32 @_FortranAioEndIoStatement(ptr) local_unnamed_addr

declare ptr @_FortranAioBeginExternalListInput(i32, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputInteger(ptr, ptr, i32) local_unnamed_addr

declare i1 @_FortranAioInputDescriptor(ptr, ptr) local_unnamed_addr

declare {} @_FortranAStopStatement(i32, i1, i1) local_unnamed_addr

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

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.module.flags = !{!0, !1, !2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{!4, !4, i64 0}
!4 = !{!"any data access", !5, i64 0}
!5 = !{!"any access", !6, i64 0}
!6 = !{!"Flang Type TBAA Root"}
!7 = !{!8, !8, i64 0}
!8 = !{!"descriptor member", !5, i64 0}
