Polycarp is sad — New Year is coming in few days but there is still no snow in his city. To bring himself New Year mood, he decided to decorate his house with some garlands.The local store introduced a new service this year, called "Build your own garland". So you can buy some red, green and blue lamps, provide them and the store workers will solder a single garland of them. The resulting garland will have all the lamps you provided put in a line. Moreover, no pair of lamps of the same color will be adjacent to each other in this garland!For example, if you provide $$$3$$$ red, $$$3$$$ green and $$$3$$$ blue lamps, the resulting garland can look like this: "RGBRBGBGR" ("RGB" being the red, green and blue color, respectively). Note that it's ok to have lamps of the same color on the ends of the garland.However, if you provide, say, $$$1$$$ red, $$$10$$$ green and $$$2$$$ blue lamps then the store workers won't be able to build any garland of them. Any garland consisting of these lamps will have at least one pair of lamps of the same color adjacent to each other. Note that the store workers should use all the lamps you provided.So Polycarp has bought some sets of lamps and now he wants to know if the store workers can build a garland from each of them.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of sets of lamps Polycarp has bought. Each of the next $$$t$$$ lines contains three integers $$$r$$$, $$$g$$$ and $$$b$$$ ($$$1 \le r, g, b \le 10^9$$$) — the number of red, green and blue lamps in the set, respectively.

Print $$$t$$$ lines — for each set of lamps print "Yes" if the store workers can build a garland from them and "No" otherwise.

NoteThe first two sets are desribed in the statement.The third set produces garland "RBRG", for example.

package main

import (
	"fmt"
)

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

func maxx(a, b, c int64) int64 {
	if t := max(a, b); t >= c {
		return t
	}

	return c
}

func main() {
	var a, b, c, n int64
	fmt.Scan(&n)
	for i := int64(0); i < n; i++ {
		fmt.Scan(&a, &b, &c)
		t := a + b + c
		t2 := maxx(a, b, c)
		println(t, t2, t-t2-t2)
		if t2 <= t-t2 {
			fmt.Println("Yes")
		} else if t2+t2-t == int64(1) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

import (
	"fmt"
	"sort"
)

func newYear(t int) int {
	for t > 0 {
		n := 3
		a := make([]int, n)
		for j := 0; j < n; j++{
			fmt.Scan(&a[j])
		}
		sort.Sort(sort.IntSlice(a))
		if a[2] <= (a[0] + a[1] + 1) {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
		t--
	}
	return 0
}

func main() {
	var t int
	fmt.Scan(&t)
	newYear(t)
}

package main

import (
	"fmt"
	"sort"
)

func sol(r,g,b int)bool {
	arr:=[]int{r,g,b}
	sort.Ints(arr)
	if arr[0]+arr[1]+1>=arr[2]{
		return true
	}
	return false
}
func main(){
	t:=0
	fmt.Scanf("%d\n",&t)
	for ;t>0;t--{
		r,g,b:=0,0,0
		fmt.Scanf("%d %d %d\n",&r,&g,&b)
		ans:=sol(r,g,b)
		if ans{
			fmt.Println("Yes")
		} else{
			fmt.Println("No")
		}
	}
}

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		r, g, b := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &r, &g, &b)

		//if (r < 0 || g < 0 || b < 0) {
		//	fmt.Println("No")
		//}
		//
		//if (r == 1 && g == 0 && b == 0) {
		//	fmt.Println("Yes")
		//}
		//
		//if (r == 0 && g == 1 && b == 0) {
		//	fmt.Println("Yes")
		//}
		//if (r == 0 && g == 0 && b == 1) {
		//	fmt.Println("Yes")
		//}

		arr := []int{r, g, b}
		sort.Ints(arr)
		if arr[0]+arr[1] >= arr[2]-1 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

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

func countWays(p, q, r, last int64) int64 {

	if (p < 0 || q < 0 || r < 0) {
		return 0
	}

	if (p == 1 && q == 0 && r == 0 && last == 0) {
		return 1
	}

	if (p == 0 && q == 1 && r == 0 && last == 1) {
		return 1
	}
	if (p == 0 && q == 0 && r == 1 && last == 2) {
		return 1
	}
	if (last == 0) {
		return countWays(p-1, q, r, 1) + countWays(p-1, q, r, 2)
	}

	if (last == 1) {
		return countWays(p, q-1, r, 0) +
			countWays(p, q-1, r, 2)
	}
	if (last == 2) {
		return countWays(p, q, r-1, 0) + countWays(p, q, r-1, 1)
	}

	return 0
}

func countUtil(p, q, r int64) int64 {
	return countWays(p, q, r, 0) + countWays(p, q, r, 1) + countWays(p, q, r, 2)
}
*/

package main

import (
	. "fmt"
)

func main() {
	var n int
	Scan(&n)

	output := ""
	for i := 0; i < n; i++ {
		var r, g, b int
		Scan(&r, &g, &b)

		if b > g { b, g = g, b }
		if g > r { g, r = r, g }
		if b > g { b, g = g, b }

		if r - g - b <= 1 {
			output += "Yes\n"
		} else {
			output += "No\n"
		}
	}

	Println(output)
}

package main
import (
	"bufio"
	"fmt"
	"os"
	"strings"
)
func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	ans := make([]string, n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Fscan(r, &a, &b, &c)
		if a + b >= c - 1 && b + c >= a - 1 && c + a >= b - 1 {
			ans[i] = "YES"
		} else {
			ans[i] = "NO"
		}
	}
	fmt.Fprintln(w, strings.Join(ans, "\n"))
}

package main

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

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

package main

import (
	"fmt"
)

func maxx(a, b, c int64) int64 {
	if a >= b && a >= c {
		return a
	} else if b >= a && b >= c {
		return b
	}

	return c
}

func main() {
	var a, b, c, n int64
	fmt.Scan(&n)
	for i := int64(0); i < n; i++ {
		fmt.Scan(&a, &b, &c)
		t := a + b + c
		t2 := maxx(a, b, c)
		if t2 <= t-t2 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

import (
	"fmt"
)

func maxx(a, b, c int) int {
	if a >= b && a >= c {
		return a
	} else if b >= a && b >= c {
		return b
	}

	return c
}

func main() {
	var a, b, c, n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b, &c)
		t := a + b + c
		t2 := maxx(a, b, c)
		if t2 <= t-t2 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		r, g, b := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &r, &g, &b)

		if (r < 0 || g < 0 || b < 0) {
			fmt.Println("No")
		}

		if (r == 1 && g == 0 && b == 0) {
			fmt.Println("Yes")
		}

		if (r == 0 && g == 1 && b == 0) {
			fmt.Println("Yes")
		}
		if (r == 0 && g == 0 && b == 1) {
			fmt.Println("Yes")
		}

		arr := []int{r, g, b}
		sort.Ints(arr)

		if arr[0]+arr[1] >= arr[2] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		r, g, b := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &r, &g, &b)

		//if (r < 0 || g < 0 || b < 0) {
		//	fmt.Println("No")
		//}
		//
		//if (r == 1 && g == 0 && b == 0) {
		//	fmt.Println("Yes")
		//}
		//
		//if (r == 0 && g == 1 && b == 0) {
		//	fmt.Println("Yes")
		//}
		//if (r == 0 && g == 0 && b == 1) {
		//	fmt.Println("Yes")
		//}

		arr := []int{r, g, b}
		sort.Ints(arr)

		if arr[0]+arr[1] >= arr[2] {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

package main

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

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

	testCount := 0
	fmt.Fscanf(in, "%d\n", &testCount)

	for i := 0; i < testCount; i++ {
		r, g, b := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &r, &g, &b)

		//if (r < 0 || g < 0 || b < 0) {
		//	fmt.Println("No")
		//}
		//
		//if (r == 1 && g == 0 && b == 0) {
		//	fmt.Println("Yes")
		//}
		//
		//if (r == 0 && g == 1 && b == 0) {
		//	fmt.Println("Yes")
		//}
		//if (r == 0 && g == 0 && b == 1) {
		//	fmt.Println("Yes")
		//}

		arr := []int{r, g, b}
		sort.Ints(arr)
		fmt.Println(arr)
		if arr[0]+arr[1] >= arr[2]-1 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

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

func countWays(p, q, r, last int64) int64 {

	if (p < 0 || q < 0 || r < 0) {
		return 0
	}

	if (p == 1 && q == 0 && r == 0 && last == 0) {
		return 1
	}

	if (p == 0 && q == 1 && r == 0 && last == 1) {
		return 1
	}
	if (p == 0 && q == 0 && r == 1 && last == 2) {
		return 1
	}
	if (last == 0) {
		return countWays(p-1, q, r, 1) + countWays(p-1, q, r, 2)
	}

	if (last == 1) {
		return countWays(p, q-1, r, 0) +
			countWays(p, q-1, r, 2)
	}
	if (last == 2) {
		return countWays(p, q, r-1, 0) + countWays(p, q, r-1, 1)
	}

	return 0
}

func countUtil(p, q, r int64) int64 {
	return countWays(p, q, r, 0) + countWays(p, q, r, 1) + countWays(p, q, r, 2)
}
*/

package main

import (
	. "fmt"
)

func main() {
	var n int
	Scan(&n)

	output := ""
	for i := 0; i < n; i++ {
		var r, g, b int
		Scan(&r, &g, &b)

		if r + g < b || g + b < r || r + b < g {
			output += "No\n"
		} else {
			output += "Yes\n"
		}
	}

	Println(output)
}

package main
import (
	"bufio"
	"fmt"
	"os"
	"strings"
)
func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	ans := make([]string, n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Fscan(r, &a, &b, &c)
		if a + b >= c && b + c >= a && c + a >= b {
			ans[i] = "YES"
		} else {
			ans[i] = "NO"
		}
	}
	fmt.Fprintln(w, strings.Join(ans, "\n"))
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(0)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		a, b, c := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &a, &b, &c)
		if a+b >= c && a+c >= b && b+c >= a {
			fmt.Fprintf(out, "YES\n")
		} else {
			fmt.Fprintf(out, "NO\n")

		}
	}
	return
}


Mr. F has $$$n$$$ positive integers, $$$a_1, a_2, \ldots, a_n$$$.He thinks the greatest common divisor of these integers is too small. So he wants to enlarge it by removing some of the integers.But this problem is too simple for him, so he does not want to do it by himself. If you help him, he will give you some scores in reward.Your task is to calculate the minimum number of integers you need to remove so that the greatest common divisor of the remaining integers is bigger than that of all integers.

