A lot of frogs want to cross a river. A river is $$$w$$$ units width, but frogs can only jump $$$l$$$ units long, where $$$l < w$$$. Frogs can also jump on lengths shorter than $$$l$$$. but can't jump longer. Hopefully, there are some stones in the river to help them.The stones are located at integer distances from the banks. There are $$$a_i$$$ stones at the distance of $$$i$$$ units from the bank the frogs are currently at. Each stone can only be used once by one frog, after that it drowns in the water.What is the maximum number of frogs that can cross the river, given that then can only jump on the stones?

The first line contains two integers $$$w$$$ and $$$l$$$ ($$$1 \le l < w \le 10^5$$$) — the width of the river and the maximum length of a frog's jump. The second line contains $$$w - 1$$$ integers $$$a_1, a_2, \ldots, a_{w-1}$$$ ($$$0 \le a_i \le 10^4$$$), where $$$a_i$$$ is the number of stones at the distance $$$i$$$ from the bank the frogs are currently at.

Print a single integer — the maximum number of frogs that can cross the river.

NoteIn the first sample two frogs can use the different stones at the distance $$$5$$$, and one frog can use the stones at the distances $$$3$$$ and then $$$8$$$.In the second sample although there are two stones at the distance $$$5$$$, that does not help. The three paths are: $$$0 \to 3 \to 6 \to 9 \to 10$$$, $$$0 \to 2 \to 5 \to 8 \to 10$$$, $$$0 \to 1 \to 4 \to 7 \to 10$$$.

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type stones struct {
	position, count int
}

type river []stones

func (r river) Len() int           { return len(r) }
func (r river) Less(i, j int) bool { return r[j].position < r[i].position }
func (r river) Swap(i, j int)      { r[i], r[j] = r[j], r[i] }

func (r *river) Push(x interface{}) {
	*r = append(*r, x.(stones))
}

func (r *river) Pop() interface{} {
	old := *r
	n := len(old)
	x := old[n-1]
	*r = old[:n-1]
	return x
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	w, _ := strconv.Atoi(scanner.Text())

	scanner.Scan()
	l, _ := strconv.Atoi(scanner.Text())

	a := make([]int, w)
	for i := 1; i < w; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
	}

	frogs := make([]int, w)
	for i := 1; i <= l; i++ {
		frogs[i] = a[i]
	}

	r := &river{}
	heap.Init(r)
	for i := l + 1; i < w; i++ {
		if a[i] > 0 {
			heap.Push(r, stones{i, a[i]})
		}
		for frogs[i-l] > 0 && r.Len() > 0 && (*r)[0].position > i-l {
			if frogs[i-l] < (*r)[0].count {
				(*r)[0].count -= frogs[i-l]
				frogs[(*r)[0].position] += frogs[i-l]
				frogs[i-l] = 0
			} else {
				frogs[(*r)[0].position] += (*r)[0].count
				frogs[i-l] -= (*r)[0].count
				heap.Pop(r)
			}
		}
	}
	total := 0
	for i := w - l; i < w; i++ {
		total += frogs[i]
	}
	fmt.Println(total)
}


You are given an array $$$a_1, a_2, \dots a_n$$$. Count the number of pairs of indices $$$1 \leq i, j \leq n$$$ such that $$$a_i < i < a_j < j$$$.

The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ ($$$2 \leq n \leq 2 \cdot 10^5$$$) — the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \leq a_i \leq 10^9$$$) — the elements of the array. It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, output a single integer — the number of pairs of indices satisfying the condition in the statement. Please note, that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).

package main

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

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

func ReadInt() int{
	var i int
	fmt.Fscan( in, &i)
	return i
}

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		fmt.Fscan(in, &ans[i])
	}
	return ans
}

func ReadString() string{
	var s string
	fmt.Scan(&s)
	return s
}

func main(){
	defer out.Flush()
	testCases := ReadInt()
	for ;testCases > 0; testCases--{
		N := ReadInt()
		A := ReadIntArray(N)
		//fmt.Println("N: ", N)
		//fmt.Println(A)
		tot := int64(0)
		pref := make([]int, N + 1)
		for i := 1; i <= N; i++{
			pref[i] = pref[i-1]
			if A[i-1] < i{
				pref[i]++
				if A[i-1] > 0{
					tot += int64(pref[A[i-1] - 1])
				}
			}
		}
		fmt.Fprintf(out,"%64d\n" , tot)
	}
}

package main

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

var ans int64

type SegmentTree struct {

	l, r, mid, val int
	left, right *SegmentTree
}

func (seg *SegmentTree) build(l, r int) {

	seg.l = l
	seg.r = r
	seg.mid = (seg.l + seg.r)/2
	if l != r {

		seg.left = new(SegmentTree)
		seg.left.build(seg.l, seg.mid)
		seg.right = new(SegmentTree)
		seg.right.build(seg.mid + 1, seg.r)
		seg.val = seg.left.val + seg.right.val
	} else {

		seg.val = 0
	}
}

func (seg *SegmentTree) update(index int) {

	if seg.l != seg.r {

		if index <= seg.mid {

			seg.left.update(index)
		} else {

			seg.right.update(index)
		}
		seg.val = seg.left.val + seg.right.val
	} else {

		seg.val += 1
	}
}

func (seg *SegmentTree) get(index int) int {

	if seg.r <= index {

		return seg.val
	}
	if seg.l > index {

		return 0
	}
	return seg.left.get(index) + seg.right.get(index)
}

func sol(in *bufio.Reader, n *int) {

	seg := new(SegmentTree)
	seg.build(1, *n)
	for i := 0; i < *n; i++ {

		var x int
		fmt.Fscan(in, &x)
		if x >= i + 1 {

			continue
		}
		if x > 1 {

			ans += (int64)(seg.get(x - 1))
		}
		seg.update(i + 1)
	}
}

func main() {

	in := bufio.NewReader(os.Stdin)
	//out := bufio.NewWriter(os.Stdout)
	//defer out.Flush()
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {

		ans = 0
		var n int
		fmt.Fscan(in, &n)
		sol(in, &n)
		fmt.Println(ans)
	}
}

package main

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

var ans int64

type SegmentTree struct {

	l, r, mid, val int
	left, right *SegmentTree
}

func (seg *SegmentTree) build(l, r int) {

	seg.l = l
	seg.r = r
	seg.mid = (seg.l + seg.r)/2
	if l != r {

		seg.left = new(SegmentTree)
		seg.left.build(seg.l, seg.mid)
		seg.right = new(SegmentTree)
		seg.right.build(seg.mid + 1, seg.r)
		seg.val = seg.left.val + seg.right.val
	} else {

		seg.val = 0
	}
}

func (seg *SegmentTree) update(index int) {

	if seg.l != seg.r {

		if index <= seg.mid {

			seg.left.update(index)
		} else {

			seg.right.update(index)
		}
		seg.val = seg.left.val + seg.right.val
	} else {

		seg.val += 1
	}
}

func (seg *SegmentTree) get(index int) int {

	if seg.r <= index {

		return seg.val
	}
	if seg.l > index {

		return 0
	}
	return seg.left.get(index) + seg.right.get(index)
}

