package main

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

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

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

func main() {
	defer out.Flush()
	var n, k int
	Fscan(in, &n, &k)
	a := make([]int, n)
	cnt := [100]int{}
	for i := 0; i < n; i++ {
		Fscan(in, &a[i])
		a[i] %= k
		cnt[a[i]]++
	}
	var ans = 0
	for i := 0; i < k; i++ {
		var mn int
		if (k-i)%k == i {
			mn = cnt[i] / 2
		} else {
			mn = min(cnt[i], cnt[k-i])
			cnt[i] -= mn
			cnt[k-i] -= mn
		}
		ans += mn
	}
	Fprint(out, ans*2)

}

package main

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

type Prob struct {
    in *bufio.Reader
}

func (prob *Prob) NextLine() string {
    line, _, _ := prob.in.ReadLine()
    return string(line[:])
}

func (prob *Prob) NextByte() byte {
    bt, _ := prob.in.ReadByte()
    return bt
}

func (prob *Prob) Next() string {
    var buff bytes.Buffer
    bt := prob.NextByte()
    for bt == '\n' || bt == ' ' {
        bt = prob.NextByte()
    }
    for bt != '\n' && bt != ' ' {
        buff.WriteByte(bt)
        bt = prob.NextByte()
    }
    return buff.String()
}

func (prob *Prob) NextInt() int {
    var x int
    bt := prob.NextByte()
    for bt > '9' || bt < '0' {
        if bt == '-' {
            return -prob.NextInt()
        }
        bt = prob.NextByte()
    }
    for bt >= '0' && bt <= '9' {
        x = x * 10 + int(bt - '0')
        bt = prob.NextByte()
    }
    return x
}

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

func (prob Prob) Solve() {
    n := prob.NextInt()
    m := prob.NextInt()
    var cnt [200000] int
    for i := 0; i < n; i++ {
        cnt[prob.NextInt() % m]++
    }
    res := 0
    for i := 0; i < m; i++ {
        j := (m - i) % m
        if i == j {
            res += cnt[i] / 2 * 2
        } else if i < j {
            res += Min(cnt[i], cnt[j]) * 2
        }
    }
    fmt.Printf("%d\n", res)
}

func main() {
    Prob{in: bufio.NewReader(os.Stdin)}.Solve()
}

package main

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

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...) }

func getLine() string {
	s, _ := reader.ReadString('\n')
	for len(s) > 0 && (s[len(s)-1] == '\n' || s[len(s)-1] == '\r') {
		s = s[:len(s)-1]
	}
	return s
}

func main() {
	var n, k int
	scanf("%d %d\n", &n, &k)
	counts := make([]int, k)
	for i := 0; i < n; i++ {
		var x int
		scanf("%d", &x)
		counts[x%k]++
	}
	result := 0
	for i := 1; i*2 < k; i++ {
		if counts[i] < counts[k-i] {
			result += counts[i]
		} else {
			result += counts[k-i]
		}
	}
	if k%2 == 0 {
		result += counts[k/2] / 2
	}
	result = result*2 + counts[0]/2*2
	fmt.Println(result)
}

/*
URL:
https://codeforces.com/problemset/problem/1133/B
*/

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, k int
	D    []int

	R [100 + 5]int
)

func main() {
	n, k = ReadInt2()
	D = ReadIntSlice(n)

	for i := 0; i < n; i++ {
		r := D[i] % k
		R[r]++
	}
	PrintfDebug("R: %v\n", R[:k])

	ans := 0
	for i := 0; i <= k/2; i++ {
		if i != k-i && i != 0 {
			ans += 2 * Min(R[i], R[k-i])
		} else {
			ans += R[i] - (R[i] % 2)
		}
	}
	fmt.Println(ans)
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

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

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

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

	var n, k int
	var v int = 0
	fmt.Fscanf(buf, "%d %d\n", &n, &k)

	mat := make([]int, k)

	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &v)
		mat[v%k]++
	}
	fmt.Fscanf(buf, "\n")
	//fmt.Printf("%v\n",mat)
	ans := mat[0] / 2
	for i := 1; i <= k/2; i++ {
		if mat[i] > 0 && mat[k-i] > 0 {
			if i == k-i {
				ans += mat[i] / 2
			} else {
				if mat[i] < mat[k-i] {
					ans += mat[i]
				} else {
					ans += mat[k-i]
				}
			}
		}
	}
	fmt.Printf("%d\n", ans*2)

}