The first line contains an integer $$$n$$$ ($$$2 \leq n \leq 3 \cdot 10^5$$$) — the number of integers Mr. F has. The second line contains $$$n$$$ integers, $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 1.5 \cdot 10^7$$$).

Print an integer — the minimum number of integers you need to remove so that the greatest common divisor of the remaining integers is bigger than that of all integers. You should not remove all of the integers. If there is no solution, print «-1» (without quotes).

NoteIn the first example, the greatest common divisor is $$$1$$$ in the beginning. You can remove $$$1$$$ so that the greatest common divisor is enlarged to $$$2$$$. The answer is $$$1$$$.In the second example, the greatest common divisor is $$$3$$$ in the beginning. You can remove $$$6$$$ and $$$9$$$ so that the greatest common divisor is enlarged to $$$15$$$. There is no solution which removes only one integer. So the answer is $$$2$$$.In the third example, there is no solution to enlarge the greatest common divisor. So the answer is $$$-1$$$.

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1034A(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}
	calcGCD := func(a, b int) int {
		for b != 0 {
			a, b = b, a%b
		}
		return a
	}
	calcGCDN := func(nums []int) (gcd int) {
		gcd = nums[0]
		for _, v := range nums[1:] {
			gcd = calcGCD(gcd, v)
		}
		return
	}

	const mx int = 1.5e7
	lpf := [mx + 1]int{}
	lpf[1] = 1
	for i := 2; i <= mx; i++ {
		if lpf[i] == 0 {
			for j := i; j <= mx; j += i {
				if lpf[j] == 0 {
					lpf[j] = i
				}
			}
		}
	}

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

	cnt := [mx + 1]int{}
	g := calcGCDN(a)
	for i := range a {
		for v := a[i] / g; v > 1; {
			p := lpf[v]
			cnt[p]++
			for v /= p; lpf[v] == p; v /= p {
			}
		}
	}
	ans := 0
	for _, c := range cnt {
		if c > ans {
			ans = c
		}
	}
	if ans == 0 {
		Fprint(out, -1)
	} else {
		Fprint(out, n-ans)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1034A(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b-'0')
		}
		return
	}
	calcGCD := func(a, b int) int {
		for b != 0 {
			a, b = b, a%b
		}
		return a
	}
	calcGCDN := func(nums []int) (gcd int) {
		gcd = nums[0]
		for _, v := range nums[1:] {
			gcd = calcGCD(gcd, v)
		}
		return
	}

	const mx int = 1.5e7
	lpf := [mx + 1]int{}
	lpf[1] = 1
	for i := 2; i <= mx; i++ {
		if lpf[i] == 0 {
			for j := i; j <= mx; j += i {
				if lpf[j] == 0 {
					lpf[j] = i
				}
			}
		}
	}

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

	cnt := [mx + 1]int{}
	g := calcGCDN(a)
	for i := range a {
		for v := a[i] / g; v > 1; {
			p := lpf[v]
			cnt[p]++
			for v /= p; lpf[v] == p; v /= p {
			}
		}
	}
	ans := -1
	for _, c := range cnt {
		if c > ans {
			ans = c
		}
	}
	if ans != -1 {
		ans = n - ans
	}
	Fprint(out, ans)
}

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


Given an array $$$a$$$, consisting of $$$n$$$ integers, find:$$$$$$\max\limits_{1 \le i < j \le n} LCM(a_i,a_j),$$$$$$where $$$LCM(x, y)$$$ is the smallest positive integer that is divisible by both $$$x$$$ and $$$y$$$. For example, $$$LCM(6, 8) = 24$$$, $$$LCM(4, 12) = 12$$$, $$$LCM(2, 3) = 6$$$.

The first line contains an integer $$$n$$$ ($$$2 \le n \le 10^5$$$) — the number of elements in the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^5$$$) — the elements of the array $$$a$$$.

Print one integer, the maximum value of the least common multiple of two elements in the array $$$a$$$.

package main

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

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

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

func scanInt64() int64 {
	sc.Scan()
	a, _ := strconv.ParseInt(sc.Text(), 10, 64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 {
			fmt.Fprint(wr, " ")
		}
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

var (
	n      int
	maxVal int
	ans    int64
	sCnt   int
	a      []int
	b      []bool
	cnt    []int
	miu    []int
	fac    [][]int
	s      []int
)

func prepare() {
	for i := range a {
		b[a[i]] = true
	}
	miu[1] = 1
	for i := 1; i <= maxVal; i++ {
		fac[i] = append(fac[i], i)
		for j := i + i; j <= maxVal; j += i {
			miu[j] -= miu[i]
			fac[j] = append(fac[j], i)
		}
	}
}

func coPrimeCnt(x int) int {
	ret := 0
	for i := range fac[x] {
		ret += miu[fac[x][i]] * cnt[fac[x][i]]
	}
	return ret
}

func update(x int, v int) {
	for i := range fac[x] {
		cnt[fac[x][i]] += v
	}
}

func gcd(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func main() {
	sc.Split(bufio.ScanWords)
	n = scanInt()
	a = scanInts(n)
	for i := range a {
		if int64(a[i]) > ans {
			ans = int64(a[i])
			maxVal = a[i]
		}
	}
	b = make([]bool, maxVal+1)
	cnt = make([]int, maxVal+1)
	miu = make([]int, maxVal+1)
	fac = make([][]int, maxVal+1)
	s = make([]int, n+1)
	prepare()
	for g := 1; g <= maxVal; g++ {
		sCnt = 0
		for i := maxVal / g; i >= 1; i-- {
			if !b[g*i] {
				continue
			}
			num := coPrimeCnt(i)
			for num > 0 {
				if gcd(i, s[sCnt]) == 1 {
					if int64(i)*int64(s[sCnt])*int64(g) > ans {
						ans = int64(i) * int64(s[sCnt]) * int64(g)
					}
					num--
				}
				update(s[sCnt], -1)
				sCnt--
			}
			update(i, 1)
			sCnt++
			s[sCnt] = i
		}
		for sCnt > 0 {
			update(s[sCnt], -1)
			sCnt--
		}
	}
	fmt.Println(ans)
}


Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs to be updated.There are n video cards in the shop, the power of the i-th video card is equal to integer value ai. As Vlad wants to be sure the new game will work he wants to buy not one, but several video cards and unite their powers using the cutting-edge technology. To use this technology one of the cards is chosen as the leading one and other video cards are attached to it as secondary. For this new technology to work it's required that the power of each of the secondary video cards is divisible by the power of the leading video card. In order to achieve that the power of any secondary video card can be reduced to any integer value less or equal than the current power. However, the power of the leading video card should remain unchanged, i.e. it can't be reduced.Vlad has an infinite amount of money so he can buy any set of video cards. Help him determine which video cards he should buy such that after picking the leading video card and may be reducing some powers of others to make them work together he will get the maximum total value of video power.

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of video cards in the shop. The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 200 000) — powers of video cards.

The only line of the output should contain one integer value — the maximum possible total power of video cards working together.

NoteIn the first sample, it would be optimal to buy video cards with powers 3, 15 and 9. The video card with power 3 should be chosen as the leading one and all other video cards will be compatible with it. Thus, the total power would be 3 + 15 + 9 = 27. If he buys all the video cards and pick the one with the power 2 as the leading, the powers of all other video cards should be reduced by 1, thus the total power would be 2 + 2 + 14 + 8 = 26, that is less than 27. Please note, that it's not allowed to reduce the power of the leading video card, i.e. one can't get the total power 3 + 1 + 15 + 9 = 28.In the second sample, the optimal answer is to buy all video cards and pick the one with the power 2 as the leading. The video card with the power 7 needs it power to be reduced down to 6. The total power would be 8 + 2 + 2 + 6 = 18.

package main

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

func solve() {
    n := readInt()
    a, mx := readInt64Array(n), int64(200009)

    c := make([]int64, 2*mx)
    for _, v := range a {
        c[v]++
    }
    for i := range c {
        if i > 0 {
            c[i] += c[i-1]
        }
    }

    mem := make([]int64, mx)
    for x := int64(1); x < mx; x++ {
        for k := int64(2); k*x < 2*mx; k++ {
            mem[x] += (c[k*x-1] - c[(k-1)*x-1]) * (k-1)*x
        }
    }

    ans := int64(0)
    for _, x := range a {
        if mem[x] > ans {
            ans = mem[x]
        }
    }
    fmt.Println(ans)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

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

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

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)
	m := 0

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

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

	dp := make([]int, m+1)
	for x := 1; x <= m; x++ {
		dp[x] = dp[x-1] + cnt[x]
	}

	res := int64(0)
	for x := 1; x <= m; x++ {
		if cnt[x] > 0 {
			sum := int64(0)
			for y := x; y <= m; y += x {
				if y+x-1 < m {
					sum += int64(y) * int64(dp[y+x-1]-dp[y-1])
				} else {
					sum += int64(y) * int64(dp[m]-dp[y-1])
				}
			}
			if res < sum {
				res = sum
			}
		}
	}

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

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

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

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

	cnt := make([]int, 200001)
	m := 0

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

	dp := make([]int, m+1)
	for x := 1; x <= m; x++ {
		dp[x] = dp[x-1] + cnt[x]
	}

	res := int64(0)
	for x := 1; x <= m; x++ {
		if cnt[x] > 0 {
			sum := int64(0)
			for y := x; y <= m; y += x {
				if y+x-1 < m {
					sum += int64(y) * int64(dp[y+x-1]-dp[y-1])
				} else {
					sum += int64(y) * int64(dp[m]-dp[y-1])
				}
			}
			if res < sum {
				res = sum
			}
		}
	}

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

// http://codeforces.com/contest/731/problem/F
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

const (
	MOD = 1e9 + 7
)

type (

)

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

	return b
}

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

	return b
}

