There are $$$n$$$ quests. If you complete the $$$i$$$-th quest, you will gain $$$a_i$$$ coins. You can only complete at most one quest per day. However, once you complete a quest, you cannot do the same quest again for $$$k$$$ days. (For example, if $$$k=2$$$ and you do quest $$$1$$$ on day $$$1$$$, then you cannot do it on day $$$2$$$ or $$$3$$$, but you can do it again on day $$$4$$$.)You are given two integers $$$c$$$ and $$$d$$$. Find the maximum value of $$$k$$$ such that you can gain at least $$$c$$$ coins over $$$d$$$ days. If no such $$$k$$$ exists, output Impossible. If $$$k$$$ can be arbitrarily large, output Infinity.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains three integers $$$n,c,d$$$ ($$$2 \leq n \leq 2\cdot10^5$$$; $$$1 \leq c \leq 10^{16}$$$; $$$1 \leq d \leq 2\cdot10^5$$$) — the number of quests, the number of coins you need, and the number of days. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \leq a_i \leq 10^9$$$) — the rewards for the quests. The sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$, and the sum of $$$d$$$ over all test cases does not exceed $$$2\cdot10^5$$$.

For each test case, output one of the following.    If no such $$$k$$$ exists, output Impossible.  If $$$k$$$ can be arbitrarily large, output Infinity.  Otherwise, output a single integer — the maximum value of $$$k$$$ such that you can gain at least $$$c$$$ coins over $$$d$$$ days.  case-sensitive

NoteIn the first test case, one way to earn $$$5$$$ coins over $$$4$$$ days with $$$k=2$$$ is as follows:   Day 1: do quest 2, and earn $$$2$$$ coins.  Day 2: do quest 1, and earn $$$1$$$ coin.  Day 3: do nothing.  Day 4: do quest 2, and earn $$$2$$$ coins.  In total, we earned $$$2+1+2=5$$$ coins.In the second test case, we can make over $$$20$$$ coins on the first day itself by doing the first quest to earn $$$100$$$ coins, so the value of $$$k$$$ can be arbitrarily large, since we never need to do another quest.In the third test case, no matter what we do, we can't earn $$$100$$$ coins over $$$3$$$ days.

package main

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

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

var T, N, C, D int64
var A []int64

func solve() string {
	sort.Slice(A[:N], func(i, j int) bool {
		return A[i] > A[j]
	})

	for i := 1; int64(i) < N; i += 1 {
		A[i] += A[i-1]
	}

	if A[int(min(N-1, D-1))] >= C {
		return "Infinity"
	}

	if A[0]*D < C {
		return "Impossible"
	}

	l, r := int64(0), D
	for l <= r {
		m := l + (r-l)/2

		s := int64(0)
		if m <= N-1 {
			s += D / (m + 1) * A[m]
			r := D % (m + 1)
			if r > 0 {
				s += A[r-1]
			}
		} else {
			s += D / (m + 1) * A[N-1]
			r := D % (m + 1)
			if r > 0 {
				r = min(r, N)
				s += A[r-1]
			}
		}

		if s >= C {
			l = m + 1
		} else {
			r = m - 1
		}
	}

	return strconv.FormatInt(r, 10)

}

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

	defer func() {
		out.Flush()
	}()

	fmt.Fscan(in, &T)
	A = make([]int64, 200005)

	rs := make([]string, 0)
	for tt := int64(0); tt < T; tt += 1 {
		fmt.Fscan(in, &N, &C, &D)
		for i := 0; int64(i) < N; i += 1 {
			fmt.Fscan(in, &A[i])
		}

		rs = append(rs, solve())
	}

	for i := 0; int64(i) < T; i++ {
		fmt.Fprintln(out, rs[i])
	}
}

package main

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

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

var T, N, C, D int64
var A []int64

func solve() string {
	sort.Slice(A[:N], func(i, j int) bool {
		return A[i] > A[j]
	})

	for i := 1; int64(i) < N; i += 1 {
		A[i] += A[i-1]
	}

	if A[int(min(N-1, D-1))] >= C {
		return "Infinity"
	}

	if A[0]*D < C {
		return "Impossible"
	}

	l, r := int64(0), D
	for l <= r {
		m := l + (r-l)/2

		s := int64(0)
		if m <= N-1 {
			s += D / (m + 1) * A[m]
			r := D % (m + 1)
			if r > 0 {
				s += A[r-1]
			}
		} else {
			s += D / (m + 1) * A[N-1]
			r := D % (m + 1)
			if r > 0 {
				r = min(r, N)
				s += A[r-1]
			}
		}

		if s >= C {
			l = m + 1
		} else {
			r = m - 1
		}
	}

	return strconv.FormatInt(r, 10)

}

func main() {
	in := bufio.NewReader(os.Stdin)

	fmt.Fscan(in, &T)
	A = make([]int64, 200005)
	for tt := int64(0); tt < T; tt += 1 {
		fmt.Fscan(in, &N, &C, &D)
		for i := 0; int64(i) < N; i += 1 {
			fmt.Fscan(in, &A[i])
		}

		fmt.Println(solve())
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	//输入t
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		var c, d int64
		fmt.Fscan(in, &c, &d)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
		}
		sort.Ints(a)
		maxn := d * int64(a[n-1])
		if maxn < c {
			fmt.Fprintln(out, "Impossible")
			continue
		}
		sum := int64(0)
		for j := n - 1; j >= max(n-int(d), 0); j-- {
			sum += int64(a[j])
		}
		if sum >= c {
			fmt.Fprintln(out, "Infinity")
			continue
		}
		l := int64(0)
		r := int64(1e16 + 1)
		k := (l + r + 1) / 2
		for l < r {
			sum = int64(0)
			k = (l + r + 1) / 2
			if k+1 >= d {
				for j := n - 1; j >= max(n-int(d), 0); j-- {
					sum += int64(a[j])
				}
			} else {
				for j := n - 1; j >= max(n-int(k)-1, 0); j-- {
					sum += int64(a[j])
				}
				if k == 0 {
					sum = int64(a[n-1]) * d
				} else {
					times := d / (k + 1)
					tempSum := times * sum
					left := d % (k + 1)
					for j := n - 1; j >= max(n-int(left), 0); j-- {
						tempSum += int64(a[j])
					}
					sum = tempSum
				}

			}
			if sum > c {
				l = k
			} else if sum == c {
				l = k
			} else {
				r = k - 1
			}
		}
		// 输出res
		fmt.Fprintln(out, l)
	}
}

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	//输入t
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		var c, d int64
		fmt.Fscan(in, &c, &d)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
		}
		sort.Ints(a)
		maxn := d * int64(a[n-1])
		if maxn < c {
			fmt.Fprintln(out, "Impossible")
			continue
		}
		sum := int64(0)
		for j := n - 1; j >= max(n-int(d), 0); j-- {
			sum += int64(a[j])
		}
		if sum >= c {
			fmt.Fprintln(out, "Infinity")
			continue
		}
		l := int64(-1)
		r := int64(d + 1)
		k := (l + r + 1) / 2
		for l < r {
			sum = int64(0)
			k = (l + r + 1) / 2
			if k+1 >= d {
				for j := n - 1; j >= max(n-int(d), 0); j-- {
					sum += int64(a[j])
				}
			} else {
				for j := n - 1; j >= max(n-int(k)-1, 0); j-- {
					sum += int64(a[j])
				}
				if k == 0 {
					sum = int64(a[n-1]) * d
				} else {
					times := d / (k + 1)
					tempSum := times * sum
					left := d % (k + 1)
					for j := n - 1; j >= max(n-int(left), 0); j-- {
						tempSum += int64(a[j])
					}
					sum = tempSum
				}

			}
			if sum > c {
				l = k
			} else if sum == c {
				l = k
				//break
			} else {
				r = k - 1
			}
		}
		// 输出res
		fmt.Fprintln(out, l)
	}
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

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

func bsearch1(ssum []int, l, r int, c int) int {
	if l == r { return l }
	m := (l + r + 1) >> 1
	if ssum[m] >= c { return bsearch1(ssum, m, r, c) }
	return bsearch1(ssum, l, m-1, c)
}

func bsearch2(l, r int, A, B int) int {
	if l == r { return l }
	m := (l + r + 1) >> 1
	if A*m <= B { return bsearch2(m, r, A, B) }
	return bsearch2(l, m-1, A, B)
}

func max(a, b int) int {
	return -min(-a, -b)
}

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n, c, d int
		fmt.Fscan(r, &n, &c, &d)

		a := make([]int, n)
		for i := range a {
			fmt.Fscan(r, &a[i])
		}

		sort.Ints(a)
		ssum := make([]int, n+1)
		for i := n-1; i >= 0; i-- {
			ssum[i] = a[i] + ssum[i+1]
		}

		if a[n-1]*d < c {
			fmt.Fprintln(w, "Impossible")
		} else if ssum[n-min(n, d)] >= c {
			fmt.Fprintln(w, "Infinity")
		} else {
			k := 0

			for i := n-1; i >= 0 && c/ssum[i] > 0 ; i-- {
				// fmt.Fprintln(w, "****************")
				// fmt.Fprintln(w, "i ", i)
				cycles := c / ssum[i]
				if c % ssum[i] == 0 {
					cycles--
				}
				// fmt.Fprintln(w, "cycles ", cycles)
				j := bsearch1(ssum, i, n, c - cycles*ssum[i])
				// fmt.Fprintln(w, "j ", j)
				l := bsearch2(0, d, cycles, d - n + j - cycles*(n-i))
				// fmt.Fprintln(w, "l ", l)
				if cycles*(n-i+l) + n - j <= d {
					k = max(k, n-i+l-1)
				}
				// fmt.Fprintln(w, "k ", k)
			}

			fmt.Fprintln(w, k)
		}
	}

}

package main

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

const cf = true