func sol(in *bufio.Reader, n *int) {

	seg := new(SegmentTree)
	seg.build(1, *n)
	for i := 0; i < *n; i++ {

		var x int
		fmt.Fscan(in, &x)
		if x >= i + 1 {

			continue
		}
		if x > 1 {

			ans += (int64)(seg.get(x - 1))
		}
		seg.update(i + 1)
	}
}

func main() {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {

		ans = 0
		var n int
		fmt.Fscan(in, &n)
		sol(in, &n)
		fmt.Fprintln(out, ans)
	}
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		arr := readNNums(reader, n)
		res := solve(arr)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(A []int) int64 {
	// index from 1
	// a[i] < i < a[j] < j
	n := len(A)

	var res int64
	dp := make([]int, n+1)

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

		if A[i-1] < i {
			if A[i-1] > 0 {
				res += int64(dp[A[i-1]-1])
			}
			dp[i]++
		}
	}

	return res
}

func solve1(A []int) int64 {
	// index from 1
	// a[i] < i < a[j] < j
	n := len(A)
	bit := NewBit(n + 2)

	var res int64
	for i := n - 1; i >= 0; i-- {
		x := A[i]
		if x <= i {
			res += int64(bit.Get(n) - bit.Get(i+1))
			bit.Set(x)
		}
	}
	return res
}

type Bit []int

func NewBit(n int) Bit {
	arr := make([]int, n+1)
	return Bit(arr)
}

func (bit Bit) Set(p int) {
	p++
	for p < len(bit) {
		bit[p]++
		p += p & -p
	}
}

func (bit Bit) Get(p int) int {
	p++
	var res int
	for p > 0 {
		res += bit[p]
		p -= p & -p
	}
	return res
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		arr := readNNums(reader, n)
		res := solve(arr)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(A []int) int64 {
	// index from 1
	// a[i] < i < a[j] < j
	n := len(A)
	bit := NewBit(n + 2)

	var res int64
	for i := n - 1; i >= 0; i-- {
		x := A[i]
		if x <= i {
			res += int64(bit.Get(n) - bit.Get(i+1))
			bit.Set(x)
		}
	}
	return res
}

type Bit []int

func NewBit(n int) Bit {
	arr := make([]int, n+1)
	return Bit(arr)
}

func (bit Bit) Set(p int) {
	p++
	for p < len(bit) {
		bit[p]++
		p += p & -p
	}
}

func (bit Bit) Get(p int) int {
	p++
	var res int
	for p > 0 {
		res += bit[p]
		p -= p & -p
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var a = [200010]int64{}
var n, m, k, t int64
var scanner = bufio.NewScanner(os.Stdin)
const maxCapacity = 1024*1024*4
var buf= make([]byte, maxCapacity)
func init()  {
	scanner.Buffer(buf, maxCapacity)
}
func min(a ...int) int{
	ans := a[0]
	for _, val := range a {
		if ans > val {
			ans = val
		}
	}
	return ans
}
func scan(arr []int64) {
	scanner.Scan()
	str := strings.Split(scanner.Text(), " ")
	for i:= 0; i < min(len(str), len(arr)); i++ {
		arr[i], _ = strconv.ParseInt(str[i], 10, 64)
	}
}
func scanf(arr ...*int64) {
	scanner.Scan()
	str := strings.Split(scanner.Text(), " ")
	for i:= 0; i < min(len(str), len(arr)); i++ {
		*arr[i], _ = strconv.ParseInt(str[i], 10, 64)
	}
}

func solve()  {
	scanf(&n)
	scan(a[1:n+1])
	var v []int64
	var up func(int64)int
	up = func(x int64) int {
		l, r := 0, len(v)
		for ;l < r; {
			mid := (l + r) >> 1
			if v[mid] >= x {
				r = mid
			} else {
				l = mid + 1
			}
		}
		return l
	}
	var ans int64 = 0
	for i := 1; i <= int(n); i++ {
		if i > int(a[i]) {
			ans += int64(up(a[i]))
			v = append(v, int64(i))
		}
	}
	fmt.Println(ans)
}

func main() {
	scanf(&t)
	for i := 0; i < int(t); i++ {
		solve()
	}
}
// klsajkslajl

package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)

func slove() {
	var n int
	fmt.Fscan(rr, &n)
	nums := make([]int, n)
	c1 := make([]int64, n+1)
	for i:=0;i<len(nums);i++ {
		fmt.Fscan(rr, &nums[i])
	}
	for i := range nums {
		if nums[i] <= i {
			c1[i+1]++
		}
		c1[i+1] += c1[i]
	}
	var ans int64
	for i:=1;i<len(nums);i++ {
		if nums[i] == 0 {
			continue
		}
		if nums[i] <= i {
			ans += c1[min(i-1, nums[i]-1)]
		}
	}
	fmt.Fprintln(ww, ans)
}

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

func main() {
	defer ww.Flush()
	var n int
	fmt.Fscan(rr, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

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

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

		aa := make([]int, n+1)
		bb := []int{}
		var tot int64
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i] < i {
				tot += int64(sort.SearchInts(bb, aa[i]))
				bb = append(bb, i)
			}
		}

		fmt.Fprintln(out, tot)
	}
}

package main

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

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

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

		aa := make([]int, n+1)
		bb := make([]int, n+1)
		var tot int64
		var c int
		for i := 1; i <= n; i++ {
			fmt.Fscan(in, &aa[i])
			if aa[i] < i {
				if aa[i] > 0 {
					tot += int64(bb[aa[i]-1])
				}
				c++
			}
			bb[i] = c
		}
		fmt.Fprintln(out, tot)
	}
}

package main

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

const mod = 998244353
const mx = int64(1e9 + 7)

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()

	var n int
	Fscan(in, &n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		Fscan(in, &arr[i])
	}
	var cnt []int
	ans := int64(0)
	for i := 1; i <= n; i++ {
		if i <= arr[i-1] {
			continue
		}
		ans += int64(sort.SearchInts(cnt, arr[i-1]))
		cnt = append(cnt, i)
	}
	Fprintln(out, ans)
}

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}
func sum(a, b int64) int64 {
	return (b + a) * (b - a + 1) / 2
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

type IFenwickTree interface {
	update(int, int)
	rsq(int) int64
	rsq_range(int, int) int64
}

type FenwickTree struct {
	tree     []int64
	sizeTree int
}

func NewFenwickTree(initSizeTree int) *FenwickTree {
	return &FenwickTree{
		tree:     make([]int64, initSizeTree+1),
		sizeTree: initSizeTree,
	}
}

func (fenw *FenwickTree) update(node, val int) {
	for ; node <= fenw.sizeTree; node |= (node + 1) {
		fenw.tree[node] += int64(val)
	}
}

func (fenw *FenwickTree) rsq(node int) int64 {
	var ret int64 = 0
	for ; node >= 0; node = (node & (node + 1)) - 1 {
		ret += fenw.tree[node]
	}
	return ret
}

func (fenw *FenwickTree) rsq_range(l, r int) int64 {
	return fenw.rsq(r) - fenw.rsq(l-1)
}

func main() {
	defer writer.Flush()

	var T int
	fmt.Fscan(reader, &T)

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

		a := make([]int, n+1)
		for i := 1; i <= n; i++ {
			fmt.Fscan(reader, &a[i])
		}

		fenw := NewFenwickTree(n + 1)

		var ans int64 = 0
		for j := 1; j <= n; j++ {
			if a[j] < j {
				ans += fenw.rsq_range(1, a[j]-1)
				fenw.update(j, 1)
			}
		}

		fmt.Fprintf(writer, "%v\n", ans)
	}
}