package main

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

type Prob struct {
    in *bufio.Reader
}

func (prob *Prob) NextLine() string {
    line, _, _ := prob.in.ReadLine()
    return string(line[:])
}

func (prob *Prob) NextByte() byte {
    bt, _ := prob.in.ReadByte()
    return bt
}

func (prob *Prob) Next() string {
    var buff bytes.Buffer
    bt := prob.NextByte()
    for bt == '\n' || bt == ' ' {
        bt = prob.NextByte()
    }
    for bt != '\n' && bt != ' ' {
        buff.WriteByte(bt)
        bt = prob.NextByte()
    }
    return buff.String()
}

func (prob *Prob) NextInt() int {
    var x int
    bt := prob.NextByte()
    for bt > '9' || bt < '0' {
        if bt == '-' {
            return -prob.NextInt()
        }
        bt = prob.NextByte()
    }
    for bt >= '0' && bt <= '9' {
        x = x * 10 + int(bt - '0')
        bt = prob.NextByte()
    }
    return x
}

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

func (prob Prob) Solve() {
    n := prob.NextInt()
    m := prob.NextInt()
    var cnt [200000] int
    for i := 0; i < n; i++ {
        cnt[prob.NextInt() % m]++
    }
    res := 0
    for i := 0; i < m; i++ {
        j := (m - i) % m
        if i == j {
            res += cnt[i] / 2 * 2
        } else if i < j {
            res += Min(cnt[i], cnt[j])
        }
    }
    fmt.Printf("%d\n", res)
}

func main() {
    Prob{in: bufio.NewReader(os.Stdin)}.Solve()
}

package main

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

type Prob struct {
    in *bufio.Reader
}

func (prob *Prob) NextLine() string {
    line, _, _ := prob.in.ReadLine()
    return string(line[:])
}

func (prob *Prob) NextByte() byte {
    bt, _ := prob.in.ReadByte()
    return bt
}

func (prob *Prob) Next() string {
    var buff bytes.Buffer
    bt := prob.NextByte()
    for bt == '\n' || bt == ' ' {
        bt = prob.NextByte()
    }
    for bt != '\n' && bt != ' ' {
        buff.WriteByte(bt)
        bt = prob.NextByte()
    }
    return buff.String()
}

func (prob *Prob) NextInt() int {
    var x int
    bt := prob.NextByte()
    for bt > '9' || bt < '0' {
        if bt == '-' {
            return -prob.NextInt()
        }
        bt = prob.NextByte()
    }
    for bt >= '0' && bt <= '9' {
        x = x * 10 + int(bt - '0')
        bt = prob.NextByte()
    }
    return x
}

func (prob Prob) Solve() {
    n := prob.NextInt()
    m := prob.NextInt()
    var cnt [200000] int
    for i := 0; i < n; i++ {
        cnt[prob.NextInt() % m]++
    }
    res := 0
    for i := 0; i < m; i++ {
        res += cnt[i] / 2 * 2
    }
    fmt.Printf("%d\n", res)
}

func main() {
    Prob{in: bufio.NewReader(os.Stdin)}.Solve()
}

package main

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

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

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

func main() {
	defer out.Flush()
	var n, k int
	Fscan(in, &n, &k)
	a := make([]int, n)
	cnt := [100]int{}
	for i := 0; i < n; i++ {
		Fscan(in, &a[i])
		a[i] %= k
		cnt[a[i]]++
	}
	var ans = 0
	for i := 0; i < k; i++ {
		var mn int
		if (k-i)%k == i {
			mn = cnt[i] / 2
		} else {
			mn = min(cnt[i], cnt[k-i])
			cnt[i] -= mn
			cnt[k-i] -= mn
		}
		Fprintln(out, mn)
		ans += mn
	}
	Fprint(out, ans*2)

}


