A championship is held in Berland, in which $$$n$$$ players participate. The player with the number $$$i$$$ has $$$a_i$$$ ($$$a_i \ge 1$$$) tokens.The championship consists of $$$n-1$$$ games, which are played according to the following rules:  in each game, two random players with non-zero tokens are selected;  the player with more tokens is considered the winner of the game (in case of a tie, the winner is chosen randomly);  the winning player takes all of the loser's tokens; The last player with non-zero tokens is the winner of the championship.All random decisions that are made during the championship are made equally probable and independently.For example, if $$$n=4$$$, $$$a = [1, 2, 4, 3]$$$, then one of the options for the game (there could be other options) is:   during the first game, the first and fourth players were selected. The fourth player has more tokens, so he takes the first player's tokens. Now $$$a = [0, 2, 4, 4]$$$;  during the second game, the fourth and third players were selected. They have the same number of tokens, but in a random way, the third player is the winner. Now $$$a = [0, 2, 8, 0]$$$;  during the third game, the second and third players were selected. The third player has more tokens, so he takes the second player's tokens. Now $$$a = [0, 0, 10, 0]$$$;  the third player is declared the winner of the championship. Championship winners will receive personalized prizes. Therefore, the judges want to know in advance which players have a chance of winning, i.e have a non-zero probability of winning the championship. You have been asked to find all such players.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case consists of one positive integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of players in the championship. The second line of each test case contains $$$n$$$ positive integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the number of tokens the players have. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print the number of players who have a nonzero probability of winning the championship. On the next line print the numbers of these players in increasing order. Players are numbered starting from one in the order in which they appear in the input.

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]Pair, n)
		for j := 0; j < n; j++ {
			var x int64
			fmt.Fscan(in, &x)
			arr[j] = Pair{index: j + 1, value: x}
		}
		// sort in increasing order with index comparator
		sort.Slice(arr, func(i, j int) bool {
			return arr[i].value < arr[j].value
		})
		sum, lastIn := int64(0), 0
		for j := 0; j < n; j++ {
			if sum < arr[j].value {
				lastIn = j
			}
			sum += arr[j].value
		}
		ans := arr[lastIn:]
		sort.Slice(ans, func(i, j int) bool {
			return ans[i].index < ans[j].index
		})
		fmt.Fprintln(out, len(ans))
		for _, val := range ans {
			fmt.Fprint(out, val.index, " ")
		}
		fmt.Fprintln(out)
	}
}

type Pair struct {
	index int
	value int64
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]Pair, n)
		for j := 0; j < n; j++ {
			var x int64
			fmt.Fscan(in, &x)
			arr[j] = Pair{index: j + 1, value: x}
		}
		// sort in increasing order with index comparator
		sort.Slice(arr, func(i, j int) bool {
			return arr[i].value < arr[j].value
		})
		sum, lastIn := int64(0), 0
		for j := 0; j < n; j++ {
			if sum < arr[j].value {
				lastIn = j
			}
			sum += arr[j].value
		}
		ans := arr[lastIn:]
		sort.Slice(ans, func(i, j int) bool {
			return ans[i].index < ans[j].index
		})
		fmt.Println(len(ans))
		for _, val := range ans {
			fmt.Println(val.index)
		}
	}
}

type Pair struct {
	index int
	value int64
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func solve() {
	n := getI()
	a := getInts(n)
	b := make([]int64, n)
	copy(b, a)

	nsort(a...)

	lo := int64(0)
	hi := n - 1

	for lo < hi {
		x := lo + (hi-lo)/2
		// out(">", x, lo, hi)

		pow := a[x]
		win := true
		for i := int64(0); i < n; i++ {
			if i != x {
				if pow < a[i] {
					win = false
					break
				}
				pow += a[i]
			}
		}

		// out(a[x], "win:", win)
		if win {
			hi = x
		} else {
			lo = x + 1
		}
	}

	var res []int64
	for i := int64(0); i < n; i++ {
		if b[i] >= a[lo] {
			res = append(res, i+1)
		}
	}

	out(len(res))
	out(njoin(res...))
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	for i := getI(); i > 0; i-- {
		solve()
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func nsort(data ...int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(s ...int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func sort(arr []int64, l, r int) {
	if l >= r {
		return
	}
	mid := (l + r) / 2
	//fmt.Println(mid)
	sort(arr, l, mid)
	sort(arr, mid+1, r)
	L := arr[l : mid+1]
	R := arr[mid+1 : r+1]
	//fmt.Println("L:", L)
	//fmt.Println("R:", R)
	i, j, idx := 0, 0, 0
	b := make([]int64, r-l+1)
	for i < len(L) && j < len(R) {
		if L[i] > R[j] {
			b[idx] = L[i]
			i++
		} else {
			b[idx] = R[j]
			j++
		}
		idx++
	}
	for i < len(L) {
		b[idx] = L[i]
		idx++
		i++
	}
	for j < len(R) {
		b[idx] = R[j]
		idx++
		j++
	}
	idx = 0
	for k := l; k <= r; k++ {
		arr[k] = b[idx]
		idx++
	}
	//fmt.Println(arr)
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	var test int
	fmt.Fscan(input, &test)
	const N = 200005
	in := make([]int64, N)
	original := make([]int64, N)
	originalSort := make([]int64, N)
	for i := 0; i < test; i++ {
		var n int
		fmt.Fscan(input, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(input, &in[j])
			original[j] = in[j]
		}
		sort(in[0:n], 0, n-1)
		for j := 0; j < n; j++ {
			originalSort[j] = in[j]
		}
		for j := n - 2; j >= 0; j-- {
			in[j] += in[j+1]
		}
		lst := originalSort[0]
		for j := 1; j < n; j++ {
			if in[j] >= originalSort[j-1] {
				lst = originalSort[j]
			} else {
				break
			}
		}
		cnt := 0
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				cnt++
			}
		}
		fmt.Println(cnt)
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				fmt.Println(j + 1)
			}
		}
		//fmt.Println(in[0:n])
		//fmt.Println(originalSort[0:n])
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		type e struct {
			v   int64
			idx int
		}
		arr := make([]e, n)
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			arr[i] = e{v, i + 1}
		}
		sort.SliceStable(arr, func(i, j int) bool { return arr[i].v < arr[j].v })
		var tot int64
		var start int
		for i := 0; i < n-1; i++ {
			tot += arr[i].v
			if tot < arr[i+1].v {
				start = i + 1
			}
		}
		if start < 0 {
			fmt.Fprintln(out, 1)
			fmt.Fprintln(out, arr[n-1].idx)
		} else {
			g := make([]int, n-start)
			idx := 0
			for i := start; i < n; i++ {
				g[idx] = arr[i].idx
				idx++
			}

			sort.Ints(g)
			fmt.Fprintln(out, len(g))
			for _, v := range g {
				fmt.Fprintf(out, "%d ", v)
			}
			fmt.Fprintln(out)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
)

func MIN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MAX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}

}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })
var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)
		// // STRING := make([]byte, 0)
		// fmt.Fscan(input, &STRING)
		ARRAY := make([]int64, n+1)
		BARRAY := make([]int64, n+1)
		for i := 1; i < n+1; i++ {
			fmt.Fscan(input, &ARRAY[i])
			BARRAY[i] = ARRAY[i]
		}

		sort.Slice(ARRAY, func(i, j int) bool {
			return ARRAY[i] > ARRAY[j]
		})

		var sum int64
		indexxx := 0
		for i := n; i > 0; i-- {
			sum = sum + ARRAY[i]
			if sum < ARRAY[i-1] {
				indexxx = i - 1
			}

		}
		fmt.Println(indexxx + 1)
		for i := 1; i < n+1; i++ {
			if BARRAY[i] >= ARRAY[indexxx] {
				fmt.Println(i)
			}
		}

	}

}