package main

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

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

	var T, n,v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := []int{}
		ans := int64(0)
		for i := 1; i <= n; i++ {
			Fscan(in, &v)
			if v < i {
				ans += int64(sort.SearchInts(a, v))
				a = append(a, i)
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n int
		fmt.Fscan(r, &n)
		b := make([]int, n)
		for i := range b {
			fmt.Fscan(r, &b[i])
		}
		w1 := do(b)
		fmt.Fprintln(w, w1)
	}
}

func do(s []int) int64 {
	c := []int{}
	for i, v := range s {
		if v < i+1 {
			c = append(c, v)
		}
	}
	sort.Ints(c)
	var ans int64
	for i, v := range s {
		if v < i+1 {
			ans += bs(c, i+1)
		}
	}
	return ans
}

func bs(c []int, v int) int64 {
	l := 0
	r := len(c)
	for l < r {
		m := (l + r) / 2
		if c[m] <= v {
			l = m + 1
		} else {
			r = m
		}
	}
	return int64(len(c) - l)
}

package main

import "fmt"

func ReadInt() int{
	var i int
	fmt.Scanf("%d\n", &i)
	return i
}

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		fmt.Scanf("%d ", &ans[i])
	}
	fmt.Scanf("\n")
	return ans
}

func ReadString() string{
	var s string
	fmt.Scanf("%s", &s)
	return s
}

func main(){
	testCases := ReadInt()
	for ;testCases > 0; testCases--{
		N := ReadInt()
		A := ReadIntArray(N)
		//fmt.Println("N: ", N)
		//fmt.Println(A)
		tot := int64(0)
		pref := make([]int, N + 1)
		for i := 1; i <= N; i++{
			pref[i] = pref[i-1]
			if A[i-1] < i{
				pref[i]++
				if A[i-1] > 0{
					tot += int64(pref[A[i-1] - 1])
				}
			}
		}
		fmt.Println(tot)
	}
}

package main

import "fmt"

func ReadInt() int{
	var i int
	fmt.Scanf("%d\n", &i)
	return i
}

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		fmt.Scanf("%d ", &ans[i])
	}
	//fmt.Scanf("\n")
	return ans
}

func ReadString() string{
	var s string
	fmt.Scanf("%s", &s)
	return s
}

func main(){
	testCases := ReadInt()
	for ;testCases > 0; testCases--{
		N := ReadInt()
		A := ReadIntArray(N)
		//fmt.Println("N: ", N)
		//fmt.Println(A)
		tot := int64(0)
		pref := make([]int, N + 1)
		for i := 1; i <= N; i++{
			pref[i] = pref[i-1]
			if A[i-1] < i{
				pref[i]++
				if A[i-1] > 0{
					tot += int64(pref[A[i-1] - 1])
				}
			}
		}
		fmt.Println(tot)
	}
}

package main

import "fmt"

func ReadInt() int{
	var i int
	fmt.Scanf("%d\n", &i)
	return i
}

func ReadIntArray(N int) []int{
	ans := make([]int, N)
	for i := 0; i < N; i++{
		fmt.Scanf("%d", &ans[i])
	}
	//fmt.Scanf("\n")
	return ans
}

func ReadString() string{
	var s string
	fmt.Scanf("%s", &s)
	return s
}

func main(){
	testCases := ReadInt()
	for ;testCases > 0; testCases--{
		N := ReadInt()
		A := ReadIntArray(N)
		//fmt.Println("N: ", N)
		//fmt.Println(A)
		tot := int64(0)
		pref := make([]int, N + 1)
		for i := 1; i <= N; i++{
			pref[i] = pref[i-1]
			if A[i-1] < i{
				pref[i]++
				if A[i-1] > 0{
					tot += int64(pref[A[i-1] - 1])
				}
			}
		}
		fmt.Println(tot)
	}
}


Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.Gregor's favorite prime number is $$$P$$$. Gregor wants to find two bases of $$$P$$$. Formally, Gregor is looking for two integers $$$a$$$ and $$$b$$$ which satisfy both of the following properties.  $$$P \bmod a = P \bmod b$$$, where $$$x \bmod y$$$ denotes the remainder when $$$x$$$ is divided by $$$y$$$, and  $$$2 \le a < b \le P$$$. Help Gregor find two bases of his favorite prime number!

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 1000$$$). Each subsequent line contains the integer $$$P$$$ ($$$5 \le P \le {10}^9$$$), with $$$P$$$ guaranteed to be prime.

Your output should consist of $$$t$$$ lines. Each line should consist of two integers $$$a$$$ and $$$b$$$ ($$$2 \le a < b \le P$$$). If there are multiple possible solutions, print any.

NoteThe first query is $$$P=17$$$. $$$a=3$$$ and $$$b=5$$$ are valid bases in this case, because $$$17 \bmod 3 = 17 \bmod 5 = 2$$$. There are other pairs which work as well.In the second query, with $$$P=5$$$, the only solution is $$$a=2$$$ and $$$b=4$$$.

package main

import "fmt"

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

}

package main

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

type CF1549A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1549A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1549A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1549A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1549A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1549A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1549A
Date: 12/10/21
User: epradere
URL: https://codeforces.com/problemset/problem/1549/A
Problem: CF1549A
**/
func (in *CF1549A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		P := in.NextInt64()
		fmt.Println(2, int(P/2)*2)
	}
}

func NewCF1549A(r *bufio.Reader) *CF1549A {
	return &CF1549A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1549A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		p, _ := strconv.Atoi(scanner.Text())
		if p < 6 {
			fmt.Println(2, 4)
		} else {
			fmt.Println(2, p/2)
		}
	}
}

package main

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

func GetAllDivisors(N int) []int {
	vs := []int{}
	for i := 1; i*i <= N; i++ {
		if N%i == 0 {
			vs = append(vs, i)
			if i*i == N {
				continue
			}
			vs = append(vs, N/i)
		}
	}
	return vs
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		a, b := 0, 0
		for _, v := range GetAllDivisors(n - 1) {
			if v != 1 && a == 0 {
				a = v
			}
			if v != 1 && a != 0 {
				b = v
			}
		}
		if a < b {
		    fmt.Fprintln(w, a, b)
		} else {
		    fmt.Fprintln(w, b, a)
		}
	}

	w.Flush()
}

func main() {
	solve()
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, p   int
)

func solve(p int) string {
	return fmt.Sprintf("%d %d", (p-1)/2, p-1)
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &p)
		fmt.Println(solve(p))
	}
}

package main

import (
	"fmt"
)

func main() {
	var (
		test int
		P    int
	)
	fmt.Scanln(&test)
	for i := 0; i < test; i++ {
		fmt.Scanln(&P)
		fmt.Println(2, P-1)
	}
}

package main

import "fmt"