package main

import (
	"fmt"
)

func Max(vars ...int64) int64 {
	r := vars[0]
	for _, v := range vars {
		if v > r {
			r = v
		}
	}
	return r
}

func Min(vars ...int64) int64 {
	r := vars[0]
	for _, v := range vars {
		if v < r {
			r = v
		}
	}
	return r
}

var T int64
var S []byte
var N int64

func cal(R []byte) int64 {
	mp, mp0 := make(map[byte]int64), make(map[byte]int64)
	for i := int64(0); i < N; i++ {
		a := R[i]
		if _, ok := mp[a]; !ok {
			mp[a] = i
		}
		mp0[a] = i
	}

	var res int64
	for i := int64(0); i < N; i++ {
		a := S[i]
		for b, v := range mp {
			if b == a {
				continue
			}

			if v < mp[a] {
				res += mp0[b] - v + 1
			}
		}

		mp[a]++
	}
	return res
}

func dfs(cs []byte) [][]byte {
	if len(cs) == 1 {
		return [][]byte{cs}
	}

	res0 := dfs(cs[1:])
	res := [][]byte{}
	for _, vs := range res0 {
		lv := len(vs)
		for i := 0; i <= lv; i++ {
			cur := make([]byte, i)
			copy(cur, vs[:i])
			cur = append(cur, cs[0])
			cur = append(cur, vs[i:]...)
			res = append(res, cur)
		}
	}
	return res
}

func solve() string {
	mp := make(map[byte]int64)
	for i := int64(0); i < N; i++ {
		a := S[i]
		if _, ok := mp[a]; !ok {
			mp[a] = 0
		}
		mp[a]++
	}

	cs := []byte{}
	for k, _ := range mp {
		cs = append(cs, k)
	}

	css := dfs(cs)

	res, num := []byte{}, int64(-1)
	for _, cs := range css {
		r := []byte{}
		for _, c := range cs {
			for i := int64(0); i < mp[c]; i++ {
				r = append(r, c)
			}
		}

		n := cal(r)
		//fmt.Print64ln(string(r), n)
		if n > num {
			num = n
			res = r
		}
	}

	return string(res)
}