func main () {
	var (
		n int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)

	fmt.Fscanln(input, &n)
	cnt := make([]int, 200001)
	sum := make([]int, 200001)

	maxa := 0
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Fscan(input, &tmp)
		cnt[tmp]++
		if maxa < tmp {
			maxa = tmp
		}
	}

	// Solve
	for i := 1; i <= maxa; i++ {
		sum[i] = sum[i - 1] + cnt[i]
	}

	maxs := int64(0)
	for i := 1; i <= maxa; i++ {
		if cnt[i] > 0 {

			total := int64(0)

			for j := i; j <= maxa; j += i {
				total += (int64(sum[min(maxa, j + i - 1)] - sum[j - 1]) * int64(j))
			}

			maxs = max(maxs, total)
		}
	}

	fmt.Println(maxs)

	/*
	// Primitive solution
	sort.Ints(a)
	maxs := int64(0)

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

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

		maxs = max(sum, maxs)
	}

	fmt.Println(maxs)*/
}

package main

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

func solve() {
    n := readInt()
    a, mx := readInt64Array(n), int64(200009)

    c := make([]int64, 2*mx)
    for _, v := range a {
        c[v]++
    }
    for i := range c {
        if i > 0 {
            c[i] += c[i-1]
        }
    }

    mem := make([]int64, mx)
    for x := int64(1); x < mx; x++ {
        for k := int64(2); k*x < mx; k++ {
            mem[x] += (c[k*x-1] - c[(k-1)*x-1]) * (k-1)*x
        }
    }

    ans := int64(0)
    for _, x := range a {
        if mem[x] > ans {
            ans = mem[x]
        }
    }
    fmt.Println(ans)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

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

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/

package main

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

func solve() {
    n := readInt()
    a, mx := readInt64Array(n), int64(400009)

    c := make([]int64, mx)
    for _, v := range a {
        c[int(v)]++
    }
    for i := range c {
        if i > 0 {
            c[i] += c[i-1]
        }
    }

    ans := int64(0)
    for _, x := range a {
        cur := int64(0)
        for k := int64(2); k*x < mx; k++ {
            cur += c[k*x-1] - c[(k-1)*x-1] * (k-1)*x
        }
        if cur > ans {
            ans = cur
        }
    }
    fmt.Println(ans)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

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

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/


Lee was cleaning his house for the party when he found a messy string under the carpets. Now he'd like to make it clean accurately and in a stylish way...The string $$$s$$$ he found is a binary string of length $$$n$$$ (i. e. string consists only of 0-s and 1-s).In one move he can choose two consecutive characters $$$s_i$$$ and $$$s_{i+1}$$$, and if $$$s_i$$$ is 1 and $$$s_{i + 1}$$$ is 0, he can erase exactly one of them (he can choose which one to erase but he can't erase both characters simultaneously). The string shrinks after erasing.Lee can make an arbitrary number of moves (possibly zero) and he'd like to make the string $$$s$$$ as clean as possible. He thinks for two different strings $$$x$$$ and $$$y$$$, the shorter string is cleaner, and if they are the same length, then the lexicographically smaller string is cleaner.Now you should answer $$$t$$$ test cases: for the $$$i$$$-th test case, print the cleanest possible string that Lee can get by doing some number of moves.Small reminder: if we have two strings $$$x$$$ and $$$y$$$ of the same length then $$$x$$$ is lexicographically smaller than $$$y$$$ if there is a position $$$i$$$ such that $$$x_1 = y_1$$$, $$$x_2 = y_2$$$,..., $$$x_{i - 1} = y_{i - 1}$$$ and $$$x_i < y_i$$$.

The first line contains the integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.  Next $$$2t$$$ lines contain test cases — one per two lines. The first line of each test case contains the integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the length of the string $$$s$$$. The second line contains the binary string $$$s$$$. The string $$$s$$$ is a string of length $$$n$$$ which consists only of zeroes and ones. It's guaranteed that sum of $$$n$$$ over test cases doesn't exceed $$$10^5$$$.

Print $$$t$$$ answers — one per test case. The answer to the $$$i$$$-th test case is the cleanest string Lee can get after doing some number of moves (possibly zero).

NoteIn the first test case, Lee can't perform any moves.In the second test case, Lee should erase $$$s_2$$$.In the third test case, Lee can make moves, for example, in the following order: 11001101 $$$\rightarrow$$$ 1100101 $$$\rightarrow$$$ 110101 $$$\rightarrow$$$ 10101 $$$\rightarrow$$$ 1101 $$$\rightarrow$$$ 101 $$$\rightarrow$$$ 01.

package main

import (
  . "fmt"
)

var t int
func main() {
  Scan(&t)
  for tc := 0; tc < t; tc++ {
  	var n int
  	var bs []byte
    Scan(&n)
    Scan(&bs)
    bef := make([]byte, 0)
    aft := make([]byte, 0)
    i := 0
    for ;i < n; i++ {
        if bs[i] == '0' {
            bef = append(bef, 0)
        } else {
            break
        }
    }
    j := n-1
    for ;i <= j; j-- {
        if bs[j] == '1' {
            aft = append(aft, 1)
        } else {
            break
        }
    }
    if i <= j {
        bef = append(bef, 0)
    }
    for k := range bef {
        Print(bef[k])
    }
    for k := range aft {
        Print(aft[k])
    }
    Println()

  }
}

package main

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

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

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		s, _ := reader.ReadBytes('\n')
		fmt.Println(solve(n, s))
	}
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, s []byte) string {
	var i int

	for i < n && s[i] == '0' {
		i++
	}
	if i == n {
		return string(s[:i])
	}
	// s[i] == '1'
	var j = n - 1
	for j >= 0 && s[j] == '1' {
		j--
	}
	// s[j] == '0'
	if j < i {
		return string(s[:n])
	}

	for j < n {
		s[i] = s[j]
		i++
		j++
	}
	return string(s[:i])
}

package main

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

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

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

	var t, n int
	var s string

	t = input()

	for ; t > 0; t-- {
		n = input()

		scanner.Scan()
		s = scanner.Text()

		len := 0
		prev := -1
		count := 0
		for i := n - 1; i >= 0; i-- {
			if s[i] == '0' {
				count++
				prev = 0
			} else {
				if prev == -1 {
					len++
				} else if prev == 0 {
					count = 1
				}
			}
		}

		for i := 0; i < count; i++ {
			fmt.Print("0")
		}

		for i := 0; i < len; i++ {
			fmt.Print("1")
		}
		fmt.Print("\n")
	}

}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		ns := readLine(reader)
		str := readLine(reader)
		n, _ := strconv.ParseInt(string(ns), 10, 64)

		if str[0] == '0' {
			zero1 := int64(0)
			for i := int64(1); i < n; i++ {
				if str[i] != '0' {
					break
				}
				zero1 = i
			}
			lastone := n
			for i:=n-1;i>zero1;i-- {
				if str[i] == '0' {
					break
				}
				lastone = i
			}
			if zero1 == n-1 {
				fmt.Println(string(str))
			} else if lastone == n {
				fmt.Println(string(str[:zero1+1])+"0")
			} else if zero1 == lastone - 1{
				fmt.Println(string(str[:zero1+1])+string(str[lastone:]))
			} else {
				fmt.Println(string(str[:zero1+1])+"0"+string(str[lastone:]))
			}
		} else {
			tailone := n
			for i:=n-1;i>=0;i-- {
				if str[i] == '0' {
					break
				}
				tailone = i
			}
			if tailone == 0 {
				fmt.Println(string(str))
			} else if tailone == n {
				fmt.Println("0")
			} else {
				fmt.Println("0"+string(str[tailone:]))
			}
		}
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			break
		}
	}
	return result
}