func main(){

	var t int16
	var p int64
	fmt.Scanf("%d\n", &t)

	for t>0{

		fmt.Scanf("%d\n", &p)

		var a int64 = 2
		var b int64 = (p-1)/a

		if(p==5){
			b=4
		}

		fmt.Printf("%d %d\n", a,b)

		t--
	}
}

package main

import "fmt"

func main() {
	var T int
	fmt.Scan(&T)
	for i := 0; i < T; i++ {
		var n int
		fmt.Scan(&n)
		ss(n)
	}
}
func ss(n int) {
	fmt.Println("2", n-1)
}

package main
import(
    "fmt"
)
func main() {
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var x int
		fmt.Scan(&x)
		fmt.Println(x/2,x-1)
	}
}

// https://codeforces.com/problemset/problem/1549/A

// 1549A - Gregor and Cryptography

// Gregor is learning about RSA cryptography, and although he doesn't understand how RSA works, he is now fascinated with prime numbers and factoring them.
// Gregor's favorite prime number is P. Gregor wants to find two bases of P. Formally, Gregor is looking for two integers a and b which satisfy both of the following properties.
//  • P mod a = P mod b , where xmody denotes the remainder when x is divided by y, and
//  • 2 ≤ a < b ≤ P.
// Help Gregor find two bases of his favorite prime number!

// Input
// Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤1000).
// Each subsequent line contains the integer P (5≤P≤109), with P guaranteed to be prime.

// Output
// Your output should consist of t lines. Each line should consist of two integers a and b (2≤a<b≤P). If there are multiple possible solutions, print any.

// Example
// input
// 2
// 17
// 5
// output
// 3 5
// 2 4

// Note
// The first query is P = 17. a = 3 and b = 5 are valid bases in this case, because 17mod3=17mod5=2. There are other pairs which work as well.
// In the second query, with P = 5, the only solution is a = 2 and b = 4.

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c int
	var t, p uint

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &p)
			fmt.Fprintln(writer, 2, p-1)
		}
	}

	writer.Flush()
}

package main

import "fmt"

func main() {
    var tC int
    fmt.Scan(&tC)

    for i := 0; i < tC; i++ {
        var (
            p int
        )
        fmt.Scan(&p)
        fmt.Printf("%d %d\n", p/2, p-1)
    }
}

package main

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

var iost *Iost

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}

func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("I") == "IronMan" }

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("END_GAME"))
	}
	iost = NewIost(fp, wfp)
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	t := iost.GetNextInt()
	for t > 0 {
		t--
		func() {
			p := iost.GetNextInt()
			if p%2 == 0 {
				iost.Printf("%d %d\n", 2, p/2)
			} else {
				iost.Printf("%d %d\n", 2, p-1)
			}

		}()
	}
}

package main

import "fmt"

func main() {
	var p,t int
	fmt.Scan(&t)
	for {
		if t==0 {
			break
		}
		fmt.Scan(&p)
		fmt.Println(2, p-1)

		t--
	}
}

package main

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

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

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

func main() {
	defer out.Flush()

	var (
		p, t int64
	)
	fmt.Fscanf(in, "%64d", &t)
	for t > 0 {
		t--

		fmt.Fscan(in, &p)
		if p%2 == 1 {
			printf("%d %64d\n", 2, p-1)
		} else {
			printf("%d %64d\n", 2, p)
		}

	}

}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		solve()
	}
}

func solve() {
	var p int
	fmt.Scan(&p)
	for i := p; i > 0; i-- {
		n:=i
		for i := 2; i*i <= n; i++ {
			if n%i==0 {
				//if i==n/i {
				//	fmt.Println(i,n)
				//}
				fmt.Println(i,n)
				return
			}
		}
	}
}

package main

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

func main() {
	Test()
}

// P mod a=P mod b, where x mod y denotes the remainder when x is divided by y, and
// 2 ≤ a <b ≤ P

func Test() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := ScanPosInt(sc)
	for i := 1; i <= N; i++ {
		P := ScanPosInt(sc)
		fmt.Println(2,P-1)
	}
}

func ScanPosInt(scanner *bufio.Scanner) (n int) {
	scanner.Scan()
	buf := scanner.Bytes()
	for _, v := range buf {
		n = n*10 + int(v-'0')
	}
	return
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	line, _, _ := reader.ReadLine()
	str := string(line)
	n, _ := strconv.Atoi(str)
	for i := 0; i < n; i++ {
		line, _, _ := reader.ReadLine()
		str := string(line)
		n, _ := strconv.Atoi(str)
		mods := make(map[int]int)
		for i := 2; i < n; i++ {
			if mods[n%i] != 0 {
				fmt.Printf("%v %v\n", mods[n%i], i)
				break
			}
			mods[n%i] = i
		}
	}
}

package main

import "fmt"

func main() {
	t := 0
	fmt.Scanf("%d\n", &t)

	for i := 0; i < t; i++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		if n == 5 {
			fmt.Println(2, 4)
		} else {
			fmt.Println(2, (n-1)/2)
		}
	}
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

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

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

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

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

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

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

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

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

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

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {

		var n int
		fmt.Fscan(input, &n)

		// STRING := make([]byte, 0)
		// fmt.Fscan(input, &STRING)

		// ARRAY := make([]int64, n)
		// fmt.Fscan(input, &ARRAY[0])
		// for i := 1; i < n; i++ {
		// 	fmt.Fscan(input, &ARRAY[i])

		// }
		fmt.Println(2)
		fmt.Println(n - 1)

	}

}

package main

import "fmt"

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

}

package main

import "fmt"

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

		fmt.Printf("%d %d\n",2,w-1)
	}

}

package main

import "fmt"

func main() {
	var t,w int
	fmt.Scanf("%d", &t)
	for i:=0;i<t;i++{
		fmt.Scanf("%d", &w)
		if w==5{
			fmt.Printf("%d %d\n",2,4)
		}else {
			fmt.Printf("%d %d\n",2,w-1)
		}

	}

}

package main

import "fmt"

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

}

package main

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

type CF1549A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1549A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1549A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1549A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1549A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1549A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1549A
Date: 12/10/21
User: epradere
URL: https://codeforces.com/problemset/problem/1549/A
Problem: CF1549A
**/
func (in *CF1549A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		in.NextInt64()
		fmt.Println(2, 4)
	}
}

func NewCF1549A(r *bufio.Reader) *CF1549A {
	return &CF1549A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1549A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

type CF1549A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1549A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1549A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1549A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1549A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1549A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1549A
Date: 12/10/21
User: epradere
URL: https://codeforces.com/problemset/problem/1549/A
Problem: CF1549A
**/
func (in *CF1549A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		P := in.NextInt64()
		fmt.Println(P+1, P+P+1)
	}
}

func NewCF1549A(r *bufio.Reader) *CF1549A {
	return &CF1549A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1549A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		p, _ := strconv.Atoi(scanner.Text())
		if p < 6 {
			fmt.Println(3, 4)
		} else {
			fmt.Println(2, p/2)
		}
	}
}

package main

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