// ZERO := 0
// ONE := 0
// TWO := 0
// for i := 0; i < n; i++ {
// 	fmt.Fscan(input, &ARRAY[i])
// 	if ARRAY[i]%3 == 0 {
// 		ZERO = ZERO + 1
// 	}
// 	if ARRAY[i]%3 == 1 {
// 		ONE = ONE + 1
// 	}
// 	if ARRAY[i]%3 == 2 {
// 		TWO = TWO + 1
// 	}
// }

// k := int(n / 3)

// if ONE == k && TWO == k && ZERO == k {
// 	fmt.Println(0)
// } else {
// 	if ONE == k || TWO == k || ZERO == k {
// 		if ONE == k {
// 			if TWO > ZERO {
// 				fmt.Println(TWO - k)
// 			} else {
// 				fmt.Println(2*TWO - 2*k)
// 			}
// 		}
// 		if TWO == k {
// 			if ZERO > ONE {
// 				fmt.Println(ZERO - k)
// 			} else {
// 				fmt.Println(2*ZERO - 2*k)
// 			}
// 		}
// 		if ZERO == k {
// 			if ONE > TWO {
// 				fmt.Println(ONE - k)
// 			} else {
// 				fmt.Println(2*ONE - 2*k)
// 			}
// 		}
// 	} else {
// 		if ONE > k {
// 			if ZERO < k {
// 				fmt.Println(ONE - TWO)
// 			} else {
// 				fmt.Println(ZERO - TWO)
// 			}
// 		}else{
// 			if TWO > k{

// 			}
// 		}

// }

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
)

func MIN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MAX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}

}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })
var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)
		// // STRING := make([]byte, 0)
		// fmt.Fscan(input, &STRING)
		ARRAY := make([]int64, n+1)
		BARRAY := make([]int64, n+1)
		for i := 1; i < n+1; i++ {
			fmt.Fscan(input, &ARRAY[i])
			BARRAY[i] = ARRAY[i]
		}

		sort.Slice(ARRAY, func(i, j int) bool {
			return ARRAY[i] > ARRAY[j]
		})

		var sum int64
		indexx := 0
		for i := n; i > 0; i-- {
			sum = sum + ARRAY[i]
			if sum < ARRAY[i-1] {
				indexx = i - 1
			}

		}
		fmt.Println(indexx + 1)
		for i := 1; i < n+1; i++ {
			if BARRAY[i] >= ARRAY[indexx] {
				fmt.Println(i)
			}
		}

	}

}

// ZERO := 0
// ONE := 0
// TWO := 0
// for i := 0; i < n; i++ {
// 	fmt.Fscan(input, &ARRAY[i])
// 	if ARRAY[i]%3 == 0 {
// 		ZERO = ZERO + 1
// 	}
// 	if ARRAY[i]%3 == 1 {
// 		ONE = ONE + 1
// 	}
// 	if ARRAY[i]%3 == 2 {
// 		TWO = TWO + 1
// 	}
// }

// k := int(n / 3)

// if ONE == k && TWO == k && ZERO == k {
// 	fmt.Println(0)
// } else {
// 	if ONE == k || TWO == k || ZERO == k {
// 		if ONE == k {
// 			if TWO > ZERO {
// 				fmt.Println(TWO - k)
// 			} else {
// 				fmt.Println(2*TWO - 2*k)
// 			}
// 		}
// 		if TWO == k {
// 			if ZERO > ONE {
// 				fmt.Println(ZERO - k)
// 			} else {
// 				fmt.Println(2*ZERO - 2*k)
// 			}
// 		}
// 		if ZERO == k {
// 			if ONE > TWO {
// 				fmt.Println(ONE - k)
// 			} else {
// 				fmt.Println(2*ONE - 2*k)
// 			}
// 		}
// 	} else {
// 		if ONE > k {
// 			if ZERO < k {
// 				fmt.Println(ONE - TWO)
// 			} else {
// 				fmt.Println(ZERO - TWO)
// 			}
// 		}else{
// 			if TWO > k{

// 			}
// 		}

// }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func CF1490E(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct {
		v int64
		i int
	}

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]pair, n)
		for i := range a {
			Fscan(in, &a[i].v)
			a[i].i = i + 1
		}
		sort.Slice(a, func(i, j int) bool { return a[i].v < a[j].v })
		s, st := int64(0), 0
		for i, p := range a {
			if s < p.v {
				st = i
			}
			s += p.v
		}
		Fprintln(out, n-st)
		a = a[st:]
		sort.Slice(a, func(i, j int) bool { return a[i].i < a[j].i })
		for _, v := range a {
			Fprint(out, v.i, " ")
		}
		Fprintln(out)
	}
}

func main() { CF1490E(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var (
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

func sstring() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		a := sint64s(n)
		res := sol(n, a)
		printf("%d\n", len(res))
		for _, d := range res {
			printf("%d ", d)
		}
		printf("\n")
	}
}

func sol(n int64, a []int64) []int64 {
	s := make([]int64, n)
	copy(s, a)
	sort.Slice(s, func(il, ir int) bool {
		return s[il] < s[ir]
	})
	min := findMin(s)
	ret := []int64{}
	for i := range a {
		if a[i] >= min {
			ret = append(ret, int64(i)+1)
		}
	}
	return ret
}

func findMin(s []int64) int64 {
	sum := int64(0)
	for _, i := range s {
		sum += i
	}
	for i := len(s) - 1; i >= 0; i-- {
		if sum-s[i] < s[i] {
			return s[i]
		}
		sum -= s[i]
	}
	return -1
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		arr := make([]Pair, n)
		for j := 0; j < n; j++ {
			var x int64
			fmt.Fscan(in, &x)
			arr[j] = Pair{index: j + 1, value: x}
		}
		// sort in increasing order with index comparator
		sort.Slice(arr, func(i, j int) bool {
			return arr[i].value < arr[j].value
		})
		sum, lastIn := int64(0), 0
		for j := 0; j < n; j++ {
			if sum < arr[j].value {
				lastIn = j
			}
			sum += arr[j].value
		}
		ans := arr[lastIn:]
		sort.Slice(ans, func(i, j int) bool {
			return ans[i].index < ans[j].index
		})
		fmt.Fprintln(out, len(ans))
		for _, val := range ans {
			fmt.Fprint(out, val, " ")
		}
		fmt.Fprintln(out)
	}
}