func solve() {
	var n, c, d int
	fmt.Fscan(in, &n, &c, &d)
	sums := make([]int, n)
	for i := range sums {
		fmt.Fscan(in, &sums[i])
	}
	sort.Slice(sums, func(i, j int) bool {
		return sums[i] > sums[j]
	})

	for i := 1; i < n; i++ {
		sums[i] += sums[i-1]
	}

	daysNeeded := c/sums[0] + min(c%sums[0], 1)
	if daysNeeded > d {
		fmt.Fprintln(out, "Impossible")
		return
	}
	mx := sums[n-1]
	if d <= n {
		mx = sums[d-1]
	}
	if mx >= c {
		fmt.Fprintln(out, "Infinity")
		return
	}

	good := func(k int) bool {
		sum := sums[n-1]
		if k < n {
			sum = sums[k]
		}
		cnt := d / (k + 1)

		left := d - cnt*(k+1)
		sumLeft := sums[n-1]
		if left == 0 {
			sumLeft = 0
		} else if left < n {
			sumLeft = sums[left-1]
		}
		return sum*cnt+sumLeft >= c
	}

	ans := 0
	l, r := 0, int(1e16)
	for l < r {
		mid := (l + r) / 2
		if good(mid) {
			ans = mid
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Fprintln(out, ans)
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

func GCD(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}

	return a
}

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []byte(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"index/suffixarray"
	"log"
	"math"
	"net"
	"os"
	"path"
	"sort"
	"strconv"
	"strings"
	"time"
)

// For Codeforces
func main() {
	io := newStdIO()
	defer io.Flush()
	for T := io.ScanUInt16(); T > 0; T-- {
		solve(&io)
	}
}

func MaxCoin(arr []int64, k, d int64) int64 {
	tmp := SumN(arr[:Min(int64(len(arr)), k+1)])
	m := tmp * (d / (k + 1))
	m += SumN(arr[:Min(int64(len(arr)), d%(k+1))])
	return m
}
func solve(io *IO) {
	n := io.ScanInt32()
	arr := make([]int64, n)
	c := io.ScanInt64()
	d := io.ScanInt64()
	for i := int32(0); i < n; i++ {
		arr[i] = io.ScanInt64()
	}

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

	if MaxCoin(arr, d, d) >= c {
		io.PrintLn("Infinity")
		return
	}
	if MaxCoin(arr, 0, d) < c {
		io.PrintLn("Impossible")
		return
	}

	var l, r int64
	l = 0
	r = d
	for r-l > 1 {
		middle := (l + r + 1) / 2
		if MaxCoin(arr, middle, d) >= c {
			l = middle
		} else {
			r = middle
		}
	}
	io.PrintLn(l)

}
func SumN(n []int64) int64 {
	m := int64(0)
	for i := 0; i < len(n); i++ {
		m += n[i]
	}
	return m
}

// #region INTERFACES

// From https://pkg.go.dev/golang.org/x/exp/constraints
type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}
type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
type Integer interface {
	Signed | Unsigned
}
type Float interface {
	~float32 | ~float64
}
type Complex interface {
	~complex64 | ~complex128
}
type Ordered interface {
	Integer | Float | ~string
}

type Prioritizable[T any] interface {
	PriorTo(x T) bool // If you take this as a relation: if (a,b) in R => (b,a) not in R
}

// #endregion
// #region TYPES WITH METHODS
// #region SingleLinkedList
type singleLinkedListNode[T comparable] struct {
	Value T
	Next  *singleLinkedListNode[T]
}

type SingleLinkedList[T comparable, IndexType Unsigned] struct {
	first  *singleLinkedListNode[T]
	last   *singleLinkedListNode[T]
	length IndexType
}

func NewSingleLinkedList[T comparable, IndexType Unsigned]() *SingleLinkedList[T, IndexType] {
	return &SingleLinkedList[T, IndexType]{
		first:  nil,
		last:   nil,
		length: 0,
	}
}
func (l *SingleLinkedList[T, I]) Len() I { return l.length }

// length > 0
func (l *SingleLinkedList[T, I]) First() T { return l.first.Value }

// length > 0
func (l *SingleLinkedList[T, I]) Last() T { return l.last.Value }

func (l *SingleLinkedList[T, I]) InsertFirst(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.first = &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) InsertLast(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.last.Next = &singleLinkedListNode[T]{
			Value: value,
			Next:  nil,
		}
		l.last = l.last.Next
	}
	l.length++
}

// index <= length
func (l *SingleLinkedList[T, I]) InsertAt(index I, value T) {
	if index == 0 {
		l.InsertFirst(value)
		return
	}
	if index == l.length {
		l.InsertLast(value)
		return
	}

	n := l.first
	for index > 1 {
		n = n.Next
		index--
	}
	n.Next = &singleLinkedListNode[T]{
		Value: value,
		Next:  n.Next,
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) Contains(value T) bool {
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		if tmp.Value == value {
			return true
		}
		tmp = tmp.Next
	}
	return false
}
func (l *SingleLinkedList[T, I]) Clear() {
	l.first = nil
	l.last = nil
	l.length = 0
}

// index < length
func (l *SingleLinkedList[T, I]) GetElementAt(index I) T {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	return n.Value
}

// index < length
func (l *SingleLinkedList[T, I]) SetElementAt(index I, value T) {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	n.Value = value
}

func (l *SingleLinkedList[T, I]) RemoveFirst() T {
	tmp := l.first
	l.first = l.first.Next
	l.length--
	if l.length == 0 {
		l.last = nil
	}
	return tmp.Value
}
func (l *SingleLinkedList[T, I]) RemoveLast() (value T) {
	value = l.last.Value
	if l.length == 1 {
		l.first = nil
		l.last = nil
		l.length = 0
		return
	}

	tmp := l.first
	for i := I(2); i < l.length; i++ {
		tmp = tmp.Next
	}
	l.last = tmp
	return
}

func (l *SingleLinkedList[T, I]) RemoveAt(index I) T {
	if index == 0 {
		return l.RemoveFirst()
	}
	if index == l.length-1 {
		return l.RemoveLast()
	}

	tmp := l.first
	for i := I(1); i < index; i++ {
		tmp = tmp.Next
	}
	res := tmp.Next.Value
	tmp.Next = tmp.Next.Next
	return res
}

func (l *SingleLinkedList[T, I]) ToSlice() (res []T) {
	res = make([]T, 0, l.length)
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		res = append(res, tmp.Value)
		tmp = tmp.Next
	}
	return
}
func (it *SingleLinkedList[T, I]) String() string {
	return "Qua:: " + fmt.Sprint(it.ToSlice())
}

// #endregion
// #region Queue