/*
URL:
https://codeforces.com/contest/1369/problem/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 (
	t int

	n int
	S []rune
)

func main() {
	t = ReadInt()

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

		solve()
	}
}

func solve() {
	// 一種類だけの場合を除去
	comp, _ := RunLengthEncoding(S)
	if len(comp) == 1 {
		fmt.Println(string(S))
		return
	}

	var l1, r0 int
	for i := 0; i < n; i++ {
		if S[i] == '1' {
			l1 = i
			break
		}
	}
	for i := n - 1; i >= 0; i-- {
		if S[i] == '0' {
			r0 = i
			break
		}
	}

	if r0 < l1 {
		fmt.Println(string(S))
		return
	}

	// PrintfDebug("jikken: %v\n", string(S[:0]))

	ans := []rune{}
	if l1 >= 0 {
		ans = append(ans, S[:l1]...)
	}
	ans = append(ans, '0')
	if r0+1 < n {
		ans = append(ans, S[r0+1:]...)
	}
	fmt.Println(string(ans))
}

// RunLengthEncoding returns encoded slice of an input.
func RunLengthEncoding(S []rune) ([]rune, []int) {
	runes := []rune{}
	lengths := []int{}

	l := 0
	for i := 0; i < len(S); i++ {
		// 1文字目の場合保持
		if i == 0 {
			l = 1
			continue
		}

		if S[i-1] == S[i] {
			// 直前の文字と一致していればインクリメント
			l++
		} else {
			// 不一致のタイミングで追加し、長さをリセットする
			runes = append(runes, S[i-1])
			lengths = append(lengths, l)
			l = 1
		}
	}
	runes = append(runes, S[len(S)-1])
	lengths = append(lengths, l)

	return runes, lengths
}

// RunLengthDecoding decodes RLE results.
func RunLengthDecoding(S []rune, L []int) []rune {
	if len(S) != len(L) {
		panic("S, L are not RunLengthEncoding results")
	}

	res := []rune{}

	for i := 0; i < len(S); i++ {
		for j := 0; j < L[i]; j++ {
			res = append(res, S[i])
		}
	}

	return res
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

var nTest, n int
var s string

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

	fmt.Fscan(in, &nTest)
	for t := 0; t < nTest; t++ {
		fmt.Fscan(in, &n, &s)
		first1ID := -1
		last0ID := -1

		for i := 0; i < n; i++ {
			if s[i] == '1' && first1ID == -1 {
				first1ID = i
			}

			if s[i] == '0' {
				last0ID = i
			}
		}

		if last0ID == -1 {
			for i := 0; i < n; i++ {
				fmt.Fprint(out, 1)
			}
		} else if first1ID == -1 {
			for i := 0; i < n; i++ {
				fmt.Fprint(out, 0)
			}
		} else {
			for i := 0; i < first1ID; i++ {
				fmt.Fprint(out, 0)
			}
			if first1ID < last0ID {
				fmt.Fprint(out, 0)
			}
			for i := n - 1; i > last0ID; i-- {
				fmt.Fprint(out, 1)
			}
		}

		fmt.Fprintln(out)
	}

	out.Flush()
}

package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var T int
	con.Scan(&T)
	for testcase := 0; testcase < T; testcase++ {
		var n int
		var s string
		con.Scan(&n, &s)
		ok := true
		for ok {
			ok = false
			for i := len(s) - 1; i >= 0; i-- {
				if s[i] == '0' {
					j := i - 1
					for j >= 0 && s[j] == '0' {
						j--
					}
					if j >= 0 {
						s = s[:j] + s[i:]
						ok = true
					}
					break
				}
			}
		}
		con.Println(s)
	}
	return nil
}

package main

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

var nTest, n int
var s string

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

	fmt.Fscan(in, &nTest)
	for t := 0; t < nTest; t++ {
		fmt.Fscan(in, &n, &s)
		first1ID := -1
		last0ID := -1

		for i := 0; i < n; i++ {
			if s[i] == '1' && first1ID == -1 {
				first1ID = i
			}

			if s[i] == '0' {
				last0ID = i
			}
		}

		for i := 0; i < first1ID; i++ {
			fmt.Fprint(out, 0)
		}

		if first1ID != -1 && last0ID != -1 && first1ID < last0ID {
			fmt.Fprint(out, 0)
		}

		if last0ID != -1 {
			for i := n - 1; i > last0ID; i-- {
				fmt.Fprint(out, 1)
			}
		} else {
			for i := 0; i < n; i++ {
				fmt.Fprint(out, 1)
			}
		}

		fmt.Fprintln(out)
	}

	out.Flush()
}


Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exactly k of the nodes should be exit-nodes, that means that each of them should be connected to exactly one other node of the network, while all other nodes should be connected to at least two nodes in order to increase the system stability.Arkady wants to make the system as fast as possible, so he wants to minimize the maximum distance between two exit-nodes. The distance between two nodes is the number of wires a package needs to go through between those two nodes.Help Arkady to find such a way to build the network that the distance between the two most distant exit-nodes is as small as possible.

The first line contains two integers n and k (3 ≤ n ≤ 2·105, 2 ≤ k ≤ n - 1) — the total number of nodes and the number of exit-nodes. Note that it is always possible to build at least one network with n nodes and k exit-nodes within the given constraints.

In the first line print the minimum possible distance between the two most distant exit-nodes. In each of the next n - 1 lines print two integers: the ids of the nodes connected by a wire. The description of each wire should be printed exactly once. You can print wires and wires' ends in arbitrary order. The nodes should be numbered from 1 to n. Exit-nodes can have any ids. If there are multiple answers, print any of them.

NoteIn the first example the only network is shown on the left picture.In the second example one of optimal networks is shown on the right picture.Exit-nodes are highlighted.

package main

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

// github.com/EndlessCheng/codeforces-go
func CF827B(in io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}

	var n, k int
	Fscan(bufio.NewReader(in), &n, &k)
	l, r := (n-1)/k, (n-1)%k
	Fprintln(out, 2*l+min(r, 2))
	c := k + 2
	for i := 1; i <= k; i++ {
		ll := l
		if i > r {
			ll--
		}
		Fprintln(out, k+1, i)
		if ll > 0 {
			Fprintln(out, i, c)
			c++
		}
		for j := 1; j < ll; j++ {
			Fprintln(out, c-1, c)
			c++
		}
	}
}

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

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	K := io.NextInt()

	what := make([]int, K)
	for i := 0; i < K; i++ {
	  what[i] = 1
	}

	sz := 0
	var sb bytes.Buffer
	for i := 2; i <= N; i++ {
	  idx := (i - 2) % K
	  if idx <= 1 {
	    sz++
	  }
	  sb.WriteString(fmt.Sprintf("%d %d\n", what[idx], i))
	  what[idx] = i
	}
	io.Println(sz)
	io.Println(sb.String())
}

type FastIO struct {
	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 sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

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()
	}
	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 (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF827B(in io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}

	var n, k int
	Fscan(bufio.NewReader(in), &n, &k)
	l, r := (n-1)/k, (n-1)%k
	Fprintln(out, 2*l+min(r, 2))
	c := k + 2
	for i := 1; i <= k; i++ {
		for j := 0; j < l-1; j++ {
			Fprintln(out, k+1, c+j)
			c++
		}
		Fprintln(out, c-1, i)
	}
	for i := 1; i <= r; i++ {
		Fprintln(out, i, c)
		c++
	}
}

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


Vasya has recently found out what a digital root of a number is and he decided to share his knowledge with you.Let's assume that S(n) is the sum of digits of number n, for example, S(4098) = 4 + 0 + 9 + 8 = 21. Then the digital root of number n equals to:   dr(n) = S(n), if S(n) < 10;  dr(n) = dr( S(n) ), if S(n) ≥ 10. For example, dr(4098)  =  dr(21)  =  3.Vasya is afraid of large numbers, so the numbers he works with are at most 101000. For all such numbers, he has proved that dr(n)  =  S( S( S( S(n) ) ) ) (n ≤ 101000).Now Vasya wants to quickly find numbers with the given digital root. The problem is, he hasn't learned how to do that and he asked you to help him. You task is, given numbers k and d, find the number consisting of exactly k digits (the leading zeroes are not allowed), with digital root equal to d, or else state that such number does not exist.

The first line contains two integers k and d (1 ≤ k ≤ 1000; 0 ≤ d ≤ 9).

In a single line print either any number that meets the requirements (without the leading zeroes) or "No solution" (without the quotes), if the corresponding number does not exist. The chosen number must consist of exactly k digits. We assume that number 0 doesn't contain any leading zeroes.

NoteFor the first test sample dr(5881)  =  dr(22)  =  4.For the second test sample dr(36172)  =  dr(19)  =  dr(10)  =  1.

package main
import (
	"fmt"
	//"sort"
	//"unicode/utf8"
)
func main() {
	var n,m int
	fmt.Scan(&n,&m)
	if m==0 {
		if n==1 {
			fmt.Println("0")
		} else {
			fmt.Println("No solution")
		}
	} else {
		fmt.Print(m)
		n--
		for ; n!=0;n-- {
			fmt.Print("0")
		}
	}
}

package main

import "fmt"

func main() {
    var k,d int
    fmt.Scan(&k,&d)
    if (d == 0) && (k != 1) {
        fmt.Println("No solution")
    } else {
        fmt.Print(d)
        for i := 1; i < k; i++ { fmt.Print(0) }
        fmt.Println()
    }
}

// hey project main.go
package main

import (
    "fmt"
)

func main() {
    var x, y int
    fmt.Scan(&x, &y)

    if y == 0 && x > 1 {
        fmt.Printf("No solution\n")
        return
    }
    fmt.Print(y)
    if y != 0 {
        for i := 0; i < x-1; i++ {
            fmt.Printf("0")
        }
    }
}

// 355A-mic
package main

import (
    "fmt"
)

func main() {
    var k, l int
    fmt.Scan(&k, &l)
    if k == 0 || (k > 1 && l == 0) {
        fmt.Println("No solution")
    } else {
        fmt.Print(l)
        for i := 1; i < k; i++ {
            fmt.Print("0")
        }
        fmt.Println()
    }
}

// Steve Phillips / elimisteve
// 2013.10.13

package main

import (
	"fmt"
	"strconv"
)

const (
	NO_SOLUTION = "No solution"
)

func main() {
	// for _, num := range []int64{4098, 5881, 36172, 0} {
	// 	fmt.Printf("digitalRoot(%6d) == %d\n", num, digitalRoot(num))
	// }

	// `The first line contains two integers k and d
	// (1 ≤ k ≤ 1000; 0 ≤ d ≤ 9)`
	var k, d int64

	// `...find the number consisting of exactly k digits (the leading
	// zeroes are not allowed), with digital root equal to d, or else
	// state that such number does not exist.`

	// So, find num s.t. len(num) == k, and digitalRoot(num) == d
	fmt.Scanf("%d %d", &k, &d)

	//
	// Handle "small" corner cases
	//

	// 1, _ -> _
	if k == 1 {
		fmt.Printf("%d\n", d)
		return
	}
	// KNOWN: 1 < k

	if k > 1 && d == 0 {
		fmt.Println(NO_SOLUTION)
		return
	}

	// If number of digits (k) > their sum (d), => 1s followed by 0s
	if k >= d {
		fmt.Printf("%s%s\n", ones(d), zeroes(k-d))
		return
	}
	// KNOWN: k < d

	// => KNOWN: 1 < k < d

	fmt.Printf("%s%v\n", ones(k-1), (d%10 - (k-1)) % 10)
}

func parseInt(s string) int64 {
	num, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}

func digitalRoot(num int64) int64 {
	// total := sumDigits(num)
	// if total < 10 {
	// 	return total
	// }
	return sumDigits(sumDigits(sumDigits(sumDigits(num))))
}

// func digitalRoot(num int64) int64 {
// 	total := sumDigits(num)
// 	if total < 10 {
// 		return total
// 	}
// 	return sumDigits(total)
// }

func sumDigits(num int64) int64 {
	var total int64
	str := strconv.FormatInt(num, 10)
	for i, _ := range str {
		total += parseInt(str[i:i+1])
	}
	return total
}

func ones(n int64) string {
	return repeat("1", n)
}

func zeroes(n int64) string {
	return repeat("0", n)
}

func repeat(s string, times int64) string {
	str := ""
	for i := int64(0); i < times; i++ {
		str += s
	}
	return str
}

package main
import (
	"fmt"
	//"sort"
	//"unicode/utf8"
)
func main() {
	var n,m int
	fmt.Scan(&n,&m)
	if m==0 {
		if n==1 {
			fmt.Println("0")
		} else {
			fmt.Println("No Solution")
		}
	} else {
		fmt.Print(m)
		n--
		for ; n!=0;n-- {
			fmt.Print("0")
		}
	}
}

package main

import "fmt"

func main() {
    var k,d int
    fmt.Scan(&k,&d)
    if (d == 0) && (k != 1) {
        d = 55
        k--
    }
    fmt.Print(d)
    for i := 1; i < k; i++ { fmt.Print(0) }
    fmt.Println()
}

// hey project main.go
package main

import (
    "fmt"
)

func main() {
    var x, y int
    fmt.Scan(&x, &y)
    fmt.Print(y)
    if y == 0 && x > 1 {
        fmt.Printf("No solution\n")
        return
    }
    if y != 0 {
        for i := 0; i < x-1; i++ {
            fmt.Printf("0")
        }
    }
}

// hey project main.go
package main

import (
    "fmt"
)

func main() {
    var x, y int
    fmt.Scan(&x, &y)
    fmt.Print(y)
    if y != 0 {
        for i := 0; i < x-1; i++ {
            fmt.Printf("0")
        }
    }
}

// hey project main.go
package main

import (
    "fmt"
)

func main() {
    var x, y int
    fmt.Scan(&x, &y)
    fmt.Print(y)
    for i := 0; i < x-1; i++ {
        fmt.Printf("0")
    }
}


Boboniu likes playing chess with his employees. As we know, no employee can beat the boss in the chess game, so Boboniu has never lost in any round.You are a new applicant for his company. Boboniu will test you with the following chess question:Consider a $$$n\times m$$$ grid (rows are numbered from $$$1$$$ to $$$n$$$, and columns are numbered from $$$1$$$ to $$$m$$$). You have a chess piece, and it stands at some cell $$$(S_x,S_y)$$$ which is not on the border (i.e. $$$2 \le S_x \le n-1$$$ and $$$2 \le S_y \le m-1$$$).From the cell $$$(x,y)$$$, you can move your chess piece to $$$(x,y')$$$ ($$$1\le y'\le m, y' \neq y$$$) or $$$(x',y)$$$ ($$$1\le x'\le n, x'\neq x$$$). In other words, the chess piece moves as a rook. From the cell, you can move to any cell on the same row or column.Your goal is to visit each cell exactly once. Can you find a solution?Note that cells on the path between two adjacent cells in your route are not counted as visited, and it is not required to return to the starting point.

The only line of the input contains four integers $$$n$$$, $$$m$$$, $$$S_x$$$ and $$$S_y$$$ ($$$3\le n,m\le 100$$$, $$$2 \le S_x \le n-1$$$, $$$2 \le S_y \le m-1$$$) — the number of rows, the number of columns, and the initial position of your chess piece, respectively.

You should print $$$n\cdot m$$$ lines. The $$$i$$$-th line should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \leq x_i \leq n$$$, $$$1 \leq y_i \leq m$$$), denoting the $$$i$$$-th cell that you visited. You should print exactly $$$nm$$$ pairs $$$(x_i, y_i)$$$, they should cover all possible pairs $$$(x_i, y_i)$$$, such that $$$1 \leq x_i \leq n$$$, $$$1 \leq y_i \leq m$$$. We can show that under these constraints there always exists a solution. If there are multiple answers, print any.

package main

import "fmt"

func main() {
	var n, m, x, y int
	fmt.Scan(&n, &m, &x, &y)

	b := make([][]bool, n+1)

	for i := range b {
		b[i] = make([]bool, m+1)
	}

	var start bool = true

	b[x][y] = true

	fmt.Println(x, y)

	count := 0
	for count < m*n-1 {
		if start == true {
			for i := 1; i <= n; i++ {
				if !b[i][y] {
					fmt.Println(i, y)
					b[i][y] = true
					count++
				}
			}
			start = false
		} else {
			for i := n; i >= 1; i-- {
				if !b[i][y] {
					fmt.Println(i, y)
					b[i][y] = true
					count++
				}
			}
			start = true
		}

		y--
		if y == 0 {
			y = m
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, m, x, y int // x - row, y - col
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &m)
	fmt.Fscan(in, &x)
	fmt.Fscan(in, &y)

	fmt.Println(x, y)
	fmt.Println(1, y)

	direction := true
	for i := 1; i <= n; i++ {
		if direction {
			for j := 1; j <= m; j++ {
				if i == 1 && j == y {
					continue
				}
				if i == x && j == y {
					continue
				}
				fmt.Println(i, j)
			}
			direction = false
		} else if !direction {
			for j := m; j >= 1; j-- {
				if i == 1 && j == y {
					continue
				}
				if i == x && j == y {
					continue
				}
				fmt.Println(i, j)
			}
			direction = true
		}
	}
}

/*
URL:
https://codeforces.com/contest/1395/problem/B
*/