func main() {
	fmt.Scanf("%d\n", &T)

	for T > 0 {
		T--
		var s string
		fmt.Scanf("%s\n", &s)
		S = []byte(s)
		N = int64(len(S))
		fmt.Println(solve())
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	perm4 := [][]byte{
		{0, 1, 2, 3}, {0, 1, 3, 2}, {0, 2, 1, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}, {0, 3, 2, 1},
		{1, 0, 2, 3}, {1, 0, 3, 2}, {1, 2, 0, 3}, {1, 2, 3, 0}, {1, 3, 0, 2}, {1, 3, 2, 0},
		{2, 0, 1, 3}, {2, 0, 3, 1}, {2, 1, 0, 3}, {2, 1, 3, 0}, {2, 3, 0, 1}, {2, 3, 1, 0},
		{3, 0, 1, 2}, {3, 0, 2, 1}, {3, 1, 0, 2}, {3, 1, 2, 0}, {3, 2, 0, 1}, {3, 2, 1, 0},
	}
	const S = "ANOT"
	P := ['Z']byte{
		'A': 0,
		'N': 1,
		'O': 2,
		'T': 3,
	}
	solve := func(Case int) {
		var s []byte
		Fscan(in, &s)

		n := len(s)

		//pos := ['Z'][]int{}
		//for i, b := range s {
		//	pos[b] = append(pos[b], i)
		//}
		cnt := [4]int{}
		for i := range S {
			cnt[i] = bytes.Count(s, []byte{S[i]})
		}
		for i, b := range s {
			s[i] = P[b]
		}

		mxD := int64(-1)
		ans := []byte{}
		for _, p := range perm4 {
			d := int64(0)

			c := [4]int{}
			right := cnt
			for i, b := range s {
				k := 0
				tar := 0
				for ; p[k] != b; k++ {
					tar += cnt[p[k]]
					i += right[p[k]]
				}
				tar += c[b]
				right[b]--
				d += int64(i-tar)
			}

			if d > mxD {
				t := make([]byte, 0, n)
				for _, i := range p {
					t = append(t, bytes.Repeat([]byte{S[i]}, cnt[i])...)
				}
				mxD, ans = d, t
			}
		}
		Fprintf(out, "%s\n", ans)
	}

	T := 1
	Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

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

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

package main

import (
	"fmt"
)

func Max(vars ...int) int {
	r := vars[0]
	for _, v := range vars {
		if v > r {
			r = v
		}
	}
	return r
}

func Min(vars ...int) int {
	r := vars[0]
	for _, v := range vars {
		if v < r {
			r = v
		}
	}
	return r
}

var T int32
var S []byte
var N int

func cal(R []byte) int {
	mp, mp0 := make(map[byte]int), make(map[byte]int)
	for i := 0; i < N; i++ {
		a := R[i]
		if _, ok := mp[a]; !ok {
			mp[a] = i
		}
		mp0[a] = i
	}

	var res int
	for i := 0; i < N; i++ {
		a := S[i]
		for b, v := range mp {
			if b == a {
				continue
			}

			if v < mp[a] {
				res += mp0[b] - v + 1
			}
		}

		mp[a]++
	}
	return res
}

func dfs(cs []byte) [][]byte {
	if len(cs) == 1 {
		return [][]byte{cs}
	}

	res0 := dfs(cs[1:])
	res := [][]byte{}
	for _, vs := range res0 {
		lv := len(vs)
		for i := 0; i <= lv; i++ {
			cur := make([]byte, i)
			copy(cur, vs[:i])
			cur = append(cur, cs[0])
			cur = append(cur, vs[i:]...)
			res = append(res, cur)
		}
	}
	return res
}

func solve() string {
	mp := make(map[byte]int)
	for i := 0; i < N; i++ {
		a := S[i]
		if _, ok := mp[a]; !ok {
			mp[a] = 0
		}
		mp[a]++
	}

	cs := []byte{}
	for k, _ := range mp {
		cs = append(cs, k)
	}

	css := dfs(cs)

	res, num := []byte{}, -1
	for _, cs := range css {
		r := []byte{}
		for _, c := range cs {
			for i := 0; i < mp[c]; i++ {
				r = append(r, c)
			}
		}

		n := cal(r)
		//fmt.Println(string(r), n)
		if n > num {
			num = n
			res = r
		}
	}

	return string(res)
}

func main() {
	fmt.Scanf("%d\n", &T)

	for T > 0 {
		T--
		var s string
		fmt.Scanf("%s\n", &s)
		S = []byte(s)
		N = len(S)
		fmt.Println(solve())
	}
}

package main

import (
	"fmt"
)

func Max(vars ...int) int {
	r := vars[0]
	for _, v := range vars {
		if v > r {
			r = v
		}
	}
	return r
}

func Min(vars ...int) int {
	r := vars[0]
	for _, v := range vars {
		if v < r {
			r = v
		}
	}
	return r
}

var T int32
var S []byte
var N int

func cal(R []byte) int {
	mp := make(map[byte]int)
	for i := 0; i < N; i++ {
		a := R[i]
		if _, ok := mp[a]; !ok {
			mp[a] = i
		}
	}

	var res int
	for i := 0; i < N; i++ {
		a := S[i]
		mi := N
		for _, v := range mp {
			mi = Min(mi, v)
		}

		res += mp[a] - mi
		mp[a]++
	}
	return res
}

func dfs(cs []byte) [][]byte {
	if len(cs) == 1 {
		return [][]byte{cs}
	}

	res0 := dfs(cs[1:])
	res := [][]byte{}
	for _, vs := range res0 {
		lv := len(vs)
		for i := 0; i <= lv; i++ {
			cur := make([]byte, i)
			copy(cur, vs[:i])
			cur = append(cur, cs[0])
			cur = append(cur, vs[i:]...)
			res = append(res, cur)
		}
	}
	return res
}

func solve() string {
	mp := make(map[byte]int)
	for i := 0; i < N; i++ {
		a := S[i]
		if _, ok := mp[a]; !ok {
			mp[a] = 0
		}
		mp[a]++
	}

	cs := []byte{}
	for k, _ := range mp {
		cs = append(cs, k)
	}

	css := dfs(cs)

	res, num := []byte{}, -1
	for _, cs := range css {
		r := []byte{}
		for _, c := range cs {
			for i := 0; i < mp[c]; i++ {
				r = append(r, c)
			}
		}

		n := cal(r)
		// fmt.Println(r, n)
		if n > num {
			num = n
			res = r
		}
	}

	return string(res)
}

func main() {
	fmt.Scanf("%d\n", &T)

	for T > 0 {
		T--
		var s string
		fmt.Scanf("%s\n", &s)
		S = []byte(s)
		N = len(S)
		fmt.Println(solve())
	}
}

package main

import (
	"fmt"
	"math"
)

func Max(vars ...int) int {
	r := vars[0]
	for _, v := range vars {
		if v > r {
			r = v
		}
	}
	return r
}

func Min(vars ...int) int {
	r := vars[0]
	for _, v := range vars {
		if v < r {
			r = v
		}
	}
	return r
}

var T int32
var S []byte
var N int

func cal(R []byte) int {
	mp := make(map[byte]int)
	for i := 0; i < N; i++ {
		a := R[i]
		if _, ok := mp[a]; !ok {
			mp[a] = i
		}
	}

	var res int
	for i := 0; i < N; i++ {
		a := S[i]
		mi := N
		for _, v := range mp {
			mi = Min(mi, v)
		}

		res += mp[a] - mi
		mp[a]++
	}
	return res
}

func dfs(cs []byte) [][]byte {
	if len(cs) == 1 {
		return [][]byte{cs}
	}

	res0 := dfs(cs[1:])
	res := [][]byte{}
	for _, vs := range res0 {
		lv := len(vs)
		for i := 0; i <= lv; i++ {
			cur := make([]byte, i)
			copy(cur, vs[:i])
			cur = append(cur, cs[0])
			cur = append(cur, vs[i:]...)
			res = append(res, cur)
		}
	}
	return res
}

func solve() string {
	mp := make(map[byte]int)
	for i := 0; i < N; i++ {
		a := S[i]
		if _, ok := mp[a]; !ok {
			mp[a] = 0
		}
		mp[a]++
	}

	cs := []byte{}
	for k, _ := range mp {
		cs = append(cs, k)
	}

	css := dfs(cs)

	res, num := []byte{}, math.MaxInt
	for _, cs := range css {
		r := []byte{}
		for _, c := range cs {
			for i := 0; i < mp[c]; i++ {
				r = append(r, c)
			}
		}

		n := cal(r)
		if n < num {
			num = n
			res = r
		}
	}

	return string(res)
}

func main() {
	fmt.Scanf("%d\n", &T)

	for T > 0 {
		T--
		var s string
		fmt.Scanf("%s\n", &s)
		S = []byte(s)
		N = len(S)
		fmt.Println(solve())
	}
}

package main

import (
	"fmt"
	"sort"
)

var T int32
var S []byte

func solve() string {
	mp := make(map[byte][]int)
	ln := len(S)
	for i := 0; i < ln; i++ {
		a := S[i]
		if _, ok := mp[a]; !ok {
			mp[a] = []int{}

		}
		mp[a] = append(mp[a], i)
	}

	cs := []byte{}
	for k, _ := range mp {
		cs = append(cs, k)
	}

	sort.Slice(cs, func(i0, j0 int) bool {
		a, b := cs[i0], cs[j0]
		va, vb := mp[a], mp[b]
		la, lb := len(va), len(vb)
		i, j := 0, 0
		c := 0
		for j < lb {
			for i < la && va[i] < vb[j] {
				i++
			}
			c += la - i
			j++
		}

		d := 0
		i, j = 0, 0
		for i < la {
			for j < lb && vb[j] < va[i] {
				j++
			}
			c += lb - j
			i++
		}

		return c >= d
	})

	res := []byte{}
	for _, c := range cs {
		for i := 0; i < len(mp[c]); i++ {
			res = append(res, c)
		}
	}

	return string(res)
}

func main() {
	fmt.Scanf("%d\n", &T)

	for T > 0 {
		T--
		var s string
		fmt.Scanf("%s\n", &s)
		S = []byte(s)
		fmt.Println(solve())
	}
}

package main

import (
	"fmt"
)

type Node struct {
	next *Node
	pre  *Node
	val  byte
}

func newNode(val byte) *Node {
	node := new(Node)
	node.val = val
	return node
}

func (node *Node) append(nn *Node) {
	nn.next = node.next
	nn.pre = node
	node.next.pre = nn
	node.next = nn
}

var T int32
var S []byte

func solve() string {
	mp := make(map[byte]*Node)

	head, tail := newNode('-'), newNode('-')
	head.next = tail
	tail.pre = head
	ln := len(S)

	for i := 0; i < ln; i++ {
		a := S[i]
		if node, ok := mp[a]; !ok {
			mp[a] = newNode(a)
			head.append(mp[a])

		} else {
			nn := newNode(a)
			node.append(nn)
			mp[a] = nn
		}
	}

	res := []byte{}
	node := head.next
	for node.next != nil {
		res = append(res, node.val)
		node = node.next
	}

	return string(res)
}

func main() {
	fmt.Scanf("%d\n", &T)

	for T > 0 {
		T--
		var s string
		fmt.Scanf("%s\n", &s)
		S = []byte(s)
		fmt.Println(solve())
	}
}

package main

import (
	"fmt"
)

type Node struct {
	next *Node
	pre  *Node
	val  byte
}

func newNode(val byte) *Node {
	node := new(Node)
	node.val = val
	return node
}

func (node *Node) append(nn *Node) {
	nn.next = node.next
	nn.pre = node
	node.next.pre = nn
	node.next = nn
}

var T int32
var S []byte

func solve() string {
	mp := make(map[byte]*Node)

	head, tail := newNode('-'), newNode('-')
	head.next = tail
	tail.pre = head
	ln := len(S)

	for i := 0; i < ln; i++ {
		a := S[i]
		if node, ok := mp[a]; !ok {
			mp[a] = newNode(a)
			head.append(mp[a])

		} else {
			nn := newNode(a)
			node.append(nn)
			mp[a] = nn
		}
	}

	res := []byte{}
	node := head.next
	for node.next != nil {
		res = append(res, node.val)
		node = node.next
	}

	return string(res)
}

func main() {
	fmt.Scanf("%d", &T)

	for T > 0 {
		T--
		var s string
		fmt.Scanf("%s", &s)
		S = []byte(s)
		fmt.Println(solve())
	}
}


package main

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

var cs map[int]int = make(map[int]int)

func Init() {}
func Solve(io *FastIO) {
	n := io.NextInt()
	u := io.NextInt()
	a := io.NextIntArray(n)
	nu := float64(-1)
	var j int
	for i := 0; i < n-1; i++ {
		j = sort.Search(n, func(j int) bool { return a[j]-a[i] > u }) - 1
		if j > i+1 {
			nu = math.Max(nu, float64(a[j]-a[i+1])/float64(a[j]-a[i]))
		}
	}
	if nu < 0 {
		io.Println(-1)
	} else {
		io.Println(nu)
	}
}

type FastIO struct {
	//by megaspazz
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}
func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = res*10 + int(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = int64(-1)
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = res*10 + int64(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}
func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt() + 1
	}
	return arr
}
func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}
func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}
func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}
func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}
func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}
func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}
func IsLineBreakChar(c byte) bool {
	switch c {
	case 0, '\n', '\r':
		return true
	default:
		return false
	}
}
func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

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

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

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