type Queue[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewQueue[T comparable, I Unsigned]() *Queue[T, I] {
	return &Queue[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (q *Queue[T, I]) Len() I          { return q.l.length }
func (q *Queue[T, I]) Enqueue(value T) { q.l.InsertLast(value) }
func (q *Queue[T, I]) Dequeue(T) T     { return q.l.RemoveFirst() }
func (q *Queue[T, I]) Preview() T      { return q.l.First() }
func (q *Queue[T, I]) String() string  { return q.l.String() }

// #endregion
// #region Stack

type Stack[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewStack[T comparable, I Unsigned]() *Stack[T, I] {
	return &Stack[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (s *Stack[T, I]) Len() I         { return s.l.length }
func (s *Stack[T, I]) Push(value T)   { s.l.InsertFirst(value) }
func (s *Stack[T, I]) Pop(T) T        { return s.l.RemoveFirst() }
func (s *Stack[T, I]) Preview() T     { return s.l.First() }
func (s *Stack[T, I]) String() string { return s.l.String() }

// #endregion
// #region Heap
type BinaryHeap[T Prioritizable[T], I Signed] struct {
	s []T
}

func NewBinaryHeap[T Prioritizable[T], I Signed](s []T) (h *BinaryHeap[T, I]) {
	h = &BinaryHeap[T, I]{
		s: s,
	}

	for i := (h.Len() - 2) / 2; i >= 0; i-- {
		h.heapifyDown(i)
	}
	return
}
func (h *BinaryHeap[T, I]) Len() I {
	return I(len(h.s))
}
func (h *BinaryHeap[T, I]) Push(value T) {
	h.s = append(h.s, value)
	h.heapifyUp(h.Len() - 1)
}
func (h *BinaryHeap[T, I]) Pop() (res T) {
	res = h.s[0]
	h.s[0] = h.s[h.Len()-1]
	h.s = h.s[:h.Len()-1]
	h.heapifyDown(0)
	return
}

func (h *BinaryHeap[T, I]) heapifyDown(index I) bool {
	origin := index
	for {
		j := index*2 + 2
		if j < h.Len() {
			if h.s[j-1].PriorTo(h.s[j]) {
				j--
			}
		} else {
			if j <= h.Len() && !h.s[j].PriorTo(h.s[index]) {
				h.s[j], h.s[index] = h.s[index], h.s[j]
			}
			break
		}
		if h.s[j].PriorTo(h.s[index]) {
			h.s[j], h.s[index] = h.s[index], h.s[j]
			index = j
		} else {
			break
		}
	}
	return origin != index
}
func (h *BinaryHeap[T, I]) heapifyUp(index I) {
	for {
		parent := (index - 1) / 2
		if parent == index || h.s[parent].PriorTo(h.s[index]) {
			break
		}
		h.s[index], h.s[parent] = h.s[parent], h.s[index]
		index = parent
	}
}

// #endregion

// #endregion

// #region FUNCTIONS
func Max[T Ordered](a, b T) T {
	if a >= b {
		return a
	}
	return b
}
func Min[T Ordered](a, b T) T {
	if a <= b {
		return a
	}
	return b
}
func Abs[T Integer | Float](a T) T {
	if a < 0 {
		return -a
	}
	return a
}
func Swap[T any](a, b *T) {
	*a, *b = *b, *a
}

// At least one != 0
func GCD[T Unsigned](a, b T) T {
	if b < a {
		Swap(&a, &b)
	}
	for {
		if a == 0 {
			return b
		}
		r := (b % a)
		b = a
		a = r
	}
}

// At least one != 0
func LCM[T Unsigned](a, b T) T {
	return (a * b) / GCD(a, b)
}

func First[T any](a T, _ any) T { return a }

// #endregion

// #region IO STUFF
type IO struct {
	r *bufio.Reader
	w *bufio.Writer
}

func newStdIO() IO {
	return IO{
		r: bufio.NewReader(os.Stdin),
		w: bufio.NewWriter(os.Stdout),
	}
}

// Is assumed that input.txt file exists
func newFileIO() IO {
	return IO{
		r: bufio.NewReader(First(os.Open("input.txt"))),
		w: bufio.NewWriter(First(os.OpenFile("output.txt", os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.ModePerm))),
	}
}

func (io *IO) ScanInt8() (x int8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt16() (x int16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt32() (x int32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt64() (x int64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanUInt8() (x uint8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt16() (x uint16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt32() (x uint32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt64() (x uint64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanFloat32() (x float32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanFloat64() (x float64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanString() (x string) { fmt.Fscan(io.r, &x); return }

func (io *IO) Print(x ...any)   { fmt.Fprint(io.w, x...) }
func (io *IO) PrintLn(x ...any) { fmt.Fprintln(io.w, x...) }

func (io *IO) Flush() { io.w.Flush() }

// #endregion

// #region KEEP IMPORTS
func D() {
	_ = bufio.Reader{}
	_ = bytes.Buffer{}
	_ = suffixarray.Index{}
	_ = log.Default()
	_ = math.Abs(0)
	_ = net.Dialer{}
	_ = path.ErrBadPattern
	_ = sort.Float64sAreSorted(nil)
	_ = strconv.ErrRange
	_ = strings.Builder{}
	_ = time.ANSIC
	_ = newStdIO()
	_ = newFileIO()
}

// #endregion

package main

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

var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

// source: _
func solve() {
	n, c, d := _readInt(), _readInt(), _readInt()
	_, a := _readArr(n)
	sort.Slice(a, func(i, j int) bool {
		return a[i] > a[j]
	})

	//sum := 0
	//for i := 0; i < d && i < n; i++ {
	//	sum += a[i]
	//}
	//if sum > c {
	//	_print("Infinity")
	//	return
	//}

	if a[0]*d < c {
		_print("Impossible")
		return
	}

	m := _max(n, d)
	ps := make([]int, m)
	ps[0] = a[0]
	for i := 1; i < n; i++ {
		ps[i] = a[i] + ps[i-1]
	}
	for i := n; i < d; i++ {
		ps[i] = ps[i-1]
	}

	for k := 0; k < m; k++ {
		f, p := d/(k+1), d%(k+1)
		x := ps[k] * f
		if p > 0 {
			x += ps[p-1]
		}
		if x < c {
			_print(k - 1)
			return
		}
	}

	_print("Infinity")
	return
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		solve()
	}
}

// ====
func _readInt() int {
	var x int
	fmt.Fscan(in, &x)
	return x
}
func _readStr() string {
	var x string
	fmt.Fscan(in, &x)
	return x
}
func _readArr(x ...int) (int, []int) {
	var n int
	if len(x) == 0 {
		fmt.Fscan(in, &n)
	} else {
		n = x[0]
	}
	var v = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &v[i])
	}
	return n, v
}
func _print(x ...any) {
	fmt.Fprintln(out, x...)
}
func _max(x ...int) int {
	mi := 0
	for i := 1; i < len(x); i++ {
		if x[i] > x[mi] {
			mi = i
		}
	}
	return x[mi]
}
func _min(x ...int) int {
	mi := 0
	for i := 1; i < len(x); i++ {
		if x[i] < x[mi] {
			mi = i
		}
	}
	return x[mi]
}
func _sum(x ...int) int {
	res := 0
	for _, i := range x {
		res += i
	}
	return res
}
func _abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func _sortStr(x string) string {
	r := []rune(x)
	sort.Slice(r, func(i, j int) bool {
		return r[i] < r[j]
	})
	return string(r)
}
func _reverseInts(x []int) {
	n := len(x)
	for i := 0; i < n/2; i++ {
		x[i], x[n-1-i] = x[n-1-i], x[i]
	}
}
func _reverseStr(s string) string {
	x := []rune(s)
	n := len(x)
	for i := 0; i < n/2; i++ {
		x[i], x[n-1-i] = x[n-1-i], x[i]
	}
	return string(x)
}
func _makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

const mod int = 998244353
const N int = 5e5 + 5

func main() {
	sc.Buffer(make([]byte, 500000*1+1), 500000)
	sc.Split(bufio.ScanWords)

	T := nextInt()
	for T > 0 {
		T--
		n := nextInt()
		a := make([]int, n)
		c, d := nextInt64(), nextInt64()
		for i := 0; i < n; i++ {
			a[i] = nextInt()
		}
		sort.Slice(a, func(i, j int) bool {
			return a[i] > a[j]
		})
		a = append([]int{0}, a...)
		//fmt.Printf("%#v\n", a)
		s := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			s[i] = s[i-1] + int64(a[i])
		}
		if int64(a[1])*d < c {
			fmt.Println("Impossible")
		} else if s[min(d, int64(n))] >= c {
			fmt.Println("Infinity")
		} else {
			l, r := int64(0), d
			for l < r {
				mid := (l + r + 1) >> 1
				if func(x int64) bool {
					t1, t2 := d/(x+1), d%(x+1)
					return t1*s[min(int64(n), x+1)]+s[min(int64(n), t2)] >= c
				}(mid) {
					l = mid
				} else {
					r = mid - 1
				}
			}
			fmt.Println(l)
		}
	}
}

func min(args ...int64) int64 {
	res := args[0]
	for _, v := range args {
		if v < res {
			res = v
		}
	}
	return res
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"sort"
	"strings"
)

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(curCase int) {
		var n int
		var c int64
		var d int64
		Fscan(in, &n, &c, &d)
		// int64 ?
		a := make([]int64, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		sort.Slice(a, func(i, j int) bool { return a[i] > a[j] })
		f := func(k int64) int64 {
			if k == 0 {
				return d * a[0]
			}
			if k < int64(n) {
				sz := k + 1
				sum := int64(0)
				for _, v := range a[:sz] {
					sum += v
				}
				sum2 := int64(0)
				for _, v := range a[:d%sz] {
					sum2 += v
				}
				res := d/sz*sum + sum2
				return res
			} else {
				sz := k + 1
				sum := int64(0)
				for _, v := range a {
					sum += v
				}
				sum2 := int64(0)
				if d%sz <= int64(n) {
					for _, v := range a[:d%sz] {
						sum2 += v
					}
				} else {
					sum2 = sum
				}

				res := d/sz*sum + sum2
				return res
			}
		}

		if f(0) < c {
			Fprintln(out, "Impossible")
		} else  {
			if f(d+10) >= c {
				Fprintln(out, "Infinity")
			} else {
				ans := sort.Search(int(d+10), func(k int) bool {
					k++
					return f(int64(k)) < c
				})
				Fprintln(out, ans)
			}
		}
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

	leftData, _ := ioutil.ReadAll(in)
	if s := strings.TrimSpace(string(leftData)); s != "" {
		panic("有未读入的数据：\n" + s)
	}

}

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	//输入t
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		var c, d int64
		fmt.Fscan(in, &c, &d)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
		}
		sort.Ints(a)
		maxn := d * int64(a[n-1])
		if maxn < c {
			fmt.Fprintln(out, "Impossible")
			continue
		}
		sum := int64(0)
		for j := n - 1; j >= max(n-int(d), 0); j-- {
			sum += int64(a[j])
		}
		if sum >= c {
			fmt.Fprintln(out, "Infinity")
			continue
		}
		l := int64(0)
		r := int64(1e16 + 1)
		k := (l + r + 1) / 2
		for l < r {
			sum = int64(0)
			k = (l + r + 1) / 2
			if k+1 >= d {
				for j := n - 1; j >= max(n-int(d), 0); j-- {
					sum += int64(a[j])
				}
			} else {
				for j := n - 1; j >= max(n-int(k)-1, 0); j-- {
					sum += int64(a[j])
				}
				if k == 0 {
					sum = int64(a[n-1]) * d
				} else {
					times := d / (k + 1)
					tempSum := times * sum
					left := d % (k + 1)
					for j := n - 1; j >= max(n-int(left), 0); j-- {
						tempSum += int64(a[j])
					}
					sum = tempSum
				}

			}
			if sum > c {
				l = k
			} else if sum == c {
				r = k
				l = k
				break
			} else {
				r = k - 1
			}
		}
		// 输出res
		fmt.Fprintln(out, l)
	}
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	//输入t
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		var c, d int64
		fmt.Fscan(in, &c, &d)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
		}
		sort.Ints(a)
		maxn := d * int64(a[n-1])
		if maxn < c {
			fmt.Fprintln(out, "Impossible")
			continue
		}
		sum := int64(0)
		for j := n - 1; j >= max(n-int(d), 0); j-- {
			sum += int64(a[j])
		}
		if sum >= c {
			fmt.Fprintln(out, "Infinity")
			continue
		}
		l := int64(0)
		r := int64(1e16 + 1)
		k := (l + r) / 2
		for l < r {
			sum = int64(0)
			k = (l + r) / 2
			if k+1 >= d {
				for j := n - 1; j >= max(n-int(d), 0); j-- {
					sum += int64(a[j])
				}
			} else {
				for j := n - 1; j >= max(n-int(k)-1, 0); j-- {
					sum += int64(a[j])
				}
				if k == 0 {
					sum = int64(a[n-1]) * d
				} else {
					times := d / (k + 1)
					tempSum := times * sum
					left := d % (k + 1)
					for j := n - 1; j >= max(n-int(left), 0); j-- {
						tempSum += int64(a[j])
					}
					sum = tempSum
				}

			}
			if sum > c {
				l = k + 1
			} else if sum == c {
				r = k
				l = k
				break
			} else {
				r = k - 1
			}
		}
		// 输出res
		fmt.Fprintln(out, l)
	}
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	//输入t
	var t, n int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		var c, d int64
		fmt.Fscan(in, &c, &d)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
		}
		sort.Ints(a)
		maxn := d * int64(a[n-1])
		if maxn < c {
			fmt.Fprintln(out, "Impossible")
			continue
		}
		sum := int64(0)
		for j := n - 1; j >= max(n-int(d), 0); j-- {
			sum += int64(a[j])
		}
		if sum >= c {
			fmt.Fprintln(out, "Infinity")
			continue
		}
		l := int64(0)
		r := int64(1e16 + 1)
		k := (l + r) / 2
		for l < r {
			sum = int64(0)
			k = (l + r) / 2
			if k+1 >= d {
				for j := n - 1; j >= max(n-int(d), 0); j-- {
					sum += int64(a[j])
				}
			} else {
				for j := n - 1; j >= max(n-int(k)-1, 0); j-- {
					sum += int64(a[j])
				}
				if k == 0 {
					sum = int64(a[n-1]) * d
				} else {
					times := d / (k + 1)
					tempSum := times * sum
					left := d % (k + 1)
					for j := n - 1; j >= max(n-int(left), 0); j-- {
						tempSum += int64(a[j])
					}
					sum = tempSum
				}

			}
			if sum > c {
				l = k + 1
			} else if sum == c {
				r = k
				//break
			} else {
				r = k - 1
			}
		}
		// 输出res
		fmt.Fprintln(out, l)
	}
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

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

func bsearch(ssum []int, l, r int, d, c, n int) int {
	if l == r { return l }
	m := (l + r + 1) >> 1
	if (d/(m+1))*ssum[n-m-1] + ssum[n-(d%(m+1))] > c { return bsearch(ssum, l, m-1, d, c, n) }
	return bsearch(ssum, m, r, d, c, n)
}

func max(a, b int) int {
	return -min(-a, -b)
}

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n, c, d int
		fmt.Fscan(r, &n, &c, &d)

		a := make([]int, n)
		for i := range a {
			fmt.Fscan(r, &a[i])
		}

		sort.Ints(a)
		ssum := make([]int, n+1)
		for i := n-1; i >= 0; i-- {
			ssum[i] = a[i] + ssum[i+1]
		}

		if a[n-1]*d < c {
			fmt.Fprintln(w, "Impossible")
		} else if ssum[n-min(n, d)] >= c {
			fmt.Fprintln(w, "Infinity")
		} else {
			k := 0

			for i := n-1; i >= 0 && c/ssum[i] > 0 ; i-- {
				cycles := c / ssum[i]
				j := n
				for ; j >= i && cycles*ssum[i] + ssum[j] < c ; j-- {}
				for l := 0; cycles*(n-i+l) + n-j <= d ; l++ {
					k = max(k, n-i+l-1)
				}
			}

			fmt.Fprintln(w, k)
		}
	}

}

package main

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

func bsearch(ssum []int, l, r int, d, c, n int) int {
	if l == r { return l }
	m := (l + r + 1) >> 1
	if (d/(m+1))*ssum[n-m-1] + ssum[n-(d%(m+1))] > c { return bsearch(ssum, l, m-1, d, c, n) }
	return bsearch(ssum, m, r, d, c, n)
}

func max(a, b int) int {
	return -min(-a, -b)
}

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		var n, c, d int
		fmt.Fscan(r, &n, &c, &d)

		a := make([]int, n)
		for i := range a {
			fmt.Fscan(r, &a[i])
		}

		sort.Ints(a)
		ssum := make([]int, n+1)
		for i := n-1; i >= 0; i-- {
			ssum[i] = a[i] + ssum[i+1]
		}

		if a[n-1]*d < c {
			fmt.Fprintln(w, "Impossible")
		} else if ssum[n-min(n, d)] >= c {
			fmt.Fprintln(w, "Infinity")
		} else {
			k := 0

			for i := n-1; i >= 0 && c/ssum[i] > 0 ; i-- {
				cycles := c / ssum[i]
				j := n-1
				for ; j >= i && cycles*ssum[i] + ssum[j] < c ; j-- {}
				for l := 0; cycles*(n-i+l) + n-j <= d ; l++ {
					k = max(k, n-i+l-1)
				}
			}

			fmt.Fprintln(w, k)
		}
	}

}

package main

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

const cf = true

func solve() {
	var n, c, d int
	fmt.Fscan(in, &n, &c, &d)
	sums := make([]int, n)
	for i := range sums {
		fmt.Fscan(in, &sums[i])
	}
	sort.Slice(sums, func(i, j int) bool {
		return sums[i] > sums[j]
	})
	daysNeeded := c/sums[0] + min(c%sums[0], 1)
	if daysNeeded > d {
		fmt.Fprintln(out, "Impossible")
		return
	}
	if sums[0] >= c {
		fmt.Fprintln(out, "Infinity")
		return
	}

	for i := 1; i < n; i++ {
		sums[i] += sums[i-1]
	}

	good := func(k int) bool {
		sum := sums[n-1]
		if k < n {
			sum = sums[k]
		}
		cnt := d / (k + 1)

		left := d - cnt*(k+1)
		sumLeft := sums[n-1]
		if left == 0 {
			sumLeft = 0
		} else if left < n {
			sumLeft = sums[left-1]
		}
		return sum*cnt+sumLeft >= c
	}

	ans := 0
	l, r := 0, int(1e16)
	for l < r {
		mid := (l + r) / 2
		if good(mid) {
			ans = mid
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Fprintln(out, ans)
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

func GCD(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}

	return a
}

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []byte(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

const cf = true

func solve() {
	var n, c, d int
	fmt.Fscan(in, &n, &c, &d)
	sums := make([]int, n)
	for i := range sums {
		fmt.Fscan(in, &sums[i])
	}
	sort.Slice(sums, func(i, j int) bool {
		return sums[i] > sums[j]
	})
	daysNeeded := c / sums[0]
	if daysNeeded > d {
		fmt.Fprintln(out, "Impossible")
		return
	}
	if sums[0] >= c {
		fmt.Fprintln(out, "Infinity")
		return
	}

	for i := 1; i < n; i++ {
		sums[i] += sums[i-1]
	}

	good := func(k int) bool {
		sum := sums[n-1]
		if k < n {
			sum = sums[k]
		}
		cnt := d / (k + 1)

		left := d - cnt*(k+1)
		sumLeft := sums[n-1]
		if left == 0 {
			sumLeft = 0
		} else if left < n {
			sumLeft = sums[left-1]
		}
		return sum*cnt+sumLeft >= c
	}

	ans := 0
	l, r := 0, int(1e16)
	for l < r {
		mid := (l + r) / 2
		if good(mid) {
			ans = mid
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Fprintln(out, ans)
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

func GCD(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}

	return a
}

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []byte(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}


Vitaly enrolled in the course Advanced Useless Algorithms. The course consists of $$$n$$$ tasks. Vitaly calculated that he has $$$a_i$$$ hours to do the task $$$i$$$ from the day he enrolled in the course. That is, the deadline before the $$$i$$$-th task is $$$a_i$$$ hours. The array $$$a$$$ is sorted in ascending order, in other words, the job numbers correspond to the order in which the assignments are turned in.Vitaly does everything conscientiously, so he wants to complete each task by $$$100$$$ percent, or more. Initially, his completion rate for each task is $$$0$$$ percent.Vitaly has $$$m$$$ training options, each option can be used not more than once. The $$$i$$$th option is characterized by three integers: $$$e_i, t_i$$$ and $$$p_i$$$. If Vitaly uses the $$$i$$$th option, then after $$$t_i$$$ hours (from the current moment) he will increase the progress of the task $$$e_i$$$ by $$$p_i$$$ percent. For example, let Vitaly have $$$3$$$ of tasks to complete. Let the array $$$a$$$ have the form: $$$a = [5, 7, 8]$$$. Suppose Vitaly has $$$5$$$ of options: $$$[e_1=1, t_1=1, p_1=30]$$$, $$$[e_2=2, t_2=3, p_2=50]$$$, $$$[e_3=2, t_3=3, p_3=100]$$$, $$$[e_4=1, t_4=1, p_4=80]$$$, $$$[e_5=3, t_5=3, p_5=100]$$$. Then, if Vitaly prepares in the following way, he will be able to complete everything in time:   Vitaly chooses the $$$4$$$-th option. Then in $$$1$$$ hour, he will complete the $$$1$$$-st task at $$$80$$$ percent. He still has $$$4$$$ hours left before the deadline for the $$$1$$$-st task.  Vitaly chooses the $$$3$$$-rd option. Then in $$$3$$$ hours, he will complete the $$$2$$$-nd task in its entirety. He has another $$$1$$$ hour left before the deadline for the $$$1$$$-st task and $$$4$$$ hours left before the deadline for the $$$3$$$-rd task.  Vitaly chooses the $$$1$$$-st option. Then after $$$1$$$ hour, he will complete the $$$1$$$-st task for $$$110$$$ percent, which means that he will complete the $$$1$$$-st task just in time for the deadline.  Vitaly chooses the $$$5$$$-th option. He will complete the $$$3$$$-rd task for $$$2$$$ hours, and after another $$$1$$$ hour, Vitaly will complete the $$$3$$$-rd task in its entirety. Thus, Vitaly has managed to complete the course completely and on time, using the $$$4$$$ options.Help Vitaly — print the options for Vitaly to complete the tasks in the correct order. Please note: each option can be used not more than once. If there are several possible answers, it is allowed to output any of them.

The first line of input data contains an integer $$$T$$$ ($$$1 \le T \le 10^4$$$) —the number of input test cases in the test. The descriptions of the input test case follow. The first line of each test case description contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n,m \le 10^5$$$) —the number of jobs and the number of training options, respectively. The next line contains $$$n$$$ numbers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the time before the deadline of job $$$i$$$. The array values — are non-decreasing, that is $$$a_1 \le a_2 \le \dots \le a_n$$$. The following $$$m$$$ lines contain triples of numbers $$$e_i, t_i, p_i$$$ ($$$1 \le e_i \le n$$$, $$$1 \le t_i \le 10^9$$$, $$$1 \le p_i \le 100$$$) — if Vitaly chooses this option, then after $$$t_i$$$ hours he will increase the progress of the task $$$e_i$$$ by $$$p_i$$$ percent. The options are numbered from $$$1$$$ to $$$m$$$ in order in the input data. It is guaranteed that the sum of $$$n+m$$$ on all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print on the first line the number $$$k$$$, meaning that for $$$k$$$ of options, Vitaly will be able to complete each task by $$$100$$$ percent or more on time. The options should not be repeated. Or print -1 if Vitaly is unable to complete all tasks in time. If there is an answer, on the next line print $$$k$$$ of different integers from $$$1$$$ to $$$m$$$ — the numbers of the options in the order you want. If there is more than one answer, it is allowed to print any of them.

package main

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

type op struct {
	step []int
	cost int
}

func (o op) clone() op {
	a := make([]int, len(o.step))
	copy(a, o.step)
	return op{step: a, cost: o.cost}
}

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var m, n int
		fmt.Fscan(in, &n, &m)
		tasks := make([]int, n)
		operations := make([][][3]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &tasks[i])
		}
		for i := 0; i < m; i++ {
			var e, ti, p int
			fmt.Fscan(in, &e, &ti, &p)
			operations[e-1] = append(operations[e-1], [3]int{ti, p, i + 1})
		}
		//fmt.Println(operations)
		var ans []int
		used := 0
		for k := 0; k < n; k++ {
			dp := [101]op{}
			for i := 1; i < 101; i++ {
				dp[i] = op{cost: 1000000001}
			}
			for _, ints := range operations[k] {
				for i := 99; i >= 0; i-- {
					if dp[i].cost == 1000000001 {
						continue
					}
					time, p, number := ints[0], ints[1], ints[2]
					p += i
					if p > 100 {
						p = 100
					}
					if time+dp[i].cost+used <= tasks[k] && dp[p].cost > time+dp[i].cost {
						dp[p] = dp[i].clone()
						dp[p].step = append(dp[p].step, number)
						dp[p].cost += time
					}
				}
			}
			//fmt.Println(used, k, dp[100])
			used += dp[100].cost
			if used > tasks[k] {
				ans = []int{}
				break
			}
			ans = append(ans, dp[100].step...)
		}
		if len(ans) != 0 {
			fmt.Fprintln(out, len(ans))
			for i, an := range ans {
				fmt.Fprint(out, an)
				if i < len(ans)-1 {
					fmt.Fprint(out, " ")
				} else {
					fmt.Fprintln(out)
				}
			}
		} else {
			fmt.Fprintln(out, -1)
		}

	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1650F(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n, m, e, t, p int
o:
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &m)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		type pair struct{ t, p, i int }
		gs := make([][]pair, n)
		for i := 1; i <= m; i++ {
			Fscan(in, &e, &t, &p)
			gs[e-1] = append(gs[e-1], pair{t, p, i})
		}

		ans := []interface{}{}
		t := 0
		for k, g := range gs {
			dp := [101]int{}
			from := make([][101]int, len(g))
			for i := range dp {
				dp[i] = 1e9 + 1
			}
			dp[0] = 0
			for i, p := range g {
				for j := 100; j > 0; j-- {
					k := j - p.p
					if k < 0 {
						k = 0
					}
					if v := dp[k] + p.t; v < dp[j] {
						dp[j] = v
						from[i][j] = k
					} else {
						from[i][j] = j
					}
				}
			}
			t += dp[100]
			if t > a[k] {
				Fprintln(out, -1)
				continue o
			}
			for i, j := len(g)-1, 100; i >= 0; i-- {
				if from[i][j] != j {
					ans = append(ans, g[i].i)
					j = from[i][j]
				}
			}
		}
		Fprintln(out, len(ans))
		Fprintln(out, ans...)
	}
}

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


There are $$$n$$$ points on the plane, $$$(x_1,y_1), (x_2,y_2), \ldots, (x_n,y_n)$$$.You need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the triangle or on the side of the triangle). Calculate the minimum length of the shorter side of the triangle.

First line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). Each of the next $$$n$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \leq x_i,y_i \leq 10^9$$$).

Print the minimum length of the shorter side of the triangle. It can be proved that it's always an integer.

NoteIllustration for the first example: Illustration for the second example:

package main

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

func main() {
	var n, x, y, result int
	in := bufio.NewReaderSize(os.Stdin, 1024*1024)
	fmt.Fscanf(in, "%d\n", &n)
	for ; n > 0; n-- {
		fmt.Fscanf(in, "%d %d\n", &x, &y)
		if x+y > result {
			result = x + y
		}
	}
	fmt.Println(result)
}

package main

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

func main() {
	var n, x, y, result int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d\n", &n)
	for ; n > 0; n-- {
		fmt.Fscanf(in, "%d %d\n", &x, &y)
		if x+y > result {
			result = x + y
		}
	}
	fmt.Println(result)
}

package main

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, x, y, ans int
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d %d\n", &x, &y)
		ans = max(ans, x+y)
	}
	fmt.Println(ans)
}