type Pair struct {
	index int
	value int64
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		arr := make([]Pair, n)
		for j := 0; j < n; j++ {
			var x int
			fmt.Scan(&x)
			arr[j] = Pair{index: j + 1, value: x}
		}
		// sort in increasing order with index comparator
		sort.SliceStable(arr, func(i, j int) bool {
			if arr[i].value < arr[j].value {
				return true
			}
			if arr[i].value == arr[j].value {
				if arr[i].index <= arr[j].index {
					return true
				}
				return false
			}
			return false
		})
		var ans []int
		// cumulative sum store of the array is needed and then traverse from back
		cumSum := 0
		for j := 0; j < n-1; j++ {
			cumSum += arr[j].value
			if cumSum >= arr[j+1].value {
				ans = append(ans, arr[j].index)
			}
		}
		ans = append(ans, arr[n-1].index)
		//var ans []int
		//for j := n - 1; j >= 0; j-- {
		//	ans = append(ans, arr[j].index)
		//	if arr[j].value > cumSum[j-1] {
		//		break
		//	}
		//}
		sort.Slice(ans, func(i, j int) bool {
			if ans[i] < ans[j] {
				return true
			}
			return false
		})
		fmt.Println(len(ans))
		for _, val := range ans {
			fmt.Print(val)
			fmt.Print(" ")
		}
		fmt.Println()
	}
}

type Pair struct {
	index int
	value int
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		arr := make([]Pair, n)
		for j := 0; j < n; j++ {
			var x int
			fmt.Scan(&x)
			arr[j] = Pair{index: j + 1, value: x}
		}
		// sort in increasing order with index comparator
		sort.SliceStable(arr, func(i, j int) bool {
			if arr[i].value < arr[j].value {
				return true
			}
			if arr[i].value == arr[j].value {
				if arr[i].index <= arr[j].index {
					return true
				}
				return false
			}
			return false
		})
		var ans []int
		// cumulative sum store of the array is needed and then traverse from back
		cumSum := 0
		for j := 0; j < n-1; j++ {
			cumSum += arr[j].value
			if cumSum >= arr[j+1].value {
				ans = append(ans, arr[j].index)
			}
		}
		ans = append(ans, arr[n-1].index)
		//var ans []int
		//for j := n - 1; j >= 0; j-- {
		//	ans = append(ans, arr[j].index)
		//	if arr[j].value > cumSum[j-1] {
		//		break
		//	}
		//}
		sort.Slice(ans, func(i, j int) bool {
			if ans[i] < ans[j] {
				return true
			}
			return false
		})
		fmt.Println(len(ans))
		for _, val := range ans {
			fmt.Println(val)
		}
	}
}