func GetAllDivisors(N int) []int {
	vs := []int{}
	for i := 1; i*i <= N; i++ {
		if N%i == 0 {
			vs = append(vs, i)
			if i*i == N {
				continue
			}
			vs = append(vs, N/i)
		}
	}
	return vs
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		a, b := 0, 0
		for _, v := range GetAllDivisors(n - 1) {
			if v != 1 && a == 0 {
				a = v
			}
			if v != 1 && a != 0 {
				b = v
			}
		}
		fmt.Fprintln(w, a, b)
	}

	w.Flush()
}

func main() {
	solve()
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, p   int
)

func solve(p int) string {
	return fmt.Sprintf("%d %d", p-1, (p-1)/2)
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &p)
		fmt.Println(solve(p))
	}
}

package main

import (
	"fmt"
)

func main() {
	var (
		test int
		P    int
	)
	fmt.Scanln(&test)
	for i := 0; i < test; i++ {
		fmt.Scanln(&P)
		fmt.Println(2, P/2)
	}
}

package main

import "fmt"

func main(){

	var t int16
	var p int64
	fmt.Scanf("%d", &t)

	for t>0{

		fmt.Scanf("%d", &p)

		var a int64 = 2
		var b int64 = (p-1)/a

		if(p==5){
			b=4
		}

		fmt.Printf("%d %d\n", a,b)

		t--
	}
}


Rhodoks has a tree with $$$n$$$ vertices, but he doesn't remember its structure. The vertices are indexed from $$$1$$$ to $$$n$$$.A segment $$$[l,r]$$$ ($$$1 \leq l \leq r \leq n$$$) is good if the vertices with indices $$$l$$$, $$$l + 1$$$, ..., $$$r$$$ form a connected component in Rhodoks' tree. Otherwise, it is bad.For example, if the tree is the one in the picture, then only the segment $$$[3,4]$$$ is bad while all the other segments are good.  For each of the $$$\frac{n(n+1)}{2}$$$ segments, Rhodoks remembers whether it is good or bad. Can you help him recover the tree? If there are multiple solutions, print any.It is guaranteed that the there is at least one tree satisfying Rhodoks' description.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 1000$$$). The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2000$$$) — the number of vertices in the tree. Then $$$n$$$ lines follow. The $$$i$$$-th of these lines contains a string $$$good_i$$$ of length $$$n+1-i$$$ consisting of 0 and 1. If the segment $$$[i,i+j-1]$$$ is good then the $$$j$$$-th character of $$$good_i$$$ is 1, otherwise $$$j$$$-th character of $$$good_i$$$ is 0. It is guaranteed that the there is at least one tree consistent with the given data.  It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2000$$$.

For each test case, print $$$n-1$$$ lines describing the tree you recover.  The $$$i$$$-th line should contain two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i,v_i \leq n$$$), denoting an edge between vertices $$$u_i$$$ and $$$v_i$$$. If there are multiple solutions, print any.

NoteThe first test case is explained in the statement.In the second test case, one possible tree is as follows:  In the third test case, one possible tree is as follows:

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)

		good := make([]string, n)
		for i := 0; i < n; i++ {
			good[i] = readString(reader)
		}

		res := solve(n, good)

		for _, edge := range res {
			buf.WriteString(fmt.Sprintf("%d %d\n", edge[0], edge[1]))
		}
	}
	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}
func solve(n int, good []string) [][]int {

	lv := make([]int, n+1)
	rv := make([]int, n+1)

	for i := 1; i <= n; i++ {
		lv[i] = i
		rv[i] = i
	}

	tmp := make([][]int, 2)
	for i := 0; i < 2; i++ {
		tmp[i] = make([]int, n)
	}
	pos := make([]int, 2)
	back := func(id int) int {
		return tmp[id][pos[id]-1]
	}

	push := func(id int, v int) {
		tmp[id][pos[id]] = v
		pos[id]++
	}

	reset := func() {
		for i := 0; i < 2; i++ {
			pos[i] = 0
		}
	}

	var edges [][]int

	for L := 2; L <= n; L++ {
		for l := 1; l <= n+1-L; l++ {
			r := l + L - 1
			if good[l-1][r-l] == '1' && lv[l] != lv[r] && rv[l] != rv[r] {
				edges = append(edges, []int{l, r})

				reset()
				push(0, l)
				push(1, r)

				id := 1

				for i := rv[l] + 1; i < lv[r]; i++ {
					if lv[i] == i {
						// the left bound
						edges = append(edges, []int{back(id), i})
						push(id, i)
						id ^= 1
					}
				}
				lm := lv[l]
				rm := rv[r]
				for i := lm; i <= rm; i++ {
					lv[i] = lm
					rv[i] = rm
				}
			}
		}
	}
	return edges
}


Petya and Vasya are competing with each other in a new interesting game as they always do.At the beginning of the game Petya has to come up with an array of $$$N$$$ positive integers. Sum of all elements in his array should be equal to $$$S$$$. Then Petya has to select an integer $$$K$$$ such that $$$0 \leq K \leq S$$$.In order to win, Vasya has to find a non-empty subarray in Petya's array such that the sum of all selected elements equals to either $$$K$$$ or $$$S - K$$$. Otherwise Vasya loses.You are given integers $$$N$$$ and $$$S$$$. You should determine if Petya can win, considering Vasya plays optimally. If Petya can win, help him to do that.

The first line contains two integers $$$N$$$ and $$$S$$$ ($$$1 \leq N \leq S \leq 10^{6}$$$) — the required length of the array and the required sum of its elements.

If Petya can win, print "YES" (without quotes) in the first line. Then print Petya's array in the second line. The array should contain $$$N$$$ positive integers with sum equal to $$$S$$$. In the third line print $$$K$$$. If there are many correct answers, you can print any of them. If Petya can't win, print "NO" (without quotes). You can print each letter in any register (lowercase or uppercase).

package main

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

type node struct {
	diff int
	time int
}

type ByTime []node

func (a ByTime) Len() int           { return len(a) }
func (a ByTime) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByTime) Less(i, j int) bool { return a[i].time < a[j].time }

var p []int
var c []int
var children [][]int
var invalid bool

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	//fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, s := 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &s)
		if n*2 <= s {
			fmt.Fprintf(out, "YES\n")
			for i := 0; i < n-1; i++ {
				fmt.Fprintf(out, "2 ")
			}
			fmt.Fprintf(out, "%d\n", s-n*2+2)
			fmt.Fprintf(out, "1\n")
		} else {
			fmt.Fprintf(out, "NO\n")
		}
	}
	return
}

func output(w io.Writer, out1 []int, out2 []string) {
	n := len(out1)
	tmpN := n
	for i := 0; i < len(out1); i++ {
		if out1[i] == 0 {
			tmpN--
		}
	}
	fmt.Fprintf(w, "YES\n")
	fmt.Fprintf(w, "%d\n", tmpN)
	for i := 0; i < n; i++ {
		if out1[i] > 0 {
			fmt.Fprintf(w, "%d %s\n", out1[i], out2[i])
		}
	}
	return
}

package main

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

var sc = WordScanner()
var memory [1000000]interface{}