package main

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

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

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

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readi()
	var ans int
	for i := 0; i < n; i++ {
		x := readi()
		y := readi()
		d := y + x
		ans = max(ans, d)
	}
	println(ans)
}

package main

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

func main() {
	scanner := bufio.NewReadWriter(bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout))

	var input int64
	fmt.Fscanf(scanner, "%d\n", &input)

	var maxX int64 = -1//; var maxY int64 = -1
	for i := int64(0); i < input; i++ {
		var x, y int64
		fmt.Fscanf(scanner, "%d %d\n", &x, &y)
		//// fmt.Printf("%d %d %d/%d", x, y, i, input)
		//if x == y {
		//	maxX = maxI(maxX, x)
		//} else {
		//	maxY = maxI(maxY, maxI(x, y))
		//}
		maxX = maxI(maxX, x+y)
	}
	fmt.Fprintf(scanner, "%d", maxX)

	// fmt.Printf("max %d %d", maxX, maxY)
	//if maxY > maxX {
	//	fmt.Printf("%d\n", maxY+1)
	//} else {
	//	fmt.Printf("%d\n", maxX*2)
	//}
	scanner.Flush()
}

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

package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	var x, y, ans float64
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &y)
		ans = math.Max(ans, x+y)
	}
	fmt.Println(ans)
}