type pair struct {
	first int
	second uint8
}

type ll []int64

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

var (
	n, U int
	a [100000]int
)

func main() {
	in := bufio.NewReader(os.Stdin)
	//in, _ := os.Open("a.txt")
	fmt.Fscanf(in, "%d %d\n", &n, &U)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	ans := -1.0
	for i := 0; i < n - 2; i++ {
		l := i + 2
		r := n - 1
		for r - l > 1 {
			mid := (l + r) / 2
			if a[mid] - a[i] <= U {
				l = mid
			} else {
				r = mid - 1
			}
		}
		if l > r {
			l , r = r, l
		}
		res := -1
		if a[l] - a[i] <= U {
			res = l
		}
		if a[r] - a[i] <= U {
			res = r
		}
		if res != -1 {
			ans = math.Max(ans, float64(a[res] - a[i + 1]) / float64(a[res] - a[i]))
		}
	}
	fmt.Printf("%.9f\n", ans)
}


package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

type User struct {
  Pos, Request, Rating int
}
type Users []*User
func (users Users) Len() int {
  return len(users)
}
func (users Users) Swap(i, j int) {
  users[i], users[j] = users[j], users[i]
}
func (users Users) Less(i, j int) bool {
  return users[i].Request < users[j].Request
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  users := make([]*User, n)
  for pos := range users {
    users[pos] = &User{ pos, getI(), 0 }
  }
  sort.Sort(Users(users))

  users[0].Rating = users[0].Request
  previous := users[0]
  for i := 1; i < n; i++ {
    user := users[i]
    if user.Request > previous.Rating {
      user.Rating = user.Request
    } else {
      user.Rating = previous.Rating + 1
    }
    previous = user
  }

  result := make([]int, n)
  for _, user := range users {
    result[user.Pos] = user.Rating
  }

  writer.WriteString(fmt.Sprintf("%d", result[0]))
  for i := 1; i < n; i++ {
    writer.WriteString(fmt.Sprintf(" %d", result[i]))
  }
  writer.WriteString("\n")
}

