Petya has an array of integers $$$a_1, a_2, \ldots, a_n$$$. He only likes sorted arrays. Unfortunately, the given array could be arbitrary, so Petya wants to sort it.Petya likes to challenge himself, so he wants to sort array using only $$$3$$$-cycles. More formally, in one operation he can pick $$$3$$$ pairwise distinct indices $$$i$$$, $$$j$$$, and $$$k$$$ ($$$1 \leq i, j, k \leq n$$$) and apply $$$i \to j \to k \to i$$$ cycle to the array $$$a$$$. It simultaneously places $$$a_i$$$ on position $$$j$$$, $$$a_j$$$ on position $$$k$$$, and $$$a_k$$$ on position $$$i$$$, without changing any other element.For example, if $$$a$$$ is $$$[10, 50, 20, 30, 40, 60]$$$ and he chooses $$$i = 2$$$, $$$j = 1$$$, $$$k = 5$$$, then the array becomes $$$[\underline{50}, \underline{40}, 20, 30, \underline{10}, 60]$$$.Petya can apply arbitrary number of $$$3$$$-cycles (possibly, zero). You are to determine if Petya can sort his array $$$a$$$, i. e. make it non-decreasing.

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^5$$$). Description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 5 \cdot 10^5$$$) — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq n$$$). It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$5 \cdot 10^5$$$.

For each test case, print "YES" (without quotes) if Petya can sort the array $$$a$$$ using $$$3$$$-cycles, and "NO" (without quotes) otherwise. You can print each letter in any case (upper or lower).

NoteIn the $$$6$$$-th test case Petya can use the $$$3$$$-cycle $$$1 \to 3 \to 2 \to 1$$$ to sort the array.In the $$$7$$$-th test case Petya can apply $$$1 \to 3 \to 2 \to 1$$$ and make $$$a = [1, 4, 2, 3]$$$. Then he can apply $$$2 \to 4 \to 3 \to 2$$$ and finally sort the array.

package main

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

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

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n+1)
		p := make([]int, n+1)
		eq := false
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			if p[a[i]] > 0 {
				eq = true
			}
			p[a[i]] = i
		}
		if eq || n < 2 {
			Fprintln(out, "YES")
			continue
		}
		for i := 1; i < n-1; i++ {
			if p[i] == i {
				continue
			}
			x, y := p[i], i
			z := n
			if x == n {
				z--
			}
			p[a[z]] = x
			p[a[y]] = z
			a[x] = a[z]
			a[z] = a[y]
		}
		if a[n-1] < a[n] {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

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

package main

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

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

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n+1)
		p := make([]int, n+1)
		eq := false
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			if p[a[i]] > 0 {
				eq = true
			}
			p[a[i]] = i
		}
		if eq || n < 2 {
			Fprintln(out, "YES")
			continue
		}
		for i := 1; i < n-1; i++ {
			if p[i] == i {
				continue
			}
			x, y := p[i], i
			z := n
			if x == n {
				z--
			}
			p[a[z]] = p[i]
			p[a[y]] = z
			a[x], a[y], a[z] = a[z], a[x], a[y]
		}
		if a[n-1] < a[n] {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

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

package main

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

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

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n+1)
		p := make([]int, n+1)
		eq := false
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			if p[a[i]] > 0 {
				eq = true
			}
			p[a[i]] = i
		}
		if !eq {
			for i := 1; i < n-1; i++ {
				if p[i] == i {
					continue
				}
				x, y := p[i], i
				if x < n {
					z := n
					p[a[z]] = p[i]
					p[a[y]] = z
					a[x], a[y], a[z] = a[z], a[x], a[y]
				} else {
					z := n - 1
					p[a[z]] = p[i]
					p[a[y]] = z
					a[x], a[y], a[z] = a[z], a[x], a[y]
				}
			}
		}
		if eq || n == 1 || a[n-1] < a[n] {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
}

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

package main

import (
	"bufio"
	"os"
	"fmt"
	"math/rand"
	"time"
)

const MOD int64 = 1000000007

var n int

var a[]int

const MAX int = 2e5 + 5

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

const LOCAL = false

var w *bufio.Writer

var cntGet int64
var cntAdd int64
var all int64
var cntLoop int64

func main() {

	read := bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)

	var t int
	fmt.Fscan(read, &t)

	if LOCAL {

		rand.Seed(time.Now().UnixNano())

		s := time.Now().UnixNano()

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

			n = 10

			a = make([]int, n)

			for j := 0; j < n; j++ {
				s := 1 + rand.Intn(n)
				a[j] = s
			}

			st := time.Now().UnixNano()
			solve()
			en := time.Now().UnixNano()
			all += en - st
		}

		w.Flush()

		e := time.Now().UnixNano()

		fmt.Println((e - s)/1000000)
		fmt.Println(cntGet/1000000)
		fmt.Println(cntAdd/1000000)
		fmt.Println(all/1000000)
		fmt.Println(cntLoop/1000000)

		return

	}

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

		fmt.Fscan(read, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(read, &a[j])
		}

		solve()
	}

	w.Flush()
}

type pair struct {
	v int
	idx []int
}

func solve() {
	//[10,50,30,20,40,60]
    //    i      k  j

    mp := make(map[int]int)

   for i := 0; i < n; i++ {
   	mp[a[i]]++
   }
   for _, v := range mp{
   	if v > 1 {
		fmt.Fprintln(w, "YES")
		return
	}
   }

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

   init := 0

	for j := n - 1; j >= 0; j-- {
		cur := a[j]
		var s int
		if cur != 1 {
			s = get(cur - 1, &bit)
		}

		init +=s

		add(cur, 1, &bit, n)
	}

	if init % 2 == 0 {
		fmt.Fprintln(w, "YES")
		return
	}

	fmt.Fprintln(w, "NO")
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

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

package main

import (
	"bufio"
	"os"
	"fmt"
	"math/rand"
	"time"
)

const MOD int64 = 1000000007

var n int

var a[]int

const MAX int = 2e5 + 5

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

const LOCAL = false

var w *bufio.Writer

var cntGet int64
var cntAdd int64
var all int64
var cntLoop int64

func main() {

	read := bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)

	var t int
	fmt.Fscan(read, &t)

	if LOCAL {

		rand.Seed(time.Now().UnixNano())

		s := time.Now().UnixNano()

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

			n = 10

			a = make([]int, n)

			for j := 0; j < n; j++ {
				s := 1 + rand.Intn(n)
				a[j] = s
			}

			st := time.Now().UnixNano()
			solve()
			en := time.Now().UnixNano()
			all += en - st
		}

		w.Flush()

		e := time.Now().UnixNano()

		fmt.Println((e - s)/1000000)
		fmt.Println(cntGet/1000000)
		fmt.Println(cntAdd/1000000)
		fmt.Println(all/1000000)
		fmt.Println(cntLoop/1000000)

		return

	}

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

		fmt.Fscan(read, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(read, &a[j])
		}

		solve()

		w.Flush()
	}
}