package main

import "fmt"

func main() {
	var input int64
	fmt.Scanf("%d", &input)

	var maxX int64 = -1; var maxY int64 = -1
	for i := int64(0); i < input; i++ {
		var x, y int64
		fmt.Scanf("%d %d", &x, &y)
		if x == y {
			maxX = maxI(maxX, x)
		} else {
			maxY = maxI(maxY, maxI(x, y))
		}
	}

	if maxX >= maxY {
		fmt.Printf("%d", maxX*2)
	} else {
		fmt.Printf("%d", maxY+1)
	}
}

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

package main

import "fmt"

func main() {
	var input int64
	fmt.Scanf("%d", &input)

	var maxX int64 = -1; var maxY int64 = -1
	for i := int64(0); i < input; i++ {
		var x, y int64
		fmt.Scanf("%d %d", &x, &y)
		fmt.Printf("%d %d %d/%d", x, y, i, input)
		if x == y {
			maxX = maxI(maxX, x)
		} else {
			maxY = maxI(maxY, maxI(x, y))
		}
	}

	fmt.Printf("max %d %d", maxX, maxY)
	if maxY > maxX {
		fmt.Printf("%d\n", maxY+1)
	} else {
		fmt.Printf("%d\n", maxX*2)
	}
}

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

package main

import "fmt"

func main() {
	var input int64
	fmt.Scanf("%d\n", &input)

	var maxX int64 = -1; var maxY int64 = -1
	for i := int64(0); i < input; i++ {
		var x, y int64
		fmt.Scanf("%d %d\n", &x, &y)
		// fmt.Printf("%d %d %d/%d", x, y, i, input)
		if x == y {
			maxX = maxI(maxX, x)
		} else {
			maxY = maxI(maxY, maxI(x, y))
		}
	}

	// fmt.Printf("max %d %d", maxX, maxY)
	if maxY > maxX {
		fmt.Printf("%d\n", maxY+1)
	} else {
		fmt.Printf("%d\n", maxX*2)
	}
}

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

package main

import "fmt"

func main() {
	var input int64
	fmt.Scanf("%d", &input)

	var maxX int64 = -1; var maxY int64 = -1
	for i := int64(0); i < input; i++ {
		var x, y int64
		fmt.Scanf("%d %d", &x, &y)
		if x == y {
			maxX = maxI(maxX, x)
		} else {
			maxY = maxI(maxY, maxI(x, y))
		}
	}

	if maxY > maxX {
		fmt.Printf("%d", maxY+1)
	} else {
		fmt.Printf("%d", maxX*2)
	}
}

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


There is a forest that we model as a plane and live $$$n$$$ rare animals. Animal number $$$i$$$ has its lair in the point $$$(x_{i}, y_{i})$$$. In order to protect them, a decision to build a nature reserve has been made.The reserve must have a form of a circle containing all lairs. There is also a straight river flowing through the forest. All animals drink from this river, therefore it must have at least one common point with the reserve. On the other hand, ships constantly sail along the river, so the reserve must not have more than one common point with the river.For convenience, scientists have made a transformation of coordinates so that the river is defined by $$$y = 0$$$. Check whether it is possible to build a reserve, and if possible, find the minimum possible radius of such a reserve.

The first line contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of animals.  Each of the next $$$n$$$ lines contains two integers $$$x_{i}$$$, $$$y_{i}$$$ ($$$-10^7 \le x_{i}, y_{i} \le 10^7$$$) — the coordinates of the $$$i$$$-th animal's lair. It is guaranteed that $$$y_{i} \neq 0$$$. No two lairs coincide.

If the reserve cannot be built, print $$$-1$$$. Otherwise print the minimum radius. Your answer will be accepted if absolute or relative error does not exceed $$$10^{-6}$$$. Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is considered correct if $$$\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$$$.

NoteIn the first sample it is optimal to build the reserve with the radius equal to $$$0.5$$$ and the center in $$$(0,\ 0.5)$$$.In the second sample it is impossible to build a reserve.In the third sample it is optimal to build the reserve with the radius equal to $$$\frac{5}{8}$$$ and the center in $$$(\frac{1}{2},\ \frac{5}{8})$$$.

package main

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

// github.com/EndlessCheng/codeforces-go
func Sol1059D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()
	const eps = 1e-8
	search := func(l, r float64, f func(x float64) bool) float64 {
		for i := 0; i < 200; i++ {
			mid := (l + r) / 2
			if f(mid) {
				r = mid
			} else {
				l = mid
			}
		}
		return (l + r) / 2
	}

	var n int
	Fscan(in, &n)
	type pair struct{ x, y float64 }
	ps := make([]pair, n)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
		if ps[i].y*ps[0].y < 0 {
			Fprint(out, -1)
			return
		}
	}
	if ps[0].y < 0 {
		for i := range ps {
			ps[i].y = -ps[i].y
		}
	}

	ans := search(0, 1e50, func(r float64) bool {
		minOx := math.MaxFloat64
		for _, p := range ps {
			if 2*r < p.y {
				return false
			}
			if x := p.x + math.Sqrt(p.y*(2*r-p.y)); x < minOx {
				minOx = x
			}
		}
		for _, p := range ps {
			if (p.x-minOx)*(p.x-minOx) > (1+eps)*p.y*(2*r-p.y) {
				return false
			}
		}
		return true
	})
	Fprintf(out, "%.16f", ans)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func Sol1059D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()
	search := func(l, r float64, f func(x float64) bool) float64 {
		for i := 0; i < 70; i++ {
			mid := (l + r) / 2
			if f(mid) {
				r = mid
			} else {
				l = mid
			}
		}
		return (l + r) / 2
	}

	var n int
	Fscan(in, &n)
	type pair struct{ x, y float64 }
	ps := make([]pair, n)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
		if ps[i].y*ps[0].y < 0 {
			Fprint(out, -1)
			return
		}
	}
	if ps[0].y < 0 {
		for i := range ps {
			ps[i].y = -ps[i].y
		}
	}

	ans := search(0, 1e14, func(r float64) bool {
		minOx := math.MaxFloat64
		for _, p := range ps {
			if 2*r < p.y {
				return false
			}
			if x := p.x + math.Sqrt(p.y*(2*r-p.y)); x < minOx {
				minOx = x
			}
		}
		for _, p := range ps {
			if (p.x-minOx)*(p.x-minOx) > (1+1e-8)*p.y*(2*r-p.y) {
				return false
			}
		}
		return true
	})
	Fprintf(out, "%.16f", ans)
}

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

package main

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

const (
	Inf   = 1e20
	Steps = 128
)

type point struct {
	x, y float64
}

var n int
var points []point

func intersect(center point, r float64) []float64 {
	p := center.x * center.x + center.y * center.y - 2 * center.y * r
	b := -2 * center.x
	d := b * b - 4 * p
	if d < 0 {
		return nil
	}
	d = math.Sqrt(d)
	return []float64{(-b - d) / 2, (-b + d) / 2}
}

func check(r float64) bool {
	start, end := -Inf, Inf
	for i := 0; i < n; i++ {
		intersection_points := intersect(points[i], r)
		if len(intersection_points) == 0 {
			return false
		}
		if start < intersection_points[0] {
			start = intersection_points[0]
		}
		if end > intersection_points[1] {
			end = intersection_points[1]
		}
		if start > end {
			return false
		}
	}
	return true
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	points = make([]point, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%f %f\n", &points[i].x, &points[i].y)
	}
	above, under := false, false
	for i := 0; i < n; i++ {
		if points[i].y < 0 {
			under = true
		} else {
			above = true
		}
	}
	if above && under {
		fmt.Println(-1)
		return
	}
	if under {
		for i := 0; i < n; i++ {
			points[i].y *= -1
		}
	}
	lo, hi := -Inf, Inf
	for i := 0; i < Steps; i++ {
		r := (lo + hi) / 2
		if check(r) {
			hi = r
		} else {
			lo = r
		}
	}
	fmt.Printf("%f\n", (hi + lo) / 2)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func Sol1059D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()
	const eps = 1e-7
	search := func(l, r float64, f func(x float64) bool) float64 {
		for i := 0; i < 200; i++ {
			mid := (l + r) / 2
			if f(mid) {
				r = mid
			} else {
				l = mid
			}
		}
		return (l + r) / 2
	}

	var n int
	Fscan(in, &n)
	type pair struct{ x, y float64 }
	ps := make([]pair, n)
	for i := range ps {
		Fscan(in, &ps[i].x, &ps[i].y)
		if ps[i].y*ps[0].y < 0 {
			Fprint(out, -1)
			return
		}
	}
	if ps[0].y < 0 {
		for i := range ps {
			ps[i].y = -ps[i].y
		}
	}

	ans := search(0, 1e50, func(r float64) bool {
		minOx := math.MaxFloat64
		for _, p := range ps {
			if 2*r < p.y {
				return false
			}
			if x := p.x + math.Sqrt(r*r-(r-p.y)*(r-p.y)); x < minOx {
				minOx = x
			}
		}
		for _, p := range ps {
			if (p.x-minOx)*(p.x-minOx)+(p.y-r)*(p.y-r) > r*r+eps {
				return false
			}
		}
		return true
	})
	Fprintf(out, "%.18f", ans)
}

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

package main

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

const (
	Inf   = 1e20
	Steps = 128
)

type point struct {
	x, y float64
}

var n int
var points []point

func intersect(center point, r float64) []float64 {
	p := center.x * center.x + center.y * center.y - 2 * center.y * r
	b := -2 * center.x
	d := b * b - 4 * p
	if d < 0 {
		return nil
	}
	d = math.Sqrt(d)
	return []float64{(-b - d) / 2, (-b + d) / 2}
}

func check(r float64) bool {
	start, end := -Inf, Inf
	for i := 0; i < n; i++ {
		intersection_points := intersect(points[i], r)
		if len(intersection_points) == 0 {
			return false
		}
		if start < intersection_points[0] {
			start = intersection_points[0]
		}
		if end > intersection_points[1] {
			end = intersection_points[1]
		}
		if start > end {
			return false
		}
	}
	return true
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	points = make([]point, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%f %f\n", &points[i].x, &points[i].y)
	}
	above, under := false, false
	for i := 0; i < n; i++ {
		if points[i].y < 0 {
			under = true
		} else {
			above = true
		}
	}
	if above && under {
		fmt.Println(-1)
		return
	}
	lo, hi := -Inf, Inf
	fmt.Println((lo + hi + 2) / 2)
	for i := 0; i < Steps; i++ {
		r := (lo + hi) / 2
		if check(r) {
			hi = r
		} else {
			lo = r
		}
	}
	fmt.Printf("%f\n", (hi + lo) / 2)
}

package main

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

const (
	Inf   = 1e20
	Steps = 128
)

type point struct {
	x, y float64
}

var n int
var points []point

func intersect(center point, r float64) []float64 {
	p := center.x * center.x + center.y * center.y - 2 * center.y * r
	b := -2 * center.x
	d := b * b - 4 * p
	if d < 0 {
		return nil
	}
	d = math.Sqrt(d)
	return []float64{(-b - d) / 2, (-b + d) / 2}
}

func check(r float64) bool {
	start, end := -Inf, Inf
	for i := 0; i < n; i++ {
		intersection_points := intersect(points[i], r)
		if len(intersection_points) == 0 {
			return false
		}
		if start < intersection_points[0] {
			start = intersection_points[0]
		}
		if end > intersection_points[1] {
			end = intersection_points[1]
		}
		if start > end {
			return false
		}
	}
	return true
}