package main

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

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func main() {
	in.Split(bufio.ScanWords)
	n := readInt()
	a := make([]int, n)
	for i := range a {
		a[i] = readInt()
	}
	order := make([]int, n)
	for i := range order {
		order[i] = i
	}
	sort.Sort(inPlace{order, a})
	last := 0
	b := make([]int, n)
	for _, i := range order {
		last++
		if last < a[i] {
			last = a[i]
		}
		b[i] = last
	}
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	for i, x := range b {
		fmt.Fprint(out, x)
		if i+1 == n {
			fmt.Fprint(out, "\n")
		} else {
			fmt.Fprint(out, " ")
		}
	}
}

type inPlace struct {
	order, a []int
}

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

package main

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

type User struct {
    r,p int
}

type UserSlice []User

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    var n int
    fmt.Scan(&n)
    a := make(UserSlice,n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i].r, _ = strconv.Atoi(scanner.Text())
        a[i].p = i
    }
    sort.Sort(a)
    ans := make([]int,n)
    for i := 0; i < n; i++ {
        if i != 0 {
            if a[i].r <= a[i-1].r {
                a[i].r = a[i-1].r+1
            }
        }
        ans[a[i].p] = a[i].r
    }
    for i := 0; i < n; i++ {
        writer.WriteString(strconv.Itoa(ans[i]))
        if i == (n-1) { writer.WriteRune('\n') } else { writer.WriteRune(' ') }
    }
    writer.Flush()
}