type Pair struct {
	index int
	value int
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func solve() {
	n := getI()
	a := getInts(n)
	nsort(a...)

	lo := int64(0)
	hi := n

	for lo < hi {
		x := lo + (hi-lo)/2

		pow := a[x]
		win := true
		for i := int64(0); i < n; i++ {
			if i != x {
				if pow < a[i] {
					win = false
					break
				}
				pow += a[i]
			}
		}

		if win {
			hi = x
		} else {
			lo = x + 1
		}
	}

	out(n - lo)
	for i := lo + 1; i <= n; i++ {
		printf("%d ", i)
	}
	out()
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	for i := getI(); i > 0; i-- {
		solve()
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func nsort(data ...int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(s ...int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func solve() {
	n := getI()
	a := getInts(n)
	nsort(a...)

	lo := int64(0)
	hi := n

	for lo < hi {
		x := lo + (hi-lo)/2

		pow := a[x]
		win := true
		for i := int64(0); i < n; i++ {
			if i != x {
				if pow < a[i] {
					win = false
					break
				}
				pow += a[i]
			}
		}

		if win {
			hi = x
		} else {
			lo = x + 1
		}
	}

	out(n - lo)
	out(njoin(a[lo:]...))
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	for i := getI(); i > 0; i-- {
		solve()
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func nsort(data ...int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func nsum(data ...int64) int64 {
	var res int64
	for _, n := range data {
		res += n
	}
	return res
}

func njoin(s ...int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI()
	for cases > 0 {
		cases--

		n := getI()
		a := getInts(n)

		if n == 1 {
			out(1)
			out(1)
			continue
		}

		sortInts(a)
		var count int64
		for i := int64(0); i < n; i++ {
			solve(a[:i+1], a[i+1:], &count)
		}

		out(count)
		var result []int64
		for i := int64(0); i < n; i++ {
			if a[i] > n-count {
				result = append(result, i+1)
			}
		}
		out(strings.Trim(fmt.Sprint(result), "[]"))
	}
}

func solve(l, r []int64, c *int64) {
	if len(r) == 0 {
		*c++
		return
	}
	var sumLeft int64
	for i := 0; i < len(l); i++ {
		sumLeft += l[i]
	}
	if sumLeft >= r[0] {
		newLeft := []int64{sumLeft + r[0]}
		solve(newLeft, r[1:], c)
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI()
	for cases > 0 {
		cases--

		n := getI()
		a := getInts(n)

		if n == 1 {
			out(1)
			out(1)
			continue
		}

		winners := make([]bool, n)
		for i := int64(0); i < n; i++ {
			for j := i + 1; j < n; j++ {
				idx := lowerBound(a, a[i]+a[j])
				if a[i] > a[j] {
					winners[i] = true
				}
				if a[i] == a[j] {
					winners[i] = true
					winners[j] = true
				}
				if a[i] < a[j] {
					winners[j] = true
				}

				if int64(idx) < n {
					winners[idx] = true
				}
			}
		}
		var result []int64
		var count int64
		forEach(n, func(i int64) {
			if winners[i] {
				count++
				result = append(result, i+1)
			}
		})
		out(count)
		out(strings.Trim(fmt.Sprint(result), "[]"))
	}
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 4096), 1e9)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	cases := getI()
	forEach(cases, func(i int64) {
		n := getI()
		a := getInts(n)
		winners := make([]bool, n)
		for i := int64(0); i < n; i++ {
			for j := i + 1; j < n; j++ {
				idx := lowerBound(a, a[i]+a[j])
				if a[i] > a[j] {
					winners[i] = true
				}
				if a[i] == a[j] {
					winners[i] = true
					winners[j] = true
				}
				if a[i] < a[j] {
					winners[j] = true
				}

				if int64(idx) < n {
					winners[idx] = true
				}
			}
		}
		var result []int64
		var count int64
		forEach(n, func(i int64) {
			if winners[i] {
				count++
				result = append(result, i+1)
			}
		})
		out(count)
		out(strings.Trim(fmt.Sprint(result), "[]"))
	})
}

// !------- HELPERS -------!

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(wr, f, a...)
}

func getI() int64 {
	s := getS()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int64) []int64 {
	ret := make([]int64, N)
	for i := range ret {
		ret[i] = getI()
	}
	return ret
}

func getS() string {
	if !sc.Scan() {
		panic(sc.Err())
	}
	return sc.Text()
}

func sortInts(data []int64) {
	sort.Slice(data, func(i, j int) bool { return data[i] < data[j] })
}

func joinInts(s []int64) string {
	return strings.Trim(fmt.Sprintf("%v", s), "[]")
}

func forEach(n int64, fn func(int64)) {
	for i := int64(0); i < n; i++ {
		fn(i)
	}
}

// min, max, asub, abs
func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// min for n entry
func nmin(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int64) int64 {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

func asub(a, b int64) int64 {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int64, x int64) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func sort(arr []int64, l, r int) {
	if l >= r {
		return
	}
	mid := (l + r) / 2
	//fmt.Println(mid)
	sort(arr, l, mid)
	sort(arr, mid+1, r)
	L := arr[l : mid+1]
	R := arr[mid+1 : r+1]
	//fmt.Println("L:", L)
	//fmt.Println("R:", R)
	i, j, idx := 0, 0, 0
	b := make([]int64, r-l+1)
	for i < len(L) && j < len(R) {
		if L[i] > R[j] {
			b[idx] = L[i]
			i++
		} else {
			b[idx] = R[j]
			j++
		}
		idx++
	}
	for i < len(L) {
		b[idx] = L[i]
		idx++
		i++
	}
	for j < len(R) {
		b[idx] = R[j]
		idx++
		j++
	}
	idx = 0
	for k := l; k <= r; k++ {
		arr[k] = b[idx]
		idx++
	}
	//fmt.Println(arr)
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	var test int
	fmt.Fscan(input, &test)
	const N = 200005
	in := make([]int64, N)
	original := make([]int64, N)
	originalSort := make([]int64, N)
	for i := 0; i < test; i++ {
		var n int
		fmt.Fscan(input, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(input, &in[j])
			original[j] = in[j]
		}
		sort(in[0:n], 0, n-1)
		for j := 0; j < n; j++ {
			originalSort[j] = in[j]
		}
		for j := n - 2; j >= 0; j-- {
			in[j] += in[j+1]
		}
		lst := originalSort[0]
		for j := 1; j < n; j++ {
			if in[j] >= originalSort[j-1] {
				lst = originalSort[j]
			} else {
				break
			}
		}
		cnt := 0
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				cnt++
			}
		}
		fmt.Println(cnt)
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				fmt.Println(j + 1)
			}
		}
		fmt.Println(in[0:n])
		fmt.Println(originalSort[0:n])
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func sort(arr []int64, l, r int) {
	if l >= r {
		return
	}
	mid := (l + r) / 2
	//fmt.Println(mid)
	sort(arr, l, mid)
	sort(arr, mid+1, r)
	L := arr[l : mid+1]
	R := arr[mid+1 : r+1]
	//fmt.Println("L:", L)
	//fmt.Println("R:", R)
	i, j, idx := 0, 0, 0
	b := make([]int64, r-l+1)
	for i < len(L) && j < len(R) {
		if L[i] > R[j] {
			b[idx] = L[i]
			i++
		} else {
			b[idx] = R[j]
			j++
		}
		idx++
	}
	for i < len(L) {
		b[idx] = L[i]
		idx++
		i++
	}
	for j < len(R) {
		b[idx] = R[j]
		idx++
		j++
	}
	idx = 0
	for k := l; k <= r; k++ {
		arr[k] = b[idx]
		idx++
	}
	//fmt.Println(arr)
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	var test int
	fmt.Fscan(input, &test)
	const N = 200005
	in := make([]int64, N)
	original := make([]int64, N)
	originalSort := make([]int64, N)
	for i := 0; i < test; i++ {
		var n int
		fmt.Fscan(input, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(input, &in[j])
			original[j] = in[j]
		}
		sort(in[0:n], 0, n-1)
		for j := 0; j < n; j++ {
			originalSort[j] = in[j]
		}
		for j := n - 2; j >= 0; j-- {
			in[j] += in[j+1]
		}
		lst := originalSort[0]
		for j := 1; j < n; j++ {
			if in[j] >= originalSort[j-1] {
				lst = originalSort[j]
			}
		}
		cnt := 0
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				cnt++
			}
		}
		fmt.Println(cnt)
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				fmt.Println(j + 1)
			}
		}
		//fmt.Println(input[0:n])
		//fmt.Println(originalSort[0:n])
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func sort(arr []int, l, r int) {
	if l >= r {
		return
	}
	mid := (l + r) / 2
	//fmt.Println(mid)
	sort(arr, l, mid)
	sort(arr, mid+1, r)
	L := arr[l : mid+1]
	R := arr[mid+1 : r+1]
	//fmt.Println("L:", L)
	//fmt.Println("R:", R)
	i, j, idx := 0, 0, 0
	b := make([]int, r-l+1)
	for i < len(L) && j < len(R) {
		if L[i] > R[j] {
			b[idx] = L[i]
			i++
		} else {
			b[idx] = R[j]
			j++
		}
		idx++
	}
	for i < len(L) {
		b[idx] = L[i]
		idx++
		i++
	}
	for j < len(R) {
		b[idx] = R[j]
		idx++
		j++
	}
	idx = 0
	for k := l; k <= r; k++ {
		arr[k] = b[idx]
		idx++
	}
	//fmt.Println(arr)
}

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	var test int
	fmt.Fscan(input, &test)
	const N = 200005
	in := make([]int, N)
	original := make([]int, N)
	originalSort := make([]int, N)
	for i := 0; i < test; i++ {
		var n int
		fmt.Fscan(input, &n)
		for j := 0; j < n; j++ {
			fmt.Fscan(input, &in[j])
			original[j] = in[j]
		}
		sort(in[0:n], 0, n-1)
		for j := 0; j < n; j++ {
			originalSort[j] = in[j]
		}
		for j := n - 2; j >= 0; j-- {
			in[j] += in[j+1]
		}
		lst := originalSort[0]
		for j := 1; j < n; j++ {
			if in[j] >= originalSort[j-1] {
				lst = originalSort[j]
			}
		}
		cnt := 0
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				cnt++
			}
		}
		fmt.Println(cnt)
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				fmt.Print(j + 1)
				if j < n-1 {
					fmt.Print(" ")
				}
			}
		}
		fmt.Println()
		//fmt.Println(input[0:n])
		//fmt.Println(originalSort[0:n])
	}
}