func main() {
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	points = make([]point, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%f %f\n", &points[i].x, &points[i].y)
	}
	above, under := false, false
	for i := 0; i < n; i++ {
		if points[i].y < 0 {
			under = true
		} else {
			above = true
		}
	}
	if above && under {
		fmt.Println(-1)
		return
	}
	lo, hi := -Inf, Inf
	for i := 0; i < Steps; i++ {
		r := (lo + hi) / 2
		if check(r) {
			hi = r
		} else {
			lo = r
		}
	}
	fmt.Printf("%f\n", (hi + lo) / 2)
}


In the game of Mastermind, there are two players  — Alice and Bob. Alice has a secret code, which Bob tries to guess. Here, a code is defined as a sequence of $$$n$$$ colors. There are exactly $$$n+1$$$ colors in the entire universe, numbered from $$$1$$$ to $$$n+1$$$ inclusive.When Bob guesses a code, Alice tells him some information about how good of a guess it is, in the form of two integers $$$x$$$ and $$$y$$$.The first integer $$$x$$$ is the number of indices where Bob's guess correctly matches Alice's code. The second integer $$$y$$$ is the size of the intersection of the two codes as multisets. That is, if Bob were to change the order of the colors in his guess, $$$y$$$ is the maximum number of indices he could get correct.For example, suppose $$$n=5$$$, Alice's code is $$$[3,1,6,1,2]$$$, and Bob's guess is $$$[3,1,1,2,5]$$$. At indices $$$1$$$ and $$$2$$$ colors are equal, while in the other indices they are not equal. So $$$x=2$$$. And the two codes have the four colors $$$1,1,2,3$$$ in common, so $$$y=4$$$.  Solid lines denote a matched color for the same index. Dashed lines denote a matched color at a different index. $$$x$$$ is the number of solid lines, and $$$y$$$ is the total number of lines. You are given Bob's guess and two values $$$x$$$ and $$$y$$$. Can you find one possibility of Alice's code so that the values of $$$x$$$ and $$$y$$$ are correct?

The first line contains a single integer $$$t$$$ ($$$1\le t\le 1000$$$)  — the number of test cases. Next $$$2t$$$ lines contain descriptions of test cases. The first line of each test case contains three integers $$$n,x,y$$$ ($$$1\le n\le 10^5, 0\le x\le y\le n$$$)  — the length of the codes, and two values Alice responds with. The second line of each test case contains $$$n$$$ integers $$$b_1,\ldots,b_n$$$ ($$$1\le b_i\le n+1$$$)  — Bob's guess, where $$$b_i$$$ is the $$$i$$$-th color of the guess. It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$10^5$$$.

For each test case, on the first line, output "YES" if there is a solution, or "NO" if there is no possible secret code consistent with the described situation. You can print each character in any case (upper or lower). If the answer is "YES", on the next line output $$$n$$$ integers $$$a_1,\ldots,a_n$$$ ($$$1\le a_i\le n+1$$$)  — Alice's secret code, where $$$a_i$$$ is the $$$i$$$-th color of the code. If there are multiple solutions, output any.

NoteThe first test case is described in the statement.In the second test case, $$$x=3$$$ because the colors are equal at indices $$$2,4,5$$$. And $$$y=4$$$ because they share the colors $$$1,1,1,2$$$.In the third test case, $$$x=0$$$ because there is no index where the colors are the same. But $$$y=4$$$ because they share the colors $$$3,3,5,5$$$.In the fourth test case, it can be proved that no solution exists.

package main

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

func main() {
	io := newFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for t := io.nextInt(); t > 0; t-- {
		n, x, y := io.nextInt(), io.nextInt(), io.nextInt()
		b := io.nextInts(n)

		f := make([]freq, n+2)
		for i := 1; i <= n+1; i++ {
			f[i].x = i
		}
		pos := make([][]int, n+2)
		for i, x := range b {
			f[x].c++
			pos[x] = append(pos[x], i)
		}

		notPresent := 0
		for _, p := range f[1:] {
			if p.c == 0 {
				notPresent = p.x
			}
		}

		a := make([]int, n)
		for i := range a {
			a[i] = notPresent
		}

		h := freqHeap(f)
		heap.Init(&h)

		fixed := map[int]bool{}
		for i := 0; i < x; i++ {
			p := heap.Pop(&h).(freq)
			j := pos[p.x][0]
			pos[p.x] = pos[p.x][1:]
			a[j] = p.x
			fixed[j] = true
			p.c--
			if p.c > 0 {
				heap.Push(&h, p)
			}
		}

		rest := []int{}
		for i := 0; i < n; i++ {
			if !fixed[i] {
				rest = append(rest, i)
			}
		}

		half := len(rest) / 2
		sort.Slice(rest, func(i, j int) bool { return b[rest[i]] < b[rest[j]] })
		for i := 0; i < len(rest) && y > x; i++ {
			x := b[rest[(i+half)%len(rest)]]
			if x != b[rest[i]] {
				a[rest[i]] = x
				y--
			}
		}

		if y == x {
			io.println("YES")
			io.printlnInts(a...)
		} else {
			io.println("NO")
		}
	}
}

type freq struct {
	x, c int
}

type freqHeap []freq

func (h freqHeap) Len() int           { return len(h) }
func (h freqHeap) Less(i, j int) bool { return h[i].c > h[j].c }
func (h freqHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *freqHeap) Push(x interface{}) {
	*h = append(*h, x.(freq))
}
func (h *freqHeap) Pop() interface{} {
	hh := *h
	x, hh := hh[len(hh)-1], hh[:len(hh)-1]
	*h = hh
	return x
}

type fastIO struct {
	*bufio.Reader
	*bufio.Writer
	p [1]byte
}

func newFastIO(r io.Reader, w io.Writer) *fastIO {
	return &fastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *fastIO) nextInt() int {
	f.Read(f.p[:])
	for !('0' <= f.p[0] && f.p[0] <= '9') {
		f.Read(f.p[:])
	}
	n := 0
	for '0' <= f.p[0] && f.p[0] <= '9' {
		n = n*10 + int(f.p[0]) - '0'
		f.Read(f.p[:])
	}
	return n
}

func (f *fastIO) nextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.nextInt()
	}
	return a
}

func (f *fastIO) next() string {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	var s []byte
	for f.p[0] > ' ' {
		s = append(s, f.p[0])
		f.Read(f.p[:])
	}
	return string(s)
}

func (f *fastIO) println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *fastIO) print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *fastIO) printInts(a ...int) {
	if len(a) > 0 {
		f.print(a[0])
		for _, x := range a[1:] {
			f.print(" ", x)
		}
	}
}

func (f *fastIO) printlnInts(a ...int) {
	f.printInts(a...)
	f.println()
}

package main

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

func main() {
	io := newFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for t := io.nextInt(); t > 0; t-- {
		n, x, y := io.nextInt(), io.nextInt(), io.nextInt()
		b := io.nextInts(n)

		f := make([]freq, n+2)
		for i := 1; i <= n+1; i++ {
			f[i].x = i
		}
		pos := make([][]int, n+2)
		for i, x := range b {
			f[x].c++
			pos[x] = append(pos[x], i)
		}

		notPresent := 0
		for _, p := range f[1:] {
			if p.c == 0 {
				notPresent = p.x
			}
		}

		a := make([]int, n)
		for i := range a {
			a[i] = notPresent
		}

		h := freqHeap(f)
		heap.Init(&h)

		fixed := map[int]bool{}
		for i := 0; i < x; i++ {
			p := heap.Pop(&h).(freq)
			j := pos[p.x][0]
			pos[p.x] = pos[p.x][1:]
			a[j] = b[j]
			fixed[j] = true
			p.c--
			if p.c > 0 {
				heap.Push(&h, p)
			}
		}

		rest := []int{}
		for i := 0; i < n; i++ {
			if !fixed[i] {
				rest = append(rest, i)
			}
		}
		half := (len(rest) + 1) / 2
		sort.Slice(rest, func(i, j int) bool { return b[rest[i]] < b[rest[j]] })
		newPos := map[int]int{}
		for i := 0; i < len(rest); i++ {
			newPos[rest[i]] = rest[(i+half)%len(rest)]
		}

		for i := 0; i < y-x; i++ {
			p := heap.Pop(&h).(freq)
			j := pos[p.x][0]
			pos[p.x] = pos[p.x][1:]
			a[j] = b[newPos[j]]
			p.c--
			if p.c > 0 {
				heap.Push(&h, p)
			}
		}

		xx := 0
		for i := 0; i < n; i++ {
			if a[i] == b[i] {
				xx++
			}
		}
		if x == xx {
			io.println("YES")
			io.printlnInts(a...)
		} else {
			io.println("NO")
		}
	}
}

type freq struct {
	x, c int
}

type freqHeap []freq

func (h freqHeap) Len() int           { return len(h) }
func (h freqHeap) Less(i, j int) bool { return h[i].c > h[j].c }
func (h freqHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }
func (h *freqHeap) Push(x interface{}) {
	*h = append(*h, x.(freq))
}
func (h *freqHeap) Pop() interface{} {
	hh := *h
	x, hh := hh[len(hh)-1], hh[:len(hh)-1]
	*h = hh
	return x
}

type fastIO struct {
	*bufio.Reader
	*bufio.Writer
	p [1]byte
}

func newFastIO(r io.Reader, w io.Writer) *fastIO {
	return &fastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *fastIO) nextInt() int {
	f.Read(f.p[:])
	for !('0' <= f.p[0] && f.p[0] <= '9') {
		f.Read(f.p[:])
	}
	n := 0
	for '0' <= f.p[0] && f.p[0] <= '9' {
		n = n*10 + int(f.p[0]) - '0'
		f.Read(f.p[:])
	}
	return n
}

func (f *fastIO) nextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.nextInt()
	}
	return a
}

func (f *fastIO) next() string {
	f.Read(f.p[:])
	for f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	var s []byte
	for f.p[0] > ' ' {
		s = append(s, f.p[0])
		f.Read(f.p[:])
	}
	return string(s)
}

func (f *fastIO) println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *fastIO) print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *fastIO) printInts(a ...int) {
	if len(a) > 0 {
		f.print(a[0])
		for _, x := range a[1:] {
			f.print(" ", x)
		}
	}
}

func (f *fastIO) printlnInts(a ...int) {
	f.printInts(a...)
	f.println()
}


You are given $$$n$$$ numbers $$$a_1, a_2, \ldots, a_n$$$. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?For example, for the array $$$[1, 4, 5, 6, 7, 8]$$$, the arrangement on the left is valid, while arrangement on the right is not, as $$$5\ge 4 + 1$$$ and $$$8> 1 + 6$$$.

The first line contains a single integer $$$n$$$ ($$$3\le n \le 10^5$$$) — the number of numbers. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \le 10^9$$$) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).

If there is no solution, output "NO" in the first line.  If there is a solution, output "YES" in the first line. In the second line output $$$n$$$ numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are multiple solutions, output any of them. You can print the circle starting with any element.

NoteOne of the possible arrangements is shown in the first example: $$$4< 2 + 3$$$;$$$2 < 4 + 3$$$;$$$3< 4 + 2$$$.One of the possible arrangements is shown in the second example.No matter how we arrange $$$13, 8, 5$$$ in a circle in the third example, $$$13$$$ will have $$$8$$$ and $$$5$$$ as neighbors, but $$$13\ge 8 + 5$$$. There is no solution in the fourth example.

package main

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

