Unusual runtime error in A of codeforces

This is the problem

This is my solution code

I just wanted to know the reason for runtime error.
PS_I know this isn’t optimal solution , but then still i wanted to know why this isn’t working.

[simon@simon-laptop][08:48:22]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh 
Compiling msatanzeel-blah.cpp
+ g++ -std=c++14 msatanzeel-blah.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
msatanzeel-blah.cpp: In function ‘bool comp(int, int)’:
msatanzeel-blah.cpp:63:21: warning: unused parameter ‘b’ [-Wunused-parameter]
 bool comp(int a,int b)
                     ^
+ set +x
Successful
[simon@simon-laptop][08:48:29]
[~/devel/hackerrank/otherpeoples]>echo "4
> 3
> 1 1 2
> 3
> 1 1 1
> 8
> 10 9 13 15 3 16 9 13
> 2
> 18 9" | ./a.out
/usr/include/c++/7/bits/stl_algo.h:4866:
Error: comparison doesn't meet irreflexive requirements, assert(!(a < a)).

Objects involved in the operation:
    instance "functor" @ 0x0x7fff2b5aaa68 {
      type = bool (*)(int, int);
    }
    iterator::value_type "ordered type" {
      type = int;
    }
Aborted (core dumped)
3 Likes