package main

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

type Person struct {
	i, x int
}

type People []Person

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

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]Person, n)
	for i := 0; i < n; i++ {
		a[i].i = i
		fmt.Fscanf(reader, "%d", &a[i].x)
	}
	sort.Sort(People(a))

	b := make([]int, n)
	x := 0
	for i := range a {
		if a[i].x > x {
			x = a[i].x
		}
		b[a[i].i] = x
		x++
	}
	pretty := fmt.Sprint(b)
	pretty = pretty[1:len(pretty)-1]
	fmt.Fprintln(writer, pretty)
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	n, _ := reader.ReadString('\n')
	mins, _ := reader.ReadString('\n')
	out, err := process(strings.TrimSpace(n), strings.TrimSpace(mins))
	if err != nil {
		panic(err)
	}
	os.Stdout.Write([]byte(out))
}

type User struct {
	Min    int
	Rating int
}

type ByMin []*User

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

func process(in0 string, in1 string) (string, error) {
	n, err := strconv.Atoi(in0)
	if err != nil {
		return "", err
	}
	users := []*User{}
	for _, s := range strings.Split(in1, " ") {
		m, err := strconv.Atoi(s)
		if err != nil {
			return "", err
		}
		users = append(users, &User{Min: m})
	}

	orig := append([]*User{}, users...)
	ratings(n, users)
	s := []string{}
	for _, u := range orig {

		s = append(s, strconv.Itoa(u.Rating))
	}
	return strings.Join(s, " "), nil
}