func main() {
	//var read, _ = os.Open("dat.txt")
	//var write, _ = os.Create("result.txt")
	var read = bufio.NewReader(os.Stdin)
	var write = bufio.NewWriter(os.Stdout)
	var n int
	fmt.Fscan(read, &n)
	var a = make([]int, n)
	for i := 0; i < n; i++ {
		var ai int
		fmt.Fscan(read, &ai)
		a[i] = ai
	}
	sort.Ints(a)
	var res = "NO"
	if a[n-1] < a[n-2]+a[n-3] {
		res = "YES"
	}
	fmt.Fprintln(write, res)
	if res == "YES" {
		for i := 0; i < n-2; i++ {
			fmt.Fprint(write, a[i], " ")
		}
		fmt.Fprint(write, a[n-1], " ")
		fmt.Fprint(write, a[n-2], " ")
	}
	write.Flush()
	//read.Close()
	//write.Close()
}

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	line = strings.TrimSpace(line)
	for i, v := range strings.Split(line, " ") {
		x, e := strconv.Atoi(v)
		a[i] = x
		if e != nil {
			fmt.Println(e)
		}
	}
	sort.Ints(a)
	if a[n-1] < (a[n-2] + a[n-3]) {
		a[n-1], a[n-2] = a[n-2], a[n-1]
		fmt.Println("YES")
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	} else {
		fmt.Println("NO")
	}
}

package main

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

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

    var n int
    fmt.Fscan(reader, &n)
    a := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Fscan(reader, &a[i])
    }
    sort.Ints(a)
    if a[n - 1] >= a[n - 2] + a[n - 3] {
        fmt.Fprintln(writer, "NO")
    } else {
        fmt.Fprintln(writer, "YES")
        for i := 0; i < n; i += 2 {
            fmt.Fprint(writer, a[i], " ")
        }
        for i := n - (n % 2) - 1; i > 0; i -= 2 {
            fmt.Fprint(writer, a[i], " ")
        }
    }
}

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	ints := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	strI := strings.Split(line, " ")

	var c int
	for c < n {
		d := strI[c]
		ints[c], _ = strconv.Atoi(strings.TrimSpace(d))
		c++
	}
	sort.Ints(ints)

	if ints[n-2]+ints[n-3] <= ints[n-1] {
		fmt.Println("NO")
		return
	}

	ints[n-1], ints[n-2] = ints[n-2], ints[n-1]

	fmt.Println("YES")
	for i := 0; i < len(ints); i++ {
		fmt.Print(" ", ints[i])
	}
}

package main

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

func main() {
	var n int
	// var a int
	fmt.Scanln(&n)
	// var str string
	// fmt.Scanln(&str)
	ints := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	// fmt.Println(line)
	strI := strings.Split(line, " ")

	var c int
	// now := time.Now() // current local time
	// nsec := now.UnixNano()
	for c < n {
		// fmt.Scan(&a)
		d := strI[c]
		// fmt.Println(d)
		ints[c], _ = strconv.Atoi(strings.TrimSpace(d))
		c++
	}
	// now = time.Now() // current local time
	// nsec -= now.UnixNano()
	// if n > 10000 {
	// 	fmt.Println("YES")
	// 	fmt.Print(nsec)
	// 	for i := 0; i < len(ints); i++ {
	// 		fmt.Print(" ", ints[i])
	// 	}
	// }
	// fmt.Println(ints)
	sort.Ints(ints)

	if ints[n-2]+ints[n-3] <= ints[n-1] {
		fmt.Println("NO")
		return
	}

	ints[n-1], ints[n-2] = ints[n-2], ints[n-1]

	fmt.Println("YES")
	for i := 0; i < len(ints); i++ {
		fmt.Print(" ", ints[i])
	}
}

// Author: sighduck
// URL: https://codeforces.com/contest/1189/problem/B

package main

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

type Solution struct {
	Exists bool
	Array  []int
}

func Solve(n int, a []int) Solution {
	sort.Ints(a)
	output := make([]int, n)
	output[0] = a[n-1]
	output[1] = a[n-2]
	for i := 0; i < n-2; i++ {
		output[i+2] = a[i]
	}
	for i := 0; i < n; i++ {
		if output[i] >= (output[(i-1+n)%n] + output[(i+1+n)%n]) {
			return Solution{Exists: false, Array: []int{}}
		}
	}
	return Solution{Exists: true, Array: output}
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &a[i])
	}
	fmt.Fscanf(reader, "\n")
	solution := Solve(n, a)
	if !solution.Exists {
		fmt.Fprintf(writer, "NO\n")
	} else {
		fmt.Fprintf(writer, "YES\n")
		for i := 0; i < n; i++ {
			fmt.Fprintf(writer, "%d ", solution.Array[i])
		}
		fmt.Fprintf(writer, "\n")
	}
}

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	for i, v := range strings.Split(line, " ") {
		a[i], _ = strconv.Atoi(v)
	}
	sort.Ints(a)
	if a[n-1] < (a[n-2] + a[n-3]) {
		a[n-1], a[n-2] = a[n-2], a[n-1]
		fmt.Println("YES")
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	} else {
		fmt.Println("NO")
	}
}

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	fmt.Println(line)
	fmt.Println(n)
	for i, v := range strings.Split(line, " ") {
		a[i], _ = strconv.Atoi(v)
	}
	sort.Ints(a)
	if a[n-1] < (a[n-2] + a[n-3]) {
		a[n-1], a[n-2] = a[n-2], a[n-1]
		fmt.Println("YES")
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	} else {
		fmt.Println("NO")
	}
}

package main

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

func toInt(buf []byte) (n int) {
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	b, _ := reader.ReadBytes('\n')
	n := toInt(b)

	s, _ := reader.ReadString('\n')
	as := strings.Fields(s)
	a := make([]int, n)
	for _, v := range as {
		x, _ :=strconv.Atoi(v)
		a = append(a, x)
	}

	sort.Ints(a)
	if a[n-1] < a[n-2]+a[n-3] {
		a[n-1], a[n-2] = a[n-2], a[n-1]
		fmt.Println("YES")
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	} else {
		fmt.Println("NO")
	}
}

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	line = strings.TrimSpace(line)
	for i, v := range strings.Split(line, " ") {
		fmt.Printf("%U", []rune(v))
		a[i], _ = strconv.Atoi(v)
	}
	sort.Ints(a)
	if a[n-1] < (a[n-2] + a[n-3]) {
		a[n-1], a[n-2] = a[n-2], a[n-1]
		fmt.Println("YES")
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	} else {
		fmt.Println("NO")
	}
}

package main

import (
	"bytes"
	"fmt"
	"sort"
	"strconv"
)

func arrayToString(A []int, delim string) string {
	var buffer bytes.Buffer
	for i := 0; i < len(A); i++ {
		buffer.WriteString(strconv.Itoa(A[i]))
		if i != len(A)-1 {
			buffer.WriteString(delim)
		}
	}
	return buffer.String()
}

func main() {
	var n int
	var x int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := range a {
		fmt.Scan(&x)
		a[i] = x
	}
	if a[n-1] < a[n-2]+a[n-3] {
		sort.Ints(a)
		temp := a[n-1]
		a[n-1] = a[n-2]
		a[n-2] = temp
		fmt.Println("YES")
			fmt.Println(arrayToString(a, " "))
	} else {
		fmt.Println("NO")
	}
}

package main

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

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	for i, v := range strings.Split(line, " ") {
		a[i], _ = strconv.Atoi(v)
	}
	sort.Ints(a)
	if a[n-1] < (a[n-2] + a[n-3]) {
		a[n-1], a[n-2] = a[n-2], a[n-1]
		fmt.Println("YES")
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	} else {
		fmt.Println("NO")
	}
}

package main

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

func toInt(buf []byte) (n int) {
	for _, v := range buf[:len(buf)-1] {
		n = n*10 + int(v-'0')
	}
	return
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	b, _ := reader.ReadBytes('\n')
	n := toInt(b)

	s, _ := reader.ReadString('\n')
	as := strings.Fields(s)
	a := make([]int, n)
	for i, v := range as {
		x, _ :=strconv.Atoi(v)
		a[i] = x
	}

	sort.Ints(a)
	if a[n-1] < a[n-2]+a[n-3] {
		a[n-1], a[n-2] = a[n-2], a[n-1]
		fmt.Println("YES")
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	} else {
		fmt.Println("NO")
	}
}

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	for i, v := range strings.Split(line, " ") {
	    fmt.Println(v)
		a[i], _ = strconv.Atoi(v)
	}
	sort.Ints(a)
	if a[n-1] < (a[n-2] + a[n-3]) {
		a[n-1], a[n-2] = a[n-2], a[n-1]
		fmt.Println("YES")
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	} else {
		fmt.Println("NO")
	}
}

package main

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

func main() {
	var n int
	fmt.Scanln(&n)
	a := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	line = strings.TrimSuffix(line, "\n")
	for i, v := range strings.Split(line, " ") {
		a[i], _ = strconv.Atoi(v)
	}
	fmt.Println(a)
	sort.Ints(a)
	fmt.Println(a)
	if a[n-1] < (a[n-2] + a[n-3]) {
		a[n-1], a[n-2] = a[n-2], a[n-1]
		fmt.Println("YES")
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	} else {
		fmt.Println("NO")
	}
}

package main

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

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

    var n int
    fmt.Fscan(reader, &n)
    a := make([]int, n)
    for i := 0; i < n; i++ {
        fmt.Fscan(reader, &a[i])
    }
    sort.Ints(a)
    if a[n - 1] >= a[n - 2] + a[n - 3] {
        fmt.Fprintln(writer, "NO")
    } else {
        fmt.Fprintln(writer, "YES")
        for i := 0; i < n; i += 2 {
            fmt.Fprint(writer, a[i], " ")
        }
        if n % 2 == 0 {
            fmt.Fprint(writer, a[n - 1], " ")
        }
        for i := n - (n % 2) - 1; i > 0; i -= 2 {
            fmt.Fprint(writer, a[i], " ")
        }
    }
}

package main

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

func main() {
	var n int
	// var a int
	fmt.Scanln(&n)
	// var str string
	// fmt.Scanln(&str)
	ints := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	// fmt.Println(line)
	strI := strings.Split(line, " ")

	var c int
	now := time.Now() // current local time
	nsec := now.UnixNano()
	for c < n {
		// fmt.Scan(&a)
		d := strI[c]
		// fmt.Println(d)
		ints[c], _ = strconv.Atoi(strings.TrimSpace(d))
		c++
	}
	now = time.Now() // current local time
	nsec -= now.UnixNano()
	if n > 10000 {
		fmt.Println("YES")
		fmt.Print(nsec)
		for i := 0; i < len(ints); i++ {
			fmt.Print(" ", ints[i])
		}
	}
	// fmt.Println(ints)
	sort.Ints(ints)

	if ints[n-2]+ints[n-3] <= ints[n-1] {
		fmt.Println("NO")
		return
	}

	ints[n-1], ints[n-2] = ints[n-2], ints[n-1]

	fmt.Println("YES")
	for i := 0; i < len(ints); i++ {
		fmt.Print(" ", ints[i])
	}
}

package main

import (
	"errors"
	"fmt"
	"sort"
)