type pair struct {
	v int
	idx []int
}

func solve() {
	//[10,50,30,20,40,60]
    //    i      k  j

   //50 20 40

   //
   bit := make([]int, n + 1)

   init := 0

	for j := n - 1; j >= 0; j-- {
		cur := a[j]
		var s int
		if cur != 1 {
			s = get(cur - 1, &bit)
		}

		init +=s

		add(cur, 1, &bit, n)
	}

	if init % 2== 0 {
		fmt.Fprintln(w, "YES")
		return
	}

	fmt.Fprintln(w, "NO")
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

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

package main

import (
	"bufio"
	"os"
	"fmt"
	"math/rand"
	"time"
)

const MOD int64 = 1000000007

var n int

var a[]int

const MAX int = 2e5 + 5

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

const LOCAL = false

var w *bufio.Writer

var cntGet int64
var cntAdd int64
var all int64
var cntLoop int64

func main() {

	read := bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)

	var t int
	fmt.Fscan(read, &t)

	if LOCAL {

		rand.Seed(time.Now().UnixNano())

		s := time.Now().UnixNano()

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

			n = 10

			a = make([]int, n)

			for j := 0; j < n; j++ {
				s := 1 + rand.Intn(n)
				a[j] = s
			}

			st := time.Now().UnixNano()
			solve()
			en := time.Now().UnixNano()
			all += en - st
		}

		w.Flush()

		e := time.Now().UnixNano()

		fmt.Println((e - s)/1000000)
		fmt.Println(cntGet/1000000)
		fmt.Println(cntAdd/1000000)
		fmt.Println(all/1000000)
		fmt.Println(cntLoop/1000000)

		return

	}

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

		fmt.Fscan(read, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(read, &a[j])
		}

		solve()
	}
	w.Flush()

}

type pair struct {
	v int
	idx []int
}

func solve() {
	//[10,50,30,20,40,60]
    //    i      k  j

   //50 20 40

   //
   bit := make([]int, n + 1)

   init := 0

	for j := n - 1; j >= 0; j-- {
		cur := a[j]
		var s int
		if cur != 1 {
			s = get(cur - 1, &bit)
		}

		init +=s

		add(cur, 1, &bit, n)
	}

	if init % 2== 0 {
		fmt.Fprintln(w, "YES")
		return
	}

	fmt.Fprintln(w, "NO")
}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

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

package main

import (
	"bufio"
	"os"
	"fmt"
	"math/rand"
	"time"
)

const MOD int64 = 1000000007

var n int

var a[]int

const MAX int = 2e5 + 5

// ByAge implements sort.Interface based on the Age field.
type ByV []*pair

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

const LOCAL = false

var w *bufio.Writer

func main() {

	read := bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)

	var t int
	fmt.Fscan(read, &t)

	if LOCAL {

		rand.Seed(time.Now().UnixNano())

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

			n = 50

			a = make([]int, n)

			for j := 0; j < n; j++ {
				s := 1 + rand.Intn(n)
				a[j] = s
			}

			solve()
		}

		return

	}

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

		fmt.Fscan(read, &n)

		a = make([]int, n)

		for j := 0; j < n; j++ {
			fmt.Fscan(read, &a[j])
		}

		solve()

		w.Flush()
	}
}

type pair struct {
	v int
	idx []int
}

func solve() {
	//[10,50,30,20,40,60]
    //    i      k  j

   //50 20 40

   //
   bit := make([]int, MAX)

   init := 0

	for j := n - 1; j >= 0; j-- {
		cur := a[j]
		var s int
		if cur != 1 {
			s = get(cur - 1, &bit)
		}

		init +=s

		add(cur, 1, &bit, n)
	}

	if init % 2== 0 {
		fmt.Fprintln(w, "YES")
	}

	fmt.Fprintln(w, "NO")

}

func add(idx int, delta int, bit *[]int, n int) {
	for ; idx <= n; idx += idx & -idx {
		(*bit)[idx] += delta
	}
}

func get(idx int, bit *[]int) int {
	ret := 0
	for ; idx > 0; idx -= idx & -idx {
		ret += (*bit)[idx];
	}
	return ret
}

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


zscoder loves simple strings! A string t is called simple if every pair of adjacent characters are distinct. For example ab, aba, zscoder are simple whereas aa, add are not simple.zscoder is given a string s. He wants to change a minimum number of characters so that the string s becomes simple. Help him with this task!

The only line contains the string s (1 ≤ |s| ≤ 2·105) — the string given to zscoder. The string s consists of only lowercase English letters.

Print the simple string s' — the string s after the minimal number of changes. If there are multiple solutions, you may output any of them. Note that the string s' should also consist of only lowercase English letters.

package main

import "fmt"

func main() {
	s := make([]byte, 2e5+1)
	fmt.Scanf("%s", &s)
	for i := range s[1:] {
		if s[i] == s[i+1] {
			c := byte('a')
			for s[i] == c || i+2 < len(s) && s[i+2] == c {
				c++
			}
			s[i+1] = c
		}
	}
	fmt.Printf("%s\n", s)
}

package main

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

var abc = []byte("abcdefghijklmnopqrstuvwxyz")

func getOtherThan(chars []byte) byte {
	for _, a := range (abc) {
		if !byteInList(a, chars) {
			return a;
		}
	}
	panic("abc is too small")
}

func byteInList(a byte, list []byte) bool {
	for _, b := range list {
		if b == a {
			return true
		}
	}
	return false
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	inputstr, _ := reader.ReadString('\n')

	input := []byte(inputstr)

	result := []byte{}

	var last byte = '\n'
	for n, ch := range input {
		if (last == ch) {
			exclude := []byte{last}
			if n + 1  < len(input) { // perf
				  exclude = append(exclude, input[n+1])
			}
			newCh := getOtherThan(exclude)
			last = newCh
			result = append(result, newCh)
		} else {
			last = ch
			result = append(result, ch)
		}
	}

	fmt.Print(string(result))
}

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	s, _ := reader.ReadBytes('\n')
	s = bytes.TrimSpace(s)

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

			for c := byte('a'); c <= 'z'; c++ {
				if i == 0 {
					if c != s[i+1] {
						s[i] = c
						break
					}
				} else if c != s[i-1] && c != s[i+1] {
					s[i] = c
					break
				}
			}
		}
	}

	println(string(s))
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

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

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

	var s []byte
	Fscan(in, &s)
	for i, b := range s {
		if i+1 < len(s) && b == s[i+1] {
			s[i+1] = b + 1
			if s[i+1] > 'z' {
				s[i+1] = 'a'
			}
			if i+2 < len(s) && s[i+1] == s[i+2] {
				s[i+1]++
				if s[i+1] > 'z' {
					s[i+1] = 'a'
				}
			}
		}
	}
	Fprint(out, string(s))
}

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