func ratings(n int, users []*User) {
	sort.Stable(ByMin(users))
	last := -1
	for _, u := range users {

		if u.Min > last {
			last = u.Min
		} else {
			last++
		}
		u.Rating = last
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	n, _ := reader.ReadString('\n')
	mins, _ := reader.ReadString('\n')
	out, err := process(strings.TrimSpace(n), strings.TrimSpace(mins))
	if err != nil {
		panic(err)
	}
	os.Stdout.Write([]byte(out))
}

type User struct {
	Index  int
	Min    int
	Rating int
}

type ByIndex []User

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

type ByMin []User

func (a ByMin) Len() int      { return len(a) }
func (a ByMin) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByMin) Less(i, j int) bool {
	if a[i].Min == a[j].Min {
		return a[i].Index < a[j].Index
	}
	return a[i].Min < a[j].Min
}

func process(in0 string, in1 string) (string, error) {
	n, err := strconv.Atoi(in0)
	if err != nil {
		return "", err
	}
	users := []User{}
	for i, s := range strings.Split(in1, " ") {
		m, err := strconv.Atoi(s)
		if err != nil {
			return "", err
		}
		users = append(users, User{Index: i, Min: m})
	}

	ratings(n, users)
	s := []string{}
	for _, u := range users {

		s = append(s, strconv.Itoa(u.Rating))
	}
	return strings.Join(s, " "), nil
}

func ratings(n int, users []User) {
	sort.Sort(ByMin(users))
	last := -1
	for i, u := range users {

		if u.Min > last {
			last = u.Min
		} else {
			last++
		}
		users[i].Rating = last
	}

	sort.Sort(ByIndex(users))
}

package main

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

type User struct {
    r,p int
}

type UserSlice []User

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    writer := bufio.NewWriter(os.Stdout)
    var n int
    fmt.Scan(&n)
    a := make(UserSlice,n)
    for i := 0; i < n; i++ {
        scanner.Scan()
        a[i].r, _ = strconv.Atoi(scanner.Text())
        a[i].p = i
    }
    sort.Sort(a)
    ans := make([]int,n)
    for i := 0; i < n; i++ {
        if i != 0 {
            if a[i].r == a[i-1].r {
                a[i].r++
            }
        }
        ans[a[i].p] = a[i].r
    }
    for i := 0; i < n; i++ {
        writer.WriteString(strconv.Itoa(ans[i]))
        if i == (n-1) { writer.WriteRune('\n') } else { writer.WriteRune(' ') }
    }
    writer.Flush()
}