package main

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

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

var (
	n, m   int
	sx, sy int

	visited [][]bool
	ans     [][]int
)

func main() {
	n, m = ReadInt2()
	sy, sx = ReadInt2() // x <==> y
	sy--
	sx--

	visited = [][]bool{}
	for i := 0; i < n; i++ {
		row := make([]bool, m)
		visited = append(visited, row)
	}
	PrintfDebug("n, m, sy, sx: %d, %d, %d, %d\n", n, m, sy, sx)

	ans = [][]int{}

	cy, cx := sy, sx
	add(cy, cx)

	for cx-1 >= 0 {
		cx--
		add(cy, cx)
	}
	for cy-1 >= 0 {
		cy--
		add(cy, cx)
	}

	for cx < m {
		// 下へ
		for cy+1 < n {
			cy++
			if !visited[cy][cx] {
				add(cy, cx)
			}
		}

		// 右へ行けないなら終わり
		if cx+1 >= m {
			break
		}
		cx++
		if !visited[cy][cx] {
			add(cy, cx)
		}

		// 上へ
		for cy-1 >= 0 {
			cy--
			if !visited[cy][cx] {
				add(cy, cx)
			}
		}

		// 右へ行けないなら終わり
		if cx+1 >= m {
			break
		}
		cx++
		if !visited[cy][cx] {
			add(cy, cx)
		}
	}

	if len(ans) != n*m {
		// fmt.Println("aaa")
		panic("aaa")
	}
	for _, p := range ans {
		fmt.Println(p[0], p[1])
	}
}

func add(y, x int) {
	visited[y][x] = true
	ans = append(ans, []int{y + 1, x + 1})
}

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
)

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

/********** bufio setting **********/

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

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

/*********** Input ***********/

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

/*********** Output ***********/

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

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

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

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

// 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
}

package main

import "fmt"

func main() {
	var n, m, x, y int
	fmt.Scan(&n, &m, &x, &y)

	sign := "+"

	b := make([][]bool, n+1)

	for i := range b {
		b[i] = make([]bool, m+1)
	}

	count := 0
	for count < m*n {
		if !b[x][y] {
			fmt.Println(x, y)
			b[x][y] = true
			count++
		}

		if sign == "+" {
			x++
		} else {
			x--
		}

		if x == n+1 {
			y = y + 1
			x = n
			sign = "-"
		} else if x == 0 {
			y = y + 1
			x = 1
			sign = "+"
		}

		if y > m {
			y = 1
		}
	}
}

package main

import "fmt"

func main() {
	var n, m, x, y int
	fmt.Scan(&n, &m, &x, &y)

	sign := "+"
	for i := 0; i < m*n; i++ {
		fmt.Println(x, y)

		if sign == "+" {
			x++
		} else {
			x--
		}

		if x == n+1 {
			y = y + 1
			x = n
			sign = "-"
		} else if x == 0 {
			y = y + 1
			x = 1
			sign = "+"
		}

		if y > m {
			y = 1
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, m, x, y int // x - row, y - col
	fmt.Fscan(in, &n)
	fmt.Fscan(in, &m)
	fmt.Fscan(in, &x)
	fmt.Fscan(in, &y)

	fmt.Println(x, y)
	fmt.Println(1, y)

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			if i == 1 && j == y {
				continue
			}
			if i == x && j == y {
				continue
			}
			fmt.Println(i, j)
		}
	}
}


Let us call two integers $$$x$$$ and $$$y$$$ adjacent if $$$\frac{lcm(x, y)}{gcd(x, y)}$$$ is a perfect square. For example, $$$3$$$ and $$$12$$$ are adjacent, but $$$6$$$ and $$$9$$$ are not.Here $$$gcd(x, y)$$$ denotes the greatest common divisor (GCD) of integers $$$x$$$ and $$$y$$$, and $$$lcm(x, y)$$$ denotes the least common multiple (LCM) of integers $$$x$$$ and $$$y$$$.You are given an array $$$a$$$ of length $$$n$$$. Each second the following happens: each element $$$a_i$$$ of the array is replaced by the product of all elements of the array (including itself), that are adjacent to the current value. Let $$$d_i$$$ be the number of adjacent elements to $$$a_i$$$ (including $$$a_i$$$ itself). The beauty of the array is defined as $$$\max_{1 \le i \le n} d_i$$$. You are given $$$q$$$ queries: each query is described by an integer $$$w$$$, and you have to output the beauty of the array after $$$w$$$ seconds.

The first input line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5)$$$ — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the array. The following line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$1 \le a_i \le 10^6$$$) — array elements.  The next line contain a single integer $$$q$$$ ($$$1 \le q \le 3 \cdot 10^5$$$) — the number of queries. The following $$$q$$$ lines contain a single integer $$$w$$$ each ($$$0 \le w \le 10^{18}$$$) — the queries themselves. It is guaranteed that the sum of values $$$n$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$, and the sum of values $$$q$$$ over all test cases does not exceed $$$3 \cdot 10^5$$$

For each query output a single integer — the beauty of the array at the corresponding moment.

NoteIn the first test case, the initial array contains elements $$$[6, 8, 4, 2]$$$. Element $$$a_4=2$$$ in this array is adjacent to $$$a_4=2$$$ (since $$$\frac{lcm(2, 2)}{gcd(2, 2)}=\frac{2}{2}=1=1^2$$$) and $$$a_2=8$$$ (since $$$\frac{lcm(8,2)}{gcd(8, 2)}=\frac{8}{2}=4=2^2$$$). Hence, $$$d_4=2$$$, and this is the maximal possible value $$$d_i$$$ in this array.In the second test case, the initial array contains elements $$$[12, 3, 20, 5, 80, 1]$$$. The elements adjacent to $$$12$$$ are $$$\{12, 3\}$$$, the elements adjacent to $$$3$$$ are $$$\{12, 3\}$$$, the elements adjacent to $$$20$$$ are $$$\{20, 5, 80\}$$$, the elements adjacent to $$$5$$$ are $$$\{20, 5, 80\}$$$, the elements adjacent to $$$80$$$ are $$$\{20, 5, 80\}$$$, the elements adjacent to $$$1$$$ are $$$\{1\}$$$. After one second, the array is transformed into $$$[36, 36, 8000, 8000, 8000, 1]$$$.

package main

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

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