package main

import "fmt"

func main() {
	s := make([]byte, 2e5+1)
	fmt.Scanf("%s", &s)
	for i := range s[1:] {
		if s[i] == s[i+1] {
			c := byte('a')
			for s[i] == c || i+1 < len(s) && s[i+1] == c {
				c++
			}
			s[i+1] = c
		}
	}
	fmt.Printf("%s\n", s)
}

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	s, _ := reader.ReadBytes('\n')
	s = bytes.TrimSpace(s)

	for i := 1; i < len(s)-1; i++ {
		if s[i] == s[i-1] || s[i] == s[i+1] {
			for c := byte('a'); c <= 'z'; c++ {
				if c != s[i-1] && c != s[i+1] {
					s[i] = c
					break
				}
			}
		}
	}

	println(string(s))
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	s, _ := reader.ReadBytes('\n')
	s = bytes.TrimSpace(s)

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

			for c := byte('a'); c <= 'z'; c++ {
				if i == 0 {
					if c != s[i+1] {
						s[i] = c
						break
					}
				} else if c != s[i-1] && c != s[i+1] {
					s[i] = c
					break
				}
			}
		}
	}

	println(string(s))
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }


Despite his bad reputation, Captain Flint is a friendly person (at least, friendly to animals). Now Captain Flint is searching worthy sailors to join his new crew (solely for peaceful purposes). A sailor is considered as worthy if he can solve Flint's task.Recently, out of blue Captain Flint has been interested in math and even defined a new class of integers. Let's define a positive integer $$$x$$$ as nearly prime if it can be represented as $$$p \cdot q$$$, where $$$1 < p < q$$$ and $$$p$$$ and $$$q$$$ are prime numbers. For example, integers $$$6$$$ and $$$10$$$ are nearly primes (since $$$2 \cdot 3 = 6$$$ and $$$2 \cdot 5 = 10$$$), but integers $$$1$$$, $$$3$$$, $$$4$$$, $$$16$$$, $$$17$$$ or $$$44$$$ are not.Captain Flint guessed an integer $$$n$$$ and asked you: can you represent it as the sum of $$$4$$$ different positive integers where at least $$$3$$$ of them should be nearly prime.Uncle Bogdan easily solved the task and joined the crew. Can you do the same?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contain test cases — one per line. The first and only line of each test case contains the single integer $$$n$$$ $$$(1 \le n \le 2 \cdot 10^5)$$$ — the number Flint guessed.

For each test case print:    YES and $$$4$$$ different positive integers such that at least $$$3$$$ of them are nearly prime and their sum is equal to $$$n$$$ (if there are multiple answers print any of them);  NO if there is no way to represent $$$n$$$ as the sum of $$$4$$$ different positive integers where at least $$$3$$$ of them are nearly prime.  YES NO

NoteIn the first and second test cases, it can be proven that there are no four different positive integers such that at least three of them are nearly prime.In the third test case, $$$n=31=2 \cdot 7 + 2 \cdot 5 + 2 \cdot 3 + 1$$$: integers $$$14$$$, $$$10$$$, $$$6$$$ are nearly prime.In the fourth test case, $$$n=36=5 + 2 \cdot 3 + 2 \cdot 5 + 3 \cdot 5$$$: integers $$$6$$$, $$$10$$$, $$$15$$$ are nearly prime.In the fifth test case, $$$n=44=2 \cdot 3 + 7 + 2 \cdot 5 + 3 \cdot 7$$$: integers $$$6$$$, $$$10$$$, $$$21$$$ are nearly prime.In the sixth test case, $$$n=100=2 + 2 \cdot 5 + 3 \cdot 11 + 5 \cdot 11$$$: integers $$$10$$$, $$$33$$$, $$$55$$$ are nearly prime.In the seventh test case, $$$n=258=2 \cdot 5 + 3 \cdot 7 + 13 \cdot 17 + 2 \cdot 3$$$: integers $$$10$$$, $$$21$$$, $$$221$$$, $$$6$$$ are nearly prime.

package main

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

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

	for t := io.nextInt(); t > 0; t-- {
		n := io.nextInt()
		if n > 6+10+14 {
			io.println("YES")
			nn := n - 6 - 10 - 14
			if nn == 6 || nn == 10 || nn == 14 {
				io.printlnInts(6, 10, 15, n-6-10-15)
			} else {
				io.printlnInts(6, 10, 14, n-6-10-14)
			}
		} else {
			io.println("NO")
		}
	}
}

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 f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	neg := false
	if f.p[0] == '-' {
		neg = true
		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[:])
	}
	if neg {
		return -n
	}
	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"
	"fmt"
	"os"
	"strconv"
)

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

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

	for  t := in() ; t > 0; t-- {
		n := in()

		if n < 31 {
			fmt.Println("No")
		} else if n == 40 {
			fmt.Println("Yes")
			fmt.Println(6, 10, 15, 9)
		} else if n == 36 {
			fmt.Println("Yes")
			fmt.Println(6, 10, 15, 5)
		} else if n == 44 {
			fmt.Println("Yes")
			fmt.Println(6, 10, 15, 13)
		} else {
			fmt.Println("Yes")
			fmt.Println(6, 10, 14, n - (10 + 6 + 14))		}
	}
}

package main

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

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n:= reader.NextInt64()
		// // s:=reader.NextString();
		// k:= reader.NextInt64()
		// aa := make([]int64, n)
		// for i := 0; i < len(aa); i++ {
		// 	aa[i]=reader.NextInt64()
		// }
		sol(n)
	}
}

func sol(n int64) {
	if n<=30 {
		writer.Printf("NO\n")
	}else{
		writer.Printf("YES\n")
		if (n==36){
			writer.Printf("5 6 10 15\n")
		}else if (n==40) {
			writer.Printf("6 10 15 9\n")
		}else if (n==44){
			writer.Printf("6 7 10 21\n")
		}else{
			writer.Printf("6 10 14 %d\n",n-30)
		}
	}
}

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

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

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

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
	impl.Scan()
	bb := impl.Bytes()
	i := 0
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