package main

import (
	"fmt"
)

func sort(arr []int, l, r int) {
	if l >= r {
		return
	}
	mid := (l + r) / 2
	//fmt.Println(mid)
	sort(arr, l, mid)
	sort(arr, mid+1, r)
	L := arr[l : mid+1]
	R := arr[mid+1 : r+1]
	//fmt.Println("L:", L)
	//fmt.Println("R:", R)
	i, j, idx := 0, 0, 0
	b := make([]int, r-l+1)
	for i < len(L) && j < len(R) {
		if L[i] > R[j] {
			b[idx] = L[i]
			i++
		} else {
			b[idx] = R[j]
			j++
		}
		idx++
	}
	for i < len(L) {
		b[idx] = L[i]
		idx++
		i++
	}
	for j < len(R) {
		b[idx] = R[j]
		idx++
		j++
	}
	idx = 0
	for k := l; k <= r; k++ {
		arr[k] = b[idx]
		idx++
	}
	//fmt.Println(arr)
}

func main() {
	var test int
	fmt.Scanf("%d", &test)
	const N = 200005
	input := make([]int, N)
	original := make([]int, N)
	originalSort := make([]int, N)
	for i := 0; i < test; i++ {
		var n int
		fmt.Scanf("%d", &n)
		for j := 0; j < n; j++ {
			fmt.Scanf("%d", &input[j])
			original[j] = input[j]
		}
		sort(input[0:n], 0, n-1)
		for j := 0; j < n; j++ {
			originalSort[j] = input[j]
		}
		for j := n - 2; j >= 0; j-- {
			input[j] += input[j+1]
		}
		lst := originalSort[0]
		for j := 1; j < n; j++ {
			if input[j] >= originalSort[j-1] {
				lst = originalSort[j]
			}
		}
		cnt := 0
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				cnt++
			}
		}
		fmt.Println(cnt)
		for j := 0; j < n; j++ {
			if original[j] >= lst {
				fmt.Print(j + 1)
				if j < n-1 {
					fmt.Print(" ")
				}
			}
		}
		fmt.Println()
		//fmt.Println(input[0:n])
		//fmt.Println(originalSort[0:n])
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		type e struct {
			v   int64
			idx int
		}
		arr := make([]e, n)
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			arr[i] = e{v, i + 1}
		}
		sort.SliceStable(arr, func(i, j int) bool { return arr[i].v < arr[j].v })
		var tot int64
		start := -1
		for i := 0; i < n-1; i++ {
			tot += arr[i].v
			if tot >= arr[i+1].v {
				start = i
				break
			}
		}
		if start < 0 {
			fmt.Fprintln(out, 1)
			fmt.Fprintln(out, arr[n-1].idx)
		} else {
			g := make([]int, n-start)
			idx := 0
			for i := start; i < n; i++ {
				g[idx] = arr[i].idx
				idx++
			}

			sort.Ints(g)
			fmt.Fprintln(out, len(g))
			for _, v := range g {
				fmt.Fprintf(out, "%d ", v)
			}
			fmt.Fprintln(out)
		}
	}
}


A country called Berland consists of n cities, numbered with integer numbers from 1 to n. Some of them are connected by bidirectional roads. Each road has some length. There is a path from each city to any other one by these roads. According to some Super Duper Documents, Berland is protected by the Super Duper Missiles. The exact position of the Super Duper Secret Missile Silos is kept secret but Bob managed to get hold of the information. That information says that all silos are located exactly at a distance l from the capital. The capital is located in the city with number s.The documents give the formal definition: the Super Duper Secret Missile Silo is located at some place (which is either city or a point on a road) if and only if the shortest distance from this place to the capital along the roads of the country equals exactly l.Bob wants to know how many missile silos are located in Berland to sell the information then to enemy spies. Help Bob.

The first line contains three integers n, m and s (2 ≤ n ≤ 105, , 1 ≤ s ≤ n) — the number of cities, the number of roads in the country and the number of the capital, correspondingly. Capital is the city no. s.  Then m lines contain the descriptions of roads. Each of them is described by three integers vi, ui, wi (1 ≤ vi, ui ≤ n, vi ≠ ui, 1 ≤ wi ≤ 1000), where vi, ui are numbers of the cities connected by this road and wi is its length. The last input line contains integer l (0 ≤ l ≤ 109) — the distance from the capital to the missile silos. It is guaranteed that:    between any two cities no more than one road exists;  each road connects two different cities;  from each city there is at least one way to any other city by the roads.

Print the single number — the number of Super Duper Secret Missile Silos that are located in Berland.

NoteIn the first sample the silos are located in cities 3 and 4 and on road (1, 3) at a distance 2 from city 1 (correspondingly, at a distance 1 from city 3).In the second sample one missile silo is located right in the middle of the road (1, 2). Two more silos are on the road (4, 5) at a distance 3 from city 4 in the direction to city 5 and at a distance 3 from city 5 to city 4.

package main

import (
	"bufio"
	. "container/heap"
	. "fmt"
	"io"
	"os"
)

type hPair struct{ x, y int }
type pairHeap []hPair

func (h pairHeap) Len() int              { return len(h) }
func (h pairHeap) Less(i, j int) bool    { return h[i].x < h[j].x || h[i].x == h[j].x && h[i].y < h[j].y }
func (h pairHeap) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *pairHeap) Push(v interface{})   { *h = append(*h, v.(hPair)) }
func (h *pairHeap) Pop() (v interface{}) { n := len(*h); *h, v = (*h)[:n-1], (*h)[n-1]; return }

// github.com/EndlessCheng/codeforces-go
func Sol144D(reader io.Reader, writer io.Writer) {
	in := bufio.NewScanner(reader)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(writer)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}

	n, m, st := read(), read(), read()-1
	type neighbor struct{ to, weight int }
	g := make([][]neighbor, n)
	for i := 0; i < m; i++ {
		v, w, weight := read()-1, read()-1, read()
		g[v] = append(g[v], neighbor{w, weight})
		g[w] = append(g[w], neighbor{v, weight})
	}
	l := read()

	const inf int = 1e9 + 1
	dist := make([]int, n)
	for i := range dist {
		dist[i] = inf
	}
	dist[st] = 0
	h := &pairHeap{}
	Push(h, hPair{0, st})
	for h.Len() > 0 {
		p := Pop(h).(hPair)
		d, v := p.x, p.y
		if dist[v] < d {
			continue
		}
		for _, e := range g[v] {
			w := e.to
			if newD := dist[v] + e.weight; newD < dist[w] {
				dist[w] = newD
				Push(h, hPair{newD, w})
			}
		}
	}

	ans := 0
	for _, d := range dist {
		if d == l {
			ans++
		}
	}
	for v, edges := range g {
		for _, e := range edges {
			w := e.to
			if w < v {
				continue
			}
			dv, dw, size := dist[v], dist[w], e.weight
			// imagine an axis from v to w
			posv := l - dv
			posw := size - (l - dw)
			if posv > posw {
				continue
			}
			if 0 < posv && posv < size {
				ans++
			}
			if 0 < posw && posw < size && posw != posv {
				ans++
			}
		}
	}
	Fprint(out, ans)
}