func sieve() []int {
	res := make([]int, 0)
	np := make([]bool, 1000)

	for i := 2; i < 1000; i++ {
		if !np[i] {
			res = append(res, i)
			for j := i * i; j < 1000; j += i {
				np[j] = true
			}
		}
	}
	// fmt.Println(res)
	return res
}

func main() {
	defer out.Flush()

	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		solve()
	}
}

func solve() {
	var a, n, m int
	var w int64
	s := make(map[int]int)
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a)
		a = foo(a)
		s[a]++
	}
	// fmt.Fprintln(out, s)
	var mx, sum int
	for val, sz := range s {
		if sz > mx {
			mx = sz
		}
		if val == 1 || sz%2 == 0 {
			sum += sz
		}
	}
	if mx > sum {
		sum = mx
	}

	fmt.Fscan(in, &m)
	for i := 0; i < m; i++ {
		fmt.Fscan(in, &w)
		if w == 0 {
			fmt.Fprintln(out, mx)
		} else {
			fmt.Fprintln(out, sum)
		}
	}
}

func foo(a int) int {
	for _, p := range primes {
		if p > a {
			break
		}
		ok := false
		for a%p == 0 {
			ok = !ok
			a /= p
		}
		if ok {
			a = a * p
		}
	}
	// fmt.Println(a)
	return a
}

package main

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

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

	const mx int = 1e6
	lpf := [mx + 1]int{1: 1}
	for i := 2; i <= mx; i++ {
		if lpf[i] == 0 {
			for j := i; j <= mx; j += i {
				if lpf[j] == 0 {
					lpf[j] = i
				}
			}
		}
	}
	core := func(x int) int {
		c := 1
		for x > 1 {
			p := lpf[x]
			e := 1
			for x /= p; lpf[x] == p; x /= p {
				e ^= 1
			}
			if e > 0 {
				c *= p
			}
		}
		return c
	}

	var T, n, v, q int
	var w int64
	for Fscan(in, &T); T > 0; T-- {
		cnt := map[int]int{}
		for Fscan(in, &n); n > 0; n-- {
			Fscan(in, &v)
			cnt[core(v)]++
		}
		maxC, c1 := 0, cnt[1]
		for v, c := range cnt {
			maxC = max(maxC, c)
			if v > 1 && c&1 == 0 {
				c1 += c
			}
		}
		for Fscan(in, &q); q > 0; q-- {
			if Fscan(in, &w); w == 0 {
				Fprintln(out, maxC)
			} else {
				Fprintln(out, max(maxC, c1))
			}
		}
	}
}

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

package main

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

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

	const mx int = 1e6
	lpf := [mx + 1]int{1: 1}
	for i := 2; i <= mx; i++ {
		if lpf[i] == 0 {
			for j := i; j <= mx; j += i {
				if lpf[j] == 0 {
					lpf[j] = i
				}
			}
		}
	}
	core := func(x int) int {
		c := 1
		for x > 1 {
			p := lpf[x]
			e := 1
			for x /= p; lpf[x] == p; x /= p {
				e ^= 1
			}
			if e > 0 {
				c *= p
			}
		}
		return c
	}

	var T, n, v, q int
	var w int64
	for Fscan(in, &T); T > 0; T-- {
		cnt := map[int]int{}
		for Fscan(in, &n); n > 0; n-- {
			Fscan(in, &v)
			cnt[core(v)]++
		}
		mx, c1 := 0, cnt[1]
		for v, c := range cnt {
			if c > mx {
				mx = c
			}
			if v > 1 && c&1 == 0 {
				c1 += c
			}
		}
		if mx > c1 {
			c1 = mx
		}
		for Fscan(in, &q); q > 0; q-- {
			if Fscan(in, &w); w > 0 {
				Fprintln(out, c1)
			} else {
				Fprintln(out, mx)
			}
		}
	}
}

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

package main

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

var primes = make([]int64, 0)

func sieve(n int64) {
	var i int64
	var isPrime = make([]bool, n+1)
	for i = 2; i <= n; i++ {
		isPrime[i] = true
	}
	for i = 2; i*i <= n; i++ {
		if !isPrime[i] {
			continue
		}
		for j := i * i; j <= n; j += i {
			isPrime[j] = false
		}
	}
	for i = 1; i <= n; i++ {
		if isPrime[i] {
			primes = append(primes, i)
		}
	}
}

func compress(x int64) int64 {
	var n, res int64 = x, 1
	for i := 0; i < len(primes) && primes[i]*primes[i] <= n; i++ {
		p := primes[i]
		c := 0
		for x%p == 0 {
			x /= p
			c++
		}
		if c%2 == 1 {
			res *= p
		}
	}
	return res * x
}

func solve(a, w []int64) {
	var max1, max2 int64 = -1e9, -1e9

	beforeFirst := make(map[int64]int64)
	for _, x := range a {
		y := compress(x)
		beforeFirst[y]++
		if max1 < beforeFirst[y] {
			max1 = beforeFirst[y]
		}
	}

	afterFirst := make(map[int64]int64)
	for k, v := range beforeFirst {
		if k == 1 || v%2 == 0 {
			afterFirst[1] += v
			if max2 < afterFirst[1] {
				max2 = afterFirst[1]
			}
		} else {
			afterFirst[k] += v
			if max2 < afterFirst[k] {
				max2 = afterFirst[k]
			}
		}
	}

	for _, q := range w {
		v := max1
		if q > 0 {
			v = max2
		}
		printf("%d\n", v)
	}
}

func main() {
	//RedirectInputToFile(reader, "input.txt")

	sieve(1e6)
	t := 1
	scan(&t)

	for T := 0; T < t; T++ {
		var (
			n, q int64
			a, w []int64
		)

		scan(&n)
		a = make([]int64, n)
		for i := range a {
			scan(&a[i])
		}

		scan(&q)
		w = make([]int64, q)
		for i := range w {
			scan(&w[i])
		}

		solve(a, w)
	}

	writer.Flush()
}

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

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

func RedirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	const N int = 1e6
	lpf := [N + 1]int{1: 1}//定义长度为1e6 + 1的数组, lpf[1]设为1
	//lpf为最大质因数的缩写
	for i := 2; i <= N; i++ {
		if lpf[i] == 0 {
			for j := i; j <= N; j += i {
				if lpf[j] == 0 {
					lpf[j] = i
				}
			}
		}
	}
	core := func(x int) int {
		c := 1
		for x > 1 {
			p := lpf[x]
			e := 1
			for x /= p; lpf[x] == p; x /= p {
				e ^= 1
			}
			if e == 1 {
				c *= p
			}
		}
		return c
	}
	var t, n, q int
	var w int64
	for Fscan(in, &t); t > 0; t-- {
		cnt := map[int]int{}
		for Fscan(in, &n); n > 0; n-- {
			var la int
			Fscan(in, &la)
			cnt[core(la)] ++
		}
		max_0, max_1 := 0, cnt[1]
		for v, c := range cnt {
			max_0 = max(max_0, c)
			if v > 1 && c & 1 == 0 {
				max_1 += c
			}
		}
		for Fscan(in, &q); q > 0 ; q-- {
			if Fscan(in, &w); w == 0 {
				Fprintln(out, max_0)
			} else {
				Fprintln(out, max(max_0, max_1))
			}
		}
	}
}

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

package main

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

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

func sieve() []int {
	res := make([]int, 0)
	np := make([]bool, 1000)

	for i := 2; i < 1000; i++ {
		if !np[i] {
			res = append(res, i)
			for j := i * i; j < 1000; j += i {
				np[j] = true
			}
		}
	}
	// fmt.Println(res)
	return res
}

func main() {
	defer out.Flush()

	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		solve()
	}
}

func solve() {
	var a, n, m int
	s := make(map[int]int)
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a)
		a = foo(a)
		s[a]++
	}
	// fmt.Fprintln(out, s)
	var mx, sum int
	sum = s[1]
	for val, sz := range s {
		if sz > mx {
			mx = sz
		}
		if val > 1 && sz%2 == 0 {
			sum += sz
		}
	}
	if mx > sum {
		sum = mx
	}

	fmt.Fscan(in, &m)
	for i := 0; i < m; i++ {
		fmt.Fscan(in, &a)
		if a == 0 {
			fmt.Fprintln(out, mx)
		} else {
			fmt.Fprintln(out, sum)
		}
	}
}

func foo(a int) int {
	for _, p := range primes {
		if p > a {
			break
		}
		ok := false
		for a%p == 0 {
			ok = !ok
			a /= p
		}
		if ok {
			a = a * p
		}
	}
	// fmt.Println(a)
	return a
}

package main

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

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

func sieve() []int {
	res := make([]int, 0)
	np := make([]bool, 1000)

	for i := 2; i < 1000; i++ {
		if !np[i] {
			res = append(res, i)
			for j := i * i; j < 1000; j += i {
				np[j] = true
			}
		}
	}
	// fmt.Println(res)
	return res
}

func main() {
	defer out.Flush()

	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		solve()
	}
}

func solve() {
	var a, n, m int
	s := make(map[int]int)
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a)
		a = foo(a)
		s[a]++
	}
	// fmt.Fprintln(out, s)
	var mx, sum int
	for val, sz := range s {
		if sz > mx {
			mx = sz
		}
		if val > 1 && sz%2 == 0 {
			sum += sz
		}
	}
	if mx > sum {
		sum = mx
	}

	fmt.Fscan(in, &m)
	for i := 0; i < m; i++ {
		fmt.Fscan(in, &a)
		if a == 0 {
			fmt.Fprintln(out, mx)
		} else {
			fmt.Fprintln(out, sum)
		}
	}
}

func foo(a int) int {
	for _, p := range primes {
		if p > a {
			break
		}
		ok := false
		for a%p == 0 {
			ok = !ok
			a /= p
		}
		if ok {
			a = a * p
		}
	}
	// fmt.Println(a)
	return a
}

package main

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

var (
	in     = bufio.NewReader(os.Stdin)
	out    = bufio.NewWriter(os.Stdout)
	primes = sieve()
	pp     = make([]int, 1000001)
)

func bar(x, y int) int {
	res := 0
	for x%y == 0 {
		res++
		x /= y
	}
	return res
}

func sieve() []int {
	res := make([]int, 0)
	np := make([]bool, 1000001)

	for i := 1; i <= 1000000; i++ {
		pp[i] = 1
	}

	for i := 2; i <= 1000000; i++ {
		if !np[i] {
			res = append(res, i)
			for j := i; j <= 1000000; j += i {
				np[j] = true
				if bar(j, i)%2 == 1 {
					pp[j] *= i
				}
			}
		}
	}
	// fmt.Println(res, len(res))
	return res
}