/*
URL:
https://codeforces.com/contest/1388/problem/A
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"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
	// MOD          = 998244353
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

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

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

var (
	t int
	n int

	C []int
)

func main() {
	_, P := sieve(30)
	for i := 0; i < len(P); i++ {
		for j := i + 1; j < len(P); j++ {
			p, q := P[i], P[j]
			C = append(C, p*q)
		}
	}
	sort.Sort(sort.IntSlice(C))
	PrintfDebug("%v\n", C)

	t = ReadInt()
	for i := 0; i < t; i++ {
		n = ReadInt()

		solve()
	}
}

func solve() {
	for i := 0; i < len(C); i++ {
		for j := i + 1; j < len(C); j++ {
			for k := j + 1; k < len(C); k++ {
				s, t, u := C[i], C[j], C[k]
				last := n - (s + t + u)

				if last > 0 && last != s && last != t && last != u {
					fmt.Println("YES")
					fmt.Println(s, t, u, last)
					return
				}
			}
		}
	}
	fmt.Println("NO")
}

// エラトステネスの篩: O(NloglogN)
// n以下の素数の数と素数のスライスを返す
func sieve(n int) (int, []int) {
	// var prime [2000000 + 5]int
	prime := []int{}
	var isPrime [2000000 + 5 + 1]bool

	p := 0
	for i := 0; i <= n; i++ {
		isPrime[i] = true
	}
	isPrime[0], isPrime[1] = false, false

	for i := 2; i <= n; i++ {
		// iがtrueで残っている場合は素数認定し、自分より大きい倍数を取り除いていく
		if isPrime[i] {
			// prime[p] = i
			prime = append(prime, i)
			p++

			// 倍数の除去
			for j := 2 * i; j <= n; j += i {
				isPrime[j] = false
			}
		}
	}

	return p, prime
}

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

/*********** 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 "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		if n < 31 {
			fmt.Println("NO")
			continue
		}
		fmt.Println("YES")
		last := n - 30
		if last == 6 || last == 10 || last == 14 {
			last--
			fmt.Printf("6 10 15 %d\n", last)
			continue
		}
		fmt.Printf("6 10 14 %d\n", last)
	}
}

package main

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

func main() {

	var input io.Reader = bufio.NewReader(os.Stdin)

	var n, t int

	fmt.Fscan(input, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(input, &n)

		if n < 31 {
			fmt.Println("NO")
			continue
		}
		if n == 36 {
			fmt.Println("YES")
			fmt.Printf("%d %d %d %d\n", 6, 10, 15, 5)
			continue
		}
		if n == 40 {
			fmt.Println("YES")
			fmt.Printf("%d %d %d %d\n", 6, 10, 15, 9)
			continue
		}
		if n == 44 {
			fmt.Println("YES")
			fmt.Printf("%d %d %d %d\n", 6, 10, 15, 13)
			continue
		} else {
			fmt.Println("YES")
			fmt.Printf("%d %d %d %d\n", 6, 10, 14, n-30)
			continue
		}
	}
}

package main

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

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

	var pattern = []int{6, 10, 14, 15}

	var nt int
	fmt.Fscanf(reader, "%d\n", &nt)
	for kk := 0; kk < nt; kk++ {
		var n int
		fmt.Fscanf(reader, "%d\n", &n)

		var ret = make([]int, 0)

		for i := 0; i < len(pattern); i++ {
			for j := i + 1; j < len(pattern); j++ {
				for k := j + 1; k < len(pattern); k++ {

					if len(ret) > 0 {
						continue
					}

					var rm = n - pattern[i] - pattern[j] - pattern[k]
					if rm != pattern[i] && rm != pattern[j] && rm != pattern[k] && rm > 0 {
						ret = append(ret, pattern[i])
						ret = append(ret, pattern[j])
						ret = append(ret, pattern[k])
						ret = append(ret, rm)
					}
				}
			}
		}
		if len(ret) > 0 {
			fmt.Fprintf(writer, "YES\n")
			for _, v := range ret {
				fmt.Fprintf(writer, "%d ", v)
			}
			fmt.Fprintf(writer, "\n")
		} else {
			fmt.Fprintf(writer, "NO\n")
		}
	}
}

package main

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

//Task -
type Task struct {
	Number int
}

func (t *Task) Solve() {
	if t.Number > 44 {
		fmt.Println("YES")
		fmt.Println(6, 10, 14, t.Number-30)
	} else if t.Number < 31 {
		fmt.Println("NO")
	} else if t.Number >= 31 && t.Number < 36 {
		fmt.Println("YES")
		fmt.Println(6, 10, 14, t.Number-30)
	} else if t.Number == 36 {
		fmt.Println("YES")
		fmt.Println(6, 15, 14, 1)
	} else if t.Number > 36 && t.Number < 40 {
		fmt.Println("YES")
		fmt.Println(6, 10, 14, t.Number-30)
	} else if t.Number == 40 {
		fmt.Println("YES")
		fmt.Println(6, 10, 21, 3)
	} else if t.Number > 40 && t.Number < 44 {
		fmt.Println("YES")
		fmt.Println(6, 10, 14, t.Number-30)
	} else if t.Number == 44 {
		fmt.Println("YES")
		fmt.Println(6, 15, 14, 9)
	}
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	// counter := 0
	// tasksAmount := 0
	tasks := []Task{}
	_ = scanner.Scan()
	for scanner.Scan() {

		var currentTask Task
		//Заполняем новое задание
		currentTask = Task{
			Number: 0,
		}
		text := scanner.Text()

		currentTask.Number, _ = strconv.Atoi(text)

		tasks = append(tasks, currentTask)

	}

	for _, t := range tasks {
		t.Solve()
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, tmp int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		fmt.Scanf("%d\n", &tmp)
		if tmp == 36 || tmp == 40 || tmp == 44 {
			fmt.Printf("YES\n6 10 15 %d\n", tmp-31)
		} else if tmp > 30 {
			fmt.Printf("YES\n6 10 14 %d\n", tmp-30)
		} else {
			fmt.Printf("NO\n")
		}
	}
}

package main

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

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		if n <= 30 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
			if n == 36 {
				fmt.Println(6, 10, 15, 5)
			} else if n == 40 {
				fmt.Println(6, 10, 15, 9)
			} else if n == 44 {
				fmt.Println(6, 10, 15, 13)
			} else {
				fmt.Println(6, 10, 14, n-30)
			}
		}
	}
}

package main

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

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

	T:= 0
	for Fscan(in, &T); T > 0; T-- {
		var n int
		Fscan(in, &n)

		if(n<=30){
			Fprintln(out,"NO")
			continue
		}

		if(n!=36&&n!=40&&n!=44){
			Fprintln(out,"YES")
			Fprintln(out,6,10,14,n-30)
			continue
		}
		Fprintln(out,"YES")
		Fprintln(out,6,10,15,n-31)
	}
}

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

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 i := 0; i < t; i++ {

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

		n -= 30

		if n <= 0 {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
			switch n {
			case 6, 10, 14:
				fmt.Fprintln(out, 6, 10, 15, n-1)
			default:
				fmt.Fprintln(out, 6, 10, 14, n)
			}
		}
	}

}

package main

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

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

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

	for  t := in() ; t > 0; t-- {
		n := in()

		if n < 31 {
			fmt.Println("No")
		} else if n == 31 {
			fmt.Println("Yes")
			fmt.Println(6, 10, 14, 1)
		} else if n == 36 {
			fmt.Println("Yes")
			fmt.Println(6, 10, 14, 5)
		} else if n == 44 {
			fmt.Println("Yes")
			fmt.Println(6, 10, 15, 13)
		} else {
			fmt.Println("Yes")
			fmt.Println(6, 10, 14, n - (10 + 6 + 14))		}
	}
}

package main

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

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

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

	for  t := in() ; t > 0; t-- {
		n := in()

		if n < 31 {
			fmt.Println("No")
		} else if n == 31 {
			fmt.Println("Yes")
			fmt.Println(6, 10, 14, 1)
		} else if n == 36 {
			fmt.Println("Yes")
			fmt.Println(6, 10, 15, 5)
		} else if n == 44 {
			fmt.Println("Yes")
			fmt.Println(6, 10, 15, 13)
		} else {
			fmt.Println("Yes")
			fmt.Println(6, 10, 14, n - (10 + 6 + 14))		}
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		if n < 31 {
			fmt.Println("No")
			continue
		}
		fmt.Println("Yes")
		last := n - 30
		fmt.Printf("6 10 14 %d\n", last)
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Scan(&n)
		if n < 31 {
			fmt.Println("NO")
			continue
		}
		fmt.Println("YES")
		last := n - 30
		fmt.Printf("6 10 14 %d\n", last)
	}
}

package main

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

func main() {

	var input io.Reader = bufio.NewReader(os.Stdin)

	var n, t int

	fmt.Fscan(input, &t)

	for i := 0; i < t; i++ {
		fmt.Fscan(input, &n)

		if n < 31 {
			fmt.Println("NO")
		}
		if n == 36 {
			fmt.Println("YES")
			fmt.Printf("%d %d %d %d\n", 6, 10, 15, 5)
		}
		if n == 40 {
			fmt.Println("YES")
			fmt.Printf("%d %d %d %d\n", 6, 10, 15, 9)
		}
		if n == 44 {
			fmt.Println("YES")
			fmt.Printf("%d %d %d %d\n", 6, 10, 15, 13)
		} else {
			fmt.Println("YES")
			fmt.Printf("%d %d %d %d\n", 6, 10, 14, n-30)
		}
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n, a int
	fmt.Fscan(os.Stdin, &n)
	for i := 1; i <= n; i++ {
		fmt.Fscan(os.Stdin, &a)
		if a <= 30 {
			fmt.Print("NO", "\n")
		} else {
			fmt.Print("YES", "\n", "6 10 14 ", a-12)
		}
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n, a int
	fmt.Fscan(os.Stdin, &n)
	for i := 1; i <= n; i++ {
		fmt.Fscan(os.Stdin, &a)
		if a <= 30 {
			fmt.Print("NO", "\n")
		} else {
			fmt.Print("YES", "\n", "6 10 14 ", a-30, "\n")
		}
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n, a int
	fmt.Fscan(os.Stdin, &n)
	for i := 1; i <= n; i++ {
		fmt.Fscan(os.Stdin, &a)
		if a <= 30 {
			fmt.Print("NO", "\n")
		} else
		if a == 31 {
			fmt.Print("YES", "\n", "6 10 14 ", a-30, "\n")
		}else {
			fmt.Print("YES", "\n", "6 10 15 ", a-31, "\n")
		}
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n, a int
	fmt.Fscan(os.Stdin, &n)
	for i := 1; i <= n; i++ {
		fmt.Fscan(os.Stdin, &a)
		if a <= 30 {
			fmt.Print("NO", "\n")
		} else {
			fmt.Print("YES", "\n", "6 10 14 ", a-30)
		}
	}
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n, a int
	fmt.Fscan(os.Stdin, &n)
	for i := 1; i <= n; i++ {
		fmt.Fscan(os.Stdin, &a)
		if a <= 31 {
			fmt.Print("NO", "\n")
		} else {
			fmt.Print("YES", "\n", "6 10 15 ", a-31, "\n")
		}
	}
}

package main

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

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

	T:= 0
	for Fscan(in, &T); T > 0; T-- {
		var n int
		Fscan(in, &n)

		if(n<=30){
			Fprintln(out,"NO")
			continue
		}

		if(n!=36&&n!=40&&n!=44){
			Fprintln(out,"YES")
			Fprintln(out,6,10,14,n-30)
			continue
		}
		Fprintln(out,"GC")
		Fprintln(out,6,10,15,n-31)
	}
}

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

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 i := 0; i < t; i++ {

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

		if n < 31 {
			fmt.Fprintln(out, "NO")
		} else {
			fmt.Fprintln(out, "YES")
			fmt.Fprintln(out, 6, 10, 14, n-30)
		}
	}

}

package main

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

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

	for t := io.nextInt(); t > 0; t-- {
		n := io.nextInt()
		if n > 6+10+14 {
			io.println("YES")
			io.printlnInts(6, 10, 14, n-6-10-14)
		} else {
			io.println("NO")
		}
	}
}

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 f.p[0] <= ' ' {
		f.Read(f.p[:])
	}
	neg := false
	if f.p[0] == '-' {
		neg = true
		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[:])
	}
	if neg {
		return -n
	}
	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()
}


For he knew every Who down in Whoville beneath, Was busy now, hanging a mistletoe wreath. "And they're hanging their stockings!" he snarled with a sneer, "Tomorrow is Christmas! It's practically here!"Dr. Suess, How The Grinch Stole ChristmasChristmas celebrations are coming to Whoville. Cindy Lou Who and her parents Lou Lou Who and Betty Lou Who decided to give sweets to all people in their street. They decided to give the residents of each house on the street, one kilogram of sweets. So they need as many kilos of sweets as there are homes on their street.The street, where the Lou Who family lives can be represented as n consecutive sections of equal length. You can go from any section to a neighbouring one in one unit of time. Each of the sections is one of three types: an empty piece of land, a house or a shop. Cindy Lou and her family can buy sweets in a shop, but no more than one kilogram of sweets in one shop (the vendors care about the residents of Whoville not to overeat on sweets).After the Lou Who family leave their home, they will be on the first section of the road. To get to this section of the road, they also require one unit of time. We can assume that Cindy and her mom and dad can carry an unlimited number of kilograms of sweets. Every time they are on a house section, they can give a kilogram of sweets to the inhabitants of the house, or they can simply move to another section. If the family have already given sweets to the residents of a house, they can't do it again. Similarly, if they are on the shop section, they can either buy a kilo of sweets in it or skip this shop. If they've bought a kilo of sweets in a shop, the seller of the shop remembered them and the won't sell them a single candy if they come again. The time to buy and give sweets can be neglected. The Lou Whos do not want the people of any house to remain without food.The Lou Whos want to spend no more than t time units of time to give out sweets, as they really want to have enough time to prepare for the Christmas celebration. In order to have time to give all the sweets, they may have to initially bring additional k kilos of sweets.Cindy Lou wants to know the minimum number of k kilos of sweets they need to take with them, to have time to give sweets to the residents of each house in their street.Your task is to write a program that will determine the minimum possible value of k.

The first line of the input contains two space-separated integers n and t (2 ≤ n ≤ 5·105, 1 ≤ t ≤ 109). The second line of the input contains n characters, the i-th of them equals "H" (if the i-th segment contains a house), "S" (if the i-th segment contains a shop) or "." (if the i-th segment doesn't contain a house or a shop).  It is guaranteed that there is at least one segment with a house.

If there isn't a single value of k that makes it possible to give sweets to everybody in at most t units of time, print in a single line "-1" (without the quotes). Otherwise, print on a single line the minimum possible value of k.

NoteIn the first example, there are as many stores, as houses. If the family do not take a single kilo of sweets from home, in order to treat the inhabitants of the first house, they will need to make at least one step back, and they have absolutely no time for it. If they take one kilogram of sweets, they won't need to go back.In the second example, the number of shops is equal to the number of houses and plenty of time. Available at all stores passing out candy in one direction and give them when passing in the opposite direction.In the third example, the shops on the street are fewer than houses. The Lou Whos have to take the missing number of kilograms of sweets with them from home.

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t || lpos+1>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	// printf("l=%d r=%d\n", cnth, cnts)

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var single int64 = 0
		var h,s int64
		var justEndIt int64 = 1e9
		var bad int64 = 1e9

		var tt int64 = candies

		var theEnd int64 = lpos

		for i,char := range st {
			if tt<t {
				theEnd = max(theEnd, int64(i))
			}
			if(char == 'S') {
				tt++
			}
		}

		for i,char := range st {

			if(bad < 1e9) {
				justEndIt = min(justEndIt, 2*theEnd - int64(i) + time + single + int64(1) - bad)
			}

			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					bad = min(bad, int64(i))
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h!=0) {
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					bad = 1e9
					time += 2*twice - int64(2)
					if(int64(i)>lpos) {
						time -= twice - int64(2)
					}
					twice = 0
					h = 0
					s = 0
				}
			}
			if(int64(i)<=lpos || h !=0) {
				single++
			}
			if(int64(i)>lpos && h == 0) {
				break
			}
		}
		time += single

		time = min(time, justEndIt)

		// printf("mid=%d oscore=%d single=%d time=%d theEnd=%d\n", (l+r)/2, justEndIt, single,time+single, theEnd)

		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t || lpos+1>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	// printf("l=%d r=%d\n", l, r)

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var single int64 = 0
		var h,s int64

		for i,char := range st {
			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h!=0) {
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					time += 2*twice - int64(2)
					if(int64(i)>lpos) {
						time -= twice - int64(2)
					}
					twice = 0
					h = 0
					s = 0
				}
			}
			if(int64(i)>lpos && h == 0) {
				break
			}
			if(int64(i)<=lpos) {
				single++
			}
		}
		// printf("%d %d %d\n", (l+r)/2, time, single)
		time += single
		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	// printf("l=%d r=%d\n", l, r)

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var h,s int64

		var changed bool = false

		for i,char := range st {
			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					changed = true
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					changed = true
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h!=0) {
					changed = true
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					time += 2*twice
					twice = 0
					h = 0
					s = 0
				}
			}
			if(int64(i)>lpos && h == 0) {
				break
			}
			if(!changed) {
				time++
				changed = false
			}
		}
		// printf("%d %d\n", (l+r)/2, time)
		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t || lpos+1>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	// printf("l=%d r=%d\n", cnth, cnts)

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var single int64 = 0
		var h,s int64

		for i,char := range st {
			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h!=0) {
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					time += 2*twice - int64(2)
					if(int64(i)>lpos) {
						time -= twice - int64(2)
					}
					twice = 0
					h = 0
					s = 0
				}
			}
			if(int64(i)<=lpos || h !=0) {
				single++
			}
			if(int64(i)>lpos && h == 0) {
				break
			}
		}
		// printf("%d %d %d %d\n", (l+r)/2, time, single,time+single)
		time += single
		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	// printf("l=%d r=%d\n", l, r)

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var h,s int64

		for i,char := range st {
			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h!=0) {
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					time += 2*twice
					twice = 0
					h = 0
					s = 0
				}
			}
			if(int64(i)>lpos && h == 0) {
				break
			}
			time++
		}
		// printf("%d %d\n", (l+r)/2, time)
		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var h,s int64

		for i,char := range st {
			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h==0) {
					time++
				} else {
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					time += 2*twice
					twice = 0
					h = 0
					s = 0
				}
			}
			if(int64(i)>lpos && h == 0) {
				break
			}
		}
		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t || lpos+1>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	// printf("l=%d r=%d\n", cnth, cnts)

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var single int64 = 0
		var h,s int64

		for i,char := range st {
			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h!=0) {
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					time += 2*twice - int64(2)
					if(int64(i)>lpos) {
						time -= twice - int64(1)
					}
					twice = 0
					h = 0
					s = 0
				}
			}
			single++
			if(int64(i)>lpos && h == 0) {
				break
			}
		}
		// printf("%d %d %d %d\n", (l+r)/2, time, single,time+single)
		time += single
		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t || lpos+1>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	// printf("l=%d r=%d\n", l, r)

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var h,s int64

		for i,char := range st {
			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h!=0) {
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					if(int64(i)>lpos) {
						time -= twice
					}
					time += 2*twice
					twice = 0
					h = 0
					s = 0
				}
			}
			if(int64(i)>lpos && h == 0) {
				break
			}
			time++
		}
		// printf("%d %d\n", (l+r)/2, time)
		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t || lpos+1>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	// printf("l=%d r=%d\n", l, r)

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var h,s int64

		for i,char := range st {
			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h!=0) {
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					time += twice
					twice = 0
					h = 0
					s = 0
				}
			}
			if(int64(i)>lpos && h == 0) {
				break
			}
			time++
		}
		// printf("%d %d\n", (l+r)/2, time)
		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t || lpos+1>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	// printf("l=%d r=%d\n", l, r)

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var single int64 = 0
		var h,s int64

		for i,char := range st {
			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h!=0) {
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					time += 2*twice - int64(1)
					if(int64(i)>lpos) {
						time -= twice
					}
					twice = 0
					h = 0
					s = 0
				}
			}
			if(int64(i)>lpos && h == 0) {
				break
			}
			single++
		}
		// printf("%d %d %d\n", (l+r)/2, time, single)
		time += single
		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}

package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()
	var n,t int64

	scanf("%d %d\n", &n, &t)

	var st string

	scanf("%s\n", &st)

	var cnth, cnts, lpos int64

	for index,char := range st {
		if(char == 'H') {
			cnth++
			lpos = int64(index)
		} else if(char == 'S') {
			cnts++
		}
	}
	if(cnth>t || lpos+1>t) {
		printf("-1\n")
		return
	}
	var l,r int64
	if(cnth>cnts) {
		l = cnth-cnts
	}
	r = cnth

	// printf("l=%d r=%d\n", l, r)

	for l < r {
		var candies = (l+r) / 2
		var time int64 = 0
		var twice int64 = 0
		var single int64 = 0
		var h,s int64

		for i,char := range st {
			if(char == 'H') {
				if(candies>0) {
					candies--
				} else {
					twice++
					h++
				}
			} else if(char == 'S') {
				if(h!=0) {
					twice++
					s++
				} else {
					candies++
				}
			} else {
				if(h!=0) {
					twice++
				}
			}
			if(h!=0) {
				if(h == s) {
					time += 2*twice - int64(1)
					if(int64(i)>lpos) {
						time -= twice - int64(1)
					}
					twice = 0
					h = 0
					s = 0
				}
			}
			if(int64(i)>lpos && h == 0) {
				break
			}
			if(int64(i)<lpos) {
				single++
			}
		}
		// printf("%d %d %d\n", (l+r)/2, time, single)
		time += single
		if(time<=t) {
			r=(l+r)/2
		} else {
			l=(l+r)/2+1
		}
	}
	printf("%d\n", l)
}


Harry Water, Ronaldo, Her-my-oh-knee and their friends have started a new school year at their MDCS School of Speechcraft and Misery. At the time, they are very happy to have seen each other after a long time. The sun is shining, birds are singing, flowers are blooming, and their Potions class teacher, professor Snipe is sulky as usual. Due to his angst fueled by disappointment in his own life, he has given them a lot of homework in Potions class. Each of the n students has been assigned a single task. Some students do certain tasks faster than others. Thus, they want to redistribute the tasks so that each student still does exactly one task, and that all tasks are finished. Each student has their own laziness level, and each task has its own difficulty level. Professor Snipe is trying hard to improve their work ethics, so each student’s laziness level is equal to their task’s difficulty level. Both sets of values are given by the sequence a, where ai represents both the laziness level of the i-th student and the difficulty of his task. The time a student needs to finish a task is equal to the product of their laziness level and the task’s difficulty. They are wondering, what is the minimum possible total time they must spend to finish all tasks if they distribute them in the optimal way. Each person should receive one task and each task should be given to one person. Print the answer modulo 10 007.

The first line of input contains integer n (1 ≤ n ≤ 100 000) — the number of tasks. The next n lines contain exactly one integer number ai (1 ≤ ai ≤ 100 000) — both the difficulty of the initial task and the laziness of the i-th students.

Print the minimum total time to finish all tasks modulo 10 007.

NoteIn the first sample, if the students switch their tasks, they will be able to finish them in 3 + 3 = 6 time units.

package main

import "fmt"
import "bufio"
import "os"
import "sort"

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

	var n int
	fmt.Fscanf(bufin, "%d\n", &n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(bufin, "%d\n", &a[i])
	}

	sort.Ints(a)
	mod := 10007

	res := 0
	for i := 0; i < n; i++ {
		x := a[i] % mod
		y := a[n-1-i] % mod
		res += (x * y) % mod
		res %= mod
	}

	fmt.Fprintf(bufout, "%d\n", res)
}

// Codeforces 717 C Potions Homework
// int - 32 bit type !!!!
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"strconv"
    "sort"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
    var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
    for i:=0; i<len(ss); i++ {
        a[i], err = strconv.Atoi(ss[i])
        if err != nil {
            fmt.Println("n atoi failure", err)
            panic(err)
        }
    }
    return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
    a := make([]int, n)
    s, err := in.ReadString('\n')
    if err != nil {
        fmt.Println("read failure", err)
        panic(err)
    }
    ss := strings.Split(strings.Trim(s, " \n\r"), " ")
    for j:=0; j<n; j++ {
        aa,err := strconv.Atoi(ss[j])
        if err != nil {
            fmt.Println("aa conv failed", err)
            panic(err)
        }
        a[j] = aa
    }
    return a
}

var n int
var sum int64
var a []int

func readData() {
 	in = bufio.NewReader(os.Stdin)
	// reading n
    n,_,_,_,_ = readFive()
    a = make([]int, n)
    for i:=0; i<n; i++ {
        a[i],_,_,_,_ = readFive()
    }
    sort.Ints(a)
}

func solve() {
    sum = 0

    for i:=0; i<n; i++ {
        sum += int64(a[i]) * int64(a[n-i-1])
    }
    sum = sum % 10007
}

func printRes() {
    fmt.Println(sum)
}

func main() {
 	readData()
    solve()
    printRes()
}

// Codeforces 717 C Potions Homework
// int - 32 bit type !!!!
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"strconv"
    "sort"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
    var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
    for i:=0; i<len(ss); i++ {
        a[i], err = strconv.Atoi(ss[i])
        if err != nil {
            fmt.Println("n atoi failure", err)
            panic(err)
        }
    }
    return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
    a := make([]int, n)
    s, err := in.ReadString('\n')
    if err != nil {
        fmt.Println("read failure", err)
        panic(err)
    }
    ss := strings.Split(strings.Trim(s, " \n\r"), " ")
    for j:=0; j<n; j++ {
        aa,err := strconv.Atoi(ss[j])
        if err != nil {
            fmt.Println("aa conv failed", err)
            panic(err)
        }
        a[j] = aa
    }
    return a
}

var n int
var sum int64
var a []int

func readData() {
 	in = bufio.NewReader(os.Stdin)
	// reading n
    n,_,_,_,_ = readFive()
    a = make([]int, n)
    for i:=0; i<n; i++ {
        a[i],_,_,_,_ = readFive()
    }
    sort.Ints(a)
}

func solve() {
    sum = 0

    for i:=0; i<n; i++ {
        sum += int64(a[i]) * int64(a[n-i-1])
    }
}

func printRes() {
    fmt.Println(sum)
}

func main() {
 	readData()
    solve()
    printRes()
}

// Codeforces 717 C Potions Homework
// int - 32 bit type !!!!
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"strconv"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
    var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
    for i:=0; i<len(ss); i++ {
        a[i], err = strconv.Atoi(ss[i])
        if err != nil {
            fmt.Println("n atoi failure", err)
            panic(err)
        }
    }
    return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
    a := make([]int, n)
    s, err := in.ReadString('\n')
    if err != nil {
        fmt.Println("read failure", err)
        panic(err)
    }
    ss := strings.Split(strings.Trim(s, " \n\r"), " ")
    for j:=0; j<n; j++ {
        aa,err := strconv.Atoi(ss[j])
        if err != nil {
            fmt.Println("aa conv failed", err)
            panic(err)
        }
        a[j] = aa
    }
    return a
}

var n int
var sum int64
var a []int64

func readData() {
 	in = bufio.NewReader(os.Stdin)
	// reading n
    n,_,_,_,_ = readFive()
    a = make([]int64, n)
    for i:=0; i<n; i++ {
        var aa int
        aa,_,_,_,_ = readFive()
        a[i] = int64(aa)
    }
}

func solve() {
    sum = 0

    for i:=0; i<n; i++ {
        sum += a[i] * a[n-i-1]
    }
}

func printRes() {
    fmt.Println(sum)
}

func main() {
 	readData()
    solve()
    printRes()
}


City X consists of n vertical and n horizontal infinite roads, forming n × n intersections. Roads (both vertical and horizontal) are numbered from 1 to n, and the intersections are indicated by the numbers of the roads that form them.Sand roads have long been recognized out of date, so the decision was made to asphalt them. To do this, a team of workers was hired and a schedule of work was made, according to which the intersections should be asphalted.Road repairs are planned for n2 days. On the i-th day of the team arrives at the i-th intersection in the list and if none of the two roads that form the intersection were already asphalted they asphalt both roads. Otherwise, the team leaves the intersection, without doing anything with the roads.According to the schedule of road works tell in which days at least one road will be asphalted.

The first line contains integer n (1 ≤ n ≤ 50) — the number of vertical and horizontal roads in the city.  Next n2 lines contain the order of intersections in the schedule. The i-th of them contains two numbers hi, vi (1 ≤ hi, vi ≤ n), separated by a space, and meaning that the intersection that goes i-th in the timetable is at the intersection of the hi-th horizontal and vi-th vertical roads. It is guaranteed that all the intersections in the timetable are distinct.

In the single line print the numbers of the days when road works will be in progress in ascending order. The days are numbered starting from 1.

NoteIn the sample the brigade acts like that:  On the first day the brigade comes to the intersection of the 1-st horizontal and the 1-st vertical road. As none of them has been asphalted, the workers asphalt the 1-st vertical and the 1-st horizontal road;  On the second day the brigade of the workers comes to the intersection of the 1-st horizontal and the 2-nd vertical road. The 2-nd vertical road hasn't been asphalted, but as the 1-st horizontal road has been asphalted on the first day, the workers leave and do not asphalt anything;  On the third day the brigade of the workers come to the intersection of the 2-nd horizontal and the 1-st vertical road. The 2-nd horizontal road hasn't been asphalted but as the 1-st vertical road has been asphalted on the first day, the workers leave and do not asphalt anything;  On the fourth day the brigade come to the intersection formed by the intersection of the 2-nd horizontal and 2-nd vertical road. As none of them has been asphalted, the workers asphalt the 2-nd vertical and the 2-nd horizontal road.

package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	h, v := make([]bool, n), make([]bool, n)
	a, b := 0, 0

	for i := 0; i < n*n; i++ {
		a, b = nextInt(), nextInt()

		if !h[a-1] && !v[b-1] {
			h[a-1] = true
			v[b-1] = true
			print(i+1, " ")
		}

	}

	println()
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import "fmt"

func main() {
	var n, h, v int
	fmt.Scan(&n)

	var visit [2][]bool
	var day []int
	visit[0], visit[1] = make([]bool, n+1), make([]bool, n+1)

	for i := 1; i <= n*n; i++ {
		fmt.Scan(&h, &v)
		if !visit[0][h] && !visit[1][v] {
			day = append(day, i)
			visit[0][h] = true
			visit[1][v] = true
		}
	}

	for i := 0; i < len(day); i++ {
		if i != 0 {
			fmt.Print(" ")
		}

		fmt.Print(day[i])
	}
}

package main

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

type pair [2]uint64

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

	line, _ := reader.ReadString('\n')
	line = strings.TrimSpace(line)
	size, _ := strconv.ParseUint(line, 10, 64)

	roadsV := make([]bool, size)
	roadsH := make([]bool, size)

	shedule := make([]pair, size*size)

	for i := uint64(0); i < size*size; i++ {
		line, _ = reader.ReadString('\n')
		line = strings.TrimSpace(line)
		for n, item := range strings.Split(line, " ") {
			shedule[i][n], _ = strconv.ParseUint(item, 10, 64)
		}
	}

	var goodDay []uint64
	for day, item := range shedule {
		if roadsV[item[0]-1] == false && roadsH[item[1]-1] == false {
			roadsV[item[0]-1] = true
			roadsH[item[1]-1] = true
			goodDay = append(goodDay, uint64(day)+1)
		}
	}

	for _, day := range goodDay {
		fmt.Print(day, " ")
	}
}

package main

import "fmt"

func main() {
	var n, h, v int
	fmt.Scan(&n)

	var visit [2][]bool
	var day []int
	visit[0], visit[1] = make([]bool, n+1), make([]bool, n+1)

	for i := 0; i < n*n; i++ {
		fmt.Scan(&h, &v)
		if !visit[0][h] && !visit[1][v] {
			day = append(day, n*(h-1)+v)
			visit[0][h] = true
			visit[1][v] = true
		}
	}

	for i := 0; i < len(day); i++ {
		if i != 0 {
			fmt.Print(" ")
		}

		fmt.Print(day[i])
	}
}