func main() {
	n := sc.Int()
	s := sc.Int()
	if n == 1 {
		if s > 1 {
			fmt.Println("YES")
			fmt.Println(s)
			fmt.Println("1")
		} else {
			fmt.Println("NO")
		}
		return
	}
	if n + n > s {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")
	p := memory[:0]
	x := s / n + 1
	for i := s % n; i > 0; i-- {
		p = append(p, x)
	}
	x = s / n
	for i := n - s % n; i > 0; i-- {
		p = append(p, x)
	}
	fmt.Println(p...)
	fmt.Println("1")
}

type Scanner struct {
	*bufio.Scanner
}

func WordScanner() Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return Scanner{sc}
}

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n, s int64
	fmt.Fscanf(in, "%d %d", &n, &s)

	if s >= 2*n {
		var i int64
		fmt.Fprintf(out, "YES\n")
		for i = 0; i < n-1; i++ {
			fmt.Fprintf(out, "2 ")
		}
		fmt.Fprintf(out, "%d\n1", s-(n-1)*2)
	} else {
		fmt.Fprintf(out, "NO")
	}
	return
}

/*
URL:
https://codeforces.com/problemset/problem/1355/D
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	n, s int
)

func main() {
	n, s = ReadInt2()

	if s < 2*n {
		fmt.Println("NO")
		return
	}

	A := []int{}
	for i := 0; i < n-1; i++ {
		A = append(A, 2)
	}
	A = append(A, s-2*(n-1))

	fmt.Println("YES")
	fmt.Println(PrintIntsLine(A...))
	fmt.Println(1)
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

var reader = bufio.NewReader(os.Stdin)  //use fmt.Fscan
var writer = bufio.NewWriter(os.Stdout) //use fmt.Fprintln

func solve() {
	var n, s int
	fmt.Fscan(reader, &n, &s)
	var x int = s / 2
	if x >= n {
		fmt.Fprintln(writer, "YES")
		last := s - (n-1)*2
		for i := 0; i < n-1; i++ {
			fmt.Fprint(writer, "2 ")
		}
		fmt.Fprintln(writer, last)
		fmt.Fprintln(writer, 1)
	} else {
		fmt.Fprintln(writer, "NO")
	}
}

func main() {
	var t int = 1
	// fmt.Fscan(reader, &t)
	defer writer.Flush()
	for t > 0 {
		solve()
		t--
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1355D(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, s int
	Fscan(_r, &n, &s)
	if s < 2*n {
		Fprint(out, "NO")
	} else {
		Fprintln(out, "YES")
		for i := 1; i < n; i++ {
			Fprint(out, "1 ")
		}
		Fprintln(out, s-n+1)
		Fprint(out, n)
	}
}

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

package main

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

func main() {
	n, s := ScanInt(), ScanInt()
	solve(n, s)

	close(O)
	oWg.Wait()
}
func solve(n, s int) {
	if s/n == 1 {
		P("NO")
		return
	}

	repeted := strconv.Itoa(s/n) + " "
	lastOne := strconv.Itoa((s / n) + (s % n))

	arrayStr := strings.Repeat(repeted, n-1) + lastOne
	P("YES")
	P(arrayStr)
	P(1)
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

func main() {
	n, s := ScanInt(), ScanInt()
	solve(n, s)

	out.Flush()
}

func solve(n, s int) {
	if s/n == 1 {
		P("NO")
		return
	}

	repeted := strconv.Itoa(s/n) + " "
	lastOne := strconv.Itoa((s / n) + (s % n))

	arrayStr := strings.Repeat(repeted, n-1) + lastOne
	P("YES")
	P(arrayStr)
	P(1)
}

/*********************** I/O ***********************/
var in *bufio.Scanner
var out *bufio.Writer

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
}

func P(args ...interface{}) {
	print("\n", args...)
}

func PS(args ...interface{}) {
	print(" ", args...)
}

func print(seperator string, args ...interface{}) {
	for _, arg := range args {
		str := ""
		switch v := arg.(type) {
		case byte:
			str = string(v)
		case rune:
			str = string(v)
		case int:
			str = strconv.Itoa(v)
		case int64:
			str = strconv.FormatInt(v, 10)
		case string:
			str = v
		}
		out.WriteString(str + seperator)
	}
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanWords(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt()
	}
	return a
}
func ScanInt64s(n int) []int64 {
	a := make([]int64, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt64()
	}
	return a
}

/*********************** Utils int64 ***********************/
func MnMx64(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn64(args ...int64) int64 { mn, _ := MnMx64(args...); return mn }
func Mx64(args ...int64) int64 { _, mx := MnMx64(args...); return mx }
func LCM64(a, b int64) int64   { return a / GCD64(a, b) * b }
func GCD64(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD64(b%a, a)
}
func SortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func Abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

/*********************** Utils int ***********************/
func MnMx(args ...int) (int, int) {
	minVal, maxVal := math.MaxInt32, math.MinInt32
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


You are given an array $$$a$$$ consisting of $$$n$$$ integers numbered from $$$1$$$ to $$$n$$$.Let's define the $$$k$$$-amazing number of the array as the minimum number that occurs in all of the subsegments of the array having length $$$k$$$ (recall that a subsegment of $$$a$$$ of length $$$k$$$ is a contiguous part of $$$a$$$ containing exactly $$$k$$$ elements). If there is no integer occuring in all subsegments of length $$$k$$$ for some value of $$$k$$$, then the $$$k$$$-amazing number is $$$-1$$$.For each $$$k$$$ from $$$1$$$ to $$$n$$$ calculate the $$$k$$$-amazing number of the array $$$a$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the number of elements in the array. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$) — the elements of the array.  It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$.

For each test case print $$$n$$$ integers, where the $$$i$$$-th integer is equal to the $$$i$$$-amazing number of the array.

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(in, a...)
}

var err error

func next() (n string) {
	scan(&n)
	return n
}

func nextInt() (n int) {
	scan(&n)
	return n
}

func nextLong() (n int64) {
	scan(&n)
	return n
}

func nextDouble() (n float64) {
	scan(&n)
	return n
}

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

func solve() {
	n := nextInt()
	arr := make([]int, n)
	for i := range arr {
		arr[i] = nextInt()
	}
	prev := map[int]int{}
	max := map[int]int{}
	for i, v := range arr {
		dist := i + 1 - prev[v]
		prev[v] = i + 1
		if dist > max[v] {
			max[v] = dist
		}
	}
	for i, v := range prev {
		if n+1-v > max[i] {
			max[i] = n + 1 - v
		}
	}
	eves := [][2]int{}
	for i, v := range max {
		eves = append(eves, [2]int{i, v})
	}
	sort.Slice(eves, func(a, b int) bool {
		return eves[a][1] < eves[b][1]
	})

	ind := 0
	res := -1
	for i := 1; i <= n; i++ {
		for ind < len(eves) && eves[ind][1] == i {
			if eves[ind][0] < res || res == -1 {
				res = eves[ind][0]
			}
			ind++
		}
		printf("%d ", res)
	}
	printf("\n")
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	name := "in"
	file1, err := os.Open(name + ".in")
	if err == nil {
		in = bufio.NewReaderSize(file1, 8192)
	}
	// file2, err := os.Create(name + ".out")
	// if err != nil {
	// 	log.Fatal(err)
	// }
	// out = bufio.NewWriterSize(file2, 8192)
	defer out.Flush()
	// start := time.Now()

	for t, i := nextInt(), 1; t > 0; t, i = t-1, i+1 {
		// printf("Case #%d:\n", i)
		solve()
	}

	// printf("%v\n", time.Now().Sub(start))
}

package main

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

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

	var T, n, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		ps := make([][]int, n+1)
		for i := range ps {
			ps[i] = []int{-1}
		}
		for i := 0; i < n; i++ {
			Fscan(in, &v)
			ps[v] = append(ps[v], i)
		}
		for i := range ps {
			ps[i] = append(ps[i], n)
		}
		ans := make([]int, n+2)
		for i := range ans {
			ans[i] = 1e9
		}
		for i := n; i > 0; i-- {
			mx := 0
			for j := 1; j < len(ps[i]); j++ {
				if d := ps[i][j] - ps[i][j-1]; d > mx {
					mx = d
				}
			}
			ans[mx] = i
		}
		for i := 1; i <= n; i++ {
			if ans[i-1] < ans[i] {
				ans[i] = ans[i-1]
			}
			if ans[i] == 1e9 {
				Fprint(out, "-1 ")
			} else {
				Fprint(out, ans[i], " ")
			}
		}
		Fprintln(out)
	}
}

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