func main() {
	defer out.Flush()

	// return

	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		solve()
	}
}

func solve() {
	var a, n, m int
	s := make(map[int]int)
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a)
		a = pp[a]
		s[a]++
	}
	var mx, sum int
	for val, sz := range s {
		if sz > mx {
			mx = sz
		}
		if val == 1 || sz%2 == 0 {
			sum += sz
		}
	}
	if mx > sum {
		sum = mx
	}

	fmt.Fscan(in, &m)
	for i := 0; i < m; i++ {
		fmt.Fscan(in, &a)
		if a == 0 {
			fmt.Fprintln(out, mx)
		} else {
			fmt.Fprintln(out, sum)
		}
	}
}

func foo(a int) int {
	for _, p := range primes {
		if p > a {
			break
		}
		ok := false
		for a%p == 0 {
			ok = !ok
			a /= p
		}
		if ok {
			a = a * p
		}
	}
	// fmt.Println(a)
	return a
}

package main

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

var (
	in     = bufio.NewReader(os.Stdin)
	out    = bufio.NewWriter(os.Stdout)
	primes = sieve()
	pp     = make([]int, 1000001)
)

func bar(x, y int) int {
	res := 0
	for x%y == 0 {
		res++
		x /= y
	}
	return res
}

func sieve() []int {
	res := make([]int, 0)
	np := make([]bool, 1000000)

	for i := 1; i <= 1000000; i++ {
		pp[i] = 1
	}

	for i := 2; i < 1000000; i++ {
		if !np[i] {
			res = append(res, i)
			for j := i; j < 1000000; j += i {
				np[j] = true
				if bar(j, i)%2 == 1 {
					pp[j] *= i
				}
			}
		}
	}
	// fmt.Println(res, len(res))
	return res
}

func main() {
	defer out.Flush()

	// return

	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		solve()
	}
}

func solve() {
	var a, n, m int
	s := make(map[int]int)
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a)
		a = pp[a]
		s[a]++
	}
	var mx, sum int
	for val, sz := range s {
		if sz > mx {
			mx = sz
		}
		if val == 1 || sz%2 == 0 {
			sum += sz
		}
	}
	if mx > sum {
		sum = mx
	}

	fmt.Fscan(in, &m)
	for i := 0; i < m; i++ {
		fmt.Fscan(in, &a)
		if a == 0 {
			fmt.Fprintln(out, mx)
		} else {
			fmt.Fprintln(out, sum)
		}
	}
}

func foo(a int) int {
	for _, p := range primes {
		if p > a {
			break
		}
		ok := false
		for a%p == 0 {
			ok = !ok
			a /= p
		}
		if ok {
			a = a * p
		}
	}
	// fmt.Println(a)
	return a
}

package main

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

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

func sieve() []int {
	res := make([]int, 0)
	np := make([]bool, 1000)

	for i := 2; i < 1000; i++ {
		if !np[i] {
			res = append(res, i)
			for j := i * i; j < 1000; j += i {
				np[j] = true
			}
		}
	}
	return res
}

func main() {
	defer out.Flush()

	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		solve()
	}
}

func solve() {
	var a, n, m int
	s := make(map[int]int)
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &a)
		a = foo(a)
		s[a]++
	}
	var mx, sum int
	for val, sz := range s {
		if sz > mx {
			mx = sz
		}
		if val == 1 || sz%2 == 0 {
			sum += sz
		}
	}
	if mx > sum {
		sum = mx
	}

	fmt.Fscan(in, &m)
	for i := 0; i < m; i++ {
		fmt.Fscan(in, &a)
		if a == 0 {
			fmt.Fprintln(out, mx)
		} else {
			fmt.Fprintln(out, sum)
		}
	}
}

func foo(a int) int {
	for _, p := range primes {
		if p > a {
			break
		}
		ok := false
		for a%p == 0 {
			ok = !ok
			a /= p
		}
		if ok {
			a = a * p
		}
	}
	return a
}

package main

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

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

	const mx int = 1e6
	lpf := [mx + 1]int{1: 1}
	for i := 2; i <= mx; i++ {
		if lpf[i] == 0 {
			for j := i; j <= mx; j += i {
				if lpf[j] == 0 {
					lpf[j] = i
				}
			}
		}
	}
	core := func(x int) int {
		c := 1
		for x > 1 {
			p := lpf[x]
			e := 1
			for x /= p; lpf[x] == p; x /= p {
				e ^= 1
			}
			if e > 0 {
				c *= p
			}
		}
		return c
	}

	var T, n, v, q int
	var w int64
	for Fscan(in, &T); T > 0; T-- {
		cnt := map[int]int{}
		for Fscan(in, &n); n > 0; n-- {
			Fscan(in, &v)
			cnt[core(v)]++
		}
		mx, c1 := 0, cnt[1]
		for _, c := range cnt {
			if c > mx {
				mx = c
			}
			if c&1 == 0 {
				c1 += c
			}
		}
		if mx > c1 {
			c1 = mx
		}
		for Fscan(in, &q); q > 0; q-- {
			if Fscan(in, &w); w > 0 {
				Fprintln(out, c1)
			} else {
				Fprintln(out, mx)
			}
		}
	}
}

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

package main

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

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

	const mx int = 1e6
	lpf := [mx + 1]int{1: 1}
	for i := 2; i <= mx; i++ {
		if lpf[i] == 0 {
			for j := i; j <= mx; j += i {
				if lpf[j] == 0 {
					lpf[j] = i
				}
			}
		}
	}
	core := func(x int) int {
		c := 1
		for x > 1 {
			p := lpf[x]
			e := 1
			for x /= p; lpf[x] == p; x /= p {
				e ^= 1
			}
			if e > 0 {
				c *= p
			}
		}
		return c
	}

	var T, n, v, q int
	var w int64
	for Fscan(in, &T); T > 0; T-- {
		cnt := map[int]int{}
		for Fscan(in, &n); n > 0; n-- {
			Fscan(in, &v)
			cnt[core(v)]++
		}
		mx, c1 := 0, cnt[1]
		for _, c := range cnt {
			if c > mx {
				mx = c
			}
			if c&1 == 0 {
				c1 += c
			}
		}
		for Fscan(in, &q); q > 0; q-- {
			if Fscan(in, &w); w > 0 {
				Fprintln(out, c1)
			} else {
				Fprintln(out, mx)
			}
		}
	}
}

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

package main

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

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

	const mx int = 1e6
	lpf := [mx + 1]int{1: 1}
	for i := 2; i <= mx; i++ {
		if lpf[i] == 0 {
			for j := i; j <= mx; j += i {
				if lpf[j] == 0 {
					lpf[j] = i
				}
			}
		}
	}
	core := func(x int) int {
		c := 1
		for x > 1 {
			p := lpf[x]
			e := 1
			for x /= p; lpf[x] == p; x /= p {
				e ^= 1
			}
			if e > 0 {
				c *= p
			}
		}
		return c
	}

	var T, n, v, q int
	var w int64
	for Fscan(in, &T); T > 0; T-- {
		c1 := 0
		cnt := map[int]int{}
		for Fscan(in, &n); n > 0; n-- {
			Fscan(in, &v)
			if v == 1 {
				c1++
			} else {
				cnt[core(v)]++
			}
		}
		mx := c1
		for _, c := range cnt {
			if c > mx {
				mx = c
			}
			if c&1 == 0 {
				c1 += c
			}
		}
		for Fscan(in, &q); q > 0; q-- {
			Fscan(in, &w)
			if w > 0 {
				Fprintln(out, c1)
			} else {
				Fprintln(out, mx)
			}
		}
	}
}

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

package main

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

var primes = make([]int64, 0)

func sieve(n int64) {
	var i int64
	var isPrime = make([]bool, n+1)
	for i = 2; i <= n; i++ {
		isPrime[i] = true
	}
	for i = 2; i*i <= n; i++ {
		if !isPrime[i] {
			continue
		}
		for j := i * i; j <= n; j += i {
			isPrime[j] = false
		}
	}
	for i = 1; i <= n; i++ {
		if isPrime[i] {
			primes = append(primes, i)
		}
	}
}

func compress(x int64) int64 {
	var res int64 = 1
	for i := 0; i < len(primes) && x > 1; i++ {
		p := primes[i]
		c := 0
		for x%p == 0 {
			x /= p
			c++
		}
		if c%2 == 1 {
			res *= p
		}
	}
	return res
}

func solve(a, w []int64) {
	var max1, max2 int64 = -1e9, -1e9

	beforeFirst := make(map[int64]int64)
	for _, x := range a {
		y := compress(x)
		beforeFirst[y]++
		if max1 < beforeFirst[y] {
			max1 = beforeFirst[y]
		}
	}

	afterFirst := make(map[int64]int64)
	for k, v := range beforeFirst {
		if k == 1 || v%2 == 0 {
			afterFirst[1] += v
			if max2 < afterFirst[1] {
				max2 = afterFirst[1]
			}
		} else {
			afterFirst[k] += v
			if max2 < afterFirst[k] {
				max2 = afterFirst[k]
			}
		}
	}

	for q := range w {
		v := max1
		if q > 0 {
			v = max2
		}
		printf("%d\n", v)
	}
}

func main() {
	//RedirectInputToFile(reader, "input.txt")

	sieve(1e6)
	t := 1
	scan(&t)

	for T := 0; T < t; T++ {
		var (
			n, q int64
			a, w []int64
		)

		scan(&n)
		a = make([]int64, n)
		for i := range a {
			scan(&a[i])
		}

		scan(&q)
		w = make([]int64, q)
		for i := range w {
			scan(&w[i])
		}

		solve(a, w)
	}

	writer.Flush()
}

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

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

func RedirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

package main

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

var primes = make([]int64, 0)

func sieve(n int64) {
	var i int64
	var isPrime = make([]bool, n+1)
	for i = 2; i <= n; i++ {
		isPrime[i] = true
	}
	for i = 2; i*i <= n; i++ {
		if !isPrime[i] {
			continue
		}
		for j := i * i; j <= n; j += i {
			isPrime[j] = false
		}
	}
	for i = 1; i <= n; i++ {
		if isPrime[i] {
			primes = append(primes, i)
		}
	}
}