func main() {
	Sol144D(os.Stdin, os.Stdout)
}


Skier rides on a snowy field. Its movements can be described by a string of characters 'S', 'N', 'W', 'E' (which correspond to $$$1$$$ meter movement in the south, north, west or east direction respectively).It is known that if he moves along a previously unvisited segment of a path (i.e. this segment of the path is visited the first time), then the time of such movement is $$$5$$$ seconds. If he rolls along previously visited segment of a path (i.e., this segment of the path has been covered by his path before), then it takes $$$1$$$ second.Find the skier's time to roll all the path.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each set is given by one nonempty string of the characters 'S', 'N', 'W', 'E'. The length of the string does not exceed $$$10^5$$$ characters. The sum of the lengths of $$$t$$$ given lines over all test cases in the input does not exceed $$$10^5$$$.

For each test case, print the desired path time in seconds.

package main

import (
	"fmt"
)

func getStringPair(s1, s2 string) string {
	var x1, y1, x2, y2 int
	fmt.Sscanf(s1, "%d,%d", &x1, &y1)
	fmt.Sscanf(s2, "%d,%d", &x2, &y2)
	if x1 < x2 {
		return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
	} else if x1 > x2 {
		return fmt.Sprintf("%d,%d,%d,%d", x2, y2, x1, y1)
	} else {
		if y1 < y2 {
			return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
		} else if y1 > y2 {
			return fmt.Sprintf("%d,%d,%d,%d", x2, y2, x1, y1)
		} else {
			return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
		}
	}
}

func solve() {
	var path string
	fmt.Scan(&path)

	var x, y int
	currPos := fmt.Sprintf("%d,%d", x, y)
	grid := map[string]bool{currPos: true} // technically used as a set

	var sum int
	for i := 0; i < len(path); i++ {
		newY := y
		newX := x
		char := path[i]
		if char == 'N' {
			newY++
		}
		if char == 'S' {
			newY--
		}
		if char == 'E' {
			newX++
		}
		if char == 'W' {
			newX--
		}

		newPos := fmt.Sprintf("%d,%d", newX, newY)
		edge := getStringPair(currPos, newPos)
		if _, ok := grid[edge]; ok {
			sum += 1
		} else {
			grid[edge] = true
			sum += 5
		}
		x = newX
		y = newY
		currPos = newPos
	}
	fmt.Println(sum)
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		solve()
		TC--
	}
}