William has two numbers $$$a$$$ and $$$b$$$ initially both equal to zero. William mastered performing three different operations with them quickly. Before performing each operation some positive integer $$$k$$$ is picked, which is then used to perform one of the following operations: (note, that for each operation you can choose a new positive integer $$$k$$$)  add number $$$k$$$ to both $$$a$$$ and $$$b$$$, or  add number $$$k$$$ to $$$a$$$ and subtract $$$k$$$ from $$$b$$$, or  add number $$$k$$$ to $$$b$$$ and subtract $$$k$$$ from $$$a$$$. Note that after performing operations, numbers $$$a$$$ and $$$b$$$ may become negative as well.William wants to find out the minimal number of operations he would have to perform to make $$$a$$$ equal to his favorite number $$$c$$$ and $$$b$$$ equal to his second favorite number $$$d$$$.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). Description of the test cases follows. The only line of each test case contains two integers $$$c$$$ and $$$d$$$ $$$(0 \le c, d \le 10^9)$$$, which are William's favorite numbers and which he wants $$$a$$$ and $$$b$$$ to be transformed into.

For each test case output a single number, which is the minimal number of operations which William would have to perform to make $$$a$$$ equal to $$$c$$$ and $$$b$$$ equal to $$$d$$$, or $$$-1$$$ if it is impossible to achieve this using the described operations.

NoteLet us demonstrate one of the suboptimal ways of getting a pair $$$(3, 5)$$$:  Using an operation of the first type with $$$k=1$$$, the current pair would be equal to $$$(1, 1)$$$.  Using an operation of the third type with $$$k=8$$$, the current pair would be equal to $$$(-7, 9)$$$.  Using an operation of the second type with $$$k=7$$$, the current pair would be equal to $$$(0, 2)$$$.  Using an operation of the first type with $$$k=3$$$, the current pair would be equal to $$$(3, 5)$$$.

package main

import (
	"fmt"
	"math"
)

func foo() {
	var c, d int
	fmt.Scan(&c, &d)
	switch {
	case c == 0 && d == 0:
		fmt.Println(0)
	case c == d:
		fmt.Println(1)
	case int(math.Abs(float64(c - d))) % 2 == 1:
		fmt.Println(-1)
	default:
		fmt.Println(2)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		foo()
	}
}

package main

import (
	"fmt"
)
var(
	t int
	a,b int
)
func Swap(a *int,b *int){
	tmp:= *a
	*a = *b
	*b = tmp
}
func main(){
	fmt.Scanf("%d\n",&t)
	for i := 1; i<=t;i++{
		fmt.Scanf("%d %d\n",&a,&b)
		if a<b{
			Swap(&a,&b)
		}
		if  a==0 &&b==0{
			fmt.Printf("0\n")
			continue
		}
		if(a-b)%2 != 0{
			fmt.Printf("-1\n")
		}else if a==b{
			fmt.Printf("1\n")
		}else {
			fmt.Printf("2\n")
		}

	}
}

package main

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

type CF1556A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1556A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1556A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1556A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1556A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1556A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1556A
Date: 14/01/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1556/A
Problem: CF1556A
**/
func (in *CF1556A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		a, b := in.NextInt(), in.NextInt()

		max := int(math.Max(float64(a), float64(b)))
		min := int(math.Min(float64(a), float64(b)))

		if (max-min)%2 == 0 {
			if max == min {
				if max == 0 {
					fmt.Println(0)
				} else {
					fmt.Println(1)
				}
			} else {
				fmt.Println(2)
			}

		} else {
			fmt.Println(-1)
		}
	}
}

func NewCF1556A(r *bufio.Reader) *CF1556A {
	return &CF1556A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1556A(bufio.NewReader(os.Stdin)).Run()
}

package main

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

func Abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		c, d := 0, 0
		fmt.Fscan(f, &c, &d)
		m := (c + d) / 2
		if c == d {
			if c == 0 {
				fmt.Fprintln(w, 0)
			} else {
				fmt.Fprintln(w, 1)
			}
		} else if Abs(m-c) == Abs(m-d) {
			fmt.Fprintln(w, 2)
		} else {
			fmt.Fprintln(w, -1)
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

var (
	reader  = bufio.NewReader(os.Stdin)
	t, c, d int
)

func solve(c, d int) int {
	if (c+d)%2 == 1 {
		return -1
	}
	if c == 0 && d == 0 {
		return 0
	}
	if c == d {
		return 1
	}
	return 2
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &c, &d)
		fmt.Println(solve(c, d))
	}
}

package main

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

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

	var T, a, b int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &a, &b)
		if a&1 != b&1 {
			Fprintln(out, -1)
		} else if a == 0 && b == 0 {
			Fprintln(out, 0)
		} else if a == b {
			Fprintln(out, 1)
		} else {
			Fprintln(out, 2)
		}
	}
}

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

package main

import(
	"fmt"
)

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

	for ;testcases > 0; testcases--{
		var c, d int
		fmt.Scanf("%d %d\n" , &c , &d)

		// swap
		if c > d {
			c, d = d , c
		}

		// corner cases
		if c == d {
			if c == 0{
				fmt.Println(0)
			}else{
				fmt.Println(1)
			}
			continue
		}

		diff := d - c
		if diff % 2 == 0 {
			fmt.Println(2)
		}else{
			fmt.Println(-1)
		}

	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

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

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

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

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

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

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

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

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

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

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

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

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

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var c, d int
		fmt.Fscan(input, &c, &d)

		if (c+d)%2 == 1 {
			fmt.Println(-1)
		} else {
			if c == 0 && d == 0 {
				fmt.Println(0)
			} else {
				if (c+d) == 0 || (c-d) == 0 {
					fmt.Println(1)
				} else {
					fmt.Println(2)
				}
			}
		}

	}
}

package main

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

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T int

	fmt.Fscanf(r, "%d\n", &T)

	for t := 0; t < T; t++ {
		var a, b int
		fmt.Fscanf(r, "%d %d\n", &a, &b)

		if a == 0 && b == 0 {
			fmt.Println(0)
		} else if a == b {
			fmt.Println(1)
		} else {
			if (a+b)%2 == 1 {
				fmt.Println(-1)
			} else {
				fmt.Println(2)
			}
		}
	}
}

