func (ins *Insertion) Sort() {
	l := len(ins.A)
	for i := 1; i < l; i++ {

		if ins.A[i-1] > ins.A[i] {

			x := ins.A[i]
			b := search.Binary{A: ins.A[:i-1], X: x}
			index := b.SearchForInsertion(0, len(b.A)-1, func(i int) bool { return b.A[i] >= b.X })

			// remove, insert and concat
			ins.A = append(ins.A[:index], append([]int{x}, append(ins.A[:i], ins.A[i+1:]...)[index:]...)...)

		}

	}
}
// may be it not working perfectly :(, but it very fast
func (ts *threesum) TriplesCountFast() int {

	is := sort.Insertion{ts.nums}
	is.Sort()

	cnt := 0
	for i, vi := range is.A {
		for j, vj := range is.A[i+1:] {
			bs := search.Binary{A: is.A[j+1:], X: -(vi + vj)}
			k := bs.Iterative(0, len(bs.A)-1)
			if k > j {
				cnt += 1
			}
		}
	}

	return cnt
}
func (ts *twosum) CountFast() int {

	is := sort.Insertion{ts.ids}
	is.Sort()
	ts.ids = is.A

	cnt := 0

	for i, v := range ts.ids {
		bs := search.Binary{A: ts.ids, X: -v}

		index := bs.Recursive(0, len(bs.A)-1)

		if index > i {
			cnt += 1
		}
	}
	return cnt
}