/*
URL:
https://codeforces.com/problemset/problem/1351/C
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t int
	S []rune
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		S = ReadRuneSlice()

		solve()
	}
}

func solve() {
	cx, cy := 0, 0
	memo := make(map[Coord]bool)

	ans := 0
	for _, r := range S {
		nx, ny := cx, cy
		if r == 'S' {
			ny--
		} else if r == 'N' {
			ny++
		} else if r == 'W' {
			nx--
		} else {
			nx++
		}

		c := Coord{x: cx + nx, y: cy + ny}
		if _, ok := memo[c]; ok {
			ans++
		} else {
			ans += 5
		}

		memo[c] = true
		cx, cy = nx, ny
	}

	fmt.Println(ans)
}

type Coord struct {
	x, y int
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1351C(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ x, y int }
	dir4 := [...]pair{
		'W': {-1, 0},
		'E': {1, 0},
		'S': {0, -1},
		'N': {0, 1},
	}

	var t int
	var s []byte
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &s)
		ans := 0
		vis := map[[2]pair]bool{}
		p := pair{}
		for _, b := range s {
			st := p
			d := dir4[b]
			p.x += d.x
			p.y += d.y
			if pp, qq := [2]pair{st, p}, [2]pair{p, st}; vis[pp] || vis[qq] {
				ans++
			} else {
				vis[pp] = true
				vis[qq] = true
				ans += 5
			}
		}
		Fprintln(out, ans)
	}
}

func main() { CF1351C(os.Stdin, os.Stdout) }

package main

import (
    "bufio"
    "fmt"
    "strings"
    "os"
)

type path struct {
    lat int
    lon int
    hor bool
}

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < t; i++ {
        s, _ := reader.ReadString('\n')
        s = strings.Replace(s, "\r\n", "", -1)
        var lat, lon, time int
        vis := map[path]bool{}
        for _, c := range s {
            var d path
            switch c {
                case 'N':
                    lat++
                    d = path{lat, lon, false}
                case 'S':
                    d = path{lat, lon, false}
                    lat--
                case 'E':
                    lon++
                    d = path{lat, lon, true}
                case 'W':
                    d = path{lat, lon, true}
                    lon--
            }
            if vis[d] {
                time += 1
            } else {
                time += 5
                vis[d] = true
            }
        }
        fmt.Println(time)
    }
}

package main

import (
    "os"
    "bufio"
    "fmt"
    "strings"
)

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < t; i++ {
        s, _ := reader.ReadString('\n')
        s = strings.Replace(s, "\r\n", "", -1)
        var lat, lon, time int64
        m := map[int64]bool{}
        for _, c := range s {
            var d int64
            switch c {
                case 'N': lat++; d = 200000 * lat + lon
                case 'S': d = 200000 * lat + lon; lat--
                case 'E': lon++; d = 200000 * lat + lon + 200000000000
                case 'W': d = 200000 * lat + lon + 200000000000; lon--
            }
            if m[d] {
                time += 1
            } else {
                time += 5
                m[d] = true
            }
        }
        fmt.Println(time)
    }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 0
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	t := getNextInt(scanner)
	for i := 0; i < t; i++ {
		s := getNextString(scanner)
		vn := map[uint64]int{}
		vs := map[uint64]int{}
		ve := map[uint64]int{}
		vw := map[uint64]int{}
		n := len(s)
		y := n + 1
		x := n + 1
		ans := 0
		for j := 0; j < n; j++ {
			k := key(y, x)
			switch s[j] {
			case 'N':
				ans += visit(k, key(y+1, x), vn, vs)
				y++
			case 'E':
				ans += visit(k, key(y, x+1), ve, vw)
				x++
			case 'W':
				ans += visit(k, key(y, x-1), vw, ve)
				x--
			case 'S':
				ans += visit(k, key(y-1, x), vs, vn)
				y--
			}
		}
		fmt.Fprintln(writer, ans)
	}
}

func visit(k1, k2 uint64, v1, v2 map[uint64]int) int {
	if v1[k1] == 0 && v2[k2] == 0 {
		v1[k1] = 1
		return 5
	}

	return 1
}

func key(y, x int) uint64 {
	return uint64(y)<<32 | uint64(x)
}

package main

import "fmt"

type Pair struct {
	first, second int
}

type Node struct {
	x1, y1, x2, y2 int
}

var m = map[rune]Pair{
	'N': {+1, 0},
	'S': {-1, 0},
	'W': {0, -1},
	'E': {0, +1},
}

func solve() {
	var s string
	fmt.Scanf("%s\n", &s)
	x, y := 0, 0
	var q = map[Node]bool{}
	ans := 0
	for _, c := range s {
		dx, dy := m[c].first, m[c].second
		if _, ok := q[Node{x, y, x + dx, y + dy}]; ok {
			ans += 1
		} else {
			ans += 5
			q[Node{x, y, x + dx, y + dy}] = true
			q[Node{x + dx, y + dy, x, y}] = true
		}
		x += dx
		y += dy
	}
	fmt.Println(ans)
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		solve()
	}
}

// https://codeforces.com/contest/1351/problem/C
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var path string
	fmt.Fscanln(input, &path)
	n := int64(len(path))
	m := make(map[int64]bool)

	r, c, n2 := int64(0), int64(0), n*n
	ans := 0
	for i := int64(0); i < n; i++ {
		switch path[i] {
		case 'S':
			if m[n2*(r*n+c) + (r+1)*n+c] {
				ans++
			} else {
				ans += 5
				m[n2*(r*n+c) + (r+1)*n+c] = true
				m[(r*n+c) + n2*((r+1)*n+c)] = true
			}
			r++
		case 'N':
			if m[n2*(r*n+c) + (r-1)*n+c] {
				ans++
			} else {
				ans += 5
				m[n2*(r*n+c) + (r-1)*n+c] = true
				m[(r*n+c) + n2*((r-1)*n+c)] = true
			}
			r--
		case 'W':
			if m[n2*(r*n+c) + r*n+c - 1] {
				ans++
			} else {
				ans += 5
				m[n2*(r*n+c) + r*n+c - 1] = true
				m[(r*n+c) + n2*(r*n+c - 1)] = true
			}
			c--
		case 'E':
			if m[n2 *(r*n+c) + r*n+c + 1] {
				ans++
			} else {
				ans += 5
				m[n2 *(r*n+c) + r*n+c + 1] = true
				m[(r*n+c) + n2*(r*n+c + 1)] = true
			}
			c++
		}
	}

	fmt.Println(ans)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func abs(i int64) int64 {
	if i < 0 {
		return -i
	}

	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	ini := func() int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	ins := func() string {
		sc.Scan()
		return sc.Text()
	}

	for t := ini(); t > 0; t-- {
		s := ins()

		currx := 0
		curry := 0

		var v int64

		m := make(map[int64]bool)
		m[0] = true

		val := 0

		var dx int64 = 0
		var dy int64 = 0

		for i := range s {

			dx, dy = 0, 0

			switch s[i] {
			case 'N':
				dy++
			case 'S':
				dy--
			case 'E':
				dx++
			case 'W':
				dx--
			}

			v = (int64(2*currx) + dx)*100000 + int64(2*curry) + dy

			if m[v] == true {
				val++
			} else {
				val += 5
			}

			m[v] = true
			currx += int(dx)
			curry += int(dy)
		}

		fmt.Println(val)
	}
}

package main

import "fmt"

type Coordinate struct {
	x, y int
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		var query string
		fmt.Scan(&query)

		c := Coordinate{}
		visited := map[[2]Coordinate]bool{}
		directions := map[byte]Coordinate{
			'N': {0, 1},
			'S': {0, -1},
			'E': {1, 0},
			'W': {-1, 0},
		}
		var ans int

		for _, move := range query {
			st := c
			dir := directions[byte(move)]
			c.x += dir.x
			c.y += dir.y
			if pp, qq := [2]Coordinate{st, c}, [2]Coordinate{c, st}; visited[pp] || visited[qq] {
				ans += 1
			} else {
				visited[pp] = true
				visited[qq] = true
				ans += 5
			}
		}
		fmt.Println(ans)
		TC--
	}
}

package main

import "fmt"

type Pair struct {
	x, y int
}

type Segment struct {
	p1, p2 Pair
}

var direction = map[byte]Pair{
	'N': Pair{1, 0},
	'S': Pair{-1, 0},
	'E': Pair{0, 1},
	'W': Pair{0, -1},
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		visited := map[Segment]bool{}
		var sequence []byte
		fmt.Scan(&sequence)

		var p Pair
		var ans int
		for _, b := range sequence {
			start := p
			dirP := direction[b]
			p.x += dirP.x
			p.y += dirP.y

			pp := Segment{start, p}
			qq := Segment{p, start}
			if v1, v2 := visited[pp], visited[qq]; v1 && v2 {
				ans++
			} else {
				visited[pp] = true
				visited[qq] = true
				ans += 5
			}
		}
		fmt.Println(ans)
		TC--
	}
}

package main

import "fmt"

func solve() {
	var path string
	fmt.Scan(&path)
	var x, y int
	grid := map[string]bool{fmt.Sprintf("%d,%d", x, y): true} // technically used as a set

	var sum int
	for i := 0; i < len(path); i++ {
		char := path[i]
		if char == 'N' {
			y++
		}
		if char == 'S' {
			y--
		}
		if char == 'E' {
			x++
		}
		if char == 'W' {
			x--
		}

		newPos := fmt.Sprintf("%d,%d", x, y)
		if _, ok := grid[newPos]; ok {
			sum += 1
		} else {
			grid[newPos] = true
			sum += 5
		}
	}
	fmt.Println(sum)
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		solve()
		TC--
	}
}

package main

import (
    "os"
    "bufio"
    "fmt"
    "strings"
)

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < t; i++ {
        s, _ := reader.ReadString('\n')
        s = strings.Replace(s, "\r\n", "", -1)
        var lat, lon, time int64
        m := map[int64]bool{
            0: true,
        }
        for _, c := range s {
            switch c {
            case 'N': lat++
            case 'S': lat--
            case 'E': lon++
            case 'W': lon--
            }
            v := m[200000 * lat + lon]
            if v {
                time += 1
            } else {
                time += 5
                m[200000 * lat + lon] = true
            }
        }
        fmt.Println(time)
    }
}

package main

import (
    "os"
    "bufio"
    "fmt"
    "strings"
)

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    reader := bufio.NewReader(os.Stdin)
    for i := 0; i < t; i++ {
        s, _ := reader.ReadString('\n')
        s = strings.Replace(s, "\r\n", "", -1)
        var lat, lon, time int64
        m := map[int64]bool{
            0: true,
        }
        for _, c := range s {
            var d int64
            switch c {
                case 'N': lat++; d = 200000 * lat + lon
                case 'S': d = 200000 * lat + lon; lat--
                case 'E': lon++; d = 200000 * lat + lon + 200000000000
                case 'W': d = 200000 * lat + lon + 200000000000; lon--
            }
            if m[d] {
                time += 1
            } else {
                time += 5
                m[d] = true
            }
        }
        fmt.Println(time)
    }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 0
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	t := getNextInt(scanner)
	for i := 0; i < t; i++ {
		s := getNextString(scanner)
		v := map[uint64]int{}
		n := len(s)
		y := n + 1
		x := n + 1
		v[key(y, x)] = 4
		ans := 0
		for j := 0; j < n; j++ {
			switch s[j] {
			case 'N':
				y++
			case 'E':
				x++
			case 'W':
				x--
			case 'S':
				y--
			}
			ans += 5 - v[key(y, x)]
			v[key(y, x)] = 4
		}
		fmt.Fprintln(writer, ans)
	}
}

func key(y, x int) uint64 {
	return uint64(y)<<32 | uint64(x)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 0
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	t := getNextInt(scanner)
	for i := 0; i < t; i++ {
		s := getNextString(scanner)
		v := map[uint64]int{}
		y := int(1e5)
		x := int(1e5)
		v[key(y, x)] = 4
		n := len(s)
		ans := 0
		for j := 0; j < n; j++ {
			switch s[j] {
			case 'N':
				y++
			case 'E':
				x++
			case 'W':
				x--
			case 'S':
				y--
			}
			ans += 5 - v[key(y, x)]
			v[key(y, x)] = 4
		}
		fmt.Fprintln(writer, ans)
	}
}

func key(y, x int) uint64 {
	return uint64(y)<<32 | uint64(x)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	ini := func() int {
		sc.Scan()
		i, _ := strconv.Atoi(sc.Text())
		return i
	}

	ins := func() string {
		sc.Scan()
		return sc.Text()
	}

	for t := ini(); t > 0; t-- {
		s := ins()

		currx := 0
		curry := 0

		var v int64

		m := make(map[int64]bool)
		m[0] = true

		val := 0

		for i := range s {
			switch s[i] {
			case 'N':
				curry++
			case 'S':
				curry--
			case 'E':
				currx++
			case 'W':
				currx--
			}

			v = int64(currx)*100000 + int64(curry)

			if m[v] == true {
				val++
			} else {
				val += 5
				m[v] = true
			}
		}

		fmt.Println(val)
	}
}

package main

import (
	"fmt"
	"strconv"
)

func getStringPair(s1, s2 string) string {
	x1, _ := strconv.Atoi(s1[0:1])
	y1, _ := strconv.Atoi(s1[2:])

	x2, _ := strconv.Atoi(s1[0:1])
	y2, _ := strconv.Atoi(s1[2:])

	if x1 < x2 {
		return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
	} else if x1 > x2 {
		return fmt.Sprintf("%d,%d,%d,%d", x2, y2, x1, y1)
	} else {
		if y1 < y2 {
			return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
		} else if y1 > y2 {
			return fmt.Sprintf("%d,%d,%d,%d", x2, y2, x1, y1)
		} else {
			return fmt.Sprintf("%d,%d,%d,%d", x1, y1, x2, y2)
		}
	}
}

func solve() {
	var path string
	fmt.Scan(&path)

	var x, y int
	currPos := fmt.Sprintf("%d,%d", x, y)
	grid := map[string]bool{currPos: true} // technically used as a set

	var sum int
	for i := 0; i < len(path); i++ {
		newY := y
		newX := x
		char := path[i]
		if char == 'N' {
			newY++
		}
		if char == 'S' {
			newY--
		}
		if char == 'E' {
			newX++
		}
		if char == 'W' {
			newX--
		}

		newPos := fmt.Sprintf("%d,%d", newX, newY)
		edge := getStringPair(currPos, newPos)
		if _, ok := grid[edge]; ok {
			sum += 1
		} else {
			grid[edge] = true

			sum += 5
		}
		x = newX
		y = newY
		currPos = newPos
	}
	fmt.Println(sum)
}

func main() {
	var TC int
	fmt.Scan(&TC)
	for TC != 0 {
		solve()
		TC--
	}
}


As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:A swap operation is the following sequence of actions:  choose two indexes i, j (i ≠ j);  perform assignments tmp = a[i], a[i] = a[j], a[j] = tmp. What maximum value of function m(a) can Sereja get if he is allowed to perform at most k swap operations?

The first line contains two integers n and k (1 ≤ n ≤ 200; 1 ≤ k ≤ 10). The next line contains n integers a[1], a[2], ..., a[n] ( - 1000 ≤ a[i] ≤ 1000).

In a single line print the maximum value of m(a) that Sereja can get if he is allowed to perform at most k swap operations.

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

const N = 202
var n, k int
var a[N] int

var L[N][12] int
var R[N][12] int

func max(a int, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func check(val int) bool  {
	var take = -int(1e6)

	for i := 1; i <= n; i++ {
		var in = make([]int, 0)
		var inSum = 0
		for j := i; j <= n; j++ {
			in = append(in, a[j])
			inSum += a[j]
			if inSum >= val {
				return true
			}
			sort.Ints(in)
			var outVal = 0
			// O(k^2)
			for z := 1; z <= min(k, len(in)); z++ {
				outVal += in[z - 1]
				for u := 0; u <= z; u++ {
					take = max(take, inSum - outVal + L[i - 1][u] + R[j + 1][z - u])

				}
				if take >= val {
					return true
				}
			}
		}
	}
	return false
}

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d\n", &n, &k)
	for i := 1; i <= n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}

	// init
	L[0][0] = 0
	for i := 1; i <= k; i++ {
		L[0][i] = -int(1e6)
	}
	R[n + 1][0] = 0
	for i := 1; i <= k; i++ {
		R[n + 1][i] = -int(1e6)
	}

	// prefix
	var pref = make([]int, 0)
	for i := 1; i <= n; i++ {
		pref = append(pref, a[i])
		sort.Ints(pref)
		L[i][0] = 0
		for j := 1; j <= k; j++ {
			if j > len(pref) {
				L[i][j] = -int(1e6)
			} else {
				L[i][j] = L[i][j - 1] + pref[len(pref) - j]
			}
		}
	}

	// suffix
	var suf = make([]int, 0)
	for i := n; i >= 1; i-- {
		suf = append(suf, a[i])
		sort.Ints(suf)
		R[i][0] = 0
		for j := 1; j <= k; j++ {
			if j > len(suf) {
				R[i][j] = -int(1e6)
			} else {
				R[i][j] = R[i][j - 1] + suf[len(suf) - j]
			}
		}
	}

	var l = -int(1e6)
	var r = int(1e6)
	var ret = l

	for l <= r {
		var mid = (l + r) / 2
		if check(mid) {
			ret = mid
			l = mid + 1
		} else {
			r = mid - 1
		}
	}

	fmt.Fprintf(writer, "%d", ret)
}