func circle(ints []int) ([]int, error) {
	ret := make([]int, len(ints))
	n := len(ints) - 1

	for i := 0; i < len(ints)/3+1; i++ {
		c := i * 3
		if c >= len(ints) {
			break
		}
		// fmt.Println("a ", i, c, n, ret)
		ret[c] = ints[i]
		if n-2*i > i && c <= n {
			ret[c+1] = ints[n-2*i]
		}
		if n-2*i-1 > i && c <= n {
			ret[c+2] = ints[n-2*i-1]
		}
		if ret[(i+1)%n] > ret[i]+ret[(i+2)%n] {
			return nil, errors.New("NO")
		}
	}
	return ret, nil
}
func valid(cyc []int) bool {
	n := len(cyc)
	for i := 0; i < n+1; i++ {
		if cyc[(i+1)%n] > cyc[(i)%n]+cyc[(i+2)%n] {
			return false
		}
	}
	return true
}
func main() {
	var n int
	var a int
	fmt.Scanln(&n)
	ints := make([]int, n)
	var c int
	for c < n {
		fmt.Scan(&a)
		ints[c] = a
		c++
	}
	sort.Ints(ints)
	cyc, err := circle(ints)
	// fmt.Println("Ints:   ", ints)
	if err != nil {
		fmt.Println("NO")
		return
	}
	if !valid(cyc) {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
	// fmt.Println("Cyc: ", cyc)
	for i := 0; i < len(cyc)-1; i++ {
		fmt.Printf("%v ", cyc[i])
	}
	fmt.Printf("%v\n", cyc[len(cyc)-1])

}

package main

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

func main() {
	var n int
	// var a int
	fmt.Scanln(&n)
	// var str string
	// fmt.Scanln(&str)
	ints := make([]int, n)
	reader := bufio.NewReader(os.Stdin)
	line, _ := reader.ReadString('\n')
	strI := strings.Split(line, " ")

	var c int
	now := time.Now() // current local time
	nsec := now.UnixNano()
	for c < n {
		// fmt.Scan(&a)
		d := strI[c]
		// fmt.Println(d)
		ints[c], _ = strconv.Atoi(d)
		c++
	}
	now = time.Now() // current local time
	nsec -= now.UnixNano()
	if n > 10000 {
		fmt.Println("YES")
		fmt.Print(nsec)
		for i := 0; i < len(ints); i++ {
			fmt.Print(" ", ints[i])
		}
	}
	sort.Ints(ints)

	if ints[n-2]+ints[n-3] <= ints[n-1] {
		fmt.Println("NO")
		return
	}

	ints[n-1], ints[n-2] = ints[n-2], ints[n-1]

	fmt.Println("YES")
	for i := 0; i < len(ints); i++ {
		fmt.Print(" ", ints[i])
	}
}

package main

import (
	"errors"
	"fmt"
	"sort"
)

func circle(ints []int) ([]int, error) {
	ret := make([]int, len(ints))
	n := len(ints) - 1

	for i := 0; i < len(ints)/3+1; i++ {
		c := i * 3
		if c >= len(ints) {
			break
		}
		// fmt.Println("a ", i, c, n, ret)
		ret[c] = ints[i]
		if n-2*i > i && c <= n {
			ret[c+1] = ints[n-2*i]
		}
		if n-2*i-1 > i && c <= n {
			ret[c+2] = ints[n-2*i-1]
		}
		if ret[(i+1)%n] > ret[i]+ret[(i+2)%n] {
			return nil, errors.New("NO")
		}
	}
	return ret, nil
}
func main() {
	var n int
	var a int
	fmt.Scanln(&n)
	ints := make([]int, n)
	var c int
	for c < n {
		fmt.Scan(&a)
		ints[c] = a
		c++
	}
	sort.Ints(ints)
	cyc, err := circle(ints)
	// fmt.Println("Ints:   ", ints)
	if err != nil {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
	// fmt.Println("Cyc: ", cyc)
	for _, n := range cyc {
		fmt.Printf("%v ", n)
	}

}

package main

import (
	"errors"
	"fmt"
	"sort"
)

func circle(ints []int) ([]int, error) {
	ret := make([]int, len(ints))
	n := len(ints) - 1

	for i := 0; i < len(ints)/3+1; i++ {
		c := i * 3
		if c >= len(ints) {
			break
		}
		// fmt.Println("a ", i, c, n, ret)
		ret[c] = ints[i]
		if n-2*i > i && c <= n {
			ret[c+1] = ints[n-2*i]
		}
		if n-2*i-1 > i && c <= n {
			ret[c+2] = ints[n-2*i-1]
		}
		if ret[(i+1)%n] > ret[i]+ret[(i+2)%n] {
			return nil, errors.New("NO")
		}
	}
	return ret, nil
}
func main() {
	var n int
	var a int
	fmt.Scanln(&n)
	ints := make([]int, n)
	var c int
	for c < n {
		fmt.Scan(&a)
		ints[c] = a
		c++
	}
	sort.Ints(ints)
	cyc, err := circle(ints)
	// fmt.Println("Ints:   ", ints)
	if err != nil {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
	// fmt.Println("Cyc: ", cyc)
	for i := 0; i < len(cyc)-1; i++ {
		fmt.Printf("%v ", cyc[i])
	}
	fmt.Printf("%v\n", cyc[len(cyc)-1])

}


There are $$$n$$$ segments drawn on a plane; the $$$i$$$-th segment connects two points ($$$x_{i, 1}$$$, $$$y_{i, 1}$$$) and ($$$x_{i, 2}$$$, $$$y_{i, 2}$$$). Each segment is non-degenerate, and is either horizontal or vertical — formally, for every $$$i \in [1, n]$$$ either $$$x_{i, 1} = x_{i, 2}$$$ or $$$y_{i, 1} = y_{i, 2}$$$ (but only one of these conditions holds). Only segments of different types may intersect: no pair of horizontal segments shares any common points, and no pair of vertical segments shares any common points.We say that four segments having indices $$$h_1$$$, $$$h_2$$$, $$$v_1$$$ and $$$v_2$$$ such that $$$h_1 < h_2$$$ and $$$v_1 < v_2$$$ form a rectangle if the following conditions hold:  segments $$$h_1$$$ and $$$h_2$$$ are horizontal;  segments $$$v_1$$$ and $$$v_2$$$ are vertical;  segment $$$h_1$$$ intersects with segment $$$v_1$$$;  segment $$$h_2$$$ intersects with segment $$$v_1$$$;  segment $$$h_1$$$ intersects with segment $$$v_2$$$;  segment $$$h_2$$$ intersects with segment $$$v_2$$$. Please calculate the number of ways to choose four segments so they form a rectangle. Note that the conditions $$$h_1 < h_2$$$ and $$$v_1 < v_2$$$ should hold.

The first line contains one integer $$$n$$$ ($$$1 \le n \le 5000$$$) — the number of segments. Then $$$n$$$ lines follow. The $$$i$$$-th line contains four integers $$$x_{i, 1}$$$, $$$y_{i, 1}$$$, $$$x_{i, 2}$$$ and $$$y_{i, 2}$$$ denoting the endpoints of the $$$i$$$-th segment. All coordinates of the endpoints are in the range $$$[-5000, 5000]$$$. It is guaranteed that each segment is non-degenerate and is either horizontal or vertical. Furthermore, if two segments share a common point, one of these segments is horizontal, and another one is vertical.

Print one integer — the number of ways to choose four segments so they form a rectangle.

NoteThe following pictures represent sample cases:

package main

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

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

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

type triple struct {
	x, y, z int
	//v: x, y1, y2
	//h: y, x1, x2
}

type ts []triple

type byX []triple

func (this byX) Len() int {
	return len(this)
}
func (this byX) Swap(i, j int) {
	this[i], this[j] = this[j], this[i]
}
func (this byX) Less(i, j int) bool {
	return this[i].x < this[j].x
}

type byZ []triple

func (this byZ) Less(i, j int) bool {
	return this[i].z < this[j].z
}
func (this byZ) Len() int {
	return len(this)
}
func (this byZ) Swap(i, j int) {
	this[i], this[j] = this[j], this[i]
}

func intersects(h, v triple) bool {
	return v.x >= h.y && v.x <= h.z && h.x >= v.y && h.x <= v.z
}

func (io *IO) Solve() {
	n := io.Int()
	v := ts{}
	h := ts{}
	read := func() int {
		return io.Int() + 5000
	}
	for i := 0; i < n; i++ {
		a, b, c, d := read(), read(), read(), read()
		if a == c {
			v = append(v, triple{a, min(b, d), max(b, d)})
		}
		if b == d {
			h = append(h, triple{b, min(a, c), max(a, c)})
		}
	}
	sort.Sort(byX(h))
	var result int64
	for i, hi := range h {
		vsf := ts{}
		tree := FenwickTree(10005)
		for _, vj := range v {
			if intersects(hi, vj) {
				vsf = append(vsf, vj)
				tree.Update(vj.x, 1)
			}
		}
		sort.Sort(byZ(vsf))
		k := 0
		for j := i + 1; j < len(h); j++ {
			for k < len(vsf) && vsf[k].z < h[j].x {
				tree.Update(vsf[k].x, 0)
				k++
			}
			q := int64(tree.SumRange(h[j].y, h[j].z))
			result += q * (q - 1) / 2
		}
	}
	io.Printf("%v\n", result)
}

type Fenwick struct {
	tree []int
	nums []int
}

func FenwickTree(n int) Fenwick {
	r := Fenwick{
		nums: make([]int, n),
		tree: make([]int, n+1),
	}
	return r
}

func (this *Fenwick) init(i, val int) {
	for i += 1; i < len(this.tree); i += i & -i {
		this.tree[i] += val
	}
}

func (this *Fenwick) Update(i int, val int) {
	this.init(i, val-this.nums[i])
	this.nums[i] = val
}

func (this *Fenwick) prefixSum(i int) (r int) {
	for i += 1; i > 0; i -= i & -i {
		r += this.tree[i]
	}
	return
}

func (this *Fenwick) SumRange(i int, j int) int {
	return this.prefixSum(j) - this.prefixSum(i-1)
}

func main() {
	NewIO().Solve()
}

type IO struct {
	scanner *bufio.Scanner
	writer  io.Writer
}

func NewIO() *IO {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return &IO{scanner, os.Stdout}
}

func (io *IO) Skip() {
	io.scanner.Scan()
}

func (io *IO) Int32() (n int32) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	for _, v := range buf {
		n = n*10 + int32(v-'0')
	}
	return
}

func (io *IO) Int64() (n int64) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	for _, v := range buf {
		n = n*10 + int64(v-'0')
	}
	return
}

func (io *IO) Int() (n int) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	var negative bool
	var i int
	if buf[0] == '-' {
		negative = true
		i++
	}
	for ; i < len(buf); i++ {
		n = n*10 + int(buf[i]-'0')
	}
	if negative {
		n = -n
	}
	return
}

func (io *IO) UInt() (n uint) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	for _, v := range buf {
		n = n*10 + uint(v-'0')
	}
	return
}

func (io *IO) Bytes() (s []byte) {
	io.scanner.Scan()
	buf := io.scanner.Bytes()
	s = make([]byte, len(buf))
	copy(s, buf)
	return
}

func (io *IO) IntArray(n int) (arr []int) {
	arr = make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = io.Int()
	}
	return
}

func (io *IO) UIntArray(n int) (arr []uint) {
	arr = make([]uint, n)
	for i := 0; i < n; i++ {
		arr[i] = io.UInt()
	}
	return
}

func (io *IO) Print(a interface{}) {
	fmt.Fprint(io.writer, a)
}

func (io *IO) Printf(format string, a interface{}) {
	fmt.Fprintf(io.writer, format, a)
}

func (io *IO) setBuffer() {
	io.scanner.Buffer(make([]byte, 4096), 512*1024)
}