package main

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

type Scanner struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) *Scanner {
	scanner := bufio.NewScanner(reader)
	scanner.Split(bufio.ScanWords)
	return &Scanner{scanner}
}

func (s *Scanner) Word() string {
	s.Scan()
	return s.Text()
}

func (s *Scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *Scanner) Int64() int64 {
	s.Scan()
	n, _ := strconv.ParseInt(s.Text(), 10, 64)
	return n
}

func (s *Scanner) Words(count int) []string {
	words := make([]string, count)
	for i := range words {
		words[i] = s.Word()
	}
	return words
}

func (s *Scanner) Ints(count int) []int {
	ints := make([]int, count)
	for i := range ints {
		ints[i] = s.Int()
	}
	return ints
}

func (s *Scanner) Int64s(count int) []int64 {
	int64s := make([]int64, count)
	for i := range int64s {
		int64s[i] = s.Int64()
	}
	return int64s
}

func solve(c, d int64) int64 {
	if c == 0 && d == 0 {
		return 0
	}
	if c == d {
		return 1
	}

	diff := c - d
	if diff < 0 {
		diff = -diff
	}
	if diff % 2 == 1 {
		return -1
	}

	return 2
}

func main() {
	stdin := NewWordScanner(os.Stdin)
	tests := stdin.Int()

	for i := 0; i < tests; i++ {
		c, d := stdin.Int64(), stdin.Int64()
		fmt.Println(solve(c, d))
	}
}

package main

import (
	"fmt"
	"math"
)

func foo() {
	var c, d int
	fmt.Scan(&c, &d)
	switch {
	case c == 0 && d == 0:
		fmt.Println(0)
	case c == d:
		fmt.Println(1)
	case math.Abs(float64(c - d)) == 1:
		fmt.Println(-1)
	default:
		fmt.Println(2)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		foo()
	}
}

package main

import (
	"fmt"
)
var(
	t int
	a,b int
)
func Swap(a *int,b *int){
	tmp:= *a
	*a = *b
	*b = tmp
}
func main(){
	fmt.Scanf("%d",&t)
	for i := 1; i<=t;i++{
		fmt.Scanf("%d%d",&a,&b)
		if a<b{
			Swap(&a,&b)
		}
		if a==0 && b==0{
			fmt.Printf("0\n")
			continue
		}
		if(a-b)%2 != 0{
			fmt.Printf("-1\n")
		}else if a==b{
			fmt.Printf("1\n")
		}else {
			fmt.Printf("2\n")
		}

	}
}


Pavel made a photo of his favourite stars in the sky. His camera takes a photo of all points of the sky that belong to some rectangle with sides parallel to the coordinate axes.Strictly speaking, it makes a photo of all points with coordinates $$$(x, y)$$$, such that $$$x_1 \leq x \leq x_2$$$ and $$$y_1 \leq y \leq y_2$$$, where $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$ are coordinates of the left bottom and the right top corners of the rectangle being photographed. The area of this rectangle can be zero.After taking the photo, Pavel wrote down coordinates of $$$n$$$ of his favourite stars which appeared in the photo. These points are not necessarily distinct, there can be multiple stars in the same point of the sky.Pavel has lost his camera recently and wants to buy a similar one. Specifically, he wants to know the dimensions of the photo he took earlier. Unfortunately, the photo is also lost. His notes are also of not much help; numbers are written in random order all over his notepad, so it's impossible to tell which numbers specify coordinates of which points.Pavel asked you to help him to determine what are the possible dimensions of the photo according to his notes. As there are multiple possible answers, find the dimensions with the minimal possible area of the rectangle.

The first line of the input contains an only integer $$$n$$$ ($$$1 \leq n \leq 100\,000$$$), the number of points in Pavel's records. The second line contains $$$2 \cdot n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_{2 \cdot n}$$$ ($$$1 \leq a_i \leq 10^9$$$), coordinates, written by Pavel in some order.

Print the only integer, the minimal area of the rectangle which could have contained all points from Pavel's records.

NoteIn the first sample stars in Pavel's records can be $$$(1, 3)$$$, $$$(1, 3)$$$, $$$(2, 3)$$$, $$$(2, 4)$$$. In this case, the minimal area of the rectangle, which contains all these points is $$$1$$$ (rectangle with corners at $$$(1, 3)$$$ and $$$(2, 4)$$$).

package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"sort"
)

type Scanner struct{
	buf []byte
	len int
	index int
}

func (scanner *Scanner) readInt() int{
	var ret = 0
	var valid = false
	for i := scanner.index; i < scanner.len; i++ {
		var ch = scanner.buf[i]
		var k = 0
		if ch >= '0' && ch <= '9' {
			k = (int)(ch - '0')
			ret = ret * 10 + k
			valid = true
		}else if valid{
			scanner.index = i + 1
			break
		}
	}
	return ret
}

func run(a []int, n int) int64 {
	if n == 1 {
		return 0
	}
	sort.Ints(a)
	var w = int64(a[n - 1] - a[0])
	var h = int64(a[n * 2 - 1] - a[n])
	var ans = w * h
	var m = n * 2

	w = int64(a[n * 2 - 1] - a[0])

	min := func(x int64, y int64) int64 {
		if x < y {
			return x
		}
		return y
	}
	for i := n ; i + 1 < m; i++ {
		h = int64(a[i] - a[i - n + 1])
		ans = min(ans,h * w)
	}
	return ans
}

func main()  {

	buffer, error := ioutil.ReadAll(os.Stdin)

	if error != nil {
		log.Fatal(error)
		return
	}

	var scanner = &Scanner{
		buf:buffer,
		len:len(buffer),
		index:0,
	}

	var n = scanner.readInt()
	var m = n << 1
	var a = make([]int,m)
	for i := 0; i < m; i++ {
		a[i] = scanner.readInt()
	}

	fmt.Println(run(a,n))
}

package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"sort"
)

type Scanner struct{
	buf []byte
	len int
	index int
}

func readInt(scanner *Scanner) int{
	var ret int = 0
	var valid = false
	for i := scanner.index; i < scanner.len; i++ {
		var ch = scanner.buf[i]
		var k = 0
		if ch >= '0' && ch <= '9' {
			k = (int)(ch - '0')
			ret = ret * 10 + k
			valid = true
		}else if valid{
			scanner.index = i + 1
			break
		}
	}
	return ret
}

func run(a []int, n int) int64 {
	if n == 1 {
		return 0
	}
	sort.Ints(a)
	var w = int64(a[n - 1] - a[0])
	var h = int64(a[n * 2 - 1] - a[n])
	return w * h
}

func main()  {

	buffer, error := ioutil.ReadAll(os.Stdin)

	if error != nil {
		log.Fatal(error)
		return
	}

	var scanner = &Scanner{
		buf:buffer,
		len:len(buffer),
		index:0,
	}

	var n = readInt(scanner)
	var m = n << 1
	var a = make([]int,m)
	for i := 0; i < m; i++ {
		a[i] = readInt(scanner)
	}

	fmt.Println(run(a,n))
}