func compress(x int64) int64 {
	var res int64 = 1
	for i := 0; i < len(primes) && x > 1; i++ {
		p := primes[i]
		c := 0
		for x%p == 0 {
			x /= p
			c++
		}
		if c%2 == 1 {
			res *= p
		}
	}
	return res
}

func solve(a []int64, q, w int64) {
	var max1, max2 int64 = -1e9, -1e9

	beforeFirst := make(map[int64]int64)
	for _, x := range a {
		y := compress(x)
		beforeFirst[y]++
		if max1 < beforeFirst[y] {
			max1 = beforeFirst[y]
		}
	}

	afterFirst := make(map[int64]int64)
	for k, v := range beforeFirst {
		if k == 1 || v%2 == 0 {
			afterFirst[1] += v
			if max2 < afterFirst[1] {
				max2 = afterFirst[1]
			}
		} else {
			afterFirst[k] += v
			if max2 < afterFirst[k] {
				max2 = afterFirst[k]
			}
		}
	}

	for i := int64(0); i < q; i++ {
		v := max1
		if w > 0 {
			v = max2
		}
		printf("%d\n", v)
	}
}

func main() {
	//RedirectInputToFile(reader, "input.txt")

	sieve(1e6)
	t := 1
	scan(&t)

	for T := 0; T < t; T++ {
		var (
			n, q, w int64
			a       []int64
		)
		scan(&n)
		a = make([]int64, n)
		for i := range a {
			scan(&a[i])
		}
		scan(&q, &w)
		solve(a, q, w)
	}

	writer.Flush()
}

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

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

func RedirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}


There is a chip on the coordinate line. Initially, the chip is located at the point $$$0$$$. You can perform any number of moves; each move increases the coordinate of the chip by some positive integer (which is called the length of the move). The length of the first move you make should be divisible by $$$k$$$, the length of the second move — by $$$k+1$$$, the third — by $$$k+2$$$, and so on.For example, if $$$k=2$$$, then the sequence of moves may look like this: $$$0 \rightarrow 4 \rightarrow 7 \rightarrow 19 \rightarrow 44$$$, because $$$4 - 0 = 4$$$ is divisible by $$$2 = k$$$, $$$7 - 4 = 3$$$ is divisible by $$$3 = k + 1$$$, $$$19 - 7 = 12$$$ is divisible by $$$4 = k + 2$$$, $$$44 - 19 = 25$$$ is divisible by $$$5 = k + 3$$$.You are given two positive integers $$$n$$$ and $$$k$$$. Your task is to count the number of ways to reach the point $$$x$$$, starting from $$$0$$$, for every $$$x \in [1, n]$$$. The number of ways can be very large, so print it modulo $$$998244353$$$. Two ways are considered different if they differ as sets of visited positions.

The first (and only) line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$).

Print $$$n$$$ integers — the number of ways to reach the point $$$x$$$, starting from $$$0$$$, for every $$$x \in [1, n]$$$, taken modulo $$$998244353$$$.

package main

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

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

func main() {
	defer ww.Flush()
	var n, k int
	fmt.Fscan(rr, &n, &k)
	const mod = 998244353
	dp0, dp1 := make([]int, n+1), make([]int, n+1)
	dp0[k] = 1
	ans := make([]int, n)
	for j:=0;j<=640;j++ {
		for i:=1;i<=n;i++ {
			if i+j+k <= n {
				dp0[i+j+k] += dp0[i]
				dp0[i+j+k] %= mod
			}
			if i+j+k+1 <= n {
				dp1[i+j+k+1] += dp0[i]
				dp1[i+j+k+1] %= mod
			}
			ans[i-1] += dp0[i]
			ans[i-1] %= mod
		}
		dp0 = dp1
		dp1 = make([]int, n+1)
	}
	for i:=0;i<len(ans);i++ {
		fmt.Fprintf(ww, "%d ", ans[i])
	}
	fmt.Fprintln(ww)
}

package main

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

func CF1716D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	Fscan(in, &n, &k)
	res := make([]int, n+1)
	dp := make([]int, n+1)
	dp1 := make([]int, n+1)
	dp[0] = 1
	st := 0
	for st+k <= n {
		for i := 0; i < k; i++ {
			idx := st + i
			cur := dp[idx]
			idx += k
			for idx <= n {
				dp1[idx] = cur
				res[idx] = (res[idx] + cur) % 998244353
				cur = (dp[idx] + cur) % 998244353
				idx += k
			}
		}
		dp, dp1 = dp1, dp
		st += k
		k += 1
	}
	for idx, i := range res[1:] {
		Fprint(out, i)
		if idx < len(res)-1 {
			Fprint(out, " ")
		}
	}

}

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

package main

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

func CF1716D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	Fscan(in, &n, &k)
	res := make([]int, n+1)
	dp := make([]int, n+1)
	dp[0] = 1
	st := 0
	for st+k <= n {
		dp1 := make([]int, n+1)
		for i := 0; i < k; i++ {
			idx := st + i
			cur := dp[idx]
			idx += k
			for idx <= n {
				dp1[idx] = cur
				res[idx] = (res[idx] + cur) % 998244353
				cur = (dp[idx] + cur) % 998244353
				idx += k
			}
		}
		dp = dp1
		st += k
		k += 1
	}
	for idx, i := range res[1:] {
		Fprint(out, i)
		if idx < len(res)-1 {
			Fprint(out, " ")
		}
	}

}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1716D(in io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	const mod = 998244353

	var n, k int
	Fscan(in, &n, &k)
	ans := make([]int, n+1)
	f := make([]int, n+1)
	f[0] = 1
	for i, s := k, 0; s+i <= n; i++ {
		s += i
		g := make([]int, n+1)
		for j := i; j <= n; j++ {
			g[j] = (g[j-i] + f[j-i]) % mod
			ans[j] = (ans[j] + g[j]) % mod
		}
		f = g
	}
	for _, v := range ans[1:] {
		Fprint(out, v, " ")
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1716D(in io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	const mod = 998244353

	var n, k int
	Fscan(in, &n, &k)
	ans := make([]int, n+1)
	f := make([]int, n+1)
	f[0] = 1
	for i, s := k, 0; s+i <= n; i++ {
		s += i
		g := make([]int, n+1)
		for j := i; j <= n; j++ {
			g[j] = (g[j-i] + f[j-i]) % mod
		}
		for j, v := range g {
			ans[j] = (ans[j] + v) % mod
		}
		f = g
	}
	for _, v := range ans[1:] {
		Fprint(out, v, " ")
	}
}

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

package main

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

func CF1716D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var n, k int
	Fscan(in, &n, &k)
	res := make([]int, n+1)
	dp := make([]int, n+1)
	dp1 := make([]int, n+1)
	dp[0] = 1
	st := 0
	for st+k <= n {
		for i := 0; i < k; i++ {
			idx := st + i
			cur := dp[idx]
			idx += k
			for idx <= n {
				dp1[idx] = cur
				res[idx] = (res[idx] + cur) % 998244353
				cur = (dp[idx] + cur) % 998244353
				idx += k
			}
		}
		dp, dp1 = dp1, dp
		st += k
		k += 1
	}
	for idx, i := range res[1:] {
		Fprint(out, i)
		if idx < len(res)-1 {
			Fprint(out, " ")
		}
	}

}

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

package main

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

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

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

func rw(r io.Reader, w io.Writer) {
	var t int = 1
	// fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n, k int
		fmt.Fscan(r, &n, &k)
		w1 := do(n, k)
		for _, v := range w1 {
			fmt.Fprint(w, v, " ")
		}
		// fmt.Fprintln(w)
	}
}

const mod = 998244353

func do(n, k int) []int {
	r := make([]int, n+1)
	d := make([]int, n+1)
	d[0] = 1
	for x := k; x <= n; x += k {
		s := make([]int, k)
		for i := 0; i <= n; i++ {
			d[i], s[i%k] = s[i%k], (s[i%k]+d[i])%mod
			r[i] = (r[i] + d[i]) % mod
		}
		k++
	}
	return r[1:]
}

package main

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

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

func main() {
	defer ww.Flush()
	var n, k int
	fmt.Fscan(rr, &n, &k)
	dp := make([][]int, n+1)
	const mod = 998244353
	for i := range dp {
		dp[i] = make([]int, 200)
	}
	for i:=k;i<n+1;i+=k {
		dp[i][0] = 1
	}
	ans := make([]int, n)
	for i:=1;i<=n;i++ {
		ans[i-1] += dp[i][0]
		for j:=1;j<200&&j<=i-k;j++ {
			dp[i][j] = dp[i-j-k][j] + dp[i-j-k][j-1]
			dp[i][j] %= mod
			ans[i-1] += dp[i][j]
			ans[i-1] %= mod
		}
	}
	for i:=0;i<len(ans);i++ {
		fmt.Fprintf(ww, "%d ", ans[i])
	}
	fmt.Fprintln(ww)
}

package main

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

func CF1716D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, k int
	Fscan(in, &n, &k)
	res := make([]int64, n+1)
	dp := make([]int64, n+1)
	dp[0] = int64(1)
	st := 0
	for st+k <= n {
		dp1 := make([]int64, n+1)
		for i := 0; i < k; i++ {
			idx := st + i
			cur := dp[idx]
			idx += k
			for idx <= n {
				dp1[idx] = cur
				res[idx] = (res[idx] + cur) % 998244353
				cur += dp[idx]
				idx += k
			}
		}
		dp = dp1
		st += k
		k += 1
	}
	for idx, i := range res[1:] {
		Fprint(out, i)
		if idx < len(res)-1 {
			Fprint(out, " ")
		}
	}

}

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

package main

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

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

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

func rw(r io.Reader, w io.Writer) {
	var t int = 1
	// fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var n, k int
		fmt.Fscan(r, &n, &k)
		w1 := do(n, k)
		for _, v := range w1 {
			fmt.Fprint(w, v, " ")
		}
		// fmt.Fprintln(w)
	}
}

func do(n, k int) []int {
	r := make([]int, n+1)
	d := make([]int, n+1)
	d[0] = 1
	for x := k; x <= n; x += k {
		s := make([]int, k)
		for i := 0; i <= n; i++ {
			d[i], s[i%k] = s[i%k], s[i%k]+d[i]
			r[i] += d[i]
		}
		k++
	}
	return r[1:]
}